From 17b90abcdc12b2e8e7fe745d2faa396cfebe843a Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Wed, 22 Jan 2020 19:29:10 +0000 Subject: [PATCH 001/118] all numerics allocated one-per-thread --- Common/include/option_structure.hpp | 74 +-- SU2_CFD/include/numerics_structure.hpp | 4 +- SU2_CFD/src/drivers/CDriver.cpp | 629 +++++++++++++--------- SU2_CFD/src/numerics_direct_turbulent.cpp | 5 +- 4 files changed, 408 insertions(+), 304 deletions(-) diff --git a/Common/include/option_structure.hpp b/Common/include/option_structure.hpp index 5e2c826dee82..16f79f65fc7d 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -386,7 +386,7 @@ enum ENUM_REGIME { * \brief different non-dimensional modes */ enum ENUM_KIND_NONDIM { - DIMENSIONAL = 0, /*!< \brief Dimensional simulation (compressible or incompressible). */ + DIMENSIONAL = 0, /*!< \brief Dimensional simulation (compressible or incompressible). */ FREESTREAM_PRESS_EQ_ONE = 1, /*!< \brief Non-dimensional compressible simulation with freestream pressure equal to 1.0. */ FREESTREAM_VEL_EQ_MACH = 2, /*!< \brief Non-dimensional compressible simulation with freestream velocity equal to Mach number. */ FREESTREAM_VEL_EQ_ONE = 3, /*!< \brief Non-dimensional compressible simulation with freestream pressure equal to 1.0. */ @@ -416,43 +416,43 @@ static const map Measurements_Map = CCreateMap Math_Problem_Map = CCreateMap ("DIRECT", DIRECT) diff --git a/SU2_CFD/include/numerics_structure.hpp b/SU2_CFD/include/numerics_structure.hpp index 68e61cf9b009..135cb3bd4e88 100644 --- a/SU2_CFD/include/numerics_structure.hpp +++ b/SU2_CFD/include/numerics_structure.hpp @@ -3827,7 +3827,7 @@ class CAvgGrad_TurbSST : public CAvgGrad_Scalar { * \param[in] config - Definition of the particular problem. */ CAvgGrad_TurbSST(unsigned short val_nDim, unsigned short val_nVar, - su2double* constants, bool correct_grad, CConfig *config); + const su2double* constants, bool correct_grad, CConfig *config); /*! * \brief Destructor of the class. @@ -4717,7 +4717,7 @@ class CSourcePieceWise_TurbSST : public CNumerics { * \param[in] val_nVar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CSourcePieceWise_TurbSST(unsigned short val_nDim, unsigned short val_nVar, su2double* constants, + CSourcePieceWise_TurbSST(unsigned short val_nDim, unsigned short val_nVar, const su2double* constants, su2double val_kine_Inf, su2double val_omega_Inf, CConfig *config); /*! diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index 6f6be2d608a0..55cddfb326ec 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -1889,41 +1889,89 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol numerics = new CNumerics***[config->GetnMGLevels()+1]; - su2double *constants = NULL; + const su2double *constants = nullptr; su2double kine_Inf = 0.0, omega_Inf = 0.0; bool compressible = false; bool incompressible = false; - bool ideal_gas = (config->GetKind_FluidModel() == STANDARD_AIR || config->GetKind_FluidModel() == IDEAL_GAS ); - bool roe_low_dissipation = config->GetKind_RoeLowDiss() != NO_ROELOWDISS; + bool ideal_gas = (config->GetKind_FluidModel() == STANDARD_AIR) || (config->GetKind_FluidModel() == IDEAL_GAS); + bool roe_low_dissipation = (config->GetKind_RoeLowDiss() != NO_ROELOWDISS); /*--- Initialize some useful booleans ---*/ - bool euler, ns, turbulent, adj_euler, adj_ns, adj_turb, fem, fem_euler, fem_ns, fem_turbulent; + bool euler, ns, turbulent, adj_euler, adj_ns, adj_turb, fem_euler, fem_ns, fem_turbulent; bool spalart_allmaras, neg_spalart_allmaras, e_spalart_allmaras, comp_spalart_allmaras, e_comp_spalart_allmaras, menter_sst; - bool heat_fvm, transition, template_solver; + bool fem, heat_fvm, transition, template_solver; - euler = ns = turbulent = adj_euler = adj_ns = adj_turb = fem = fem_euler = fem_ns = fem_turbulent = false; + euler = ns = turbulent = adj_euler = adj_ns = adj_turb = fem_euler = fem_ns = fem_turbulent = false; spalart_allmaras = neg_spalart_allmaras = e_spalart_allmaras = comp_spalart_allmaras = e_comp_spalart_allmaras = menter_sst = false; - heat_fvm = transition = template_solver = false; + fem = heat_fvm = transition = template_solver = false; /*--- Assign booleans ---*/ switch (config->GetKind_Solver()) { - case TEMPLATE_SOLVER: template_solver = true; break; - case EULER : case DISC_ADJ_EULER: compressible = true; euler = true; break; - case NAVIER_STOKES: case DISC_ADJ_NAVIER_STOKES:compressible = true; ns = true; break; - case RANS : case DISC_ADJ_RANS: ns = true; compressible = true; turbulent = true; if (config->GetKind_Trans_Model() == LM) transition = true; break; - case INC_EULER : case DISC_ADJ_INC_EULER: incompressible =true; euler = true; break; - case INC_NAVIER_STOKES: case DISC_ADJ_INC_NAVIER_STOKES:incompressible =true; ns = true; heat_fvm = config->GetWeakly_Coupled_Heat(); break; - case INC_RANS : case DISC_ADJ_INC_RANS: incompressible =true; ns = true; turbulent = true; heat_fvm = config->GetWeakly_Coupled_Heat(); if (config->GetKind_Trans_Model() == LM) transition = true; break; - case FEM_EULER : case DISC_ADJ_FEM_EULER : compressible =true; fem_euler = true; break; - 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: 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; - case ADJ_RANS : compressible =true; ns = true; turbulent = true; adj_ns = true; adj_turb = (!config->GetFrozen_Visc_Cont()); break; + case TEMPLATE_SOLVER: + template_solver = true; break; + + case EULER : + case DISC_ADJ_EULER: + euler = compressible = true; break; + + case NAVIER_STOKES: + case DISC_ADJ_NAVIER_STOKES: + ns = compressible = true; break; + + case RANS: + case DISC_ADJ_RANS: + ns = compressible = turbulent = true; + transition = (config->GetKind_Trans_Model() == LM); break; + + case INC_EULER: + case DISC_ADJ_INC_EULER: + euler = incompressible = true; break; + + case INC_NAVIER_STOKES: + case DISC_ADJ_INC_NAVIER_STOKES: + ns = incompressible = true; + heat_fvm = config->GetWeakly_Coupled_Heat(); break; + + case INC_RANS: + case DISC_ADJ_INC_RANS: + ns = incompressible = turbulent = true; + heat_fvm = config->GetWeakly_Coupled_Heat(); + transition = (config->GetKind_Trans_Model() == LM); break; + + case FEM_EULER: + case DISC_ADJ_FEM_EULER: + fem_euler = compressible = true; break; + + case FEM_NAVIER_STOKES: + case DISC_ADJ_FEM_NS: + fem_ns = compressible = true; break; + + case FEM_RANS: + case DISC_ADJ_FEM_RANS: + fem_ns = compressible = fem_turbulent = true; break; + + case FEM_LES: + fem_ns = compressible = 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: + adj_euler = euler = compressible = true; break; + + case ADJ_NAVIER_STOKES: + adj_ns = ns = compressible = true; + turbulent = (config->GetKind_Turb_Model() != NONE); break; + + case ADJ_RANS: + adj_ns = ns = compressible = turbulent = true; + adj_turb = !config->GetFrozen_Visc_Cont(); break; } /*--- Assign turbulence model booleans ---*/ @@ -1937,7 +1985,9 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol case SA_E_COMP: e_comp_spalart_allmaras = true; break; case SST: menter_sst = true; break; case SST_SUST: menter_sst = true; break; - default: SU2_MPI::Error("Specified turbulence model unavailable or none selected", CURRENT_FUNCTION); break; + default: + SU2_MPI::Error("Specified turbulence model unavailable or none selected", CURRENT_FUNCTION); + break; } /*--- If the Menter SST model is used, store the constants of the model and determine the @@ -1960,8 +2010,8 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol if (turbulent) nVar_Turb = solver[MESH_0][TURB_SOL]->GetnVar(); if (transition) nVar_Trans = solver[MESH_0][TRANS_SOL]->GetnVar(); - if (fem_euler) nVar_Flow = solver[MESH_0][FLOW_SOL]->GetnVar(); - if (fem_ns) nVar_Flow = solver[MESH_0][FLOW_SOL]->GetnVar(); + if (fem_euler) nVar_Flow = solver[MESH_0][FLOW_SOL]->GetnVar(); + if (fem_ns) nVar_Flow = solver[MESH_0][FLOW_SOL]->GetnVar(); //if (fem_turbulent) nVar_Turb = solver_container[MESH_0][FEM_TURB_SOL]->GetnVar(); if (fem) nVar_FEM = solver[MESH_0][FEA_SOL]->GetnVar(); @@ -1969,9 +2019,9 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol /*--- Number of variables for adjoint problem ---*/ - if (adj_euler) nVar_Adj_Flow = solver[MESH_0][ADJFLOW_SOL]->GetnVar(); - if (adj_ns) nVar_Adj_Flow = solver[MESH_0][ADJFLOW_SOL]->GetnVar(); - if (adj_turb) nVar_Adj_Turb = solver[MESH_0][ADJTURB_SOL]->GetnVar(); + if (adj_euler) nVar_Adj_Flow = solver[MESH_0][ADJFLOW_SOL]->GetnVar(); + if (adj_ns) nVar_Adj_Flow = solver[MESH_0][ADJFLOW_SOL]->GetnVar(); + if (adj_turb) nVar_Adj_Turb = solver[MESH_0][ADJTURB_SOL]->GetnVar(); /*--- Definition of the Class for the numerical method: numerics_container[INSTANCE_LEVEL][MESH_LEVEL][EQUATION][EQ_TERM] ---*/ @@ -1981,6 +2031,24 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol numerics[iMGlevel][iSol] = new CNumerics* [MAX_TERMS*omp_get_max_threads()](); } + /*--- Instantiate one numerics object per thread for each required term. ---*/ + + SU2_OMP_PARALLEL + { + const int thread = omp_get_thread_num(); + const int offset = thread * MAX_TERMS; + + const int conv_term = CONV_TERM + offset; + const int visc_term = VISC_TERM + offset; + + const int source_first_term = SOURCE_FIRST_TERM + offset; + const int source_second_term = SOURCE_SECOND_TERM + offset; + + const int conv_bound_term = CONV_BOUND_TERM + offset; + const int visc_bound_term = VISC_BOUND_TERM + offset; + + const int fea_term = FEA_TERM + offset; + /*--- Solver definition for the template problem ---*/ if (template_solver) { @@ -1988,22 +2056,25 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol switch (config->GetKind_ConvNumScheme_Template()) { case SPACE_CENTERED : case SPACE_UPWIND : for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) - numerics[iMGlevel][TEMPLATE_SOL][CONV_TERM] = new CConvective_Template(nDim, nVar_Template, config); + numerics[iMGlevel][TEMPLATE_SOL][conv_term] = new CConvective_Template(nDim, nVar_Template, config); + break; + default: + SU2_OMP_MASTER + SU2_MPI::Error("Convective scheme not implemented (template_solver).", CURRENT_FUNCTION); break; - default : SU2_MPI::Error("Convective scheme not implemented (template_solver).", CURRENT_FUNCTION); break; } /*--- Definition of the viscous scheme for each equation and mesh level ---*/ for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) - numerics[iMGlevel][TEMPLATE_SOL][VISC_TERM] = new CViscous_Template(nDim, nVar_Template, config); + numerics[iMGlevel][TEMPLATE_SOL][visc_term] = new CViscous_Template(nDim, nVar_Template, config); /*--- Definition of the source term integration scheme for each equation and mesh level ---*/ for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) - numerics[iMGlevel][TEMPLATE_SOL][SOURCE_FIRST_TERM] = new CSource_Template(nDim, nVar_Template, config); + numerics[iMGlevel][TEMPLATE_SOL][source_first_term] = new CSource_Template(nDim, nVar_Template, config); /*--- Definition of the boundary condition method ---*/ for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { - numerics[iMGlevel][TEMPLATE_SOL][CONV_BOUND_TERM] = new CConvective_Template(nDim, nVar_Template, config); + numerics[iMGlevel][TEMPLATE_SOL][conv_bound_term] = new CConvective_Template(nDim, nVar_Template, config); } } @@ -2014,6 +2085,7 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol /*--- Definition of the convective scheme for each equation and mesh level ---*/ switch (config->GetKind_ConvNumScheme_Flow()) { case NO_CONVECTIVE : + SU2_OMP_MASTER SU2_MPI::Error("Config file is missing the CONV_NUM_METHOD_FLOW option.", CURRENT_FUNCTION); break; @@ -2021,33 +2093,39 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol if (compressible) { /*--- Compressible flow ---*/ switch (config->GetKind_Centered_Flow()) { - case LAX : numerics[MESH_0][FLOW_SOL][CONV_TERM] = new CCentLax_Flow(nDim, nVar_Flow, config); break; - case JST : numerics[MESH_0][FLOW_SOL][CONV_TERM] = new CCentJST_Flow(nDim, nVar_Flow, config); break; - case JST_KE : numerics[MESH_0][FLOW_SOL][CONV_TERM] = new CCentJST_KE_Flow(nDim, nVar_Flow, config); break; - default : SU2_MPI::Error("Invalid centered scheme or not implemented.", CURRENT_FUNCTION); break; + case LAX : numerics[MESH_0][FLOW_SOL][conv_term] = new CCentLax_Flow(nDim, nVar_Flow, config); break; + case JST : numerics[MESH_0][FLOW_SOL][conv_term] = new CCentJST_Flow(nDim, nVar_Flow, config); break; + case JST_KE : numerics[MESH_0][FLOW_SOL][conv_term] = new CCentJST_KE_Flow(nDim, nVar_Flow, config); break; + default: + SU2_OMP_MASTER + SU2_MPI::Error("Invalid centered scheme or not implemented.", CURRENT_FUNCTION); + break; } for (iMGlevel = 1; iMGlevel <= config->GetnMGLevels(); iMGlevel++) - numerics[iMGlevel][FLOW_SOL][CONV_TERM] = new CCentLax_Flow(nDim, nVar_Flow, config); + numerics[iMGlevel][FLOW_SOL][conv_term] = new CCentLax_Flow(nDim, nVar_Flow, config); /*--- Definition of the boundary condition method ---*/ for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) - numerics[iMGlevel][FLOW_SOL][CONV_BOUND_TERM] = new CUpwRoe_Flow(nDim, nVar_Flow, config, false); + numerics[iMGlevel][FLOW_SOL][conv_bound_term] = new CUpwRoe_Flow(nDim, nVar_Flow, config, false); } if (incompressible) { /*--- Incompressible flow, use preconditioning method ---*/ switch (config->GetKind_Centered_Flow()) { - case LAX : numerics[MESH_0][FLOW_SOL][CONV_TERM] = new CCentLaxInc_Flow(nDim, nVar_Flow, config); break; - case JST : numerics[MESH_0][FLOW_SOL][CONV_TERM] = new CCentJSTInc_Flow(nDim, nVar_Flow, config); break; - default : SU2_MPI::Error("Invalid centered scheme or not implemented.\n Currently, only JST and LAX-FRIEDRICH are available for incompressible flows.", CURRENT_FUNCTION); break; + case LAX : numerics[MESH_0][FLOW_SOL][conv_term] = new CCentLaxInc_Flow(nDim, nVar_Flow, config); break; + case JST : numerics[MESH_0][FLOW_SOL][conv_term] = new CCentJSTInc_Flow(nDim, nVar_Flow, config); break; + default: + SU2_OMP_MASTER + SU2_MPI::Error("Invalid centered scheme or not implemented.\n Currently, only JST and LAX-FRIEDRICH are available for incompressible flows.", CURRENT_FUNCTION); + break; } for (iMGlevel = 1; iMGlevel <= config->GetnMGLevels(); iMGlevel++) - numerics[iMGlevel][FLOW_SOL][CONV_TERM] = new CCentLaxInc_Flow(nDim, nVar_Flow, config); + numerics[iMGlevel][FLOW_SOL][conv_term] = new CCentLaxInc_Flow(nDim, nVar_Flow, config); /*--- Definition of the boundary condition method ---*/ for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) - numerics[iMGlevel][FLOW_SOL][CONV_BOUND_TERM] = new CUpwFDSInc_Flow(nDim, nVar_Flow, config); + numerics[iMGlevel][FLOW_SOL][conv_bound_term] = new CUpwFDSInc_Flow(nDim, nVar_Flow, config); } break; @@ -2059,103 +2137,106 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol if (ideal_gas) { for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { - numerics[iMGlevel][FLOW_SOL][CONV_TERM] = new CUpwRoe_Flow(nDim, nVar_Flow, config, roe_low_dissipation); - numerics[iMGlevel][FLOW_SOL][CONV_BOUND_TERM] = new CUpwRoe_Flow(nDim, nVar_Flow, config, false); + numerics[iMGlevel][FLOW_SOL][conv_term] = new CUpwRoe_Flow(nDim, nVar_Flow, config, roe_low_dissipation); + numerics[iMGlevel][FLOW_SOL][conv_bound_term] = new CUpwRoe_Flow(nDim, nVar_Flow, config, false); } } else { for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { - numerics[iMGlevel][FLOW_SOL][CONV_TERM] = new CUpwGeneralRoe_Flow(nDim, nVar_Flow, config); - numerics[iMGlevel][FLOW_SOL][CONV_BOUND_TERM] = new CUpwGeneralRoe_Flow(nDim, nVar_Flow, config); + numerics[iMGlevel][FLOW_SOL][conv_term] = new CUpwGeneralRoe_Flow(nDim, nVar_Flow, config); + numerics[iMGlevel][FLOW_SOL][conv_bound_term] = new CUpwGeneralRoe_Flow(nDim, nVar_Flow, config); } } break; case AUSM: for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { - numerics[iMGlevel][FLOW_SOL][CONV_TERM] = new CUpwAUSM_Flow(nDim, nVar_Flow, config); - numerics[iMGlevel][FLOW_SOL][CONV_BOUND_TERM] = new CUpwAUSM_Flow(nDim, nVar_Flow, config); + numerics[iMGlevel][FLOW_SOL][conv_term] = new CUpwAUSM_Flow(nDim, nVar_Flow, config); + numerics[iMGlevel][FLOW_SOL][conv_bound_term] = new CUpwAUSM_Flow(nDim, nVar_Flow, config); } break; case AUSMPLUSUP: for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { - numerics[iMGlevel][FLOW_SOL][CONV_TERM] = new CUpwAUSMPLUSUP_Flow(nDim, nVar_Flow, config); - numerics[iMGlevel][FLOW_SOL][CONV_BOUND_TERM] = new CUpwAUSMPLUSUP_Flow(nDim, nVar_Flow, config); + numerics[iMGlevel][FLOW_SOL][conv_term] = new CUpwAUSMPLUSUP_Flow(nDim, nVar_Flow, config); + numerics[iMGlevel][FLOW_SOL][conv_bound_term] = new CUpwAUSMPLUSUP_Flow(nDim, nVar_Flow, config); } break; case AUSMPLUSUP2: for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { - numerics[iMGlevel][FLOW_SOL][CONV_TERM] = new CUpwAUSMPLUSUP2_Flow(nDim, nVar_Flow, config); - numerics[iMGlevel][FLOW_SOL][CONV_BOUND_TERM] = new CUpwAUSMPLUSUP2_Flow(nDim, nVar_Flow, config); + numerics[iMGlevel][FLOW_SOL][conv_term] = new CUpwAUSMPLUSUP2_Flow(nDim, nVar_Flow, config); + numerics[iMGlevel][FLOW_SOL][conv_bound_term] = new CUpwAUSMPLUSUP2_Flow(nDim, nVar_Flow, config); } break; case TURKEL: for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { - numerics[iMGlevel][FLOW_SOL][CONV_TERM] = new CUpwTurkel_Flow(nDim, nVar_Flow, config); - numerics[iMGlevel][FLOW_SOL][CONV_BOUND_TERM] = new CUpwTurkel_Flow(nDim, nVar_Flow, config); + numerics[iMGlevel][FLOW_SOL][conv_term] = new CUpwTurkel_Flow(nDim, nVar_Flow, config); + numerics[iMGlevel][FLOW_SOL][conv_bound_term] = new CUpwTurkel_Flow(nDim, nVar_Flow, config); } break; case L2ROE: for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { - numerics[iMGlevel][FLOW_SOL][CONV_TERM] = new CUpwL2Roe_Flow(nDim, nVar_Flow, config); - numerics[iMGlevel][FLOW_SOL][CONV_BOUND_TERM] = new CUpwL2Roe_Flow(nDim, nVar_Flow, config); + numerics[iMGlevel][FLOW_SOL][conv_term] = new CUpwL2Roe_Flow(nDim, nVar_Flow, config); + numerics[iMGlevel][FLOW_SOL][conv_bound_term] = new CUpwL2Roe_Flow(nDim, nVar_Flow, config); } break; case LMROE: for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { - numerics[iMGlevel][FLOW_SOL][CONV_TERM] = new CUpwLMRoe_Flow(nDim, nVar_Flow, config); - numerics[iMGlevel][FLOW_SOL][CONV_BOUND_TERM] = new CUpwLMRoe_Flow(nDim, nVar_Flow, config); + numerics[iMGlevel][FLOW_SOL][conv_term] = new CUpwLMRoe_Flow(nDim, nVar_Flow, config); + numerics[iMGlevel][FLOW_SOL][conv_bound_term] = new CUpwLMRoe_Flow(nDim, nVar_Flow, config); } break; case SLAU: for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { - numerics[iMGlevel][FLOW_SOL][CONV_TERM] = new CUpwSLAU_Flow(nDim, nVar_Flow, config, roe_low_dissipation); - numerics[iMGlevel][FLOW_SOL][CONV_BOUND_TERM] = new CUpwSLAU_Flow(nDim, nVar_Flow, config, false); + numerics[iMGlevel][FLOW_SOL][conv_term] = new CUpwSLAU_Flow(nDim, nVar_Flow, config, roe_low_dissipation); + numerics[iMGlevel][FLOW_SOL][conv_bound_term] = new CUpwSLAU_Flow(nDim, nVar_Flow, config, false); } break; case SLAU2: for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { - numerics[iMGlevel][FLOW_SOL][CONV_TERM] = new CUpwSLAU2_Flow(nDim, nVar_Flow, config, roe_low_dissipation); - numerics[iMGlevel][FLOW_SOL][CONV_BOUND_TERM] = new CUpwSLAU2_Flow(nDim, nVar_Flow, config, false); + numerics[iMGlevel][FLOW_SOL][conv_term] = new CUpwSLAU2_Flow(nDim, nVar_Flow, config, roe_low_dissipation); + numerics[iMGlevel][FLOW_SOL][conv_bound_term] = new CUpwSLAU2_Flow(nDim, nVar_Flow, config, false); } break; case HLLC: if (ideal_gas) { for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { - numerics[iMGlevel][FLOW_SOL][CONV_TERM] = new CUpwHLLC_Flow(nDim, nVar_Flow, config); - numerics[iMGlevel][FLOW_SOL][CONV_BOUND_TERM] = new CUpwHLLC_Flow(nDim, nVar_Flow, config); + numerics[iMGlevel][FLOW_SOL][conv_term] = new CUpwHLLC_Flow(nDim, nVar_Flow, config); + numerics[iMGlevel][FLOW_SOL][conv_bound_term] = new CUpwHLLC_Flow(nDim, nVar_Flow, config); } } else { for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { - numerics[iMGlevel][FLOW_SOL][CONV_TERM] = new CUpwGeneralHLLC_Flow(nDim, nVar_Flow, config); - numerics[iMGlevel][FLOW_SOL][CONV_BOUND_TERM] = new CUpwGeneralHLLC_Flow(nDim, nVar_Flow, config); + numerics[iMGlevel][FLOW_SOL][conv_term] = new CUpwGeneralHLLC_Flow(nDim, nVar_Flow, config); + numerics[iMGlevel][FLOW_SOL][conv_bound_term] = new CUpwGeneralHLLC_Flow(nDim, nVar_Flow, config); } } break; case MSW: for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { - numerics[iMGlevel][FLOW_SOL][CONV_TERM] = new CUpwMSW_Flow(nDim, nVar_Flow, config); - numerics[iMGlevel][FLOW_SOL][CONV_BOUND_TERM] = new CUpwMSW_Flow(nDim, nVar_Flow, config); + numerics[iMGlevel][FLOW_SOL][conv_term] = new CUpwMSW_Flow(nDim, nVar_Flow, config); + numerics[iMGlevel][FLOW_SOL][conv_bound_term] = new CUpwMSW_Flow(nDim, nVar_Flow, config); } break; case CUSP: for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { - numerics[iMGlevel][FLOW_SOL][CONV_TERM] = new CUpwCUSP_Flow(nDim, nVar_Flow, config); - numerics[iMGlevel][FLOW_SOL][CONV_BOUND_TERM] = new CUpwCUSP_Flow(nDim, nVar_Flow, config); + numerics[iMGlevel][FLOW_SOL][conv_term] = new CUpwCUSP_Flow(nDim, nVar_Flow, config); + numerics[iMGlevel][FLOW_SOL][conv_bound_term] = new CUpwCUSP_Flow(nDim, nVar_Flow, config); } break; - default : SU2_MPI::Error("Invalid upwind scheme or not implemented.", CURRENT_FUNCTION); break; + default: + SU2_OMP_MASTER + SU2_MPI::Error("Invalid upwind scheme or not implemented.", CURRENT_FUNCTION); + break; } } @@ -2164,16 +2245,20 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol switch (config->GetKind_Upwind_Flow()) { case FDS: for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { - numerics[iMGlevel][FLOW_SOL][CONV_TERM] = new CUpwFDSInc_Flow(nDim, nVar_Flow, config); - numerics[iMGlevel][FLOW_SOL][CONV_BOUND_TERM] = new CUpwFDSInc_Flow(nDim, nVar_Flow, config); + numerics[iMGlevel][FLOW_SOL][conv_term] = new CUpwFDSInc_Flow(nDim, nVar_Flow, config); + numerics[iMGlevel][FLOW_SOL][conv_bound_term] = new CUpwFDSInc_Flow(nDim, nVar_Flow, config); } break; - default : SU2_MPI::Error("Invalid upwind scheme or not implemented.\n Currently, only FDS is available for incompressible flows.", CURRENT_FUNCTION); break; + default: + SU2_OMP_MASTER + SU2_MPI::Error("Invalid upwind scheme or not implemented.\n Currently, only FDS is available for incompressible flows.", CURRENT_FUNCTION); + break; } } break; - default : + default: + SU2_OMP_MASTER SU2_MPI::Error("Invalid convective scheme for the Euler / Navier-Stokes equations.", CURRENT_FUNCTION); break; } @@ -2183,66 +2268,73 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol if (ideal_gas) { /*--- Compressible flow Ideal gas ---*/ - numerics[MESH_0][FLOW_SOL][VISC_TERM] = new CAvgGrad_Flow(nDim, nVar_Flow, true, config); + numerics[MESH_0][FLOW_SOL][visc_term] = new CAvgGrad_Flow(nDim, nVar_Flow, true, config); for (iMGlevel = 1; iMGlevel <= config->GetnMGLevels(); iMGlevel++) - numerics[iMGlevel][FLOW_SOL][VISC_TERM] = new CAvgGrad_Flow(nDim, nVar_Flow, false, config); + numerics[iMGlevel][FLOW_SOL][visc_term] = new CAvgGrad_Flow(nDim, nVar_Flow, false, config); /*--- Definition of the boundary condition method ---*/ for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) - numerics[iMGlevel][FLOW_SOL][VISC_BOUND_TERM] = new CAvgGrad_Flow(nDim, nVar_Flow, false, config); + numerics[iMGlevel][FLOW_SOL][visc_bound_term] = new CAvgGrad_Flow(nDim, nVar_Flow, false, config); } else { - /*--- Compressible flow Realgas ---*/ - numerics[MESH_0][FLOW_SOL][VISC_TERM] = new CGeneralAvgGrad_Flow(nDim, nVar_Flow, true, config); + /*--- Compressible flow Real gas ---*/ + numerics[MESH_0][FLOW_SOL][visc_term] = new CGeneralAvgGrad_Flow(nDim, nVar_Flow, true, config); for (iMGlevel = 1; iMGlevel <= config->GetnMGLevels(); iMGlevel++) - numerics[iMGlevel][FLOW_SOL][VISC_TERM] = new CGeneralAvgGrad_Flow(nDim, nVar_Flow, false, config); + numerics[iMGlevel][FLOW_SOL][visc_term] = new CGeneralAvgGrad_Flow(nDim, nVar_Flow, false, config); /*--- Definition of the boundary condition method ---*/ for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) - numerics[iMGlevel][FLOW_SOL][VISC_BOUND_TERM] = new CGeneralAvgGrad_Flow(nDim, nVar_Flow, false, config); + numerics[iMGlevel][FLOW_SOL][visc_bound_term] = new CGeneralAvgGrad_Flow(nDim, nVar_Flow, false, config); } } if (incompressible) { /*--- Incompressible flow, use preconditioning method ---*/ - numerics[MESH_0][FLOW_SOL][VISC_TERM] = new CAvgGradInc_Flow(nDim, nVar_Flow, true, config); + numerics[MESH_0][FLOW_SOL][visc_term] = new CAvgGradInc_Flow(nDim, nVar_Flow, true, config); for (iMGlevel = 1; iMGlevel <= config->GetnMGLevels(); iMGlevel++) - numerics[iMGlevel][FLOW_SOL][VISC_TERM] = new CAvgGradInc_Flow(nDim, nVar_Flow, false, config); + numerics[iMGlevel][FLOW_SOL][visc_term] = new CAvgGradInc_Flow(nDim, nVar_Flow, false, config); /*--- Definition of the boundary condition method ---*/ for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) - numerics[iMGlevel][FLOW_SOL][VISC_BOUND_TERM] = new CAvgGradInc_Flow(nDim, nVar_Flow, false, config); + numerics[iMGlevel][FLOW_SOL][visc_bound_term] = new CAvgGradInc_Flow(nDim, nVar_Flow, false, config); } /*--- Definition of the source term integration scheme for each equation and mesh level ---*/ for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { - if (config->GetBody_Force() == YES) + if (config->GetBody_Force() == YES) { if (incompressible) - numerics[iMGlevel][FLOW_SOL][SOURCE_FIRST_TERM] = new CSourceIncBodyForce(nDim, nVar_Flow, config); + numerics[iMGlevel][FLOW_SOL][source_first_term] = new CSourceIncBodyForce(nDim, nVar_Flow, config); else - numerics[iMGlevel][FLOW_SOL][SOURCE_FIRST_TERM] = new CSourceBodyForce(nDim, nVar_Flow, config); - else if (incompressible && (config->GetKind_DensityModel() == BOUSSINESQ)) - numerics[iMGlevel][FLOW_SOL][SOURCE_FIRST_TERM] = new CSourceBoussinesq(nDim, nVar_Flow, config); - else if (config->GetRotating_Frame() == YES) + numerics[iMGlevel][FLOW_SOL][source_first_term] = new CSourceBodyForce(nDim, nVar_Flow, config); + } + else if (incompressible && (config->GetKind_DensityModel() == BOUSSINESQ)) { + numerics[iMGlevel][FLOW_SOL][source_first_term] = new CSourceBoussinesq(nDim, nVar_Flow, config); + } + else if (config->GetRotating_Frame() == YES) { if (incompressible) - numerics[iMGlevel][FLOW_SOL][SOURCE_FIRST_TERM] = new CSourceIncRotatingFrame_Flow(nDim, nVar_Flow, config); + numerics[iMGlevel][FLOW_SOL][source_first_term] = new CSourceIncRotatingFrame_Flow(nDim, nVar_Flow, config); else - numerics[iMGlevel][FLOW_SOL][SOURCE_FIRST_TERM] = new CSourceRotatingFrame_Flow(nDim, nVar_Flow, config); - else if (config->GetAxisymmetric() == YES) + numerics[iMGlevel][FLOW_SOL][source_first_term] = new CSourceRotatingFrame_Flow(nDim, nVar_Flow, config); + } + else if (config->GetAxisymmetric() == YES) { if (incompressible) - numerics[iMGlevel][FLOW_SOL][SOURCE_FIRST_TERM] = new CSourceIncAxisymmetric_Flow(nDim, nVar_Flow, config); + numerics[iMGlevel][FLOW_SOL][source_first_term] = new CSourceIncAxisymmetric_Flow(nDim, nVar_Flow, config); else - numerics[iMGlevel][FLOW_SOL][SOURCE_FIRST_TERM] = new CSourceAxisymmetric_Flow(nDim, nVar_Flow, config); - else if (config->GetGravityForce() == YES) - numerics[iMGlevel][FLOW_SOL][SOURCE_FIRST_TERM] = new CSourceGravity(nDim, nVar_Flow, config); - else if (config->GetWind_Gust() == YES) - numerics[iMGlevel][FLOW_SOL][SOURCE_FIRST_TERM] = new CSourceWindGust(nDim, nVar_Flow, config); - else - numerics[iMGlevel][FLOW_SOL][SOURCE_FIRST_TERM] = new CSourceNothing(nDim, nVar_Flow, config); + numerics[iMGlevel][FLOW_SOL][source_first_term] = new CSourceAxisymmetric_Flow(nDim, nVar_Flow, config); + } + else if (config->GetGravityForce() == YES) { + numerics[iMGlevel][FLOW_SOL][source_first_term] = new CSourceGravity(nDim, nVar_Flow, config); + } + else if (config->GetWind_Gust() == YES) { + numerics[iMGlevel][FLOW_SOL][source_first_term] = new CSourceWindGust(nDim, nVar_Flow, config); + } + else { + numerics[iMGlevel][FLOW_SOL][source_first_term] = new CSourceNothing(nDim, nVar_Flow, config); + } - numerics[iMGlevel][FLOW_SOL][SOURCE_SECOND_TERM] = new CSourceNothing(nDim, nVar_Flow, config); + numerics[iMGlevel][FLOW_SOL][source_second_term] = new CSourceNothing(nDim, nVar_Flow, config); } } @@ -2251,7 +2343,6 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol if ((fem_euler) || (fem_ns)) { switch (config->GetRiemann_Solver_FEM()) { - case NO_UPWIND : cout << "Riemann solver disabled." << endl; break; case ROE: case LAX_FRIEDRICH: /* Hard coded optimized implementation is used in the DG solver. No need to allocate the @@ -2260,41 +2351,43 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol case AUSM: for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { - numerics[iMGlevel][FLOW_SOL][CONV_TERM] = new CUpwAUSM_Flow(nDim, nVar_Flow, config); - numerics[iMGlevel][FLOW_SOL][CONV_BOUND_TERM] = new CUpwAUSM_Flow(nDim, nVar_Flow, config); + numerics[iMGlevel][FLOW_SOL][conv_term] = new CUpwAUSM_Flow(nDim, nVar_Flow, config); + numerics[iMGlevel][FLOW_SOL][conv_bound_term] = new CUpwAUSM_Flow(nDim, nVar_Flow, config); } break; case TURKEL: for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { - numerics[iMGlevel][FLOW_SOL][CONV_TERM] = new CUpwTurkel_Flow(nDim, nVar_Flow, config); - numerics[iMGlevel][FLOW_SOL][CONV_BOUND_TERM] = new CUpwTurkel_Flow(nDim, nVar_Flow, config); + numerics[iMGlevel][FLOW_SOL][conv_term] = new CUpwTurkel_Flow(nDim, nVar_Flow, config); + numerics[iMGlevel][FLOW_SOL][conv_bound_term] = new CUpwTurkel_Flow(nDim, nVar_Flow, config); } break; case HLLC: for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { - numerics[iMGlevel][FLOW_SOL][CONV_TERM] = new CUpwHLLC_Flow(nDim, nVar_Flow, config); - numerics[iMGlevel][FLOW_SOL][CONV_BOUND_TERM] = new CUpwHLLC_Flow(nDim, nVar_Flow, config); + numerics[iMGlevel][FLOW_SOL][conv_term] = new CUpwHLLC_Flow(nDim, nVar_Flow, config); + numerics[iMGlevel][FLOW_SOL][conv_bound_term] = new CUpwHLLC_Flow(nDim, nVar_Flow, config); } break; case MSW: for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { - numerics[iMGlevel][FLOW_SOL][CONV_TERM] = new CUpwMSW_Flow(nDim, nVar_Flow, config); - numerics[iMGlevel][FLOW_SOL][CONV_BOUND_TERM] = new CUpwMSW_Flow(nDim, nVar_Flow, config); + numerics[iMGlevel][FLOW_SOL][conv_term] = new CUpwMSW_Flow(nDim, nVar_Flow, config); + numerics[iMGlevel][FLOW_SOL][conv_bound_term] = new CUpwMSW_Flow(nDim, nVar_Flow, config); } break; case CUSP: for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { - numerics[iMGlevel][FLOW_SOL][CONV_TERM] = new CUpwCUSP_Flow(nDim, nVar_Flow, config); - numerics[iMGlevel][FLOW_SOL][CONV_BOUND_TERM] = new CUpwCUSP_Flow(nDim, nVar_Flow, config); + numerics[iMGlevel][FLOW_SOL][conv_term] = new CUpwCUSP_Flow(nDim, nVar_Flow, config); + numerics[iMGlevel][FLOW_SOL][conv_bound_term] = new CUpwCUSP_Flow(nDim, nVar_Flow, config); } break; - default : + default: + SU2_OMP_MASTER SU2_MPI::Error("Riemann solver not implemented.", CURRENT_FUNCTION); + break; } } @@ -2306,18 +2399,20 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol /*--- Definition of the convective scheme for each equation and mesh level ---*/ switch (config->GetKind_ConvNumScheme_Turb()) { - case NO_UPWIND : + case NO_UPWIND: + SU2_OMP_MASTER SU2_MPI::Error("Config file is missing the CONV_NUM_METHOD_TURB option.", CURRENT_FUNCTION); break; case SPACE_UPWIND : for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { if (spalart_allmaras || neg_spalart_allmaras || e_spalart_allmaras || comp_spalart_allmaras || e_comp_spalart_allmaras ) { - numerics[iMGlevel][TURB_SOL][CONV_TERM] = new CUpwSca_TurbSA(nDim, nVar_Turb, config); + numerics[iMGlevel][TURB_SOL][conv_term] = new CUpwSca_TurbSA(nDim, nVar_Turb, config); } - else if (menter_sst) numerics[iMGlevel][TURB_SOL][CONV_TERM] = new CUpwSca_TurbSST(nDim, nVar_Turb, config); + else if (menter_sst) numerics[iMGlevel][TURB_SOL][conv_term] = new CUpwSca_TurbSST(nDim, nVar_Turb, config); } break; - default : + default: + SU2_OMP_MASTER SU2_MPI::Error("Invalid convective scheme for the turbulence equations.", CURRENT_FUNCTION); break; } @@ -2326,38 +2421,38 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { if (spalart_allmaras || e_spalart_allmaras || comp_spalart_allmaras || e_comp_spalart_allmaras){ - numerics[iMGlevel][TURB_SOL][VISC_TERM] = new CAvgGrad_TurbSA(nDim, nVar_Turb, true, config); + numerics[iMGlevel][TURB_SOL][visc_term] = new CAvgGrad_TurbSA(nDim, nVar_Turb, true, config); } - else if (neg_spalart_allmaras) numerics[iMGlevel][TURB_SOL][VISC_TERM] = new CAvgGrad_TurbSA_Neg(nDim, nVar_Turb, true, config); - else if (menter_sst) numerics[iMGlevel][TURB_SOL][VISC_TERM] = new CAvgGrad_TurbSST(nDim, nVar_Turb, constants, true, config); + else if (neg_spalart_allmaras) numerics[iMGlevel][TURB_SOL][visc_term] = new CAvgGrad_TurbSA_Neg(nDim, nVar_Turb, true, config); + else if (menter_sst) numerics[iMGlevel][TURB_SOL][visc_term] = new CAvgGrad_TurbSST(nDim, nVar_Turb, constants, true, config); } /*--- Definition of the source term integration scheme for each equation and mesh level ---*/ for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { - if (spalart_allmaras) numerics[iMGlevel][TURB_SOL][SOURCE_FIRST_TERM] = new CSourcePieceWise_TurbSA(nDim, nVar_Turb, config); - else if (e_spalart_allmaras) numerics[iMGlevel][TURB_SOL][SOURCE_FIRST_TERM] = new CSourcePieceWise_TurbSA_E(nDim, nVar_Turb, config); - else if (comp_spalart_allmaras) numerics[iMGlevel][TURB_SOL][SOURCE_FIRST_TERM] = new CSourcePieceWise_TurbSA_COMP(nDim, nVar_Turb, config); - else if (e_comp_spalart_allmaras) numerics[iMGlevel][TURB_SOL][SOURCE_FIRST_TERM] = new CSourcePieceWise_TurbSA_E_COMP(nDim, nVar_Turb, config); - else if (neg_spalart_allmaras) numerics[iMGlevel][TURB_SOL][SOURCE_FIRST_TERM] = new CSourcePieceWise_TurbSA_Neg(nDim, nVar_Turb, config); - else if (menter_sst) numerics[iMGlevel][TURB_SOL][SOURCE_FIRST_TERM] = new CSourcePieceWise_TurbSST(nDim, nVar_Turb, constants, kine_Inf, omega_Inf, config); - numerics[iMGlevel][TURB_SOL][SOURCE_SECOND_TERM] = new CSourceNothing(nDim, nVar_Turb, config); + if (spalart_allmaras) numerics[iMGlevel][TURB_SOL][source_first_term] = new CSourcePieceWise_TurbSA(nDim, nVar_Turb, config); + else if (e_spalart_allmaras) numerics[iMGlevel][TURB_SOL][source_first_term] = new CSourcePieceWise_TurbSA_E(nDim, nVar_Turb, config); + else if (comp_spalart_allmaras) numerics[iMGlevel][TURB_SOL][source_first_term] = new CSourcePieceWise_TurbSA_COMP(nDim, nVar_Turb, config); + else if (e_comp_spalart_allmaras) numerics[iMGlevel][TURB_SOL][source_first_term] = new CSourcePieceWise_TurbSA_E_COMP(nDim, nVar_Turb, config); + else if (neg_spalart_allmaras) numerics[iMGlevel][TURB_SOL][source_first_term] = new CSourcePieceWise_TurbSA_Neg(nDim, nVar_Turb, config); + else if (menter_sst) numerics[iMGlevel][TURB_SOL][source_first_term] = new CSourcePieceWise_TurbSST(nDim, nVar_Turb, constants, kine_Inf, omega_Inf, config); + numerics[iMGlevel][TURB_SOL][source_second_term] = new CSourceNothing(nDim, nVar_Turb, config); } /*--- Definition of the boundary condition method ---*/ for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { if (spalart_allmaras || e_spalart_allmaras || comp_spalart_allmaras || e_comp_spalart_allmaras) { - numerics[iMGlevel][TURB_SOL][CONV_BOUND_TERM] = new CUpwSca_TurbSA(nDim, nVar_Turb, config); - numerics[iMGlevel][TURB_SOL][VISC_BOUND_TERM] = new CAvgGrad_TurbSA(nDim, nVar_Turb, false, config); + numerics[iMGlevel][TURB_SOL][conv_bound_term] = new CUpwSca_TurbSA(nDim, nVar_Turb, config); + numerics[iMGlevel][TURB_SOL][visc_bound_term] = new CAvgGrad_TurbSA(nDim, nVar_Turb, false, config); } else if (neg_spalart_allmaras) { - numerics[iMGlevel][TURB_SOL][CONV_BOUND_TERM] = new CUpwSca_TurbSA(nDim, nVar_Turb, config); - numerics[iMGlevel][TURB_SOL][VISC_BOUND_TERM] = new CAvgGrad_TurbSA_Neg(nDim, nVar_Turb, false, config); + numerics[iMGlevel][TURB_SOL][conv_bound_term] = new CUpwSca_TurbSA(nDim, nVar_Turb, config); + numerics[iMGlevel][TURB_SOL][visc_bound_term] = new CAvgGrad_TurbSA_Neg(nDim, nVar_Turb, false, config); } else if (menter_sst) { - numerics[iMGlevel][TURB_SOL][CONV_BOUND_TERM] = new CUpwSca_TurbSST(nDim, nVar_Turb, config); - numerics[iMGlevel][TURB_SOL][VISC_BOUND_TERM] = new CAvgGrad_TurbSST(nDim, nVar_Turb, constants, false, config); + numerics[iMGlevel][TURB_SOL][conv_bound_term] = new CUpwSca_TurbSST(nDim, nVar_Turb, config); + numerics[iMGlevel][TURB_SOL][visc_bound_term] = new CAvgGrad_TurbSST(nDim, nVar_Turb, constants, false, config); } } } @@ -2367,33 +2462,35 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol /*--- Definition of the convective scheme for each equation and mesh level ---*/ switch (config->GetKind_ConvNumScheme_Turb()) { - case NO_UPWIND : + case NO_UPWIND: + SU2_OMP_MASTER SU2_MPI::Error("Config file is missing the CONV_NUM_METHOD_TURB option.", CURRENT_FUNCTION); break; - case SPACE_UPWIND : + case SPACE_UPWIND: for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { - numerics[iMGlevel][TRANS_SOL][CONV_TERM] = new CUpwSca_TransLM(nDim, nVar_Trans, config); + numerics[iMGlevel][TRANS_SOL][conv_term] = new CUpwSca_TransLM(nDim, nVar_Trans, config); } break; - default : + default: + SU2_OMP_MASTER SU2_MPI::Error("Invalid convective scheme for the transition equations.", CURRENT_FUNCTION); break; } /*--- Definition of the viscous scheme for each equation and mesh level ---*/ for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { - numerics[iMGlevel][TRANS_SOL][VISC_TERM] = new CAvgGradCorrected_TransLM(nDim, nVar_Trans, config); + numerics[iMGlevel][TRANS_SOL][visc_term] = new CAvgGradCorrected_TransLM(nDim, nVar_Trans, config); } /*--- Definition of the source term integration scheme for each equation and mesh level ---*/ for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { - numerics[iMGlevel][TRANS_SOL][SOURCE_FIRST_TERM] = new CSourcePieceWise_TransLM(nDim, nVar_Trans, config); - numerics[iMGlevel][TRANS_SOL][SOURCE_SECOND_TERM] = new CSourceNothing(nDim, nVar_Trans, config); + numerics[iMGlevel][TRANS_SOL][source_first_term] = new CSourcePieceWise_TransLM(nDim, nVar_Trans, config); + numerics[iMGlevel][TRANS_SOL][source_second_term] = new CSourceNothing(nDim, nVar_Trans, config); } /*--- Definition of the boundary condition method ---*/ for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { - numerics[iMGlevel][TRANS_SOL][CONV_BOUND_TERM] = new CUpwLin_TransLM(nDim, nVar_Trans, config); + numerics[iMGlevel][TRANS_SOL][conv_bound_term] = new CUpwLin_TransLM(nDim, nVar_Trans, config); } } @@ -2403,22 +2500,23 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol /*--- Definition of the viscous scheme for each equation and mesh level ---*/ for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { - numerics[iMGlevel][HEAT_SOL][VISC_TERM] = new CAvgGradCorrected_Heat(nDim, nVar_Heat, config); - numerics[iMGlevel][HEAT_SOL][VISC_BOUND_TERM] = new CAvgGrad_Heat(nDim, nVar_Heat, config); + numerics[iMGlevel][HEAT_SOL][visc_term] = new CAvgGradCorrected_Heat(nDim, nVar_Heat, config); + numerics[iMGlevel][HEAT_SOL][visc_bound_term] = new CAvgGrad_Heat(nDim, nVar_Heat, config); switch (config->GetKind_ConvNumScheme_Heat()) { case SPACE_UPWIND : - numerics[iMGlevel][HEAT_SOL][CONV_TERM] = new CUpwSca_Heat(nDim, nVar_Heat, config); - numerics[iMGlevel][HEAT_SOL][CONV_BOUND_TERM] = new CUpwSca_Heat(nDim, nVar_Heat, config); + numerics[iMGlevel][HEAT_SOL][conv_term] = new CUpwSca_Heat(nDim, nVar_Heat, config); + numerics[iMGlevel][HEAT_SOL][conv_bound_term] = new CUpwSca_Heat(nDim, nVar_Heat, config); break; case SPACE_CENTERED : - numerics[iMGlevel][HEAT_SOL][CONV_TERM] = new CCentSca_Heat(nDim, nVar_Heat, config); - numerics[iMGlevel][HEAT_SOL][CONV_BOUND_TERM] = new CUpwSca_Heat(nDim, nVar_Heat, config); + numerics[iMGlevel][HEAT_SOL][conv_term] = new CCentSca_Heat(nDim, nVar_Heat, config); + numerics[iMGlevel][HEAT_SOL][conv_bound_term] = new CUpwSca_Heat(nDim, nVar_Heat, config); break; - default : + default: + SU2_OMP_MASTER SU2_MPI::Error("Invalid convective scheme for the heat transfer equations.", CURRENT_FUNCTION); break; } @@ -2430,12 +2528,14 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol if (adj_euler || adj_ns) { if (incompressible) + SU2_OMP_MASTER SU2_MPI::Error("Convective schemes not implemented for incompressible continuous adjoint.", CURRENT_FUNCTION); /*--- Definition of the convective scheme for each equation and mesh level ---*/ switch (config->GetKind_ConvNumScheme_AdjFlow()) { - case NO_CONVECTIVE : + case NO_CONVECTIVE: + SU2_OMP_MASTER SU2_MPI::Error("Config file is missing the CONV_NUM_METHOD_ADJFLOW option.", CURRENT_FUNCTION); break; @@ -2446,16 +2546,19 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol /*--- Compressible flow ---*/ switch (config->GetKind_Centered_AdjFlow()) { - case LAX : numerics[MESH_0][ADJFLOW_SOL][CONV_TERM] = new CCentLax_AdjFlow(nDim, nVar_Adj_Flow, config); break; - case JST : numerics[MESH_0][ADJFLOW_SOL][CONV_TERM] = new CCentJST_AdjFlow(nDim, nVar_Adj_Flow, config); break; - default : SU2_MPI::Error("Centered scheme not implemented.", CURRENT_FUNCTION); break; + case LAX : numerics[MESH_0][ADJFLOW_SOL][conv_term] = new CCentLax_AdjFlow(nDim, nVar_Adj_Flow, config); break; + case JST : numerics[MESH_0][ADJFLOW_SOL][conv_term] = new CCentJST_AdjFlow(nDim, nVar_Adj_Flow, config); break; + default: + SU2_OMP_MASTER + SU2_MPI::Error("Centered scheme not implemented.", CURRENT_FUNCTION); + break; } for (iMGlevel = 1; iMGlevel <= config->GetnMGLevels(); iMGlevel++) - numerics[iMGlevel][ADJFLOW_SOL][CONV_TERM] = new CCentLax_AdjFlow(nDim, nVar_Adj_Flow, config); + numerics[iMGlevel][ADJFLOW_SOL][conv_term] = new CCentLax_AdjFlow(nDim, nVar_Adj_Flow, config); for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) - numerics[iMGlevel][ADJFLOW_SOL][CONV_BOUND_TERM] = new CUpwRoe_AdjFlow(nDim, nVar_Adj_Flow, config); + numerics[iMGlevel][ADJFLOW_SOL][conv_bound_term] = new CUpwRoe_AdjFlow(nDim, nVar_Adj_Flow, config); } break; @@ -2469,16 +2572,20 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol switch (config->GetKind_Upwind_AdjFlow()) { case ROE: for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { - numerics[iMGlevel][ADJFLOW_SOL][CONV_TERM] = new CUpwRoe_AdjFlow(nDim, nVar_Adj_Flow, config); - numerics[iMGlevel][ADJFLOW_SOL][CONV_BOUND_TERM] = new CUpwRoe_AdjFlow(nDim, nVar_Adj_Flow, config); + numerics[iMGlevel][ADJFLOW_SOL][conv_term] = new CUpwRoe_AdjFlow(nDim, nVar_Adj_Flow, config); + numerics[iMGlevel][ADJFLOW_SOL][conv_bound_term] = new CUpwRoe_AdjFlow(nDim, nVar_Adj_Flow, config); } break; - default : SU2_MPI::Error("Upwind scheme not implemented.", CURRENT_FUNCTION); break; + default: + SU2_OMP_MASTER + SU2_MPI::Error("Upwind scheme not implemented.", CURRENT_FUNCTION); + break; } } break; - default : + default: + SU2_OMP_MASTER SU2_MPI::Error("Invalid convective scheme for the continuous adjoint Euler / Navier-Stokes equations.", CURRENT_FUNCTION); break; } @@ -2489,12 +2596,12 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol /*--- Compressible flow ---*/ - numerics[MESH_0][ADJFLOW_SOL][VISC_TERM] = new CAvgGradCorrected_AdjFlow(nDim, nVar_Adj_Flow, config); - numerics[MESH_0][ADJFLOW_SOL][VISC_BOUND_TERM] = new CAvgGrad_AdjFlow(nDim, nVar_Adj_Flow, config); + numerics[MESH_0][ADJFLOW_SOL][visc_term] = new CAvgGradCorrected_AdjFlow(nDim, nVar_Adj_Flow, config); + numerics[MESH_0][ADJFLOW_SOL][visc_bound_term] = new CAvgGrad_AdjFlow(nDim, nVar_Adj_Flow, config); for (iMGlevel = 1; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { - numerics[iMGlevel][ADJFLOW_SOL][VISC_TERM] = new CAvgGrad_AdjFlow(nDim, nVar_Adj_Flow, config); - numerics[iMGlevel][ADJFLOW_SOL][VISC_BOUND_TERM] = new CAvgGrad_AdjFlow(nDim, nVar_Adj_Flow, config); + numerics[iMGlevel][ADJFLOW_SOL][visc_term] = new CAvgGrad_AdjFlow(nDim, nVar_Adj_Flow, config); + numerics[iMGlevel][ADJFLOW_SOL][visc_bound_term] = new CAvgGrad_AdjFlow(nDim, nVar_Adj_Flow, config); } } @@ -2509,25 +2616,25 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol if (adj_ns) { - numerics[iMGlevel][ADJFLOW_SOL][SOURCE_FIRST_TERM] = new CSourceViscous_AdjFlow(nDim, nVar_Adj_Flow, config); + numerics[iMGlevel][ADJFLOW_SOL][source_first_term] = new CSourceViscous_AdjFlow(nDim, nVar_Adj_Flow, config); if (config->GetRotating_Frame() == YES) - numerics[iMGlevel][ADJFLOW_SOL][SOURCE_SECOND_TERM] = new CSourceRotatingFrame_AdjFlow(nDim, nVar_Adj_Flow, config); + numerics[iMGlevel][ADJFLOW_SOL][source_second_term] = new CSourceRotatingFrame_AdjFlow(nDim, nVar_Adj_Flow, config); else - numerics[iMGlevel][ADJFLOW_SOL][SOURCE_SECOND_TERM] = new CSourceConservative_AdjFlow(nDim, nVar_Adj_Flow, config); + numerics[iMGlevel][ADJFLOW_SOL][source_second_term] = new CSourceConservative_AdjFlow(nDim, nVar_Adj_Flow, config); } else { if (config->GetRotating_Frame() == YES) - numerics[iMGlevel][ADJFLOW_SOL][SOURCE_FIRST_TERM] = new CSourceRotatingFrame_AdjFlow(nDim, nVar_Adj_Flow, config); + numerics[iMGlevel][ADJFLOW_SOL][source_first_term] = new CSourceRotatingFrame_AdjFlow(nDim, nVar_Adj_Flow, config); else if (config->GetAxisymmetric() == YES) - numerics[iMGlevel][ADJFLOW_SOL][SOURCE_FIRST_TERM] = new CSourceAxisymmetric_AdjFlow(nDim, nVar_Adj_Flow, config); + numerics[iMGlevel][ADJFLOW_SOL][source_first_term] = new CSourceAxisymmetric_AdjFlow(nDim, nVar_Adj_Flow, config); else - numerics[iMGlevel][ADJFLOW_SOL][SOURCE_FIRST_TERM] = new CSourceNothing(nDim, nVar_Adj_Flow, config); + numerics[iMGlevel][ADJFLOW_SOL][source_first_term] = new CSourceNothing(nDim, nVar_Adj_Flow, config); - numerics[iMGlevel][ADJFLOW_SOL][SOURCE_SECOND_TERM] = new CSourceNothing(nDim, nVar_Adj_Flow, config); + numerics[iMGlevel][ADJFLOW_SOL][source_second_term] = new CSourceNothing(nDim, nVar_Adj_Flow, config); } @@ -2541,137 +2648,133 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol if (adj_turb) { if (!spalart_allmaras) + SU2_OMP_MASTER SU2_MPI::Error("Only the SA turbulence model can be used with the continuous adjoint solver.", CURRENT_FUNCTION); /*--- Definition of the convective scheme for each equation and mesh level ---*/ switch (config->GetKind_ConvNumScheme_AdjTurb()) { - case NO_CONVECTIVE : + case NO_CONVECTIVE: + SU2_OMP_MASTER SU2_MPI::Error("Config file is missing the CONV_NUM_METHOD_ADJTURB option.", CURRENT_FUNCTION); break; case SPACE_UPWIND : for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) - numerics[iMGlevel][ADJTURB_SOL][CONV_TERM] = new CUpwSca_AdjTurb(nDim, nVar_Adj_Turb, config); + numerics[iMGlevel][ADJTURB_SOL][conv_term] = new CUpwSca_AdjTurb(nDim, nVar_Adj_Turb, config); break; - default : + default: + SU2_OMP_MASTER SU2_MPI::Error("Convective scheme not implemented (adjoint turbulence).", CURRENT_FUNCTION); break; } /*--- Definition of the viscous scheme for each equation and mesh level ---*/ for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) - numerics[iMGlevel][ADJTURB_SOL][VISC_TERM] = new CAvgGradCorrected_AdjTurb(nDim, nVar_Adj_Turb, config); + numerics[iMGlevel][ADJTURB_SOL][visc_term] = new CAvgGradCorrected_AdjTurb(nDim, nVar_Adj_Turb, config); /*--- Definition of the source term integration scheme for each equation and mesh level ---*/ for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { - numerics[iMGlevel][ADJTURB_SOL][SOURCE_FIRST_TERM] = new CSourcePieceWise_AdjTurb(nDim, nVar_Adj_Turb, config); - numerics[iMGlevel][ADJTURB_SOL][SOURCE_SECOND_TERM] = new CSourceConservative_AdjTurb(nDim, nVar_Adj_Turb, config); + numerics[iMGlevel][ADJTURB_SOL][source_first_term] = new CSourcePieceWise_AdjTurb(nDim, nVar_Adj_Turb, config); + numerics[iMGlevel][ADJTURB_SOL][source_second_term] = new CSourceConservative_AdjTurb(nDim, nVar_Adj_Turb, config); } /*--- Definition of the boundary condition method ---*/ for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) - numerics[iMGlevel][ADJTURB_SOL][CONV_BOUND_TERM] = new CUpwLin_AdjTurb(nDim, nVar_Adj_Turb, config); + numerics[iMGlevel][ADJTURB_SOL][conv_bound_term] = new CUpwLin_AdjTurb(nDim, nVar_Adj_Turb, config); } - /*--- Numerics definition for FEM-like problems. Instantiate one numerics per thread. ---*/ - - SU2_OMP_PARALLEL - { - int thread = omp_get_thread_num(); - int offset = thread * MAX_TERMS; - int fea_term = FEA_TERM + offset; + /*--- Numerics definition for FEM-like problems. ---*/ - if (fem) { - /*--- Initialize the container for FEA_TERM. This will be the only one for most of the cases ---*/ - switch (config->GetGeometricConditions()) { - case SMALL_DEFORMATIONS: - switch (config->GetMaterialModel()) { - case LINEAR_ELASTIC: - numerics[MESH_0][FEA_SOL][fea_term] = new CFEALinearElasticity(nDim, nVar_FEM, config); - break; - case NEO_HOOKEAN: - SU2_OMP_MASTER - SU2_MPI::Error("Material model does not correspond to geometric conditions.", CURRENT_FUNCTION); - break; - default: + if (fem) { + /*--- Initialize the container for FEA_TERM. This will be the only one for most of the cases. ---*/ + switch (config->GetGeometricConditions()) { + case SMALL_DEFORMATIONS: + switch (config->GetMaterialModel()) { + case LINEAR_ELASTIC: + numerics[MESH_0][FEA_SOL][fea_term] = new CFEALinearElasticity(nDim, nVar_FEM, config); + break; + case NEO_HOOKEAN: + SU2_OMP_MASTER + SU2_MPI::Error("Material model does not correspond to geometric conditions.", CURRENT_FUNCTION); + break; + default: + SU2_OMP_MASTER + SU2_MPI::Error("Material model not implemented.", CURRENT_FUNCTION); + break; + } + break; + case LARGE_DEFORMATIONS : + switch (config->GetMaterialModel()) { + case LINEAR_ELASTIC: + SU2_OMP_MASTER + SU2_MPI::Error("Material model does not correspond to geometric conditions.", CURRENT_FUNCTION); + break; + case NEO_HOOKEAN: + if (config->GetMaterialCompressibility() == COMPRESSIBLE_MAT) { + numerics[MESH_0][FEA_SOL][fea_term] = new CFEM_NeoHookean_Comp(nDim, nVar_FEM, config); + } else { SU2_OMP_MASTER SU2_MPI::Error("Material model not implemented.", CURRENT_FUNCTION); - break; - } - break; - case LARGE_DEFORMATIONS : - switch (config->GetMaterialModel()) { - case LINEAR_ELASTIC: + } + break; + case KNOWLES: + if (config->GetMaterialCompressibility() == NEARLY_INCOMPRESSIBLE_MAT) { + numerics[MESH_0][FEA_SOL][fea_term] = new CFEM_Knowles_NearInc(nDim, nVar_FEM, config); + } else { SU2_OMP_MASTER - SU2_MPI::Error("Material model does not correspond to geometric conditions.", CURRENT_FUNCTION); - break; - case NEO_HOOKEAN: - if (config->GetMaterialCompressibility() == COMPRESSIBLE_MAT) { - numerics[MESH_0][FEA_SOL][fea_term] = new CFEM_NeoHookean_Comp(nDim, nVar_FEM, config); - } else { - SU2_OMP_MASTER - SU2_MPI::Error("Material model not implemented.", CURRENT_FUNCTION); - } - break; - case KNOWLES: - if (config->GetMaterialCompressibility() == NEARLY_INCOMPRESSIBLE_MAT) { - numerics[MESH_0][FEA_SOL][fea_term] = new CFEM_Knowles_NearInc(nDim, nVar_FEM, config); - } else { - SU2_OMP_MASTER - SU2_MPI::Error("Material model not implemented.", CURRENT_FUNCTION); - } - break; - case IDEAL_DE: - if (config->GetMaterialCompressibility() == NEARLY_INCOMPRESSIBLE_MAT) { - numerics[MESH_0][FEA_SOL][fea_term] = new CFEM_IdealDE(nDim, nVar_FEM, config); - } else { - SU2_OMP_MASTER - SU2_MPI::Error("Material model not implemented.", CURRENT_FUNCTION); - } - break; - default: + SU2_MPI::Error("Material model not implemented.", CURRENT_FUNCTION); + } + break; + case IDEAL_DE: + if (config->GetMaterialCompressibility() == NEARLY_INCOMPRESSIBLE_MAT) { + numerics[MESH_0][FEA_SOL][fea_term] = new CFEM_IdealDE(nDim, nVar_FEM, config); + } else { SU2_OMP_MASTER SU2_MPI::Error("Material model not implemented.", CURRENT_FUNCTION); - break; - } - break; - default: - SU2_OMP_MASTER - SU2_MPI::Error("Solver not implemented.", CURRENT_FUNCTION); - break; - } + } + break; + default: + SU2_OMP_MASTER + SU2_MPI::Error("Material model not implemented.", CURRENT_FUNCTION); + break; + } + break; + default: + SU2_OMP_MASTER + SU2_MPI::Error("Solver not implemented.", CURRENT_FUNCTION); + break; + } - /*--- The following definitions only make sense if we have a non-linear solution. ---*/ - if (config->GetGeometricConditions() == LARGE_DEFORMATIONS) { + /*--- The following definitions only make sense if we have a non-linear solution. ---*/ + if (config->GetGeometricConditions() == LARGE_DEFORMATIONS) { - /*--- This allocates a container for electromechanical effects. ---*/ + /*--- This allocates a container for electromechanical effects. ---*/ - bool de_effects = config->GetDE_Effects(); - if (de_effects) - numerics[MESH_0][FEA_SOL][DE_TERM+offset] = new CFEM_DielectricElastomer(nDim, nVar_FEM, config); + bool de_effects = config->GetDE_Effects(); + if (de_effects) + numerics[MESH_0][FEA_SOL][DE_TERM+offset] = new CFEM_DielectricElastomer(nDim, nVar_FEM, config); - string filename; - ifstream properties_file; + ifstream properties_file; - filename = config->GetFEA_FileName(); - if (nZone > 1) - filename = config->GetMultizone_FileName(filename, iZone, ".dat"); + string filename = config->GetFEA_FileName(); + if (nZone > 1) + filename = config->GetMultizone_FileName(filename, iZone, ".dat"); - properties_file.open(filename.data(), ios::in); + properties_file.open(filename.data(), ios::in); - /*--- In case there is a properties file, containers are allocated for a number of material models. ---*/ + /*--- In case there is a properties file, containers are allocated for a number of material models. ---*/ - if (!(properties_file.fail())) { - numerics[MESH_0][FEA_SOL][MAT_NHCOMP+offset] = new CFEM_NeoHookean_Comp(nDim, nVar_FEM, config); - numerics[MESH_0][FEA_SOL][MAT_IDEALDE+offset] = new CFEM_IdealDE(nDim, nVar_FEM, config); - numerics[MESH_0][FEA_SOL][MAT_KNOWLES+offset] = new CFEM_Knowles_NearInc(nDim, nVar_FEM, config); - } + if (!(properties_file.fail())) { + numerics[MESH_0][FEA_SOL][MAT_NHCOMP+offset] = new CFEM_NeoHookean_Comp(nDim, nVar_FEM, config); + numerics[MESH_0][FEA_SOL][MAT_IDEALDE+offset] = new CFEM_IdealDE(nDim, nVar_FEM, config); + numerics[MESH_0][FEA_SOL][MAT_KNOWLES+offset] = new CFEM_Knowles_NearInc(nDim, nVar_FEM, config); } } + } - /*--- Instantiate the numerics for the mesh solver. ---*/ - if (config->GetDeform_Mesh()) - numerics[MESH_0][MESH_SOL][fea_term] = new CFEAMeshElasticity(nDim, nDim, geometry[MESH_0]->GetnElem(), config); + /*--- Instantiate the numerics for the mesh solver. ---*/ + if (config->GetDeform_Mesh()) + numerics[MESH_0][MESH_SOL][fea_term] = new CFEAMeshElasticity(nDim, nDim, geometry[MESH_0]->GetnElem(), config); } // end SU2_OMP_PARALLEL diff --git a/SU2_CFD/src/numerics_direct_turbulent.cpp b/SU2_CFD/src/numerics_direct_turbulent.cpp index 853b5291c83a..3a2bab6fe51e 100644 --- a/SU2_CFD/src/numerics_direct_turbulent.cpp +++ b/SU2_CFD/src/numerics_direct_turbulent.cpp @@ -1105,7 +1105,8 @@ void CUpwSca_TurbSST::FinishResidualCalc(su2double *val_residual, CAvgGrad_TurbSST::CAvgGrad_TurbSST(unsigned short val_nDim, unsigned short val_nVar, - su2double *constants, bool correct_grad, + const su2double *constants, + bool correct_grad, CConfig *config) : CAvgGrad_Scalar(val_nDim, val_nVar, correct_grad, config) { @@ -1161,7 +1162,7 @@ void CAvgGrad_TurbSST::FinishResidualCalc(su2double *val_residual, su2double **J } -CSourcePieceWise_TurbSST::CSourcePieceWise_TurbSST(unsigned short val_nDim, unsigned short val_nVar, su2double *constants, +CSourcePieceWise_TurbSST::CSourcePieceWise_TurbSST(unsigned short val_nDim, unsigned short val_nVar, const su2double *constants, su2double val_kine_Inf, su2double val_omega_Inf, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { From a7722608563ed0a6084e42faf7929583dac7901d Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Thu, 23 Jan 2020 20:22:58 +0000 Subject: [PATCH 002/118] const correct MMS classes for thread safety --- .../include/toolboxes/MMS/CIncTGVSolution.hpp | 30 ++++---- .../toolboxes/MMS/CInviscidVortexSolution.hpp | 14 ++-- .../toolboxes/MMS/CMMSIncEulerSolution.hpp | 36 +++++----- .../toolboxes/MMS/CMMSIncNSSolution.hpp | 36 +++++----- .../MMS/CMMSNSTwoHalfCirclesSolution.hpp | 18 ++--- .../MMS/CMMSNSTwoHalfSpheresSolution.hpp | 20 +++--- .../toolboxes/MMS/CMMSNSUnitQuadSolution.hpp | 20 +++--- .../MMS/CMMSNSUnitQuadSolutionWallBC.hpp | 18 ++--- .../toolboxes/MMS/CNSUnitQuadSolution.hpp | 16 ++--- .../toolboxes/MMS/CRinglebSolution.hpp | 14 ++-- Common/include/toolboxes/MMS/CTGVSolution.hpp | 26 +++---- .../toolboxes/MMS/CUserDefinedSolution.hpp | 18 ++--- .../toolboxes/MMS/CVerificationSolution.hpp | 68 +++++++++++-------- .../toolboxes/MMS/CVerificationSolution.inl | 25 ------- Common/src/toolboxes/MMS/CIncTGVSolution.cpp | 50 +++++++------- .../toolboxes/MMS/CInviscidVortexSolution.cpp | 8 +-- .../toolboxes/MMS/CMMSIncEulerSolution.cpp | 44 ++++++------ .../src/toolboxes/MMS/CMMSIncNSSolution.cpp | 46 ++++++------- .../MMS/CMMSNSTwoHalfCirclesSolution.cpp | 18 ++--- .../MMS/CMMSNSTwoHalfSpheresSolution.cpp | 14 ++-- .../toolboxes/MMS/CMMSNSUnitQuadSolution.cpp | 12 ++-- .../MMS/CMMSNSUnitQuadSolutionWallBC.cpp | 14 ++-- .../src/toolboxes/MMS/CNSUnitQuadSolution.cpp | 8 +-- Common/src/toolboxes/MMS/CRinglebSolution.cpp | 8 +-- Common/src/toolboxes/MMS/CTGVSolution.cpp | 38 +++++------ .../toolboxes/MMS/CUserDefinedSolution.cpp | 14 ++-- .../toolboxes/MMS/CVerificationSolution.cpp | 38 +++++------ 27 files changed, 327 insertions(+), 344 deletions(-) delete mode 100644 Common/include/toolboxes/MMS/CVerificationSolution.inl diff --git a/Common/include/toolboxes/MMS/CIncTGVSolution.hpp b/Common/include/toolboxes/MMS/CIncTGVSolution.hpp index 2125ab45018f..0dd5c83c2ab5 100644 --- a/Common/include/toolboxes/MMS/CIncTGVSolution.hpp +++ b/Common/include/toolboxes/MMS/CIncTGVSolution.hpp @@ -7,7 +7,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -31,32 +31,32 @@ #include #include "CVerificationSolution.hpp" - + /*! * \class CIncTGVSolution * \brief Class to define the required data for the incompressible Taylor Green Vortex. * \author T. Economon, E. van der Weide */ -class CIncTGVSolution: public CVerificationSolution { - +class CIncTGVSolution final: public CVerificationSolution { + protected: - + /*--- TGV specific conditions. ---*/ - + su2double tgvLength; /*!< \brief Taylor-Green length scale. */ su2double tgvVelocity; /*!< \brief Taylor-Green velocity. */ su2double tgvDensity; /*!< \brief Taylor-Green density. */ su2double tgvViscosity; /*!< \brief Taylor-Green viscosity. */ - + su2double Temperature; /*!< \brief Temperature, just to be safe. */ - + public: - + /*! * \brief Constructor of the class. */ CIncTGVSolution(void); - + /*! * \overload * \param[in] val_nDim - Number of dimensions of the problem. @@ -68,12 +68,12 @@ class CIncTGVSolution: public CVerificationSolution { unsigned short val_nvar, unsigned short val_iMesh, CConfig* config); - + /*! * \brief Destructor of the class. */ ~CIncTGVSolution(void); - + /*! * \brief Get the exact solution at the current position and time. * \param[in] val_coords - Cartesian coordinates of the current position. @@ -82,8 +82,8 @@ class CIncTGVSolution: public CVerificationSolution { */ void GetSolution(const su2double *val_coords, const su2double val_t, - su2double *val_solution); - + su2double *val_solution) const override; + /*! * \brief Get the boundary conditions state for an exact solution. * \param[in] val_coords - Cartesian coordinates of the current position. @@ -92,5 +92,5 @@ class CIncTGVSolution: public CVerificationSolution { */ void GetBCState(const su2double *val_coords, const su2double val_t, - su2double *val_solution); + su2double *val_solution) const override; }; diff --git a/Common/include/toolboxes/MMS/CInviscidVortexSolution.hpp b/Common/include/toolboxes/MMS/CInviscidVortexSolution.hpp index d55087749fd0..a70f3a9131f7 100644 --- a/Common/include/toolboxes/MMS/CInviscidVortexSolution.hpp +++ b/Common/include/toolboxes/MMS/CInviscidVortexSolution.hpp @@ -7,7 +7,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -37,7 +37,7 @@ * \brief Class to define the required data for the Inviscid Vortex. * \author E. van der Weide, T. Economon */ -class CInviscidVortexSolution: public CVerificationSolution { +class CInviscidVortexSolution final: public CVerificationSolution { protected: @@ -56,12 +56,12 @@ class CInviscidVortexSolution: public CVerificationSolution { su2double gamOvGm1; /*!< \brief Gamma over Gamma minus 1 */ public: - + /*! * \brief Constructor of the class. */ CInviscidVortexSolution(void); - + /*! * \overload * \param[in] val_nDim - Number of dimensions of the problem. @@ -73,7 +73,7 @@ class CInviscidVortexSolution: public CVerificationSolution { unsigned short val_nvar, unsigned short val_iMesh, CConfig* config); - + /*! * \brief Destructor of the class. */ @@ -87,7 +87,7 @@ class CInviscidVortexSolution: public CVerificationSolution { */ void GetSolution(const su2double *val_coords, const su2double val_t, - su2double *val_solution); + su2double *val_solution) const override; /*! * \brief Get the boundary conditions state for an exact solution. @@ -97,5 +97,5 @@ class CInviscidVortexSolution: public CVerificationSolution { */ void GetBCState(const su2double *val_coords, const su2double val_t, - su2double *val_solution); + su2double *val_solution) const override; }; diff --git a/Common/include/toolboxes/MMS/CMMSIncEulerSolution.hpp b/Common/include/toolboxes/MMS/CMMSIncEulerSolution.hpp index 8a48963f6e2f..8353f2047820 100644 --- a/Common/include/toolboxes/MMS/CMMSIncEulerSolution.hpp +++ b/Common/include/toolboxes/MMS/CMMSIncEulerSolution.hpp @@ -7,7 +7,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -38,32 +38,32 @@ * incompressible Euler equations. * \author T. Economon, E. van der Weide */ -class CMMSIncEulerSolution: public CVerificationSolution { - +class CMMSIncEulerSolution final: public CVerificationSolution { + protected: - + /*--- Variables that define the solution and MMS source term. ---*/ su2double Density; /*!< \brief Density, must be constant. */ su2double Temperature; /*!< \brief Temperature, just to be safe. */ - + /*--- Constants, which describe this manufactured solution. This is a solution where the primitive variables vary as a combination of sine and cosine functions. The solution is from Salari K, and Knupp P, "Code verification by the method of manufactured solutions," SAND 2000-1444, Sandia National Laboratories, Albuquerque, NM, 2000. ---*/ - + su2double P_0; /*!< \brief Parameter for the pressure solution. */ su2double u_0; /*!< \brief Parameter for the x-velocity solution. */ su2double v_0; /*!< \brief Parameter for the y-velocity solution. */ su2double epsilon; /*!< \brief Parameter for the velocity solutions. */ - + public: - + /*! * \brief Constructor of the class. */ CMMSIncEulerSolution(void); - + /*! * \overload * \param[in] val_nDim - Number of dimensions of the problem. @@ -75,12 +75,12 @@ class CMMSIncEulerSolution: public CVerificationSolution { unsigned short val_nvar, unsigned short val_iMesh, CConfig* config); - + /*! * \brief Destructor of the class. */ ~CMMSIncEulerSolution(void); - + /*! * \brief Get the exact solution at the current position and time. * \param[in] val_coords - Cartesian coordinates of the current position. @@ -89,8 +89,8 @@ class CMMSIncEulerSolution: public CVerificationSolution { */ void GetSolution(const su2double *val_coords, const su2double val_t, - su2double *val_solution); - + su2double *val_solution) const override; + /*! * \brief Get the boundary conditions state for an exact solution. * \param[in] val_coords - Cartesian coordinates of the current position. @@ -99,8 +99,8 @@ class CMMSIncEulerSolution: public CVerificationSolution { */ void GetBCState(const su2double *val_coords, const su2double val_t, - su2double *val_solution); - + su2double *val_solution) const override; + /*! * \brief Get the source term for the manufactured solution (MMS). * \param[in] val_coords - Cartesian coordinates of the current position. @@ -109,11 +109,11 @@ class CMMSIncEulerSolution: public CVerificationSolution { */ void GetMMSSourceTerm(const su2double *val_coords, const su2double val_t, - su2double *val_source); - + su2double *val_source) const override; + /*! * \brief Whether or not this verification solution is a manufactured solution. * \return - True, because this is a manufactured solution. */ - bool IsManufacturedSolution(void); + bool IsManufacturedSolution(void) const override; }; diff --git a/Common/include/toolboxes/MMS/CMMSIncNSSolution.hpp b/Common/include/toolboxes/MMS/CMMSIncNSSolution.hpp index c418cc681441..249ed3cef5d7 100644 --- a/Common/include/toolboxes/MMS/CMMSIncNSSolution.hpp +++ b/Common/include/toolboxes/MMS/CMMSIncNSSolution.hpp @@ -7,7 +7,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -38,33 +38,33 @@ * laminar incompressible Navier-Stokes equations. * \author T. Economon, E. van der Weide */ -class CMMSIncNSSolution: public CVerificationSolution { - +class CMMSIncNSSolution final: public CVerificationSolution { + protected: - + /*--- Variables that define the solution and MMS source term. ---*/ su2double Viscosity; /*!< \brief Viscosity, must be constant. */ su2double Density; /*!< \brief Density, must be constant. */ su2double Temperature; /*!< \brief Temperature, just to be safe. */ - + /*--- Constants, which describe this manufactured solution. This is a viscous solution where the primitive variables vary as a combination of sine and cosine functions. The solution is from Salari K, and Knupp P, "Code verification by the method of manufactured solutions," SAND 2000-1444, Sandia National Laboratories, Albuquerque, NM, 2000. ---*/ - + su2double P_0; /*!< \brief Parameter for the pressure solution. */ su2double u_0; /*!< \brief Parameter for the x-velocity solution. */ su2double v_0; /*!< \brief Parameter for the y-velocity solution. */ su2double epsilon; /*!< \brief Parameter for the velocity solutions. */ - + public: - + /*! * \brief Constructor of the class. */ CMMSIncNSSolution(void); - + /*! * \overload * \param[in] val_nDim - Number of dimensions of the problem. @@ -76,12 +76,12 @@ class CMMSIncNSSolution: public CVerificationSolution { unsigned short val_nvar, unsigned short val_iMesh, CConfig* config); - + /*! * \brief Destructor of the class. */ ~CMMSIncNSSolution(void); - + /*! * \brief Get the exact solution at the current position and time. * \param[in] val_coords - Cartesian coordinates of the current position. @@ -90,8 +90,8 @@ class CMMSIncNSSolution: public CVerificationSolution { */ void GetSolution(const su2double *val_coords, const su2double val_t, - su2double *val_solution); - + su2double *val_solution) const override; + /*! * \brief Get the boundary conditions state for an exact solution. * \param[in] val_coords - Cartesian coordinates of the current position. @@ -100,8 +100,8 @@ class CMMSIncNSSolution: public CVerificationSolution { */ void GetBCState(const su2double *val_coords, const su2double val_t, - su2double *val_solution); - + su2double *val_solution) const override; + /*! * \brief Get the source term for the manufactured solution (MMS). * \param[in] val_coords - Cartesian coordinates of the current position. @@ -110,11 +110,11 @@ class CMMSIncNSSolution: public CVerificationSolution { */ void GetMMSSourceTerm(const su2double *val_coords, const su2double val_t, - su2double *val_source); - + su2double *val_source) const override; + /*! * \brief Whether or not this verification solution is a manufactured solution. * \return - True, because this is a manufactured solution. */ - bool IsManufacturedSolution(void); + bool IsManufacturedSolution(void) const override; }; diff --git a/Common/include/toolboxes/MMS/CMMSNSTwoHalfCirclesSolution.hpp b/Common/include/toolboxes/MMS/CMMSNSTwoHalfCirclesSolution.hpp index 9772f8d0fcf4..7a4902423ca7 100644 --- a/Common/include/toolboxes/MMS/CMMSNSTwoHalfCirclesSolution.hpp +++ b/Common/include/toolboxes/MMS/CMMSNSTwoHalfCirclesSolution.hpp @@ -7,7 +7,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -38,7 +38,7 @@ laminar Navier-Stokes equations on the domain between two half circles. * \author E. van der Weide, T. Economon */ -class CMMSNSTwoHalfCirclesSolution: public CVerificationSolution { +class CMMSNSTwoHalfCirclesSolution final: public CVerificationSolution { protected: /*--- Variables that define the solution and MMS source term. ---*/ @@ -64,12 +64,12 @@ class CMMSNSTwoHalfCirclesSolution: public CVerificationSolution { su2double a_T2; /*!< \brief Parameter for the temperature solution. */ public: - + /*! * \brief Constructor of the class. */ CMMSNSTwoHalfCirclesSolution(void); - + /*! * \overload * \param[in] val_nDim - Number of dimensions of the problem. @@ -81,7 +81,7 @@ class CMMSNSTwoHalfCirclesSolution: public CVerificationSolution { unsigned short val_nvar, unsigned short val_iMesh, CConfig* config); - + /*! * \brief Destructor of the class. */ @@ -95,7 +95,7 @@ class CMMSNSTwoHalfCirclesSolution: public CVerificationSolution { */ void GetSolution(const su2double *val_coords, const su2double val_t, - su2double *val_solution); + su2double *val_solution) const override; /*! * \brief Get the boundary conditions state for an exact solution. @@ -105,7 +105,7 @@ class CMMSNSTwoHalfCirclesSolution: public CVerificationSolution { */ void GetBCState(const su2double *val_coords, const su2double val_t, - su2double *val_solution); + su2double *val_solution) const override; /*! * \brief Get the source term for the manufactured solution (MMS). @@ -115,11 +115,11 @@ class CMMSNSTwoHalfCirclesSolution: public CVerificationSolution { */ void GetMMSSourceTerm(const su2double *val_coords, const su2double val_t, - su2double *val_source); + su2double *val_source) const override; /*! * \brief Whether or not this verification solution is a manufactured solution. * \return - True, because this is a manufactured solution. */ - bool IsManufacturedSolution(void); + bool IsManufacturedSolution(void) const override; }; diff --git a/Common/include/toolboxes/MMS/CMMSNSTwoHalfSpheresSolution.hpp b/Common/include/toolboxes/MMS/CMMSNSTwoHalfSpheresSolution.hpp index 2f04519d3a2c..ca25d28d5535 100644 --- a/Common/include/toolboxes/MMS/CMMSNSTwoHalfSpheresSolution.hpp +++ b/Common/include/toolboxes/MMS/CMMSNSTwoHalfSpheresSolution.hpp @@ -7,7 +7,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -25,7 +25,7 @@ * You should have received a copy of the GNU Lesser General Public * License along with SU2. If not, see . */ - + #pragma once @@ -38,7 +38,7 @@ laminar Navier-Stokes equations on the domain between two half spheres. * \author E. van der Weide, T. Economon */ -class CMMSNSTwoHalfSpheresSolution: public CVerificationSolution { +class CMMSNSTwoHalfSpheresSolution final: public CVerificationSolution { protected: /*--- Variables that define the solution and MMS source term. ---*/ @@ -65,12 +65,12 @@ class CMMSNSTwoHalfSpheresSolution: public CVerificationSolution { su2double a_T2; /*!< \brief Parameter for the temperature solution. */ public: - + /*! * \brief Constructor of the class. */ CMMSNSTwoHalfSpheresSolution(void); - + /*! * \overload * \param[in] val_nDim - Number of dimensions of the problem. @@ -82,7 +82,7 @@ class CMMSNSTwoHalfSpheresSolution: public CVerificationSolution { unsigned short val_nvar, unsigned short val_iMesh, CConfig* config); - + /*! * \brief Destructor of the class. */ @@ -96,7 +96,7 @@ class CMMSNSTwoHalfSpheresSolution: public CVerificationSolution { */ void GetSolution(const su2double *val_coords, const su2double val_t, - su2double *val_solution); + su2double *val_solution) const override; /*! * \brief Get the boundary conditions state for an exact solution. @@ -106,7 +106,7 @@ class CMMSNSTwoHalfSpheresSolution: public CVerificationSolution { */ void GetBCState(const su2double *val_coords, const su2double val_t, - su2double *val_solution); + su2double *val_solution) const override; /*! * \brief Get the source term for the manufactured solution (MMS). @@ -116,11 +116,11 @@ class CMMSNSTwoHalfSpheresSolution: public CVerificationSolution { */ void GetMMSSourceTerm(const su2double *val_coords, const su2double val_t, - su2double *val_source); + su2double *val_source) const override; /*! * \brief Whether or not this verification solution is a manufactured solution. * \return - True, because this is a manufactured solution. */ - bool IsManufacturedSolution(void); + bool IsManufacturedSolution(void) const override; }; diff --git a/Common/include/toolboxes/MMS/CMMSNSUnitQuadSolution.hpp b/Common/include/toolboxes/MMS/CMMSNSUnitQuadSolution.hpp index 61eaf3f8fc3c..15cb6d1deaec 100644 --- a/Common/include/toolboxes/MMS/CMMSNSUnitQuadSolution.hpp +++ b/Common/include/toolboxes/MMS/CMMSNSUnitQuadSolution.hpp @@ -7,7 +7,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -38,7 +38,7 @@ laminar Navier-Stokes equations on a unit quad. * \author E. van der Weide, T. Economon */ -class CMMSNSUnitQuadSolution: public CVerificationSolution { +class CMMSNSUnitQuadSolution final: public CVerificationSolution { protected: @@ -69,7 +69,7 @@ class CMMSNSUnitQuadSolution: public CVerificationSolution { su2double P_0; /*!< \brief Parameter for the pressure solution. */ su2double P_x; /*!< \brief Parameter for the pressure solution. */ su2double P_xy; /*!< \brief Parameter for the pressure solution. */ - su2double P_y; /*!< \brief Parameter for the pressure solution. */ + su2double P_y; /*!< \brief Parameter for the pressure solution. */ su2double rho_0; /*!< \brief Parameter for the density solution. */ su2double rho_x; /*!< \brief Parameter for the density solution. */ su2double rho_xy; /*!< \brief Parameter for the density solution. */ @@ -84,12 +84,12 @@ class CMMSNSUnitQuadSolution: public CVerificationSolution { su2double v_y; /*!< \brief Parameter for the y-velocity solution. */ public: - + /*! * \brief Constructor of the class. */ CMMSNSUnitQuadSolution(void); - + /*! * \overload * \param[in] val_nDim - Number of dimensions of the problem. @@ -101,7 +101,7 @@ class CMMSNSUnitQuadSolution: public CVerificationSolution { unsigned short val_nvar, unsigned short val_iMesh, CConfig* config); - + /*! * \brief Destructor of the class. */ @@ -115,7 +115,7 @@ class CMMSNSUnitQuadSolution: public CVerificationSolution { */ void GetSolution(const su2double *val_coords, const su2double val_t, - su2double *val_solution); + su2double *val_solution) const override; /*! * \brief Get the boundary conditions state for an exact solution. @@ -125,7 +125,7 @@ class CMMSNSUnitQuadSolution: public CVerificationSolution { */ void GetBCState(const su2double *val_coords, const su2double val_t, - su2double *val_solution); + su2double *val_solution) const override; /*! * \brief Get the source term for the manufactured solution (MMS). @@ -135,11 +135,11 @@ class CMMSNSUnitQuadSolution: public CVerificationSolution { */ void GetMMSSourceTerm(const su2double *val_coords, const su2double val_t, - su2double *val_source); + su2double *val_source) const override; /*! * \brief Whether or not this verification solution is a manufactured solution. * \return - True, because this is a manufactured solution. */ - bool IsManufacturedSolution(void); + bool IsManufacturedSolution(void) const override; }; diff --git a/Common/include/toolboxes/MMS/CMMSNSUnitQuadSolutionWallBC.hpp b/Common/include/toolboxes/MMS/CMMSNSUnitQuadSolutionWallBC.hpp index b612e502e57b..59a8ca5277d4 100644 --- a/Common/include/toolboxes/MMS/CMMSNSUnitQuadSolutionWallBC.hpp +++ b/Common/include/toolboxes/MMS/CMMSNSUnitQuadSolutionWallBC.hpp @@ -7,7 +7,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -38,7 +38,7 @@ laminar Navier-Stokes equations on a unit quad with wall boundary conditions. * \author E. van der Weide, T. Economon */ -class CMMSNSUnitQuadSolutionWallBC: public CVerificationSolution { +class CMMSNSUnitQuadSolutionWallBC final: public CVerificationSolution { protected: @@ -65,12 +65,12 @@ class CMMSNSUnitQuadSolutionWallBC: public CVerificationSolution { su2double a_T2; /*!< \brief Parameter for the temperature solution. */ public: - + /*! * \brief Constructor of the class. */ CMMSNSUnitQuadSolutionWallBC(void); - + /*! * \overload * \param[in] val_nDim - Number of dimensions of the problem. @@ -82,7 +82,7 @@ class CMMSNSUnitQuadSolutionWallBC: public CVerificationSolution { unsigned short val_nvar, unsigned short val_iMesh, CConfig* config); - + /*! * \brief Destructor of the class. */ @@ -96,7 +96,7 @@ class CMMSNSUnitQuadSolutionWallBC: public CVerificationSolution { */ void GetSolution(const su2double *val_coords, const su2double val_t, - su2double *val_solution); + su2double *val_solution) const override; /*! * \brief Get the boundary conditions state for an exact solution. @@ -106,7 +106,7 @@ class CMMSNSUnitQuadSolutionWallBC: public CVerificationSolution { */ void GetBCState(const su2double *val_coords, const su2double val_t, - su2double *val_solution); + su2double *val_solution) const override; /*! * \brief Get the source term for the manufactured solution (MMS). @@ -116,11 +116,11 @@ class CMMSNSUnitQuadSolutionWallBC: public CVerificationSolution { */ void GetMMSSourceTerm(const su2double *val_coords, const su2double val_t, - su2double *val_source); + su2double *val_source) const override; /*! * \brief Whether or not this verification solution is a manufactured solution. * \return - True, because this is a manufactured solution. */ - bool IsManufacturedSolution(void); + bool IsManufacturedSolution(void) const override; }; diff --git a/Common/include/toolboxes/MMS/CNSUnitQuadSolution.hpp b/Common/include/toolboxes/MMS/CNSUnitQuadSolution.hpp index 3160743a6144..7d6d822561b5 100644 --- a/Common/include/toolboxes/MMS/CNSUnitQuadSolution.hpp +++ b/Common/include/toolboxes/MMS/CNSUnitQuadSolution.hpp @@ -7,7 +7,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -38,7 +38,7 @@ on a unit quad, heat conduction is neglected. * \author E. van der Weide, T. Economon */ -class CNSUnitQuadSolution: public CVerificationSolution { +class CNSUnitQuadSolution final: public CVerificationSolution { protected: @@ -48,12 +48,12 @@ class CNSUnitQuadSolution: public CVerificationSolution { su2double Viscosity; /*!< \brief Viscosity, must be constant. */ public: - + /*! * \brief Constructor of the class. */ CNSUnitQuadSolution(void); - + /*! * \overload * \param[in] val_nDim - Number of dimensions of the problem. @@ -65,7 +65,7 @@ class CNSUnitQuadSolution: public CVerificationSolution { unsigned short val_nvar, unsigned short val_iMesh, CConfig* config); - + /*! * \brief Destructor of the class. */ @@ -79,8 +79,8 @@ class CNSUnitQuadSolution: public CVerificationSolution { */ void GetSolution(const su2double *val_coords, const su2double val_t, - su2double *val_solution); - + su2double *val_solution) const override; + /*! * \brief Get the boundary conditions state for an exact solution. * \param[in] val_coords - Cartesian coordinates of the current position. @@ -89,5 +89,5 @@ class CNSUnitQuadSolution: public CVerificationSolution { */ void GetBCState(const su2double *val_coords, const su2double val_t, - su2double *val_solution); + su2double *val_solution) const override; }; diff --git a/Common/include/toolboxes/MMS/CRinglebSolution.hpp b/Common/include/toolboxes/MMS/CRinglebSolution.hpp index ea59b59e9ced..abf0f6b2f910 100644 --- a/Common/include/toolboxes/MMS/CRinglebSolution.hpp +++ b/Common/include/toolboxes/MMS/CRinglebSolution.hpp @@ -7,7 +7,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -37,7 +37,7 @@ * \brief Class to define the required data for the Ringleb flow. * \author E. van der Weide, T. Economon */ -class CRinglebSolution: public CVerificationSolution { +class CRinglebSolution final: public CVerificationSolution { protected: @@ -48,12 +48,12 @@ class CRinglebSolution: public CVerificationSolution { su2double tGamOvGm1; /*!< \brief 2 Gamma over Gamma minus 1 */ public: - + /*! * \brief Constructor of the class. */ CRinglebSolution(void); - + /*! * \overload * \param[in] val_nDim - Number of dimensions of the problem. @@ -65,7 +65,7 @@ class CRinglebSolution: public CVerificationSolution { unsigned short val_nvar, unsigned short val_iMesh, CConfig* config); - + /*! * \brief Destructor of the class. */ @@ -79,7 +79,7 @@ class CRinglebSolution: public CVerificationSolution { */ void GetSolution(const su2double *val_coords, const su2double val_t, - su2double *val_solution); + su2double *val_solution) const override; /*! * \brief Get the boundary conditions state for an exact solution. @@ -89,5 +89,5 @@ class CRinglebSolution: public CVerificationSolution { */ void GetBCState(const su2double *val_coords, const su2double val_t, - su2double *val_solution); + su2double *val_solution) const override; }; diff --git a/Common/include/toolboxes/MMS/CTGVSolution.hpp b/Common/include/toolboxes/MMS/CTGVSolution.hpp index f189e014e7c1..6e5112e2b389 100644 --- a/Common/include/toolboxes/MMS/CTGVSolution.hpp +++ b/Common/include/toolboxes/MMS/CTGVSolution.hpp @@ -7,7 +7,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -37,25 +37,25 @@ * \brief Class to define the required data for the Taylor Green Vortex. * \author E. van der Weide, T. Economon */ -class CTGVSolution: public CVerificationSolution { - +class CTGVSolution final: public CVerificationSolution { + protected: - + /*--- TGV specific conditions. ---*/ - + su2double tgvLength; /*!< \brief Taylor-Green length scale. */ su2double tgvVelocity; /*!< \brief Taylor-Green velocity. */ su2double tgvDensity; /*!< \brief Taylor-Green density. */ su2double tgvPressure; /*!< \brief Taylor-Green pressure. */ su2double ovGm1; /*!< \brief 1 over Gamma minus 1 */ - + public: - + /*! * \brief Constructor of the class. */ CTGVSolution(void); - + /*! * \overload * \param[in] val_nDim - Number of dimensions of the problem. @@ -67,12 +67,12 @@ class CTGVSolution: public CVerificationSolution { unsigned short val_nvar, unsigned short val_iMesh, CConfig* config); - + /*! * \brief Destructor of the class. */ ~CTGVSolution(void); - + /*! * \brief Get the exact solution at the current position and time. * \param[in] val_coords - Cartesian coordinates of the current position. @@ -81,11 +81,11 @@ class CTGVSolution: public CVerificationSolution { */ void GetSolution(const su2double *val_coords, const su2double val_t, - su2double *val_solution); - + su2double *val_solution) const override; + /*! * \brief Whether or not the exact solution is known for this verification solution. * \return - False, because the exact solution is not known for the TGV case. */ - bool ExactSolutionKnown(void); + bool ExactSolutionKnown(void) const override; }; diff --git a/Common/include/toolboxes/MMS/CUserDefinedSolution.hpp b/Common/include/toolboxes/MMS/CUserDefinedSolution.hpp index 66a477393de6..2a0ce5a23978 100644 --- a/Common/include/toolboxes/MMS/CUserDefinedSolution.hpp +++ b/Common/include/toolboxes/MMS/CUserDefinedSolution.hpp @@ -7,7 +7,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -36,15 +36,15 @@ * \brief Class to define the required data for a user defined solution. * \author E. van der Weide, T. Economon */ -class CUserDefinedSolution: public CVerificationSolution { +class CUserDefinedSolution final: public CVerificationSolution { public: - + /*! * \brief Constructor of the class. */ CUserDefinedSolution(void); - + /*! * \overload * \param[in] val_nDim - Number of dimensions of the problem. @@ -56,7 +56,7 @@ class CUserDefinedSolution: public CVerificationSolution { unsigned short val_nvar, unsigned short val_iMesh, CConfig* config); - + /*! * \brief Destructor of the class. */ @@ -70,7 +70,7 @@ class CUserDefinedSolution: public CVerificationSolution { */ void GetSolution(const su2double *val_coords, const su2double val_t, - su2double *val_solution); + su2double *val_solution) const override; /*! * \brief Get the boundary conditions state for an exact solution. @@ -80,7 +80,7 @@ class CUserDefinedSolution: public CVerificationSolution { */ void GetBCState(const su2double *val_coords, const su2double val_t, - su2double *val_solution); + su2double *val_solution) const override; /*! * \brief Get the source term for the manufactured solution (MMS). @@ -90,11 +90,11 @@ class CUserDefinedSolution: public CVerificationSolution { */ void GetMMSSourceTerm(const su2double *val_coords, const su2double val_t, - su2double *val_source); + su2double *val_source) const override; /*! * \brief Whether or not this verification solution is a manufactured solution. * \return - True if this is a manufactured solution and false otherwise. */ - bool IsManufacturedSolution(void); + bool IsManufacturedSolution(void) const override; }; diff --git a/Common/include/toolboxes/MMS/CVerificationSolution.hpp b/Common/include/toolboxes/MMS/CVerificationSolution.hpp index 472853c69525..105f4049ac7e 100644 --- a/Common/include/toolboxes/MMS/CVerificationSolution.hpp +++ b/Common/include/toolboxes/MMS/CVerificationSolution.hpp @@ -7,7 +7,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -38,14 +38,14 @@ * \author T. Economon, E. van der Weide */ class CVerificationSolution { - + protected: int rank; /*!< \brief MPI Rank. */ int size; /*!< \brief MPI Size. */ - + unsigned short nDim; /*!< \brief Number of dimension of the problem. */ unsigned short nVar; /*!< \brief Number of variables of the problem */ - + unsigned short Kind_Solver; /*!< \brief The kind of solver we are running. */ private: @@ -54,14 +54,14 @@ class CVerificationSolution { su2double *Error_Max; /*!< \brief Vector with the global max error for each variable in a verification case. */ unsigned long *Error_Point_Max; /*!< \brief Global index for the node with the max error in a verification case. */ su2double **Error_Point_Max_Coord; /*!< \brief Coordinates for the node with the max error in a verification case. */ - + public: - + /*! * \brief Constructor of the class. */ CVerificationSolution(void); - + /*! * \overload * \param[in] val_nDim - Number of dimensions of the problem. @@ -73,7 +73,7 @@ class CVerificationSolution { unsigned short val_nvar, unsigned short val_iMesh, CConfig *config); - + /*! * \brief Destructor of the class. */ @@ -87,16 +87,16 @@ class CVerificationSolution { */ virtual void GetSolution(const su2double *val_coords, const su2double val_t, - su2double *val_solution); - + su2double *val_solution) const; + /*! * \brief Get the exact solution at the current position and t = 0. * \param[in] val_coords - Cartesian coordinates of the current position. * \param[in] val_solution - Array where the exact solution is stored. */ void GetInitialCondition(const su2double *val_coords, - su2double *val_solution); - + su2double *val_solution) const; + /*! * \brief Get the boundary conditions state for an exact solution. * \param[in] val_coords - Cartesian coordinates of the current position. @@ -105,8 +105,8 @@ class CVerificationSolution { */ virtual void GetBCState(const su2double *val_coords, const su2double val_t, - su2double *val_solution); - + su2double *val_solution) const; + /*! * \brief Get the source term for the manufactured solution (MMS). * \param[in] val_coords - Cartesian coordinates of the current position. @@ -115,22 +115,22 @@ class CVerificationSolution { */ virtual void GetMMSSourceTerm(const su2double *val_coords, const su2double val_t, - su2double *val_source); + su2double *val_source) const; /*! * \brief Whether or not this verification solution is a manufactured solution. * \return - False as default value. Overwrite this function for a manufactured solution. */ - virtual bool IsManufacturedSolution(void); + virtual bool IsManufacturedSolution(void) const; /*! * \brief Whether or not the exact solution is known for this verification solution. * \return - True as default value. Overwrite this function if the exact solution is not known. */ - virtual bool ExactSolutionKnown(void); - + virtual bool ExactSolutionKnown(void) const; + /*! * \brief Get the local error defined as the local solution minus the verification solution. * \param[in] val_coords - Cartesian coordinates of the current position. @@ -140,65 +140,75 @@ class CVerificationSolution { void GetLocalError(const su2double *val_coords, const su2double val_t, const su2double *GetLocalErrorval_solution, - su2double *val_error); + su2double *val_error) const; /*! * \brief Set the global RMS error for verification cases. * \param[in] val_var - Index of the variable. * \param[in] val_error - Value of the RMS error to store in the position val_var. */ - void SetError_RMS(unsigned short val_var, su2double val_error); + void SetError_RMS(unsigned short val_var, su2double val_error) { Error_RMS[val_var] = val_error; } /*! * \brief Increments the global RMS error for verification cases. * \param[in] val_var - Index of the variable. * \param[in] val_error - Value of the RMS error to store in the position val_var. */ - void AddError_RMS(unsigned short val_var, su2double val_error); + void AddError_RMS(unsigned short val_var, su2double val_error) { Error_RMS[val_var] += val_error; } /*! * \brief Get the global RMS error for verification cases. * \param[in] val_var - Index of the variable. * \return Value of global RMS error for the variable in the position val_var. */ - su2double GetError_RMS(unsigned short val_var); + su2double GetError_RMS(unsigned short val_var) const { return Error_RMS[val_var]; } /*! * \brief Set the global maximum error for verification cases. * \param[in] val_var - Index of the variable. * \param[in] val_error - Value of the maximum error to store in the position val_var. */ - void SetError_Max(unsigned short val_var, su2double val_error, unsigned long val_point); + void SetError_Max(unsigned short val_var, su2double val_error, unsigned long val_point) { + Error_Max[val_var] = val_error; + Error_Point_Max[val_var] = val_point; + } - /*! + /*! * \brief Increment the global maximum error for verification cases. * \param[in] val_var - Index of the variable. * \param[in] val_error - Value of the maximum error to store in the position val_var. * \param[in] val_point - Value of the point index for the max error. * \param[in] val_coord - Location (x, y, z) of the max error point. */ - void AddError_Max(unsigned short val_var, su2double val_error, unsigned long val_point, su2double* val_coord); + void AddError_Max(unsigned short val_var, su2double val_error, unsigned long val_point, const su2double* val_coord) { + if (val_error > Error_Max[val_var]) { + Error_Max[val_var] = val_error; + Error_Point_Max[val_var] = val_point; + for (unsigned short iDim = 0; iDim < nDim; iDim++) + Error_Point_Max_Coord[val_var][iDim] = val_coord[iDim]; + } + } /*! * \brief Get the global maximum error for verification cases. * \param[in] val_var - Index of the variable. * \return Value of global maximum error for the variable in the position val_var. */ - su2double GetError_Max(unsigned short val_var); + su2double GetError_Max(unsigned short val_var) const { return Error_Max[val_var]; } /*! * \brief Get the global index of the node with the max error for verification cases. * \param[in] val_var - Index of the variable. * \return Global index of the point with the max error for the variable in the position val_var. */ - unsigned long GetError_Point_Max(unsigned short val_var); + unsigned long GetError_Point_Max(unsigned short val_var) const { return Error_Point_Max[val_var]; } /*! * \brief Get the coordinates of the node with the max error for verification cases. * \param[in] val_var - Index of the variable. * \return Coordinates of the point with the max error for the variable in the position val_var. */ - su2double* GetError_Point_Max_Coord(unsigned short val_var); + const su2double* GetError_Point_Max_Coord(unsigned short val_var) const { return Error_Point_Max_Coord[val_var]; } /*! * \brief Calculate the global error metrics for verification cases. @@ -208,5 +218,3 @@ class CVerificationSolution { void SetVerificationError(unsigned long nDOFsGlobal, CConfig *config); }; - -#include "CVerificationSolution.inl" diff --git a/Common/include/toolboxes/MMS/CVerificationSolution.inl b/Common/include/toolboxes/MMS/CVerificationSolution.inl deleted file mode 100644 index ced45443d3bf..000000000000 --- a/Common/include/toolboxes/MMS/CVerificationSolution.inl +++ /dev/null @@ -1,25 +0,0 @@ -inline void CVerificationSolution::SetError_RMS(unsigned short val_var, su2double val_error) { Error_RMS[val_var] = val_error; } - -inline void CVerificationSolution::AddError_RMS(unsigned short val_var, su2double val_error) { Error_RMS[val_var] += val_error; } - -inline su2double CVerificationSolution::GetError_RMS(unsigned short val_var) { return Error_RMS[val_var]; } - -inline void CVerificationSolution::SetError_Max(unsigned short val_var, su2double val_error, unsigned long val_point) { - Error_Max[val_var] = val_error; - Error_Point_Max[val_var] = val_point; -} - -inline void CVerificationSolution::AddError_Max(unsigned short val_var, su2double val_error, unsigned long val_point, su2double* val_coord) { - if (val_error > Error_Max[val_var]) { - Error_Max[val_var] = val_error; - Error_Point_Max[val_var] = val_point; - for (unsigned short iDim = 0; iDim < nDim; iDim++) - Error_Point_Max_Coord[val_var][iDim] = val_coord[iDim]; - } -} - -inline su2double CVerificationSolution::GetError_Max(unsigned short val_var) { return Error_Max[val_var]; } - -inline unsigned long CVerificationSolution::GetError_Point_Max(unsigned short val_var) { return Error_Point_Max[val_var]; } - -inline su2double* CVerificationSolution::GetError_Point_Max_Coord(unsigned short val_var) { return Error_Point_Max_Coord[val_var]; } diff --git a/Common/src/toolboxes/MMS/CIncTGVSolution.cpp b/Common/src/toolboxes/MMS/CIncTGVSolution.cpp index 7f1aecabc799..f3fb5978d643 100644 --- a/Common/src/toolboxes/MMS/CIncTGVSolution.cpp +++ b/Common/src/toolboxes/MMS/CIncTGVSolution.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -34,62 +34,62 @@ CIncTGVSolution::CIncTGVSolution(unsigned short val_nDim, unsigned short val_iMesh, CConfig* config) : CVerificationSolution(val_nDim, val_nVar, val_iMesh, config) { - + /*--- Disable this solution for now, as it has not been tested. ---*/ - + SU2_MPI::Error("CIncTGVSolution not yet fully implemented/tested.", CURRENT_FUNCTION); - + /*--- Write a message that the solution is initialized for the Taylor-Green vortex test case. ---*/ - + if ((rank == MASTER_NODE) && (val_iMesh == MESH_0)) { cout << endl; cout << "Warning: Fluid properties and solution are being " << endl; cout << " initialized for the incompressible Taylor-Green vortex case!!!" << endl; cout << endl << flush; } - + /*--- Store TGV specific parameters here. ---*/ - + tgvLength = 1.0; tgvVelocity = 1.0; tgvDensity = config->GetDensity_FreeStreamND(); tgvViscosity = config->GetViscosity_FreeStreamND(); - + /*--- We keep a copy of the freestream temperature just to be safe when we set the solution, even though this is an isothermal case. ---*/ - + Temperature = config->GetTemperature_FreeStreamND(); - + /*--- Perform some sanity and error checks for this solution here. ---*/ - + if((config->GetTime_Marching() != TIME_STEPPING) && (config->GetTime_Marching() != DT_STEPPING_1ST) && (config->GetTime_Marching() != DT_STEPPING_2ND)) SU2_MPI::Error("Unsteady mode must be selected for the incompressible Taylor Green Vortex", CURRENT_FUNCTION); - + if(Kind_Solver != INC_EULER && Kind_Solver != INC_NAVIER_STOKES && Kind_Solver != INC_RANS ) SU2_MPI::Error("Incompressible flow equations must be selected for the incompressible Taylor Green Vortex", CURRENT_FUNCTION); - + if(Kind_Solver != INC_NAVIER_STOKES) SU2_MPI::Error("Navier Stokes equations must be selected for the incompressible Taylor Green Vortex", CURRENT_FUNCTION); - + if(config->GetKind_FluidModel() != CONSTANT_DENSITY) SU2_MPI::Error("Constant density fluid model must be selected for the incompressible Taylor Green Vortex", CURRENT_FUNCTION); - + if(config->GetKind_ViscosityModel() != CONSTANT_VISCOSITY) SU2_MPI::Error("Constant viscosity must be selected for the incompressible Taylor Green Vortex", CURRENT_FUNCTION); - + if(config->GetEnergy_Equation()) SU2_MPI::Error("Energy equation must be disabled (isothermal) for the incompressible Taylor Green Vortex", CURRENT_FUNCTION); - + if(nDim != 2) SU2_MPI::Error("2D calculation required for the incompressible Taylor Green Vortex", CURRENT_FUNCTION); @@ -99,34 +99,34 @@ CIncTGVSolution::~CIncTGVSolution(void) { } void CIncTGVSolution::GetBCState(const su2double *val_coords, const su2double val_t, - su2double *val_solution) { - + su2double *val_solution) const { + /*--- The exact solution is prescribed on the boundaries. ---*/ GetSolution(val_coords, val_t, val_solution); } void CIncTGVSolution::GetSolution(const su2double *val_coords, const su2double val_t, - su2double *val_solution) { - + su2double *val_solution) const { + /* The exact solution is set for the incompressible Taylor-Green vortex case. This is the classic solution from the original work of Taylor and Green for the specific 2D situation where the exact solution can be derived for an incompressible flow. */ - + /* Store the termporal term more easily (Taylor expansion). */ su2double F = 1.0 - 2.0*(tgvViscosity/tgvDensity)*val_t; - + /* Compute the primitive variables. */ su2double u = tgvVelocity * F * (sin(val_coords[0]/tgvLength)* cos(val_coords[1]/tgvLength)); su2double v = -tgvVelocity * F * (cos(val_coords[0]/tgvLength)* sin(val_coords[1]/tgvLength)); - + su2double B = (cos(2.0*val_coords[0]/tgvLength) + cos(2.0*val_coords[1]/tgvLength)); su2double p = -(tgvDensity/4.0)*B*F*F; - + /* Compute the conservative variables. Note that both 2D and 3D cases are treated correctly. */ val_solution[0] = p; diff --git a/Common/src/toolboxes/MMS/CInviscidVortexSolution.cpp b/Common/src/toolboxes/MMS/CInviscidVortexSolution.cpp index 193fd1278168..6ddc7ea3081f 100644 --- a/Common/src/toolboxes/MMS/CInviscidVortexSolution.cpp +++ b/Common/src/toolboxes/MMS/CInviscidVortexSolution.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -34,7 +34,7 @@ CInviscidVortexSolution::CInviscidVortexSolution(unsigned short val_nDim, unsigned short val_iMesh, CConfig* config) : CVerificationSolution(val_nDim, val_nVar, val_iMesh, config) { - + /*--- Write a message that the solution is initialized for the inviscid vortex test case. ---*/ if ((rank == MASTER_NODE) && (val_iMesh == MESH_0)) { @@ -96,7 +96,7 @@ CInviscidVortexSolution::~CInviscidVortexSolution(void) { } void CInviscidVortexSolution::GetBCState(const su2double *val_coords, const su2double val_t, - su2double *val_solution) { + su2double *val_solution) const { /*--- For the case that the inviscid vortex is run with boundary conditions (other possibility is with periodic conditions), @@ -106,7 +106,7 @@ void CInviscidVortexSolution::GetBCState(const su2double *val_coords, void CInviscidVortexSolution::GetSolution(const su2double *val_coords, const su2double val_t, - su2double *val_solution) { + su2double *val_solution) const { /* Compute the free stream velocities in x- and y-direction. */ const su2double VelInf = MachVortex*sqrt(Gamma); diff --git a/Common/src/toolboxes/MMS/CMMSIncEulerSolution.cpp b/Common/src/toolboxes/MMS/CMMSIncEulerSolution.cpp index 6274fbb4bd72..b24c85d2a20c 100644 --- a/Common/src/toolboxes/MMS/CMMSIncEulerSolution.cpp +++ b/Common/src/toolboxes/MMS/CMMSIncEulerSolution.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -34,7 +34,7 @@ CMMSIncEulerSolution::CMMSIncEulerSolution(unsigned short val_nDim, unsigned short val_iMesh, CConfig* config) : CVerificationSolution(val_nDim, val_nVar, val_iMesh, config) { - + /*--- Write a message that the solution is initialized for the manufactured solution for the incompressible Navier-Stokes equations. ---*/ if ((rank == MASTER_NODE) && (val_iMesh == MESH_0)) { @@ -44,39 +44,39 @@ CMMSIncEulerSolution::CMMSIncEulerSolution(unsigned short val_nDim, cout << " of the incompressible Euler equations!!!" << endl; cout << endl << flush; } - + /*--- Coefficients, needed to determine the solution. ---*/ Density = config->GetDensity_FreeStreamND(); Temperature = config->GetTemperature_FreeStreamND(); - + /*--- Constants, which describe this manufactured solution. This is a solution where the primitive variables vary as a combination of sine and cosine functions. The solution is from Salari K, and Knupp P, "Code verification by the method of manufactured solutions," SAND 2000-1444, Sandia National Laboratories, Albuquerque, NM, 2000. ---*/ - + P_0 = 1.0; u_0 = 1.0; v_0 = 1.0; epsilon = 0.001; - + /*--- Perform some sanity and error checks for this solution here. ---*/ if(config->GetTime_Marching() != STEADY) SU2_MPI::Error("Steady mode must be selected for the MMS incompressible Euler case", CURRENT_FUNCTION); - + if(Kind_Solver != INC_EULER && Kind_Solver != INC_NAVIER_STOKES && Kind_Solver != INC_RANS ) SU2_MPI::Error("Incompressible flow equations must be selected for the MMS incompressible Euler case", CURRENT_FUNCTION); - + if(Kind_Solver != INC_EULER) SU2_MPI::Error("Euler equations must be selected for the MMS incompressible Euler case", CURRENT_FUNCTION); - + if(config->GetKind_FluidModel() != CONSTANT_DENSITY) SU2_MPI::Error("Constant density fluid model must be selected for the MMS incompressible Euler case", CURRENT_FUNCTION); - + if(config->GetEnergy_Equation()) SU2_MPI::Error("Energy equation must be disabled (isothermal) for the MMS incompressible Euler case", CURRENT_FUNCTION); @@ -86,25 +86,25 @@ CMMSIncEulerSolution::~CMMSIncEulerSolution(void) { } void CMMSIncEulerSolution::GetBCState(const su2double *val_coords, const su2double val_t, - su2double *val_solution) { - + su2double *val_solution) const { + /*--- The exact solution is prescribed on the boundaries. ---*/ GetSolution(val_coords, val_t, val_solution); } void CMMSIncEulerSolution::GetSolution(const su2double *val_coords, const su2double val_t, - su2double *val_solution) { - + su2double *val_solution) const { + /* Easier storage of the x- and y-coordinates. */ const su2double x = val_coords[0]; const su2double y = val_coords[1]; - + /* Compute the primitives from the defined solution. */ const su2double u = u_0*(sin(x*x + y*y) + epsilon); const su2double v = v_0*(cos(x*x + y*y) + epsilon); const su2double p = P_0*(sin(x*x + y*y) + 2.0); - + /* For the incompressible solver, we return the primitive variables directly, as they are used for the working variables in the solver. Note that the implementation below is valid for both 2D and 3D. */ @@ -113,17 +113,17 @@ void CMMSIncEulerSolution::GetSolution(const su2double *val_coords, val_solution[2] = v; val_solution[3] = 0.0; val_solution[nVar-1] = Temperature; - + } void CMMSIncEulerSolution::GetMMSSourceTerm(const su2double *val_coords, const su2double val_t, - su2double *val_source) { - + su2double *val_source) const { + /*--- Easier storage of the x- and y-coordinates. ---*/ const su2double x = val_coords[0]; const su2double y = val_coords[1]; - + /*--- The expressions for the source terms are generated automatically by the sympy package in python.---*/ val_source[0] = 2*Density*(u_0*x*cos(pow(x, 2) + pow(y, 2)) - v_0*y*sin(pow(x, 2) + pow(y, 2))); @@ -131,9 +131,9 @@ void CMMSIncEulerSolution::GetMMSSourceTerm(const su2double *val_coords, val_source[2] = -2*Density*u_0*v_0*x*(epsilon + sin(pow(x, 2) + pow(y, 2)))*sin(pow(x, 2) + pow(y, 2)) + 2*Density*u_0*v_0*x*(epsilon + cos(pow(x, 2) + pow(y, 2)))*cos(pow(x, 2) + pow(y, 2)) - 4*Density*pow(v_0, 2)*y*(epsilon + cos(pow(x, 2) + pow(y, 2)))*sin(pow(x, 2) + pow(y, 2)) + 2*P_0*y*cos(pow(x, 2) + pow(y, 2)); val_source[3] = 0.0; val_source[nVar-1] = 0.0; - + } -bool CMMSIncEulerSolution::IsManufacturedSolution(void) { +bool CMMSIncEulerSolution::IsManufacturedSolution(void) const { return true; } diff --git a/Common/src/toolboxes/MMS/CMMSIncNSSolution.cpp b/Common/src/toolboxes/MMS/CMMSIncNSSolution.cpp index 5a9fd5bbbb97..2cf0e832120f 100644 --- a/Common/src/toolboxes/MMS/CMMSIncNSSolution.cpp +++ b/Common/src/toolboxes/MMS/CMMSIncNSSolution.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -34,7 +34,7 @@ CMMSIncNSSolution::CMMSIncNSSolution(unsigned short val_nDim, unsigned short val_iMesh, CConfig* config) : CVerificationSolution(val_nDim, val_nVar, val_iMesh, config) { - + /*--- Write a message that the solution is initialized for the manufactured solution for the incompressible Navier-Stokes equations. ---*/ if ((rank == MASTER_NODE) && (val_iMesh == MESH_0)) { @@ -44,44 +44,44 @@ CMMSIncNSSolution::CMMSIncNSSolution(unsigned short val_nDim, cout << " of the incompressible Navier-Stokes equations!!!" << endl; cout << endl << flush; } - + /*--- Coefficients, needed to determine the solution. ---*/ Viscosity = config->GetViscosity_FreeStreamND(); Density = config->GetDensity_FreeStreamND(); Temperature = config->GetTemperature_FreeStreamND(); - + /*--- Constants, which describe this manufactured solution. This is a viscous solution where the primitive variables vary as a combination of sine and cosine functions. The solution is from Salari K, and Knupp P, "Code verification by the method of manufactured solutions," SAND 2000-1444, Sandia National Laboratories, Albuquerque, NM, 2000. ---*/ - + P_0 = 1.0; u_0 = 1.0; v_0 = 1.0; epsilon = 0.001; - + /*--- Perform some sanity and error checks for this solution here. ---*/ if(config->GetTime_Marching() != STEADY) SU2_MPI::Error("Steady mode must be selected for the MMS incompressible NS case", CURRENT_FUNCTION); - + if(Kind_Solver != INC_EULER && Kind_Solver != INC_NAVIER_STOKES && Kind_Solver != INC_RANS ) SU2_MPI::Error("Incompressible flow equations must be selected for the MMS incompressible NS case", CURRENT_FUNCTION); - + if(Kind_Solver != INC_NAVIER_STOKES) SU2_MPI::Error("Navier Stokes equations must be selected for the MMS incompressible NS case", CURRENT_FUNCTION); - + if(config->GetKind_FluidModel() != CONSTANT_DENSITY) SU2_MPI::Error("Constant density fluid model must be selected for the MMS incompressible NS case", CURRENT_FUNCTION); - + if(config->GetKind_ViscosityModel() != CONSTANT_VISCOSITY) SU2_MPI::Error("Constant viscosity must be selected for the MMS incompressible NS case", CURRENT_FUNCTION); - + if(config->GetEnergy_Equation()) SU2_MPI::Error("Energy equation must be disabled (isothermal) for the MMS incompressible NS case", CURRENT_FUNCTION); @@ -91,25 +91,25 @@ CMMSIncNSSolution::~CMMSIncNSSolution(void) { } void CMMSIncNSSolution::GetBCState(const su2double *val_coords, const su2double val_t, - su2double *val_solution) { - + su2double *val_solution) const { + /*--- The exact solution is prescribed on the boundaries. ---*/ GetSolution(val_coords, val_t, val_solution); } void CMMSIncNSSolution::GetSolution(const su2double *val_coords, const su2double val_t, - su2double *val_solution) { - + su2double *val_solution) const { + /* Easier storage of the x- and y-coordinates. */ const su2double x = val_coords[0]; const su2double y = val_coords[1]; - + /* Compute the primitives from the defined solution. */ const su2double u = u_0*(sin(x*x + y*y) + epsilon); const su2double v = v_0*(cos(x*x + y*y) + epsilon); const su2double p = P_0*(sin(x*x + y*y) + 2.0); - + /* For the incompressible solver, we return the primitive variables directly, as they are used for the working variables in the solver. Note that the implementation below is valid for both 2D and 3D. */ @@ -118,17 +118,17 @@ void CMMSIncNSSolution::GetSolution(const su2double *val_coords, val_solution[2] = v; val_solution[3] = 0.0; val_solution[nVar-1] = Temperature; - + } void CMMSIncNSSolution::GetMMSSourceTerm(const su2double *val_coords, const su2double val_t, - su2double *val_source) { - + su2double *val_source) const { + /*--- Easier storage of the x- and y-coordinates. ---*/ const su2double x = val_coords[0]; const su2double y = val_coords[1]; - + /*--- The expressions for the source terms are generated automatically by the sympy package in python.---*/ val_source[0] = 2*Density*(u_0*x*cos(pow(x, 2) + pow(y, 2)) - v_0*y*sin(pow(x, 2) + pow(y, 2))); @@ -136,9 +136,9 @@ void CMMSIncNSSolution::GetMMSSourceTerm(const su2double *val_coords, val_source[2] = -2*Density*u_0*v_0*x*(epsilon + sin(pow(x, 2) + pow(y, 2)))*sin(pow(x, 2) + pow(y, 2)) + 2*Density*u_0*v_0*x*(epsilon + cos(pow(x, 2) + pow(y, 2)))*cos(pow(x, 2) + pow(y, 2)) - 4*Density*pow(v_0, 2)*y*(epsilon + cos(pow(x, 2) + pow(y, 2)))*sin(pow(x, 2) + pow(y, 2)) + 2*P_0*y*cos(pow(x, 2) + pow(y, 2)) + 0.666666666666667*Viscosity*(-4*u_0*x*y*sin(pow(x, 2) + pow(y, 2)) + 8.0*v_0*pow(y, 2)*cos(pow(x, 2) + pow(y, 2)) + 4.0*v_0*sin(pow(x, 2) + pow(y, 2))) + 2*Viscosity*(2*u_0*x*y*sin(pow(x, 2) + pow(y, 2)) + 2*v_0*pow(x, 2)*cos(pow(x, 2) + pow(y, 2)) + v_0*sin(pow(x, 2) + pow(y, 2))); val_source[3] = 0.0; val_source[nVar-1] = 0.0; - + } -bool CMMSIncNSSolution::IsManufacturedSolution(void) { +bool CMMSIncNSSolution::IsManufacturedSolution(void) const { return true; } diff --git a/Common/src/toolboxes/MMS/CMMSNSTwoHalfCirclesSolution.cpp b/Common/src/toolboxes/MMS/CMMSNSTwoHalfCirclesSolution.cpp index b53080cfbcae..200da0076ce4 100644 --- a/Common/src/toolboxes/MMS/CMMSNSTwoHalfCirclesSolution.cpp +++ b/Common/src/toolboxes/MMS/CMMSNSTwoHalfCirclesSolution.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -34,7 +34,7 @@ CMMSNSTwoHalfCirclesSolution::CMMSNSTwoHalfCirclesSolution(unsigned short val_nD unsigned short val_iMesh, CConfig* config) : CVerificationSolution(val_nDim, val_nVar, val_iMesh, config) { - + /*--- Write a message that the solution is initialized for the manufactured solution for the Navier-Stokes equations between two half circles. ---*/ if ((rank == MASTER_NODE) && (val_iMesh == MESH_0)) { @@ -111,7 +111,7 @@ CMMSNSTwoHalfCirclesSolution::~CMMSNSTwoHalfCirclesSolution(void) { } void CMMSNSTwoHalfCirclesSolution::GetBCState(const su2double *val_coords, const su2double val_t, - su2double *val_solution) { + su2double *val_solution) const { /*--- The exact solution is prescribed on the boundaries. ---*/ GetSolution(val_coords, val_t, val_solution); @@ -119,7 +119,7 @@ void CMMSNSTwoHalfCirclesSolution::GetBCState(const su2double *val_coords, void CMMSNSTwoHalfCirclesSolution::GetSolution(const su2double *val_coords, const su2double val_t, - su2double *val_solution) { + su2double *val_solution) const { /* Easier storage of the x- and y-coordinates. */ const su2double x = val_coords[0]; @@ -158,7 +158,7 @@ void CMMSNSTwoHalfCirclesSolution::GetSolution(const su2double *val_coords, void CMMSNSTwoHalfCirclesSolution::GetMMSSourceTerm(const su2double *val_coords, const su2double val_t, - su2double *val_source) { + su2double *val_source) const { /*--- Abbreviate Pi and the coordinates. ---*/ const su2double Pi = PI_NUMBER; @@ -264,7 +264,7 @@ void CMMSNSTwoHalfCirclesSolution::GetMMSSourceTerm(const su2double *val_coords, const su2double t261 = t248 * t246 * t34 / 0.4e1 + 0.8e1 * (t25 * t252 + t25 * t254) * rho_0 + t246 * t34 / 0.4e1; const su2double t262 = v_0 * t261; const su2double t267 = -0.4e1 * t193 * t2 * TWall * t65 - 0.4e1 * t193 * TWall * t65 * t3 - 0.8e1 * t193 * t201 - + 0.64e2 / 0.3e1 * t8 * t12 * t22 * t76 - 0.4e1 * t9 * t213 + 0.4e1 * t13 * t213 + + 0.64e2 / 0.3e1 * t8 * t12 * t22 * t76 - 0.4e1 * t9 * t213 + 0.4e1 * t13 * t213 - 0.4e1 * t17 * t218 + 0.4e1 * t19 * t218 + 0.128e3 / 0.3e1 * t8 * t11 * Viscosity * t6 * t161 * t138 + 0.64e2 / 0.3e1 * t231 * t230 * t173 * t172 - 0.32e2 / 0.3e1 * t237 * t236 * t82 * t76 - 0.4e1 * t8 * t236 * t113 - 0.4e1 * t19 * t262 + 0.4e1 * t17 * t262; @@ -292,7 +292,7 @@ void CMMSNSTwoHalfCirclesSolution::GetMMSSourceTerm(const su2double *val_coords, + t11 * a_T2 * x * t285 - Pi * t7 * t183 - 0.2e1 * a_T2 * t51 * x * t292 - t53 / 0.2e1) * t201 + 0.4e1 * t300 * t2 * t190 * t11 * TWall * t81 + 0.64e2 / 0.3e1 * t317 * u_0 * t70 * x * t66 - 0.32e2 / 0.3e1 * x * t11 * t311 * t310 + 0.4e1 * t317 * u_0 * (t248 * t62 * t34 / 0.4e1 - + 0.16e2 * (-t9 * t252 - t9 * t254 + t27 * t364 + t27 * t367) * rho_0 + t64) + + 0.16e2 * (-t9 * t252 - t9 * t254 + t27 * t364 + t27 * t367) * rho_0 + t64) + 0.4e1 * t317 * v_0 * (t248 * t158 * t34 / 0.4e1 + 0.16e2 * (t141 * t364 + t141 * t367 - t17 * t252 - t17 * t254) * rho_0 + t160); @@ -300,7 +300,7 @@ void CMMSNSTwoHalfCirclesSolution::GetMMSSourceTerm(const su2double *val_coords, Note the scaling for the correct non-dimensionalization. ---*/ val_source[0] = -0.4e1 * t13 * t1 + 0.4e1 * t9 * t1 + 0.4e1 * t17 * t15 - 0.4e1 * t19 * t15; val_source[1] = 0.32e2 * t27 * t11 * t23 - 0.32e2 * t9 * t30 * t23 + t64 + 0.16e2 / 0.3e1 * t70 * x * t66 - + 0.16e2 / 0.3e1 * t6 * u_0 * t76 - 0.8e1 / 0.3e1 * x * t82 * t76 + 0.32e2 * t16 * t87 * t86 + + 0.16e2 / 0.3e1 * t6 * u_0 * t76 - 0.8e1 / 0.3e1 * x * t82 * t76 + 0.32e2 * t16 * t87 * t86 - 0.32e2 * t16 * t92 * t91 - t113; val_source[2] = 0.32e2 * t7 * t87 * t86 - 0.32e2 * t7 * t92 * t91 - t137 + 0.32e2 * t141 * t11 * t139 - 0.32e2 * t17 * t30 * t139 + t160 + 0.32e2 / 0.3e1 * Viscosity * t6 * t161 * v_0 @@ -314,6 +314,6 @@ void CMMSNSTwoHalfCirclesSolution::GetMMSSourceTerm(const su2double *val_coords, val_source[nDim+1] /= Velocity_Ref*Pressure_Ref; } -bool CMMSNSTwoHalfCirclesSolution::IsManufacturedSolution(void) { +bool CMMSNSTwoHalfCirclesSolution::IsManufacturedSolution(void) const { return true; } diff --git a/Common/src/toolboxes/MMS/CMMSNSTwoHalfSpheresSolution.cpp b/Common/src/toolboxes/MMS/CMMSNSTwoHalfSpheresSolution.cpp index bd99cfe593df..bb317504e144 100644 --- a/Common/src/toolboxes/MMS/CMMSNSTwoHalfSpheresSolution.cpp +++ b/Common/src/toolboxes/MMS/CMMSNSTwoHalfSpheresSolution.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -34,7 +34,7 @@ CMMSNSTwoHalfSpheresSolution::CMMSNSTwoHalfSpheresSolution(unsigned short val_nD unsigned short val_iMesh, CConfig* config) : CVerificationSolution(val_nDim, val_nVar, val_iMesh, config) { - + /*--- Write a message that the solution is initialized for the manufactured solution for the Navier-Stokes equations between two half spheres. ---*/ if ((rank == MASTER_NODE) && (val_iMesh == MESH_0)) { @@ -117,7 +117,7 @@ CMMSNSTwoHalfSpheresSolution::~CMMSNSTwoHalfSpheresSolution(void) { } void CMMSNSTwoHalfSpheresSolution::GetBCState(const su2double *val_coords, const su2double val_t, - su2double *val_solution) { + su2double *val_solution) const { /*--- The exact solution is prescribed on the boundaries. ---*/ GetSolution(val_coords, val_t, val_solution); @@ -125,7 +125,7 @@ void CMMSNSTwoHalfSpheresSolution::GetBCState(const su2double *val_coords, void CMMSNSTwoHalfSpheresSolution::GetSolution(const su2double *val_coords, const su2double val_t, - su2double *val_solution) { + su2double *val_solution) const { /* Easier storage of the x-, y- and z-coordinates. */ const su2double x = val_coords[0]; @@ -166,7 +166,7 @@ void CMMSNSTwoHalfSpheresSolution::GetSolution(const su2double *val_coords, void CMMSNSTwoHalfSpheresSolution::GetMMSSourceTerm(const su2double *val_coords, const su2double val_t, - su2double *val_source) { + su2double *val_source) const { /*--- Abbreviate Pi and the coordinates. ---*/ const su2double Pi = PI_NUMBER; @@ -370,7 +370,7 @@ void CMMSNSTwoHalfSpheresSolution::GetMMSSourceTerm(const su2double *val_coords, const su2double t616 = 0.4e1 * t18 * t528 - 0.4e1 * t20 * t528 + 0.4e1 * t24 * t533 - 0.4e1 * t26 * t533 + 0.12e2 * t541 * t12 * t7 * t410 + 0.320e3 / 0.3e1 * t545 * t155 * t112 + 0.320e3 / 0.3e1 * t545 * Viscosity * t111 * t231 + 0.64e2 * t545 * t29 * t112 - + 0.64e2 / 0.3e1 * t545 * t29 * t84 + 0.4e1 * t541 * t2 * t558 + 0.4e1 * t541 * t3 * t558 + + 0.64e2 / 0.3e1 * t545 * t29 * t84 + 0.4e1 * t541 * t2 * t558 + 0.4e1 * t541 * t3 * t558 + 0.4e1 * t541 * t72 * t486 + 0.4e1 * t305 * u_0 * (t508 * t70 * t41 + 0.16e2 * (-t10 * t511 - t10 * t513 - t10 * t515 + t34 * t570 + t34 * t573 + t34 * t576) * rho_0 + t71) + 0.4e1 * t305 * v_0 * (t508 * t176 * t41 + 0.16e2 * (t158 * t570 + t158 * t573 + t158 * t576 @@ -391,6 +391,6 @@ void CMMSNSTwoHalfSpheresSolution::GetMMSSourceTerm(const su2double *val_coords, val_source[4] /= Velocity_Ref*Pressure_Ref; } -bool CMMSNSTwoHalfSpheresSolution::IsManufacturedSolution(void) { +bool CMMSNSTwoHalfSpheresSolution::IsManufacturedSolution(void) const { return true; } diff --git a/Common/src/toolboxes/MMS/CMMSNSUnitQuadSolution.cpp b/Common/src/toolboxes/MMS/CMMSNSUnitQuadSolution.cpp index 83a24cfd2858..ba3500904064 100644 --- a/Common/src/toolboxes/MMS/CMMSNSUnitQuadSolution.cpp +++ b/Common/src/toolboxes/MMS/CMMSNSUnitQuadSolution.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -34,7 +34,7 @@ CMMSNSUnitQuadSolution::CMMSNSUnitQuadSolution(unsigned short val_nDim, unsigned short val_iMesh, CConfig* config) : CVerificationSolution(val_nDim, val_nVar, val_iMesh, config) { - + /*--- Write a message that the solution is initialized for the manufactured solution for the Navier-Stokes equations on a unit quad. ---*/ if ((rank == MASTER_NODE) && (val_iMesh == MESH_0)) { @@ -120,7 +120,7 @@ CMMSNSUnitQuadSolution::~CMMSNSUnitQuadSolution(void) { } void CMMSNSUnitQuadSolution::GetBCState(const su2double *val_coords, const su2double val_t, - su2double *val_solution) { + su2double *val_solution) const { /*--- The exact solution is prescribed on the boundaries. ---*/ GetSolution(val_coords, val_t, val_solution); @@ -128,7 +128,7 @@ void CMMSNSUnitQuadSolution::GetBCState(const su2double *val_coords, void CMMSNSUnitQuadSolution::GetSolution(const su2double *val_coords, const su2double val_t, - su2double *val_solution) { + su2double *val_solution) const { /* Easier storage of the x- and y-coordinates. */ const su2double x = val_coords[0]; @@ -167,7 +167,7 @@ void CMMSNSUnitQuadSolution::GetSolution(const su2double *val_coords, void CMMSNSUnitQuadSolution::GetMMSSourceTerm(const su2double *val_coords, const su2double val_t, - su2double *val_source) { + su2double *val_source) const { /*--- The source code for the source terms is generated in Maple. See the file CMMSNSUnitQuadSolution.mw in the directory @@ -378,6 +378,6 @@ void CMMSNSUnitQuadSolution::GetMMSSourceTerm(const su2double *val_coords, val_source[nDim+1] = t564 + t565 + t566 + t567; } -bool CMMSNSUnitQuadSolution::IsManufacturedSolution(void) { +bool CMMSNSUnitQuadSolution::IsManufacturedSolution(void) const { return true; } diff --git a/Common/src/toolboxes/MMS/CMMSNSUnitQuadSolutionWallBC.cpp b/Common/src/toolboxes/MMS/CMMSNSUnitQuadSolutionWallBC.cpp index 665e4fa8d2dd..eb1969d2f816 100644 --- a/Common/src/toolboxes/MMS/CMMSNSUnitQuadSolutionWallBC.cpp +++ b/Common/src/toolboxes/MMS/CMMSNSUnitQuadSolutionWallBC.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -26,7 +26,7 @@ */ #include "../../../include/toolboxes/MMS/CMMSNSUnitQuadSolutionWallBC.hpp" - + CMMSNSUnitQuadSolutionWallBC::CMMSNSUnitQuadSolutionWallBC(void) : CVerificationSolution() { } CMMSNSUnitQuadSolutionWallBC::CMMSNSUnitQuadSolutionWallBC(unsigned short val_nDim, @@ -34,7 +34,7 @@ CMMSNSUnitQuadSolutionWallBC::CMMSNSUnitQuadSolutionWallBC(unsigned short val_nD unsigned short val_iMesh, CConfig* config) : CVerificationSolution(val_nDim, val_nVar, val_iMesh, config) { - + /*--- Write a message that the solution is initialized for the manufactured solution for the Navier-Stokes equations on a unit quad with no-slip wall boundary conditions. ---*/ @@ -114,7 +114,7 @@ CMMSNSUnitQuadSolutionWallBC::~CMMSNSUnitQuadSolutionWallBC(void) { } void CMMSNSUnitQuadSolutionWallBC::GetBCState(const su2double *val_coords, const su2double val_t, - su2double *val_solution) { + su2double *val_solution) const { /*--- The exact solution is prescribed on the boundaries. ---*/ GetSolution(val_coords, val_t, val_solution); @@ -122,7 +122,7 @@ void CMMSNSUnitQuadSolutionWallBC::GetBCState(const su2double *val_coords, void CMMSNSUnitQuadSolutionWallBC::GetSolution(const su2double *val_coords, const su2double val_t, - su2double *val_solution) { + su2double *val_solution) const { /* Easier storage of the y-coordinate. */ const su2double y = val_coords[1]; @@ -158,7 +158,7 @@ void CMMSNSUnitQuadSolutionWallBC::GetSolution(const su2double *val_coords, void CMMSNSUnitQuadSolutionWallBC::GetMMSSourceTerm(const su2double *val_coords, const su2double val_t, - su2double *val_source) { + su2double *val_source) const { /*--- Abbreviate Pi and the y-coordinate. ---*/ const su2double Pi = PI_NUMBER; @@ -231,6 +231,6 @@ void CMMSNSUnitQuadSolutionWallBC::GetMMSSourceTerm(const su2double *val_coords, val_source[nDim+1] /= Velocity_Ref*Pressure_Ref; } -bool CMMSNSUnitQuadSolutionWallBC::IsManufacturedSolution(void) { +bool CMMSNSUnitQuadSolutionWallBC::IsManufacturedSolution(void) const { return true; } diff --git a/Common/src/toolboxes/MMS/CNSUnitQuadSolution.cpp b/Common/src/toolboxes/MMS/CNSUnitQuadSolution.cpp index f1f3233bd6e8..b690f5a0ec1b 100644 --- a/Common/src/toolboxes/MMS/CNSUnitQuadSolution.cpp +++ b/Common/src/toolboxes/MMS/CNSUnitQuadSolution.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -38,7 +38,7 @@ CNSUnitQuadSolution::CNSUnitQuadSolution(unsigned short val_nDim, /*--- Write a message that the solution is initialized for the Navier-Stokes case on a unit quad. Note that heat conduction is neglected for this case. ---*/ - + if ((rank == MASTER_NODE) && (val_iMesh == MESH_0)) { cout << endl; cout << "Warning: Fluid properties and solution are being " << endl; @@ -94,7 +94,7 @@ CNSUnitQuadSolution::~CNSUnitQuadSolution(void) { } void CNSUnitQuadSolution::GetBCState(const su2double *val_coords, const su2double val_t, - su2double *val_solution) { + su2double *val_solution) const { /*--- The exact solution is prescribed on the boundaries. ---*/ GetSolution(val_coords, val_t, val_solution); @@ -102,7 +102,7 @@ void CNSUnitQuadSolution::GetBCState(const su2double *val_coords, void CNSUnitQuadSolution::GetSolution(const su2double *val_coords, const su2double val_t, - su2double *val_solution) { + su2double *val_solution) const { /*--- Compute the flow direction and the coordinates in the rotated frame. ---*/ diff --git a/Common/src/toolboxes/MMS/CRinglebSolution.cpp b/Common/src/toolboxes/MMS/CRinglebSolution.cpp index fc2cdab32988..0305ba6b9e01 100644 --- a/Common/src/toolboxes/MMS/CRinglebSolution.cpp +++ b/Common/src/toolboxes/MMS/CRinglebSolution.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -76,7 +76,7 @@ CRinglebSolution::~CRinglebSolution(void) { } void CRinglebSolution::GetBCState(const su2double *val_coords, const su2double val_t, - su2double *val_solution) { + su2double *val_solution) const { /*--- The exact solution is prescribed on the boundaries for the Ringleb flow. Note that a (much) more difficult test case is to @@ -87,7 +87,7 @@ void CRinglebSolution::GetBCState(const su2double *val_coords, void CRinglebSolution::GetSolution(const su2double *val_coords, const su2double val_t, - su2double *val_solution) { + su2double *val_solution) const { /* Easier storage of the coordinates and abbreviate y*y. */ const su2double x = val_coords[0], y = val_coords[1]; @@ -150,7 +150,7 @@ void CRinglebSolution::GetSolution(const su2double *val_coords, /* Check if the Newton algorithm actually converged. */ if(iter == iterMax) SU2_MPI::Error("Newton algorithm did not converge", CURRENT_FUNCTION); - + /* Compute the speed of sound, density and pressure. */ const su2double a = sqrt(1.0 - 0.5*Gm1*q*q); const su2double rho = pow(a,tovGm1); diff --git a/Common/src/toolboxes/MMS/CTGVSolution.cpp b/Common/src/toolboxes/MMS/CTGVSolution.cpp index 4d7c9303e40e..5fc08885db40 100644 --- a/Common/src/toolboxes/MMS/CTGVSolution.cpp +++ b/Common/src/toolboxes/MMS/CTGVSolution.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -34,35 +34,35 @@ CTGVSolution::CTGVSolution(unsigned short val_nDim, unsigned short val_iMesh, CConfig* config) : CVerificationSolution(val_nDim, val_nVar, val_iMesh, config) { - + /*--- Write a message that the solution is initialized for the Taylor-Green vortex test case. ---*/ - + if ((rank == MASTER_NODE) && (val_iMesh == MESH_0)) { cout << endl; cout << "Warning: Fluid properties and solution are being " << endl; cout << " initialized for the Taylor-Green vortex case!!!" << endl; cout << endl << flush; } - + /*--- Store TGV specific parameters here. ---*/ - + tgvLength = 1.0; // Taylor-Green length scale. tgvVelocity = 1.0; // Taylor-Green velocity. tgvDensity = 1.0; // Taylor-Green density. tgvPressure = 100.0; // Taylor-Green pressure. - + /*--- Useful coefficient in which Gamma is present. ---*/ - + ovGm1 = 1.0/(config->GetGamma() - 1.0); - + /*--- Perform some sanity and error checks for this solution here. ---*/ if((config->GetTime_Marching() != TIME_STEPPING) && (config->GetTime_Marching() != DT_STEPPING_1ST) && (config->GetTime_Marching() != DT_STEPPING_2ND)) SU2_MPI::Error("Unsteady mode must be selected for the Taylor Green Vortex", - CURRENT_FUNCTION); + CURRENT_FUNCTION); if(Kind_Solver != EULER && Kind_Solver != NAVIER_STOKES && Kind_Solver != RANS && Kind_Solver != FEM_EULER && Kind_Solver != FEM_NAVIER_STOKES && Kind_Solver != FEM_RANS && @@ -93,19 +93,19 @@ CTGVSolution::~CTGVSolution(void) { } void CTGVSolution::GetSolution(const su2double *val_coords, const su2double val_t, - su2double *val_solution) { - + su2double *val_solution) const { + /* The initial conditions are set for the Taylor-Green vortex case, which is a DNS case that features vortex breakdown into turbulence. These particular settings are for the typical Re = 1600 case (M = 0.08) with an initial temperature of 300 K. Note that this condition works in both 2D and 3D. */ - + su2double val_coordsZ = 0.0; if (nDim == 3) val_coordsZ = val_coords[2]; - + /* Compute the primitive variables. */ - + su2double rho = tgvDensity; su2double u = tgvVelocity * (sin(val_coords[0]/tgvLength)* cos(val_coords[1]/tgvLength)* @@ -113,17 +113,17 @@ void CTGVSolution::GetSolution(const su2double *val_coords, su2double v = -tgvVelocity * (cos(val_coords[0]/tgvLength)* sin(val_coords[1]/tgvLength)* cos(val_coordsZ /tgvLength)); - + su2double factorA = cos(2.0*val_coordsZ/tgvLength) + 2.0; su2double factorB = (cos(2.0*val_coords[0]/tgvLength) + cos(2.0*val_coords[1]/tgvLength)); - + su2double p = (tgvPressure + tgvDensity*(pow(tgvVelocity,2.0)/16.0)*factorA*factorB); - + /* Compute the conservative variables. Note that both 2D and 3D cases are treated correctly. */ - + val_solution[0] = rho; val_solution[1] = rho*u; val_solution[2] = rho*v; @@ -131,4 +131,4 @@ void CTGVSolution::GetSolution(const su2double *val_coords, val_solution[nVar-1] = p*ovGm1 + 0.5*rho*(u*u + v*v); } -bool CTGVSolution::ExactSolutionKnown(void) {return false;} +bool CTGVSolution::ExactSolutionKnown(void) const {return false;} diff --git a/Common/src/toolboxes/MMS/CUserDefinedSolution.cpp b/Common/src/toolboxes/MMS/CUserDefinedSolution.cpp index 2516fd8f9dc0..f23461d99f42 100644 --- a/Common/src/toolboxes/MMS/CUserDefinedSolution.cpp +++ b/Common/src/toolboxes/MMS/CUserDefinedSolution.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -34,10 +34,10 @@ CUserDefinedSolution::CUserDefinedSolution(unsigned short val_nDim, unsigned short val_iMesh, CConfig* config) : CVerificationSolution(val_nDim, val_nVar, val_iMesh, config) { - + /*--- Write a message that the solution is initialized for a user-defined verification case. ---*/ - + if ((rank == MASTER_NODE) && (val_iMesh == MESH_0)) { cout << endl; cout << "Warning: Fluid properties and solution are being " << endl; @@ -52,26 +52,26 @@ CUserDefinedSolution::~CUserDefinedSolution(void) { } void CUserDefinedSolution::GetBCState(const su2double *val_coords, const su2double val_t, - su2double *val_solution) { + su2double *val_solution) const { SU2_MPI::Error("User must implement this function", CURRENT_FUNCTION); } void CUserDefinedSolution::GetSolution(const su2double *val_coords, const su2double val_t, - su2double *val_solution) { + su2double *val_solution) const { SU2_MPI::Error("User must implement this function", CURRENT_FUNCTION); } void CUserDefinedSolution::GetMMSSourceTerm(const su2double *val_coords, const su2double val_t, - su2double *val_source) { + su2double *val_source) const { SU2_MPI::Error("User must implement this function", CURRENT_FUNCTION); } -bool CUserDefinedSolution::IsManufacturedSolution(void) { +bool CUserDefinedSolution::IsManufacturedSolution(void) const { SU2_MPI::Error("User must implement this function", CURRENT_FUNCTION); return false; /* True if manufactured. */ } diff --git a/Common/src/toolboxes/MMS/CVerificationSolution.cpp b/Common/src/toolboxes/MMS/CVerificationSolution.cpp index 5083debeeafe..2b2d9b28c07c 100644 --- a/Common/src/toolboxes/MMS/CVerificationSolution.cpp +++ b/Common/src/toolboxes/MMS/CVerificationSolution.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -41,16 +41,16 @@ CVerificationSolution::CVerificationSolution(unsigned short val_nDim, unsigned short val_iMesh, CConfig* config) { /*--- Store the kind of solver ---*/ - + Kind_Solver = config->GetKind_Solver(); - + /*--- Store the rank and size for the calculation. ---*/ - + size = SU2_MPI::GetSize(); rank = SU2_MPI::GetRank(); - + /*--- Store the dimension and number of variables. ---*/ - + nDim = val_nDim; nVar = val_nVar; @@ -88,28 +88,28 @@ CVerificationSolution::~CVerificationSolution(void) { void CVerificationSolution::GetSolution(const su2double *val_coords, const su2double val_t, - su2double *val_solution) { + su2double *val_solution) const { SU2_MPI::Error("Function must be overwritten by the derived class", CURRENT_FUNCTION); } void CVerificationSolution::GetInitialCondition(const su2double *val_coords, - su2double *val_solution) { - + su2double *val_solution) const { + /*--- Initial conditions call the GetSolution() method at t = 0. ---*/ GetSolution(val_coords, 0.0, val_solution); } void CVerificationSolution::GetBCState(const su2double *val_coords, const su2double val_t, - su2double *val_solution) { + su2double *val_solution) const { SU2_MPI::Error("Function must be overwritten by the derived class", CURRENT_FUNCTION); } void CVerificationSolution::GetMMSSourceTerm(const su2double *val_coords, const su2double val_t, - su2double *val_source) { + su2double *val_source) const { /* Default implementation of the source terms for the method of manufactured solutions. Simply set them to zero. */ @@ -117,26 +117,26 @@ void CVerificationSolution::GetMMSSourceTerm(const su2double *val_coords, val_source[iVar] = 0.0; } -bool CVerificationSolution::IsManufacturedSolution(void) {return false;} +bool CVerificationSolution::IsManufacturedSolution(void) const {return false;} -bool CVerificationSolution::ExactSolutionKnown(void) {return true;} +bool CVerificationSolution::ExactSolutionKnown(void) const {return true;} void CVerificationSolution::GetLocalError(const su2double *val_coords, const su2double val_t, const su2double *val_solution, - su2double *val_error) { - + su2double *val_error) const { + /*--- Get the value of the verification solution first. Use val_error to store this solution. ---*/ - + GetSolution(val_coords, val_t, val_error); - + /*--- Compute the local error as the difference between the current numerical solution and the verification solution. ---*/ - + for (unsigned short iVar=0; iVar Date: Thu, 23 Jan 2020 20:23:49 +0000 Subject: [PATCH 003/118] array of FluidModels for parallel execution (not trivial to make it thread safe...) --- SU2_CFD/include/solvers/CEulerSolver.hpp | 35 +- SU2_CFD/src/solvers/CEulerSolver.cpp | 1076 ++++++++++------------ SU2_CFD/src/solvers/CFEASolver.cpp | 28 +- SU2_CFD/src/solvers/CNSSolver.cpp | 45 +- 4 files changed, 567 insertions(+), 617 deletions(-) diff --git a/SU2_CFD/include/solvers/CEulerSolver.hpp b/SU2_CFD/include/solvers/CEulerSolver.hpp index b1549ff5ecc1..17a442b5e4e0 100644 --- a/SU2_CFD/include/solvers/CEulerSolver.hpp +++ b/SU2_CFD/include/solvers/CEulerSolver.hpp @@ -29,6 +29,7 @@ #include "CSolver.hpp" #include "../variables/CEulerVariable.hpp" +#include "../../../Common/include/omp_structure.hpp" /*! * \class CSolver @@ -39,6 +40,10 @@ class CEulerSolver : public CSolver { protected: + enum : size_t {OMP_MAX_SIZE = 512}; + + unsigned long omp_chunk_size; /*!< \brief Chunk size used in light point loops. */ + su2double Mach_Inf, /*!< \brief Mach number at the infinity. */ Density_Inf, /*!< \brief Density at the infinity. */ @@ -268,7 +273,7 @@ class CEulerSolver : public CSolver { unsigned short nSpanMax; /*!< \brief Max number of maximum span-wise sections for all zones */ unsigned short nMarkerTurboPerf; /*!< \brief Number of turbo performance. */ - CFluidModel *FluidModel; /*!< \brief fluid model used in the solver */ + vector FluidModel; /*!< \brief fluid model used in the solver */ /*--- Turbomachinery Solver Variables ---*/ su2double *** AverageFlux, @@ -308,14 +313,26 @@ class CEulerSolver : public CSolver { ***CkOutflow1, ***CkOutflow2; - /*--- End of Turbomachinery Solver Variables ---*/ + /*--- End of Turbomachinery Solver Variables ---*/ - /* Sliding meshes variables */ + /*--- Sliding meshes variables ---*/ su2double ****SlidingState; int **SlidingStateNodes; - CEulerVariable* nodes = nullptr; /*!< \brief The highest level in the variable hierarchy this solver can safely use. */ + /*--- Shallow copy of grid coloring for OpenMP parallelization. ---*/ + + struct EdgeColor { + unsigned long size; /*!< \brief Number of edges with a given color. */ + const unsigned long* indices; /*!< \brief Array of edge indices for a given color. */ + }; + vector EdgeColoring; /*!< \brief Edge colors. */ + unsigned long ColorGroupSize; /*!< \brief Group size used for coloring, chunk size in edge loops must be a multiple of this. */ + + /*! + * \brief The highest level in the variable hierarchy this solver can safely use. + */ + CEulerVariable* nodes = nullptr; /*! * \brief Return nodes to allow CSolver::base_nodes to be set. @@ -353,7 +370,7 @@ class CEulerSolver : public CSolver { * \brief Compute the pressure at the infinity. * \return Value of the pressure at the infinity. */ - inline CFluidModel* GetFluidModel(void) const final { return FluidModel;} + inline CFluidModel* GetFluidModel(void) const final { return FluidModel[omp_get_thread_num()]; } /*! * \brief Compute the density at the infinity. @@ -1132,8 +1149,8 @@ class CEulerSolver : public CSolver { inline su2double GetSlidingState(unsigned short val_marker, unsigned long val_vertex, unsigned short val_state, - unsigned long donor_index) const final { - return SlidingState[val_marker][val_vertex][val_state][donor_index]; + unsigned long donor_index) const final { + return SlidingState[val_marker][val_vertex][val_state][donor_index]; } /*! @@ -2309,8 +2326,8 @@ class CEulerSolver : public CSolver { * \param[in] val_marker - marker index * \param[in] val_vertex - vertex index */ - inline int GetnSlidingStates(unsigned short val_marker, unsigned long val_vertex) const final { - return SlidingStateNodes[val_marker][val_vertex]; + inline int GetnSlidingStates(unsigned short val_marker, unsigned long val_vertex) const final { + return SlidingStateNodes[val_marker][val_vertex]; } /*! diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 3269fa9789d2..01b92befba54 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -105,8 +105,6 @@ CEulerSolver::CEulerSolver(void) : CSolver() { Update_AoA = false; Iter_Update_AoA = 0; - FluidModel = NULL; - SlidingState = NULL; SlidingStateNodes = NULL; @@ -287,8 +285,6 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short Update_AoA = false; Iter_Update_AoA = 0; - FluidModel = NULL; - /*--- Initialize quantities for the average process for internal flow ---*/ AverageVelocity = NULL; @@ -487,10 +483,7 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short for (iMarker = 0; iMarker < nMarker; iMarker++) { CharacPrimVar[iMarker] = new su2double* [geometry->nVertex[iMarker]]; for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { - CharacPrimVar[iMarker][iVertex] = new su2double [nPrimVar]; - for (iVar = 0; iVar < nPrimVar; iVar++) { - CharacPrimVar[iMarker][iVertex][iVar] = 0.0; - } + CharacPrimVar[iMarker][iVertex] = new su2double [nPrimVar](); } } @@ -502,16 +495,10 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short DonorPrimVar[iMarker] = new su2double* [geometry->nVertex[iMarker]]; for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { if (rans) { - DonorPrimVar[iMarker][iVertex] = new su2double [nPrimVar+2]; - for (iVar = 0; iVar < nPrimVar + 2 ; iVar++) { - DonorPrimVar[iMarker][iVertex][iVar] = 0.0; - } + DonorPrimVar[iMarker][iVertex] = new su2double [nPrimVar+2](); } else { - DonorPrimVar[iMarker][iVertex] = new su2double [nPrimVar]; - for (iVar = 0; iVar < nPrimVar ; iVar++) { - DonorPrimVar[iMarker][iVertex][iVar] = 0.0; - } + DonorPrimVar[iMarker][iVertex] = new su2double [nPrimVar](); } } } @@ -520,63 +507,45 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short DonorGlobalIndex = new unsigned long* [nMarker]; for (iMarker = 0; iMarker < nMarker; iMarker++) { - DonorGlobalIndex[iMarker] = new unsigned long [geometry->nVertex[iMarker]]; - for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { - DonorGlobalIndex[iMarker][iVertex] = 0; - } + DonorGlobalIndex[iMarker] = new unsigned long [geometry->nVertex[iMarker]](); } /*--- Store the value of the Delta P at the Actuator Disk ---*/ ActDisk_DeltaP = new su2double* [nMarker]; for (iMarker = 0; iMarker < nMarker; iMarker++) { - ActDisk_DeltaP[iMarker] = new su2double [geometry->nVertex[iMarker]]; - for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { - ActDisk_DeltaP[iMarker][iVertex] = 0; - } + ActDisk_DeltaP[iMarker] = new su2double [geometry->nVertex[iMarker]](); } /*--- Store the value of the Delta T at the Actuator Disk ---*/ ActDisk_DeltaT = new su2double* [nMarker]; for (iMarker = 0; iMarker < nMarker; iMarker++) { - ActDisk_DeltaT[iMarker] = new su2double [geometry->nVertex[iMarker]]; - for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { - ActDisk_DeltaT[iMarker][iVertex] = 0; - } + ActDisk_DeltaT[iMarker] = new su2double [geometry->nVertex[iMarker]](); } /*--- Store the value of the Total Pressure at the inlet BC ---*/ Inlet_Ttotal = new su2double* [nMarker]; for (iMarker = 0; iMarker < nMarker; iMarker++) { - Inlet_Ttotal[iMarker] = new su2double [geometry->nVertex[iMarker]]; - for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { - Inlet_Ttotal[iMarker][iVertex] = 0; - } + Inlet_Ttotal[iMarker] = new su2double [geometry->nVertex[iMarker]](); } /*--- Store the value of the Total Temperature at the inlet BC ---*/ Inlet_Ptotal = new su2double* [nMarker]; for (iMarker = 0; iMarker < nMarker; iMarker++) { - Inlet_Ptotal[iMarker] = new su2double [geometry->nVertex[iMarker]]; - for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { - Inlet_Ptotal[iMarker][iVertex] = 0; - } + Inlet_Ptotal[iMarker] = new su2double [geometry->nVertex[iMarker]](); } /*--- Store the value of the Flow direction at the inlet BC ---*/ Inlet_FlowDir = new su2double** [nMarker]; for (iMarker = 0; iMarker < nMarker; iMarker++) { - Inlet_FlowDir[iMarker] = new su2double* [geometry->nVertex[iMarker]]; - for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { - Inlet_FlowDir[iMarker][iVertex] = new su2double [nDim]; - for (iDim = 0; iDim < nDim; iDim++) { - Inlet_FlowDir[iMarker][iVertex][iDim] = 0; - } - } + Inlet_FlowDir[iMarker] = new su2double* [geometry->nVertex[iMarker]]; + for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { + Inlet_FlowDir[iMarker][iVertex] = new su2double [nDim](); + } } /*--- Force definition and coefficient arrays for all of the markers ---*/ @@ -584,21 +553,17 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short CPressure = new su2double* [nMarker]; CPressureTarget = new su2double* [nMarker]; for (iMarker = 0; iMarker < nMarker; iMarker++) { - CPressure[iMarker] = new su2double [geometry->nVertex[iMarker]]; - CPressureTarget[iMarker] = new su2double [geometry->nVertex[iMarker]]; - for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { - CPressure[iMarker][iVertex] = 0.0; - CPressureTarget[iMarker][iVertex] = 0.0; - } + CPressure[iMarker] = new su2double [geometry->nVertex[iMarker]](); + CPressureTarget[iMarker] = new su2double [geometry->nVertex[iMarker]](); } /*--- Non-dimensional coefficients ---*/ ForceInviscid = new su2double[nDim]; MomentInviscid = new su2double[3]; - CD_Inv = new su2double[nMarker]; - CL_Inv = new su2double[nMarker]; - CSF_Inv = new su2double[nMarker]; + CD_Inv = new su2double[nMarker]; + CL_Inv = new su2double[nMarker]; + CSF_Inv = new su2double[nMarker]; CMx_Inv = new su2double[nMarker]; CMy_Inv = new su2double[nMarker]; CMz_Inv = new su2double[nMarker]; @@ -606,29 +571,29 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short CFx_Inv = new su2double[nMarker]; CFy_Inv = new su2double[nMarker]; CFz_Inv = new su2double[nMarker]; - CoPx_Inv = new su2double[nMarker]; - CoPy_Inv = new su2double[nMarker]; - CoPz_Inv = new su2double[nMarker]; + CoPx_Inv = new su2double[nMarker]; + CoPy_Inv = new su2double[nMarker]; + CoPz_Inv = new su2double[nMarker]; ForceMomentum = new su2double[nDim]; MomentMomentum = new su2double[3]; - CD_Mnt = new su2double[nMarker]; - CL_Mnt = new su2double[nMarker]; - CSF_Mnt = new su2double[nMarker]; - CMx_Mnt = new su2double[nMarker]; - CMy_Mnt = new su2double[nMarker]; - CMz_Mnt = new su2double[nMarker]; - CEff_Mnt = new su2double[nMarker]; - CFx_Mnt = new su2double[nMarker]; - CFy_Mnt = new su2double[nMarker]; - CFz_Mnt = new su2double[nMarker]; + CD_Mnt = new su2double[nMarker]; + CL_Mnt = new su2double[nMarker]; + CSF_Mnt = new su2double[nMarker]; + CMx_Mnt = new su2double[nMarker]; + CMy_Mnt = new su2double[nMarker]; + CMz_Mnt = new su2double[nMarker]; + CEff_Mnt = new su2double[nMarker]; + CFx_Mnt = new su2double[nMarker]; + CFy_Mnt = new su2double[nMarker]; + CFz_Mnt = new su2double[nMarker]; CoPx_Mnt = new su2double[nMarker]; CoPy_Mnt = new su2double[nMarker]; CoPz_Mnt = new su2double[nMarker]; - Surface_CL_Inv = new su2double[config->GetnMarker_Monitoring()]; - Surface_CD_Inv = new su2double[config->GetnMarker_Monitoring()]; - Surface_CSF_Inv = new su2double[config->GetnMarker_Monitoring()]; + Surface_CL_Inv = new su2double[config->GetnMarker_Monitoring()]; + Surface_CD_Inv = new su2double[config->GetnMarker_Monitoring()]; + Surface_CSF_Inv = new su2double[config->GetnMarker_Monitoring()]; Surface_CEff_Inv = new su2double[config->GetnMarker_Monitoring()]; Surface_CFx_Inv = new su2double[config->GetnMarker_Monitoring()]; Surface_CFy_Inv = new su2double[config->GetnMarker_Monitoring()]; @@ -637,20 +602,20 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short Surface_CMy_Inv = new su2double[config->GetnMarker_Monitoring()]; Surface_CMz_Inv = new su2double[config->GetnMarker_Monitoring()]; - Surface_CL_Mnt = new su2double[config->GetnMarker_Monitoring()]; - Surface_CD_Mnt = new su2double[config->GetnMarker_Monitoring()]; - Surface_CSF_Mnt= new su2double[config->GetnMarker_Monitoring()]; - Surface_CEff_Mnt = new su2double[config->GetnMarker_Monitoring()]; - Surface_CFx_Mnt = new su2double[config->GetnMarker_Monitoring()]; - Surface_CFy_Mnt = new su2double[config->GetnMarker_Monitoring()]; - Surface_CFz_Mnt = new su2double[config->GetnMarker_Monitoring()]; - Surface_CMx_Mnt = new su2double[config->GetnMarker_Monitoring()]; + Surface_CL_Mnt = new su2double[config->GetnMarker_Monitoring()]; + Surface_CD_Mnt = new su2double[config->GetnMarker_Monitoring()]; + Surface_CSF_Mnt = new su2double[config->GetnMarker_Monitoring()]; + Surface_CEff_Mnt = new su2double[config->GetnMarker_Monitoring()]; + Surface_CFx_Mnt = new su2double[config->GetnMarker_Monitoring()]; + Surface_CFy_Mnt = new su2double[config->GetnMarker_Monitoring()]; + Surface_CFz_Mnt = new su2double[config->GetnMarker_Monitoring()]; + Surface_CMx_Mnt = new su2double[config->GetnMarker_Monitoring()]; Surface_CMy_Mnt = new su2double[config->GetnMarker_Monitoring()]; Surface_CMz_Mnt = new su2double[config->GetnMarker_Monitoring()]; - Surface_CL = new su2double[config->GetnMarker_Monitoring()]; - Surface_CD = new su2double[config->GetnMarker_Monitoring()]; - Surface_CSF = new su2double[config->GetnMarker_Monitoring()]; + Surface_CL = new su2double[config->GetnMarker_Monitoring()]; + Surface_CD = new su2double[config->GetnMarker_Monitoring()]; + Surface_CSF = new su2double[config->GetnMarker_Monitoring()]; Surface_CEff = new su2double[config->GetnMarker_Monitoring()]; Surface_CFx = new su2double[config->GetnMarker_Monitoring()]; Surface_CFy = new su2double[config->GetnMarker_Monitoring()]; @@ -695,12 +660,12 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short Total_CFx = 0.0; Total_CFy = 0.0; Total_CFz = 0.0; Total_CT = 0.0; Total_CQ = 0.0; Total_CMerit = 0.0; Total_MaxHeat = 0.0; Total_Heat = 0.0; Total_ComboObj = 0.0; - Total_CpDiff = 0.0; Total_HeatFluxDiff = 0.0; Total_Custom_ObjFunc=0.0; + Total_CpDiff = 0.0; Total_HeatFluxDiff = 0.0; Total_Custom_ObjFunc = 0.0; Total_NetThrust = 0.0; - Total_Power = 0.0; AoA_Prev = 0.0; AoA_inc = 0.0; - Total_CL_Prev = 0.0; Total_CD_Prev = 0.0; - Total_CMx_Prev = 0.0; Total_CMy_Prev = 0.0; Total_CMz_Prev = 0.0; - Total_AeroCD = 0.0; Total_SolidCD = 0.0; Total_IDR = 0.0; Total_IDC = 0.0; + Total_Power = 0.0; AoA_Prev = 0.0; AoA_inc = 0.0; + Total_CL_Prev = 0.0; Total_CD_Prev = 0.0; + Total_CMx_Prev = 0.0; Total_CMy_Prev = 0.0; Total_CMz_Prev = 0.0; + Total_AeroCD = 0.0; Total_SolidCD = 0.0; Total_IDR = 0.0; Total_IDC = 0.0; /*--- Read farfield conditions ---*/ @@ -752,26 +717,18 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short /*--- Initializate quantities for SlidingMesh Interface ---*/ - SlidingState = new su2double*** [nMarker]; - SlidingStateNodes = new int* [nMarker]; + SlidingState = new su2double*** [nMarker](); + SlidingStateNodes = new int* [nMarker](); - for (iMarker = 0; iMarker < nMarker; iMarker++){ - SlidingState[iMarker] = NULL; - SlidingStateNodes[iMarker] = NULL; - - if (config->GetMarker_All_KindBC(iMarker) == FLUID_INTERFACE){ - - SlidingState[iMarker] = new su2double**[geometry->GetnVertex(iMarker)]; - SlidingStateNodes[iMarker] = new int [geometry->GetnVertex(iMarker)]; + for (iMarker = 0; iMarker < nMarker; iMarker++) { - for (iPoint = 0; iPoint < geometry->GetnVertex(iMarker); iPoint++){ - SlidingState[iMarker][iPoint] = new su2double*[nPrimVar+1]; + if (config->GetMarker_All_KindBC(iMarker) == FLUID_INTERFACE) { - SlidingStateNodes[iMarker][iPoint] = 0; - for (iVar = 0; iVar < nPrimVar+1; iVar++) - SlidingState[iMarker][iPoint][iVar] = NULL; - } + SlidingState[iMarker] = new su2double**[geometry->GetnVertex(iMarker)](); + SlidingStateNodes[iMarker] = new int [geometry->GetnVertex(iMarker)](); + for (iPoint = 0; iPoint < geometry->GetnVertex(iMarker); iPoint++) + SlidingState[iMarker][iPoint] = new su2double*[nPrimVar+1](); } } @@ -791,6 +748,24 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short nodes = new CEulerVariable(Density_Inf, Velocity_Inf, Energy_Inf, nPoint, nDim, nVar, config); SetBaseClassPointerToNodes(); +#ifndef HAVE_OMP + /*--- Get the edge coloring. ---*/ + + const auto& coloring = geometry->GetEdgeColoring(); + + auto nColor = coloring.getOuterSize(); + EdgeColoring.resize(nColor); + + for(auto iColor = 0ul; iColor < nColor; ++iColor) { + EdgeColoring[iColor].size = coloring.getNumNonZeros(iColor); + EdgeColoring[iColor].indices = coloring.innerIdx(iColor); + } + + ColorGroupSize = geometry->GetEdgeColorGroupSize(); + + omp_chunk_size = computeStaticChunkSize(nPoint, omp_get_max_threads(), OMP_MAX_SIZE); +#endif + /*--- Check that the initial solution is physical, report any non-physical nodes ---*/ counter_local = 0; @@ -805,9 +780,9 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short StaticEnergy= nodes->GetEnergy(iPoint) - 0.5*Velocity2; - FluidModel->SetTDState_rhoe(Density, StaticEnergy); - Pressure= FluidModel->GetPressure(); - Temperature= FluidModel->GetTemperature(); + GetFluidModel()->SetTDState_rhoe(Density, StaticEnergy); + Pressure= GetFluidModel()->GetPressure(); + Temperature= GetFluidModel()->GetTemperature(); /*--- Use the values at the infinity ---*/ @@ -825,16 +800,15 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short /*--- Initialize the BGS residuals in FSI problems. ---*/ if (fsi || multizone){ - Residual_BGS = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) Residual_BGS[iVar] = 1.0; - Residual_Max_BGS = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) Residual_Max_BGS[iVar] = 1.0; + Residual_BGS = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) Residual_BGS[iVar] = 1.0; + Residual_Max_BGS = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) Residual_Max_BGS[iVar] = 1.0; /*--- Define some structures for locating max residuals ---*/ - Point_Max_BGS = new unsigned long[nVar]; for (iVar = 0; iVar < nVar; iVar++) Point_Max_BGS[iVar] = 0; - Point_Max_Coord_BGS = new su2double*[nVar]; + Point_Max_BGS = new unsigned long[nVar](); + Point_Max_Coord_BGS = new su2double*[nVar](); for (iVar = 0; iVar < nVar; iVar++) { - Point_Max_Coord_BGS[iVar] = new su2double[nDim]; - for (iDim = 0; iDim < nDim; iDim++) Point_Max_Coord_BGS[iVar][iDim] = 0.0; + Point_Max_Coord_BGS[iVar] = new su2double[nDim](); } } @@ -901,95 +875,95 @@ CEulerSolver::~CEulerSolver(void) { /*--- Array deallocation ---*/ - if (CD_Inv != NULL) delete [] CD_Inv; - if (CL_Inv != NULL) delete [] CL_Inv; - if (CSF_Inv != NULL) delete [] CSF_Inv; - if (CMx_Inv != NULL) delete [] CMx_Inv; - if (CMy_Inv != NULL) delete [] CMy_Inv; - if (CMz_Inv != NULL) delete [] CMz_Inv; - if (CFx_Inv != NULL) delete [] CFx_Inv; - if (CFy_Inv != NULL) delete [] CFy_Inv; - if (CFz_Inv != NULL) delete [] CFz_Inv; - if (CoPx_Inv != NULL) delete [] CoPx_Inv; - if (CoPy_Inv != NULL) delete [] CoPy_Inv; - if (CoPz_Inv != NULL) delete [] CoPz_Inv; - if (Surface_CL_Inv != NULL) delete[] Surface_CL_Inv; - if (Surface_CD_Inv != NULL) delete[] Surface_CD_Inv; - if (Surface_CSF_Inv != NULL) delete[] Surface_CSF_Inv; - if (Surface_CEff_Inv != NULL) delete[] Surface_CEff_Inv; - if (Surface_CFx_Inv != NULL) delete [] Surface_CFx_Inv; - if (Surface_CFy_Inv != NULL) delete [] Surface_CFy_Inv; - if (Surface_CFz_Inv != NULL) delete [] Surface_CFz_Inv; - if (Surface_CMx_Inv != NULL) delete [] Surface_CMx_Inv; - if (Surface_CMy_Inv != NULL) delete [] Surface_CMy_Inv; - if (Surface_CMz_Inv != NULL) delete [] Surface_CMz_Inv; - - if (CD_Mnt != NULL) delete [] CD_Mnt; - if (CL_Mnt != NULL) delete [] CL_Mnt; - if (CSF_Mnt != NULL) delete [] CSF_Mnt; - if (CFx_Mnt != NULL) delete [] CFx_Mnt; - if (CFy_Mnt != NULL) delete [] CFy_Mnt; - if (CFz_Mnt != NULL) delete [] CFz_Mnt; - if (CMx_Mnt != NULL) delete [] CMx_Mnt; - if (CMy_Mnt != NULL) delete [] CMy_Mnt; - if (CMz_Mnt != NULL) delete [] CMz_Mnt; - if (CoPx_Mnt != NULL) delete [] CoPx_Mnt; - if (CoPy_Mnt != NULL) delete [] CoPy_Mnt; - if (CoPz_Mnt != NULL) delete [] CoPz_Mnt; - if (Surface_CL_Mnt != NULL) delete[] Surface_CL_Mnt; - if (Surface_CD_Mnt != NULL) delete[] Surface_CD_Mnt; - if (Surface_CSF_Mnt != NULL) delete[] Surface_CSF_Mnt; - if (Surface_CEff_Mnt != NULL) delete[] Surface_CEff_Mnt; - if (Surface_CFx_Mnt != NULL) delete [] Surface_CFx_Mnt; - if (Surface_CFy_Mnt != NULL) delete [] Surface_CFy_Mnt; - if (Surface_CFz_Mnt != NULL) delete [] Surface_CFz_Mnt; - if (Surface_CMx_Mnt != NULL) delete [] Surface_CMx_Mnt; - if (Surface_CMy_Mnt != NULL) delete [] Surface_CMy_Mnt; - if (Surface_CMz_Mnt != NULL) delete [] Surface_CMz_Mnt; - - if (Surface_CL != NULL) delete [] Surface_CL; - if (Surface_CD != NULL) delete [] Surface_CD; - if (Surface_CSF != NULL) delete [] Surface_CSF; - if (Surface_CEff != NULL) delete [] Surface_CEff; - if (Surface_CFx != NULL) delete [] Surface_CFx; - if (Surface_CFy != NULL) delete [] Surface_CFy; - if (Surface_CFz != NULL) delete [] Surface_CFz; - if (Surface_CMx != NULL) delete [] Surface_CMx; - if (Surface_CMy != NULL) delete [] Surface_CMy; - if (Surface_CMz != NULL) delete [] Surface_CMz; - if (CEff_Inv != NULL) delete [] CEff_Inv; - if (CMerit_Inv != NULL) delete [] CMerit_Inv; - if (CT_Inv != NULL) delete [] CT_Inv; - if (CQ_Inv != NULL) delete [] CQ_Inv; - if (CEquivArea_Inv != NULL) delete [] CEquivArea_Inv; - if (CNearFieldOF_Inv != NULL) delete [] CNearFieldOF_Inv; - - if (CEff_Mnt != NULL) delete [] CEff_Mnt; - if (CMerit_Mnt != NULL) delete [] CMerit_Mnt; - if (CT_Mnt != NULL) delete [] CT_Mnt; - if (CQ_Mnt != NULL) delete [] CQ_Mnt; - - if (ForceInviscid != NULL) delete [] ForceInviscid; - if (MomentInviscid != NULL) delete [] MomentInviscid; - if (ForceMomentum != NULL) delete [] ForceMomentum; - if (MomentMomentum != NULL) delete [] MomentMomentum; - if (Inflow_MassFlow != NULL) delete [] Inflow_MassFlow; - if (Exhaust_MassFlow != NULL) delete [] Exhaust_MassFlow; - if (Exhaust_Area != NULL) delete [] Exhaust_Area; - if (Inflow_Pressure != NULL) delete [] Inflow_Pressure; - if (Inflow_Mach != NULL) delete [] Inflow_Mach; - if (Inflow_Area != NULL) delete [] Inflow_Area; - - if (Exhaust_Pressure != NULL) delete [] Exhaust_Pressure; - if (Exhaust_Temperature != NULL) delete [] Exhaust_Temperature; - - if (Primitive != NULL) delete [] Primitive; - if (Primitive_i != NULL) delete [] Primitive_i; - if (Primitive_j != NULL) delete [] Primitive_j; - - if (Secondary != NULL) delete [] Secondary; - if (Secondary_i != NULL) delete [] Secondary_i; - if (Secondary_j != NULL) delete [] Secondary_j; + delete [] CD_Inv; + delete [] CL_Inv; + delete [] CSF_Inv; + delete [] CMx_Inv; + delete [] CMy_Inv; + delete [] CMz_Inv; + delete [] CFx_Inv; + delete [] CFy_Inv; + delete [] CFz_Inv; + delete [] CoPx_Inv; + delete [] CoPy_Inv; + delete [] CoPz_Inv; + delete[] Surface_CL_Inv; + delete[] Surface_CD_Inv; + delete[] Surface_CSF_Inv; + delete[] Surface_CEff_Inv; + delete [] Surface_CFx_Inv; + delete [] Surface_CFy_Inv; + delete [] Surface_CFz_Inv; + delete [] Surface_CMx_Inv; + delete [] Surface_CMy_Inv; + delete [] Surface_CMz_Inv; + + delete [] CD_Mnt; + delete [] CL_Mnt; + delete [] CSF_Mnt; + delete [] CFx_Mnt; + delete [] CFy_Mnt; + delete [] CFz_Mnt; + delete [] CMx_Mnt; + delete [] CMy_Mnt; + delete [] CMz_Mnt; + delete [] CoPx_Mnt; + delete [] CoPy_Mnt; + delete [] CoPz_Mnt; + delete [] Surface_CL_Mnt; + delete [] Surface_CD_Mnt; + delete [] Surface_CSF_Mnt; + delete [] Surface_CEff_Mnt; + delete [] Surface_CFx_Mnt; + delete [] Surface_CFy_Mnt; + delete [] Surface_CFz_Mnt; + delete [] Surface_CMx_Mnt; + delete [] Surface_CMy_Mnt; + delete [] Surface_CMz_Mnt; + + delete [] Surface_CL; + delete [] Surface_CD; + delete [] Surface_CSF; + delete [] Surface_CEff; + delete [] Surface_CFx; + delete [] Surface_CFy; + delete [] Surface_CFz; + delete [] Surface_CMx; + delete [] Surface_CMy; + delete [] Surface_CMz; + delete [] CEff_Inv; + delete [] CMerit_Inv; + delete [] CT_Inv; + delete [] CQ_Inv; + delete [] CEquivArea_Inv; + delete [] CNearFieldOF_Inv; + + delete [] CEff_Mnt; + delete [] CMerit_Mnt; + delete [] CT_Mnt; + delete [] CQ_Mnt; + + delete [] ForceInviscid; + delete [] MomentInviscid; + delete [] ForceMomentum; + delete [] MomentMomentum; + delete [] Inflow_MassFlow; + delete [] Exhaust_MassFlow; + delete [] Exhaust_Area; + delete [] Inflow_Pressure; + delete [] Inflow_Mach; + delete [] Inflow_Area; + + delete [] Exhaust_Pressure; + delete [] Exhaust_Temperature; + + delete [] Primitive; + delete [] Primitive_i; + delete [] Primitive_j; + + delete [] Secondary; + delete [] Secondary_i; + delete [] Secondary_j; if (LowMach_Precontioner != NULL) { for (iVar = 0; iVar < nVar; iVar ++) @@ -1114,7 +1088,7 @@ CEulerSolver::~CEulerSolver(void) { delete [] YPlus; } - if (FluidModel != NULL) delete FluidModel; + for(auto& model : FluidModel) delete model; if(AverageVelocity !=NULL){ for (iMarker = 0; iMarker < nMarker; iMarker++) { @@ -1356,11 +1330,11 @@ CEulerSolver::~CEulerSolver(void) { delete [] CkOutflow2; } - if (nodes != nullptr) delete nodes; + delete nodes; } void CEulerSolver::InitTurboContainers(CGeometry *geometry, CConfig *config){ - unsigned short iMarker, iSpan, iDim, iVar; + unsigned short iMarker, iSpan, iVar; nSpanMax = config->GetnSpanMaxAllZones(); @@ -1395,56 +1369,30 @@ void CEulerSolver::InitTurboContainers(CGeometry *geometry, CConfig *config){ ExtAverageTurboVelocity[iMarker] = new su2double* [nSpanWiseSections + 1]; AverageFlux[iMarker] = new su2double* [nSpanWiseSections + 1]; SpanTotalFlux[iMarker] = new su2double* [nSpanWiseSections + 1]; - AveragePressure[iMarker] = new su2double [nSpanWiseSections + 1]; - OldAveragePressure[iMarker] = new su2double [nSpanWiseSections + 1]; - RadialEquilibriumPressure[iMarker] = new su2double [nSpanWiseSections + 1]; - ExtAveragePressure[iMarker] = new su2double [nSpanWiseSections + 1]; - AverageDensity[iMarker] = new su2double [nSpanWiseSections + 1]; - OldAverageDensity[iMarker] = new su2double [nSpanWiseSections + 1]; - ExtAverageDensity[iMarker] = new su2double [nSpanWiseSections + 1]; - AverageNu[iMarker] = new su2double [nSpanWiseSections + 1]; - AverageKine[iMarker] = new su2double [nSpanWiseSections + 1]; - AverageOmega[iMarker] = new su2double [nSpanWiseSections + 1]; - ExtAverageNu[iMarker] = new su2double [nSpanWiseSections + 1]; - ExtAverageKine[iMarker] = new su2double [nSpanWiseSections + 1]; - ExtAverageOmega[iMarker] = new su2double [nSpanWiseSections + 1]; + AveragePressure[iMarker] = new su2double [nSpanWiseSections + 1](); + OldAveragePressure[iMarker] = new su2double [nSpanWiseSections + 1](); + RadialEquilibriumPressure[iMarker] = new su2double [nSpanWiseSections + 1](); + ExtAveragePressure[iMarker] = new su2double [nSpanWiseSections + 1](); + AverageDensity[iMarker] = new su2double [nSpanWiseSections + 1](); + OldAverageDensity[iMarker] = new su2double [nSpanWiseSections + 1](); + ExtAverageDensity[iMarker] = new su2double [nSpanWiseSections + 1](); + AverageNu[iMarker] = new su2double [nSpanWiseSections + 1](); + AverageKine[iMarker] = new su2double [nSpanWiseSections + 1](); + AverageOmega[iMarker] = new su2double [nSpanWiseSections + 1](); + ExtAverageNu[iMarker] = new su2double [nSpanWiseSections + 1](); + ExtAverageKine[iMarker] = new su2double [nSpanWiseSections + 1](); + ExtAverageOmega[iMarker] = new su2double [nSpanWiseSections + 1](); for(iSpan = 0; iSpan < nSpanWiseSections + 1; iSpan++){ - AverageVelocity[iMarker][iSpan] = new su2double [nDim]; - AverageTurboVelocity[iMarker][iSpan] = new su2double [nDim]; - OldAverageTurboVelocity[iMarker][iSpan] = new su2double [nDim]; - ExtAverageTurboVelocity[iMarker][iSpan] = new su2double [nDim]; - AverageFlux[iMarker][iSpan] = new su2double [nVar]; - SpanTotalFlux[iMarker][iSpan] = new su2double [nVar]; - AveragePressure[iMarker][iSpan] = 0.0; - OldAveragePressure[iMarker][iSpan] = 0.0; - RadialEquilibriumPressure[iMarker][iSpan] = 0.0; - ExtAveragePressure[iMarker][iSpan] = 0.0; - AverageDensity[iMarker][iSpan] = 0.0; - OldAverageDensity[iMarker][iSpan] = 0.0; - ExtAverageDensity[iMarker][iSpan] = 0.0; - AverageNu[iMarker][iSpan] = 0.0; - AverageKine[iMarker][iSpan] = 0.0; - AverageOmega[iMarker][iSpan] = 0.0; - ExtAverageNu[iMarker][iSpan] = 0.0; - ExtAverageKine[iMarker][iSpan] = 0.0; - ExtAverageOmega[iMarker][iSpan] = 0.0; - - for (iDim = 0; iDim < nDim; iDim++) { - AverageVelocity[iMarker][iSpan][iDim] = 0.0; - AverageTurboVelocity[iMarker][iSpan][iDim] = 0.0; - OldAverageTurboVelocity[iMarker][iSpan][iDim] = 0.0; - ExtAverageTurboVelocity[iMarker][iSpan][iDim] = 0.0; - } - - for (iVar = 0; iVar < nVar; iVar++) { - AverageFlux[iMarker][iSpan][iVar] = 0.0; - SpanTotalFlux[iMarker][iSpan][iVar] = 0.0; - } + AverageVelocity[iMarker][iSpan] = new su2double [nDim](); + AverageTurboVelocity[iMarker][iSpan] = new su2double [nDim](); + OldAverageTurboVelocity[iMarker][iSpan] = new su2double [nDim](); + ExtAverageTurboVelocity[iMarker][iSpan] = new su2double [nDim](); + AverageFlux[iMarker][iSpan] = new su2double [nVar](); + SpanTotalFlux[iMarker][iSpan] = new su2double [nVar](); } } - /*--- Initialize primitive quantities for turboperformace ---*/ nMarkerTurboPerf = config->GetnMarker_TurboPerformance(); @@ -1462,40 +1410,23 @@ void CEulerSolver::InitTurboContainers(CGeometry *geometry, CConfig *config){ OmegaOut = new su2double*[nMarkerTurboPerf]; NuOut = new su2double*[nMarkerTurboPerf]; - for (iMarker = 0; iMarker < nMarkerTurboPerf; iMarker++){ - DensityIn[iMarker] = new su2double [nSpanMax + 1]; - PressureIn[iMarker] = new su2double [nSpanMax + 1]; - TurboVelocityIn[iMarker] = new su2double*[nSpanMax + 1]; - DensityOut[iMarker] = new su2double [nSpanMax + 1]; - PressureOut[iMarker] = new su2double [nSpanMax + 1]; - TurboVelocityOut[iMarker] = new su2double*[nSpanMax + 1]; - KineIn[iMarker] = new su2double [nSpanMax + 1]; - OmegaIn[iMarker] = new su2double [nSpanMax + 1]; - NuIn[iMarker] = new su2double [nSpanMax + 1]; - KineOut[iMarker] = new su2double [nSpanMax + 1]; - OmegaOut[iMarker] = new su2double [nSpanMax + 1]; - NuOut[iMarker] = new su2double [nSpanMax + 1]; - - - - for (iSpan = 0; iSpan < nSpanMax + 1; iSpan++){ - DensityIn[iMarker][iSpan] = 0.0; - PressureIn[iMarker][iSpan] = 0.0; - TurboVelocityIn[iMarker][iSpan] = new su2double[nDim]; - DensityOut[iMarker][iSpan] = 0.0; - PressureOut[iMarker][iSpan] = 0.0; - TurboVelocityOut [iMarker][iSpan] = new su2double[nDim]; - KineIn[iMarker][iSpan] = 0.0; - OmegaIn[iMarker][iSpan] = 0.0; - NuIn[iMarker][iSpan] = 0.0; - KineOut[iMarker][iSpan] = 0.0; - OmegaOut[iMarker][iSpan] = 0.0; - NuOut[iMarker][iSpan] = 0.0; + for (iMarker = 0; iMarker < nMarkerTurboPerf; iMarker++) { + DensityIn[iMarker] = new su2double [nSpanMax + 1](); + PressureIn[iMarker] = new su2double [nSpanMax + 1](); + TurboVelocityIn[iMarker] = new su2double*[nSpanMax + 1](); + DensityOut[iMarker] = new su2double [nSpanMax + 1](); + PressureOut[iMarker] = new su2double [nSpanMax + 1](); + TurboVelocityOut[iMarker] = new su2double*[nSpanMax + 1](); + KineIn[iMarker] = new su2double [nSpanMax + 1](); + OmegaIn[iMarker] = new su2double [nSpanMax + 1](); + NuIn[iMarker] = new su2double [nSpanMax + 1](); + KineOut[iMarker] = new su2double [nSpanMax + 1](); + OmegaOut[iMarker] = new su2double [nSpanMax + 1](); + NuOut[iMarker] = new su2double [nSpanMax + 1](); - for (iDim = 0; iDim < nDim; iDim++){ - TurboVelocityIn [iMarker][iSpan][iDim] = 0.0; - TurboVelocityOut [iMarker][iSpan][iDim] = 0.0; - } + for (iSpan = 0; iSpan < nSpanMax + 1; iSpan++) { + TurboVelocityIn[iMarker][iSpan] = new su2double[nDim](); + TurboVelocityOut [iMarker][iSpan] = new su2double[nDim](); } } @@ -1905,15 +1836,14 @@ void CEulerSolver::Set_MPI_Nearfield(CGeometry *geometry, CConfig *config) { unsigned long *nPointTotal_s = new unsigned long[size]; unsigned long *nPointTotal_r = new unsigned long[size]; - su2double *iPrimVar = new su2double [nPrimVar]; - - unsigned long Buffer_Size_PrimVar = 0; + su2double *iPrimVar = new su2double [nPrimVar]; + unsigned long Buffer_Size_PrimVar = 0; unsigned long PointTotal_Counter = 0; /*--- Allocate the memory that we only need if we have MPI support ---*/ - su2double *Buffer_Receive_PrimVar = NULL; + su2double* Buffer_Receive_PrimVar = NULL; /*--- Basic dimensionalization ---*/ @@ -1950,13 +1880,13 @@ void CEulerSolver::Set_MPI_Nearfield(CGeometry *geometry, CConfig *config) { /*--- Total counts for allocating send buffers below ---*/ - Buffer_Size_PrimVar += nPointTotal_s[iDomain]*(nPrimVar+3); + Buffer_Size_PrimVar += nPointTotal_s[iDomain]*(nPrimVar+3); } /*--- Allocate the buffer vectors in the appropiate domain (master, iDomain) ---*/ - Buffer_Send_PrimVar = new su2double[Buffer_Size_PrimVar]; + Buffer_Send_PrimVar = new su2double[Buffer_Size_PrimVar]; /*--- Now that we know the sizes of the point, we can allocate and send the information in large chunks to all processors. ---*/ @@ -2044,9 +1974,9 @@ void CEulerSolver::Set_MPI_Nearfield(CGeometry *geometry, CConfig *config) { for (iVar = 0; iVar < nPrimVar; 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+0)] = su2double(iGlobalIndex); Buffer_Send_PrimVar[(nPrimVar+3)*(PointTotal_Counter+iPointTotal)+(nPrimVar+1)] = su2double(jVertex); - Buffer_Send_PrimVar[(nPrimVar+3)*(PointTotal_Counter+iPointTotal)+(nPrimVar+2)] = su2double(jMarker); + Buffer_Send_PrimVar[(nPrimVar+3)*(PointTotal_Counter+iPointTotal)+(nPrimVar+2)] = su2double(jMarker); iPointTotal++; @@ -2079,7 +2009,7 @@ void CEulerSolver::Set_MPI_Nearfield(CGeometry *geometry, CConfig *config) { /*--- Allocate local memory for the local recv of the elements ---*/ - Buffer_Receive_PrimVar = new su2double[nPointTotal_s[iDomain]*(nPrimVar+3)]; + Buffer_Receive_PrimVar = new su2double[nPointTotal_s[iDomain]*(nPrimVar+3)]; for (iter = 0; iter < nPointTotal_s[iDomain]*(nPrimVar+3); iter++) Buffer_Receive_PrimVar[iter] = Buffer_Send_PrimVar[PointTotal_Counter*(nPrimVar+3)+iter]; @@ -2088,8 +2018,8 @@ void CEulerSolver::Set_MPI_Nearfield(CGeometry *geometry, CConfig *config) { for (iPoint = 0; iPoint < nPointTotal_r[iDomain]; iPoint++) { - iGlobal = SU2_TYPE::Int(Buffer_Receive_PrimVar[iPoint*(nPrimVar+3)+(nPrimVar+0)]); - iVertex = SU2_TYPE::Int(Buffer_Receive_PrimVar[iPoint*(nPrimVar+3)+(nPrimVar+1)]); + iGlobal = SU2_TYPE::Int(Buffer_Receive_PrimVar[iPoint*(nPrimVar+3)+(nPrimVar+0)]); + iVertex = SU2_TYPE::Int(Buffer_Receive_PrimVar[iPoint*(nPrimVar+3)+(nPrimVar+1)]); iMarker = SU2_TYPE::Int(Buffer_Receive_PrimVar[iPoint*(nPrimVar+3)+(nPrimVar+2)]); for (iVar = 0; iVar < nPrimVar; iVar++) iPrimVar[iVar] = Buffer_Receive_PrimVar[iPoint*(nPrimVar+3)+iVar]; @@ -2140,7 +2070,7 @@ void CEulerSolver::Set_MPI_Nearfield(CGeometry *geometry, CConfig *config) { /*--- Allocate the receive buffer vector. Send the colors so that we know whether what we recv is an owned or halo node. ---*/ - Buffer_Receive_PrimVar = new su2double [nPointTotal_r[iDomain]*(nPrimVar+3)]; + Buffer_Receive_PrimVar = new su2double [nPointTotal_r[iDomain]*(nPrimVar+3)]; /*--- Receive the buffers with the coords, global index, and colors ---*/ @@ -2220,10 +2150,10 @@ void CEulerSolver::SetNondimensionalization(CConfig *config, unsigned short iMes /*--- Local variables ---*/ - su2double Alpha = config->GetAoA()*PI_NUMBER/180.0; - su2double Beta = config->GetAoS()*PI_NUMBER/180.0; - su2double Mach = config->GetMach(); - su2double Reynolds = config->GetReynolds(); + su2double Alpha = config->GetAoA()*PI_NUMBER/180.0; + su2double Beta = config->GetAoS()*PI_NUMBER/180.0; + su2double Mach = config->GetMach(); + su2double Reynolds = config->GetReynolds(); bool unsteady = (config->GetTime_Marching() != NO); bool viscous = config->GetViscous(); bool gravity = config->GetGravityForce(); @@ -2249,82 +2179,61 @@ void CEulerSolver::SetNondimensionalization(CConfig *config, unsigned short iMes Pressure_FreeStream = config->GetPressure_FreeStream(); Density_FreeStream = config->GetDensity_FreeStream(); - Temperature_FreeStream = config->GetTemperature_FreeStream(); + Temperature_FreeStream = config->GetTemperature_FreeStream(); + + CFluidModel* auxFluidModel = nullptr; switch (config->GetKind_FluidModel()) { case STANDARD_AIR: - if (config->GetSystemMeasurements() == SI) config->SetGas_Constant(287.058); - else if (config->GetSystemMeasurements() == US) config->SetGas_Constant(1716.49); - - FluidModel = new CIdealGas(1.4, config->GetGas_Constant()); - if (free_stream_temp) { - if (aeroelastic) { - Temperature_FreeStream = TgammaR / (config->GetGas_Constant()*1.4); - config->SetTemperature_FreeStream(Temperature_FreeStream); - } - FluidModel->SetTDState_PT(Pressure_FreeStream, Temperature_FreeStream); - Density_FreeStream = FluidModel->GetDensity(); - config->SetDensity_FreeStream(Density_FreeStream); + switch (config->GetSystemMeasurements()) { + case SI: config->SetGas_Constant(287.058); break; + case US: config->SetGas_Constant(1716.49); break; } - else { - FluidModel->SetTDState_Prho(Pressure_FreeStream, Density_FreeStream ); - Temperature_FreeStream = FluidModel->GetTemperature(); + + auxFluidModel = new CIdealGas(1.4, config->GetGas_Constant()); + + if (free_stream_temp && aeroelastic) { + Temperature_FreeStream = TgammaR / (config->GetGas_Constant()*1.4); config->SetTemperature_FreeStream(Temperature_FreeStream); } break; case IDEAL_GAS: - FluidModel = new CIdealGas(Gamma, config->GetGas_Constant()); - if (free_stream_temp) { - FluidModel->SetTDState_PT(Pressure_FreeStream, Temperature_FreeStream); - Density_FreeStream = FluidModel->GetDensity(); - config->SetDensity_FreeStream(Density_FreeStream); - } - else { - FluidModel->SetTDState_Prho(Pressure_FreeStream, Density_FreeStream ); - Temperature_FreeStream = FluidModel->GetTemperature(); - config->SetTemperature_FreeStream(Temperature_FreeStream); - } + auxFluidModel = new CIdealGas(Gamma, config->GetGas_Constant()); break; case VW_GAS: - FluidModel = new CVanDerWaalsGas(Gamma, config->GetGas_Constant(), - config->GetPressure_Critical(), config->GetTemperature_Critical()); - if (free_stream_temp) { - FluidModel->SetTDState_PT(Pressure_FreeStream, Temperature_FreeStream); - Density_FreeStream = FluidModel->GetDensity(); - config->SetDensity_FreeStream(Density_FreeStream); - } - else { - FluidModel->SetTDState_Prho(Pressure_FreeStream, Density_FreeStream ); - Temperature_FreeStream = FluidModel->GetTemperature(); - config->SetTemperature_FreeStream(Temperature_FreeStream); - } + auxFluidModel = new CVanDerWaalsGas(Gamma, config->GetGas_Constant(), + config->GetPressure_Critical(), config->GetTemperature_Critical()); break; case PR_GAS: - FluidModel = new CPengRobinson(Gamma, config->GetGas_Constant(), config->GetPressure_Critical(), - config->GetTemperature_Critical(), config->GetAcentric_Factor()); - if (free_stream_temp) { - FluidModel->SetTDState_PT(Pressure_FreeStream, Temperature_FreeStream); - Density_FreeStream = FluidModel->GetDensity(); - config->SetDensity_FreeStream(Density_FreeStream); - } - else { - FluidModel->SetTDState_Prho(Pressure_FreeStream, Density_FreeStream ); - Temperature_FreeStream = FluidModel->GetTemperature(); - config->SetTemperature_FreeStream(Temperature_FreeStream); - } + auxFluidModel = new CPengRobinson(Gamma, config->GetGas_Constant(), config->GetPressure_Critical(), + config->GetTemperature_Critical(), config->GetAcentric_Factor()); + break; + + default: + SU2_MPI::Error("Unknown fluid model.", CURRENT_FUNCTION); break; + } + if (free_stream_temp) { + auxFluidModel->SetTDState_PT(Pressure_FreeStream, Temperature_FreeStream); + Density_FreeStream = auxFluidModel->GetDensity(); + config->SetDensity_FreeStream(Density_FreeStream); + } + else { + auxFluidModel->SetTDState_Prho(Pressure_FreeStream, Density_FreeStream ); + Temperature_FreeStream = auxFluidModel->GetTemperature(); + config->SetTemperature_FreeStream(Temperature_FreeStream); } - Mach2Vel_FreeStream = FluidModel->GetSoundSpeed(); + Mach2Vel_FreeStream = auxFluidModel->GetSoundSpeed(); /*--- Compute the Free Stream velocity, using the Mach number ---*/ @@ -2373,17 +2282,17 @@ void CEulerSolver::SetNondimensionalization(CConfig *config, unsigned short iMes from the dimensional version of Sutherland's law or the constant viscosity, depending on the input option.---*/ - FluidModel->SetLaminarViscosityModel(config); + auxFluidModel->SetLaminarViscosityModel(config); - Viscosity_FreeStream = FluidModel->GetLaminarViscosity(); + Viscosity_FreeStream = auxFluidModel->GetLaminarViscosity(); config->SetViscosity_FreeStream(Viscosity_FreeStream); Density_FreeStream = Reynolds*Viscosity_FreeStream/(Velocity_Reynolds*config->GetLength_Reynolds()); config->SetDensity_FreeStream(Density_FreeStream); - FluidModel->SetTDState_rhoT(Density_FreeStream, Temperature_FreeStream); - Pressure_FreeStream = FluidModel->GetPressure(); + auxFluidModel->SetTDState_rhoT(Density_FreeStream, Temperature_FreeStream); + Pressure_FreeStream = auxFluidModel->GetPressure(); config->SetPressure_FreeStream(Pressure_FreeStream); - Energy_FreeStream = FluidModel->GetStaticEnergy() + 0.5*ModVel_FreeStream*ModVel_FreeStream; + Energy_FreeStream = auxFluidModel->GetStaticEnergy() + 0.5*ModVel_FreeStream*ModVel_FreeStream; } @@ -2391,10 +2300,10 @@ void CEulerSolver::SetNondimensionalization(CConfig *config, unsigned short iMes else { - FluidModel->SetLaminarViscosityModel(config); - Viscosity_FreeStream = FluidModel->GetLaminarViscosity(); + auxFluidModel->SetLaminarViscosityModel(config); + Viscosity_FreeStream = auxFluidModel->GetLaminarViscosity(); config->SetViscosity_FreeStream(Viscosity_FreeStream); - Energy_FreeStream = FluidModel->GetStaticEnergy() + 0.5*ModVel_FreeStream*ModVel_FreeStream; + Energy_FreeStream = auxFluidModel->GetStaticEnergy() + 0.5*ModVel_FreeStream*ModVel_FreeStream; } @@ -2408,7 +2317,7 @@ void CEulerSolver::SetNondimensionalization(CConfig *config, unsigned short iMes /*--- For inviscid flow, energy is calculated from the specified FreeStream quantities using the proper gas law. ---*/ - Energy_FreeStream = FluidModel->GetStaticEnergy() + 0.5*ModVel_FreeStream*ModVel_FreeStream; + Energy_FreeStream = auxFluidModel->GetStaticEnergy() + 0.5*ModVel_FreeStream*ModVel_FreeStream; } @@ -2488,58 +2397,71 @@ void CEulerSolver::SetNondimensionalization(CConfig *config, unsigned short iMes /*--- Initialize the dimensionless Fluid Model that will be used to solve the dimensionless problem ---*/ - /*--- Delete the original (dimensional) FluidModel object before replacing. ---*/ + /*--- Auxilary (dimensional) FluidModel no longer needed. ---*/ + delete auxFluidModel; - delete FluidModel; + /*--- Set viscosity ND constants before defining the visc. model of the fluid models. ---*/ - switch (config->GetKind_FluidModel()) { + if (viscous) { + /*--- Constant viscosity model. ---*/ + config->SetMu_ConstantND(config->GetMu_Constant()/Viscosity_Ref); - case STANDARD_AIR: - FluidModel = new CIdealGas(1.4, Gas_ConstantND); - FluidModel->SetEnergy_Prho(Pressure_FreeStreamND, Density_FreeStreamND); - break; + /*--- Sutherland's model. ---*/ + config->SetMu_RefND(config->GetMu_Ref()/Viscosity_Ref); + config->SetMu_SND(config->GetMu_S()/config->GetTemperature_Ref()); + config->SetMu_Temperature_RefND(config->GetMu_Temperature_Ref()/config->GetTemperature_Ref()); - case IDEAL_GAS: - FluidModel = new CIdealGas(Gamma, Gas_ConstantND); - FluidModel->SetEnergy_Prho(Pressure_FreeStreamND, Density_FreeStreamND); - break; + /*--- Constant thermal conductivity model. ---*/ + config->SetKt_ConstantND(config->GetKt_Constant()/Conductivity_Ref); + } - case VW_GAS: - FluidModel = new CVanDerWaalsGas(Gamma, Gas_ConstantND, config->GetPressure_Critical() /config->GetPressure_Ref(), - config->GetTemperature_Critical()/config->GetTemperature_Ref()); - FluidModel->SetEnergy_Prho(Pressure_FreeStreamND, Density_FreeStreamND); - break; + /*--- Create one final fluid model object per OpenMP thread to be able to use them in parallel. + * GetFluidModel() should be used to automatically access the "right" object of each thread. ---*/ - case PR_GAS: - FluidModel = new CPengRobinson(Gamma, Gas_ConstantND, config->GetPressure_Critical() /config->GetPressure_Ref(), - config->GetTemperature_Critical()/config->GetTemperature_Ref(), config->GetAcentric_Factor()); - FluidModel->SetEnergy_Prho(Pressure_FreeStreamND, Density_FreeStreamND); - break; + assert(FluidModel.empty() && "Potential memory leak!"); + FluidModel.resize(omp_get_max_threads()); - } + SU2_OMP_PARALLEL + { + const int thread = omp_get_thread_num(); - Energy_FreeStreamND = FluidModel->GetStaticEnergy() + 0.5*ModVel_FreeStreamND*ModVel_FreeStreamND; + switch (config->GetKind_FluidModel()) { - if (viscous) { + case STANDARD_AIR: + FluidModel[thread] = new CIdealGas(1.4, Gas_ConstantND); + break; - /*--- Constant viscosity model ---*/ - config->SetMu_ConstantND(config->GetMu_Constant()/Viscosity_Ref); + case IDEAL_GAS: + FluidModel[thread] = new CIdealGas(Gamma, Gas_ConstantND); + break; - /*--- Sutherland's model ---*/ + case VW_GAS: + FluidModel[thread] = new CVanDerWaalsGas(Gamma, Gas_ConstantND, + config->GetPressure_Critical() / config->GetPressure_Ref(), + config->GetTemperature_Critical() / config->GetTemperature_Ref()); + break; - config->SetMu_RefND(config->GetMu_Ref()/Viscosity_Ref); - config->SetMu_SND(config->GetMu_S()/config->GetTemperature_Ref()); - config->SetMu_Temperature_RefND(config->GetMu_Temperature_Ref()/config->GetTemperature_Ref()); + case PR_GAS: + FluidModel[thread] = new CPengRobinson(Gamma, Gas_ConstantND, + config->GetPressure_Critical() / config->GetPressure_Ref(), + config->GetTemperature_Critical() / config->GetTemperature_Ref(), + config->GetAcentric_Factor()); + break; + } - /* constant thermal conductivity model */ - config->SetKt_ConstantND(config->GetKt_Constant()/Conductivity_Ref); + GetFluidModel()->SetEnergy_Prho(Pressure_FreeStreamND, Density_FreeStreamND); + if (viscous) { + GetFluidModel()->SetLaminarViscosityModel(config); + GetFluidModel()->SetThermalConductivityModel(config); + } - FluidModel->SetLaminarViscosityModel(config); - FluidModel->SetThermalConductivityModel(config); + } // end SU2_OMP_PARALLEL - } + Energy_FreeStreamND = GetFluidModel()->GetStaticEnergy() + 0.5*ModVel_FreeStreamND*ModVel_FreeStreamND; - if (tkeNeeded) { Energy_FreeStreamND += Tke_FreeStreamND; }; config->SetEnergy_FreeStreamND(Energy_FreeStreamND); + if (tkeNeeded) Energy_FreeStreamND += Tke_FreeStreamND; + + config->SetEnergy_FreeStreamND(Energy_FreeStreamND); Energy_Ref = Energy_FreeStream/Energy_FreeStreamND; config->SetEnergy_Ref(Energy_Ref); @@ -2758,26 +2680,31 @@ void CEulerSolver::SetNondimensionalization(CConfig *config, unsigned short iMes void CEulerSolver::SetInitialCondition(CGeometry **geometry, CSolver ***solver_container, CConfig *config, unsigned long TimeIter) { + const bool restart = (config->GetRestart() || config->GetRestart_Flow()); + const bool rans = (config->GetKind_Turb_Model() != NONE); + const bool dual_time = ((config->GetTime_Marching() == DT_STEPPING_1ST) || + (config->GetTime_Marching() == DT_STEPPING_2ND)); + const bool SubsonicEngine = config->GetSubsonicEngine(); + + /*--- Start OpenMP parallel region. ---*/ + + SU2_OMP_PARALLEL + { + unsigned long iPoint; unsigned short iMesh, iDim; su2double X0[3] = {0.0,0.0,0.0}, X1[3] = {0.0,0.0,0.0}, X2[3] = {0.0,0.0,0.0}, X1_X0[3] = {0.0,0.0,0.0}, X2_X0[3] = {0.0,0.0,0.0}, X2_X1[3] = {0.0,0.0,0.0}, CP[3] = {0.0,0.0,0.0}, Distance, DotCheck, Radius; - unsigned short nDim = geometry[MESH_0]->GetnDim(); - bool restart = (config->GetRestart() || config->GetRestart_Flow()); - bool rans = (config->GetKind_Turb_Model() != NONE); - bool dual_time = ((config->GetTime_Marching() == DT_STEPPING_1ST) || - (config->GetTime_Marching() == DT_STEPPING_2ND)); - bool SubsonicEngine = config->GetSubsonicEngine(); - /*--- Check if a verification solution is to be computed. ---*/ - if ((VerificationSolution) && (TimeIter == 0) && !restart) { + if ((VerificationSolution) && (TimeIter == 0) && !restart) { /*--- Loop over the multigrid levels. ---*/ for (iMesh = 0; iMesh <= config->GetnMGLevels(); iMesh++) { /*--- Loop over all grid points. ---*/ + SU2_OMP_FOR_STAT(omp_chunk_size) for (iPoint = 0; iPoint < geometry[iMesh]->GetnPoint(); iPoint++) { /* Set the pointers to the coordinates and solution of this DOF. */ @@ -2803,7 +2730,8 @@ void CEulerSolver::SetInitialCondition(CGeometry **geometry, CSolver ***solver_c su2double Velocity_Cyl[3] = {0.0, 0.0, 0.0}, Velocity_CylND[3] = {0.0, 0.0, 0.0}, Viscosity_Cyl, Density_Cyl, Density_CylND, Pressure_CylND, ModVel_Cyl, ModVel_CylND, Energy_CylND, - T_ref = 0.0, S = 0.0, Mu_ref = 0.0, *Coord, *SubsonicEngine_Cyl, *SubsonicEngine_Values; + T_ref = 0.0, S = 0.0, Mu_ref = 0.0; + const su2double *Coord, *SubsonicEngine_Cyl, *SubsonicEngine_Values; SubsonicEngine_Values = config->GetSubsonicEngine_Values(); su2double Mach_Cyl = SubsonicEngine_Values[0]; @@ -2822,6 +2750,7 @@ void CEulerSolver::SetInitialCondition(CGeometry **geometry, CSolver ***solver_c for (iMesh = 0; iMesh <= config->GetnMGLevels(); iMesh++) { + SU2_OMP_FOR_STAT(omp_chunk_size) for (iPoint = 0; iPoint < geometry[iMesh]->GetnPoint(); iPoint++) { Velocity_Cyl[0] = cos(Alpha)*cos(Beta)*Mach_Cyl*Mach2Vel_Cyl; @@ -2868,9 +2797,9 @@ void CEulerSolver::SetInitialCondition(CGeometry **geometry, CSolver ***solver_c SubsonicEngine_Cyl = config->GetSubsonicEngine_Cyl(); - X0[0] = Coord[0]; X0[1] = Coord[1]; X0[2] = Coord[2]; - X1[0] = SubsonicEngine_Cyl[0]; X1[1] = SubsonicEngine_Cyl[1]; X1[2] = SubsonicEngine_Cyl[2]; - X2[0] = SubsonicEngine_Cyl[3]; X2[1] = SubsonicEngine_Cyl[4]; X2[2] = SubsonicEngine_Cyl[5]; + X0[0] = Coord[0]; X0[1] = Coord[1]; X0[2] = Coord[2]; + X1[0] = SubsonicEngine_Cyl[0]; X1[1] = SubsonicEngine_Cyl[1]; X1[2] = SubsonicEngine_Cyl[2]; + X2[0] = SubsonicEngine_Cyl[3]; X2[1] = SubsonicEngine_Cyl[4]; X2[2] = SubsonicEngine_Cyl[5]; Radius = SubsonicEngine_Cyl[6]; for (iDim = 0; iDim < nDim; iDim++) { @@ -2909,11 +2838,15 @@ void CEulerSolver::SetInitialCondition(CGeometry **geometry, CSolver ***solver_c /*--- Set the MPI communication ---*/ - solver_container[iMesh][FLOW_SOL]->InitiateComms(geometry[iMesh], config, SOLUTION); - solver_container[iMesh][FLOW_SOL]->CompleteComms(geometry[iMesh], config, SOLUTION); + SU2_OMP_MASTER + { + solver_container[iMesh][FLOW_SOL]->InitiateComms(geometry[iMesh], config, SOLUTION); + solver_container[iMesh][FLOW_SOL]->CompleteComms(geometry[iMesh], config, SOLUTION); - solver_container[iMesh][FLOW_SOL]->InitiateComms(geometry[iMesh], config, SOLUTION_OLD); - solver_container[iMesh][FLOW_SOL]->CompleteComms(geometry[iMesh], config, SOLUTION_OLD); + solver_container[iMesh][FLOW_SOL]->InitiateComms(geometry[iMesh], config, SOLUTION_OLD); + solver_container[iMesh][FLOW_SOL]->CompleteComms(geometry[iMesh], config, SOLUTION_OLD); + } + SU2_OMP_BARRIER } @@ -2921,15 +2854,19 @@ void CEulerSolver::SetInitialCondition(CGeometry **geometry, CSolver ***solver_c } + } // end SU2_OMP_PARALLEL + + /// TODO: The rest in not included in parallel region because Set_Solution_time_n* does not have worksharing yet. + /*--- Make sure that the solution is well initialized for unsteady calculations with dual time-stepping (load additional restarts for 2nd-order). ---*/ - if (dual_time && (TimeIter == 0 || (restart && (long)TimeIter == (long)config->GetRestart_Iter()))) { + if (dual_time && ((TimeIter == 0) || (restart && (TimeIter == config->GetRestart_Iter()))) ) { /*--- Push back the initial condition to previous solution containers for a 1st-order restart or when simply intitializing to freestream. ---*/ - for (iMesh = 0; iMesh <= config->GetnMGLevels(); iMesh++) { + for (unsigned short iMesh = 0; iMesh <= config->GetnMGLevels(); iMesh++) { solver_container[iMesh][FLOW_SOL]->GetNodes()->Set_Solution_time_n(); solver_container[iMesh][FLOW_SOL]->GetNodes()->Set_Solution_time_n1(); if (rans) { @@ -2938,8 +2875,7 @@ void CEulerSolver::SetInitialCondition(CGeometry **geometry, CSolver ***solver_c } } - if ((restart && (long)TimeIter == (long)config->GetRestart_Iter()) && - (config->GetTime_Marching() == DT_STEPPING_2ND)) { + if (restart && (TimeIter == config->GetRestart_Iter()) && (config->GetTime_Marching() == DT_STEPPING_2ND)) { /*--- Load an additional restart file for a 2nd-order restart ---*/ @@ -2951,7 +2887,7 @@ 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 (unsigned short iMesh = 0; iMesh <= config->GetnMGLevels(); iMesh++) { solver_container[iMesh][FLOW_SOL]->GetNodes()->Set_Solution_time_n(); if (rans) { solver_container[iMesh][TURB_SOL]->GetNodes()->Set_Solution_time_n(); @@ -3070,15 +3006,15 @@ void CEulerSolver::Postprocessing(CGeometry *geometry, CSolver **solver_containe unsigned long CEulerSolver::SetPrimitive_Variables(CSolver **solver_container, CConfig *config, bool Output) { - unsigned long iPoint, nonPhysicalPoints = 0; - bool physical = true; + unsigned long nonPhysicalPoints = 0; - for (iPoint = 0; iPoint < nPoint; iPoint ++) { + SU2_OMP(parallel for schedule(static,omp_chunk_size) reduction(+:nonPhysicalPoints)) + for (unsigned long iPoint = 0; iPoint < nPoint; iPoint ++) { /*--- Compressible flow, primitive variables nDim+5, (T, vx, vy, vz, P, rho, h, c, lamMu, eddyMu, ThCond, Cp) ---*/ - physical = nodes->SetPrimVar(iPoint, FluidModel); - nodes->SetSecondaryVar(iPoint, FluidModel); + bool physical = nodes->SetPrimVar(iPoint, GetFluidModel()); + nodes->SetSecondaryVar(iPoint, GetFluidModel()); /* Check for non-realizable states for reporting. */ @@ -3463,11 +3399,11 @@ void CEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_contain Primitive_j[iDim+1] = vel_j_corr[iDim]; } - FluidModel->SetEnergy_Prho(Primitive_i[nDim+1],Primitive_i[nDim+2]); - Primitive_i[nDim+3]= FluidModel->GetStaticEnergy() + Primitive_i[nDim+1]/Primitive_i[nDim+2] + 0.5*velocity2_i; + GetFluidModel()->SetEnergy_Prho(Primitive_i[nDim+1],Primitive_i[nDim+2]); + Primitive_i[nDim+3]= GetFluidModel()->GetStaticEnergy() + Primitive_i[nDim+1]/Primitive_i[nDim+2] + 0.5*velocity2_i; - FluidModel->SetEnergy_Prho(Primitive_j[nDim+1],Primitive_j[nDim+2]); - Primitive_j[nDim+3]= FluidModel->GetStaticEnergy() + Primitive_j[nDim+1]/Primitive_j[nDim+2] + 0.5*velocity2_j; + GetFluidModel()->SetEnergy_Prho(Primitive_j[nDim+1],Primitive_j[nDim+2]); + Primitive_j[nDim+3]= GetFluidModel()->GetStaticEnergy() + Primitive_j[nDim+1]/Primitive_j[nDim+2] + 0.5*velocity2_j; } @@ -3612,13 +3548,13 @@ void CEulerSolver::ComputeConsExtrapolation(CConfig *config) { velocity2_i += Primitive_i[iDim+1]*Primitive_i[iDim+1]; } - FluidModel->SetTDState_Prho(pressure_i, density_i); + GetFluidModel()->SetTDState_Prho(pressure_i, density_i); - Primitive_i[0]= FluidModel->GetTemperature(); - Primitive_i[nDim+3]= FluidModel->GetStaticEnergy() + Primitive_i[nDim+1]/Primitive_i[nDim+2] + 0.5*velocity2_i; - Primitive_i[nDim+4]= FluidModel->GetSoundSpeed(); - Secondary_i[0]=FluidModel->GetdPdrho_e(); - Secondary_i[1]=FluidModel->GetdPde_rho(); + Primitive_i[0]= GetFluidModel()->GetTemperature(); + Primitive_i[nDim+3]= GetFluidModel()->GetStaticEnergy() + Primitive_i[nDim+1]/Primitive_i[nDim+2] + 0.5*velocity2_i; + Primitive_i[nDim+4]= GetFluidModel()->GetSoundSpeed(); + Secondary_i[0]=GetFluidModel()->GetdPdrho_e(); + Secondary_i[1]=GetFluidModel()->GetdPde_rho(); su2double density_j = Primitive_j[nDim+2]; @@ -3628,13 +3564,13 @@ void CEulerSolver::ComputeConsExtrapolation(CConfig *config) { velocity2_j += Primitive_j[iDim+1]*Primitive_j[iDim+1]; } - FluidModel->SetTDState_Prho(pressure_j, density_j); + GetFluidModel()->SetTDState_Prho(pressure_j, density_j); - Primitive_j[0]= FluidModel->GetTemperature(); - Primitive_j[nDim+3]= FluidModel->GetStaticEnergy() + Primitive_j[nDim+1]/Primitive_j[nDim+2] + 0.5*velocity2_j; - Primitive_j[nDim+4]=FluidModel->GetSoundSpeed(); - Secondary_j[0]=FluidModel->GetdPdrho_e(); - Secondary_j[1]=FluidModel->GetdPde_rho(); + Primitive_j[0]= GetFluidModel()->GetTemperature(); + Primitive_j[nDim+3]= GetFluidModel()->GetStaticEnergy() + Primitive_j[nDim+1]/Primitive_j[nDim+2] + 0.5*velocity2_j; + Primitive_j[nDim+4]=GetFluidModel()->GetSoundSpeed(); + Secondary_j[0]=GetFluidModel()->GetdPdrho_e(); + Secondary_j[1]=GetFluidModel()->GetdPde_rho(); } @@ -7946,15 +7882,15 @@ void CEulerSolver::BC_Riemann(CGeometry *geometry, CSolver **solver_container, Energy_i = nodes->GetEnergy(iPoint); StaticEnergy_i = Energy_i - 0.5*Velocity2_i; - FluidModel->SetTDState_rhoe(Density_i, StaticEnergy_i); + GetFluidModel()->SetTDState_rhoe(Density_i, StaticEnergy_i); - Pressure_i = FluidModel->GetPressure(); + Pressure_i = GetFluidModel()->GetPressure(); Enthalpy_i = Energy_i + Pressure_i/Density_i; - SoundSpeed_i = FluidModel->GetSoundSpeed(); + SoundSpeed_i = GetFluidModel()->GetSoundSpeed(); - Kappa_i = FluidModel->GetdPde_rho() / Density_i; - Chi_i = FluidModel->GetdPdrho_e() - Kappa_i * StaticEnergy_i; + Kappa_i = GetFluidModel()->GetdPde_rho() / Density_i; + Chi_i = GetFluidModel()->GetdPdrho_e() - Kappa_i * StaticEnergy_i; ProjVelocity_i = 0.0; for (iDim = 0; iDim < nDim; iDim++) @@ -7977,9 +7913,9 @@ void CEulerSolver::BC_Riemann(CGeometry *geometry, CSolver **solver_container, T_Total /= config->GetTemperature_Ref(); /* --- Computes the total state --- */ - FluidModel->SetTDState_PT(P_Total, T_Total); - Enthalpy_e = FluidModel->GetStaticEnergy()+ FluidModel->GetPressure()/FluidModel->GetDensity(); - Entropy_e = FluidModel->GetEntropy(); + GetFluidModel()->SetTDState_PT(P_Total, T_Total); + Enthalpy_e = GetFluidModel()->GetStaticEnergy()+ GetFluidModel()->GetPressure()/GetFluidModel()->GetDensity(); + Entropy_e = GetFluidModel()->GetEntropy(); /* --- Compute the boundary state u_e --- */ Velocity2_e = Velocity2_i; @@ -7993,9 +7929,9 @@ void CEulerSolver::BC_Riemann(CGeometry *geometry, CSolver **solver_container, Velocity_e[iDim] = sqrt(Velocity2_e)*Flow_Dir[iDim]; } StaticEnthalpy_e = Enthalpy_e - 0.5 * Velocity2_e; - FluidModel->SetTDState_hs(StaticEnthalpy_e, Entropy_e); - Density_e = FluidModel->GetDensity(); - StaticEnergy_e = FluidModel->GetStaticEnergy(); + GetFluidModel()->SetTDState_hs(StaticEnthalpy_e, Entropy_e); + Density_e = GetFluidModel()->GetDensity(); + StaticEnergy_e = GetFluidModel()->GetStaticEnergy(); Energy_e = StaticEnergy_e + 0.5 * Velocity2_e; if (tkeNeeded) Energy_e += GetTke_Inf(); break; @@ -8013,16 +7949,16 @@ void CEulerSolver::BC_Riemann(CGeometry *geometry, CSolver **solver_container, T_static /= config->GetTemperature_Ref(); /* --- Computes the total state --- */ - FluidModel->SetTDState_PT(P_static, T_static); + GetFluidModel()->SetTDState_PT(P_static, T_static); /* --- Compute the boundary state u_e --- */ Velocity2_e = 0.0; for (iDim = 0; iDim < nDim; iDim++) { - Velocity_e[iDim] = Mach[iDim]*FluidModel->GetSoundSpeed(); + Velocity_e[iDim] = Mach[iDim]*GetFluidModel()->GetSoundSpeed(); Velocity2_e += Velocity_e[iDim]*Velocity_e[iDim]; } - Density_e = FluidModel->GetDensity(); - StaticEnergy_e = FluidModel->GetStaticEnergy(); + Density_e = GetFluidModel()->GetDensity(); + StaticEnergy_e = GetFluidModel()->GetStaticEnergy(); Energy_e = StaticEnergy_e + 0.5 * Velocity2_e; if (tkeNeeded) Energy_e += GetTke_Inf(); break; @@ -8041,16 +7977,16 @@ void CEulerSolver::BC_Riemann(CGeometry *geometry, CSolver **solver_container, Rho_static /= config->GetDensity_Ref(); /* --- Computes the total state --- */ - FluidModel->SetTDState_Prho(P_static, Rho_static); + GetFluidModel()->SetTDState_Prho(P_static, Rho_static); /* --- Compute the boundary state u_e --- */ Velocity2_e = 0.0; for (iDim = 0; iDim < nDim; iDim++) { - Velocity_e[iDim] = Mach[iDim]*FluidModel->GetSoundSpeed(); + Velocity_e[iDim] = Mach[iDim]*GetFluidModel()->GetSoundSpeed(); Velocity2_e += Velocity_e[iDim]*Velocity_e[iDim]; } - Density_e = FluidModel->GetDensity(); - StaticEnergy_e = FluidModel->GetStaticEnergy(); + Density_e = GetFluidModel()->GetDensity(); + StaticEnergy_e = GetFluidModel()->GetStaticEnergy(); Energy_e = StaticEnergy_e + 0.5 * Velocity2_e; if (tkeNeeded) Energy_e += GetTke_Inf(); break; @@ -8079,13 +8015,13 @@ void CEulerSolver::BC_Riemann(CGeometry *geometry, CSolver **solver_container, Density_e = Density_i; /* --- Compute the boundary state u_e --- */ - FluidModel->SetTDState_Prho(Pressure_e, Density_e); + GetFluidModel()->SetTDState_Prho(Pressure_e, Density_e); Velocity2_e = 0.0; for (iDim = 0; iDim < nDim; iDim++) { Velocity_e[iDim] = Velocity_i[iDim]; Velocity2_e += Velocity_e[iDim]*Velocity_e[iDim]; } - Energy_e = FluidModel->GetStaticEnergy() + 0.5*Velocity2_e; + Energy_e = GetFluidModel()->GetStaticEnergy() + 0.5*Velocity2_e; break; default: @@ -8162,12 +8098,12 @@ void CEulerSolver::BC_Riemann(CGeometry *geometry, CSolver **solver_container, } Energy_b = u_b[nVar-1]/Density_b; StaticEnergy_b = Energy_b - 0.5*Velocity2_b; - FluidModel->SetTDState_rhoe(Density_b, StaticEnergy_b); - Pressure_b = FluidModel->GetPressure(); - Temperature_b = FluidModel->GetTemperature(); + GetFluidModel()->SetTDState_rhoe(Density_b, StaticEnergy_b); + Pressure_b = GetFluidModel()->GetPressure(); + Temperature_b = GetFluidModel()->GetTemperature(); Enthalpy_b = Energy_b + Pressure_b/Density_b; - Kappa_b = FluidModel->GetdPde_rho() / Density_b; - Chi_b = FluidModel->GetdPdrho_e() - Kappa_b * StaticEnergy_b; + Kappa_b = GetFluidModel()->GetdPde_rho() / Density_b; + Chi_b = GetFluidModel()->GetdPdrho_e() - Kappa_b * StaticEnergy_b; /*--- Compute the residuals ---*/ conv_numerics->GetInviscidProjFlux(&Density_b, Velocity_b, &Pressure_b, &Enthalpy_b, Normal, Residual); @@ -8277,10 +8213,10 @@ 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+5] = GetFluidModel()->GetLaminarViscosity(); V_boundary[nDim+6] = nodes->GetEddyViscosity(iPoint); - V_boundary[nDim+7] = FluidModel->GetThermalConductivity(); - V_boundary[nDim+8] = FluidModel->GetCp(); + V_boundary[nDim+7] = GetFluidModel()->GetThermalConductivity(); + V_boundary[nDim+8] = GetFluidModel()->GetCp(); /*--- Set the normal vector and the coordinates ---*/ @@ -8298,19 +8234,19 @@ void CEulerSolver::BC_Riemann(CGeometry *geometry, CSolver **solver_container, /*--- Compute secondary thermodynamic properties (partial derivatives...) ---*/ - S_boundary[0]= FluidModel->GetdPdrho_e(); - S_boundary[1]= FluidModel->GetdPde_rho(); + S_boundary[0]= GetFluidModel()->GetdPdrho_e(); + S_boundary[1]= GetFluidModel()->GetdPde_rho(); - S_boundary[2]= FluidModel->GetdTdrho_e(); - S_boundary[3]= FluidModel->GetdTde_rho(); + S_boundary[2]= GetFluidModel()->GetdTdrho_e(); + S_boundary[3]= GetFluidModel()->GetdTde_rho(); /*--- Compute secondary thermo-physical properties (partial derivatives...) ---*/ - S_boundary[4]= FluidModel->Getdmudrho_T(); - S_boundary[5]= FluidModel->GetdmudT_rho(); + S_boundary[4]= GetFluidModel()->Getdmudrho_T(); + S_boundary[5]= GetFluidModel()->GetdmudT_rho(); - S_boundary[6]= FluidModel->Getdktdrho_T(); - S_boundary[7]= FluidModel->GetdktdT_rho(); + S_boundary[6]= GetFluidModel()->Getdktdrho_T(); + S_boundary[7]= GetFluidModel()->GetdktdT_rho(); visc_numerics->SetSecondary(S_domain, S_boundary); @@ -8452,15 +8388,15 @@ void CEulerSolver::BC_TurboRiemann(CGeometry *geometry, CSolver **solver_contain Energy_i = nodes->GetEnergy(iPoint); StaticEnergy_i = Energy_i - 0.5*Velocity2_i; - FluidModel->SetTDState_rhoe(Density_i, StaticEnergy_i); + GetFluidModel()->SetTDState_rhoe(Density_i, StaticEnergy_i); - Pressure_i = FluidModel->GetPressure(); + Pressure_i = GetFluidModel()->GetPressure(); Enthalpy_i = Energy_i + Pressure_i/Density_i; - SoundSpeed_i = FluidModel->GetSoundSpeed(); + SoundSpeed_i = GetFluidModel()->GetSoundSpeed(); - Kappa_i = FluidModel->GetdPde_rho() / Density_i; - Chi_i = FluidModel->GetdPdrho_e() - Kappa_i * StaticEnergy_i; + Kappa_i = GetFluidModel()->GetdPde_rho() / Density_i; + Chi_i = GetFluidModel()->GetdPdrho_e() - Kappa_i * StaticEnergy_i; ProjVelocity_i = 0.0; for (iDim = 0; iDim < nDim; iDim++) @@ -8486,9 +8422,9 @@ void CEulerSolver::BC_TurboRiemann(CGeometry *geometry, CSolver **solver_contain T_Total /= config->GetTemperature_Ref(); /* --- Computes the total state --- */ - FluidModel->SetTDState_PT(P_Total, T_Total); - Enthalpy_e = FluidModel->GetStaticEnergy()+ FluidModel->GetPressure()/FluidModel->GetDensity(); - Entropy_e = FluidModel->GetEntropy(); + GetFluidModel()->SetTDState_PT(P_Total, T_Total); + Enthalpy_e = GetFluidModel()->GetStaticEnergy()+ GetFluidModel()->GetPressure()/GetFluidModel()->GetDensity(); + Entropy_e = GetFluidModel()->GetEntropy(); /* --- Compute the boundary state u_e --- */ Velocity2_e = Velocity2_i; @@ -8496,9 +8432,9 @@ void CEulerSolver::BC_TurboRiemann(CGeometry *geometry, CSolver **solver_contain turboVelocity[iDim] = sqrt(Velocity2_e)*Flow_Dir[iDim]; ComputeBackVelocity(turboVelocity,turboNormal, Velocity_e, config->GetMarker_All_TurbomachineryFlag(val_marker),config->GetKind_TurboMachinery(iZone)); StaticEnthalpy_e = Enthalpy_e - 0.5 * Velocity2_e; - FluidModel->SetTDState_hs(StaticEnthalpy_e, Entropy_e); - Density_e = FluidModel->GetDensity(); - StaticEnergy_e = FluidModel->GetStaticEnergy(); + GetFluidModel()->SetTDState_hs(StaticEnthalpy_e, Entropy_e); + Density_e = GetFluidModel()->GetDensity(); + StaticEnergy_e = GetFluidModel()->GetStaticEnergy(); Energy_e = StaticEnergy_e + 0.5 * Velocity2_e; if (tkeNeeded) Energy_e += GetTke_Inf(); break; @@ -8506,9 +8442,9 @@ void CEulerSolver::BC_TurboRiemann(CGeometry *geometry, CSolver **solver_contain case MIXING_IN: /* --- compute total averaged quantities ---*/ - FluidModel->SetTDState_Prho(ExtAveragePressure[val_marker][iSpan], ExtAverageDensity[val_marker][iSpan]); - AverageEnthalpy = FluidModel->GetStaticEnergy() + ExtAveragePressure[val_marker][iSpan]/ExtAverageDensity[val_marker][iSpan]; - AverageEntropy = FluidModel->GetEntropy(); + GetFluidModel()->SetTDState_Prho(ExtAveragePressure[val_marker][iSpan], ExtAverageDensity[val_marker][iSpan]); + AverageEnthalpy = GetFluidModel()->GetStaticEnergy() + ExtAveragePressure[val_marker][iSpan]/ExtAverageDensity[val_marker][iSpan]; + AverageEntropy = GetFluidModel()->GetEntropy(); FlowDirMixMag = 0; for (iDim = 0; iDim < nDim; iDim++) @@ -8531,9 +8467,9 @@ void CEulerSolver::BC_TurboRiemann(CGeometry *geometry, CSolver **solver_contain ComputeBackVelocity(turboVelocity,turboNormal, Velocity_e, config->GetMarker_All_TurbomachineryFlag(val_marker),config->GetKind_TurboMachinery(iZone)); StaticEnthalpy_e = Enthalpy_e - 0.5 * Velocity2_e; - FluidModel->SetTDState_hs(StaticEnthalpy_e, Entropy_e); - Density_e = FluidModel->GetDensity(); - StaticEnergy_e = FluidModel->GetStaticEnergy(); + GetFluidModel()->SetTDState_hs(StaticEnthalpy_e, Entropy_e); + Density_e = GetFluidModel()->GetDensity(); + StaticEnergy_e = GetFluidModel()->GetStaticEnergy(); Energy_e = StaticEnergy_e + 0.5 * Velocity2_e; // if (tkeNeeded) Energy_e += GetTke_Inf(); break; @@ -8546,13 +8482,13 @@ void CEulerSolver::BC_TurboRiemann(CGeometry *geometry, CSolver **solver_contain Density_e = Density_i; /* --- Compute the boundary state u_e --- */ - FluidModel->SetTDState_Prho(Pressure_e, Density_e); + GetFluidModel()->SetTDState_Prho(Pressure_e, Density_e); Velocity2_e = 0.0; for (iDim = 0; iDim < nDim; iDim++) { Velocity_e[iDim] = Velocity_i[iDim]; Velocity2_e += Velocity_e[iDim]*Velocity_e[iDim]; } - Energy_e = FluidModel->GetStaticEnergy() + 0.5*Velocity2_e; + Energy_e = GetFluidModel()->GetStaticEnergy() + 0.5*Velocity2_e; break; case STATIC_PRESSURE: @@ -8563,13 +8499,13 @@ void CEulerSolver::BC_TurboRiemann(CGeometry *geometry, CSolver **solver_contain Density_e = Density_i; /* --- Compute the boundary state u_e --- */ - FluidModel->SetTDState_Prho(Pressure_e, Density_e); + GetFluidModel()->SetTDState_Prho(Pressure_e, Density_e); Velocity2_e = 0.0; for (iDim = 0; iDim < nDim; iDim++) { Velocity_e[iDim] = Velocity_i[iDim]; Velocity2_e += Velocity_e[iDim]*Velocity_e[iDim]; } - Energy_e = FluidModel->GetStaticEnergy() + 0.5*Velocity2_e; + Energy_e = GetFluidModel()->GetStaticEnergy() + 0.5*Velocity2_e; break; @@ -8580,13 +8516,13 @@ void CEulerSolver::BC_TurboRiemann(CGeometry *geometry, CSolver **solver_contain Density_e = Density_i; /* --- Compute the boundary state u_e --- */ - FluidModel->SetTDState_Prho(Pressure_e, Density_e); + GetFluidModel()->SetTDState_Prho(Pressure_e, Density_e); Velocity2_e = 0.0; for (iDim = 0; iDim < nDim; iDim++) { Velocity_e[iDim] = Velocity_i[iDim]; Velocity2_e += Velocity_e[iDim]*Velocity_e[iDim]; } - Energy_e = FluidModel->GetStaticEnergy() + 0.5*Velocity2_e; + Energy_e = GetFluidModel()->GetStaticEnergy() + 0.5*Velocity2_e; break; default: @@ -8663,12 +8599,12 @@ void CEulerSolver::BC_TurboRiemann(CGeometry *geometry, CSolver **solver_contain } Energy_b = u_b[nVar-1]/Density_b; StaticEnergy_b = Energy_b - 0.5*Velocity2_b; - FluidModel->SetTDState_rhoe(Density_b, StaticEnergy_b); - Pressure_b = FluidModel->GetPressure(); - Temperature_b = FluidModel->GetTemperature(); + GetFluidModel()->SetTDState_rhoe(Density_b, StaticEnergy_b); + Pressure_b = GetFluidModel()->GetPressure(); + Temperature_b = GetFluidModel()->GetTemperature(); Enthalpy_b = Energy_b + Pressure_b/Density_b; - Kappa_b = FluidModel->GetdPde_rho() / Density_b; - Chi_b = FluidModel->GetdPdrho_e() - Kappa_b * StaticEnergy_b; + Kappa_b = GetFluidModel()->GetdPde_rho() / Density_b; + Chi_b = GetFluidModel()->GetdPdrho_e() - Kappa_b * StaticEnergy_b; /*--- Compute the residuals ---*/ conv_numerics->GetInviscidProjFlux(&Density_b, Velocity_b, &Pressure_b, &Enthalpy_b, Normal, Residual); @@ -8778,10 +8714,10 @@ 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+5] = GetFluidModel()->GetLaminarViscosity(); V_boundary[nDim+6] = nodes->GetEddyViscosity(iPoint); - V_boundary[nDim+7] = FluidModel->GetThermalConductivity(); - V_boundary[nDim+8] = FluidModel->GetCp(); + V_boundary[nDim+7] = GetFluidModel()->GetThermalConductivity(); + V_boundary[nDim+8] = GetFluidModel()->GetCp(); /*--- Set the normal vector and the coordinates ---*/ @@ -8799,19 +8735,19 @@ void CEulerSolver::BC_TurboRiemann(CGeometry *geometry, CSolver **solver_contain /*--- Compute secondary thermodynamic properties (partial derivatives...) ---*/ - S_boundary[0]= FluidModel->GetdPdrho_e(); - S_boundary[1]= FluidModel->GetdPde_rho(); + S_boundary[0]= GetFluidModel()->GetdPdrho_e(); + S_boundary[1]= GetFluidModel()->GetdPde_rho(); - S_boundary[2]= FluidModel->GetdTdrho_e(); - S_boundary[3]= FluidModel->GetdTde_rho(); + S_boundary[2]= GetFluidModel()->GetdTdrho_e(); + S_boundary[3]= GetFluidModel()->GetdTde_rho(); /*--- Compute secondary thermo-physical properties (partial derivatives...) ---*/ - S_boundary[4]= FluidModel->Getdmudrho_T(); - S_boundary[5]= FluidModel->GetdmudT_rho(); + S_boundary[4]= GetFluidModel()->Getdmudrho_T(); + S_boundary[5]= GetFluidModel()->GetdmudT_rho(); - S_boundary[6]= FluidModel->Getdktdrho_T(); - S_boundary[7]= FluidModel->GetdktdT_rho(); + S_boundary[6]= GetFluidModel()->Getdktdrho_T(); + S_boundary[7]= GetFluidModel()->GetdktdT_rho(); visc_numerics->SetSecondary(S_domain, S_boundary); @@ -8930,8 +8866,8 @@ void CEulerSolver::PreprocessBC_Giles(CGeometry *geometry, CConfig *config, CNum deltaprim[4] = Pressure_i - AveragePressure[iMarker][iSpan]; } - FluidModel->SetTDState_Prho(AveragePressure[iMarker][iSpan], AverageDensity[iMarker][iSpan]); - AverageSoundSpeed = FluidModel->GetSoundSpeed(); + GetFluidModel()->SetTDState_Prho(AveragePressure[iMarker][iSpan], AverageDensity[iMarker][iSpan]); + AverageSoundSpeed = GetFluidModel()->GetSoundSpeed(); conv_numerics->GetCharJump(AverageSoundSpeed, AverageDensity[iMarker][iSpan], deltaprim, cj); /*-----this is only valid 2D ----*/ @@ -9121,8 +9057,8 @@ void CEulerSolver::BC_Giles(CGeometry *geometry, CSolver **solver_container, } } - FluidModel->SetTDState_Prho(AveragePressure[val_marker][iSpan], AverageDensity[val_marker][iSpan]); - AverageSoundSpeed = FluidModel->GetSoundSpeed(); + GetFluidModel()->SetTDState_Prho(AveragePressure[val_marker][iSpan], AverageDensity[val_marker][iSpan]); + AverageSoundSpeed = GetFluidModel()->GetSoundSpeed(); AverageTurboMach[0] = AverageTurboVelocity[val_marker][iSpan][0]/AverageSoundSpeed; AverageTurboMach[1] = AverageTurboVelocity[val_marker][iSpan][1]/AverageSoundSpeed; @@ -9156,17 +9092,18 @@ void CEulerSolver::BC_Giles(CGeometry *geometry, CSolver **solver_container, T_Total /= config->GetTemperature_Ref(); /* --- Computes the total state --- */ - FluidModel->SetTDState_PT(P_Total, T_Total); - Enthalpy_BC = FluidModel->GetStaticEnergy()+ FluidModel->GetPressure()/FluidModel->GetDensity(); - Entropy_BC = FluidModel->GetEntropy(); + GetFluidModel()->SetTDState_PT(P_Total, T_Total); + Enthalpy_BC = GetFluidModel()->GetStaticEnergy()+ GetFluidModel()->GetPressure()/GetFluidModel()->GetDensity(); + Entropy_BC = GetFluidModel()->GetEntropy(); /* --- Computes the inverse matrix R_c --- */ - conv_numerics->ComputeResJacobianGiles(FluidModel, AveragePressure[val_marker][iSpan], AverageDensity[val_marker][iSpan], AverageTurboVelocity[val_marker][iSpan], alphaIn_BC, gammaIn_BC, R_c, R_c_inv); + conv_numerics->ComputeResJacobianGiles(GetFluidModel(), AveragePressure[val_marker][iSpan], AverageDensity[val_marker][iSpan], + AverageTurboVelocity[val_marker][iSpan], alphaIn_BC, gammaIn_BC, R_c, R_c_inv); - FluidModel->SetTDState_Prho(AveragePressure[val_marker][iSpan], AverageDensity[val_marker][iSpan]); - AverageEnthalpy = FluidModel->GetStaticEnergy() + AveragePressure[val_marker][iSpan]/AverageDensity[val_marker][iSpan]; - AverageEntropy = FluidModel->GetEntropy(); + GetFluidModel()->SetTDState_Prho(AveragePressure[val_marker][iSpan], AverageDensity[val_marker][iSpan]); + AverageEnthalpy = GetFluidModel()->GetStaticEnergy() + AveragePressure[val_marker][iSpan]/AverageDensity[val_marker][iSpan]; + AverageEntropy = GetFluidModel()->GetEntropy(); avgVel2 = 0.0; for (iDim = 0; iDim < nDim; iDim++) avgVel2 += AverageVelocity[val_marker][iSpan][iDim]*AverageVelocity[val_marker][iSpan][iDim]; @@ -9211,17 +9148,18 @@ void CEulerSolver::BC_Giles(CGeometry *geometry, CSolver **solver_container, T_Total /= config->GetTemperature_Ref(); /* --- Computes the total state --- */ - FluidModel->SetTDState_PT(P_Total, T_Total); - Enthalpy_BC = FluidModel->GetStaticEnergy()+ FluidModel->GetPressure()/FluidModel->GetDensity(); - Entropy_BC = FluidModel->GetEntropy(); + GetFluidModel()->SetTDState_PT(P_Total, T_Total); + Enthalpy_BC = GetFluidModel()->GetStaticEnergy()+ GetFluidModel()->GetPressure()/GetFluidModel()->GetDensity(); + Entropy_BC = GetFluidModel()->GetEntropy(); /* --- Computes the inverse matrix R_c --- */ - conv_numerics->ComputeResJacobianGiles(FluidModel, AveragePressure[val_marker][iSpan], AverageDensity[val_marker][iSpan], AverageTurboVelocity[val_marker][iSpan], alphaIn_BC, gammaIn_BC, R_c, R_c_inv); + conv_numerics->ComputeResJacobianGiles(GetFluidModel(), AveragePressure[val_marker][iSpan], AverageDensity[val_marker][iSpan], + AverageTurboVelocity[val_marker][iSpan], alphaIn_BC, gammaIn_BC, R_c, R_c_inv); - FluidModel->SetTDState_Prho(AveragePressure[val_marker][nSpanWiseSections], AverageDensity[val_marker][nSpanWiseSections]); - AverageEnthalpy = FluidModel->GetStaticEnergy() + AveragePressure[val_marker][nSpanWiseSections]/AverageDensity[val_marker][nSpanWiseSections]; - AverageEntropy = FluidModel->GetEntropy(); + GetFluidModel()->SetTDState_Prho(AveragePressure[val_marker][nSpanWiseSections], AverageDensity[val_marker][nSpanWiseSections]); + AverageEnthalpy = GetFluidModel()->GetStaticEnergy() + AveragePressure[val_marker][nSpanWiseSections]/AverageDensity[val_marker][nSpanWiseSections]; + AverageEntropy = GetFluidModel()->GetEntropy(); avgVel2 = 0.0; @@ -9265,8 +9203,8 @@ void CEulerSolver::BC_Giles(CGeometry *geometry, CSolver **solver_container, /* --- Compute average jump of charachteristic variable at the mixing-plane interface--- */ - FluidModel->SetTDState_Prho(AveragePressure[val_marker][iSpan], AverageDensity[val_marker][iSpan]); - AverageSoundSpeed = FluidModel->GetSoundSpeed(); + GetFluidModel()->SetTDState_Prho(AveragePressure[val_marker][iSpan], AverageDensity[val_marker][iSpan]); + AverageSoundSpeed = GetFluidModel()->GetSoundSpeed(); conv_numerics->GetCharJump(AverageSoundSpeed, AverageDensity[val_marker][iSpan], deltaprim, c_avg); break; @@ -9286,8 +9224,8 @@ void CEulerSolver::BC_Giles(CGeometry *geometry, CSolver **solver_container, } /* --- Compute average jump of charachteristic variable at the mixing-plane interface--- */ - FluidModel->SetTDState_Prho(AveragePressure[val_marker][nSpanWiseSections], AverageDensity[val_marker][nSpanWiseSections]); - AverageSoundSpeed = FluidModel->GetSoundSpeed(); + GetFluidModel()->SetTDState_Prho(AveragePressure[val_marker][nSpanWiseSections], AverageDensity[val_marker][nSpanWiseSections]); + AverageSoundSpeed = GetFluidModel()->GetSoundSpeed(); conv_numerics->GetCharJump(AverageSoundSpeed, AverageDensity[val_marker][nSpanWiseSections], deltaprim, c_avg); break; @@ -9375,9 +9313,9 @@ void CEulerSolver::BC_Giles(CGeometry *geometry, CSolver **solver_container, Energy_i = nodes->GetEnergy(iPoint); StaticEnergy_i = Energy_i - 0.5*Velocity2_i; - FluidModel->SetTDState_rhoe(Density_i, StaticEnergy_i); + GetFluidModel()->SetTDState_rhoe(Density_i, StaticEnergy_i); - Pressure_i = FluidModel->GetPressure(); + Pressure_i = GetFluidModel()->GetPressure(); ComputeTurboVelocity(Velocity_i, turboNormal, turboVelocity, config->GetMarker_All_TurbomachineryFlag(val_marker),config->GetKind_TurboMachinery(iZone)); if (nDim == 2){ @@ -9394,8 +9332,8 @@ void CEulerSolver::BC_Giles(CGeometry *geometry, CSolver **solver_container, deltaprim[4] = Pressure_i - AveragePressure[val_marker][iSpan]; } - FluidModel->SetTDState_Prho(AveragePressure[val_marker][iSpan], AverageDensity[val_marker][iSpan]); - AverageSoundSpeed = FluidModel->GetSoundSpeed(); + GetFluidModel()->SetTDState_Prho(AveragePressure[val_marker][iSpan], AverageDensity[val_marker][iSpan]); + AverageSoundSpeed = GetFluidModel()->GetSoundSpeed(); conv_numerics->GetCharJump(AverageSoundSpeed, AverageDensity[val_marker][iSpan], deltaprim, cj); @@ -9626,9 +9564,9 @@ void CEulerSolver::BC_Giles(CGeometry *geometry, CSolver **solver_container, } } - FluidModel->SetTDState_Prho(Pressure_b, Density_b); - Energy_b = FluidModel->GetStaticEnergy() + 0.5*Velocity2_b; - Temperature_b= FluidModel->GetTemperature(); + GetFluidModel()->SetTDState_Prho(Pressure_b, Density_b); + Energy_b = GetFluidModel()->GetStaticEnergy() + 0.5*Velocity2_b; + Temperature_b= GetFluidModel()->GetTemperature(); Enthalpy_b = Energy_b + Pressure_b/Density_b; /*--- Primitive variables, using the derived quantities ---*/ @@ -9639,8 +9577,8 @@ void CEulerSolver::BC_Giles(CGeometry *geometry, CSolver **solver_container, V_boundary[nDim+2] = Density_b; V_boundary[nDim+3] = Enthalpy_b; - S_boundary[0]= FluidModel->GetdPdrho_e(); - S_boundary[1]= FluidModel->GetdPde_rho(); + S_boundary[0]= GetFluidModel()->GetdPdrho_e(); + S_boundary[1]= GetFluidModel()->GetdPde_rho(); @@ -9670,10 +9608,10 @@ 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+5] = GetFluidModel()->GetLaminarViscosity(); V_boundary[nDim+6] = nodes->GetEddyViscosity(iPoint); - V_boundary[nDim+7] = FluidModel->GetThermalConductivity(); - V_boundary[nDim+8] = FluidModel->GetCp(); + V_boundary[nDim+7] = GetFluidModel()->GetThermalConductivity(); + V_boundary[nDim+8] = GetFluidModel()->GetCp(); /*--- Set the normal vector and the coordinates ---*/ @@ -9688,19 +9626,19 @@ void CEulerSolver::BC_Giles(CGeometry *geometry, CSolver **solver_container, /*--- Compute secondary thermodynamic properties (partial derivatives...) ---*/ - S_boundary[0]= FluidModel->GetdPdrho_e(); - S_boundary[1]= FluidModel->GetdPde_rho(); + S_boundary[0]= GetFluidModel()->GetdPdrho_e(); + S_boundary[1]= GetFluidModel()->GetdPde_rho(); - S_boundary[2]= FluidModel->GetdTdrho_e(); - S_boundary[3]= FluidModel->GetdTde_rho(); + S_boundary[2]= GetFluidModel()->GetdTdrho_e(); + S_boundary[3]= GetFluidModel()->GetdTde_rho(); /*--- Compute secondary thermo-physical properties (partial derivatives...) ---*/ - S_boundary[4]= FluidModel->Getdmudrho_T(); - S_boundary[5]= FluidModel->GetdmudT_rho(); + S_boundary[4]= GetFluidModel()->Getdmudrho_T(); + S_boundary[5]= GetFluidModel()->GetdmudT_rho(); - S_boundary[6]= FluidModel->Getdktdrho_T(); - S_boundary[7]= FluidModel->GetdktdT_rho(); + S_boundary[6]= GetFluidModel()->Getdktdrho_T(); + S_boundary[7]= GetFluidModel()->GetdktdT_rho(); visc_numerics->SetSecondary(S_domain, S_boundary); @@ -11016,10 +10954,10 @@ void CEulerSolver::BC_Fluid_Interface(CGeometry *geometry, CSolver **solver_cont P_static = PrimVar_j[nDim+1]; rho_static = PrimVar_j[nDim+2]; - FluidModel->SetTDState_Prho(P_static, rho_static); + GetFluidModel()->SetTDState_Prho(P_static, rho_static); - Secondary_j[0] = FluidModel->GetdPdrho_e(); - Secondary_j[1] = FluidModel->GetdPde_rho(); + Secondary_j[0] = GetFluidModel()->GetdPdrho_e(); + Secondary_j[1] = GetFluidModel()->GetdPde_rho(); conv_numerics->SetSecondary(Secondary_i, Secondary_j); } @@ -11441,9 +11379,9 @@ void CEulerSolver::BC_ActDisk(CGeometry *geometry, CSolver **solver_container, C else { - FluidModel->SetTDState_PT(P_static, T_static); - SoS_outlet = FluidModel->GetSoundSpeed(); - Rho_outlet = FluidModel->GetDensity(); + GetFluidModel()->SetTDState_PT(P_static, T_static); + SoS_outlet = GetFluidModel()->GetSoundSpeed(); + Rho_outlet = GetFluidModel()->GetDensity(); /*--- We use the velocity and the density from the flow inlet to evaluate flow direction and mass flow ---*/ @@ -12316,8 +12254,8 @@ void CEulerSolver::SetFreeStream_TurboSolution(CConfig *config) { turboNormal = config->GetFreeStreamTurboNormal(); - FluidModel->SetTDState_Prho(Pressure_Inf, Density_Inf); - SoundSpeed = FluidModel->GetSoundSpeed(); + GetFluidModel()->SetTDState_Prho(Pressure_Inf, Density_Inf); + SoundSpeed = GetFluidModel()->GetSoundSpeed(); /*--- Compute the Free Stream velocity, using the Mach number ---*/ turboVelocity[0] = cos(Alpha)*Mach*SoundSpeed; @@ -12337,8 +12275,8 @@ void CEulerSolver::SetFreeStream_TurboSolution(CConfig *config) { } nodes->SetSolution(iPoint,nVar-1, Density_Inf*Energy_Inf); - nodes->SetPrimVar(iPoint,FluidModel); - nodes->SetSecondaryVar(iPoint,FluidModel); + nodes->SetPrimVar(iPoint, GetFluidModel()); + nodes->SetSecondaryVar(iPoint, GetFluidModel()); } delete [] turboVelocity; @@ -12848,8 +12786,8 @@ void CEulerSolver::TurboAverageProcess(CSolver **solver, CGeometry *geometry, CC /*--- compute normal Mach number as a check for massflow average and mixedout average ---*/ - FluidModel->SetTDState_Prho(TotalAreaPressure/TotalArea, TotalAreaDensity / TotalArea); - soundSpeed = FluidModel->GetSoundSpeed(); + GetFluidModel()->SetTDState_Prho(TotalAreaPressure/TotalArea, TotalAreaDensity / TotalArea); + soundSpeed = GetFluidModel()->GetSoundSpeed(); MachTest = TotalFluxes[0]/(TotalAreaDensity*soundSpeed); /*--- Compute the averaged value for the boundary of interest for the span of interest ---*/ @@ -13171,12 +13109,12 @@ void CEulerSolver::MixedOut_Average (CConfig *config, su2double val_init_pressur while ( iter <= maxiter ) { density_mix = val_Averaged_Flux[0]*val_Averaged_Flux[0]/(val_Averaged_Flux[1] - pressure_mix); - FluidModel->SetTDState_Prho(pressure_mix, density_mix); - enthalpy_mix = FluidModel->GetStaticEnergy() + (pressure_mix)/(density_mix); + GetFluidModel()->SetTDState_Prho(pressure_mix, density_mix); + enthalpy_mix = GetFluidModel()->GetStaticEnergy() + (pressure_mix)/(density_mix); - FluidModel->ComputeDerivativeNRBC_Prho(pressure_mix, density_mix); - dhdP = FluidModel->GetdhdP_rho(); - dhdrho = FluidModel->Getdhdrho_P(); + GetFluidModel()->ComputeDerivativeNRBC_Prho(pressure_mix, density_mix); + dhdP = GetFluidModel()->GetdhdP_rho(); + dhdrho = GetFluidModel()->Getdhdrho_P(); vel[0] = (val_Averaged_Flux[1] - pressure_mix) / val_Averaged_Flux[0]; for (iDim = 1; iDim < nDim; iDim++) { diff --git a/SU2_CFD/src/solvers/CFEASolver.cpp b/SU2_CFD/src/solvers/CFEASolver.cpp index 3c64d8ba244c..f89e4766c20b 100644 --- a/SU2_CFD/src/solvers/CFEASolver.cpp +++ b/SU2_CFD/src/solvers/CFEASolver.cpp @@ -408,7 +408,6 @@ void CFEASolver::Set_ElementProperties(CGeometry *geometry, CConfig *config) { long iElem_Local; unsigned long iElem_Global_Local = 0, iElem_Global = 0; string text_line; - unsigned short rbuf_NotMatching = 0, sbuf_NotMatching = 0; /*--- The first line is the header ---*/ @@ -451,11 +450,7 @@ void CFEASolver::Set_ElementProperties(CGeometry *geometry, CConfig *config) { /*--- Detect a wrong solution file ---*/ - if (iElem_Global_Local < nElement) { sbuf_NotMatching = 1; } - - SU2_MPI::Allreduce(&sbuf_NotMatching, &rbuf_NotMatching, 1, MPI_UNSIGNED_SHORT, MPI_SUM, MPI_COMM_WORLD); - - if (rbuf_NotMatching != 0) { + if (iElem_Global_Local != nElement) { SU2_MPI::Error(string("The properties file ") + filename + string(" doesn't match with the mesh file!\n") + string("It could be empty lines at the end of the file."), CURRENT_FUNCTION); } @@ -502,6 +497,7 @@ void CFEASolver::Set_Prestretch(CGeometry *geometry, CConfig *config) { if (prestretch_file.fail()) { SU2_MPI::Error(string("There is no FEM prestretch reference file ") + filename, CURRENT_FUNCTION); } + /*--- In case this is a parallel simulation, we need to perform the Global2Local index transformation first. ---*/ @@ -517,7 +513,6 @@ void CFEASolver::Set_Prestretch(CGeometry *geometry, CConfig *config) { long iPoint_Local; unsigned long iPoint_Global_Local = 0, iPoint_Global = 0; string text_line; - unsigned short rbuf_NotMatching = 0, sbuf_NotMatching = 0; /*--- The first line is the header ---*/ @@ -548,13 +543,9 @@ void CFEASolver::Set_Prestretch(CGeometry *geometry, CConfig *config) { /*--- Detect a wrong solution file ---*/ - if (iPoint_Global_Local < nPointDomain) { sbuf_NotMatching = 1; } - - SU2_MPI::Allreduce(&sbuf_NotMatching, &rbuf_NotMatching, 1, MPI_UNSIGNED_SHORT, MPI_SUM, MPI_COMM_WORLD); - - if (rbuf_NotMatching != 0) { - SU2_MPI::Error(string("The solution file ") + filename + string(" doesn't match with the mesh file!\n") + - string("It could be empty lines at the end of the file."), CURRENT_FUNCTION); + if (iPoint_Global_Local != nPointDomain) { + SU2_MPI::Error(string("The solution file ") + filename + string(" doesn't match with the mesh file!\n") + + string("It could be empty lines at the end of the file."), CURRENT_FUNCTION); } /*--- Close the restart file ---*/ @@ -673,7 +664,6 @@ void CFEASolver::Set_ReferenceGeometry(CGeometry *geometry, CConfig *config) { long iPoint_Local; unsigned long iPoint_Global_Local = 0, iPoint_Global = 0; string text_line; - unsigned short rbuf_NotMatching = 0, sbuf_NotMatching = 0; /*--- The first line is the header ---*/ @@ -713,17 +703,11 @@ void CFEASolver::Set_ReferenceGeometry(CGeometry *geometry, CConfig *config) { /*--- Detect a wrong solution file ---*/ - if (iPoint_Global_Local < nPointDomain) { sbuf_NotMatching = 1; } - - SU2_MPI::Allreduce(&sbuf_NotMatching, &rbuf_NotMatching, 1, MPI_UNSIGNED_SHORT, MPI_SUM, MPI_COMM_WORLD); - - if (rbuf_NotMatching != 0) { + if (iPoint_Global_Local != nPointDomain) { SU2_MPI::Error(string("The solution file ") + filename + string(" doesn't match with the mesh file!\n") + string("It could be empty lines at the end of the file."), CURRENT_FUNCTION); } - /*--- I don't think we need to communicate ---*/ - /*--- Close the restart file ---*/ reference_file.close(); diff --git a/SU2_CFD/src/solvers/CNSSolver.cpp b/SU2_CFD/src/solvers/CNSSolver.cpp index 7c1633bfd42a..d749f17f8371 100644 --- a/SU2_CFD/src/solvers/CNSSolver.cpp +++ b/SU2_CFD/src/solvers/CNSSolver.cpp @@ -765,6 +765,24 @@ CNSSolver::CNSSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) nodes = new CNSVariable(Density_Inf, Velocity_Inf, Energy_Inf, nPoint, nDim, nVar, config); SetBaseClassPointerToNodes(); + #ifndef HAVE_OMP + /*--- Get the edge coloring. ---*/ + + const auto& coloring = geometry->GetEdgeColoring(); + + auto nColor = coloring.getOuterSize(); + EdgeColoring.resize(nColor); + + for(auto iColor = 0ul; iColor < nColor; ++iColor) { + EdgeColoring[iColor].size = coloring.getNumNonZeros(iColor); + EdgeColoring[iColor].indices = coloring.innerIdx(iColor); + } + + ColorGroupSize = geometry->GetEdgeColorGroupSize(); + + omp_chunk_size = computeStaticChunkSize(nPoint, omp_get_max_threads(), OMP_MAX_SIZE); +#endif + /*--- Check that the initial solution is physical, report any non-physical nodes ---*/ counter_local = 0; @@ -779,9 +797,9 @@ CNSSolver::CNSSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) StaticEnergy= nodes->GetEnergy(iPoint) - 0.5*Velocity2; - FluidModel->SetTDState_rhoe(Density, StaticEnergy); - Pressure= FluidModel->GetPressure(); - Temperature= FluidModel->GetTemperature(); + GetFluidModel()->SetTDState_rhoe(Density, StaticEnergy); + Pressure= GetFluidModel()->GetPressure(); + Temperature= GetFluidModel()->GetTemperature(); /*--- Use the values at the infinity ---*/ @@ -800,11 +818,9 @@ CNSSolver::CNSSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) /*--- Warning message about non-physical points ---*/ 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 ((rank == MASTER_NODE) && (counter_global != 0)) cout << "Warning. The original solution contains "<< counter_global << " points that are not physical." << endl; } @@ -826,14 +842,9 @@ CNSSolver::CNSSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) /*--- Define solver parameters needed for execution of destructor ---*/ - if (config->GetKind_ConvNumScheme_Flow() == SPACE_CENTERED) space_centered = true; - else space_centered = false; - - if (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT) euler_implicit = true; - else euler_implicit = false; - - if (config->GetKind_Gradient_Method() == WEIGHTED_LEAST_SQUARES) least_squares = true; - else least_squares = false; + space_centered = (config->GetKind_ConvNumScheme_Flow() == SPACE_CENTERED); + euler_implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + least_squares = (config->GetKind_Gradient_Method() == WEIGHTED_LEAST_SQUARES); /*--- Communicate and store volume and the number of neighbors for any dual CVs that lie on on periodic markers. ---*/ @@ -1105,8 +1116,8 @@ 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) ---*/ - physical = static_cast(nodes)->SetPrimVar(iPoint,eddy_visc, turb_ke, FluidModel); - nodes->SetSecondaryVar(iPoint,FluidModel); + physical = static_cast(nodes)->SetPrimVar(iPoint,eddy_visc, turb_ke, GetFluidModel()); + nodes->SetSecondaryVar(iPoint, GetFluidModel()); /* Check for non-realizable states for reporting. */ From 83521b7ca2c16be439527744921cb71056454653 Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Fri, 24 Jan 2020 12:19:27 +0000 Subject: [PATCH 004/118] begin SetTimeStep --- SU2_CFD/src/solvers/CEulerSolver.cpp | 133 ++++++++++++++++----------- 1 file changed, 80 insertions(+), 53 deletions(-) diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 01b92befba54..d09abe6ba113 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -2856,7 +2856,7 @@ void CEulerSolver::SetInitialCondition(CGeometry **geometry, CSolver ***solver_c } // end SU2_OMP_PARALLEL - /// TODO: The rest in not included in parallel region because Set_Solution_time_n* does not have worksharing yet. + /// TODO: The rest is not included in parallel region because Set_Solution_time_n* does not have worksharing yet. /*--- Make sure that the solution is well initialized for unsteady calculations with dual time-stepping (load additional restarts for 2nd-order). ---*/ @@ -3031,33 +3031,55 @@ unsigned long CEulerSolver::SetPrimitive_Variables(CSolver **solver_container, C void CEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh, unsigned long Iteration) { - su2double *Normal, Area, Vol, Mean_SoundSpeed = 0.0, Mean_ProjVel = 0.0, Lambda, Local_Delta_Time, - Global_Delta_Time = 1E6, Global_Delta_UnstTimeND, ProjVel, ProjVel_i, ProjVel_j; - unsigned long iEdge, iVertex, iPoint, jPoint; - unsigned short iDim, iMarker; - - 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)); + const bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + const bool time_stepping = config->GetTime_Marching() == TIME_STEPPING; + const 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; + /*--- Start OpenMP parallel section. ---*/ + + SU2_OMP_PARALLEL + { + + const su2double *Normal = nullptr; + su2double Area, Vol, Mean_SoundSpeed = 0.0, Mean_ProjVel = 0.0, Lambda, Local_Delta_Time; + su2double Global_Delta_Time = 1E6, Global_Delta_UnstTimeND, ProjVel, ProjVel_i, ProjVel_j; + unsigned long iEdge, iVertex, iPoint, jPoint; + unsigned short iDim, iMarker; + /*--- Set maximum inviscid eigenvalue to zero, and compute sound speed ---*/ + SU2_OMP_FOR_STAT(omp_chunk_size) for (iPoint = 0; iPoint < nPointDomain; iPoint++) nodes->SetMax_Lambda_Inv(iPoint,0.0); /*--- Loop interior edges ---*/ - for (iEdge = 0; iEdge < geometry->GetnEdge(); iEdge++) { +#ifdef HAVE_OMP + /*--- Chunk size is at least OMP_MIN_SIZE and a multiple of the color group size. ---*/ + auto chunkSize = roundUpDiv(OMP_MIN_SIZE, ColorGroupSize)*ColorGroupSize; + + /*--- Loop over edge colors. ---*/ + for (auto color : EdgeColoring) + { + SU2_OMP_FOR_DYN(chunkSize) + for(auto k = 0ul; k < color.size; ++k) { + + iEdge = color.indices[k]; +#else + /*--- Natural coloring. ---*/ + { + for (iEdge = 0; iEdge < geometry->GetnEdge(); iEdge++) { +#endif /*--- Point identification, Normal vector and area ---*/ iPoint = geometry->edge[iEdge]->GetNode(0); jPoint = geometry->edge[iEdge]->GetNode(1); Normal = geometry->edge[iEdge]->GetNormal(); - Area = 0.0; for (iDim = 0; iDim < nDim; iDim++) Area += Normal[iDim]*Normal[iDim]; Area = sqrt(Area); + Area = 0.0; for (iDim = 0; iDim < nDim; iDim++) Area += pow(Normal[iDim],2); Area = sqrt(Area); /*--- Mean Values ---*/ @@ -3067,8 +3089,8 @@ void CEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, /*--- Adjustment for grid movement ---*/ if (dynamic_grid) { - su2double *GridVel_i = geometry->node[iPoint]->GetGridVel(); - su2double *GridVel_j = geometry->node[jPoint]->GetGridVel(); + const su2double *GridVel_i = geometry->node[iPoint]->GetGridVel(); + const su2double *GridVel_j = geometry->node[jPoint]->GetGridVel(); ProjVel_i = 0.0; ProjVel_j = 0.0; for (iDim = 0; iDim < nDim; iDim++) { ProjVel_i += GridVel_i[iDim]*Normal[iDim]; @@ -3084,19 +3106,21 @@ void CEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, if (geometry->node[jPoint]->GetDomain()) nodes->AddMax_Lambda_Inv(jPoint,Lambda); } + } // end color loop /*--- Loop boundary edges ---*/ for (iMarker = 0; iMarker < geometry->GetnMarker(); iMarker++) { if ((config->GetMarker_All_KindBC(iMarker) != INTERNAL_BOUNDARY) && (config->GetMarker_All_KindBC(iMarker) != PERIODIC_BOUNDARY)) { + SU2_OMP_FOR_STAT(omp_chunk_size) for (iVertex = 0; iVertex < geometry->GetnVertex(iMarker); iVertex++) { /*--- Point identification, Normal vector and area ---*/ iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); Normal = geometry->vertex[iMarker][iVertex]->GetNormal(); - Area = 0.0; for (iDim = 0; iDim < nDim; iDim++) Area += Normal[iDim]*Normal[iDim]; Area = sqrt(Area); + Area = 0.0; for (iDim = 0; iDim < nDim; iDim++) Area += pow(Normal[iDim],2); Area = sqrt(Area); /*--- Mean Values ---*/ @@ -3106,7 +3130,7 @@ void CEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, /*--- Adjustment for grid movement ---*/ if (dynamic_grid) { - su2double *GridVel = geometry->node[iPoint]->GetGridVel(); + const su2double *GridVel = geometry->node[iPoint]->GetGridVel(); ProjVel = 0.0; for (iDim = 0; iDim < nDim; iDim++) ProjVel += GridVel[iDim]*Normal[iDim]; @@ -3122,8 +3146,9 @@ void CEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, } } - /*--- Each element uses their own speed, steady state simulation ---*/ + /*--- Each element uses their own speed, steady state simulation. ---*/ + SU2_OMP_FOR_STAT(OMP_MIN_SIZE) for (iPoint = 0; iPoint < nPointDomain; iPoint++) { Vol = geometry->node[iPoint]->GetVolume(); @@ -3143,56 +3168,58 @@ void CEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, } - /*--- Compute the max and the min dt (in parallel) ---*/ + + SU2_OMP_MASTER if (config->GetComm_Level() == COMM_FULL) { -#ifdef HAVE_MPI - su2double rbuf_time, sbuf_time; - sbuf_time = Min_Delta_Time; - SU2_MPI::Reduce(&sbuf_time, &rbuf_time, 1, MPI_DOUBLE, MPI_MIN, MASTER_NODE, MPI_COMM_WORLD); - SU2_MPI::Bcast(&rbuf_time, 1, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); + su2double rbuf_time; + SU2_MPI::Allreduce(&Min_Delta_Time, &rbuf_time, 1, MPI_DOUBLE, MPI_MIN, MPI_COMM_WORLD); Min_Delta_Time = rbuf_time; - sbuf_time = Max_Delta_Time; - SU2_MPI::Reduce(&sbuf_time, &rbuf_time, 1, MPI_DOUBLE, MPI_MAX, MASTER_NODE, MPI_COMM_WORLD); - SU2_MPI::Bcast(&rbuf_time, 1, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); + SU2_MPI::Allreduce(&Max_Delta_Time, &rbuf_time, 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD); Max_Delta_Time = rbuf_time; -#endif } + SU2_OMP_BARRIER /*--- For exact time solution use the minimum delta time of the whole mesh ---*/ if (time_stepping) { -#ifdef HAVE_MPI - su2double rbuf_time, sbuf_time; - sbuf_time = Global_Delta_Time; - SU2_MPI::Reduce(&sbuf_time, &rbuf_time, 1, MPI_DOUBLE, MPI_MIN, MASTER_NODE, MPI_COMM_WORLD); - 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(); + SU2_OMP_MASTER + { + if (config->GetUnst_CFL() == 0.0) { + Global_Delta_Time = config->GetDelta_UnstTime(); + } + else { + su2double rbuf_time; + SU2_MPI::Allreduce(&Global_Delta_Time, &rbuf_time, 1, MPI_DOUBLE, MPI_MIN, MPI_COMM_WORLD); + Global_Delta_Time = rbuf_time; + } + config->SetDelta_UnstTimeND(Global_Delta_Time); + + Min_Delta_Time = Global_Delta_Time; + Max_Delta_Time = Global_Delta_Time; } - config->SetDelta_UnstTimeND(Global_Delta_Time); - for (iPoint = 0; iPoint < nPointDomain; iPoint++){ + SU2_OMP_BARRIER - /*--- Sets the regular CFL equal to the unsteady CFL ---*/ + /*--- Sets the regular CFL equal to the unsteady CFL ---*/ + SU2_OMP_FOR_STAT(omp_chunk_size) + for (iPoint = 0; iPoint < nPointDomain; iPoint++){ 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; - } + } /*--- Recompute the unsteady time step for the dual time strategy if the unsteady CFL is diferent from 0 ---*/ + SU2_OMP_MASTER if ((dual_time) && (Iteration == 0) && (config->GetUnst_CFL() != 0.0) && (iMesh == MESH_0)) { Global_Delta_UnstTimeND = 1e30; @@ -3200,25 +3227,25 @@ void CEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, Global_Delta_UnstTimeND = min(Global_Delta_UnstTimeND,config->GetUnst_CFL()*Global_Delta_Time/nodes->GetLocalCFL(iPoint)); } -#ifdef HAVE_MPI - su2double rbuf_time, sbuf_time; - sbuf_time = Global_Delta_UnstTimeND; - SU2_MPI::Reduce(&sbuf_time, &rbuf_time, 1, MPI_DOUBLE, MPI_MIN, MASTER_NODE, MPI_COMM_WORLD); - SU2_MPI::Bcast(&rbuf_time, 1, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); + su2double rbuf_time; + SU2_MPI::Allreduce(&Global_Delta_UnstTimeND, &rbuf_time, 1, MPI_DOUBLE, MPI_MIN, MPI_COMM_WORLD); Global_Delta_UnstTimeND = rbuf_time; -#endif + config->SetDelta_UnstTimeND(Global_Delta_UnstTimeND); } + SU2_OMP_BARRIER /*--- The pseudo local time (explicit integration) cannot be greater than the physical time ---*/ - if (dual_time) + if (dual_time && !implicit) { + SU2_OMP_FOR_STAT(omp_chunk_size) for (iPoint = 0; iPoint < nPointDomain; iPoint++) { - if (!implicit) { - Local_Delta_Time = min((2.0/3.0)*config->GetDelta_UnstTimeND(), nodes->GetDelta_Time(iPoint)); - nodes->SetDelta_Time(iPoint,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); } + } + + } // end SU2_OMP_PARALLEL } From c316c8df116eebd8f7aa8eab16598d681359629f Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Fri, 24 Jan 2020 14:24:30 +0000 Subject: [PATCH 005/118] intermediate changes --- SU2_CFD/src/solvers/CEulerSolver.cpp | 74 ++++++++++++++-------------- 1 file changed, 38 insertions(+), 36 deletions(-) diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index d09abe6ba113..370ae49a60a5 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -3038,10 +3038,12 @@ void CEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, Min_Delta_Time = 1.E30; Max_Delta_Time = 0.0; + /*--- Start OpenMP parallel section. ---*/ SU2_OMP_PARALLEL { + const int thread = omp_get_thread_num(); const su2double *Normal = nullptr; su2double Area, Vol, Mean_SoundSpeed = 0.0, Mean_ProjVel = 0.0, Lambda, Local_Delta_Time; @@ -3089,14 +3091,11 @@ void CEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, /*--- Adjustment for grid movement ---*/ if (dynamic_grid) { - const su2double *GridVel_i = geometry->node[iPoint]->GetGridVel(); - const su2double *GridVel_j = geometry->node[jPoint]->GetGridVel(); - ProjVel_i = 0.0; ProjVel_j = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - ProjVel_i += GridVel_i[iDim]*Normal[iDim]; - ProjVel_j += GridVel_j[iDim]*Normal[iDim]; - } - Mean_ProjVel -= 0.5 * (ProjVel_i + ProjVel_j); + const su2double* GridVel_i = geometry->node[iPoint]->GetGridVel(); + const su2double* GridVel_j = geometry->node[jPoint]->GetGridVel(); + + for (iDim = 0; iDim < nDim; iDim++) + Mean_ProjVel -= 0.5 * (GridVel_i[iDim] + GridVel_j[iDim]) * Normal[iDim]; } /*--- Inviscid contribution ---*/ @@ -3113,37 +3112,38 @@ void CEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, for (iMarker = 0; iMarker < geometry->GetnMarker(); iMarker++) { if ((config->GetMarker_All_KindBC(iMarker) != INTERNAL_BOUNDARY) && (config->GetMarker_All_KindBC(iMarker) != PERIODIC_BOUNDARY)) { - SU2_OMP_FOR_STAT(omp_chunk_size) - for (iVertex = 0; iVertex < geometry->GetnVertex(iMarker); iVertex++) { - /*--- Point identification, Normal vector and area ---*/ + SU2_OMP_FOR_STAT(omp_chunk_size) + for (iVertex = 0; iVertex < geometry->GetnVertex(iMarker); iVertex++) { - iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); - Normal = geometry->vertex[iMarker][iVertex]->GetNormal(); - Area = 0.0; for (iDim = 0; iDim < nDim; iDim++) Area += pow(Normal[iDim],2); Area = sqrt(Area); + /*--- Point identification, Normal vector and area ---*/ - /*--- Mean Values ---*/ + iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); - Mean_ProjVel = nodes->GetProjVel(iPoint,Normal); - Mean_SoundSpeed = nodes->GetSoundSpeed(iPoint) * Area; + if (!geometry->node[iPoint]->GetDomain()) continue; - /*--- Adjustment for grid movement ---*/ + Normal = geometry->vertex[iMarker][iVertex]->GetNormal(); + Area = 0.0; for (iDim = 0; iDim < nDim; iDim++) Area += pow(Normal[iDim],2); Area = sqrt(Area); - if (dynamic_grid) { - const su2double *GridVel = geometry->node[iPoint]->GetGridVel(); - ProjVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjVel += GridVel[iDim]*Normal[iDim]; - Mean_ProjVel -= ProjVel; - } + /*--- Mean Values ---*/ - /*--- Inviscid contribution ---*/ - Lambda = fabs(Mean_ProjVel) + Mean_SoundSpeed; - if (geometry->node[iPoint]->GetDomain()) { + Mean_ProjVel = nodes->GetProjVel(iPoint,Normal); + Mean_SoundSpeed = nodes->GetSoundSpeed(iPoint) * Area; + + /*--- Adjustment for grid movement ---*/ + + if (dynamic_grid) { + const su2double* GridVel = geometry->node[iPoint]->GetGridVel(); + + for (iDim = 0; iDim < nDim; iDim++) + Mean_ProjVel -= GridVel[iDim]*Normal[iDim]; + } + + /*--- Inviscid contribution ---*/ + Lambda = fabs(Mean_ProjVel) + Mean_SoundSpeed; nodes->AddMax_Lambda_Inv(iPoint,Lambda); } } - } } /*--- Each element uses their own speed, steady state simulation. ---*/ @@ -3219,21 +3219,23 @@ void CEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, /*--- Recompute the unsteady time step for the dual time strategy if the unsteady CFL is diferent from 0 ---*/ - SU2_OMP_MASTER if ((dual_time) && (Iteration == 0) && (config->GetUnst_CFL() != 0.0) && (iMesh == MESH_0)) { Global_Delta_UnstTimeND = 1e30; - for (iPoint = 0; iPoint < nPointDomain; iPoint++){ + for (iPoint = 0; iPoint < nPointDomain; iPoint++) { Global_Delta_UnstTimeND = min(Global_Delta_UnstTimeND,config->GetUnst_CFL()*Global_Delta_Time/nodes->GetLocalCFL(iPoint)); } - su2double rbuf_time; - SU2_MPI::Allreduce(&Global_Delta_UnstTimeND, &rbuf_time, 1, MPI_DOUBLE, MPI_MIN, MPI_COMM_WORLD); - Global_Delta_UnstTimeND = rbuf_time; + SU2_OMP_MASTER + { + su2double rbuf_time; + SU2_MPI::Allreduce(&Global_Delta_UnstTimeND, &rbuf_time, 1, MPI_DOUBLE, MPI_MIN, MPI_COMM_WORLD); + Global_Delta_UnstTimeND = rbuf_time; - config->SetDelta_UnstTimeND(Global_Delta_UnstTimeND); + config->SetDelta_UnstTimeND(Global_Delta_UnstTimeND); + } + SU2_OMP_BARRIER } - SU2_OMP_BARRIER /*--- The pseudo local time (explicit integration) cannot be greater than the physical time ---*/ From 92200e86b9f3047a6bde8d560871a333debb286e Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Fri, 24 Jan 2020 19:22:30 +0000 Subject: [PATCH 006/118] finish time_step routine, allow array of numerics to be passed to solver residual routines --- Common/include/omp_structure.hpp | 1 + SU2_CFD/include/solvers/CAdjEulerSolver.hpp | 22 +-- SU2_CFD/include/solvers/CAdjTurbSolver.hpp | 4 +- SU2_CFD/include/solvers/CEulerSolver.hpp | 26 ++-- SU2_CFD/include/solvers/CHeatSolverFVM.hpp | 14 +- SU2_CFD/include/solvers/CIncEulerSolver.hpp | 16 +- SU2_CFD/include/solvers/CSolver.hpp | 8 +- SU2_CFD/include/solvers/CTemplateSolver.hpp | 10 +- SU2_CFD/include/solvers/CTransLMSolver.hpp | 6 +- SU2_CFD/include/solvers/CTurbSolver.hpp | 14 +- SU2_CFD/src/integration_structure.cpp | 4 +- .../cht/CConjugateHeatInterface.cpp | 6 +- SU2_CFD/src/solvers/CAdjEulerSolver.cpp | 11 +- SU2_CFD/src/solvers/CAdjTurbSolver.cpp | 5 +- SU2_CFD/src/solvers/CEulerSolver.cpp | 141 +++++++++++------- SU2_CFD/src/solvers/CHeatSolverFVM.cpp | 13 +- SU2_CFD/src/solvers/CIncEulerSolver.cpp | 10 +- SU2_CFD/src/solvers/CIncNSSolver.cpp | 1 + SU2_CFD/src/solvers/CNSSolver.cpp | 2 +- SU2_CFD/src/solvers/CTemplateSolver.cpp | 4 +- SU2_CFD/src/solvers/CTransLMSolver.cpp | 6 +- SU2_CFD/src/solvers/CTurbSolver.cpp | 5 +- 22 files changed, 197 insertions(+), 132 deletions(-) diff --git a/Common/include/omp_structure.hpp b/Common/include/omp_structure.hpp index a4439211e2ba..c135c08deab4 100644 --- a/Common/include/omp_structure.hpp +++ b/Common/include/omp_structure.hpp @@ -85,6 +85,7 @@ inline constexpr int omp_get_thread_num(void) {return 0;} #define SU2_OMP_MASTER SU2_OMP(master) #define SU2_OMP_BARRIER SU2_OMP(barrier) +#define SU2_OMP_CRITICAL SU2_OMP(critical) #define SU2_OMP_PARALLEL SU2_OMP(parallel) #define SU2_OMP_PARALLEL_(ARGS) SU2_OMP(parallel ARGS) diff --git a/SU2_CFD/include/solvers/CAdjEulerSolver.hpp b/SU2_CFD/include/solvers/CAdjEulerSolver.hpp index b5124fc1f929..083fbf2df828 100644 --- a/SU2_CFD/include/solvers/CAdjEulerSolver.hpp +++ b/SU2_CFD/include/solvers/CAdjEulerSolver.hpp @@ -169,14 +169,14 @@ class CAdjEulerSolver : public CSolver { * \brief Compute the spatial integration using a centered scheme for the adjoint equations. * \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] numerics_container - Description of the numerical method. * \param[in] config - Definition of the particular problem. * \param[in] iMesh - Index of the mesh in multigrid computations. * \param[in] iRKStep - Current step of the Runge-Kutta iteration. */ void Centered_Residual(CGeometry *geometry, CSolver **solver_container, - CNumerics *numerics, + CNumerics **numerics_container, CConfig *config, unsigned short iMesh, unsigned short iRKStep) final; @@ -185,13 +185,13 @@ class CAdjEulerSolver : public CSolver { * \brief Compute the spatial integration using a upwind scheme. * \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] numerics_container - Description of the numerical method. * \param[in] config - Definition of the particular problem. * \param[in] iMesh - Index of the mesh in multigrid computations. */ void Upwind_Residual(CGeometry *geometry, CSolver **solver_container, - CNumerics *numerics, + CNumerics **numerics_container, CConfig *config, unsigned short iMesh) final; @@ -285,7 +285,7 @@ class CAdjEulerSolver : public CSolver { unsigned long val_index) final { DonorGlobalIndex[val_marker][val_vertex] = val_index; } - + /*! * \brief Compute the sensor for higher order dissipation control in rotating problems. * \param[in] geometry - Geometrical definition of the problem. @@ -608,9 +608,9 @@ class CAdjEulerSolver : public CSolver { * \param[in] val_vertex - Vertex of the marker val_marker where the coefficient is evaluated. * \return Value of the sensitivity coefficient. */ - inline su2double GetCSensitivity(unsigned short val_marker, - unsigned long val_vertex) const final{ - return CSensitivity[val_marker][val_vertex]; + inline su2double GetCSensitivity(unsigned short val_marker, + unsigned long val_vertex) const final{ + return CSensitivity[val_marker][val_vertex]; } /*! @@ -621,8 +621,8 @@ class CAdjEulerSolver : public CSolver { */ inline void SetCSensitivity(unsigned short val_marker, unsigned long val_vertex, - su2double val_sensitivity) final { - CSensitivity[val_marker][val_vertex] = val_sensitivity; + su2double val_sensitivity) final { + CSensitivity[val_marker][val_vertex] = val_sensitivity; } /*! @@ -710,4 +710,4 @@ class CAdjEulerSolver : public CSolver { int val_iter, bool val_update_geo) final; -}; \ No newline at end of file +}; diff --git a/SU2_CFD/include/solvers/CAdjTurbSolver.hpp b/SU2_CFD/include/solvers/CAdjTurbSolver.hpp index 9105a8aebe81..f0be052e191a 100644 --- a/SU2_CFD/include/solvers/CAdjTurbSolver.hpp +++ b/SU2_CFD/include/solvers/CAdjTurbSolver.hpp @@ -139,13 +139,13 @@ class CAdjTurbSolver final : public CSolver { * \brief Compute the spatial integration using a upwind scheme. * \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] numerics_container - Description of the numerical method. * \param[in] config - Definition of the particular problem. * \param[in] iMesh - Index of the mesh in multigrid computations. */ void Upwind_Residual(CGeometry *geometry, CSolver **solver_container, - CNumerics *numerics, + CNumerics **numerics_container, CConfig *config, unsigned short iMesh) override; diff --git a/SU2_CFD/include/solvers/CEulerSolver.hpp b/SU2_CFD/include/solvers/CEulerSolver.hpp index c682197d600d..a5f6f3ecb827 100644 --- a/SU2_CFD/include/solvers/CEulerSolver.hpp +++ b/SU2_CFD/include/solvers/CEulerSolver.hpp @@ -39,10 +39,10 @@ */ class CEulerSolver : public CSolver { protected: + enum : size_t {OMP_MAX_SIZE = 512}; /*!< \brief Max chunk size for light point loops. */ + enum : size_t {OMP_MIN_SIZE = 128}; /*!< \brief Min chunk size for edge loops (max is color group size). */ - enum : size_t {OMP_MAX_SIZE = 512}; - - unsigned long omp_chunk_size; /*!< \brief Chunk size used in light point loops. */ + unsigned long omp_chunk_size; /*!< \brief Chunk size used in light point loops. */ su2double Mach_Inf, /*!< \brief Mach number at the infinity. */ @@ -440,14 +440,14 @@ class CEulerSolver : public CSolver { * \brief Compute the spatial integration using a centered scheme. * \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] numerics_container - Description of the numerical method. * \param[in] config - Definition of the particular problem. * \param[in] iMesh - Index of the mesh in multigrid computations. * \param[in] iRKStep - Current step of the Runge-Kutta iteration. */ void Centered_Residual(CGeometry *geometry, CSolver **solver_container, - CNumerics *numerics, + CNumerics **numerics_container, CConfig *config, unsigned short iMesh, unsigned short iRKStep) final; @@ -456,13 +456,13 @@ class CEulerSolver : public CSolver { * \brief Compute the spatial integration using a upwind scheme. * \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] numerics_container - Description of the numerical method. * \param[in] config - Definition of the particular problem. * \param[in] iMesh - Index of the mesh in multigrid computations. */ void Upwind_Residual(CGeometry *geometry, CSolver **solver_container, - CNumerics *numerics, + CNumerics **numerics_container, CConfig *config, unsigned short iMesh) final; @@ -541,7 +541,7 @@ class CEulerSolver : public CSolver { unsigned long SetPrimitive_Variables(CSolver **solver_container, CConfig *config, bool Output) override; - + /*! * \brief Compute a pressure sensor switch. * \param[in] geometry - Geometrical definition of the problem. @@ -2117,7 +2117,7 @@ class CEulerSolver : public CSolver { * \param[in] val_vertex - Vertex of the marker val_marker where the coefficient is evaluated. * \return Value of the pressure coefficient. */ - inline void SetActDisk_DeltaP(unsigned short val_marker, + inline void SetActDisk_DeltaP(unsigned short val_marker, unsigned long val_vertex, su2double val_deltap) final { ActDisk_DeltaP[val_marker][val_vertex] = val_deltap; } @@ -2605,7 +2605,7 @@ class CEulerSolver : public CSolver { * \param[in] val_Span - value of the Span. * \param[in] valDensity - value to set. */ - inline void SetExtAverageDensity(unsigned short valMarker, + inline void SetExtAverageDensity(unsigned short valMarker, unsigned short valSpan, su2double valDensity) final { ExtAverageDensity[valMarker][valSpan] = valDensity; @@ -2642,7 +2642,7 @@ class CEulerSolver : public CSolver { * \param[in] valNu - value to set. */ inline void SetExtAverageNu(unsigned short valMarker, - unsigned short valSpan, + unsigned short valSpan, su2double valNu) final { ExtAverageNu[valMarker][valSpan] = valNu; } @@ -2784,7 +2784,7 @@ class CEulerSolver : public CSolver { * \param[in] value - turboperformance value to set. * \param[in] inMarkerTP - turboperformance marker. */ - inline void SetDensityIn(su2double value, + inline void SetDensityIn(su2double value, unsigned short inMarkerTP, unsigned short valSpan) final { DensityIn[inMarkerTP][valSpan] = value; @@ -2842,7 +2842,7 @@ class CEulerSolver : public CSolver { * \param[in] value - turboperformance value to set. * \param[in] inMarkerTP - turboperformance marker. */ - inline void SetTurboVelocityOut(su2double *value, + inline void SetTurboVelocityOut(su2double *value, unsigned short inMarkerTP, unsigned short valSpan) final { unsigned short iDim; diff --git a/SU2_CFD/include/solvers/CHeatSolverFVM.hpp b/SU2_CFD/include/solvers/CHeatSolverFVM.hpp index 8647ebdbd30a..3dc5653ff90a 100644 --- a/SU2_CFD/include/solvers/CHeatSolverFVM.hpp +++ b/SU2_CFD/include/solvers/CHeatSolverFVM.hpp @@ -138,14 +138,14 @@ class CHeatSolverFVM final : public CSolver { * \brief Compute the spatial integration using a centered scheme. * \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] numerics_container - Description of the numerical method. * \param[in] config - Definition of the particular problem. * \param[in] iMesh - Index of the mesh in multigrid computations. * \param[in] iRKStep - Current step of the Runge-Kutta iteration. */ void Centered_Residual(CGeometry *geometry, CSolver **solver_container, - CNumerics *numerics, + CNumerics **numerics_container, CConfig *config, unsigned short iMesh, unsigned short iRKStep) override; @@ -153,13 +153,13 @@ class CHeatSolverFVM final : public CSolver { * \brief Compute the spatial integration using a upwind scheme. * \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] numerics_container - Description of the numerical method. * \param[in] config - Definition of the particular problem. * \param[in] iMesh - Index of the mesh in multigrid computations. */ void Upwind_Residual(CGeometry *geometry, CSolver **solver_container, - CNumerics *numerics, + CNumerics **numerics_container, CConfig *config, unsigned short iMesh) override; @@ -267,8 +267,8 @@ class CHeatSolverFVM final : public CSolver { */ inline su2double GetConjugateHeatVariable(unsigned short val_marker, unsigned long val_vertex, - unsigned short pos_var) const override { - return ConjugateVar[val_marker][val_vertex][pos_var]; + unsigned short pos_var) const override { + return ConjugateVar[val_marker][val_vertex][pos_var]; } /*! @@ -380,4 +380,4 @@ class CHeatSolverFVM final : public CSolver { */ inline su2double GetHeatFlux(unsigned short val_marker, unsigned long val_vertex) const override { return HeatFlux[val_marker][val_vertex]; } -}; \ No newline at end of file +}; diff --git a/SU2_CFD/include/solvers/CIncEulerSolver.hpp b/SU2_CFD/include/solvers/CIncEulerSolver.hpp index e8eea93f62f4..cc61fe3cd427 100644 --- a/SU2_CFD/include/solvers/CIncEulerSolver.hpp +++ b/SU2_CFD/include/solvers/CIncEulerSolver.hpp @@ -328,14 +328,14 @@ class CIncEulerSolver : public CSolver { * \brief Compute the spatial integration using a centered scheme. * \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] numerics_container - Description of the numerical method. * \param[in] config - Definition of the particular problem. * \param[in] iMesh - Index of the mesh in multigrid computations. * \param[in] iRKStep - Current step of the Runge-Kutta iteration. */ void Centered_Residual(CGeometry *geometry, CSolver **solver_container, - CNumerics *numerics, + CNumerics **numerics_container, CConfig *config, unsigned short iMesh, unsigned short iRKStep) final; @@ -344,13 +344,13 @@ class CIncEulerSolver : public CSolver { * \brief Compute the spatial integration using a upwind scheme. * \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] numerics_container - Description of the numerical method. * \param[in] config - Definition of the particular problem. * \param[in] iMesh - Index of the mesh in multigrid computations. */ void Upwind_Residual(CGeometry *geometry, CSolver **solver_container, - CNumerics *numerics, + CNumerics **numerics_container, CConfig *config, unsigned short iMesh) final; @@ -1517,8 +1517,8 @@ class CIncEulerSolver : public CSolver { * \param[in] val_marker - marker index * \param[in] val_vertex - vertex index */ - inline int GetnSlidingStates(unsigned short val_marker, unsigned long val_vertex) const final{ - return SlidingStateNodes[val_marker][val_vertex]; + inline int GetnSlidingStates(unsigned short val_marker, unsigned long val_vertex) const final{ + return SlidingStateNodes[val_marker][val_vertex]; } /*! @@ -1531,8 +1531,8 @@ class CIncEulerSolver : public CSolver { inline su2double GetSlidingState(unsigned short val_marker, unsigned long val_vertex, unsigned short val_state, - unsigned long donor_index) const final { - return SlidingState[val_marker][val_vertex][val_state][donor_index]; + unsigned long donor_index) const final { + return SlidingState[val_marker][val_vertex][val_state][donor_index]; } /*! diff --git a/SU2_CFD/include/solvers/CSolver.hpp b/SU2_CFD/include/solvers/CSolver.hpp index 243a122be5bd..0e2939e06dcf 100644 --- a/SU2_CFD/include/solvers/CSolver.hpp +++ b/SU2_CFD/include/solvers/CSolver.hpp @@ -766,14 +766,14 @@ class CSolver { * \brief A virtual member. * \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] numerics_container - Description of the numerical method. * \param[in] config - Definition of the particular problem. * \param[in] iMesh - Index of the mesh in multigrid computations. * \param[in] iRKStep - Current step of the Runge-Kutta iteration. */ inline virtual void Centered_Residual(CGeometry *geometry, CSolver **solver_container, - CNumerics *numerics, + CNumerics **numerics_container, CConfig *config, unsigned short iMesh, unsigned short iRKStep) { } @@ -782,13 +782,13 @@ class CSolver { * \brief A virtual member. * \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] numerics_container - Description of the numerical method. * \param[in] config - Definition of the particular problem. * \param[in] iMesh - Index of the mesh in multigrid computations. */ inline virtual void Upwind_Residual(CGeometry *geometry, CSolver **solver_container, - CNumerics *numerics, + CNumerics **numerics_container, CConfig *config, unsigned short iMesh) { } diff --git a/SU2_CFD/include/solvers/CTemplateSolver.hpp b/SU2_CFD/include/solvers/CTemplateSolver.hpp index bff4927a5a24..6e6a6a53a102 100644 --- a/SU2_CFD/include/solvers/CTemplateSolver.hpp +++ b/SU2_CFD/include/solvers/CTemplateSolver.hpp @@ -100,14 +100,14 @@ class CTemplateSolver final : public CSolver { * \brief Compute the spatial integration using a centered scheme. * \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] numerics_container - Description of the numerical method. * \param[in] config - Definition of the particular problem. * \param[in] iMesh - Index of the mesh in multigrid computations. * \param[in] iRKStep - Current step of the Runge-Kutta iteration. */ void Centered_Residual(CGeometry *geometry, CSolver **solver_container, - CNumerics *numerics, + CNumerics **numerics_container, CConfig *config, unsigned short iMesh, unsigned short iRKStep) override; @@ -116,13 +116,13 @@ class CTemplateSolver final : public CSolver { * \brief Compute the spatial integration using a upwind scheme. * \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] numerics_container - Description of the numerical method. * \param[in] config - Definition of the particular problem. * \param[in] iMesh - Index of the mesh in multigrid computations. */ void Upwind_Residual(CGeometry *geometry, CSolver **solver_container, - CNumerics *numerics, + CNumerics **numerics_container, CConfig *config, unsigned short iMesh) override; @@ -295,4 +295,4 @@ class CTemplateSolver final : public CSolver { CSolver **solver_container, CConfig *config) override; -}; \ No newline at end of file +}; diff --git a/SU2_CFD/include/solvers/CTransLMSolver.hpp b/SU2_CFD/include/solvers/CTransLMSolver.hpp index 158e0036ef5c..4e76354fcc93 100644 --- a/SU2_CFD/include/solvers/CTransLMSolver.hpp +++ b/SU2_CFD/include/solvers/CTransLMSolver.hpp @@ -92,13 +92,13 @@ class CTransLMSolver final : public CTurbSolver { * \brief Compute the spatial integration using a upwind scheme. * \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] numerics_container - Description of the numerical method. * \param[in] config - Definition of the particular problem. * \param[in] iMesh - Index of the mesh in multigrid computations. */ void Upwind_Residual(CGeometry *geometry, CSolver **solver_container, - CNumerics *numerics, + CNumerics **numerics_container, CConfig *config, unsigned short iMesh) override; @@ -246,4 +246,4 @@ class CTransLMSolver final : public CTurbSolver { su2double *LinSysSolReth; /*!< \brief vector to store iterative solution of implicit linear system. */ su2double *LinSysResReth; /*!< \brief vector to store iterative residual of implicit linear system. */ su2double *rhsReth; /*!< \brief right hand side of implicit linear system. */ -}; \ No newline at end of file +}; diff --git a/SU2_CFD/include/solvers/CTurbSolver.hpp b/SU2_CFD/include/solvers/CTurbSolver.hpp index e44f0160e31d..270c3da7e95c 100644 --- a/SU2_CFD/include/solvers/CTurbSolver.hpp +++ b/SU2_CFD/include/solvers/CTurbSolver.hpp @@ -83,14 +83,14 @@ class CTurbSolver : public CSolver { * \brief Compute the spatial integration using a upwind scheme. * \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] numerics_container - Description of the numerical method. * \param[in] config - Definition of the particular problem. * \param[in] iMesh - Index of the mesh in multigrid computations. */ void Upwind_Residual(CGeometry *geometry, CSolver **solver_container, - CNumerics *numerics, + CNumerics **numerics_container, CConfig *config, unsigned short iMesh) override; @@ -254,8 +254,8 @@ class CTurbSolver : public CSolver { inline su2double GetSlidingState(unsigned short val_marker, unsigned long val_vertex, unsigned short val_state, - unsigned long donor_index) const final { - return SlidingState[val_marker][val_vertex][val_state][donor_index]; + unsigned long donor_index) const final { + return SlidingState[val_marker][val_vertex][val_state][donor_index]; } /*! @@ -306,8 +306,8 @@ class CTurbSolver : public CSolver { * \param[in] val_marker - marker index * \param[in] val_vertex - vertex index */ - inline int GetnSlidingStates(unsigned short val_marker, unsigned long val_vertex) const final { - return SlidingStateNodes[val_marker][val_vertex]; + inline int GetnSlidingStates(unsigned short val_marker, unsigned long val_vertex) const final { + return SlidingStateNodes[val_marker][val_vertex]; } /*! @@ -335,4 +335,4 @@ class CTurbSolver : public CSolver { Inlet_TurbVars[val_marker][val_vertex][val_dim] = val_turb_var; } -}; \ No newline at end of file +}; diff --git a/SU2_CFD/src/integration_structure.cpp b/SU2_CFD/src/integration_structure.cpp index 4548d9566b69..2bf69ea53d7b 100644 --- a/SU2_CFD/src/integration_structure.cpp +++ b/SU2_CFD/src/integration_structure.cpp @@ -63,10 +63,10 @@ void CIntegration::Space_Integration(CGeometry *geometry, switch (config->GetKind_ConvNumScheme()) { case SPACE_CENTERED: - solver_container[MainSolver]->Centered_Residual(geometry, solver_container, numerics[CONV_TERM], config, iMesh, iRKStep); + solver_container[MainSolver]->Centered_Residual(geometry, solver_container, numerics, config, iMesh, iRKStep); break; case SPACE_UPWIND: - solver_container[MainSolver]->Upwind_Residual(geometry, solver_container, numerics[CONV_TERM], config, iMesh); + solver_container[MainSolver]->Upwind_Residual(geometry, solver_container, numerics, config, iMesh); break; case FINITE_ELEMENT: solver_container[MainSolver]->Convective_Residual(geometry, solver_container, numerics[CONV_TERM], config, iMesh, iRKStep); diff --git a/SU2_CFD/src/interfaces/cht/CConjugateHeatInterface.cpp b/SU2_CFD/src/interfaces/cht/CConjugateHeatInterface.cpp index 835ad3dcef25..7a22bf5ba01f 100644 --- a/SU2_CFD/src/interfaces/cht/CConjugateHeatInterface.cpp +++ b/SU2_CFD/src/interfaces/cht/CConjugateHeatInterface.cpp @@ -7,7 +7,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -62,8 +62,8 @@ void CConjugateHeatInterface::GetDonor_Variable(CSolver *donor_solution, CGeomet || (donor_config->GetKind_Solver() == DISC_ADJ_INC_NAVIER_STOKES) || (donor_config->GetKind_Solver() == DISC_ADJ_INC_RANS) && (donor_config->GetEnergy_Equation())); - bool heat_equation = (donor_config->GetKind_Solver() == HEAT_EQUATION_FVM - || donor_config->GetKind_Solver() == DISC_ADJ_HEAT); + bool heat_equation = (donor_config->GetKind_Solver() == HEAT_EQUATION_FVM) || + (donor_config->GetKind_Solver() == DISC_ADJ_HEAT); Coord = donor_geometry->node[Point_Donor]->GetCoord(); diff --git a/SU2_CFD/src/solvers/CAdjEulerSolver.cpp b/SU2_CFD/src/solvers/CAdjEulerSolver.cpp index f033221e3f6d..5f52e00b70cc 100644 --- a/SU2_CFD/src/solvers/CAdjEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CAdjEulerSolver.cpp @@ -1701,9 +1701,11 @@ void CAdjEulerSolver::Preprocessing(CGeometry *geometry, CSolver **solver_contai } -void CAdjEulerSolver::Centered_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, +void CAdjEulerSolver::Centered_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics_container, CConfig *config, unsigned short iMesh, unsigned short iRKStep) { + CNumerics* numerics = numerics_container[CONV_TERM]; + unsigned long iEdge, iPoint, jPoint; bool implicit = (config->GetKind_TimeIntScheme_AdjFlow() == EULER_IMPLICIT); @@ -1773,7 +1775,10 @@ 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) { +void CAdjEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_container, + CNumerics **numerics_container, CConfig *config, unsigned short iMesh) { + + CNumerics* numerics = numerics_container[CONV_TERM]; 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; @@ -4888,4 +4893,4 @@ void CAdjEulerSolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConf if (Restart_Data != NULL) delete [] Restart_Data; Restart_Vars = NULL; Restart_Data = NULL; -} \ No newline at end of file +} diff --git a/SU2_CFD/src/solvers/CAdjTurbSolver.cpp b/SU2_CFD/src/solvers/CAdjTurbSolver.cpp index 95c1549784e2..c409af03f69e 100644 --- a/SU2_CFD/src/solvers/CAdjTurbSolver.cpp +++ b/SU2_CFD/src/solvers/CAdjTurbSolver.cpp @@ -294,7 +294,10 @@ void CAdjTurbSolver::Preprocessing(CGeometry *geometry, CSolver **solver_contain } -void CAdjTurbSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, CConfig *config, unsigned short iMesh) { +void CAdjTurbSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_container, + CNumerics **numerics_container, CConfig *config, unsigned short iMesh) { + + CNumerics* numerics = numerics_container[CONV_TERM]; unsigned long iEdge, iPoint, jPoint; su2double *U_i, *U_j, *TurbPsi_i, *TurbPsi_j, **TurbVar_Grad_i, **TurbVar_Grad_j; diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index e048794de9fd..eccaf9686242 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -3032,22 +3032,25 @@ void CEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, unsigned short iMesh, unsigned long Iteration) { const bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - const bool time_stepping = config->GetTime_Marching() == TIME_STEPPING; - const bool dual_time = ((config->GetTime_Marching() == DT_STEPPING_1ST) || - (config->GetTime_Marching() == DT_STEPPING_2ND)); + const bool time_stepping = (config->GetTime_Marching() == TIME_STEPPING); + const 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; + /*--- Init thread-shared variables to compute min/max values. + * Critical sections are used for this instead of reduction + * clauses for compatibility with OpenMP 2.0 (Windows...). ---*/ + Min_Delta_Time = 1e30; Max_Delta_Time = 0.0; + + su2double Global_Delta_Time, Global_Delta_UnstTimeND = 1e30; /*--- Start OpenMP parallel section. ---*/ SU2_OMP_PARALLEL { - const int thread = omp_get_thread_num(); const su2double *Normal = nullptr; su2double Area, Vol, Mean_SoundSpeed = 0.0, Mean_ProjVel = 0.0, Lambda, Local_Delta_Time; - su2double Global_Delta_Time = 1E6, Global_Delta_UnstTimeND, ProjVel, ProjVel_i, ProjVel_j; unsigned long iEdge, iVertex, iPoint, jPoint; unsigned short iDim, iMarker; @@ -3113,7 +3116,7 @@ void CEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, if ((config->GetMarker_All_KindBC(iMarker) != INTERNAL_BOUNDARY) && (config->GetMarker_All_KindBC(iMarker) != PERIODIC_BOUNDARY)) { - SU2_OMP_FOR_STAT(omp_chunk_size) + SU2_OMP_FOR_STAT(OMP_MIN_SIZE) for (iVertex = 0; iVertex < geometry->GetnVertex(iMarker); iVertex++) { /*--- Point identification, Normal vector and area ---*/ @@ -3147,28 +3150,37 @@ void CEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, } /*--- Each element uses their own speed, steady state simulation. ---*/ + { + /*--- Thread-local variables for min/max reduction. ---*/ + su2double minDt = 1e30, maxDt = 0.0; - SU2_OMP_FOR_STAT(OMP_MIN_SIZE) - for (iPoint = 0; iPoint < nPointDomain; iPoint++) { + SU2_OMP(for schedule(static,omp_chunk_size) nowait) + for (iPoint = 0; iPoint < nPointDomain; iPoint++) { + + Vol = geometry->node[iPoint]->GetVolume(); - Vol = geometry->node[iPoint]->GetVolume(); + if (Vol != 0.0) { + Local_Delta_Time = nodes->GetLocalCFL(iPoint)*Vol / nodes->GetMax_Lambda_Inv(iPoint); - if (Vol != 0.0) { - 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(); - nodes->SetDelta_Time(iPoint,Local_Delta_Time); + minDt = min(minDt, Local_Delta_Time); + maxDt = max(maxDt, Local_Delta_Time); + + nodes->SetDelta_Time(iPoint, min(Local_Delta_Time, config->GetMax_DeltaTime())); + } + else { + nodes->SetDelta_Time(iPoint,0.0); + } } - else { - nodes->SetDelta_Time(iPoint,0.0); + /*--- Min/max over threads. ---*/ + SU2_OMP_CRITICAL + { + Min_Delta_Time = min(Min_Delta_Time, minDt); + Max_Delta_Time = max(Max_Delta_Time, maxDt); } - + SU2_OMP_BARRIER } - /*--- Compute the max and the min dt (in parallel) ---*/ + /*--- Compute the min/max dt (in parallel, now over mpi ranks). ---*/ SU2_OMP_MASTER if (config->GetComm_Level() == COMM_FULL) { @@ -3181,13 +3193,12 @@ void CEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, } SU2_OMP_BARRIER - /*--- For exact time solution use the minimum delta time of the whole mesh ---*/ + /*--- For exact time solution use the minimum delta time of the whole mesh. ---*/ if (time_stepping) { - /*--- 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 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. ---*/ SU2_OMP_MASTER { @@ -3195,42 +3206,43 @@ void CEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, Global_Delta_Time = config->GetDelta_UnstTime(); } else { - su2double rbuf_time; - SU2_MPI::Allreduce(&Global_Delta_Time, &rbuf_time, 1, MPI_DOUBLE, MPI_MIN, MPI_COMM_WORLD); - Global_Delta_Time = rbuf_time; + Global_Delta_Time = Min_Delta_Time; } - config->SetDelta_UnstTimeND(Global_Delta_Time); - - Min_Delta_Time = Global_Delta_Time; Max_Delta_Time = Global_Delta_Time; + + config->SetDelta_UnstTimeND(Global_Delta_Time); } SU2_OMP_BARRIER - /*--- Sets the regular CFL equal to the unsteady CFL ---*/ + /*--- Sets the regular CFL equal to the unsteady CFL. ---*/ SU2_OMP_FOR_STAT(omp_chunk_size) - for (iPoint = 0; iPoint < nPointDomain; iPoint++){ + for (iPoint = 0; iPoint < nPointDomain; iPoint++) { nodes->SetLocalCFL(iPoint, config->GetUnst_CFL()); nodes->SetDelta_Time(iPoint, Global_Delta_Time); } } - /*--- Recompute the unsteady time step for the dual time strategy - if the unsteady CFL is diferent from 0 ---*/ + /*--- 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 = 1e30; + /*--- Thread-local variable for reduction. ---*/ + su2double glbDtND = 1e30; + + SU2_OMP(for schedule(static,omp_chunk_size) nowait) for (iPoint = 0; iPoint < nPointDomain; iPoint++) { - Global_Delta_UnstTimeND = min(Global_Delta_UnstTimeND,config->GetUnst_CFL()*Global_Delta_Time/nodes->GetLocalCFL(iPoint)); + glbDtND = min(glbDtND, config->GetUnst_CFL()*Global_Delta_Time/nodes->GetLocalCFL(iPoint)); } + SU2_OMP_CRITICAL + Global_Delta_UnstTimeND = min(Global_Delta_UnstTimeND, glbDtND); + SU2_OMP_BARRIER SU2_OMP_MASTER { - su2double rbuf_time; - SU2_MPI::Allreduce(&Global_Delta_UnstTimeND, &rbuf_time, 1, MPI_DOUBLE, MPI_MIN, MPI_COMM_WORLD); - Global_Delta_UnstTimeND = rbuf_time; + SU2_MPI::Allreduce(&Global_Delta_UnstTimeND, &glbDtND, 1, MPI_DOUBLE, MPI_MIN, MPI_COMM_WORLD); + Global_Delta_UnstTimeND = glbDtND; config->SetDelta_UnstTimeND(Global_Delta_UnstTimeND); } @@ -3251,19 +3263,40 @@ void CEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, } -void CEulerSolver::Centered_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, +void CEulerSolver::Centered_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics_container, CConfig *config, unsigned short iMesh, unsigned short iRKStep) { - unsigned long iEdge, iPoint, jPoint; + const bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + const bool jst_scheme = ((config->GetKind_Centered_Flow() == JST) && (iMesh == MESH_0)); - bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - bool jst_scheme = ((config->GetKind_Centered_Flow() == JST) && (iMesh == MESH_0)); + /*--- Start OpenMP parallel section. ---*/ - for (iEdge = 0; iEdge < geometry->GetnEdge(); iEdge++) { + SU2_OMP_PARALLEL + { + /*--- Pick one numerics object per thread. ---*/ + CNumerics* numerics = numerics_container[CONV_TERM + omp_get_thread_num()*MAX_TERMS]; + +#ifdef HAVE_OMP + /*--- Chunk size is at least OMP_MIN_SIZE and a multiple of the color group size. ---*/ + auto chunkSize = roundUpDiv(OMP_MIN_SIZE, ColorGroupSize)*ColorGroupSize; + /*--- Loop over edge colors. ---*/ + for (auto color : EdgeColoring) + { + SU2_OMP_FOR_DYN(chunkSize) + for(auto k = 0ul; k < color.size; ++k) { + + auto iEdge = color.indices[k]; +#else + /*--- Natural coloring. ---*/ + { + for (auto iEdge = 0ul; iEdge < geometry->GetnEdge(); iEdge++) { +#endif /*--- Points in edge, set normal vectors, and number of neighbors ---*/ - iPoint = geometry->edge[iEdge]->GetNode(0); jPoint = geometry->edge[iEdge]->GetNode(1); + auto iPoint = geometry->edge[iEdge]->GetNode(0); + auto jPoint = geometry->edge[iEdge]->GetNode(1); + numerics->SetNormal(geometry->edge[iEdge]->GetNormal()); numerics->SetNeighbor(geometry->node[iPoint]->GetnNeighbor(), geometry->node[jPoint]->GetnNeighbor()); @@ -3278,8 +3311,10 @@ void CEulerSolver::Centered_Residual(CGeometry *geometry, CSolver **solver_conta /*--- Set undivided laplacian an pressure based sensor ---*/ if (jst_scheme) { - numerics->SetUndivided_Laplacian(nodes->GetUndivided_Laplacian(iPoint), nodes->GetUndivided_Laplacian(jPoint)); - numerics->SetSensor(nodes->GetSensor(iPoint), nodes->GetSensor(jPoint)); + numerics->SetUndivided_Laplacian(nodes->GetUndivided_Laplacian(iPoint), + nodes->GetUndivided_Laplacian(jPoint)); + numerics->SetSensor(nodes->GetSensor(iPoint), + nodes->GetSensor(jPoint)); } /*--- Grid movement ---*/ @@ -3302,11 +3337,15 @@ void CEulerSolver::Centered_Residual(CGeometry *geometry, CSolver **solver_conta Jacobian.UpdateBlocks(iEdge, iPoint, jPoint, Jacobian_i, Jacobian_j); } } + } // end color loop + } // end SU2_OMP_PARALLEL } -void CEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, - CConfig *config, unsigned short iMesh) { +void CEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_container, + CNumerics **numerics_container, CConfig *config, unsigned short iMesh) { + + CNumerics* numerics = numerics_container[CONV_TERM]; 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, Sensor_i, Sensor_j, Dissipation_i, Dissipation_j, *Coord_i, *Coord_j; diff --git a/SU2_CFD/src/solvers/CHeatSolverFVM.cpp b/SU2_CFD/src/solvers/CHeatSolverFVM.cpp index 7f65acfd26e6..fd9c23ed64ef 100644 --- a/SU2_CFD/src/solvers/CHeatSolverFVM.cpp +++ b/SU2_CFD/src/solvers/CHeatSolverFVM.cpp @@ -505,9 +505,11 @@ void CHeatSolverFVM::SetUndivided_Laplacian(CGeometry *geometry, CConfig *config } -void CHeatSolverFVM::Centered_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, +void CHeatSolverFVM::Centered_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics_container, CConfig *config, unsigned short iMesh, unsigned short iRKStep) { + CNumerics* numerics = numerics_container[CONV_TERM]; + su2double *V_i, *V_j, Temp_i, Temp_j; unsigned long iEdge, iPoint, jPoint; bool flow = ((config->GetKind_Solver() == INC_NAVIER_STOKES) @@ -551,7 +553,10 @@ 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) { +void CHeatSolverFVM::Upwind_Residual(CGeometry *geometry, CSolver **solver_container, + CNumerics **numerics_container, CConfig *config, unsigned short iMesh) { + + CNumerics* numerics = numerics_container[CONV_TERM]; 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; @@ -1094,12 +1099,12 @@ void CHeatSolverFVM::BC_Outlet(CGeometry *geometry, CSolver **solver_container, void CHeatSolverFVM::BC_ConjugateHeat_Interface(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, CConfig *config, unsigned short val_marker) { unsigned long iVertex, iPoint, total_index; - unsigned short iDim, iVar, iMarker; + unsigned short iDim, iVar; 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 implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); bool flow = ((config->GetKind_Solver() == INC_NAVIER_STOKES) || (config->GetKind_Solver() == INC_RANS) || (config->GetKind_Solver() == DISC_ADJ_INC_NAVIER_STOKES) diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index 494418e8f574..8658c0f3fc80 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -1812,9 +1812,11 @@ void CIncEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_contain } -void CIncEulerSolver::Centered_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, +void CIncEulerSolver::Centered_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics_container, CConfig *config, unsigned short iMesh, unsigned short iRKStep) { + CNumerics* numerics = numerics_container[CONV_TERM]; + unsigned long iEdge, iPoint, jPoint; bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); @@ -1867,8 +1869,10 @@ void CIncEulerSolver::Centered_Residual(CGeometry *geometry, CSolver **solver_co } -void CIncEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, - CConfig *config, unsigned short iMesh) { +void CIncEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_container, + CNumerics **numerics_container, CConfig *config, unsigned short iMesh) { + + CNumerics* numerics = numerics_container[CONV_TERM]; 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; diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index 84fa0d8309a6..941b4838a067 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -1948,6 +1948,7 @@ void CIncNSSolver::BC_ConjugateHeat_Interface(CGeometry *geometry, CSolver **sol Twall = Tconjugate; } else { + Twall = 0.0; SU2_MPI::Error("Unknown CHT coupling method.", CURRENT_FUNCTION); } diff --git a/SU2_CFD/src/solvers/CNSSolver.cpp b/SU2_CFD/src/solvers/CNSSolver.cpp index 0124bdcba672..511291417faf 100644 --- a/SU2_CFD/src/solvers/CNSSolver.cpp +++ b/SU2_CFD/src/solvers/CNSSolver.cpp @@ -2746,7 +2746,7 @@ void CNSSolver::BC_ConjugateHeat_Interface(CGeometry *geometry, CSolver **solver dTdn = -(There - Twall)/dist_ij; } else { - + Twall = dTdn = 0.0; SU2_MPI::Error("Unknown CHT coupling method.", CURRENT_FUNCTION); } diff --git a/SU2_CFD/src/solvers/CTemplateSolver.cpp b/SU2_CFD/src/solvers/CTemplateSolver.cpp index 481ff253acac..28b995fa8371 100644 --- a/SU2_CFD/src/solvers/CTemplateSolver.cpp +++ b/SU2_CFD/src/solvers/CTemplateSolver.cpp @@ -38,10 +38,10 @@ void CTemplateSolver::Preprocessing(CGeometry *geometry, CSolver **solver_contai void CTemplateSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh, unsigned long Iteration) { } -void CTemplateSolver::Centered_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, +void CTemplateSolver::Centered_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics_container, CConfig *config, unsigned short iMesh, unsigned short iRKStep) { } -void CTemplateSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, +void CTemplateSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics_container, CConfig *config, unsigned short iMesh) { } void CTemplateSolver::Source_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, CNumerics *second_numerics, diff --git a/SU2_CFD/src/solvers/CTransLMSolver.cpp b/SU2_CFD/src/solvers/CTransLMSolver.cpp index df2c8d1d6059..c807859d5f2c 100644 --- a/SU2_CFD/src/solvers/CTransLMSolver.cpp +++ b/SU2_CFD/src/solvers/CTransLMSolver.cpp @@ -259,7 +259,11 @@ void CTransLMSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solv } -void CTransLMSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, CConfig *config, unsigned short iMesh) { +void CTransLMSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_container, + CNumerics **numerics_container, CConfig *config, unsigned short iMesh) { + + CNumerics* numerics = numerics_container[CONV_TERM]; + su2double *trans_var_i, *trans_var_j, *U_i, *U_j; unsigned long iEdge, iPoint, jPoint; diff --git a/SU2_CFD/src/solvers/CTurbSolver.cpp b/SU2_CFD/src/solvers/CTurbSolver.cpp index d21873dfd043..b959386e3962 100644 --- a/SU2_CFD/src/solvers/CTurbSolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSolver.cpp @@ -84,7 +84,10 @@ CTurbSolver::~CTurbSolver(void) { if (nodes != nullptr) delete nodes; } -void CTurbSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, CConfig *config, unsigned short iMesh) { +void CTurbSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_container, + CNumerics **numerics_container, CConfig *config, unsigned short iMesh) { + + CNumerics* numerics = numerics_container[CONV_TERM]; su2double *Turb_i, *Turb_j, *Limiter_i = NULL, *Limiter_j = NULL, *V_i, *V_j, **Gradient_i, **Gradient_j, Project_Grad_i, Project_Grad_j; unsigned long iEdge, iPoint, jPoint; From 87cb8bb0b7e53ae4c3be6d266970344c671d2c7e Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Sun, 26 Jan 2020 12:19:43 +0000 Subject: [PATCH 007/118] split and move CNumerics files --- Common/include/interpolation_structure.hpp | 6 +- SU2_CFD/include/SU2_CFD.hpp | 1 - SU2_CFD/include/drivers/CDriver.hpp | 41 +- SU2_CFD/include/iteration_structure.hpp | 99 +- SU2_CFD/include/numerics/CNumerics.hpp | 1638 +++++ .../CAvgGradCorrected_AdjFlow.hpp | 78 + .../CAvgGradCorrected_AdjTurb.hpp | 82 + .../continuous_adjoint/CAvgGrad_AdjFlow.hpp | 72 + .../continuous_adjoint/CAvgGrad_AdjTurb.hpp | 82 + .../continuous_adjoint/CCentJST_AdjFlow.hpp | 80 + .../continuous_adjoint/CCentLax_AdjFlow.hpp | 80 + .../CSourceAxisymmetric_AdjFlow.hpp | 61 + .../CSourceConservative_AdjFlow.hpp | 59 + .../CSourceConservative_AdjTurb.hpp | 63 + .../CSourcePieceWise_AdjTurb.hpp | 66 + .../CSourceRotatingFrame_AdjFlow.hpp | 62 + .../CSourceViscous_AdjFlow.hpp | 66 + .../continuous_adjoint/CUpwLin_AdjTurb.hpp | 66 + .../continuous_adjoint/CUpwRoe_AdjFlow.hpp | 81 + .../continuous_adjoint/CUpwSca_AdjTurb.hpp | 69 + .../numerics/elasticity/CFEAElasticity.hpp | 6 +- .../convection_centered/CCentBase_Flow.hpp | 106 + .../convection_centered/CCentJSTInc_Flow.hpp | 90 + .../convection_centered/CCentJST_Flow.hpp | 75 + .../convection_centered/CCentJST_KE_Flow.hpp | 75 + .../convection_centered/CCentLaxInc_Flow.hpp | 88 + .../convection_centered/CCentLax_Flow.hpp | 74 + .../CUpwAUSMPLUSUP2_Flow.hpp | 66 + .../convection_upwind/CUpwAUSMPLUSUP_Flow.hpp | 65 + .../CUpwAUSMPLUS_SLAU_Base_Flow.hpp | 100 + .../flow/convection_upwind/CUpwAUSM_Flow.hpp | 77 + .../flow/convection_upwind/CUpwCUSP_Flow.hpp | 69 + .../convection_upwind/CUpwFDSInc_Flow.hpp | 81 + .../CUpwGeneralHLLC_Flow.hpp | 90 + .../convection_upwind/CUpwGeneralRoe_Flow.hpp | 90 + .../flow/convection_upwind/CUpwHLLC_Flow.hpp | 82 + .../flow/convection_upwind/CUpwL2Roe_Flow.hpp | 64 + .../flow/convection_upwind/CUpwLMRoe_Flow.hpp | 64 + .../flow/convection_upwind/CUpwMSW_Flow.hpp | 75 + .../convection_upwind/CUpwRoeBase_Flow.hpp | 80 + .../flow/convection_upwind/CUpwRoe_Flow.hpp | 66 + .../flow/convection_upwind/CUpwSLAU_Flow.hpp | 90 + .../convection_upwind/CUpwTurkel_Flow.hpp | 80 + .../flow/diffusion/CAvgGradInc_Flow.hpp | 97 + .../numerics/flow/diffusion/CAvgGrad_Base.hpp | 255 + .../numerics/flow/diffusion/CAvgGrad_Flow.hpp | 94 + .../flow/diffusion/CGeneralAvgGrad_Flow.hpp | 103 + .../flow/sources/CSourceAxisymmetric_Flow.hpp | 62 + .../flow/sources/CSourceBodyForce.hpp | 63 + .../flow/sources/CSourceBoussinesq.hpp | 64 + .../numerics/flow/sources/CSourceGravity.hpp | 61 + .../sources/CSourceIncAxisymmetric_Flow.hpp | 66 + .../flow/sources/CSourceIncBodyForce.hpp | 64 + .../sources/CSourceIncRotatingFrame_Flow.hpp | 67 + .../sources/CSourceRotatingFrame_Flow.hpp | 62 + .../numerics/flow/sources/CSourceWindGust.hpp | 62 + .../numerics/heat/CAvgGradCorrected_Heat.hpp | 72 + .../include/numerics/heat/CAvgGrad_Heat.hpp | 72 + .../include/numerics/heat/CCentSca_Heat.hpp | 80 + .../include/numerics/heat/CUpwSca_Heat.hpp | 70 + SU2_CFD/include/numerics/include_all.hpp | 84 + .../template/CConvective_Template.hpp | 78 + .../numerics/template/CSource_Template.hpp | 64 + .../numerics/template/CViscous_Template.hpp | 65 + .../transition/CAvgGradCorrected_TransLM.hpp | 70 + .../numerics/transition/CAvgGrad_TransLM.hpp | 73 + .../transition/CSourcePieceWise_TransLM.hpp | 95 + .../numerics/transition/CUpwLin_TransLM.hpp | 70 + .../numerics/transition/CUpwSca_TransLM.hpp | 69 + .../numerics/turbulent/CAvgGrad_Scalar.hpp | 103 + .../numerics/turbulent/CAvgGrad_TurbSA.hpp | 75 + .../turbulent/CAvgGrad_TurbSA_Neg.hpp | 77 + .../numerics/turbulent/CAvgGrad_TurbSST.hpp | 89 + .../turbulent/CSourcePieceWise_TurbSA.hpp | 133 + .../CSourcePieceWise_TurbSA_COMP.hpp | 128 + .../turbulent/CSourcePieceWise_TurbSA_E.hpp | 128 + .../CSourcePieceWise_TurbSA_E_COMP.hpp | 129 + .../turbulent/CSourcePieceWise_TurbSA_Neg.hpp | 125 + .../turbulent/CSourcePieceWise_TurbSST.hpp | 141 + .../numerics/turbulent/CUpwSca_TurbSA.hpp | 71 + .../numerics/turbulent/CUpwSca_TurbSST.hpp | 71 + .../include/numerics/turbulent/CUpwScalar.hpp | 99 + SU2_CFD/include/numerics_structure.hpp | 5381 ----------------- SU2_CFD/include/numerics_structure.inl | 494 -- SU2_CFD/include/solvers/CSolver.hpp | 2 +- SU2_CFD/src/drivers/CDriver.cpp | 37 +- .../CNumerics.cpp} | 249 +- .../CAvgGradCorrected_AdjFlow.cpp | 173 + .../CAvgGradCorrected_AdjTurb.cpp | 158 + .../continuous_adjoint/CAvgGrad_AdjFlow.cpp | 139 + .../continuous_adjoint/CAvgGrad_AdjTurb.cpp | 149 + .../continuous_adjoint/CCentJST_AdjFlow.cpp | 248 + .../continuous_adjoint/CCentLax_AdjFlow.cpp | 235 + .../CSourceAxisymmetric_AdjFlow.cpp | 74 + .../CSourceConservative_AdjFlow.cpp | 190 + .../CSourceConservative_AdjTurb.cpp | 66 + .../CSourcePieceWise_AdjTurb.cpp | 162 + .../CSourceRotatingFrame_AdjFlow.cpp | 86 + .../CSourceViscous_AdjFlow.cpp | 341 ++ .../continuous_adjoint/CUpwLin_AdjTurb.cpp | 66 + .../continuous_adjoint/CUpwRoe_AdjFlow.cpp | 334 + .../continuous_adjoint/CUpwSca_AdjTurb.cpp | 74 + .../convection_centered/CCentBase_Flow.cpp | 207 + .../convection_centered/CCentJSTInc_Flow.cpp | 241 + .../convection_centered/CCentJST_Flow.cpp | 81 + .../convection_centered/CCentJST_KE_Flow.cpp | 70 + .../convection_centered/CCentLaxInc_Flow.cpp | 234 + .../convection_centered/CCentLax_Flow.cpp | 69 + .../CUpwAUSMPLUSUP2_Flow.cpp | 120 + .../convection_upwind/CUpwAUSMPLUSUP_Flow.cpp | 258 + .../CUpwAUSMPLUS_SLAU_Base_Flow.cpp | 384 ++ .../flow/convection_upwind/CUpwAUSM_Flow.cpp | 208 + .../flow/convection_upwind/CUpwCUSP_Flow.cpp | 175 + .../convection_upwind/CUpwFDSInc_Flow.cpp | 270 + .../CUpwGeneralHLLC_Flow.cpp | 908 +++ .../convection_upwind/CUpwGeneralRoe_Flow.cpp | 360 ++ .../flow/convection_upwind/CUpwHLLC_Flow.cpp | 539 ++ .../flow/convection_upwind/CUpwL2Roe_Flow.cpp | 103 + .../flow/convection_upwind/CUpwLMRoe_Flow.cpp | 103 + .../flow/convection_upwind/CUpwMSW_Flow.cpp | 244 + .../convection_upwind/CUpwRoeBase_Flow.cpp | 242 + .../flow/convection_upwind/CUpwRoe_Flow.cpp | 72 + .../flow/convection_upwind/CUpwSLAU_Flow.cpp | 119 + .../convection_upwind/CUpwTurkel_Flow.cpp | 257 + .../flow/diffusion/CAvgGradInc_Flow.cpp | 274 + .../numerics/flow/diffusion/CAvgGrad_Base.cpp | 560 ++ .../numerics/flow/diffusion/CAvgGrad_Flow.cpp | 223 + .../flow/diffusion/CGeneralAvgGrad_Flow.cpp | 232 + .../flow/sources/CSourceAxisymmetric_Flow.cpp | 107 + .../flow/sources/CSourceBodyForce.cpp | 66 + .../flow/sources/CSourceBoussinesq.cpp | 72 + .../numerics/flow/sources/CSourceGravity.cpp | 45 + .../sources/CSourceIncAxisymmetric_Flow.cpp | 154 + .../flow/sources/CSourceIncBodyForce.cpp | 73 + .../sources/CSourceIncRotatingFrame_Flow.cpp | 94 + .../sources/CSourceRotatingFrame_Flow.cpp | 91 + .../numerics/flow/sources/CSourceWindGust.cpp | 93 + .../numerics/heat/CAvgGradCorrected_Heat.cpp | 107 + SU2_CFD/src/numerics/heat/CAvgGrad_Heat.cpp | 99 + SU2_CFD/src/numerics/heat/CCentSca_Heat.cpp | 114 + SU2_CFD/src/numerics/heat/CUpwSca_Heat.cpp | 80 + .../template/CConvective_Template.cpp} | 27 +- .../numerics/template/CSource_Template.cpp | 37 + .../numerics/template/CViscous_Template.cpp | 35 + .../transition/CAvgGradCorrected_TransLM.cpp | 108 + .../numerics/transition/CAvgGrad_TransLM.cpp | 139 + .../transition/CSourcePieceWise_TransLM.cpp} | 294 +- .../numerics/transition/CUpwLin_TransLM.cpp | 74 + .../numerics/transition/CUpwSca_TransLM.cpp | 72 + .../numerics/turbulent/CAvgGrad_Scalar.cpp | 126 + .../numerics/turbulent/CAvgGrad_TurbSA.cpp | 59 + .../turbulent/CAvgGrad_TurbSA_Neg.cpp | 76 + .../numerics/turbulent/CAvgGrad_TurbSST.cpp | 87 + .../turbulent/CSourcePieceWise_TurbSA.cpp | 202 + .../CSourcePieceWise_TurbSA_COMP.cpp | 166 + .../turbulent/CSourcePieceWise_TurbSA_E.cpp | 171 + .../CSourcePieceWise_TurbSA_E_COMP.cpp | 183 + .../turbulent/CSourcePieceWise_TurbSA_Neg.cpp | 193 + .../turbulent/CSourcePieceWise_TurbSST.cpp | 371 ++ .../src/numerics/turbulent/CUpwSca_TurbSA.cpp | 51 + .../numerics/turbulent/CUpwSca_TurbSST.cpp | 61 + SU2_CFD/src/numerics/turbulent/CUpwScalar.cpp | 94 + SU2_CFD/src/numerics_adjoint_mean.cpp | 1598 ----- SU2_CFD/src/numerics_adjoint_turbulent.cpp | 538 -- SU2_CFD/src/numerics_direct_heat.cpp | 318 - SU2_CFD/src/numerics_direct_mean.cpp | 5210 ---------------- SU2_CFD/src/numerics_direct_mean_inc.cpp | 1219 ---- SU2_CFD/src/numerics_direct_turbulent.cpp | 1506 ----- 168 files changed, 20675 insertions(+), 16802 deletions(-) create mode 100644 SU2_CFD/include/numerics/CNumerics.hpp create mode 100644 SU2_CFD/include/numerics/continuous_adjoint/CAvgGradCorrected_AdjFlow.hpp create mode 100644 SU2_CFD/include/numerics/continuous_adjoint/CAvgGradCorrected_AdjTurb.hpp create mode 100644 SU2_CFD/include/numerics/continuous_adjoint/CAvgGrad_AdjFlow.hpp create mode 100644 SU2_CFD/include/numerics/continuous_adjoint/CAvgGrad_AdjTurb.hpp create mode 100644 SU2_CFD/include/numerics/continuous_adjoint/CCentJST_AdjFlow.hpp create mode 100644 SU2_CFD/include/numerics/continuous_adjoint/CCentLax_AdjFlow.hpp create mode 100644 SU2_CFD/include/numerics/continuous_adjoint/CSourceAxisymmetric_AdjFlow.hpp create mode 100644 SU2_CFD/include/numerics/continuous_adjoint/CSourceConservative_AdjFlow.hpp create mode 100644 SU2_CFD/include/numerics/continuous_adjoint/CSourceConservative_AdjTurb.hpp create mode 100644 SU2_CFD/include/numerics/continuous_adjoint/CSourcePieceWise_AdjTurb.hpp create mode 100644 SU2_CFD/include/numerics/continuous_adjoint/CSourceRotatingFrame_AdjFlow.hpp create mode 100644 SU2_CFD/include/numerics/continuous_adjoint/CSourceViscous_AdjFlow.hpp create mode 100644 SU2_CFD/include/numerics/continuous_adjoint/CUpwLin_AdjTurb.hpp create mode 100644 SU2_CFD/include/numerics/continuous_adjoint/CUpwRoe_AdjFlow.hpp create mode 100644 SU2_CFD/include/numerics/continuous_adjoint/CUpwSca_AdjTurb.hpp create mode 100644 SU2_CFD/include/numerics/flow/convection_centered/CCentBase_Flow.hpp create mode 100644 SU2_CFD/include/numerics/flow/convection_centered/CCentJSTInc_Flow.hpp create mode 100644 SU2_CFD/include/numerics/flow/convection_centered/CCentJST_Flow.hpp create mode 100644 SU2_CFD/include/numerics/flow/convection_centered/CCentJST_KE_Flow.hpp create mode 100644 SU2_CFD/include/numerics/flow/convection_centered/CCentLaxInc_Flow.hpp create mode 100644 SU2_CFD/include/numerics/flow/convection_centered/CCentLax_Flow.hpp create mode 100644 SU2_CFD/include/numerics/flow/convection_upwind/CUpwAUSMPLUSUP2_Flow.hpp create mode 100644 SU2_CFD/include/numerics/flow/convection_upwind/CUpwAUSMPLUSUP_Flow.hpp create mode 100644 SU2_CFD/include/numerics/flow/convection_upwind/CUpwAUSMPLUS_SLAU_Base_Flow.hpp create mode 100644 SU2_CFD/include/numerics/flow/convection_upwind/CUpwAUSM_Flow.hpp create mode 100644 SU2_CFD/include/numerics/flow/convection_upwind/CUpwCUSP_Flow.hpp create mode 100644 SU2_CFD/include/numerics/flow/convection_upwind/CUpwFDSInc_Flow.hpp create mode 100644 SU2_CFD/include/numerics/flow/convection_upwind/CUpwGeneralHLLC_Flow.hpp create mode 100644 SU2_CFD/include/numerics/flow/convection_upwind/CUpwGeneralRoe_Flow.hpp create mode 100644 SU2_CFD/include/numerics/flow/convection_upwind/CUpwHLLC_Flow.hpp create mode 100644 SU2_CFD/include/numerics/flow/convection_upwind/CUpwL2Roe_Flow.hpp create mode 100644 SU2_CFD/include/numerics/flow/convection_upwind/CUpwLMRoe_Flow.hpp create mode 100644 SU2_CFD/include/numerics/flow/convection_upwind/CUpwMSW_Flow.hpp create mode 100644 SU2_CFD/include/numerics/flow/convection_upwind/CUpwRoeBase_Flow.hpp create mode 100644 SU2_CFD/include/numerics/flow/convection_upwind/CUpwRoe_Flow.hpp create mode 100644 SU2_CFD/include/numerics/flow/convection_upwind/CUpwSLAU_Flow.hpp create mode 100644 SU2_CFD/include/numerics/flow/convection_upwind/CUpwTurkel_Flow.hpp create mode 100644 SU2_CFD/include/numerics/flow/diffusion/CAvgGradInc_Flow.hpp create mode 100644 SU2_CFD/include/numerics/flow/diffusion/CAvgGrad_Base.hpp create mode 100644 SU2_CFD/include/numerics/flow/diffusion/CAvgGrad_Flow.hpp create mode 100644 SU2_CFD/include/numerics/flow/diffusion/CGeneralAvgGrad_Flow.hpp create mode 100644 SU2_CFD/include/numerics/flow/sources/CSourceAxisymmetric_Flow.hpp create mode 100644 SU2_CFD/include/numerics/flow/sources/CSourceBodyForce.hpp create mode 100644 SU2_CFD/include/numerics/flow/sources/CSourceBoussinesq.hpp create mode 100644 SU2_CFD/include/numerics/flow/sources/CSourceGravity.hpp create mode 100644 SU2_CFD/include/numerics/flow/sources/CSourceIncAxisymmetric_Flow.hpp create mode 100644 SU2_CFD/include/numerics/flow/sources/CSourceIncBodyForce.hpp create mode 100644 SU2_CFD/include/numerics/flow/sources/CSourceIncRotatingFrame_Flow.hpp create mode 100644 SU2_CFD/include/numerics/flow/sources/CSourceRotatingFrame_Flow.hpp create mode 100644 SU2_CFD/include/numerics/flow/sources/CSourceWindGust.hpp create mode 100644 SU2_CFD/include/numerics/heat/CAvgGradCorrected_Heat.hpp create mode 100644 SU2_CFD/include/numerics/heat/CAvgGrad_Heat.hpp create mode 100644 SU2_CFD/include/numerics/heat/CCentSca_Heat.hpp create mode 100644 SU2_CFD/include/numerics/heat/CUpwSca_Heat.hpp create mode 100644 SU2_CFD/include/numerics/include_all.hpp create mode 100644 SU2_CFD/include/numerics/template/CConvective_Template.hpp create mode 100644 SU2_CFD/include/numerics/template/CSource_Template.hpp create mode 100644 SU2_CFD/include/numerics/template/CViscous_Template.hpp create mode 100644 SU2_CFD/include/numerics/transition/CAvgGradCorrected_TransLM.hpp create mode 100644 SU2_CFD/include/numerics/transition/CAvgGrad_TransLM.hpp create mode 100644 SU2_CFD/include/numerics/transition/CSourcePieceWise_TransLM.hpp create mode 100644 SU2_CFD/include/numerics/transition/CUpwLin_TransLM.hpp create mode 100644 SU2_CFD/include/numerics/transition/CUpwSca_TransLM.hpp create mode 100644 SU2_CFD/include/numerics/turbulent/CAvgGrad_Scalar.hpp create mode 100644 SU2_CFD/include/numerics/turbulent/CAvgGrad_TurbSA.hpp create mode 100644 SU2_CFD/include/numerics/turbulent/CAvgGrad_TurbSA_Neg.hpp create mode 100644 SU2_CFD/include/numerics/turbulent/CAvgGrad_TurbSST.hpp create mode 100644 SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA.hpp create mode 100644 SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA_COMP.hpp create mode 100644 SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA_E.hpp create mode 100644 SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA_E_COMP.hpp create mode 100644 SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA_Neg.hpp create mode 100644 SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSST.hpp create mode 100644 SU2_CFD/include/numerics/turbulent/CUpwSca_TurbSA.hpp create mode 100644 SU2_CFD/include/numerics/turbulent/CUpwSca_TurbSST.hpp create mode 100644 SU2_CFD/include/numerics/turbulent/CUpwScalar.hpp delete mode 100644 SU2_CFD/include/numerics_structure.hpp delete mode 100644 SU2_CFD/include/numerics_structure.inl rename SU2_CFD/src/{numerics_structure.cpp => numerics/CNumerics.cpp} (98%) create mode 100644 SU2_CFD/src/numerics/continuous_adjoint/CAvgGradCorrected_AdjFlow.cpp create mode 100644 SU2_CFD/src/numerics/continuous_adjoint/CAvgGradCorrected_AdjTurb.cpp create mode 100644 SU2_CFD/src/numerics/continuous_adjoint/CAvgGrad_AdjFlow.cpp create mode 100644 SU2_CFD/src/numerics/continuous_adjoint/CAvgGrad_AdjTurb.cpp create mode 100644 SU2_CFD/src/numerics/continuous_adjoint/CCentJST_AdjFlow.cpp create mode 100644 SU2_CFD/src/numerics/continuous_adjoint/CCentLax_AdjFlow.cpp create mode 100644 SU2_CFD/src/numerics/continuous_adjoint/CSourceAxisymmetric_AdjFlow.cpp create mode 100644 SU2_CFD/src/numerics/continuous_adjoint/CSourceConservative_AdjFlow.cpp create mode 100644 SU2_CFD/src/numerics/continuous_adjoint/CSourceConservative_AdjTurb.cpp create mode 100644 SU2_CFD/src/numerics/continuous_adjoint/CSourcePieceWise_AdjTurb.cpp create mode 100644 SU2_CFD/src/numerics/continuous_adjoint/CSourceRotatingFrame_AdjFlow.cpp create mode 100644 SU2_CFD/src/numerics/continuous_adjoint/CSourceViscous_AdjFlow.cpp create mode 100644 SU2_CFD/src/numerics/continuous_adjoint/CUpwLin_AdjTurb.cpp create mode 100644 SU2_CFD/src/numerics/continuous_adjoint/CUpwRoe_AdjFlow.cpp create mode 100644 SU2_CFD/src/numerics/continuous_adjoint/CUpwSca_AdjTurb.cpp create mode 100644 SU2_CFD/src/numerics/flow/convection_centered/CCentBase_Flow.cpp create mode 100644 SU2_CFD/src/numerics/flow/convection_centered/CCentJSTInc_Flow.cpp create mode 100644 SU2_CFD/src/numerics/flow/convection_centered/CCentJST_Flow.cpp create mode 100644 SU2_CFD/src/numerics/flow/convection_centered/CCentJST_KE_Flow.cpp create mode 100644 SU2_CFD/src/numerics/flow/convection_centered/CCentLaxInc_Flow.cpp create mode 100644 SU2_CFD/src/numerics/flow/convection_centered/CCentLax_Flow.cpp create mode 100644 SU2_CFD/src/numerics/flow/convection_upwind/CUpwAUSMPLUSUP2_Flow.cpp create mode 100644 SU2_CFD/src/numerics/flow/convection_upwind/CUpwAUSMPLUSUP_Flow.cpp create mode 100644 SU2_CFD/src/numerics/flow/convection_upwind/CUpwAUSMPLUS_SLAU_Base_Flow.cpp create mode 100644 SU2_CFD/src/numerics/flow/convection_upwind/CUpwAUSM_Flow.cpp create mode 100644 SU2_CFD/src/numerics/flow/convection_upwind/CUpwCUSP_Flow.cpp create mode 100644 SU2_CFD/src/numerics/flow/convection_upwind/CUpwFDSInc_Flow.cpp create mode 100644 SU2_CFD/src/numerics/flow/convection_upwind/CUpwGeneralHLLC_Flow.cpp create mode 100644 SU2_CFD/src/numerics/flow/convection_upwind/CUpwGeneralRoe_Flow.cpp create mode 100644 SU2_CFD/src/numerics/flow/convection_upwind/CUpwHLLC_Flow.cpp create mode 100644 SU2_CFD/src/numerics/flow/convection_upwind/CUpwL2Roe_Flow.cpp create mode 100644 SU2_CFD/src/numerics/flow/convection_upwind/CUpwLMRoe_Flow.cpp create mode 100644 SU2_CFD/src/numerics/flow/convection_upwind/CUpwMSW_Flow.cpp create mode 100644 SU2_CFD/src/numerics/flow/convection_upwind/CUpwRoeBase_Flow.cpp create mode 100644 SU2_CFD/src/numerics/flow/convection_upwind/CUpwRoe_Flow.cpp create mode 100644 SU2_CFD/src/numerics/flow/convection_upwind/CUpwSLAU_Flow.cpp create mode 100644 SU2_CFD/src/numerics/flow/convection_upwind/CUpwTurkel_Flow.cpp create mode 100644 SU2_CFD/src/numerics/flow/diffusion/CAvgGradInc_Flow.cpp create mode 100644 SU2_CFD/src/numerics/flow/diffusion/CAvgGrad_Base.cpp create mode 100644 SU2_CFD/src/numerics/flow/diffusion/CAvgGrad_Flow.cpp create mode 100644 SU2_CFD/src/numerics/flow/diffusion/CGeneralAvgGrad_Flow.cpp create mode 100644 SU2_CFD/src/numerics/flow/sources/CSourceAxisymmetric_Flow.cpp create mode 100644 SU2_CFD/src/numerics/flow/sources/CSourceBodyForce.cpp create mode 100644 SU2_CFD/src/numerics/flow/sources/CSourceBoussinesq.cpp create mode 100644 SU2_CFD/src/numerics/flow/sources/CSourceGravity.cpp create mode 100644 SU2_CFD/src/numerics/flow/sources/CSourceIncAxisymmetric_Flow.cpp create mode 100644 SU2_CFD/src/numerics/flow/sources/CSourceIncBodyForce.cpp create mode 100644 SU2_CFD/src/numerics/flow/sources/CSourceIncRotatingFrame_Flow.cpp create mode 100644 SU2_CFD/src/numerics/flow/sources/CSourceRotatingFrame_Flow.cpp create mode 100644 SU2_CFD/src/numerics/flow/sources/CSourceWindGust.cpp create mode 100644 SU2_CFD/src/numerics/heat/CAvgGradCorrected_Heat.cpp create mode 100644 SU2_CFD/src/numerics/heat/CAvgGrad_Heat.cpp create mode 100644 SU2_CFD/src/numerics/heat/CCentSca_Heat.cpp create mode 100644 SU2_CFD/src/numerics/heat/CUpwSca_Heat.cpp rename SU2_CFD/src/{numerics_template.cpp => numerics/template/CConvective_Template.cpp} (89%) create mode 100644 SU2_CFD/src/numerics/template/CSource_Template.cpp create mode 100644 SU2_CFD/src/numerics/template/CViscous_Template.cpp create mode 100644 SU2_CFD/src/numerics/transition/CAvgGradCorrected_TransLM.cpp create mode 100644 SU2_CFD/src/numerics/transition/CAvgGrad_TransLM.cpp rename SU2_CFD/src/{numerics_direct_transition.cpp => numerics/transition/CSourcePieceWise_TransLM.cpp} (60%) create mode 100644 SU2_CFD/src/numerics/transition/CUpwLin_TransLM.cpp create mode 100644 SU2_CFD/src/numerics/transition/CUpwSca_TransLM.cpp create mode 100644 SU2_CFD/src/numerics/turbulent/CAvgGrad_Scalar.cpp create mode 100644 SU2_CFD/src/numerics/turbulent/CAvgGrad_TurbSA.cpp create mode 100644 SU2_CFD/src/numerics/turbulent/CAvgGrad_TurbSA_Neg.cpp create mode 100644 SU2_CFD/src/numerics/turbulent/CAvgGrad_TurbSST.cpp create mode 100644 SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSA.cpp create mode 100644 SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSA_COMP.cpp create mode 100644 SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSA_E.cpp create mode 100644 SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSA_E_COMP.cpp create mode 100644 SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSA_Neg.cpp create mode 100644 SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSST.cpp create mode 100644 SU2_CFD/src/numerics/turbulent/CUpwSca_TurbSA.cpp create mode 100644 SU2_CFD/src/numerics/turbulent/CUpwSca_TurbSST.cpp create mode 100644 SU2_CFD/src/numerics/turbulent/CUpwScalar.cpp delete mode 100644 SU2_CFD/src/numerics_adjoint_mean.cpp delete mode 100644 SU2_CFD/src/numerics_adjoint_turbulent.cpp delete mode 100644 SU2_CFD/src/numerics_direct_heat.cpp delete mode 100644 SU2_CFD/src/numerics_direct_mean.cpp delete mode 100644 SU2_CFD/src/numerics_direct_mean_inc.cpp delete mode 100644 SU2_CFD/src/numerics_direct_turbulent.cpp diff --git a/Common/include/interpolation_structure.hpp b/Common/include/interpolation_structure.hpp index d76f479c5f2b..67058010bbe4 100644 --- a/Common/include/interpolation_structure.hpp +++ b/Common/include/interpolation_structure.hpp @@ -1,7 +1,7 @@ /*! * \file interpolation_structure.hpp - * \brief Headers of the main subroutines used by SU2_FSI. - * The subroutines and functions are in the interpolation_structure.cpp file. + * \brief Headers of classes used for multiphysics interpolation. + * The implementation is in the interpolation_structure.cpp file. * \author H. Kline * \version 7.0.0 "Blackbird" * @@ -244,7 +244,7 @@ class CIsoparametric : public CInterpolator { * \param[in] nDim - the dimension of the coordinates. * \param[in] iZone_1 - zone index of the element to use for interpolation (the DONOR zone) * \param[in] donor_elem - element index of the element to use for interpolation (or global index of a point in 2D) - * \param[in[ nDonorPoints - number of donor points in the element. + * \param[in] nDonorPoints - number of donor points in the element. * \param[in] xj - point projected onto the plane of the donor element. * \param[out] isoparams - isoparametric coefficients. Must be allocated to size nNodes ahead of time. (size> nDonors) * diff --git a/SU2_CFD/include/SU2_CFD.hpp b/SU2_CFD/include/SU2_CFD.hpp index 1c0d0e0f11b5..3d95bb2e910d 100644 --- a/SU2_CFD/include/SU2_CFD.hpp +++ b/SU2_CFD/include/SU2_CFD.hpp @@ -41,7 +41,6 @@ #include "drivers/CDummyDriver.hpp" #include "integration_structure.hpp" #include "output/COutput.hpp" -#include "numerics_structure.hpp" #include "../../Common/include/fem_geometry_structure.hpp" #include "../../Common/include/geometry/CGeometry.hpp" #include "../../Common/include/grid_movement_structure.hpp" diff --git a/SU2_CFD/include/drivers/CDriver.hpp b/SU2_CFD/include/drivers/CDriver.hpp index 262fb1480ba3..3285080b5271 100644 --- a/SU2_CFD/include/drivers/CDriver.hpp +++ b/SU2_CFD/include/drivers/CDriver.hpp @@ -7,7 +7,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -29,50 +29,17 @@ #pragma once #include "../../../Common/include/mpi_structure.hpp" -#include "../iteration_structure.hpp" -#include "../solvers/CSolver.hpp" -#include "../solvers/CEulerSolver.hpp" -#include "../solvers/CIncEulerSolver.hpp" -#include "../solvers/CNSSolver.hpp" -#include "../solvers/CIncNSSolver.hpp" -#include "../solvers/CTurbSASolver.hpp" -#include "../solvers/CTurbSSTSolver.hpp" -#include "../solvers/CTransLMSolver.hpp" -#include "../solvers/CAdjEulerSolver.hpp" -#include "../solvers/CAdjNSSolver.hpp" -#include "../solvers/CAdjTurbSolver.hpp" -#include "../solvers/CHeatSolverFVM.hpp" -#include "../solvers/CFEASolver.hpp" -#include "../solvers/CTemplateSolver.hpp" -#include "../solvers/CDiscAdjSolver.hpp" -#include "../solvers/CDiscAdjFEASolver.hpp" -#include "../solvers/CFEM_DG_EulerSolver.hpp" -#include "../solvers/CFEM_DG_NSSolver.hpp" - +#include "../iteration_structure.hpp" #include "../integration_structure.hpp" - -#include "../numerics_structure.hpp" -/*--- Transfer includes ---*/ +#include "../solvers/CSolver.hpp" #include "../interfaces/CInterface.hpp" -#include "../interfaces/cfd/CConservativeVarsInterface.hpp" -#include "../interfaces/cfd/CMixingPlaneInterface.hpp" -#include "../interfaces/cfd/CSlidingInterface.hpp" -#include "../interfaces/cht/CConjugateHeatInterface.hpp" -#include "../interfaces/fsi/CDisplacementsInterface.hpp" -#include "../interfaces/fsi/CFlowTractionInterface.hpp" -#include "../interfaces/fsi/CDiscAdjFlowTractionInterface.hpp" -#include "../interfaces/fsi/CDisplacementsInterfaceLegacy.hpp" -#include "../interfaces/fsi/CDiscAdjDisplacementsInterfaceLegacy.hpp" -#include "../solvers/CDiscAdjMeshSolver.hpp" -#include "../solvers/CMeshSolver.hpp" + #include "../../../Common/include/geometry/CGeometry.hpp" #include "../../../Common/include/grid_movement_structure.hpp" -#include "../../../Common/include/config_structure.hpp" #include "../../../Common/include/interpolation_structure.hpp" #include "../output/COutputLegacy.hpp" - #include "../output/COutput.hpp" #include "../output/CMultizoneOutput.hpp" #include "../output/CElasticityOutput.hpp" diff --git a/SU2_CFD/include/iteration_structure.hpp b/SU2_CFD/include/iteration_structure.hpp index 6dca138d3cb1..d14de580041e 100644 --- a/SU2_CFD/include/iteration_structure.hpp +++ b/SU2_CFD/include/iteration_structure.hpp @@ -7,7 +7,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -36,7 +36,6 @@ #include "solvers/CFEASolver.hpp" #include "integration_structure.hpp" #include "output/COutput.hpp" -#include "numerics_structure.hpp" #include "../../Common/include/geometry/CGeometry.hpp" #include "../../Common/include/grid_movement_structure.hpp" #include "../../Common/include/config_structure.hpp" @@ -54,7 +53,7 @@ class CIteration { size; /*!< \brief MPI Size. */ unsigned short nZone; /*!< \brief Total number of zones in the problem. */ unsigned short nInst; /*!< \brief Total number of instances in the problem. */ - + bool multizone, /*!< \brief Flag for multizone problems. */ singlezone; /*!< \brief Flag for singlezone problems. */ @@ -63,12 +62,12 @@ class CIteration { UsedTime; public: - + /*! * \brief Constructor of the class. */ CIteration(CConfig *config); - + /*! * \brief Destructor of the class. */ @@ -104,7 +103,7 @@ class CIteration { CNumerics ***numerics_container, CConfig *config_container, unsigned short kind_recording); - + /*! * \brief A virtual member. * \param[in] ??? - Description here. @@ -120,7 +119,7 @@ class CIteration { CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst); - + /*! * \brief A virtual member. * \param[in] output - Pointer to the COutput class. @@ -144,7 +143,7 @@ class CIteration { CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst); - + /*! * \brief A virtual member. * \param[in] output - Pointer to the COutput class. @@ -192,7 +191,7 @@ class CIteration { CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst); - + /*! * \brief A virtual member. * \param[in] output - Pointer to the COutput class. @@ -256,7 +255,7 @@ class CIteration { CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst); - + /*! * \brief A virtual member. * \param[in] ??? - Description here. @@ -269,7 +268,7 @@ class CIteration { bool StopCalc, unsigned short val_iZone, unsigned short val_iInst); - + /*! * \brief A virtual member. * \param[in] output - Pointer to the COutput class. @@ -359,18 +358,18 @@ class CIteration { */ class CFluidIteration : public CIteration { public: - + /*! * \brief Constructor of the class. * \param[in] config - Definition of the particular problem. */ CFluidIteration(CConfig *config); - + /*! * \brief Destructor of the class. */ ~CFluidIteration(void); - + /*! * \brief Preprocessing to prepare for an iteration of the physics. * \param[in] ??? - Description here. @@ -386,7 +385,7 @@ class CFluidIteration : public CIteration { CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst); - + /*! * \brief Perform a single iteration of the fluid system. * \param[in] output - Pointer to the COutput class. @@ -410,7 +409,7 @@ class CFluidIteration : public CIteration { CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst); - + /*! * \brief Iterate the fluid system for a number of Inner_Iter iterations. * \param[in] output - Pointer to the COutput class. @@ -450,7 +449,7 @@ class CFluidIteration : public CIteration { CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst); - + /*! * \brief Monitors the convergence and other metrics for the fluid system. * \param[in] ??? - Description here. @@ -466,7 +465,7 @@ class CFluidIteration : public CIteration { CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst); - + /*! * \brief Postprocesses the fluid system before heading to another physics system or the next iteration. * \param[in] solver - Container vector with all the solutions. @@ -484,7 +483,7 @@ class CFluidIteration : public CIteration { CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst); - + /*! * \brief Imposes a gust via the grid velocities. * \author S. Padron @@ -493,7 +492,7 @@ class CFluidIteration : public CIteration { * \param[in] solver - Container vector with all the solutions. */ void SetWind_GustField(CConfig *config, CGeometry **geometry, CSolver ***solver); - + /*! * \brief Reads and initializes the vortex positions, strengths and gradient. * \author S. Padron @@ -504,7 +503,7 @@ class CFluidIteration : public CIteration { * \param[in] r_core - Vector of vortex core size. */ void InitializeVortexDistribution(unsigned long &nVortex, vector& x0, vector& y0, vector& vort_strength, vector& r_core); - + /*! * \brief Fixed CL monitoring function @@ -513,7 +512,7 @@ class CFluidIteration : public CIteration { * \param[in] geometry - Geometrical definition of the problem. * \param[in] solver - Pointer to the flow solver * \param[in] config - Definition of the particular problem. - * \return Boolean indicating weather calculation should be stopped + * \return Boolean indicating weather calculation should be stopped */ bool MonitorFixed_CL(COutput *output, CGeometry *geometry, CSolver **solver, CConfig *config); }; @@ -584,18 +583,18 @@ class CTurboIteration : public CFluidIteration { */ class CFEMFluidIteration : public CFluidIteration { public: - + /*! * \brief Constructor of the class. * \param[in] config - Definition of the particular problem. */ CFEMFluidIteration(CConfig *config); - + /*! * \brief Destructor of the class. */ ~CFEMFluidIteration(void); - + /*! * \brief Preprocessing to prepare for an iteration of the physics. * \param[in] output - Pointer to the COutput class. @@ -642,7 +641,7 @@ class CFEMFluidIteration : public CFluidIteration { CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst); - + /*! * \brief Updates the containers for the finite element flow system. * \param[in] ??? - Description here. @@ -658,7 +657,7 @@ class CFEMFluidIteration : public CFluidIteration { CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst); - + /*! * \brief Postprocess routine for the finite element flow system. * \param[in] solver - Container vector with all the solutions. @@ -685,18 +684,18 @@ class CFEMFluidIteration : public CFluidIteration { */ class CHeatIteration : public CIteration { public: - + /*! * \brief Constructor of the class. * \param[in] config - Definition of the particular problem. */ CHeatIteration(CConfig *config); - + /*! * \brief Destructor of the class. */ ~CHeatIteration(void); - + /*! * \brief Preprocessing to prepare for an iteration of the physics. * \param[in] ??? - Description here. @@ -712,7 +711,7 @@ class CHeatIteration : public CIteration { CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst); - + /*! * \brief Perform a single iteration of the heat system. * \param[in] output - Pointer to the COutput class. @@ -777,7 +776,7 @@ class CHeatIteration : public CIteration { CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst); - + /*! * \brief Monitors the convergence and other metrics for the heat system. * \param[in] ??? - Description here. @@ -793,7 +792,7 @@ class CHeatIteration : public CIteration { CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst); - + /*! * \brief Postprocess ???. * \param[in] solver - Container vector with all the solutions. @@ -811,7 +810,7 @@ class CHeatIteration : public CIteration { CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst); - + }; /*! @@ -1000,18 +999,18 @@ class CFEAIteration : public CIteration { */ class CAdjFluidIteration : public CFluidIteration { public: - + /*! * \brief Constructor of the class. * \param[in] config - Definition of the particular problem. */ CAdjFluidIteration(CConfig *config); - + /*! * \brief Destructor of the class. */ ~CAdjFluidIteration(void); - + /*! * \brief Preprocessing to prepare for an iteration of the physics. * \param[in] ??? - Description here. @@ -1027,7 +1026,7 @@ class CAdjFluidIteration : public CFluidIteration { CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst); - + /*! * \brief Perform a single iteration of the adjoint fluid system. * \param[in] output - Pointer to the COutput class. @@ -1051,7 +1050,7 @@ class CAdjFluidIteration : public CFluidIteration { CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst); - + /*! * \brief Updates the containers for the adjoint fluid system. * \param[in] ??? - Description here. @@ -1067,9 +1066,9 @@ class CAdjFluidIteration : public CFluidIteration { CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst); - - + + }; /*! @@ -1086,18 +1085,18 @@ class CDiscAdjFluidIteration : public CIteration { bool turbulent; /*!< \brief Stores the turbulent flag. */ public: - + /*! * \brief Constructor of the class. * \param[in] config - Definition of the particular problem. */ CDiscAdjFluidIteration(CConfig *config); - + /*! * \brief Destructor of the class. */ ~CDiscAdjFluidIteration(void); - + /*! * \brief Preprocessing to prepare for an iteration of the physics. * \brief Perform a single iteration of the adjoint fluid system. @@ -1124,7 +1123,7 @@ class CDiscAdjFluidIteration : public CIteration { CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst); - + /*! * \brief Perform a single iteration of the adjoint fluid system. * \param[in] output - Pointer to the COutput class. @@ -1150,7 +1149,7 @@ class CDiscAdjFluidIteration : public CIteration { CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst); - + /*! * \brief Updates the containers for the discrete adjoint fluid system. @@ -1177,7 +1176,7 @@ class CDiscAdjFluidIteration : public CIteration { CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst); - + /*! * \brief Monitors the convergence and other metrics for the discrete adjoint fluid system. * \param[in] output - Pointer to the COutput class. @@ -1203,7 +1202,7 @@ class CDiscAdjFluidIteration : public CIteration { CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst); - + /*! * \brief Postprocess the discrete adjoint fluid iteration. * \param[in] output - Pointer to the COutput class. @@ -1544,7 +1543,7 @@ class CDiscAdjFEAIteration : public CIteration { */ void RegisterOutput(CSolver *****solver, CGeometry ****geometry, CConfig** config, unsigned short iZone, unsigned short iInst); using CIteration::RegisterOutput; - + /*! * \brief Initializes the adjoints of the output variables of the FEM iteration. * \param[in] solver - Container vector with all the solutions. @@ -1774,7 +1773,7 @@ class CDiscAdjHeatIteration : public CIteration { bool StopCalc, unsigned short val_iZone, unsigned short val_iInst); - + /*! * \brief Perform a single iteration of the adjoint fluid system. diff --git a/SU2_CFD/include/numerics/CNumerics.hpp b/SU2_CFD/include/numerics/CNumerics.hpp new file mode 100644 index 000000000000..535166461607 --- /dev/null +++ b/SU2_CFD/include/numerics/CNumerics.hpp @@ -0,0 +1,1638 @@ +/*! + * \file CNumerics.hpp + * \brief Delaration of numerics class CNumerics, the + * implementation is in the CNumerics.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../../../Common/include/mpi_structure.hpp" + +#include +#include +#include +#include + +#include "../../../Common/include/config_structure.hpp" +#include "../fluid_model.hpp" + +using namespace std; + +class CElement; + +/*! + * \class CNumerics + * \brief Class for defining the numerical methods. + * \author F. Palacios, T. Economon + */ +class CNumerics { +protected: + unsigned short nDim, nVar; /*!< \brief Number of dimensions and variables. */ + su2double Gamma; /*!< \brief Fluid's Gamma constant (ratio of specific heats). */ + su2double Gamma_Minus_One; /*!< \brief Fluids's Gamma - 1.0 . */ + su2double Minf; /*!< \brief Free stream Mach number . */ + su2double Gas_Constant; /*!< \brief Gas constant. */ + su2double *Vector; /*!< \brief Auxiliary vector. */ + su2double *Enthalpy_formation; /*!< \brief Enthalpy of formation. */ + su2double Prandtl_Lam; /*!< \brief Laminar Prandtl's number. */ + su2double Prandtl_Turb; /*!< \brief Turbulent Prandtl's number. */ + +public: + + su2double + **Flux_Tensor, /*!< \brief Flux tensor (used for viscous and inviscid purposes. */ + *Proj_Flux_Tensor; /*!< \brief Flux tensor projected in a direction. */ + + su2double + **tau, /*!< \brief Viscous stress tensor. */ + **delta, /*!< \brief Identity matrix. */ + **delta3; /*!< \brief 3 row Identity matrix. */ + su2double + *Diffusion_Coeff_i, /*!< \brief Species diffusion coefficients at point i. */ + *Diffusion_Coeff_j; /*!< \brief Species diffusion coefficients at point j. */ + su2double + Laminar_Viscosity_i, /*!< \brief Laminar viscosity at point i. */ + Laminar_Viscosity_j, /*!< \brief Laminar viscosity at point j. */ + Laminar_Viscosity_id, /*!< \brief Variation of laminar viscosity at point i. */ + Laminar_Viscosity_jd; /*!< \brief Variation of laminar viscosity at point j. */ + su2double + Thermal_Conductivity_i, /*!< \brief Thermal conductivity at point i. */ + Thermal_Conductivity_j, /*!< \brief Thermal conductivity at point j. */ + Thermal_Conductivity_ve_i, /*!< \brief Thermal conductivity at point i. */ + Thermal_Conductivity_ve_j, /*!< \brief Thermal conductivity at point j. */ + Thermal_Diffusivity_i, /*!< \brief Thermal diffusivity at point i. */ + Thermal_Diffusivity_j; /*!< \brief Thermal diffusivity at point j. */ + su2double + Cp_i, /*!< \brief Cp at point i. */ + Cp_j; /*!< \brief Cp at point j. */ + su2double *Theta_v; /*!< \brief Characteristic vibrational temperature */ + su2double + Eddy_Viscosity_i, /*!< \brief Eddy viscosity at point i. */ + Eddy_Viscosity_j; /*!< \brief Eddy viscosity at point j. */ + su2double + turb_ke_i, /*!< \brief Turbulent kinetic energy at point i. */ + turb_ke_j; /*!< \brief Turbulent kinetic energy at point j. */ + su2double + Pressure_i, /*!< \brief Pressure at point i. */ + Pressure_j; /*!< \brief Pressure at point j. */ + su2double + GravityForce_i, /*!< \brief Gravity force at point i. */ + GravityForce_j; /*!< \brief Gravity force at point j. */ + su2double + Density_i, /*!< \brief Density at point i. */ + Density_j; /*!< \brief Density at point j. */ + su2double + DensityInc_i, /*!< \brief Incompressible density at point i. */ + DensityInc_j; /*!< \brief Incompressible density at point j. */ + su2double + BetaInc2_i, /*!< \brief Beta incompressible at point i. */ + BetaInc2_j; /*!< \brief Beta incompressible at point j. */ + su2double + Lambda_i, /*!< \brief Spectral radius at point i. */ + Lambda_j; /*!< \brief Spectral radius at point j. */ + su2double + LambdaComb_i, /*!< \brief Spectral radius at point i. */ + LambdaComb_j; /*!< \brief Spectral radius at point j. */ + su2double + SoundSpeed_i, /*!< \brief Sound speed at point i. */ + SoundSpeed_j; /*!< \brief Sound speed at point j. */ + su2double + Enthalpy_i, /*!< \brief Enthalpy at point i. */ + Enthalpy_j; /*!< \brief Enthalpy at point j. */ + su2double + dist_i, /*!< \brief Distance of point i to the nearest wall. */ + dist_j; /*!< \brief Distance of point j to the nearest wall. */ + su2double + Temp_i, /*!< \brief Temperature at point i. */ + Temp_j; /*!< \brief Temperature at point j. */ + su2double + *Temp_tr_i, /*!< \brief Temperature transl-rot at point i. */ + *Temp_tr_j; /*!< \brief Temperature transl-rot at point j. */ + su2double + *Temp_vib_i, /*!< \brief Temperature vibrational at point i. */ + *Temp_vib_j; /*!< \brief Temperature vibrational at point j. */ + su2double + *Und_Lapl_i, /*!< \brief Undivided laplacians at point i. */ + *Und_Lapl_j; /*!< \brief Undivided laplacians at point j. */ + su2double + Sensor_i, /*!< \brief Pressure sensor at point i. */ + Sensor_j; /*!< \brief Pressure sensor at point j. */ + su2double + *GridVel_i, /*!< \brief Grid velocity at point i. */ + *GridVel_j; /*!< \brief Grid velocity at point j. */ + su2double + *U_i, /*!< \brief Vector of conservative variables at point i. */ + *U_id, /*!< \brief Vector of derivative of conservative variables at point i. */ + *UZeroOrder_i, /*!< \brief Vector of conservative variables at point i without reconstruction. */ + *U_j, /*!< \brief Vector of conservative variables at point j. */ + *UZeroOrder_j, /*!< \brief Vector of conservative variables at point j without reconstruction. */ + *U_jd, /*!< \brief Vector of derivative of conservative variables at point j. */ + *U_0, /*!< \brief Vector of conservative variables at node 0. */ + *U_1, /*!< \brief Vector of conservative variables at node 1. */ + *U_2, /*!< \brief Vector of conservative variables at node 2. */ + *U_3; /*!< \brief Vector of conservative variables at node 3. */ + su2double + *V_i, /*!< \brief Vector of primitive variables at point i. */ + *V_j; /*!< \brief Vector of primitive variables at point j. */ + su2double + *S_i, /*!< \brief Vector of secondary variables at point i. */ + *S_j; /*!< \brief Vector of secondary variables at point j. */ + su2double + *Psi_i, /*!< \brief Vector of adjoint variables at point i. */ + *Psi_j; /*!< \brief Vector of adjoint variables at point j. */ + su2double + *DeltaU_i, /*!< \brief Vector of linearized variables at point i. */ + *DeltaU_j; /*!< \brief Vector of linearized variables at point j. */ + su2double + *TurbVar_i, /*!< \brief Vector of turbulent variables at point i. */ + *TurbVar_id, /*!< \brief Vector of derivative of turbulent variables at point i. */ + *TurbVar_j, /*!< \brief Vector of turbulent variables at point j. */ + *TurbVar_jd; /*!< \brief Vector of derivative of turbulent variables at point j. */ + su2double + *TransVar_i, /*!< \brief Vector of turbulent variables at point i. */ + *TransVar_j; /*!< \brief Vector of turbulent variables at point j. */ + su2double + *TurbPsi_i, /*!< \brief Vector of adjoint turbulent variables at point i. */ + *TurbPsi_j; /*!< \brief Vector of adjoint turbulent variables at point j. */ + su2double + **ConsVar_Grad_i, /*!< \brief Gradient of conservative variables at point i. */ + **ConsVar_Grad_j, /*!< \brief Gradient of conservative variables at point j. */ + **ConsVar_Grad_0, /*!< \brief Gradient of conservative variables at point 0. */ + **ConsVar_Grad_1, /*!< \brief Gradient of conservative variables at point 1. */ + **ConsVar_Grad_2, /*!< \brief Gradient of conservative variables at point 2. */ + **ConsVar_Grad_3, /*!< \brief Gradient of conservative variables at point 3. */ + **ConsVar_Grad; /*!< \brief Gradient of conservative variables which is a scalar. */ + su2double + **PrimVar_Grad_i, /*!< \brief Gradient of primitive variables at point i. */ + **PrimVar_Grad_j; /*!< \brief Gradient of primitive variables at point j. */ + su2double + **PsiVar_Grad_i, /*!< \brief Gradient of adjoint variables at point i. */ + **PsiVar_Grad_j; /*!< \brief Gradient of adjoint variables at point j. */ + su2double + **TurbVar_Grad_i, /*!< \brief Gradient of turbulent variables at point i. */ + **TurbVar_Grad_j; /*!< \brief Gradient of turbulent variables at point j. */ + su2double + **TransVar_Grad_i, /*!< \brief Gradient of turbulent variables at point i. */ + **TransVar_Grad_j; /*!< \brief Gradient of turbulent variables at point j. */ + su2double + **TurbPsi_Grad_i, /*!< \brief Gradient of adjoint turbulent variables at point i. */ + **TurbPsi_Grad_j; /*!< \brief Gradient of adjoint turbulent variables at point j. */ + su2double + *AuxVar_Grad_i, /*!< \brief Gradient of an auxiliary variable at point i. */ + *AuxVar_Grad_j; /*!< \brief Gradient of an auxiliary variable at point i. */ + su2double + *Coord_i, /*!< \brief Cartesians coordinates of point i. */ + *Coord_j, /*!< \brief Cartesians coordinates of point j. */ + *Coord_0, /*!< \brief Cartesians coordinates of point 0 (Galerkin method, triangle). */ + *Coord_1, /*!< \brief Cartesians coordinates of point 1 (Galerkin method, tetrahedra). */ + *Coord_2, /*!< \brief Cartesians coordinates of point 2 (Galerkin method, triangle). */ + *Coord_3; /*!< \brief Cartesians coordinates of point 3 (Galerkin method, tetrahedra). */ + unsigned short + Neighbor_i, /*!< \brief Number of neighbors of the point i. */ + Neighbor_j; /*!< \brief Number of neighbors of the point j. */ + su2double + *Normal, /*!< \brief Normal vector, it norm is the area of the face. */ + *UnitNormal, /*!< \brief Unitary normal vector. */ + *UnitNormald; /*!< \brief derivatve of unitary normal vector. */ + su2double + TimeStep, /*!< \brief Time step useful in dual time method. */ + Area, /*!< \brief Area of the face i-j. */ + Volume; /*!< \brief Volume of the control volume around point i. */ + su2double + Volume_n, /*!< \brief Volume of the control volume at time n. */ + Volume_nM1, /*!< \brief Volume of the control volume at time n-1. */ + Volume_nP1; /*!< \brief Volume of the control volume at time n+1. */ + su2double + *U_n, /*!< \brief Vector of conservative variables at time n. */ + *U_nM1, /*!< \brief Vector of conservative variables at time n-1. */ + *U_nP1; /*!< \brief Vector of conservative variables at time n+1. */ + su2double vel2_inf; /*!< \brief value of the square of freestream speed. */ + su2double + *WindGust_i, /*!< \brief Wind gust at point i. */ + *WindGust_j; /*!< \brief Wind gust at point j. */ + su2double + *WindGustDer_i, /*!< \brief Wind gust derivatives at point i. */ + *WindGustDer_j; /*!< \brief Wind gust derivatives at point j. */ + su2double *Vorticity_i, *Vorticity_j; /*!< \brief Vorticity. */ + su2double StrainMag_i, StrainMag_j; /*!< \brief Strain rate magnitude. */ + su2double Dissipation_i, Dissipation_j; /*!< \brief Dissipation. */ + su2double Dissipation_ij; + + su2double *l, *m; + + su2double **MeanReynoldsStress; /*!< \brief Mean Reynolds stress tensor */ + su2double **MeanPerturbedRSM; /*!< \brief Perturbed Reynolds stress tensor */ + bool using_uq; /*!< \brief Flag for UQ methodology */ + su2double PerturbedStrainMag; /*!< \brief Strain magnitude calculated using perturbed stress tensor */ + unsigned short Eig_Val_Comp; /*!< \brief Component towards which perturbation is perfromed */ + su2double uq_delta_b; /*!< \brief Magnitude of perturbation */ + su2double uq_urlx; /*!< \brief Under-relaxation factor for numerical stability */ + bool uq_permute; /*!< \brief Flag for eigenvector permutation */ + + /* Supporting data structures for the eigenspace perturbation for UQ methodology */ + su2double **A_ij, **newA_ij, **Eig_Vec, **New_Eig_Vec, **Corners; + su2double *Eig_Val, *Barycentric_Coord, *New_Coord; + + /*! + * \brief Constructor of the class. + */ + CNumerics(void); + + /*! + * \overload + * \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. + */ + CNumerics(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + virtual ~CNumerics(void); + + /*! + * \brief Compute the determinant of a 3 by 3 matrix. + * \param[in] val_matrix 3 by 3 matrix. + * \result Determinant of the matrix + */ + inline static su2double Determinant_3x3(su2double A00, su2double A01, su2double A02, + su2double A10, su2double A11, su2double A12, + su2double A20, su2double A21, su2double A22) { + return A00*(A11*A22-A12*A21) - A01*(A10*A22-A12*A20) + A02*(A10*A21-A11*A20); + } + + /*! + * \brief Set the solution at different times. + * \param[in] val_u_nM1 Conservative solution at time n-1. + * \param[in] val_u_n Conservative solution at time n. + * \param[in] val_u_nP1 Conservative solution at time n+1. + */ + void SetPastSol(su2double *val_u_nM1, su2double *val_u_n, su2double *val_u_nP1); + + /*! + * \brief Set the control volume at different times. + * \param[in] val_volume_nM1 - Control volume at time n-1. + * \param[in] val_volume_n - Control volume at time n. + * \param[in] val_volume_nP1 - Control volume at time n+1. + */ + void SetPastVolume(su2double val_volume_nM1, su2double val_volume_n, su2double val_volume_nP1); + + /*! + * \brief Set the time step. + * \param[in] val_timestep - Value of the time step. + */ + inline void SetTimeStep(su2double val_timestep) { TimeStep = val_timestep;} + + /*! + * \brief Set the freestream velocity square. + * \param[in] SetVelocity2_Inf - Value of the square of the freestream velocity. + */ + inline void SetVelocity2_Inf(su2double val_velocity2) { vel2_inf = val_velocity2; } + + /*! + * \brief Set the value of the vorticity + * \param[in] val_vorticity - Value of the vorticity. + */ + void SetVorticity(su2double *val_vorticity_i, su2double *val_vorticity_j) { + Vorticity_i = val_vorticity_i; + Vorticity_j = val_vorticity_j; + } + + /*! + * \brief Set the value of the rate of strain magnitude. + * \param[in] val_StrainMag_i - Value of the magnitude of rate of strain at point i. + * \param[in] val_StrainMag_j - Value of the magnitude of rate of strain at point j. + */ + void SetStrainMag(su2double val_strainmag_i, su2double val_strainmag_j) { + StrainMag_i = val_strainmag_i; + StrainMag_j = val_strainmag_j; + } + + /*! + * \brief Set the value of the conservative variables. + * \param[in] val_u_i - Value of the conservative variable at point i. + * \param[in] val_u_j - Value of the conservative variable at point j. + */ + inline void SetConservative(su2double *val_u_i, su2double *val_u_j) { + U_i = val_u_i; + U_j = val_u_j; + } + + /*! + * \brief Set the value of the conservative variables withour reconstruction. + * \param[in] val_u_i - Value of the conservative variable at point i. + * \param[in] val_u_j - Value of the conservative variable at point j. + */ + inline void SetConservative_ZeroOrder(su2double *val_u_i, su2double *val_u_j) { + UZeroOrder_i = val_u_i; + UZeroOrder_j = val_u_j; + } + + /*! + * \brief Set the value of the primitive variables. + * \param[in] val_v_i - Value of the primitive variable at point i. + * \param[in] val_v_j - Value of the primitive variable at point j. + */ + inline void SetPrimitive(su2double *val_v_i, su2double *val_v_j) { + V_i = val_v_i; + V_j = val_v_j; + } + + /*! + * \brief Set the value of the primitive variables. + * \param[in] val_v_i - Value of the primitive variable at point i. + * \param[in] val_v_j - Value of the primitive variable at point j. + */ + inline void SetSecondary(su2double *val_s_i, su2double *val_s_j) { + S_i = val_s_i; + S_j = val_s_j; + } + + /*! + * \brief Set the value of the conservative variables. + * \param[in] val_u_0 - Value of the conservative variable at point 0. + * \param[in] val_u_1 - Value of the conservative variable at point 1. + * \param[in] val_u_2 - Value of the conservative variable at point 2. + */ + inline void SetConservative(su2double *val_u_0, su2double *val_u_1, su2double *val_u_2) { + U_0 = val_u_0; + U_1 = val_u_1; + U_2 = val_u_2; + } + + /*! + * \brief Set the value of the conservative variables. + * \param[in] val_u_0 - Value of the conservative variable at point 0. + * \param[in] val_u_1 - Value of the conservative variable at point 1. + * \param[in] val_u_2 - Value of the conservative variable at point 2. + * \param[in] val_u_3 - Value of the conservative variable at point 3. + */ + inline void SetConservative(su2double *val_u_0, su2double *val_u_1, su2double *val_u_2, su2double *val_u_3) { + U_0 = val_u_0; + U_1 = val_u_1; + U_2 = val_u_2; + U_3 = val_u_3; + } + + /*! + * \brief Set the gradient of the conservative variables. + * \param[in] val_consvar_grad_i - Gradient of the conservative variable at point i. + * \param[in] val_consvar_grad_j - Gradient of the conservative variable at point j. + */ + inline void SetConsVarGradient(su2double **val_consvar_grad_i, + su2double **val_consvar_grad_j) { + ConsVar_Grad_i = val_consvar_grad_i; + ConsVar_Grad_j = val_consvar_grad_j; + } + + /*! + * \brief Set the gradient of the conservative variables. + * \param[in] val_consvar_grad_0 - Gradient of the conservative variable at point 0. + * \param[in] val_consvar_grad_1 - Gradient of the conservative variable at point 1. + * \param[in] val_consvar_grad_2 - Gradient of the conservative variable at point 2. + */ + inline void SetConsVarGradient(su2double **val_consvar_grad_0, + su2double **val_consvar_grad_1, + su2double **val_consvar_grad_2) { + ConsVar_Grad_0 = val_consvar_grad_0; + ConsVar_Grad_1 = val_consvar_grad_1; + ConsVar_Grad_2 = val_consvar_grad_2; + } + + /*! + * \brief Set the gradient of the conservative variables. + * \param[in] val_consvar_grad_0 - Gradient of the conservative variable at point 0. + * \param[in] val_consvar_grad_1 - Gradient of the conservative variable at point 1. + * \param[in] val_consvar_grad_2 - Gradient of the conservative variable at point 2. + * \param[in] val_consvar_grad_3 - Gradient of the conservative variable at point 3. + */ + inline void SetConsVarGradient(su2double **val_consvar_grad_0, + su2double **val_consvar_grad_1, + su2double **val_consvar_grad_2, + su2double **val_consvar_grad_3) { + ConsVar_Grad_0 = val_consvar_grad_0; + ConsVar_Grad_1 = val_consvar_grad_1; + ConsVar_Grad_2 = val_consvar_grad_2; + ConsVar_Grad_3 = val_consvar_grad_3; + } + + /*! + * \brief Set the gradient of the conservative variables. + * \param[in] val_consvar_grad - Gradient of the conservative variable which is a scalar. + */ + inline void SetConsVarGradient(su2double **val_consvar_grad) { ConsVar_Grad = val_consvar_grad; } + + /*! + * \brief Set the gradient of the primitive variables. + * \param[in] val_primvar_grad_i - Gradient of the primitive variable at point i. + * \param[in] val_primvar_grad_j - Gradient of the primitive variable at point j. + */ + void SetPrimVarGradient(su2double **val_primvar_grad_i, + su2double **val_primvar_grad_j) { + PrimVar_Grad_i = val_primvar_grad_i; + PrimVar_Grad_j = val_primvar_grad_j; + } + + /*! + * \brief Set the value of the adjoint variable. + * \param[in] val_psi_i - Value of the adjoint variable at point i. + * \param[in] val_psi_j - Value of the adjoint variable at point j. + */ + inline void SetAdjointVar(su2double *val_psi_i, su2double *val_psi_j) { + Psi_i = val_psi_i; + Psi_j = val_psi_j; + } + + /*! + * \brief Set the gradient of the adjoint variables. + * \param[in] val_psivar_grad_i - Gradient of the adjoint variable at point i. + * \param[in] val_psivar_grad_j - Gradient of the adjoint variable at point j. + */ + inline void SetAdjointVarGradient(su2double **val_psivar_grad_i, + su2double **val_psivar_grad_j) { + PsiVar_Grad_i = val_psivar_grad_i; + PsiVar_Grad_j = val_psivar_grad_j; + } + + /*! + * \brief Set the value of the turbulent variable. + * \param[in] val_turbvar_i - Value of the turbulent variable at point i. + * \param[in] val_turbvar_j - Value of the turbulent variable at point j. + */ + inline void SetTurbVar(su2double *val_turbvar_i, su2double *val_turbvar_j) { + TurbVar_i = val_turbvar_i; + TurbVar_j = val_turbvar_j; + } + + /*! + * \brief Set the value of the turbulent variable. + * \param[in] val_transvar_i - Value of the turbulent variable at point i. + * \param[in] val_transvar_j - Value of the turbulent variable at point j. + */ + inline void SetTransVar(su2double *val_transvar_i, su2double *val_transvar_j) { + TransVar_i = val_transvar_i; + TransVar_j = val_transvar_j; + } + + /*! + * \brief Set the gradient of the turbulent variables. + * \param[in] val_turbvar_grad_i - Gradient of the turbulent variable at point i. + * \param[in] val_turbvar_grad_j - Gradient of the turbulent variable at point j. + */ + inline void SetTurbVarGradient(su2double **val_turbvar_grad_i, + su2double **val_turbvar_grad_j) { + TurbVar_Grad_i = val_turbvar_grad_i; + TurbVar_Grad_j = val_turbvar_grad_j; + } + + /*! + * \brief Set the gradient of the turbulent variables. + * \param[in] val_turbvar_grad_i - Gradient of the turbulent variable at point i. + * \param[in] val_turbvar_grad_j - Gradient of the turbulent variable at point j. + */ + inline void SetTransVarGradient(su2double **val_transvar_grad_i, + su2double **val_transvar_grad_j) { + TransVar_Grad_i = val_transvar_grad_i; + TransVar_Grad_j = val_transvar_grad_j; + } + + /*! + * \brief Set the value of the adjoint turbulent variable. + * \param[in] val_turbpsivar_i - Value of the adjoint turbulent variable at point i. + * \param[in] val_turbpsivar_j - Value of the adjoint turbulent variable at point j. + */ + inline void SetTurbAdjointVar(su2double *val_turbpsivar_i, su2double *val_turbpsivar_j) { + TurbPsi_i = val_turbpsivar_i; + TurbPsi_j = val_turbpsivar_j; + } + + /*! + * \brief Set the gradient of the adjoint turbulent variables. + * \param[in] val_turbpsivar_grad_i - Gradient of the adjoint turbulent variable at point i. + * \param[in] val_turbpsivar_grad_j - Gradient of the adjoint turbulent variable at point j. + */ + inline void SetTurbAdjointGradient(su2double **val_turbpsivar_grad_i, + su2double **val_turbpsivar_grad_j) { + TurbPsi_Grad_i = val_turbpsivar_grad_i; + TurbPsi_Grad_j = val_turbpsivar_grad_j; + } + + /*! + * \brief Set the value of the first blending function. + * \param[in] val_F1_i - Value of the first Menter blending function at point i. + * \param[in] val_F1_j - Value of the first Menter blending function at point j. + */ + virtual void SetF1blending(su2double val_F1_i, su2double val_F1_j) {/* empty */}; + + /*! + * \brief Set the value of the second blending function. + * \param[in] val_F1_i - Value of the second Menter blending function at point i. + * \param[in] val_F1_j - Value of the second Menter blending function at point j. + */ + virtual void SetF2blending(su2double val_F1_i, su2double val_F1_j) {/* empty */}; + + /*! + * \brief Set the value of the cross diffusion for the SST model. + * \param[in] val_CDkw_i - Value of the cross diffusion at point i. + * \param[in] val_CDkw_j - Value of the cross diffusion at point j. + */ + virtual void SetCrossDiff(su2double val_CDkw_i, su2double val_CDkw_j) {/* empty */}; + + /*! + * \brief Set the gradient of the auxiliary variables. + * \param[in] val_auxvargrad_i - Gradient of the auxiliary variable at point i. + * \param[in] val_auxvargrad_j - Gradient of the auxiliary variable at point j. + */ + inline void SetAuxVarGrad(su2double *val_auxvargrad_i, su2double *val_auxvargrad_j) { + AuxVar_Grad_i = val_auxvargrad_i; + AuxVar_Grad_j = val_auxvargrad_j; + } + + /*! + * \brief Set the diffusion coefficient + * \param[in] val_diffusioncoeff_i - Value of the diffusion coefficients at i. + * \param[in] val_diffusioncoeff_j - Value of the diffusion coefficients at j + */ + inline void SetDiffusionCoeff(su2double* val_diffusioncoeff_i, + su2double* val_diffusioncoeff_j) { + Diffusion_Coeff_i = val_diffusioncoeff_i; + Diffusion_Coeff_j = val_diffusioncoeff_j; + } + + /*! + * \brief Set the laminar viscosity. + * \param[in] val_laminar_viscosity_i - Value of the laminar viscosity at point i. + * \param[in] val_laminar_viscosity_j - Value of the laminar viscosity at point j. + */ + inline void SetLaminarViscosity(su2double val_laminar_viscosity_i, + su2double val_laminar_viscosity_j) { + Laminar_Viscosity_i = val_laminar_viscosity_i; + Laminar_Viscosity_j = val_laminar_viscosity_j; + } + + /*! + * \brief Set the thermal conductivity (translational/rotational) + * \param[in] val_thermal_conductivity_i - Value of the thermal conductivity at point i. + * \param[in] val_thermal_conductivity_j - Value of the thermal conductivity at point j. + * \param[in] iSpecies - Value of the species. + */ + inline void SetThermalConductivity(su2double val_thermal_conductivity_i, + su2double val_thermal_conductivity_j) { + Thermal_Conductivity_i = val_thermal_conductivity_i; + Thermal_Conductivity_j = val_thermal_conductivity_j; + } + + /*! + * \brief Set the thermal conductivity (translational/rotational) + * \param[in] val_thermal_conductivity_i - Value of the thermal conductivity at point i. + * \param[in] val_thermal_conductivity_j - Value of the thermal conductivity at point j. + * \param[in] iSpecies - Value of the species. + */ + inline void SetThermalConductivity_ve(su2double val_thermal_conductivity_ve_i, + su2double val_thermal_conductivity_ve_j) { + Thermal_Conductivity_ve_i = val_thermal_conductivity_ve_i; + Thermal_Conductivity_ve_j = val_thermal_conductivity_ve_j; + } + + /*! + * \brief Set the thermal diffusivity (translational/rotational) + * \param[in] val_thermal_diffusivity_i - Value of the thermal diffusivity at point i. + * \param[in] val_thermal_diffusivity_j - Value of the thermal diffusivity at point j. + * \param[in] iSpecies - Value of the species. + */ + inline void SetThermalDiffusivity(su2double val_thermal_diffusivity_i, + su2double val_thermal_diffusivity_j) { + Thermal_Diffusivity_i = val_thermal_diffusivity_i; + Thermal_Diffusivity_j = val_thermal_diffusivity_j; + } + + /*! + * \brief Set the eddy viscosity. + * \param[in] val_eddy_viscosity_i - Value of the eddy viscosity at point i. + * \param[in] val_eddy_viscosity_j - Value of the eddy viscosity at point j. + */ + inline void SetEddyViscosity(su2double val_eddy_viscosity_i, + su2double val_eddy_viscosity_j) { + Eddy_Viscosity_i = val_eddy_viscosity_i; + Eddy_Viscosity_j = val_eddy_viscosity_j; + } + + /*! + * \brief Set the turbulent kinetic energy. + * \param[in] val_turb_ke_i - Value of the turbulent kinetic energy at point i. + * \param[in] val_turb_ke_j - Value of the turbulent kinetic energy at point j. + */ + inline void SetTurbKineticEnergy(su2double val_turb_ke_i, su2double val_turb_ke_j) { + turb_ke_i = val_turb_ke_i; + turb_ke_j = val_turb_ke_j; + } + + /*! + * \brief Set the value of the distance from the nearest wall. + * \param[in] val_dist_i - Value of of the distance from point i to the nearest wall. + * \param[in] val_dist_j - Value of of the distance from point j to the nearest wall. + */ + void SetDistance(su2double val_dist_i, su2double val_dist_j) { + dist_i = val_dist_i; + dist_j = val_dist_j; + } + + /*! + * \brief Set coordinates of the points. + * \param[in] val_coord_i - Coordinates of the point i. + * \param[in] val_coord_j - Coordinates of the point j. + */ + inline void SetCoord(su2double *val_coord_i, su2double *val_coord_j) { + Coord_i = val_coord_i; + Coord_j = val_coord_j; + } + + /*! + * \overload + * \param[in] val_coord_0 - Coordinates of the point 0. + * \param[in] val_coord_1 - Coordinates of the point 1. + * \param[in] val_coord_2 - Coordinates of the point 2. + */ + inline void SetCoord(su2double *val_coord_0, su2double *val_coord_1, + su2double *val_coord_2) { + Coord_0 = val_coord_0; + Coord_1 = val_coord_1; + Coord_2 = val_coord_2; + } + + /*! + * \overload + * \param[in] val_coord_0 - Coordinates of the point 0. + * \param[in] val_coord_1 - Coordinates of the point 1. + * \param[in] val_coord_2 - Coordinates of the point 2. + * \param[in] val_coord_3 - Coordinates of the point 3. + */ + inline void SetCoord(su2double *val_coord_0, su2double *val_coord_1, + su2double *val_coord_2, su2double *val_coord_3) { + Coord_0 = val_coord_0; + Coord_1 = val_coord_1; + Coord_2 = val_coord_2; + Coord_3 = val_coord_3; + } + + /*! + * \brief Set the velocity of the computational grid. + * \param[in] val_gridvel_i - Grid velocity of the point i. + * \param[in] val_gridvel_j - Grid velocity of the point j. + */ + inline void SetGridVel(su2double *val_gridvel_i, su2double *val_gridvel_j) { + GridVel_i = val_gridvel_i; + GridVel_j = val_gridvel_j; + } + + /*! + * \brief Set the wind gust value. + * \param[in] val_windgust_i - Wind gust of the point i. + * \param[in] val_windgust_j - Wind gust of the point j. + */ + inline void SetWindGust(su2double *val_windgust_i, su2double *val_windgust_j) { + WindGust_i = val_windgust_i; + WindGust_j = val_windgust_j; + } + + /*! + * \brief Set the wind gust derivatives values. + * \param[in] val_windgust_i - Wind gust derivatives of the point i. + * \param[in] val_windgust_j - Wind gust derivatives of the point j. + */ + inline void SetWindGustDer(su2double *val_windgustder_i, su2double *val_windgustder_j) { + WindGustDer_i = val_windgustder_i; + WindGustDer_j = val_windgustder_j; + } + + /*! + * \brief Set the value of the pressure. + * \param[in] val_pressure_i - Value of the pressure at point i. + * \param[in] val_pressure_j - Value of the pressure at point j. + */ + void SetPressure(su2double val_pressure_i, su2double val_pressure_j) { + Pressure_i = val_pressure_i; + Pressure_j = val_pressure_j; +} + + /*! + * \brief Set the value of the density for the incompressible solver. + * \param[in] val_densityinc_i - Value of the pressure at point i. + * \param[in] val_densityinc_j - Value of the pressure at point j. + */ + void SetDensity(su2double val_densityinc_i, su2double val_densityinc_j) { + DensityInc_i = val_densityinc_i; + DensityInc_j = val_densityinc_j; + } + + /*! + * \brief Set the value of the beta for incompressible flows. + * \param[in] val_betainc2_i - Value of beta for incompressible flows at point i. + * \param[in] val_betainc2_j - Value of beta for incompressible flows at point j. + */ + inline void SetBetaInc2(su2double val_betainc2_i, su2double val_betainc2_j) { + BetaInc2_i = val_betainc2_i; + BetaInc2_j = val_betainc2_j; + } + + /*! + * \brief Set the value of the sound speed. + * \param[in] val_soundspeed_i - Value of the sound speed at point i. + * \param[in] val_soundspeed_j - Value of the sound speed at point j. + */ + inline void SetSoundSpeed(su2double val_soundspeed_i, su2double val_soundspeed_j) { + SoundSpeed_i = val_soundspeed_i; + SoundSpeed_j = val_soundspeed_j; + } + + /*! + * \brief Set the value of the temperature. + * \param[in] val_temp_i - Value of the temperature at point i. + * \param[in] val_temp_j - Value of the temperature at point j. + */ + inline void SetTemperature(su2double val_temp_i, su2double val_temp_j) { + Temp_i = val_temp_i; + Temp_j = val_temp_j; + } + + /*! + * \brief Set the value of the enthalpy. + * \param[in] val_enthalpy_i - Value of the enthalpy at point i. + * \param[in] val_enthalpy_j - Value of the enthalpy at point j. + */ + inline void SetEnthalpy(su2double val_enthalpy_i, su2double val_enthalpy_j) { + Enthalpy_i = val_enthalpy_i; + Enthalpy_j = val_enthalpy_j; + } + + /*! + * \brief Set the value of the spectral radius. + * \param[in] val_lambda_i - Value of the spectral radius at point i. + * \param[in] val_lambda_j - Value of the spectral radius at point j. + */ + inline void SetLambda(su2double val_lambda_i, su2double val_lambda_j) { + Lambda_i = val_lambda_i; + Lambda_j = val_lambda_j; + } + + /*! + * \brief Set the value of undivided laplacian. + * \param[in] val_und_lapl_i Undivided laplacian at point i. + * \param[in] val_und_lapl_j Undivided laplacian at point j. + */ + inline void 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; + } + + /*! + * \brief Set the value of the pressure sensor. + * \param[in] val_sensor_i Pressure sensor at point i. + * \param[in] val_sensor_j Pressure sensor at point j. + */ + inline void SetSensor(su2double val_sensor_i, su2double val_sensor_j) { + Sensor_i = val_sensor_i; + Sensor_j = val_sensor_j; + } + + /*! + * \brief Set the number of neighbor to a point. + * \param[in] val_neighbor_i - Number of neighbor to point i. + * \param[in] val_neighbor_j - Number of neighbor to point j. + */ + inline void SetNeighbor(unsigned short val_neighbor_i, unsigned short val_neighbor_j) { + Neighbor_i = val_neighbor_i; + Neighbor_j = val_neighbor_j; + } + + /*! + * \brief Set the value of the normal vector to the face between two points. + * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. + */ + inline void SetNormal(su2double *val_normal) { Normal = val_normal; } + + /*! + * \brief Set the value of the volume of the control volume. + * \param[in] val_volume Volume of the control volume. + */ + inline void SetVolume(su2double val_volume) { Volume = val_volume; } + + /*! + * \brief Retrieves the value of the species density in the primitive variable vector. + * \param[in] iRho_s + */ + void SetRhosIndex(unsigned short val_Index); + + /*! + * \brief Retrieves the value of the species density in the primitive variable vector. + * \param[in] iRho_s + */ + void SetRhoIndex(unsigned short val_Index); + + /*! + * \brief Retrieves the value of the species density in the primitive variable vector. + * \param[in] iRho_s + */ + void SetPIndex(unsigned short val_Index); + + /*! + * \brief Retrieves the value of the species density in the primitive variable vector. + * \param[in] iRho_s + */ + void SetTIndex(unsigned short val_Index); + + /*! + * \brief Retrieves the value of the species density in the primitive variable vector. + * \param[in] iRho_s + */ + void SetTveIndex(unsigned short val_Index); + + /*! + * \brief Retrieves the value of the velocity index in the primitive variable vector. + * \param[in] i(rho*u) + */ + void SetVelIndex(unsigned short val_Index); + + /*! + * \brief Retrieves the value of the species density in the primitive variable vector. + * \param[in] iRho_s + */ + void SetHIndex(unsigned short val_Index); + + /*! + * \brief Retrieves the value of the species density in the primitive variable vector. + * \param[in] iRho_s + */ + void SetAIndex(unsigned short val_Index); + + /*! + * \brief Retrieves the value of the species density in the primitive variable vector. + * \param[in] iRho_s + */ + void SetRhoCvtrIndex(unsigned short val_Index); + + /*! + * \brief Retrieves the value of the species density in the primitive variable vector. + * \param[in] iRho_s + */ + void SetRhoCvveIndex(unsigned short val_Index); + + /*! + * \brief Sets the value of the derivative of pressure w.r.t. species density. + * \param[in] iRho_s + */ + void SetdPdU(su2double *val_dPdU_i, su2double *val_dPdU_j); + + /*! + * \brief Sets the value of the derivative of temperature w.r.t. species density. + * \param[in] iRho_s + */ + void SetdTdU(su2double *val_dTdU_i, su2double *val_dTdU_j); + + /*! + * \brief Sets the value of the derivative of vib-el. temperature w.r.t. species density. + * \param[in] iRho_s + */ + void SetdTvedU(su2double *val_dTvedU_i, su2double *val_dTvedU_j); + + /*! + * \brief Sets the values of the roe dissipation. + * \param[in] diss_i - Dissipation value at node i + * \param[in] diss_j - Dissipation value at node j + */ + inline void SetDissipation(su2double diss_i, su2double diss_j) { + Dissipation_i = diss_i; + Dissipation_j = diss_j; + } + + /*! + * \brief Get the final Roe dissipation factor. + */ + inline su2double GetDissipation() const { return Dissipation_ij; } + + /*! + * \brief Get the inviscid fluxes. + * \param[in] val_density - Value of the density. + * \param[in] val_velocity - Value of the velocity. + * \param[in] val_pressure - Value of the pressure. + * \param[in] val_enthalpy - Value of the enthalpy. + */ + void GetInviscidFlux(su2double val_density, su2double *val_velocity, su2double val_pressure, su2double val_enthalpy); + + /*! + * \brief Compute the projected inviscid flux vector. + * \param[in] val_density - Pointer to the density. + * \param[in] val_velocity - Pointer to the velocity. + * \param[in] val_pressure - Pointer to the pressure. + * \param[in] val_enthalpy - Pointer to the enthalpy. + * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. + * \param[out] val_Proj_Flux - Pointer to the projected flux. + */ + void GetInviscidProjFlux(su2double *val_density, su2double *val_velocity, + su2double *val_pressure, su2double *val_enthalpy, + su2double *val_normal, su2double *val_Proj_Flux); + + /*! + * \brief Compute the projected inviscid flux vector for incompresible simulations + * \param[in] val_density - Pointer to the density. + * \param[in] val_velocity - Pointer to the velocity. + * \param[in] val_pressure - Pointer to the pressure. + * \param[in] val_betainc2 - Value of the artificial compresibility factor. + * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. + * \param[out] val_Proj_Flux - Pointer to the projected flux. + */ + void GetInviscidIncProjFlux(su2double *val_density, su2double *val_velocity, + su2double *val_pressure, su2double *val_betainc2, + su2double *val_enthalpy, + su2double *val_normal, su2double *val_Proj_Flux); + + /*! + * \brief Compute the projection of the inviscid Jacobian matrices. + * \param[in] val_velocity Pointer to the velocity. + * \param[in] val_energy Value of the energy. + * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. + * \param[in] val_scale - Scale of the projection. + * \param[out] val_Proj_Jac_tensor - Pointer to the projected inviscid Jacobian. + */ + void GetInviscidProjJac(su2double *val_velocity, su2double *val_energy, + su2double *val_normal, su2double val_scale, + su2double **val_Proj_Jac_tensor); + + /*! + * \brief Compute the projection of the inviscid Jacobian matrices (incompressible). + * \param[in] val_density - Value of the density. + * \param[in] val_velocity - Pointer to the velocity. + * \param[in] val_betainc2 - Value of the artificial compresibility factor. + * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. + * \param[in] val_scale - Scale of the projection. + * \param[out] val_Proj_Jac_tensor - Pointer to the projected inviscid Jacobian. + */ + void GetInviscidIncProjJac(su2double *val_density, su2double *val_velocity, + su2double *val_betainc2, su2double *val_normal, + su2double val_scale, + su2double **val_Proj_Jac_tensor); + + /*! + * \brief Compute the projection of the inviscid Jacobian matrices (overload for low speed preconditioner version). + * \param[in] val_density - Value of the density. + * \param[in] val_velocity - Pointer to the velocity. + * \param[in] val_betainc2 - Value of the artificial compresibility factor. + * \param[in] val_cp - Value of the specific heat at constant pressure. + * \param[in] val_temperature - Value of the temperature. + * \param[in] val_dRhodT - Value of the derivative of density w.r.t. temperature. + * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. + * \param[in] val_scale - Scale of the projection. + * \param[out] val_Proj_Jac_tensor - Pointer to the projected inviscid Jacobian. + */ + void GetInviscidIncProjJac(su2double *val_density, + su2double *val_velocity, + su2double *val_betainc2, + su2double *val_cp, + su2double *val_temperature, + su2double *val_dRhodT, + su2double *val_normal, + su2double val_scale, + su2double **val_Proj_Jac_Tensor); + + /*! + * \brief Compute the low speed preconditioning matrix. + * \param[in] val_density - Value of the density. + * \param[in] val_velocity - Pointer to the velocity. + * \param[in] val_betainc2 - Value of the artificial compresibility factor. + * \param[in] val_cp - Value of the specific heat at constant pressure. + * \param[in] val_temperature - Value of the temperature. + * \param[in] val_dRhodT - Value of the derivative of density w.r.t. temperature. + * \param[out] val_Precon - Pointer to the preconditioning matrix. + */ + void GetPreconditioner(su2double *val_density, + su2double *val_velocity, + su2double *val_betainc2, + su2double *val_cp, + su2double *val_temperature, + su2double *val_drhodt, + su2double **val_Precon); + + /*! + * \brief Compute the projection of the preconditioned inviscid Jacobian matrices. + * \param[in] val_density - Value of the density. + * \param[in] val_velocity - Pointer to the velocity. + * \param[in] val_betainc2 - Value of the artificial compresibility factor. + * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. + * \param[out] val_Proj_Jac_tensor - Pointer to the projected inviscid Jacobian. + */ + void GetPreconditionedProjJac(su2double *val_density, + su2double *val_velocity, + su2double *val_betainc2, + su2double *val_normal, + su2double **val_Proj_Jac_Tensor); + + /*! + * \brief Compute the projection of the inviscid Jacobian matrices for general fluid model. + * \param[in] val_velocity Pointer to the velocity. + * \param[in] val_energy Value of the energy. + * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. + * \param[in] val_scale - Scale of the projection. + * \param[out] val_Proj_Jac_tensor - Pointer to the projected inviscid Jacobian. + */ + void GetInviscidProjJac(su2double *val_velocity, su2double *val_enthalphy, + su2double *val_chi, su2double *val_kappa, + su2double *val_normal, su2double val_scale, + su2double **val_Proj_Jac_tensor); + + /*! + * \brief Mapping between primitives variables P and conservatives variables C. + * \param[in] val_Mean_PrimVar - Mean value of the primitive variables. + * \param[in] val_Mean_PrimVar - Mean Value of the secondary variables. + * \param[out] val_Jac_PC - Pointer to the Jacobian dPdC. + */ + void GetPrimitive2Conservative (su2double *val_Mean_PrimVar, + su2double *val_Mean_SecVar, + su2double **val_Jac_PC); + + /*! + * \overload + * \brief Computation of the matrix P for a generic fluid model + * \param[in] val_density - Value of the density. + * \param[in] val_velocity - Value of the velocity. + * \param[in] val_soundspeed - Value of the sound speed. + * \param[in] val_enthalpy - Value of the Enthalpy + * \param[in] val_chi - Value of the derivative of Pressure with respect to the Density. + * \param[in] val_kappa - Value of the derivative of Pressure with respect to the volume specific Static Energy. + * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. + * \param[out] val_p_tensor - Pointer to the P matrix. + */ + void GetPMatrix(su2double *val_density, su2double *val_velocity, + su2double *val_soundspeed, su2double *val_enthalpy, su2double *val_chi, su2double *val_kappa, + su2double *val_normal, su2double **val_p_tensor); + + /*! + * \brief Computation of the matrix P, this matrix diagonalize the conservative Jacobians in + * the form $P^{-1}(A.Normal)P=Lambda$. + * \param[in] val_density - Value of the density. + * \param[in] val_velocity - Value of the velocity. + * \param[in] val_soundspeed - Value of the sound speed. + * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. + * \param[out] val_p_tensor - Pointer to the P matrix. + */ + void GetPMatrix(su2double *val_density, su2double *val_velocity, + su2double *val_soundspeed, su2double *val_normal, + su2double **val_p_tensor); + + /*! + * \brief Computation of the matrix Rinv*Pe. + * \param[in] Beta2 - A variable in used to define Pe matrix. + * \param[in] val_enthalpy - value of the enthalpy. + * \param[in] val_soundspeed - value of the sound speed. + * \param[in] val_density - value of the density. + * \param[in] val_velocity - value of the velocity. + * \param[out] val_invR_invPe - Pointer to the matrix of conversion from entropic to conserved variables. + */ + void GetinvRinvPe(su2double Beta2, su2double val_enthalpy, su2double val_soundspeed, + su2double val_density, su2double* val_velocity, + su2double** val_invR_invPe); + + /*! + * \brief Computation of the matrix R. + * \param[in] val_pressure - value of the pressure. + * \param[in] val_soundspeed - value of the sound speed. + * \param[in] val_density - value of the density. + * \param[in] val_velocity - value of the velocity. + * \param[out] val_invR_invPe - Pointer to the matrix of conversion from entropic to conserved variables. + */ + + void GetRMatrix(su2double val_pressure, su2double val_soundspeed, + su2double val_density, su2double* val_velocity, + su2double** val_invR_invPe); + /*! + * \brief Computation of the matrix R. + * \param[in] val_soundspeed - value of the sound speed. + * \param[in] val_density - value of the density. + * \param[out] R_Matrix - Pointer to the matrix of conversion from entropic to conserved variables. + */ + void GetRMatrix(su2double val_soundspeed, su2double val_density, su2double **R_Matrix); + + /*! + * \brief Computation of the matrix R. + * \param[in] val_soundspeed - value of the sound speed. + * \param[in] val_density - value of the density. + * \param[out] L_Matrix - Pointer to the matrix of conversion from conserved to entropic variables. + */ + void GetLMatrix(su2double val_soundspeed, su2double val_density, su2double **L_Matrix); + + /*! + * \brief Computation of the flow Residual Jacoboan Matrix for Non Reflecting BC. + * \param[in] val_soundspeed - value of the sound speed. + * \param[in] val_density - value of the density. + * \param[out] R_c - Residual Jacoboan Matrix + * \param[out] R_c_inv- inverse of the Residual Jacoboan Matrix . + */ + void ComputeResJacobianGiles(CFluidModel *FluidModel, su2double pressure, su2double density, su2double *turboVel, + su2double alphaInBC, su2double gammaInBC, su2double **R_c, su2double **R_c_inv); + + /*! + * \brief Computate the inverse of a 3x3 matrix + * \param[in] matrix - the matrix to invert + * \param[out] invMatrix - inverse matrix. + */ + void InvMatrix3D(su2double **matrix, su2double **invMatrix); + + /*! + * \brief Computate the inverse of a 4x4 matrix + * \param[in] matrix - the matrix to invert + * \param[out] invMatrix - inverse matrix. + */ + void InvMatrix4D(su2double **matrix, su2double **invMatrix); + + /*! + * \brief Computation of the matrix R. + * \param[in] val_soundspeed - value of the sound speed. + * \param[in] val_density - value of the density. + * \param[in] prim_jump - pointer to the vector containing the primitive variable jump (drho, dV, dp). + * \param[out]char_jump - pointer to the vector containing the characteristic variable jump. + */ + void GetCharJump(su2double val_soundspeed, su2double val_density, su2double *prim_jump, su2double *char_jump); + + /*! + * \brief Computation of the matrix Td, this matrix diagonalize the preconditioned conservative Jacobians + * in the form $Tg |Lambda| Td = Pc{-1}|Pc (A.Normal)|$. + * \param[in] Beta2 - A variable in used to define absPeJacobian matrix. + * \param[in] r_hat - A variable in used to define absPeJacobian matrix. + * \param[in] s_hat - A variable in used to define absPeJacobian matrix. + * \param[in] t_hat - A variable in used to define absPeJacobian matrix. + * \param[in] rB2a2 - A variable in used to define absPeJacobian matrix. + * \param[in] val_Lambda - Eigenvalues of the Preconditioned Jacobian. + * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. + * \param[out] val_absPeJac - Pointer to the Preconditioned Jacobian matrix. + */ + void GetPrecondJacobian(su2double Beta2, su2double r_hat, su2double s_hat, su2double t_hat, su2double rB2a2, su2double* val_Lambda, su2double* val_normal, su2double** val_absPeJac); + + + /*! + * \brief Computation of the matrix P^{-1}, this matrix diagonalize the conservative Jacobians + * in the form $P^{-1}(A.Normal)P=Lambda$. + * \param[in] val_density - Value of the density. + * \param[in] val_velocity - Value of the velocity. + * \param[in] val_soundspeed - Value of the sound speed. + * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. + * \param[out] val_invp_tensor - Pointer to inverse of the P matrix. + */ + void GetPMatrix_inv(su2double **val_invp_tensor, su2double *val_density, + su2double *val_velocity, su2double *val_soundspeed, + su2double *val_chi, su2double *val_kappa, + su2double *val_normal); + + /*! + * \brief Computation of the matrix P^{-1}, this matrix diagonalize the conservative Jacobians + * in the form $P^{-1}(A.Normal)P=Lambda$. + * \param[in] val_density - Value of the density. + * \param[in] val_velocity - Value of the velocity. + * \param[in] val_soundspeed - Value of the sound speed. + * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. + * \param[out] val_invp_tensor - Pointer to inverse of the P matrix. + */ + void GetPMatrix_inv(su2double *val_density, su2double *val_velocity, + su2double *val_soundspeed, su2double *val_normal, + su2double **val_invp_tensor); + + /*! + * \brief Compute viscous residual and jacobian. + */ + void GetAdjViscousFlux_Jac(su2double Pressure_i, su2double Pressure_j, su2double Density_i, su2double Density_j, + su2double ViscDens_i, su2double ViscDens_j, su2double *Velocity_i, su2double *Velocity_j, + su2double sq_vel_i, su2double sq_vel_j, + su2double XiDens_i, su2double XiDens_j, su2double **Mean_GradPhi, su2double *Mean_GradPsiE, + su2double dPhiE_dn, su2double *Normal, su2double *Edge_Vector, su2double dist_ij_2, su2double *val_residual_i, + su2double *val_residual_j, + su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, su2double **val_Jacobian_ji, + su2double **val_Jacobian_jj, bool implicit); + + /*! + * \brief Computation of the projected inviscid lambda (eingenvalues). + * \param[in] val_velocity - Value of the velocity. + * \param[in] val_soundspeed - Value of the sound speed. + * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. + * \param[in] val_Lambda_Vector - Pointer to Lambda matrix. + */ + void GetJacInviscidLambda_fabs(su2double *val_velocity, su2double val_soundspeed, + su2double *val_normal, su2double *val_Lambda_Vector); + + /*! + * \brief Compute the numerical residual. + * \param[out] val_residual - Pointer to the total residual. + * \param[in] config - Definition of the particular problem. + */ + inline virtual void ComputeResidual(su2double *val_residual, CConfig *config) { } + + /*! + * \overload + * \param[out] val_residual_i - Pointer to the total residual at point i. + * \param[out] val_residual_j - Pointer to the total residual at point j. + */ + inline virtual void ComputeResidual(su2double *val_residual_i, su2double *val_residual_j) { } + + inline virtual void ComputeResidual_TransLM(su2double *val_residual, + su2double **val_Jacobian_i, + su2double **val_Jacobian_j, CConfig *config, + su2double &gamma_sep) { } + + /*! + * \overload + * \param[out] val_residual_i - Pointer to the total residual at point i. + * \param[out] val_residual_j - Pointer to the total residual at point j. + * \param[in] config - Definition of the particular problem. + */ + inline virtual void ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, CConfig *config) { } + + /*! + * \overload + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + inline virtual void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, + su2double **val_Jacobian_j, CConfig *config) { } + + /*! + * \overload + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[out] val_JacobianMeanFlow_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_JacobianMeanFlow_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + inline virtual void ComputeResidual(su2double *val_residual, + su2double **val_Jacobian_i, + su2double **val_Jacobian_j, + su2double **val_JacobianMeanFlow_i, + su2double **val_JacobianMeanFlow_j, + CConfig *config) { } + + /*! + * \overload + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + inline virtual void ComputeResidual(su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { } + + /*! + * \overload + * \param[out] val_resconv - Pointer to the convective residual. + * \param[out] val_resvisc - Pointer to the artificial viscosity residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + inline virtual void ComputeResidual(su2double *val_resconv, su2double *val_resvisc, + su2double **val_Jacobian_i, su2double **val_Jacobian_j, + CConfig *config) { } + + /*! + * \overload + * \param[out] val_residual_i - Pointer to the total residual at point i. + * \param[out] val_residual_j - Pointer to the total viscosity residual at point j. + * \param[out] val_Jacobian_ii - Jacobian of the numerical method at node i (implicit computation) from node i. + * \param[out] val_Jacobian_ij - Jacobian of the numerical method at node i (implicit computation) from node j. + * \param[out] val_Jacobian_ji - Jacobian of the numerical method at node j (implicit computation) from node i. + * \param[out] val_Jacobian_jj - Jacobian of the numerical method at node j (implicit computation) from node j. + * \param[in] config - Definition of the particular problem. + */ + inline virtual void ComputeResidual(su2double *val_residual_i, + su2double *val_residual_j, + su2double **val_Jacobian_ii, + su2double **val_Jacobian_ij, + su2double **val_Jacobian_ji, + su2double **val_Jacobian_jj, CConfig *config) { } + + /*! + * \overload + * \param[out] val_resconv_i - Pointer to the convective residual at point i. + * \param[out] val_resvisc_i - Pointer to the artificial viscosity residual at point i. + * \param[out] val_resconv_j - Pointer to the convective residual at point j. + * \param[out] val_resvisc_j - Pointer to the artificial viscosity residual at point j. + * \param[out] val_Jacobian_ii - Jacobian of the numerical method at node i (implicit computation) from node i. + * \param[out] val_Jacobian_ij - Jacobian of the numerical method at node i (implicit computation) from node j. + * \param[out] val_Jacobian_ji - Jacobian of the numerical method at node j (implicit computation) from node i. + * \param[out] val_Jacobian_jj - Jacobian of the numerical method at node j (implicit computation) from node j. + * \param[in] config - Definition of the particular problem. + */ + inline virtual void ComputeResidual(su2double *val_resconv_i, su2double *val_resvisc_i, + su2double *val_resconv_j, su2double *val_resvisc_j, + su2double **val_Jacobian_ii, + su2double **val_Jacobian_ij, + su2double **val_Jacobian_ji, + su2double **val_Jacobian_jj, CConfig *config) { } + + /*! + * \overload + * \param[out] val_stiffmatrix_elem - Stiffness matrix for Galerkin computation. + * \param[in] config - Definition of the particular problem. + */ + inline virtual void ComputeResidual(su2double **val_stiffmatrix_elem, CConfig *config) { } + + /*! + * \overload + * \param[in] config - Definition of the particular problem. + * \param[out] val_residual - residual of the source terms + * \param[out] val_Jacobian_i - Jacobian of the source terms + */ + inline virtual void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config) { } + + /*! + * \overload + * \param[out] - Matrix for storing the constants to be used in the calculation of the equilibrium extent of reaction Keq. + * \param[in] config - Definition of the particular problem. + */ + inline virtual void GetEq_Rxn_Coefficients(su2double **EqnRxnConstants, CConfig *config) { } + + /*! + * \brief Residual for source term integration. + * \param[out] val_residual - Pointer to the source residual containing chemistry terms. + * \param[in] config - Definition of the particular problem. + */ + inline virtual void ComputeResidual_Axisymmetric(su2double *val_residual, CConfig *config) { } + + /*! + * \brief Residual for source term integration. + * \param[out] val_residual - Pointer to the source residual containing chemistry terms. + * \param[in] config - Definition of the particular problem. + */ + inline virtual void ComputeResidual_Axisymmetric_ad(su2double *val_residual, su2double *val_residuald, CConfig *config) { } + + /*! + * \brief Calculation of axisymmetric source term Jacobian + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + inline virtual void SetJacobian_Axisymmetric(su2double **val_Jacobian_i, CConfig *config) { } + + /*! + * \brief Calculation of the translational-vibrational energy exchange source term + * \param[in] config - Definition of the particular problem. + * \param[out] val_residual - residual of the source terms + * \param[out] val_Jacobian_i - Jacobian of the source terms + */ + inline virtual void ComputeVibRelaxation(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config) { } + + /*! + * \brief Calculation of the chemistry source term + * \param[in] config - Definition of the particular problem. + * \param[out] val_residual - residual of the source terms + * \param[out] val_Jacobian_i - Jacobian of the source terms + */ + inline virtual void ComputeChemistry(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config) { } + + /*! + * \brief Calculates constants used for Keq correlation. + * \param[out] A - Pointer to coefficient array. + * \param[in] val_reaction - Reaction number indicator. + * \param[in] config - Definition of the particular problem. + */ + inline virtual void GetKeqConstants(su2double *A, unsigned short val_reaction, CConfig *config) { } + + /*! + * \brief Set intermittency for numerics (used in SA with LM transition model) + */ + inline virtual void SetIntermittency(su2double intermittency_in) { } + + /*! + * \brief Residual for source term integration. + * \param[in] val_production - Value of the Production. + */ + inline virtual void SetProduction(su2double val_production) { } + + /*! + * \brief Residual for source term integration. + * \param[in] val_destruction - Value of the Destruction. + */ + inline virtual void SetDestruction(su2double val_destruction) { } + + /*! + * \brief Residual for source term integration. + * \param[in] val_crossproduction - Value of the CrossProduction. + */ + inline virtual void SetCrossProduction(su2double val_crossproduction) { } + + /*! + * \brief Residual for source term integration. + * \param[in] val_production - Value of the Production. + */ + inline virtual su2double GetProduction(void) { return 0; } + + /*! + * \brief Residual for source term integration. + * \param[in] val_destruction - Value of the Destruction. + */ + inline virtual su2double GetDestruction(void) { return 0; } + + /*! + * \brief Residual for source term integration. + * \param[in] val_crossproduction - Value of the CrossProduction. + */ + inline virtual su2double GetCrossProduction(void) { return 0; } + + /*! + * \brief A virtual member. + */ + inline virtual su2double GetGammaBC(void) { return 0.0; } + + /*! + * \overload + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i + * \param[in] config - Definition of the particular problem. + */ + inline virtual void ComputeResidual(su2double **val_Jacobian_i, + su2double *val_Jacobian_mui, + su2double ***val_Jacobian_gradi, CConfig *config) { } + + /*! + * \overload + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i + * \param[in] config - Definition of the particular problem. + */ + inline virtual void ComputeResidual(su2double **val_Jacobian_i, + su2double *val_Jacobian_mui, + su2double ***val_Jacobian_gradi, + su2double **val_Jacobian_j, + su2double *val_Jacobian_muj, + su2double ***val_Jacobian_gradj, CConfig *config) { } + + /*! + * \brief A virtual member to compute the tangent matrix in structural problems + * \param[in] element_container - Element structure for the particular element integrated. + */ + inline virtual void Compute_Tangent_Matrix(CElement *element_container, CConfig *config) { } + + /*! + * \brief A virtual member to compute the nodal stress term in non-linear structural problems + * \param[in] element_container - Definition of the particular element integrated. + */ + inline virtual void Compute_NodalStress_Term(CElement *element_container, CConfig *config) { } + + /*! + * \brief Set the element-based local Young's modulus in mesh problems + * \param[in] iElem - Element index. + * \param[in] val_E - Value of elasticity modulus. + */ + inline virtual void SetMeshElasticProperties(unsigned long iElem, su2double val_E) { } + + /*! + * \brief A virtual member to set the value of the design variables + * \param[in] i_DV - Index of the design variable. + * \param[in] val_DV - Value of the design variable + */ + inline virtual void Set_DV_Val(unsigned short i_DV, su2double val_DV) { } + + /*! + * \brief A virtual member to retrieve the value of the design variables + * \param[in] i_DV - Index of the design variable. + */ + inline virtual su2double Get_DV_Val(unsigned short i_DV) const { return 0.0; } + + /*! + * \brief A virtual member to set the electric field + * \param[in] EField_DV - New electric field computed by adjoint methods. + */ + inline virtual void Set_ElectricField(unsigned short i_DV, su2double val_EField) { } + + /*! + * \brief A virtual member to set the material properties + * \param[in] iVal - Index of the region of concern + * \param[in] val_E - Value of the Young Modulus. + * \param[in] val_Nu - Value of the Poisson's ratio. + */ + inline virtual void SetMaterial_Properties(unsigned short iVal, su2double val_E, su2double val_Nu) { } + + /*! + * \brief A virtual member to set the material properties + * \param[in] iVal - Index of the region of concern + * \param[in] val_Rho - Value of the density (inertial effects). + * \param[in] val_Rho_DL - Value of the density (dead load effects). + */ + inline virtual void SetMaterial_Density(unsigned short iVal, su2double val_Rho, su2double val_Rho_DL) { } + + /*! + * \brief A virtual member to compute the mass matrix + * \param[in] element_container - Element structure for the particular element integrated. + */ + inline virtual void Compute_Mass_Matrix(CElement *element_container, CConfig *config) { } + + /*! + * \brief A virtual member to compute the residual component due to dead loads + * \param[in] element_container - Element structure for the particular element integrated. + */ + inline virtual void Compute_Dead_Load(CElement *element_container, CConfig *config) { } + + /*! + * \brief A virtual member to compute the averaged nodal stresses + * \param[in] element_container - Element structure for the particular element integrated. + */ + inline virtual void Compute_Averaged_NodalStress(CElement *element_container, CConfig *config) { } + + /*! + * \brief Computes a basis of orthogonal vectors from a suppled vector + * \param[in] config - Normal vector + */ + void CreateBasis(su2double *val_Normal); + + /*! + * \brief Set the value of the Tauwall + * \param[in] val_tauwall_i - Tauwall at point i + * \param[in] val_tauwall_j - Tauwall at point j + */ + inline virtual void SetTauWall(su2double val_tauwall_i, su2double val_tauwall_j) { } + + /*! + * \brief - Calculate the central/upwind blending function for a face + * + * At its simplest level, this function will calculate the average + * value of the "Roe dissipation" or central/upwind blending function + * at a face. If Ducros shock sensors are used, then this method will + * also adjust the central/upwind blending to account for shocks. + * + * \param[in] Dissipation_i - Value of the blending function at point i + * \param[in] Dissipation_j - Value of the bledning function at point j + * \param[in] Sensor_i - Shock sensor at point i + * \param[in] Sensor_j - Shock sensor at point j + * \param[out] Dissipation_ij - Blending parameter at face + */ + void SetRoe_Dissipation(const su2double Dissipation_i, + const su2double Dissipation_j, + const su2double Sensor_i, const su2double Sensor_j, + su2double& Dissipation_ij, CConfig *config); + + /*! + * \brief Setting the UQ framework usage + * \param[in] val_using_uq + */ + inline void SetUsing_UQ(bool val_using_uq) { using_uq = val_using_uq; } + + /*! + * \brief Decomposes the symmetric matrix A_ij, into eigenvectors and eigenvalues + * \param[in] A_i: symmetric matrix to be decomposed + * \param[in] Eig_Vec: strores the eigenvectors + * \param[in] Eig_Val: stores the eigenvalues + * \param[in] n: order of matrix A_ij + */ + static void EigenDecomposition(su2double **A_ij, su2double **Eig_Vec, su2double *Eig_Val, unsigned short n); + + /*! + * \brief Recomposes the eigenvectors and eigenvalues into a matrix + * \param[in] A_ij: recomposed matrix + * \param[in] Eig_Vec: eigenvectors + * \param[in] Eig_Val: eigenvalues + * \param[in] n: order of matrix A_ij + */ + static void EigenRecomposition(su2double **A_ij, su2double **Eig_Vec, su2double *Eig_Val, unsigned short n); + + /*! + * \brief tred2 + * \param[in] V: matrix that needs to be decomposed + * \param[in] d: holds eigenvalues + * \param[in] e: supplemental data structure + * \param[in] n: order of matrix V + */ + static void tred2(su2double **V, su2double *d, su2double *e, unsigned short n); + + /*! + * \brief tql2 + * \param[in] V: matrix that will hold the eigenvectors + * \param[in] d: array that will hold the ordered eigenvalues + * \param[in] e: supplemental data structure + * \param[in] n: order of matrix V + + */ + static void tql2(su2double **V, su2double *d, su2double *e, unsigned short n); + +}; + +/*! + * /brief Alias for a "do nothing" source term class + */ +using CSourceNothing = CNumerics; + diff --git a/SU2_CFD/include/numerics/continuous_adjoint/CAvgGradCorrected_AdjFlow.hpp b/SU2_CFD/include/numerics/continuous_adjoint/CAvgGradCorrected_AdjFlow.hpp new file mode 100644 index 000000000000..8d15e342e7f4 --- /dev/null +++ b/SU2_CFD/include/numerics/continuous_adjoint/CAvgGradCorrected_AdjFlow.hpp @@ -0,0 +1,78 @@ +/*! + * \file CAvgGradCorrected_AdjFlow.hpp + * \brief Delaration of numerics class CAvgGradCorrected_AdjFlow, the + * implementation is in the CAvgGradCorrected_AdjFlow.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../CNumerics.hpp" + +/*! + * \class CAvgGradCorrected_AdjFlow + * \brief Class for computing the adjoint viscous terms, including correction. + * \ingroup ViscDiscr + * \author A. Bueno. + */ +class CAvgGradCorrected_AdjFlow : public CNumerics { +private: + su2double *Velocity_i; /*!< \brief Auxiliary vector for storing the velocity of point i. */ + su2double *Velocity_j; /*!< \brief Auxiliary vector for storing the velocity of point j. */ + su2double *Mean_Velocity; + su2double **Mean_GradPsiVar; /*!< \brief Counter for dimensions of the problem. */ + su2double *Edge_Vector; /*!< \brief Vector going from node i to node j. */ + su2double *Proj_Mean_GradPsiVar_Edge; /*!< \brief Projection of Mean_GradPsiVar onto Edge_Vector. */ + su2double *Mean_GradPsiE; /*!< \brief Counter for dimensions of the problem. */ + su2double **Mean_GradPhi; /*!< \brief Counter for dimensions of the problem. */ + bool implicit; /*!< \brief Boolean controlling Jacobian calculations. */ + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CAvgGradCorrected_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CAvgGradCorrected_AdjFlow(void); + + /*! + * \brief Compute the adjoint flow viscous residual in a non-conservative way using an average of gradients and derivative correction. + * \param[out] val_residual_i - Pointer to the viscous residual at point i. + * \param[out] val_residual_j - Pointer to the viscous residual at point j. + * \param[out] val_Jacobian_ii - Jacobian of the numerical method at node i (implicit computation) from node i. + * \param[out] val_Jacobian_ij - Jacobian of the numerical method at node i (implicit computation) from node j. + * \param[out] val_Jacobian_ji - Jacobian of the numerical method at node j (implicit computation) from node i. + * \param[out] val_Jacobian_jj - Jacobian of the numerical method at node j (implicit computation) from node j. + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, + su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config); +}; diff --git a/SU2_CFD/include/numerics/continuous_adjoint/CAvgGradCorrected_AdjTurb.hpp b/SU2_CFD/include/numerics/continuous_adjoint/CAvgGradCorrected_AdjTurb.hpp new file mode 100644 index 000000000000..89d1232288eb --- /dev/null +++ b/SU2_CFD/include/numerics/continuous_adjoint/CAvgGradCorrected_AdjTurb.hpp @@ -0,0 +1,82 @@ +/*! + * \file CAvgGradCorrected_AdjTurb.hpp + * \brief Delaration of numerics class CAvgGradCorrected_AdjTurb, the + * implementation is in the CAvgGradCorrected_AdjTurb.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../CNumerics.hpp" + +/*! + * \class CAvgGradCorrected_AdjTurb + * \brief Class for adjoint turbulent using average of gradients with a correction. + * \ingroup ViscDiscr + * \author A. Bueno. + */ +class CAvgGradCorrected_AdjTurb : public CNumerics { +private: + su2double **Mean_GradTurbPsi; + su2double *Proj_Mean_GradTurbPsi_Kappa, *Proj_Mean_GradTurbPsi_Edge, *Proj_Mean_GradTurbPsi_Corrected; + su2double *Edge_Vector; + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CAvgGradCorrected_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CAvgGradCorrected_AdjTurb(void); + + /*! + * \brief Compute the adjoint turbulent residual using average of gradients and a derivative correction. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + + /*! + * \overload + * \param[out] val_residual_i - Pointer to the total residual at point i. + * \param[out] val_residual_j - Pointer to the total viscosity residual at point j. + * \param[out] val_Jacobian_ii - Jacobian of the numerical method at node i (implicit computation) from node i. + * \param[out] val_Jacobian_ij - Jacobian of the numerical method at node i (implicit computation) from node j. + * \param[out] val_Jacobian_ji - Jacobian of the numerical method at node j (implicit computation) from node i. + * \param[out] val_Jacobian_jj - Jacobian of the numerical method at node j (implicit computation) from node j. + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, + su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config); +}; diff --git a/SU2_CFD/include/numerics/continuous_adjoint/CAvgGrad_AdjFlow.hpp b/SU2_CFD/include/numerics/continuous_adjoint/CAvgGrad_AdjFlow.hpp new file mode 100644 index 000000000000..e563a9517d8f --- /dev/null +++ b/SU2_CFD/include/numerics/continuous_adjoint/CAvgGrad_AdjFlow.hpp @@ -0,0 +1,72 @@ +/*! + * \file CAvgGrad_AdjFlow.hpp + * \brief Delaration of numerics class CAvgGrad_AdjFlow, the + * implementation is in the CAvgGrad_AdjFlow.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../CNumerics.hpp" + +/*! + * \class CAvgGrad_AdjFlow + * \brief Class for computing the adjoint viscous terms. + * \ingroup ViscDiscr + * \author F. Palacios + */ +class CAvgGrad_AdjFlow : public CNumerics { +private: + su2double *Velocity_i; /*!< \brief Auxiliary vector for storing the velocity of point i. */ + su2double *Velocity_j; /*!< \brief Auxiliary vector for storing the velocity of point j. */ + su2double *Mean_Velocity; + su2double *Mean_GradPsiE; /*!< \brief Counter for dimensions of the problem. */ + su2double **Mean_GradPhi; /*!< \brief Counter for dimensions of the problem. */ + su2double *Edge_Vector; /*!< \brief Vector going from node i to node j. */ + bool implicit; /*!< \brief Implicit calculus. */ + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CAvgGrad_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CAvgGrad_AdjFlow(void); + + /*! + * \brief Residual computation. + * \param[out] val_residual_i - Pointer to the total residual at point i. + * \param[out] val_residual_j - Pointer to the total residual at point j. + */ + void ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, + su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, + su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config); +}; diff --git a/SU2_CFD/include/numerics/continuous_adjoint/CAvgGrad_AdjTurb.hpp b/SU2_CFD/include/numerics/continuous_adjoint/CAvgGrad_AdjTurb.hpp new file mode 100644 index 000000000000..829a4006e7cc --- /dev/null +++ b/SU2_CFD/include/numerics/continuous_adjoint/CAvgGrad_AdjTurb.hpp @@ -0,0 +1,82 @@ +/*! + * \file CAvgGrad_AdjTurb.hpp + * \brief Delaration of numerics class CAvgGrad_AdjTurb, the + * implementation is in the CAvgGrad_AdjTurb.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../CNumerics.hpp" + +/*! + * \class CAvgGrad_AdjTurb + * \brief Class for adjoint turbulent using average of gradients with a correction. + * \ingroup ViscDiscr + * \author F. Palacios + */ +class CAvgGrad_AdjTurb : public CNumerics { +private: + su2double **Mean_GradTurbPsi; + su2double *Proj_Mean_GradTurbPsi_Kappa, *Proj_Mean_GradTurbPsi_Edge, *Proj_Mean_GradTurbPsi_Corrected; + su2double *Edge_Vector; + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CAvgGrad_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CAvgGrad_AdjTurb(void); + + /*! + * \brief Compute the adjoint turbulent residual using average of gradients and a derivative correction. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + + /*! + * \overload + * \param[out] val_residual_i - Pointer to the total residual at point i. + * \param[out] val_residual_j - Pointer to the total viscosity residual at point j. + * \param[out] val_Jacobian_ii - Jacobian of the numerical method at node i (implicit computation) from node i. + * \param[out] val_Jacobian_ij - Jacobian of the numerical method at node i (implicit computation) from node j. + * \param[out] val_Jacobian_ji - Jacobian of the numerical method at node j (implicit computation) from node i. + * \param[out] val_Jacobian_jj - Jacobian of the numerical method at node j (implicit computation) from node j. + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, + su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config); +}; diff --git a/SU2_CFD/include/numerics/continuous_adjoint/CCentJST_AdjFlow.hpp b/SU2_CFD/include/numerics/continuous_adjoint/CCentJST_AdjFlow.hpp new file mode 100644 index 000000000000..3d7bf4f8d117 --- /dev/null +++ b/SU2_CFD/include/numerics/continuous_adjoint/CCentJST_AdjFlow.hpp @@ -0,0 +1,80 @@ +/*! + * \file CCentJST_AdjFlow.hpp + * \brief Delaration of numerics class CCentJST_AdjFlow, the + * implementation is in the CCentJST_AdjFlow.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../CNumerics.hpp" + +/*! + * \class CCentJST_AdjFlow + * \brief Class for and adjoint centered scheme - JST. + * \ingroup ConvDiscr + * \author F. Palacios + */ +class CCentJST_AdjFlow : public CNumerics { +private: + su2double *Diff_Psi, *Diff_Lapl; + su2double *Velocity_i, *Velocity_j; + su2double *MeanPhi; + unsigned short iDim, jDim, iVar, jVar; + su2double Residual, ProjVelocity_i, ProjVelocity_j, ProjPhi, ProjPhi_Vel, sq_vel, phis1, phis2; + su2double MeanPsiRho, MeanPsiE, Param_p, Param_Kappa_4, Param_Kappa_2, Local_Lambda_i, Local_Lambda_j, MeanLambda; + su2double Phi_i, Phi_j, sc4, StretchingFactor, Epsilon_4, Epsilon_2; + bool implicit, grid_movement; + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CCentJST_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CCentJST_AdjFlow(void); + + /*! + * \brief Compute the adjoint flow residual using a JST method. + * \param[out] val_resconv_i - Pointer to the convective residual at point i. + * \param[out] val_resvisc_i - Pointer to the artificial viscosity residual at point i. + * \param[out] val_resconv_j - Pointer to the convective residual at point j. + * \param[out] val_resvisc_j - Pointer to the artificial viscosity residual at point j. + * \param[out] val_Jacobian_ii - Jacobian of the numerical method at node i (implicit computation) from node i. + * \param[out] val_Jacobian_ij - Jacobian of the numerical method at node i (implicit computation) from node j. + * \param[out] val_Jacobian_ji - Jacobian of the numerical method at node j (implicit computation) from node i. + * \param[out] val_Jacobian_jj - Jacobian of the numerical method at node j (implicit computation) from node j. + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual (su2double *val_resconv_i, su2double *val_resvisc_i, su2double *val_resconv_j, su2double *val_resvisc_j, + su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, + CConfig *config); +}; diff --git a/SU2_CFD/include/numerics/continuous_adjoint/CCentLax_AdjFlow.hpp b/SU2_CFD/include/numerics/continuous_adjoint/CCentLax_AdjFlow.hpp new file mode 100644 index 000000000000..f67886abb244 --- /dev/null +++ b/SU2_CFD/include/numerics/continuous_adjoint/CCentLax_AdjFlow.hpp @@ -0,0 +1,80 @@ +/*! + * \file CCentLax_AdjFlow.hpp + * \brief Delaration of numerics class CCentLax_AdjFlow, the + * implementation is in the CCentLax_AdjFlow.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../CNumerics.hpp" + +/*! + * \class CCentLax_AdjFlow + * \brief Class for computing the Lax-Friedrich adjoint centered scheme. + * \ingroup ConvDiscr + * \author F. Palacios + */ +class CCentLax_AdjFlow : public CNumerics { +private: + su2double *Diff_Psi; + su2double *Velocity_i, *Velocity_j; + su2double *MeanPhi; + unsigned short iDim, jDim, iVar, jVar; + su2double Residual, ProjVelocity_i, ProjVelocity_j, ProjPhi, ProjPhi_Vel, sq_vel, phis1, phis2, + MeanPsiRho, MeanPsiE, Param_p, Param_Kappa_0, Local_Lambda_i, Local_Lambda_j, MeanLambda, + Phi_i, Phi_j, sc2, StretchingFactor, Epsilon_0; + bool implicit, grid_movement; + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CCentLax_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CCentLax_AdjFlow(void); + + /*! + * \brief Compute the adjoint flow residual using a Lax method. + * \param[out] val_resconv_i - Pointer to the convective residual at point i. + * \param[out] val_resvisc_i - Pointer to the artificial viscosity residual at point i. + * \param[out] val_resconv_j - Pointer to the convective residual at point j. + * \param[out] val_resvisc_j - Pointer to the artificial viscosity residual at point j. + * \param[out] val_Jacobian_ii - Jacobian of the numerical method at node i (implicit computation) from node i. + * \param[out] val_Jacobian_ij - Jacobian of the numerical method at node i (implicit computation) from node j. + * \param[out] val_Jacobian_ji - Jacobian of the numerical method at node j (implicit computation) from node i. + * \param[out] val_Jacobian_jj - Jacobian of the numerical method at node j (implicit computation) from node j. + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual (su2double *val_resconv_i, su2double *val_resvisc_i, su2double *val_resconv_j, su2double *val_resvisc_j, + su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, + CConfig *config); +}; diff --git a/SU2_CFD/include/numerics/continuous_adjoint/CSourceAxisymmetric_AdjFlow.hpp b/SU2_CFD/include/numerics/continuous_adjoint/CSourceAxisymmetric_AdjFlow.hpp new file mode 100644 index 000000000000..2fc39bced4aa --- /dev/null +++ b/SU2_CFD/include/numerics/continuous_adjoint/CSourceAxisymmetric_AdjFlow.hpp @@ -0,0 +1,61 @@ +/*! + * \file CSourceAxisymmetric_AdjFlow.hpp + * \brief Delaration of numerics class CSourceAxisymmetric_AdjFlow, the + * implementation is in the CSourceAxisymmetric_AdjFlow.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../CNumerics.hpp" + +/*! + * \class CSourceAxisymmetric_AdjFlow + * \brief Class for source term for solving axisymmetric problems. + * \ingroup SourceDiscr + * \author F. Palacios + */ +class CSourceAxisymmetric_AdjFlow : public CNumerics { +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CSourceAxisymmetric_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CSourceAxisymmetric_AdjFlow(void); + + /*! + * \brief Residual of the rotational frame source term. + * \param[out] val_residual - Pointer to the total residual. + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **Jacobian_i, CConfig *config); +}; diff --git a/SU2_CFD/include/numerics/continuous_adjoint/CSourceConservative_AdjFlow.hpp b/SU2_CFD/include/numerics/continuous_adjoint/CSourceConservative_AdjFlow.hpp new file mode 100644 index 000000000000..44d2158214ea --- /dev/null +++ b/SU2_CFD/include/numerics/continuous_adjoint/CSourceConservative_AdjFlow.hpp @@ -0,0 +1,59 @@ +/*! + * \file CSourceConservative_AdjFlow.hpp + * \brief Delaration of numerics class CSourceConservative_AdjFlow, the + * implementation is in the CSourceConservative_AdjFlow.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../CNumerics.hpp" + +class CSourceConservative_AdjFlow : public CNumerics { +private: + su2double *Velocity, *Residual_i, *Residual_j, *Mean_Residual; + su2double **Mean_PrimVar_Grad; + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CSourceConservative_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CSourceConservative_AdjFlow(void); + + /*! + * \brief Source term integration using a conservative scheme. + * \param[out] val_residual - Pointer to the total residual. + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, CConfig *config); +}; diff --git a/SU2_CFD/include/numerics/continuous_adjoint/CSourceConservative_AdjTurb.hpp b/SU2_CFD/include/numerics/continuous_adjoint/CSourceConservative_AdjTurb.hpp new file mode 100644 index 000000000000..626721f2c61a --- /dev/null +++ b/SU2_CFD/include/numerics/continuous_adjoint/CSourceConservative_AdjTurb.hpp @@ -0,0 +1,63 @@ +/*! + * \file CSourceConservative_AdjTurb.hpp + * \brief Delaration of numerics class CSourceConservative_AdjTurb, the + * implementation is in the CSourceConservative_AdjTurb.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../CNumerics.hpp" + +/*! + * \class CSourceConservative_AdjTurb + * \brief Class for source term integration in adjoint turbulent problem using a conservative scheme. + * \ingroup SourceDiscr + * \author A. Bueno. + */ +class CSourceConservative_AdjTurb : public CNumerics { +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CSourceConservative_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CSourceConservative_AdjTurb(void); + + /*! + * \brief Source term integration using a conservative scheme. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); +}; diff --git a/SU2_CFD/include/numerics/continuous_adjoint/CSourcePieceWise_AdjTurb.hpp b/SU2_CFD/include/numerics/continuous_adjoint/CSourcePieceWise_AdjTurb.hpp new file mode 100644 index 000000000000..9ea4c3db6c81 --- /dev/null +++ b/SU2_CFD/include/numerics/continuous_adjoint/CSourcePieceWise_AdjTurb.hpp @@ -0,0 +1,66 @@ +/*! + * \file CSourcePieceWise_AdjTurb.hpp + * \brief Delaration of numerics class CSourcePieceWise_AdjTurb, the + * implementation is in the CSourcePieceWise_AdjTurb.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../CNumerics.hpp" + +/*! + * \class CSourcePieceWise_AdjTurb + * \brief Class for source term integration of the adjoint turbulent equation. + * \ingroup SourceDiscr + * \author A. Bueno. + */ +class CSourcePieceWise_AdjTurb : public CNumerics { +private: + su2double **tau, *Velocity; + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CSourcePieceWise_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CSourcePieceWise_AdjTurb(void); + + /*! + * \brief Source term integration of the adjoint turbulence equation. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); +}; diff --git a/SU2_CFD/include/numerics/continuous_adjoint/CSourceRotatingFrame_AdjFlow.hpp b/SU2_CFD/include/numerics/continuous_adjoint/CSourceRotatingFrame_AdjFlow.hpp new file mode 100644 index 000000000000..ddaf0a7f4a60 --- /dev/null +++ b/SU2_CFD/include/numerics/continuous_adjoint/CSourceRotatingFrame_AdjFlow.hpp @@ -0,0 +1,62 @@ +/*! + * \file CSourceRotatingFrame_AdjFlow.hpp + * \brief Delaration of numerics class CSourceRotatingFrame_AdjFlow, the + * implementation is in the CSourceRotatingFrame_AdjFlow.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../CNumerics.hpp" + +/*! + * \class CSourceRotatingFrame_AdjFlow + * \brief Source term class for rotating frame adjoint. + * \ingroup SourceDiscr + * \author T. Economon. + */ +class CSourceRotatingFrame_AdjFlow : public CNumerics { +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CSourceRotatingFrame_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CSourceRotatingFrame_AdjFlow(void); + + /*! + * \brief Residual of the adjoint rotating frame source term. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config); +}; diff --git a/SU2_CFD/include/numerics/continuous_adjoint/CSourceViscous_AdjFlow.hpp b/SU2_CFD/include/numerics/continuous_adjoint/CSourceViscous_AdjFlow.hpp new file mode 100644 index 000000000000..96e74d16e913 --- /dev/null +++ b/SU2_CFD/include/numerics/continuous_adjoint/CSourceViscous_AdjFlow.hpp @@ -0,0 +1,66 @@ +/*! + * \file CSourceViscous_AdjFlow.hpp + * \brief Delaration of numerics class CSourceViscous_AdjFlow, the + * implementation is in the CSourceViscous_AdjFlow.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../CNumerics.hpp" + +/*! + * \class CSourceViscous_AdjFlow + * \brief Class for source term integration in adjoint problem. + * \ingroup SourceDiscr + * \author F. Palacios + */ +class CSourceViscous_AdjFlow : public CNumerics { +private: + su2double *Velocity, *GradDensity, *GradInvDensity, *dPoDensity2, *alpha, *beta, *Sigma_5_vec; + su2double **GradVel_o_Rho, **sigma, **Sigma_phi, **Sigma_5_Tensor, **Sigma; + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CSourceViscous_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CSourceViscous_AdjFlow(void); + + /*! + * \brief Source term integration of the flow adjoint equation. + * \param[out] val_residual - Pointer to the total residual. + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual (su2double *val_residual, CConfig *config); + +}; diff --git a/SU2_CFD/include/numerics/continuous_adjoint/CUpwLin_AdjTurb.hpp b/SU2_CFD/include/numerics/continuous_adjoint/CUpwLin_AdjTurb.hpp new file mode 100644 index 000000000000..839c988ab3d7 --- /dev/null +++ b/SU2_CFD/include/numerics/continuous_adjoint/CUpwLin_AdjTurb.hpp @@ -0,0 +1,66 @@ +/*! + * \file CUpwLin_AdjTurb.hpp + * \brief Delaration of numerics class CUpwLin_AdjTurb, the + * implementation is in the CUpwLin_AdjTurb.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../CNumerics.hpp" + +/*! + * \class CUpwLin_AdjTurb + * \brief Class for performing a linear upwind solver for the adjoint turbulence equations. + * \ingroup ConvDiscr + * \author A. Bueno. + */ +class CUpwLin_AdjTurb : public CNumerics { +private: + su2double *Velocity_i; + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CUpwLin_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CUpwLin_AdjTurb(void); + + /*! + * \brief Compute the adjoint upwind flux between two nodes i and j. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual (su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); +}; diff --git a/SU2_CFD/include/numerics/continuous_adjoint/CUpwRoe_AdjFlow.hpp b/SU2_CFD/include/numerics/continuous_adjoint/CUpwRoe_AdjFlow.hpp new file mode 100644 index 000000000000..f517257c012c --- /dev/null +++ b/SU2_CFD/include/numerics/continuous_adjoint/CUpwRoe_AdjFlow.hpp @@ -0,0 +1,81 @@ +/*! + * \file CUpwRoe_AdjFlow.hpp + * \brief Delaration of numerics class CUpwRoe_AdjFlow, the + * implementation is in the CUpwRoe_AdjFlow.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../CNumerics.hpp" + +/*! + * \class CUpwRoe_AdjFlow + * \brief Class for solving an approximate Riemann solver of Roe + * for the adjoint flow equations. + * \ingroup ConvDiscr + * \author F. Palacios + */ +class CUpwRoe_AdjFlow : public CNumerics { +private: + su2double *Residual_Roe; + su2double area, Sx, Sy, Sz, rarea, nx, ny, nz, rho_l, u_l, v_l, w_l, h_l, rho_r, + u_r, v_r, w_r, h_r, psi1, psi2, psi3, psi4, psi5; + su2double h, u, v, w, c, psi1_l, psi2_l, psi3_l, psi4_l, psi5_l, + psi1_r, psi2_r, psi3_r, psi4_r, psi5_r, q_l, q_r, Q_l, Q_r, vn, + rrho_l, weight, rweight1, cc; + su2double l1psi, l2psi, absQ, absQp, absQm, q2, alpha, beta_u, beta_v, beta_w, Q, l1l2p, l1l2m, eta; + su2double RoeDensity, RoeSoundSpeed, *RoeVelocity, *Lambda, *Velocity_i, *Velocity_j, **ProjFlux_i, **ProjFlux_j, + Proj_ModJac_Tensor_ij, **Proj_ModJac_Tensor, Energy_i, Energy_j, **P_Tensor, **invP_Tensor; + unsigned short iDim, iVar, jVar, kVar; + bool implicit, grid_movement; + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CUpwRoe_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CUpwRoe_AdjFlow(void); + + /*! + * \brief Compute the adjoint Roe's flux between two nodes i and j. + * \param[out] val_residual_i - Pointer to the total residual at point i. + * \param[out] val_residual_j - Pointer to the total residual at point j. + * \param[out] val_Jacobian_ii - Jacobian of the numerical method at node i (implicit computation) from node i. + * \param[out] val_Jacobian_ij - Jacobian of the numerical method at node i (implicit computation) from node j. + * \param[out] val_Jacobian_ji - Jacobian of the numerical method at node j (implicit computation) from node i. + * \param[out] val_Jacobian_jj - Jacobian of the numerical method at node j (implicit computation) from node j. + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, su2double **val_Jacobian_ii, + su2double **val_Jacobian_ij, su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config); +}; diff --git a/SU2_CFD/include/numerics/continuous_adjoint/CUpwSca_AdjTurb.hpp b/SU2_CFD/include/numerics/continuous_adjoint/CUpwSca_AdjTurb.hpp new file mode 100644 index 000000000000..eee40de14311 --- /dev/null +++ b/SU2_CFD/include/numerics/continuous_adjoint/CUpwSca_AdjTurb.hpp @@ -0,0 +1,69 @@ +/*! + * \file CUpwSca_AdjTurb.hpp + * \brief Delaration of numerics class CUpwSca_AdjTurb, the + * implementation is in the CUpwSca_AdjTurb.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../CNumerics.hpp" + +/*! + * \class CUpwSca_AdjTurb + * \brief Class for doing a scalar upwind solver for the adjoint turbulence equations. + * \ingroup ConvDiscr + * \author A. Bueno. + */ +class CUpwSca_AdjTurb : public CNumerics { +private: + su2double *Velocity_i, *Velocity_j; + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CUpwSca_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CUpwSca_AdjTurb(void); + + /*! + * \param[out] val_residual_i - Pointer to the total residual at point i. + * \param[out] val_residual_j - Pointer to the total viscosity residual at point j. + * \param[out] val_Jacobian_ii - Jacobian of the numerical method at node i (implicit computation) from node i. + * \param[out] val_Jacobian_ij - Jacobian of the numerical method at node i (implicit computation) from node j. + * \param[out] val_Jacobian_ji - Jacobian of the numerical method at node j (implicit computation) from node i. + * \param[out] val_Jacobian_jj - Jacobian of the numerical method at node j (implicit computation) from node j. + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, + su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config); +}; diff --git a/SU2_CFD/include/numerics/elasticity/CFEAElasticity.hpp b/SU2_CFD/include/numerics/elasticity/CFEAElasticity.hpp index 0ba9344d0445..50ab13bb0751 100644 --- a/SU2_CFD/include/numerics/elasticity/CFEAElasticity.hpp +++ b/SU2_CFD/include/numerics/elasticity/CFEAElasticity.hpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -27,8 +27,8 @@ #pragma once -#include "../../numerics_structure.hpp" - +#include "../CNumerics.hpp" +#include "../../../../Common/include/geometry/elements/CElement.hpp" /*! * \class CFEAElasticity diff --git a/SU2_CFD/include/numerics/flow/convection_centered/CCentBase_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_centered/CCentBase_Flow.hpp new file mode 100644 index 000000000000..6892e8ac4fde --- /dev/null +++ b/SU2_CFD/include/numerics/flow/convection_centered/CCentBase_Flow.hpp @@ -0,0 +1,106 @@ +/*! + * \file CCentBase_Flow.hpp + * \brief Delaration of numerics class CCentBase_Flow, the + * implementation is in the CCentBase_Flow.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../../CNumerics.hpp" + +/*! + * \class CCentBase_Flow + * \brief Intermediate class to define centered schemes. + * \ingroup ConvDiscr + * \author F. Palacios + */ +class CCentBase_Flow : public CNumerics { + +protected: + unsigned short iDim, iVar, jVar; /*!< \brief Iteration on dimension and variables. */ + bool dynamic_grid; /*!< \brief Consider grid movement. */ + bool implicit; /*!< \brief Implicit calculation (compute Jacobians). */ + su2double fix_factor; /*!< \brief Fix factor for dissipation Jacobians (more diagonal dominance). */ + + su2double *Velocity_i, *Velocity_j, *MeanVelocity; /*!< \brief Velocity at nodes i and j and mean. */ + su2double ProjVelocity_i, ProjVelocity_j; /*!< \brief Velocities in the face normal direction. */ + su2double sq_vel_i, sq_vel_j; /*!< \brief Squared norm of the velocity vectors. */ + su2double Energy_i, Energy_j, MeanEnergy; /*!< \brief Energy at nodes i and j and mean. */ + su2double MeanDensity, MeanPressure, MeanEnthalpy; /*!< \brief Mean density, pressure, and enthalpy. */ + su2double *ProjFlux; /*!< \brief Projected inviscid flux. */ + + su2double *Diff_U, *Diff_Lapl; /*!< \brief Differences of conservatives and undiv. Laplacians. */ + su2double Local_Lambda_i, Local_Lambda_j, MeanLambda; /*!< \brief Local eingenvalues. */ + su2double Param_p, Phi_i, Phi_j, StretchingFactor; /*!< \brief Streching parameters. */ + su2double cte_0, cte_1; /*!< \brief Constants for the scalar dissipation Jacobian. */ + + su2double ProjGridVel; /*!< \brief Projected grid velocity. */ + + /*! + * \brief Hook method for derived classes to define preaccumulated variables, optional to implement. + * \return true if any variable was set as preacc. input, in which case the residual will be output. + */ + virtual bool SetPreaccInVars(void) {return false;} + + /*! + * \brief Derived classes must implement this method, called in ComputeResidual after inviscid part. + * \param[in,out] val_residual - Pointer to the convective flux contribution to the residual. + * \param[in,out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[in,out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + */ + virtual void DissipationTerm(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j) = 0; + + /*! + * \brief Add the contribution of a scalar dissipation term to the Jacobians. + * \param[in,out] val_Jacobian_i - Jacobian of the numerical method at node i. + * \param[in,out] val_Jacobian_j - Jacobian of the numerical method at node j. + */ + void ScalarDissipationJacobian(su2double **val_Jacobian_i, su2double **val_Jacobian_j); + +public: + + /*! + * \brief Constructor of the class. + * \param[in] val_nDim - Number of dimension of the problem. + * \param[in] val_nVar - Number of variables of the problem. + * \param[in] config - Definition of the particular problem. + */ + CCentBase_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + virtual ~CCentBase_Flow(void); + + /*! + * \brief Compute the flow residual using a centered method with artificial dissipation. + * \param[out] val_residual - Pointer to the convective flux contribution to the residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + +}; diff --git a/SU2_CFD/include/numerics/flow/convection_centered/CCentJSTInc_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_centered/CCentJSTInc_Flow.hpp new file mode 100644 index 000000000000..8e3a926a2e9b --- /dev/null +++ b/SU2_CFD/include/numerics/flow/convection_centered/CCentJSTInc_Flow.hpp @@ -0,0 +1,90 @@ +/*! + * \file CCentJSTInc_Flow.hpp + * \brief Delaration of numerics class CCentJSTInc_Flow, the + * implementation is in the CCentJSTInc_Flow.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../../CNumerics.hpp" + +/*! + * \class CCentJSTInc_Flow + * \brief Class for centered scheme - modified JST with incompressible preconditioning. + * \ingroup ConvDiscr + * \author F. Palacios, T. Economon + */ +class CCentJSTInc_Flow : public CNumerics { + +private: + unsigned short iDim, iVar, jVar; /*!< \brief Iteration on dimension and variables. */ + su2double *Diff_V, *Diff_Lapl, /*!< \brief Diference of primitive variables and undivided laplacians. */ + *Velocity_i, *Velocity_j, /*!< \brief Velocity at node 0 and 1. */ + *MeanVelocity, ProjVelocity_i, + ProjVelocity_j, /*!< \brief Mean and projected velocities. */ + sq_vel_i, sq_vel_j, /*!< \brief Modulus of the velocity and the normal vector. */ + Temperature_i, Temperature_j, /*!< \brief Temperature at node 0 and 1. */ + MeanDensity, MeanPressure, + MeanBetaInc2, MeanEnthalpy, + MeanCp, MeanTemperature, /*!< \brief Mean values of primitive variables. */ + MeandRhodT, /*!< \brief Derivative of density w.r.t. temperature (variable density flows). */ + Param_p, Param_Kappa_2, + Param_Kappa_4, /*!< \brief Artificial dissipation parameters. */ + Local_Lambda_i, Local_Lambda_j, + MeanLambda, /*!< \brief Local eingenvalues. */ + Phi_i, Phi_j, sc2, sc4, + StretchingFactor, /*!< \brief Streching parameters. */ + *ProjFlux, /*!< \brief Projected inviscid flux tensor. */ + Epsilon_2, Epsilon_4; /*!< \brief Artificial dissipation values. */ + su2double **Precon; + bool implicit, /*!< \brief Implicit calculation. */ + dynamic_grid, /*!< \brief Modification for grid movement. */ + variable_density, /*!< \brief Variable density incompressible flows. */ + energy; /*!< \brief computation with the energy equation. */ + +public: + + /*! + * \brief Constructor of the class. + * \param[in] val_nDim - Number of dimension of the problem. + * \param[in] val_nVar - Number of variables of the problem. + * \param[in] config - Definition of the particular problem. + */ + CCentJSTInc_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CCentJSTInc_Flow(void); + + /*! + * \brief Compute the flow residual using a JST method. + * \param[out] val_residual - Pointer to the residual array. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); +}; diff --git a/SU2_CFD/include/numerics/flow/convection_centered/CCentJST_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_centered/CCentJST_Flow.hpp new file mode 100644 index 000000000000..05cc611d99c4 --- /dev/null +++ b/SU2_CFD/include/numerics/flow/convection_centered/CCentJST_Flow.hpp @@ -0,0 +1,75 @@ +/*! + * \file CCentJST_Flow.hpp + * \brief Delaration of numerics class CCentJST_Flow, the + * implementation is in the CCentJST_Flow.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "CCentBase_Flow.hpp" + +/*! + * \class CCentJST_Flow + * \brief Class for centered scheme - JST. + * \ingroup ConvDiscr + * \author F. Palacios + */ +class CCentJST_Flow : public CCentBase_Flow { + +private: + su2double Param_Kappa_2, Param_Kappa_4; /*!< \brief Artificial dissipation parameters. */ + su2double sc2, sc4; /*!< \brief Streching parameters. */ + su2double Epsilon_2, Epsilon_4; /*!< \brief Artificial dissipation coefficients. */ + + /*! + * \brief JST second and forth order dissipation terms. + * \param[in,out] val_residual - Pointer to the convective flux contribution to the residual. + * \param[in,out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[in,out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + */ + void DissipationTerm(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j); + + /*! + * \brief Set input variables for AD preaccumulation. + * \return true, as we will define inputs. + */ + bool SetPreaccInVars(void); + +public: + + /*! + * \brief Constructor of the class. + * \param[in] val_nDim - Number of dimension of the problem. + * \param[in] val_nVar - Number of variables of the problem. + * \param[in] config - Definition of the particular problem. + */ + CCentJST_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CCentJST_Flow(void); + +}; diff --git a/SU2_CFD/include/numerics/flow/convection_centered/CCentJST_KE_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_centered/CCentJST_KE_Flow.hpp new file mode 100644 index 000000000000..34f92df45669 --- /dev/null +++ b/SU2_CFD/include/numerics/flow/convection_centered/CCentJST_KE_Flow.hpp @@ -0,0 +1,75 @@ +/*! + * \file CCentJST_KE_Flow.hpp + * \brief Delaration of numerics class CCentJST_KE_Flow, the + * implementation is in the CCentJST_KE_Flow.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "CCentBase_Flow.hpp" + +/*! + * \class CCentJST_KE_Flow + * \brief Class for centered scheme - JST_KE (no 4th dissipation order term). + * \ingroup ConvDiscr + * \author F. Palacios + */ +class CCentJST_KE_Flow : public CCentBase_Flow { + +private: + su2double Param_Kappa_2; /*!< \brief Artificial dissipation parameter. */ + su2double sc2; /*!< \brief Streching parameter. */ + su2double Epsilon_2; /*!< \brief Artificial dissipation coefficient. */ + + /*! + * \brief JST_KE second order dissipation term. + * \param[in,out] val_residual - Pointer to the convective flux contribution to the residual. + * \param[in,out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[in,out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + */ + void DissipationTerm(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j); + + /*! + * \brief Set input variables for AD preaccumulation. + * \return true, as we will define inputs. + */ + bool SetPreaccInVars(void); + +public: + + /*! + * \brief Constructor of the class. + * \param[in] val_nDim - Number of dimension of the problem. + * \param[in] val_nVar - Number of variables of the problem. + * \param[in] config - Definition of the particular problem. + */ + CCentJST_KE_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CCentJST_KE_Flow(void); + +}; diff --git a/SU2_CFD/include/numerics/flow/convection_centered/CCentLaxInc_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_centered/CCentLaxInc_Flow.hpp new file mode 100644 index 000000000000..8a998fdb90ed --- /dev/null +++ b/SU2_CFD/include/numerics/flow/convection_centered/CCentLaxInc_Flow.hpp @@ -0,0 +1,88 @@ +/*! + * \file CCentLaxInc_Flow.hpp + * \brief Delaration of numerics class CCentLaxInc_Flow, the + * implementation is in the CCentLaxInc_Flow.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../../CNumerics.hpp" + +/*! + * \class CCentLaxInc_Flow + * \brief Class for computing the Lax-Friedrich centered scheme (modified with incompressible preconditioning). + * \ingroup ConvDiscr + * \author F. Palacios, T. Economon + */ +class CCentLaxInc_Flow : public CNumerics { +private: + unsigned short iDim, iVar, jVar; /*!< \brief Iteration on dimension and variables. */ + su2double *Diff_V, /*!< \brief Difference of primitive variables. */ + *Velocity_i, *Velocity_j, /*!< \brief Velocity at node 0 and 1. */ + *MeanVelocity, ProjVelocity_i, + ProjVelocity_j, /*!< \brief Mean and projected velocities. */ + *ProjFlux, /*!< \brief Projected inviscid flux tensor. */ + sq_vel_i, sq_vel_j, /*!< \brief Modulus of the velocity and the normal vector. */ + Temperature_i, Temperature_j, /*!< \brief Temperature at node 0 and 1. */ + MeanDensity, MeanPressure, + MeanBetaInc2, MeanEnthalpy, + MeanCp, MeanTemperature, /*!< \brief Mean values of primitive variables. */ + MeandRhodT, /*!< \brief Derivative of density w.r.t. temperature (variable density flows). */ + Param_p, Param_Kappa_0, /*!< \brief Artificial dissipation parameters. */ + Local_Lambda_i, Local_Lambda_j, + MeanLambda, /*!< \brief Local eingenvalues. */ + Phi_i, Phi_j, sc0, + StretchingFactor, /*!< \brief Streching parameters. */ + Epsilon_0; /*!< \brief Artificial dissipation values. */ + su2double **Precon; + bool implicit, /*!< \brief Implicit calculation. */ + dynamic_grid, /*!< \brief Modification for grid movement. */ + variable_density, /*!< \brief Variable density incompressible flows. */ + energy; /*!< \brief computation with the energy equation. */ + +public: + + /*! + * \brief Constructor of the class. + * \param[in] val_nDim - Number of dimension of the problem. + * \param[in] val_nVar - Number of variables of the problem. + * \param[in] config - Definition of the particular problem. + */ + CCentLaxInc_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CCentLaxInc_Flow(void); + + /*! + * \brief Compute the flow residual using a Lax method. + * \param[out] val_residual - Pointer to the residual array. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); +}; diff --git a/SU2_CFD/include/numerics/flow/convection_centered/CCentLax_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_centered/CCentLax_Flow.hpp new file mode 100644 index 000000000000..410a3355f8c0 --- /dev/null +++ b/SU2_CFD/include/numerics/flow/convection_centered/CCentLax_Flow.hpp @@ -0,0 +1,74 @@ +/*! + * \file CCentLax_Flow.hpp + * \brief Delaration of numerics class CCentLax_Flow, the + * implementation is in the CCentLax_Flow.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "CCentBase_Flow.hpp" + +/*! + * \class CCentLax_Flow + * \brief Class for computing the Lax-Friedrich centered scheme. + * \ingroup ConvDiscr + * \author F. Palacios + */ +class CCentLax_Flow : public CCentBase_Flow { +private: + su2double Param_Kappa_0; /*!< \brief Artificial dissipation parameter. */ + su2double sc0; /*!< \brief Streching parameter. */ + su2double Epsilon_0; /*!< \brief Artificial dissipation coefficient. */ + + /*! + * \brief Lax-Friedrich first order dissipation term. + * \param[in,out] val_residual - Pointer to the convective flux contribution to the residual. + * \param[in,out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[in,out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + */ + void DissipationTerm(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j); + + /*! + * \brief Set input variables for AD preaccumulation. + * \return true, as we will define inputs. + */ + bool SetPreaccInVars(void); + +public: + + /*! + * \brief Constructor of the class. + * \param[in] val_nDim - Number of dimension of the problem. + * \param[in] val_nVar - Number of variables of the problem. + * \param[in] config - Definition of the particular problem. + */ + CCentLax_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CCentLax_Flow(void); + +}; diff --git a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwAUSMPLUSUP2_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwAUSMPLUSUP2_Flow.hpp new file mode 100644 index 000000000000..9bf82919fde5 --- /dev/null +++ b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwAUSMPLUSUP2_Flow.hpp @@ -0,0 +1,66 @@ +/*! + * \file CUpwAUSMPLUSUP2_Flow.hpp + * \brief Delaration of numerics class CUpwAUSMPLUSUP2_Flow, the + * implementation is in the CUpwAUSMPLUSUP2_Flow.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "CUpwAUSMPLUS_SLAU_Base_Flow.hpp" + +/*! + * \class CUpwAUSMPLUSUP2_Flow + * \brief Class for solving an approximate Riemann AUSM+ -up. + * \ingroup ConvDiscr + * \author Amit Sachdeva + */ +class CUpwAUSMPLUSUP2_Flow : public CUpwAUSMPLUS_SLAU_Base_Flow { +private: + su2double Kp, sigma; + + /*! + * \brief Mass flux and pressure for the AUSM+up2 scheme. + * \param[in] config - Definition of the particular problem. + * \param[out] mdot - The mass flux. + * \param[out] pressure - The pressure at the control volume face. + */ + void ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure); + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CUpwAUSMPLUSUP2_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CUpwAUSMPLUSUP2_Flow(void); + +}; diff --git a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwAUSMPLUSUP_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwAUSMPLUSUP_Flow.hpp new file mode 100644 index 000000000000..f9ded3d836cc --- /dev/null +++ b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwAUSMPLUSUP_Flow.hpp @@ -0,0 +1,65 @@ +/*! + * \file CUpwAUSMPLUSUP_Flow.hpp + * \brief Delaration of numerics class CUpwAUSMPLUSUP_Flow, the + * implementation is in the CUpwAUSMPLUSUP_Flow.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "CUpwAUSMPLUS_SLAU_Base_Flow.hpp" + +/*! + * \class CUpwAUSMPLUSUP_Flow + * \brief Class for solving an approximate Riemann AUSM+ -up. + * \ingroup ConvDiscr + * \author Amit Sachdeva + */ +class CUpwAUSMPLUSUP_Flow : public CUpwAUSMPLUS_SLAU_Base_Flow { +private: + su2double Kp, Ku, sigma; + + /*! + * \brief Mass flux and pressure for the AUSM+up scheme. + * \param[in] config - Definition of the particular problem. + * \param[out] mdot - The mass flux. + * \param[out] pressure - The pressure at the control volume face. + */ + void ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure); + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CUpwAUSMPLUSUP_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CUpwAUSMPLUSUP_Flow(void); +}; diff --git a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwAUSMPLUS_SLAU_Base_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwAUSMPLUS_SLAU_Base_Flow.hpp new file mode 100644 index 000000000000..57d26196019c --- /dev/null +++ b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwAUSMPLUS_SLAU_Base_Flow.hpp @@ -0,0 +1,100 @@ +/*! + * \file CUpwAUSMPLUS_SLAU_Base_Flow.hpp + * \brief Delaration of numerics class CUpwAUSMPLUS_SLAU_Base_Flow, the + * implementation is in the CUpwAUSMPLUS_SLAU_Base_Flow.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../../CNumerics.hpp" + +/*! + * \class CUpwAUSMPLUS_SLAU_Base_Flow + * \brief Base class for AUSM+up(2) and SLAU(2) convective schemes. + * \ingroup ConvDiscr + * \author Amit Sachdeva + */ +class CUpwAUSMPLUS_SLAU_Base_Flow : public CNumerics { +protected: + bool implicit; + bool UseAccurateJacobian; + bool HasAnalyticalDerivatives; + su2double FinDiffStep; + + su2double MassFlux, DissFlux, Pressure; + su2double *Velocity_i, *Velocity_j; + su2double *psi_i, *psi_j; + su2double dmdot_dVi[6], dmdot_dVj[6], dpres_dVi[6], dpres_dVj[6]; + + /*--- Roe variables (for approximate Jacobian) ---*/ + su2double *Lambda, *Epsilon, *RoeVelocity, **P_Tensor, **invP_Tensor; + + /*! + * \brief Compute the mass flux and pressure based on Primitives_i/j, derived classes must implement this method. + * \note See the body of the (empty) default implementation for instructions on how to implement the method. + * \param[in] config - Definition of the particular problem. + * \param[out] mdot - The mass flux. + * \param[out] pressure - The pressure at the control volume face. + */ + virtual void ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure) = 0; + + /*! + * \brief Compute the flux Jacobians of the Roe scheme to use as an approximation. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + */ + void ApproximateJacobian(su2double **val_Jacobian_i, su2double **val_Jacobian_j); + + /*! + * \brief Compute the flux Jacobians using a mix of finite differences and manual differentiation. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + */ + void AccurateJacobian(CConfig *config, su2double **val_Jacobian_i, su2double **val_Jacobian_j); + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CUpwAUSMPLUS_SLAU_Base_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CUpwAUSMPLUS_SLAU_Base_Flow(void); + + /*! + * \brief Compute the AUSM+ and SLAU family of schemes. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); +}; diff --git a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwAUSM_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwAUSM_Flow.hpp new file mode 100644 index 000000000000..196f1040bb03 --- /dev/null +++ b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwAUSM_Flow.hpp @@ -0,0 +1,77 @@ +/*! + * \file CUpwAUSM_Flow.hpp + * \brief Delaration of numerics class CUpwAUSM_Flow, the + * implementation is in the CUpwAUSM_Flow.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../../CNumerics.hpp" + +/*! + * \class CUpwAUSM_Flow + * \brief Class for solving an approximate Riemann AUSM. + * \ingroup ConvDiscr + * \author F. Palacios + */ +class CUpwAUSM_Flow : public CNumerics { +private: + bool implicit; + su2double *Diff_U; + su2double *Velocity_i, *Velocity_j, *RoeVelocity; + su2double *ProjFlux_i, *ProjFlux_j; + su2double *delta_wave, *delta_vel; + su2double *Lambda, *Epsilon; + su2double **P_Tensor, **invP_Tensor; + su2double sq_vel, Proj_ModJac_Tensor_ij, Density_i, Energy_i, SoundSpeed_i, Pressure_i, Enthalpy_i, + Density_j, Energy_j, SoundSpeed_j, Pressure_j, Enthalpy_j, R, RoeDensity, RoeEnthalpy, RoeSoundSpeed, + ProjVelocity, ProjVelocity_i, ProjVelocity_j; + unsigned short iDim, iVar, jVar, kVar; + su2double mL, mR, mLP, mRM, mF, pLP, pRM, pF, Phi; + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CUpwAUSM_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CUpwAUSM_Flow(void); + + /*! + * \brief Compute the Roe's flux between two nodes i and j. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); +}; diff --git a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwCUSP_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwCUSP_Flow.hpp new file mode 100644 index 000000000000..3f77d81bd6f9 --- /dev/null +++ b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwCUSP_Flow.hpp @@ -0,0 +1,69 @@ +/*! + * \file CUpwCUSP_Flow.hpp + * \brief Delaration of numerics class CUpwCUSP_Flow, the + * implementation is in the CUpwCUSP_Flow.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../../CNumerics.hpp" + +/*! + * \class CUpwCUSP_Flow + * \brief Class for centered scheme - CUSP. + * \ingroup ConvDiscr + * \author F. Palacios + */ +class CUpwCUSP_Flow : public CNumerics { + +private: + su2double *Velocity_i, *Velocity_j, *ProjFlux_i, *ProjFlux_j; + bool implicit; + +public: + + /*! + * \brief Constructor of the class. + * \param[in] val_nDim - Number of dimension of the problem. + * \param[in] val_nVar - Number of variables of the problem. + * \param[in] config - Definition of the particular problem. + */ + CUpwCUSP_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CUpwCUSP_Flow(void); + + /*! + * \brief Compute the flow residual using a JST method. + * \param[out] val_residual - Pointer to the residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, + CConfig *config); +}; diff --git a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwFDSInc_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwFDSInc_Flow.hpp new file mode 100644 index 000000000000..ce3d233345b1 --- /dev/null +++ b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwFDSInc_Flow.hpp @@ -0,0 +1,81 @@ +/*! + * \file CUpwFDSInc_Flow.hpp + * \brief Delaration of numerics class CUpwFDSInc_Flow, the + * implementation is in the CUpwFDSInc_Flow.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../../CNumerics.hpp" + +/*! + * \class CUpwFDSInc_Flow + * \brief Class for solving a Flux Difference Splitting (FDS) upwind method for the incompressible flow equations. + * \ingroup ConvDiscr + * \author F. Palacios, T. Economon + */ +class CUpwFDSInc_Flow : public CNumerics { +private: + bool implicit, /*!< \brief Implicit calculation. */ + dynamic_grid, /*!< \brief Modification for grid movement. */ + variable_density, /*!< \brief Variable density incompressible flows. */ + energy; /*!< \brief computation with the energy equation. */ + su2double *Diff_V; + su2double *Velocity_i, *Velocity_j, *MeanVelocity; + su2double *ProjFlux_i, *ProjFlux_j; + su2double *Lambda, *Epsilon; + su2double **Precon, **invPrecon_A; + su2double Proj_ModJac_Tensor_ij, Pressure_i, + Pressure_j, ProjVelocity, + MeandRhodT, dRhodT_i, dRhodT_j, /*!< \brief Derivative of density w.r.t. temperature (variable density flows). */ + Temperature_i, Temperature_j, /*!< \brief Temperature at node 0 and 1. */ + MeanDensity, MeanPressure, MeanSoundSpeed, MeanBetaInc2, MeanEnthalpy, MeanCp, MeanTemperature; /*!< \brief Mean values of primitive variables. */ + unsigned short iDim, iVar, jVar, kVar; + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CUpwFDSInc_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CUpwFDSInc_Flow(void); + + /*! + * \brief Compute the upwind flux between two nodes i and j. + * \param[out] val_residual - Pointer to the residual array. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, + CConfig *config); +}; diff --git a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwGeneralHLLC_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwGeneralHLLC_Flow.hpp new file mode 100644 index 000000000000..4a2ac443476b --- /dev/null +++ b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwGeneralHLLC_Flow.hpp @@ -0,0 +1,90 @@ +/*! + * \file CUpwGeneralHLLC_Flow.hpp + * \brief Delaration of numerics class CUpwGeneralHLLC_Flow, the + * implementation is in the CUpwGeneralHLLC_Flow.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../../CNumerics.hpp" + +/*! + * \class CUpwGeneralHLLC_Flow + * \brief Class for solving an approximate Riemann HLLC. + * \ingroup ConvDiscr + * \author G. Gori, Politecnico di Milano + * \version 7.0.0 "Blackbird" + */ +class CUpwGeneralHLLC_Flow : public CNumerics { +private: + bool implicit, dynamic_grid; + unsigned short iDim, jDim, iVar, jVar; + + su2double *IntermediateState; + su2double *Velocity_i, *Velocity_j, *RoeVelocity; + + su2double sq_vel_i, Density_i, Energy_i, SoundSpeed_i, Pressure_i, Enthalpy_i, ProjVelocity_i, StaticEnthalpy_i, StaticEnergy_i; + su2double sq_vel_j, Density_j, Energy_j, SoundSpeed_j, Pressure_j, Enthalpy_j, ProjVelocity_j, StaticEnthalpy_j, StaticEnergy_j; + + su2double sq_velRoe, RoeDensity, RoeEnthalpy, RoeSoundSpeed, RoeProjVelocity, ProjInterfaceVel; + su2double Kappa_i, Kappa_j, Chi_i, Chi_j, RoeKappa, RoeChi, RoeKappaStaticEnthalpy; + + su2double sL, sR, sM, pStar, EStar, rhoSL, rhoSR, Rrho, kappa; + + su2double Omega, RHO, OmegaSM; + su2double *dSm_dU, *dPI_dU, *drhoStar_dU, *dpStar_dU, *dEStar_dU; + + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CUpwGeneralHLLC_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CUpwGeneralHLLC_Flow(void); + + /*! + + * \brief Compute the Roe's flux between two nodes i and j. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + + /*! + * \brief Compute the Average quantities for a general fluid flux between two nodes i and j. + * Using the approach of Vinokur and Montagne' + */ + void VinokurMontagne(); +}; diff --git a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwGeneralRoe_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwGeneralRoe_Flow.hpp new file mode 100644 index 000000000000..109634af5bb3 --- /dev/null +++ b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwGeneralRoe_Flow.hpp @@ -0,0 +1,90 @@ +/*! + * \file CUpwGeneralRoe_Flow.hpp + * \brief Delaration of numerics class CUpwGeneralRoe_Flow, the + * implementation is in the CUpwGeneralRoe_Flow.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../../CNumerics.hpp" + +/*! + * \class CUpwGeneralRoe_Flow + * \brief Class for solving an approximate Riemann solver of Roe for the flow equations for a general fluid model. + * \ingroup ConvDiscr + * \author S.Vitale, G.Gori, M.Pini + */ +class CUpwGeneralRoe_Flow : public CNumerics { +private: + + bool implicit, dynamic_grid; + + su2double *Diff_U; + su2double *Velocity_i, *Velocity_j, *RoeVelocity; + su2double *ProjFlux_i, *ProjFlux_j; + su2double *delta_wave, *delta_vel; + su2double *Lambda, *Epsilon, MaxLambda, Delta; + su2double **P_Tensor, **invP_Tensor; + su2double sq_vel, Proj_ModJac_Tensor_ij, Density_i, Energy_i, SoundSpeed_i, Pressure_i, Enthalpy_i, + + Density_j, Energy_j, SoundSpeed_j, Pressure_j, Enthalpy_j, R, RoeDensity, RoeEnthalpy, RoeSoundSpeed, RoeSoundSpeed2, + ProjVelocity, ProjVelocity_i, ProjVelocity_j, proj_delta_vel, delta_p, delta_rho, kappa; + unsigned short iDim, iVar, jVar, kVar; + + + su2double StaticEnthalpy_i, StaticEnergy_i, StaticEnthalpy_j, StaticEnergy_j, Kappa_i, Kappa_j, Chi_i, Chi_j, Velocity2_i, Velocity2_j; + su2double RoeKappa, RoeChi; + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CUpwGeneralRoe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CUpwGeneralRoe_Flow(void); + + /*! + * \brief Compute the Roe's flux between two nodes i and j. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + + /*! + * \brief Compute the Average for a general fluid flux between two nodes i and j. + * Using the approach of Vinokur and Montagne' + */ + + void ComputeRoeAverage(); +}; diff --git a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwHLLC_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwHLLC_Flow.hpp new file mode 100644 index 000000000000..49e8e4c044a4 --- /dev/null +++ b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwHLLC_Flow.hpp @@ -0,0 +1,82 @@ +/*! + * \file CUpwHLLC_Flow.hpp + * \brief Delaration of numerics class CUpwHLLC_Flow, the + * implementation is in the CUpwHLLC_Flow.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../../CNumerics.hpp" + +/*! + * \class CUpwHLLC_Flow + * \brief Class for solving an approximate Riemann HLLC. + * \ingroup ConvDiscr + * \author G. Gori, Politecnico di Milano + * \version 7.0.0 "Blackbird" + */ +class CUpwHLLC_Flow : public CNumerics { +private: + bool implicit, dynamic_grid; + unsigned short iDim, jDim, iVar, jVar; + + su2double *IntermediateState; + su2double *Velocity_i, *Velocity_j, *RoeVelocity; + + su2double sq_vel_i, Density_i, Energy_i, SoundSpeed_i, Pressure_i, Enthalpy_i, ProjVelocity_i; + su2double sq_vel_j, Density_j, Energy_j, SoundSpeed_j, Pressure_j, Enthalpy_j, ProjVelocity_j; + + su2double sq_velRoe, RoeDensity, RoeEnthalpy, RoeSoundSpeed, RoeProjVelocity, ProjInterfaceVel; + + su2double sL, sR, sM, pStar, EStar, rhoSL, rhoSR, Rrho, kappa; + + su2double Omega, RHO, OmegaSM; + su2double *dSm_dU, *dPI_dU, *drhoStar_dU, *dpStar_dU, *dEStar_dU; + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CUpwHLLC_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CUpwHLLC_Flow(void); + + /*! + * \brief Compute the Roe's flux between two nodes i and j. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + +}; diff --git a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwL2Roe_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwL2Roe_Flow.hpp new file mode 100644 index 000000000000..9e1fcca2b74d --- /dev/null +++ b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwL2Roe_Flow.hpp @@ -0,0 +1,64 @@ +/*! + * \file CUpwL2Roe_Flow.hpp + * \brief Delaration of numerics class CUpwL2Roe_Flow, the + * implementation is in the CUpwL2Roe_Flow.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "CUpwRoeBase_Flow.hpp" + +/*! + * \class CUpwL2Roe_Flow + * \brief Class for solving an approximate Riemann solver of L2Roe for the flow equations. + * \ingroup ConvDiscr + * \author E. Molina, A. Bueno, F. Palacios + * \version 7.0.0 "Blackbird" + */ +class CUpwL2Roe_Flow : public CUpwRoeBase_Flow { +private: + /*! + * \brief Add L^2 Roe dissipation to the flux (low-Mach scheme). + * \param[out] val_residual - Convective flux. + * \param[out] val_Jacobian_i - Flux Jacobian wrt node i conservatives (implicit computation). + * \param[out] val_Jacobian_j - Flux Jacobian wrt node j conservatives (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + +public: + /*! + * \brief Constructor of the class. + * \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. + */ + CUpwL2Roe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CUpwL2Roe_Flow(void); +}; diff --git a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwLMRoe_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwLMRoe_Flow.hpp new file mode 100644 index 000000000000..157a8a44b1f8 --- /dev/null +++ b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwLMRoe_Flow.hpp @@ -0,0 +1,64 @@ +/*! + * \file CUpwLMRoe_Flow.hpp + * \brief Delaration of numerics class CUpwLMRoe_Flow, the + * implementation is in the CUpwLMRoe_Flow.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "CUpwRoeBase_Flow.hpp" + +/*! + * \class CUpwLMRoe_Flow + * \brief Class for solving an approximate Riemann solver of LMRoe for the flow equations. + * \ingroup ConvDiscr + * \author E. Molina, A. Bueno, F. Palacios + * \version 7.0.0 "Blackbird" + */ +class CUpwLMRoe_Flow : public CUpwRoeBase_Flow { +private: + /*! + * \brief Add LMRoe dissipation to the flux (low-Mach scheme). + * \param[out] val_residual - Convective flux. + * \param[out] val_Jacobian_i - Flux Jacobian wrt node i conservatives (implicit computation). + * \param[out] val_Jacobian_j - Flux Jacobian wrt node j conservatives (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + +public: + /*! + * \brief Constructor of the class. + * \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. + */ + CUpwLMRoe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CUpwLMRoe_Flow(void); +}; diff --git a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwMSW_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwMSW_Flow.hpp new file mode 100644 index 000000000000..6ccc8137ce2b --- /dev/null +++ b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwMSW_Flow.hpp @@ -0,0 +1,75 @@ +/*! + * \file CUpwMSW_Flow.hpp + * \brief Delaration of numerics class CUpwMSW_Flow, the + * implementation is in the CUpwMSW_Flow.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../../CNumerics.hpp" + +/*! + * \class CUpwMSW_Flow + * \brief Class for solving a flux-vector splitting method by Steger & Warming, modified version. + * \ingroup ConvDiscr + * \author S. Copeland + */ +class CUpwMSW_Flow : public CNumerics { +private: + bool implicit; + su2double *Diff_U; + su2double *u_i, *u_j, *ust_i, *ust_j; + su2double *Fc_i, *Fc_j; + su2double *Lambda_i, *Lambda_j; + su2double rhos_i, rhos_j; + su2double *Ust_i, *Ust_j, *Vst_i, *Vst_j, *Velst_i, *Velst_j; + su2double **P_Tensor, **invP_Tensor; + unsigned short nPrimVar, nVar, nDim; + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CUpwMSW_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CUpwMSW_Flow(void); + + /*! + * \brief Compute the Roe's flux between two nodes i and j. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + +}; diff --git a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwRoeBase_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwRoeBase_Flow.hpp new file mode 100644 index 000000000000..d861e37cc5c9 --- /dev/null +++ b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwRoeBase_Flow.hpp @@ -0,0 +1,80 @@ +/*! + * \file CUpwRoeBase_Flow.hpp + * \brief Delaration of numerics class CUpwRoeBase_Flow, the + * implementation is in the CUpwRoeBase_Flow.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../../CNumerics.hpp" + +/*! + * \class CUpwRoeBase_Flow + * \brief Intermediate base class for Roe schemes on ideal gas. + * \ingroup ConvDiscr + * \author A. Bueno, F. Palacios + */ +class CUpwRoeBase_Flow : public CNumerics { +protected: + bool implicit, dynamic_grid, roe_low_dissipation; + su2double *Velocity_i, *Velocity_j, *ProjFlux_i, *ProjFlux_j, *Conservatives_i, *Conservatives_j; + su2double *Diff_U, *Lambda, **P_Tensor, **invP_Tensor; + su2double *RoeVelocity, RoeDensity, RoeEnthalpy, RoeSoundSpeed, ProjVelocity, RoeSoundSpeed2, kappa; + + /*! + * \brief Derived classes must specialize this method to add the specifics of the scheme they implement (e.g. low-Mach precond.). + * \param[out] val_residual - Convective flux. + * \param[out] val_Jacobian_i - Flux Jacobian wrt node i conservatives (implicit computation). + * \param[out] val_Jacobian_j - Flux Jacobian wrt node j conservatives (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + virtual void FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) = 0; + +public: + + /*! + * \brief Constructor of the class. + * \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. + * \param[in] val_low_dissipation - Use a low dissipation formulation. + */ + CUpwRoeBase_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, bool val_low_dissipation); + + /*! + * \brief Destructor of the class. + */ + ~CUpwRoeBase_Flow(void); + + /*! + * \brief Compute the flux from node i to node j, part common to most Roe schemes. + * \param[out] val_residual - Convective flux. + * \param[out] val_Jacobian_i - Flux Jacobian wrt node i conservatives (implicit computation). + * \param[out] val_Jacobian_j - Flux Jacobian wrt node j conservatives (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + +}; diff --git a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwRoe_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwRoe_Flow.hpp new file mode 100644 index 000000000000..a4113f0627b9 --- /dev/null +++ b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwRoe_Flow.hpp @@ -0,0 +1,66 @@ +/*! + * \file CUpwRoe_Flow.hpp + * \brief Delaration of numerics class CUpwRoe_Flow, the + * implementation is in the CUpwRoe_Flow.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "CUpwRoeBase_Flow.hpp" + +/*! + * \class CUpwRoe_Flow + * \brief Class for solving an approximate Riemann solver of Roe for the flow equations. + * \ingroup ConvDiscr + * \author A. Bueno, F. Palacios + */ +class CUpwRoe_Flow : public CUpwRoeBase_Flow { +private: + /*! + * \brief Add standard Roe dissipation to the flux. + * \param[out] val_residual - Convective flux. + * \param[out] val_Jacobian_i - Flux Jacobian wrt node i conservatives (implicit computation). + * \param[out] val_Jacobian_j - Flux Jacobian wrt node j conservatives (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + +public: + + /*! + * \brief Constructor of the class. + * \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. + * \param[in] val_low_dissipation - Use a low dissipation formulation. + */ + CUpwRoe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, bool val_low_dissipation); + + /*! + * \brief Destructor of the class. + */ + ~CUpwRoe_Flow(void); + +}; diff --git a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwSLAU_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwSLAU_Flow.hpp new file mode 100644 index 000000000000..0ac781ec818b --- /dev/null +++ b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwSLAU_Flow.hpp @@ -0,0 +1,90 @@ +/*! + * \file CUpwSLAU_Flow.hpp + * \brief Delaration of numerics class CUpwSLAU_Flow, the + * implementation is in the CUpwSLAU_Flow.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "CUpwAUSMPLUS_SLAU_Base_Flow.hpp" + +/*! + * \class CUpwSLAU_Flow + * \brief Class for solving the Low-Dissipation AUSM. + * \ingroup ConvDiscr + * \author E. Molina + */ +class CUpwSLAU_Flow : public CUpwAUSMPLUS_SLAU_Base_Flow { +protected: + bool slau_low_diss; + bool slau2; + + /*! + * \brief Mass flux and pressure for the SLAU and SLAU2 schemes. + * \param[in] config - Definition of the particular problem. + * \param[out] mdot - The mass flux. + * \param[out] pressure - The pressure at the control volume face. + */ + void ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure); + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CUpwSLAU_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, bool val_low_dissipation); + + /*! + * \brief Destructor of the class. + */ + ~CUpwSLAU_Flow(void); + +}; + +/*! + * \class CUpwSLAU2_Flow + * \brief Class for solving the Simple Low-Dissipation AUSM 2. + * \ingroup ConvDiscr + * \author E. Molina + */ +class CUpwSLAU2_Flow : public CUpwSLAU_Flow { +public: + /*! + * \brief Constructor of the class. + * \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. + */ + CUpwSLAU2_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, bool val_low_dissipation); + + /*! + * \brief Destructor of the class. + */ + ~CUpwSLAU2_Flow(void); + +}; diff --git a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwTurkel_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwTurkel_Flow.hpp new file mode 100644 index 000000000000..642291e7c499 --- /dev/null +++ b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwTurkel_Flow.hpp @@ -0,0 +1,80 @@ +/*! + * \file CUpwTurkel_Flow.hpp + * \brief Delaration of numerics class CUpwTurkel_Flow, the + * implementation is in the CUpwTurkel_Flow.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../../CNumerics.hpp" + +/*! + * \class CUpwTurkel_Flow + * \brief Class for solving an approximate Riemann solver of Roe with Turkel Preconditioning for the flow equations. + * \ingroup ConvDiscr + * \author A. K. Lonkar + */ +class CUpwTurkel_Flow : public CNumerics { +private: + bool implicit, dynamic_grid; + su2double *Diff_U; + su2double *Velocity_i, *Velocity_j, *RoeVelocity; + su2double *ProjFlux_i, *ProjFlux_j; + su2double *Lambda, *Epsilon; + su2double **absPeJac, **invRinvPe, **R_Tensor, **Matrix, **Art_Visc; + su2double sq_vel, Density_i, Energy_i, SoundSpeed_i, Pressure_i, Enthalpy_i, + Density_j, Energy_j, SoundSpeed_j, Pressure_j, Enthalpy_j, R, RoePressure, RoeDensity, RoeEnthalpy, RoeSoundSpeed, + ProjVelocity, ProjVelocity_i, ProjVelocity_j; + unsigned short iDim, iVar, jVar, kVar; + su2double Beta, Beta_min, Beta_max; + su2double r_hat, s_hat, t_hat, rhoB2a2, sqr_one_m_Betasqr_Lam1; + su2double Beta2, one_m_Betasqr, one_p_Betasqr, sqr_two_Beta_c_Area; + su2double local_Mach; + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CUpwTurkel_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CUpwTurkel_Flow(void); + + /*! + * \brief Compute the Roe's flux between two nodes i and j. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + +}; diff --git a/SU2_CFD/include/numerics/flow/diffusion/CAvgGradInc_Flow.hpp b/SU2_CFD/include/numerics/flow/diffusion/CAvgGradInc_Flow.hpp new file mode 100644 index 000000000000..68f0fcb4a8ac --- /dev/null +++ b/SU2_CFD/include/numerics/flow/diffusion/CAvgGradInc_Flow.hpp @@ -0,0 +1,97 @@ +/*! + * \file CAvgGradInc_Flow.hpp + * \brief Delaration of numerics class CAvgGradInc_Flow, the + * implementation is in the CAvgGradInc_Flow.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "CAvgGrad_Base.hpp" + +/*! + * \class CAvgGradInc_Flow + * \brief Class for computing viscous term using an average of gradients. + * \ingroup ViscDiscr + * \author A. Bueno, F. Palacios, T. Economon + */ +class CAvgGradInc_Flow : public CAvgGrad_Base { +private: + su2double Mean_Thermal_Conductivity; /*!< \brief Mean value of the effective thermal conductivity. */ + bool energy; /*!< \brief computation with the energy equation. */ + + /* + * \brief Compute the projection of the viscous fluxes into a direction + * + * The viscous + turbulent stress tensor must be calculated before calling + * this function. + * + * \param[in] val_gradprimvar - Gradient of the primitive variables. + * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. + * \param[in] val_thermal_conductivity - Thermal conductivity. + */ + void GetViscousIncProjFlux(const su2double* const *val_gradprimvar, + const su2double *val_normal, + su2double val_thermal_conductivity); + + /*! + * \brief Compute the projection of the viscous Jacobian matrices. + * + * The Jacobian of the stress tensor must be calculated before calling + * this function. + * + * \param[in] val_dS - Area of the face between two nodes. + * \param[out] val_Proj_Jac_Tensor_i - Pointer to the projected viscous Jacobian at point i. + * \param[out] val_Proj_Jac_Tensor_j - Pointer to the projected viscous Jacobian at point j. + */ + void GetViscousIncProjJacs(su2double val_dS, + su2double **val_Proj_Jac_Tensor_i, + su2double **val_Proj_Jac_Tensor_j); + +public: + + /*! + * \brief Constructor of the class. + * \param[in] val_nDim - Number of dimension of the problem. + * \param[in] val_nVar - Number of variables of the problem. + * \param[in] val_correct_grad - Apply a correction to the gradient + * \param[in] config - Definition of the particular problem. + */ + CAvgGradInc_Flow(unsigned short val_nDim, unsigned short val_nVar, + bool val_correct_grad, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CAvgGradInc_Flow(void); + + /*! + * \brief Compute the viscous flow residual using an average of gradients. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); +}; diff --git a/SU2_CFD/include/numerics/flow/diffusion/CAvgGrad_Base.hpp b/SU2_CFD/include/numerics/flow/diffusion/CAvgGrad_Base.hpp new file mode 100644 index 000000000000..d72243085269 --- /dev/null +++ b/SU2_CFD/include/numerics/flow/diffusion/CAvgGrad_Base.hpp @@ -0,0 +1,255 @@ +/*! + * \file CAvgGrad_Base.hpp + * \brief Delaration of numerics class CAvgGrad_Base, the + * implementation is in the CAvgGrad_Base.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../../CNumerics.hpp" + +/*! + * \class CAvgGrad_Base + * \brief A base class for computing viscous terms using an average of gradients. + * \details This is the base class for the numerics classes that compute the + * viscous fluxes for the flow solvers (i.e. compressible or incompressible + * Navier Stokes). The actual numerics classes derive from this class. + * This class is used to share functions and variables that are common to all + * of the flow viscous numerics. For example, the turbulent stress tensor + * is computed identically for all three derived classes. + * \ingroup ViscDiscr + * \author C. Pederson, A. Bueno, F. Palacios, T. Economon + */ +class CAvgGrad_Base : public CNumerics { +protected: + const unsigned short nPrimVar; /*!< \brief The size of the primitive variable array used in the numerics class. */ + const bool correct_gradient; /*!< \brief Apply a correction to the gradient term */ + bool implicit; /*!< \brief Implicit calculus. */ + su2double *heat_flux_vector, /*!< \brief Flux of total energy due to molecular and turbulent diffusion */ + *heat_flux_jac_i, /*!< \brief Jacobian of the molecular + turbulent heat flux vector, projected onto the normal vector. */ + **tau_jacobian_i; /*!< \brief Jacobian of the viscous + turbulent stress tensor, projected onto the normal vector. */ + su2double *Mean_PrimVar, /*!< \brief Mean primitive variables. */ + *PrimVar_i, *PrimVar_j, /*!< \brief Primitives variables at point i and 1. */ + **Mean_GradPrimVar, /*!< \brief Mean value of the gradient. */ + Mean_Laminar_Viscosity, /*!< \brief Mean value of the viscosity. */ + Mean_Eddy_Viscosity, /*!< \brief Mean value of the eddy viscosity. */ + Mean_turb_ke, /*!< \brief Mean value of the turbulent kinetic energy. */ + Mean_TauWall, /*!< \brief Mean wall shear stress (wall functions). */ + TauWall_i, TauWall_j, /*!< \brief Wall shear stress at point i and j (wall functions). */ + dist_ij_2, /*!< \brief Length of the edge and face, squared */ + *Proj_Mean_GradPrimVar_Edge, /*!< \brief Inner product of the Mean gradient and the edge vector. */ + *Edge_Vector; /*!< \brief Vector from point i to point j. */ + + + + /*! + * \brief Add a correction using a Quadratic Constitutive Relation + * + * This function requires that the stress tensor already be + * computed using \ref GetStressTensor + * + * See: Spalart, P. R., "Strategies for Turbulence Modelling and + * Simulation," International Journal of Heat and Fluid Flow, Vol. 21, + * 2000, pp. 252-263 + * + * \param[in] val_gradprimvar + */ + void AddQCR(const su2double* const *val_gradprimvar); + + /*! + * \brief Scale the stress tensor using a predefined wall stress. + * + * This function requires that the stress tensor already be + * computed using \ref GetStressTensor + * + * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. + * \param[in] val_tau_wall - The wall stress + */ + void AddTauWall(const su2double *val_normal, + su2double val_tau_wall); + + /** + * \brief Calculate the Jacobian of the viscous + turbulent stress tensor + * + * This function is intended only for the compressible flow solver. + * This Jacobian is projected onto the normal vector, so it is of dimension + * [nDim][nVar] + * + * \param[in] val_Mean_PrimVar - Mean value of the primitive variables. + * \param[in] val_laminar_viscosity - Value of the laminar viscosity. + * \param[in] val_eddy_viscosity - Value of the eddy viscosity. + * \param[in] val_dist_ij - Distance between the points. + * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. + */ + void SetTauJacobian(const su2double* val_Mean_PrimVar, + su2double val_laminar_viscosity, + su2double val_eddy_viscosity, + su2double val_dist_ij, + const su2double *val_normal); + + + /** + * \brief Calculate the Jacobian of the viscous and turbulent stress tensor + * + * This function is intended only for the incompressible flow solver. + * This Jacobian is projected onto the normal vector, so it is of dimension + * [nDim][nVar] + * + * \param[in] val_laminar_viscosity - Value of the laminar viscosity. + * \param[in] val_eddy_viscosity - Value of the eddy viscosity. + * \param[in] val_dist_ij - Distance between the points. + * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. + */ + void SetIncTauJacobian(su2double val_laminar_viscosity, + su2double val_eddy_viscosity, + su2double val_dist_ij, + const su2double *val_normal); + + /*! + * \brief Compute the projection of the viscous fluxes into a direction. + * + * The heat flux vector and the stress tensor must be calculated before + * calling this function. + * + * \param[in] val_primvar - Primitive variables. + * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. + */ + void GetViscousProjFlux(const su2double *val_primvar, + const su2double *val_normal); + + /*! + * \brief TSL-Approximation of Viscous NS Jacobians. + * + * The Jacobians of the heat flux vector and the stress tensor must be + * calculated before calling this function. + * + * \param[in] val_Mean_PrimVar - Mean value of the primitive variables. + * \param[in] val_dS - Area of the face between two nodes. + * \param[in] val_Proj_Visc_Flux - Pointer to the projected viscous flux. + * \param[out] val_Proj_Jac_Tensor_i - Pointer to the projected viscous Jacobian at point i. + * \param[out] val_Proj_Jac_Tensor_j - Pointer to the projected viscous Jacobian at point j. + */ + void GetViscousProjJacs(const su2double *val_Mean_PrimVar, + su2double val_dS, + const su2double *val_Proj_Visc_Flux, + su2double **val_Proj_Jac_Tensor_i, + su2double **val_Proj_Jac_Tensor_j); + + /*! + * \brief Apply a correction to the gradient to reduce the truncation error + * + * \param[in] val_PrimVar_i - Primitive variables at point i + * \param[in] val_PrimVar_j - Primitive variables at point j + * \param[in] val_edge_vector - The vector between points i and j + * \param[in] val_dist_ij_2 - The distance between points i and j, squared + * \param[in] val_nPrimVar - The number of primitive variables + */ + void CorrectGradient(su2double** GradPrimVar, + const su2double* val_PrimVar_i, + const su2double* val_PrimVar_j, + const su2double* val_edge_vector, + su2double val_dist_ij_2, + const unsigned short val_nPrimVar); + + /*! + * \brief Initialize the Reynolds Stress Matrix + * \param[in] turb_ke turbulent kinetic energy of node + */ + void SetReynoldsStressMatrix(su2double turb_ke); + + /*! + * \brief Perturb the Reynolds stress tensor based on parameters + * \param[in] turb_ke: turbulent kinetic energy of the noce + * \param[in] Eig_Val_Comp: Defines type of eigenspace perturbation + * \param[in] beta_delta: Defines the amount of eigenvalue perturbation + */ + void SetPerturbedRSM(su2double turb_ke, CConfig *config); + + /*! + * \brief Get the mean rate of strain matrix based on velocity gradients + * \param[in] S_ij + */ + void GetMeanRateOfStrainMatrix(su2double **S_ij) const; + +public: + + /*! + * \brief Constructor of the class. + * \param[in] val_nDim - Number of dimension of the problem. + * \param[in] val_nVar - Number of variables of the problem. + * \param[in] val_nPrimVar - Number of primitive variables to use. + * \param[in] val_correct_grad - Apply a correction to the gradient + * \param[in] config - Definition of the particular problem. + */ + CAvgGrad_Base(unsigned short val_nDim, unsigned short val_nVar, + unsigned short val_nPrimVar, + bool val_correct_grad, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CAvgGrad_Base(); + + /*! + * \brief Set the value of the wall shear stress at point i and j (wall functions). + * \param[in] val_tauwall_i - Value of the wall shear stress at point i. + * \param[in] val_tauwall_j - Value of the wall shear stress at point j. + */ + inline void SetTauWall(su2double val_tauwall_i, su2double val_tauwall_j) override { + TauWall_i = val_tauwall_i; + TauWall_j = val_tauwall_j; + } + + /*! + * \brief Calculate the viscous + turbulent stress tensor + * \param[in] val_primvar - Primitive variables. + * \param[in] val_gradprimvar - Gradient of the primitive variables. + * \param[in] val_turb_ke - Turbulent kinetic energy + * \param[in] val_laminar_viscosity - Laminar viscosity. + * \param[in] val_eddy_viscosity - Eddy viscosity. + */ + void SetStressTensor(const su2double *val_primvar, + const su2double* const *val_gradprimvar, + su2double val_turb_ke, + su2double val_laminar_viscosity, + su2double val_eddy_viscosity); + + /*! + * \brief Get a component of the viscous stress tensor. + * + * \param[in] iDim - The first index + * \param[in] jDim - The second index + * \return The component of the viscous stress tensor at iDim, jDim + */ + inline su2double GetStressTensor(unsigned short iDim, unsigned short jDim) const { return tau[iDim][jDim];} + + /*! + * \brief Get a component of the heat flux vector. + * \param[in] iDim - The index of the component + * \return The component of the heat flux vector at iDim + */ + inline su2double GetHeatFluxVector(unsigned short iDim) const { return heat_flux_vector[iDim]; } + +}; diff --git a/SU2_CFD/include/numerics/flow/diffusion/CAvgGrad_Flow.hpp b/SU2_CFD/include/numerics/flow/diffusion/CAvgGrad_Flow.hpp new file mode 100644 index 000000000000..cbda63710060 --- /dev/null +++ b/SU2_CFD/include/numerics/flow/diffusion/CAvgGrad_Flow.hpp @@ -0,0 +1,94 @@ +/*! + * \file CAvgGrad_Flow.hpp + * \brief Delaration of numerics class CAvgGrad_Flow, the + * implementation is in the CAvgGrad_Flow.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "CAvgGrad_Base.hpp" + +/*! + * \class CAvgGrad_Flow + * \brief Class for computing viscous term using the average of gradients. + * \ingroup ViscDiscr + * \author A. Bueno, and F. Palacios + */ +class CAvgGrad_Flow : public CAvgGrad_Base { +public: + + /*! + * \brief Constructor of the class. + * \param[in] val_nDim - Number of dimension of the problem. + * \param[in] val_nVar - Number of variables of the problem. + * \param[in] val_correct_grad - Apply a correction to the gradient + * \param[in] config - Definition of the particular problem. + */ + CAvgGrad_Flow(unsigned short val_nDim, unsigned short val_nVar, + bool val_correct_grad, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CAvgGrad_Flow(void); + + /*! + * \brief Compute the viscous flow residual using an average of gradients. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + + /*! + * \brief Compute the heat flux due to molecular and turbulent diffusivity + * \param[in] val_gradprimvar - Gradient of the primitive variables. + * \param[in] val_laminar_viscosity - Laminar viscosity. + * \param[in] val_eddy_viscosity - Eddy viscosity. + */ + void SetHeatFluxVector(const su2double* const *val_gradprimvar, + su2double val_laminar_viscosity, + su2double val_eddy_viscosity); + + /*! + * \brief Compute the Jacobian of the heat flux vector + * + * This Jacobian is projected onto the normal vector, so it is of + * dimension nVar. + * + * \param[in] val_Mean_PrimVar - Mean value of the primitive variables. + * \param[in] val_gradprimvar - Mean value of the gradient of the primitive variables. + * \param[in] val_laminar_viscosity - Value of the laminar viscosity. + * \param[in] val_eddy_viscosity - Value of the eddy viscosity. + * \param[in] val_dist_ij - Distance between the points. + * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. + */ + void SetHeatFluxJacobian(const su2double *val_Mean_PrimVar, + su2double val_laminar_viscosity, + su2double val_eddy_viscosity, + su2double val_dist_ij, + const su2double *val_normal); +}; diff --git a/SU2_CFD/include/numerics/flow/diffusion/CGeneralAvgGrad_Flow.hpp b/SU2_CFD/include/numerics/flow/diffusion/CGeneralAvgGrad_Flow.hpp new file mode 100644 index 000000000000..3b154ef93185 --- /dev/null +++ b/SU2_CFD/include/numerics/flow/diffusion/CGeneralAvgGrad_Flow.hpp @@ -0,0 +1,103 @@ +/*! + * \file CGeneralAvgGrad_Flow.hpp + * \brief Delaration of numerics class CGeneralAvgGrad_Flow, the + * implementation is in the CGeneralAvgGrad_Flow.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "CAvgGrad_Base.hpp" + +/*! + * \class CGeneralAvgGrad_Flow + * \brief Class for computing viscous term using the average of gradients. + * \ingroup ViscDiscr + * \author M.Pini, S. Vitale + */ +class CGeneralAvgGrad_Flow : public CAvgGrad_Base { +private: + su2double *Mean_SecVar, /*!< \brief Mean secondary variables. */ + Mean_Thermal_Conductivity, /*!< \brief Mean value of the thermal conductivity. */ + Mean_Cp; /*!< \brief Mean value of the Cp. */ + + /*! + * \brief Compute the heat flux due to molecular and turbulent diffusivity + * \param[in] val_gradprimvar - Gradient of the primitive variables. + * \param[in] val_laminar_viscosity - Laminar viscosity. + * \param[in] val_eddy_viscosity - Eddy viscosity. + * \param[in] val_thermal_conductivity - Thermal Conductivity. + * \param[in] val_heat_capacity_cp - Heat Capacity at constant pressure. + */ + void SetHeatFluxVector(const su2double* const *val_gradprimvar, + su2double val_laminar_viscosity, + su2double val_eddy_viscosity, + su2double val_thermal_conductivity, + su2double val_heat_capacity_cp); + + /*! + * \brief Compute the Jacobian of the heat flux vector + * + * This Jacobian is projected onto the normal vector, so it is of + * dimension nVar. + * + * \param[in] val_Mean_PrimVar - Mean value of the primitive variables. + * \param[in] val_Mean_SecVar - Mean value of the secondary variables. + * \param[in] val_eddy_viscosity - Value of the eddy viscosity. + * \param[in] val_thermal_conductivity - Value of the thermal conductivity. + * \param[in] val_heat_capacity_cp - Value of the specific heat at constant pressure. + * \param[in] val_dist_ij - Distance between the points. + */ + void SetHeatFluxJacobian(const su2double *val_Mean_PrimVar, + const su2double *val_Mean_SecVar, + su2double val_eddy_viscosity, + su2double val_thermal_conductivity, + su2double val_heat_capacity_cp, + su2double val_dist_ij); + +public: + + /*! + * \brief Constructor of the class. + * \param[in] val_nDim - Number of dimension of the problem. + * \param[in] val_nVar - Number of variables of the problem. + * \param[in] val_correct_grad - Apply a correction to the gradient + * \param[in] config - Definition of the particular problem. + */ + CGeneralAvgGrad_Flow(unsigned short val_nDim, unsigned short val_nVar, bool val_correct_grad, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CGeneralAvgGrad_Flow(void); + + /*! + * \brief Compute the viscous flow residual using an average of gradients. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); +}; diff --git a/SU2_CFD/include/numerics/flow/sources/CSourceAxisymmetric_Flow.hpp b/SU2_CFD/include/numerics/flow/sources/CSourceAxisymmetric_Flow.hpp new file mode 100644 index 000000000000..75ab05033a1d --- /dev/null +++ b/SU2_CFD/include/numerics/flow/sources/CSourceAxisymmetric_Flow.hpp @@ -0,0 +1,62 @@ +/*! + * \file CSourceAxisymmetric_Flow.hpp + * \brief Delaration of numerics class CSourceAxisymmetric_Flow, the + * implementation is in the CSourceAxisymmetric_Flow.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../../CNumerics.hpp" + +/*! + * \class CSourceAxisymmetric_Flow + * \brief Class for source term for solving axisymmetric problems. + * \ingroup SourceDiscr + * \author F. Palacios + */ +class CSourceAxisymmetric_Flow : public CNumerics { +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CSourceAxisymmetric_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CSourceAxisymmetric_Flow(void); + + /*! + * \brief Residual of the rotational frame source term. + * \param[out] val_residual - Pointer to the total residual. + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **Jacobian_i, CConfig *config); + +}; diff --git a/SU2_CFD/include/numerics/flow/sources/CSourceBodyForce.hpp b/SU2_CFD/include/numerics/flow/sources/CSourceBodyForce.hpp new file mode 100644 index 000000000000..4a49c43f2c20 --- /dev/null +++ b/SU2_CFD/include/numerics/flow/sources/CSourceBodyForce.hpp @@ -0,0 +1,63 @@ +/*! + * \file CSourceBodyForce.hpp + * \brief Delaration of numerics class CSourceBodyForce, the + * implementation is in the CSourceBodyForce.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../../CNumerics.hpp" + +/*! + * \class CSourceBodyForce + * \brief Class for the source term integration of a body force. + * \ingroup SourceDiscr + * \author T. Economon + */ +class CSourceBodyForce : public CNumerics { + su2double *Body_Force_Vector; + +public: + + /*! + * \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. + */ + CSourceBodyForce(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CSourceBodyForce(void); + + /*! + * \brief Source term integration for a body force. + * \param[out] val_residual - Pointer to the residual vector. + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, CConfig *config); + +}; diff --git a/SU2_CFD/include/numerics/flow/sources/CSourceBoussinesq.hpp b/SU2_CFD/include/numerics/flow/sources/CSourceBoussinesq.hpp new file mode 100644 index 000000000000..6ad6751f9512 --- /dev/null +++ b/SU2_CFD/include/numerics/flow/sources/CSourceBoussinesq.hpp @@ -0,0 +1,64 @@ +/*! + * \file CSourceBoussinesq.hpp + * \brief Delaration of numerics class CSourceBoussinesq, the + * implementation is in the CSourceBoussinesq.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../../CNumerics.hpp" + +/*! + * \class CSourceBoussinesq + * \brief Class for the source term integration of the Boussinesq approximation for incompressible flow. + * \ingroup SourceDiscr + * \author T. Economon + * \version 7.0.0 "Blackbird" + */ +class CSourceBoussinesq : public CNumerics { + su2double *Gravity_Vector; + +public: + + /*! + * \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. + */ + CSourceBoussinesq(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CSourceBoussinesq(void); + + /*! + * \brief Source term integration for the Boussinesq approximation. + * \param[out] val_residual - Pointer to the residual vector. + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, CConfig *config); + +}; diff --git a/SU2_CFD/include/numerics/flow/sources/CSourceGravity.hpp b/SU2_CFD/include/numerics/flow/sources/CSourceGravity.hpp new file mode 100644 index 000000000000..5edd870cec20 --- /dev/null +++ b/SU2_CFD/include/numerics/flow/sources/CSourceGravity.hpp @@ -0,0 +1,61 @@ +/*! + * \file CSourceGravity.hpp + * \brief Delaration of numerics class CSourceGravity, the + * implementation is in the CSourceGravity.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../../CNumerics.hpp" + +/*! + * \class CSourceGravity + * \brief Class for the source term integration of the gravity force. + * \ingroup SourceDiscr + * \author F. Palacios + */ +class CSourceGravity : public CNumerics { + +public: + + /*! + * \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. + */ + CSourceGravity(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CSourceGravity(void); + + /*! + * \brief Source term integration for the poissonal potential. + * \param[out] val_residual - Pointer to the total residual. + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, CConfig *config); +}; diff --git a/SU2_CFD/include/numerics/flow/sources/CSourceIncAxisymmetric_Flow.hpp b/SU2_CFD/include/numerics/flow/sources/CSourceIncAxisymmetric_Flow.hpp new file mode 100644 index 000000000000..caf38ae01b12 --- /dev/null +++ b/SU2_CFD/include/numerics/flow/sources/CSourceIncAxisymmetric_Flow.hpp @@ -0,0 +1,66 @@ +/*! + * \file CSourceIncAxisymmetric_Flow.hpp + * \brief Delaration of numerics class CSourceIncAxisymmetric_Flow, the + * implementation is in the CSourceIncAxisymmetric_Flow.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../../CNumerics.hpp" + +/*! + * \class CSourceIncAxisymmetric_Flow + * \brief Class for source term for solving incompressible axisymmetric problems. + * \ingroup SourceDiscr + * \author T. Economon + */ +class CSourceIncAxisymmetric_Flow : public CNumerics { + bool implicit, /*!< \brief Implicit calculation. */ + viscous, /*!< \brief Viscous incompressible flows. */ + energy; /*!< \brief computation with the energy equation. */ + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CSourceIncAxisymmetric_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CSourceIncAxisymmetric_Flow(void); + + /*! + * \brief Residual of the rotational frame source term. + * \param[out] val_residual - Pointer to the total residual. + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **Jacobian_i, CConfig *config); + +}; diff --git a/SU2_CFD/include/numerics/flow/sources/CSourceIncBodyForce.hpp b/SU2_CFD/include/numerics/flow/sources/CSourceIncBodyForce.hpp new file mode 100644 index 000000000000..d392cd75eb71 --- /dev/null +++ b/SU2_CFD/include/numerics/flow/sources/CSourceIncBodyForce.hpp @@ -0,0 +1,64 @@ +/*! + * \file CSourceIncBodyForce.hpp + * \brief Delaration of numerics class CSourceIncBodyForce, the + * implementation is in the CSourceIncBodyForce.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../../CNumerics.hpp" + +/*! + * \class CSourceIncBodyForce + * \brief Class for the source term integration of a body force in the incompressible solver. + * \ingroup SourceDiscr + * \author T. Economon + * \version 7.0.0 "Blackbird" + */ +class CSourceIncBodyForce : public CNumerics { + su2double *Body_Force_Vector; + +public: + + /*! + * \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. + */ + CSourceIncBodyForce(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CSourceIncBodyForce(void); + + /*! + * \brief Source term integration for a body force. + * \param[out] val_residual - Pointer to the residual vector. + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, CConfig *config); + +}; diff --git a/SU2_CFD/include/numerics/flow/sources/CSourceIncRotatingFrame_Flow.hpp b/SU2_CFD/include/numerics/flow/sources/CSourceIncRotatingFrame_Flow.hpp new file mode 100644 index 000000000000..4c8a8aa99873 --- /dev/null +++ b/SU2_CFD/include/numerics/flow/sources/CSourceIncRotatingFrame_Flow.hpp @@ -0,0 +1,67 @@ +/*! + * \file CSourceIncRotatingFrame_Flow.hpp + * \brief Delaration of numerics class CSourceIncRotatingFrame_Flow, the + * implementation is in the CSourceIncRotatingFrame_Flow.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../../CNumerics.hpp" + +/*! + * \class CSourceIncRotatingFrame_Flow + * \brief Class for a rotating frame source term. + * \ingroup SourceDiscr + */ +class CSourceIncRotatingFrame_Flow : public CNumerics { + +private: + su2double Omega[3]; /*!< \brief Angular velocity */ + bool implicit; /*!< \brief Implicit calculation. */ + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CSourceIncRotatingFrame_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CSourceIncRotatingFrame_Flow(void); + + /*! + * \brief Residual of the rotational frame source term. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config); + +}; diff --git a/SU2_CFD/include/numerics/flow/sources/CSourceRotatingFrame_Flow.hpp b/SU2_CFD/include/numerics/flow/sources/CSourceRotatingFrame_Flow.hpp new file mode 100644 index 000000000000..b0a4766b9038 --- /dev/null +++ b/SU2_CFD/include/numerics/flow/sources/CSourceRotatingFrame_Flow.hpp @@ -0,0 +1,62 @@ +/*! + * \file CSourceRotatingFrame_Flow.hpp + * \brief Delaration of numerics class CSourceRotatingFrame_Flow, the + * implementation is in the CSourceRotatingFrame_Flow.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../../CNumerics.hpp" + +/*! + * \class CSourceRotatingFrame_Flow + * \brief Class for a rotating frame source term. + * \ingroup SourceDiscr + * \author F. Palacios, T. Economon. + */ +class CSourceRotatingFrame_Flow : public CNumerics { +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CSourceRotatingFrame_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CSourceRotatingFrame_Flow(void); + + /*! + * \brief Residual of the rotational frame source term. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config); +}; diff --git a/SU2_CFD/include/numerics/flow/sources/CSourceWindGust.hpp b/SU2_CFD/include/numerics/flow/sources/CSourceWindGust.hpp new file mode 100644 index 000000000000..e296724455e4 --- /dev/null +++ b/SU2_CFD/include/numerics/flow/sources/CSourceWindGust.hpp @@ -0,0 +1,62 @@ +/*! + * \file CSourceWindGust.hpp + * \brief Delaration of numerics class CSourceWindGust, the + * implementation is in the CSourceWindGust.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../../CNumerics.hpp" + +/*! + * \class CSourceWindGust + * \brief Class for a source term due to a wind gust. + * \ingroup SourceDiscr + * \author S. Padrón + */ +class CSourceWindGust : public CNumerics { +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CSourceWindGust(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CSourceWindGust(void); + + /*! + * \brief Residual of the wind gust source term. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config); +}; diff --git a/SU2_CFD/include/numerics/heat/CAvgGradCorrected_Heat.hpp b/SU2_CFD/include/numerics/heat/CAvgGradCorrected_Heat.hpp new file mode 100644 index 000000000000..893abad44e54 --- /dev/null +++ b/SU2_CFD/include/numerics/heat/CAvgGradCorrected_Heat.hpp @@ -0,0 +1,72 @@ +/*! + * \file CAvgGradCorrected_Heat.hpp + * \brief Delaration of numerics class CAvgGradCorrected_Heat, the + * implementation is in the CAvgGradCorrected_Heat.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../CNumerics.hpp" + +/*! + * \class CAvgGradCorrected_Heat + * \brief Class for computing viscous term using average of gradients with correction (heat equation). + * \ingroup ViscDiscr + * \author O. Burghardt. + * \version 7.0.0 "Blackbird" + */ +class CAvgGradCorrected_Heat : public CNumerics { +private: + su2double **Mean_GradHeatVar; + su2double *Proj_Mean_GradHeatVar_Kappa, *Proj_Mean_GradHeatVar_Edge, *Proj_Mean_GradHeatVar_Corrected; + su2double *Edge_Vector; + bool implicit; + su2double dist_ij_2, proj_vector_ij, Thermal_Diffusivity_Mean; + unsigned short iVar, iDim; + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CAvgGradCorrected_Heat(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CAvgGradCorrected_Heat(void); + + /*! + * \brief Compute the viscous heat residual using an average of gradients with correction. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config); +}; diff --git a/SU2_CFD/include/numerics/heat/CAvgGrad_Heat.hpp b/SU2_CFD/include/numerics/heat/CAvgGrad_Heat.hpp new file mode 100644 index 000000000000..742a0d7f3bb6 --- /dev/null +++ b/SU2_CFD/include/numerics/heat/CAvgGrad_Heat.hpp @@ -0,0 +1,72 @@ +/*! + * \file CAvgGrad_Heat.hpp + * \brief Delaration of numerics class CAvgGrad_Heat, the + * implementation is in the CAvgGrad_Heat.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../CNumerics.hpp" + +/*! + * \class CAvgGrad_Heat + * \brief Class for computing viscous term using average of gradients without correction (heat equation). + * \ingroup ViscDiscr + * \author O. Burghardt. + * \version 7.0.0 "Blackbird" + */ +class CAvgGrad_Heat : public CNumerics { +private: + su2double **Mean_GradHeatVar; + su2double *Proj_Mean_GradHeatVar_Normal, *Proj_Mean_GradHeatVar_Corrected; + su2double *Edge_Vector; + bool implicit; + su2double dist_ij_2, proj_vector_ij, Thermal_Diffusivity_Mean; + unsigned short iVar, iDim; + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CAvgGrad_Heat(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CAvgGrad_Heat(void); + + /*! + * \brief Compute the viscous heat residual using an average of gradients with correction. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config); +}; diff --git a/SU2_CFD/include/numerics/heat/CCentSca_Heat.hpp b/SU2_CFD/include/numerics/heat/CCentSca_Heat.hpp new file mode 100644 index 000000000000..ee6fa1f53a9b --- /dev/null +++ b/SU2_CFD/include/numerics/heat/CCentSca_Heat.hpp @@ -0,0 +1,80 @@ +/*! + * \file CCentSca_Heat.hpp + * \brief Delaration of numerics class CCentSca_Heat, the + * implementation is in the CCentSca_Heat.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../CNumerics.hpp" + +/*! + * \class CCentSca_Heat + * \brief Class for scalar centered scheme. + * \ingroup ConvDiscr + * \author O. Burghardt + * \version 7.0.0 "Blackbird" + */ +class CCentSca_Heat : public CNumerics { + +private: + unsigned short iDim; /*!< \brief Iteration on dimension and variables. */ + su2double *Diff_Lapl, /*!< \brief Diference of conservative variables and undivided laplacians. */ + *MeanVelocity, ProjVelocity, + ProjVelocity_i, ProjVelocity_j, /*!< \brief Mean and projected velocities. */ + Param_Kappa_4, /*!< \brief Artificial dissipation parameters. */ + Local_Lambda_i, Local_Lambda_j, + MeanLambda, /*!< \brief Local eingenvalues. */ + cte_0, cte_1; /*!< \brief Artificial dissipation values. */ + bool implicit, /*!< \brief Implicit calculation. */ + dynamic_grid; /*!< \brief Modification for grid movement. */ + + +public: + + /*! + * \brief Constructor of the class. + * \param[in] val_nDim - Number of dimension of the problem. + * \param[in] val_nVar - Number of variables of the problem. + * \param[in] config - Definition of the particular problem. + */ + CCentSca_Heat(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CCentSca_Heat(void); + + /*! + * \brief Compute the flow residual using a JST method. + * \param[out] val_resconv - Pointer to the convective residual. + * \param[out] val_resvisc - Pointer to the artificial viscosity residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, + CConfig *config); +}; diff --git a/SU2_CFD/include/numerics/heat/CUpwSca_Heat.hpp b/SU2_CFD/include/numerics/heat/CUpwSca_Heat.hpp new file mode 100644 index 000000000000..046147726cfa --- /dev/null +++ b/SU2_CFD/include/numerics/heat/CUpwSca_Heat.hpp @@ -0,0 +1,70 @@ +/*! + * \file CUpwSca_Heat.hpp + * \brief Delaration of numerics class CUpwSca_Heat, the + * implementation is in the CUpwSca_Heat.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../CNumerics.hpp" + +/*! + * \class CUpwSca_Heat + * \brief Class for doing a scalar upwind solver for the heat convection equation. + * \ingroup ConvDiscr + * \author O. Burghardt. + * \version 7.0.0 "Blackbird" + */ +class CUpwSca_Heat : public CNumerics { +private: + su2double *Velocity_i, *Velocity_j; + bool implicit, dynamic_grid; + su2double q_ij, a0, a1; + unsigned short iDim; + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CUpwSca_Heat(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CUpwSca_Heat(void); + + /*! + * \brief Compute the scalar upwind flux between two nodes i and j. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); +}; diff --git a/SU2_CFD/include/numerics/include_all.hpp b/SU2_CFD/include/numerics/include_all.hpp new file mode 100644 index 000000000000..a9337786e496 --- /dev/null +++ b/SU2_CFD/include/numerics/include_all.hpp @@ -0,0 +1,84 @@ +#include "template/CViscous_Template.hpp" +#include "template/CConvective_Template.hpp" +#include "template/CSource_Template.hpp" +#include "transition/CUpwLin_TransLM.hpp" +#include "transition/CAvgGrad_TransLM.hpp" +#include "transition/CSourcePieceWise_TransLM.hpp" +#include "transition/CAvgGradCorrected_TransLM.hpp" +#include "transition/CUpwSca_TransLM.hpp" +#include "heat/CAvgGrad_Heat.hpp" +#include "heat/CCentSca_Heat.hpp" +#include "heat/CAvgGradCorrected_Heat.hpp" +#include "heat/CUpwSca_Heat.hpp" +#include "flow/diffusion/CAvgGrad_Base.hpp" +#include "flow/diffusion/CAvgGradInc_Flow.hpp" +#include "flow/diffusion/CAvgGrad_Flow.hpp" +#include "flow/diffusion/CGeneralAvgGrad_Flow.hpp" +#include "flow/convection_upwind/CUpwRoe_Flow.hpp" +#include "flow/convection_upwind/CUpwL2Roe_Flow.hpp" +#include "flow/convection_upwind/CUpwAUSMPLUS_SLAU_Base_Flow.hpp" +#include "flow/convection_upwind/CUpwHLLC_Flow.hpp" +#include "flow/convection_upwind/CUpwSLAU_Flow.hpp" +#include "flow/convection_upwind/CUpwGeneralRoe_Flow.hpp" +#include "flow/convection_upwind/CUpwLMRoe_Flow.hpp" +#include "flow/convection_upwind/CUpwAUSMPLUSUP_Flow.hpp" +#include "flow/convection_upwind/CUpwRoeBase_Flow.hpp" +#include "flow/convection_upwind/CUpwTurkel_Flow.hpp" +#include "flow/convection_upwind/CUpwGeneralHLLC_Flow.hpp" +#include "flow/convection_upwind/CUpwAUSM_Flow.hpp" +#include "flow/convection_upwind/CUpwCUSP_Flow.hpp" +#include "flow/convection_upwind/CUpwFDSInc_Flow.hpp" +#include "flow/convection_upwind/CUpwMSW_Flow.hpp" +#include "flow/convection_upwind/CUpwAUSMPLUSUP2_Flow.hpp" +#include "flow/sources/CSourceAxisymmetric_Flow.hpp" +#include "flow/sources/CSourceGravity.hpp" +#include "flow/sources/CSourceIncAxisymmetric_Flow.hpp" +#include "flow/sources/CSourceIncRotatingFrame_Flow.hpp" +#include "flow/sources/CSourceBodyForce.hpp" +#include "flow/sources/CSourceWindGust.hpp" +#include "flow/sources/CSourceRotatingFrame_Flow.hpp" +#include "flow/sources/CSourceIncBodyForce.hpp" +#include "flow/sources/CSourceBoussinesq.hpp" +#include "flow/convection_centered/CCentLaxInc_Flow.hpp" +#include "flow/convection_centered/CCentLax_Flow.hpp" +#include "flow/convection_centered/CCentBase_Flow.hpp" +#include "flow/convection_centered/CCentJST_KE_Flow.hpp" +#include "flow/convection_centered/CCentJSTInc_Flow.hpp" +#include "flow/convection_centered/CCentJST_Flow.hpp" +#include "elasticity/CFEALinearElasticity.hpp" +#include "elasticity/CFEM_IdealDE.hpp" +#include "elasticity/CFEM_NeoHookean_Comp.hpp" +#include "elasticity/CFEAElasticity.hpp" +#include "elasticity/CFEANonlinearElasticity.hpp" +#include "elasticity/CFEAMeshElasticity.hpp" +#include "elasticity/CFEM_Knowles_NearInc.hpp" +#include "elasticity/CFEM_DielectricElastomer.hpp" +#include "continuous_adjoint/CCentJST_AdjFlow.hpp" +#include "continuous_adjoint/CAvgGrad_AdjFlow.hpp" +#include "continuous_adjoint/CSourceRotatingFrame_AdjFlow.hpp" +#include "continuous_adjoint/CSourceConservative_AdjFlow.hpp" +#include "continuous_adjoint/CUpwSca_AdjTurb.hpp" +#include "continuous_adjoint/CSourceConservative_AdjTurb.hpp" +#include "continuous_adjoint/CSourceAxisymmetric_AdjFlow.hpp" +#include "continuous_adjoint/CAvgGrad_AdjTurb.hpp" +#include "continuous_adjoint/CSourcePieceWise_AdjTurb.hpp" +#include "continuous_adjoint/CCentLax_AdjFlow.hpp" +#include "continuous_adjoint/CUpwRoe_AdjFlow.hpp" +#include "continuous_adjoint/CSourceViscous_AdjFlow.hpp" +#include "continuous_adjoint/CAvgGradCorrected_AdjFlow.hpp" +#include "continuous_adjoint/CUpwLin_AdjTurb.hpp" +#include "continuous_adjoint/CAvgGradCorrected_AdjTurb.hpp" +#include "turbulent/CSourcePieceWise_TurbSA_E.hpp" +#include "turbulent/CAvgGrad_TurbSA_Neg.hpp" +#include "turbulent/CSourcePieceWise_TurbSA_E_COMP.hpp" +#include "turbulent/CSourcePieceWise_TurbSA.hpp" +#include "turbulent/CAvgGrad_TurbSST.hpp" +#include "turbulent/CSourcePieceWise_TurbSST.hpp" +#include "turbulent/CUpwSca_TurbSST.hpp" +#include "turbulent/CAvgGrad_TurbSA.hpp" +#include "turbulent/CAvgGrad_Scalar.hpp" +#include "turbulent/CSourcePieceWise_TurbSA_Neg.hpp" +#include "turbulent/CSourcePieceWise_TurbSA_COMP.hpp" +#include "turbulent/CUpwScalar.hpp" +#include "turbulent/CUpwSca_TurbSA.hpp" + diff --git a/SU2_CFD/include/numerics/template/CConvective_Template.hpp b/SU2_CFD/include/numerics/template/CConvective_Template.hpp new file mode 100644 index 000000000000..2d44c6fbcd12 --- /dev/null +++ b/SU2_CFD/include/numerics/template/CConvective_Template.hpp @@ -0,0 +1,78 @@ +/*! + * \file CConvective_Template.hpp + * \brief Delaration of numerics class CConvective_Template, the + * implementation is in the CConvective_Template.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../CNumerics.hpp" + +/*! + * \class CConvectiveTemplate + * \brief Class for setting up new method for spatial discretization of convective terms in flow Equations + * \ingroup ConvDiscr + * \author A. Lonkar + */ +class CConvective_Template : public CNumerics { +private: + + /* define private variables here */ + bool implicit; + su2double *Diff_U; + su2double *Velocity_i, *Velocity_j, *RoeVelocity; + su2double *ProjFlux_i, *ProjFlux_j; + su2double *delta_wave, *delta_vel; + su2double *Lambda, *Epsilon; + su2double **P_Tensor, **invP_Tensor; + su2double sq_vel, Proj_ModJac_Tensor_ij, Density_i, Energy_i, SoundSpeed_i, Pressure_i, Enthalpy_i, + Density_j, Energy_j, SoundSpeed_j, Pressure_j, Enthalpy_j, R, RoeDensity, RoeEnthalpy, RoeSoundSpeed, + ProjVelocity, ProjVelocity_i, ProjVelocity_j, proj_delta_vel, delta_p, delta_rho; + unsigned short iDim, iVar, jVar, kVar; + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CConvective_Template(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CConvective_Template(void); + + /*! + * \brief Compute the Roe's flux between two nodes i and j. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); +}; diff --git a/SU2_CFD/include/numerics/template/CSource_Template.hpp b/SU2_CFD/include/numerics/template/CSource_Template.hpp new file mode 100644 index 000000000000..5bd09a2898b6 --- /dev/null +++ b/SU2_CFD/include/numerics/template/CSource_Template.hpp @@ -0,0 +1,64 @@ +/*! + * \file CSource_Template.hpp + * \brief Delaration of numerics class CSource_Template, the + * implementation is in the CSource_Template.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../CNumerics.hpp" + +/*! + * \class CSource_Template + * \brief Dummy class. + * \ingroup SourceDiscr + * \author A. Lonkar. + */ +class CSource_Template : public CNumerics { +public: + + /*! + * \brief Constructor of the class. + * \param[in] val_nDim - Number of dimensions of the problem. + * \param[in] val_nVar - Number of variables of the problem. + * \param[in] config - Name of the input config file + * + */ + CSource_Template(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + + /*! + * \brief Residual for source term integration. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CSource_Template(void); +}; diff --git a/SU2_CFD/include/numerics/template/CViscous_Template.hpp b/SU2_CFD/include/numerics/template/CViscous_Template.hpp new file mode 100644 index 000000000000..49cf2ae0bb05 --- /dev/null +++ b/SU2_CFD/include/numerics/template/CViscous_Template.hpp @@ -0,0 +1,65 @@ +/*! + * \file CViscous_Template.hpp + * \brief Delaration of numerics class CViscous_Template, the + * implementation is in the CViscous_Template.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../CNumerics.hpp" + +/*! + * \class CViscous_Template + * \brief Class for computing viscous term using average of gradients. + * \ingroup ViscDiscr + * \author F. Palacios + */ +class CViscous_Template : public CNumerics { +private: + +public: + + /*! + * \brief Constructor of the class. + * \param[in] val_nDim - Number of dimension of the problem. + * \param[in] val_nVar - Number of variables of the problem. + * \param[in] config - Definition of the particular problem. + */ + CViscous_Template(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CViscous_Template(void); + + /*! + * \brief Compute the viscous flow residual using an average of gradients. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); +}; diff --git a/SU2_CFD/include/numerics/transition/CAvgGradCorrected_TransLM.hpp b/SU2_CFD/include/numerics/transition/CAvgGradCorrected_TransLM.hpp new file mode 100644 index 000000000000..6073bf2f006b --- /dev/null +++ b/SU2_CFD/include/numerics/transition/CAvgGradCorrected_TransLM.hpp @@ -0,0 +1,70 @@ +/*! + * \file CAvgGradCorrected_TransLM.hpp + * \brief Delaration of numerics class CAvgGradCorrected_TransLM, the + * implementation is in the CAvgGradCorrected_TransLM.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../CNumerics.hpp" + +/*! + * \class CAvgGradCorrected_TransLM + * \brief Class for computing viscous term using average of gradients with correction (Spalart-Allmaras turbulence model). + * \ingroup ViscDiscr + * \author A. Bueno. + */ +class CAvgGradCorrected_TransLM : public CNumerics { +private: + su2double **Mean_GradTurbVar; + su2double *Proj_Mean_GradTurbVar_Kappa, *Proj_Mean_GradTurbVar_Edge, *Proj_Mean_GradTurbVar_Corrected; + su2double *Edge_Vector; + bool implicit, incompressible; + su2double sigma; + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CAvgGradCorrected_TransLM(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CAvgGradCorrected_TransLM(void); + + /*! + * \brief Compute the viscous turbulent residual using an average of gradients with correction. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config); +}; diff --git a/SU2_CFD/include/numerics/transition/CAvgGrad_TransLM.hpp b/SU2_CFD/include/numerics/transition/CAvgGrad_TransLM.hpp new file mode 100644 index 000000000000..56db3e8438ae --- /dev/null +++ b/SU2_CFD/include/numerics/transition/CAvgGrad_TransLM.hpp @@ -0,0 +1,73 @@ +/*! + * \file CAvgGrad_TransLM.hpp + * \brief Delaration of numerics class CAvgGrad_TransLM, the + * implementation is in the CAvgGrad_TransLM.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../CNumerics.hpp" + +/*! + * \class CAvgGrad_TransLM + * \brief Class for computing viscous term using average of gradients (Spalart-Allmaras Turbulence model). + * \ingroup ViscDiscr + * \author A. Bueno. + */ +class CAvgGrad_TransLM : public CNumerics { +private: + su2double **Mean_GradTransVar; + su2double *Proj_Mean_GradTransVar_Kappa, *Proj_Mean_GradTransVar_Edge; + su2double *Edge_Vector; + bool implicit, incompressible; + su2double sigma; + //su2double dist_ij_2; + //su2double proj_vector_ij; + //unsigned short iVar, iDim; + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CAvgGrad_TransLM(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CAvgGrad_TransLM(void); + + /*! + * \brief Compute the viscous turbulence terms residual using an average of gradients. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config); +}; diff --git a/SU2_CFD/include/numerics/transition/CSourcePieceWise_TransLM.hpp b/SU2_CFD/include/numerics/transition/CSourcePieceWise_TransLM.hpp new file mode 100644 index 000000000000..d75748145389 --- /dev/null +++ b/SU2_CFD/include/numerics/transition/CSourcePieceWise_TransLM.hpp @@ -0,0 +1,95 @@ +/*! + * \file CSourcePieceWise_TransLM.hpp + * \brief Delaration of numerics class CSourcePieceWise_TransLM, the + * implementation is in the CSourcePieceWise_TransLM.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../CNumerics.hpp" + +/*! + * \class CSourcePieceWise_TransLM + * \brief Class for integrating the source terms of the Spalart-Allmaras turbulence model equation. + * \ingroup SourceDiscr + * \author A. Bueno. + */ +class CSourcePieceWise_TransLM : public CNumerics { +private: + + /*-- SA model constants --*/ + su2double cv1_3; + su2double k2; + su2double cb1; + su2double cw2; + su2double cw3_6; + su2double sigma; + su2double cb2; + su2double cw1; + + /*-- gamma-theta model constants --*/ + su2double c_e1; + su2double c_a1; + su2double c_e2; + su2double c_a2; + su2double sigmaf; + su2double s1; + su2double c_theta; + su2double sigmat; + + /*-- Correlation constants --*/ + su2double flen_global; + su2double alpha_global; + su2double Vorticity; + + bool implicit; + +public: + bool debugme; // For debugging only, remove this. -AA + + /*! + * \brief Constructor of the class. + * \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. + */ + CSourcePieceWise_TransLM(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CSourcePieceWise_TransLM(void); + + /*! + * \brief Residual for source term integration. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual_TransLM(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config, su2double &gamma_sep); + + void CSourcePieceWise_TransLM__ComputeResidual_TransLM_d(su2double *TransVar_i, su2double *TransVar_id, su2double *val_residual, su2double *val_residuald, CConfig *config); +}; diff --git a/SU2_CFD/include/numerics/transition/CUpwLin_TransLM.hpp b/SU2_CFD/include/numerics/transition/CUpwLin_TransLM.hpp new file mode 100644 index 000000000000..0983493e19ea --- /dev/null +++ b/SU2_CFD/include/numerics/transition/CUpwLin_TransLM.hpp @@ -0,0 +1,70 @@ +/*! + * \file CUpwLin_TransLM.hpp + * \brief Delaration of numerics class CUpwLin_TransLM, the + * implementation is in the CUpwLin_TransLM.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../CNumerics.hpp" + +/*! + * \class CUpwLin_TransLM + * \brief Class for performing a linear upwind solver for the Spalart-Allmaras turbulence model equations with transition + * \ingroup ConvDiscr + * \author A. Aranake + */ +class CUpwLin_TransLM : public CNumerics { +private: + su2double *Velocity_i; + su2double *Velocity_j; + bool implicit, incompressible; + su2double Density_i, Density_j, q_ij, a0, a1; + unsigned short iDim; + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CUpwLin_TransLM(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CUpwLin_TransLM(void); + + /*! + * \brief Compute the upwind flux between two nodes i and j. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual (su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); +}; diff --git a/SU2_CFD/include/numerics/transition/CUpwSca_TransLM.hpp b/SU2_CFD/include/numerics/transition/CUpwSca_TransLM.hpp new file mode 100644 index 000000000000..dcb65dfa4a45 --- /dev/null +++ b/SU2_CFD/include/numerics/transition/CUpwSca_TransLM.hpp @@ -0,0 +1,69 @@ +/*! + * \file CUpwSca_TransLM.hpp + * \brief Delaration of numerics class CUpwSca_TransLM, the + * implementation is in the CUpwSca_TransLM.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../CNumerics.hpp" + +/*! + * \class CUpwSca_TransLM + * \brief Class for doing a scalar upwind solver for the Spalart-Allmaras turbulence model equations with transition. + * \ingroup ConvDiscr + * \author A. Aranake. + */ +class CUpwSca_TransLM : public CNumerics { +private: + su2double *Velocity_i, *Velocity_j; + bool implicit; + su2double q_ij, a0, a1; + unsigned short iDim; + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CUpwSca_TransLM(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CUpwSca_TransLM(void); + + /*! + * \brief Compute the scalar upwind flux between two nodes i and j. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); +}; diff --git a/SU2_CFD/include/numerics/turbulent/CAvgGrad_Scalar.hpp b/SU2_CFD/include/numerics/turbulent/CAvgGrad_Scalar.hpp new file mode 100644 index 000000000000..ebc40cdca52c --- /dev/null +++ b/SU2_CFD/include/numerics/turbulent/CAvgGrad_Scalar.hpp @@ -0,0 +1,103 @@ +/*! + * \file CAvgGrad_Scalar.hpp + * \brief Delaration of numerics class CAvgGrad_Scalar, the + * implementation is in the CAvgGrad_Scalar.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../CNumerics.hpp" + +/*! + * \class CAvgGrad_Scalar + * \brief Template class for computing viscous residual of scalar values + * \details This class serves as a template for the scalar viscous residual + * classes. The general structure of a viscous residual calculation is the + * same for many different models, which leads to a lot of repeated code. + * By using the template design pattern, these sections of repeated code are + * moved to a shared base class, and the specifics of each model + * are implemented by derived classes. In order to add a new residual + * calculation for a viscous residual, extend this class and implement + * the pure virtual functions with model-specific behavior. + * \ingroup ViscDiscr + * \author C. Pederson, A. Bueno, and F. Palacios + */ +class CAvgGrad_Scalar : public CNumerics { + private: + + /*! + * \brief A pure virtual function; Adds any extra variables to AD + */ + virtual void ExtraADPreaccIn() = 0; + + /*! + * \brief Model-specific steps in the ComputeResidual method + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + virtual void FinishResidualCalc(su2double *val_residual, + su2double **Jacobian_i, + su2double **Jacobian_j, + CConfig *config) = 0; + + protected: + bool implicit, incompressible; + bool correct_gradient; + unsigned short iVar, iDim; + su2double **Mean_GradTurbVar; /*!< \brief Average of gradients at cell face */ + su2double *Edge_Vector, /*!< \brief Vector from node i to node j. */ + *Proj_Mean_GradTurbVar_Normal, /*!< \brief Mean_gradTurbVar DOT normal */ + *Proj_Mean_GradTurbVar_Edge, /*!< \brief Mean_gradTurbVar DOT Edge_Vector */ + *Proj_Mean_GradTurbVar; /*!< \brief Mean_gradTurbVar DOT normal, corrected if required*/ + su2double dist_ij_2, /*!< \brief |Edge_Vector|^2 */ + proj_vector_ij; /*!< \brief (Edge_Vector DOT normal)/|Edge_Vector|^2 */ + + public: + /*! + * \brief Constructor of the class. + * \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. + */ + CAvgGrad_Scalar(unsigned short val_nDim, unsigned short val_nVar, + bool correct_gradient, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CAvgGrad_Scalar(void); + + /*! + * \brief Compute the viscous residual using an average of gradients without correction. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **Jacobian_i, + su2double **Jacobian_j, CConfig *config); +}; diff --git a/SU2_CFD/include/numerics/turbulent/CAvgGrad_TurbSA.hpp b/SU2_CFD/include/numerics/turbulent/CAvgGrad_TurbSA.hpp new file mode 100644 index 000000000000..faa75e21d134 --- /dev/null +++ b/SU2_CFD/include/numerics/turbulent/CAvgGrad_TurbSA.hpp @@ -0,0 +1,75 @@ +/*! + * \file CAvgGrad_TurbSA.hpp + * \brief Delaration of numerics class CAvgGrad_TurbSA, the + * implementation is in the CAvgGrad_TurbSA.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "CAvgGrad_Scalar.hpp" + +/*! + * \class CAvgGrad_TurbSA + * \brief Class for computing viscous term using average of gradients (Spalart-Allmaras Turbulence model). + * \ingroup ViscDiscr + * \author A. Bueno. + */ +class CAvgGrad_TurbSA : public CAvgGrad_Scalar { +private: + + const su2double sigma; + su2double nu_i, nu_j, nu_e; + + /*! + * \brief Adds any extra variables to AD + */ + void ExtraADPreaccIn(void); + + /*! + * \brief SA specific steps in the ComputeResidual method + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void FinishResidualCalc(su2double *val_residual, su2double **Jacobian_i, + su2double **Jacobian_j, CConfig *config); + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CAvgGrad_TurbSA(unsigned short val_nDim, unsigned short val_nVar, + bool correct_grad, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CAvgGrad_TurbSA(void); +}; diff --git a/SU2_CFD/include/numerics/turbulent/CAvgGrad_TurbSA_Neg.hpp b/SU2_CFD/include/numerics/turbulent/CAvgGrad_TurbSA_Neg.hpp new file mode 100644 index 000000000000..849bb534ec29 --- /dev/null +++ b/SU2_CFD/include/numerics/turbulent/CAvgGrad_TurbSA_Neg.hpp @@ -0,0 +1,77 @@ +/*! + * \file CAvgGrad_TurbSA_Neg.hpp + * \brief Delaration of numerics class CAvgGrad_TurbSA_Neg, the + * implementation is in the CAvgGrad_TurbSA_Neg.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "CAvgGrad_Scalar.hpp" + +/*! + * \class CAvgGrad_TurbSA_Neg + * \brief Class for computing viscous term using average of gradients (Spalart-Allmaras Turbulence model). + * \ingroup ViscDiscr + * \author F. Palacios + */ +class CAvgGrad_TurbSA_Neg : public CAvgGrad_Scalar { +private: + + const su2double sigma; + const su2double cn1; + su2double fn, Xi; + su2double nu_i, nu_j, nu_ij, nu_tilde_ij, nu_e; + + /*! + * \brief Adds any extra variables to AD + */ + void ExtraADPreaccIn(void); + + /*! + * \brief SA specific steps in the ComputeResidual method + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void FinishResidualCalc(su2double *val_residual, su2double **Jacobian_i, + su2double **Jacobian_j, CConfig *config); + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CAvgGrad_TurbSA_Neg(unsigned short val_nDim, unsigned short val_nVar, + bool correct_grad, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CAvgGrad_TurbSA_Neg(void); +}; diff --git a/SU2_CFD/include/numerics/turbulent/CAvgGrad_TurbSST.hpp b/SU2_CFD/include/numerics/turbulent/CAvgGrad_TurbSST.hpp new file mode 100644 index 000000000000..3f74a49c050d --- /dev/null +++ b/SU2_CFD/include/numerics/turbulent/CAvgGrad_TurbSST.hpp @@ -0,0 +1,89 @@ +/*! + * \file CAvgGrad_TurbSST.hpp + * \brief Delaration of numerics class CAvgGrad_TurbSST, the + * implementation is in the CAvgGrad_TurbSST.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "CAvgGrad_Scalar.hpp" + +/*! + * \class CAvgGrad_TurbSST + * \brief Class for computing viscous term using average of gradient with correction (Menter SST turbulence model). + * \ingroup ViscDiscr + * \author A. Bueno. + */ +class CAvgGrad_TurbSST : public CAvgGrad_Scalar { +private: + su2double sigma_k1, /*!< \brief Constants for the viscous terms, k-w (1), k-eps (2)*/ + sigma_k2, + sigma_om1, + sigma_om2; + + su2double diff_kine, /*!< \brief Diffusivity for viscous terms of tke eq */ + diff_omega; /*!< \brief Diffusivity for viscous terms of omega eq */ + + su2double F1_i, F1_j; /*!< \brief Menter's first blending function */ + + /*! + * \brief Adds any extra variables to AD + */ + void ExtraADPreaccIn(void); + + /*! + * \brief SST specific steps in the ComputeResidual method + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void FinishResidualCalc(su2double *val_residual, su2double **Jacobian_i, + su2double **Jacobian_j, CConfig *config); + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CAvgGrad_TurbSST(unsigned short val_nDim, unsigned short val_nVar, + const su2double* constants, bool correct_grad, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CAvgGrad_TurbSST(void); + + /*! + * \brief Sets value of first blending function. + */ + void SetF1blending(su2double val_F1_i, su2double val_F1_j) { + F1_i = val_F1_i; F1_j = val_F1_j; + } + +}; diff --git a/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA.hpp b/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA.hpp new file mode 100644 index 000000000000..c03710aadce2 --- /dev/null +++ b/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA.hpp @@ -0,0 +1,133 @@ +/*! + * \file CSourcePieceWise_TurbSA.hpp + * \brief Delaration of numerics class CSourcePieceWise_TurbSA, the + * implementation is in the CSourcePieceWise_TurbSA.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../CNumerics.hpp" + +/*! + * \class CSourcePieceWise_TurbSA + * \brief Class for integrating the source terms of the Spalart-Allmaras turbulence model equation. + * \ingroup SourceDiscr + * \author A. Bueno. + */ +class CSourcePieceWise_TurbSA : public CNumerics { +private: + su2double cv1_3; + su2double k2; + su2double cb1; + su2double cw2; + su2double ct3; + su2double ct4; + su2double cw3_6; + su2double cb2_sigma; + su2double sigma; + su2double cb2; + su2double cw1; + unsigned short iDim; + su2double nu, Ji, fv1, fv2, ft2, Omega, S, Shat, inv_Shat, dist_i_2, Ji_2, Ji_3, inv_k2_d2; + su2double r, g, g_6, glim, fw; + su2double norm2_Grad; + su2double dfv1, dfv2, dShat; + su2double dr, dg, dfw; + bool incompressible; + bool rotating_frame; + bool transition; + su2double gamma_BC; + su2double intermittency; + su2double Production, Destruction, CrossProduction; + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CSourcePieceWise_TurbSA(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CSourcePieceWise_TurbSA(void); + + /*! + * \brief Residual for source term integration. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + + /*! + * \brief Residual for source term integration. + * \param[in] intermittency_in - Value of the intermittency. + */ + inline void SetIntermittency(su2double intermittency_in) { intermittency = intermittency_in; } + + /*! + * \brief Residual for source term integration. + * \param[in] val_production - Value of the Production. + */ + inline void SetProduction(su2double val_production) { Production = val_production; } + + /*! + * \brief Residual for source term integration. + * \param[in] val_destruction - Value of the Destruction. + */ + inline void SetDestruction(su2double val_destruction) { Destruction = val_destruction; } + + /*! + * \brief Residual for source term integration. + * \param[in] val_crossproduction - Value of the CrossProduction. + */ + inline void SetCrossProduction(su2double val_crossproduction) { CrossProduction = val_crossproduction; } + + /*! + * \brief ______________. + */ + inline su2double GetProduction(void) { return Production; } + + /*! + * \brief Get the intermittency for the BC trans. model. + * \return Value of the intermittency. + */ + inline su2double GetGammaBC(void) { return gamma_BC; } + + /*! + * \brief ______________. + */ + inline su2double GetDestruction(void) { return Destruction; } + + /*! + * \brief ______________. + */ + inline su2double GetCrossProduction(void) { return CrossProduction; } +}; diff --git a/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA_COMP.hpp b/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA_COMP.hpp new file mode 100644 index 000000000000..38ef713a9fb3 --- /dev/null +++ b/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA_COMP.hpp @@ -0,0 +1,128 @@ +/*! + * \file CSourcePieceWise_TurbSA_COMP.hpp + * \brief Delaration of numerics class CSourcePieceWise_TurbSA_COMP, the + * implementation is in the CSourcePieceWise_TurbSA_COMP.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../CNumerics.hpp" + +/*! + * \class CSourcePieceWise_TurbSA_COMP + * \brief Class for integrating the source terms of the Spalart-Allmaras CC modification turbulence model equation. + * \ingroup SourceDiscr + * \author E.Molina, A. Bueno. + * \version 7.0.0 "Blackbird" + */ +class CSourcePieceWise_TurbSA_COMP : public CNumerics { +private: + su2double cv1_3; + su2double k2; + su2double cb1; + su2double cw2; + su2double ct3; + su2double ct4; + su2double cw3_6; + su2double cb2_sigma; + su2double sigma; + su2double cb2; + su2double cw1; + unsigned short iDim; + su2double nu, Ji, fv1, fv2, ft2, Omega, S, Shat, inv_Shat, dist_i_2, Ji_2, Ji_3, inv_k2_d2; + su2double r, g, g_6, glim, fw; + su2double norm2_Grad; + su2double dfv1, dfv2, dShat; + su2double dr, dg, dfw; + bool incompressible; + bool rotating_frame; + su2double intermittency; + su2double Production, Destruction, CrossProduction; + su2double aux_cc, CompCorrection, c5; + unsigned short jDim; + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CSourcePieceWise_TurbSA_COMP(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CSourcePieceWise_TurbSA_COMP(void); + + /*! + * \brief Residual for source term integration. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + + /*! + * \brief Residual for source term integration. + * \param[in] intermittency_in - Value of the intermittency. + */ + inline void SetIntermittency(su2double intermittency_in) { intermittency = intermittency_in; } + + /*! + * \brief Residual for source term integration. + * \param[in] val_production - Value of the Production. + */ + inline void SetProduction(su2double val_production) { Production = val_production; } + + /*! + * \brief Residual for source term integration. + * \param[in] val_destruction - Value of the Destruction. + */ + inline void SetDestruction(su2double val_destruction) { Destruction = val_destruction; } + + /*! + * \brief Residual for source term integration. + * \param[in] val_crossproduction - Value of the CrossProduction. + */ + inline void SetCrossProduction(su2double val_crossproduction) { CrossProduction = val_crossproduction; } + + /*! + * \brief ______________. + */ + inline su2double GetProduction(void) { return Production; } + + /*! + * \brief ______________. + */ + inline su2double GetDestruction(void) { return Destruction; } + + /*! + * \brief ______________. + */ + inline su2double GetCrossProduction(void) { return CrossProduction; } +}; diff --git a/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA_E.hpp b/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA_E.hpp new file mode 100644 index 000000000000..b735b226d2e3 --- /dev/null +++ b/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA_E.hpp @@ -0,0 +1,128 @@ +/*! + * \file CSourcePieceWise_TurbSA_E.hpp + * \brief Delaration of numerics class CSourcePieceWise_TurbSA_E, the + * implementation is in the CSourcePieceWise_TurbSA_E.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../CNumerics.hpp" + +/*! + * \class CSourcePieceWise_TurbSA_E + * \brief Class for integrating the source terms of the Spalart-Allmaras Edwards modification turbulence model equation. + * \ingroup SourceDiscr + * \author E.Molina, A. Bueno. + * \version 7.0.0 "Blackbird" + */ +class CSourcePieceWise_TurbSA_E : public CNumerics { +private: + su2double cv1_3; + su2double k2; + su2double cb1; + su2double cw2; + su2double ct3; + su2double ct4; + su2double cw3_6; + su2double cb2_sigma; + su2double sigma; + su2double cb2; + su2double cw1; + unsigned short iDim; + su2double nu, Ji, fv1, fv2, ft2, Omega, S, Shat, inv_Shat, dist_i_2, Ji_2, Ji_3, inv_k2_d2; + su2double r, g, g_6, glim, fw; + su2double norm2_Grad; + su2double dfv1, dfv2, dShat; + su2double dr, dg, dfw; + bool incompressible; + bool rotating_frame; + su2double intermittency; + su2double Production, Destruction, CrossProduction; + su2double Sbar; + unsigned short jDim; + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CSourcePieceWise_TurbSA_E(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CSourcePieceWise_TurbSA_E(void); + + /*! + * \brief Residual for source term integration. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + + /*! + * \brief Residual for source term integration. + * \param[in] intermittency_in - Value of the intermittency. + */ + inline void SetIntermittency(su2double intermittency_in) { intermittency = intermittency_in; } + + /*! + * \brief Residual for source term integration. + * \param[in] val_production - Value of the Production. + */ + inline void SetProduction(su2double val_production) { Production = val_production; } + + /*! + * \brief Residual for source term integration. + * \param[in] val_destruction - Value of the Destruction. + */ + inline void SetDestruction(su2double val_destruction) { Destruction = val_destruction; } + + /*! + * \brief Residual for source term integration. + * \param[in] val_crossproduction - Value of the CrossProduction. + */ + inline void SetCrossProduction(su2double val_crossproduction) { CrossProduction = val_crossproduction; } + + /*! + * \brief ______________. + */ + inline su2double GetProduction(void) { return Production; } + + /*! + * \brief ______________. + */ + inline su2double GetDestruction(void) { return Destruction; } + + /*! + * \brief ______________. + */ + inline su2double GetCrossProduction(void) { return CrossProduction; } +}; diff --git a/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA_E_COMP.hpp b/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA_E_COMP.hpp new file mode 100644 index 000000000000..651f8a47f57e --- /dev/null +++ b/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA_E_COMP.hpp @@ -0,0 +1,129 @@ +/*! + * \file CSourcePieceWise_TurbSA_E_COMP.hpp + * \brief Delaration of numerics class CSourcePieceWise_TurbSA_E_COMP, the + * implementation is in the CSourcePieceWise_TurbSA_E_COMP.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../CNumerics.hpp" + +/*! + * \class CSourcePieceWise_TurbSA_E_COMP + * \brief Class for integrating the source terms of the Spalart-Allmaras Edwards modification with CC turbulence model equation. + * \ingroup SourceDiscr + * \author E.Molina, A. Bueno. + * \version 7.0.0 "Blackbird" + */ +class CSourcePieceWise_TurbSA_E_COMP : public CNumerics { +private: + su2double cv1_3; + su2double k2; + su2double cb1; + su2double cw2; + su2double ct3; + su2double ct4; + su2double cw3_6; + su2double cb2_sigma; + su2double sigma; + su2double cb2; + su2double cw1; + unsigned short iDim; + su2double nu, Ji, fv1, fv2, ft2, Omega, S, Shat, inv_Shat, dist_i_2, Ji_2, Ji_3, inv_k2_d2; + su2double r, g, g_6, glim, fw; + su2double norm2_Grad; + su2double dfv1, dfv2, dShat; + su2double dr, dg, dfw; + bool incompressible; + bool rotating_frame; + su2double intermittency; + su2double Production, Destruction, CrossProduction; + su2double Sbar; + unsigned short jDim; + su2double aux_cc, CompCorrection, c5; + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CSourcePieceWise_TurbSA_E_COMP(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CSourcePieceWise_TurbSA_E_COMP(void); + + /*! + * \brief Residual for source term integration. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + + /*! + * \brief Residual for source term integration. + * \param[in] intermittency_in - Value of the intermittency. + */ + inline void SetIntermittency(su2double intermittency_in) { intermittency = intermittency_in; } + + /*! + * \brief Residual for source term integration. + * \param[in] val_production - Value of the Production. + */ + inline void SetProduction(su2double val_production) { Production = val_production; } + + /*! + * \brief Residual for source term integration. + * \param[in] val_destruction - Value of the Destruction. + */ + inline void SetDestruction(su2double val_destruction) { Destruction = val_destruction; } + + /*! + * \brief Residual for source term integration. + * \param[in] val_crossproduction - Value of the CrossProduction. + */ + inline void SetCrossProduction(su2double val_crossproduction) { CrossProduction = val_crossproduction; } + + /*! + * \brief ______________. + */ + inline su2double GetProduction(void) { return Production; } + + /*! + * \brief ______________. + */ + inline su2double GetDestruction(void) { return Destruction; } + + /*! + * \brief ______________. + */ + inline su2double GetCrossProduction(void) { return CrossProduction; } +}; diff --git a/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA_Neg.hpp b/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA_Neg.hpp new file mode 100644 index 000000000000..70d0dabe21ae --- /dev/null +++ b/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA_Neg.hpp @@ -0,0 +1,125 @@ +/*! + * \file CSourcePieceWise_TurbSA_Neg.hpp + * \brief Delaration of numerics class CSourcePieceWise_TurbSA_Neg, the + * implementation is in the CSourcePieceWise_TurbSA_Neg.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../CNumerics.hpp" + +/*! + * \class CSourcePieceWise_TurbSA_Neg + * \brief Class for integrating the source terms of the Spalart-Allmaras turbulence model equation. + * \ingroup SourceDiscr + * \author F. Palacios + */ +class CSourcePieceWise_TurbSA_Neg : public CNumerics { +private: + su2double cv1_3; + su2double k2; + su2double cb1; + su2double cw2; + su2double ct3; + su2double ct4; + su2double cw3_6; + su2double cb2_sigma; + su2double sigma; + su2double cb2; + su2double cw1; + unsigned short iDim; + su2double nu, Ji, fv1, fv2, ft2, Omega, S, Shat, inv_Shat, dist_i_2, Ji_2, Ji_3, inv_k2_d2; + su2double r, g, g_6, glim, fw; + su2double norm2_Grad; + su2double dfv1, dfv2, dShat; + su2double dr, dg, dfw; + bool incompressible; + bool rotating_frame; + su2double intermittency; + su2double Production, Destruction, CrossProduction; + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CSourcePieceWise_TurbSA_Neg(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CSourcePieceWise_TurbSA_Neg(void); + + /*! + * \brief Residual for source term integration. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + + /*! + * \brief Residual for source term integration. + * \param[in] intermittency_in - Value of the intermittency. + */ + inline void SetIntermittency(su2double intermittency_in) { intermittency = intermittency_in; } + + /*! + * \brief Residual for source term integration. + * \param[in] val_production - Value of the Production. + */ + inline void SetProduction(su2double val_production) { Production = val_production; } + + /*! + * \brief Residual for source term integration. + * \param[in] val_destruction - Value of the Destruction. + */ + inline void SetDestruction(su2double val_destruction) { Destruction = val_destruction; } + + /*! + * \brief Residual for source term integration. + * \param[in] val_crossproduction - Value of the CrossProduction. + */ + inline void SetCrossProduction(su2double val_crossproduction) { CrossProduction = val_crossproduction; } + + /*! + * \brief ______________. + */ + inline su2double GetProduction(void) { return Production; } + + /*! + * \brief ______________. + */ + inline su2double GetDestruction(void) { return Destruction; } + + /*! + * \brief ______________. + */ + inline su2double GetCrossProduction(void) { return CrossProduction; } +}; diff --git a/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSST.hpp b/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSST.hpp new file mode 100644 index 000000000000..7e1200554b6e --- /dev/null +++ b/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSST.hpp @@ -0,0 +1,141 @@ +/*! + * \file CSourcePieceWise_TurbSST.hpp + * \brief Delaration of numerics class CSourcePieceWise_TurbSST, the + * implementation is in the CSourcePieceWise_TurbSST.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../CNumerics.hpp" + +/*! + * \class CSourcePieceWise_TurbSST + * \brief Class for integrating the source terms of the Menter SST turbulence model equations. + * \ingroup SourceDiscr + * \author A. Campos. + */ +class CSourcePieceWise_TurbSST : public CNumerics { +private: + su2double F1_i, + F1_j, + F2_i, + F2_j; + + su2double alfa_1, + alfa_2, + beta_1, + beta_2, + sigma_omega_1, + sigma_omega_2, + beta_star, + a1; + + su2double CDkw_i, CDkw_j; + + su2double kAmb, omegaAmb; + + bool incompressible; + bool sustaining_terms; + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CSourcePieceWise_TurbSST(unsigned short val_nDim, unsigned short val_nVar, const su2double* constants, + su2double val_kine_Inf, su2double val_omega_Inf, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CSourcePieceWise_TurbSST(void); + + /*! + * \brief Set the value of the first blending function. + * \param[in] val_F1_i - Value of the first blending function at point i. + * \param[in] val_F1_j - Value of the first blending function at point j. + */ + inline void SetF1blending(su2double val_F1_i, su2double val_F1_j) { + F1_i = val_F1_i; + F1_j = val_F1_j; + } + + /*! + * \brief Set the value of the second blending function. + * \param[in] val_F2_i - Value of the second blending function at point i. + * \param[in] val_F2_j - Value of the second blending function at point j. + */ + inline void SetF2blending(su2double val_F2_i, su2double val_F2_j) { + F2_i = val_F2_i; + F2_j = val_F2_j; + } + + /*! + * \brief Set the value of the cross diffusion for the SST model. + * \param[in] val_CDkw_i - Value of the cross diffusion at point i. + * \param[in] val_CDkw_j - Value of the cross diffusion at point j. + */ + inline void SetCrossDiff(su2double val_CDkw_i, su2double val_CDkw_j) override { + CDkw_i = val_CDkw_i; + CDkw_j = val_CDkw_j; + } + + /*! + * \brief Residual for source term integration. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + + /*! + * \brief Initialize the Reynolds Stress Matrix + * \param[in] turb_ke turbulent kinetic energy of node + */ + void SetReynoldsStressMatrix(su2double turb_ke); + + /*! + * \brief Perturb the Reynolds stress tensor based on parameters + * \param[in] turb_ke: turbulent kinetic energy of the noce + * \param[in] config: config file + */ + void SetPerturbedRSM(su2double turb_ke, CConfig *config); + /*! + * \brief A virtual member. Get strain magnitude based on perturbed reynolds stress matrix + * \param[in] turb_ke: turbulent kinetic energy of the node + */ + void SetPerturbedStrainMag(su2double turb_ke); + + /*! + * \brief Get the mean rate of strain matrix based on velocity gradients + * \param[in] S_ij + */ + void GetMeanRateOfStrainMatrix(su2double **S_ij); + +}; diff --git a/SU2_CFD/include/numerics/turbulent/CUpwSca_TurbSA.hpp b/SU2_CFD/include/numerics/turbulent/CUpwSca_TurbSA.hpp new file mode 100644 index 000000000000..1bf8ff43b923 --- /dev/null +++ b/SU2_CFD/include/numerics/turbulent/CUpwSca_TurbSA.hpp @@ -0,0 +1,71 @@ +/*! + * \file CUpwSca_TurbSA.hpp + * \brief Delaration of numerics class CUpwSca_TurbSA, the + * implementation is in the CUpwSca_TurbSA.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "CUpwScalar.hpp" + +/*! + * \class CUpwSca_TurbSA + * \brief Class for doing a scalar upwind solver for the Spalar-Allmaras turbulence model equations. + * \ingroup ConvDiscr + * \author A. Bueno. + */ +class CUpwSca_TurbSA : public CUpwScalar { +private: + + /*! + * \brief Adds any extra variables to AD + */ + void ExtraADPreaccIn(); + + /*! + * \brief SA specific steps in the ComputeResidual method + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void FinishResidualCalc(su2double *val_residual, su2double **Jacobian_i, + su2double **Jacobian_j, CConfig *config); + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CUpwSca_TurbSA(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CUpwSca_TurbSA(void); +}; diff --git a/SU2_CFD/include/numerics/turbulent/CUpwSca_TurbSST.hpp b/SU2_CFD/include/numerics/turbulent/CUpwSca_TurbSST.hpp new file mode 100644 index 000000000000..17a5889888ec --- /dev/null +++ b/SU2_CFD/include/numerics/turbulent/CUpwSca_TurbSST.hpp @@ -0,0 +1,71 @@ +/*! + * \file CUpwSca_TurbSST.hpp + * \brief Delaration of numerics class CUpwSca_TurbSST, the + * implementation is in the CUpwSca_TurbSST.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "CUpwScalar.hpp" + +/*! + * \class CUpwSca_TurbSST + * \brief Class for doing a scalar upwind solver for the Menter SST turbulence model equations. + * \ingroup ConvDiscr + * \author A. Campos. + */ +class CUpwSca_TurbSST : public CUpwScalar { +private: + + /*! + * \brief Adds any extra variables to AD + */ + void ExtraADPreaccIn(); + + /*! + * \brief SST specific steps in the ComputeResidual method + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void FinishResidualCalc(su2double *val_residual, su2double **Jacobian_i, + su2double **Jacobian_j, CConfig *config); + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CUpwSca_TurbSST(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CUpwSca_TurbSST(void); +}; diff --git a/SU2_CFD/include/numerics/turbulent/CUpwScalar.hpp b/SU2_CFD/include/numerics/turbulent/CUpwScalar.hpp new file mode 100644 index 000000000000..ced8eed03124 --- /dev/null +++ b/SU2_CFD/include/numerics/turbulent/CUpwScalar.hpp @@ -0,0 +1,99 @@ +/*! + * \file CUpwScalar.hpp + * \brief Delaration of numerics class CUpwScalar, the + * implementation is in the CUpwScalar.cpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../CNumerics.hpp" + +/*! + * \class CUpwScalar + * \brief Template class for scalar upwind fluxes between nodes i and j. + * \details This class serves as a template for the scalar upwinding residual + * classes. The general structure of a scalar upwinding calculation is the + * same for many different models, which leads to a lot of repeated code. + * By using the template design pattern, these sections of repeated code are + * moved to this shared base class, and the specifics of each model + * are implemented by derived classes. In order to add a new residual + * calculation for a convection residual, extend this class and implement + * the pure virtual functions with model-specific behavior. + * \ingroup ConvDiscr + * \author C. Pederson, A. Bueno., and A. Campos. + */ +class CUpwScalar : public CNumerics { +private: + + /*! + * \brief A pure virtual function; Adds any extra variables to AD + */ + virtual void ExtraADPreaccIn() = 0; + + /*! + * \brief Model-specific steps in the ComputeResidual method + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + virtual void FinishResidualCalc(su2double *val_residual, + su2double **Jacobian_i, + su2double **Jacobian_j, + CConfig *config) = 0; + +protected: + su2double *Velocity_i, *Velocity_j; /*!< \brief Velocity, minus any grid movement. */ + su2double Density_i, Density_j; + bool implicit, dynamic_grid, incompressible; + su2double q_ij, /*!< \brief Projected velocity at the face. */ + a0, /*!< \brief The maximum of the face-normal velocity and 0 */ + a1; /*!< \brief The minimum of the face-normal velocity and 0 */ + unsigned short iDim; + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CUpwScalar(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CUpwScalar(void); + + /*! + * \brief Compute the scalar upwind flux between two nodes i and j. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); +}; diff --git a/SU2_CFD/include/numerics_structure.hpp b/SU2_CFD/include/numerics_structure.hpp deleted file mode 100644 index 135cb3bd4e88..000000000000 --- a/SU2_CFD/include/numerics_structure.hpp +++ /dev/null @@ -1,5381 +0,0 @@ -/*! - * \file numerics_structure.hpp - * \brief Headers of the main subroutines for the dumerical definition of the problem. - * The subroutines and functions are in the numerics_structure.cpp, - * numerics_convective.cpp, numerics_viscous.cpp, and - * numerics_source.cpp files. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../../Common/include/mpi_structure.hpp" - -#include -#include -#include -#include - -#include "../../Common/include/config_structure.hpp" -#include "../../Common/include/geometry/elements/CElement.hpp" -#include "fluid_model.hpp" - -using namespace std; - -/*! - * \class CNumerics - * \brief Class for defining the numerical methods. - * \author F. Palacios, T. Economon - */ -class CNumerics { -protected: - unsigned short nDim, nVar; /*!< \brief Number of dimensions and variables. */ - su2double Gamma; /*!< \brief Fluid's Gamma constant (ratio of specific heats). */ - su2double Gamma_Minus_One; /*!< \brief Fluids's Gamma - 1.0 . */ - su2double Minf; /*!< \brief Free stream Mach number . */ - su2double Gas_Constant; /*!< \brief Gas constant. */ - su2double *Vector; /*!< \brief Auxiliary vector. */ - su2double *Enthalpy_formation; /*!< \brief Enthalpy of formation. */ - su2double Prandtl_Lam; /*!< \brief Laminar Prandtl's number. */ - su2double Prandtl_Turb; /*!< \brief Turbulent Prandtl's number. */ - -public: - - su2double - **Flux_Tensor, /*!< \brief Flux tensor (used for viscous and inviscid purposes. */ - *Proj_Flux_Tensor; /*!< \brief Flux tensor projected in a direction. */ - - su2double - **tau, /*!< \brief Viscous stress tensor. */ - **delta, /*!< \brief Identity matrix. */ - **delta3; /*!< \brief 3 row Identity matrix. */ - su2double - *Diffusion_Coeff_i, /*!< \brief Species diffusion coefficients at point i. */ - *Diffusion_Coeff_j; /*!< \brief Species diffusion coefficients at point j. */ - su2double - Laminar_Viscosity_i, /*!< \brief Laminar viscosity at point i. */ - Laminar_Viscosity_j, /*!< \brief Laminar viscosity at point j. */ - Laminar_Viscosity_id, /*!< \brief Variation of laminar viscosity at point i. */ - Laminar_Viscosity_jd; /*!< \brief Variation of laminar viscosity at point j. */ - su2double - Thermal_Conductivity_i, /*!< \brief Thermal conductivity at point i. */ - Thermal_Conductivity_j, /*!< \brief Thermal conductivity at point j. */ - Thermal_Conductivity_ve_i, /*!< \brief Thermal conductivity at point i. */ - Thermal_Conductivity_ve_j, /*!< \brief Thermal conductivity at point j. */ - Thermal_Diffusivity_i, /*!< \brief Thermal diffusivity at point i. */ - Thermal_Diffusivity_j; /*!< \brief Thermal diffusivity at point j. */ - su2double - Cp_i, /*!< \brief Cp at point i. */ - Cp_j; /*!< \brief Cp at point j. */ - su2double *Theta_v; /*!< \brief Characteristic vibrational temperature */ - su2double - Eddy_Viscosity_i, /*!< \brief Eddy viscosity at point i. */ - Eddy_Viscosity_j; /*!< \brief Eddy viscosity at point j. */ - su2double - turb_ke_i, /*!< \brief Turbulent kinetic energy at point i. */ - turb_ke_j; /*!< \brief Turbulent kinetic energy at point j. */ - su2double - Pressure_i, /*!< \brief Pressure at point i. */ - Pressure_j; /*!< \brief Pressure at point j. */ - su2double - GravityForce_i, /*!< \brief Gravity force at point i. */ - GravityForce_j; /*!< \brief Gravity force at point j. */ - su2double - Density_i, /*!< \brief Density at point i. */ - Density_j; /*!< \brief Density at point j. */ - su2double - DensityInc_i, /*!< \brief Incompressible density at point i. */ - DensityInc_j; /*!< \brief Incompressible density at point j. */ - su2double - BetaInc2_i, /*!< \brief Beta incompressible at point i. */ - BetaInc2_j; /*!< \brief Beta incompressible at point j. */ - su2double - Lambda_i, /*!< \brief Spectral radius at point i. */ - Lambda_j; /*!< \brief Spectral radius at point j. */ - su2double - LambdaComb_i, /*!< \brief Spectral radius at point i. */ - LambdaComb_j; /*!< \brief Spectral radius at point j. */ - su2double - SoundSpeed_i, /*!< \brief Sound speed at point i. */ - SoundSpeed_j; /*!< \brief Sound speed at point j. */ - su2double - Enthalpy_i, /*!< \brief Enthalpy at point i. */ - Enthalpy_j; /*!< \brief Enthalpy at point j. */ - su2double - dist_i, /*!< \brief Distance of point i to the nearest wall. */ - dist_j; /*!< \brief Distance of point j to the nearest wall. */ - su2double - Temp_i, /*!< \brief Temperature at point i. */ - Temp_j; /*!< \brief Temperature at point j. */ - su2double - *Temp_tr_i, /*!< \brief Temperature transl-rot at point i. */ - *Temp_tr_j; /*!< \brief Temperature transl-rot at point j. */ - su2double - *Temp_vib_i, /*!< \brief Temperature vibrational at point i. */ - *Temp_vib_j; /*!< \brief Temperature vibrational at point j. */ - su2double - *Und_Lapl_i, /*!< \brief Undivided laplacians at point i. */ - *Und_Lapl_j; /*!< \brief Undivided laplacians at point j. */ - su2double - Sensor_i, /*!< \brief Pressure sensor at point i. */ - Sensor_j; /*!< \brief Pressure sensor at point j. */ - su2double - *GridVel_i, /*!< \brief Grid velocity at point i. */ - *GridVel_j; /*!< \brief Grid velocity at point j. */ - su2double - *U_i, /*!< \brief Vector of conservative variables at point i. */ - *U_id, /*!< \brief Vector of derivative of conservative variables at point i. */ - *UZeroOrder_i, /*!< \brief Vector of conservative variables at point i without reconstruction. */ - *U_j, /*!< \brief Vector of conservative variables at point j. */ - *UZeroOrder_j, /*!< \brief Vector of conservative variables at point j without reconstruction. */ - *U_jd, /*!< \brief Vector of derivative of conservative variables at point j. */ - *U_0, /*!< \brief Vector of conservative variables at node 0. */ - *U_1, /*!< \brief Vector of conservative variables at node 1. */ - *U_2, /*!< \brief Vector of conservative variables at node 2. */ - *U_3; /*!< \brief Vector of conservative variables at node 3. */ - su2double - *V_i, /*!< \brief Vector of primitive variables at point i. */ - *V_j; /*!< \brief Vector of primitive variables at point j. */ - su2double - *S_i, /*!< \brief Vector of secondary variables at point i. */ - *S_j; /*!< \brief Vector of secondary variables at point j. */ - su2double - *Psi_i, /*!< \brief Vector of adjoint variables at point i. */ - *Psi_j; /*!< \brief Vector of adjoint variables at point j. */ - su2double - *DeltaU_i, /*!< \brief Vector of linearized variables at point i. */ - *DeltaU_j; /*!< \brief Vector of linearized variables at point j. */ - su2double - *TurbVar_i, /*!< \brief Vector of turbulent variables at point i. */ - *TurbVar_id, /*!< \brief Vector of derivative of turbulent variables at point i. */ - *TurbVar_j, /*!< \brief Vector of turbulent variables at point j. */ - *TurbVar_jd; /*!< \brief Vector of derivative of turbulent variables at point j. */ - su2double - *TransVar_i, /*!< \brief Vector of turbulent variables at point i. */ - *TransVar_j; /*!< \brief Vector of turbulent variables at point j. */ - su2double - *TurbPsi_i, /*!< \brief Vector of adjoint turbulent variables at point i. */ - *TurbPsi_j; /*!< \brief Vector of adjoint turbulent variables at point j. */ - su2double - **ConsVar_Grad_i, /*!< \brief Gradient of conservative variables at point i. */ - **ConsVar_Grad_j, /*!< \brief Gradient of conservative variables at point j. */ - **ConsVar_Grad_0, /*!< \brief Gradient of conservative variables at point 0. */ - **ConsVar_Grad_1, /*!< \brief Gradient of conservative variables at point 1. */ - **ConsVar_Grad_2, /*!< \brief Gradient of conservative variables at point 2. */ - **ConsVar_Grad_3, /*!< \brief Gradient of conservative variables at point 3. */ - **ConsVar_Grad; /*!< \brief Gradient of conservative variables which is a scalar. */ - su2double - **PrimVar_Grad_i, /*!< \brief Gradient of primitive variables at point i. */ - **PrimVar_Grad_j; /*!< \brief Gradient of primitive variables at point j. */ - su2double - **PsiVar_Grad_i, /*!< \brief Gradient of adjoint variables at point i. */ - **PsiVar_Grad_j; /*!< \brief Gradient of adjoint variables at point j. */ - su2double - **TurbVar_Grad_i, /*!< \brief Gradient of turbulent variables at point i. */ - **TurbVar_Grad_j; /*!< \brief Gradient of turbulent variables at point j. */ - su2double - **TransVar_Grad_i, /*!< \brief Gradient of turbulent variables at point i. */ - **TransVar_Grad_j; /*!< \brief Gradient of turbulent variables at point j. */ - su2double - **TurbPsi_Grad_i, /*!< \brief Gradient of adjoint turbulent variables at point i. */ - **TurbPsi_Grad_j; /*!< \brief Gradient of adjoint turbulent variables at point j. */ - su2double - *AuxVar_Grad_i, /*!< \brief Gradient of an auxiliary variable at point i. */ - *AuxVar_Grad_j; /*!< \brief Gradient of an auxiliary variable at point i. */ - su2double - *Coord_i, /*!< \brief Cartesians coordinates of point i. */ - *Coord_j, /*!< \brief Cartesians coordinates of point j. */ - *Coord_0, /*!< \brief Cartesians coordinates of point 0 (Galerkin method, triangle). */ - *Coord_1, /*!< \brief Cartesians coordinates of point 1 (Galerkin method, tetrahedra). */ - *Coord_2, /*!< \brief Cartesians coordinates of point 2 (Galerkin method, triangle). */ - *Coord_3; /*!< \brief Cartesians coordinates of point 3 (Galerkin method, tetrahedra). */ - unsigned short - Neighbor_i, /*!< \brief Number of neighbors of the point i. */ - Neighbor_j; /*!< \brief Number of neighbors of the point j. */ - su2double - *Normal, /*!< \brief Normal vector, it norm is the area of the face. */ - *UnitNormal, /*!< \brief Unitary normal vector. */ - *UnitNormald; /*!< \brief derivatve of unitary normal vector. */ - su2double - TimeStep, /*!< \brief Time step useful in dual time method. */ - Area, /*!< \brief Area of the face i-j. */ - Volume; /*!< \brief Volume of the control volume around point i. */ - su2double - Volume_n, /*!< \brief Volume of the control volume at time n. */ - Volume_nM1, /*!< \brief Volume of the control volume at time n-1. */ - Volume_nP1; /*!< \brief Volume of the control volume at time n+1. */ - su2double - *U_n, /*!< \brief Vector of conservative variables at time n. */ - *U_nM1, /*!< \brief Vector of conservative variables at time n-1. */ - *U_nP1; /*!< \brief Vector of conservative variables at time n+1. */ - su2double vel2_inf; /*!< \brief value of the square of freestream speed. */ - su2double - *WindGust_i, /*!< \brief Wind gust at point i. */ - *WindGust_j; /*!< \brief Wind gust at point j. */ - su2double - *WindGustDer_i, /*!< \brief Wind gust derivatives at point i. */ - *WindGustDer_j; /*!< \brief Wind gust derivatives at point j. */ - su2double *Vorticity_i, *Vorticity_j; /*!< \brief Vorticity. */ - su2double StrainMag_i, StrainMag_j; /*!< \brief Strain rate magnitude. */ - su2double Dissipation_i, Dissipation_j; /*!< \brief Dissipation. */ - su2double Dissipation_ij; - - su2double *l, *m; - - su2double **MeanReynoldsStress; /*!< \brief Mean Reynolds stress tensor */ - su2double **MeanPerturbedRSM; /*!< \brief Perturbed Reynolds stress tensor */ - bool using_uq; /*!< \brief Flag for UQ methodology */ - su2double PerturbedStrainMag; /*!< \brief Strain magnitude calculated using perturbed stress tensor */ - unsigned short Eig_Val_Comp; /*!< \brief Component towards which perturbation is perfromed */ - su2double uq_delta_b; /*!< \brief Magnitude of perturbation */ - su2double uq_urlx; /*!< \brief Under-relaxation factor for numerical stability */ - bool uq_permute; /*!< \brief Flag for eigenvector permutation */ - - /* Supporting data structures for the eigenspace perturbation for UQ methodology */ - su2double **A_ij, **newA_ij, **Eig_Vec, **New_Eig_Vec, **Corners; - su2double *Eig_Val, *Barycentric_Coord, *New_Coord; - - /*! - * \brief Constructor of the class. - */ - CNumerics(void); - - /*! - * \overload - * \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. - */ - CNumerics(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - virtual ~CNumerics(void); - - /*! - * \brief Compute the determinant of a 3 by 3 matrix. - * \param[in] val_matrix 3 by 3 matrix. - * \result Determinant of the matrix - */ - su2double Determinant_3x3(su2double A00, su2double A01, su2double A02, - su2double A10, su2double A11, su2double A12, - su2double A20, su2double A21, su2double A22); - - /*! - * \brief Set the solution at different times. - * \param[in] val_u_nM1 Conservative solution at time n-1. - * \param[in] val_u_n Conservative solution at time n. - * \param[in] val_u_nP1 Conservative solution at time n+1. - */ - void SetPastSol(su2double *val_u_nM1, su2double *val_u_n, su2double *val_u_nP1); - - /*! - * \brief Set the control volume at different times. - * \param[in] val_volume_nM1 - Control volume at time n-1. - * \param[in] val_volume_n - Control volume at time n. - * \param[in] val_volume_nP1 - Control volume at time n+1. - */ - void SetPastVolume(su2double val_volume_nM1, su2double val_volume_n, su2double val_volume_nP1); - - /*! - * \brief Set the time step. - * \param[in] val_timestep - Value of the time step. - */ - void SetTimeStep(su2double val_timestep); - - /*! - * \brief Set the freestream velocity square. - * \param[in] SetVelocity2_Inf - Value of the square of the freestream velocity. - */ - void SetVelocity2_Inf(su2double val_velocity2); - - /*! - * \brief Set the value of the vorticity - * \param[in] val_vorticity - Value of the vorticity. - */ - void SetVorticity(su2double *val_vorticity_i, su2double *val_vorticity_j); - - /*! - * \brief Set the value of the rate of strain magnitude. - * \param[in] val_StrainMag_i - Value of the magnitude of rate of strain at point i. - * \param[in] val_StrainMag_j - Value of the magnitude of rate of strain at point j. - */ - void SetStrainMag(su2double val_strainmag_i, su2double val_strainmag_j); - - /*! - * \brief Set the value of the conservative variables. - * \param[in] val_u_i - Value of the conservative variable at point i. - * \param[in] val_u_j - Value of the conservative variable at point j. - */ - void SetConservative(su2double *val_u_i, su2double *val_u_j); - - /*! - * \brief Set the value of the conservative variables withour reconstruction. - * \param[in] val_u_i - Value of the conservative variable at point i. - * \param[in] val_u_j - Value of the conservative variable at point j. - */ - void SetConservative_ZeroOrder(su2double *val_u_i, su2double *val_u_j); - - /*! - * \brief Set the value of the primitive variables. - * \param[in] val_v_i - Value of the primitive variable at point i. - * \param[in] val_v_j - Value of the primitive variable at point j. - */ - void SetPrimitive(su2double *val_v_i, su2double *val_v_j); - - /*! - * \brief Set the value of the primitive variables. - * \param[in] val_v_i - Value of the primitive variable at point i. - * \param[in] val_v_j - Value of the primitive variable at point j. - */ - void SetSecondary(su2double *val_s_i, su2double *val_s_j); - - /*! - * \brief Set the value of the conservative variables. - * \param[in] val_u_0 - Value of the conservative variable at point 0. - * \param[in] val_u_1 - Value of the conservative variable at point 1. - * \param[in] val_u_2 - Value of the conservative variable at point 2. - */ - void SetConservative(su2double *val_u_0, su2double *val_u_1, su2double *val_u_2); - - /*! - * \brief Set the value of the conservative variables. - * \param[in] val_u_0 - Value of the conservative variable at point 0. - * \param[in] val_u_1 - Value of the conservative variable at point 1. - * \param[in] val_u_2 - Value of the conservative variable at point 2. - * \param[in] val_u_3 - Value of the conservative variable at point 3. - */ - void SetConservative(su2double *val_u_0, su2double *val_u_1, su2double *val_u_2, su2double *val_u_3); - - /*! - * \brief Set the gradient of the conservative variables. - * \param[in] val_consvar_grad_i - Gradient of the conservative variable at point i. - * \param[in] val_consvar_grad_j - Gradient of the conservative variable at point j. - */ - void SetConsVarGradient(su2double **val_consvar_grad_i, su2double **val_consvar_grad_j); - - /*! - * \brief Set the gradient of the conservative variables. - * \param[in] val_consvar_grad_0 - Gradient of the conservative variable at point 0. - * \param[in] val_consvar_grad_1 - Gradient of the conservative variable at point 1. - * \param[in] val_consvar_grad_2 - Gradient of the conservative variable at point 2. - */ - void SetConsVarGradient(su2double **val_consvar_grad_0, - su2double **val_consvar_grad_1, - su2double **val_consvar_grad_2); - - /*! - * \brief Set the gradient of the conservative variables. - * \param[in] val_consvar_grad_0 - Gradient of the conservative variable at point 0. - * \param[in] val_consvar_grad_1 - Gradient of the conservative variable at point 1. - * \param[in] val_consvar_grad_2 - Gradient of the conservative variable at point 2. - * \param[in] val_consvar_grad_3 - Gradient of the conservative variable at point 3. - */ - void SetConsVarGradient(su2double **val_consvar_grad_0, - su2double **val_consvar_grad_1, - su2double **val_consvar_grad_2, - su2double **val_consvar_grad_3); - - /*! - * \brief Set the gradient of the conservative variables. - * \param[in] val_consvar_grad - Gradient of the conservative variable which is a scalar. - */ - void SetConsVarGradient(su2double **val_consvar_grad); - - /*! - * \brief Set the gradient of the primitive variables. - * \param[in] val_primvar_grad_i - Gradient of the primitive variable at point i. - * \param[in] val_primvar_grad_j - Gradient of the primitive variable at point j. - */ - void SetPrimVarGradient(su2double **val_primvar_grad_i, - su2double **val_primvar_grad_j); - - /*! - * \brief Set the value of the adjoint variable. - * \param[in] val_psi_i - Value of the adjoint variable at point i. - * \param[in] val_psi_j - Value of the adjoint variable at point j. - */ - void SetAdjointVar(su2double *val_psi_i, su2double *val_psi_j); - - /*! - * \brief Set the gradient of the adjoint variables. - * \param[in] val_psivar_grad_i - Gradient of the adjoint variable at point i. - * \param[in] val_psivar_grad_j - Gradient of the adjoint variable at point j. - */ - void SetAdjointVarGradient(su2double **val_psivar_grad_i, su2double **val_psivar_grad_j); - - /*! - * \brief Set the value of the turbulent variable. - * \param[in] val_turbvar_i - Value of the turbulent variable at point i. - * \param[in] val_turbvar_j - Value of the turbulent variable at point j. - */ - void SetTurbVar(su2double *val_turbvar_i, su2double *val_turbvar_j); - - /*! - * \brief Set the value of the turbulent variable. - * \param[in] val_transvar_i - Value of the turbulent variable at point i. - * \param[in] val_transvar_j - Value of the turbulent variable at point j. - */ - void SetTransVar(su2double *val_transvar_i, su2double *val_transvar_j); - - /*! - * \brief Set the gradient of the turbulent variables. - * \param[in] val_turbvar_grad_i - Gradient of the turbulent variable at point i. - * \param[in] val_turbvar_grad_j - Gradient of the turbulent variable at point j. - */ - void SetTurbVarGradient(su2double **val_turbvar_grad_i, su2double **val_turbvar_grad_j); - - /*! - * \brief Set the gradient of the turbulent variables. - * \param[in] val_turbvar_grad_i - Gradient of the turbulent variable at point i. - * \param[in] val_turbvar_grad_j - Gradient of the turbulent variable at point j. - */ - void SetTransVarGradient(su2double **val_transvar_grad_i, su2double **val_transvar_grad_j); - - /*! - * \brief Set the value of the adjoint turbulent variable. - * \param[in] val_turbpsivar_i - Value of the adjoint turbulent variable at point i. - * \param[in] val_turbpsivar_j - Value of the adjoint turbulent variable at point j. - */ - void SetTurbAdjointVar(su2double *val_turbpsivar_i, su2double *val_turbpsivar_j); - - /*! - * \brief Set the gradient of the adjoint turbulent variables. - * \param[in] val_turbpsivar_grad_i - Gradient of the adjoint turbulent variable at point i. - * \param[in] val_turbpsivar_grad_j - Gradient of the adjoint turbulent variable at point j. - */ - void SetTurbAdjointGradient (su2double **val_turbpsivar_grad_i, su2double **val_turbpsivar_grad_j); - - /*! - * \brief Set the value of the first blending function. - * \param[in] val_F1_i - Value of the first Menter blending function at point i. - * \param[in] val_F1_j - Value of the first Menter blending function at point j. - */ - virtual void SetF1blending(su2double val_F1_i, su2double val_F1_j) {/* empty */}; - - /*! - * \brief Set the value of the second blending function. - * \param[in] val_F1_i - Value of the second Menter blending function at point i. - * \param[in] val_F1_j - Value of the second Menter blending function at point j. - */ - virtual void SetF2blending(su2double val_F1_i, su2double val_F1_j) {/* empty */}; - - /*! - * \brief Set the value of the cross diffusion for the SST model. - * \param[in] val_CDkw_i - Value of the cross diffusion at point i. - * \param[in] val_CDkw_j - Value of the cross diffusion at point j. - */ - virtual void SetCrossDiff(su2double val_CDkw_i, su2double val_CDkw_j) {/* empty */}; - - /*! - * \brief Set the gradient of the auxiliary variables. - * \param[in] val_auxvargrad_i - Gradient of the auxiliary variable at point i. - * \param[in] val_auxvargrad_j - Gradient of the auxiliary variable at point j. - */ - void SetAuxVarGrad(su2double *val_auxvargrad_i, su2double *val_auxvargrad_j); - - /*! - * \brief Set the diffusion coefficient - * \param[in] val_diffusioncoeff_i - Value of the diffusion coefficients at i. - * \param[in] val_diffusioncoeff_j - Value of the diffusion coefficients at j - */ - void SetDiffusionCoeff(su2double* val_diffusioncoeff_i, - su2double* val_diffusioncoeff_j); - - /*! - * \brief Set the laminar viscosity. - * \param[in] val_laminar_viscosity_i - Value of the laminar viscosity at point i. - * \param[in] val_laminar_viscosity_j - Value of the laminar viscosity at point j. - */ - void SetLaminarViscosity(su2double val_laminar_viscosity_i, - su2double val_laminar_viscosity_j); - - /*! - * \brief Set the thermal conductivity (translational/rotational) - * \param[in] val_thermal_conductivity_i - Value of the thermal conductivity at point i. - * \param[in] val_thermal_conductivity_j - Value of the thermal conductivity at point j. - * \param[in] iSpecies - Value of the species. - */ - void SetThermalConductivity(su2double val_thermal_conductivity_i, - su2double val_thermal_conductivity_j); - - /*! - * \brief Set the thermal conductivity (translational/rotational) - * \param[in] val_thermal_conductivity_i - Value of the thermal conductivity at point i. - * \param[in] val_thermal_conductivity_j - Value of the thermal conductivity at point j. - * \param[in] iSpecies - Value of the species. - */ - void SetThermalConductivity_ve(su2double val_thermal_conductivity_ve_i, - su2double val_thermal_conductivity_ve_j); - - /*! - * \brief Set the thermal diffusivity (translational/rotational) - * \param[in] val_thermal_diffusivity_i - Value of the thermal diffusivity at point i. - * \param[in] val_thermal_diffusivity_j - Value of the thermal diffusivity at point j. - * \param[in] iSpecies - Value of the species. - */ - void SetThermalDiffusivity(su2double val_thermal_diffusivity_i, - su2double val_thermal_diffusivity_j); - /*! - * \brief Set the eddy viscosity. - * \param[in] val_eddy_viscosity_i - Value of the eddy viscosity at point i. - * \param[in] val_eddy_viscosity_j - Value of the eddy viscosity at point j. - */ - void SetEddyViscosity(su2double val_eddy_viscosity_i, - su2double val_eddy_viscosity_j); - - /*! - * \brief Set the turbulent kinetic energy. - * \param[in] val_turb_ke_i - Value of the turbulent kinetic energy at point i. - * \param[in] val_turb_ke_j - Value of the turbulent kinetic energy at point j. - */ - void SetTurbKineticEnergy(su2double val_turb_ke_i, su2double val_turb_ke_j); - - /*! - * \brief Set the value of the distance from the nearest wall. - * \param[in] val_dist_i - Value of of the distance from point i to the nearest wall. - * \param[in] val_dist_j - Value of of the distance from point j to the nearest wall. - */ - void SetDistance(su2double val_dist_i, su2double val_dist_j); - - /*! - * \brief Set coordinates of the points. - * \param[in] val_coord_i - Coordinates of the point i. - * \param[in] val_coord_j - Coordinates of the point j. - */ - void SetCoord(su2double *val_coord_i, su2double *val_coord_j); - - /*! - * \overload - * \param[in] val_coord_0 - Coordinates of the point 0. - * \param[in] val_coord_1 - Coordinates of the point 1. - * \param[in] val_coord_2 - Coordinates of the point 2. - */ - void SetCoord(su2double *val_coord_0, su2double *val_coord_1, su2double *val_coord_2); - - /*! - * \overload - * \param[in] val_coord_0 - Coordinates of the point 0. - * \param[in] val_coord_1 - Coordinates of the point 1. - * \param[in] val_coord_2 - Coordinates of the point 2. - * \param[in] val_coord_3 - Coordinates of the point 3. - */ - void SetCoord(su2double *val_coord_0, su2double *val_coord_1, su2double *val_coord_2, - su2double *val_coord_3); - - /*! - * \brief Set the velocity of the computational grid. - * \param[in] val_gridvel_i - Grid velocity of the point i. - * \param[in] val_gridvel_j - Grid velocity of the point j. - */ - void SetGridVel(su2double *val_gridvel_i, su2double *val_gridvel_j); - - /*! - * \brief Set the wind gust value. - * \param[in] val_windgust_i - Wind gust of the point i. - * \param[in] val_windgust_j - Wind gust of the point j. - */ - void SetWindGust(su2double *val_windgust_i, su2double *val_windgust_j); - - /*! - * \brief Set the wind gust derivatives values. - * \param[in] val_windgust_i - Wind gust derivatives of the point i. - * \param[in] val_windgust_j - Wind gust derivatives of the point j. - */ - void SetWindGustDer(su2double *val_windgustder_i, su2double *val_windgustder_j); - - /*! - * \brief Set the value of the pressure. - * \param[in] val_pressure_i - Value of the pressure at point i. - * \param[in] val_pressure_j - Value of the pressure at point j. - */ - void SetPressure(su2double val_pressure_i, su2double val_pressure_j); - - /*! - * \brief Set the value of the density for the incompressible solver. - * \param[in] val_densityinc_i - Value of the pressure at point i. - * \param[in] val_densityinc_j - Value of the pressure at point j. - */ - void SetDensity(su2double val_densityinc_i, su2double val_densityinc_j); - - /*! - * \brief Set the value of the beta for incompressible flows. - * \param[in] val_betainc2_i - Value of beta for incompressible flows at point i. - * \param[in] val_betainc2_j - Value of beta for incompressible flows at point j. - */ - void SetBetaInc2(su2double val_betainc2_i, su2double val_betainc2_j); - - /*! - * \brief Set the value of the sound speed. - * \param[in] val_soundspeed_i - Value of the sound speed at point i. - * \param[in] val_soundspeed_j - Value of the sound speed at point j. - */ - void SetSoundSpeed(su2double val_soundspeed_i, su2double val_soundspeed_j); - - /*! - * \brief Set the value of the temperature. - * \param[in] val_temp_i - Value of the temperature at point i. - * \param[in] val_temp_j - Value of the temperature at point j. - */ - void SetTemperature(su2double val_temp_i, su2double val_temp_j); - - /*! - * \brief Set the value of the enthalpy. - * \param[in] val_enthalpy_i - Value of the enthalpy at point i. - * \param[in] val_enthalpy_j - Value of the enthalpy at point j. - */ - void SetEnthalpy(su2double val_enthalpy_i, su2double val_enthalpy_j); - - /*! - * \brief Set the value of the spectral radius. - * \param[in] val_lambda_i - Value of the spectral radius at point i. - * \param[in] val_lambda_j - Value of the spectral radius at point j. - */ - void SetLambda(su2double val_lambda_i, su2double val_lambda_j); - - /*! - * \brief Set the value of undivided laplacian. - * \param[in] val_und_lapl_i Undivided laplacian at point i. - * \param[in] val_und_lapl_j Undivided laplacian at point j. - */ - void SetUndivided_Laplacian(su2double *val_und_lapl_i, su2double *val_und_lapl_j); - - /*! - * \brief Set the value of the pressure sensor. - * \param[in] val_sensor_i Pressure sensor at point i. - * \param[in] val_sensor_j Pressure sensor at point j. - */ - void SetSensor(su2double val_sensor_i, su2double val_sensor_j); - - /*! - * \brief Set the number of neighbor to a point. - * \param[in] val_neighbor_i - Number of neighbor to point i. - * \param[in] val_neighbor_j - Number of neighbor to point j. - */ - void SetNeighbor(unsigned short val_neighbor_i, unsigned short val_neighbor_j); - - /*! - * \brief Set the value of the normal vector to the face between two points. - * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. - */ - void SetNormal(su2double *val_normal); - - /*! - * \brief Set the value of the volume of the control volume. - * \param[in] val_volume Volume of the control volume. - */ - void SetVolume(su2double val_volume); - - /*! - * \brief Retrieves the value of the species density in the primitive variable vector. - * \param[in] iRho_s - */ - void SetRhosIndex(unsigned short val_Index); - - /*! - * \brief Retrieves the value of the species density in the primitive variable vector. - * \param[in] iRho_s - */ - void SetRhoIndex(unsigned short val_Index); - - /*! - * \brief Retrieves the value of the species density in the primitive variable vector. - * \param[in] iRho_s - */ - void SetPIndex(unsigned short val_Index); - - /*! - * \brief Retrieves the value of the species density in the primitive variable vector. - * \param[in] iRho_s - */ - void SetTIndex(unsigned short val_Index); - - /*! - * \brief Retrieves the value of the species density in the primitive variable vector. - * \param[in] iRho_s - */ - void SetTveIndex(unsigned short val_Index); - - /*! - * \brief Retrieves the value of the velocity index in the primitive variable vector. - * \param[in] i(rho*u) - */ - void SetVelIndex(unsigned short val_Index); - - /*! - * \brief Retrieves the value of the species density in the primitive variable vector. - * \param[in] iRho_s - */ - void SetHIndex(unsigned short val_Index); - - /*! - * \brief Retrieves the value of the species density in the primitive variable vector. - * \param[in] iRho_s - */ - void SetAIndex(unsigned short val_Index); - - /*! - * \brief Retrieves the value of the species density in the primitive variable vector. - * \param[in] iRho_s - */ - void SetRhoCvtrIndex(unsigned short val_Index); - - /*! - * \brief Retrieves the value of the species density in the primitive variable vector. - * \param[in] iRho_s - */ - void SetRhoCvveIndex(unsigned short val_Index); - - /*! - * \brief Sets the value of the derivative of pressure w.r.t. species density. - * \param[in] iRho_s - */ - void SetdPdU(su2double *val_dPdU_i, su2double *val_dPdU_j); - - /*! - * \brief Sets the value of the derivative of temperature w.r.t. species density. - * \param[in] iRho_s - */ - void SetdTdU(su2double *val_dTdU_i, su2double *val_dTdU_j); - - /*! - * \brief Sets the value of the derivative of vib-el. temperature w.r.t. species density. - * \param[in] iRho_s - */ - void SetdTvedU(su2double *val_dTvedU_i, su2double *val_dTvedU_j); - - /*! - * \brief Sets the values of the roe dissipation. - * \param[in] diss_i - Dissipation value at node i - * \param[in] diss_j - Dissipation value at node j - */ - void SetDissipation(su2double diss_i, su2double diss_j); - - /*! - * \brief Get the final Roe dissipation factor. - */ - su2double GetDissipation(); - - /*! - * \brief Get the inviscid fluxes. - * \param[in] val_density - Value of the density. - * \param[in] val_velocity - Value of the velocity. - * \param[in] val_pressure - Value of the pressure. - * \param[in] val_enthalpy - Value of the enthalpy. - */ - void GetInviscidFlux(su2double val_density, su2double *val_velocity, su2double val_pressure, su2double val_enthalpy); - - /*! - * \brief Compute the projected inviscid flux vector. - * \param[in] val_density - Pointer to the density. - * \param[in] val_velocity - Pointer to the velocity. - * \param[in] val_pressure - Pointer to the pressure. - * \param[in] val_enthalpy - Pointer to the enthalpy. - * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. - * \param[out] val_Proj_Flux - Pointer to the projected flux. - */ - void GetInviscidProjFlux(su2double *val_density, su2double *val_velocity, - su2double *val_pressure, su2double *val_enthalpy, - su2double *val_normal, su2double *val_Proj_Flux); - - /*! - * \brief Compute the projected inviscid flux vector for incompresible simulations - * \param[in] val_density - Pointer to the density. - * \param[in] val_velocity - Pointer to the velocity. - * \param[in] val_pressure - Pointer to the pressure. - * \param[in] val_betainc2 - Value of the artificial compresibility factor. - * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. - * \param[out] val_Proj_Flux - Pointer to the projected flux. - */ - void GetInviscidIncProjFlux(su2double *val_density, su2double *val_velocity, - su2double *val_pressure, su2double *val_betainc2, - su2double *val_enthalpy, - su2double *val_normal, su2double *val_Proj_Flux); - - /*! - * \brief Compute the projection of the inviscid Jacobian matrices. - * \param[in] val_velocity Pointer to the velocity. - * \param[in] val_energy Value of the energy. - * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. - * \param[in] val_scale - Scale of the projection. - * \param[out] val_Proj_Jac_tensor - Pointer to the projected inviscid Jacobian. - */ - void GetInviscidProjJac(su2double *val_velocity, su2double *val_energy, - su2double *val_normal, su2double val_scale, - su2double **val_Proj_Jac_tensor); - - /*! - * \brief Compute the projection of the inviscid Jacobian matrices (incompressible). - * \param[in] val_density - Value of the density. - * \param[in] val_velocity - Pointer to the velocity. - * \param[in] val_betainc2 - Value of the artificial compresibility factor. - * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. - * \param[in] val_scale - Scale of the projection. - * \param[out] val_Proj_Jac_tensor - Pointer to the projected inviscid Jacobian. - */ - void GetInviscidIncProjJac(su2double *val_density, su2double *val_velocity, - su2double *val_betainc2, su2double *val_normal, - su2double val_scale, - su2double **val_Proj_Jac_tensor); - - /*! - * \brief Compute the projection of the inviscid Jacobian matrices (overload for low speed preconditioner version). - * \param[in] val_density - Value of the density. - * \param[in] val_velocity - Pointer to the velocity. - * \param[in] val_betainc2 - Value of the artificial compresibility factor. - * \param[in] val_cp - Value of the specific heat at constant pressure. - * \param[in] val_temperature - Value of the temperature. - * \param[in] val_dRhodT - Value of the derivative of density w.r.t. temperature. - * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. - * \param[in] val_scale - Scale of the projection. - * \param[out] val_Proj_Jac_tensor - Pointer to the projected inviscid Jacobian. - */ - void GetInviscidIncProjJac(su2double *val_density, - su2double *val_velocity, - su2double *val_betainc2, - su2double *val_cp, - su2double *val_temperature, - su2double *val_dRhodT, - su2double *val_normal, - su2double val_scale, - su2double **val_Proj_Jac_Tensor); - - /*! - * \brief Compute the low speed preconditioning matrix. - * \param[in] val_density - Value of the density. - * \param[in] val_velocity - Pointer to the velocity. - * \param[in] val_betainc2 - Value of the artificial compresibility factor. - * \param[in] val_cp - Value of the specific heat at constant pressure. - * \param[in] val_temperature - Value of the temperature. - * \param[in] val_dRhodT - Value of the derivative of density w.r.t. temperature. - * \param[out] val_Precon - Pointer to the preconditioning matrix. - */ - void GetPreconditioner(su2double *val_density, - su2double *val_velocity, - su2double *val_betainc2, - su2double *val_cp, - su2double *val_temperature, - su2double *val_drhodt, - su2double **val_Precon); - - /*! - * \brief Compute the projection of the preconditioned inviscid Jacobian matrices. - * \param[in] val_density - Value of the density. - * \param[in] val_velocity - Pointer to the velocity. - * \param[in] val_betainc2 - Value of the artificial compresibility factor. - * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. - * \param[out] val_Proj_Jac_tensor - Pointer to the projected inviscid Jacobian. - */ - void GetPreconditionedProjJac(su2double *val_density, - su2double *val_velocity, - su2double *val_betainc2, - su2double *val_normal, - su2double **val_Proj_Jac_Tensor); - - /*! - * \brief Compute the projection of the inviscid Jacobian matrices for general fluid model. - * \param[in] val_velocity Pointer to the velocity. - * \param[in] val_energy Value of the energy. - * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. - * \param[in] val_scale - Scale of the projection. - * \param[out] val_Proj_Jac_tensor - Pointer to the projected inviscid Jacobian. - */ - void GetInviscidProjJac(su2double *val_velocity, su2double *val_enthalphy, - su2double *val_chi, su2double *val_kappa, - su2double *val_normal, su2double val_scale, - su2double **val_Proj_Jac_tensor); - - /*! - * \brief Mapping between primitives variables P and conservatives variables C. - * \param[in] val_Mean_PrimVar - Mean value of the primitive variables. - * \param[in] val_Mean_PrimVar - Mean Value of the secondary variables. - * \param[out] val_Jac_PC - Pointer to the Jacobian dPdC. - */ - void GetPrimitive2Conservative (su2double *val_Mean_PrimVar, - su2double *val_Mean_SecVar, - su2double **val_Jac_PC); - - /*! - * \overload - * \brief Computation of the matrix P for a generic fluid model - * \param[in] val_density - Value of the density. - * \param[in] val_velocity - Value of the velocity. - * \param[in] val_soundspeed - Value of the sound speed. - * \param[in] val_enthalpy - Value of the Enthalpy - * \param[in] val_chi - Value of the derivative of Pressure with respect to the Density. - * \param[in] val_kappa - Value of the derivative of Pressure with respect to the volume specific Static Energy. - * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. - * \param[out] val_p_tensor - Pointer to the P matrix. - */ - void GetPMatrix(su2double *val_density, su2double *val_velocity, - su2double *val_soundspeed, su2double *val_enthalpy, su2double *val_chi, su2double *val_kappa, - su2double *val_normal, su2double **val_p_tensor); - - /*! - * \brief Computation of the matrix P, this matrix diagonalize the conservative Jacobians in - * the form $P^{-1}(A.Normal)P=Lambda$. - * \param[in] val_density - Value of the density. - * \param[in] val_velocity - Value of the velocity. - * \param[in] val_soundspeed - Value of the sound speed. - * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. - * \param[out] val_p_tensor - Pointer to the P matrix. - */ - void GetPMatrix(su2double *val_density, su2double *val_velocity, - su2double *val_soundspeed, su2double *val_normal, - su2double **val_p_tensor); - - /*! - * \brief Computation of the matrix Rinv*Pe. - * \param[in] Beta2 - A variable in used to define Pe matrix. - * \param[in] val_enthalpy - value of the enthalpy. - * \param[in] val_soundspeed - value of the sound speed. - * \param[in] val_density - value of the density. - * \param[in] val_velocity - value of the velocity. - * \param[out] val_invR_invPe - Pointer to the matrix of conversion from entropic to conserved variables. - */ - void GetinvRinvPe(su2double Beta2, su2double val_enthalpy, su2double val_soundspeed, - su2double val_density, su2double* val_velocity, - su2double** val_invR_invPe); - - /*! - * \brief Computation of the matrix R. - * \param[in] val_pressure - value of the pressure. - * \param[in] val_soundspeed - value of the sound speed. - * \param[in] val_density - value of the density. - * \param[in] val_velocity - value of the velocity. - * \param[out] val_invR_invPe - Pointer to the matrix of conversion from entropic to conserved variables. - */ - - void GetRMatrix(su2double val_pressure, su2double val_soundspeed, - su2double val_density, su2double* val_velocity, - su2double** val_invR_invPe); - /*! - * \brief Computation of the matrix R. - * \param[in] val_soundspeed - value of the sound speed. - * \param[in] val_density - value of the density. - * \param[out] R_Matrix - Pointer to the matrix of conversion from entropic to conserved variables. - */ - void GetRMatrix(su2double val_soundspeed, su2double val_density, su2double **R_Matrix); - - /*! - * \brief Computation of the matrix R. - * \param[in] val_soundspeed - value of the sound speed. - * \param[in] val_density - value of the density. - * \param[out] L_Matrix - Pointer to the matrix of conversion from conserved to entropic variables. - */ - void GetLMatrix(su2double val_soundspeed, su2double val_density, su2double **L_Matrix); - - /*! - * \brief Computation of the flow Residual Jacoboan Matrix for Non Reflecting BC. - * \param[in] val_soundspeed - value of the sound speed. - * \param[in] val_density - value of the density. - * \param[out] R_c - Residual Jacoboan Matrix - * \param[out] R_c_inv- inverse of the Residual Jacoboan Matrix . - */ - void ComputeResJacobianGiles(CFluidModel *FluidModel, su2double pressure, su2double density, su2double *turboVel, - su2double alphaInBC, su2double gammaInBC, su2double **R_c, su2double **R_c_inv); - - /*! - * \brief Computate the inverse of a 3x3 matrix - * \param[in] matrix - the matrix to invert - * \param[out] invMatrix - inverse matrix. - */ - void InvMatrix3D(su2double **matrix, su2double **invMatrix); - - /*! - * \brief Computate the inverse of a 4x4 matrix - * \param[in] matrix - the matrix to invert - * \param[out] invMatrix - inverse matrix. - */ - void InvMatrix4D(su2double **matrix, su2double **invMatrix); - - /*! - * \brief Computation of the matrix R. - * \param[in] val_soundspeed - value of the sound speed. - * \param[in] val_density - value of the density. - * \param[in] prim_jump - pointer to the vector containing the primitive variable jump (drho, dV, dp). - * \param[out]char_jump - pointer to the vector containing the characteristic variable jump. - */ - void GetCharJump(su2double val_soundspeed, su2double val_density, su2double *prim_jump, su2double *char_jump); - - /*! - * \brief Computation of the matrix Td, this matrix diagonalize the preconditioned conservative Jacobians - * in the form $Tg |Lambda| Td = Pc{-1}|Pc (A.Normal)|$. - * \param[in] Beta2 - A variable in used to define absPeJacobian matrix. - * \param[in] r_hat - A variable in used to define absPeJacobian matrix. - * \param[in] s_hat - A variable in used to define absPeJacobian matrix. - * \param[in] t_hat - A variable in used to define absPeJacobian matrix. - * \param[in] rB2a2 - A variable in used to define absPeJacobian matrix. - * \param[in] val_Lambda - Eigenvalues of the Preconditioned Jacobian. - * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. - * \param[out] val_absPeJac - Pointer to the Preconditioned Jacobian matrix. - */ - void GetPrecondJacobian(su2double Beta2, su2double r_hat, su2double s_hat, su2double t_hat, su2double rB2a2, su2double* val_Lambda, su2double* val_normal, su2double** val_absPeJac); - - - /*! - * \brief Computation of the matrix P^{-1}, this matrix diagonalize the conservative Jacobians - * in the form $P^{-1}(A.Normal)P=Lambda$. - * \param[in] val_density - Value of the density. - * \param[in] val_velocity - Value of the velocity. - * \param[in] val_soundspeed - Value of the sound speed. - * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. - * \param[out] val_invp_tensor - Pointer to inverse of the P matrix. - */ - void GetPMatrix_inv(su2double **val_invp_tensor, su2double *val_density, - su2double *val_velocity, su2double *val_soundspeed, - su2double *val_chi, su2double *val_kappa, - su2double *val_normal); - - /*! - * \brief Computation of the matrix P^{-1}, this matrix diagonalize the conservative Jacobians - * in the form $P^{-1}(A.Normal)P=Lambda$. - * \param[in] val_density - Value of the density. - * \param[in] val_velocity - Value of the velocity. - * \param[in] val_soundspeed - Value of the sound speed. - * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. - * \param[out] val_invp_tensor - Pointer to inverse of the P matrix. - */ - void GetPMatrix_inv(su2double *val_density, su2double *val_velocity, - su2double *val_soundspeed, su2double *val_normal, - su2double **val_invp_tensor); - - /*! - * \brief Compute viscous residual and jacobian. - */ - void GetAdjViscousFlux_Jac(su2double Pressure_i, su2double Pressure_j, su2double Density_i, su2double Density_j, - su2double ViscDens_i, su2double ViscDens_j, su2double *Velocity_i, su2double *Velocity_j, - su2double sq_vel_i, su2double sq_vel_j, - su2double XiDens_i, su2double XiDens_j, su2double **Mean_GradPhi, su2double *Mean_GradPsiE, - su2double dPhiE_dn, su2double *Normal, su2double *Edge_Vector, su2double dist_ij_2, su2double *val_residual_i, - su2double *val_residual_j, - su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, su2double **val_Jacobian_ji, - su2double **val_Jacobian_jj, bool implicit); - - /*! - * \brief Computation of the projected inviscid lambda (eingenvalues). - * \param[in] val_velocity - Value of the velocity. - * \param[in] val_soundspeed - Value of the sound speed. - * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. - * \param[in] val_Lambda_Vector - Pointer to Lambda matrix. - */ - void GetJacInviscidLambda_fabs(su2double *val_velocity, su2double val_soundspeed, - su2double *val_normal, su2double *val_Lambda_Vector); - - /*! - * \brief Compute the numerical residual. - * \param[out] val_residual - Pointer to the total residual. - * \param[in] config - Definition of the particular problem. - */ - virtual void ComputeResidual(su2double *val_residual, CConfig *config); - - /*! - * \overload - * \param[out] val_residual_i - Pointer to the total residual at point i. - * \param[out] val_residual_j - Pointer to the total residual at point j. - */ - virtual void ComputeResidual(su2double *val_residual_i, su2double *val_residual_j); - - virtual void ComputeResidual_TransLM(su2double *val_residual, - su2double **val_Jacobian_i, - su2double **val_Jacobian_j, CConfig *config, - su2double &gamma_sep) ; - - /*! - * \overload - * \param[out] val_residual_i - Pointer to the total residual at point i. - * \param[out] val_residual_j - Pointer to the total residual at point j. - * \param[in] config - Definition of the particular problem. - */ - virtual void ComputeResidual(su2double *val_residual_i, - su2double *val_residual_j, CConfig *config); - - /*! - * \overload - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - virtual void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, - su2double **val_Jacobian_j, CConfig *config); - - /*! - * \overload - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[out] val_JacobianMeanFlow_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_JacobianMeanFlow_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - virtual void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, - su2double **val_Jacobian_j, - su2double **val_JacobianMeanFlow_i, - su2double **val_JacobianMeanFlow_j, - CConfig *config); - - /*! - * \overload - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - virtual void ComputeResidual(su2double **val_Jacobian_i, su2double **val_Jacobian_j, - CConfig *config); - - /*! - * \overload - * \param[out] val_resconv - Pointer to the convective residual. - * \param[out] val_resvisc - Pointer to the artificial viscosity residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - virtual void ComputeResidual(su2double *val_resconv, su2double *val_resvisc, - su2double **val_Jacobian_i, su2double **val_Jacobian_j, - CConfig *config); - - /*! - * \overload - * \param[out] val_residual_i - Pointer to the total residual at point i. - * \param[out] val_residual_j - Pointer to the total viscosity residual at point j. - * \param[out] val_Jacobian_ii - Jacobian of the numerical method at node i (implicit computation) from node i. - * \param[out] val_Jacobian_ij - Jacobian of the numerical method at node i (implicit computation) from node j. - * \param[out] val_Jacobian_ji - Jacobian of the numerical method at node j (implicit computation) from node i. - * \param[out] val_Jacobian_jj - Jacobian of the numerical method at node j (implicit computation) from node j. - * \param[in] config - Definition of the particular problem. - */ - virtual void ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, - su2double **val_Jacobian_ii, - su2double **val_Jacobian_ij, - su2double **val_Jacobian_ji, - su2double **val_Jacobian_jj, CConfig *config); - - /*! - * \overload - * \param[out] val_resconv_i - Pointer to the convective residual at point i. - * \param[out] val_resvisc_i - Pointer to the artificial viscosity residual at point i. - * \param[out] val_resconv_j - Pointer to the convective residual at point j. - * \param[out] val_resvisc_j - Pointer to the artificial viscosity residual at point j. - * \param[out] val_Jacobian_ii - Jacobian of the numerical method at node i (implicit computation) from node i. - * \param[out] val_Jacobian_ij - Jacobian of the numerical method at node i (implicit computation) from node j. - * \param[out] val_Jacobian_ji - Jacobian of the numerical method at node j (implicit computation) from node i. - * \param[out] val_Jacobian_jj - Jacobian of the numerical method at node j (implicit computation) from node j. - * \param[in] config - Definition of the particular problem. - */ - virtual void ComputeResidual(su2double *val_resconv_i, su2double *val_resvisc_i, - su2double *val_resconv_j, su2double *val_resvisc_j, - su2double **val_Jacobian_ii, - su2double **val_Jacobian_ij, - su2double **val_Jacobian_ji, - su2double **val_Jacobian_jj, CConfig *config); - - /*! - * \overload - * \param[out] val_stiffmatrix_elem - Stiffness matrix for Galerkin computation. - * \param[in] config - Definition of the particular problem. - */ - virtual void ComputeResidual(su2double **val_stiffmatrix_elem, CConfig *config); - - /*! - * \overload - * \param[in] config - Definition of the particular problem. - * \param[out] val_residual - residual of the source terms - * \param[out] val_Jacobian_i - Jacobian of the source terms - */ - virtual void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, - CConfig *config); - - /*! - * \overload - * \param[out] - Matrix for storing the constants to be used in the calculation of the equilibrium extent of reaction Keq. - * \param[in] config - Definition of the particular problem. - */ - virtual void GetEq_Rxn_Coefficients(su2double **EqnRxnConstants, CConfig *config); - - /*! - * \brief Residual for source term integration. - * \param[out] val_residual - Pointer to the source residual containing chemistry terms. - * \param[in] config - Definition of the particular problem. - */ - virtual void ComputeResidual_Axisymmetric(su2double *val_residual, CConfig *config); - - /*! - * \brief Residual for source term integration. - * \param[out] val_residual - Pointer to the source residual containing chemistry terms. - * \param[in] config - Definition of the particular problem. - */ - virtual void ComputeResidual_Axisymmetric_ad(su2double *val_residual, su2double *val_residuald, CConfig *config); - - /*! - * \brief Calculation of axisymmetric source term Jacobian - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - virtual void SetJacobian_Axisymmetric(su2double **val_Jacobian_i, CConfig *config); - - /*! - * \brief Calculation of the translational-vibrational energy exchange source term - * \param[in] config - Definition of the particular problem. - * \param[out] val_residual - residual of the source terms - * \param[out] val_Jacobian_i - Jacobian of the source terms - */ - virtual void ComputeVibRelaxation(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config); - - /*! - * \brief Calculation of the chemistry source term - * \param[in] config - Definition of the particular problem. - * \param[out] val_residual - residual of the source terms - * \param[out] val_Jacobian_i - Jacobian of the source terms - */ - virtual void ComputeChemistry(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config); - - /*! - * \brief Calculates constants used for Keq correlation. - * \param[out] A - Pointer to coefficient array. - * \param[in] val_reaction - Reaction number indicator. - * \param[in] config - Definition of the particular problem. - */ - virtual void GetKeqConstants(su2double *A, unsigned short val_reaction, CConfig *config); - - /*! - * \brief Set intermittency for numerics (used in SA with LM transition model) - */ - virtual void SetIntermittency(su2double intermittency_in); - - /*! - * \brief Residual for source term integration. - * \param[in] val_production - Value of the Production. - */ - virtual void SetProduction(su2double val_production); - - /*! - * \brief Residual for source term integration. - * \param[in] val_destruction - Value of the Destruction. - */ - virtual void SetDestruction(su2double val_destruction); - - /*! - * \brief Residual for source term integration. - * \param[in] val_crossproduction - Value of the CrossProduction. - */ - virtual void SetCrossProduction(su2double val_crossproduction); - - /*! - * \brief Residual for source term integration. - * \param[in] val_production - Value of the Production. - */ - virtual su2double GetProduction(void); - - /*! - * \brief Residual for source term integration. - * \param[in] val_destruction - Value of the Destruction. - */ - virtual su2double GetDestruction(void); - - /*! - * \brief Residual for source term integration. - * \param[in] val_crossproduction - Value of the CrossProduction. - */ - virtual su2double GetCrossProduction(void); - - /*! - * \brief A virtual member. - */ - virtual su2double GetGammaBC(void); - - /*! - * \overload - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i - * \param[in] config - Definition of the particular problem. - */ - virtual void ComputeResidual(su2double **val_Jacobian_i, - su2double *val_Jacobian_mui, - su2double ***val_Jacobian_gradi, CConfig *config); - - /*! - * \overload - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i - * \param[in] config - Definition of the particular problem. - */ - virtual void ComputeResidual(su2double **val_Jacobian_i, - su2double *val_Jacobian_mui, - su2double ***val_Jacobian_gradi, - su2double **val_Jacobian_j, - su2double *val_Jacobian_muj, - su2double ***val_Jacobian_gradj, CConfig *config); - - /*! - * \brief A virtual member to compute the tangent matrix in structural problems - * \param[in] element_container - Element structure for the particular element integrated. - */ - virtual void Compute_Tangent_Matrix(CElement *element_container, CConfig *config); - - /*! - * \brief A virtual member to compute the nodal stress term in non-linear structural problems - * \param[in] element_container - Definition of the particular element integrated. - */ - virtual void Compute_NodalStress_Term(CElement *element_container, CConfig *config); - - /*! - * \brief Set the element-based local Young's modulus in mesh problems - * \param[in] iElem - Element index. - * \param[in] val_E - Value of elasticity modulus. - */ - virtual void SetMeshElasticProperties(unsigned long iElem, su2double val_E); - - /*! - * \brief A virtual member to set the value of the design variables - * \param[in] i_DV - Index of the design variable. - * \param[in] val_DV - Value of the design variable - */ - virtual void Set_DV_Val(unsigned short i_DV, su2double val_DV); - - /*! - * \brief A virtual member to retrieve the value of the design variables - * \param[in] i_DV - Index of the design variable. - */ - virtual su2double Get_DV_Val(unsigned short i_DV) const; - - /*! - * \brief A virtual member to set the electric field - * \param[in] EField_DV - New electric field computed by adjoint methods. - */ - virtual void Set_ElectricField(unsigned short i_DV, su2double val_EField); - - /*! - * \brief A virtual member to set the material properties - * \param[in] iVal - Index of the region of concern - * \param[in] val_E - Value of the Young Modulus. - * \param[in] val_Nu - Value of the Poisson's ratio. - */ - virtual void SetMaterial_Properties(unsigned short iVal, su2double val_E, su2double val_Nu); - - /*! - * \brief A virtual member to set the material properties - * \param[in] iVal - Index of the region of concern - * \param[in] val_Rho - Value of the density (inertial effects). - * \param[in] val_Rho_DL - Value of the density (dead load effects). - */ - virtual void SetMaterial_Density(unsigned short iVal, su2double val_Rho, su2double val_Rho_DL); - - /*! - * \brief A virtual member to compute the mass matrix - * \param[in] element_container - Element structure for the particular element integrated. - */ - virtual void Compute_Mass_Matrix(CElement *element_container, CConfig *config); - - /*! - * \brief A virtual member to compute the residual component due to dead loads - * \param[in] element_container - Element structure for the particular element integrated. - */ - virtual void Compute_Dead_Load(CElement *element_container, CConfig *config); - - /*! - * \brief A virtual member to compute the averaged nodal stresses - * \param[in] element_container - Element structure for the particular element integrated. - */ - virtual void Compute_Averaged_NodalStress(CElement *element_container, CConfig *config); - - /*! - * \brief Computes a basis of orthogonal vectors from a suppled vector - * \param[in] config - Normal vector - */ - void CreateBasis(su2double *val_Normal); - - /*! - * \brief Set the value of the Tauwall - * \param[in] val_tauwall_i - Tauwall at point i - * \param[in] val_tauwall_j - Tauwall at point j - */ - virtual void SetTauWall(su2double val_tauwall_i, su2double val_tauwall_j); - - /*! - * \brief - Calculate the central/upwind blending function for a face - * - * At its simplest level, this function will calculate the average - * value of the "Roe dissipation" or central/upwind blending function - * at a face. If Ducros shock sensors are used, then this method will - * also adjust the central/upwind blending to account for shocks. - * - * \param[in] Dissipation_i - Value of the blending function at point i - * \param[in] Dissipation_j - Value of the bledning function at point j - * \param[in] Sensor_i - Shock sensor at point i - * \param[in] Sensor_j - Shock sensor at point j - * \param[out] Dissipation_ij - Blending parameter at face - */ - void SetRoe_Dissipation(const su2double Dissipation_i, - const su2double Dissipation_j, - const su2double Sensor_i, const su2double Sensor_j, - su2double& Dissipation_ij, CConfig *config); - - /*! - * \brief Setting the UQ framework usage - * \param[in] val_using_uq - */ - void SetUsing_UQ(bool val_using_uq); - - /*! - * \brief Decomposes the symmetric matrix A_ij, into eigenvectors and eigenvalues - * \param[in] A_i: symmetric matrix to be decomposed - * \param[in] Eig_Vec: strores the eigenvectors - * \param[in] Eig_Val: stores the eigenvalues - * \param[in] n: order of matrix A_ij - */ - static void EigenDecomposition(su2double **A_ij, su2double **Eig_Vec, su2double *Eig_Val, unsigned short n); - - /*! - * \brief Recomposes the eigenvectors and eigenvalues into a matrix - * \param[in] A_ij: recomposed matrix - * \param[in] Eig_Vec: eigenvectors - * \param[in] Eig_Val: eigenvalues - * \param[in] n: order of matrix A_ij - */ - static void EigenRecomposition(su2double **A_ij, su2double **Eig_Vec, su2double *Eig_Val, unsigned short n); - - /*! - * \brief tred2 - * \param[in] V: matrix that needs to be decomposed - * \param[in] d: holds eigenvalues - * \param[in] e: supplemental data structure - * \param[in] n: order of matrix V - */ - static void tred2(su2double **V, su2double *d, su2double *e, unsigned short n); - - /*! - * \brief tql2 - * \param[in] V: matrix that will hold the eigenvectors - * \param[in] d: array that will hold the ordered eigenvalues - * \param[in] e: supplemental data structure - * \param[in] n: order of matrix V - - */ - static void tql2(su2double **V, su2double *d, su2double *e, unsigned short n); - -}; - -/*! - * \class CUpwCUSP_Flow - * \brief Class for centered scheme - CUSP. - * \ingroup ConvDiscr - * \author F. Palacios - */ -class CUpwCUSP_Flow : public CNumerics { - -private: - su2double *Velocity_i, *Velocity_j, *ProjFlux_i, *ProjFlux_j; - bool implicit; - -public: - - /*! - * \brief Constructor of the class. - * \param[in] val_nDim - Number of dimension of the problem. - * \param[in] val_nVar - Number of variables of the problem. - * \param[in] config - Definition of the particular problem. - */ - CUpwCUSP_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwCUSP_Flow(void); - - /*! - * \brief Compute the flow residual using a JST method. - * \param[out] val_residual - Pointer to the residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, - CConfig *config); -}; - -/*! - * \class CUpwRoeBase_Flow - * \brief Intermediate base class for Roe schemes on ideal gas. - * \ingroup ConvDiscr - * \author A. Bueno, F. Palacios - */ -class CUpwRoeBase_Flow : public CNumerics { -protected: - bool implicit, dynamic_grid, roe_low_dissipation; - su2double *Velocity_i, *Velocity_j, *ProjFlux_i, *ProjFlux_j, *Conservatives_i, *Conservatives_j; - su2double *Diff_U, *Lambda, **P_Tensor, **invP_Tensor; - su2double *RoeVelocity, RoeDensity, RoeEnthalpy, RoeSoundSpeed, ProjVelocity, RoeSoundSpeed2, kappa; - - /*! - * \brief Derived classes must specialize this method to add the specifics of the scheme they implement (e.g. low-Mach precond.). - * \param[out] val_residual - Convective flux. - * \param[out] val_Jacobian_i - Flux Jacobian wrt node i conservatives (implicit computation). - * \param[out] val_Jacobian_j - Flux Jacobian wrt node j conservatives (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - virtual void FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) = 0; - -public: - - /*! - * \brief Constructor of the class. - * \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. - * \param[in] val_low_dissipation - Use a low dissipation formulation. - */ - CUpwRoeBase_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, bool val_low_dissipation); - - /*! - * \brief Destructor of the class. - */ - ~CUpwRoeBase_Flow(void); - - /*! - * \brief Compute the flux from node i to node j, part common to most Roe schemes. - * \param[out] val_residual - Convective flux. - * \param[out] val_Jacobian_i - Flux Jacobian wrt node i conservatives (implicit computation). - * \param[out] val_Jacobian_j - Flux Jacobian wrt node j conservatives (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - -}; - -/*! - * \class CUpwRoe_Flow - * \brief Class for solving an approximate Riemann solver of Roe for the flow equations. - * \ingroup ConvDiscr - * \author A. Bueno, F. Palacios - */ -class CUpwRoe_Flow : public CUpwRoeBase_Flow { -private: - /*! - * \brief Add standard Roe dissipation to the flux. - * \param[out] val_residual - Convective flux. - * \param[out] val_Jacobian_i - Flux Jacobian wrt node i conservatives (implicit computation). - * \param[out] val_Jacobian_j - Flux Jacobian wrt node j conservatives (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - -public: - - /*! - * \brief Constructor of the class. - * \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. - * \param[in] val_low_dissipation - Use a low dissipation formulation. - */ - CUpwRoe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, bool val_low_dissipation); - - /*! - * \brief Destructor of the class. - */ - ~CUpwRoe_Flow(void); - -}; - - -/*! - * \class CUpwGeneralRoe_Flow - * \brief Class for solving an approximate Riemann solver of Roe for the flow equations for a general fluid model. - * \ingroup ConvDiscr - * \author S.Vitale, G.Gori, M.Pini - */ -class CUpwGeneralRoe_Flow : public CNumerics { -private: - - bool implicit, dynamic_grid; - - su2double *Diff_U; - su2double *Velocity_i, *Velocity_j, *RoeVelocity; - su2double *ProjFlux_i, *ProjFlux_j; - su2double *delta_wave, *delta_vel; - su2double *Lambda, *Epsilon, MaxLambda, Delta; - su2double **P_Tensor, **invP_Tensor; - su2double sq_vel, Proj_ModJac_Tensor_ij, Density_i, Energy_i, SoundSpeed_i, Pressure_i, Enthalpy_i, - - Density_j, Energy_j, SoundSpeed_j, Pressure_j, Enthalpy_j, R, RoeDensity, RoeEnthalpy, RoeSoundSpeed, RoeSoundSpeed2, - ProjVelocity, ProjVelocity_i, ProjVelocity_j, proj_delta_vel, delta_p, delta_rho, kappa; - unsigned short iDim, iVar, jVar, kVar; - - - su2double StaticEnthalpy_i, StaticEnergy_i, StaticEnthalpy_j, StaticEnergy_j, Kappa_i, Kappa_j, Chi_i, Chi_j, Velocity2_i, Velocity2_j; - su2double RoeKappa, RoeChi; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwGeneralRoe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwGeneralRoe_Flow(void); - - /*! - * \brief Compute the Roe's flux between two nodes i and j. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - - /*! - * \brief Compute the Average for a general fluid flux between two nodes i and j. - * Using the approach of Vinokur and Montagne' - */ - - void ComputeRoeAverage(); -}; - -/*! - * \class CUpwL2Roe_Flow - * \brief Class for solving an approximate Riemann solver of L2Roe for the flow equations. - * \ingroup ConvDiscr - * \author E. Molina, A. Bueno, F. Palacios - * \version 7.0.0 "Blackbird" - */ -class CUpwL2Roe_Flow : public CUpwRoeBase_Flow { -private: - /*! - * \brief Add L^2 Roe dissipation to the flux (low-Mach scheme). - * \param[out] val_residual - Convective flux. - * \param[out] val_Jacobian_i - Flux Jacobian wrt node i conservatives (implicit computation). - * \param[out] val_Jacobian_j - Flux Jacobian wrt node j conservatives (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - -public: - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwL2Roe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwL2Roe_Flow(void); -}; - -/*! - * \class CUpwLMRoe_Flow - * \brief Class for solving an approximate Riemann solver of LMRoe for the flow equations. - * \ingroup ConvDiscr - * \author E. Molina, A. Bueno, F. Palacios - * \version 7.0.0 "Blackbird" - */ -class CUpwLMRoe_Flow : public CUpwRoeBase_Flow { -private: - /*! - * \brief Add LMRoe dissipation to the flux (low-Mach scheme). - * \param[out] val_residual - Convective flux. - * \param[out] val_Jacobian_i - Flux Jacobian wrt node i conservatives (implicit computation). - * \param[out] val_Jacobian_j - Flux Jacobian wrt node j conservatives (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - -public: - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwLMRoe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwLMRoe_Flow(void); -}; - -/*! - * \class CUpwMSW_Flow - * \brief Class for solving a flux-vector splitting method by Steger & Warming, modified version. - * \ingroup ConvDiscr - * \author S. Copeland - */ -class CUpwMSW_Flow : public CNumerics { -private: - bool implicit; - su2double *Diff_U; - su2double *u_i, *u_j, *ust_i, *ust_j; - su2double *Fc_i, *Fc_j; - su2double *Lambda_i, *Lambda_j; - su2double rhos_i, rhos_j; - su2double *Ust_i, *Ust_j, *Vst_i, *Vst_j, *Velst_i, *Velst_j; - su2double **P_Tensor, **invP_Tensor; - unsigned short nPrimVar, nVar, nDim; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwMSW_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwMSW_Flow(void); - - /*! - * \brief Compute the Roe's flux between two nodes i and j. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - -}; - -/*! - * \class CUpwTurkel_Flow - * \brief Class for solving an approximate Riemann solver of Roe with Turkel Preconditioning for the flow equations. - * \ingroup ConvDiscr - * \author A. K. Lonkar - */ -class CUpwTurkel_Flow : public CNumerics { -private: - bool implicit, dynamic_grid; - su2double *Diff_U; - su2double *Velocity_i, *Velocity_j, *RoeVelocity; - su2double *ProjFlux_i, *ProjFlux_j; - su2double *Lambda, *Epsilon; - su2double **absPeJac, **invRinvPe, **R_Tensor, **Matrix, **Art_Visc; - su2double sq_vel, Density_i, Energy_i, SoundSpeed_i, Pressure_i, Enthalpy_i, - Density_j, Energy_j, SoundSpeed_j, Pressure_j, Enthalpy_j, R, RoePressure, RoeDensity, RoeEnthalpy, RoeSoundSpeed, - ProjVelocity, ProjVelocity_i, ProjVelocity_j; - unsigned short iDim, iVar, jVar, kVar; - su2double Beta, Beta_min, Beta_max; - su2double r_hat, s_hat, t_hat, rhoB2a2, sqr_one_m_Betasqr_Lam1; - su2double Beta2, one_m_Betasqr, one_p_Betasqr, sqr_two_Beta_c_Area; - su2double local_Mach; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwTurkel_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwTurkel_Flow(void); - - /*! - * \brief Compute the Roe's flux between two nodes i and j. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - -}; - -/*! - * \class CUpwFDSInc_Flow - * \brief Class for solving a Flux Difference Splitting (FDS) upwind method for the incompressible flow equations. - * \ingroup ConvDiscr - * \author F. Palacios, T. Economon - */ -class CUpwFDSInc_Flow : public CNumerics { -private: - bool implicit, /*!< \brief Implicit calculation. */ - dynamic_grid, /*!< \brief Modification for grid movement. */ - variable_density, /*!< \brief Variable density incompressible flows. */ - energy; /*!< \brief computation with the energy equation. */ - su2double *Diff_V; - su2double *Velocity_i, *Velocity_j, *MeanVelocity; - su2double *ProjFlux_i, *ProjFlux_j; - su2double *Lambda, *Epsilon; - su2double **Precon, **invPrecon_A; - su2double Proj_ModJac_Tensor_ij, Pressure_i, - Pressure_j, ProjVelocity, - MeandRhodT, dRhodT_i, dRhodT_j, /*!< \brief Derivative of density w.r.t. temperature (variable density flows). */ - Temperature_i, Temperature_j, /*!< \brief Temperature at node 0 and 1. */ - MeanDensity, MeanPressure, MeanSoundSpeed, MeanBetaInc2, MeanEnthalpy, MeanCp, MeanTemperature; /*!< \brief Mean values of primitive variables. */ - unsigned short iDim, iVar, jVar, kVar; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwFDSInc_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwFDSInc_Flow(void); - - /*! - * \brief Compute the upwind flux between two nodes i and j. - * \param[out] val_residual - Pointer to the residual array. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, - CConfig *config); -}; - -/*! - * \class CUpwRoe_AdjFlow - * \brief Class for solving an approximate Riemann solver of Roe - * for the adjoint flow equations. - * \ingroup ConvDiscr - * \author F. Palacios - */ -class CUpwRoe_AdjFlow : public CNumerics { -private: - su2double *Residual_Roe; - su2double area, Sx, Sy, Sz, rarea, nx, ny, nz, rho_l, u_l, v_l, w_l, h_l, rho_r, - u_r, v_r, w_r, h_r, psi1, psi2, psi3, psi4, psi5; - su2double h, u, v, w, c, psi1_l, psi2_l, psi3_l, psi4_l, psi5_l, - psi1_r, psi2_r, psi3_r, psi4_r, psi5_r, q_l, q_r, Q_l, Q_r, vn, - rrho_l, weight, rweight1, cc; - su2double l1psi, l2psi, absQ, absQp, absQm, q2, alpha, beta_u, beta_v, beta_w, Q, l1l2p, l1l2m, eta; - su2double RoeDensity, RoeSoundSpeed, *RoeVelocity, *Lambda, *Velocity_i, *Velocity_j, **ProjFlux_i, **ProjFlux_j, - Proj_ModJac_Tensor_ij, **Proj_ModJac_Tensor, Energy_i, Energy_j, **P_Tensor, **invP_Tensor; - unsigned short iDim, iVar, jVar, kVar; - bool implicit, grid_movement; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwRoe_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwRoe_AdjFlow(void); - - /*! - * \brief Compute the adjoint Roe's flux between two nodes i and j. - * \param[out] val_residual_i - Pointer to the total residual at point i. - * \param[out] val_residual_j - Pointer to the total residual at point j. - * \param[out] val_Jacobian_ii - Jacobian of the numerical method at node i (implicit computation) from node i. - * \param[out] val_Jacobian_ij - Jacobian of the numerical method at node i (implicit computation) from node j. - * \param[out] val_Jacobian_ji - Jacobian of the numerical method at node j (implicit computation) from node i. - * \param[out] val_Jacobian_jj - Jacobian of the numerical method at node j (implicit computation) from node j. - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, su2double **val_Jacobian_ii, - su2double **val_Jacobian_ij, su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config); -}; - -/*! - * \class CUpwAUSM_Flow - * \brief Class for solving an approximate Riemann AUSM. - * \ingroup ConvDiscr - * \author F. Palacios - */ -class CUpwAUSM_Flow : public CNumerics { -private: - bool implicit; - su2double *Diff_U; - su2double *Velocity_i, *Velocity_j, *RoeVelocity; - su2double *ProjFlux_i, *ProjFlux_j; - su2double *delta_wave, *delta_vel; - su2double *Lambda, *Epsilon; - su2double **P_Tensor, **invP_Tensor; - su2double sq_vel, Proj_ModJac_Tensor_ij, Density_i, Energy_i, SoundSpeed_i, Pressure_i, Enthalpy_i, - Density_j, Energy_j, SoundSpeed_j, Pressure_j, Enthalpy_j, R, RoeDensity, RoeEnthalpy, RoeSoundSpeed, - ProjVelocity, ProjVelocity_i, ProjVelocity_j; - unsigned short iDim, iVar, jVar, kVar; - su2double mL, mR, mLP, mRM, mF, pLP, pRM, pF, Phi; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwAUSM_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwAUSM_Flow(void); - - /*! - * \brief Compute the Roe's flux between two nodes i and j. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); -}; - -/*! - * \class CUpwAUSMPLUS_SLAU_Base_Flow - * \brief Base class for AUSM+up(2) and SLAU(2) convective schemes. - * \ingroup ConvDiscr - * \author Amit Sachdeva - */ -class CUpwAUSMPLUS_SLAU_Base_Flow : public CNumerics { -protected: - bool implicit; - bool UseAccurateJacobian; - bool HasAnalyticalDerivatives; - su2double FinDiffStep; - - su2double MassFlux, DissFlux, Pressure; - su2double *Velocity_i, *Velocity_j; - su2double *psi_i, *psi_j; - su2double dmdot_dVi[6], dmdot_dVj[6], dpres_dVi[6], dpres_dVj[6]; - - /*--- Roe variables (for approximate Jacobian) ---*/ - su2double *Lambda, *Epsilon, *RoeVelocity, **P_Tensor, **invP_Tensor; - - /*! - * \brief Compute the mass flux and pressure based on Primitives_i/j, derived classes must implement this method. - * \note See the body of the (empty) default implementation for instructions on how to implement the method. - * \param[in] config - Definition of the particular problem. - * \param[out] mdot - The mass flux. - * \param[out] pressure - The pressure at the control volume face. - */ - virtual void ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure) = 0; - - /*! - * \brief Compute the flux Jacobians of the Roe scheme to use as an approximation. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - */ - void ApproximateJacobian(su2double **val_Jacobian_i, su2double **val_Jacobian_j); - - /*! - * \brief Compute the flux Jacobians using a mix of finite differences and manual differentiation. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - */ - void AccurateJacobian(CConfig *config, su2double **val_Jacobian_i, su2double **val_Jacobian_j); - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwAUSMPLUS_SLAU_Base_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwAUSMPLUS_SLAU_Base_Flow(void); - - /*! - * \brief Compute the AUSM+ and SLAU family of schemes. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); -}; - -/*! - * \class CUpwAUSMPLUSUP_Flow - * \brief Class for solving an approximate Riemann AUSM+ -up. - * \ingroup ConvDiscr - * \author Amit Sachdeva - */ -class CUpwAUSMPLUSUP_Flow : public CUpwAUSMPLUS_SLAU_Base_Flow { -private: - su2double Kp, Ku, sigma; - - /*! - * \brief Mass flux and pressure for the AUSM+up scheme. - * \param[in] config - Definition of the particular problem. - * \param[out] mdot - The mass flux. - * \param[out] pressure - The pressure at the control volume face. - */ - void ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure); - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwAUSMPLUSUP_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwAUSMPLUSUP_Flow(void); -}; - -/*! - * \class CUpwAUSMPLUSUP2_Flow - * \brief Class for solving an approximate Riemann AUSM+ -up. - * \ingroup ConvDiscr - * \author Amit Sachdeva - */ -class CUpwAUSMPLUSUP2_Flow : public CUpwAUSMPLUS_SLAU_Base_Flow { -private: - su2double Kp, sigma; - - /*! - * \brief Mass flux and pressure for the AUSM+up2 scheme. - * \param[in] config - Definition of the particular problem. - * \param[out] mdot - The mass flux. - * \param[out] pressure - The pressure at the control volume face. - */ - void ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure); - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwAUSMPLUSUP2_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwAUSMPLUSUP2_Flow(void); - -}; - -/*! - * \class CUpwSLAU_Flow - * \brief Class for solving the Low-Dissipation AUSM. - * \ingroup ConvDiscr - * \author E. Molina - */ -class CUpwSLAU_Flow : public CUpwAUSMPLUS_SLAU_Base_Flow { -protected: - bool slau_low_diss; - bool slau2; - - /*! - * \brief Mass flux and pressure for the SLAU and SLAU2 schemes. - * \param[in] config - Definition of the particular problem. - * \param[out] mdot - The mass flux. - * \param[out] pressure - The pressure at the control volume face. - */ - void ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure); - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwSLAU_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, bool val_low_dissipation); - - /*! - * \brief Destructor of the class. - */ - ~CUpwSLAU_Flow(void); - -}; - -/*! - * \class CUpwSLAU2_Flow - * \brief Class for solving the Simple Low-Dissipation AUSM 2. - * \ingroup ConvDiscr - * \author E. Molina - */ -class CUpwSLAU2_Flow : public CUpwSLAU_Flow { -public: - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwSLAU2_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, bool val_low_dissipation); - - /*! - * \brief Destructor of the class. - */ - ~CUpwSLAU2_Flow(void); - -}; - -/*! - * \class CUpwHLLC_Flow - * \brief Class for solving an approximate Riemann HLLC. - * \ingroup ConvDiscr - * \author G. Gori, Politecnico di Milano - * \version 7.0.0 "Blackbird" - */ -class CUpwHLLC_Flow : public CNumerics { -private: - bool implicit, dynamic_grid; - unsigned short iDim, jDim, iVar, jVar; - - su2double *IntermediateState; - su2double *Velocity_i, *Velocity_j, *RoeVelocity; - - su2double sq_vel_i, Density_i, Energy_i, SoundSpeed_i, Pressure_i, Enthalpy_i, ProjVelocity_i; - su2double sq_vel_j, Density_j, Energy_j, SoundSpeed_j, Pressure_j, Enthalpy_j, ProjVelocity_j; - - su2double sq_velRoe, RoeDensity, RoeEnthalpy, RoeSoundSpeed, RoeProjVelocity, ProjInterfaceVel; - - su2double sL, sR, sM, pStar, EStar, rhoSL, rhoSR, Rrho, kappa; - - su2double Omega, RHO, OmegaSM; - su2double *dSm_dU, *dPI_dU, *drhoStar_dU, *dpStar_dU, *dEStar_dU; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwHLLC_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwHLLC_Flow(void); - - /*! - * \brief Compute the Roe's flux between two nodes i and j. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - -}; - -/*! - * \class CUpwGeneralHLLC_Flow - * \brief Class for solving an approximate Riemann HLLC. - * \ingroup ConvDiscr - * \author G. Gori, Politecnico di Milano - * \version 7.0.0 "Blackbird" - */ -class CUpwGeneralHLLC_Flow : public CNumerics { -private: - bool implicit, dynamic_grid; - unsigned short iDim, jDim, iVar, jVar; - - su2double *IntermediateState; - su2double *Velocity_i, *Velocity_j, *RoeVelocity; - - su2double sq_vel_i, Density_i, Energy_i, SoundSpeed_i, Pressure_i, Enthalpy_i, ProjVelocity_i, StaticEnthalpy_i, StaticEnergy_i; - su2double sq_vel_j, Density_j, Energy_j, SoundSpeed_j, Pressure_j, Enthalpy_j, ProjVelocity_j, StaticEnthalpy_j, StaticEnergy_j; - - su2double sq_velRoe, RoeDensity, RoeEnthalpy, RoeSoundSpeed, RoeProjVelocity, ProjInterfaceVel; - su2double Kappa_i, Kappa_j, Chi_i, Chi_j, RoeKappa, RoeChi, RoeKappaStaticEnthalpy; - - su2double sL, sR, sM, pStar, EStar, rhoSL, rhoSR, Rrho, kappa; - - su2double Omega, RHO, OmegaSM; - su2double *dSm_dU, *dPI_dU, *drhoStar_dU, *dpStar_dU, *dEStar_dU; - - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwGeneralHLLC_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwGeneralHLLC_Flow(void); - - /*! - - * \brief Compute the Roe's flux between two nodes i and j. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - - /*! - * \brief Compute the Average quantities for a general fluid flux between two nodes i and j. - * Using the approach of Vinokur and Montagne' - */ - void VinokurMontagne(); -}; - -/*! - * \class CUpwLin_TransLM - * \brief Class for performing a linear upwind solver for the Spalart-Allmaras turbulence model equations with transition - * \ingroup ConvDiscr - * \author A. Aranake - */ -class CUpwLin_TransLM : public CNumerics { -private: - su2double *Velocity_i; - su2double *Velocity_j; - bool implicit, incompressible; - su2double Density_i, Density_j, q_ij, a0, a1; - unsigned short iDim; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwLin_TransLM(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwLin_TransLM(void); - - /*! - * \brief Compute the upwind flux between two nodes i and j. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual (su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); -}; - -/*! - * \class CUpwLin_AdjTurb - * \brief Class for performing a linear upwind solver for the adjoint turbulence equations. - * \ingroup ConvDiscr - * \author A. Bueno. - */ -class CUpwLin_AdjTurb : public CNumerics { -private: - su2double *Velocity_i; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwLin_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwLin_AdjTurb(void); - - /*! - * \brief Compute the adjoint upwind flux between two nodes i and j. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual (su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); -}; - -/*! - * \class CUpwScalar - * \brief Template class for scalar upwind fluxes between nodes i and j. - * \details This class serves as a template for the scalar upwinding residual - * classes. The general structure of a scalar upwinding calculation is the - * same for many different models, which leads to a lot of repeated code. - * By using the template design pattern, these sections of repeated code are - * moved to this shared base class, and the specifics of each model - * are implemented by derived classes. In order to add a new residual - * calculation for a convection residual, extend this class and implement - * the pure virtual functions with model-specific behavior. - * \ingroup ConvDiscr - * \author C. Pederson, A. Bueno., and A. Campos. - */ -class CUpwScalar : public CNumerics { -private: - - /*! - * \brief A pure virtual function; Adds any extra variables to AD - */ - virtual void ExtraADPreaccIn() = 0; - - /*! - * \brief Model-specific steps in the ComputeResidual method - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - virtual void FinishResidualCalc(su2double *val_residual, - su2double **Jacobian_i, - su2double **Jacobian_j, - CConfig *config) = 0; - -protected: - su2double *Velocity_i, *Velocity_j; /*!< \brief Velocity, minus any grid movement. */ - su2double Density_i, Density_j; - bool implicit, dynamic_grid, incompressible; - su2double q_ij, /*!< \brief Projected velocity at the face. */ - a0, /*!< \brief The maximum of the face-normal velocity and 0 */ - a1; /*!< \brief The minimum of the face-normal velocity and 0 */ - unsigned short iDim; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwScalar(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwScalar(void); - - /*! - * \brief Compute the scalar upwind flux between two nodes i and j. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); -}; - -/*! - * \class CUpwSca_TurbSA - * \brief Class for doing a scalar upwind solver for the Spalar-Allmaras turbulence model equations. - * \ingroup ConvDiscr - * \author A. Bueno. - */ -class CUpwSca_TurbSA : public CUpwScalar { -private: - - /*! - * \brief Adds any extra variables to AD - */ - void ExtraADPreaccIn(); - - /*! - * \brief SA specific steps in the ComputeResidual method - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void FinishResidualCalc(su2double *val_residual, su2double **Jacobian_i, - su2double **Jacobian_j, CConfig *config); - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwSca_TurbSA(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwSca_TurbSA(void); -}; - -/*! - * \class CUpwSca_TurbSST - * \brief Class for doing a scalar upwind solver for the Menter SST turbulence model equations. - * \ingroup ConvDiscr - * \author A. Campos. - */ -class CUpwSca_TurbSST : public CUpwScalar { -private: - - /*! - * \brief Adds any extra variables to AD - */ - void ExtraADPreaccIn(); - - /*! - * \brief SST specific steps in the ComputeResidual method - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void FinishResidualCalc(su2double *val_residual, su2double **Jacobian_i, - su2double **Jacobian_j, CConfig *config); - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwSca_TurbSST(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwSca_TurbSST(void); -}; - -/*! - * \class CUpwSca_TransLM - * \brief Class for doing a scalar upwind solver for the Spalart-Allmaras turbulence model equations with transition. - * \ingroup ConvDiscr - * \author A. Aranake. - */ -class CUpwSca_TransLM : public CNumerics { -private: - su2double *Velocity_i, *Velocity_j; - bool implicit; - su2double q_ij, a0, a1; - unsigned short iDim; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwSca_TransLM(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwSca_TransLM(void); - - /*! - * \brief Compute the scalar upwind flux between two nodes i and j. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); -}; - -/*! - * \class CUpwSca_AdjTurb - * \brief Class for doing a scalar upwind solver for the adjoint turbulence equations. - * \ingroup ConvDiscr - * \author A. Bueno. - */ -class CUpwSca_AdjTurb : public CNumerics { -private: - su2double *Velocity_i, *Velocity_j; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwSca_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwSca_AdjTurb(void); - - /*! - * \param[out] val_residual_i - Pointer to the total residual at point i. - * \param[out] val_residual_j - Pointer to the total viscosity residual at point j. - * \param[out] val_Jacobian_ii - Jacobian of the numerical method at node i (implicit computation) from node i. - * \param[out] val_Jacobian_ij - Jacobian of the numerical method at node i (implicit computation) from node j. - * \param[out] val_Jacobian_ji - Jacobian of the numerical method at node j (implicit computation) from node i. - * \param[out] val_Jacobian_jj - Jacobian of the numerical method at node j (implicit computation) from node j. - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, - su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config); -}; - -/*! - * \class CUpwSca_Heat - * \brief Class for doing a scalar upwind solver for the heat convection equation. - * \ingroup ConvDiscr - * \author O. Burghardt. - * \version 7.0.0 "Blackbird" - */ -class CUpwSca_Heat : public CNumerics { -private: - su2double *Velocity_i, *Velocity_j; - bool implicit, dynamic_grid; - su2double q_ij, a0, a1; - unsigned short iDim; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwSca_Heat(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwSca_Heat(void); - - /*! - * \brief Compute the scalar upwind flux between two nodes i and j. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); -}; - -/*! - * \class CCentBase_Flow - * \brief Intermediate class to define centered schemes. - * \ingroup ConvDiscr - * \author F. Palacios - */ -class CCentBase_Flow : public CNumerics { - -protected: - unsigned short iDim, iVar, jVar; /*!< \brief Iteration on dimension and variables. */ - bool dynamic_grid; /*!< \brief Consider grid movement. */ - bool implicit; /*!< \brief Implicit calculation (compute Jacobians). */ - su2double fix_factor; /*!< \brief Fix factor for dissipation Jacobians (more diagonal dominance). */ - - su2double *Velocity_i, *Velocity_j, *MeanVelocity; /*!< \brief Velocity at nodes i and j and mean. */ - su2double ProjVelocity_i, ProjVelocity_j; /*!< \brief Velocities in the face normal direction. */ - su2double sq_vel_i, sq_vel_j; /*!< \brief Squared norm of the velocity vectors. */ - su2double Energy_i, Energy_j, MeanEnergy; /*!< \brief Energy at nodes i and j and mean. */ - su2double MeanDensity, MeanPressure, MeanEnthalpy; /*!< \brief Mean density, pressure, and enthalpy. */ - su2double *ProjFlux; /*!< \brief Projected inviscid flux. */ - - su2double *Diff_U, *Diff_Lapl; /*!< \brief Differences of conservatives and undiv. Laplacians. */ - su2double Local_Lambda_i, Local_Lambda_j, MeanLambda; /*!< \brief Local eingenvalues. */ - su2double Param_p, Phi_i, Phi_j, StretchingFactor; /*!< \brief Streching parameters. */ - su2double cte_0, cte_1; /*!< \brief Constants for the scalar dissipation Jacobian. */ - - su2double ProjGridVel; /*!< \brief Projected grid velocity. */ - - /*! - * \brief Hook method for derived classes to define preaccumulated variables, optional to implement. - * \return true if any variable was set as preacc. input, in which case the residual will be output. - */ - virtual bool SetPreaccInVars(void) {return false;} - - /*! - * \brief Derived classes must implement this method, called in ComputeResidual after inviscid part. - * \param[in,out] val_residual - Pointer to the convective flux contribution to the residual. - * \param[in,out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[in,out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - */ - virtual void DissipationTerm(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j) = 0; - - /*! - * \brief Add the contribution of a scalar dissipation term to the Jacobians. - * \param[in,out] val_Jacobian_i - Jacobian of the numerical method at node i. - * \param[in,out] val_Jacobian_j - Jacobian of the numerical method at node j. - */ - void ScalarDissipationJacobian(su2double **val_Jacobian_i, su2double **val_Jacobian_j); - -public: - - /*! - * \brief Constructor of the class. - * \param[in] val_nDim - Number of dimension of the problem. - * \param[in] val_nVar - Number of variables of the problem. - * \param[in] config - Definition of the particular problem. - */ - CCentBase_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - virtual ~CCentBase_Flow(void); - - /*! - * \brief Compute the flow residual using a centered method with artificial dissipation. - * \param[out] val_residual - Pointer to the convective flux contribution to the residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - -}; - -/*! - * \class CCentLax_Flow - * \brief Class for computing the Lax-Friedrich centered scheme. - * \ingroup ConvDiscr - * \author F. Palacios - */ -class CCentLax_Flow : public CCentBase_Flow { -private: - su2double Param_Kappa_0; /*!< \brief Artificial dissipation parameter. */ - su2double sc0; /*!< \brief Streching parameter. */ - su2double Epsilon_0; /*!< \brief Artificial dissipation coefficient. */ - - /*! - * \brief Lax-Friedrich first order dissipation term. - * \param[in,out] val_residual - Pointer to the convective flux contribution to the residual. - * \param[in,out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[in,out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - */ - void DissipationTerm(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j); - - /*! - * \brief Set input variables for AD preaccumulation. - * \return true, as we will define inputs. - */ - bool SetPreaccInVars(void); - -public: - - /*! - * \brief Constructor of the class. - * \param[in] val_nDim - Number of dimension of the problem. - * \param[in] val_nVar - Number of variables of the problem. - * \param[in] config - Definition of the particular problem. - */ - CCentLax_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CCentLax_Flow(void); - -}; - -/*! - * \class CCentJST_KE_Flow - * \brief Class for centered scheme - JST_KE (no 4th dissipation order term). - * \ingroup ConvDiscr - * \author F. Palacios - */ -class CCentJST_KE_Flow : public CCentBase_Flow { - -private: - su2double Param_Kappa_2; /*!< \brief Artificial dissipation parameter. */ - su2double sc2; /*!< \brief Streching parameter. */ - su2double Epsilon_2; /*!< \brief Artificial dissipation coefficient. */ - - /*! - * \brief JST_KE second order dissipation term. - * \param[in,out] val_residual - Pointer to the convective flux contribution to the residual. - * \param[in,out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[in,out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - */ - void DissipationTerm(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j); - - /*! - * \brief Set input variables for AD preaccumulation. - * \return true, as we will define inputs. - */ - bool SetPreaccInVars(void); - -public: - - /*! - * \brief Constructor of the class. - * \param[in] val_nDim - Number of dimension of the problem. - * \param[in] val_nVar - Number of variables of the problem. - * \param[in] config - Definition of the particular problem. - */ - CCentJST_KE_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CCentJST_KE_Flow(void); - -}; - -/*! - * \class CCentJST_Flow - * \brief Class for centered scheme - JST. - * \ingroup ConvDiscr - * \author F. Palacios - */ -class CCentJST_Flow : public CCentBase_Flow { - -private: - su2double Param_Kappa_2, Param_Kappa_4; /*!< \brief Artificial dissipation parameters. */ - su2double sc2, sc4; /*!< \brief Streching parameters. */ - su2double Epsilon_2, Epsilon_4; /*!< \brief Artificial dissipation coefficients. */ - - /*! - * \brief JST second and forth order dissipation terms. - * \param[in,out] val_residual - Pointer to the convective flux contribution to the residual. - * \param[in,out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[in,out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - */ - void DissipationTerm(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j); - - /*! - * \brief Set input variables for AD preaccumulation. - * \return true, as we will define inputs. - */ - bool SetPreaccInVars(void); - -public: - - /*! - * \brief Constructor of the class. - * \param[in] val_nDim - Number of dimension of the problem. - * \param[in] val_nVar - Number of variables of the problem. - * \param[in] config - Definition of the particular problem. - */ - CCentJST_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CCentJST_Flow(void); - -}; - -/*! - * \class CCentJSTInc_Flow - * \brief Class for centered scheme - modified JST with incompressible preconditioning. - * \ingroup ConvDiscr - * \author F. Palacios, T. Economon - */ -class CCentJSTInc_Flow : public CNumerics { - -private: - unsigned short iDim, iVar, jVar; /*!< \brief Iteration on dimension and variables. */ - su2double *Diff_V, *Diff_Lapl, /*!< \brief Diference of primitive variables and undivided laplacians. */ - *Velocity_i, *Velocity_j, /*!< \brief Velocity at node 0 and 1. */ - *MeanVelocity, ProjVelocity_i, - ProjVelocity_j, /*!< \brief Mean and projected velocities. */ - sq_vel_i, sq_vel_j, /*!< \brief Modulus of the velocity and the normal vector. */ - Temperature_i, Temperature_j, /*!< \brief Temperature at node 0 and 1. */ - MeanDensity, MeanPressure, - MeanBetaInc2, MeanEnthalpy, - MeanCp, MeanTemperature, /*!< \brief Mean values of primitive variables. */ - MeandRhodT, /*!< \brief Derivative of density w.r.t. temperature (variable density flows). */ - Param_p, Param_Kappa_2, - Param_Kappa_4, /*!< \brief Artificial dissipation parameters. */ - Local_Lambda_i, Local_Lambda_j, - MeanLambda, /*!< \brief Local eingenvalues. */ - Phi_i, Phi_j, sc2, sc4, - StretchingFactor, /*!< \brief Streching parameters. */ - *ProjFlux, /*!< \brief Projected inviscid flux tensor. */ - Epsilon_2, Epsilon_4; /*!< \brief Artificial dissipation values. */ - su2double **Precon; - bool implicit, /*!< \brief Implicit calculation. */ - dynamic_grid, /*!< \brief Modification for grid movement. */ - variable_density, /*!< \brief Variable density incompressible flows. */ - energy; /*!< \brief computation with the energy equation. */ - -public: - - /*! - * \brief Constructor of the class. - * \param[in] val_nDim - Number of dimension of the problem. - * \param[in] val_nVar - Number of variables of the problem. - * \param[in] config - Definition of the particular problem. - */ - CCentJSTInc_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CCentJSTInc_Flow(void); - - /*! - * \brief Compute the flow residual using a JST method. - * \param[out] val_residual - Pointer to the residual array. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); -}; - -/*! - * \class CCentJST_AdjFlow - * \brief Class for and adjoint centered scheme - JST. - * \ingroup ConvDiscr - * \author F. Palacios - */ -class CCentJST_AdjFlow : public CNumerics { -private: - su2double *Diff_Psi, *Diff_Lapl; - su2double *Velocity_i, *Velocity_j; - su2double *MeanPhi; - unsigned short iDim, jDim, iVar, jVar; - su2double Residual, ProjVelocity_i, ProjVelocity_j, ProjPhi, ProjPhi_Vel, sq_vel, phis1, phis2; - su2double MeanPsiRho, MeanPsiE, Param_p, Param_Kappa_4, Param_Kappa_2, Local_Lambda_i, Local_Lambda_j, MeanLambda; - su2double Phi_i, Phi_j, sc4, StretchingFactor, Epsilon_4, Epsilon_2; - bool implicit, grid_movement; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CCentJST_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CCentJST_AdjFlow(void); - - /*! - * \brief Compute the adjoint flow residual using a JST method. - * \param[out] val_resconv_i - Pointer to the convective residual at point i. - * \param[out] val_resvisc_i - Pointer to the artificial viscosity residual at point i. - * \param[out] val_resconv_j - Pointer to the convective residual at point j. - * \param[out] val_resvisc_j - Pointer to the artificial viscosity residual at point j. - * \param[out] val_Jacobian_ii - Jacobian of the numerical method at node i (implicit computation) from node i. - * \param[out] val_Jacobian_ij - Jacobian of the numerical method at node i (implicit computation) from node j. - * \param[out] val_Jacobian_ji - Jacobian of the numerical method at node j (implicit computation) from node i. - * \param[out] val_Jacobian_jj - Jacobian of the numerical method at node j (implicit computation) from node j. - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual (su2double *val_resconv_i, su2double *val_resvisc_i, su2double *val_resconv_j, su2double *val_resvisc_j, - su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, - CConfig *config); -}; - -/*! - * \class CCentSca_Heat - * \brief Class for scalar centered scheme. - * \ingroup ConvDiscr - * \author O. Burghardt - * \version 7.0.0 "Blackbird" - */ -class CCentSca_Heat : public CNumerics { - -private: - unsigned short iDim; /*!< \brief Iteration on dimension and variables. */ - su2double *Diff_Lapl, /*!< \brief Diference of conservative variables and undivided laplacians. */ - *MeanVelocity, ProjVelocity, - ProjVelocity_i, ProjVelocity_j, /*!< \brief Mean and projected velocities. */ - Param_Kappa_4, /*!< \brief Artificial dissipation parameters. */ - Local_Lambda_i, Local_Lambda_j, - MeanLambda, /*!< \brief Local eingenvalues. */ - cte_0, cte_1; /*!< \brief Artificial dissipation values. */ - bool implicit, /*!< \brief Implicit calculation. */ - dynamic_grid; /*!< \brief Modification for grid movement. */ - - -public: - - /*! - * \brief Constructor of the class. - * \param[in] val_nDim - Number of dimension of the problem. - * \param[in] val_nVar - Number of variables of the problem. - * \param[in] config - Definition of the particular problem. - */ - CCentSca_Heat(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CCentSca_Heat(void); - - /*! - * \brief Compute the flow residual using a JST method. - * \param[out] val_resconv - Pointer to the convective residual. - * \param[out] val_resvisc - Pointer to the artificial viscosity residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, - CConfig *config); -}; - -/*! - * \class CCentLaxInc_Flow - * \brief Class for computing the Lax-Friedrich centered scheme (modified with incompressible preconditioning). - * \ingroup ConvDiscr - * \author F. Palacios, T. Economon - */ -class CCentLaxInc_Flow : public CNumerics { -private: - unsigned short iDim, iVar, jVar; /*!< \brief Iteration on dimension and variables. */ - su2double *Diff_V, /*!< \brief Difference of primitive variables. */ - *Velocity_i, *Velocity_j, /*!< \brief Velocity at node 0 and 1. */ - *MeanVelocity, ProjVelocity_i, - ProjVelocity_j, /*!< \brief Mean and projected velocities. */ - *ProjFlux, /*!< \brief Projected inviscid flux tensor. */ - sq_vel_i, sq_vel_j, /*!< \brief Modulus of the velocity and the normal vector. */ - Temperature_i, Temperature_j, /*!< \brief Temperature at node 0 and 1. */ - MeanDensity, MeanPressure, - MeanBetaInc2, MeanEnthalpy, - MeanCp, MeanTemperature, /*!< \brief Mean values of primitive variables. */ - MeandRhodT, /*!< \brief Derivative of density w.r.t. temperature (variable density flows). */ - Param_p, Param_Kappa_0, /*!< \brief Artificial dissipation parameters. */ - Local_Lambda_i, Local_Lambda_j, - MeanLambda, /*!< \brief Local eingenvalues. */ - Phi_i, Phi_j, sc0, - StretchingFactor, /*!< \brief Streching parameters. */ - Epsilon_0; /*!< \brief Artificial dissipation values. */ - su2double **Precon; - bool implicit, /*!< \brief Implicit calculation. */ - dynamic_grid, /*!< \brief Modification for grid movement. */ - variable_density, /*!< \brief Variable density incompressible flows. */ - energy; /*!< \brief computation with the energy equation. */ - -public: - - /*! - * \brief Constructor of the class. - * \param[in] val_nDim - Number of dimension of the problem. - * \param[in] val_nVar - Number of variables of the problem. - * \param[in] config - Definition of the particular problem. - */ - CCentLaxInc_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CCentLaxInc_Flow(void); - - /*! - * \brief Compute the flow residual using a Lax method. - * \param[out] val_residual - Pointer to the residual array. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); -}; - -/*! - * \class CCentLax_AdjFlow - * \brief Class for computing the Lax-Friedrich adjoint centered scheme. - * \ingroup ConvDiscr - * \author F. Palacios - */ -class CCentLax_AdjFlow : public CNumerics { -private: - su2double *Diff_Psi; - su2double *Velocity_i, *Velocity_j; - su2double *MeanPhi; - unsigned short iDim, jDim, iVar, jVar; - su2double Residual, ProjVelocity_i, ProjVelocity_j, ProjPhi, ProjPhi_Vel, sq_vel, phis1, phis2, - MeanPsiRho, MeanPsiE, Param_p, Param_Kappa_0, Local_Lambda_i, Local_Lambda_j, MeanLambda, - Phi_i, Phi_j, sc2, StretchingFactor, Epsilon_0; - bool implicit, grid_movement; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CCentLax_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CCentLax_AdjFlow(void); - - /*! - * \brief Compute the adjoint flow residual using a Lax method. - * \param[out] val_resconv_i - Pointer to the convective residual at point i. - * \param[out] val_resvisc_i - Pointer to the artificial viscosity residual at point i. - * \param[out] val_resconv_j - Pointer to the convective residual at point j. - * \param[out] val_resvisc_j - Pointer to the artificial viscosity residual at point j. - * \param[out] val_Jacobian_ii - Jacobian of the numerical method at node i (implicit computation) from node i. - * \param[out] val_Jacobian_ij - Jacobian of the numerical method at node i (implicit computation) from node j. - * \param[out] val_Jacobian_ji - Jacobian of the numerical method at node j (implicit computation) from node i. - * \param[out] val_Jacobian_jj - Jacobian of the numerical method at node j (implicit computation) from node j. - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual (su2double *val_resconv_i, su2double *val_resvisc_i, su2double *val_resconv_j, su2double *val_resvisc_j, - su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, - CConfig *config); -}; - - -/*! - * \class CAvgGrad_Base - * \brief A base class for computing viscous terms using an average of gradients. - * \details This is the base class for the numerics classes that compute the - * viscous fluxes for the flow solvers (i.e. compressible or incompressible - * Navier Stokes). The actual numerics classes derive from this class. - * This class is used to share functions and variables that are common to all - * of the flow viscous numerics. For example, the turbulent stress tensor - * is computed identically for all three derived classes. - * \ingroup ViscDiscr - * \author C. Pederson, A. Bueno, F. Palacios, T. Economon - */ -class CAvgGrad_Base : public CNumerics { - protected: - const unsigned short nPrimVar; /*!< \brief The size of the primitive variable array used in the numerics class. */ - const bool correct_gradient; /*!< \brief Apply a correction to the gradient term */ - bool implicit; /*!< \brief Implicit calculus. */ - su2double *heat_flux_vector, /*!< \brief Flux of total energy due to molecular and turbulent diffusion */ - *heat_flux_jac_i, /*!< \brief Jacobian of the molecular + turbulent heat flux vector, projected onto the normal vector. */ - **tau_jacobian_i; /*!< \brief Jacobian of the viscous + turbulent stress tensor, projected onto the normal vector. */ - su2double *Mean_PrimVar, /*!< \brief Mean primitive variables. */ - *PrimVar_i, *PrimVar_j, /*!< \brief Primitives variables at point i and 1. */ - **Mean_GradPrimVar, /*!< \brief Mean value of the gradient. */ - Mean_Laminar_Viscosity, /*!< \brief Mean value of the viscosity. */ - Mean_Eddy_Viscosity, /*!< \brief Mean value of the eddy viscosity. */ - Mean_turb_ke, /*!< \brief Mean value of the turbulent kinetic energy. */ - Mean_TauWall, /*!< \brief Mean wall shear stress (wall functions). */ - TauWall_i, TauWall_j, /*!< \brief Wall shear stress at point i and j (wall functions). */ - dist_ij_2, /*!< \brief Length of the edge and face, squared */ - *Proj_Mean_GradPrimVar_Edge, /*!< \brief Inner product of the Mean gradient and the edge vector. */ - *Edge_Vector; /*!< \brief Vector from point i to point j. */ - - - - /*! - * \brief Add a correction using a Quadratic Constitutive Relation - * - * This function requires that the stress tensor already be - * computed using \ref GetStressTensor - * - * See: Spalart, P. R., "Strategies for Turbulence Modelling and - * Simulation," International Journal of Heat and Fluid Flow, Vol. 21, - * 2000, pp. 252-263 - * - * \param[in] val_gradprimvar - */ - void AddQCR(const su2double* const *val_gradprimvar); - - /*! - * \brief Scale the stress tensor using a predefined wall stress. - * - * This function requires that the stress tensor already be - * computed using \ref GetStressTensor - * - * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. - * \param[in] val_tau_wall - The wall stress - */ - void AddTauWall(const su2double *val_normal, - su2double val_tau_wall); - - /** - * \brief Calculate the Jacobian of the viscous + turbulent stress tensor - * - * This function is intended only for the compressible flow solver. - * This Jacobian is projected onto the normal vector, so it is of dimension - * [nDim][nVar] - * - * \param[in] val_Mean_PrimVar - Mean value of the primitive variables. - * \param[in] val_laminar_viscosity - Value of the laminar viscosity. - * \param[in] val_eddy_viscosity - Value of the eddy viscosity. - * \param[in] val_dist_ij - Distance between the points. - * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. - */ - void SetTauJacobian(const su2double* val_Mean_PrimVar, - su2double val_laminar_viscosity, - su2double val_eddy_viscosity, - su2double val_dist_ij, - const su2double *val_normal); - - - /** - * \brief Calculate the Jacobian of the viscous and turbulent stress tensor - * - * This function is intended only for the incompressible flow solver. - * This Jacobian is projected onto the normal vector, so it is of dimension - * [nDim][nVar] - * - * \param[in] val_laminar_viscosity - Value of the laminar viscosity. - * \param[in] val_eddy_viscosity - Value of the eddy viscosity. - * \param[in] val_dist_ij - Distance between the points. - * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. - */ - void SetIncTauJacobian(su2double val_laminar_viscosity, - su2double val_eddy_viscosity, - su2double val_dist_ij, - const su2double *val_normal); - - /*! - * \brief Compute the projection of the viscous fluxes into a direction. - * - * The heat flux vector and the stress tensor must be calculated before - * calling this function. - * - * \param[in] val_primvar - Primitive variables. - * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. - */ - void GetViscousProjFlux(const su2double *val_primvar, - const su2double *val_normal); - - /*! - * \brief TSL-Approximation of Viscous NS Jacobians. - * - * The Jacobians of the heat flux vector and the stress tensor must be - * calculated before calling this function. - * - * \param[in] val_Mean_PrimVar - Mean value of the primitive variables. - * \param[in] val_dS - Area of the face between two nodes. - * \param[in] val_Proj_Visc_Flux - Pointer to the projected viscous flux. - * \param[out] val_Proj_Jac_Tensor_i - Pointer to the projected viscous Jacobian at point i. - * \param[out] val_Proj_Jac_Tensor_j - Pointer to the projected viscous Jacobian at point j. - */ - void GetViscousProjJacs(const su2double *val_Mean_PrimVar, - su2double val_dS, - const su2double *val_Proj_Visc_Flux, - su2double **val_Proj_Jac_Tensor_i, - su2double **val_Proj_Jac_Tensor_j); - - /*! - * \brief Apply a correction to the gradient to reduce the truncation error - * - * \param[in] val_PrimVar_i - Primitive variables at point i - * \param[in] val_PrimVar_j - Primitive variables at point j - * \param[in] val_edge_vector - The vector between points i and j - * \param[in] val_dist_ij_2 - The distance between points i and j, squared - * \param[in] val_nPrimVar - The number of primitive variables - */ - void CorrectGradient(su2double** GradPrimVar, - const su2double* val_PrimVar_i, - const su2double* val_PrimVar_j, - const su2double* val_edge_vector, - su2double val_dist_ij_2, - const unsigned short val_nPrimVar); - - /*! - * \brief Initialize the Reynolds Stress Matrix - * \param[in] turb_ke turbulent kinetic energy of node - */ - void SetReynoldsStressMatrix(su2double turb_ke); - - /*! - * \brief Perturb the Reynolds stress tensor based on parameters - * \param[in] turb_ke: turbulent kinetic energy of the noce - * \param[in] Eig_Val_Comp: Defines type of eigenspace perturbation - * \param[in] beta_delta: Defines the amount of eigenvalue perturbation - */ - void SetPerturbedRSM(su2double turb_ke, CConfig *config); - - /*! - * \brief Get the mean rate of strain matrix based on velocity gradients - * \param[in] S_ij - */ - void GetMeanRateOfStrainMatrix(su2double **S_ij) const; - - public: - - /*! - * \brief Constructor of the class. - * \param[in] val_nDim - Number of dimension of the problem. - * \param[in] val_nVar - Number of variables of the problem. - * \param[in] val_nPrimVar - Number of primitive variables to use. - * \param[in] val_correct_grad - Apply a correction to the gradient - * \param[in] config - Definition of the particular problem. - */ - CAvgGrad_Base(unsigned short val_nDim, unsigned short val_nVar, - unsigned short val_nPrimVar, - bool val_correct_grad, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CAvgGrad_Base(); - - /*! - * \brief Set the value of the wall shear stress at point i and j (wall functions). - * \param[in] val_tauwall_i - Value of the wall shear stress at point i. - * \param[in] val_tauwall_j - Value of the wall shear stress at point j. - */ - void SetTauWall(su2double val_tauwall_i, su2double val_tauwall_j); - - /*! - * \brief Calculate the viscous + turbulent stress tensor - * \param[in] val_primvar - Primitive variables. - * \param[in] val_gradprimvar - Gradient of the primitive variables. - * \param[in] val_turb_ke - Turbulent kinetic energy - * \param[in] val_laminar_viscosity - Laminar viscosity. - * \param[in] val_eddy_viscosity - Eddy viscosity. - */ - void SetStressTensor(const su2double *val_primvar, - const su2double* const *val_gradprimvar, - su2double val_turb_ke, - su2double val_laminar_viscosity, - su2double val_eddy_viscosity); - - /*! - * \brief Get a component of the viscous stress tensor. - * - * \param[in] iDim - The first index - * \param[in] jDim - The second index - * \return The component of the viscous stress tensor at iDim, jDim - */ - su2double GetStressTensor(unsigned short iDim, unsigned short jDim) const; - - /*! - * \brief Get a component of the heat flux vector. - * \param[in] iDim - The index of the component - * \return The component of the heat flux vector at iDim - */ - su2double GetHeatFluxVector(unsigned short iDim) const; - -}; - -/*! - * \class CAvgGrad_Flow - * \brief Class for computing viscous term using the average of gradients. - * \ingroup ViscDiscr - * \author A. Bueno, and F. Palacios - */ -class CAvgGrad_Flow : public CAvgGrad_Base { -public: - - /*! - * \brief Constructor of the class. - * \param[in] val_nDim - Number of dimension of the problem. - * \param[in] val_nVar - Number of variables of the problem. - * \param[in] val_correct_grad - Apply a correction to the gradient - * \param[in] config - Definition of the particular problem. - */ - CAvgGrad_Flow(unsigned short val_nDim, unsigned short val_nVar, - bool val_correct_grad, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CAvgGrad_Flow(void); - - /*! - * \brief Compute the viscous flow residual using an average of gradients. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - - /*! - * \brief Compute the heat flux due to molecular and turbulent diffusivity - * \param[in] val_gradprimvar - Gradient of the primitive variables. - * \param[in] val_laminar_viscosity - Laminar viscosity. - * \param[in] val_eddy_viscosity - Eddy viscosity. - */ - void SetHeatFluxVector(const su2double* const *val_gradprimvar, - su2double val_laminar_viscosity, - su2double val_eddy_viscosity); - - /*! - * \brief Compute the Jacobian of the heat flux vector - * - * This Jacobian is projected onto the normal vector, so it is of - * dimension nVar. - * - * \param[in] val_Mean_PrimVar - Mean value of the primitive variables. - * \param[in] val_gradprimvar - Mean value of the gradient of the primitive variables. - * \param[in] val_laminar_viscosity - Value of the laminar viscosity. - * \param[in] val_eddy_viscosity - Value of the eddy viscosity. - * \param[in] val_dist_ij - Distance between the points. - * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. - */ - void SetHeatFluxJacobian(const su2double *val_Mean_PrimVar, - su2double val_laminar_viscosity, - su2double val_eddy_viscosity, - su2double val_dist_ij, - const su2double *val_normal); -}; - -/*! - * \class CGeneralAvgGrad_Flow - * \brief Class for computing viscous term using the average of gradients. - * \ingroup ViscDiscr - * \author M.Pini, S. Vitale - */ -class CGeneralAvgGrad_Flow : public CAvgGrad_Base { -private: - su2double *Mean_SecVar, /*!< \brief Mean secondary variables. */ - Mean_Thermal_Conductivity, /*!< \brief Mean value of the thermal conductivity. */ - Mean_Cp; /*!< \brief Mean value of the Cp. */ - - /*! - * \brief Compute the heat flux due to molecular and turbulent diffusivity - * \param[in] val_gradprimvar - Gradient of the primitive variables. - * \param[in] val_laminar_viscosity - Laminar viscosity. - * \param[in] val_eddy_viscosity - Eddy viscosity. - * \param[in] val_thermal_conductivity - Thermal Conductivity. - * \param[in] val_heat_capacity_cp - Heat Capacity at constant pressure. - */ - void SetHeatFluxVector(const su2double* const *val_gradprimvar, - su2double val_laminar_viscosity, - su2double val_eddy_viscosity, - su2double val_thermal_conductivity, - su2double val_heat_capacity_cp); - - /*! - * \brief Compute the Jacobian of the heat flux vector - * - * This Jacobian is projected onto the normal vector, so it is of - * dimension nVar. - * - * \param[in] val_Mean_PrimVar - Mean value of the primitive variables. - * \param[in] val_Mean_SecVar - Mean value of the secondary variables. - * \param[in] val_eddy_viscosity - Value of the eddy viscosity. - * \param[in] val_thermal_conductivity - Value of the thermal conductivity. - * \param[in] val_heat_capacity_cp - Value of the specific heat at constant pressure. - * \param[in] val_dist_ij - Distance between the points. - */ - void SetHeatFluxJacobian(const su2double *val_Mean_PrimVar, - const su2double *val_Mean_SecVar, - su2double val_eddy_viscosity, - su2double val_thermal_conductivity, - su2double val_heat_capacity_cp, - su2double val_dist_ij); - -public: - - /*! - * \brief Constructor of the class. - * \param[in] val_nDim - Number of dimension of the problem. - * \param[in] val_nVar - Number of variables of the problem. - * \param[in] val_correct_grad - Apply a correction to the gradient - * \param[in] config - Definition of the particular problem. - */ - CGeneralAvgGrad_Flow(unsigned short val_nDim, unsigned short val_nVar, bool val_correct_grad, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CGeneralAvgGrad_Flow(void); - - /*! - * \brief Compute the viscous flow residual using an average of gradients. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); -}; - - -/*! - * \class CAvgGradInc_Flow - * \brief Class for computing viscous term using an average of gradients. - * \ingroup ViscDiscr - * \author A. Bueno, F. Palacios, T. Economon - */ -class CAvgGradInc_Flow : public CAvgGrad_Base { -private: - su2double Mean_Thermal_Conductivity; /*!< \brief Mean value of the effective thermal conductivity. */ - bool energy; /*!< \brief computation with the energy equation. */ - - /* - * \brief Compute the projection of the viscous fluxes into a direction - * - * The viscous + turbulent stress tensor must be calculated before calling - * this function. - * - * \param[in] val_gradprimvar - Gradient of the primitive variables. - * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. - * \param[in] val_thermal_conductivity - Thermal conductivity. - */ - void GetViscousIncProjFlux(const su2double* const *val_gradprimvar, - const su2double *val_normal, - su2double val_thermal_conductivity); - - /*! - * \brief Compute the projection of the viscous Jacobian matrices. - * - * The Jacobian of the stress tensor must be calculated before calling - * this function. - * - * \param[in] val_dS - Area of the face between two nodes. - * \param[out] val_Proj_Jac_Tensor_i - Pointer to the projected viscous Jacobian at point i. - * \param[out] val_Proj_Jac_Tensor_j - Pointer to the projected viscous Jacobian at point j. - */ - void GetViscousIncProjJacs(su2double val_dS, - su2double **val_Proj_Jac_Tensor_i, - su2double **val_Proj_Jac_Tensor_j); - -public: - - /*! - * \brief Constructor of the class. - * \param[in] val_nDim - Number of dimension of the problem. - * \param[in] val_nVar - Number of variables of the problem. - * \param[in] val_correct_grad - Apply a correction to the gradient - * \param[in] config - Definition of the particular problem. - */ - CAvgGradInc_Flow(unsigned short val_nDim, unsigned short val_nVar, - bool val_correct_grad, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CAvgGradInc_Flow(void); - - /*! - * \brief Compute the viscous flow residual using an average of gradients. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); -}; - -/*! - * \class CAvgGrad_Scalar - * \brief Template class for computing viscous residual of scalar values - * \details This class serves as a template for the scalar viscous residual - * classes. The general structure of a viscous residual calculation is the - * same for many different models, which leads to a lot of repeated code. - * By using the template design pattern, these sections of repeated code are - * moved to a shared base class, and the specifics of each model - * are implemented by derived classes. In order to add a new residual - * calculation for a viscous residual, extend this class and implement - * the pure virtual functions with model-specific behavior. - * \ingroup ViscDiscr - * \author C. Pederson, A. Bueno, and F. Palacios - */ -class CAvgGrad_Scalar : public CNumerics { - private: - - /*! - * \brief A pure virtual function; Adds any extra variables to AD - */ - virtual void ExtraADPreaccIn() = 0; - - /*! - * \brief Model-specific steps in the ComputeResidual method - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - virtual void FinishResidualCalc(su2double *val_residual, - su2double **Jacobian_i, - su2double **Jacobian_j, - CConfig *config) = 0; - - protected: - bool implicit, incompressible; - bool correct_gradient; - unsigned short iVar, iDim; - su2double **Mean_GradTurbVar; /*!< \brief Average of gradients at cell face */ - su2double *Edge_Vector, /*!< \brief Vector from node i to node j. */ - *Proj_Mean_GradTurbVar_Normal, /*!< \brief Mean_gradTurbVar DOT normal */ - *Proj_Mean_GradTurbVar_Edge, /*!< \brief Mean_gradTurbVar DOT Edge_Vector */ - *Proj_Mean_GradTurbVar; /*!< \brief Mean_gradTurbVar DOT normal, corrected if required*/ - su2double dist_ij_2, /*!< \brief |Edge_Vector|^2 */ - proj_vector_ij; /*!< \brief (Edge_Vector DOT normal)/|Edge_Vector|^2 */ - - public: - /*! - * \brief Constructor of the class. - * \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. - */ - CAvgGrad_Scalar(unsigned short val_nDim, unsigned short val_nVar, - bool correct_gradient, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CAvgGrad_Scalar(void); - - /*! - * \brief Compute the viscous residual using an average of gradients without correction. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **Jacobian_i, - su2double **Jacobian_j, CConfig *config); -}; - -/*! - * \class CAvgGrad_TurbSA - * \brief Class for computing viscous term using average of gradients (Spalart-Allmaras Turbulence model). - * \ingroup ViscDiscr - * \author A. Bueno. - */ -class CAvgGrad_TurbSA : public CAvgGrad_Scalar { -private: - - const su2double sigma; - su2double nu_i, nu_j, nu_e; - - /*! - * \brief Adds any extra variables to AD - */ - void ExtraADPreaccIn(void); - - /*! - * \brief SA specific steps in the ComputeResidual method - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void FinishResidualCalc(su2double *val_residual, su2double **Jacobian_i, - su2double **Jacobian_j, CConfig *config); - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CAvgGrad_TurbSA(unsigned short val_nDim, unsigned short val_nVar, - bool correct_grad, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CAvgGrad_TurbSA(void); -}; - -/*! - * \class CAvgGrad_TurbSA_Neg - * \brief Class for computing viscous term using average of gradients (Spalart-Allmaras Turbulence model). - * \ingroup ViscDiscr - * \author F. Palacios - */ -class CAvgGrad_TurbSA_Neg : public CAvgGrad_Scalar { -private: - - const su2double sigma; - const su2double cn1; - su2double fn, Xi; - su2double nu_i, nu_j, nu_ij, nu_tilde_ij, nu_e; - - /*! - * \brief Adds any extra variables to AD - */ - void ExtraADPreaccIn(void); - - /*! - * \brief SA specific steps in the ComputeResidual method - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void FinishResidualCalc(su2double *val_residual, su2double **Jacobian_i, - su2double **Jacobian_j, CConfig *config); - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CAvgGrad_TurbSA_Neg(unsigned short val_nDim, unsigned short val_nVar, - bool correct_grad, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CAvgGrad_TurbSA_Neg(void); -}; - -/*! - * \class CAvgGrad_TransLM - * \brief Class for computing viscous term using average of gradients (Spalart-Allmaras Turbulence model). - * \ingroup ViscDiscr - * \author A. Bueno. - */ -class CAvgGrad_TransLM : public CNumerics { -private: - su2double **Mean_GradTransVar; - su2double *Proj_Mean_GradTransVar_Kappa, *Proj_Mean_GradTransVar_Edge; - su2double *Edge_Vector; - bool implicit, incompressible; - su2double sigma; - //su2double dist_ij_2; - //su2double proj_vector_ij; - //unsigned short iVar, iDim; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CAvgGrad_TransLM(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CAvgGrad_TransLM(void); - - /*! - * \brief Compute the viscous turbulence terms residual using an average of gradients. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config); -}; - -/*! - * \class CAvgGrad_AdjFlow - * \brief Class for computing the adjoint viscous terms. - * \ingroup ViscDiscr - * \author F. Palacios - */ -class CAvgGrad_AdjFlow : public CNumerics { -private: - su2double *Velocity_i; /*!< \brief Auxiliary vector for storing the velocity of point i. */ - su2double *Velocity_j; /*!< \brief Auxiliary vector for storing the velocity of point j. */ - su2double *Mean_Velocity; - su2double *Mean_GradPsiE; /*!< \brief Counter for dimensions of the problem. */ - su2double **Mean_GradPhi; /*!< \brief Counter for dimensions of the problem. */ - su2double *Edge_Vector; /*!< \brief Vector going from node i to node j. */ - bool implicit; /*!< \brief Implicit calculus. */ - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CAvgGrad_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CAvgGrad_AdjFlow(void); - - /*! - * \brief Residual computation. - * \param[out] val_residual_i - Pointer to the total residual at point i. - * \param[out] val_residual_j - Pointer to the total residual at point j. - */ - void ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, - su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, - su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config); -}; - -/*! - * \class CAvgGradCorrected_TransLM - * \brief Class for computing viscous term using average of gradients with correction (Spalart-Allmaras turbulence model). - * \ingroup ViscDiscr - * \author A. Bueno. - */ -class CAvgGradCorrected_TransLM : public CNumerics { -private: - su2double **Mean_GradTurbVar; - su2double *Proj_Mean_GradTurbVar_Kappa, *Proj_Mean_GradTurbVar_Edge, *Proj_Mean_GradTurbVar_Corrected; - su2double *Edge_Vector; - bool implicit, incompressible; - su2double sigma; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CAvgGradCorrected_TransLM(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CAvgGradCorrected_TransLM(void); - - /*! - * \brief Compute the viscous turbulent residual using an average of gradients with correction. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config); -}; - -/*! - * \class CAvgGrad_TurbSST - * \brief Class for computing viscous term using average of gradient with correction (Menter SST turbulence model). - * \ingroup ViscDiscr - * \author A. Bueno. - */ -class CAvgGrad_TurbSST : public CAvgGrad_Scalar { -private: - su2double sigma_k1, /*!< \brief Constants for the viscous terms, k-w (1), k-eps (2)*/ - sigma_k2, - sigma_om1, - sigma_om2; - - su2double diff_kine, /*!< \brief Diffusivity for viscous terms of tke eq */ - diff_omega; /*!< \brief Diffusivity for viscous terms of omega eq */ - - su2double F1_i, F1_j; /*!< \brief Menter's first blending function */ - - /*! - * \brief Adds any extra variables to AD - */ - void ExtraADPreaccIn(void); - - /*! - * \brief SST specific steps in the ComputeResidual method - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void FinishResidualCalc(su2double *val_residual, su2double **Jacobian_i, - su2double **Jacobian_j, CConfig *config); - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CAvgGrad_TurbSST(unsigned short val_nDim, unsigned short val_nVar, - const su2double* constants, bool correct_grad, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CAvgGrad_TurbSST(void); - - /*! - * \brief Sets value of first blending function. - */ - void SetF1blending(su2double val_F1_i, su2double val_F1_j) { - F1_i = val_F1_i; F1_j = val_F1_j; - } - -}; - -/*! - * \class CAvgGradCorrected_AdjFlow - * \brief Class for computing the adjoint viscous terms, including correction. - * \ingroup ViscDiscr - * \author A. Bueno. - */ -class CAvgGradCorrected_AdjFlow : public CNumerics { -private: - su2double *Velocity_i; /*!< \brief Auxiliary vector for storing the velocity of point i. */ - su2double *Velocity_j; /*!< \brief Auxiliary vector for storing the velocity of point j. */ - su2double *Mean_Velocity; - su2double **Mean_GradPsiVar; /*!< \brief Counter for dimensions of the problem. */ - su2double *Edge_Vector; /*!< \brief Vector going from node i to node j. */ - su2double *Proj_Mean_GradPsiVar_Edge; /*!< \brief Projection of Mean_GradPsiVar onto Edge_Vector. */ - su2double *Mean_GradPsiE; /*!< \brief Counter for dimensions of the problem. */ - su2double **Mean_GradPhi; /*!< \brief Counter for dimensions of the problem. */ - bool implicit; /*!< \brief Boolean controlling Jacobian calculations. */ - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CAvgGradCorrected_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CAvgGradCorrected_AdjFlow(void); - - /*! - * \brief Compute the adjoint flow viscous residual in a non-conservative way using an average of gradients and derivative correction. - * \param[out] val_residual_i - Pointer to the viscous residual at point i. - * \param[out] val_residual_j - Pointer to the viscous residual at point j. - * \param[out] val_Jacobian_ii - Jacobian of the numerical method at node i (implicit computation) from node i. - * \param[out] val_Jacobian_ij - Jacobian of the numerical method at node i (implicit computation) from node j. - * \param[out] val_Jacobian_ji - Jacobian of the numerical method at node j (implicit computation) from node i. - * \param[out] val_Jacobian_jj - Jacobian of the numerical method at node j (implicit computation) from node j. - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, - su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config); -}; - -/*! - * \class CAvgGradCorrected_AdjTurb - * \brief Class for adjoint turbulent using average of gradients with a correction. - * \ingroup ViscDiscr - * \author A. Bueno. - */ -class CAvgGradCorrected_AdjTurb : public CNumerics { -private: - su2double **Mean_GradTurbPsi; - su2double *Proj_Mean_GradTurbPsi_Kappa, *Proj_Mean_GradTurbPsi_Edge, *Proj_Mean_GradTurbPsi_Corrected; - su2double *Edge_Vector; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CAvgGradCorrected_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CAvgGradCorrected_AdjTurb(void); - - /*! - * \brief Compute the adjoint turbulent residual using average of gradients and a derivative correction. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - - /*! - * \overload - * \param[out] val_residual_i - Pointer to the total residual at point i. - * \param[out] val_residual_j - Pointer to the total viscosity residual at point j. - * \param[out] val_Jacobian_ii - Jacobian of the numerical method at node i (implicit computation) from node i. - * \param[out] val_Jacobian_ij - Jacobian of the numerical method at node i (implicit computation) from node j. - * \param[out] val_Jacobian_ji - Jacobian of the numerical method at node j (implicit computation) from node i. - * \param[out] val_Jacobian_jj - Jacobian of the numerical method at node j (implicit computation) from node j. - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, - su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config); -}; - -/*! - * \class CAvgGrad_AdjTurb - * \brief Class for adjoint turbulent using average of gradients with a correction. - * \ingroup ViscDiscr - * \author F. Palacios - */ -class CAvgGrad_AdjTurb : public CNumerics { -private: - su2double **Mean_GradTurbPsi; - su2double *Proj_Mean_GradTurbPsi_Kappa, *Proj_Mean_GradTurbPsi_Edge, *Proj_Mean_GradTurbPsi_Corrected; - su2double *Edge_Vector; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CAvgGrad_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CAvgGrad_AdjTurb(void); - - /*! - * \brief Compute the adjoint turbulent residual using average of gradients and a derivative correction. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - - /*! - * \overload - * \param[out] val_residual_i - Pointer to the total residual at point i. - * \param[out] val_residual_j - Pointer to the total viscosity residual at point j. - * \param[out] val_Jacobian_ii - Jacobian of the numerical method at node i (implicit computation) from node i. - * \param[out] val_Jacobian_ij - Jacobian of the numerical method at node i (implicit computation) from node j. - * \param[out] val_Jacobian_ji - Jacobian of the numerical method at node j (implicit computation) from node i. - * \param[out] val_Jacobian_jj - Jacobian of the numerical method at node j (implicit computation) from node j. - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, - su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config); -}; - - -/*! - * \class CAvgGrad_Heat - * \brief Class for computing viscous term using average of gradients without correction (heat equation). - * \ingroup ViscDiscr - * \author O. Burghardt. - * \version 7.0.0 "Blackbird" - */ -class CAvgGrad_Heat : public CNumerics { -private: - su2double **Mean_GradHeatVar; - su2double *Proj_Mean_GradHeatVar_Normal, *Proj_Mean_GradHeatVar_Corrected; - su2double *Edge_Vector; - bool implicit; - su2double dist_ij_2, proj_vector_ij, Thermal_Diffusivity_Mean; - unsigned short iVar, iDim; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CAvgGrad_Heat(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CAvgGrad_Heat(void); - - /*! - * \brief Compute the viscous heat residual using an average of gradients with correction. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config); -}; - -/*! - * \class CAvgGradCorrected_Heat - * \brief Class for computing viscous term using average of gradients with correction (heat equation). - * \ingroup ViscDiscr - * \author O. Burghardt. - * \version 7.0.0 "Blackbird" - */ -class CAvgGradCorrected_Heat : public CNumerics { -private: - su2double **Mean_GradHeatVar; - su2double *Proj_Mean_GradHeatVar_Kappa, *Proj_Mean_GradHeatVar_Edge, *Proj_Mean_GradHeatVar_Corrected; - su2double *Edge_Vector; - bool implicit; - su2double dist_ij_2, proj_vector_ij, Thermal_Diffusivity_Mean; - unsigned short iVar, iDim; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CAvgGradCorrected_Heat(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CAvgGradCorrected_Heat(void); - - /*! - * \brief Compute the viscous heat residual using an average of gradients with correction. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config); -}; - -/*! - * \class CGalerkin_Flow - * \brief Class for computing the stiffness matrix of the Galerkin method. - * \ingroup ViscDiscr - * \author F. Palacios - */ -class CGalerkin_Flow : public CNumerics { -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CGalerkin_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CGalerkin_Flow(void); - - /*! - * \brief Computing stiffness matrix of the Galerkin method. - * \param[out] val_stiffmatrix_elem - Stiffness matrix for Galerkin computation. - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual (su2double **val_stiffmatrix_elem, CConfig *config); -}; - -/*! - * \class CSourceNothing - * \brief Dummy class. - * \ingroup SourceDiscr - * \author F. Palacios - */ -class CSourceNothing : public CNumerics { -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourceNothing(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourceNothing(void); -}; - -/*! - * \class CSourcePieceWise_TurbSA - * \brief Class for integrating the source terms of the Spalart-Allmaras turbulence model equation. - * \ingroup SourceDiscr - * \author A. Bueno. - */ -class CSourcePieceWise_TurbSA : public CNumerics { -private: - su2double cv1_3; - su2double k2; - su2double cb1; - su2double cw2; - su2double ct3; - su2double ct4; - su2double cw3_6; - su2double cb2_sigma; - su2double sigma; - su2double cb2; - su2double cw1; - unsigned short iDim; - su2double nu, Ji, fv1, fv2, ft2, Omega, S, Shat, inv_Shat, dist_i_2, Ji_2, Ji_3, inv_k2_d2; - su2double r, g, g_6, glim, fw; - su2double norm2_Grad; - su2double dfv1, dfv2, dShat; - su2double dr, dg, dfw; - bool incompressible; - bool rotating_frame; - bool transition; - su2double gamma_BC; - su2double intermittency; - su2double Production, Destruction, CrossProduction; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourcePieceWise_TurbSA(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourcePieceWise_TurbSA(void); - - /*! - * \brief Residual for source term integration. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - - /*! - * \brief Residual for source term integration. - * \param[in] intermittency_in - Value of the intermittency. - */ - void SetIntermittency(su2double intermittency_in); - - /*! - * \brief Residual for source term integration. - * \param[in] val_production - Value of the Production. - */ - void SetProduction(su2double val_production); - - /*! - * \brief Residual for source term integration. - * \param[in] val_destruction - Value of the Destruction. - */ - void SetDestruction(su2double val_destruction); - - /*! - * \brief Residual for source term integration. - * \param[in] val_crossproduction - Value of the CrossProduction. - */ - void SetCrossProduction(su2double val_crossproduction); - - /*! - * \brief ______________. - */ - su2double GetProduction(void); - - /*! - * \brief Get the intermittency for the BC trans. model. - * \return Value of the intermittency. - */ - su2double GetGammaBC(void); - - /*! - * \brief ______________. - */ - su2double GetDestruction(void); - - /*! - * \brief ______________. - */ - su2double GetCrossProduction(void); -}; - -/*! - * \class CSourcePieceWise_TurbSA_E - * \brief Class for integrating the source terms of the Spalart-Allmaras Edwards modification turbulence model equation. - * \ingroup SourceDiscr - * \author E.Molina, A. Bueno. - * \version 7.0.0 "Blackbird" - */ -class CSourcePieceWise_TurbSA_E : public CNumerics { -private: - su2double cv1_3; - su2double k2; - su2double cb1; - su2double cw2; - su2double ct3; - su2double ct4; - su2double cw3_6; - su2double cb2_sigma; - su2double sigma; - su2double cb2; - su2double cw1; - unsigned short iDim; - su2double nu, Ji, fv1, fv2, ft2, Omega, S, Shat, inv_Shat, dist_i_2, Ji_2, Ji_3, inv_k2_d2; - su2double r, g, g_6, glim, fw; - su2double norm2_Grad; - su2double dfv1, dfv2, dShat; - su2double dr, dg, dfw; - bool incompressible; - bool rotating_frame; - su2double intermittency; - su2double Production, Destruction, CrossProduction; - su2double Sbar; - unsigned short jDim; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourcePieceWise_TurbSA_E(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourcePieceWise_TurbSA_E(void); - - /*! - * \brief Residual for source term integration. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - - /*! - * \brief Residual for source term integration. - * \param[in] intermittency_in - Value of the intermittency. - */ - void SetIntermittency(su2double intermittency_in); - - /*! - * \brief Residual for source term integration. - * \param[in] val_production - Value of the Production. - */ - void SetProduction(su2double val_production); - - /*! - * \brief Residual for source term integration. - * \param[in] val_destruction - Value of the Destruction. - */ - void SetDestruction(su2double val_destruction); - - /*! - * \brief Residual for source term integration. - * \param[in] val_crossproduction - Value of the CrossProduction. - */ - void SetCrossProduction(su2double val_crossproduction); - - /*! - * \brief ______________. - */ - su2double GetProduction(void); - - /*! - * \brief ______________. - */ - su2double GetDestruction(void); - - /*! - * \brief ______________. - */ - su2double GetCrossProduction(void); -}; - -/*! - * \class CSourcePieceWise_TurbSA_COMP - * \brief Class for integrating the source terms of the Spalart-Allmaras CC modification turbulence model equation. - * \ingroup SourceDiscr - * \author E.Molina, A. Bueno. - * \version 7.0.0 "Blackbird" - */ -class CSourcePieceWise_TurbSA_COMP : public CNumerics { -private: - su2double cv1_3; - su2double k2; - su2double cb1; - su2double cw2; - su2double ct3; - su2double ct4; - su2double cw3_6; - su2double cb2_sigma; - su2double sigma; - su2double cb2; - su2double cw1; - unsigned short iDim; - su2double nu, Ji, fv1, fv2, ft2, Omega, S, Shat, inv_Shat, dist_i_2, Ji_2, Ji_3, inv_k2_d2; - su2double r, g, g_6, glim, fw; - su2double norm2_Grad; - su2double dfv1, dfv2, dShat; - su2double dr, dg, dfw; - bool incompressible; - bool rotating_frame; - su2double intermittency; - su2double Production, Destruction, CrossProduction; - su2double aux_cc, CompCorrection, c5; - unsigned short jDim; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourcePieceWise_TurbSA_COMP(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourcePieceWise_TurbSA_COMP(void); - - /*! - * \brief Residual for source term integration. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - - /*! - * \brief Residual for source term integration. - * \param[in] intermittency_in - Value of the intermittency. - */ - void SetIntermittency(su2double intermittency_in); - - /*! - * \brief Residual for source term integration. - * \param[in] val_production - Value of the Production. - */ - void SetProduction(su2double val_production); - - /*! - * \brief Residual for source term integration. - * \param[in] val_destruction - Value of the Destruction. - */ - void SetDestruction(su2double val_destruction); - - /*! - * \brief Residual for source term integration. - * \param[in] val_crossproduction - Value of the CrossProduction. - */ - void SetCrossProduction(su2double val_crossproduction); - - /*! - * \brief ______________. - */ - su2double GetProduction(void); - - /*! - * \brief ______________. - */ - su2double GetDestruction(void); - - /*! - * \brief ______________. - */ - su2double GetCrossProduction(void); -}; - -/*! - * \class CSourcePieceWise_TurbSA_E_COMP - * \brief Class for integrating the source terms of the Spalart-Allmaras Edwards modification with CC turbulence model equation. - * \ingroup SourceDiscr - * \author E.Molina, A. Bueno. - * \version 7.0.0 "Blackbird" - */ -class CSourcePieceWise_TurbSA_E_COMP : public CNumerics { -private: - su2double cv1_3; - su2double k2; - su2double cb1; - su2double cw2; - su2double ct3; - su2double ct4; - su2double cw3_6; - su2double cb2_sigma; - su2double sigma; - su2double cb2; - su2double cw1; - unsigned short iDim; - su2double nu, Ji, fv1, fv2, ft2, Omega, S, Shat, inv_Shat, dist_i_2, Ji_2, Ji_3, inv_k2_d2; - su2double r, g, g_6, glim, fw; - su2double norm2_Grad; - su2double dfv1, dfv2, dShat; - su2double dr, dg, dfw; - bool incompressible; - bool rotating_frame; - su2double intermittency; - su2double Production, Destruction, CrossProduction; - su2double Sbar; - unsigned short jDim; - su2double aux_cc, CompCorrection, c5; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourcePieceWise_TurbSA_E_COMP(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourcePieceWise_TurbSA_E_COMP(void); - - /*! - * \brief Residual for source term integration. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - - /*! - * \brief Residual for source term integration. - * \param[in] intermittency_in - Value of the intermittency. - */ - void SetIntermittency(su2double intermittency_in); - - /*! - * \brief Residual for source term integration. - * \param[in] val_production - Value of the Production. - */ - void SetProduction(su2double val_production); - - /*! - * \brief Residual for source term integration. - * \param[in] val_destruction - Value of the Destruction. - */ - void SetDestruction(su2double val_destruction); - - /*! - * \brief Residual for source term integration. - * \param[in] val_crossproduction - Value of the CrossProduction. - */ - void SetCrossProduction(su2double val_crossproduction); - - /*! - * \brief ______________. - */ - su2double GetProduction(void); - - /*! - * \brief ______________. - */ - su2double GetDestruction(void); - - /*! - * \brief ______________. - */ - su2double GetCrossProduction(void); -}; - -/*! - * \class CSourcePieceWise_TurbSA_Neg - * \brief Class for integrating the source terms of the Spalart-Allmaras turbulence model equation. - * \ingroup SourceDiscr - * \author F. Palacios - */ -class CSourcePieceWise_TurbSA_Neg : public CNumerics { -private: - su2double cv1_3; - su2double k2; - su2double cb1; - su2double cw2; - su2double ct3; - su2double ct4; - su2double cw3_6; - su2double cb2_sigma; - su2double sigma; - su2double cb2; - su2double cw1; - unsigned short iDim; - su2double nu, Ji, fv1, fv2, ft2, Omega, S, Shat, inv_Shat, dist_i_2, Ji_2, Ji_3, inv_k2_d2; - su2double r, g, g_6, glim, fw; - su2double norm2_Grad; - su2double dfv1, dfv2, dShat; - su2double dr, dg, dfw; - bool incompressible; - bool rotating_frame; - su2double intermittency; - su2double Production, Destruction, CrossProduction; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourcePieceWise_TurbSA_Neg(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourcePieceWise_TurbSA_Neg(void); - - /*! - * \brief Residual for source term integration. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - - /*! - * \brief Residual for source term integration. - * \param[in] intermittency_in - Value of the intermittency. - */ - void SetIntermittency(su2double intermittency_in); - - /*! - * \brief Residual for source term integration. - * \param[in] val_production - Value of the Production. - */ - void SetProduction(su2double val_production); - - /*! - * \brief Residual for source term integration. - * \param[in] val_destruction - Value of the Destruction. - */ - void SetDestruction(su2double val_destruction); - - /*! - * \brief Residual for source term integration. - * \param[in] val_crossproduction - Value of the CrossProduction. - */ - void SetCrossProduction(su2double val_crossproduction); - - /*! - * \brief ______________. - */ - su2double GetProduction(void); - - /*! - * \brief ______________. - */ - su2double GetDestruction(void); - - /*! - * \brief ______________. - */ - su2double GetCrossProduction(void); -}; - -/*! - * \class CSourcePieceWise_TransLM - * \brief Class for integrating the source terms of the Spalart-Allmaras turbulence model equation. - * \ingroup SourceDiscr - * \author A. Bueno. - */ -class CSourcePieceWise_TransLM : public CNumerics { -private: - - /*-- SA model constants --*/ - su2double cv1_3; - su2double k2; - su2double cb1; - su2double cw2; - su2double cw3_6; - su2double sigma; - su2double cb2; - su2double cw1; - - /*-- gamma-theta model constants --*/ - su2double c_e1; - su2double c_a1; - su2double c_e2; - su2double c_a2; - su2double sigmaf; - su2double s1; - su2double c_theta; - su2double sigmat; - - /*-- Correlation constants --*/ - su2double flen_global; - su2double alpha_global; - su2double Vorticity; - - bool implicit; - -public: - bool debugme; // For debugging only, remove this. -AA - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourcePieceWise_TransLM(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourcePieceWise_TransLM(void); - - /*! - * \brief Residual for source term integration. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual_TransLM(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config, su2double &gamma_sep); - - void CSourcePieceWise_TransLM__ComputeResidual_TransLM_d(su2double *TransVar_i, su2double *TransVar_id, su2double *val_residual, su2double *val_residuald, CConfig *config); -}; - -/*! - * \class CSourcePieceWise_TurbSST - * \brief Class for integrating the source terms of the Menter SST turbulence model equations. - * \ingroup SourceDiscr - * \author A. Campos. - */ -class CSourcePieceWise_TurbSST : public CNumerics { -private: - su2double F1_i, - F1_j, - F2_i, - F2_j; - - su2double alfa_1, - alfa_2, - beta_1, - beta_2, - sigma_omega_1, - sigma_omega_2, - beta_star, - a1; - - su2double CDkw_i, CDkw_j; - - su2double kAmb, omegaAmb; - - bool incompressible; - bool sustaining_terms; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourcePieceWise_TurbSST(unsigned short val_nDim, unsigned short val_nVar, const su2double* constants, - su2double val_kine_Inf, su2double val_omega_Inf, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourcePieceWise_TurbSST(void); - - /*! - * \brief Set the value of the first blending function. - * \param[in] val_F1_i - Value of the first blending function at point i. - * \param[in] val_F1_j - Value of the first blending function at point j. - */ - void SetF1blending(su2double val_F1_i, su2double val_F1_j); - - /*! - * \brief Set the value of the second blending function. - * \param[in] val_F2_i - Value of the second blending function at point i. - * \param[in] val_F2_j - Value of the second blending function at point j. - */ - void SetF2blending(su2double val_F2_i, su2double val_F2_j); - - /*! - * \brief Set the value of the cross diffusion for the SST model. - * \param[in] val_CDkw_i - Value of the cross diffusion at point i. - * \param[in] val_CDkw_j - Value of the cross diffusion at point j. - */ - virtual void SetCrossDiff(su2double val_CDkw_i, su2double val_CDkw_j); - - /*! - * \brief Residual for source term integration. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - - /*! - * \brief Initialize the Reynolds Stress Matrix - * \param[in] turb_ke turbulent kinetic energy of node - */ - void SetReynoldsStressMatrix(su2double turb_ke); - - /*! - * \brief Perturb the Reynolds stress tensor based on parameters - * \param[in] turb_ke: turbulent kinetic energy of the noce - * \param[in] config: config file - */ - void SetPerturbedRSM(su2double turb_ke, CConfig *config); - /*! - * \brief A virtual member. Get strain magnitude based on perturbed reynolds stress matrix - * \param[in] turb_ke: turbulent kinetic energy of the node - */ - void SetPerturbedStrainMag(su2double turb_ke); - - /*! - * \brief Get the mean rate of strain matrix based on velocity gradients - * \param[in] S_ij - */ - void GetMeanRateOfStrainMatrix(su2double **S_ij); - -}; - -/*! - * \class CSourceGravity - * \brief Class for the source term integration of the gravity force. - * \ingroup SourceDiscr - * \author F. Palacios - */ -class CSourceGravity : public CNumerics { - -public: - - /*! - * \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. - */ - CSourceGravity(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourceGravity(void); - - /*! - * \brief Source term integration for the poissonal potential. - * \param[out] val_residual - Pointer to the total residual. - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, CConfig *config); -}; - -/*! - * \class CSourceBodyForce - * \brief Class for the source term integration of a body force. - * \ingroup SourceDiscr - * \author T. Economon - */ -class CSourceBodyForce : public CNumerics { - su2double *Body_Force_Vector; - -public: - - /*! - * \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. - */ - CSourceBodyForce(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourceBodyForce(void); - - /*! - * \brief Source term integration for a body force. - * \param[out] val_residual - Pointer to the residual vector. - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, CConfig *config); - -}; - -/*! - * \class CSourceIncBodyForce - * \brief Class for the source term integration of a body force in the incompressible solver. - * \ingroup SourceDiscr - * \author T. Economon - * \version 7.0.0 "Blackbird" - */ -class CSourceIncBodyForce : public CNumerics { - su2double *Body_Force_Vector; - -public: - - /*! - * \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. - */ - CSourceIncBodyForce(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourceIncBodyForce(void); - - /*! - * \brief Source term integration for a body force. - * \param[out] val_residual - Pointer to the residual vector. - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, CConfig *config); - -}; - -/*! - * \class CSourceIncRotatingFrame_Flow - * \brief Class for a rotating frame source term. - * \ingroup SourceDiscr - */ -class CSourceIncRotatingFrame_Flow : public CNumerics { - -private: - su2double Omega[3]; /*!< \brief Angular velocity */ - bool implicit; /*!< \brief Implicit calculation. */ - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourceIncRotatingFrame_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourceIncRotatingFrame_Flow(void); - - /*! - * \brief Residual of the rotational frame source term. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config); - -}; - -/*! - * \class CSourceBoussinesq - * \brief Class for the source term integration of the Boussinesq approximation for incompressible flow. - * \ingroup SourceDiscr - * \author T. Economon - * \version 7.0.0 "Blackbird" - */ -class CSourceBoussinesq : public CNumerics { - su2double *Gravity_Vector; - -public: - - /*! - * \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. - */ - CSourceBoussinesq(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourceBoussinesq(void); - - /*! - * \brief Source term integration for the Boussinesq approximation. - * \param[out] val_residual - Pointer to the residual vector. - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, CConfig *config); - -}; - -/*! - * \class CSourceIncAxisymmetric_Flow - * \brief Class for source term for solving incompressible axisymmetric problems. - * \ingroup SourceDiscr - * \author T. Economon - */ -class CSourceIncAxisymmetric_Flow : public CNumerics { - bool implicit, /*!< \brief Implicit calculation. */ - viscous, /*!< \brief Viscous incompressible flows. */ - energy; /*!< \brief computation with the energy equation. */ - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourceIncAxisymmetric_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourceIncAxisymmetric_Flow(void); - - /*! - * \brief Residual of the rotational frame source term. - * \param[out] val_residual - Pointer to the total residual. - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **Jacobian_i, CConfig *config); - -}; - -/*! - * \class CSourceViscous_AdjFlow - * \brief Class for source term integration in adjoint problem. - * \ingroup SourceDiscr - * \author F. Palacios - */ -class CSourceViscous_AdjFlow : public CNumerics { -private: - su2double *Velocity, *GradDensity, *GradInvDensity, *dPoDensity2, *alpha, *beta, *Sigma_5_vec; - su2double **GradVel_o_Rho, **sigma, **Sigma_phi, **Sigma_5_Tensor, **Sigma; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourceViscous_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourceViscous_AdjFlow(void); - - /*! - * \brief Source term integration of the flow adjoint equation. - * \param[out] val_residual - Pointer to the total residual. - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual (su2double *val_residual, CConfig *config); - -}; - -/*! - * \class CSourcePieceWise_AdjTurb - * \brief Class for source term integration of the adjoint turbulent equation. - * \ingroup SourceDiscr - * \author A. Bueno. - */ -class CSourcePieceWise_AdjTurb : public CNumerics { -private: - su2double **tau, *Velocity; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourcePieceWise_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourcePieceWise_AdjTurb(void); - - /*! - * \brief Source term integration of the adjoint turbulence equation. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); -}; - -class CSourceConservative_AdjFlow : public CNumerics { -private: - su2double *Velocity, *Residual_i, *Residual_j, *Mean_Residual; - su2double **Mean_PrimVar_Grad; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourceConservative_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourceConservative_AdjFlow(void); - - /*! - * \brief Source term integration using a conservative scheme. - * \param[out] val_residual - Pointer to the total residual. - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, CConfig *config); -}; - -/*! - * \class CSourceConservative_AdjTurb - * \brief Class for source term integration in adjoint turbulent problem using a conservative scheme. - * \ingroup SourceDiscr - * \author A. Bueno. - */ -class CSourceConservative_AdjTurb : public CNumerics { -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourceConservative_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourceConservative_AdjTurb(void); - - /*! - * \brief Source term integration using a conservative scheme. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); -}; - -/*! - * \class CSourceRotatingFrame_Flow - * \brief Class for a rotating frame source term. - * \ingroup SourceDiscr - * \author F. Palacios, T. Economon. - */ -class CSourceRotatingFrame_Flow : public CNumerics { -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourceRotatingFrame_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourceRotatingFrame_Flow(void); - - /*! - * \brief Residual of the rotational frame source term. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config); -}; - -/*! - * \class CSourceRotatingFrame_AdjFlow - * \brief Source term class for rotating frame adjoint. - * \ingroup SourceDiscr - * \author T. Economon. - */ -class CSourceRotatingFrame_AdjFlow : public CNumerics { -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourceRotatingFrame_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourceRotatingFrame_AdjFlow(void); - - /*! - * \brief Residual of the adjoint rotating frame source term. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config); -}; - -/*! - * \class CSourceAxisymmetric_Flow - * \brief Class for source term for solving axisymmetric problems. - * \ingroup SourceDiscr - * \author F. Palacios - */ -class CSourceAxisymmetric_Flow : public CNumerics { -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourceAxisymmetric_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourceAxisymmetric_Flow(void); - - /*! - * \brief Residual of the rotational frame source term. - * \param[out] val_residual - Pointer to the total residual. - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **Jacobian_i, CConfig *config); - -}; - -/*! - * \class CSourceAxisymmetric_AdjFlow - * \brief Class for source term for solving axisymmetric problems. - * \ingroup SourceDiscr - * \author F. Palacios - */ -class CSourceAxisymmetric_AdjFlow : public CNumerics { -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourceAxisymmetric_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourceAxisymmetric_AdjFlow(void); - - /*! - * \brief Residual of the rotational frame source term. - * \param[out] val_residual - Pointer to the total residual. - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **Jacobian_i, CConfig *config); -}; - -/*! - * \class CSourceWindGust - * \brief Class for a source term due to a wind gust. - * \ingroup SourceDiscr - * \author S. Padrón - */ -class CSourceWindGust : public CNumerics { -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourceWindGust(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourceWindGust(void); - - /*! - * \brief Residual of the wind gust source term. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config); -}; - -/*! - * \class CSource_Template - * \brief Dummy class. - * \ingroup SourceDiscr - * \author A. Lonkar. - */ -class CSource_Template : public CNumerics { -public: - - /*! - * \brief Constructor of the class. - * \param[in] val_nDim - Number of dimensions of the problem. - * \param[in] val_nVar - Number of variables of the problem. - * \param[in] config - Name of the input config file - * - */ - CSource_Template(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - - /*! - * \brief Residual for source term integration. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSource_Template(void); -}; - -/*! - * \class CConvectiveTemplate - * \brief Class for setting up new method for spatial discretization of convective terms in flow Equations - * \ingroup ConvDiscr - * \author A. Lonkar - */ -class CConvective_Template : public CNumerics { -private: - - /* define private variables here */ - bool implicit; - su2double *Diff_U; - su2double *Velocity_i, *Velocity_j, *RoeVelocity; - su2double *ProjFlux_i, *ProjFlux_j; - su2double *delta_wave, *delta_vel; - su2double *Lambda, *Epsilon; - su2double **P_Tensor, **invP_Tensor; - su2double sq_vel, Proj_ModJac_Tensor_ij, Density_i, Energy_i, SoundSpeed_i, Pressure_i, Enthalpy_i, - Density_j, Energy_j, SoundSpeed_j, Pressure_j, Enthalpy_j, R, RoeDensity, RoeEnthalpy, RoeSoundSpeed, - ProjVelocity, ProjVelocity_i, ProjVelocity_j, proj_delta_vel, delta_p, delta_rho; - unsigned short iDim, iVar, jVar, kVar; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CConvective_Template(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CConvective_Template(void); - - /*! - * \brief Compute the Roe's flux between two nodes i and j. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); -}; - -/*! - * \class CViscous_Template - * \brief Class for computing viscous term using average of gradients. - * \ingroup ViscDiscr - * \author F. Palacios - */ -class CViscous_Template : public CNumerics { -private: - -public: - - /*! - * \brief Constructor of the class. - * \param[in] val_nDim - Number of dimension of the problem. - * \param[in] val_nVar - Number of variables of the problem. - * \param[in] config - Definition of the particular problem. - */ - CViscous_Template(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CViscous_Template(void); - - /*! - * \brief Compute the viscous flow residual using an average of gradients. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); -}; - -#include "numerics_structure.inl" diff --git a/SU2_CFD/include/numerics_structure.inl b/SU2_CFD/include/numerics_structure.inl deleted file mode 100644 index 676a63759cbd..000000000000 --- a/SU2_CFD/include/numerics_structure.inl +++ /dev/null @@ -1,494 +0,0 @@ -/*! - * \file numerics_structure.inl - * \brief In-Line subroutines of the numerics_structure.hpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -inline su2double CNumerics::Determinant_3x3(su2double A00, - su2double A01, - su2double A02, - su2double A10, - su2double A11, - su2double A12, - su2double A20, - su2double A21, - su2double A22) { - - return A00*(A11*A22-A12*A21) - A01*(A10*A22-A12*A20) + A02*(A10*A21-A11*A20); - -} - -inline void CNumerics::Compute_Mass_Matrix(CElement *element_container, CConfig *config) { } - -inline void CNumerics::Compute_Dead_Load(CElement *element_container, CConfig *config) { } - -inline void CNumerics::Compute_Tangent_Matrix(CElement *element_container, CConfig *config) { } - -inline void CNumerics::Compute_NodalStress_Term(CElement *element_container, CConfig *config) { } - -inline void CNumerics::Compute_Averaged_NodalStress(CElement *element_container, CConfig *config) { } - -inline void CNumerics::SetMeshElasticProperties(unsigned long iElem, su2double val_E) { } - -inline void CNumerics::Set_DV_Val(unsigned short i_DV, su2double val_DV) { } - -inline su2double CNumerics::Get_DV_Val(unsigned short i_DV) const { return 0.0; } - -inline void CNumerics::Set_ElectricField(unsigned short i_DV, su2double val_EField) { } - -inline void CNumerics::SetMaterial_Properties(unsigned short iVal, su2double val_E, su2double val_Nu) { } - -inline void CNumerics::SetMaterial_Density(unsigned short iVal, su2double val_Rho, su2double val_Rho_DL) { } - -inline void CNumerics::ComputeResidual(su2double *val_residual, CConfig *config) { } - -inline void CNumerics::ComputeResidual(su2double *val_residual_i, su2double *val_residual_j) { } - -inline void CNumerics::ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, CConfig *config) { } - -inline void CNumerics::ComputeResidual(su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { } - -inline void CNumerics::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, - CConfig *config) { } - -inline void CNumerics::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, - su2double **val_JacobianMeanFlow_i, su2double **val_JacobianMeanFlow_j, CConfig *config) { } - -inline void CNumerics::ComputeResidual(su2double *val_resconv, su2double *val_resvisc, su2double **val_Jacobian_i, - su2double **val_Jacobian_j, CConfig *config) { } - -inline void CNumerics::ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, - su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, - su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config) { } - -inline void CNumerics::ComputeResidual(su2double *val_resconv_i, su2double *val_resvisc_i, su2double *val_resconv_j, - su2double *val_resvisc_j, su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, - su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config) { } - -inline void CNumerics::ComputeResidual(su2double **val_stiffmatrix_elem, CConfig *config) { } - -inline void CNumerics::GetEq_Rxn_Coefficients(su2double **EqnRxnConstants, CConfig *config) { }; - -inline void CNumerics::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config) { } - -inline void CNumerics::ComputeResidual_TransLM(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config, su2double &gamma_sep) {} - -inline void CNumerics::ComputeResidual_Axisymmetric(su2double *val_residual, CConfig *config) { } - -inline void CNumerics::ComputeResidual_Axisymmetric_ad(su2double *val_residual, su2double *val_residuald, CConfig *config) { } - -inline void CNumerics::SetJacobian_Axisymmetric(su2double **val_Jacobian_i, CConfig *config) { } - -inline void CNumerics::ComputeVibRelaxation(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config) { } - -inline void CNumerics::ComputeChemistry(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config) { } - -inline void CNumerics::GetKeqConstants(su2double *A, unsigned short val_reaction, CConfig *config) { } - -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; -} - -inline void CNumerics::SetSensor( su2double val_sensor_i, su2double val_sensor_j) { - Sensor_i = val_sensor_i; - Sensor_j = val_sensor_j; -} - -inline void CNumerics::SetConservative(su2double *val_u_i, su2double *val_u_j) { - U_i = val_u_i; - U_j = val_u_j; -} - -inline void CNumerics::SetConservative_ZeroOrder(su2double *val_u_i, su2double *val_u_j) { - UZeroOrder_i = val_u_i; - UZeroOrder_j = val_u_j; -} - -inline void CNumerics::SetPrimitive(su2double *val_v_i, su2double *val_v_j) { - V_i = val_v_i; - V_j = val_v_j; -} - -inline void CNumerics::SetSecondary(su2double *val_s_i, su2double *val_s_j) { - S_i = val_s_i; - S_j = val_s_j; -} - -inline void CNumerics::SetConservative(su2double *val_u_0, su2double *val_u_1, su2double *val_u_2) { - U_0 = val_u_0; - U_1 = val_u_1; - U_2 = val_u_2; -} - -inline void CNumerics::SetConservative(su2double *val_u_0, su2double *val_u_1, su2double *val_u_2, su2double *val_u_3) { - U_0 = val_u_0; - U_1 = val_u_1; - U_2 = val_u_2; - U_3 = val_u_3; -} - -inline void CNumerics::SetVelocity2_Inf(su2double velocity2) { - vel2_inf = velocity2; -} - -inline void CNumerics::SetVorticity(su2double *val_vorticity_i, su2double *val_vorticity_j) { - Vorticity_i = val_vorticity_i; - Vorticity_j = val_vorticity_j; -} - -inline void CNumerics::SetStrainMag(su2double val_strainmag_i, su2double val_strainmag_j) { - StrainMag_i = val_strainmag_i; - StrainMag_j = val_strainmag_j; -} - -inline void CNumerics::SetTimeStep(su2double val_timestep) {TimeStep = val_timestep;} - -inline void CNumerics::SetLaminarViscosity(su2double val_lam_viscosity_i, su2double val_lam_viscosity_j) { - Laminar_Viscosity_i = val_lam_viscosity_i; - Laminar_Viscosity_j = val_lam_viscosity_j; -} - -inline void CNumerics::SetThermalConductivity(su2double val_therm_conductivity_i, su2double val_therm_conductivity_j) { - Thermal_Conductivity_i = val_therm_conductivity_i; - Thermal_Conductivity_j = val_therm_conductivity_j; -} - -inline void CNumerics::SetThermalConductivity_ve(su2double val_therm_conductivity_ve_i, su2double val_therm_conductivity_ve_j) { - Thermal_Conductivity_ve_i = val_therm_conductivity_ve_i; - Thermal_Conductivity_ve_j = val_therm_conductivity_ve_j; -} - -inline void CNumerics::SetThermalDiffusivity(su2double val_thermal_diffusivity_i,su2double val_thermal_diffusivity_j) { - Thermal_Diffusivity_i = val_thermal_diffusivity_i; - Thermal_Diffusivity_j = val_thermal_diffusivity_j; -} - -inline void CNumerics::SetDiffusionCoeff(su2double* val_diffusioncoeff_i, su2double* val_diffusioncoeff_j) { - Diffusion_Coeff_i = val_diffusioncoeff_i; - Diffusion_Coeff_j = val_diffusioncoeff_j; -} - -inline void CNumerics::SetEddyViscosity(su2double val_eddy_viscosity_i, su2double val_eddy_viscosity_j) { - Eddy_Viscosity_i = val_eddy_viscosity_i; - Eddy_Viscosity_j = val_eddy_viscosity_j; -} - -inline void CNumerics::SetIntermittency(su2double intermittency_in) { } - -inline void CNumerics::SetProduction(su2double val_production) { } - -inline void CNumerics::SetDestruction(su2double val_destruction) { } - -inline void CNumerics::SetCrossProduction(su2double val_crossproduction) { } - -inline su2double CNumerics::GetProduction(void) { return 0; } - -inline su2double CNumerics::GetDestruction(void) { return 0; } - -inline su2double CNumerics::GetCrossProduction(void) { return 0; } - -inline su2double CNumerics::GetGammaBC(void) { return 0.0; } - -inline void CNumerics::SetTurbKineticEnergy(su2double val_turb_ke_i, su2double val_turb_ke_j) { - turb_ke_i = val_turb_ke_i; - turb_ke_j = val_turb_ke_j; -} - -inline void CNumerics::SetDistance(su2double val_dist_i, su2double val_dist_j) { - dist_i = val_dist_i; - dist_j = val_dist_j; -} - -inline void CNumerics::SetAdjointVar(su2double *val_psi_i, su2double *val_psi_j) { - Psi_i = val_psi_i; - Psi_j = val_psi_j; -} - -inline void CNumerics::SetAdjointVarGradient(su2double **val_psivar_grad_i, su2double **val_psivar_grad_j) { - PsiVar_Grad_i = val_psivar_grad_i; - PsiVar_Grad_j = val_psivar_grad_j; -} - -inline void CNumerics::SetTurbVar(su2double *val_turbvar_i, su2double *val_turbvar_j) { - TurbVar_i = val_turbvar_i; - TurbVar_j = val_turbvar_j; -} - -inline void CNumerics::SetTransVar(su2double *val_transvar_i, su2double *val_transvar_j) { - TransVar_i = val_transvar_i; - TransVar_j = val_transvar_j; -} - -inline void CNumerics::SetTurbVarGradient(su2double **val_turbvar_grad_i, su2double **val_turbvar_grad_j) { - TurbVar_Grad_i = val_turbvar_grad_i; - TurbVar_Grad_j = val_turbvar_grad_j; -} - -inline void CNumerics::SetTransVarGradient(su2double **val_transvar_grad_i, su2double **val_transvar_grad_j) { - TransVar_Grad_i = val_transvar_grad_i; - TransVar_Grad_j = val_transvar_grad_j; -} - -inline void CNumerics::SetPrimVarGradient(su2double **val_primvar_grad_i, su2double **val_primvar_grad_j) { - PrimVar_Grad_i = val_primvar_grad_i; - PrimVar_Grad_j = val_primvar_grad_j; -} - - -inline void CNumerics::SetConsVarGradient(su2double **val_consvar_grad_i, su2double **val_consvar_grad_j) { - ConsVar_Grad_i = val_consvar_grad_i; - ConsVar_Grad_j = val_consvar_grad_j; -} - -inline void CNumerics::SetConsVarGradient(su2double **val_consvar_grad_0, su2double **val_consvar_grad_1, su2double **val_consvar_grad_2) { - ConsVar_Grad_0 = val_consvar_grad_0; - ConsVar_Grad_1 = val_consvar_grad_1; - ConsVar_Grad_2 = val_consvar_grad_2; -} - -inline void CNumerics::SetConsVarGradient(su2double **val_consvar_grad_0, su2double **val_consvar_grad_1, su2double **val_consvar_grad_2, su2double **val_consvar_grad_3) { - ConsVar_Grad_0 = val_consvar_grad_0; - ConsVar_Grad_1 = val_consvar_grad_1; - ConsVar_Grad_2 = val_consvar_grad_2; - ConsVar_Grad_3 = val_consvar_grad_3; -} - -inline void CNumerics::SetConsVarGradient(su2double **val_consvar_grad) { - ConsVar_Grad = val_consvar_grad; -} - -inline void CNumerics::SetCoord(su2double *val_coord_i, su2double *val_coord_j) { - Coord_i = val_coord_i; - Coord_j = val_coord_j; -} - -inline void CNumerics::SetCoord(su2double *val_coord_0, su2double *val_coord_1, - su2double *val_coord_2) { - Coord_0 = val_coord_0; - Coord_1 = val_coord_1; - Coord_2 = val_coord_2; -} - -inline void CNumerics::SetCoord(su2double *val_coord_0, su2double *val_coord_1, - su2double *val_coord_2, su2double *val_coord_3) { - Coord_0 = val_coord_0; - Coord_1 = val_coord_1; - Coord_2 = val_coord_2; - Coord_3 = val_coord_3; -} - -inline void CNumerics::SetGridVel(su2double *val_gridvel_i, su2double *val_gridvel_j) { - GridVel_i = val_gridvel_i; - GridVel_j = val_gridvel_j; -} - -inline void CNumerics::SetWindGust(su2double *val_windgust_i, su2double *val_windgust_j) { - WindGust_i = val_windgust_i; - WindGust_j = val_windgust_j; -} - -inline void CNumerics::SetWindGustDer(su2double *val_windgustder_i, su2double *val_windgustder_j) { - WindGustDer_i = val_windgustder_i; - WindGustDer_j = val_windgustder_j; -} - -inline void CNumerics::SetPressure(su2double val_pressure_i, su2double val_pressure_j) { - Pressure_i = val_pressure_i; - Pressure_j = val_pressure_j; -} - -inline void CNumerics::SetDensity(su2double val_densityinc_i, su2double val_densityinc_j) { - DensityInc_i = val_densityinc_i; - DensityInc_j = val_densityinc_j; -} - -inline void CNumerics::SetBetaInc2(su2double val_betainc2_i, su2double val_betainc2_j) { - BetaInc2_i = val_betainc2_i; - BetaInc2_j = val_betainc2_j; -} - -inline void CNumerics::SetSoundSpeed(su2double val_soundspeed_i, su2double val_soundspeed_j) { - SoundSpeed_i = val_soundspeed_i; - SoundSpeed_j = val_soundspeed_j; -} - -inline void CNumerics::SetEnthalpy(su2double val_enthalpy_i, su2double val_enthalpy_j) { - Enthalpy_i = val_enthalpy_i; - Enthalpy_j = val_enthalpy_j; -} - -inline void CNumerics::SetLambda(su2double val_lambda_i, su2double val_lambda_j) { - Lambda_i = val_lambda_i; - Lambda_j = val_lambda_j; -} - -inline void CNumerics::SetNeighbor(unsigned short val_neighbor_i, unsigned short val_neighbor_j) { - Neighbor_i = val_neighbor_i; - Neighbor_j = val_neighbor_j; -} - -inline void CNumerics::SetTurbAdjointVar(su2double *val_turbpsivar_i, su2double *val_turbpsivar_j) { - TurbPsi_i = val_turbpsivar_i; - TurbPsi_j = val_turbpsivar_j; -} - -inline void CNumerics::SetTurbAdjointGradient(su2double **val_turbpsivar_grad_i, su2double **val_turbpsivar_grad_j) { - TurbPsi_Grad_i = val_turbpsivar_grad_i; - TurbPsi_Grad_j = val_turbpsivar_grad_j; -} - -inline void CNumerics::SetTemperature(su2double val_temp_i, su2double val_temp_j) { - Temp_i = val_temp_i; - Temp_j = val_temp_j; -} - -inline void CNumerics::SetAuxVarGrad(su2double *val_auxvargrad_i, su2double *val_auxvargrad_j) { - AuxVar_Grad_i = val_auxvargrad_i; - AuxVar_Grad_j = val_auxvargrad_j; -} - -inline void CNumerics::SetNormal(su2double *val_normal) { Normal = val_normal; } - -inline void CNumerics::SetVolume(su2double val_volume) { Volume = val_volume; } - -inline void CNumerics::SetDissipation(su2double diss_i, su2double diss_j) { - Dissipation_i = diss_i; - Dissipation_j = diss_j; -} - -inline su2double CNumerics::GetDissipation(){ - return Dissipation_ij; -} - -inline void CSourcePieceWise_TurbSST::SetF1blending(su2double val_F1_i, su2double val_F1_j) { - F1_i = val_F1_i; - F1_j = val_F1_j; -} - -inline void CSourcePieceWise_TurbSST::SetF2blending(su2double val_F2_i, su2double val_F2_j) { - F2_i = val_F2_i; - F2_j = val_F2_j; -} - -inline void CSourcePieceWise_TurbSST::SetCrossDiff(su2double val_CDkw_i, su2double val_CDkw_j) { - CDkw_i = val_CDkw_i; - CDkw_j = val_CDkw_j; -} - -inline void CSourcePieceWise_TurbSA::SetIntermittency(su2double intermittency_in) { intermittency = intermittency_in; } - -inline void CSourcePieceWise_TurbSA::SetProduction(su2double val_production) { Production = val_production; } - -inline void CSourcePieceWise_TurbSA::SetDestruction(su2double val_destruction) { Destruction = val_destruction; } - -inline void CSourcePieceWise_TurbSA::SetCrossProduction(su2double val_crossproduction) { CrossProduction = val_crossproduction; } - -inline su2double CSourcePieceWise_TurbSA::GetProduction(void) { return Production; } - -inline su2double CSourcePieceWise_TurbSA::GetGammaBC(void) { return gamma_BC; } - -inline su2double CSourcePieceWise_TurbSA::GetDestruction(void) { return Destruction; } - -inline su2double CSourcePieceWise_TurbSA::GetCrossProduction(void) { return CrossProduction; } - -inline void CSourcePieceWise_TurbSA_E::SetIntermittency(su2double intermittency_in) { intermittency = intermittency_in; } - -inline void CSourcePieceWise_TurbSA_E::SetProduction(su2double val_production) { Production = val_production; } - -inline void CSourcePieceWise_TurbSA_E::SetDestruction(su2double val_destruction) { Destruction = val_destruction; } - -inline void CSourcePieceWise_TurbSA_E::SetCrossProduction(su2double val_crossproduction) { CrossProduction = val_crossproduction; } - -inline su2double CSourcePieceWise_TurbSA_E::GetProduction(void) { return Production; } - -inline su2double CSourcePieceWise_TurbSA_E::GetDestruction(void) { return Destruction; } - -inline su2double CSourcePieceWise_TurbSA_E::GetCrossProduction(void) { return CrossProduction; } - -inline void CSourcePieceWise_TurbSA_E_COMP::SetIntermittency(su2double intermittency_in) { intermittency = intermittency_in; } - -inline void CSourcePieceWise_TurbSA_E_COMP::SetProduction(su2double val_production) { Production = val_production; } - -inline void CSourcePieceWise_TurbSA_E_COMP::SetDestruction(su2double val_destruction) { Destruction = val_destruction; } - -inline void CSourcePieceWise_TurbSA_E_COMP::SetCrossProduction(su2double val_crossproduction) { CrossProduction = val_crossproduction; } - -inline su2double CSourcePieceWise_TurbSA_E_COMP::GetProduction(void) { return Production; } - -inline su2double CSourcePieceWise_TurbSA_E_COMP::GetDestruction(void) { return Destruction; } - -inline su2double CSourcePieceWise_TurbSA_E_COMP::GetCrossProduction(void) { return CrossProduction; } - -inline void CSourcePieceWise_TurbSA_COMP::SetIntermittency(su2double intermittency_in) { intermittency = intermittency_in; } - -inline void CSourcePieceWise_TurbSA_COMP::SetProduction(su2double val_production) { Production = val_production; } - -inline void CSourcePieceWise_TurbSA_COMP::SetDestruction(su2double val_destruction) { Destruction = val_destruction; } - -inline void CSourcePieceWise_TurbSA_COMP::SetCrossProduction(su2double val_crossproduction) { CrossProduction = val_crossproduction; } - -inline su2double CSourcePieceWise_TurbSA_COMP::GetProduction(void) { return Production; } - -inline su2double CSourcePieceWise_TurbSA_COMP::GetDestruction(void) { return Destruction; } - -inline su2double CSourcePieceWise_TurbSA_COMP::GetCrossProduction(void) { return CrossProduction; } - -inline void CSourcePieceWise_TurbSA_Neg::SetIntermittency(su2double intermittency_in) { intermittency = intermittency_in; } - -inline void CSourcePieceWise_TurbSA_Neg::SetProduction(su2double val_production) { Production = val_production; } - -inline void CSourcePieceWise_TurbSA_Neg::SetDestruction(su2double val_destruction) { Destruction = val_destruction; } - -inline void CSourcePieceWise_TurbSA_Neg::SetCrossProduction(su2double val_crossproduction) { CrossProduction = val_crossproduction; } - -inline su2double CSourcePieceWise_TurbSA_Neg::GetProduction(void) { return Production; } - -inline su2double CSourcePieceWise_TurbSA_Neg::GetDestruction(void) { return Destruction; } - -inline su2double CSourcePieceWise_TurbSA_Neg::GetCrossProduction(void) { return CrossProduction; } - -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, - su2double **val_Jacobian_j, su2double *val_Jacobian_muj, su2double ***val_Jacobian_gradj, CConfig *config) { } - -inline void CNumerics::SetTauWall(su2double val_tauwall_i, su2double val_tauwall_j) { } - -inline void CAvgGrad_Base::SetTauWall(su2double val_tauwall_i, su2double val_tauwall_j) { - TauWall_i = val_tauwall_i; - TauWall_j = val_tauwall_j; -} - -inline su2double CAvgGrad_Base::GetStressTensor(unsigned short iDim, unsigned short jDim) const { - return tau[iDim][jDim]; -} - -inline su2double CAvgGrad_Base::GetHeatFluxVector(unsigned short iDim) const { - return heat_flux_vector[iDim]; -} - -inline void CNumerics::SetUsing_UQ(bool val_using_uq) { using_uq = val_using_uq; } diff --git a/SU2_CFD/include/solvers/CSolver.hpp b/SU2_CFD/include/solvers/CSolver.hpp index 0e2939e06dcf..4fdc29531c98 100644 --- a/SU2_CFD/include/solvers/CSolver.hpp +++ b/SU2_CFD/include/solvers/CSolver.hpp @@ -42,7 +42,7 @@ #include "../fluid_model.hpp" #include "../task_definition.hpp" -#include "../numerics_structure.hpp" +#include "../numerics/CNumerics.hpp" #include "../sgs_model.hpp" #include "../../../Common/include/fem_geometry_structure.hpp" #include "../../../Common/include/geometry/CGeometry.hpp" diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index 3707c30cd822..a99180a040ed 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -32,12 +32,37 @@ #include "../../../Common/include/geometry/CPhysicalGeometry.hpp" #include "../../../Common/include/geometry/CMultiGridGeometry.hpp" -#include "../../include/numerics/elasticity/CFEALinearElasticity.hpp" -#include "../../include/numerics/elasticity/CFEAMeshElasticity.hpp" -#include "../../include/numerics/elasticity/CFEM_NeoHookean_Comp.hpp" -#include "../../include/numerics/elasticity/CFEM_Knowles_NearInc.hpp" -#include "../../include/numerics/elasticity/CFEM_IdealDE.hpp" -#include "../../include/numerics/elasticity/CFEM_DielectricElastomer.hpp" +#include "../../include/solvers/CEulerSolver.hpp" +#include "../../include/solvers/CIncEulerSolver.hpp" +#include "../../include/solvers/CNSSolver.hpp" +#include "../../include/solvers/CIncNSSolver.hpp" +#include "../../include/solvers/CTurbSASolver.hpp" +#include "../../include/solvers/CTurbSSTSolver.hpp" +#include "../../include/solvers/CTransLMSolver.hpp" +#include "../../include/solvers/CAdjEulerSolver.hpp" +#include "../../include/solvers/CAdjNSSolver.hpp" +#include "../../include/solvers/CAdjTurbSolver.hpp" +#include "../../include/solvers/CHeatSolverFVM.hpp" +#include "../../include/solvers/CFEASolver.hpp" +#include "../../include/solvers/CTemplateSolver.hpp" +#include "../../include/solvers/CDiscAdjSolver.hpp" +#include "../../include/solvers/CDiscAdjFEASolver.hpp" +#include "../../include/solvers/CFEM_DG_EulerSolver.hpp" +#include "../../include/solvers/CFEM_DG_NSSolver.hpp" +#include "../../include/solvers/CDiscAdjMeshSolver.hpp" +#include "../../include/solvers/CMeshSolver.hpp" + +#include "../../include/interfaces/cfd/CConservativeVarsInterface.hpp" +#include "../../include/interfaces/cfd/CMixingPlaneInterface.hpp" +#include "../../include/interfaces/cfd/CSlidingInterface.hpp" +#include "../../include/interfaces/cht/CConjugateHeatInterface.hpp" +#include "../../include/interfaces/fsi/CDisplacementsInterface.hpp" +#include "../../include/interfaces/fsi/CFlowTractionInterface.hpp" +#include "../../include/interfaces/fsi/CDiscAdjFlowTractionInterface.hpp" +#include "../../include/interfaces/fsi/CDisplacementsInterfaceLegacy.hpp" +#include "../../include/interfaces/fsi/CDiscAdjDisplacementsInterfaceLegacy.hpp" + +#include "../../include/numerics/include_all.hpp" #include "../../../Common/include/omp_structure.hpp" diff --git a/SU2_CFD/src/numerics_structure.cpp b/SU2_CFD/src/numerics/CNumerics.cpp similarity index 98% rename from SU2_CFD/src/numerics_structure.cpp rename to SU2_CFD/src/numerics/CNumerics.cpp index be6263f6e45e..b41295e127ef 100644 --- a/SU2_CFD/src/numerics_structure.cpp +++ b/SU2_CFD/src/numerics/CNumerics.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -26,21 +26,21 @@ */ -#include "../include/numerics_structure.hpp" +#include "../../include/numerics/CNumerics.hpp" CNumerics::CNumerics(void) { Normal = NULL; UnitNormal = NULL; UnitNormald = NULL; - + U_n = NULL; U_nM1 = NULL; U_nP1 = NULL; - + Proj_Flux_Tensor = NULL; Flux_Tensor = NULL; - + tau = NULL; delta = NULL; delta3 = NULL; @@ -55,27 +55,27 @@ CNumerics::CNumerics(void) { l = NULL; m = NULL; - + using_uq = false; } CNumerics::CNumerics(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) { - + unsigned short iVar, iDim, jDim; - + Normal = NULL; UnitNormal = NULL; UnitNormald = NULL; - + U_n = NULL; U_nM1 = NULL; U_nP1 = NULL; - + Proj_Flux_Tensor = NULL; Flux_Tensor = NULL; - + tau = NULL; delta = NULL; delta3 = NULL; @@ -89,7 +89,7 @@ CNumerics::CNumerics(unsigned short val_nDim, unsigned short val_nVar, l = NULL; m = NULL; - MeanReynoldsStress = NULL; + MeanReynoldsStress = NULL; MeanPerturbedRSM = NULL; A_ij = NULL; Eig_Vec = NULL; @@ -98,8 +98,8 @@ CNumerics::CNumerics(unsigned short val_nDim, unsigned short val_nVar, Corners = NULL; Eig_Val = NULL; Barycentric_Coord = NULL; - New_Coord = NULL; - + New_Coord = NULL; + nDim = val_nDim; nVar = val_nVar; Gamma = config->GetGamma(); @@ -152,12 +152,12 @@ CNumerics::CNumerics(unsigned short val_nDim, unsigned short val_nVar, turb_ke_i = 0.0; turb_ke_j = 0.0; - + Vector = new su2double[nDim]; - + l = new su2double [nDim]; m = new su2double [nDim]; - + Dissipation_ij = 1.0; /* --- Initializing variables for the UQ methodology --- */ @@ -165,7 +165,7 @@ CNumerics::CNumerics(unsigned short val_nDim, unsigned short val_nVar, if (using_uq){ MeanReynoldsStress = new su2double* [3]; MeanPerturbedRSM = new su2double* [3]; - A_ij = new su2double* [3]; + A_ij = new su2double* [3]; newA_ij = new su2double* [3]; Eig_Vec = new su2double* [3]; New_Eig_Vec = new su2double* [3]; @@ -196,7 +196,7 @@ CNumerics::CNumerics(unsigned short val_nDim, unsigned short val_nVar, Corners[2][0] = 0.5; Corners[2][1] = 0.866025; } - + } CNumerics::~CNumerics(void) { @@ -314,11 +314,11 @@ void CNumerics::GetInviscidProjFlux(su2double *val_density, su2double *val_enthalpy, su2double *val_normal, su2double *val_Proj_Flux) { - + su2double rhou, rhov, rhow; - + if (nDim == 2) { - + rhou = (*val_density)*val_velocity[0]; rhov = (*val_density)*val_velocity[1]; @@ -331,10 +331,10 @@ void CNumerics::GetInviscidProjFlux(su2double *val_density, val_Proj_Flux[1] += rhov*val_velocity[0]*val_normal[1]; val_Proj_Flux[2] += (rhov*val_velocity[1]+(*val_pressure))*val_normal[1]; val_Proj_Flux[3] += rhov*(*val_enthalpy)*val_normal[1]; - - } + + } else { - + rhou = (*val_density)*val_velocity[0]; rhov = (*val_density)*val_velocity[1]; rhow = (*val_density)*val_velocity[2]; @@ -356,7 +356,7 @@ void CNumerics::GetInviscidProjFlux(su2double *val_density, val_Proj_Flux[2] += rhow*val_velocity[1]*val_normal[2]; val_Proj_Flux[3] += (rhow*val_velocity[2]+(*val_pressure))*val_normal[2]; val_Proj_Flux[4] += rhow*(*val_enthalpy)*val_normal[2]; - + } } @@ -369,7 +369,7 @@ void CNumerics::GetInviscidIncProjFlux(su2double *val_density, su2double *val_normal, su2double *val_Proj_Flux) { su2double rhou, rhov, rhow; - + if (nDim == 2) { rhou = (*val_density)*val_velocity[0]; rhov = (*val_density)*val_velocity[1]; @@ -383,14 +383,14 @@ void CNumerics::GetInviscidIncProjFlux(su2double *val_density, rhou = (*val_density)*val_velocity[0]; rhov = (*val_density)*val_velocity[1]; rhow = (*val_density)*val_velocity[2]; - + val_Proj_Flux[0] = rhou*val_normal[0] + rhov*val_normal[1] + rhow*val_normal[2]; val_Proj_Flux[1] = (rhou*val_velocity[0]+(*val_pressure))*val_normal[0] + rhou*val_velocity[1]*val_normal[1] + rhou*val_velocity[2]*val_normal[2]; val_Proj_Flux[2] = rhov*val_velocity[0]*val_normal[0] + (rhov*val_velocity[1]+(*val_pressure))*val_normal[1] + rhov*val_velocity[2]*val_normal[2]; val_Proj_Flux[3] = rhow*val_velocity[0]*val_normal[0] + rhow*val_velocity[1]*val_normal[1] + (rhow*val_velocity[2]+(*val_pressure))*val_normal[2]; val_Proj_Flux[4] = (rhou*val_normal[0] + rhov*val_normal[1] + rhow*val_normal[2])*(*val_enthalpy); } - + } void CNumerics::GetInviscidProjJac(su2double *val_velocity, su2double *val_energy, @@ -399,22 +399,22 @@ void CNumerics::GetInviscidProjJac(su2double *val_velocity, su2double *val_energ AD_BEGIN_PASSIVE unsigned short iDim, jDim; su2double sqvel, proj_vel, phi, a1, a2; - + sqvel = 0.0; proj_vel = 0.0; for (iDim = 0; iDim < nDim; iDim++) { sqvel += val_velocity[iDim]*val_velocity[iDim]; proj_vel += val_velocity[iDim]*val_normal[iDim]; } - + phi = 0.5*Gamma_Minus_One*sqvel; a1 = Gamma*(*val_energy)-phi; a2 = Gamma-1.0; - + val_Proj_Jac_Tensor[0][0] = 0.0; for (iDim = 0; iDim < nDim; iDim++) val_Proj_Jac_Tensor[0][iDim+1] = val_scale*val_normal[iDim]; val_Proj_Jac_Tensor[0][nDim+1] = 0.0; - + for (iDim = 0; iDim < nDim; iDim++) { val_Proj_Jac_Tensor[iDim+1][0] = val_scale*(val_normal[iDim]*phi - val_velocity[iDim]*proj_vel); for (jDim = 0; jDim < nDim; jDim++) @@ -422,7 +422,7 @@ void CNumerics::GetInviscidProjJac(su2double *val_velocity, su2double *val_energ val_Proj_Jac_Tensor[iDim+1][iDim+1] += val_scale*proj_vel; val_Proj_Jac_Tensor[iDim+1][nDim+1] = val_scale*a2*val_normal[iDim]; } - + val_Proj_Jac_Tensor[nDim+1][0] = val_scale*proj_vel*(phi-a1); for (iDim = 0; iDim < nDim; iDim++) val_Proj_Jac_Tensor[nDim+1][iDim+1] = val_scale*(val_normal[iDim]*a1-a2*val_velocity[iDim]*proj_vel); @@ -589,7 +589,7 @@ void CNumerics::GetPreconditionedProjJac(su2double *val_density, su2double *val_ for (iDim = 0; iDim < nDim; iDim++) val_invPrecon_A[iDim+1][nDim+1] = 0.0; val_invPrecon_A[nDim+1][nDim+1] = val_lambda[nDim-1]; - + } void CNumerics::SetPastSol (su2double *val_u_nM1, su2double *val_u_n, su2double *val_u_nP1) { @@ -611,75 +611,75 @@ void CNumerics::SetPastVolume (su2double val_volume_nM1, su2double val_volume_n, void CNumerics::GetPMatrix(su2double *val_density, su2double *val_velocity, su2double *val_soundspeed, su2double *val_normal, su2double **val_p_tensor) { - + su2double sqvel, rhooc, rhoxc; //su2double c2; - + rhooc = *val_density / *val_soundspeed; rhoxc = *val_density * *val_soundspeed; //c2 = *val_soundspeed * *val_soundspeed; - + if (nDim == 2) { - + sqvel = val_velocity[0]*val_velocity[0]+val_velocity[1]*val_velocity[1]; - + val_p_tensor[0][0] = 1.0; val_p_tensor[0][1]=0.0; val_p_tensor[0][2]=0.5*rhooc; val_p_tensor[0][3]=0.5*rhooc; - + val_p_tensor[1][0]=val_velocity[0]; val_p_tensor[1][1]=*val_density*val_normal[1]; val_p_tensor[1][2]=0.5*(val_velocity[0]*rhooc+val_normal[0]**val_density); val_p_tensor[1][3]=0.5*(val_velocity[0]*rhooc-val_normal[0]**val_density); - + val_p_tensor[2][0]=val_velocity[1]; val_p_tensor[2][1]=-*val_density*val_normal[0]; val_p_tensor[2][2]=0.5*(val_velocity[1]*rhooc+val_normal[1]**val_density); val_p_tensor[2][3]=0.5*(val_velocity[1]*rhooc-val_normal[1]**val_density); - + val_p_tensor[3][0]=0.5*sqvel; val_p_tensor[3][1]=*val_density*val_velocity[0]*val_normal[1]-*val_density*val_velocity[1]*val_normal[0]; val_p_tensor[3][2]=0.5*(0.5*sqvel*rhooc+*val_density*val_velocity[0]*val_normal[0]+*val_density*val_velocity[1]*val_normal[1]+rhoxc/Gamma_Minus_One); val_p_tensor[3][3]=0.5*(0.5*sqvel*rhooc-*val_density*val_velocity[0]*val_normal[0]-*val_density*val_velocity[1]*val_normal[1]+rhoxc/Gamma_Minus_One); - + } else { - + sqvel = val_velocity[0]*val_velocity[0]+val_velocity[1]*val_velocity[1]+val_velocity[2]*val_velocity[2]; - + val_p_tensor[0][0]=val_normal[0]; val_p_tensor[0][1]=val_normal[1]; val_p_tensor[0][2]=val_normal[2]; val_p_tensor[0][3]=0.5*rhooc; val_p_tensor[0][4]=0.5*rhooc; - + val_p_tensor[1][0]=val_velocity[0]*val_normal[0]; val_p_tensor[1][1]=val_velocity[0]*val_normal[1]-*val_density*val_normal[2]; val_p_tensor[1][2]=val_velocity[0]*val_normal[2]+*val_density*val_normal[1]; val_p_tensor[1][3]=0.5*(val_velocity[0]*rhooc+*val_density*val_normal[0]); val_p_tensor[1][4]=0.5*(val_velocity[0]*rhooc-*val_density*val_normal[0]); - + val_p_tensor[2][0]=val_velocity[1]*val_normal[0]+*val_density*val_normal[2]; val_p_tensor[2][1]=val_velocity[1]*val_normal[1]; val_p_tensor[2][2]=val_velocity[1]*val_normal[2]-*val_density*val_normal[0]; val_p_tensor[2][3]=0.5*(val_velocity[1]*rhooc+*val_density*val_normal[1]); val_p_tensor[2][4]=0.5*(val_velocity[1]*rhooc-*val_density*val_normal[1]); - + val_p_tensor[3][0]=val_velocity[2]*val_normal[0]-*val_density*val_normal[1]; val_p_tensor[3][1]=val_velocity[2]*val_normal[1]+*val_density*val_normal[0]; val_p_tensor[3][2]=val_velocity[2]*val_normal[2]; val_p_tensor[3][3]=0.5*(val_velocity[2]*rhooc+*val_density*val_normal[2]); val_p_tensor[3][4]=0.5*(val_velocity[2]*rhooc-*val_density*val_normal[2]); - + val_p_tensor[4][0]=0.5*sqvel*val_normal[0]+*val_density*val_velocity[1]*val_normal[2]-*val_density*val_velocity[2]*val_normal[1]; val_p_tensor[4][1]=0.5*sqvel*val_normal[1]-*val_density*val_velocity[0]*val_normal[2]+*val_density*val_velocity[2]*val_normal[0]; val_p_tensor[4][2]=0.5*sqvel*val_normal[2]+*val_density*val_velocity[0]*val_normal[1]-*val_density*val_velocity[1]*val_normal[0]; val_p_tensor[4][3]=0.5*(0.5*sqvel*rhooc+*val_density*(val_velocity[0]*val_normal[0]+val_velocity[1]*val_normal[1]+val_velocity[2]*val_normal[2])+rhoxc/Gamma_Minus_One); val_p_tensor[4][4]=0.5*(0.5*sqvel*rhooc-*val_density*(val_velocity[0]*val_normal[0]+val_velocity[1]*val_normal[1]+val_velocity[2]*val_normal[2])+rhoxc/Gamma_Minus_One); - + } - + } void CNumerics::GetPMatrix(su2double *val_density, su2double *val_velocity, @@ -687,7 +687,7 @@ void CNumerics::GetPMatrix(su2double *val_density, su2double *val_velocity, su2double sqvel, rhooc, zeta; //su2double rhoxc, c2; - + rhooc = *val_density / *val_soundspeed; //rhoxc = *val_density * *val_soundspeed; //c2 = *val_soundspeed * *val_soundspeed; @@ -755,7 +755,7 @@ void CNumerics::GetPMatrix(su2double *val_density, su2double *val_velocity, void CNumerics::GetPMatrix_inv(su2double *val_density, su2double *val_velocity, su2double *val_soundspeed, su2double *val_normal, su2double **val_invp_tensor) { - + su2double rhoxc, c2, gm1, k0orho, k1orho, gm1_o_c2, gm1_o_rhoxc, sqvel; rhoxc = *val_density * *val_soundspeed; @@ -767,7 +767,7 @@ void CNumerics::GetPMatrix_inv(su2double *val_density, su2double *val_velocity, gm1_o_rhoxc = gm1/rhoxc; if (nDim == 3) { - + sqvel = val_velocity[0]*val_velocity[0]+val_velocity[1]*val_velocity[1]+val_velocity[2]*val_velocity[2]; val_invp_tensor[0][0]=val_normal[0]-val_normal[2]*val_velocity[1] / *val_density+val_normal[1]*val_velocity[2] / *val_density-val_normal[0]*0.5*gm1*sqvel/c2; @@ -799,10 +799,10 @@ void CNumerics::GetPMatrix_inv(su2double *val_density, su2double *val_velocity, val_invp_tensor[4][2]=-val_normal[1] / *val_density-gm1*val_velocity[1]/rhoxc; val_invp_tensor[4][3]=-val_normal[2] / *val_density-gm1*val_velocity[2]/rhoxc; val_invp_tensor[4][4]=Gamma_Minus_One/rhoxc; - + } if (nDim == 2) { - + sqvel = val_velocity[0]*val_velocity[0]+val_velocity[1]*val_velocity[1]; val_invp_tensor[0][0] = 1.0-0.5*gm1_o_c2*sqvel; @@ -824,7 +824,7 @@ void CNumerics::GetPMatrix_inv(su2double *val_density, su2double *val_velocity, val_invp_tensor[3][1]=-k0orho-gm1_o_rhoxc*val_velocity[0]; val_invp_tensor[3][2]=-k1orho-gm1_o_rhoxc*val_velocity[1]; val_invp_tensor[3][3]=gm1_o_rhoxc; - + } } @@ -1396,7 +1396,7 @@ void CNumerics::GetAdjViscousFlux_Jac(su2double Pressure_i, su2double Pressure_j su2double dPhiE_dn, su2double *Normal, su2double *Edge_Vector, su2double dist_ij_2, su2double *val_residual_i, su2double *val_residual_j, su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, bool implicit) { - + su2double Sigma_xx, Sigma_yy, Sigma_zz, Sigma_xy, Sigma_xz, Sigma_yz, Sigma_xx5, Sigma_yy5, Sigma_zz5, Sigma_xy5, Sigma_xz5, Sigma_yz5, Sigma_5, eta_xx, eta_yy, eta_zz, eta_xy, eta_xz, eta_yz; @@ -1405,11 +1405,11 @@ void CNumerics::GetAdjViscousFlux_Jac(su2double Pressure_i, su2double Pressure_j su2double dSigmaxx_phi3, dSigmayy_phi3, dSigmazz_phi3, dSigmaxy_phi3, dSigmaxz_phi3, dSigmayz_phi3; su2double dSigma5_psi5; unsigned short iVar, jVar; - + if (nDim == 3) { - + /*--- Residual at iPoint ---*/ - + Sigma_xx = ViscDens_i * (FOUR3 * Mean_GradPhi[0][0] - TWO3 * Mean_GradPhi[1][1] - TWO3 * Mean_GradPhi[2][2]); Sigma_yy = ViscDens_i * (-TWO3 * Mean_GradPhi[0][0] + FOUR3 * Mean_GradPhi[1][1] - TWO3 * Mean_GradPhi[2][2]); Sigma_zz = ViscDens_i * (-TWO3 * Mean_GradPhi[0][0] - TWO3 * Mean_GradPhi[1][1] + FOUR3 * Mean_GradPhi[2][2]); @@ -1425,22 +1425,22 @@ void CNumerics::GetAdjViscousFlux_Jac(su2double Pressure_i, su2double Pressure_j Sigma_5 = XiDens_i * dPhiE_dn; eta_xx = Sigma_xx + Sigma_xx5; eta_yy = Sigma_yy + Sigma_yy5; eta_zz = Sigma_zz + Sigma_zz5; eta_xy = Sigma_xy + Sigma_xy5; eta_xz = Sigma_xz + Sigma_xz5; eta_yz = Sigma_yz + Sigma_yz5; - + val_residual_i[0] = - (Velocity_i[0] * Normal[0] * eta_xx + Velocity_i[1] * Normal[1] * eta_yy + Velocity_i[2] * Normal[2] * eta_zz + (Velocity_i[0] * Normal[1] + Velocity_i[1] * Normal[0]) * eta_xy + (Velocity_i[0] * Normal[2] + Velocity_i[2] * Normal[0]) * eta_xz + (Velocity_i[2] * Normal[1] + Velocity_i[1] * Normal[2]) * eta_yz - (sq_vel_i - Pressure_i/(Density_i*Gamma_Minus_One)) * Sigma_5); - + val_residual_i[1] = (eta_xx * Normal[0] + eta_xy * Normal[1] + eta_xz * Normal[2] - Velocity_i[0] * Sigma_5); val_residual_i[2] = (eta_xy * Normal[0] + eta_yy * Normal[1] + eta_yz * Normal[2] - Velocity_i[1] * Sigma_5); val_residual_i[3] = (eta_xz * Normal[0] + eta_yz * Normal[1] + eta_zz * Normal[2] - Velocity_i[2] * Sigma_5); val_residual_i[4] = (Sigma_5); - + /*--- Computation of the Jacobians at Point i---*/ - + if (implicit) { - + dSigmaxx_phi1 = -FOUR3 * ViscDens_i * Edge_Vector[0]/dist_ij_2; dSigmaxx_phi2 = TWO3 * ViscDens_i * Edge_Vector[1]/dist_ij_2; dSigmaxx_phi3 = TWO3 * ViscDens_i * Edge_Vector[2]/dist_ij_2; @@ -1459,7 +1459,7 @@ void CNumerics::GetAdjViscousFlux_Jac(su2double Pressure_i, su2double Pressure_j dSigmayz_phi1 = 0; dSigmayz_phi2 = -ViscDens_i * Edge_Vector[2]/dist_ij_2; dSigmayz_phi3 = -ViscDens_i * Edge_Vector[1]/dist_ij_2; - + // dSigmaxx5_psi5 = -ViscDens_i * ( FOUR3*Velocity_i[0]*Edge_Vector[0] - TWO3*Velocity_i[1]*Edge_Vector[1] - TWO3*Velocity_i[2]*Edge_Vector[2])/dist_ij_2; // dSigmayy5_psi5 = -ViscDens_i * (- TWO3*Velocity_i[0]*Edge_Vector[0] + FOUR3*Velocity_i[1]*Edge_Vector[1] - TWO3*Velocity_i[2]*Edge_Vector[2])/dist_ij_2; // dSigmazz5_psi5 = -ViscDens_i * (- TWO3*Velocity_i[0]*Edge_Vector[0] - TWO3*Velocity_i[1]*Edge_Vector[1] + FOUR3*Velocity_i[2]*Edge_Vector[2])/dist_ij_2; @@ -1467,7 +1467,7 @@ void CNumerics::GetAdjViscousFlux_Jac(su2double Pressure_i, su2double Pressure_j // dSigmaxz5_psi5 = -ViscDens_i * ( Velocity_i[0]*Edge_Vector[2] + Velocity_i[2]*Edge_Vector[0] )/dist_ij_2; // dSigmayz5_psi5 = -ViscDens_i * ( Velocity_i[1]*Edge_Vector[2] + Velocity_i[2]*Edge_Vector[1] )/dist_ij_2; dSigma5_psi5 = -XiDens_i * ( Edge_Vector[0]*Normal[0] + Edge_Vector[1]*Normal[1] + Edge_Vector[2]*Normal[2] )/dist_ij_2; - + val_Jacobian_ii[0][0] = 0; val_Jacobian_ii[0][1] = -( Velocity_i[0]*Normal[0]*dSigmaxx_phi1 + Velocity_i[1]*Normal[1]*dSigmayy_phi1 + Velocity_i[2]*Normal[2]*dSigmazz_phi1 + (Velocity_i[0]*Normal[1] + Velocity_i[1]*Normal[0])*dSigmaxy_phi1 @@ -1482,38 +1482,38 @@ void CNumerics::GetAdjViscousFlux_Jac(su2double Pressure_i, su2double Pressure_j + (Velocity_i[0]*Normal[2] + Velocity_i[2]*Normal[0])*dSigmaxz_phi3 + (Velocity_i[2]*Normal[1] + Velocity_i[1]*Normal[2])*dSigmayz_phi3 ); val_Jacobian_ii[0][4] = (sq_vel_i - Pressure_i/(Density_i*Gamma_Minus_One)) * dSigma5_psi5; - + val_Jacobian_ii[1][0] = 0; val_Jacobian_ii[1][1] = Normal[0]*dSigmaxx_phi1 + Normal[1]*dSigmaxy_phi1 + Normal[2]*dSigmaxz_phi1; val_Jacobian_ii[1][2] = Normal[0]*dSigmaxx_phi2 + Normal[1]*dSigmaxy_phi2 + Normal[2]*dSigmaxz_phi2; val_Jacobian_ii[1][3] = Normal[0]*dSigmaxx_phi3 + Normal[1]*dSigmaxy_phi3 + Normal[2]*dSigmaxz_phi3; val_Jacobian_ii[1][4] = -Velocity_i[0]*dSigma5_psi5; - + val_Jacobian_ii[2][0] = 0; val_Jacobian_ii[2][1] = Normal[0]*dSigmaxy_phi1 + Normal[1]*dSigmayy_phi1 + Normal[2]*dSigmayz_phi1; val_Jacobian_ii[2][2] = Normal[0]*dSigmaxy_phi2 + Normal[1]*dSigmayy_phi2 + Normal[2]*dSigmayz_phi2; val_Jacobian_ii[2][3] = Normal[0]*dSigmaxy_phi3 + Normal[1]*dSigmayy_phi3 + Normal[2]*dSigmayz_phi3; val_Jacobian_ii[2][4] = -Velocity_i[1]*dSigma5_psi5; - + val_Jacobian_ii[3][0] = 0; val_Jacobian_ii[3][1] = Normal[0]*dSigmaxz_phi1 + Normal[1]*dSigmayz_phi1 + Normal[2]*dSigmazz_phi1; val_Jacobian_ii[3][2] = Normal[0]*dSigmaxz_phi2 + Normal[1]*dSigmayz_phi2 + Normal[2]*dSigmazz_phi2; val_Jacobian_ii[3][3] = Normal[0]*dSigmaxz_phi3 + Normal[1]*dSigmayz_phi3 + Normal[2]*dSigmazz_phi3; val_Jacobian_ii[3][4] = -Velocity_i[2]*dSigma5_psi5; - + val_Jacobian_ii[4][0] = 0; val_Jacobian_ii[4][1] = 0; val_Jacobian_ii[4][2] = 0; val_Jacobian_ii[4][3] = 0; val_Jacobian_ii[4][4] = dSigma5_psi5; - + for (iVar = 0; iVar < nVar; iVar++) for (jVar = 0; jVar < nVar; jVar++) val_Jacobian_ij[iVar][jVar] = -val_Jacobian_ii[iVar][jVar]; } - + /*--- Residual at jPoint ---*/ - + Sigma_xx = ViscDens_j * (FOUR3 * Mean_GradPhi[0][0] - TWO3 * Mean_GradPhi[1][1] - TWO3 * Mean_GradPhi[2][2]); Sigma_yy = ViscDens_j * (-TWO3 * Mean_GradPhi[0][0] + FOUR3 * Mean_GradPhi[1][1] - TWO3 * Mean_GradPhi[2][2]); Sigma_zz = ViscDens_j * (-TWO3 * Mean_GradPhi[0][0] - TWO3 * Mean_GradPhi[1][1] + FOUR3 * Mean_GradPhi[2][2]); @@ -1529,7 +1529,7 @@ void CNumerics::GetAdjViscousFlux_Jac(su2double Pressure_i, su2double Pressure_j Sigma_5 = XiDens_j * dPhiE_dn; eta_xx = Sigma_xx + Sigma_xx5; eta_yy = Sigma_yy + Sigma_yy5; eta_zz = Sigma_zz + Sigma_zz5; eta_xy = Sigma_xy + Sigma_xy5; eta_xz = Sigma_xz + Sigma_xz5; eta_yz = Sigma_yz + Sigma_yz5; - + val_residual_j[0] = - (Velocity_j[0] * Normal[0] * eta_xx + Velocity_j[1] * Normal[1] * eta_yy + Velocity_j[2] * Normal[2] * eta_zz + (Velocity_j[0] * Normal[1] + Velocity_j[1] * Normal[0]) * eta_xy + (Velocity_j[0] * Normal[2] + Velocity_j[2] * Normal[0]) * eta_xz @@ -1539,11 +1539,11 @@ void CNumerics::GetAdjViscousFlux_Jac(su2double Pressure_i, su2double Pressure_j val_residual_j[2] = (eta_xy * Normal[0] + eta_yy * Normal[1] + eta_yz * Normal[2] - Velocity_j[1] * Sigma_5); val_residual_j[3] = (eta_xz * Normal[0] + eta_yz * Normal[1] + eta_zz * Normal[2] - Velocity_j[2] * Sigma_5); val_residual_j[4] = (Sigma_5); - + /*--- Computation of the Jacobians at Point j---*/ - + if (implicit) { - + dSigmaxx_phi1 = FOUR3 * ViscDens_j * Edge_Vector[0]/dist_ij_2; dSigmaxx_phi2 = -TWO3 * ViscDens_j * Edge_Vector[1]/dist_ij_2; dSigmaxx_phi3 = -TWO3 * ViscDens_j * Edge_Vector[2]/dist_ij_2; @@ -1562,7 +1562,7 @@ void CNumerics::GetAdjViscousFlux_Jac(su2double Pressure_i, su2double Pressure_j dSigmayz_phi1 = 0; dSigmayz_phi2 = ViscDens_j * Edge_Vector[2]/dist_ij_2; dSigmayz_phi3 = ViscDens_j * Edge_Vector[1]/dist_ij_2; - + // dSigmaxx5_psi5 = ViscDens_j * ( FOUR3*Velocity_j[0]*Edge_Vector[0] - TWO3*Velocity_j[1]*Edge_Vector[1] - TWO3*Velocity_j[2]*Edge_Vector[2])/dist_ij_2; // dSigmayy5_psi5 = ViscDens_j * (- TWO3*Velocity_j[0]*Edge_Vector[0] + FOUR3*Velocity_j[1]*Edge_Vector[1] - TWO3*Velocity_j[2]*Edge_Vector[2])/dist_ij_2; // dSigmazz5_psi5 = ViscDens_j * (- TWO3*Velocity_j[0]*Edge_Vector[0] - TWO3*Velocity_j[1]*Edge_Vector[1] + FOUR3*Velocity_j[2]*Edge_Vector[2])/dist_ij_2; @@ -1570,7 +1570,7 @@ void CNumerics::GetAdjViscousFlux_Jac(su2double Pressure_i, su2double Pressure_j // dSigmaxz5_psi5 = ViscDens_j * ( Velocity_j[0]*Edge_Vector[2] + Velocity_j[2]*Edge_Vector[0] )/dist_ij_2; // dSigmayz5_psi5 = ViscDens_j * ( Velocity_j[1]*Edge_Vector[2] + Velocity_j[2]*Edge_Vector[1] )/dist_ij_2; dSigma5_psi5 = XiDens_j * ( Edge_Vector[0]*Normal[0] + Edge_Vector[1]*Normal[1] + Edge_Vector[2]*Normal[2] )/dist_ij_2; - + val_Jacobian_jj[0][0] = 0; val_Jacobian_jj[0][1] = -( Velocity_j[0]*Normal[0]*dSigmaxx_phi1 + Velocity_j[1]*Normal[1]*dSigmayy_phi1 + Velocity_j[2]*Normal[2]*dSigmazz_phi1 + (Velocity_j[0]*Normal[1] + Velocity_j[1]*Normal[0])*dSigmaxy_phi1 @@ -1585,41 +1585,41 @@ void CNumerics::GetAdjViscousFlux_Jac(su2double Pressure_i, su2double Pressure_j + (Velocity_j[0]*Normal[2] + Velocity_j[2]*Normal[0])*dSigmaxz_phi3 + (Velocity_j[2]*Normal[1] + Velocity_j[1]*Normal[2])*dSigmayz_phi3 ); val_Jacobian_jj[0][4] = (sq_vel_j - Pressure_j/(Density_j*Gamma_Minus_One)) * dSigma5_psi5; - + val_Jacobian_jj[1][0] = 0; val_Jacobian_jj[1][1] = Normal[0]*dSigmaxx_phi1 + Normal[1]*dSigmaxy_phi1 + Normal[2]*dSigmaxz_phi1; val_Jacobian_jj[1][2] = Normal[0]*dSigmaxx_phi2 + Normal[1]*dSigmaxy_phi2 + Normal[2]*dSigmaxz_phi2; val_Jacobian_jj[1][3] = Normal[0]*dSigmaxx_phi3 + Normal[1]*dSigmaxy_phi3 + Normal[2]*dSigmaxz_phi3; val_Jacobian_jj[1][4] = -Velocity_j[0]*dSigma5_psi5; - + val_Jacobian_jj[2][0] = 0; val_Jacobian_jj[2][1] = Normal[0]*dSigmaxy_phi1 + Normal[1]*dSigmayy_phi1 + Normal[2]*dSigmayz_phi1; val_Jacobian_jj[2][2] = Normal[0]*dSigmaxy_phi2 + Normal[1]*dSigmayy_phi2 + Normal[2]*dSigmayz_phi2; val_Jacobian_jj[2][3] = Normal[0]*dSigmaxy_phi3 + Normal[1]*dSigmayy_phi3 + Normal[2]*dSigmayz_phi3; val_Jacobian_jj[2][4] = -Velocity_j[1]*dSigma5_psi5; - + val_Jacobian_jj[3][0] = 0; val_Jacobian_jj[3][1] = Normal[0]*dSigmaxz_phi1 + Normal[1]*dSigmayz_phi1 + Normal[2]*dSigmazz_phi1; val_Jacobian_jj[3][2] = Normal[0]*dSigmaxz_phi2 + Normal[1]*dSigmayz_phi2 + Normal[2]*dSigmazz_phi2; val_Jacobian_jj[3][3] = Normal[0]*dSigmaxz_phi3 + Normal[1]*dSigmayz_phi3 + Normal[2]*dSigmazz_phi3; val_Jacobian_jj[3][4] = -Velocity_j[2]*dSigma5_psi5; - + val_Jacobian_jj[4][0] = 0; val_Jacobian_jj[4][1] = 0; val_Jacobian_jj[4][2] = 0; val_Jacobian_jj[4][3] = 0; val_Jacobian_jj[4][4] = dSigma5_psi5; - + for (iVar = 0; iVar < nVar; iVar++) for (jVar = 0; jVar < nVar; jVar++) val_Jacobian_ji[iVar][jVar] = -val_Jacobian_jj[iVar][jVar]; } - + } else if (nDim == 2) { - + /*--- Residual at iPoint ---*/ - + Sigma_xx = ViscDens_i * (FOUR3 * Mean_GradPhi[0][0] - TWO3 * Mean_GradPhi[1][1]); Sigma_yy = ViscDens_i * (-TWO3 * Mean_GradPhi[0][0] + FOUR3 * Mean_GradPhi[1][1]); Sigma_xy = ViscDens_i * (Mean_GradPhi[1][0] + Mean_GradPhi[0][1]); @@ -1628,58 +1628,58 @@ void CNumerics::GetAdjViscousFlux_Jac(su2double Pressure_i, su2double Pressure_j Sigma_xy5 = ViscDens_i * (Velocity_i[0] * Mean_GradPsiE[1] + Velocity_i[1] * Mean_GradPsiE[0]); Sigma_5 = XiDens_i * dPhiE_dn; eta_xx = Sigma_xx + Sigma_xx5; eta_yy = Sigma_yy + Sigma_yy5; eta_xy = Sigma_xy + Sigma_xy5; - + val_residual_i[0] = - (Velocity_i[0] * Normal[0] * eta_xx + Velocity_i[1] * Normal[1] * eta_yy + (Velocity_i[0] * Normal[1] + Velocity_i[1] * Normal[0]) * eta_xy - (sq_vel_i - Pressure_i/(Density_i*Gamma_Minus_One)) * Sigma_5); val_residual_i[1] = (eta_xx * Normal[0] + eta_xy * Normal[1] - Velocity_i[0] * Sigma_5); val_residual_i[2] = (eta_xy * Normal[0] + eta_yy * Normal[1] - Velocity_i[1] * Sigma_5); val_residual_i[3] = (Sigma_5); - + /*--- Computation of the Jacobians at Point i---*/ - + if (implicit) { - + dSigmaxx_phi1 = -FOUR3 * ViscDens_i * Edge_Vector[0]/dist_ij_2; dSigmaxx_phi2 = TWO3 * ViscDens_i * Edge_Vector[1]/dist_ij_2; dSigmayy_phi1 = TWO3 * ViscDens_i * Edge_Vector[0]/dist_ij_2; dSigmayy_phi2 = -FOUR3 * ViscDens_i * Edge_Vector[1]/dist_ij_2; dSigmaxy_phi1 = -ViscDens_i * Edge_Vector[1]/dist_ij_2; dSigmaxy_phi2 = -ViscDens_i * Edge_Vector[0]/dist_ij_2; - + // dSigmaxx5_psi5 = -ViscDens_i * ( FOUR3*Velocity_i[0]*Edge_Vector[0] - TWO3*Velocity_i[1]*Edge_Vector[1] )/dist_ij_2; // dSigmayy5_psi5 = -ViscDens_i * (- TWO3*Velocity_i[0]*Edge_Vector[0] + FOUR3*Velocity_i[1]*Edge_Vector[1] )/dist_ij_2; // dSigmaxy5_psi5 = -ViscDens_i * ( Velocity_i[0]*Edge_Vector[1] + Velocity_i[1]*Edge_Vector[0] )/dist_ij_2; dSigma5_psi5 = -XiDens_i * ( Edge_Vector[0]*Normal[0] + Edge_Vector[1]*Normal[1] )/dist_ij_2; - + val_Jacobian_ii[0][0] = 0; - + val_Jacobian_ii[0][1] = -( Velocity_i[0]*Normal[0]*dSigmaxx_phi1 + Velocity_i[1]*Normal[1]*dSigmayy_phi1 + (Velocity_i[0]*Normal[1] + Velocity_i[1]*Normal[0])*dSigmaxy_phi1 ); val_Jacobian_ii[0][2] = -( Velocity_i[0]*Normal[0]*dSigmaxx_phi2 + Velocity_i[1]*Normal[1]*dSigmayy_phi2 + (Velocity_i[0]*Normal[1] + Velocity_i[1]*Normal[0])*dSigmaxy_phi2 ); val_Jacobian_ii[0][3] = (sq_vel_i - Pressure_i/(Density_i*Gamma_Minus_One)) * dSigma5_psi5; - + val_Jacobian_ii[1][0] = 0; val_Jacobian_ii[1][1] = Normal[0]*dSigmaxx_phi1 + Normal[1]*dSigmaxy_phi1; val_Jacobian_ii[1][2] = Normal[0]*dSigmaxx_phi2 + Normal[1]*dSigmaxy_phi2; val_Jacobian_ii[1][3] = -Velocity_i[0]*dSigma5_psi5; - + val_Jacobian_ii[2][0] = 0; val_Jacobian_ii[2][1] = Normal[0]*dSigmaxy_phi1 + Normal[1]*dSigmayy_phi1; val_Jacobian_ii[2][2] = Normal[0]*dSigmaxy_phi2 + Normal[1]*dSigmayy_phi2; val_Jacobian_ii[2][3] = -Velocity_i[1]*dSigma5_psi5; - + val_Jacobian_ii[3][0] = 0; val_Jacobian_ii[3][1] = 0; val_Jacobian_ii[3][2] = 0; val_Jacobian_ii[3][3] = dSigma5_psi5; - + for (iVar = 0; iVar < nVar; iVar++) for (jVar = 0; jVar < nVar; jVar++) val_Jacobian_ij[iVar][jVar] = -val_Jacobian_ii[iVar][jVar]; } - + /*--- Residual at jPoint ---*/ Sigma_xx = ViscDens_j * (FOUR3 * Mean_GradPhi[0][0] - TWO3 * Mean_GradPhi[1][1]); Sigma_yy = ViscDens_j * (-TWO3 * Mean_GradPhi[0][0] + FOUR3 * Mean_GradPhi[1][1]); @@ -1689,14 +1689,14 @@ void CNumerics::GetAdjViscousFlux_Jac(su2double Pressure_i, su2double Pressure_j Sigma_xy5 = ViscDens_j * (Velocity_j[0] * Mean_GradPsiE[1] + Velocity_j[1] * Mean_GradPsiE[0]); Sigma_5 = XiDens_j * dPhiE_dn; eta_xx = Sigma_xx + Sigma_xx5; eta_yy = Sigma_yy + Sigma_yy5; eta_xy = Sigma_xy + Sigma_xy5; - + val_residual_j[0] = - (Velocity_j[0] * Normal[0] * eta_xx + Velocity_j[1] * Normal[1] * eta_yy + (Velocity_j[0] * Normal[1] + Velocity_j[1] * Normal[0]) * eta_xy - (sq_vel_j - Pressure_j/(Density_j*Gamma_Minus_One)) * Sigma_5); val_residual_j[1] = (eta_xx * Normal[0] + eta_xy * Normal[1] - Velocity_j[0] * Sigma_5); val_residual_j[2] = (eta_xy * Normal[0] + eta_yy * Normal[1] - Velocity_j[1] * Sigma_5); val_residual_j[3] = (Sigma_5); - + /*--- Computation of the Jacobians at Point j---*/ if (implicit) { dSigmaxx_phi1 = FOUR3 * ViscDens_j * Edge_Vector[0]/dist_ij_2; @@ -1705,40 +1705,40 @@ void CNumerics::GetAdjViscousFlux_Jac(su2double Pressure_i, su2double Pressure_j dSigmayy_phi2 = FOUR3 * ViscDens_j * Edge_Vector[1]/dist_ij_2; dSigmaxy_phi1 = ViscDens_j * Edge_Vector[1]/dist_ij_2; dSigmaxy_phi2 = ViscDens_j * Edge_Vector[0]/dist_ij_2; - + // dSigmaxx5_psi5 = ViscDens_j * ( FOUR3*Velocity_j[0]*Edge_Vector[0] - TWO3*Velocity_j[1]*Edge_Vector[1] )/dist_ij_2; // dSigmayy5_psi5 = ViscDens_j * (- TWO3*Velocity_j[0]*Edge_Vector[0] + FOUR3*Velocity_j[1]*Edge_Vector[1] )/dist_ij_2; // dSigmaxy5_psi5 = ViscDens_j * ( Velocity_j[0]*Edge_Vector[1] + Velocity_j[1]*Edge_Vector[0] )/dist_ij_2; dSigma5_psi5 = XiDens_j * ( Edge_Vector[0]*Normal[0] + Edge_Vector[1]*Normal[1] )/dist_ij_2; - + val_Jacobian_jj[0][0] = 0; val_Jacobian_jj[0][1] = -( Velocity_j[0]*Normal[0]*dSigmaxx_phi1 + Velocity_j[1]*Normal[1]*dSigmayy_phi1 + (Velocity_j[0]*Normal[1] + Velocity_j[1]*Normal[0])*dSigmaxy_phi1 ); val_Jacobian_jj[0][2] = -( Velocity_j[0]*Normal[0]*dSigmaxx_phi2 + Velocity_j[1]*Normal[1]*dSigmayy_phi2 + (Velocity_j[0]*Normal[1] + Velocity_j[1]*Normal[0])*dSigmaxy_phi2 ); val_Jacobian_jj[0][3] = (sq_vel_j - Pressure_j/(Density_j*Gamma_Minus_One)) * dSigma5_psi5; - + val_Jacobian_jj[1][0] = 0; val_Jacobian_jj[1][1] = Normal[0]*dSigmaxx_phi1 + Normal[1]*dSigmaxy_phi1; val_Jacobian_jj[1][2] = Normal[0]*dSigmaxx_phi2 + Normal[1]*dSigmaxy_phi2; val_Jacobian_jj[1][3] = -Velocity_j[0]*dSigma5_psi5; - + val_Jacobian_jj[2][0] = 0; val_Jacobian_jj[2][1] = Normal[0]*dSigmaxy_phi1 + Normal[1]*dSigmayy_phi1; val_Jacobian_jj[2][2] = Normal[0]*dSigmaxy_phi2 + Normal[1]*dSigmayy_phi2; val_Jacobian_jj[2][3] = -Velocity_j[1]*dSigma5_psi5; - + val_Jacobian_jj[3][0] = 0; val_Jacobian_jj[3][1] = 0; val_Jacobian_jj[3][2] = 0; val_Jacobian_jj[3][3] = dSigma5_psi5; - + for (iVar = 0; iVar < nVar; iVar++) for (jVar = 0; jVar < nVar; jVar++) val_Jacobian_ji[iVar][jVar] = -val_Jacobian_jj[iVar][jVar]; } } - + } void CNumerics::GetPrimitive2Conservative (su2double *val_Mean_PrimVar, su2double *val_Mean_SecVar, su2double **val_Jac_PC) { @@ -1834,24 +1834,24 @@ void CNumerics::GetPrimitive2Conservative (su2double *val_Mean_PrimVar, su2doubl void CNumerics::CreateBasis(su2double *val_Normal) { unsigned short iDim; su2double modm, modl; - + /*--- Define l as a vector in the plane normal to the supplied vector ---*/ l[0] = 0.0; l[1] = -val_Normal[2]; l[2] = val_Normal[1]; - + /*--- Check for the zero vector and re-assign if needed ---*/ if (l[0] == 0.0 && l[1] == 0.0 && l[2] == 0.0) { l[0] = -val_Normal[2]; l[1] = 0.0; l[2] = val_Normal[0]; } - + /*--- Take vector product of n * l to make m ---*/ m[0] = val_Normal[1]*l[2] - val_Normal[2]*l[1]; m[1] = val_Normal[2]*l[0] - val_Normal[0]*l[2]; m[2] = val_Normal[0]*l[1] - val_Normal[1]*l[0]; - + /*--- Normalize ---*/ modm =0 ; modl = 0; for (iDim =0 ; iDim < nDim; iDim++) { @@ -1887,30 +1887,30 @@ void CNumerics::SetRoe_Dissipation(const su2double Dissipation_i, /*--- A minimum level of upwinding is used to enhance stability ---*/ const su2double Min_Dissipation = 0.05; - + const su2double Mean_Dissipation = 0.5*(Dissipation_i + Dissipation_j); const su2double Mean_Sensor = 0.5*(Sensor_i + Sensor_j); - + if (roe_low_diss == FD || roe_low_diss == FD_DUCROS){ Dissipation_ij = max(0.05,1.0 - (0.5 * (Dissipation_i + Dissipation_j))); - + if (roe_low_diss == FD_DUCROS){ - + /*--- See Jonhsen et al. JCP 229 (2010) pag. 1234 ---*/ su2double Ducros_ij; - + if (0.5*(Sensor_i + Sensor_j) > 0.65) Ducros_ij = 1.0; else Ducros_ij = 0.05; - + Dissipation_ij = max(Ducros_ij, Dissipation_ij); } } else if (roe_low_diss == NTS) { - + Dissipation_ij = max(Min_Dissipation, Mean_Dissipation); } else if (roe_low_diss == NTS_DUCROS) { @@ -2163,7 +2163,7 @@ void CNumerics::tql2(su2double **V, su2double *d, su2double *e, unsigned short n * LC: QA193.M37 */ - + int i,j,k,l; for (i = 1; i < n; i++) { e[i-1] = e[i]; @@ -2276,6 +2276,3 @@ void CNumerics::tql2(su2double **V, su2double *d, su2double *e, unsigned short n } } -CSourceNothing::CSourceNothing(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { } - -CSourceNothing::~CSourceNothing(void) { } diff --git a/SU2_CFD/src/numerics/continuous_adjoint/CAvgGradCorrected_AdjFlow.cpp b/SU2_CFD/src/numerics/continuous_adjoint/CAvgGradCorrected_AdjFlow.cpp new file mode 100644 index 000000000000..a01251b4bd0e --- /dev/null +++ b/SU2_CFD/src/numerics/continuous_adjoint/CAvgGradCorrected_AdjFlow.cpp @@ -0,0 +1,173 @@ +/*! + * \file CAvgGradCorrected_AdjFlow.cpp + * \brief Implementation of numerics class CAvgGradCorrected_AdjFlow. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../include/numerics/continuous_adjoint/CAvgGradCorrected_AdjFlow.hpp" + +CAvgGradCorrected_AdjFlow::CAvgGradCorrected_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + implicit = (config->GetKind_TimeIntScheme_AdjFlow() == EULER_IMPLICIT); + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + + Velocity_i = new su2double [nDim]; + Velocity_j = new su2double [nDim]; + Mean_Velocity = new su2double [nDim]; + + Mean_GradPsiVar = new su2double* [nVar]; + for (unsigned short iVar = 0; iVar < nVar; iVar++) + Mean_GradPsiVar[iVar] = new su2double [nDim]; + + Edge_Vector = new su2double [nDim]; + Proj_Mean_GradPsiVar_Edge = new su2double [nVar]; + + Mean_GradPhi = new su2double* [nDim]; + for (unsigned short iDim = 0; iDim < nDim; iDim++) + Mean_GradPhi[iDim] = new su2double [nDim]; + Mean_GradPsiE = new su2double [nDim]; + +} + +CAvgGradCorrected_AdjFlow::~CAvgGradCorrected_AdjFlow(void) { + + delete [] Velocity_i; + delete [] Velocity_j; + delete [] Mean_Velocity; + delete [] Edge_Vector; + delete [] Proj_Mean_GradPsiVar_Edge; + + for (unsigned short iVar = 0; iVar < nVar; iVar++) + delete [] Mean_GradPsiVar[iVar]; + delete [] Mean_GradPsiVar; + + for (unsigned short iDim = 0; iDim < nDim; iDim++) + delete [] Mean_GradPhi[iDim]; + delete [] Mean_GradPhi; + delete [] Mean_GradPsiE; + +} + +void CAvgGradCorrected_AdjFlow::ComputeResidual(su2double *val_residual_i, + su2double *val_residual_j, + su2double **val_Jacobian_ii, + su2double **val_Jacobian_ij, + su2double **val_Jacobian_ji, + su2double **val_Jacobian_jj, + CConfig *config) { + + unsigned short iVar, iDim, jDim; + su2double Density_i, sq_vel_i, Pressure_i, ViscDens_i, XiDens_i; + su2double Density_j, sq_vel_j, Pressure_j, ViscDens_j, XiDens_j; + su2double dist_ij_2, dPhiE_dn; + + su2double Prandtl_Lam = config->GetPrandtl_Lam(); + su2double Prandtl_Turb = config->GetPrandtl_Turb(); + + /*--- States in point i ---*/ + + sq_vel_i = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + Velocity_i[iDim] = V_i[iDim+1]; + sq_vel_i += 0.5*Velocity_i[iDim]*Velocity_i[iDim]; + } + Pressure_i = V_i[nDim+1]; + Density_i = V_i[nDim+2]; + Enthalpy_i = V_i[nDim+3]; + + /*--- Laminar and Eddy viscosity ---*/ + + Laminar_Viscosity_i = V_i[nDim+5]; + Eddy_Viscosity_i = V_i[nDim+6]; + + ViscDens_i = (Laminar_Viscosity_i + Eddy_Viscosity_i) / Density_i; + XiDens_i = Gamma*(Laminar_Viscosity_i/Prandtl_Lam + + Eddy_Viscosity_i/Prandtl_Turb) / Density_i; + + /*--- States in point j ---*/ + + sq_vel_j = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + Velocity_j[iDim] = V_j[iDim+1]; + sq_vel_j += 0.5*Velocity_j[iDim]*Velocity_j[iDim]; + } + Pressure_j = V_j[nDim+1]; + Density_j = V_j[nDim+2]; + Enthalpy_j = V_j[nDim+3]; + + /*--- Laminar and Eddy viscosity ---*/ + + Laminar_Viscosity_j = V_j[nDim+5]; + Eddy_Viscosity_j = V_j[nDim+6]; + + ViscDens_j = (Laminar_Viscosity_j + Eddy_Viscosity_j) / Density_j; + XiDens_j = Gamma*(Laminar_Viscosity_j/Prandtl_Lam + + Eddy_Viscosity_j/Prandtl_Turb) / Density_j; + + /*--- Compute vector going from iPoint to jPoint ---*/ + + dist_ij_2 = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + Mean_Velocity[iDim] = 0.5*(Velocity_i[iDim]+Velocity_j[iDim]); + Edge_Vector[iDim] = Coord_j[iDim]-Coord_i[iDim]; + dist_ij_2 += Edge_Vector[iDim]*Edge_Vector[iDim]; + } + + /*--- Mean gradient approximation. Projection of the mean gradient in the direction of the edge, weiss correction ---*/ + + for (iVar = 0; iVar < nVar; iVar++) { + Proj_Mean_GradPsiVar_Edge[iVar] = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + Mean_GradPsiVar[iVar][iDim] = 0.5*(PsiVar_Grad_i[iVar][iDim] + PsiVar_Grad_j[iVar][iDim]); + Proj_Mean_GradPsiVar_Edge[iVar] += Mean_GradPsiVar[iVar][iDim]*Edge_Vector[iDim]; + } + for (iDim = 0; iDim < nDim; iDim++) + Mean_GradPsiVar[iVar][iDim] -= (Proj_Mean_GradPsiVar_Edge[iVar] - + (Psi_j[iVar]-Psi_i[iVar]))*Edge_Vector[iDim]/dist_ij_2; + } + + /*--- Average of the derivatives of the adjoint variables ---*/ + + for (iDim = 0; iDim < nDim; iDim++) { + Mean_GradPsiE[iDim] = Mean_GradPsiVar[nVar-1][iDim]; + for (jDim = 0; jDim < nDim; jDim++) + Mean_GradPhi[iDim][jDim] = Mean_GradPsiVar[iDim+1][jDim]; + } + + dPhiE_dn = 0; + for (iDim = 0; iDim < nDim; iDim++) + dPhiE_dn += Mean_GradPsiE[iDim]*Normal[iDim]; + + /*--- Compute the viscous residual and jacobian ---*/ + + GetAdjViscousFlux_Jac(Pressure_i, Pressure_j, Density_i, Density_j, + ViscDens_i, ViscDens_j, Velocity_i, Velocity_j, sq_vel_i, sq_vel_j, + XiDens_i, XiDens_j, Mean_GradPhi, Mean_GradPsiE, + dPhiE_dn, Normal, Edge_Vector, dist_ij_2, val_residual_i, val_residual_j, + val_Jacobian_ii, val_Jacobian_ij, val_Jacobian_ji, val_Jacobian_jj, + implicit); + +} diff --git a/SU2_CFD/src/numerics/continuous_adjoint/CAvgGradCorrected_AdjTurb.cpp b/SU2_CFD/src/numerics/continuous_adjoint/CAvgGradCorrected_AdjTurb.cpp new file mode 100644 index 000000000000..d96dab0702b7 --- /dev/null +++ b/SU2_CFD/src/numerics/continuous_adjoint/CAvgGradCorrected_AdjTurb.cpp @@ -0,0 +1,158 @@ +/*! + * \file CAvgGradCorrected_AdjTurb.cpp + * \brief Implementation of numerics class CAvgGradCorrected_AdjTurb. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../include/numerics/continuous_adjoint/CAvgGradCorrected_AdjTurb.hpp" + +CAvgGradCorrected_AdjTurb::CAvgGradCorrected_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + Edge_Vector = new su2double [nDim]; + Mean_GradTurbPsi = new su2double* [nVar]; + Proj_Mean_GradTurbPsi_Kappa = new su2double [nVar]; + Proj_Mean_GradTurbPsi_Edge = new su2double [nVar]; + Proj_Mean_GradTurbPsi_Corrected = new su2double [nVar]; + for (unsigned short iVar = 0; iVar < nVar; iVar++) + Mean_GradTurbPsi[iVar] = new su2double [nDim]; +} + +CAvgGradCorrected_AdjTurb::~CAvgGradCorrected_AdjTurb(void) { + delete [] Edge_Vector; + delete [] Proj_Mean_GradTurbPsi_Kappa; + delete [] Proj_Mean_GradTurbPsi_Edge; + delete [] Proj_Mean_GradTurbPsi_Corrected; + for (unsigned short iVar = 0; iVar < nVar; iVar++) { + delete [] Mean_GradTurbPsi[iVar]; + } + delete [] Mean_GradTurbPsi; +} + +void CAvgGradCorrected_AdjTurb::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, + su2double **val_Jacobian_j, CConfig *config) { + + bool implicit = (config->GetKind_TimeIntScheme_AdjTurb() == EULER_IMPLICIT); + + su2double sigma = 2./3.; + su2double nu_i, nu_j, nu_e; + su2double dist_ij_2 = 0; + su2double proj_vector_ij = 0; + unsigned short iVar, iDim; + + /*--- Compute mean effective viscosity ---*/ + nu_i = Laminar_Viscosity_i/U_i[0]; + nu_j = Laminar_Viscosity_j/U_j[0]; + nu_e = 0.5*(nu_i+nu_j+TurbVar_i[0]+TurbVar_j[0])/sigma; + + /*--- Compute vector going from iPoint to jPoint ---*/ + 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]; + } + proj_vector_ij = proj_vector_ij/dist_ij_2; + + /*--- Mean gradient approximation ---*/ + for (iVar = 0; iVar < nVar; iVar++) { + Proj_Mean_GradTurbPsi_Edge[iVar] = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + Mean_GradTurbPsi[iVar][iDim] = 0.5*(TurbPsi_Grad_i[iVar][iDim] + TurbPsi_Grad_j[iVar][iDim]); + Proj_Mean_GradTurbPsi_Edge[iVar] += Mean_GradTurbPsi[iVar][iDim]*Edge_Vector[iDim]; + } + + for (iDim = 0; iDim < nDim; iDim++) + Mean_GradTurbPsi[iVar][iDim] -= (Proj_Mean_GradTurbPsi_Edge[iVar] - (TurbPsi_j[iVar]-TurbPsi_i[iVar]))*Edge_Vector[iDim]/dist_ij_2; + + /*--- Projection of the corrected gradient ---*/ + Proj_Mean_GradTurbPsi_Corrected[iVar] = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + Proj_Mean_GradTurbPsi_Corrected[iVar] += Mean_GradTurbPsi[iVar][iDim]*Normal[iDim]; + } + + val_residual[0] = -nu_e*Proj_Mean_GradTurbPsi_Corrected[0]; + + if (implicit) { + val_Jacobian_i[0][0] = nu_e*proj_vector_ij; + val_Jacobian_j[0][0] = -nu_e*proj_vector_ij; + } + +} + +void CAvgGradCorrected_AdjTurb::ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, + su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, + su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config) { + + bool implicit = (config->GetKind_TimeIntScheme_AdjTurb() == EULER_IMPLICIT); + + su2double sigma = 2./3.; + su2double nu_i, nu_j, nu_e_i, nu_e_j; + su2double dist_ij_2 = 0; + su2double proj_vector_ij = 0; + unsigned short iVar, iDim; + + /*--- Compute mean effective viscosity ---*/ + nu_i = Laminar_Viscosity_i/U_i[0]; + nu_j = Laminar_Viscosity_j/U_j[0]; + nu_e_i = (nu_i+TurbVar_i[0])/sigma; + nu_e_j = (nu_j+TurbVar_j[0])/sigma; + + /*--- Compute vector going from iPoint to jPoint ---*/ + 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]; + } + proj_vector_ij = proj_vector_ij/dist_ij_2; // to normalize vectors + + /*--- Mean gradient approximation ---*/ + for (iVar = 0; iVar < nVar; iVar++) { + Proj_Mean_GradTurbPsi_Edge[iVar] = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + Mean_GradTurbPsi[iVar][iDim] = 0.5*(TurbPsi_Grad_i[iVar][iDim] + TurbPsi_Grad_j[iVar][iDim]); + Proj_Mean_GradTurbPsi_Edge[iVar] += Mean_GradTurbPsi[iVar][iDim]*Edge_Vector[iDim]; + } + + for (iDim = 0; iDim < nDim; iDim++) + Mean_GradTurbPsi[iVar][iDim] -= (Proj_Mean_GradTurbPsi_Edge[iVar] - + (TurbPsi_j[iVar]-TurbPsi_i[iVar]))*Edge_Vector[iDim]/dist_ij_2; + + /*--- Projection of the corrected gradient ---*/ + Proj_Mean_GradTurbPsi_Corrected[iVar] = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + Proj_Mean_GradTurbPsi_Corrected[iVar] += Mean_GradTurbPsi[iVar][iDim]*Normal[iDim]; + } + + val_residual_i[0] = -nu_e_i*Proj_Mean_GradTurbPsi_Corrected[0]; + val_residual_j[0] = nu_e_j*Proj_Mean_GradTurbPsi_Corrected[0]; + + if (implicit) { + val_Jacobian_ii[0][0] = nu_e_i*proj_vector_ij; + val_Jacobian_ij[0][0] = -nu_e_i*proj_vector_ij; + val_Jacobian_ji[0][0] = -nu_e_j*proj_vector_ij; + val_Jacobian_jj[0][0] = nu_e_j*proj_vector_ij; + } + +} diff --git a/SU2_CFD/src/numerics/continuous_adjoint/CAvgGrad_AdjFlow.cpp b/SU2_CFD/src/numerics/continuous_adjoint/CAvgGrad_AdjFlow.cpp new file mode 100644 index 000000000000..573fb535ef8e --- /dev/null +++ b/SU2_CFD/src/numerics/continuous_adjoint/CAvgGrad_AdjFlow.cpp @@ -0,0 +1,139 @@ +/*! + * \file CAvgGrad_AdjFlow.cpp + * \brief Implementation of numerics class CAvgGrad_AdjFlow. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../include/numerics/continuous_adjoint/CAvgGrad_AdjFlow.hpp" + +CAvgGrad_AdjFlow::CAvgGrad_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + unsigned short iDim; + + implicit = (config->GetKind_TimeIntScheme_AdjFlow() == EULER_IMPLICIT); + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + + Velocity_i = new su2double [nDim]; + Velocity_j = new su2double [nDim]; + Mean_Velocity = new su2double [nDim]; + Mean_GradPhi = new su2double* [nDim]; + for (iDim = 0; iDim < nDim; iDim++) + Mean_GradPhi[iDim] = new su2double [nDim]; + Mean_GradPsiE = new su2double [nDim]; + Edge_Vector = new su2double [nDim]; + +} + +CAvgGrad_AdjFlow::~CAvgGrad_AdjFlow(void) { + delete [] Velocity_i; + delete [] Velocity_j; + delete [] Mean_Velocity; + delete [] Edge_Vector; + delete [] Mean_GradPsiE; + for (unsigned short iDim = 0; iDim < nDim; iDim++) + delete [] Mean_GradPhi[iDim]; +} + +void CAvgGrad_AdjFlow::ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, + su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, + su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config) { + unsigned short iDim, jDim; + su2double sq_vel_i, ViscDens_i, XiDens_i; + su2double sq_vel_j, ViscDens_j, XiDens_j; + su2double dist_ij_2, dPhiE_dn; + + su2double Prandtl_Lam = config->GetPrandtl_Lam(); + su2double Prandtl_Turb = config->GetPrandtl_Turb(); + + /*--- States in point i ---*/ + + sq_vel_i = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + Velocity_i[iDim] = V_i[iDim+1]; + sq_vel_i += 0.5*Velocity_i[iDim]*Velocity_i[iDim]; + } + Pressure_i = V_i[nDim+1]; + Density_i = V_i[nDim+2]; + Enthalpy_i = V_i[nDim+3]; + SoundSpeed_i = sqrt(fabs(Pressure_i*Gamma/Density_i)); + + /*--- Laminar and Eddy viscosity ---*/ + + Laminar_Viscosity_i = V_i[nDim+5]; + Eddy_Viscosity_i = V_i[nDim+6]; + + ViscDens_i = (Laminar_Viscosity_i + Eddy_Viscosity_i) / Density_i; + XiDens_i = Gamma*(Laminar_Viscosity_i/Prandtl_Lam + Eddy_Viscosity_i/Prandtl_Turb) / Density_i; + + /*--- States in point j ---*/ + + sq_vel_j = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + Velocity_j[iDim] = V_j[iDim+1]; + sq_vel_j += 0.5*Velocity_j[iDim]*Velocity_j[iDim]; + } + Pressure_j = V_j[nDim+1]; + Density_j = V_j[nDim+2]; + Enthalpy_j = V_j[nDim+3]; + SoundSpeed_j = sqrt(fabs(Pressure_j*Gamma/Density_j)); + + /*--- Laminar and Eddy viscosity ---*/ + + Laminar_Viscosity_j = V_j[nDim+5]; + Eddy_Viscosity_j = V_j[nDim+6]; + + ViscDens_j = (Laminar_Viscosity_j + Eddy_Viscosity_j) / Density_j; + XiDens_j = Gamma*(Laminar_Viscosity_j/Prandtl_Lam + Eddy_Viscosity_j/Prandtl_Turb) / Density_j; + + /*--- Compute vector going from iPoint to jPoint ---*/ + + dist_ij_2 = 0.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]; + } + + /*--- Average of the derivatives of the adjoint variables ---*/ + + for (iDim = 0; iDim < nDim; iDim++) { + Mean_GradPsiE[iDim] = 0.5*(PsiVar_Grad_i[nVar-1][iDim]+PsiVar_Grad_j[nVar-1][iDim]); + for (jDim = 0; jDim < nDim; jDim++) + Mean_GradPhi[iDim][jDim] = 0.5*(PsiVar_Grad_i[iDim+1][jDim]+PsiVar_Grad_j[iDim+1][jDim]); + } + + dPhiE_dn = 0; + for (iDim = 0; iDim < nDim; iDim++) + dPhiE_dn += Mean_GradPsiE[iDim]*Normal[iDim]; + + /*--- Compute the viscous residual and jacobian ---*/ + + GetAdjViscousFlux_Jac(Pressure_i, Pressure_j, Density_i, Density_j, + ViscDens_i, ViscDens_j, Velocity_i, Velocity_j, sq_vel_i, sq_vel_j, + XiDens_i, XiDens_j, Mean_GradPhi, Mean_GradPsiE, + dPhiE_dn, Normal, Edge_Vector, dist_ij_2, val_residual_i, val_residual_j, + val_Jacobian_ii, val_Jacobian_ij, val_Jacobian_ji, val_Jacobian_jj, + implicit); + +} diff --git a/SU2_CFD/src/numerics/continuous_adjoint/CAvgGrad_AdjTurb.cpp b/SU2_CFD/src/numerics/continuous_adjoint/CAvgGrad_AdjTurb.cpp new file mode 100644 index 000000000000..61819d5d88b4 --- /dev/null +++ b/SU2_CFD/src/numerics/continuous_adjoint/CAvgGrad_AdjTurb.cpp @@ -0,0 +1,149 @@ +/*! + * \file CAvgGrad_AdjTurb.cpp + * \brief Implementation of numerics class CAvgGrad_AdjTurb. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../include/numerics/continuous_adjoint/CAvgGrad_AdjTurb.hpp" + +CAvgGrad_AdjTurb::CAvgGrad_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + Edge_Vector = new su2double [nDim]; + Mean_GradTurbPsi = new su2double* [nVar]; + Proj_Mean_GradTurbPsi_Kappa = new su2double [nVar]; + Proj_Mean_GradTurbPsi_Edge = new su2double [nVar]; + Proj_Mean_GradTurbPsi_Corrected = new su2double [nVar]; + for (unsigned short iVar = 0; iVar < nVar; iVar++) + Mean_GradTurbPsi[iVar] = new su2double [nDim]; +} + +CAvgGrad_AdjTurb::~CAvgGrad_AdjTurb(void) { + delete [] Edge_Vector; + delete [] Proj_Mean_GradTurbPsi_Kappa; + delete [] Proj_Mean_GradTurbPsi_Edge; + delete [] Proj_Mean_GradTurbPsi_Corrected; + for (unsigned short iVar = 0; iVar < nVar; iVar++) { + delete [] Mean_GradTurbPsi[iVar]; + } + delete [] Mean_GradTurbPsi; +} + +void CAvgGrad_AdjTurb::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, + su2double **val_Jacobian_j, CConfig *config) { + + bool implicit = (config->GetKind_TimeIntScheme_AdjTurb() == EULER_IMPLICIT); + + su2double sigma = 2./3.; + su2double nu_i, nu_j, nu_e; + su2double dist_ij_2 = 0; + su2double proj_vector_ij = 0; + unsigned short iVar, iDim; + + /*--- Compute mean effective viscosity ---*/ + nu_i = Laminar_Viscosity_i/U_i[0]; + nu_j = Laminar_Viscosity_j/U_j[0]; + nu_e = 0.5*(nu_i+nu_j+TurbVar_i[0]+TurbVar_j[0])/sigma; + + /*--- Compute vector going from iPoint to jPoint ---*/ + 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]; + } + proj_vector_ij = proj_vector_ij/dist_ij_2; + + /*--- Mean gradient approximation ---*/ + for (iVar = 0; iVar < nVar; iVar++) { + Proj_Mean_GradTurbPsi_Edge[iVar] = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + Mean_GradTurbPsi[iVar][iDim] = 0.5*(TurbPsi_Grad_i[iVar][iDim] + TurbPsi_Grad_j[iVar][iDim]); + } + + /*--- Projection of the corrected gradient ---*/ + Proj_Mean_GradTurbPsi_Corrected[iVar] = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + Proj_Mean_GradTurbPsi_Corrected[iVar] += Mean_GradTurbPsi[iVar][iDim]*Normal[iDim]; + } + + val_residual[0] = -nu_e*Proj_Mean_GradTurbPsi_Corrected[0]; + + if (implicit) { + val_Jacobian_i[0][0] = nu_e*proj_vector_ij; + val_Jacobian_j[0][0] = -nu_e*proj_vector_ij; + } + +} + +void CAvgGrad_AdjTurb::ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, + su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, + su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config) { + + bool implicit = (config->GetKind_TimeIntScheme_AdjTurb() == EULER_IMPLICIT); + + su2double sigma = 2./3.; + su2double nu_i, nu_j, nu_e_i, nu_e_j; + su2double dist_ij_2 = 0; + su2double proj_vector_ij = 0; + unsigned short iVar, iDim; + + /*--- Compute mean effective viscosity ---*/ + nu_i = Laminar_Viscosity_i/U_i[0]; + nu_j = Laminar_Viscosity_j/U_j[0]; + nu_e_i = (nu_i+TurbVar_i[0])/sigma; + nu_e_j = (nu_j+TurbVar_j[0])/sigma; + + /*--- Compute vector going from iPoint to jPoint ---*/ + 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]; + } + proj_vector_ij = proj_vector_ij/dist_ij_2; // to normalize vectors + + /*--- Mean gradient approximation ---*/ + for (iVar = 0; iVar < nVar; iVar++) { + Proj_Mean_GradTurbPsi_Edge[iVar] = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + Mean_GradTurbPsi[iVar][iDim] = 0.5*(TurbPsi_Grad_i[iVar][iDim] + TurbPsi_Grad_j[iVar][iDim]); + } + + /*--- Projection of the corrected gradient ---*/ + Proj_Mean_GradTurbPsi_Corrected[iVar] = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + Proj_Mean_GradTurbPsi_Corrected[iVar] += Mean_GradTurbPsi[iVar][iDim]*Normal[iDim]; + } + + val_residual_i[0] = -nu_e_i*Proj_Mean_GradTurbPsi_Corrected[0]; + val_residual_j[0] = nu_e_j*Proj_Mean_GradTurbPsi_Corrected[0]; + + if (implicit) { + val_Jacobian_ii[0][0] = nu_e_i*proj_vector_ij; + val_Jacobian_ij[0][0] = -nu_e_i*proj_vector_ij; + val_Jacobian_ji[0][0] = -nu_e_j*proj_vector_ij; + val_Jacobian_jj[0][0] = nu_e_j*proj_vector_ij; + } + +} diff --git a/SU2_CFD/src/numerics/continuous_adjoint/CCentJST_AdjFlow.cpp b/SU2_CFD/src/numerics/continuous_adjoint/CCentJST_AdjFlow.cpp new file mode 100644 index 000000000000..f4c778e8c0b2 --- /dev/null +++ b/SU2_CFD/src/numerics/continuous_adjoint/CCentJST_AdjFlow.cpp @@ -0,0 +1,248 @@ +/*! + * \file CCentJST_AdjFlow.cpp + * \brief Implementation of numerics class CCentJST_AdjFlow. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../include/numerics/continuous_adjoint/CCentJST_AdjFlow.hpp" + +CCentJST_AdjFlow::CCentJST_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + + grid_movement = config->GetGrid_Movement(); + + Diff_Psi = new su2double [nVar]; Diff_Lapl = new su2double [nVar]; + Velocity_i = new su2double [nDim]; Velocity_j = new su2double [nDim]; + MeanPhi = new su2double [nDim]; + + Param_p = 0.3; + Param_Kappa_2 = config->GetKappa_2nd_AdjFlow(); + Param_Kappa_4 = config->GetKappa_4th_AdjFlow(); + implicit = (config->GetKind_TimeIntScheme_AdjFlow() == EULER_IMPLICIT); + +} + +CCentJST_AdjFlow::~CCentJST_AdjFlow(void) { + + delete [] Diff_Psi; delete [] Diff_Lapl; + delete [] Velocity_i; delete [] Velocity_j; + delete [] MeanPhi; +} + +void CCentJST_AdjFlow::ComputeResidual (su2double *val_resconv_i, su2double *val_resvisc_i, su2double *val_resconv_j, su2double *val_resvisc_j, + su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, + CConfig *config) { + + /*--- Mean Values ---*/ + + MeanPsiRho = 0.5*(Psi_i[0]+Psi_j[0]); + for (iDim = 0; iDim < nDim; iDim++) + MeanPhi[iDim] = 0.5*(Psi_i[iDim+1]+Psi_j[iDim+1]); + MeanPsiE = 0.5*(Psi_i[nVar-1]+Psi_j[nVar-1]); + + /*--- Point i convective residual evaluation ---*/ + + ProjVelocity_i = 0; ProjPhi = 0; ProjPhi_Vel = 0; sq_vel = 0; Area = 0; + for (iDim = 0; iDim < nDim; iDim++) { + Velocity_i[iDim] = U_i[iDim+1] / U_i[0]; + ProjVelocity_i += Velocity_i[iDim]*Normal[iDim]; + ProjPhi += MeanPhi[iDim]*Normal[iDim]; + ProjPhi_Vel += MeanPhi[iDim]*Velocity_i[iDim]; + sq_vel += 0.5*Velocity_i[iDim]*Velocity_i[iDim]; + Area += Normal[iDim]*Normal[iDim]; + } + Area = sqrt(Area); + phis1 = ProjPhi + ProjVelocity_i*MeanPsiE; + phis2 = MeanPsiRho + ProjPhi_Vel + Enthalpy_i*MeanPsiE; + + val_resconv_i[0] = ProjVelocity_i*MeanPsiRho - phis2*ProjVelocity_i + Gamma_Minus_One*phis1*sq_vel; + for (iDim = 0; iDim < nDim; iDim++) + val_resconv_i[iDim+1] = ProjVelocity_i*MeanPhi[iDim] + phis2*Normal[iDim] - Gamma_Minus_One*phis1*Velocity_i[iDim]; + val_resconv_i[nVar-1] = ProjVelocity_i*MeanPsiE + Gamma_Minus_One*phis1; + + /*--- Flux contributions due to grid movement at point i ---*/ + + if (grid_movement) { + su2double ProjGridVel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; + val_resconv_i[0] -= ProjGridVel*MeanPsiRho; + for (iDim = 0; iDim < nDim; iDim++) + val_resconv_i[iDim+1] -= ProjGridVel*MeanPhi[iDim]; + val_resconv_i[nVar-1] -= ProjGridVel*MeanPsiE; + } + + /*--- Jacobians of the inviscid flux ---*/ + + if (implicit) { + val_Jacobian_ii[0][0] = 0.0; + for (jDim = 0; jDim < nDim; jDim++) + val_Jacobian_ii[0][jDim+1] = -0.5*ProjVelocity_i*Velocity_i[jDim] + Gamma_Minus_One*sq_vel*0.5*Normal[jDim]; + val_Jacobian_ii[0][nVar-1] = 0.5*ProjVelocity_i*(Gamma_Minus_One*sq_vel - Enthalpy_i); + for (iDim = 0; iDim < nDim; iDim++) { + val_Jacobian_ii[iDim+1][0] = 0.5*Normal[iDim]; + for (jDim = 0; jDim < nDim; jDim++) + val_Jacobian_ii[iDim+1][jDim+1] = 0.5*Normal[iDim]*Velocity_i[jDim] - 0.5*Gamma_Minus_One*Velocity_i[iDim]*Normal[jDim]; + val_Jacobian_ii[iDim+1][iDim+1] += 0.5*ProjVelocity_i; + val_Jacobian_ii[iDim+1][nVar-1] = 0.5*Enthalpy_i*Normal[iDim] - 0.5*Gamma_Minus_One*Velocity_i[iDim]*ProjVelocity_i; + } + val_Jacobian_ii[nVar-1][0] = 0; + for (jDim = 0; jDim < nDim; jDim++) + val_Jacobian_ii[nVar-1][jDim+1] = 0.5*Gamma_Minus_One*Normal[jDim]; + val_Jacobian_ii[nVar-1][nVar-1] = 0.5*Gamma*ProjVelocity_i; + + for (iVar = 0; iVar < nVar; iVar++) + for (jVar = 0; jVar < nVar; jVar++) + val_Jacobian_ij[iVar][jVar] = val_Jacobian_ii[iVar][jVar]; + + /*--- Jacobian contributions due to grid movement at point i ---*/ + + if (grid_movement) { + su2double ProjGridVel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; + for (iVar = 0; iVar < nVar; iVar++) { + val_Jacobian_ii[iVar][iVar] -= 0.5*ProjGridVel; + val_Jacobian_ij[iVar][iVar] -= 0.5*ProjGridVel; + } + } + } + + + /*--- Point j convective residual evaluation ---*/ + + ProjVelocity_j = 0; ProjPhi_Vel = 0; sq_vel = 0; + for (iDim = 0; iDim < nDim; iDim++) { + Velocity_j[iDim] = U_j[iDim+1] / U_j[0]; + ProjVelocity_j += Velocity_j[iDim]*Normal[iDim]; + ProjPhi_Vel += MeanPhi[iDim]*Velocity_j[iDim]; + sq_vel += 0.5*Velocity_j[iDim]*Velocity_j[iDim]; + } + + phis1 = ProjPhi + ProjVelocity_j*MeanPsiE; + phis2 = MeanPsiRho + ProjPhi_Vel + Enthalpy_j*MeanPsiE; + + val_resconv_j[0] = -(ProjVelocity_j*MeanPsiRho - phis2*ProjVelocity_j + Gamma_Minus_One*phis1*sq_vel); + for (iDim = 0; iDim < nDim; iDim++) + val_resconv_j[iDim+1] = -(ProjVelocity_j*MeanPhi[iDim] + phis2*Normal[iDim] - Gamma_Minus_One*phis1*Velocity_j[iDim]); + val_resconv_j[nVar-1] = -(ProjVelocity_j*MeanPsiE + Gamma_Minus_One*phis1); + + /*--- Flux contributions due to grid motion at point j ---*/ + + if (grid_movement) { + su2double ProjGridVel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; + val_resconv_j[0] += ProjGridVel*MeanPsiRho; + for (iDim = 0; iDim < nDim; iDim++) + val_resconv_j[iDim+1] += ProjGridVel*MeanPhi[iDim]; + val_resconv_j[nVar-1] += ProjGridVel*MeanPsiE; + } + + /*--- Jacobians of the inviscid flux ---*/ + + if (implicit) { + val_Jacobian_jj[0][0] = 0.0; + for (jDim = 0; jDim < nDim; jDim++) + val_Jacobian_jj[0][jDim+1] = 0.5*ProjVelocity_j*Velocity_j[jDim] - Gamma_Minus_One*sq_vel*0.5*Normal[jDim]; + val_Jacobian_jj[0][nVar-1] = -0.5*ProjVelocity_j*(Gamma_Minus_One*sq_vel - Enthalpy_j); + for (iDim = 0; iDim < nDim; iDim++) { + val_Jacobian_jj[iDim+1][0] = -0.5*Normal[iDim]; + for (jDim = 0; jDim < nDim; jDim++) + val_Jacobian_jj[iDim+1][jDim+1] = -0.5*Normal[iDim]*Velocity_j[jDim] + 0.5*Gamma_Minus_One*Velocity_j[iDim]*Normal[jDim]; + val_Jacobian_jj[iDim+1][iDim+1] -= 0.5*ProjVelocity_j; + val_Jacobian_jj[iDim+1][nVar-1] = -0.5*Enthalpy_j*Normal[iDim] + 0.5*Gamma_Minus_One*Velocity_j[iDim]*ProjVelocity_j; + } + val_Jacobian_jj[nVar-1][0] = 0; + for (jDim = 0; jDim < nDim; jDim++) + val_Jacobian_jj[nVar-1][jDim+1] = -0.5*Gamma_Minus_One*Normal[jDim]; + val_Jacobian_jj[nVar-1][nVar-1] = -0.5*Gamma*ProjVelocity_j; + + for (iVar = 0; iVar < nVar; iVar++) + for (jVar = 0; jVar < nVar; jVar++) + val_Jacobian_ji[iVar][jVar] = val_Jacobian_jj[iVar][jVar]; + + /*--- Jacobian contributions due to grid motion at point j ---*/ + + if (grid_movement) { + su2double ProjGridVel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; + for (iVar = 0; iVar < nVar; iVar++) { + val_Jacobian_jj[iVar][iVar] += 0.5*ProjGridVel; + val_Jacobian_ji[iVar][iVar] += 0.5*ProjGridVel; + } + } + } + + /*--- Computes differences btw. variables and Laplacians ---*/ + + for (iVar = 0; iVar < nVar; iVar++) { + Diff_Lapl[iVar] = Und_Lapl_i[iVar]-Und_Lapl_j[iVar]; + Diff_Psi[iVar] = Psi_i[iVar]-Psi_j[iVar]; + } + + /*--- Adjustment to projected velocity due to grid motion ---*/ + + if (grid_movement) { + su2double ProjGridVel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; + } + ProjVelocity_i -= ProjGridVel; + ProjVelocity_j += ProjGridVel; + } + + /*--- Compute the spectral radius and stretching factor ---*/ + + Local_Lambda_i = (fabs(ProjVelocity_i)+SoundSpeed_i*Area); + Local_Lambda_j = (fabs(ProjVelocity_j)+SoundSpeed_j*Area); + MeanLambda = 0.5*(Local_Lambda_i+Local_Lambda_j); + + Phi_i = pow(Lambda_i/(4.0*MeanLambda), Param_p); + Phi_j = pow(Lambda_j/(4.0*MeanLambda), Param_p); + StretchingFactor = 4.0*Phi_i*Phi_j/(Phi_i+Phi_j); + + su2double sc2 = 3.0*(su2double(Neighbor_i)+su2double(Neighbor_j))/(su2double(Neighbor_i)*su2double(Neighbor_j)); + sc4 = sc2*sc2/4.0; + Epsilon_2 = Param_Kappa_2*0.5*(Sensor_i+Sensor_j)*sc2; + Epsilon_4 = max(0.0, Param_Kappa_4-Epsilon_2)*sc4; + + /*--- Compute viscous residual 1st- & 3rd-order dissipation ---*/ + + for (iVar = 0; iVar < nVar; iVar++) { + Residual = (Epsilon_2*Diff_Psi[iVar]-Epsilon_4*Diff_Lapl[iVar])*StretchingFactor*MeanLambda; + val_resvisc_i[iVar] = -Residual; + val_resvisc_j[iVar] = Residual; + if (implicit) { + val_Jacobian_ii[iVar][iVar] -= Epsilon_2 + su2double(Neighbor_i+1)*Epsilon_4*StretchingFactor*MeanLambda; + val_Jacobian_ij[iVar][iVar] += Epsilon_2 + su2double(Neighbor_j+1)*Epsilon_4*StretchingFactor*MeanLambda; + val_Jacobian_ji[iVar][iVar] += Epsilon_2 + su2double(Neighbor_i+1)*Epsilon_4*StretchingFactor*MeanLambda; + val_Jacobian_jj[iVar][iVar] -= Epsilon_2 + su2double(Neighbor_j+1)*Epsilon_4*StretchingFactor*MeanLambda; + } + } + +} diff --git a/SU2_CFD/src/numerics/continuous_adjoint/CCentLax_AdjFlow.cpp b/SU2_CFD/src/numerics/continuous_adjoint/CCentLax_AdjFlow.cpp new file mode 100644 index 000000000000..e58e27983a6b --- /dev/null +++ b/SU2_CFD/src/numerics/continuous_adjoint/CCentLax_AdjFlow.cpp @@ -0,0 +1,235 @@ +/*! + * \file CCentLax_AdjFlow.cpp + * \brief Implementation of numerics class CCentLax_AdjFlow. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../include/numerics/continuous_adjoint/CCentLax_AdjFlow.hpp" + +CCentLax_AdjFlow::CCentLax_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + + Diff_Psi = new su2double [nVar]; MeanPhi = new su2double [nDim]; + Velocity_i = new su2double [nDim]; Velocity_j = new su2double [nDim]; + + implicit = (config->GetKind_TimeIntScheme_AdjFlow() == EULER_IMPLICIT); + + grid_movement = config->GetGrid_Movement(); + + Param_p = 0.3; + Param_Kappa_0 = config->GetKappa_1st_AdjFlow(); + +} + +CCentLax_AdjFlow::~CCentLax_AdjFlow(void) { + + delete [] Diff_Psi; delete [] MeanPhi; + delete [] Velocity_i; delete [] Velocity_j; + +} + +void CCentLax_AdjFlow::ComputeResidual (su2double *val_resconv_i, su2double *val_resvisc_i, su2double *val_resconv_j, su2double *val_resvisc_j, + su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, + CConfig *config) { + + /*--- Mean value of the adjoint variables ---*/ + MeanPsiRho = 0.5*(Psi_i[0]+Psi_j[0]); + for (iDim = 0; iDim < nDim; iDim++) + MeanPhi[iDim] = 0.5*(Psi_i[iDim+1]+Psi_j[iDim+1]); + MeanPsiE = 0.5*(Psi_i[nVar-1]+Psi_j[nVar-1]); + + /*--- Evaluation at point i ---*/ + ProjVelocity_i = 0; ProjPhi = 0; ProjPhi_Vel = 0; sq_vel = 0; Area = 0; + for (iDim = 0; iDim < nDim; iDim++) { + Velocity_i[iDim] = U_i[iDim+1] / U_i[0]; + ProjVelocity_i += Velocity_i[iDim]*Normal[iDim]; + ProjPhi += MeanPhi[iDim]*Normal[iDim]; + ProjPhi_Vel += MeanPhi[iDim]*Velocity_i[iDim]; + sq_vel += 0.5*Velocity_i[iDim]*Velocity_i[iDim]; + Area += Normal[iDim]*Normal[iDim]; + } + Area = sqrt(Area); + phis1 = ProjPhi + ProjVelocity_i*MeanPsiE; + phis2 = MeanPsiRho + ProjPhi_Vel + Enthalpy_i*MeanPsiE; + + /*--- Compute inviscid residual at point i ---*/ + val_resconv_i[0] = ProjVelocity_i*MeanPsiRho - phis2*ProjVelocity_i + Gamma_Minus_One*phis1*sq_vel; + for (iDim = 0; iDim < nDim; iDim++) + val_resconv_i[iDim+1] = ProjVelocity_i*MeanPhi[iDim] + phis2*Normal[iDim] - Gamma_Minus_One*phis1*Velocity_i[iDim]; + val_resconv_i[nVar-1] = ProjVelocity_i*MeanPsiE + Gamma_Minus_One*phis1; + + /*--- Flux contributions due to grid motion at point i ---*/ + if (grid_movement) { + su2double ProjGridVel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; + val_resconv_i[0] -= ProjGridVel*MeanPsiRho; + for (iDim = 0; iDim < nDim; iDim++) + val_resconv_i[iDim+1] -= ProjGridVel*MeanPhi[iDim]; + val_resconv_i[nVar-1] -= ProjGridVel*MeanPsiE; + } + + /*--- Inviscid contribution to the implicit part ---*/ + if (implicit) { + val_Jacobian_ii[0][0] = 0.0; + for (jDim = 0; jDim < nDim; jDim++) + val_Jacobian_ii[0][jDim+1] = -0.5*ProjVelocity_i*Velocity_i[jDim] + Gamma_Minus_One*sq_vel*0.5*Normal[jDim]; + val_Jacobian_ii[0][nVar-1] = 0.5*ProjVelocity_i*(Gamma_Minus_One*sq_vel - Enthalpy_i); + for (iDim = 0; iDim < nDim; iDim++) { + val_Jacobian_ii[iDim+1][0] = 0.5*Normal[iDim]; + for (jDim = 0; jDim < nDim; jDim++) + val_Jacobian_ii[iDim+1][jDim+1] = 0.5*Normal[iDim]*Velocity_i[jDim] - 0.5*Gamma_Minus_One*Velocity_i[iDim]*Normal[jDim]; + val_Jacobian_ii[iDim+1][iDim+1] += 0.5*ProjVelocity_i; + val_Jacobian_ii[iDim+1][nVar-1] = 0.5*Enthalpy_i*Normal[iDim] - 0.5*Gamma_Minus_One*Velocity_i[iDim]*ProjVelocity_i; + } + val_Jacobian_ii[nVar-1][0] = 0; + for (jDim = 0; jDim < nDim; jDim++) + val_Jacobian_ii[nVar-1][jDim+1] = 0.5*Gamma_Minus_One*Normal[jDim]; + val_Jacobian_ii[nVar-1][nVar-1] = 0.5*Gamma*ProjVelocity_i; + + for (iVar = 0; iVar < nVar; iVar++) + for (jVar = 0; jVar < nVar; jVar++) + val_Jacobian_ij[iVar][jVar] = val_Jacobian_ii[iVar][jVar]; + + /*--- Jacobian contributions due to grid motion at point i ---*/ + if (grid_movement) { + su2double ProjGridVel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; + for (iVar = 0; iVar < nVar; iVar++) { + val_Jacobian_ii[iVar][iVar] -= 0.5*ProjGridVel; + val_Jacobian_ij[iVar][iVar] -= 0.5*ProjGridVel; + } + } + } + + /*--- Evaluation at point j ---*/ + ProjVelocity_j = 0; ProjPhi_Vel = 0; sq_vel = 0; + for (iDim = 0; iDim < nDim; iDim++) { + Velocity_j[iDim] = U_j[iDim+1] / U_j[0]; + ProjVelocity_j += Velocity_j[iDim]*Normal[iDim]; + ProjPhi_Vel += MeanPhi[iDim]*Velocity_j[iDim]; + sq_vel += 0.5*Velocity_j[iDim]*Velocity_j[iDim]; + } + + phis1 = ProjPhi + ProjVelocity_j*MeanPsiE; + phis2 = MeanPsiRho + ProjPhi_Vel + Enthalpy_j*MeanPsiE; + + /*--- Compute inviscid residual at point j ---*/ + val_resconv_j[0] = -(ProjVelocity_j*MeanPsiRho - phis2*ProjVelocity_j + Gamma_Minus_One*phis1*sq_vel); + for (iDim = 0; iDim < nDim; iDim++) + val_resconv_j[iDim+1] = -(ProjVelocity_j*MeanPhi[iDim] + phis2*Normal[iDim] - Gamma_Minus_One*phis1*Velocity_j[iDim]); + val_resconv_j[nVar-1] = -(ProjVelocity_j*MeanPsiE + Gamma_Minus_One*phis1); + + /*--- Flux contributions due to grid movement at point j ---*/ + if (grid_movement) { + su2double ProjGridVel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; + val_resconv_j[0] += ProjGridVel*MeanPsiRho; + for (iDim = 0; iDim < nDim; iDim++) + val_resconv_j[iDim+1] += ProjGridVel*MeanPhi[iDim]; + val_resconv_j[nVar-1] += ProjGridVel*MeanPsiE; + } + + /*--- Inviscid contribution to the implicit part ---*/ + if (implicit) { + val_Jacobian_jj[0][0] = 0.0; + for (jDim = 0; jDim < nDim; jDim++) + val_Jacobian_jj[0][jDim+1] = 0.5*ProjVelocity_j*Velocity_j[jDim] - Gamma_Minus_One*sq_vel*0.5*Normal[jDim]; + val_Jacobian_jj[0][nVar-1] = -0.5*ProjVelocity_j*(Gamma_Minus_One*sq_vel - Enthalpy_j); + for (iDim = 0; iDim < nDim; iDim++) { + val_Jacobian_jj[iDim+1][0] = -0.5*Normal[iDim]; + for (jDim = 0; jDim < nDim; jDim++) + val_Jacobian_jj[iDim+1][jDim+1] = -0.5*Normal[iDim]*Velocity_j[jDim] + 0.5*Gamma_Minus_One*Velocity_j[iDim]*Normal[jDim]; + val_Jacobian_jj[iDim+1][iDim+1] -= 0.5*ProjVelocity_j; + val_Jacobian_jj[iDim+1][nVar-1] = -0.5*Enthalpy_j*Normal[iDim] + 0.5*Gamma_Minus_One*Velocity_j[iDim]*ProjVelocity_j; + } + val_Jacobian_jj[nVar-1][0] = 0; + for (jDim = 0; jDim < nDim; jDim++) + val_Jacobian_jj[nVar-1][jDim+1] = -0.5*Gamma_Minus_One*Normal[jDim]; + val_Jacobian_jj[nVar-1][nVar-1] = -0.5*Gamma*ProjVelocity_j; + + for (iVar = 0; iVar < nVar; iVar++) + for (jVar = 0; jVar < nVar; jVar++) + val_Jacobian_ji[iVar][jVar] = val_Jacobian_jj[iVar][jVar]; + + /*--- Jacobian contributions due to grid movement at point j ---*/ + if (grid_movement) { + su2double ProjGridVel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; + for (iVar = 0; iVar < nVar; iVar++) { + val_Jacobian_jj[iVar][iVar] += 0.5*ProjGridVel; + val_Jacobian_ji[iVar][iVar] += 0.5*ProjGridVel; + } + } + } + + /*--- Computes differences btw. variables ---*/ + for (iVar = 0; iVar < nVar; iVar++) + Diff_Psi[iVar] = Psi_i[iVar]-Psi_j[iVar]; + + /*--- Adjustment to projected velocity due to grid motion ---*/ + if (grid_movement) { + su2double ProjGridVel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; + ProjVelocity_i -= ProjGridVel; + ProjVelocity_j += ProjGridVel; + } + + /*--- Compute spectral radius ---*/ + Local_Lambda_i = (fabs(ProjVelocity_i)+SoundSpeed_i*Area); + Local_Lambda_j = (fabs(ProjVelocity_j)+SoundSpeed_j*Area); + MeanLambda = 0.5*(Local_Lambda_i+Local_Lambda_j); + + /*--- Compute streching factor ---*/ + Phi_i = pow(Lambda_i/(4.0*MeanLambda), Param_p); + Phi_j = pow(Lambda_j/(4.0*MeanLambda), Param_p); + StretchingFactor = 4.0*Phi_i*Phi_j/(Phi_i+Phi_j); + + sc2 = 3.0*(su2double(Neighbor_i)+su2double(Neighbor_j))/(su2double(Neighbor_i)*su2double(Neighbor_j)); + Epsilon_0 = Param_Kappa_0*sc2*su2double(nDim)/3.0; + + /*--- Artifical dissipation evaluation ---*/ + for (iVar = 0; iVar < nVar; iVar++) { + Residual = Epsilon_0*StretchingFactor*MeanLambda*Diff_Psi[iVar]; + val_resvisc_i[iVar] = -Residual; + val_resvisc_j[iVar] = Residual; + } + + /*--- Contribution to implicit part ---*/ + if (implicit) { + for (iVar = 0; iVar < nVar; iVar++) { + val_Jacobian_ii[iVar][iVar] -= Epsilon_0*StretchingFactor*MeanLambda; + val_Jacobian_ij[iVar][iVar] += Epsilon_0*StretchingFactor*MeanLambda; + val_Jacobian_ji[iVar][iVar] += Epsilon_0*StretchingFactor*MeanLambda; + val_Jacobian_jj[iVar][iVar] -= Epsilon_0*StretchingFactor*MeanLambda; + } + } + +} diff --git a/SU2_CFD/src/numerics/continuous_adjoint/CSourceAxisymmetric_AdjFlow.cpp b/SU2_CFD/src/numerics/continuous_adjoint/CSourceAxisymmetric_AdjFlow.cpp new file mode 100644 index 000000000000..7a30a454f35b --- /dev/null +++ b/SU2_CFD/src/numerics/continuous_adjoint/CSourceAxisymmetric_AdjFlow.cpp @@ -0,0 +1,74 @@ +/*! + * \file CSourceAxisymmetric_AdjFlow.cpp + * \brief Implementation of numerics class CSourceAxisymmetric_AdjFlow. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../include/numerics/continuous_adjoint/CSourceAxisymmetric_AdjFlow.hpp" + +CSourceAxisymmetric_AdjFlow::CSourceAxisymmetric_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { } + +CSourceAxisymmetric_AdjFlow::~CSourceAxisymmetric_AdjFlow(void) { } + +void CSourceAxisymmetric_AdjFlow::ComputeResidual(su2double *val_residual, su2double **Jacobian_ii, CConfig *config) { + + su2double yinv; + su2double Jacobian_Axisymmetric[4][4]; + + if (Coord_i[1] > 0.0) yinv = 1.0/Coord_i[1]; + else yinv = 0.0; + + Jacobian_Axisymmetric[0][0] = 0; + Jacobian_Axisymmetric[0][1] = 0; + Jacobian_Axisymmetric[0][2] = 1.; + Jacobian_Axisymmetric[0][3] = 0; + + Jacobian_Axisymmetric[1][0] = -U_i[1]*U_i[2]/(U_i[0]*U_i[0]); + Jacobian_Axisymmetric[1][1] = U_i[2]/U_i[0]; + Jacobian_Axisymmetric[1][2] = U_i[1]/U_i[0]; + Jacobian_Axisymmetric[1][3] = 0; + + Jacobian_Axisymmetric[2][0] = -U_i[2]*U_i[2]/(U_i[0]*U_i[0]); + Jacobian_Axisymmetric[2][1] = 0; + Jacobian_Axisymmetric[2][2] = 2*U_i[2]/U_i[0]; + Jacobian_Axisymmetric[2][3] = 0; + + Jacobian_Axisymmetric[3][0] = -Gamma*U_i[2]*U_i[3]/(U_i[0]*U_i[0]) + (Gamma-1)*U_i[2]*(U_i[1]*U_i[1]+U_i[2]*U_i[2])/(U_i[0]*U_i[0]*U_i[0]); + Jacobian_Axisymmetric[3][1] = -(Gamma-1)*U_i[2]*U_i[1]/(U_i[0]*U_i[0]); + Jacobian_Axisymmetric[3][2] = Gamma*U_i[3]/U_i[0] - 1/2*(Gamma-1)*( (U_i[1]*U_i[1]+U_i[2]*U_i[2])/(U_i[0]*U_i[0]) + 2*U_i[2]*U_i[2]/(U_i[0]*U_i[0]) ); + Jacobian_Axisymmetric[3][3] = Gamma*U_i[2]/U_i[0]; + + for (int iVar=0; iVar<4; iVar++) + for (int jVar=0; jVar<4; jVar++) + Jacobian_Axisymmetric[iVar][jVar] *= yinv*Volume; + + /* -- Residual = transpose(Jacobian) * psi --*/ + for (int iVar = 0; iVar < nVar; iVar++) { + val_residual[iVar] = 0.0; + for (int jVar = 0; jVar < nVar; jVar++) { + val_residual[iVar] += Jacobian_Axisymmetric[jVar][iVar]*Psi_i[jVar]; + Jacobian_ii[iVar][jVar] = Jacobian_Axisymmetric[jVar][iVar]; + } + } +} diff --git a/SU2_CFD/src/numerics/continuous_adjoint/CSourceConservative_AdjFlow.cpp b/SU2_CFD/src/numerics/continuous_adjoint/CSourceConservative_AdjFlow.cpp new file mode 100644 index 000000000000..340421c5ed8a --- /dev/null +++ b/SU2_CFD/src/numerics/continuous_adjoint/CSourceConservative_AdjFlow.cpp @@ -0,0 +1,190 @@ +/*! + * \file CSourceConservative_AdjFlow.cpp + * \brief Implementation of numerics class CSourceConservative_AdjFlow. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../include/numerics/continuous_adjoint/CSourceConservative_AdjFlow.hpp" + +CSourceConservative_AdjFlow::CSourceConservative_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + + Velocity = new su2double [nDim]; + Residual_i = new su2double [nVar]; + Residual_j = new su2double [nVar]; + Mean_Residual = new su2double [nVar]; + + Mean_PrimVar_Grad = new su2double* [nVar]; + for (unsigned short iVar = 0; iVar < nVar; iVar++) + Mean_PrimVar_Grad[iVar] = new su2double [nDim]; +} + +CSourceConservative_AdjFlow::~CSourceConservative_AdjFlow(void) { + delete [] Mean_Residual; + delete [] Residual_j; + delete [] Residual_i; + delete [] Velocity; + + for (unsigned short iVar = 0; iVar < nVar; iVar++) + delete [] Mean_PrimVar_Grad[iVar]; + delete [] Mean_PrimVar_Grad; +} + +void CSourceConservative_AdjFlow::ComputeResidual (su2double *val_residual, CConfig *config) { + unsigned short iDim, jDim, iVar; + su2double rho, nu, Ji, fv1, fv2, Omega, Shat, dist_sq, Ji_2, Ji_3, one_o_oneplusJifv1; + su2double r, g, g_6, glim, dfw_g, dg_r, dr_nuhat, dr_Shat, Ms_coeff, invOmega; + + su2double cv1_3 = 7.1*7.1*7.1; + su2double k2 = 0.41*0.41; + su2double cb1 = 0.1355; + su2double cw2 = 0.3; + su2double cw3_6 = pow(2.0,6.0); + su2double sigma = 2./3.; + su2double cb2 = 0.622; + su2double cw1 = cb1/k2+(1+cb2)/sigma; + + for (iVar = 0; iVar < nVar; iVar++) { + Residual_i[iVar] = 0.0; + Residual_j[iVar] = 0.0; + } + + /*--- iPoint ---*/ + + /*--- Density and velocities ---*/ + + rho = U_i[0]; + for (iDim = 0; iDim < nDim; iDim++) + Velocity[iDim] = U_i[iDim+1]/rho; + + /*--- Vorticity ---*/ + + Omega = (PrimVar_Grad_i[1][1]-PrimVar_Grad_i[2][0])*(PrimVar_Grad_i[1][1]-PrimVar_Grad_i[2][0]); + if (nDim == 3) Omega += (PrimVar_Grad_i[1][2]-PrimVar_Grad_i[3][0])*(PrimVar_Grad_i[1][2]-PrimVar_Grad_i[3][0]) + + (PrimVar_Grad_i[2][2]-PrimVar_Grad_i[3][1])*(PrimVar_Grad_i[2][2]-PrimVar_Grad_i[3][1]); + Omega = sqrt(Omega); + invOmega = 1.0/(Omega + TURB_EPS); + + /*--- Compute Ms_coeff -> coming from partial derivatives ---*/ + + Ms_coeff = 0.0; + if (dist_i > 0) { + dist_sq = dist_i*dist_i; + nu = Laminar_Viscosity_i/rho; + Ji = TurbVar_i[0]/nu; + Ji_2 = Ji*Ji; + Ji_3 = Ji_2*Ji; + fv1 = Ji_3/(Ji_3+cv1_3); + one_o_oneplusJifv1 = 1.0/(1.0+Ji*fv1); + fv2 = 1.0 - Ji*one_o_oneplusJifv1; + Shat = max(Omega + TurbVar_i[0]*fv2/(k2*dist_sq), TURB_EPS); + + r = min(TurbVar_i[0]/(Shat*k2*dist_sq),10.); + g = r + cw2*(pow(r,6.)-r); + g_6 = pow(g,6.); + glim = pow((1+cw3_6)/(g_6+cw3_6),1./6.); + + dfw_g = glim*cw3_6/(g_6+cw3_6); + dg_r = 1.0 + cw2*(6.0*pow(r,5.0)-1.0); + dr_nuhat = 1.0/(Shat*k2*dist_sq); + dr_Shat = -dr_nuhat*TurbVar_i[0]/Shat; + + Ms_coeff = (cb1*TurbVar_i[0]-cw1*TurbVar_i[0]*TurbVar_i[0]/dist_sq*dfw_g*dg_r*dr_Shat); + } + Ms_coeff *= TurbPsi_i[0]*invOmega/rho; + + /*--- Compute residual of iPoint ---*/ + + for (iDim = 0; iDim < nDim; iDim++) { + for (jDim = 0; jDim < nDim; jDim++) { + Residual_i[0] -= Ms_coeff*(Velocity[jDim]*PrimVar_Grad_i[jDim+1][iDim]*Normal[iDim] - + Velocity[jDim]*PrimVar_Grad_i[iDim+1][jDim]*Normal[iDim]); + Residual_i[iDim+1] += Ms_coeff*(PrimVar_Grad_i[iDim+1][jDim]*Normal[jDim] - + PrimVar_Grad_i[jDim+1][iDim]*Normal[jDim]); + } + } + + /*--- jPoint ---*/ + + /*--- Density and velocities ---*/ + + rho = U_j[0]; + for (iDim = 0; iDim < nDim; iDim++) + Velocity[iDim] = U_j[iDim+1]/rho; + + /*--- Vorticity ---*/ + + Omega = (PrimVar_Grad_j[1][1]-PrimVar_Grad_j[2][0])*(PrimVar_Grad_j[1][1]-PrimVar_Grad_j[2][0]); + if (nDim == 3) Omega += (PrimVar_Grad_j[1][2]-PrimVar_Grad_j[3][0])*(PrimVar_Grad_j[1][2]-PrimVar_Grad_j[3][0]) + + (PrimVar_Grad_j[2][2]-PrimVar_Grad_j[3][1])*(PrimVar_Grad_j[2][2]-PrimVar_Grad_j[3][1]); + Omega = sqrt(Omega); + invOmega = 1.0/(Omega + TURB_EPS); + + /*--- Compute Ms_coeff -> coming from partial derivatives ---*/ + + Ms_coeff = 0.0; + if (dist_j > 0) { + dist_sq = dist_j*dist_j; + nu = Laminar_Viscosity_j/rho; + Ji = TurbVar_j[0]/nu; + Ji_2 = Ji*Ji; + Ji_3 = Ji_2*Ji; + fv1 = Ji_3/(Ji_3+cv1_3); + one_o_oneplusJifv1 = 1.0/(1.0+Ji*fv1); + fv2 = 1.0 - Ji*one_o_oneplusJifv1; + Shat = max(Omega + TurbVar_j[0]*fv2/(k2*dist_sq), TURB_EPS); + + r = min(TurbVar_j[0]/(Shat*k2*dist_sq),10.); + g = r + cw2*(pow(r,6.)-r); + g_6 = pow(g,6.); + glim = pow((1+cw3_6)/(g_6+cw3_6),1./6.); + + dfw_g = glim*cw3_6/(g_6+cw3_6); + dg_r = 1.0 + cw2*(6.0*pow(r,5.0)-1.0); + dr_nuhat = 1.0/(Shat*k2*dist_sq); + dr_Shat = -dr_nuhat*TurbVar_j[0]/Shat; + + Ms_coeff = (cb1*TurbVar_j[0]-cw1*TurbVar_j[0]*TurbVar_j[0]/dist_sq*dfw_g*dg_r*dr_Shat); + } + Ms_coeff *= TurbPsi_j[0]*invOmega/rho; + + /*--- Compute residual of jPoint ---*/ + + for (iDim = 0; iDim < nDim; iDim++) { + for (jDim = 0; jDim < nDim; jDim++) { + Residual_j[0] -= Ms_coeff*(Velocity[jDim]*PrimVar_Grad_j[jDim+1][iDim]*Normal[iDim] - + Velocity[jDim]*PrimVar_Grad_j[iDim+1][jDim]*Normal[iDim]); + Residual_j[iDim+1] += Ms_coeff*(PrimVar_Grad_j[iDim+1][jDim]*Normal[jDim] - + PrimVar_Grad_j[jDim+1][iDim]*Normal[jDim]); + } + } + + /*--- Compute the mean residual ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + val_residual[iVar] = 0.5*(Residual_i[iVar] + Residual_j[iVar]); + +} diff --git a/SU2_CFD/src/numerics/continuous_adjoint/CSourceConservative_AdjTurb.cpp b/SU2_CFD/src/numerics/continuous_adjoint/CSourceConservative_AdjTurb.cpp new file mode 100644 index 000000000000..da6a7e674893 --- /dev/null +++ b/SU2_CFD/src/numerics/continuous_adjoint/CSourceConservative_AdjTurb.cpp @@ -0,0 +1,66 @@ +/*! + * \file CSourceConservative_AdjTurb.cpp + * \brief Implementation of numerics class CSourceConservative_AdjTurb. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../include/numerics/continuous_adjoint/CSourceConservative_AdjTurb.hpp" + +CSourceConservative_AdjTurb::CSourceConservative_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + +} + +CSourceConservative_AdjTurb::~CSourceConservative_AdjTurb(void) { +} + +void CSourceConservative_AdjTurb::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { + + /*--- SOURCE term --> \nabla ( \psi_\mu \B7 E^{s} ) + E^{s} = 2 c_{b2}/\sigma \nabla \hat{nu} ---*/ + + unsigned short iDim; + bool implicit = (config->GetKind_TimeIntScheme_AdjTurb() == EULER_IMPLICIT); + + su2double cb2 = 0.622; + su2double sigma = 2./3.; + su2double coeff = 2.0*cb2/sigma; + su2double E_ij, proj_TurbVar_Grad_i, proj_TurbVar_Grad_j; + + E_ij = 0.0; proj_TurbVar_Grad_i = 0.0; proj_TurbVar_Grad_j = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + proj_TurbVar_Grad_i += coeff*TurbVar_Grad_i[0][iDim]*Normal[iDim]; + proj_TurbVar_Grad_j += coeff*TurbVar_Grad_j[0][iDim]*Normal[iDim]; + E_ij += 0.5*(TurbPsi_i[0]*proj_TurbVar_Grad_i + TurbPsi_j[0]*proj_TurbVar_Grad_j); + } + + val_residual[0] = E_ij; + + if (implicit) { + val_Jacobian_i[0][0] = 0.5*proj_TurbVar_Grad_i; + val_Jacobian_j[0][0] = 0.5*proj_TurbVar_Grad_j; + } +} diff --git a/SU2_CFD/src/numerics/continuous_adjoint/CSourcePieceWise_AdjTurb.cpp b/SU2_CFD/src/numerics/continuous_adjoint/CSourcePieceWise_AdjTurb.cpp new file mode 100644 index 000000000000..89b869fbbe3c --- /dev/null +++ b/SU2_CFD/src/numerics/continuous_adjoint/CSourcePieceWise_AdjTurb.cpp @@ -0,0 +1,162 @@ +/*! + * \file CSourcePieceWise_AdjTurb.cpp + * \brief Implementation of numerics class CSourcePieceWise_AdjTurb. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../include/numerics/continuous_adjoint/CSourcePieceWise_AdjTurb.hpp" + +CSourcePieceWise_AdjTurb::CSourcePieceWise_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + + Velocity = new su2double [nDim]; + tau = new su2double* [nDim]; + for (unsigned short iDim = 0; iDim < nDim; iDim++) + tau[iDim] = new su2double [nDim]; +} + +CSourcePieceWise_AdjTurb::~CSourcePieceWise_AdjTurb(void) { + delete [] Velocity; + + for (unsigned short iDim = 0; iDim < nDim; iDim++) + delete [] tau[iDim]; + delete [] tau; +} + +void CSourcePieceWise_AdjTurb::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { + unsigned short iDim, jDim; + + bool implicit = (config->GetKind_TimeIntScheme_AdjTurb() == EULER_IMPLICIT); + su2double Prandtl_Turb = config->GetPrandtl_Turb(); + + val_residual[0] = 0.0; + if (implicit) + val_Jacobian_i[0][0] = 0.0; + + if (dist_i > 0.0) { + + /*--- Computation of Vorticity and Divergence of velocity ---*/ + su2double div_vel = 0; + for (iDim = 0; iDim < nDim; iDim++) { + Velocity[iDim] = U_i[iDim+1]/U_i[0]; + div_vel += PrimVar_Grad_i[iDim+1][iDim]; + } + + su2double Vorticity = (PrimVar_Grad_i[2][0]-PrimVar_Grad_i[1][1])*(PrimVar_Grad_i[2][0]-PrimVar_Grad_i[1][1]); + if (nDim == 3) + Vorticity += ( (PrimVar_Grad_i[3][1]-PrimVar_Grad_i[2][2])*(PrimVar_Grad_i[3][1]-PrimVar_Grad_i[2][2]) + + (PrimVar_Grad_i[1][2]-PrimVar_Grad_i[3][0])*(PrimVar_Grad_i[1][2]-PrimVar_Grad_i[3][0]) ); + Vorticity = sqrt(Vorticity); + + /*--- FIRST PART: -Bs*TurbPsi_i ---*/ + /*--- CLOUSURE CONSTANTS ---*/ + su2double cv1 = 7.1; + su2double cv1_3 = cv1*cv1*cv1; + su2double k = 0.41; + su2double k2 = k*k; + su2double cb1 = 0.1355; + su2double cw2 = 0.3; + su2double cw3_6 = pow(2.0,6.0); + su2double sigma = 2./3.; + su2double cb2 = 0.622; + su2double cw1 = cb1/k2+(1+cb2)/sigma; + + su2double nu, Ji, fv1, fv2, Shat, dist_0_2, Ji_2, Ji_3, one_o_oneplusJifv1; + su2double r, g, g_6, glim, fw; + su2double dTs_nuhat, dTs_Shat, dShat_nuhat, dTs_fw, dfw_g, dg_r, dr_nuhat, dr_Shat; + su2double dShat_fv2, dfv2_fv1, dfv1_Ji, dJi_nuhat, dfv2_Ji; + su2double Bs; + + dist_0_2 = dist_i*dist_i; + nu = Laminar_Viscosity_i/U_i[0]; + Ji = TurbVar_i[0]/nu; + Ji_2 = Ji*Ji; + Ji_3 = Ji_2*Ji; + fv1 = Ji_3/(Ji_3+cv1_3); + one_o_oneplusJifv1 = 1.0/(1.0+Ji*fv1); + fv2 = 1.0 - Ji*one_o_oneplusJifv1; + Shat = max(Vorticity + TurbVar_i[0]*fv2/(k2*dist_0_2), TURB_EPS); + + // r = TurbVar_i[0]/(Shat*k2*dist_0_2); + r = min(TurbVar_i[0]/(Shat*k2*dist_0_2),10.); + g = r + cw2*(pow(r,6.)-r); + g_6 = pow(g,6.); + glim = pow((1+cw3_6)/(g_6+cw3_6),1./6.); + fw = g*glim; + + dTs_nuhat = cb1*Shat-2.0*cw1*fw*TurbVar_i[0]/dist_0_2; + dTs_Shat = cb1*TurbVar_i[0]; + dTs_fw = -cw1*TurbVar_i[0]*TurbVar_i[0]/dist_0_2; + dfw_g = glim*cw3_6/(g_6+cw3_6); + dg_r = 1.0 + cw2*(6.0*pow(r,5.0)-1.0); + dr_nuhat = 1.0/(Shat*k2*dist_0_2); + dr_Shat = -dr_nuhat*TurbVar_i[0]/Shat; + + dShat_nuhat = fv2/(k2*dist_0_2); + dShat_fv2 = TurbVar_i[0]/(k2*dist_0_2); + dfv2_fv1 = Ji_2*one_o_oneplusJifv1*one_o_oneplusJifv1; + dfv1_Ji = 3.0*cv1_3*Ji_2/((Ji_3+cv1_3)*(Ji_3+cv1_3)); + dJi_nuhat = 1.0/nu; + dfv2_Ji = -one_o_oneplusJifv1*one_o_oneplusJifv1; + dShat_nuhat += dShat_fv2*(dfv2_fv1*dfv1_Ji+dfv2_Ji)*dJi_nuhat; + + Bs = dTs_nuhat; // nu_hat term + Bs += dTs_Shat*dShat_nuhat; // S_hat term + Bs += dTs_fw*dfw_g*dg_r*(dr_nuhat+dr_Shat*dShat_nuhat); // fw terms + + val_residual[0] = -Bs*TurbPsi_i[0]*Volume; + + if (implicit) + val_Jacobian_i[0][0] = -Bs*Volume; + + /*---SECOND PART: \partial_nu_hat mu^k F^{vk} cdot \grad Psi ---*/ + su2double dEddyVisc_nuhat; + if (!config->GetFrozen_Visc_Cont()) + dEddyVisc_nuhat = U_i[0]*fv1*(1.0 + 3.0*cv1_3/(Ji_3+cv1_3)); + else + dEddyVisc_nuhat = 0; + + for (iDim = 0; iDim < nDim; iDim++) { + for (jDim = 0; jDim < nDim; jDim++) + tau[iDim][jDim] = PrimVar_Grad_i[iDim+1][jDim] + PrimVar_Grad_i[jDim+1][iDim]; + tau[iDim][iDim] -= TWO3*div_vel; + } + + su2double Gas_Constant = config->GetGas_ConstantND(); + su2double Cp = (Gamma/Gamma_Minus_One)*Gas_Constant; + su2double tau_gradphi = 0.0, vel_tau_gradpsi5 = 0.0, gradT_gradpsi5 = 0.0; + + for (iDim = 0; iDim < nDim; iDim++) { + gradT_gradpsi5 += PrimVar_Grad_i[0][iDim]*PsiVar_Grad_i[nVar-1][iDim]; + for (jDim = 0; jDim < nDim; jDim++) { + tau_gradphi += tau[iDim][jDim]*PsiVar_Grad_i[iDim+1][jDim]; + vel_tau_gradpsi5 += Velocity[iDim]*tau[iDim][jDim]*PsiVar_Grad_i[nVar-1][jDim]; + } + } + val_residual[0] += (tau_gradphi + vel_tau_gradpsi5 + Cp/Prandtl_Turb*gradT_gradpsi5)*dEddyVisc_nuhat*Volume; + + } +} diff --git a/SU2_CFD/src/numerics/continuous_adjoint/CSourceRotatingFrame_AdjFlow.cpp b/SU2_CFD/src/numerics/continuous_adjoint/CSourceRotatingFrame_AdjFlow.cpp new file mode 100644 index 000000000000..7669202ada3c --- /dev/null +++ b/SU2_CFD/src/numerics/continuous_adjoint/CSourceRotatingFrame_AdjFlow.cpp @@ -0,0 +1,86 @@ +/*! + * \file CSourceRotatingFrame_AdjFlow.cpp + * \brief Implementation of numerics class CSourceRotatingFrame_AdjFlow. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../include/numerics/continuous_adjoint/CSourceRotatingFrame_AdjFlow.hpp" + +CSourceRotatingFrame_AdjFlow::CSourceRotatingFrame_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { } + +CSourceRotatingFrame_AdjFlow::~CSourceRotatingFrame_AdjFlow(void) { } + +void CSourceRotatingFrame_AdjFlow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config) { + + unsigned short iDim, iVar, jVar; + su2double Omega[3] = {0,0,0}, Phi[3] = {0,0,0}; + bool implicit = (config->GetKind_TimeIntScheme_AdjFlow() == EULER_IMPLICIT); + + /*--- Retrieve the angular velocity vector from config. ---*/ + + for (iDim = 0; iDim < 3; iDim++){ + Omega[iDim] = config->GetRotation_Rate(iDim)/config->GetOmega_Ref(); + } + + /*--- Get the adjoint velocity vector at the current node. ---*/ + + for (iDim = 0; iDim < nDim; iDim++) + Phi[iDim] = Psi_i[iDim+1]; + + /*--- Compute the source term as the Jacobian of the rotating frame + source term multiplied by the adjoint state and the dual cell volume. ---*/ + + if (nDim == 2) { + val_residual[0] = 0.0; + val_residual[1] = Omega[2]*Phi[1]*Volume; + val_residual[2] = -Omega[2]*Phi[0]*Volume; + val_residual[3] = 0.0; + } else { + val_residual[0] = 0.0; + val_residual[1] = (Omega[2]*Phi[1] - Omega[1]*Phi[2])*Volume; + val_residual[2] = (Omega[0]*Phi[2] - Omega[2]*Phi[0])*Volume; + val_residual[3] = (Omega[1]*Phi[0] - Omega[0]*Phi[1])*Volume; + val_residual[4] = 0.0; + } + + /*--- Calculate the source term Jacobian ---*/ + + if (implicit) { + for (iVar = 0; iVar < nVar; iVar++) + for (jVar = 0; jVar < nVar; jVar++) + val_Jacobian_i[iVar][jVar] = 0.0; + if (nDim == 2) { + val_Jacobian_i[1][2] = Omega[2]*Volume; + val_Jacobian_i[2][1] = -Omega[2]*Volume; + } else { + val_Jacobian_i[1][2] = Omega[2]*Volume; + val_Jacobian_i[1][3] = -Omega[1]*Volume; + val_Jacobian_i[2][1] = -Omega[2]*Volume; + val_Jacobian_i[2][3] = Omega[0]*Volume; + val_Jacobian_i[3][1] = Omega[1]*Volume; + val_Jacobian_i[3][2] = -Omega[0]*Volume; + } + } + +} diff --git a/SU2_CFD/src/numerics/continuous_adjoint/CSourceViscous_AdjFlow.cpp b/SU2_CFD/src/numerics/continuous_adjoint/CSourceViscous_AdjFlow.cpp new file mode 100644 index 000000000000..47e7bf9f2c42 --- /dev/null +++ b/SU2_CFD/src/numerics/continuous_adjoint/CSourceViscous_AdjFlow.cpp @@ -0,0 +1,341 @@ +/*! + * \file CSourceViscous_AdjFlow.cpp + * \brief Implementation of numerics class CSourceViscous_AdjFlow. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../include/numerics/continuous_adjoint/CSourceViscous_AdjFlow.hpp" + +CSourceViscous_AdjFlow::CSourceViscous_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + unsigned short iDim; + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + + Velocity = new su2double [nVar]; + GradDensity = new su2double [nDim]; + GradInvDensity = new su2double [nDim]; + dPoDensity2 = new su2double [nDim]; + alpha = new su2double [nDim]; + beta = new su2double [nDim]; + Sigma_5_vec = new su2double [nDim]; + + GradVel_o_Rho = new su2double* [nDim]; + sigma = new su2double* [nDim]; + Sigma_phi = new su2double* [nDim]; + Sigma_5_Tensor = new su2double* [nDim]; + Sigma = new su2double* [nDim]; + + for (iDim = 0; iDim < nDim; iDim++) { + GradVel_o_Rho[iDim] = new su2double [nDim]; + sigma[iDim] = new su2double [nDim]; + Sigma_phi[iDim] = new su2double [nDim]; + Sigma_5_Tensor[iDim] = new su2double [nDim]; + Sigma[iDim] = new su2double [nDim]; + } + +} + +CSourceViscous_AdjFlow::~CSourceViscous_AdjFlow(void) { + unsigned short iDim; + + for (iDim = 0; iDim < nDim; iDim++) { + delete [] GradVel_o_Rho[iDim]; + delete [] sigma[iDim]; + delete [] Sigma_phi[iDim]; + delete [] Sigma_5_Tensor[iDim]; + delete [] Sigma[iDim]; + } + + delete [] GradVel_o_Rho; + delete [] sigma; + delete [] Sigma_phi; + delete [] Sigma_5_Tensor; + delete [] Sigma; + + delete [] Velocity; + delete [] GradDensity; + delete [] GradInvDensity; + delete [] dPoDensity2; + delete [] alpha; + delete [] beta; + delete [] Sigma_5_vec; + +} + +void CSourceViscous_AdjFlow::ComputeResidual (su2double *val_residual, CConfig *config) { + + unsigned short iDim, jDim; + +// su2double Temperature = V_i[0]; + su2double Pressure = V_i[nDim+1]; + su2double Density = V_i[nDim+2]; +// su2double Enthalpy = V_i[nDim+3]; + su2double Laminar_Viscosity = V_i[nDim+5]; + su2double Eddy_Viscosity = V_i[nDim+6]; + +// su2double Energy = Enthalpy - Pressure/Density; + su2double invDensity = 1.0/Density; + su2double invDensitysq = invDensity*invDensity; + su2double invDensitycube = invDensitysq*invDensity; + su2double Prandtl_Lam = config->GetPrandtl_Lam(); + su2double Prandtl_Turb = config->GetPrandtl_Turb(); + su2double mu_tot_1 = Laminar_Viscosity + Eddy_Viscosity; + su2double mu_tot_2 = Laminar_Viscosity/Prandtl_Lam + Eddy_Viscosity/Prandtl_Turb; +// su2double Gas_Constant = config->GetGas_ConstantND(); + + /*--- Required gradients of the flow variables, point j ---*/ + + for (iDim = 0; iDim < nDim; iDim++) { + + /*--- Gradient density ---*/ + + GradDensity[iDim] = PrimVar_Grad_i[nDim+2][iDim]; + + /*--- Gradient (1/rho) ---*/ + + GradInvDensity[iDim] = -GradDensity[iDim]*invDensitysq; + + /*--- Computation of the derivatives of P/(Density^2) ---*/ + + dPoDensity2[iDim] = (PrimVar_Grad_i[nVar-1][iDim]*Density - 2.0*GradDensity[iDim]*Pressure)*invDensitycube; + + /*--- Abbreviations: alpha, beta, sigma_5_vec ---*/ + + alpha[iDim] = Gamma*mu_tot_2*GradInvDensity[iDim]; + beta[iDim] = Gamma*mu_tot_2*dPoDensity2[iDim]/Gamma_Minus_One; + Sigma_5_vec[iDim] = Gamma*mu_tot_2*PsiVar_Grad_i[nVar-1][iDim]; + + } + + /*--- Definition of tensors and derivatives of velocity over density ---*/ + + su2double div_vel = 0.0, div_phi = 0.0, vel_gradpsi5 = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + div_vel += PrimVar_Grad_i[iDim+1][iDim]; + div_phi += PsiVar_Grad_i[iDim+1][iDim]; + vel_gradpsi5 += V_i[iDim+1]*PsiVar_Grad_i[nVar-1][iDim]; + for (jDim = 0; jDim < nDim; jDim++) { + sigma[iDim][jDim] = mu_tot_1*(PrimVar_Grad_i[iDim+1][jDim]+PrimVar_Grad_i[jDim+1][iDim]); + Sigma_phi[iDim][jDim] = mu_tot_1*(PsiVar_Grad_i[iDim+1][jDim]+PsiVar_Grad_i[jDim+1][iDim]); + Sigma_5_Tensor[iDim][jDim] = mu_tot_1*(V_i[jDim+1]*PsiVar_Grad_i[nVar-1][iDim]+V_i[iDim+1]*PsiVar_Grad_i[nVar-1][jDim]); + GradVel_o_Rho[iDim][jDim] = (PrimVar_Grad_i[iDim+1][jDim]*Density - V_i[iDim+1]*GradDensity[jDim])*invDensitysq; + } + } + + for (iDim = 0; iDim < nDim; iDim++) { + sigma[iDim][iDim] -= TWO3*mu_tot_1*div_vel; + Sigma_phi[iDim][iDim] -= TWO3*mu_tot_1*div_phi; + Sigma_5_Tensor[iDim][iDim] -= TWO3*mu_tot_1*vel_gradpsi5; + } + + for (iDim = 0; iDim < nDim; iDim++) { + for (jDim = 0; jDim < nDim; jDim++) { + Sigma[iDim][jDim] = Sigma_phi[iDim][jDim] + Sigma_5_Tensor[iDim][jDim]; + } + } + + /*--- Vector-Tensors products ---*/ + + su2double gradT_gradpsi5 = 0.0, sigma_gradpsi = 0.0, vel_sigma_gradpsi5 = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + gradT_gradpsi5 += PrimVar_Grad_i[0][iDim]*PsiVar_Grad_i[nVar-1][iDim]; + for (jDim = 0; jDim < nDim; jDim++) { + sigma_gradpsi += sigma[iDim][jDim]*PsiVar_Grad_i[jDim+1][iDim]; + vel_sigma_gradpsi5 += V_i[iDim+1]*sigma[iDim][jDim]*PsiVar_Grad_i[nVar-1][jDim]; + } + } + + /*--- Residuals ---*/ + + su2double alpha_gradpsi5 = 0.0, beta_gradpsi5 = 0.0, Sigma_gradvel_o_rho = 0.0, Sigma5_vel_gradvel = 0.0, sq_vel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + alpha_gradpsi5 += alpha[iDim]*PsiVar_Grad_i[nVar-1][iDim]; + beta_gradpsi5 += beta[iDim]*PsiVar_Grad_i[nVar-1][iDim]; + for (jDim = 0; jDim < nDim; jDim++) { + Sigma_gradvel_o_rho += Sigma[iDim][jDim]*GradVel_o_Rho[iDim][jDim]; + Sigma5_vel_gradvel += Sigma_5_vec[iDim]*(V_i[jDim+1]*PrimVar_Grad_i[jDim+1][iDim]); + } + sq_vel += V_i[iDim+1]*V_i[iDim+1]; + } + + val_residual[0] = (-vel_sigma_gradpsi5*invDensity + 0.5*sq_vel*alpha_gradpsi5 - + beta_gradpsi5) * Volume; + for (iDim = 0; iDim < nDim; iDim++) { + val_residual[iDim+1] = 0.0; + for (jDim = 0; jDim < nDim; jDim++) { + val_residual[iDim+1] += (sigma[iDim][jDim]*PsiVar_Grad_i[nVar-1][jDim]*invDensity - V_i[iDim+1]*alpha[jDim]*PsiVar_Grad_i[nVar-1][jDim]) * Volume; + } + } + val_residual[nVar-1] = alpha_gradpsi5 * Volume; + +// val_residual[0] += (Sigma5_vel_gradvel*invDensity - Sigma_gradvel_o_rho) * Volume; +// for (iDim = 0; iDim < nDim; iDim++) { +// for (jDim = 0; jDim < nDim; jDim++) { +// val_residual[iDim+1] += (Sigma[iDim][jDim]*GradInvDensity[jDim] - +// Sigma_5_vec[jDim]*PrimVar_Grad_i[iDim+1][jDim]*invDensity) * Volume; +// } +// } + + /*--- Laminar viscosity sensitivity for NS ---*/ + + if (config->GetKind_Solver() != ADJ_RANS) { + +// su2double Temperature_Ref = config->GetTemperature_Ref(); +// su2double Temperature_Dim = Temperature*Temperature_Ref; +// +// su2double S = 0.0; +// if (config->GetSystemMeasurements() == SI) { S = 110.4; } +// if (config->GetSystemMeasurements() == US) { S = 198.72; } +// su2double dVisc_T = ((Laminar_Viscosity)/(2.0*Temperature_Dim*(Temperature_Dim + S)))*(Temperature_Dim + 3.0*S)*Temperature_Ref; +// +// su2double Cp = (Gamma/Gamma_Minus_One)*Gas_Constant; +// su2double kappa_psi = (sigma_gradpsi + vel_sigma_gradpsi5)/mu_tot_1; +// su2double theta = (kappa_psi + Cp/Prandtl_Lam*gradT_gradpsi5)*dVisc_T*Gamma_Minus_One/(Gas_Constant*Density); +// +// val_residual[0] += (theta*(sq_vel-Energy))*Volume; +// for (iDim = 0; iDim < nDim; iDim++) +// val_residual[iDim+1] -= theta*V_i[iDim+1]*Volume; +// val_residual[nVar-1] += theta*Volume; + + } + +// /*--- Coupling terms coming from the continuous adjoint turbulent equations ---*/ +// +// if ((config->GetKind_Solver() == ADJ_RANS) && (!config->GetFrozen_Visc_Cont())) { +// +// /*--- Closure constants ---*/ +// +// su2double cv1_3 = 7.1*7.1*7.1; +// su2double k2 = 0.41*0.41; +// su2double cb1 = 0.1355; +// su2double cw2 = 0.3; +// su2double cw3_6 = pow(2.0,6.0); +// su2double sigma = 2./3.; +// su2double cb2 = 0.622; +// su2double cw1 = cb1/k2+(1+cb2)/sigma; +// +// su2double nu, Ji, Ji_2, Ji_3, fv1; +// nu = Laminar_Viscosity/Density; +// Ji = TurbVar_i[0]/nu; +// Ji_2 = Ji*Ji; +// Ji_3 = Ji_2*Ji; +// fv1 = Ji_3/(Ji_3+cv1_3); +// +// /*--- Contributions due to variation of viscosities ---*/ +// +// su2double Temperature_Ref = config->GetTemperature_Ref(); +// su2double Temperature_Dim = Temperature*Temperature_Ref; +// +// su2double S = 0.0; +// if (config->GetSystemMeasurements() == SI) { S = 110.4; } +// if (config->GetSystemMeasurements() == US) { S = 198.72; } +// su2double dVisc_T = ((Laminar_Viscosity)/(2.0*Temperature_Dim*(Temperature_Dim + S)))*(Temperature_Dim + 3.0*S)*Temperature_Ref; +// +// su2double Cp = (Gamma/Gamma_Minus_One)*Gas_Constant; +// su2double kappa_psi = (sigma_gradpsi + vel_sigma_gradpsi5)/mu_tot_1 + Cp/Prandtl_Turb*gradT_gradpsi5; +// su2double cv1_const = 3.0*cv1_3/(Ji_3+cv1_3); +// su2double theta = (kappa_psi*(1.0-Eddy_Viscosity/Laminar_Viscosity*cv1_const) - +// Cp/Prandtl_Turb*gradT_gradpsi5*(1.0-Prandtl_Turb/Prandtl_Lam))*dVisc_T*Gamma_Minus_One/(Gas_Constant*Density); +// su2double xi = kappa_psi*(1.0+cv1_const)*Eddy_Viscosity/Density; +// +// val_residual[0] += (theta*(sq_vel-Energy) + xi)*Volume; +// for (iDim = 0; iDim < nDim; iDim++) +// val_residual[iDim+1] -= theta*V_i[iDim+1]*Volume; +// val_residual[nVar-1] += theta*Volume; +// +// /*--- Coupling residuals ---*/ +// +// if (dist_i > 0.0) { +// su2double fv2, Omega, Shat, dist_0_2, one_o_oneplusJifv1; +// su2double r, g, g_6, glim, fw; +// su2double dfw_g, dg_r, dr_nuhat, dr_Shat; +// su2double dShat_fv2, dfv2_fv1, dfv1_Ji, dJi_nu, dJi_nuhat, dfv2_Ji; +// +// /*--- Vorticity ---*/ +// Omega = (PrimVar_Grad_i[1][1]-PrimVar_Grad_i[2][0])*(PrimVar_Grad_i[1][1]-PrimVar_Grad_i[2][0]); +// if (nDim == 3) Omega += (PrimVar_Grad_i[1][2]-PrimVar_Grad_i[3][0])*(PrimVar_Grad_i[1][2]-PrimVar_Grad_i[3][0]) + +// (PrimVar_Grad_i[2][2]-PrimVar_Grad_i[3][1])*(PrimVar_Grad_i[2][2]-PrimVar_Grad_i[3][1]); +// Omega = sqrt(Omega); +// +// dist_0_2 = dist_i*dist_i; +// one_o_oneplusJifv1 = 1.0/(1.0+Ji*fv1); +// fv2 = 1.0 - Ji*one_o_oneplusJifv1; +// Shat = max(Omega + TurbVar_i[0]*fv2/(k2*dist_0_2), TURB_EPS); +// +// r = min(TurbVar_i[0]/(Shat*k2*dist_0_2), 10.); +// g = r + cw2*(pow(r,6.)-r); +// g_6 = pow(g,6.); +// glim = pow((1+cw3_6)/(g_6+cw3_6),1./6.); +// fw = g*glim; +// +// dfw_g = glim*cw3_6/(g_6+cw3_6); +// dg_r = 1.0 + cw2*(6.0*pow(r,5.0)-1.0); +// dr_nuhat = 1.0/(Shat*k2*dist_0_2); +// dr_Shat = -dr_nuhat*TurbVar_i[0]/Shat; +// +// dShat_fv2 = TurbVar_i[0]/(k2*dist_0_2); +// dfv2_fv1 = Ji_2*one_o_oneplusJifv1*one_o_oneplusJifv1; +// dfv1_Ji = 3.0*cv1_3*Ji_2/((Ji_3+cv1_3)*(Ji_3+cv1_3)); +// dJi_nuhat = 1.0/nu; +// dJi_nu = -Ji/nu; +// dfv2_Ji = -one_o_oneplusJifv1*one_o_oneplusJifv1; +// +// /*--- Terms 1 & 2: -Fcv\B7nabla(TurbPsi_i) - Fs\B7TurbPsi_i ---*/ +// +// su2double gradTurbVar_gradTurbPsi = 0, vel_gradTurbPsi = 0; +// for (iDim = 0; iDim < nDim; iDim++) { +// gradTurbVar_gradTurbPsi += TurbVar_Grad_i[0][iDim]*TurbPsi_Grad_i[0][iDim]; +// vel_gradTurbPsi += V_i[iDim+1]*TurbPsi_Grad_i[0][iDim]; +// } +// +// su2double alpha_coeff = Gamma_Minus_One/(Gas_Constant*Density)*dVisc_T; +// su2double beta_coeff = alpha_coeff*(sq_vel-Energy)-Laminar_Viscosity_i/Density; +// su2double Fs_coeff = TurbPsi_i[0]*(cb1*TurbVar_i[0]-cw1*TurbVar_i[0]*TurbVar_i[0]/dist_0_2*dfw_g*dg_r*dr_Shat)* +// dShat_fv2*(dfv2_Ji+dfv2_fv1*dfv1_Ji)*dJi_nu; +// su2double Gamma = Fs_coeff - gradTurbVar_gradTurbPsi/sigma; +// +// val_residual[0] -= (Gamma*beta_coeff - TurbVar_i[0]*vel_gradTurbPsi)/Density*Volume; +// for (iDim = 0; iDim < nDim; iDim++) +// val_residual[iDim+1] += (Gamma*alpha_coeff*V_i[iDim+1] - TurbVar_i[0]*TurbPsi_Grad_i[0][iDim])/Density*Volume; +// val_residual[nVar-1] -= (Gamma*alpha_coeff)/Density*Volume; +// +// // this should improve stability (when commented): +// /*--- Terms 3: -partial{T^s}_GradVel x GradN ---*/ +// // su2double Ms_coeff = (cb1*TurbVar_i[0]-cw1*TurbVar_i[0]*TurbVar_i[0]/dist_0_2*dfw_g*dg_r*dr_Shat); +// // Ms_coeff *= TurbPsi_i[0]/(Omega + TURB_EPS); +// // +// // for (iDim = 0; iDim < nDim; iDim++) { +// // for (jDim = 0; jDim < nDim; jDim++) { +// // val_residual[0] += Ms_coeff*(PrimVar_Grad_i[iDim+1][jDim]-PrimVar_Grad_i[jDim+1][iDim])* +// // GradVel_o_Rho[iDim][jDim]*dV; +// // val_residual[iDim+1] -= Ms_coeff*(PrimVar_Grad_i[iDim+1][jDim]-PrimVar_Grad_i[jDim+1][iDim])* +// // GradInvDensity[jDim]*dV; +// // } +// // } +// +// } +// } + +} diff --git a/SU2_CFD/src/numerics/continuous_adjoint/CUpwLin_AdjTurb.cpp b/SU2_CFD/src/numerics/continuous_adjoint/CUpwLin_AdjTurb.cpp new file mode 100644 index 000000000000..ee2f322a9fe2 --- /dev/null +++ b/SU2_CFD/src/numerics/continuous_adjoint/CUpwLin_AdjTurb.cpp @@ -0,0 +1,66 @@ +/*! + * \file CUpwLin_AdjTurb.cpp + * \brief Implementation of numerics class CUpwLin_AdjTurb. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../include/numerics/continuous_adjoint/CUpwLin_AdjTurb.hpp" + +CUpwLin_AdjTurb::CUpwLin_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + + Velocity_i = new su2double [nDim]; +} + +CUpwLin_AdjTurb::~CUpwLin_AdjTurb(void) { + delete [] Velocity_i; +} + +void CUpwLin_AdjTurb::ComputeResidual (su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { + bool implicit = (config->GetKind_TimeIntScheme_AdjTurb() == EULER_IMPLICIT); + + /*--- Non-conservative term --> -\nabla \psi_\mu B^{cv} + B^{cv} = -v ---*/ + + unsigned short iDim; + su2double proj_conv_flux = 0; + + for (iDim = 0; iDim < nDim; iDim++) { + Velocity_i[iDim] = U_i[iDim+1]/U_i[0]; + proj_conv_flux += Velocity_i[iDim]*Normal[iDim]; // projection of convective flux at iPoint + } + su2double psinu0 = TurbPsi_i[0]; + su2double psinu1; + if (proj_conv_flux > 0) + psinu1 = psinu0 + proj_conv_flux; + else + psinu1 = psinu0; + + val_residual[0] = 0.5*( proj_conv_flux*(psinu0+psinu1)-fabs(proj_conv_flux)*(psinu1-psinu0)); + if (implicit) { + val_Jacobian_i[0][0] = 0.5*( proj_conv_flux + fabs(proj_conv_flux)); + } +} diff --git a/SU2_CFD/src/numerics/continuous_adjoint/CUpwRoe_AdjFlow.cpp b/SU2_CFD/src/numerics/continuous_adjoint/CUpwRoe_AdjFlow.cpp new file mode 100644 index 000000000000..6c5e6530ceb2 --- /dev/null +++ b/SU2_CFD/src/numerics/continuous_adjoint/CUpwRoe_AdjFlow.cpp @@ -0,0 +1,334 @@ +/*! + * \file CUpwRoe_AdjFlow.cpp + * \brief Implementation of numerics class CUpwRoe_AdjFlow. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../include/numerics/continuous_adjoint/CUpwRoe_AdjFlow.hpp" + +CUpwRoe_AdjFlow::CUpwRoe_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + implicit = (config->GetKind_TimeIntScheme_AdjFlow() == EULER_IMPLICIT); + grid_movement = config->GetGrid_Movement(); + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + + Residual_Roe = new su2double [nVar]; + RoeVelocity = new su2double [nDim]; + Velocity_i = new su2double [nDim]; + Velocity_j = new su2double [nDim]; + Lambda = new su2double [nVar]; + P_Tensor = new su2double* [nVar]; + invP_Tensor = new su2double* [nVar]; + ProjFlux_i = new su2double*[nVar]; + ProjFlux_j = new su2double*[nVar]; + Proj_ModJac_Tensor = new su2double*[nVar]; + for (iVar = 0; iVar < nVar; iVar++) { + P_Tensor[iVar] = new su2double [nVar]; + invP_Tensor[iVar] = new su2double [nVar]; + ProjFlux_i[iVar] = new su2double[nVar]; + ProjFlux_j[iVar] = new su2double[nVar]; + Proj_ModJac_Tensor[iVar] = new su2double[nVar]; + } + +} + +CUpwRoe_AdjFlow::~CUpwRoe_AdjFlow(void) { + + delete [] Residual_Roe; + delete [] RoeVelocity; + delete [] Velocity_i; + delete [] Velocity_j; + delete [] Lambda; + for (iVar = 0; iVar < nVar; iVar++) { + delete [] P_Tensor[iVar]; + delete [] invP_Tensor[iVar]; + delete [] ProjFlux_i[iVar]; + delete [] ProjFlux_j[iVar]; + delete [] Proj_ModJac_Tensor[iVar]; + } + delete [] P_Tensor; + delete [] invP_Tensor; + delete [] ProjFlux_i; + delete [] ProjFlux_j; + delete [] Proj_ModJac_Tensor; + +} + +void CUpwRoe_AdjFlow::ComputeResidual (su2double *val_residual_i, su2double *val_residual_j, su2double **val_Jacobian_ii, + su2double **val_Jacobian_ij, su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config) { + + /*--- Compute the area ---*/ + + area = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + area += Normal[iDim]*Normal[iDim]; + area = sqrt(area); + rarea = 1.0 / area; + + /*--- Components of the normal & unit normal vector of the current face ---*/ + + Sx = Normal[0]; + Sy = Normal[1]; + Sz = 0.0; if (nDim == 3) Sz = Normal[2]; + nx = Sx * rarea; + ny = Sy * rarea; + nz = Sz * rarea; + + /*--- Flow variable states at point i (left, _l) and j (right, _r)---*/ + + rho_l = V_i[nDim+2]; rho_r = V_j[nDim+2]; + u_l = V_i[1]; v_l = V_i[2]; w_l = 0.0; if (nDim == 3) w_l = V_i[3]; + u_r = V_j[1]; v_r = V_j[2]; w_r = 0.0; if (nDim == 3) w_r = V_j[3]; + h_l = V_i[nDim+3]; h_r = V_j[nDim+3]; + + /*--- One-half speed squared ---*/ + + q_l = ONE2 * ((u_l*u_l) + (v_l*v_l) + (w_l*w_l)); + q_r = ONE2 * ((u_r*u_r) + (v_r*v_r) + (w_r*w_r)); + + /*--- Projected velocity ---*/ + + Q_l = (u_l * Sx) + (v_l * Sy) + (w_l * Sz); + Q_r = (u_r * Sx) + (v_r * Sy) + (w_r * Sz); + + /*--- Mean adjoint variables ---*/ + + psi1 = ONE2 * (Psi_i[0] + Psi_j[0]); + psi2 = ONE2 * (Psi_i[1] + Psi_j[1]); + psi3 = ONE2 * (Psi_i[2] + Psi_j[2]); + psi4 = 0.0; if (nDim == 3) psi4 = ONE2 * (Psi_i[3] + Psi_j[3]); + psi5 = ONE2 * (Psi_i[nVar-1] + Psi_j[nVar-1]); + + /*--- Left state ---*/ + + l1psi = (Sx * psi2) + (Sy * psi3) + (Sz * psi4) + (Q_l * psi5); + l2psi = psi1 + (u_l * psi2) + (v_l * psi3) + (w_l * psi4) + (h_l * psi5); + + val_residual_i[0] = Q_l * psi1 - l2psi * Q_l + l1psi * Gamma_Minus_One * q_l; + val_residual_i[1] = Q_l * psi2 + l2psi * Sx - l1psi * Gamma_Minus_One * u_l; + val_residual_i[2] = Q_l * psi3 + l2psi * Sy - l1psi * Gamma_Minus_One * v_l; + if (nDim == 3) val_residual_i[3] = Q_l * psi4 + l2psi * Sz - l1psi * Gamma_Minus_One * w_l; + val_residual_i[nVar-1] = Q_l * psi5 + l1psi * Gamma_Minus_One; + + /*--- Right state ---*/ + + l1psi = (Sx * psi2) + (Sy * psi3) + (Sz * psi4) + (Q_r * psi5); + l2psi = psi1 + (u_r * psi2) + (v_r * psi3) + (w_r * psi4) + (h_r * psi5); + + val_residual_j[0] = -(Q_r * psi1 - l2psi * Q_r + l1psi * Gamma_Minus_One * q_r); + val_residual_j[1] = -(Q_r * psi2 + l2psi * Sx - l1psi * Gamma_Minus_One * u_r); + val_residual_j[2] = -(Q_r * psi3 + l2psi * Sy - l1psi * Gamma_Minus_One * v_r); + if (nDim == 3) val_residual_j[3] = -(Q_r * psi4 + l2psi * Sz - l1psi * Gamma_Minus_One * w_r); + val_residual_j[nVar-1] = -(Q_r * psi5 + l1psi * Gamma_Minus_One); + + + /*--- f_{roe} = P^{-T} |lambda| P^T \delta \psi ---*/ + + psi1_l = Psi_i[0]; + psi2_l = Psi_i[1]; + psi3_l = Psi_i[2]; + psi4_l = 0.0; if (nDim == 3) psi4_l = Psi_i[3]; + psi5_l = Psi_i[nVar-1]; + + psi1_r = Psi_j[0]; + psi2_r = Psi_j[1]; + psi3_r = Psi_j[2]; + psi4_r = 0.0; if (nDim == 3) psi4_r = Psi_j[3]; + psi5_r = Psi_j[nVar-1]; + + /*--- Roe averaging ---*/ + + rrho_l = 1.0 / rho_l; + weight = sqrt(rho_r * rrho_l); + rweight1 = 1.0 / (1.0 + weight); + weight *= rweight1; + + h = h_l * rweight1 + weight * h_r; + u = u_l * rweight1 + weight * u_r; + v = v_l * rweight1 + weight * v_r; + w = w_l * rweight1 + weight * w_r; + + psi1 = ONE2 * (psi1_r - psi1_l); + psi2 = ONE2 * (psi2_r - psi2_l); + psi3 = ONE2 * (psi3_r - psi3_l); + psi4 = ONE2 * (psi4_r - psi4_l); + psi5 = ONE2 * (psi5_r - psi5_l); + + q2 = (u*u) + (v*v) + (w*w); + Q = (u * Sx) + (v * Sy) + (w * Sz); + vn = nx * u + ny * v + nz * w; + cc = Gamma_Minus_One * h - 0.5 * Gamma_Minus_One * q2; + c = sqrt(cc); + + /*--- Contribution to velocity projection due to grid movement ---*/ + + if (grid_movement) { + su2double ProjGridVel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; + Q -= ProjGridVel; + } + + /*--- Eigenvalues from the primal solution ---*/ + + absQ = fabs(Q); + absQp = fabs(Q + c * area); + absQm = fabs(Q - c * area); + + alpha = ONE2 * Gamma_Minus_One * q2 / cc; + beta_u = psi2 + u * psi5; + beta_v = psi3 + v * psi5; + beta_w = psi4 + w * psi5; + eta = Gamma_Minus_One / cc; + l1psi = (nx * psi2) + (ny * psi3) + (nz * psi4) + (vn * psi5); + l2psi = psi1 + (u * psi2) + (v * psi3) + (w * psi4) + (h * psi5); + l1l2p = (l2psi + c * l1psi) * absQp; + l1l2m = (l2psi - c * l1psi) * absQm; + + /*--- adjoint flux computation in the x, y and z coordinate system ---*/ + + Residual_Roe[0] = ((1.0-alpha)*l2psi - (1.0-alpha)*cc/Gamma_Minus_One*psi5 + - u*beta_u*(1.0-(nx*nx)) - v*beta_v*(1.0-(ny*ny)) + - w*beta_w*(1.0-(nz*nz)) + ny*nz*(w*beta_v + v*beta_w) + + nx*nz*(w*beta_u + u*beta_w) + ny*nx*(v*beta_u + u*beta_v) ) * absQ + - ONE2 / c * vn * (l1l2p - l1l2m) + ONE2 * alpha * (l1l2p + l1l2m); + + Residual_Roe[1] = (l2psi*u*eta - u*psi5 + beta_u*(1.0-(nx*nx)) + - nx*(beta_v*ny + beta_w*nz) ) * absQ + ONE2*nx/c * (l1l2p - l1l2m ) + - ONE2*eta*u * (l1l2p + l1l2m ); + + Residual_Roe[2] = (l2psi*v*eta - v*psi5 + beta_v*(1.0-(ny*ny)) + - ny*(beta_w*nz + beta_u*nx) ) * absQ + ONE2*ny/c * (l1l2p - l1l2m ) + - ONE2*eta*v * (l1l2p + l1l2m ); + + if (nDim == 3) Residual_Roe[3] = (l2psi*w*eta - w*psi5 + beta_w*(1.0-(nz*nz)) - nz*(beta_u*nx + beta_v*ny) ) * absQ + + ONE2*nz/c * (l1l2p - l1l2m ) - ONE2*eta*w * (l1l2p + l1l2m ); + + Residual_Roe[nVar-1] = (psi5 - l2psi*eta) * absQ + ONE2*eta*(l1l2p + l1l2m); + + for (iVar = 0; iVar < nVar; iVar++) { + val_residual_i[iVar] += Residual_Roe[iVar]; + val_residual_j[iVar] -= Residual_Roe[iVar]; + } + + /*--- Flux contribution due to grid movement ---*/ + + if (grid_movement) { + su2double ProjGridVel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; + for (iVar = 0; iVar < nVar; iVar++) { + val_residual_i[iVar] -= ProjGridVel * 0.5*(Psi_i[iVar]+Psi_j[iVar]); + val_residual_j[iVar] += ProjGridVel * 0.5*(Psi_i[iVar]+Psi_j[iVar]); + } + } + + /*--- Implicit Contributions ---*/ + + if (implicit) { + + /*--- Prepare variables for use in matrix routines ---*/ + + RoeDensity = V_i[nDim+2]*sqrt(V_j[nDim+2]/V_i[nDim+2]); + RoeSoundSpeed = c; + UnitNormal[0] = nx; UnitNormal[1] = ny; if (nDim == 3 ) UnitNormal[2] = nz; + RoeVelocity[0] = u; RoeVelocity[1] = v; if (nDim == 3 ) RoeVelocity[2] = w; + Velocity_i[0] = u_l; Velocity_i[1] = v_l; if (nDim == 3 ) Velocity_i[2] = w_l; + Velocity_j[0] = u_r; Velocity_j[1] = v_r; if (nDim == 3 ) Velocity_j[2] = w_r; + + Pressure_i = V_i[nDim+1]; + Density_i = V_i[nDim+2]; + Enthalpy_i = V_i[nDim+3]; + Energy_i = Enthalpy_i - Pressure_i/Density_i; + + Pressure_j = V_i[nDim+1]; + Density_j = V_i[nDim+2]; + Enthalpy_j = V_i[nDim+3]; + Energy_j = Enthalpy_j - Pressure_j/Density_j; + + /*--- Jacobians of the inviscid flux, scaled by + 0.5 because val_resconv ~ 0.5*(fc_i+fc_j)*Normal ---*/ + + GetInviscidProjJac(Velocity_i, &Energy_i, Normal, 0.5, ProjFlux_i); + GetInviscidProjJac(Velocity_j, &Energy_j, Normal, 0.5, ProjFlux_j); + + /*--- Compute P, inverse P, and store eigenvalues ---*/ + + GetPMatrix_inv(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, invP_Tensor); + GetPMatrix(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, P_Tensor); + + /*--- Flow eigenvalues ---*/ + + for (iDim = 0; iDim < nDim; iDim++) + Lambda[iDim] = absQ; + Lambda[nVar-2] = absQp; + Lambda[nVar-1] = absQm; + + /*--- Roe's Flux approximation ---*/ + + for (iVar = 0; iVar < nVar; iVar++) { + for (jVar = 0; jVar < nVar; jVar++) { + Proj_ModJac_Tensor_ij = 0.0; + + /*--- Compute |Proj_ModJac_Tensor| = P x |Lambda| x inverse P ---*/ + + for (kVar = 0; kVar < nVar; kVar++) + Proj_ModJac_Tensor_ij += P_Tensor[iVar][kVar]*Lambda[kVar]*invP_Tensor[kVar][jVar]; + Proj_ModJac_Tensor[iVar][jVar] = 0.5*Proj_ModJac_Tensor_ij*area; + } + } + + /*--- Transpose the matrices and store the Jacobians. Note the negative + sign for the ji and jj Jacobians bc the normal direction is flipped. ---*/ + + for (iVar = 0; iVar < nVar; iVar++) { + for (jVar = 0; jVar < nVar; jVar++) { + val_Jacobian_ii[jVar][iVar] = ProjFlux_i[iVar][jVar] - Proj_ModJac_Tensor[iVar][jVar]; + val_Jacobian_ij[jVar][iVar] = ProjFlux_i[iVar][jVar] + Proj_ModJac_Tensor[iVar][jVar]; + val_Jacobian_ji[jVar][iVar] = -(ProjFlux_j[iVar][jVar] - Proj_ModJac_Tensor[iVar][jVar]); + val_Jacobian_jj[jVar][iVar] = -(ProjFlux_j[iVar][jVar] + Proj_ModJac_Tensor[iVar][jVar]); + } + } + + /*--- Jacobian contribution due to grid movement ---*/ + + if (grid_movement) { + su2double ProjGridVel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; + for (iVar = 0; iVar < nVar; iVar++) { + + /*--- Adjust Jacobian main diagonal ---*/ + + val_Jacobian_ii[iVar][iVar] -= 0.5*ProjGridVel; + val_Jacobian_ij[iVar][iVar] -= 0.5*ProjGridVel; + val_Jacobian_ji[iVar][iVar] += 0.5*ProjGridVel; + val_Jacobian_jj[iVar][iVar] += 0.5*ProjGridVel; + } + } + + } +} diff --git a/SU2_CFD/src/numerics/continuous_adjoint/CUpwSca_AdjTurb.cpp b/SU2_CFD/src/numerics/continuous_adjoint/CUpwSca_AdjTurb.cpp new file mode 100644 index 000000000000..cc3c9ee6ab9b --- /dev/null +++ b/SU2_CFD/src/numerics/continuous_adjoint/CUpwSca_AdjTurb.cpp @@ -0,0 +1,74 @@ +/*! + * \file CUpwSca_AdjTurb.cpp + * \brief Implementation of numerics class CUpwSca_AdjTurb. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../include/numerics/continuous_adjoint/CUpwSca_AdjTurb.hpp" + +CUpwSca_AdjTurb::CUpwSca_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + + Velocity_i = new su2double [nDim]; + Velocity_j = new su2double [nDim]; +} + +CUpwSca_AdjTurb::~CUpwSca_AdjTurb(void) { + delete [] Velocity_i; + delete [] Velocity_j; +} + +void CUpwSca_AdjTurb::ComputeResidual (su2double *val_residual_i, su2double *val_residual_j, + su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, + su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config) { + + bool implicit = (config->GetKind_TimeIntScheme_AdjTurb() == EULER_IMPLICIT); + + /*--- Non-conservative term --> -\nabla \psi_\mu B^{cv} + B^{cv} = -\nabla \hat{nu}/\sigma + v ---*/ + + unsigned short iDim; + su2double proj_conv_flux_i = 0, proj_conv_flux_j = 0, proj_conv_flux_ij = 0; + su2double sigma = 2./3.; + + for (iDim = 0; iDim < nDim; iDim++) { + Velocity_i[iDim] = U_i[iDim+1]/U_i[0]; + Velocity_j[iDim] = U_j[iDim+1]/U_j[0]; + proj_conv_flux_i += (TurbVar_Grad_i[0][iDim]/sigma - Velocity_i[iDim])*Normal[iDim]; // projection of convective flux at iPoint + proj_conv_flux_j += (TurbVar_Grad_j[0][iDim]/sigma - Velocity_j[iDim])*Normal[iDim]; // projection of convective flux at jPoint + } + proj_conv_flux_ij = 0.5*fabs(proj_conv_flux_i+proj_conv_flux_j); // projection of average convective flux + + val_residual_i[0] = 0.5*( proj_conv_flux_i*(TurbPsi_i[0]+TurbPsi_j[0])-proj_conv_flux_ij*(TurbPsi_j[0]-TurbPsi_i[0])); + val_residual_j[0] = 0.5*(-proj_conv_flux_j*(TurbPsi_j[0]+TurbPsi_i[0])-proj_conv_flux_ij*(TurbPsi_i[0]-TurbPsi_j[0])); + if (implicit) { + val_Jacobian_ii[0][0] = 0.5*( proj_conv_flux_i+proj_conv_flux_ij); + val_Jacobian_ij[0][0] = 0.5*( proj_conv_flux_i-proj_conv_flux_ij); + val_Jacobian_ji[0][0] = 0.5*(-proj_conv_flux_j-proj_conv_flux_ij); + val_Jacobian_jj[0][0] = 0.5*(-proj_conv_flux_j+proj_conv_flux_ij); + } + +} diff --git a/SU2_CFD/src/numerics/flow/convection_centered/CCentBase_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_centered/CCentBase_Flow.cpp new file mode 100644 index 000000000000..b348935b4dbc --- /dev/null +++ b/SU2_CFD/src/numerics/flow/convection_centered/CCentBase_Flow.cpp @@ -0,0 +1,207 @@ +/*! + * \file CCentBase_Flow.cpp + * \brief Implementation of numerics class CCentBase_Flow. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../../include/numerics/flow/convection_centered/CCentBase_Flow.hpp" + +CCentBase_Flow::CCentBase_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : + CNumerics(val_nDim, val_nVar, config) { + + implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ + dynamic_grid = config->GetDynamic_Grid(); + fix_factor = config->GetCent_Jac_Fix_Factor(); + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + + /*--- Allocate required structures ---*/ + Diff_U = new su2double [nVar]; + Diff_Lapl = new su2double [nVar]; + Velocity_i = new su2double [nDim]; + Velocity_j = new su2double [nDim]; + MeanVelocity = new su2double [nDim]; + ProjFlux = new su2double [nVar]; +} + +CCentBase_Flow::~CCentBase_Flow(void) { + delete [] Diff_U; + delete [] Diff_Lapl; + delete [] Velocity_i; + delete [] Velocity_j; + delete [] MeanVelocity; + delete [] ProjFlux; +} + +void CCentBase_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, + CConfig *config) { + + su2double U_i[5] = {0.0,0.0,0.0,0.0,0.0}, U_j[5] = {0.0,0.0,0.0,0.0,0.0}; + + bool preacc = SetPreaccInVars(); + + if (preacc) { + AD::SetPreaccIn(Normal, nDim); + AD::SetPreaccIn(V_i, nDim+5); AD::SetPreaccIn(V_j, nDim+5); + AD::SetPreaccIn(Lambda_i); AD::SetPreaccIn(Lambda_j); + if (dynamic_grid) { + AD::SetPreaccIn(GridVel_i, nDim); AD::SetPreaccIn(GridVel_j, nDim); + } + } + + /*--- Pressure, density, enthalpy, energy, and velocity at points i and j ---*/ + + Pressure_i = V_i[nDim+1]; Pressure_j = V_j[nDim+1]; + Density_i = V_i[nDim+2]; Density_j = V_j[nDim+2]; + Enthalpy_i = V_i[nDim+3]; Enthalpy_j = V_j[nDim+3]; + SoundSpeed_i = V_i[nDim+4]; SoundSpeed_j = V_j[nDim+4]; + Energy_i = Enthalpy_i - Pressure_i/Density_i; Energy_j = Enthalpy_j - Pressure_j/Density_j; + + sq_vel_i = 0.0; sq_vel_j = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + Velocity_i[iDim] = V_i[iDim+1]; + Velocity_j[iDim] = V_j[iDim+1]; + sq_vel_i += 0.5*Velocity_i[iDim]*Velocity_i[iDim]; + sq_vel_j += 0.5*Velocity_j[iDim]*Velocity_j[iDim]; + } + + /*--- Recompute conservative variables ---*/ + + U_i[0] = Density_i; U_j[0] = Density_j; + for (iDim = 0; iDim < nDim; iDim++) { + U_i[iDim+1] = Density_i*Velocity_i[iDim]; U_j[iDim+1] = Density_j*Velocity_j[iDim]; + } + U_i[nDim+1] = Density_i*Energy_i; U_j[nDim+1] = Density_j*Energy_j; + + /*--- Compute mean values of the variables ---*/ + + MeanDensity = 0.5*(Density_i+Density_j); + MeanPressure = 0.5*(Pressure_i+Pressure_j); + MeanEnthalpy = 0.5*(Enthalpy_i+Enthalpy_j); + for (iDim = 0; iDim < nDim; iDim++) + MeanVelocity[iDim] = 0.5*(Velocity_i[iDim]+Velocity_j[iDim]); + MeanEnergy = 0.5*(Energy_i+Energy_j); + + /*--- Get projected flux tensor ---*/ + + GetInviscidProjFlux(&MeanDensity, MeanVelocity, &MeanPressure, &MeanEnthalpy, Normal, ProjFlux); + + /*--- Residual of the inviscid flux ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + val_residual[iVar] = ProjFlux[iVar]; + + /*--- Jacobians of the inviscid flux, scale = 0.5 because val_residual ~ 0.5*(fc_i+fc_j)*Normal ---*/ + + if (implicit) { + GetInviscidProjJac(MeanVelocity, &MeanEnergy, Normal, 0.5, val_Jacobian_i); + for (iVar = 0; iVar < nVar; iVar++) + for (jVar = 0; jVar < nVar; jVar++) + val_Jacobian_j[iVar][jVar] = val_Jacobian_i[iVar][jVar]; + } + + /*--- Adjustment due to grid motion ---*/ + + if (dynamic_grid) { + ProjGridVel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; + + for (iVar = 0; iVar < nVar; iVar++) { + val_residual[iVar] -= ProjGridVel * 0.5*(U_i[iVar] + U_j[iVar]); + if (implicit) { + val_Jacobian_i[iVar][iVar] -= 0.5*ProjGridVel; + val_Jacobian_j[iVar][iVar] -= 0.5*ProjGridVel; + } + } + } + + /*--- Compute the local spectral radius and the stretching factor ---*/ + + ProjVelocity_i = 0.0; ProjVelocity_j = 0.0; Area = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + ProjVelocity_i += Velocity_i[iDim]*Normal[iDim]; + ProjVelocity_j += Velocity_j[iDim]*Normal[iDim]; + Area += Normal[iDim]*Normal[iDim]; + } + Area = sqrt(Area); + + /*--- Adjustment due to mesh motion ---*/ + + if (dynamic_grid) { + ProjVelocity_i -= ProjGridVel; + ProjVelocity_j -= ProjGridVel; + } + + /*--- Dissipation term ---*/ + + Local_Lambda_i = (fabs(ProjVelocity_i)+SoundSpeed_i*Area); + Local_Lambda_j = (fabs(ProjVelocity_j)+SoundSpeed_j*Area); + MeanLambda = 0.5*(Local_Lambda_i+Local_Lambda_j); + + Phi_i = pow(Lambda_i/(4.0*MeanLambda), Param_p); + Phi_j = pow(Lambda_j/(4.0*MeanLambda), Param_p); + StretchingFactor = 4.0*Phi_i*Phi_j/(Phi_i+Phi_j); + + /*--- Compute differences btw. conservative variables, with a correction for enthalpy ---*/ + + for (iVar = 0; iVar < nVar-1; iVar++) { + Diff_U[iVar] = U_i[iVar]-U_j[iVar]; + } + Diff_U[nVar-1] = Density_i*Enthalpy_i-Density_j*Enthalpy_j; + + DissipationTerm(val_residual, val_Jacobian_i, val_Jacobian_j); + + if (preacc) { + AD::SetPreaccOut(val_residual, nVar); + AD::EndPreacc(); + } +} + +void CCentBase_Flow::ScalarDissipationJacobian(su2double **val_Jacobian_i, su2double **val_Jacobian_j) { + + /*--- n-1 diagonal entries ---*/ + + for (iVar = 0; iVar < (nVar-1); iVar++) { + val_Jacobian_i[iVar][iVar] += fix_factor*cte_0; + val_Jacobian_j[iVar][iVar] -= fix_factor*cte_1; + } + + /*--- Last row of Jacobian_i ---*/ + + val_Jacobian_i[nVar-1][0] += fix_factor*cte_0*Gamma_Minus_One*sq_vel_i; + for (iDim = 0; iDim < nDim; iDim++) + val_Jacobian_i[nVar-1][iDim+1] -= fix_factor*cte_0*Gamma_Minus_One*Velocity_i[iDim]; + val_Jacobian_i[nVar-1][nVar-1] += fix_factor*cte_0*Gamma; + + /*--- Last row of Jacobian_j ---*/ + + val_Jacobian_j[nVar-1][0] -= fix_factor*cte_1*Gamma_Minus_One*sq_vel_j; + for (iDim = 0; iDim < nDim; iDim++) + val_Jacobian_j[nVar-1][iDim+1] += fix_factor*cte_1*Gamma_Minus_One*Velocity_j[iDim]; + val_Jacobian_j[nVar-1][nVar-1] -= fix_factor*cte_1*Gamma; + +} diff --git a/SU2_CFD/src/numerics/flow/convection_centered/CCentJSTInc_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_centered/CCentJSTInc_Flow.cpp new file mode 100644 index 000000000000..e3489686ad66 --- /dev/null +++ b/SU2_CFD/src/numerics/flow/convection_centered/CCentJSTInc_Flow.cpp @@ -0,0 +1,241 @@ +/*! + * \file CCentJSTInc_Flow.cpp + * \brief Implementation of numerics class CCentJSTInc_Flow. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../../include/numerics/flow/convection_centered/CCentJSTInc_Flow.hpp" + +CCentJSTInc_Flow::CCentJSTInc_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + variable_density = (config->GetKind_DensityModel() == VARIABLE); + energy = config->GetEnergy_Equation(); + /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ + dynamic_grid = config->GetDynamic_Grid(); + + /*--- Artifical dissipation part ---*/ + + Param_p = 0.3; + Param_Kappa_2 = config->GetKappa_2nd_Flow(); + Param_Kappa_4 = config->GetKappa_4th_Flow(); + + /*--- Allocate some structures ---*/ + + Diff_V = new su2double [nVar]; + Diff_Lapl = new su2double [nVar]; + Velocity_i = new su2double [nDim]; + Velocity_j = new su2double [nDim]; + MeanVelocity = new su2double [nDim]; + ProjFlux = new su2double [nVar]; + Precon = new su2double*[nVar]; + + for (iVar = 0; iVar < nVar; iVar++) + Precon[iVar] = new su2double[nVar]; + +} + +CCentJSTInc_Flow::~CCentJSTInc_Flow(void) { + + delete [] Diff_V; + delete [] Diff_Lapl; + delete [] Velocity_i; + delete [] Velocity_j; + delete [] MeanVelocity; + delete [] ProjFlux; + + for (iVar = 0; iVar < nVar; iVar++) + delete [] Precon[iVar]; + delete [] Precon; + +} + +void CCentJSTInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { + + su2double U_i[5] = {0.0,0.0,0.0,0.0,0.0}, U_j[5] = {0.0,0.0,0.0,0.0,0.0}; + su2double ProjGridVel = 0.0; + + /*--- Primitive variables at point i and j ---*/ + + Pressure_i = V_i[0]; Pressure_j = V_j[0]; + Temperature_i = V_i[nDim+1]; Temperature_j = V_j[nDim+1]; + DensityInc_i = V_i[nDim+2]; DensityInc_j = V_j[nDim+2]; + BetaInc2_i = V_i[nDim+3]; BetaInc2_j = V_j[nDim+3]; + Cp_i = V_i[nDim+7]; Cp_j = V_j[nDim+7]; + Enthalpy_i = Cp_i*Temperature_i; Enthalpy_j = Cp_j*Temperature_j; + + Area = 0.0; + sq_vel_i = 0.0; sq_vel_j = 0.0; ProjVelocity_i = 0.0; ProjVelocity_j = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + Velocity_i[iDim] = V_i[iDim+1]; + Velocity_j[iDim] = V_j[iDim+1]; + MeanVelocity[iDim] = 0.5*(Velocity_i[iDim]+Velocity_j[iDim]); + sq_vel_i += 0.5*Velocity_i[iDim]*Velocity_i[iDim]; + sq_vel_j += 0.5*Velocity_j[iDim]*Velocity_j[iDim]; + ProjVelocity_i += Velocity_i[iDim]*Normal[iDim]; + ProjVelocity_j += Velocity_j[iDim]*Normal[iDim]; + Area += Normal[iDim]*Normal[iDim]; + } + Area = sqrt(Area); + + /*--- Compute mean values of the variables ---*/ + + MeanDensity = 0.5*(DensityInc_i + DensityInc_j); + MeanPressure = 0.5*(Pressure_i + Pressure_j); + MeanBetaInc2 = 0.5*(BetaInc2_i + BetaInc2_j); + MeanEnthalpy = 0.5*(Enthalpy_i + Enthalpy_j); + MeanCp = 0.5*(Cp_i + Cp_j); + MeanTemperature = 0.5*(Temperature_i + Temperature_j); + + /*--- We need the derivative of the equation of state to build the + preconditioning matrix. For now, the only option is the ideal gas + law, but in the future, dRhodT should be in the fluid model. ---*/ + + MeandRhodT = 0.0; + if (variable_density) { + MeandRhodT = -MeanDensity/MeanTemperature; + } + + /*--- Get projected flux tensor ---*/ + + GetInviscidIncProjFlux(&MeanDensity, MeanVelocity, &MeanPressure, &MeanBetaInc2, &MeanEnthalpy, Normal, ProjFlux); + + for (iVar = 0; iVar < nVar; iVar++) { + val_residual[iVar] = ProjFlux[iVar]; + } + + /*--- Jacobians of the inviscid flux ---*/ + + if (implicit) { + GetInviscidIncProjJac(&MeanDensity, MeanVelocity, &MeanBetaInc2, &MeanCp, &MeanTemperature, &MeandRhodT, Normal, 0.5, val_Jacobian_i); + for (iVar = 0; iVar < nVar; iVar++) { + for (jVar = 0; jVar < nVar; jVar++) { + val_Jacobian_j[iVar][jVar] = val_Jacobian_i[iVar][jVar]; + } + } + } + + /*--- Corrections due to grid motion ---*/ + if (dynamic_grid) { + + /*--- Recompute conservative variables ---*/ + + U_i[0] = DensityInc_i; U_j[0] = DensityInc_j; + for (iDim = 0; iDim < nDim; iDim++) { + U_i[iDim+1] = DensityInc_i*Velocity_i[iDim]; U_j[iDim+1] = DensityInc_j*Velocity_j[iDim]; + } + U_i[nDim+1] = DensityInc_i*Enthalpy_i; U_j[nDim+1] = DensityInc_j*Enthalpy_j; + + su2double ProjVelocity = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + ProjVelocity += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; + + /*--- Residual contributions ---*/ + for (iVar = 0; iVar < nVar; iVar++) { + val_residual[iVar] -= ProjVelocity * 0.5*(U_i[iVar]+U_j[iVar]); + + /*--- Jacobian contributions ---*/ + /*--- Implicit terms ---*/ + if (implicit) { + for (iDim = 0; iDim < nDim; iDim++){ + val_Jacobian_i[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_i; + val_Jacobian_j[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_j; + } + val_Jacobian_i[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_i*Cp_i; + val_Jacobian_j[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_j*Cp_j; + } + } + } + + /*--- Computes differences between Laplacians and conservative variables ---*/ + + for (iVar = 0; iVar < nVar; iVar++) { + Diff_Lapl[iVar] = Und_Lapl_i[iVar]-Und_Lapl_j[iVar]; + Diff_V[iVar] = V_i[iVar]-V_j[iVar]; + } + + /*--- Build the preconditioning matrix using mean values ---*/ + + GetPreconditioner(&MeanDensity, MeanVelocity, &MeanBetaInc2, &MeanCp, &MeanTemperature, &MeandRhodT, Precon); + + /*--- Compute the local spectral radius of the preconditioned system + and the stretching factor. ---*/ + + /*--- Projected velocity adjustment due to mesh motion ---*/ + + if (dynamic_grid) { + ProjGridVel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; + } + ProjVelocity_i -= ProjGridVel; + ProjVelocity_j -= ProjGridVel; + } + + SoundSpeed_i = sqrt(BetaInc2_i*Area*Area); + SoundSpeed_j = sqrt(BetaInc2_j*Area*Area); + + Local_Lambda_i = fabs(ProjVelocity_i)+SoundSpeed_i; + Local_Lambda_j = fabs(ProjVelocity_j)+SoundSpeed_j; + + MeanLambda = 0.5*(Local_Lambda_i+Local_Lambda_j); + + Phi_i = pow(Lambda_i/(4.0*MeanLambda), Param_p); + Phi_j = pow(Lambda_j/(4.0*MeanLambda), Param_p); + + StretchingFactor = 4.0*Phi_i*Phi_j/(Phi_i+Phi_j); + + sc2 = 3.0*(su2double(Neighbor_i)+su2double(Neighbor_j))/(su2double(Neighbor_i)*su2double(Neighbor_j)); + sc4 = sc2*sc2/4.0; + + Epsilon_2 = Param_Kappa_2*0.5*(Sensor_i+Sensor_j)*sc2; + Epsilon_4 = max(0.0, Param_Kappa_4-Epsilon_2)*sc4; + + /*--- Compute viscous part of the residual ---*/ + + for (iVar = 0; iVar < nVar; iVar++) { + for (jVar = 0; jVar < nVar; jVar++) { + val_residual[iVar] += Precon[iVar][jVar]*(Epsilon_2*Diff_V[jVar] - Epsilon_4*Diff_Lapl[jVar])*StretchingFactor*MeanLambda; + if (implicit) { + val_Jacobian_i[iVar][jVar] += Precon[iVar][jVar]*(Epsilon_2 + Epsilon_4*su2double(Neighbor_i+1))*StretchingFactor*MeanLambda; + val_Jacobian_j[iVar][jVar] -= Precon[iVar][jVar]*(Epsilon_2 + Epsilon_4*su2double(Neighbor_j+1))*StretchingFactor*MeanLambda; + } + } + } + + /*--- Remove energy contributions if not solving the energy equation. ---*/ + + if (!energy) { + val_residual[nDim+1] = 0.0; + if (implicit) { + for (iVar = 0; iVar < nVar; iVar++) { + val_Jacobian_i[iVar][nDim+1] = 0.0; + val_Jacobian_j[iVar][nDim+1] = 0.0; + + val_Jacobian_i[nDim+1][iVar] = 0.0; + val_Jacobian_j[nDim+1][iVar] = 0.0; + } + } + } +} diff --git a/SU2_CFD/src/numerics/flow/convection_centered/CCentJST_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_centered/CCentJST_Flow.cpp new file mode 100644 index 000000000000..964e1a319fa3 --- /dev/null +++ b/SU2_CFD/src/numerics/flow/convection_centered/CCentJST_Flow.cpp @@ -0,0 +1,81 @@ +/*! + * \file CCentJST_Flow.cpp + * \brief Implementation of numerics class CCentJST_Flow. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../../include/numerics/flow/convection_centered/CCentJST_Flow.hpp" + +CCentJST_Flow::CCentJST_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : + CCentBase_Flow(val_nDim, val_nVar, config) { + + /*--- Artifical dissipation parameters ---*/ + Param_p = 0.3; + Param_Kappa_2 = config->GetKappa_2nd_Flow(); + Param_Kappa_4 = config->GetKappa_4th_Flow(); + +} + +CCentJST_Flow::~CCentJST_Flow(void) { + +} + +void CCentJST_Flow::DissipationTerm(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j) { + + /*--- Compute differences btw. Laplacians ---*/ + + for (iVar = 0; iVar < nVar; iVar++) { + Diff_Lapl[iVar] = Und_Lapl_i[iVar]-Und_Lapl_j[iVar]; + } + + /*--- Compute dissipation coefficients ---*/ + + sc2 = 3.0*(su2double(Neighbor_i)+su2double(Neighbor_j))/(su2double(Neighbor_i)*su2double(Neighbor_j)); + sc4 = sc2*sc2/4.0; + + Epsilon_2 = Param_Kappa_2*0.5*(Sensor_i+Sensor_j)*sc2; + Epsilon_4 = max(0.0, Param_Kappa_4-Epsilon_2)*sc4; + + /*--- Compute viscous part of the residual ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + val_residual[iVar] += (Epsilon_2*Diff_U[iVar] - Epsilon_4*Diff_Lapl[iVar])*StretchingFactor*MeanLambda; + + /*--- Jacobian computation ---*/ + + if (implicit) { + + cte_0 = (Epsilon_2 + Epsilon_4*su2double(Neighbor_i+1))*StretchingFactor*MeanLambda; + cte_1 = (Epsilon_2 + Epsilon_4*su2double(Neighbor_j+1))*StretchingFactor*MeanLambda; + + ScalarDissipationJacobian(val_Jacobian_i, val_Jacobian_j); + } +} + +bool CCentJST_Flow::SetPreaccInVars(void) { + AD::StartPreacc(); + AD::SetPreaccIn(Sensor_i); AD::SetPreaccIn(Und_Lapl_i, nVar); + AD::SetPreaccIn(Sensor_j); AD::SetPreaccIn(Und_Lapl_j, nVar); + return true; +} diff --git a/SU2_CFD/src/numerics/flow/convection_centered/CCentJST_KE_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_centered/CCentJST_KE_Flow.cpp new file mode 100644 index 000000000000..745169b95f33 --- /dev/null +++ b/SU2_CFD/src/numerics/flow/convection_centered/CCentJST_KE_Flow.cpp @@ -0,0 +1,70 @@ +/*! + * \file CCentJST_KE_Flow.cpp + * \brief Implementation of numerics class CCentJST_KE_Flow. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../../include/numerics/flow/convection_centered/CCentJST_KE_Flow.hpp" + +CCentJST_KE_Flow::CCentJST_KE_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : + CCentBase_Flow(val_nDim, val_nVar, config) { + + /*--- Artifical dissipation parameters ---*/ + Param_p = 0.3; + Param_Kappa_2 = config->GetKappa_2nd_Flow(); + +} + +CCentJST_KE_Flow::~CCentJST_KE_Flow(void) { + +} + +void CCentJST_KE_Flow::DissipationTerm(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j) { + + /*--- Compute dissipation coefficient ---*/ + + sc2 = 3.0*(su2double(Neighbor_i)+su2double(Neighbor_j))/(su2double(Neighbor_i)*su2double(Neighbor_j)); + Epsilon_2 = Param_Kappa_2*0.5*(Sensor_i+Sensor_j)*sc2; + + /*--- Compute viscous part of the residual ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + val_residual[iVar] += Epsilon_2*(Diff_U[iVar])*StretchingFactor*MeanLambda; + + /*--- Jacobian computation ---*/ + + if (implicit) { + + cte_0 = Epsilon_2*StretchingFactor*MeanLambda; + cte_1 = cte_0; + + ScalarDissipationJacobian(val_Jacobian_i, val_Jacobian_j); + } +} + +bool CCentJST_KE_Flow::SetPreaccInVars(void) { + AD::StartPreacc(); + AD::SetPreaccIn(Sensor_i); AD::SetPreaccIn(Sensor_j); + return true; +} diff --git a/SU2_CFD/src/numerics/flow/convection_centered/CCentLaxInc_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_centered/CCentLaxInc_Flow.cpp new file mode 100644 index 000000000000..b8e38dbd553d --- /dev/null +++ b/SU2_CFD/src/numerics/flow/convection_centered/CCentLaxInc_Flow.cpp @@ -0,0 +1,234 @@ +/*! + * \file CCentLaxInc_Flow.cpp + * \brief Implementation of numerics class CCentLaxInc_Flow. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../../include/numerics/flow/convection_centered/CCentLaxInc_Flow.hpp" + +CCentLaxInc_Flow::CCentLaxInc_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + variable_density = (config->GetKind_DensityModel() == VARIABLE); + /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ + dynamic_grid = config->GetDynamic_Grid(); + energy = config->GetEnergy_Equation(); + + /*--- Artificial dissipation part ---*/ + + Param_p = 0.3; + Param_Kappa_0 = config->GetKappa_1st_Flow(); + + /*--- Allocate some structures ---*/ + + Diff_V = new su2double[nVar]; + Velocity_i = new su2double[nDim]; + Velocity_j = new su2double[nDim]; + MeanVelocity = new su2double[nDim]; + ProjFlux = new su2double[nVar]; + Precon = new su2double*[nVar]; + + for (iVar = 0; iVar < nVar; iVar++) + Precon[iVar] = new su2double[nVar]; + +} + +CCentLaxInc_Flow::~CCentLaxInc_Flow(void) { + + delete [] Diff_V; + delete [] Velocity_i; + delete [] Velocity_j; + delete [] MeanVelocity; + delete [] ProjFlux; + + for (iVar = 0; iVar < nVar; iVar++) + delete [] Precon[iVar]; + delete [] Precon; + +} + +void CCentLaxInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { + + su2double U_i[5] = {0.0,0.0,0.0,0.0,0.0}, U_j[5] = {0.0,0.0,0.0,0.0,0.0}; + su2double ProjGridVel = 0.0, ProjVelocity = 0.0; + + /*--- Primitive variables at point i and j ---*/ + + Pressure_i = V_i[0]; Pressure_j = V_j[0]; + Temperature_i = V_i[nDim+1]; Temperature_j = V_j[nDim+1]; + DensityInc_i = V_i[nDim+2]; DensityInc_j = V_j[nDim+2]; + BetaInc2_i = V_i[nDim+3]; BetaInc2_j = V_j[nDim+3]; + Cp_i = V_i[nDim+7]; Cp_j = V_j[nDim+7]; + Enthalpy_i = Cp_i*Temperature_i; Enthalpy_j = Cp_j*Temperature_j; + + Area = 0.0; + sq_vel_i = 0.0; sq_vel_j = 0.0; ProjVelocity_i = 0.0; ProjVelocity_j = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + Velocity_i[iDim] = V_i[iDim+1]; + Velocity_j[iDim] = V_j[iDim+1]; + MeanVelocity[iDim] = 0.5*(Velocity_i[iDim]+Velocity_j[iDim]); + sq_vel_i += 0.5*Velocity_i[iDim]*Velocity_i[iDim]; + sq_vel_j += 0.5*Velocity_j[iDim]*Velocity_j[iDim]; + ProjVelocity_i += Velocity_i[iDim]*Normal[iDim]; + ProjVelocity_j += Velocity_j[iDim]*Normal[iDim]; + Area += Normal[iDim]*Normal[iDim]; + } + Area = sqrt(Area); + + /*--- Compute mean values of the variables ---*/ + + MeanDensity = 0.5*(DensityInc_i + DensityInc_j); + MeanPressure = 0.5*(Pressure_i + Pressure_j); + MeanBetaInc2 = 0.5*(BetaInc2_i + BetaInc2_j); + MeanEnthalpy = 0.5*(Enthalpy_i + Enthalpy_j); + MeanCp = 0.5*(Cp_i + Cp_j); + MeanTemperature = 0.5*(Temperature_i + Temperature_j); + + /*--- We need the derivative of the equation of state to build the + preconditioning matrix. For now, the only option is the ideal gas + law, but in the future, dRhodT should be in the fluid model. ---*/ + + MeandRhodT = 0.0; + if (variable_density) { + MeandRhodT = -MeanDensity/MeanTemperature; + } + + /*--- Get projected flux tensor ---*/ + + GetInviscidIncProjFlux(&MeanDensity, MeanVelocity, &MeanPressure, &MeanBetaInc2, &MeanEnthalpy, Normal, ProjFlux); + + /*--- Compute inviscid residual ---*/ + + for (iVar = 0; iVar < nVar; iVar++) { + val_residual[iVar] = ProjFlux[iVar]; + } + + /*--- Jacobians of the inviscid flux ---*/ + + if (implicit) { + GetInviscidIncProjJac(&MeanDensity, MeanVelocity, &MeanBetaInc2, &MeanCp, &MeanTemperature, &MeandRhodT, Normal, 0.5, val_Jacobian_i); + for (iVar = 0; iVar < nVar; iVar++) { + for (jVar = 0; jVar < nVar; jVar++) { + val_Jacobian_j[iVar][jVar] = val_Jacobian_i[iVar][jVar]; + } + } + } + + /*--- Corrections due to grid motion ---*/ + if (dynamic_grid) { + + /*--- Recompute conservative variables ---*/ + + U_i[0] = DensityInc_i; U_j[0] = DensityInc_j; + for (iDim = 0; iDim < nDim; iDim++) { + U_i[iDim+1] = DensityInc_i*Velocity_i[iDim]; U_j[iDim+1] = DensityInc_j*Velocity_j[iDim]; + } + U_i[nDim+1] = DensityInc_i*Enthalpy_i; U_j[nDim+1] = DensityInc_j*Enthalpy_j; + + for (iDim = 0; iDim < nDim; iDim++) + ProjVelocity += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; + + /*--- Residual contributions ---*/ + for (iVar = 0; iVar < nVar; iVar++) { + val_residual[iVar] -= ProjVelocity * 0.5*(U_i[iVar]+U_j[iVar]); + + /*--- Jacobian contributions ---*/ + /*--- Implicit terms ---*/ + if (implicit) { + for (iDim = 0; iDim < nDim; iDim++){ + val_Jacobian_i[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_i; + val_Jacobian_j[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_j; + } + val_Jacobian_i[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_i*Cp_i; + val_Jacobian_j[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_j*Cp_j; + } + } + } + + /*--- Computes differences btw. conservative variables ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + Diff_V[iVar] = V_i[iVar]-V_j[iVar]; + + /*--- Build the preconditioning matrix using mean values ---*/ + + GetPreconditioner(&MeanDensity, MeanVelocity, &MeanBetaInc2, &MeanCp, &MeanTemperature, &MeandRhodT, Precon); + + /*--- Compute the local espectral radius of the preconditioned system + and the stretching factor. ---*/ + + SoundSpeed_i = sqrt(BetaInc2_i*Area*Area); + SoundSpeed_j = sqrt(BetaInc2_j*Area*Area); + + /*--- Projected velocity adjustment due to mesh motion ---*/ + + if (dynamic_grid) { + ProjGridVel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; + } + ProjVelocity_i -= ProjGridVel; + ProjVelocity_j -= ProjGridVel; + } + + Local_Lambda_i = fabs(ProjVelocity_i)+SoundSpeed_i; + Local_Lambda_j = fabs(ProjVelocity_j)+SoundSpeed_j; + + MeanLambda = 0.5*(Local_Lambda_i+Local_Lambda_j); + + Phi_i = pow(Lambda_i/(4.0*MeanLambda), Param_p); + Phi_j = pow(Lambda_j/(4.0*MeanLambda), Param_p); + + StretchingFactor = 4.0*Phi_i*Phi_j/(Phi_i+Phi_j); + + sc0 = 3.0*(su2double(Neighbor_i)+su2double(Neighbor_j))/(su2double(Neighbor_i)*su2double(Neighbor_j)); + Epsilon_0 = Param_Kappa_0*sc0*su2double(nDim)/3.0; + + /*--- Compute viscous part of the residual ---*/ + + for (iVar = 0; iVar < nVar; iVar++) { + for (jVar = 0; jVar < nVar; jVar++) { + val_residual[iVar] += Precon[iVar][jVar]*Epsilon_0*Diff_V[jVar]*StretchingFactor*MeanLambda; + if (implicit) { + val_Jacobian_i[iVar][jVar] += Precon[iVar][jVar]*Epsilon_0*StretchingFactor*MeanLambda; + val_Jacobian_j[iVar][jVar] -= Precon[iVar][jVar]*Epsilon_0*StretchingFactor*MeanLambda; + } + } + } + + /*--- Remove energy contributions if we aren't solving the energy equation. ---*/ + + if (!energy) { + val_residual[nDim+1] = 0.0; + if (implicit) { + for (iVar = 0; iVar < nVar; iVar++) { + val_Jacobian_i[iVar][nDim+1] = 0.0; + val_Jacobian_j[iVar][nDim+1] = 0.0; + + val_Jacobian_i[nDim+1][iVar] = 0.0; + val_Jacobian_j[nDim+1][iVar] = 0.0; + } + } + } +} diff --git a/SU2_CFD/src/numerics/flow/convection_centered/CCentLax_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_centered/CCentLax_Flow.cpp new file mode 100644 index 000000000000..e621392a0bab --- /dev/null +++ b/SU2_CFD/src/numerics/flow/convection_centered/CCentLax_Flow.cpp @@ -0,0 +1,69 @@ +/*! + * \file CCentLax_Flow.cpp + * \brief Implementation of numerics class CCentLax_Flow. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../../include/numerics/flow/convection_centered/CCentLax_Flow.hpp" + +CCentLax_Flow::CCentLax_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : + CCentBase_Flow(val_nDim, val_nVar, config) { + + /*--- Artifical dissipation parameters ---*/ + Param_p = 0.3; + Param_Kappa_0 = config->GetKappa_1st_Flow(); + +} + +CCentLax_Flow::~CCentLax_Flow(void) { + +} + +void CCentLax_Flow::DissipationTerm(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j) { + + /*--- Compute dissipation coefficient ---*/ + + sc0 = 3.0*(su2double(Neighbor_i)+su2double(Neighbor_j))/(su2double(Neighbor_i)*su2double(Neighbor_j)); + Epsilon_0 = Param_Kappa_0*sc0*su2double(nDim)/3.0; + + /*--- Compute viscous part of the residual ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + val_residual[iVar] += Epsilon_0*Diff_U[iVar]*StretchingFactor*MeanLambda; + + /*--- Jacobian computation ---*/ + + if (implicit) { + + cte_0 = Epsilon_0*StretchingFactor*MeanLambda; + cte_1 = cte_0; + + ScalarDissipationJacobian(val_Jacobian_i, val_Jacobian_j); + } +} + +bool CCentLax_Flow::SetPreaccInVars(void) { + AD::StartPreacc(); + return true; +} diff --git a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwAUSMPLUSUP2_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwAUSMPLUSUP2_Flow.cpp new file mode 100644 index 000000000000..ab97186e2f87 --- /dev/null +++ b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwAUSMPLUSUP2_Flow.cpp @@ -0,0 +1,120 @@ +/*! + * \file CUpwAUSMPLUSUP2_Flow.cpp + * \brief Implementation of numerics class CUpwAUSMPLUSUP2_Flow. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../../include/numerics/flow/convection_upwind/CUpwAUSMPLUSUP2_Flow.hpp" + +CUpwAUSMPLUSUP2_Flow::CUpwAUSMPLUSUP2_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : + CUpwAUSMPLUS_SLAU_Base_Flow(val_nDim, val_nVar, config) { + + 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) { + +} + +void CUpwAUSMPLUSUP2_Flow::ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure) { + + /*--- Projected velocities and squared magnitude ---*/ + + su2double ProjVelocity_i = 0.0, ProjVelocity_j = 0.0, sq_vel = 0.0; + + for (unsigned short iDim = 0; iDim < nDim; iDim++) { + ProjVelocity_i += Velocity_i[iDim]*UnitNormal[iDim]; + ProjVelocity_j += Velocity_j[iDim]*UnitNormal[iDim]; + + sq_vel += 0.5*(Velocity_i[iDim]*Velocity_i[iDim] + Velocity_j[iDim]*Velocity_j[iDim]); + } + + /*--- Compute interface speed of sound (aF) ---*/ + + su2double astarL = sqrt(2.0*(Gamma-1.0)/(Gamma+1.0)*Enthalpy_i); + su2double astarR = sqrt(2.0*(Gamma-1.0)/(Gamma+1.0)*Enthalpy_j); + + su2double ahatL = astarL*astarL/max(astarL, ProjVelocity_i); + su2double ahatR = astarR*astarR/max(astarR,-ProjVelocity_j); + + su2double aF = min(ahatL,ahatR); + + /*--- Left and right pressure functions and Mach numbers ---*/ + + su2double mLP, pLP, mRM, pRM; + + su2double mL = ProjVelocity_i/aF; + su2double mR = ProjVelocity_j/aF; + + su2double MFsq = 0.5*(mL*mL+mR*mR); + su2double param1 = max(MFsq, Minf*Minf); + su2double Mrefsq = min(1.0, param1); + + su2double fa = 2.0*sqrt(Mrefsq)-Mrefsq; + + su2double alpha = 3.0/16.0*(-4.0+5.0*fa*fa); + su2double beta = 1.0/8.0; + + if (fabs(mL) <= 1.0) { + su2double p1 = 0.25*(mL+1.0)*(mL+1.0); + su2double p2 = (mL*mL-1.0)*(mL*mL-1.0); + + mLP = p1 + beta*p2; + pLP = p1*(2.0-mL) + alpha*mL*p2; + } + else { + mLP = 0.5*(mL+fabs(mL)); + pLP = mLP/mL; + } + + if (fabs(mR) <= 1.0) { + su2double p1 = 0.25*(mR-1.0)*(mR-1.0); + su2double p2 = (mR*mR-1.0)*(mR*mR-1.0); + + mRM = -p1 - beta*p2; + pRM = p1*(2.0+mR) - alpha*mR*p2; + } + else { + mRM = 0.5*(mR-fabs(mR)); + pRM = mRM/mR; + } + + /*--- Mass flux with pressure diffusion term ---*/ + + su2double rhoF = 0.5*(Density_i+Density_j); + su2double Mp = -(Kp/fa)*max((1.0-sigma*MFsq),0.0)*(Pressure_j-Pressure_i)/(rhoF*aF*aF); + + su2double mF = mLP + mRM + Mp; + mdot = aF * (max(mF,0.0)*Density_i + min(mF,0.0)*Density_j); + + /*--- Modified pressure flux ---*/ + + pressure = 0.5*(Pressure_j+Pressure_i) + 0.5*(pLP-pRM)*(Pressure_i-Pressure_j) + sqrt(sq_vel)*(pLP+pRM-1.0)*rhoF*aF; + +} diff --git a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwAUSMPLUSUP_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwAUSMPLUSUP_Flow.cpp new file mode 100644 index 000000000000..35c0c77656c5 --- /dev/null +++ b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwAUSMPLUSUP_Flow.cpp @@ -0,0 +1,258 @@ +/*! + * \file CUpwAUSMPLUSUP_Flow.cpp + * \brief Implementation of numerics class CUpwAUSMPLUSUP_Flow. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../../include/numerics/flow/convection_upwind/CUpwAUSMPLUSUP_Flow.hpp" + +CUpwAUSMPLUSUP_Flow::CUpwAUSMPLUSUP_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : + CUpwAUSMPLUS_SLAU_Base_Flow(val_nDim, val_nVar, config) { + + HasAnalyticalDerivatives = true; + Minf = config->GetMach(); + 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) { + +} + +void CUpwAUSMPLUSUP_Flow::ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure) { + + /*--- Projected velocities ---*/ + + su2double ProjVelocity_i = 0.0, ProjVelocity_j = 0.0; + + for (unsigned short iDim = 0; iDim < nDim; iDim++) { + ProjVelocity_i += Velocity_i[iDim]*UnitNormal[iDim]; + ProjVelocity_j += Velocity_j[iDim]*UnitNormal[iDim]; + } + + /*--- Compute interface speed of sound (aF) ---*/ + + su2double astarL = sqrt(2.0*(Gamma-1.0)/(Gamma+1.0)*Enthalpy_i); + su2double astarR = sqrt(2.0*(Gamma-1.0)/(Gamma+1.0)*Enthalpy_j); + + su2double ahatL = astarL*astarL/max(astarL, ProjVelocity_i); + su2double ahatR = astarR*astarR/max(astarR,-ProjVelocity_j); + + su2double aF = min(ahatL,ahatR); + + /*--- Left and right pressures and Mach numbers ---*/ + + su2double mLP, betaLP, mRM, betaRM; + + su2double mL = ProjVelocity_i/aF; + su2double mR = ProjVelocity_j/aF; + + su2double MFsq = 0.5*(mL*mL+mR*mR); + su2double param1 = max(MFsq, Minf*Minf); + su2double Mrefsq = min(1.0, param1); + + su2double fa = 2.0*sqrt(Mrefsq)-Mrefsq; + + su2double alpha = 3.0/16.0*(-4.0+5.0*fa*fa); + su2double beta = 1.0/8.0; + + if (fabs(mL) <= 1.0) { + su2double p1 = 0.25*(mL+1.0)*(mL+1.0); + su2double p2 = (mL*mL-1.0)*(mL*mL-1.0); + + mLP = p1 + beta*p2; + betaLP = p1*(2.0-mL) + alpha*mL*p2; + } + else { + mLP = 0.5*(mL+fabs(mL)); + betaLP = mLP/mL; + } + + if (fabs(mR) <= 1.0) { + su2double p1 = 0.25*(mR-1.0)*(mR-1.0); + su2double p2 = (mR*mR-1.0)*(mR*mR-1.0); + + mRM = -p1 - beta*p2; + betaRM = p1*(2.0+mR) - alpha*mR*p2; + } + else { + mRM = 0.5*(mR-fabs(mR)); + betaRM = mRM/mR; + } + + /*--- Pressure and velocity diffusion terms ---*/ + + su2double rhoF = 0.5*(Density_i+Density_j); + su2double Mp = -(Kp/fa)*max((1.0-sigma*MFsq),0.0)*(Pressure_j-Pressure_i)/(rhoF*aF*aF); + + su2double Pu = -Ku*fa*betaLP*betaRM*2.0*rhoF*aF*(ProjVelocity_j-ProjVelocity_i); + + /*--- Finally the fluxes ---*/ + + su2double mF = mLP + mRM + Mp; + mdot = aF * (max(mF,0.0)*Density_i + min(mF,0.0)*Density_j); + + pressure = betaLP*Pressure_i + betaRM*Pressure_j + Pu; + + if (!implicit || !UseAccurateJacobian) return; + + /*--- Analytical differentiation of the face mass flux and + pressure (in reverse mode, "?_b" denotes dmot_d?). ---*/ + + /*--- limited mean Mach number (used in division...) ---*/ + su2double MF = max(numeric_limits::epsilon(),sqrt(MFsq)); + + for (int outVar=0; outVar<2; ++outVar) { + + su2double aF_b = 0.0, mF_b = 0.0, MF_b = 0.0, rhoF_b = 0.0, fa_b = 0.0, alpha_b = 0.0, + rho_i_b = 0.0, rho_j_b = 0.0, p_i_b = 0.0, p_j_b = 0.0, Vn_i_b = 0.0, Vn_j_b = 0.0, + mR_b = 0.0, mL_b = 0.0, betaLP_b = 0.0, betaRM_b = 0.0, tmp = 0.0; + + if (outVar==0) { + /*--- mdot = ... ---*/ + if (mF > 0.0) { + aF_b += mF*Density_i; + mF_b += aF*Density_i; + rho_i_b += mF*aF; + } + else { + aF_b += mF*Density_j; + mF_b += aF*Density_j; + rho_j_b += mF*aF; + } + + /*--- Mp = ... ---*/ + if (sigma*MFsq < 1.0) { + rhoF_b -= Mp/rhoF * mF_b; + fa_b -= Mp/fa * mF_b; + aF_b -= 2.0*Mp/aF * mF_b; + MF_b += 2.0*sigma*MF*(Kp/fa)*(Pressure_j-Pressure_i)/(rhoF*aF*aF) * mF_b; + tmp = -(Kp/fa)*(1.0-sigma*MFsq)/(rhoF*aF*aF); + p_i_b -= tmp * mF_b; + p_j_b += tmp * mF_b; + } + + /*--- rhoF = ... ---*/ + rho_i_b += 0.5*rhoF_b; rho_j_b += 0.5*rhoF_b; + + /*--- mRM = ... ---*/ + if (fabs(mR) < 1.0) mR_b += (1.0-mR)*(0.5+4.0*beta*mR*(mR+1.0)) * mF_b; + else if (mR <=-1.0) mR_b += mF_b; + + /*--- mLP = ... ---*/ + if (fabs(mL) < 1.0) mL_b += (1.0+mL)*(0.5+4.0*beta*mL*(mL-1.0)) * mF_b; + else if (mL >= 1.0) mL_b += mF_b; + } + else { + /*--- pressure = ... ---*/ + p_i_b += betaLP; betaLP_b += Pressure_i; + p_j_b += betaRM; betaRM_b += Pressure_j; + + /*--- Pu = ... ---*/ + rhoF_b += Pu/rhoF; + fa_b += Pu/fa; + aF_b += Pu/aF; + tmp = -Ku*fa*2.0*rhoF*aF*(ProjVelocity_j-ProjVelocity_i); + betaLP_b += tmp*betaRM; + betaRM_b += tmp*betaLP; + tmp = -Ku*fa*betaLP*betaRM*2.0*rhoF*aF; + Vn_i_b -= tmp; + Vn_j_b += tmp; + + /*--- rhoF = ... ---*/ + rho_i_b += 0.5*rhoF_b; rho_j_b += 0.5*rhoF_b; + + /*--- betaRM = ... ---*/ + if (fabs(mR) < 1.0) { + tmp = mR*mR-1.0; + mR_b += tmp*(0.75-alpha*(5.0*tmp+4.0)) * betaRM_b; + alpha_b -= mR*tmp*tmp * betaRM_b; + } + + /*--- betaLP = ... ---*/ + if (fabs(mL) < 1.0) { + tmp = mL*mL-1.0; + mL_b -= tmp*(0.75-alpha*(5.0*tmp+4.0)) * betaLP_b; + alpha_b += mL*tmp*tmp * betaLP_b; + } + + /*--- alpha = ... ---*/ + fa_b += 1.875*fa * alpha_b; + } + + /*--- steps shared by both ---*/ + /*--- fa = ... ---*/ + su2double Mref_b = 2.0*(1.0-sqrt(Mrefsq)) * fa_b; + + /*--- Mrefsq = ... ---*/ + if (MF < 1.0 && MF > Minf) MF_b += Mref_b; + + /*--- MFsq = ... ---*/ + mL_b += 0.5*mL/MF * MF_b; mR_b += 0.5*mR/MF * MF_b; + + /*--- mL/R = ... ---*/ + Vn_i_b += mL_b/aF; Vn_j_b += mR_b/aF; + aF_b -= (mL*mL_b+mR*mR_b)/aF; + + /*--- aF,ahat,astar = f(H_i,H_j) ---*/ + su2double astar_b = aF_b, H_i_b, H_j_b; + + if (ahatL < ahatR) { + if (astarL <= ProjVelocity_i) { + tmp = astarL/ProjVelocity_i; + astar_b *= 2.0*tmp; + Vn_i_b -= tmp*tmp * aF_b; + } + H_i_b = sqrt(0.5*(Gamma-1.0)/((Gamma+1.0)*Enthalpy_i)) * astar_b; + H_j_b = 0.0; + } + else { + if (astarR <= -ProjVelocity_j) { + tmp = -astarR/ProjVelocity_j; + astar_b *= 2.0*tmp; + Vn_j_b += tmp*tmp * aF_b; + } + H_j_b = sqrt(0.5*(Gamma-1.0)/((Gamma+1.0)*Enthalpy_j)) * astar_b; + H_i_b = 0.0; + } + + /*--- store derivatives ---*/ + su2double *target_i = (outVar==0 ? dmdot_dVi : dpres_dVi), + *target_j = (outVar==0 ? dmdot_dVj : dpres_dVj); + target_i[5] = target_j[5] = 0.0; + + /*--- ProjVelocity = ... ---*/ + for (unsigned short iDim = 0; iDim < nDim; ++iDim) { + target_i[iDim] = UnitNormal[iDim] * Vn_i_b; + target_j[iDim] = UnitNormal[iDim] * Vn_j_b; + } + target_i[ nDim ] = p_i_b; target_j[ nDim ] = p_j_b; + target_i[nDim+1] = rho_i_b; target_j[nDim+1] = rho_j_b; + target_i[nDim+2] = H_i_b; target_j[nDim+2] = H_j_b; + } +} diff --git a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwAUSMPLUS_SLAU_Base_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwAUSMPLUS_SLAU_Base_Flow.cpp new file mode 100644 index 000000000000..c5b69c9454eb --- /dev/null +++ b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwAUSMPLUS_SLAU_Base_Flow.cpp @@ -0,0 +1,384 @@ +/*! + * \file CUpwAUSMPLUS_SLAU_Base_Flow.cpp + * \brief Implementation of numerics class CUpwAUSMPLUS_SLAU_Base_Flow. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../../include/numerics/flow/convection_upwind/CUpwAUSMPLUS_SLAU_Base_Flow.hpp" + +CUpwAUSMPLUS_SLAU_Base_Flow::CUpwAUSMPLUS_SLAU_Base_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : + CNumerics(val_nDim, val_nVar, config) { + + if (config->GetDynamic_Grid() && (SU2_MPI::GetRank() == MASTER_NODE)) + cout << "WARNING: Grid velocities are NOT yet considered in AUSM-type schemes." << endl; + + implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + UseAccurateJacobian = config->GetUse_Accurate_Jacobians(); + HasAnalyticalDerivatives = false; + FinDiffStep = 1e-4; + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + + Velocity_i = new su2double [nDim]; + Velocity_j = new su2double [nDim]; + psi_i = new su2double [nVar]; + psi_j = new su2double [nVar]; + + RoeVelocity = new su2double [nDim]; + Lambda = new su2double [nVar]; + Epsilon = new su2double [nVar]; + P_Tensor = new su2double* [nVar]; + invP_Tensor = new su2double* [nVar]; + for (unsigned short iVar = 0; iVar < nVar; iVar++) { + P_Tensor[iVar] = new su2double [nVar]; + invP_Tensor[iVar] = new su2double [nVar]; + } +} + +CUpwAUSMPLUS_SLAU_Base_Flow::~CUpwAUSMPLUS_SLAU_Base_Flow(void) { + + delete [] Velocity_i; + delete [] Velocity_j; + delete [] psi_i; + delete [] psi_j; + + delete [] RoeVelocity; + delete [] Lambda; + delete [] Epsilon; + for (unsigned short iVar = 0; iVar < nVar; iVar++) { + delete [] P_Tensor[iVar]; + delete [] invP_Tensor[iVar]; + } + delete [] P_Tensor; + delete [] invP_Tensor; + +} + +void CUpwAUSMPLUS_SLAU_Base_Flow::ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure) +{ + /*--- For schemes that fit in the general form of AUSM+up and SLAU schemes you can inherit from this class + and implement only the specifics, which should be the face mass flux (per unit area) and the face pressure. + For implicit solution methods this class can either approximate the flux Jacobians (using those of the Roe + scheme) or compute accurate ones. This is done either numerically, differentiating "mdot" and "pressure" + using 1st order finite differences, or analytically if you use this function to set the values of + "dmdot_dVi/j", "dpres_dVi/j" and set "HasAnalyticalDerivatives" to true in the ctor of the derived class. + For accurate numerical differentiation "mdot" and "pressure" can be functions of, at most, the velocities, + pressures, densities, and enthalpies at nodes i/j. This is also the order expected for the partial derivatives + of "mdot" and "pressure" in "d?_dVi/j" (in case they are known analytically, see the AUSM+up implementation). + ---*/ +} + +void CUpwAUSMPLUS_SLAU_Base_Flow::ApproximateJacobian(su2double **val_Jacobian_i, su2double **val_Jacobian_j) { + + unsigned short iDim, iVar, jVar, kVar; + su2double R, RoeDensity, RoeEnthalpy, RoeSoundSpeed, ProjVelocity, sq_vel, Energy_i, Energy_j; + + Energy_i = Enthalpy_i - Pressure_i/Density_i; + Energy_j = Enthalpy_j - Pressure_j/Density_j; + + /*--- Mean Roe variables iPoint and jPoint ---*/ + + R = sqrt(fabs(Density_j/Density_i)); + RoeDensity = R*Density_i; + ProjVelocity = 0.0; + sq_vel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + RoeVelocity[iDim] = (R*Velocity_j[iDim]+Velocity_i[iDim])/(R+1); + ProjVelocity += RoeVelocity[iDim]*UnitNormal[iDim]; + sq_vel += RoeVelocity[iDim]*RoeVelocity[iDim]; + } + RoeEnthalpy = (R*Enthalpy_j+Enthalpy_i)/(R+1); + RoeSoundSpeed = sqrt(fabs((Gamma-1)*(RoeEnthalpy-0.5*sq_vel))); + + /*--- Compute P and Lambda (do it with the Normal) ---*/ + + GetPMatrix(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, P_Tensor); + + /*--- Flow eigenvalues and Entropy correctors ---*/ + + for (iDim = 0; iDim < nDim; iDim++) + Lambda[iDim] = ProjVelocity; + Lambda[nVar-2] = ProjVelocity + RoeSoundSpeed; + Lambda[nVar-1] = ProjVelocity - RoeSoundSpeed; + + /*--- Compute inverse P ---*/ + GetPMatrix_inv(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, invP_Tensor); + + /*--- Jacobians of the inviscid flux, scale = 0.5 because val_residual ~ 0.5*(fc_i+fc_j)*Normal ---*/ + GetInviscidProjJac(Velocity_i, &Energy_i, Normal, 0.5, val_Jacobian_i); + GetInviscidProjJac(Velocity_j, &Energy_j, Normal, 0.5, val_Jacobian_j); + + /*--- Roe's Flux approximation ---*/ + + for (iVar = 0; iVar < nVar; iVar++) { + for (jVar = 0; jVar < nVar; jVar++) { + su2double Proj_ModJac_Tensor_ij = 0.0; + /*--- Compute |Proj_ModJac_Tensor| = P x |Lambda| x inverse P ---*/ + for (kVar = 0; kVar < nVar; kVar++) + Proj_ModJac_Tensor_ij += P_Tensor[iVar][kVar]*fabs(Lambda[kVar])*invP_Tensor[kVar][jVar]; + val_Jacobian_i[iVar][jVar] += 0.5*Proj_ModJac_Tensor_ij*Area; + val_Jacobian_j[iVar][jVar] -= 0.5*Proj_ModJac_Tensor_ij*Area; + } + } + +} + +void CUpwAUSMPLUS_SLAU_Base_Flow::AccurateJacobian(CConfig *config, su2double **val_Jacobian_i, su2double **val_Jacobian_j) { + + /*--- Compute Jacobians using a mixed (numerical/analytical) formulation ---*/ + + unsigned short iDim, iVar, jVar; + + /*--- If not computed analytically, numerically differentiate the fluxes wrt primitives ---*/ + + if (!HasAnalyticalDerivatives) { + + /*--- Create arrays of pointers to the primitive variables so + we can loop through and perturb them in a general way. ---*/ + + su2double *primitives_i[6], *primitives_j[6]; + + for (iDim = 0; iDim < nDim; ++iDim) { + primitives_i[iDim] = &Velocity_i[iDim]; + primitives_j[iDim] = &Velocity_j[iDim]; + } + primitives_i[ nDim ] = &Pressure_i; primitives_j[ nDim ] = &Pressure_j; + primitives_i[nDim+1] = &Density_i; primitives_j[nDim+1] = &Density_j; + primitives_i[nDim+2] = &Enthalpy_i; primitives_j[nDim+2] = &Enthalpy_j; + + /*--- Initialize the gradient arrays with the negative of the quantity, + then for forward finite differences we add to it and divide. ---*/ + + for (iVar = 0; iVar < 6; ++iVar) { + dmdot_dVi[iVar] = -MassFlux; dpres_dVi[iVar] = -Pressure; + dmdot_dVj[iVar] = -MassFlux; dpres_dVj[iVar] = -Pressure; + } + + for (iVar = 0; iVar < nDim+3; ++iVar) { + /*--- Perturb side i ---*/ + su2double epsilon = FinDiffStep * max(1.0, fabs(*primitives_i[iVar])); + *primitives_i[iVar] += epsilon; + ComputeMassAndPressureFluxes(config, MassFlux, Pressure); + dmdot_dVi[iVar] += MassFlux; dpres_dVi[iVar] += Pressure; + dmdot_dVi[iVar] /= epsilon; dpres_dVi[iVar] /= epsilon; + *primitives_i[iVar] -= epsilon; + + /*--- Perturb side j ---*/ + epsilon = FinDiffStep * max(1.0, fabs(*primitives_j[iVar])); + *primitives_j[iVar] += epsilon; + ComputeMassAndPressureFluxes(config, MassFlux, Pressure); + dmdot_dVj[iVar] += MassFlux; dpres_dVj[iVar] += Pressure; + dmdot_dVj[iVar] /= epsilon; dpres_dVj[iVar] /= epsilon; + *primitives_j[iVar] -= epsilon; + } + } + + /*--- Differentiation of fluxes wrt conservatives assuming ideal gas ---*/ + + su2double dmdot_dUi[5], dmdot_dUj[5], dpres_dUi[5], dpres_dUj[5]; + su2double sq_veli = 0.0, sq_velj = 0.0, dHi_drhoi = 0.0, dHj_drhoj = 0.0; + su2double oneOnRhoi = 1.0/Density_i, oneOnRhoj = 1.0/Density_j; + + for (jVar = 0; jVar < nVar; ++jVar) { + + /*--- Partial derivatives of the primitives wrt conservative "jVar" ---*/ + su2double dVi_dUi[6] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; + su2double dVj_dUj[6] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; + + if (jVar == 0) { // Density + for (iDim = 0; iDim < nDim; ++iDim) { + // -u,v,w / rho + dVi_dUi[iDim] = -Velocity_i[iDim] * oneOnRhoi; + dVj_dUj[iDim] = -Velocity_j[iDim] * oneOnRhoj; + // ||V||^2 + sq_veli += Velocity_i[iDim] * Velocity_i[iDim]; + sq_velj += Velocity_j[iDim] * Velocity_j[iDim]; + } + dVi_dUi[nDim] = 0.5*Gamma_Minus_One*sq_veli; + dVj_dUj[nDim] = 0.5*Gamma_Minus_One*sq_velj; + + dVi_dUi[nDim+1] = dVj_dUj[nDim+1] = 1.0; + + dHi_drhoi = 0.5*(Gamma-2.0)*sq_veli - Gamma*Pressure_i/((Gamma-1.0)*Density_i); + dHj_drhoj = 0.5*(Gamma-2.0)*sq_velj - Gamma*Pressure_j/((Gamma-1.0)*Density_j); + dVi_dUi[nDim+2] = dHi_drhoi * oneOnRhoi; + dVj_dUj[nDim+2] = dHj_drhoj * oneOnRhoj; + } + else if (jVar == nVar-1) { // rho*Energy + dVi_dUi[nDim] = dVj_dUj[nDim] = Gamma_Minus_One; + dVi_dUi[nDim+2] = Gamma * oneOnRhoi; + dVj_dUj[nDim+2] = Gamma * oneOnRhoj; + } + else { // Momentum + dVi_dUi[jVar-1] = oneOnRhoi; + dVj_dUj[jVar-1] = oneOnRhoj; + + dVi_dUi[nDim] = -Gamma_Minus_One*Velocity_i[jVar-1]; + dVj_dUj[nDim] = -Gamma_Minus_One*Velocity_j[jVar-1]; + + dVi_dUi[nDim+2] = dVi_dUi[nDim] * oneOnRhoi; + dVj_dUj[nDim+2] = dVj_dUj[nDim] * oneOnRhoj; + } + + /*--- Dot product to complete chain rule ---*/ + dmdot_dUi[jVar] = 0.0; dpres_dUi[jVar] = 0.0; + dmdot_dUj[jVar] = 0.0; dpres_dUj[jVar] = 0.0; + for (iVar = 0; iVar < 6; ++iVar) { + dmdot_dUi[jVar] += dmdot_dVi[iVar]*dVi_dUi[iVar]; + dpres_dUi[jVar] += dpres_dVi[iVar]*dVi_dUi[iVar]; + dmdot_dUj[jVar] += dmdot_dVj[iVar]*dVj_dUj[iVar]; + dpres_dUj[jVar] += dpres_dVj[iVar]*dVj_dUj[iVar]; + } + } + + /*--- Assemble final Jacobians (assuming phi = |mdot|) ---*/ + + su2double mdot_hat, psi_hat[5]; + + if (MassFlux > 0.0) { + mdot_hat = Area*MassFlux*oneOnRhoi; + for (iVar = 0; iVar < nVar; ++iVar) psi_hat[iVar] = Area*psi_i[iVar]; + } + else { + mdot_hat = Area*MassFlux*oneOnRhoj; + for (iVar = 0; iVar < nVar; ++iVar) psi_hat[iVar] = Area*psi_j[iVar]; + } + + /*--- Contribution from the mass flux derivatives ---*/ + for (iVar = 0; iVar < nVar; ++iVar) { + for (jVar = 0; jVar < nVar; ++jVar) { + val_Jacobian_i[iVar][jVar] = psi_hat[iVar] * dmdot_dUi[jVar]; + val_Jacobian_j[iVar][jVar] = psi_hat[iVar] * dmdot_dUj[jVar]; + } + } + + /*--- Contribution from the pressure derivatives ---*/ + for (iDim = 0; iDim < nDim; ++iDim) { + for (jVar = 0; jVar < nVar; ++jVar) { + val_Jacobian_i[iDim+1][jVar] += Normal[iDim] * dpres_dUi[jVar]; + val_Jacobian_j[iDim+1][jVar] += Normal[iDim] * dpres_dUj[jVar]; + } + } + + /*--- Contributions from the derivatives of PSI wrt the conservatives ---*/ + if (MassFlux > 0.0) { + /*--- Velocity terms ---*/ + for (iDim = 0; iDim < nDim; ++iDim) { + val_Jacobian_i[iDim+1][0] -= mdot_hat*Velocity_i[iDim]; + val_Jacobian_i[iDim+1][iDim+1] += mdot_hat; + val_Jacobian_i[nVar-1][iDim+1] -= mdot_hat*Gamma_Minus_One*Velocity_i[iDim]; + } + /*--- Energy terms ---*/ + val_Jacobian_i[nVar-1][0] += mdot_hat*dHi_drhoi; + val_Jacobian_i[nVar-1][nVar-1] += mdot_hat*Gamma; + } + else { + /*--- Velocity terms ---*/ + for (iDim = 0; iDim < nDim; ++iDim) { + val_Jacobian_j[iDim+1][0] -= mdot_hat*Velocity_j[iDim]; + val_Jacobian_j[iDim+1][iDim+1] += mdot_hat; + val_Jacobian_j[nVar-1][iDim+1] -= mdot_hat*Gamma_Minus_One*Velocity_j[iDim]; + } + /*--- Energy terms ---*/ + val_Jacobian_j[nVar-1][0] += mdot_hat*dHj_drhoj; + val_Jacobian_j[nVar-1][nVar-1] += mdot_hat*Gamma; + } + +} + +void CUpwAUSMPLUS_SLAU_Base_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { + + unsigned short iDim, iVar; + + /*--- Space to start preaccumulation ---*/ + + AD::StartPreacc(); + AD::SetPreaccIn(Normal, nDim); + AD::SetPreaccIn(V_i, nDim+4); + AD::SetPreaccIn(V_j, nDim+4); + + /*--- Variables for the general form and primitives for mass flux and pressure calculation. ---*/ + /*--- F_{1/2} = ||A|| ( 0.5 * mdot * (psi_i+psi_j) - 0.5 * |mdot| * (psi_i-psi_j) + N * pf ) ---*/ + + psi_i[0] = 1.0; psi_j[0] = 1.0; + + for (iDim = 0; iDim < nDim; iDim++) { + /*--- Velocities ---*/ + Velocity_i[iDim] = psi_i[iDim+1] = V_i[iDim+1]; + Velocity_j[iDim] = psi_j[iDim+1] = V_j[iDim+1]; + } + + /*--- Pressure and Density ---*/ + Pressure_i = V_i[nDim+1]; Pressure_j = V_j[nDim+1]; + Density_i = V_i[nDim+2]; Density_j = V_j[nDim+2]; + + /*--- Enthalpy ---*/ + Enthalpy_i = psi_i[nVar-1] = V_i[nDim+3]; + Enthalpy_j = psi_j[nVar-1] = V_j[nDim+3]; + + /*--- Face area (norm or the normal vector) ---*/ + + Area = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + Area += Normal[iDim]*Normal[iDim]; + Area = sqrt(Area); + + /*-- Unit Normal ---*/ + for (iDim = 0; iDim < nDim; iDim++) + UnitNormal[iDim] = Normal[iDim]/Area; + + /*--- Mass and pressure fluxes defined by derived classes ---*/ + + ComputeMassAndPressureFluxes(config, MassFlux, Pressure); + DissFlux = fabs(MassFlux); + + val_residual[0] = MassFlux; + + for (iDim = 0; iDim < nDim; iDim++) + val_residual[iDim+1] = 0.5*MassFlux*(psi_i[iDim+1]+psi_j[iDim+1]) + + 0.5*DissFlux*(psi_i[iDim+1]-psi_j[iDim+1]) + + UnitNormal[iDim]*Pressure; + + val_residual[nVar-1] = 0.5*MassFlux*(psi_i[nVar-1]+psi_j[nVar-1]) + + 0.5*DissFlux*(psi_i[nVar-1]-psi_j[nVar-1]); + + for (iVar = 0; iVar < nVar; iVar++) val_residual[iVar] *= Area; + + /*--- Space to end preaccumulation ---*/ + + AD::SetPreaccOut(val_residual, nVar); + AD::EndPreacc(); + + /*--- If required, compute Jacobians, either approximately (Roe) or numerically ---*/ + + if (!implicit) return; + + if (UseAccurateJacobian) + AccurateJacobian(config, val_Jacobian_i, val_Jacobian_j); + else + ApproximateJacobian(val_Jacobian_i, val_Jacobian_j); + +} + diff --git a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwAUSM_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwAUSM_Flow.cpp new file mode 100644 index 000000000000..8bdd2886efd0 --- /dev/null +++ b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwAUSM_Flow.cpp @@ -0,0 +1,208 @@ +/*! + * \file CUpwAUSM_Flow.cpp + * \brief Implementation of numerics class CUpwAUSM_Flow. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../../include/numerics/flow/convection_upwind/CUpwAUSM_Flow.hpp" + +CUpwAUSM_Flow::CUpwAUSM_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + if (config->GetDynamic_Grid() && (SU2_MPI::GetRank() == MASTER_NODE)) + cout << "WARNING: Grid velocities are NOT yet considered in AUSM-type schemes." << endl; + + implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + + Diff_U = new su2double [nVar]; + Velocity_i = new su2double [nDim]; + Velocity_j = new su2double [nDim]; + RoeVelocity = new su2double [nDim]; + delta_vel = new su2double [nDim]; + delta_wave = new su2double [nVar]; + ProjFlux_i = new su2double [nVar]; + ProjFlux_j = new su2double [nVar]; + Lambda = new su2double [nVar]; + Epsilon = new su2double [nVar]; + P_Tensor = new su2double* [nVar]; + invP_Tensor = new su2double* [nVar]; + for (iVar = 0; iVar < nVar; iVar++) { + P_Tensor[iVar] = new su2double [nVar]; + invP_Tensor[iVar] = new su2double [nVar]; + } +} + +CUpwAUSM_Flow::~CUpwAUSM_Flow(void) { + + delete [] Diff_U; + delete [] Velocity_i; + delete [] Velocity_j; + delete [] RoeVelocity; + delete [] delta_vel; + delete [] delta_wave; + delete [] ProjFlux_i; + delete [] ProjFlux_j; + delete [] Lambda; + delete [] Epsilon; + for (iVar = 0; iVar < nVar; iVar++) { + delete [] P_Tensor[iVar]; + delete [] invP_Tensor[iVar]; + } + delete [] P_Tensor; + delete [] invP_Tensor; + +} + +void CUpwAUSM_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { + + AD::StartPreacc(); + AD::SetPreaccIn(Normal, nDim); + AD::SetPreaccIn(V_i, nDim+4); + AD::SetPreaccIn(V_j, nDim+4); + + /*--- Face area (norm or the normal vector) ---*/ + Area = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + Area += Normal[iDim]*Normal[iDim]; + Area = sqrt(Area); + + /*-- Unit Normal ---*/ + for (iDim = 0; iDim < nDim; iDim++) + UnitNormal[iDim] = Normal[iDim]/Area; + + /*--- Primitive variables at point i ---*/ + sq_vel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + Velocity_i[iDim] = V_i[iDim+1]; + sq_vel += Velocity_i[iDim]*Velocity_i[iDim]; + } + Pressure_i = V_i[nDim+1]; + Density_i = V_i[nDim+2]; + Enthalpy_i = V_i[nDim+3]; + Energy_i = Enthalpy_i - Pressure_i/Density_i; + SoundSpeed_i = sqrt(fabs(Gamma*Gamma_Minus_One*(Energy_i-0.5*sq_vel))); + + /*--- Primitive variables at point j ---*/ + sq_vel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + Velocity_j[iDim] = V_j[iDim+1]; + sq_vel += Velocity_j[iDim]*Velocity_j[iDim]; + } + Pressure_j = V_j[nDim+1]; + Density_j = V_j[nDim+2]; + Enthalpy_j = V_j[nDim+3]; + Energy_j = Enthalpy_j - Pressure_j/Density_j; + SoundSpeed_j = sqrt(fabs(Gamma*Gamma_Minus_One*(Energy_j-0.5*sq_vel))); + + /*--- Projected velocities ---*/ + ProjVelocity_i = 0.0; ProjVelocity_j = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + ProjVelocity_i += Velocity_i[iDim]*UnitNormal[iDim]; + ProjVelocity_j += Velocity_j[iDim]*UnitNormal[iDim]; + } + + mL = ProjVelocity_i/SoundSpeed_i; + mR = ProjVelocity_j/SoundSpeed_j; + + if (fabs(mL) <= 1.0) mLP = 0.25*(mL+1.0)*(mL+1.0); + else mLP = 0.5*(mL+fabs(mL)); + + if (fabs(mR) <= 1.0) mRM = -0.25*(mR-1.0)*(mR-1.0); + else mRM = 0.5*(mR-fabs(mR)); + + mF = mLP + mRM; + + if (fabs(mL) <= 1.0) pLP = 0.25*Pressure_i*(mL+1.0)*(mL+1.0)*(2.0-mL); + else pLP = 0.5*Pressure_i*(mL+fabs(mL))/mL; + + if (fabs(mR) <= 1.0) pRM = 0.25*Pressure_j*(mR-1.0)*(mR-1.0)*(2.0+mR); + else pRM = 0.5*Pressure_j*(mR-fabs(mR))/mR; + + pF = pLP + pRM; + Phi = fabs(mF); + + val_residual[0] = 0.5*(mF*((Density_i*SoundSpeed_i)+(Density_j*SoundSpeed_j))-Phi*((Density_j*SoundSpeed_j)-(Density_i*SoundSpeed_i))); + for (iDim = 0; iDim < nDim; iDim++) + val_residual[iDim+1] = 0.5*(mF*((Density_i*SoundSpeed_i*Velocity_i[iDim])+(Density_j*SoundSpeed_j*Velocity_j[iDim])) + -Phi*((Density_j*SoundSpeed_j*Velocity_j[iDim])-(Density_i*SoundSpeed_i*Velocity_i[iDim])))+UnitNormal[iDim]*pF; + val_residual[nVar-1] = 0.5*(mF*((Density_i*SoundSpeed_i*Enthalpy_i)+(Density_j*SoundSpeed_j*Enthalpy_j))-Phi*((Density_j*SoundSpeed_j*Enthalpy_j)-(Density_i*SoundSpeed_i*Enthalpy_i))); + + for (iVar = 0; iVar < nVar; iVar++) + val_residual[iVar] *= Area; + + AD::SetPreaccOut(val_residual, nVar); + AD::EndPreacc(); + + /*--- Roe's Jacobian for AUSM (this must be fixed) ---*/ + if (implicit) { + + /*--- Mean Roe variables iPoint and jPoint ---*/ + R = sqrt(fabs(Density_j/Density_i)); + RoeDensity = R*Density_i; + sq_vel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + RoeVelocity[iDim] = (R*Velocity_j[iDim]+Velocity_i[iDim])/(R+1); + sq_vel += RoeVelocity[iDim]*RoeVelocity[iDim]; + } + RoeEnthalpy = (R*Enthalpy_j+Enthalpy_i)/(R+1); + RoeSoundSpeed = sqrt(fabs((Gamma-1)*(RoeEnthalpy-0.5*sq_vel))); + + /*--- Compute P and Lambda (do it with the Normal) ---*/ + GetPMatrix(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, P_Tensor); + + ProjVelocity = 0.0; ProjVelocity_i = 0.0; ProjVelocity_j = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + ProjVelocity += RoeVelocity[iDim]*UnitNormal[iDim]; + ProjVelocity_i += Velocity_i[iDim]*UnitNormal[iDim]; + ProjVelocity_j += Velocity_j[iDim]*UnitNormal[iDim]; + } + + /*--- Flow eigenvalues and Entropy correctors ---*/ + for (iDim = 0; iDim < nDim; iDim++) + Lambda[iDim] = ProjVelocity; + Lambda[nVar-2] = ProjVelocity + RoeSoundSpeed; + Lambda[nVar-1] = ProjVelocity - RoeSoundSpeed; + + /*--- Compute inverse P ---*/ + GetPMatrix_inv(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, invP_Tensor); + + /*--- Jacobias of the inviscid flux, scale = 0.5 because val_residual ~ 0.5*(fc_i+fc_j)*Normal ---*/ + GetInviscidProjJac(Velocity_i, &Energy_i, Normal, 0.5, val_Jacobian_i); + GetInviscidProjJac(Velocity_j, &Energy_j, Normal, 0.5, val_Jacobian_j); + + /*--- Roe's Flux approximation ---*/ + for (iVar = 0; iVar < nVar; iVar++) { + for (jVar = 0; jVar < nVar; jVar++) { + Proj_ModJac_Tensor_ij = 0.0; + /*--- Compute |Proj_ModJac_Tensor| = P x |Lambda| x inverse P ---*/ + for (kVar = 0; kVar < nVar; kVar++) + Proj_ModJac_Tensor_ij += P_Tensor[iVar][kVar]*fabs(Lambda[kVar])*invP_Tensor[kVar][jVar]; + val_Jacobian_i[iVar][jVar] += 0.5*Proj_ModJac_Tensor_ij*Area; + val_Jacobian_j[iVar][jVar] -= 0.5*Proj_ModJac_Tensor_ij*Area; + } + } + } +} diff --git a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwCUSP_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwCUSP_Flow.cpp new file mode 100644 index 000000000000..f647a029a400 --- /dev/null +++ b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwCUSP_Flow.cpp @@ -0,0 +1,175 @@ +/*! + * \file CUpwCUSP_Flow.cpp + * \brief Implementation of numerics class CUpwCUSP_Flow. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../../include/numerics/flow/convection_upwind/CUpwCUSP_Flow.hpp" + +CUpwCUSP_Flow::CUpwCUSP_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + + if (config->GetDynamic_Grid() && (SU2_MPI::GetRank() == MASTER_NODE)) + cout << "WARNING: Grid velocities are NOT yet considered by the CUSP scheme." << endl; + + /*--- Allocate some structures ---*/ + Velocity_i = new su2double [nDim]; + Velocity_j = new su2double [nDim]; + ProjFlux_i = new su2double [nVar]; + ProjFlux_j = new su2double [nVar]; +} + +CUpwCUSP_Flow::~CUpwCUSP_Flow(void) { + delete [] Velocity_i; + delete [] Velocity_j; + delete [] ProjFlux_i; + delete [] ProjFlux_j; +} + +void CUpwCUSP_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, + CConfig *config) { + + unsigned short iDim, iVar; + su2double Diff_U[5] = {0.0,0.0,0.0,0.0,0.0}; + + AD::SetPreaccIn(Normal, nDim); + AD::SetPreaccIn(V_i, nDim+4); + AD::SetPreaccIn(V_j, nDim+4); + + /*--- Pressure, density, enthalpy, energy, and velocity at points i and j ---*/ + + Pressure_i = V_i[nDim+1]; Pressure_j = V_j[nDim+1]; + Density_i = V_i[nDim+2]; Density_j = V_j[nDim+2]; + Enthalpy_i = V_i[nDim+3]; Enthalpy_j = V_j[nDim+3]; + su2double Energy_i = Enthalpy_i - Pressure_i/Density_i; + su2double Energy_j = Enthalpy_j - Pressure_j/Density_j; + + su2double sq_vel_i = 0.0, sq_vel_j = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + Velocity_i[iDim] = V_i[iDim+1]; + Velocity_j[iDim] = V_j[iDim+1]; + sq_vel_i += Velocity_i[iDim]*Velocity_i[iDim]; + sq_vel_j += Velocity_j[iDim]*Velocity_j[iDim]; + } + + /*-- Face area and unit normal ---*/ + + 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; + + /*--- Computes differences of conservative variables, with a correction for the enthalpy ---*/ + + Diff_U[0] = Density_i - Density_j; + for (iDim = 0; iDim < nDim; iDim++) + Diff_U[iDim+1] = Density_i*Velocity_i[iDim] - Density_j*Velocity_j[iDim]; + Diff_U[nVar-1] = Density_i*Enthalpy_i - Density_j*Enthalpy_j; + + /*--- Get left and right fluxes ---*/ + + GetInviscidProjFlux(&Density_i, Velocity_i, &Pressure_i, &Enthalpy_i, UnitNormal, ProjFlux_i); + GetInviscidProjFlux(&Density_j, Velocity_j, &Pressure_j, &Enthalpy_j, UnitNormal, ProjFlux_j); + + /*--- Compute dissipation parameters based on Roe-averaged values ---*/ + + su2double Beta, Nu_c; + + su2double R = sqrt(Density_j/Density_i), ProjVelocity = 0.0, sq_vel = 0.0; + + for (iDim = 0; iDim < nDim; iDim++) { + su2double MeanVel = (R*Velocity_j[iDim]+Velocity_i[iDim])/(R+1.0); + ProjVelocity += MeanVel*UnitNormal[iDim]; + sq_vel += MeanVel*MeanVel; + } + su2double MeanEnthalpy = (R*Enthalpy_j+Enthalpy_i)/(R+1.0); + su2double MeanSoundSpeed = sqrt(Gamma_Minus_One*fabs(MeanEnthalpy-0.5*sq_vel)); + + su2double Mach = ProjVelocity / MeanSoundSpeed; + + su2double tmp1 = 0.5*(Gamma+1.0)/Gamma*ProjVelocity; + su2double tmp2 = sqrt(pow(tmp1-ProjVelocity/Gamma, 2.0) + pow(MeanSoundSpeed,2.0)/Gamma); + su2double LamdaNeg = tmp1 - tmp2, LamdaPos = tmp1 + tmp2; + + if (fabs(Mach) >= 1.0) Beta = Mach/fabs(Mach); + else if (Mach >= 0.0) Beta = max(0.0, (ProjVelocity + LamdaNeg)/(ProjVelocity - LamdaNeg)); + else Beta =-max(0.0, (ProjVelocity + LamdaPos)/(ProjVelocity - LamdaPos)); + + if (fabs(Mach) >= 1.0) Nu_c = 0.0; + else { + if (Beta > 0.0) Nu_c =-(1.0+Beta)*LamdaNeg; + else if (Beta < 0.0) Nu_c = (1.0-Beta)*LamdaPos; + /*--- Limit the minimum scalar dissipation ---*/ + else Nu_c = max(fabs(ProjVelocity), config->GetEntropyFix_Coeff()*MeanSoundSpeed); + } + + /*--- Compute the residual ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + val_residual[iVar] = 0.5*((1.0+Beta)*ProjFlux_i[iVar] + (1.0-Beta)*ProjFlux_j[iVar] + Nu_c*Diff_U[iVar])*Area; + + /*--- Jacobian computation ---*/ + + if (implicit) { + + /*--- Flux average and difference contributions ---*/ + + GetInviscidProjJac(Velocity_i, &Energy_i, Normal, 0.5*(1.0+Beta), val_Jacobian_i); + GetInviscidProjJac(Velocity_j, &Energy_j, Normal, 0.5*(1.0-Beta), val_Jacobian_j); + + /*--- Solution difference (scalar dissipation) contribution ---*/ + + su2double cte_0 = 0.5*Nu_c*Area*config->GetCent_Jac_Fix_Factor(); + + /*--- n-1 diagonal entries ---*/ + + for (iVar = 0; iVar < (nVar-1); iVar++) { + val_Jacobian_i[iVar][iVar] += cte_0; + val_Jacobian_j[iVar][iVar] -= cte_0; + } + + /*--- Last rows ---*/ + + val_Jacobian_i[nVar-1][0] += cte_0*Gamma_Minus_One*0.5*sq_vel_i; + for (iDim = 0; iDim < nDim; iDim++) + val_Jacobian_i[nVar-1][iDim+1] -= cte_0*Gamma_Minus_One*Velocity_i[iDim]; + val_Jacobian_i[nVar-1][nVar-1] += cte_0*Gamma; + + val_Jacobian_j[nVar-1][0] -= cte_0*Gamma_Minus_One*0.5*sq_vel_j; + for (iDim = 0; iDim < nDim; iDim++) + val_Jacobian_j[nVar-1][iDim+1] += cte_0*Gamma_Minus_One*Velocity_j[iDim]; + val_Jacobian_j[nVar-1][nVar-1] -= cte_0*Gamma; + + } + + AD::SetPreaccOut(val_residual, nVar); + AD::EndPreacc(); +} diff --git a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwFDSInc_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwFDSInc_Flow.cpp new file mode 100644 index 000000000000..ce9bc1813bf5 --- /dev/null +++ b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwFDSInc_Flow.cpp @@ -0,0 +1,270 @@ +/*! + * \file CUpwFDSInc_Flow.cpp + * \brief Implementation of numerics class CUpwFDSInc_Flow. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../../include/numerics/flow/convection_upwind/CUpwFDSInc_Flow.hpp" + +CUpwFDSInc_Flow::CUpwFDSInc_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + variable_density = (config->GetKind_DensityModel() == VARIABLE); + energy = config->GetEnergy_Equation(); + /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ + dynamic_grid = config->GetDynamic_Grid(); + + Diff_V = new su2double[nVar]; + Velocity_i = new su2double[nDim]; + Velocity_j = new su2double[nDim]; + MeanVelocity = new su2double[nDim]; + ProjFlux_i = new su2double[nVar]; + ProjFlux_j = new su2double[nVar]; + Lambda = new su2double[nVar]; + Epsilon = new su2double[nVar]; + Precon = new su2double*[nVar]; + invPrecon_A = new su2double*[nVar]; + + for (iVar = 0; iVar < nVar; iVar++) { + Precon[iVar] = new su2double[nVar]; + invPrecon_A[iVar] = new su2double[nVar]; + } + +} + +CUpwFDSInc_Flow::~CUpwFDSInc_Flow(void) { + + delete [] Diff_V; + delete [] Velocity_i; + delete [] Velocity_j; + delete [] MeanVelocity; + delete [] ProjFlux_i; + delete [] ProjFlux_j; + delete [] Lambda; + delete [] Epsilon; + + for (iVar = 0; iVar < nVar; iVar++) { + delete [] Precon[iVar]; + delete [] invPrecon_A[iVar]; + } + delete [] Precon; + delete [] invPrecon_A; + +} + +void CUpwFDSInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { + + su2double U_i[5] = {0.0,0.0,0.0,0.0,0.0}, U_j[5] = {0.0,0.0,0.0,0.0,0.0}; + su2double ProjGridVel = 0.0; + + AD::StartPreacc(); + AD::SetPreaccIn(V_i, nDim+9); AD::SetPreaccIn(V_j, nDim+9); AD::SetPreaccIn(Normal, nDim); + if (dynamic_grid) { + AD::SetPreaccIn(GridVel_i, nDim); + AD::SetPreaccIn(GridVel_j, nDim); + } + + /*--- Face area (norm or the normal vector) ---*/ + + Area = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + Area += Normal[iDim]*Normal[iDim]; + Area = sqrt(Area); + + /*--- Compute and unitary normal vector ---*/ + + for (iDim = 0; iDim < nDim; iDim++) { + UnitNormal[iDim] = Normal[iDim]/Area; + if (fabs(UnitNormal[iDim]) < EPS) UnitNormal[iDim] = EPS; + } + + /*--- Set primitive variables at points iPoint and jPoint ---*/ + + Pressure_i = V_i[0]; Pressure_j = V_j[0]; + Temperature_i = V_i[nDim+1]; Temperature_j = V_j[nDim+1]; + DensityInc_i = V_i[nDim+2]; DensityInc_j = V_j[nDim+2]; + BetaInc2_i = V_i[nDim+3]; BetaInc2_j = V_j[nDim+3]; + Cp_i = V_i[nDim+7]; Cp_j = V_j[nDim+7]; + Enthalpy_i = Cp_i*Temperature_i; Enthalpy_j = Cp_j*Temperature_j; + + ProjVelocity = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + Velocity_i[iDim] = V_i[iDim+1]; + Velocity_j[iDim] = V_j[iDim+1]; + MeanVelocity[iDim] = 0.5*(Velocity_i[iDim] + Velocity_j[iDim]); + ProjVelocity += MeanVelocity[iDim]*Normal[iDim]; + } + + /*--- Projected velocity adjustment due to mesh motion ---*/ + + if (dynamic_grid) { + ProjGridVel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; + } + ProjVelocity -= ProjGridVel; + } + + /*--- Mean variables at points iPoint and jPoint ---*/ + + MeanDensity = 0.5*(DensityInc_i + DensityInc_j); + MeanPressure = 0.5*(Pressure_i + Pressure_j); + MeanBetaInc2 = 0.5*(BetaInc2_i + BetaInc2_j); + MeanEnthalpy = 0.5*(Enthalpy_i + Enthalpy_j); + MeanCp = 0.5*(Cp_i + Cp_j); + MeanTemperature = 0.5*(Temperature_i + Temperature_j); + + /*--- Artificial sound speed based on eigs of preconditioned system ---*/ + + MeanSoundSpeed = sqrt(MeanBetaInc2*Area*Area); + + /*--- We need the derivative of the equation of state to build the + preconditioning matrix. For now, the only option is the ideal gas + law, but in the future, dRhodT should be in the fluid model. ---*/ + + MeandRhodT = 0.0; dRhodT_i = 0.0; dRhodT_j = 0.0; + if (variable_density) { + MeandRhodT = -MeanDensity/MeanTemperature; + dRhodT_i = -DensityInc_i/Temperature_i; + dRhodT_j = -DensityInc_j/Temperature_j; + } + + /*--- Compute ProjFlux_i ---*/ + + GetInviscidIncProjFlux(&DensityInc_i, Velocity_i, &Pressure_i, &BetaInc2_i, &Enthalpy_i, Normal, ProjFlux_i); + + /*--- Compute ProjFlux_j ---*/ + + GetInviscidIncProjFlux(&DensityInc_j, Velocity_j, &Pressure_j, &BetaInc2_j, &Enthalpy_j, Normal, ProjFlux_j); + + /*--- Eigenvalues of the preconditioned system ---*/ + + if (nDim == 2) { + Lambda[0] = ProjVelocity; + Lambda[1] = ProjVelocity; + Lambda[2] = ProjVelocity - MeanSoundSpeed; + Lambda[3] = ProjVelocity + MeanSoundSpeed; + } + if (nDim == 3) { + Lambda[0] = ProjVelocity; + Lambda[1] = ProjVelocity; + Lambda[2] = ProjVelocity; + Lambda[3] = ProjVelocity - MeanSoundSpeed; + Lambda[4] = ProjVelocity + MeanSoundSpeed; + } + + /*--- Absolute value of the eigenvalues ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + Lambda[iVar] = fabs(Lambda[iVar]); + + /*--- Build the preconditioning matrix using mean values ---*/ + + GetPreconditioner(&MeanDensity, MeanVelocity, &MeanBetaInc2, &MeanCp, &MeanTemperature, &MeandRhodT, Precon); + + /*--- Build the absolute value of the preconditioned Jacobian, i.e., + |A_precon| = P x |Lambda| x inv(P), where P diagonalizes the matrix + inv(Precon) x dF/dV and Lambda is the diag. matrix of its eigenvalues. ---*/ + + GetPreconditionedProjJac(&MeanDensity, Lambda, &MeanBetaInc2, UnitNormal, invPrecon_A); + + /*--- Difference of primitive variables at iPoint and jPoint ---*/ + + Diff_V[0] = Pressure_j - Pressure_i; + for (iDim = 0; iDim < nDim; iDim++) + Diff_V[iDim+1] = Velocity_j[iDim] - Velocity_i[iDim]; + Diff_V[nDim+1] = Temperature_j - Temperature_i; + + /*--- Build the inviscid Jacobian w.r.t. the primitive variables ---*/ + + if (implicit) { + GetInviscidIncProjJac(&DensityInc_i, Velocity_i, &BetaInc2_i, &Cp_i, &Temperature_i, &dRhodT_i, Normal, 0.5, val_Jacobian_i); + GetInviscidIncProjJac(&DensityInc_j, Velocity_j, &BetaInc2_j, &Cp_j, &Temperature_j, &dRhodT_j, Normal, 0.5, val_Jacobian_j); + } + + /*--- Compute dissipation as Precon x |A_precon| x dV. If implicit, + store Precon x |A_precon| from dissipation term. ---*/ + + for (iVar = 0; iVar < nVar; iVar++) { + val_residual[iVar] = 0.5*(ProjFlux_i[iVar]+ProjFlux_j[iVar]); + for (jVar = 0; jVar < nVar; jVar++) { + Proj_ModJac_Tensor_ij = 0.0; + for (kVar = 0; kVar < nVar; kVar++) + Proj_ModJac_Tensor_ij += Precon[iVar][kVar]*invPrecon_A[kVar][jVar]; + val_residual[iVar] -= 0.5*Proj_ModJac_Tensor_ij*Diff_V[jVar]; + if (implicit) { + val_Jacobian_i[iVar][jVar] += 0.5*Proj_ModJac_Tensor_ij; + val_Jacobian_j[iVar][jVar] -= 0.5*Proj_ModJac_Tensor_ij; + } + } + } + + /*--- Corrections due to grid motion ---*/ + if (dynamic_grid) { + + /*--- Recompute conservative variables ---*/ + + U_i[0] = DensityInc_i; U_j[0] = DensityInc_j; + for (iDim = 0; iDim < nDim; iDim++) { + U_i[iDim+1] = DensityInc_i*Velocity_i[iDim]; U_j[iDim+1] = DensityInc_j*Velocity_j[iDim]; + } + U_i[nDim+1] = DensityInc_i*Enthalpy_i; U_j[nDim+1] = DensityInc_j*Enthalpy_j; + + ProjVelocity = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + ProjVelocity += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; + + /*--- Residual contributions ---*/ + for (iVar = 0; iVar < nVar; iVar++) { + val_residual[iVar] -= ProjVelocity * 0.5*(U_i[iVar]+U_j[iVar]); + + /*--- Jacobian contributions ---*/ + /*--- Implicit terms ---*/ + if (implicit) { + for (iDim = 0; iDim < nDim; iDim++){ + val_Jacobian_i[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_i; + val_Jacobian_j[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_j; + } + val_Jacobian_i[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_i*Cp_i; + val_Jacobian_j[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_j*Cp_j; + } + } + } + + if (!energy) { + val_residual[nDim+1] = 0.0; + if (implicit) { + for (iVar = 0; iVar < nVar; iVar++) { + val_Jacobian_i[iVar][nDim+1] = 0.0; + val_Jacobian_j[iVar][nDim+1] = 0.0; + + val_Jacobian_i[nDim+1][iVar] = 0.0; + val_Jacobian_j[nDim+1][iVar] = 0.0; + } + } + } + + AD::SetPreaccOut(val_residual, nVar); + AD::EndPreacc(); +} diff --git a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwGeneralHLLC_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwGeneralHLLC_Flow.cpp new file mode 100644 index 000000000000..e53c32efb963 --- /dev/null +++ b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwGeneralHLLC_Flow.cpp @@ -0,0 +1,908 @@ +/*! + * \file CUpwGeneralHLLC_Flow.cpp + * \brief Implementation of numerics class CUpwGeneralHLLC_Flow. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../../include/numerics/flow/convection_upwind/CUpwGeneralHLLC_Flow.hpp" + +CUpwGeneralHLLC_Flow::CUpwGeneralHLLC_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + kappa = config->GetRoe_Kappa(); + /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ + dynamic_grid = config->GetDynamic_Grid(); + + Gamma = config->GetGamma(); + + IntermediateState = new su2double [nVar]; + dSm_dU = new su2double [nVar]; + dPI_dU = new su2double [nVar]; + drhoStar_dU = new su2double [nVar]; + dpStar_dU = new su2double [nVar]; + dEStar_dU = new su2double [nVar]; + + Velocity_i = new su2double [nDim]; + Velocity_j = new su2double [nDim]; + RoeVelocity = new su2double [nDim]; + +} + +CUpwGeneralHLLC_Flow::~CUpwGeneralHLLC_Flow(void) { + + delete [] IntermediateState; + delete [] dSm_dU; + delete [] dPI_dU; + delete [] drhoStar_dU; + delete [] dpStar_dU; + delete [] dEStar_dU; + + delete [] Velocity_i; + delete [] Velocity_j; + delete [] RoeVelocity; + +} + +void CUpwGeneralHLLC_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { + + /*--- Face area (norm or the normal vector) ---*/ + + Area = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + Area += Normal[iDim] * Normal[iDim]; + + Area = sqrt(Area); + + /*-- Unit Normal ---*/ + + for (iDim = 0; iDim < nDim; iDim++) + UnitNormal[iDim] = Normal[iDim] / Area; + + /*-- Fluid velocity at node i,j ---*/ + + for (iDim = 0; iDim < nDim; iDim++) { + Velocity_i[iDim] = V_i[iDim+1]; + Velocity_j[iDim] = V_j[iDim+1]; + } + + /*--- Primitive variables at point i ---*/ + + Pressure_i = V_i[nDim+1]; + Density_i = V_i[nDim+2]; + Enthalpy_i = V_i[nDim+3]; + + /*--- Primitive variables at point j ---*/ + + Pressure_j = V_j[nDim+1]; + Density_j = V_j[nDim+2]; + Enthalpy_j = V_j[nDim+3]; + + + sq_vel_i = 0.0; + sq_vel_j = 0.0; + + for (iDim = 0; iDim < nDim; iDim++) { + sq_vel_i += Velocity_i[iDim] * Velocity_i[iDim]; + sq_vel_j += Velocity_j[iDim] * Velocity_j[iDim]; + } + + Energy_i = Enthalpy_i - Pressure_i / Density_i; + StaticEnthalpy_i = Enthalpy_i - 0.5 * sq_vel_i; + StaticEnergy_i = Energy_i - 0.5 * sq_vel_i; + + Kappa_i = S_i[1] / Density_i; + Chi_i = S_i[0] - Kappa_i * StaticEnergy_i; + SoundSpeed_i = sqrt(Chi_i + StaticEnthalpy_i * Kappa_i); + + + Energy_j = Enthalpy_j - Pressure_j / Density_j; + StaticEnthalpy_j = Enthalpy_j - 0.5 * sq_vel_j; + StaticEnergy_j = Energy_j - 0.5 * sq_vel_j; + + Kappa_j = S_j[1] / Density_j; + Chi_j = S_j[0] - Kappa_j * StaticEnergy_j; + SoundSpeed_j = sqrt(Chi_j + StaticEnthalpy_j * Kappa_j); + + /*--- Projected velocities ---*/ + + ProjVelocity_i = 0.0; + ProjVelocity_j = 0.0; + + for (iDim = 0; iDim < nDim; iDim++) { + ProjVelocity_i += Velocity_i[iDim] * UnitNormal[iDim]; + ProjVelocity_j += Velocity_j[iDim] * UnitNormal[iDim]; + } + + + /*--- Projected Grid Velocity ---*/ + + ProjInterfaceVel = 0; + + if (dynamic_grid) { + + for (iDim = 0; iDim < nDim; iDim++) + ProjInterfaceVel += 0.5 * ( GridVel_i[iDim] + GridVel_j[iDim] )*UnitNormal[iDim]; + + SoundSpeed_i -= ProjInterfaceVel; + SoundSpeed_j += ProjInterfaceVel; + + ProjVelocity_i -= ProjInterfaceVel; + ProjVelocity_j -= ProjInterfaceVel; + } + + /*--- Roe's averaging ---*/ + + Rrho = ( sqrt(Density_i) + sqrt(Density_j) ); + + sq_velRoe = 0.0; + RoeProjVelocity = - ProjInterfaceVel; + + for (iDim = 0; iDim < nDim; iDim++) { + RoeVelocity[iDim] = ( Velocity_i[iDim] * sqrt(Density_i) + Velocity_j[iDim] * sqrt(Density_j) ) / Rrho; + sq_velRoe += RoeVelocity[iDim] * RoeVelocity[iDim]; + RoeProjVelocity += RoeVelocity[iDim] * UnitNormal[iDim]; + } + + /*--- Mean Roe variables iPoint and jPoint ---*/ + + RoeKappa = 0.5 * ( Kappa_i + Kappa_j ); + RoeChi = 0.5 * ( Chi_i + Chi_j ); + RoeDensity = sqrt( Density_i * Density_j ); + RoeEnthalpy = ( sqrt(Density_j) * Enthalpy_j + sqrt(Density_i) * Enthalpy_i) / Rrho; + + VinokurMontagne(); + + /*--- Roe-averaged speed of sound ---*/ + + //RoeSoundSpeed2 = RoeChi + RoeKappa * ( RoeEnthalpy - 0.5 * sq_velRoe ); + RoeSoundSpeed = sqrt( RoeChi + RoeKappa * ( RoeEnthalpy - 0.5 * sq_velRoe ) ) - ProjInterfaceVel; + + /*--- Speed of sound at L and R ---*/ + + sL = min( RoeProjVelocity - RoeSoundSpeed, ProjVelocity_i - SoundSpeed_i ); + sR = max( RoeProjVelocity + RoeSoundSpeed, ProjVelocity_j + SoundSpeed_j ); + + /*--- speed of contact surface ---*/ + + RHO = Density_j * (sR - ProjVelocity_j) - Density_i * (sL - ProjVelocity_i); + sM = ( Pressure_i - Pressure_j - Density_i * ProjVelocity_i * ( sL - ProjVelocity_i ) + Density_j * ProjVelocity_j * ( sR - ProjVelocity_j ) ) / RHO; + + /*--- Pressure at right and left (Pressure_j=Pressure_i) side of contact surface ---*/ + + pStar = Density_j * ( ProjVelocity_j - sR ) * ( ProjVelocity_j - sM ) + Pressure_j; + + +if (sM > 0.0) { + + if (sL > 0.0) { + + /*--- Compute Left Flux ---*/ + + val_residual[0] = Density_i * ProjVelocity_i; + for (iDim = 0; iDim < nDim; iDim++) + val_residual[iDim+1] = Density_i * Velocity_i[iDim] * ProjVelocity_i + Pressure_i * UnitNormal[iDim]; + val_residual[nVar-1] = Enthalpy_i * Density_i * ProjVelocity_i; + } + else { + + /*--- Compute Flux Left Star from Left Star State ---*/ + + rhoSL = ( sL - ProjVelocity_i ) / ( sL - sM ); + + IntermediateState[0] = rhoSL * Density_i; + for (iDim = 0; iDim < nDim; iDim++) + IntermediateState[iDim+1] = rhoSL * ( Density_i * Velocity_i[iDim] + ( pStar - Pressure_i ) / ( sL - ProjVelocity_i ) * UnitNormal[iDim] ) ; + IntermediateState[nVar-1] = rhoSL * ( Density_i * Energy_i - ( Pressure_i * ProjVelocity_i - pStar * sM) / ( sL - ProjVelocity_i ) ); + + + val_residual[0] = sM * IntermediateState[0]; + for (iDim = 0; iDim < nDim; iDim++) + val_residual[iDim+1] = sM * IntermediateState[iDim+1] + pStar * UnitNormal[iDim]; + val_residual[nVar-1] = sM * ( IntermediateState[nVar-1] + pStar ) + pStar * ProjInterfaceVel; + } + } + else { + + if (sR < 0.0) { + + /*--- Compute Right Flux ---*/ + + val_residual[0] = Density_j * ProjVelocity_j; + for (iDim = 0; iDim < nDim; iDim++) + val_residual[iDim+1] = Density_j * Velocity_j[iDim] * ProjVelocity_j + Pressure_j * UnitNormal[iDim]; + val_residual[nVar-1] = Enthalpy_j * Density_j * ProjVelocity_j; + } + else { + + /*--- Compute Flux Right Star from Right Star State ---*/ + + rhoSR = ( sR - ProjVelocity_j ) / ( sR - sM ); + + IntermediateState[0] = rhoSR * Density_j; + for (iDim = 0; iDim < nDim; iDim++) + IntermediateState[iDim+1] = rhoSR * ( Density_j * Velocity_j[iDim] + ( pStar - Pressure_j ) / ( sR - ProjVelocity_j ) * UnitNormal[iDim] ) ; + IntermediateState[nVar-1] = rhoSR * ( Density_j * Energy_j - ( Pressure_j * ProjVelocity_j - pStar * sM ) / ( sR - ProjVelocity_j ) ); + + + val_residual[0] = sM * IntermediateState[0]; + for (iDim = 0; iDim < nDim; iDim++) + val_residual[iDim+1] = sM * IntermediateState[iDim+1] + pStar * UnitNormal[iDim]; + val_residual[nVar-1] = sM * (IntermediateState[nVar-1] + pStar ) + pStar * ProjInterfaceVel; + } + } + + for (iVar = 0; iVar < nVar; iVar++) + val_residual[iVar] *= Area; + + + if (implicit) { + + if (sM > 0.0) { + + if (sL > 0.0) { + + /*--- Compute Jacobian based on Left State ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + for (jVar = 0; jVar < nVar; jVar++) + val_Jacobian_j[iVar][jVar] = 0; + + + GetInviscidProjJac(Velocity_i, &Enthalpy_i, &Chi_i, &Kappa_i, UnitNormal, 1.0, val_Jacobian_i); + + } + else { + /*--- Compute Jacobian based on Left Star State ---*/ + + EStar = IntermediateState[nVar-1]; + Omega = 1/(sL-sM); + OmegaSM = Omega * sM; + + + /*--------- Left Jacobian ---------*/ + + + /*--- Computing pressure derivatives d/dU_L (PI) ---*/ + + dPI_dU[0] = Chi_i - 0.5 * Kappa_i * sq_vel_i; + for (iDim = 0; iDim < nDim; iDim++) + dPI_dU[iDim+1] = - Kappa_i * Velocity_i[iDim]; + dPI_dU[nVar-1] = Kappa_i; + + + /*--- Computing d/dU_L (Sm) ---*/ + + dSm_dU[0] = ( - ProjVelocity_i * ProjVelocity_i + sM * sL + dPI_dU[0] ) / RHO; + for (iDim = 0; iDim < nDim; iDim++) + dSm_dU[iDim+1] = ( UnitNormal[iDim] * ( 2 * ProjVelocity_i - sL - sM ) + dPI_dU[iDim+1] ) / RHO; + dSm_dU[nVar-1] = dPI_dU[nVar-1] / RHO; + + + /*--- Computing d/dU_L (rhoStar) ---*/ + + drhoStar_dU[0] = Omega * ( sL + IntermediateState[0] * dSm_dU[0] ); + for (iDim = 0; iDim < nDim; iDim++) + drhoStar_dU[iDim+1] = Omega * ( - UnitNormal[iDim] + IntermediateState[0] * dSm_dU[iDim+1] ); + drhoStar_dU[nVar-1] = Omega * IntermediateState[0] * dSm_dU[nVar-1]; + + + /*--- Computing d/dU_L (pStar) ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + dpStar_dU[iVar] = Density_i * (sR - ProjVelocity_j) * dSm_dU[iVar]; + + + /*--- Computing d/dU_L (EStar) ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); + + dEStar_dU[0] += Omega * ProjVelocity_i * ( Enthalpy_i - dPI_dU[0] ); + for (iDim = 0; iDim < nDim; iDim++) + dEStar_dU[iDim+1] += Omega * ( - UnitNormal[iDim] * Enthalpy_i - ProjVelocity_i * dPI_dU[iDim+1] ); + dEStar_dU[nVar-1] += Omega * ( sL - ProjVelocity_i - ProjVelocity_i * dPI_dU[nVar-1] ); + + + + /*--- Jacobian First Row ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_i[0][iVar] = sM * drhoStar_dU[iVar] + IntermediateState[0] * dSm_dU[iVar]; + + /*--- Jacobian Middle Rows ---*/ + + for (jDim = 0; jDim < nDim; jDim++) { + + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_i[jDim+1][iVar] = ( OmegaSM + 1 ) * ( UnitNormal[jDim] * dpStar_dU[iVar] + IntermediateState[jDim+1] * dSm_dU[iVar] ); + + val_Jacobian_i[jDim+1][0] += OmegaSM * Velocity_i[jDim] * ProjVelocity_i; + + val_Jacobian_i[jDim+1][jDim+1] += OmegaSM * (sL - ProjVelocity_i); + + for (iDim = 0; iDim < nDim; iDim++) + val_Jacobian_i[jDim+1][iDim+1] -= OmegaSM * Velocity_i[jDim] * UnitNormal[iDim]; + + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_i[jDim+1][iVar] -= OmegaSM * dPI_dU[iVar] * UnitNormal[jDim]; + } + + /*--- Jacobian Last Row ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_i[nVar-1][iVar] = sM * ( dEStar_dU[iVar] + dpStar_dU[iVar] ) + ( EStar + pStar ) * dSm_dU[iVar]; + + + + + /*--------- Right Jacobian ---------*/ + + + /*--- Computing pressure derivatives d/dU_R (PI) ---*/ + + dPI_dU[0] = Chi_j - 0.5 * Kappa_j * sq_vel_j; + for (iDim = 0; iDim < nDim; iDim++) + dPI_dU[iDim+1] = - Kappa_j * Velocity_j[iDim]; + dPI_dU[nVar-1] = Kappa_j; + + + /*--- Computing d/dU_R (Sm) ---*/ + + dSm_dU[0] = ( ProjVelocity_j * ProjVelocity_j - sM * sR - dPI_dU[0] ) / RHO; + for (iDim = 0; iDim < nDim; iDim++) + dSm_dU[iDim+1] = - ( UnitNormal[iDim] * ( 2 * ProjVelocity_j - sR - sM) + dPI_dU[iDim+1] ) / RHO; + dSm_dU[nVar-1] = - dPI_dU[nVar-1] / RHO; + + + /*--- Computing d/dU_R (pStar) ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + dpStar_dU[iVar] = Density_j * (sL - ProjVelocity_i) * dSm_dU[iVar]; + + + /*--- Computing d/dU_R (EStar) ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); + + + + /*--- Jacobian First Row ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_j[0][iVar] = IntermediateState[0] * ( OmegaSM + 1 ) * dSm_dU[iVar]; + + /*--- Jacobian Middle Rows ---*/ + + for (iDim = 0; iDim < nDim; iDim++) { + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_j[iDim+1][iVar] = ( OmegaSM + 1 ) * ( IntermediateState[iDim+1] * dSm_dU[iVar] + UnitNormal[iDim] * dpStar_dU[iVar] ); + } + + /*--- Jacobian Last Row ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_j[nVar-1][iVar] = sM * (dEStar_dU[iVar] + dpStar_dU[iVar]) + (EStar + pStar) * dSm_dU[iVar]; + } + } + else { + if (sR < 0.0) { + + /*--- Compute Jacobian based on Right State ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + for (jVar = 0; jVar < nVar; jVar++) + val_Jacobian_i[iVar][jVar] = 0; + + GetInviscidProjJac(Velocity_j, &Enthalpy_j, &Chi_j, &Kappa_j, UnitNormal, 1.0, val_Jacobian_j); + + } + else { + /*--- Compute Jacobian based on Right Star State ---*/ + + EStar = IntermediateState[nVar-1]; + Omega = 1/(sR-sM); + OmegaSM = Omega * sM; + + + /*--------- Left Jacobian ---------*/ + + + /*--- Computing pressure derivatives d/dU_L (PI) ---*/ + + dPI_dU[0] = Chi_i - 0.5 * Kappa_i * sq_vel_i; + for (iDim = 0; iDim < nDim; iDim++) + dPI_dU[iDim+1] = - Kappa_i * Velocity_i[iDim]; + dPI_dU[nVar-1] = Kappa_i; + + + /*--- Computing d/dU_L (Sm) ---*/ + + dSm_dU[0] = ( - ProjVelocity_i * ProjVelocity_i + sM * sL + dPI_dU[0] ) / RHO; + for (iDim = 0; iDim < nDim; iDim++) + dSm_dU[iDim+1] = ( UnitNormal[iDim] * ( 2 * ProjVelocity_i - sL - sM ) + dPI_dU[iDim+1] ) / RHO; + dSm_dU[nVar-1] = dPI_dU[nVar-1] / RHO; + + + /*--- Computing d/dU_L (pStar) ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + dpStar_dU[iVar] = Density_i * (sR - ProjVelocity_j) * dSm_dU[iVar]; + + + /*--- Computing d/dU_L (EStar) ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); + + + + /*--- Jacobian First Row ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_i[0][iVar] = IntermediateState[0] * ( OmegaSM + 1 ) * dSm_dU[iVar]; + + /*--- Jacobian Middle Rows ---*/ + + for (iDim = 0; iDim < nDim; iDim++) { + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_i[iDim+1][iVar] = (OmegaSM + 1) * ( IntermediateState[iDim+1] * dSm_dU[iVar] + UnitNormal[iDim] * dpStar_dU[iVar] ); + } + + /*--- Jacobian Last Row ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_i[nVar-1][iVar] = sM * (dEStar_dU[iVar] + dpStar_dU[iVar]) + (EStar + pStar) * dSm_dU[iVar]; + + + + /*--------- Right Jacobian ---------*/ + + + /*--- Computing pressure derivatives d/dU_R (PI) ---*/ + + dPI_dU[0] = Chi_j - 0.5 * Kappa_j * sq_vel_j; + for (iDim = 0; iDim < nDim; iDim++) + dPI_dU[iDim+1] = - Kappa_j * Velocity_j[iDim]; + dPI_dU[nVar-1] = Kappa_j; + + + /*--- Computing d/dU_R (Sm) ---*/ + + dSm_dU[0] = - ( - ProjVelocity_j * ProjVelocity_j + sM * sR + dPI_dU[0] ) / RHO; + for (iDim = 0; iDim < nDim; iDim++) + dSm_dU[iDim+1] = - ( UnitNormal[iDim] * ( 2 * ProjVelocity_j - sR - sM) + dPI_dU[iDim+1] ) / RHO; + dSm_dU[nVar-1] = - dPI_dU[nVar-1] / RHO; + + + /*--- Computing d/dU_R (pStar) ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + dpStar_dU[iVar] = Density_j * (sL - ProjVelocity_i) * dSm_dU[iVar]; + + + /*--- Computing d/dU_R (rhoStar) ---*/ + + drhoStar_dU[0] = Omega * ( sR + IntermediateState[0] * dSm_dU[0] ); + for (iDim = 0; iDim < nDim; iDim++) + drhoStar_dU[iDim+1] = Omega * ( - UnitNormal[iDim] + IntermediateState[0] * dSm_dU[iDim+1] ); + drhoStar_dU[nVar-1] = Omega * IntermediateState[0] * dSm_dU[nVar-1]; + + + /*--- Computing d/dU_R (EStar) ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); + + dEStar_dU[0] += Omega * ProjVelocity_j * ( Enthalpy_j - dPI_dU[0] ); + for (iDim = 0; iDim < nDim; iDim++) + dEStar_dU[iDim+1] += Omega * ( - UnitNormal[iDim] * Enthalpy_j - ProjVelocity_j * dPI_dU[iDim+1] ); + dEStar_dU[nVar-1] += Omega * ( sR - ProjVelocity_j - ProjVelocity_j * dPI_dU[nVar-1] ); + + + + /*--- Jacobian First Row ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_j[0][iVar] = sM * drhoStar_dU[iVar] + IntermediateState[0] * dSm_dU[iVar]; + + /*--- Jacobian Middle Rows ---*/ + + for (jDim = 0; jDim < nDim; jDim++) { + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_j[jDim+1][iVar] = ( OmegaSM + 1 ) * ( UnitNormal[jDim] * dpStar_dU[iVar] + IntermediateState[jDim+1] * dSm_dU[iVar] ); + + val_Jacobian_j[jDim+1][0] += OmegaSM * Velocity_j[jDim] * ProjVelocity_j; + + val_Jacobian_j[jDim+1][jDim+1] += OmegaSM * (sR - ProjVelocity_j); + + for (iDim = 0; iDim < nDim; iDim++) + val_Jacobian_j[jDim+1][iDim+1] -= OmegaSM * Velocity_j[jDim] * UnitNormal[iDim]; + + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_j[jDim+1][iVar] -= OmegaSM * dPI_dU[iVar] * UnitNormal[jDim]; + } + + /*--- Jacobian Last Row ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_j[nVar-1][iVar] = sM * ( dEStar_dU[iVar] + dpStar_dU[iVar] ) + ( EStar + pStar ) * dSm_dU[iVar]; + } + } + + + /*--- Jacobians of the inviscid flux, scale = kappa because val_residual ~ 0.5*(fc_i+fc_j)*Normal ---*/ + + Area *= kappa; + + for (iVar = 0; iVar < nVar; iVar++) { + for (jVar = 0; jVar < nVar; jVar++) { + val_Jacobian_i[iVar][jVar] *= Area; + val_Jacobian_j[iVar][jVar] *= Area; + } + } + + } + +} + +void CUpwGeneralHLLC_Flow::VinokurMontagne() { + + su2double delta_rhoStaticEnergy, delta_rho, delta_p, err_P, s, D; + + delta_rho = Density_j - Density_i; + delta_p = Pressure_j - Pressure_i; + + RoeKappaStaticEnthalpy = 0.5 * ( StaticEnthalpy_i * Kappa_i + StaticEnthalpy_j * Kappa_j ); + + s = RoeChi + RoeKappaStaticEnthalpy; + + D = s*s * delta_rho * delta_rho + delta_p * delta_p; + + delta_rhoStaticEnergy = Density_j * StaticEnergy_j - Density_i * StaticEnergy_i; + + err_P = delta_p - RoeChi * delta_rho - RoeKappa * delta_rhoStaticEnergy; + + if (abs((D - delta_p*err_P)/Density_i) > 1e-3 && abs(delta_rho/Density_i) > 1e-3 && s/Density_i > 1e-3) { + + RoeKappa = ( D * RoeKappa ) / ( D - delta_p * err_P ); + RoeChi = ( D * RoeChi+ s*s * delta_rho * err_P ) / ( D - delta_p * err_P ); + + } +} + +#ifdef CHECK + +int UgpWithCvCompFlow::calcEulerFluxMatrices_HLLC(su2double (*val_Jacobian_i)[5], su2double (*val_Jacobian_j)[5], su2double (*val_Jacobian_i_Scal)[6], su2double (*val_Jacobian_j_Scal)[6], + const su2double Density_i, const su2double *uL, const su2double pL, const su2double TL, const su2double h0, const su2double RL, const su2double gammaL, const su2double *scalL, const su2double kL, + const su2double Density_j, const su2double *uR, const su2double pR, const su2double TR, const su2double h1, const su2double RR, const su2double gammaR, const su2double *scalR, const su2double kR, + const su2double area, const su2double *nVec, const int nScal, const su2double surfVeloc) +{ + + su2double unL = vecDotVec3d(uL, nVec); + su2double uLuL = vecDotVec3d(uL, uL); + su2double cL = sqrt(gammaL*pL/Density_i); + su2double hL = gammaL/(gammaL-1.0)*pL/Density_i + 0.5*uLuL + kL; + // su2double hL = h0 + 0.5*uLuL + kL; + su2double eL = hL*Density_i-pL; + + su2double unR = vecDotVec3d(uR, nVec); + su2double uRuR = vecDotVec3d(uR, uR); + su2double cR = sqrt(gammaR*pR/Density_j); + su2double hR = gammaR/(gammaR-1.0)*pR/Density_j + 0.5*uRuR + kR; + // su2double hR = h1 + 0.5*uRuR + kR; + su2double eR = hR*Density_j-pR; + + + // Roe's aveaging + su2double Rrho = sqrt(Density_j/Density_i); + su2double tmp = 1.0/(1.0+Rrho); + su2double velRoe[3]; + for (int i=0; i<3; i++) + velRoe[i] = tmp*(uL[i] + uR[i]*Rrho); + su2double uRoe = vecDotVec3d(velRoe, nVec); + su2double hRoe = tmp*(hL + hR*Rrho); + + // su2double cRoe = sqrt((gammaL-1.0)*(hRoe- 0.5*vecDotVec3d(velRoe, velRoe))); + su2double gamPdivRho = tmp*((gammaL*pL/Density_i+0.5*(gammaL-1.0)*uLuL) + (gammaR*pR/Density_j+0.5*(gammaR-1.0)*uRuR)*Rrho); + su2double cRoe = sqrt(gamPdivRho - ((gammaL+gammaR)*0.5-1.0)*0.5*vecDotVec3d(velRoe, velRoe)); + + // speed of sound at L and R + su2double sL = min(uRoe-cRoe, unL-cL); + su2double sR = max(uRoe+cRoe, unR+cR); + + // speed of contact surface + su2double sM = (pL-pR-Density_i*unL*(sL-unL)+Density_j*unR*(sR-unR))/(Density_j*(sR-unR)-Density_i*(sL-unL)); + + // pressure at right and left (pR=pL) side of contact surface + su2double pStar = Density_j*(unR-sR)*(unR-sM)+pR; + + if (sM >= 0.0) { + + if (sL > 0.0) { + + su2double nVecArea[3]; + for (int i=0; i<3; i++) nVecArea[i] = nVec[i]*area; + + calcJacobianA(val_Jacobian_i, uL, pL, Density_i, nVecArea, 0.5*(gammaL+gammaR), 0.0); + + for (iVar = 0; iVar < nVar; iVar++) + for (jVar = 0; jVar < nVar; jVar++) + val_Jacobian_j[i][j] = 0.0; + + } + else { + + su2double invSLmSs = 1.0/(sL-sM); + su2double sLmuL = sL-unL; + su2double rhoSL = Density_i*sLmuL*invSLmSs; + su2double rhouSL[3]; + + for (int i=0; i<3; i++) + rhouSL[i] = (Density_i*uL[i]*sLmuL+(pStar-pL)*nVec[i])*invSLmSs; + + su2double eSL = (sLmuL*eL-pL*unL+pStar*sM)*invSLmSs; + su2double gammaLM1 = (gammaL-1.0); + su2double gammaRM1 = (gammaR-1.0); + su2double invrhotld = 1.0/(Density_j*(sR-unR)-Density_i*(sL-unL)); + + su2double dSMdUL[5], dSMdUR[5]; + su2double dpsdUL[5], dpsdUR[5]; + + dSMdUL[0] = -unL*unL + uLuL*gammaLM1/2.0 + sM*sL; + dSMdUL[1] = nVec[0]*(2.0*unL-sL-sM) - gammaLM1*uL[0]; + dSMdUL[2] = nVec[1]*(2.0*unL-sL-sM) - gammaLM1*uL[1]; + dSMdUL[3] = nVec[2]*(2.0*unL-sL-sM) - gammaLM1*uL[2]; + dSMdUL[4] = gammaLM1; + + for (iVar = 0; iVar < nVar; iVar++) + { + dSMdUL[i] *= invrhotld; + dpsdUL[i] = Density_j*(sR-unR)*dSMdUL[i]; + } + + dSMdUR[0] = unR*unR - uRuR*gammaRM1/2.0 - sM*sR; + dSMdUR[1] = -nVec[0]*(2.0*unR-sR-sM) + gammaRM1*uR[0]; + dSMdUR[2] = -nVec[1]*(2.0*unR-sR-sM) + gammaRM1*uR[1]; + dSMdUR[3] = -nVec[2]*(2.0*unR-sR-sM) + gammaRM1*uR[2]; + dSMdUR[4] = -gammaRM1; + + for (iVar = 0; iVar < nVar; iVar++) + { + dSMdUR[i] *= invrhotld; + dpsdUR[i] = Density_i*(sL-unL)*dSMdUR[i]; + } + + calcSubSonicJacobeanHLLC(val_Jacobian_i, val_Jacobian_j, + Density_i, uL, pL, eL, unL, uLuL, sL, + rhoSL, rhouSL, eSL, dSMdUL, + dSMdUR, dpsdUL, dpsdUR, sM, pStar, 0.5*(gammaL+gammaR), nVec); + + for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[0][i] = val_Jacobian_i[0][i]*sM + dSMdUL[i]*rhoSL; + for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[1][i] = val_Jacobian_i[1][i]*sM + dSMdUL[i]*rhouSL[0] + dpsdUL[i]*nVec[0]; + for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[2][i] = val_Jacobian_i[2][i]*sM + dSMdUL[i]*rhouSL[1] + dpsdUL[i]*nVec[1]; + for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[3][i] = val_Jacobian_i[3][i]*sM + dSMdUL[i]*rhouSL[2] + dpsdUL[i]*nVec[2]; + for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[4][i] = (val_Jacobian_i[4][i]+dpsdUL[i])*sM + (eSL+pStar)*dSMdUL[i]; + + for (iVar = 0; iVar < nVar; iVar++) + for (jVar = 0; jVar < nVar; jVar++) + val_Jacobian_i[i][j] *= area; + + for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[0][i] = val_Jacobian_j[0][i]*sM + dSMdUR[i]*rhoSL; + for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[1][i] = val_Jacobian_j[1][i]*sM + dSMdUR[i]*rhouSL[0] + dpsdUR[i]*nVec[0]; + for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[2][i] = val_Jacobian_j[2][i]*sM + dSMdUR[i]*rhouSL[1] + dpsdUR[i]*nVec[1]; + for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[3][i] = val_Jacobian_j[3][i]*sM + dSMdUR[i]*rhouSL[2] + dpsdUR[i]*nVec[2]; + for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[4][i] = (val_Jacobian_j[4][i]+dpsdUR[i])*sM + (eSL+pStar)*dSMdUR[i]; + + for (iVar = 0; iVar < nVar; iVar++) + for (jVar = 0; jVar < nVar; jVar++) + val_Jacobian_j[i][j] *= area; + + } + } + + else { + + if (sR >= 0.0) { + + su2double invSRmSs = 1.0/(sR-sM); + su2double sRmuR = sR-unR; + su2double rhoSR = Density_j*sRmuR*invSRmSs; + su2double rhouSR[3]; + for (int i=0; i<3; i++) + rhouSR[i] = (Density_j*uR[i]*sRmuR+(pStar-pR)*nVec[i])*invSRmSs; + su2double eSR = (sRmuR*eR-pR*unR+pStar*sM)*invSRmSs; + su2double gammaLM1 = (gammaL-1.0); + su2double gammaRM1 = (gammaR-1.0); + su2double invrhotld = 1.0/(Density_j*(sR-unR)-Density_i*(sL-unL)); + + su2double dSMdUL[5], dSMdUR[5]; + su2double dpsdUL[5], dpsdUR[5]; + + dSMdUL[0] = -unL*unL + uLuL*gammaLM1/2.0 + sM*sL; + dSMdUL[1] = nVec[0]*(2.0*unL-sL-sM) - gammaLM1*uL[0]; + dSMdUL[2] = nVec[1]*(2.0*unL-sL-sM) - gammaLM1*uL[1]; + dSMdUL[3] = nVec[2]*(2.0*unL-sL-sM) - gammaLM1*uL[2]; + dSMdUL[4] = gammaLM1; + + for (iVar = 0; iVar < nVar; iVar++) { + dSMdUL[i] *= invrhotld; + dpsdUL[i] = Density_j*(sR-unR)*dSMdUL[i]; + } + + dSMdUR[0] = unR*unR - uRuR*gammaRM1/2.0 - sM*sR; + dSMdUR[1] = -nVec[0]*(2.0*unR-sR-sM) + gammaRM1*uR[0]; + dSMdUR[2] = -nVec[1]*(2.0*unR-sR-sM) + gammaRM1*uR[1]; + dSMdUR[3] = -nVec[2]*(2.0*unR-sR-sM) + gammaRM1*uR[2]; + dSMdUR[4] = -gammaRM1; + + for (iVar = 0; iVar < nVar; iVar++) { + dSMdUR[i] *= invrhotld; + dpsdUR[i] = Density_i*(sL-unL)*dSMdUR[i]; + } + + calcSubSonicJacobeanHLLC(val_Jacobian_j, val_Jacobian_i, + Density_j, uR, pR, eR, unR, uRuR, sR, + rhoSR, rhouSR, eSR, + dSMdUR, dSMdUL, dpsdUR, dpsdUL, sM, pStar, 0.5*(gammaL+gammaR), nVec); + + for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[0][i] = val_Jacobian_i[0][i]*sM + dSMdUL[i]*rhoSR; + for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[1][i] = val_Jacobian_i[1][i]*sM + dSMdUL[i]*rhouSR[0] + dpsdUL[i]*nVec[0]; + for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[2][i] = val_Jacobian_i[2][i]*sM + dSMdUL[i]*rhouSR[1] + dpsdUL[i]*nVec[1]; + for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[3][i] = val_Jacobian_i[3][i]*sM + dSMdUL[i]*rhouSR[2] + dpsdUL[i]*nVec[2]; + for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[4][i] = (val_Jacobian_i[4][i]+dpsdUL[i])*sM + (eSR+pStar)*dSMdUL[i]; + + for (iVar = 0; iVar < nVar; iVar++) + for (jVar = 0; jVar < nVar; jVar++) + val_Jacobian_i[i][j] *= area; + + for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[0][i] = val_Jacobian_j[0][i]*sM + dSMdUR[i]*rhoSR; + for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[1][i] = val_Jacobian_j[1][i]*sM + dSMdUR[i]*rhouSR[0] + dpsdUR[i]*nVec[0]; + for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[2][i] = val_Jacobian_j[2][i]*sM + dSMdUR[i]*rhouSR[1] + dpsdUR[i]*nVec[1]; + for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[3][i] = val_Jacobian_j[3][i]*sM + dSMdUR[i]*rhouSR[2] + dpsdUR[i]*nVec[2]; + for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[4][i] = (val_Jacobian_j[4][i]+dpsdUR[i])*sM + (eSR+pStar)*dSMdUR[i]; + + for (iVar = 0; iVar < nVar; iVar++) + for (jVar = 0; jVar < nVar; jVar++) + val_Jacobian_j[i][j] *= area; + + } + + else { + + su2double nVecArea[3]; + for (int i=0; i<3; i++) nVecArea[i] = nVec[i]*area; + calcJacobianA(val_Jacobian_j, uR, pR, Density_j, nVecArea, 0.5*(gammaL+gammaR), 0.0); + + for (iVar = 0; iVar < nVar; iVar++) + for (jVar = 0; jVar < nVar; jVar++) + val_Jacobian_i[i][j] = 0.0; + + } + + } + +} + +void UgpWithCvCompFlow::calcSubSonicJacobeanHLLC(su2double (*AL)[5], su2double (*AR)[5], + su2double Density_i, const su2double *uL, su2double pL, su2double eL, su2double qL, su2double psiL, su2double SL, + su2double rhoSL, su2double *rhouSL, su2double eSL, + su2double *dSMdUL, su2double *dSMdUR, su2double *dpsdUL, su2double *dpsdUR, su2double SM, su2double pS, + su2double gamma, const su2double *nV) // nV is not normalized +{ + + su2double gammaMinus1 = (gamma-1.0); + su2double omL = 1.0/(SL-SM); + + AL[0][0] = SL + rhoSL*dSMdUL[0]; + AL[0][1] = -nV[0] + rhoSL*dSMdUL[1]; + AL[0][2] = -nV[1] + rhoSL*dSMdUL[2]; + AL[0][3] = -nV[2] + rhoSL*dSMdUL[3]; + AL[0][4] = + rhoSL*dSMdUL[4]; + + AL[1][0] = qL*uL[0] - nV[0]*psiL*gammaMinus1/2.0 + nV[0]*dpsdUL[0] + rhouSL[0]*dSMdUL[0]; + AL[1][1] = SL - qL + nV[0]*(gamma-2.0)*uL[0] + nV[0]*dpsdUL[1] + rhouSL[0]*dSMdUL[1]; + AL[1][2] = - uL[0]*nV[1] + nV[0]*gammaMinus1*uL[1] + nV[0]*dpsdUL[2] + rhouSL[0]*dSMdUL[2]; + AL[1][3] = - uL[0]*nV[2] + nV[0]*gammaMinus1*uL[2] + nV[0]*dpsdUL[3] + rhouSL[0]*dSMdUL[3]; + AL[1][4] = -gammaMinus1*nV[0] + nV[0]*dpsdUL[4] + rhouSL[0]*dSMdUL[4]; + + AL[2][0] = qL*uL[1] - nV[1]*psiL*gammaMinus1/2.0 + nV[1]*dpsdUL[0] + rhouSL[1]*dSMdUL[0]; + AL[2][1] = - uL[1]*nV[0] + nV[1]*gammaMinus1*uL[0] + nV[1]*dpsdUL[1] + rhouSL[1]*dSMdUL[1]; + AL[2][2] = SL - qL + nV[1]*(gamma-2.0)*uL[1] + nV[1]*dpsdUL[2] + rhouSL[1]*dSMdUL[2]; + AL[2][3] = - uL[1]*nV[2] + nV[1]*gammaMinus1*uL[2] + nV[1]*dpsdUL[3] + rhouSL[1]*dSMdUL[3]; + AL[2][4] = -gammaMinus1*nV[1] + nV[1]*dpsdUL[4] + rhouSL[1]*dSMdUL[4]; + + AL[3][0] = qL*uL[2] - nV[2]*psiL*gammaMinus1/2.0 + nV[2]*dpsdUL[0] + rhouSL[2]*dSMdUL[0]; + AL[3][1] = - uL[2]*nV[0] + nV[2]*gammaMinus1*uL[0] + nV[2]*dpsdUL[1] + rhouSL[2]*dSMdUL[1]; + AL[3][2] = - uL[2]*nV[1] + nV[2]*gammaMinus1*uL[1] + nV[2]*dpsdUL[2] + rhouSL[2]*dSMdUL[2]; + AL[3][3] = SL - qL + nV[2]*(gamma-2.0)*uL[2] + nV[2]*dpsdUL[3] + rhouSL[2]*dSMdUL[3]; + AL[3][4] = -gammaMinus1*nV[2] + nV[2]*dpsdUL[4] + rhouSL[2]*dSMdUL[4]; + + AL[4][0] = qL*(eL+pL)/Density_i - qL*psiL*(gamma-1.0)/2.0 + SM*dpsdUL[0] + (pS+eSL)*dSMdUL[0]; + AL[4][1] = - nV[0]*(eL+pL)/Density_i + gammaMinus1*uL[0]*qL + SM*dpsdUL[1] + (pS+eSL)*dSMdUL[1]; + AL[4][2] = - nV[1]*(eL+pL)/Density_i + gammaMinus1*uL[1]*qL + SM*dpsdUL[2] + (pS+eSL)*dSMdUL[2]; + AL[4][3] = - nV[2]*(eL+pL)/Density_i + gammaMinus1*uL[2]*qL + SM*dpsdUL[3] + (pS+eSL)*dSMdUL[3]; + AL[4][4] = SL-qL*gamma + SM*dpsdUL[4] + (pS+eSL)*dSMdUL[4]; + + for (iVar = 0; iVar < nVar; iVar++) + for (jVar = 0; jVar < nVar; jVar++) + AL[i][j] *= omL; + + for (iVar = 0; iVar < nVar; iVar++) AR[0][i] = omL*rhoSL*dSMdUR[i]; + for (iVar = 0; iVar < nVar; iVar++) AR[1][i] = omL*(nV[0]*dpsdUR[i]+rhouSL[0]*dSMdUR[i]); + for (iVar = 0; iVar < nVar; iVar++) AR[2][i] = omL*(nV[1]*dpsdUR[i]+rhouSL[1]*dSMdUR[i]); + for (iVar = 0; iVar < nVar; iVar++) AR[3][i] = omL*(nV[2]*dpsdUR[i]+rhouSL[2]*dSMdUR[i]); + for (iVar = 0; iVar < nVar; iVar++) AR[4][i] = omL*(dpsdUR[i]*SM+(pS+eSL)*dSMdUR[i]); + +} + +void UgpWithCvCompFlow::calcJacobianA(su2double (*A)[5], const su2double *vel, su2double pp, su2double rrho, const su2double *nV, su2double gamma, su2double surfVeloc) // nV is not normalized +{ + + su2double kapm1 = (gamma - 1.0); + + su2double nVel[3]; + nVel[0] = vel[0]*nV[0]; + nVel[1] = vel[1]*nV[1]; + nVel[2] = vel[2]*nV[2]; + su2double U_k = nVel[0]+nVel[1]+nVel[2]; + su2double vSquHlf = 0.5*vecDotVec3d(vel, vel); + su2double c = sqrt(gamma*pp/rrho); + su2double inv_kap_m1 = 1.0/kapm1; + + A[0][0] =-surfVeloc; + A[0][1] = nV[0]; + A[0][2] = nV[1]; + A[0][3] = nV[2]; + A[0][4] = 0.0; + + A[1][0] = -vel[0]*(nVel[1]+nVel[2])+nV[0]*(kapm1*vSquHlf-vel[0]*vel[0]); + A[1][1] = (2.-gamma)*nVel[0]+U_k-surfVeloc; + A[1][2] = vel[0]*nV[1]-kapm1*vel[1]*nV[0]; + A[1][3] = vel[0]*nV[2]-kapm1*vel[2]*nV[0]; + A[1][4] = kapm1*nV[0]; + + A[2][0] = -vel[1]*(nVel[0]+nVel[2])+nV[1]*(kapm1*vSquHlf-vel[1]*vel[1]); + A[2][1] = -kapm1*vel[0]*nV[1]+ vel[1]*nV[0]; + A[2][2] = (2.-gamma)*nVel[1]+U_k-surfVeloc; + A[2][3] = vel[1]*nV[2]-kapm1*vel[2]*nV[1]; + A[2][4] = kapm1*nV[1]; + + A[3][0] = -vel[2]*(nVel[0]+nVel[1])+nV[2]*(kapm1*vSquHlf-vel[2]*vel[2]); + A[3][1] = -kapm1*vel[0]*nV[2]+vel[2]*nV[0]; + A[3][2] = -kapm1*vel[1]*nV[2]+vel[2]*nV[1]; + A[3][3] = (2.-gamma)*nVel[2]+U_k-surfVeloc; + A[3][4] = kapm1*nV[2]; + + A[4][0] = U_k*((gamma-2.)*vSquHlf-c*c*inv_kap_m1); + A[4][1] = c*c*inv_kap_m1*nV[0]-kapm1*vel[0]*(nVel[1]+nVel[2])-(kapm1*vel[0]*vel[0]-vSquHlf)*nV[0]; + A[4][2] = c*c*inv_kap_m1*nV[1]-kapm1*vel[1]*(nVel[0]+nVel[2])-(kapm1*vel[1]*vel[1]-vSquHlf)*nV[1]; + A[4][3] = c*c*inv_kap_m1*nV[2]-kapm1*vel[2]*(nVel[0]+nVel[1])-(kapm1*vel[2]*vel[2]-vSquHlf)*nV[2]; + A[4][4] = gamma*U_k-surfVeloc; + +} + + +#endif + diff --git a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwGeneralRoe_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwGeneralRoe_Flow.cpp new file mode 100644 index 000000000000..d132e73baebc --- /dev/null +++ b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwGeneralRoe_Flow.cpp @@ -0,0 +1,360 @@ +/*! + * \file CUpwGeneralRoe_Flow.cpp + * \brief Implementation of numerics class CUpwGeneralRoe_Flow. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../../include/numerics/flow/convection_upwind/CUpwGeneralRoe_Flow.hpp" + +CUpwGeneralRoe_Flow::CUpwGeneralRoe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ + dynamic_grid = config->GetDynamic_Grid(); + kappa = config->GetRoe_Kappa(); // 1 is unstable + + + Diff_U = new su2double [nVar]; + Velocity_i = new su2double [nDim]; + Velocity_j = new su2double [nDim]; + RoeVelocity = new su2double [nDim]; + delta_vel = new su2double [nDim]; + delta_wave = new su2double [nVar]; + ProjFlux_i = new su2double [nVar]; + ProjFlux_j = new su2double [nVar]; + Lambda = new su2double [nVar]; + Epsilon = new su2double [nVar]; + P_Tensor = new su2double* [nVar]; + invP_Tensor = new su2double* [nVar]; + + for (iVar = 0; iVar < nVar; iVar++) { + P_Tensor[iVar] = new su2double [nVar]; + invP_Tensor[iVar] = new su2double [nVar]; + } +} + +CUpwGeneralRoe_Flow::~CUpwGeneralRoe_Flow(void) { + + delete [] Diff_U; + delete [] Velocity_i; + delete [] Velocity_j; + delete [] RoeVelocity; + delete [] delta_vel; + delete [] delta_wave; + delete [] ProjFlux_i; + delete [] ProjFlux_j; + delete [] Lambda; + delete [] Epsilon; + for (iVar = 0; iVar < nVar; iVar++) { + delete [] P_Tensor[iVar]; + delete [] invP_Tensor[iVar]; + } + delete [] P_Tensor; + delete [] invP_Tensor; + +} + +void CUpwGeneralRoe_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { + + AD::StartPreacc(); + AD::SetPreaccIn(V_i, nDim+4); AD::SetPreaccIn(V_j, nDim+4); AD::SetPreaccIn(Normal, nDim); + AD::SetPreaccIn(S_i, 2); AD::SetPreaccIn(S_j, 2); + if (dynamic_grid) { + AD::SetPreaccIn(GridVel_i, nDim); AD::SetPreaccIn(GridVel_j, nDim); + } + su2double U_i[5] = {0.0,0.0,0.0,0.0,0.0}, U_j[5] = {0.0,0.0,0.0,0.0,0.0}; + + /*--- Face area (norm or the normal vector) ---*/ + + Area = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + Area += Normal[iDim]*Normal[iDim]; + Area = sqrt(Area); + + /*-- Unit Normal ---*/ + + for (iDim = 0; iDim < nDim; iDim++) + UnitNormal[iDim] = Normal[iDim]/Area; + + /*--- Primitive variables at point i ---*/ + + Velocity2_i = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + Velocity_i[iDim] = V_i[iDim+1]; + Velocity2_i += Velocity_i[iDim]*Velocity_i[iDim]; + } + + Pressure_i = V_i[nDim+1]; + Density_i = V_i[nDim+2]; + Enthalpy_i = V_i[nDim+3]; + Energy_i = Enthalpy_i - Pressure_i/Density_i; + StaticEnthalpy_i = Enthalpy_i - 0.5*Velocity2_i; + StaticEnergy_i = StaticEnthalpy_i - Pressure_i/Density_i; + + Kappa_i = S_i[1]/Density_i; + Chi_i = S_i[0] - Kappa_i*StaticEnergy_i; + SoundSpeed_i = sqrt(Chi_i + StaticEnthalpy_i*Kappa_i); + + /*--- Primitive variables at point j ---*/ + + + Velocity2_j = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + Velocity_j[iDim] = V_j[iDim+1]; + Velocity2_j += Velocity_j[iDim]*Velocity_j[iDim]; + } + + Pressure_j = V_j[nDim+1]; + Density_j = V_j[nDim+2]; + Enthalpy_j = V_j[nDim+3]; + Energy_j = Enthalpy_j - Pressure_j/Density_j; + + StaticEnthalpy_j = Enthalpy_j - 0.5*Velocity2_j; + StaticEnergy_j = StaticEnthalpy_j - Pressure_j/Density_j; + + Kappa_j = S_j[1]/Density_j; + Chi_j = S_j[0] - Kappa_j*StaticEnergy_j; + SoundSpeed_j = sqrt(Chi_j + StaticEnthalpy_j*Kappa_j); + + /*--- Recompute conservative variables ---*/ + + U_i[0] = Density_i; U_j[0] = Density_j; + for (iDim = 0; iDim < nDim; iDim++) { + U_i[iDim+1] = Density_i*Velocity_i[iDim]; U_j[iDim+1] = Density_j*Velocity_j[iDim]; + } + U_i[nDim+1] = Density_i*Energy_i; U_j[nDim+1] = Density_j*Energy_j; + +// /*--- Roe-averaged variables at interface between i & j ---*/ + + ComputeRoeAverage(); + + if (RoeSoundSpeed2 <= 0.0) { + for (iVar = 0; iVar < nVar; iVar++) { + val_residual[iVar] = 0.0; + for (jVar = 0; jVar < nVar; jVar++) { + val_Jacobian_i[iVar][iVar] = 0.0; + val_Jacobian_j[iVar][iVar] = 0.0; + } + } + return; + } + + RoeSoundSpeed = sqrt(RoeSoundSpeed2); + + /*--- Compute ProjFlux_i ---*/ + GetInviscidProjFlux(&Density_i, Velocity_i, &Pressure_i, &Enthalpy_i, Normal, ProjFlux_i); + + /*--- Compute ProjFlux_j ---*/ + GetInviscidProjFlux(&Density_j, Velocity_j, &Pressure_j, &Enthalpy_j, Normal, ProjFlux_j); + + /*--- Compute P and Lambda (do it with the Normal) ---*/ + + GetPMatrix(&RoeDensity, RoeVelocity, &RoeSoundSpeed, &RoeEnthalpy, &RoeChi, &RoeKappa, UnitNormal, P_Tensor); + + ProjVelocity = 0.0; ProjVelocity_i = 0.0; ProjVelocity_j = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + ProjVelocity += RoeVelocity[iDim]*UnitNormal[iDim]; + ProjVelocity_i += Velocity_i[iDim]*UnitNormal[iDim]; + ProjVelocity_j += Velocity_j[iDim]*UnitNormal[iDim]; + } + + /*--- Projected velocity adjustment due to mesh motion ---*/ + if (dynamic_grid) { + su2double ProjGridVel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*UnitNormal[iDim]; + } + ProjVelocity -= ProjGridVel; + ProjVelocity_i -= ProjGridVel; + ProjVelocity_j -= ProjGridVel; + } + + /*--- Flow eigenvalues and entropy correctors ---*/ + for (iDim = 0; iDim < nDim; iDim++) + Lambda[iDim] = ProjVelocity; + + Lambda[nVar-2] = ProjVelocity + RoeSoundSpeed; + Lambda[nVar-1] = ProjVelocity - RoeSoundSpeed; + + /*--- Compute absolute value with Mavriplis' entropy correction ---*/ + + MaxLambda = fabs(ProjVelocity) + RoeSoundSpeed; + Delta = config->GetEntropyFix_Coeff(); + + for (iVar = 0; iVar < nVar; iVar++) { + Lambda[iVar] = max(fabs(Lambda[iVar]), Delta*MaxLambda); + } + +// /*--- Harten and Hyman (1983) entropy correction ---*/ +// for (iDim = 0; iDim < nDim; iDim++) +// Epsilon[iDim] = 4.0*max(0.0, max(Lambda[iDim]-ProjVelocity_i, ProjVelocity_j-Lambda[iDim])); +// +// Epsilon[nVar-2] = 4.0*max(0.0, max(Lambda[nVar-2]-(ProjVelocity_i+SoundSpeed_i),(ProjVelocity_j+SoundSpeed_j)-Lambda[nVar-2])); +// Epsilon[nVar-1] = 4.0*max(0.0, max(Lambda[nVar-1]-(ProjVelocity_i-SoundSpeed_i),(ProjVelocity_j-SoundSpeed_j)-Lambda[nVar-1])); +// +// for (iVar = 0; iVar < nVar; iVar++) +// if ( fabs(Lambda[iVar]) < Epsilon[iVar] ) +// Lambda[iVar] = (Lambda[iVar]*Lambda[iVar] + Epsilon[iVar]*Epsilon[iVar])/(2.0*Epsilon[iVar]); +// else +// Lambda[iVar] = fabs(Lambda[iVar]); + +// for (iVar = 0; iVar < nVar; iVar++) +// Lambda[iVar] = fabs(Lambda[iVar]); + + if (!implicit) { + + /*--- Compute wave amplitudes (characteristics) ---*/ + proj_delta_vel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + delta_vel[iDim] = Velocity_j[iDim] - Velocity_i[iDim]; + proj_delta_vel += delta_vel[iDim]*Normal[iDim]; + } + delta_p = Pressure_j - Pressure_i; + delta_rho = Density_j - Density_i; + proj_delta_vel = proj_delta_vel/Area; + + if (nDim == 2) { + delta_wave[0] = delta_rho - delta_p/(RoeSoundSpeed*RoeSoundSpeed); + delta_wave[1] = UnitNormal[1]*delta_vel[0]-UnitNormal[0]*delta_vel[1]; + delta_wave[2] = proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); + delta_wave[3] = -proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); + } else { + delta_wave[0] = delta_rho - delta_p/(RoeSoundSpeed*RoeSoundSpeed); + delta_wave[1] = UnitNormal[0]*delta_vel[2]-UnitNormal[2]*delta_vel[0]; + delta_wave[2] = UnitNormal[1]*delta_vel[0]-UnitNormal[0]*delta_vel[1]; + delta_wave[3] = proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); + delta_wave[4] = -proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); + } + + /*--- Roe's Flux approximation ---*/ + for (iVar = 0; iVar < nVar; iVar++) { + val_residual[iVar] = 0.5*(ProjFlux_i[iVar]+ProjFlux_j[iVar]); + for (jVar = 0; jVar < nVar; jVar++) + val_residual[iVar] -= 0.5*Lambda[jVar]*delta_wave[jVar]*P_Tensor[iVar][jVar]*Area; + } + + /*--- Flux contribution due to grid motion ---*/ + if (dynamic_grid) { + ProjVelocity = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + ProjVelocity += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; + for (iVar = 0; iVar < nVar; iVar++) { + val_residual[iVar] -= ProjVelocity * 0.5*(U_i[iVar]+U_j[iVar]); + } + } + } + else { + + /*--- Compute inverse P ---*/ + + GetPMatrix_inv(invP_Tensor, &RoeDensity, RoeVelocity, &RoeSoundSpeed, &RoeChi , &RoeKappa, UnitNormal); + + /*--- Jacobians of the inviscid flux, scaled by + kappa because val_resconv ~ kappa*(fc_i+fc_j)*Normal ---*/ + + GetInviscidProjJac(Velocity_i, &Enthalpy_i, &Chi_i, &Kappa_i, Normal, kappa, val_Jacobian_i); + + GetInviscidProjJac(Velocity_j, &Enthalpy_j, &Chi_j, &Kappa_j, Normal, kappa, val_Jacobian_j); + + + /*--- Diference variables iPoint and jPoint ---*/ + for (iVar = 0; iVar < nVar; iVar++) + Diff_U[iVar] = U_j[iVar]-U_i[iVar]; + + /*--- Roe's Flux approximation ---*/ + for (iVar = 0; iVar < nVar; iVar++) { + val_residual[iVar] = kappa*(ProjFlux_i[iVar]+ProjFlux_j[iVar]); + for (jVar = 0; jVar < nVar; jVar++) { + Proj_ModJac_Tensor_ij = 0.0; + + /*--- Compute |Proj_ModJac_Tensor| = P x |Lambda| x inverse P ---*/ + + for (kVar = 0; kVar < nVar; kVar++) + Proj_ModJac_Tensor_ij += P_Tensor[iVar][kVar]*Lambda[kVar]*invP_Tensor[kVar][jVar]; + + val_residual[iVar] -= (1.0-kappa)*Proj_ModJac_Tensor_ij*Diff_U[jVar]*Area; + val_Jacobian_i[iVar][jVar] += (1.0-kappa)*Proj_ModJac_Tensor_ij*Area; + val_Jacobian_j[iVar][jVar] -= (1.0-kappa)*Proj_ModJac_Tensor_ij*Area; + } + } + + /*--- Jacobian contributions due to grid motion ---*/ + if (dynamic_grid) { + ProjVelocity = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + ProjVelocity += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; + for (iVar = 0; iVar < nVar; iVar++) { + val_residual[iVar] -= ProjVelocity * 0.5*(U_i[iVar]+U_j[iVar]); + /*--- Implicit terms ---*/ + val_Jacobian_i[iVar][iVar] -= 0.5*ProjVelocity; + val_Jacobian_j[iVar][iVar] -= 0.5*ProjVelocity; + } + } + + } + + AD::SetPreaccOut(val_residual, nVar); + AD::EndPreacc(); +} + + +void CUpwGeneralRoe_Flow::ComputeRoeAverage() { + + //su2double delta_rhoStaticEnergy, err_P, s, D; + // su2double tol = 10-6; + + R = sqrt(fabs(Density_j/Density_i)); + RoeDensity = R*Density_i; + sq_vel = 0; for (iDim = 0; iDim < nDim; iDim++) { + RoeVelocity[iDim] = (R*Velocity_j[iDim]+Velocity_i[iDim])/(R+1); + sq_vel += RoeVelocity[iDim]*RoeVelocity[iDim]; + } + + RoeEnthalpy = (R*Enthalpy_j+Enthalpy_i)/(R+1); + delta_rho = Density_j - Density_i; + delta_p = Pressure_j - Pressure_i; + RoeKappa = 0.5*(Kappa_i + Kappa_j); + RoeKappa = (Kappa_i + Kappa_j + 4*RoeKappa)/6; + RoeChi = 0.5*(Chi_i + Chi_j); + RoeChi = (Chi_i + Chi_j + 4*RoeChi)/6; + + +// RoeKappaStaticEnthalpy = 0.5*(StaticEnthalpy_i*Kappa_i + StaticEnthalpy_j*Kappa_j); +// RoeKappaStaticEnthalpy = (StaticEnthalpy_i*Kappa_i + StaticEnthalpy_j*Kappa_j + 4*RoeKappaStaticEnthalpy)/6; +// s = RoeChi + RoeKappaStaticEnthalpy; +// D = s*s*delta_rho*delta_rho + delta_p*delta_p; +// delta_rhoStaticEnergy = Density_j*StaticEnergy_j - Density_i*StaticEnergy_i; +// err_P = delta_p - RoeChi*delta_rho - RoeKappa*delta_rhoStaticEnergy; +// +// +// if (abs((D - delta_p*err_P)/Density_i)>1e-3 && abs(delta_rho/Density_i)>1e-3 && s/Density_i > 1e-3) { +// +// RoeKappa = (D*RoeKappa)/(D - delta_p*err_P); +// RoeChi = (D*RoeChi+ s*s*delta_rho*err_P)/(D - delta_p*err_P); +// +// } + + RoeSoundSpeed2 = RoeChi + RoeKappa*(RoeEnthalpy-0.5*sq_vel); + +} diff --git a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwHLLC_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwHLLC_Flow.cpp new file mode 100644 index 000000000000..a926c9b9b5ef --- /dev/null +++ b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwHLLC_Flow.cpp @@ -0,0 +1,539 @@ +/*! + * \file CUpwHLLC_Flow.cpp + * \brief Implementation of numerics class CUpwHLLC_Flow. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../../include/numerics/flow/convection_upwind/CUpwHLLC_Flow.hpp" + +CUpwHLLC_Flow::CUpwHLLC_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + kappa = config->GetRoe_Kappa(); + /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ + dynamic_grid = config->GetDynamic_Grid(); + + Gamma = config->GetGamma(); + + Gamma_Minus_One = Gamma - 1.0; + + IntermediateState = new su2double [nVar]; + dSm_dU = new su2double [nVar]; + dPI_dU = new su2double [nVar]; + drhoStar_dU = new su2double [nVar]; + dpStar_dU = new su2double [nVar]; + dEStar_dU = new su2double [nVar]; + + Velocity_i = new su2double [nDim]; + Velocity_j = new su2double [nDim]; + RoeVelocity = new su2double [nDim]; + +} + +CUpwHLLC_Flow::~CUpwHLLC_Flow(void) { + + delete [] IntermediateState; + delete [] dSm_dU; + delete [] dPI_dU; + delete [] drhoStar_dU; + delete [] dpStar_dU; + delete [] dEStar_dU; + + delete [] Velocity_i; + delete [] Velocity_j; + delete [] RoeVelocity; + +} + +void CUpwHLLC_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { + + /*--- Face area (norm or the normal vector) ---*/ + + Area = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + Area += Normal[iDim] * Normal[iDim]; + + Area = sqrt(Area); + + /*-- Unit Normal ---*/ + + for (iDim = 0; iDim < nDim; iDim++) + UnitNormal[iDim] = Normal[iDim] / Area; + + /*-- Fluid velocity at node i,j ---*/ + + for (iDim = 0; iDim < nDim; iDim++) { + Velocity_i[iDim] = V_i[iDim+1]; + Velocity_j[iDim] = V_j[iDim+1]; + } + + /*--- Primitive variables at point i ---*/ + + Pressure_i = V_i[nDim+1]; + Density_i = V_i[nDim+2]; + Enthalpy_i = V_i[nDim+3]; + + /*--- Primitive variables at point j ---*/ + + Pressure_j = V_j[nDim+1]; + Density_j = V_j[nDim+2]; + Enthalpy_j = V_j[nDim+3]; + + + sq_vel_i = 0.0; + sq_vel_j = 0.0; + + for (iDim = 0; iDim < nDim; iDim++) { + sq_vel_i += Velocity_i[iDim] * Velocity_i[iDim]; + sq_vel_j += Velocity_j[iDim] * Velocity_j[iDim]; + } + + Energy_i = Enthalpy_i - Pressure_i / Density_i; + Energy_j = Enthalpy_j - Pressure_j / Density_j; + + SoundSpeed_i = sqrt( (Enthalpy_i - 0.5 * sq_vel_i) * Gamma_Minus_One ); + SoundSpeed_j = sqrt( (Enthalpy_j - 0.5 * sq_vel_j) * Gamma_Minus_One ); + + /*--- Projected velocities ---*/ + + ProjVelocity_i = 0; + ProjVelocity_j = 0; + + for (iDim = 0; iDim < nDim; iDim++) { + ProjVelocity_i += Velocity_i[iDim] * UnitNormal[iDim]; + ProjVelocity_j += Velocity_j[iDim] * UnitNormal[iDim]; + } + + /*--- Projected Grid Velocity ---*/ + + ProjInterfaceVel = 0; + + if (dynamic_grid) { + + for (iDim = 0; iDim < nDim; iDim++) + ProjInterfaceVel += 0.5 * ( GridVel_i[iDim] + GridVel_j[iDim] )*UnitNormal[iDim]; + + SoundSpeed_i -= ProjInterfaceVel; + SoundSpeed_j += ProjInterfaceVel; + + ProjVelocity_i -= ProjInterfaceVel; + ProjVelocity_j -= ProjInterfaceVel; + } + + /*--- Roe's averaging ---*/ + + Rrho = ( sqrt(Density_i) + sqrt(Density_j) ); + + sq_velRoe = 0.0; + RoeProjVelocity = - ProjInterfaceVel; + + for (iDim = 0; iDim < nDim; iDim++) { + RoeVelocity[iDim] = ( Velocity_i[iDim] * sqrt(Density_i) + Velocity_j[iDim] * sqrt(Density_j) ) / Rrho; + sq_velRoe += RoeVelocity[iDim] * RoeVelocity[iDim]; + RoeProjVelocity += RoeVelocity[iDim] * UnitNormal[iDim]; + } + + /*--- Mean Roe variables iPoint and jPoint ---*/ + + RoeDensity = sqrt( Density_i * Density_j ); + RoeEnthalpy = ( sqrt(Density_j) * Enthalpy_j + sqrt(Density_i) * Enthalpy_i) / Rrho; + + /*--- Roe-averaged speed of sound ---*/ + + //RoeSoundSpeed2 = Gamma_Minus_One * ( RoeEnthalpy - 0.5 * sq_velRoe ); + RoeSoundSpeed = sqrt( Gamma_Minus_One * ( RoeEnthalpy - 0.5 * sq_velRoe ) ) - ProjInterfaceVel; + + + /*--- Speed of sound at L and R ---*/ + + sL = min( RoeProjVelocity - RoeSoundSpeed, ProjVelocity_i - SoundSpeed_i); + sR = max( RoeProjVelocity + RoeSoundSpeed, ProjVelocity_j + SoundSpeed_j); + + /*--- speed of contact surface ---*/ + + RHO = Density_j * (sR - ProjVelocity_j) - Density_i * (sL - ProjVelocity_i); + sM = ( Pressure_i - Pressure_j - Density_i * ProjVelocity_i * ( sL - ProjVelocity_i ) + Density_j * ProjVelocity_j * ( sR - ProjVelocity_j ) ) / RHO; + + /*--- Pressure at right and left (Pressure_j=Pressure_i) side of contact surface ---*/ + + pStar = Density_j * ( ProjVelocity_j - sR ) * ( ProjVelocity_j - sM ) + Pressure_j; + + +if (sM > 0.0) { + + if (sL > 0.0) { + + /*--- Compute Left Flux ---*/ + + val_residual[0] = Density_i * ProjVelocity_i; + for (iDim = 0; iDim < nDim; iDim++) + val_residual[iDim+1] = Density_i * Velocity_i[iDim] * ProjVelocity_i + Pressure_i * UnitNormal[iDim]; + val_residual[nVar-1] = Enthalpy_i * Density_i * ProjVelocity_i; + } + else { + + /*--- Compute Flux Left Star from Left Star State ---*/ + + rhoSL = ( sL - ProjVelocity_i ) / ( sL - sM ); + + IntermediateState[0] = rhoSL * Density_i; + for (iDim = 0; iDim < nDim; iDim++) + IntermediateState[iDim+1] = rhoSL * ( Density_i * Velocity_i[iDim] + ( pStar - Pressure_i ) / ( sL - ProjVelocity_i ) * UnitNormal[iDim] ) ; + IntermediateState[nVar-1] = rhoSL * ( Density_i * Energy_i - ( Pressure_i * ProjVelocity_i - pStar * sM) / ( sL - ProjVelocity_i ) ); + + + val_residual[0] = sM * IntermediateState[0]; + for (iDim = 0; iDim < nDim; iDim++) + val_residual[iDim+1] = sM * IntermediateState[iDim+1] + pStar * UnitNormal[iDim]; + val_residual[nVar-1] = sM * ( IntermediateState[nVar-1] + pStar ) + pStar * ProjInterfaceVel; + } + } + else { + + if (sR < 0.0) { + + /*--- Compute Right Flux ---*/ + + val_residual[0] = Density_j * ProjVelocity_j; + for (iDim = 0; iDim < nDim; iDim++) + val_residual[iDim+1] = Density_j * Velocity_j[iDim] * ProjVelocity_j + Pressure_j * UnitNormal[iDim]; + val_residual[nVar-1] = Enthalpy_j * Density_j * ProjVelocity_j; + } + else { + + /*--- Compute Flux Right Star from Right Star State ---*/ + + rhoSR = ( sR - ProjVelocity_j ) / ( sR - sM ); + + IntermediateState[0] = rhoSR * Density_j; + for (iDim = 0; iDim < nDim; iDim++) + IntermediateState[iDim+1] = rhoSR * ( Density_j * Velocity_j[iDim] + ( pStar - Pressure_j ) / ( sR - ProjVelocity_j ) * UnitNormal[iDim] ) ; + IntermediateState[nVar-1] = rhoSR * ( Density_j * Energy_j - ( Pressure_j * ProjVelocity_j - pStar * sM ) / ( sR - ProjVelocity_j ) ); + + + val_residual[0] = sM * IntermediateState[0]; + for (iDim = 0; iDim < nDim; iDim++) + val_residual[iDim+1] = sM * IntermediateState[iDim+1] + pStar * UnitNormal[iDim]; + val_residual[nVar-1] = sM * (IntermediateState[nVar-1] + pStar ) + pStar * ProjInterfaceVel; + } + } + + + for (iVar = 0; iVar < nVar; iVar++) + val_residual[iVar] *= Area; + + + if (implicit) { + + if (sM > 0.0) { + + if (sL > 0.0) { + + /*--- Compute Jacobian based on Left State ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + for (jVar = 0; jVar < nVar; jVar++) + val_Jacobian_j[iVar][jVar] = 0; + + GetInviscidProjJac(Velocity_i, &Energy_i, UnitNormal, 1.0, val_Jacobian_i); + + } + else { + /*--- Compute Jacobian based on Left Star State ---*/ + + EStar = IntermediateState[nVar-1]; + Omega = 1/(sL-sM); + OmegaSM = Omega * sM; + + + /*--------- Left Jacobian ---------*/ + + + /*--- Computing pressure derivatives d/dU_L (PI) ---*/ + + dPI_dU[0] = 0.5 * Gamma_Minus_One * sq_vel_i; + for (iDim = 0; iDim < nDim; iDim++) + dPI_dU[iDim+1] = - Gamma_Minus_One * Velocity_i[iDim]; + dPI_dU[nVar-1] = Gamma_Minus_One; + + + /*--- Computing d/dU_L (Sm) ---*/ + + dSm_dU[0] = ( - ProjVelocity_i * ProjVelocity_i + sM * sL + dPI_dU[0] ) / RHO; + for (iDim = 0; iDim < nDim; iDim++) + dSm_dU[iDim+1] = ( UnitNormal[iDim] * ( 2 * ProjVelocity_i - sL - sM ) + dPI_dU[iDim+1] ) / RHO; + dSm_dU[nVar-1] = dPI_dU[nVar-1] / RHO; + + + /*--- Computing d/dU_L (rhoStar) ---*/ + + drhoStar_dU[0] = Omega * ( sL + IntermediateState[0] * dSm_dU[0] ); + for (iDim = 0; iDim < nDim; iDim++) + drhoStar_dU[iDim+1] = Omega * ( - UnitNormal[iDim] + IntermediateState[0] * dSm_dU[iDim+1] ); + drhoStar_dU[nVar-1] = Omega * IntermediateState[0] * dSm_dU[nVar-1]; + + + /*--- Computing d/dU_L (pStar) ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + dpStar_dU[iVar] = Density_i * (sR - ProjVelocity_j) * dSm_dU[iVar]; + + + /*--- Computing d/dU_L (EStar) ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); + + dEStar_dU[0] += Omega * ProjVelocity_i * ( Enthalpy_i - dPI_dU[0] ); + for (iDim = 0; iDim < nDim; iDim++) + dEStar_dU[iDim+1] += Omega * ( - UnitNormal[iDim] * Enthalpy_i - ProjVelocity_i * dPI_dU[iDim+1] ); + dEStar_dU[nVar-1] += Omega * ( sL - ProjVelocity_i - ProjVelocity_i * dPI_dU[nVar-1] ); + + + + /*--- Jacobian First Row ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_i[0][iVar] = sM * drhoStar_dU[iVar] + IntermediateState[0] * dSm_dU[iVar]; + + /*--- Jacobian Middle Rows ---*/ + + for (jDim = 0; jDim < nDim; jDim++) { + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_i[jDim+1][iVar] = ( OmegaSM + 1 ) * ( UnitNormal[jDim] * dpStar_dU[iVar] + IntermediateState[jDim+1] * dSm_dU[iVar] ); + + val_Jacobian_i[jDim+1][0] += OmegaSM * Velocity_i[jDim] * ProjVelocity_i; + + val_Jacobian_i[jDim+1][jDim+1] += OmegaSM * (sL - ProjVelocity_i); + + for (iDim = 0; iDim < nDim; iDim++) + val_Jacobian_i[jDim+1][iDim+1] -= OmegaSM * Velocity_i[jDim] * UnitNormal[iDim]; + + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_i[jDim+1][iVar] -= OmegaSM * dPI_dU[iVar] * UnitNormal[jDim]; + } + + /*--- Jacobian Last Row ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_i[nVar-1][iVar] = sM * ( dEStar_dU[iVar] + dpStar_dU[iVar] ) + ( EStar + pStar ) * dSm_dU[iVar]; + + + + + /*--------- Right Jacobian ---------*/ + + + /*--- Computing d/dU_R (Sm) ---*/ + + dSm_dU[0] = ( ProjVelocity_j * ProjVelocity_j - sM * sR - 0.5 * Gamma_Minus_One * sq_vel_j ) / RHO; + for (iDim = 0; iDim < nDim; iDim++) + dSm_dU[iDim+1] = - ( UnitNormal[iDim] * ( 2 * ProjVelocity_j - sR - sM) - Gamma_Minus_One * Velocity_j[iDim] ) / RHO; + dSm_dU[nVar-1] = - Gamma_Minus_One / RHO; + + + /*--- Computing d/dU_R (pStar) ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + dpStar_dU[iVar] = Density_j * (sL - ProjVelocity_i) * dSm_dU[iVar]; + + + /*--- Computing d/dU_R (EStar) ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); + + + + /*--- Jacobian First Row ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_j[0][iVar] = IntermediateState[0] * ( OmegaSM + 1 ) * dSm_dU[iVar]; + + /*--- Jacobian Middle Rows ---*/ + + for (iDim = 0; iDim < nDim; iDim++) { + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_j[iDim+1][iVar] = ( OmegaSM + 1 ) * ( IntermediateState[iDim+1] * dSm_dU[iVar] + UnitNormal[iDim] * dpStar_dU[iVar] ); + } + + /*--- Jacobian Last Row ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_j[nVar-1][iVar] = sM * (dEStar_dU[iVar] + dpStar_dU[iVar]) + (EStar + pStar) * dSm_dU[iVar]; + } + } + else { + if (sR < 0.0) { + + /*--- Compute Jacobian based on Right State ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + for (jVar = 0; jVar < nVar; jVar++) + val_Jacobian_i[iVar][jVar] = 0; + + GetInviscidProjJac(Velocity_j, &Energy_j, UnitNormal, 1.0, val_Jacobian_j); + + } + else { + /*--- Compute Jacobian based on Right Star State ---*/ + + EStar = IntermediateState[nVar-1]; + Omega = 1/(sR-sM); + OmegaSM = Omega * sM; + + + /*--------- Left Jacobian ---------*/ + + + /*--- Computing d/dU_L (Sm) ---*/ + + dSm_dU[0] = ( - ProjVelocity_i * ProjVelocity_i + sM * sL + 0.5 * Gamma_Minus_One * sq_vel_i ) / RHO; + for (iDim = 0; iDim < nDim; iDim++) + dSm_dU[iDim+1] = ( UnitNormal[iDim] * ( 2 * ProjVelocity_i - sL - sM ) - Gamma_Minus_One * Velocity_i[iDim] ) / RHO; + dSm_dU[nVar-1] = Gamma_Minus_One / RHO; + + + /*--- Computing d/dU_L (pStar) ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + dpStar_dU[iVar] = Density_i * (sR - ProjVelocity_j) * dSm_dU[iVar]; + + + /*--- Computing d/dU_L (EStar) ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); + + + + /*--- Jacobian First Row ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_i[0][iVar] = IntermediateState[0] * ( OmegaSM + 1 ) * dSm_dU[iVar]; + + /*--- Jacobian Middle Rows ---*/ + + for (iDim = 0; iDim < nDim; iDim++) { + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_i[iDim+1][iVar] = (OmegaSM + 1) * ( IntermediateState[iDim+1] * dSm_dU[iVar] + UnitNormal[iDim] * dpStar_dU[iVar] ); + } + + /*--- Jacobian Last Row ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_i[nVar-1][iVar] = sM * (dEStar_dU[iVar] + dpStar_dU[iVar]) + (EStar + pStar) * dSm_dU[iVar]; + + + + /*--------- Right Jacobian ---------*/ + + + /*--- Computing pressure derivatives d/dU_R (PI) ---*/ + + dPI_dU[0] = 0.5 * Gamma_Minus_One * sq_vel_j; + for (iDim = 0; iDim < nDim; iDim++) + dPI_dU[iDim+1] = - Gamma_Minus_One * Velocity_j[iDim]; + dPI_dU[nVar-1] = Gamma_Minus_One; + + + + /*--- Computing d/dU_R (Sm) ---*/ + + dSm_dU[0] = - ( - ProjVelocity_j * ProjVelocity_j + sM * sR + dPI_dU[0] ) / RHO; + for (iDim = 0; iDim < nDim; iDim++) + dSm_dU[iDim+1] = - ( UnitNormal[iDim] * ( 2 * ProjVelocity_j - sR - sM) + dPI_dU[iDim+1] ) / RHO; + dSm_dU[nVar-1] = - dPI_dU[nVar-1] / RHO; + + + /*--- Computing d/dU_R (pStar) ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + dpStar_dU[iVar] = Density_j * (sL - ProjVelocity_i) * dSm_dU[iVar]; + + + /*--- Computing d/dU_R (rhoStar) ---*/ + + drhoStar_dU[0] = Omega * ( sR + IntermediateState[0] * dSm_dU[0] ); + for (iDim = 0; iDim < nDim; iDim++) + drhoStar_dU[iDim+1] = Omega * ( - UnitNormal[iDim] + IntermediateState[0] * dSm_dU[iDim+1] ); + drhoStar_dU[nVar-1] = Omega * IntermediateState[0] * dSm_dU[nVar-1]; + + + /*--- Computing d/dU_R (EStar) ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); + + dEStar_dU[0] += Omega * ProjVelocity_j * ( Enthalpy_j - dPI_dU[0] ); + for (iDim = 0; iDim < nDim; iDim++) + dEStar_dU[iDim+1] += Omega * ( - UnitNormal[iDim] * Enthalpy_j - ProjVelocity_j * dPI_dU[iDim+1] ); + dEStar_dU[nVar-1] += Omega * ( sR - ProjVelocity_j - ProjVelocity_j * dPI_dU[nVar-1] ); + + + + /*--- Jacobian First Row ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_j[0][iVar] = sM * drhoStar_dU[iVar] + IntermediateState[0] * dSm_dU[iVar]; + + /*--- Jacobian Middle Rows ---*/ + + for (jDim = 0; jDim < nDim; jDim++) { + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_j[jDim+1][iVar] = ( OmegaSM + 1 ) * ( UnitNormal[jDim] * dpStar_dU[iVar] + IntermediateState[jDim+1] * dSm_dU[iVar] ); + + val_Jacobian_j[jDim+1][0] += OmegaSM * Velocity_j[jDim] * ProjVelocity_j; + + val_Jacobian_j[jDim+1][jDim+1] += OmegaSM * (sR - ProjVelocity_j); + + for (iDim = 0; iDim < nDim; iDim++) + val_Jacobian_j[jDim+1][iDim+1] -= OmegaSM * Velocity_j[jDim] * UnitNormal[iDim]; + + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_j[jDim+1][iVar] -= OmegaSM * dPI_dU[iVar] * UnitNormal[jDim]; + } + + /*--- Jacobian Last Row ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_j[nVar-1][iVar] = sM * ( dEStar_dU[iVar] + dpStar_dU[iVar] ) + ( EStar + pStar ) * dSm_dU[iVar]; + + } + } + + + /*--- Jacobians of the inviscid flux, scale = k because val_residual ~ 0.5*(fc_i+fc_j)*Normal ---*/ + + Area *= kappa; + + for (iVar = 0; iVar < nVar; iVar++) { + for (jVar = 0; jVar < nVar; jVar++) { + val_Jacobian_i[iVar][jVar] *= Area; + val_Jacobian_j[iVar][jVar] *= Area; + } + } +} + +} diff --git a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwL2Roe_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwL2Roe_Flow.cpp new file mode 100644 index 000000000000..0c0cd9efb59a --- /dev/null +++ b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwL2Roe_Flow.cpp @@ -0,0 +1,103 @@ +/*! + * \file CUpwL2Roe_Flow.cpp + * \brief Implementation of numerics class CUpwL2Roe_Flow. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../../include/numerics/flow/convection_upwind/CUpwL2Roe_Flow.hpp" + +CUpwL2Roe_Flow::CUpwL2Roe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : + CUpwRoeBase_Flow(val_nDim, val_nVar, config, false) {} + +CUpwL2Roe_Flow::~CUpwL2Roe_Flow() {} + +void CUpwL2Roe_Flow::FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, + su2double **val_Jacobian_j, CConfig *config) { + + /*--- L2Roe: a low dissipation version of Roe's approximate Riemann solver for low Mach numbers. IJNMF 2015 ---*/ + + unsigned short iVar, jVar, kVar, iDim; + + /*--- Clamped Mach number ---*/ + + su2double M_i = 0.0, M_j = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + M_i += Velocity_i[iDim]*Velocity_i[iDim]; + M_j += Velocity_j[iDim]*Velocity_j[iDim]; + } + M_i = sqrt(M_i / fabs(Pressure_i*Gamma/Density_i)); + M_j = sqrt(M_j / fabs(Pressure_j*Gamma/Density_j)); + + su2double zeta = max(0.05,min(max(M_i,M_j),1.0)); + + /*--- Compute wave amplitudes (characteristics) ---*/ + + su2double proj_delta_vel = 0.0, delta_vel[3]; + for (iDim = 0; iDim < nDim; iDim++) { + delta_vel[iDim] = Velocity_j[iDim] - Velocity_i[iDim]; + proj_delta_vel += delta_vel[iDim]*UnitNormal[iDim]; + } + proj_delta_vel *= zeta; + su2double delta_p = Pressure_j - Pressure_i; + su2double delta_rho = Density_j - Density_i; + + su2double delta_wave[5] = {0.0, 0.0, 0.0, 0.0, 0.0}; + if (nDim == 2) { + delta_wave[0] = delta_rho - delta_p/RoeSoundSpeed2; + delta_wave[1] = (UnitNormal[1]*delta_vel[0]-UnitNormal[0]*delta_vel[1])*zeta; + delta_wave[2] = proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); + delta_wave[3] = -proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); + } else { + delta_wave[0] = delta_rho - delta_p/RoeSoundSpeed2; + delta_wave[1] = (UnitNormal[0]*delta_vel[2]-UnitNormal[2]*delta_vel[0])*zeta; + delta_wave[2] = (UnitNormal[1]*delta_vel[0]-UnitNormal[0]*delta_vel[1])*zeta; + delta_wave[3] = proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); + delta_wave[4] = -proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); + } + + /*--- Update residual ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + for (kVar = 0; kVar < nVar; kVar++) + val_residual[iVar] -= (1.0-kappa)*Lambda[kVar]*delta_wave[kVar]*P_Tensor[iVar][kVar]*Area; + + if (!implicit) return; + + /*--- If implicit use the Jacobians of the standard Roe scheme as an approximation ---*/ + + GetPMatrix_inv(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, invP_Tensor); + + for (iVar = 0; iVar < nVar; iVar++) { + for (jVar = 0; jVar < nVar; jVar++) { + /*--- Compute |Proj_ModJac_Tensor| = P x |Lambda| x inverse P ---*/ + su2double Proj_ModJac_Tensor_ij = 0.0; + for (kVar = 0; kVar < nVar; kVar++) + Proj_ModJac_Tensor_ij += P_Tensor[iVar][kVar]*Lambda[kVar]*invP_Tensor[kVar][jVar]; + + val_Jacobian_i[iVar][jVar] += (1.0-kappa)*Proj_ModJac_Tensor_ij*Area; + val_Jacobian_j[iVar][jVar] -= (1.0-kappa)*Proj_ModJac_Tensor_ij*Area; + } + } + +} diff --git a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwLMRoe_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwLMRoe_Flow.cpp new file mode 100644 index 000000000000..618ee0668ffa --- /dev/null +++ b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwLMRoe_Flow.cpp @@ -0,0 +1,103 @@ +/*! + * \file CUpwLMRoe_Flow.cpp + * \brief Implementation of numerics class CUpwLMRoe_Flow. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../../include/numerics/flow/convection_upwind/CUpwLMRoe_Flow.hpp" + +CUpwLMRoe_Flow::CUpwLMRoe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : + CUpwRoeBase_Flow(val_nDim, val_nVar, config, false) {} + +CUpwLMRoe_Flow::~CUpwLMRoe_Flow() {} + +void CUpwLMRoe_Flow::FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, + su2double **val_Jacobian_j, CConfig *config) { + + /*--- Rieper, A low-Mach number fix for Roe's approximate Riemman Solver, JCP 2011 ---*/ + + unsigned short iVar, jVar, kVar, iDim; + + /*--- Clamped Mach number ---*/ + + su2double M_i = 0.0, M_j = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + M_i += Velocity_i[iDim]*Velocity_i[iDim]; + M_j += Velocity_j[iDim]*Velocity_j[iDim]; + } + M_i = sqrt(M_i / fabs(Pressure_i*Gamma/Density_i)); + M_j = sqrt(M_j / fabs(Pressure_j*Gamma/Density_j)); + + su2double zeta = max(0.05,min(max(M_i,M_j),1.0)); + + /*--- Compute wave amplitudes (characteristics) ---*/ + + su2double proj_delta_vel = 0.0, delta_vel[3]; + for (iDim = 0; iDim < nDim; iDim++) { + delta_vel[iDim] = Velocity_j[iDim] - Velocity_i[iDim]; + proj_delta_vel += delta_vel[iDim]*UnitNormal[iDim]; + } + proj_delta_vel *= zeta; + su2double delta_p = Pressure_j - Pressure_i; + su2double delta_rho = Density_j - Density_i; + + su2double delta_wave[5] = {0.0, 0.0, 0.0, 0.0, 0.0}; + if (nDim == 2) { + delta_wave[0] = delta_rho - delta_p/RoeSoundSpeed2; + delta_wave[1] = (UnitNormal[1]*delta_vel[0]-UnitNormal[0]*delta_vel[1]); + delta_wave[2] = proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); + delta_wave[3] = -proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); + } else { + delta_wave[0] = delta_rho - delta_p/RoeSoundSpeed2; + delta_wave[1] = (UnitNormal[0]*delta_vel[2]-UnitNormal[2]*delta_vel[0]); + delta_wave[2] = (UnitNormal[1]*delta_vel[0]-UnitNormal[0]*delta_vel[1]); + delta_wave[3] = proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); + delta_wave[4] = -proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); + } + + /*--- Update residual ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + for (kVar = 0; kVar < nVar; kVar++) + val_residual[iVar] -= (1.0-kappa)*Lambda[kVar]*delta_wave[kVar]*P_Tensor[iVar][kVar]*Area; + + if (!implicit) return; + + /*--- If implicit use the Jacobians of the standard Roe scheme as an approximation ---*/ + + GetPMatrix_inv(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, invP_Tensor); + + for (iVar = 0; iVar < nVar; iVar++) { + for (jVar = 0; jVar < nVar; jVar++) { + /*--- Compute |Proj_ModJac_Tensor| = P x |Lambda| x inverse P ---*/ + su2double Proj_ModJac_Tensor_ij = 0.0; + for (kVar = 0; kVar < nVar; kVar++) + Proj_ModJac_Tensor_ij += P_Tensor[iVar][kVar]*Lambda[kVar]*invP_Tensor[kVar][jVar]; + + val_Jacobian_i[iVar][jVar] += (1.0-kappa)*Proj_ModJac_Tensor_ij*Area; + val_Jacobian_j[iVar][jVar] -= (1.0-kappa)*Proj_ModJac_Tensor_ij*Area; + } + } + +} diff --git a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwMSW_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwMSW_Flow.cpp new file mode 100644 index 000000000000..a4904037681e --- /dev/null +++ b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwMSW_Flow.cpp @@ -0,0 +1,244 @@ +/*! + * \file CUpwMSW_Flow.cpp + * \brief Implementation of numerics class CUpwMSW_Flow. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../../include/numerics/flow/convection_upwind/CUpwMSW_Flow.hpp" + +CUpwMSW_Flow::CUpwMSW_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + if (config->GetDynamic_Grid() && (SU2_MPI::GetRank() == MASTER_NODE)) + cout << "WARNING: Grid velocities are NOT yet considered in the MSW scheme." << endl; + + /*--- Set booleans from CConfig settings ---*/ + implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + + /*--- Allocate arrays ---*/ + Diff_U = new su2double [nVar]; + Fc_i = new su2double [nVar]; + Fc_j = new su2double [nVar]; + Lambda_i = new su2double [nVar]; + Lambda_j = new su2double [nVar]; + + u_i = new su2double [nDim]; + u_j = new su2double [nDim]; + ust_i = new su2double [nDim]; + ust_j = new su2double [nDim]; + Vst_i = new su2double [nPrimVar]; + Vst_j = new su2double [nPrimVar]; + Ust_i = new su2double [nVar]; + Ust_j = new su2double [nVar]; + + Velst_i = new su2double [nDim]; + Velst_j = new su2double [nDim]; + + P_Tensor = new su2double* [nVar]; + invP_Tensor = new su2double* [nVar]; + for (unsigned short iVar = 0; iVar < nVar; iVar++) { + P_Tensor[iVar] = new su2double [nVar]; + invP_Tensor[iVar] = new su2double [nVar]; + } + +} + +CUpwMSW_Flow::~CUpwMSW_Flow(void) { + + delete [] Diff_U; + delete [] Fc_i; + delete [] Fc_j; + delete [] Lambda_i; + delete [] Lambda_j; + + delete [] u_i; + delete [] u_j; + delete [] ust_i; + delete [] ust_j; + delete [] Ust_i; + delete [] Vst_i; + delete [] Ust_j; + delete [] Vst_j; + delete [] Velst_i; + delete [] Velst_j; + + for (unsigned short iVar = 0; iVar < nVar; iVar++) { + delete [] P_Tensor[iVar]; + delete [] invP_Tensor[iVar]; + } + delete [] P_Tensor; + delete [] invP_Tensor; + +} + +void CUpwMSW_Flow::ComputeResidual(su2double *val_residual, + su2double **val_Jacobian_i, + su2double **val_Jacobian_j, CConfig *config) { + + unsigned short iDim, iVar, jVar, kVar; + su2double P_i, P_j; + su2double ProjVel_i, ProjVel_j, ProjVelst_i, ProjVelst_j; + su2double sqvel_i, sqvel_j; + su2double alpha, w, dp, onemw; + su2double Proj_ModJac_Tensor_i, Proj_ModJac_Tensor_j; + + /*--- Set parameters in the numerical method ---*/ + alpha = 6.0; + + /*--- Calculate supporting geometry parameters ---*/ + + Area = 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; + + /*--- Initialize flux & Jacobian vectors ---*/ + + for (iVar = 0; iVar < nVar; iVar++) { + Fc_i[iVar] = 0.0; + Fc_j[iVar] = 0.0; + } + if (implicit) { + for (iVar = 0; iVar < nVar; iVar++) { + for (jVar = 0; jVar < nVar; jVar++) { + val_Jacobian_i[iVar][jVar] = 0.0; + val_Jacobian_j[iVar][jVar] = 0.0; + } + } + } + + /*--- Load variables from nodes i & j ---*/ + + rhos_i = V_i[0]; + rhos_j = V_j[0]; + for (iDim = 0; iDim < nDim; iDim++) { + u_i[iDim] = V_i[iDim+1]; + u_j[iDim] = V_j[iDim+1]; + } + P_i = V_i[nDim+1]; + P_j = V_j[nDim+1]; + + /*--- Calculate supporting quantities ---*/ + + sqvel_i = 0.0; sqvel_j = 0.0; + ProjVel_i = 0.0; ProjVel_j = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + sqvel_i += u_i[iDim]*u_i[iDim]; + sqvel_j += u_j[iDim]*u_j[iDim]; + ProjVel_i += u_i[iDim]*UnitNormal[iDim]; + ProjVel_j += u_j[iDim]*UnitNormal[iDim]; + } + + /*--- Calculate the state weighting function ---*/ + + dp = fabs(P_j-P_i) / min(P_j, P_i); + w = 0.5 * (1.0/(pow(alpha*dp,2.0) +1.0)); + onemw = 1.0 - w; + + /*--- Calculate weighted state vector (*) for i & j ---*/ + + for (iVar = 0; iVar < nVar; iVar++) { + Ust_i[iVar] = onemw*U_i[iVar] + w*U_j[iVar]; + Ust_j[iVar] = onemw*U_j[iVar] + w*U_i[iVar]; + } + for (iVar = 0; iVar < nDim+5; iVar++) { + Vst_i[iVar] = onemw*V_i[iVar] + w*V_j[iVar]; + Vst_j[iVar] = onemw*V_j[iVar] + w*V_i[iVar]; + } + ProjVelst_i = onemw*ProjVel_i + w*ProjVel_j; + ProjVelst_j = onemw*ProjVel_j + w*ProjVel_i; + + for (iDim = 0; iDim < nDim; iDim++) { + Velst_i[iDim] = Vst_i[iDim+1]; + Velst_j[iDim] = Vst_j[iDim+1]; + } + + /*--- Flow eigenvalues at i (Lambda+) ---*/ + + for (iDim = 0; iDim < nDim; iDim++) { + Lambda_i[iDim] = 0.5*(ProjVelst_i + fabs(ProjVelst_i)); + } + + Lambda_i[nDim] = 0.5*( ProjVelst_i + Vst_i[nDim+4] + fabs(ProjVelst_i + Vst_i[nDim+4]) ); + Lambda_i[nDim+1] = 0.5*( ProjVelst_i - Vst_i[nDim+4] + fabs(ProjVelst_i - Vst_i[nDim+4]) ); + + /*--- Compute projected P, invP, and Lambda ---*/ + + GetPMatrix(&Vst_i[nDim+2], Velst_i, &Vst_i[nDim+4], UnitNormal, P_Tensor); + GetPMatrix_inv(&Vst_i[nDim+2], Velst_i, &Vst_i[nDim+4], UnitNormal, invP_Tensor); + + /*--- Projected flux (f+) at i ---*/ + + for (iVar = 0; iVar < nVar; iVar++) { + for (jVar = 0; jVar < nVar; jVar++) { + Proj_ModJac_Tensor_i = 0.0; + + /*--- Compute Proj_ModJac_Tensor = P x Lambda+ x inverse P ---*/ + + for (kVar = 0; kVar < nVar; kVar++) + Proj_ModJac_Tensor_i += P_Tensor[iVar][kVar]*Lambda_i[kVar]*invP_Tensor[kVar][jVar]; + Fc_i[iVar] += Proj_ModJac_Tensor_i*U_i[jVar]*Area; + if (implicit) + val_Jacobian_i[iVar][jVar] += Proj_ModJac_Tensor_i*Area; + } + } + + /*--- Flow eigenvalues at j (Lambda-) ---*/ + + for (iDim = 0; iDim < nDim; iDim++) { + Lambda_j[iDim] = 0.5*(ProjVelst_j - fabs(ProjVelst_j)); + } + Lambda_j[nDim] = 0.5*( ProjVelst_j + Vst_j[nDim+4] - + fabs(ProjVelst_j + Vst_j[nDim+4]) ); + Lambda_j[nDim+1] = 0.5*( ProjVelst_j - Vst_j[nDim+4] - + fabs(ProjVelst_j - Vst_j[nDim+4]) ); + + /*--- Compute projected P, invP, and Lambda ---*/ + + GetPMatrix(&Vst_j[nDim+2], Velst_j, &Vst_j[nDim+4], UnitNormal, P_Tensor); + GetPMatrix_inv(&Vst_j[nDim+2], Velst_j, &Vst_j[nDim+4], UnitNormal, invP_Tensor); + + /*--- Projected flux (f-) ---*/ + + for (iVar = 0; iVar < nVar; iVar++) { + for (jVar = 0; jVar < nVar; jVar++) { + Proj_ModJac_Tensor_j = 0.0; + /*--- Compute Proj_ModJac_Tensor = P x Lambda- x inverse P ---*/ + for (kVar = 0; kVar < nVar; kVar++) + Proj_ModJac_Tensor_j += P_Tensor[iVar][kVar]*Lambda_j[kVar]*invP_Tensor[kVar][jVar]; + Fc_j[iVar] += Proj_ModJac_Tensor_j*U_j[jVar]*Area; + if (implicit) + val_Jacobian_j[iVar][jVar] += Proj_ModJac_Tensor_j*Area; + } + } + + /*--- Flux splitting ---*/ + + for (iVar = 0; iVar < nVar; iVar++) { + val_residual[iVar] = Fc_i[iVar]+Fc_j[iVar]; + } + +} diff --git a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwRoeBase_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwRoeBase_Flow.cpp new file mode 100644 index 000000000000..c74ce0d01e23 --- /dev/null +++ b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwRoeBase_Flow.cpp @@ -0,0 +1,242 @@ +/*! + * \file CUpwRoeBase_Flow.cpp + * \brief Implementation of numerics class CUpwRoeBase_Flow. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../../include/numerics/flow/convection_upwind/CUpwRoeBase_Flow.hpp" + +CUpwRoeBase_Flow::CUpwRoeBase_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, + bool val_low_dissipation) : CNumerics(val_nDim, val_nVar, config) { + + implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ + dynamic_grid = config->GetDynamic_Grid(); + kappa = config->GetRoe_Kappa(); // 1 is unstable + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + + roe_low_dissipation = val_low_dissipation; + + Diff_U = new su2double [nVar]; + Velocity_i = new su2double [nDim]; + Velocity_j = new su2double [nDim]; + RoeVelocity = new su2double [nDim]; + ProjFlux_i = new su2double [nVar]; + ProjFlux_j = new su2double [nVar]; + Conservatives_i = new su2double [nVar]; + Conservatives_j = new su2double [nVar]; + Lambda = new su2double [nVar]; + P_Tensor = new su2double* [nVar]; + invP_Tensor = new su2double* [nVar]; + for (unsigned short iVar = 0; iVar < nVar; iVar++) { + P_Tensor[iVar] = new su2double [nVar]; + invP_Tensor[iVar] = new su2double [nVar]; + } +} + +CUpwRoeBase_Flow::~CUpwRoeBase_Flow(void) { + + delete [] Diff_U; + delete [] Velocity_i; + delete [] Velocity_j; + delete [] RoeVelocity; + delete [] ProjFlux_i; + delete [] ProjFlux_j; + delete [] Conservatives_i; + delete [] Conservatives_j; + delete [] Lambda; + for (unsigned short iVar = 0; iVar < nVar; iVar++) { + delete [] P_Tensor[iVar]; + delete [] invP_Tensor[iVar]; + } + delete [] P_Tensor; + delete [] invP_Tensor; + +} + +void CUpwRoeBase_Flow::FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { +/*--- + CUpwRoeBase_Flow::ComputeResidual initializes the residual (flux) and its Jacobians with the standard Roe averaging + fc_{1/2} = kappa*(fc_i+fc_j)*Normal. It then calls this method, which derived classes specialize, to account for + the dissipation part. +---*/ +} + +void CUpwRoeBase_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { + + unsigned short iVar, jVar, iDim; + su2double ProjGridVel = 0.0, Energy_i, Energy_j; + + AD::StartPreacc(); + AD::SetPreaccIn(V_i, nDim+4); AD::SetPreaccIn(V_j, nDim+4); AD::SetPreaccIn(Normal, nDim); + if (dynamic_grid) { + AD::SetPreaccIn(GridVel_i, nDim); AD::SetPreaccIn(GridVel_j, nDim); + } + if (roe_low_dissipation){ + AD::SetPreaccIn(Sensor_i); AD::SetPreaccIn(Sensor_j); + AD::SetPreaccIn(Dissipation_i); AD::SetPreaccIn(Dissipation_j); + } + + /*--- Face area (norm or the normal vector) and unit normal ---*/ + + 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; + + /*--- Primitive variables at point i ---*/ + + for (iDim = 0; iDim < nDim; iDim++) + Velocity_i[iDim] = V_i[iDim+1]; + Pressure_i = V_i[nDim+1]; + Density_i = V_i[nDim+2]; + Enthalpy_i = V_i[nDim+3]; + Energy_i = Enthalpy_i - Pressure_i/Density_i; + + /*--- Primitive variables at point j ---*/ + + for (iDim = 0; iDim < nDim; iDim++) + Velocity_j[iDim] = V_j[iDim+1]; + Pressure_j = V_j[nDim+1]; + Density_j = V_j[nDim+2]; + Enthalpy_j = V_j[nDim+3]; + Energy_j = Enthalpy_j - Pressure_j/Density_j; + + /*--- Compute variables that are common to the derived schemes ---*/ + + /*--- Roe-averaged variables at interface between i & j ---*/ + + su2double R = sqrt(fabs(Density_j/Density_i)); + RoeDensity = R*Density_i; + su2double sq_vel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + RoeVelocity[iDim] = (R*Velocity_j[iDim]+Velocity_i[iDim])/(R+1); + sq_vel += RoeVelocity[iDim]*RoeVelocity[iDim]; + } + RoeEnthalpy = (R*Enthalpy_j+Enthalpy_i)/(R+1); + RoeSoundSpeed2 = (Gamma-1)*(RoeEnthalpy-0.5*sq_vel); + + /*--- Negative RoeSoundSpeed^2, the jump variables is too large, clear fluxes and exit. ---*/ + + if (RoeSoundSpeed2 <= 0.0) { + for (iVar = 0; iVar < nVar; iVar++) { + val_residual[iVar] = 0.0; + if (implicit){ + for (jVar = 0; jVar < nVar; jVar++) { + val_Jacobian_i[iVar][jVar] = 0.0; + val_Jacobian_j[iVar][jVar] = 0.0; + } + } + } + AD::SetPreaccOut(val_residual, nVar); + AD::EndPreacc(); + return; + } + + RoeSoundSpeed = sqrt(RoeSoundSpeed2); + + /*--- P tensor ---*/ + + GetPMatrix(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, P_Tensor); + + /*--- Projected velocity adjusted for mesh motion ---*/ + + ProjVelocity = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + ProjVelocity += RoeVelocity[iDim]*UnitNormal[iDim]; + + if (dynamic_grid) { + for (iDim = 0; iDim < nDim; iDim++) + ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*UnitNormal[iDim]; + ProjVelocity -= ProjGridVel; + } + + /*--- Flow eigenvalues ---*/ + + for (iDim = 0; iDim < nDim; iDim++) + Lambda[iDim] = ProjVelocity; + + Lambda[nVar-2] = ProjVelocity + RoeSoundSpeed; + Lambda[nVar-1] = ProjVelocity - RoeSoundSpeed; + + /*--- Apply Mavriplis' entropy correction to eigenvalues ---*/ + + su2double MaxLambda = fabs(ProjVelocity) + RoeSoundSpeed; + + for (iVar = 0; iVar < nVar; iVar++) + Lambda[iVar] = max(fabs(Lambda[iVar]), config->GetEntropyFix_Coeff()*MaxLambda); + + /*--- Reconstruct conservative variables ---*/ + + Conservatives_i[0] = Density_i; + Conservatives_j[0] = Density_j; + + for (iDim = 0; iDim < nDim; iDim++) { + Conservatives_i[iDim+1] = Density_i*Velocity_i[iDim]; + Conservatives_j[iDim+1] = Density_j*Velocity_j[iDim]; + } + Conservatives_i[nDim+1] = Density_i*Energy_i; + Conservatives_j[nDim+1] = Density_j*Energy_j; + + /*--- Compute left and right fluxes ---*/ + + GetInviscidProjFlux(&Density_i, Velocity_i, &Pressure_i, &Enthalpy_i, Normal, ProjFlux_i); + GetInviscidProjFlux(&Density_j, Velocity_j, &Pressure_j, &Enthalpy_j, Normal, ProjFlux_j); + + /*--- Initialize residual (flux) and Jacobians ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + val_residual[iVar] = kappa*(ProjFlux_i[iVar]+ProjFlux_j[iVar]); + + if (implicit) { + GetInviscidProjJac(Velocity_i, &Energy_i, Normal, kappa, val_Jacobian_i); + GetInviscidProjJac(Velocity_j, &Energy_j, Normal, kappa, val_Jacobian_j); + } + + /*--- Finalize in children class ---*/ + + FinalizeResidual(val_residual, val_Jacobian_i, val_Jacobian_j, config); + + /*--- Correct for grid motion ---*/ + + if (dynamic_grid) { + for (iVar = 0; iVar < nVar; iVar++) { + val_residual[iVar] -= ProjGridVel*Area * 0.5*(Conservatives_i[iVar]+Conservatives_j[iVar]); + + if (implicit) { + val_Jacobian_i[iVar][iVar] -= 0.5*ProjGridVel*Area; + val_Jacobian_j[iVar][iVar] -= 0.5*ProjGridVel*Area; + } + } + } + + AD::SetPreaccOut(val_residual, nVar); + AD::EndPreacc(); + +} diff --git a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwRoe_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwRoe_Flow.cpp new file mode 100644 index 000000000000..aef4808927f3 --- /dev/null +++ b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwRoe_Flow.cpp @@ -0,0 +1,72 @@ +/*! + * \file CUpwRoe_Flow.cpp + * \brief Implementation of numerics class CUpwRoe_Flow. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../../include/numerics/flow/convection_upwind/CUpwRoe_Flow.hpp" + +CUpwRoe_Flow::CUpwRoe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, + bool val_low_dissipation) : CUpwRoeBase_Flow(val_nDim, val_nVar, config, val_low_dissipation) {} + +CUpwRoe_Flow::~CUpwRoe_Flow() {} + +void CUpwRoe_Flow::FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, + su2double **val_Jacobian_j, CConfig *config) { + + unsigned short iVar, jVar, kVar; + + /*--- Compute inverse P tensor ---*/ + GetPMatrix_inv(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, invP_Tensor); + + /*--- Diference between conservative variables at jPoint and iPoint ---*/ + for (iVar = 0; iVar < nVar; iVar++) + Diff_U[iVar] = Conservatives_j[iVar]-Conservatives_i[iVar]; + + /*--- Low dissipation formulation ---*/ + if (roe_low_dissipation) + SetRoe_Dissipation(Dissipation_i, Dissipation_j, Sensor_i, Sensor_j, Dissipation_ij, config); + else + Dissipation_ij = 1.0; + + /*--- Standard Roe "dissipation" ---*/ + + for (iVar = 0; iVar < nVar; iVar++) { + for (jVar = 0; jVar < nVar; jVar++) { + /*--- Compute |Proj_ModJac_Tensor| = P x |Lambda| x inverse P ---*/ + su2double Proj_ModJac_Tensor_ij = 0.0; + for (kVar = 0; kVar < nVar; kVar++) + Proj_ModJac_Tensor_ij += P_Tensor[iVar][kVar]*Lambda[kVar]*invP_Tensor[kVar][jVar]; + + /*--- Update residual and Jacobians ---*/ + val_residual[iVar] -= (1.0-kappa)*Proj_ModJac_Tensor_ij*Diff_U[jVar]*Area*Dissipation_ij; + + if(implicit){ + val_Jacobian_i[iVar][jVar] += (1.0-kappa)*Proj_ModJac_Tensor_ij*Area; + val_Jacobian_j[iVar][jVar] -= (1.0-kappa)*Proj_ModJac_Tensor_ij*Area; + } + } + } + +} diff --git a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwSLAU_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwSLAU_Flow.cpp new file mode 100644 index 000000000000..72f42417e73e --- /dev/null +++ b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwSLAU_Flow.cpp @@ -0,0 +1,119 @@ +/*! + * \file CUpwSLAU_Flow.cpp + * \brief Implementation of numerics class CUpwSLAU_Flow. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../../include/numerics/flow/convection_upwind/CUpwSLAU_Flow.hpp" + +CUpwSLAU_Flow::CUpwSLAU_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, bool val_low_dissipation) : + CUpwAUSMPLUS_SLAU_Base_Flow(val_nDim, val_nVar, config) { + + slau_low_diss = val_low_dissipation; + slau2 = false; +} + +CUpwSLAU_Flow::~CUpwSLAU_Flow(void) { + +} + +void CUpwSLAU_Flow::ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure) { + + /*--- Project velocities and speed of sound ---*/ + + su2double ProjVelocity_i = 0.0, ProjVelocity_j = 0.0, sq_veli = 0.0, sq_velj = 0.0; + + for (unsigned short iDim = 0; iDim < nDim; iDim++) { + ProjVelocity_i += Velocity_i[iDim]*UnitNormal[iDim]; + ProjVelocity_j += Velocity_j[iDim]*UnitNormal[iDim]; + + sq_veli += Velocity_i[iDim]*Velocity_i[iDim]; + sq_velj += Velocity_j[iDim]*Velocity_j[iDim]; + } + + su2double Energy_i = Enthalpy_i - Pressure_i/Density_i; + SoundSpeed_i = sqrt(fabs(Gamma*Gamma_Minus_One*(Energy_i-0.5*sq_veli))); + + su2double Energy_j = Enthalpy_j - Pressure_j/Density_j; + SoundSpeed_j = sqrt(fabs(Gamma*Gamma_Minus_One*(Energy_j-0.5*sq_velj))); + + /*--- Compute interface speed of sound (aF), and left/right Mach number ---*/ + + su2double aF = 0.5 * (SoundSpeed_i + SoundSpeed_j); + su2double mL = ProjVelocity_i/aF; + su2double mR = ProjVelocity_j/aF; + + /*--- Smooth function of the local Mach number---*/ + + su2double Mach_tilde = min(1.0, (1.0/aF) * sqrt(0.5*(sq_veli+sq_velj))); + su2double Chi = pow((1.0 - Mach_tilde),2.0); + su2double f_rho = -max(min(mL,0.0),-1.0) * min(max(mR,0.0),1.0); + + /*--- Mean normal velocity with density weighting ---*/ + + su2double Vn_Mag = (Density_i*fabs(ProjVelocity_i) + Density_j*fabs(ProjVelocity_j)) / (Density_i + Density_j); + su2double Vn_MagL= (1.0 - f_rho)*Vn_Mag + f_rho*fabs(ProjVelocity_i); + su2double Vn_MagR= (1.0 - f_rho)*Vn_Mag + f_rho*fabs(ProjVelocity_j); + + /*--- Mass flux function ---*/ + + mdot = 0.5 * (Density_i*(ProjVelocity_i+Vn_MagL) + Density_j*(ProjVelocity_j-Vn_MagR) - (Chi/aF)*(Pressure_j-Pressure_i)); + + /*--- Pressure function ---*/ + + su2double BetaL, BetaR, Dissipation_ij; + + if (fabs(mL) < 1.0) BetaL = 0.25*(2.0-mL)*pow((mL+1.0),2.0); + else if (mL >= 0) BetaL = 1.0; + else BetaL = 0.0; + + if (fabs(mR) < 1.0) BetaR = 0.25*(2.0+mR)*pow((mR-1.0),2.0); + else if (mR >= 0) BetaR = 0.0; + else BetaR = 1.0; + + if (slau_low_diss) + SetRoe_Dissipation(Dissipation_i, Dissipation_j, Sensor_i, Sensor_j, Dissipation_ij, config); + else + Dissipation_ij = 1.0; + + pressure = 0.5*(Pressure_i+Pressure_j) + 0.5*(BetaL-BetaR)*(Pressure_i-Pressure_j); + + if (!slau2) pressure += Dissipation_ij*(1.0-Chi)*(BetaL+BetaR-1.0)*0.5*(Pressure_i+Pressure_j); + else pressure += Dissipation_ij*sqrt(0.5*(sq_veli+sq_velj))*(BetaL+BetaR-1.0)*aF*0.5*(Density_i+Density_j); + +} + + +CUpwSLAU2_Flow::CUpwSLAU2_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, bool val_low_dissipation) : + CUpwSLAU_Flow(val_nDim, val_nVar, config, val_low_dissipation) { + + /*--- The difference between SLAU and SLAU2 is minimal, so we derive from SLAU and set this flag + so that the ComputeMassAndPressureFluxes function modifies the pressure according to SLAU2. + This is safe since this constructor is guaranteed to execute after SLAU's one. ---*/ + slau2 = true; +} + +CUpwSLAU2_Flow::~CUpwSLAU2_Flow(void) { + +} diff --git a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwTurkel_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwTurkel_Flow.cpp new file mode 100644 index 000000000000..985f77b2ea4e --- /dev/null +++ b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwTurkel_Flow.cpp @@ -0,0 +1,257 @@ +/*! + * \file CUpwTurkel_Flow.cpp + * \brief Implementation of numerics class CUpwTurkel_Flow. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../../include/numerics/flow/convection_upwind/CUpwTurkel_Flow.hpp" + +CUpwTurkel_Flow::CUpwTurkel_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ + dynamic_grid = config->GetDynamic_Grid(); + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + + Beta_min = config->GetminTurkelBeta(); + Beta_max = config->GetmaxTurkelBeta(); + + Diff_U = new su2double [nVar]; + Velocity_i = new su2double [nDim]; + Velocity_j = new su2double [nDim]; + RoeVelocity = new su2double [nDim]; + ProjFlux_i = new su2double [nVar]; + ProjFlux_j = new su2double [nVar]; + Lambda = new su2double [nVar]; + Epsilon = new su2double [nVar]; + absPeJac = new su2double* [nVar]; + invRinvPe = new su2double* [nVar]; + R_Tensor = new su2double* [nVar]; + Matrix = new su2double* [nVar]; + Art_Visc = new su2double* [nVar]; + for (iVar = 0; iVar < nVar; iVar++) { + absPeJac[iVar] = new su2double [nVar]; + invRinvPe[iVar] = new su2double [nVar]; + Matrix[iVar] = new su2double [nVar]; + Art_Visc[iVar] = new su2double [nVar]; + R_Tensor[iVar] = new su2double [nVar]; + } +} + +CUpwTurkel_Flow::~CUpwTurkel_Flow(void) { + + delete [] Diff_U; + delete [] Velocity_i; + delete [] Velocity_j; + delete [] RoeVelocity; + delete [] ProjFlux_i; + delete [] ProjFlux_j; + delete [] Lambda; + delete [] Epsilon; + for (iVar = 0; iVar < nVar; iVar++) { + delete [] absPeJac[iVar]; + delete [] invRinvPe[iVar]; + delete [] Matrix[iVar]; + delete [] Art_Visc[iVar]; + delete [] R_Tensor[iVar]; + } + delete [] Matrix; + delete [] Art_Visc; + delete [] absPeJac; + delete [] invRinvPe; + delete [] R_Tensor; + +} + +void CUpwTurkel_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { + + su2double U_i[5] = {0.0,0.0,0.0,0.0,0.0}, U_j[5] = {0.0,0.0,0.0,0.0,0.0}; + + /*--- Face area (norm or the normal vector) ---*/ + + Area = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + Area += Normal[iDim]*Normal[iDim]; + Area = sqrt(Area); + + /*-- Unit Normal ---*/ + + for (iDim = 0; iDim < nDim; iDim++) + UnitNormal[iDim] = Normal[iDim]/Area; + + /*--- Primitive variables at point i ---*/ + + for (iDim = 0; iDim < nDim; iDim++) + Velocity_i[iDim] = V_i[iDim+1]; + Pressure_i = V_i[nDim+1]; + Density_i = V_i[nDim+2]; + Enthalpy_i = V_i[nDim+3]; + Energy_i = Enthalpy_i - Pressure_i/Density_i; + SoundSpeed_i = sqrt(fabs(Pressure_i*Gamma/Density_i)); + + /*--- Primitive variables at point j ---*/ + + for (iDim = 0; iDim < nDim; iDim++) + Velocity_j[iDim] = V_j[iDim+1]; + Pressure_j = V_j[nDim+1]; + Density_j = V_j[nDim+2]; + Enthalpy_j = V_j[nDim+3]; + Energy_j = Enthalpy_j - Pressure_j/Density_j; + SoundSpeed_j = sqrt(fabs(Pressure_j*Gamma/Density_j)); + + /*--- Recompute conservative variables ---*/ + + U_i[0] = Density_i; U_j[0] = Density_j; + for (iDim = 0; iDim < nDim; iDim++) { + U_i[iDim+1] = Density_i*Velocity_i[iDim]; U_j[iDim+1] = Density_j*Velocity_j[iDim]; + } + U_i[nDim+1] = Density_i*Energy_i; U_j[nDim+1] = Density_j*Energy_j; + + /*--- Roe-averaged variables at interface between i & j ---*/ + + R = sqrt(fabs(Density_j/Density_i)); + RoeDensity = R*Density_i; + sq_vel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + RoeVelocity[iDim] = (R*Velocity_j[iDim]+Velocity_i[iDim])/(R+1); + sq_vel += RoeVelocity[iDim]*RoeVelocity[iDim]; + } + RoeEnthalpy = (R*Enthalpy_j+Enthalpy_i)/(R+1); + RoeSoundSpeed = sqrt(fabs((Gamma-1)*(RoeEnthalpy-0.5*sq_vel))); + RoePressure = RoeDensity/Gamma*RoeSoundSpeed*RoeSoundSpeed; + + /*--- Compute ProjFlux_i ---*/ + GetInviscidProjFlux(&Density_i, Velocity_i, &Pressure_i, &Enthalpy_i, Normal, ProjFlux_i); + + /*--- Compute ProjFlux_j ---*/ + GetInviscidProjFlux(&Density_j, Velocity_j, &Pressure_j, &Enthalpy_j, Normal, ProjFlux_j); + + ProjVelocity = 0.0; ProjVelocity_i = 0.0; ProjVelocity_j = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + ProjVelocity += RoeVelocity[iDim]*UnitNormal[iDim]; + ProjVelocity_i += Velocity_i[iDim]*UnitNormal[iDim]; + ProjVelocity_j += Velocity_j[iDim]*UnitNormal[iDim]; + } + + /*--- Projected velocity adjustment due to mesh motion ---*/ + if (dynamic_grid) { + su2double ProjGridVel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*UnitNormal[iDim]; + } + ProjVelocity -= ProjGridVel; + ProjVelocity_i -= ProjGridVel; + ProjVelocity_j -= ProjGridVel; + } + + /*--- First few flow eigenvalues of A.Normal with the normal---*/ + for (iDim = 0; iDim < nDim; iDim++) + Lambda[iDim] = ProjVelocity; + + local_Mach = sqrt(sq_vel)/RoeSoundSpeed; + Beta = max(Beta_min, min(local_Mach, Beta_max)); + Beta2 = Beta*Beta; + + one_m_Betasqr = 1.0 - Beta2; // 1-Beta*Beta + one_p_Betasqr = 1.0 + Beta2; // 1+Beta*Beta + sqr_one_m_Betasqr_Lam1 = pow((one_m_Betasqr*Lambda[0]),2); // [(1-Beta^2)*Lambda[0]]^2 + sqr_two_Beta_c_Area = pow(2.0*Beta*RoeSoundSpeed*Area,2); // [2*Beta*c*Area]^2 + + /*--- The rest of the flow eigenvalues of preconditioned matrix---*/ + Lambda[nVar-2] = 0.5 * ( one_p_Betasqr*Lambda[0] + sqrt( sqr_one_m_Betasqr_Lam1 + sqr_two_Beta_c_Area)); + Lambda[nVar-1] = 0.5 * ( one_p_Betasqr*Lambda[0] - sqrt( sqr_one_m_Betasqr_Lam1 + sqr_two_Beta_c_Area)); + + s_hat = 1.0/Area * (Lambda[nVar-1] - Lambda[0]*Beta2); + r_hat = 1.0/Area * (Lambda[nVar-2] - Lambda[0]*Beta2); + t_hat = 0.5/Area * (Lambda[nVar-1] - Lambda[nVar-2]); + rhoB2a2 = RoeDensity*Beta2*RoeSoundSpeed*RoeSoundSpeed; + + /*--- Diference variables iPoint and jPoint and absolute value of the eigen values---*/ + for (iVar = 0; iVar < nVar; iVar++) { + Diff_U[iVar] = U_j[iVar]-U_i[iVar]; + Lambda[iVar] = fabs(Lambda[iVar]); + } + + /*--- Compute the absolute Preconditioned Jacobian in entropic Variables (do it with the Unitary Normal) ---*/ + GetPrecondJacobian(Beta2, r_hat, s_hat, t_hat, rhoB2a2, Lambda, UnitNormal, absPeJac); + + /*--- Compute the matrix from entropic variables to conserved variables ---*/ + GetinvRinvPe(Beta2, RoeEnthalpy, RoeSoundSpeed, RoeDensity, RoeVelocity, invRinvPe); + + /*--- Compute the matrix from entropic variables to conserved variables ---*/ + GetRMatrix(RoePressure, RoeSoundSpeed, RoeDensity, RoeVelocity, R_Tensor); + + if (implicit) { + /*--- Jacobians of the inviscid flux, scaled by + 0.5 because val_residual ~ 0.5*(fc_i+fc_j)*Normal ---*/ + GetInviscidProjJac(Velocity_i, &Energy_i, Normal, 0.5, val_Jacobian_i); + GetInviscidProjJac(Velocity_j, &Energy_j, Normal, 0.5, val_Jacobian_j); + } + + for (iVar = 0; iVar < nVar; iVar ++) { + for (jVar = 0; jVar < nVar; jVar ++) { + Matrix[iVar][jVar] = 0.0; + for (kVar = 0; kVar < nVar; kVar++) + Matrix[iVar][jVar] += absPeJac[iVar][kVar]*R_Tensor[kVar][jVar]; + } + } + + for (iVar = 0; iVar < nVar; iVar ++) { + for (jVar = 0; jVar < nVar; jVar ++) { + Art_Visc[iVar][jVar] = 0.0; + for (kVar = 0; kVar < nVar; kVar++) + Art_Visc[iVar][jVar] += invRinvPe[iVar][kVar]*Matrix[kVar][jVar]; + } + } + + /*--- Roe's Flux approximation ---*/ + for (iVar = 0; iVar < nVar; iVar++) { + val_residual[iVar] = 0.5*(ProjFlux_i[iVar]+ProjFlux_j[iVar]); + for (jVar = 0; jVar < nVar; jVar++) { + val_residual[iVar] -= 0.5*Art_Visc[iVar][jVar]*Diff_U[jVar]; + if (implicit) { + val_Jacobian_i[iVar][jVar] += 0.5*Art_Visc[iVar][jVar]; + val_Jacobian_j[iVar][jVar] -= 0.5*Art_Visc[iVar][jVar]; + } + } + } + + /*--- Contributions due to mesh motion---*/ + if (dynamic_grid) { + ProjVelocity = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + ProjVelocity += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*UnitNormal[iDim]; + for (iVar = 0; iVar < nVar; iVar++) { + val_residual[iVar] -= ProjVelocity * 0.5*(U_i[iVar]+U_j[iVar]); + /*--- Implicit terms ---*/ + if (implicit) { + val_Jacobian_i[iVar][iVar] -= 0.5*ProjVelocity; + val_Jacobian_j[iVar][iVar] -= 0.5*ProjVelocity; + } + } + } + +} diff --git a/SU2_CFD/src/numerics/flow/diffusion/CAvgGradInc_Flow.cpp b/SU2_CFD/src/numerics/flow/diffusion/CAvgGradInc_Flow.cpp new file mode 100644 index 000000000000..a2c3a9eddf92 --- /dev/null +++ b/SU2_CFD/src/numerics/flow/diffusion/CAvgGradInc_Flow.cpp @@ -0,0 +1,274 @@ +/*! + * \file CAvgGradInc_Flow.cpp + * \brief Implementation of numerics class CAvgGradInc_Flow. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../../include/numerics/flow/diffusion/CAvgGradInc_Flow.hpp" + +CAvgGradInc_Flow::CAvgGradInc_Flow(unsigned short val_nDim, + unsigned short val_nVar, + bool val_correct_grad, CConfig *config) + : CAvgGrad_Base(val_nDim, val_nVar, val_nDim+3, val_correct_grad, config) { + + energy = config->GetEnergy_Equation(); + +} + +CAvgGradInc_Flow::~CAvgGradInc_Flow(void) { +} + +void CAvgGradInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { + + AD::StartPreacc(); + AD::SetPreaccIn(V_i, nDim+9); AD::SetPreaccIn(V_j, nDim+9); + AD::SetPreaccIn(Coord_i, nDim); AD::SetPreaccIn(Coord_j, nDim); + AD::SetPreaccIn(PrimVar_Grad_i, nVar, nDim); + AD::SetPreaccIn(PrimVar_Grad_j, nVar, nDim); + AD::SetPreaccIn(turb_ke_i); AD::SetPreaccIn(turb_ke_j); + AD::SetPreaccIn(Normal, nDim); + + unsigned short iVar, jVar, iDim; + + /*--- Normalized normal vector ---*/ + + 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; + + for (iVar = 0; iVar < nPrimVar; iVar++) { + PrimVar_i[iVar] = V_i[iVar]; + PrimVar_j[iVar] = V_j[iVar]; + Mean_PrimVar[iVar] = 0.5*(PrimVar_i[iVar]+PrimVar_j[iVar]); + } + + /*--- Compute vector going from iPoint to jPoint ---*/ + + dist_ij_2 = 0.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]; + } + + /*--- Density and transport properties ---*/ + + Laminar_Viscosity_i = V_i[nDim+4]; Laminar_Viscosity_j = V_j[nDim+4]; + Eddy_Viscosity_i = V_i[nDim+5]; Eddy_Viscosity_j = V_j[nDim+5]; + Thermal_Conductivity_i = V_i[nDim+6]; Thermal_Conductivity_j = V_j[nDim+6]; + + /*--- Mean transport properties ---*/ + + Mean_Laminar_Viscosity = 0.5*(Laminar_Viscosity_i + Laminar_Viscosity_j); + Mean_Eddy_Viscosity = 0.5*(Eddy_Viscosity_i + Eddy_Viscosity_j); + Mean_turb_ke = 0.5*(turb_ke_i + turb_ke_j); + Mean_Thermal_Conductivity = 0.5*(Thermal_Conductivity_i + Thermal_Conductivity_j); + + /*--- Mean gradient approximation ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + for (iDim = 0; iDim < nDim; iDim++) + Mean_GradPrimVar[iVar][iDim] = 0.5*(PrimVar_Grad_i[iVar][iDim] + PrimVar_Grad_j[iVar][iDim]); + + /*--- Projection of the mean gradient in the direction of the edge ---*/ + + if (correct_gradient && dist_ij_2 != 0.0) { + CorrectGradient(Mean_GradPrimVar, PrimVar_i, PrimVar_j, Edge_Vector, + dist_ij_2, nVar); + } + + /*--- Get projected flux tensor ---*/ + SetStressTensor(Mean_PrimVar, Mean_GradPrimVar, Mean_turb_ke, + Mean_Laminar_Viscosity, Mean_Eddy_Viscosity); + GetViscousIncProjFlux(Mean_GradPrimVar, Normal, Mean_Thermal_Conductivity); + + /*--- Update viscous residual ---*/ + + for (iVar = 0; iVar < nVar; iVar++) { + val_residual[iVar] = Proj_Flux_Tensor[iVar]; + } + + /*--- Implicit part ---*/ + + if (implicit) { + + if (dist_ij_2 == 0.0) { + for (iVar = 0; iVar < nVar; iVar++) { + for (jVar = 0; jVar < nVar; jVar++) { + val_Jacobian_i[iVar][jVar] = 0.0; + val_Jacobian_j[iVar][jVar] = 0.0; + } + } + } else { + + const su2double dist_ij = sqrt(dist_ij_2); + SetIncTauJacobian(Mean_Laminar_Viscosity, Mean_Eddy_Viscosity, + dist_ij, UnitNormal); + GetViscousIncProjJacs(Area, val_Jacobian_i, val_Jacobian_j); + + /*--- Include the temperature equation Jacobian. ---*/ + su2double proj_vector_ij = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + proj_vector_ij += (Coord_j[iDim]-Coord_i[iDim])*Normal[iDim]; + } + proj_vector_ij = proj_vector_ij/dist_ij_2; + val_Jacobian_i[nDim+1][nDim+1] = -Mean_Thermal_Conductivity*proj_vector_ij; + val_Jacobian_j[nDim+1][nDim+1] = Mean_Thermal_Conductivity*proj_vector_ij; + } + + } + + if (!energy) { + val_residual[nDim+1] = 0.0; + if (implicit) { + for (iVar = 0; iVar < nVar; iVar++) { + val_Jacobian_i[iVar][nDim+1] = 0.0; + val_Jacobian_j[iVar][nDim+1] = 0.0; + + val_Jacobian_i[nDim+1][iVar] = 0.0; + val_Jacobian_j[nDim+1][iVar] = 0.0; + } + } + } + + AD::SetPreaccOut(val_residual, nVar); + AD::EndPreacc(); + +} + +void CAvgGradInc_Flow::GetViscousIncProjFlux(const su2double* const *val_gradprimvar, + const su2double *val_normal, + su2double val_thermal_conductivity) { + + /*--- Gradient of primitive variables -> [Pressure vel_x vel_y vel_z Temperature] ---*/ + + if (nDim == 2) { + Flux_Tensor[0][0] = 0.0; + Flux_Tensor[1][0] = tau[0][0]; + Flux_Tensor[2][0] = tau[0][1]; + Flux_Tensor[3][0] = val_thermal_conductivity*val_gradprimvar[nDim+1][0]; + + Flux_Tensor[0][1] = 0.0; + Flux_Tensor[1][1] = tau[1][0]; + Flux_Tensor[2][1] = tau[1][1]; + Flux_Tensor[3][1] = val_thermal_conductivity*val_gradprimvar[nDim+1][1]; + + } else { + + Flux_Tensor[0][0] = 0.0; + Flux_Tensor[1][0] = tau[0][0]; + Flux_Tensor[2][0] = tau[0][1]; + Flux_Tensor[3][0] = tau[0][2]; + Flux_Tensor[4][0] = val_thermal_conductivity*val_gradprimvar[nDim+1][0]; + + Flux_Tensor[0][1] = 0.0; + Flux_Tensor[1][1] = tau[1][0]; + Flux_Tensor[2][1] = tau[1][1]; + Flux_Tensor[3][1] = tau[1][2]; + Flux_Tensor[4][1] = val_thermal_conductivity*val_gradprimvar[nDim+1][1]; + + Flux_Tensor[0][2] = 0.0; + Flux_Tensor[1][2] = tau[2][0]; + Flux_Tensor[2][2] = tau[2][1]; + Flux_Tensor[3][2] = tau[2][2]; + Flux_Tensor[4][2] = val_thermal_conductivity*val_gradprimvar[nDim+1][2]; + + } + + for (unsigned short iVar = 0; iVar < nVar; iVar++) { + Proj_Flux_Tensor[iVar] = 0.0; + for (unsigned short iDim = 0; iDim < nDim; iDim++) + Proj_Flux_Tensor[iVar] += Flux_Tensor[iVar][iDim] * val_normal[iDim]; + } + +} + +void CAvgGradInc_Flow::GetViscousIncProjJacs(su2double val_dS, + su2double **val_Proj_Jac_Tensor_i, + su2double **val_Proj_Jac_Tensor_j) { + + if (nDim == 2) { + + val_Proj_Jac_Tensor_i[0][0] = 0.0; + val_Proj_Jac_Tensor_i[0][1] = 0.0; + val_Proj_Jac_Tensor_i[0][2] = 0.0; + val_Proj_Jac_Tensor_i[0][3] = 0.0; + + val_Proj_Jac_Tensor_i[1][0] = val_dS*tau_jacobian_i[0][0]; + val_Proj_Jac_Tensor_i[1][1] = val_dS*tau_jacobian_i[0][1]; + val_Proj_Jac_Tensor_i[1][2] = val_dS*tau_jacobian_i[0][2]; + val_Proj_Jac_Tensor_i[1][3] = val_dS*tau_jacobian_i[0][3]; + + val_Proj_Jac_Tensor_i[2][0] = val_dS*tau_jacobian_i[1][0]; + val_Proj_Jac_Tensor_i[2][1] = val_dS*tau_jacobian_i[1][1]; + val_Proj_Jac_Tensor_i[2][2] = val_dS*tau_jacobian_i[1][2]; + val_Proj_Jac_Tensor_i[2][3] = val_dS*tau_jacobian_i[1][3]; + + val_Proj_Jac_Tensor_i[3][0] = 0.0; + val_Proj_Jac_Tensor_i[3][1] = 0.0; + val_Proj_Jac_Tensor_i[3][2] = 0.0; + val_Proj_Jac_Tensor_i[3][3] = 0.0; + + } else { + + val_Proj_Jac_Tensor_i[0][0] = 0.0; + val_Proj_Jac_Tensor_i[0][1] = 0.0; + val_Proj_Jac_Tensor_i[0][2] = 0.0; + val_Proj_Jac_Tensor_i[0][3] = 0.0; + val_Proj_Jac_Tensor_i[0][4] = 0.0; + + val_Proj_Jac_Tensor_i[1][0] = val_dS*tau_jacobian_i[0][0]; + val_Proj_Jac_Tensor_i[1][1] = val_dS*tau_jacobian_i[0][1]; + val_Proj_Jac_Tensor_i[1][2] = val_dS*tau_jacobian_i[0][2]; + val_Proj_Jac_Tensor_i[1][3] = val_dS*tau_jacobian_i[0][3]; + val_Proj_Jac_Tensor_i[1][4] = val_dS*tau_jacobian_i[0][4]; + + val_Proj_Jac_Tensor_i[2][0] = val_dS*tau_jacobian_i[1][0]; + val_Proj_Jac_Tensor_i[2][1] = val_dS*tau_jacobian_i[1][1]; + val_Proj_Jac_Tensor_i[2][2] = val_dS*tau_jacobian_i[1][2]; + val_Proj_Jac_Tensor_i[2][3] = val_dS*tau_jacobian_i[1][3]; + val_Proj_Jac_Tensor_i[2][4] = val_dS*tau_jacobian_i[1][4]; + + val_Proj_Jac_Tensor_i[3][0] = val_dS*tau_jacobian_i[2][0]; + val_Proj_Jac_Tensor_i[3][1] = val_dS*tau_jacobian_i[2][1]; + val_Proj_Jac_Tensor_i[3][2] = val_dS*tau_jacobian_i[2][2]; + val_Proj_Jac_Tensor_i[3][3] = val_dS*tau_jacobian_i[2][3]; + val_Proj_Jac_Tensor_i[3][4] = val_dS*tau_jacobian_i[2][4]; + + val_Proj_Jac_Tensor_i[4][0] = 0.0; + val_Proj_Jac_Tensor_i[4][1] = 0.0; + val_Proj_Jac_Tensor_i[4][2] = 0.0; + val_Proj_Jac_Tensor_i[4][3] = 0.0; + val_Proj_Jac_Tensor_i[4][4] = 0.0; + + } + + for (unsigned short iVar = 0; iVar < nVar; iVar++) + for (unsigned short jVar = 0; jVar < nVar; jVar++) + val_Proj_Jac_Tensor_j[iVar][jVar] = -val_Proj_Jac_Tensor_i[iVar][jVar]; + +} diff --git a/SU2_CFD/src/numerics/flow/diffusion/CAvgGrad_Base.cpp b/SU2_CFD/src/numerics/flow/diffusion/CAvgGrad_Base.cpp new file mode 100644 index 000000000000..d7e9d361616e --- /dev/null +++ b/SU2_CFD/src/numerics/flow/diffusion/CAvgGrad_Base.cpp @@ -0,0 +1,560 @@ +/*! + * \file CAvgGrad_Base.cpp + * \brief Implementation of numerics class CAvgGrad_Base. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../../include/numerics/flow/diffusion/CAvgGrad_Base.hpp" + +CAvgGrad_Base::CAvgGrad_Base(unsigned short val_nDim, + unsigned short val_nVar, + unsigned short val_nPrimVar, + bool val_correct_grad, + CConfig *config) + : CNumerics(val_nDim, val_nVar, config), + nPrimVar(val_nPrimVar), + correct_gradient(val_correct_grad) { + + unsigned short iVar, iDim; + + implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + + TauWall_i = 0; TauWall_j = 0; + + PrimVar_i = new su2double [nPrimVar]; + PrimVar_j = new su2double [nPrimVar]; + Mean_PrimVar = new su2double [nPrimVar]; + + Mean_GradPrimVar = new su2double* [nPrimVar]; + for (iVar = 0; iVar < nPrimVar; iVar++) + Mean_GradPrimVar[iVar] = new su2double [nDim]; + + Edge_Vector = new su2double[nDim]; + + if (correct_gradient) { + Proj_Mean_GradPrimVar_Edge = new su2double[val_nPrimVar]; + } else { + Proj_Mean_GradPrimVar_Edge = NULL; + } + + tau_jacobian_i = new su2double* [nDim]; + for (iDim = 0; iDim < nDim; iDim++) { + tau_jacobian_i[iDim] = new su2double [nVar]; + } + heat_flux_vector = new su2double[nDim]; + heat_flux_jac_i = new su2double[nVar]; + +} + +CAvgGrad_Base::~CAvgGrad_Base() { + + delete [] PrimVar_i; + delete [] PrimVar_j; + delete [] Mean_PrimVar; + for (unsigned short iVar = 0; iVar < nPrimVar; iVar++) + delete [] Mean_GradPrimVar[iVar]; + delete [] Mean_GradPrimVar; + + if (tau_jacobian_i != NULL) { + for (unsigned short iDim = 0; iDim < nDim; iDim++) { + delete [] tau_jacobian_i[iDim]; + } + delete [] tau_jacobian_i; + } + if (heat_flux_vector != NULL) { + delete [] heat_flux_vector; + } + if (heat_flux_jac_i != NULL) { + delete [] heat_flux_jac_i; + } + + delete [] Edge_Vector; + if (Proj_Mean_GradPrimVar_Edge != NULL) + delete [] Proj_Mean_GradPrimVar_Edge; +} + +void CAvgGrad_Base::CorrectGradient(su2double** GradPrimVar, + const su2double* val_PrimVar_i, + const su2double* val_PrimVar_j, + const su2double* val_edge_vector, + const su2double val_dist_ij_2, + const unsigned short val_nPrimVar) { + for (unsigned short iVar = 0; iVar < val_nPrimVar; iVar++) { + Proj_Mean_GradPrimVar_Edge[iVar] = 0.0; + for (unsigned short iDim = 0; iDim < nDim; iDim++) { + Proj_Mean_GradPrimVar_Edge[iVar] += GradPrimVar[iVar][iDim]*val_edge_vector[iDim]; + } + for (unsigned short iDim = 0; iDim < nDim; iDim++) { + GradPrimVar[iVar][iDim] -= (Proj_Mean_GradPrimVar_Edge[iVar] - + (val_PrimVar_j[iVar]-val_PrimVar_i[iVar]))*val_edge_vector[iDim] / val_dist_ij_2; + } + } +} + +void CAvgGrad_Base::SetStressTensor(const su2double *val_primvar, + const su2double* const *val_gradprimvar, + const su2double val_turb_ke, + const su2double val_laminar_viscosity, + const su2double val_eddy_viscosity) { + + unsigned short iDim, jDim; + const su2double Density = val_primvar[nDim+2]; + const su2double total_viscosity = val_laminar_viscosity + val_eddy_viscosity; + + su2double div_vel = 0.0; + for (iDim = 0 ; iDim < nDim; iDim++) + div_vel += val_gradprimvar[iDim+1][iDim]; + + /* --- If UQ methodology is used, calculate tau using the perturbed reynolds stress tensor --- */ + + if (using_uq){ + for (iDim = 0 ; iDim < nDim; iDim++) + for (jDim = 0 ; jDim < nDim; jDim++) + tau[iDim][jDim] = val_laminar_viscosity*( val_gradprimvar[jDim+1][iDim] + val_gradprimvar[iDim+1][jDim] ) + - TWO3*val_laminar_viscosity*div_vel*delta[iDim][jDim] - Density * MeanPerturbedRSM[iDim][jDim]; + + } else { + + 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]; + } +} + +void CAvgGrad_Base::AddQCR(const su2double* const *val_gradprimvar) { + + su2double den_aux, c_cr1= 0.3, O_ik, O_jk; + unsigned short iDim, jDim, kDim; + + /*--- Denominator Antisymmetric normalized rotation tensor ---*/ + + den_aux = 0.0; + for (iDim = 0 ; iDim < nDim; iDim++) + for (jDim = 0 ; jDim < nDim; jDim++) + den_aux += val_gradprimvar[iDim+1][jDim] * val_gradprimvar[iDim+1][jDim]; + den_aux = sqrt(max(den_aux,1E-10)); + + /*--- Adding the QCR contribution ---*/ + + for (iDim = 0 ; iDim < nDim; iDim++){ + for (jDim = 0 ; jDim < nDim; jDim++){ + for (kDim = 0 ; kDim < nDim; kDim++){ + O_ik = (val_gradprimvar[iDim+1][kDim] - val_gradprimvar[kDim+1][iDim])/ den_aux; + O_jk = (val_gradprimvar[jDim+1][kDim] - val_gradprimvar[kDim+1][jDim])/ den_aux; + tau[iDim][jDim] -= c_cr1 * ((O_ik * tau[jDim][kDim]) + (O_jk * tau[iDim][kDim])); + } + } + } +} + +void CAvgGrad_Base::AddTauWall(const su2double *val_normal, + const su2double val_tau_wall) { + + unsigned short iDim, jDim; + su2double TauNormal, TauElem[3], TauTangent[3], WallShearStress, Area, UnitNormal[3]; + + Area = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + Area += val_normal[iDim]*val_normal[iDim]; + Area = sqrt(Area); + + for (iDim = 0; iDim < nDim; iDim++) + UnitNormal[iDim] = val_normal[iDim]/Area; + + /*--- First, compute wall shear stress as the magnitude of the wall-tangential + component of the shear stress tensor---*/ + + for (iDim = 0; iDim < nDim; iDim++) { + TauElem[iDim] = 0.0; + for (jDim = 0; jDim < nDim; jDim++) + TauElem[iDim] += tau[iDim][jDim]*UnitNormal[jDim]; + } + + TauNormal = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + TauNormal += TauElem[iDim] * UnitNormal[iDim]; + + for (iDim = 0; iDim < nDim; iDim++) + TauTangent[iDim] = TauElem[iDim] - TauNormal * UnitNormal[iDim]; + + WallShearStress = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + WallShearStress += TauTangent[iDim]*TauTangent[iDim]; + WallShearStress = sqrt(WallShearStress); + + /*--- Scale the stress tensor by the ratio of the wall shear stress + to the computed representation of the shear stress ---*/ + + for (iDim = 0 ; iDim < nDim; iDim++) + for (jDim = 0 ; jDim < nDim; jDim++) + tau[iDim][jDim] = tau[iDim][jDim]*(val_tau_wall/WallShearStress); +} + +void CAvgGrad_Base::GetMeanRateOfStrainMatrix(su2double **S_ij) const +{ + /* --- Calculate the rate of strain tensor, using mean velocity gradients --- */ + + if (nDim == 3){ + S_ij[0][0] = Mean_GradPrimVar[1][0]; + S_ij[1][1] = Mean_GradPrimVar[2][1]; + S_ij[2][2] = Mean_GradPrimVar[3][2]; + S_ij[0][1] = 0.5 * (Mean_GradPrimVar[1][1] + Mean_GradPrimVar[2][0]); + S_ij[0][2] = 0.5 * (Mean_GradPrimVar[1][2] + Mean_GradPrimVar[3][0]); + S_ij[1][2] = 0.5 * (Mean_GradPrimVar[2][2] + Mean_GradPrimVar[3][1]); + S_ij[1][0] = S_ij[0][1]; + S_ij[2][1] = S_ij[1][2]; + S_ij[2][0] = S_ij[0][2]; + } + else { + S_ij[0][0] = Mean_GradPrimVar[1][0]; + S_ij[1][1] = Mean_GradPrimVar[2][1]; + S_ij[2][2] = 0.0; + S_ij[0][1] = 0.5 * (Mean_GradPrimVar[1][1] + Mean_GradPrimVar[2][0]); + S_ij[0][2] = 0.0; + S_ij[1][2] = 0.0; + S_ij[1][0] = S_ij[0][1]; + S_ij[2][1] = S_ij[1][2]; + S_ij[2][0] = S_ij[0][2]; + + } +} + +void CAvgGrad_Base::SetReynoldsStressMatrix(su2double turb_ke){ + unsigned short iDim, jDim; + su2double **S_ij = new su2double* [3]; + su2double muT = Mean_Eddy_Viscosity; + su2double divVel = 0; + su2double density; + su2double TWO3 = 2.0/3.0; + density = Mean_PrimVar[nDim+2]; + + for (iDim = 0; iDim < 3; iDim++){ + S_ij[iDim] = new su2double [3]; + } + + + GetMeanRateOfStrainMatrix(S_ij); + + /* --- Using rate of strain matrix, calculate Reynolds stress tensor --- */ + + for (iDim = 0; iDim < 3; iDim++){ + divVel += S_ij[iDim][iDim]; + } + + for (iDim = 0; iDim < 3; iDim++){ + for (jDim = 0; jDim < 3; jDim++){ + MeanReynoldsStress[iDim][jDim] = TWO3 * turb_ke * delta3[iDim][jDim] + - muT / density * (2 * S_ij[iDim][jDim] - TWO3 * divVel * delta3[iDim][jDim]); + } + } + + for (iDim = 0; iDim < 3; iDim++) + delete [] S_ij[iDim]; + delete [] S_ij; +} + +void CAvgGrad_Base::SetPerturbedRSM(su2double turb_ke, CConfig *config){ + + unsigned short iDim,jDim; + + /* --- Calculate anisotropic part of Reynolds Stress tensor --- */ + + for (iDim = 0; iDim< 3; iDim++){ + for (jDim = 0; jDim < 3; jDim++){ + A_ij[iDim][jDim] = .5 * MeanReynoldsStress[iDim][jDim] / turb_ke - delta3[iDim][jDim] / 3.0; + Eig_Vec[iDim][jDim] = A_ij[iDim][jDim]; + } + } + + /* --- Get ordered eigenvectors and eigenvalues of A_ij --- */ + + EigenDecomposition(A_ij, Eig_Vec, Eig_Val, 3); + + /* compute convex combination coefficients */ + su2double c1c = Eig_Val[2] - Eig_Val[1]; + su2double c2c = 2.0 * (Eig_Val[1] - Eig_Val[0]); + su2double c3c = 3.0 * Eig_Val[0] + 1.0; + + /* define barycentric traingle corner points */ + Corners[0][0] = 1.0; + Corners[0][1] = 0.0; + Corners[1][0] = 0.0; + Corners[1][1] = 0.0; + Corners[2][0] = 0.5; + Corners[2][1] = 0.866025; + + /* define barycentric coordinates */ + Barycentric_Coord[0] = Corners[0][0] * c1c + Corners[1][0] * c2c + Corners[2][0] * c3c; + Barycentric_Coord[1] = Corners[0][1] * c1c + Corners[1][1] * c2c + Corners[2][1] * c3c; + + if (Eig_Val_Comp == 1) { + /* 1C turbulence */ + New_Coord[0] = Corners[0][0]; + New_Coord[1] = Corners[0][1]; + } + else if (Eig_Val_Comp== 2) { + /* 2C turbulence */ + New_Coord[0] = Corners[1][0]; + New_Coord[1] = Corners[1][1]; + } + else if (Eig_Val_Comp == 3) { + /* 3C turbulence */ + New_Coord[0] = Corners[2][0]; + New_Coord[1] = Corners[2][1]; + } + else { + /* 2C turbulence */ + New_Coord[0] = Corners[1][0]; + New_Coord[1] = Corners[1][1]; + } + + /* calculate perturbed barycentric coordinates */ + Barycentric_Coord[0] = Barycentric_Coord[0] + (uq_delta_b) * (New_Coord[0] - Barycentric_Coord[0]); + Barycentric_Coord[1] = Barycentric_Coord[1] + (uq_delta_b) * (New_Coord[1] - Barycentric_Coord[1]); + + /* rebuild c1c,c2c,c3c based on perturbed barycentric coordinates */ + c3c = Barycentric_Coord[1] / Corners[2][1]; + c1c = Barycentric_Coord[0] - Corners[2][0] * c3c; + c2c = 1 - c1c - c3c; + + /* build new anisotropy eigenvalues */ + Eig_Val[0] = (c3c - 1) / 3.0; + Eig_Val[1] = 0.5 *c2c + Eig_Val[0]; + Eig_Val[2] = c1c + Eig_Val[1]; + + /* permute eigenvectors if required */ + if (uq_permute) { + for (iDim=0; iDim<3; iDim++) { + for (jDim=0; jDim<3; jDim++) { + New_Eig_Vec[iDim][jDim] = Eig_Vec[2-iDim][jDim]; + } + } + } + + else { + for (iDim=0; iDim<3; iDim++) { + for (jDim=0; jDim<3; jDim++) { + New_Eig_Vec[iDim][jDim] = Eig_Vec[iDim][jDim]; + } + } + } + + EigenRecomposition(newA_ij, New_Eig_Vec, Eig_Val, 3); + + /* compute perturbed Reynolds stress matrix; use under-relaxation factor (uq_urlx)*/ + for (iDim = 0; iDim< 3; iDim++){ + for (jDim = 0; jDim < 3; jDim++){ + MeanPerturbedRSM[iDim][jDim] = 2.0 * turb_ke * (newA_ij[iDim][jDim] + 1.0/3.0 * delta3[iDim][jDim]); + MeanPerturbedRSM[iDim][jDim] = MeanReynoldsStress[iDim][jDim] + + uq_urlx*(MeanPerturbedRSM[iDim][jDim] - MeanReynoldsStress[iDim][jDim]); + } + } + +} + + +void CAvgGrad_Base::SetTauJacobian(const su2double *val_Mean_PrimVar, + const su2double val_laminar_viscosity, + const su2double val_eddy_viscosity, + const su2double val_dist_ij, + const su2double *val_normal) { + + /*--- QCR and wall functions are **not** accounted for here ---*/ + + const su2double Density = val_Mean_PrimVar[nDim+2]; + const su2double total_viscosity = val_laminar_viscosity + val_eddy_viscosity; + const su2double xi = total_viscosity/(Density*val_dist_ij); + + for (unsigned short iDim = 0; iDim < nDim; iDim++) { + for (unsigned short jDim = 0; jDim < nDim; jDim++) { + // Jacobian w.r.t. momentum + tau_jacobian_i[iDim][jDim+1] = -xi*(delta[iDim][jDim] + val_normal[iDim]*val_normal[jDim]/3.0); + } + // Jacobian w.r.t. density + tau_jacobian_i[iDim][0] = 0; + for (unsigned short jDim = 0; jDim < nDim; jDim++) { + tau_jacobian_i[iDim][0] -= tau_jacobian_i[iDim][jDim+1]*val_Mean_PrimVar[jDim+1]; + } + // Jacobian w.r.t. energy + tau_jacobian_i[iDim][nDim+1] = 0; + } +} + +void CAvgGrad_Base::SetIncTauJacobian(const su2double val_laminar_viscosity, + const su2double val_eddy_viscosity, + const su2double val_dist_ij, + const su2double *val_normal) { + + const su2double total_viscosity = val_laminar_viscosity + val_eddy_viscosity; + const su2double xi = total_viscosity/val_dist_ij; + + for (unsigned short iDim = 0; iDim < nDim; iDim++) { + tau_jacobian_i[iDim][0] = 0; + for (unsigned short jDim = 0; jDim < nDim; jDim++) { + tau_jacobian_i[iDim][jDim+1] = -xi*(delta[iDim][jDim] + val_normal[iDim]*val_normal[jDim]/3.0); + } + tau_jacobian_i[iDim][nDim+1] = 0; + } +} + +void CAvgGrad_Base::GetViscousProjFlux(const su2double *val_primvar, + const su2double *val_normal) { + + /*--- Primitive variables -> [Temp vel_x vel_y vel_z Pressure] ---*/ + + if (nDim == 2) { + Flux_Tensor[0][0] = 0.0; + Flux_Tensor[1][0] = tau[0][0]; + Flux_Tensor[2][0] = tau[0][1]; + Flux_Tensor[3][0] = tau[0][0]*val_primvar[1] + tau[0][1]*val_primvar[2]+ + heat_flux_vector[0]; + Flux_Tensor[0][1] = 0.0; + Flux_Tensor[1][1] = tau[1][0]; + Flux_Tensor[2][1] = tau[1][1]; + Flux_Tensor[3][1] = tau[1][0]*val_primvar[1] + tau[1][1]*val_primvar[2]+ + heat_flux_vector[1]; + } else { + Flux_Tensor[0][0] = 0.0; + Flux_Tensor[1][0] = tau[0][0]; + Flux_Tensor[2][0] = tau[0][1]; + Flux_Tensor[3][0] = tau[0][2]; + Flux_Tensor[4][0] = tau[0][0]*val_primvar[1] + tau[0][1]*val_primvar[2] + tau[0][2]*val_primvar[3] + + heat_flux_vector[0]; + Flux_Tensor[0][1] = 0.0; + Flux_Tensor[1][1] = tau[1][0]; + Flux_Tensor[2][1] = tau[1][1]; + Flux_Tensor[3][1] = tau[1][2]; + Flux_Tensor[4][1] = tau[1][0]*val_primvar[1] + tau[1][1]*val_primvar[2] + tau[1][2]*val_primvar[3] + + heat_flux_vector[1]; + Flux_Tensor[0][2] = 0.0; + Flux_Tensor[1][2] = tau[2][0]; + Flux_Tensor[2][2] = tau[2][1]; + Flux_Tensor[3][2] = tau[2][2]; + Flux_Tensor[4][2] = tau[2][0]*val_primvar[1] + tau[2][1]*val_primvar[2] + tau[2][2]*val_primvar[3] + + heat_flux_vector[2]; + } + + for (unsigned short iVar = 0; iVar < nVar; iVar++) { + Proj_Flux_Tensor[iVar] = 0.0; + for (unsigned short iDim = 0; iDim < nDim; iDim++) + Proj_Flux_Tensor[iVar] += Flux_Tensor[iVar][iDim] * val_normal[iDim]; + } + +} + +void CAvgGrad_Base::GetViscousProjJacs(const su2double *val_Mean_PrimVar, + const su2double val_dS, + const su2double *val_Proj_Visc_Flux, + su2double **val_Proj_Jac_Tensor_i, + su2double **val_Proj_Jac_Tensor_j) { + + const su2double Density = val_Mean_PrimVar[nDim+2]; + const su2double factor = 0.5/Density; + + if (nDim == 2) { + + val_Proj_Jac_Tensor_i[0][0] = 0.0; + val_Proj_Jac_Tensor_i[0][1] = 0.0; + val_Proj_Jac_Tensor_i[0][2] = 0.0; + val_Proj_Jac_Tensor_i[0][3] = 0.0; + val_Proj_Jac_Tensor_i[1][0] = val_dS*tau_jacobian_i[0][0]; + val_Proj_Jac_Tensor_i[1][1] = val_dS*tau_jacobian_i[0][1]; + val_Proj_Jac_Tensor_i[1][2] = val_dS*tau_jacobian_i[0][2]; + val_Proj_Jac_Tensor_i[1][3] = val_dS*tau_jacobian_i[0][3]; + val_Proj_Jac_Tensor_i[2][0] = val_dS*tau_jacobian_i[1][0]; + val_Proj_Jac_Tensor_i[2][1] = val_dS*tau_jacobian_i[1][1]; + val_Proj_Jac_Tensor_i[2][2] = val_dS*tau_jacobian_i[1][2]; + val_Proj_Jac_Tensor_i[2][3] = val_dS*tau_jacobian_i[1][3]; + const su2double contraction = tau_jacobian_i[0][0]*val_Mean_PrimVar[1] + + tau_jacobian_i[1][0]*val_Mean_PrimVar[2]; + val_Proj_Jac_Tensor_i[3][0] = val_dS*(contraction - heat_flux_jac_i[0]); + val_Proj_Jac_Tensor_i[3][1] = -val_dS*(tau_jacobian_i[0][0] + heat_flux_jac_i[1]); + val_Proj_Jac_Tensor_i[3][2] = -val_dS*(tau_jacobian_i[1][0] + heat_flux_jac_i[2]); + val_Proj_Jac_Tensor_i[3][3] = -val_dS*heat_flux_jac_i[3]; + + for (unsigned short iVar = 0; iVar < nVar; iVar++) + for (unsigned short jVar = 0; jVar < nVar; jVar++) + val_Proj_Jac_Tensor_j[iVar][jVar] = -val_Proj_Jac_Tensor_i[iVar][jVar]; + + const su2double proj_viscousflux_vel= val_Proj_Visc_Flux[1]*val_Mean_PrimVar[1] + + val_Proj_Visc_Flux[2]*val_Mean_PrimVar[2]; + val_Proj_Jac_Tensor_i[3][0] -= factor*proj_viscousflux_vel; + val_Proj_Jac_Tensor_j[3][0] -= factor*proj_viscousflux_vel; + val_Proj_Jac_Tensor_i[3][1] += factor*val_Proj_Visc_Flux[1]; + val_Proj_Jac_Tensor_j[3][1] += factor*val_Proj_Visc_Flux[1]; + val_Proj_Jac_Tensor_i[3][2] += factor*val_Proj_Visc_Flux[2]; + val_Proj_Jac_Tensor_j[3][2] += factor*val_Proj_Visc_Flux[2]; + + + } else { + + val_Proj_Jac_Tensor_i[0][0] = 0.0; + val_Proj_Jac_Tensor_i[0][1] = 0.0; + val_Proj_Jac_Tensor_i[0][2] = 0.0; + val_Proj_Jac_Tensor_i[0][3] = 0.0; + val_Proj_Jac_Tensor_i[0][4] = 0.0; + val_Proj_Jac_Tensor_i[1][0] = val_dS*tau_jacobian_i[0][0]; + val_Proj_Jac_Tensor_i[1][1] = val_dS*tau_jacobian_i[0][1]; + val_Proj_Jac_Tensor_i[1][2] = val_dS*tau_jacobian_i[0][2]; + val_Proj_Jac_Tensor_i[1][3] = val_dS*tau_jacobian_i[0][3]; + val_Proj_Jac_Tensor_i[1][4] = val_dS*tau_jacobian_i[0][4]; + val_Proj_Jac_Tensor_i[2][0] = val_dS*tau_jacobian_i[1][0]; + val_Proj_Jac_Tensor_i[2][1] = val_dS*tau_jacobian_i[1][1]; + val_Proj_Jac_Tensor_i[2][2] = val_dS*tau_jacobian_i[1][2]; + val_Proj_Jac_Tensor_i[2][3] = val_dS*tau_jacobian_i[1][3]; + val_Proj_Jac_Tensor_i[2][4] = val_dS*tau_jacobian_i[1][4]; + val_Proj_Jac_Tensor_i[3][0] = val_dS*tau_jacobian_i[2][0]; + val_Proj_Jac_Tensor_i[3][1] = val_dS*tau_jacobian_i[2][1]; + val_Proj_Jac_Tensor_i[3][2] = val_dS*tau_jacobian_i[2][2]; + val_Proj_Jac_Tensor_i[3][3] = val_dS*tau_jacobian_i[2][3]; + val_Proj_Jac_Tensor_i[3][4] = val_dS*tau_jacobian_i[2][4]; + const su2double contraction = tau_jacobian_i[0][0]*val_Mean_PrimVar[1] + + tau_jacobian_i[1][0]*val_Mean_PrimVar[2] + + tau_jacobian_i[2][0]*val_Mean_PrimVar[3]; + val_Proj_Jac_Tensor_i[4][0] = val_dS*(contraction - heat_flux_jac_i[0]); + val_Proj_Jac_Tensor_i[4][1] = -val_dS*(tau_jacobian_i[0][0] + heat_flux_jac_i[1]); + val_Proj_Jac_Tensor_i[4][2] = -val_dS*(tau_jacobian_i[1][0] + heat_flux_jac_i[2]); + val_Proj_Jac_Tensor_i[4][3] = -val_dS*(tau_jacobian_i[2][0] + heat_flux_jac_i[3]); + val_Proj_Jac_Tensor_i[4][4] = -val_dS*heat_flux_jac_i[4]; + + for (unsigned short iVar = 0; iVar < nVar; iVar++) + for (unsigned short jVar = 0; jVar < nVar; jVar++) + val_Proj_Jac_Tensor_j[iVar][jVar] = -val_Proj_Jac_Tensor_i[iVar][jVar]; + + const su2double proj_viscousflux_vel= val_Proj_Visc_Flux[1]*val_Mean_PrimVar[1] + + val_Proj_Visc_Flux[2]*val_Mean_PrimVar[2] + + val_Proj_Visc_Flux[3]*val_Mean_PrimVar[3]; + val_Proj_Jac_Tensor_i[4][0] -= factor*proj_viscousflux_vel; + val_Proj_Jac_Tensor_j[4][0] -= factor*proj_viscousflux_vel; + val_Proj_Jac_Tensor_i[4][1] += factor*val_Proj_Visc_Flux[1]; + val_Proj_Jac_Tensor_j[4][1] += factor*val_Proj_Visc_Flux[1]; + val_Proj_Jac_Tensor_i[4][2] += factor*val_Proj_Visc_Flux[2]; + val_Proj_Jac_Tensor_j[4][2] += factor*val_Proj_Visc_Flux[2]; + val_Proj_Jac_Tensor_i[4][3] += factor*val_Proj_Visc_Flux[3]; + val_Proj_Jac_Tensor_j[4][3] += factor*val_Proj_Visc_Flux[3]; + + } + +} diff --git a/SU2_CFD/src/numerics/flow/diffusion/CAvgGrad_Flow.cpp b/SU2_CFD/src/numerics/flow/diffusion/CAvgGrad_Flow.cpp new file mode 100644 index 000000000000..ec6a04b9374b --- /dev/null +++ b/SU2_CFD/src/numerics/flow/diffusion/CAvgGrad_Flow.cpp @@ -0,0 +1,223 @@ +/*! + * \file CAvgGrad_Flow.cpp + * \brief Implementation of numerics class CAvgGrad_Flow. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../../include/numerics/flow/diffusion/CAvgGrad_Flow.hpp" + +CAvgGrad_Flow::CAvgGrad_Flow(unsigned short val_nDim, + unsigned short val_nVar, + bool val_correct_grad, + CConfig *config) + : CAvgGrad_Base(val_nDim, val_nVar, val_nDim+3, val_correct_grad, config) { + +} + +CAvgGrad_Flow::~CAvgGrad_Flow(void) { + +} + +void CAvgGrad_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { + + AD::StartPreacc(); + AD::SetPreaccIn(V_i, nDim+9); AD::SetPreaccIn(V_j, nDim+9); + AD::SetPreaccIn(Coord_i, nDim); AD::SetPreaccIn(Coord_j, nDim); + AD::SetPreaccIn(PrimVar_Grad_i, nDim+1, nDim); + AD::SetPreaccIn(PrimVar_Grad_j, nDim+1, nDim); + AD::SetPreaccIn(turb_ke_i); AD::SetPreaccIn(turb_ke_j); + AD::SetPreaccIn(Normal, nDim); + + unsigned short iVar, jVar, iDim; + + /*--- Normalized normal vector ---*/ + + 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; + + for (iVar = 0; iVar < nPrimVar; iVar++) { + PrimVar_i[iVar] = V_i[iVar]; + PrimVar_j[iVar] = V_j[iVar]; + Mean_PrimVar[iVar] = 0.5*(PrimVar_i[iVar]+PrimVar_j[iVar]); + } + + + /*--- Compute vector going from iPoint to jPoint ---*/ + + dist_ij_2 = 0.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]; + } + + /*--- Laminar and Eddy viscosity ---*/ + + Laminar_Viscosity_i = V_i[nDim+5]; Laminar_Viscosity_j = V_j[nDim+5]; + Eddy_Viscosity_i = V_i[nDim+6]; Eddy_Viscosity_j = V_j[nDim+6]; + + /*--- Mean Viscosities and turbulent kinetic energy---*/ + + Mean_Laminar_Viscosity = 0.5*(Laminar_Viscosity_i + Laminar_Viscosity_j); + Mean_Eddy_Viscosity = 0.5*(Eddy_Viscosity_i + Eddy_Viscosity_j); + Mean_turb_ke = 0.5*(turb_ke_i + turb_ke_j); + + /*--- Mean gradient approximation ---*/ + + for (iVar = 0; iVar < nDim+1; iVar++) { + for (iDim = 0; iDim < nDim; iDim++) { + Mean_GradPrimVar[iVar][iDim] = 0.5*(PrimVar_Grad_i[iVar][iDim] + PrimVar_Grad_j[iVar][iDim]); + } + } + + /*--- Projection of the mean gradient in the direction of the edge ---*/ + + if (correct_gradient && dist_ij_2 != 0.0) { + CorrectGradient(Mean_GradPrimVar, PrimVar_i, PrimVar_j, Edge_Vector, + dist_ij_2, nDim+1); + } + + /*--- Wall shear stress values (wall functions) ---*/ + + if (TauWall_i > 0.0 && TauWall_j > 0.0) Mean_TauWall = 0.5*(TauWall_i + TauWall_j); + else if (TauWall_i > 0.0) Mean_TauWall = TauWall_i; + else if (TauWall_j > 0.0) Mean_TauWall = TauWall_j; + else Mean_TauWall = -1.0; + + /* --- If using UQ methodology, set Reynolds Stress tensor and perform perturbation--- */ + + if (using_uq){ + SetReynoldsStressMatrix(Mean_turb_ke); + SetPerturbedRSM(Mean_turb_ke, config); + } + + /*--- Get projected flux tensor ---*/ + + SetStressTensor(Mean_PrimVar, Mean_GradPrimVar, Mean_turb_ke, + Mean_Laminar_Viscosity, Mean_Eddy_Viscosity); + if (config->GetQCR()) AddQCR(Mean_GradPrimVar); + if (Mean_TauWall > 0) AddTauWall(Normal, Mean_TauWall); + + SetHeatFluxVector(Mean_GradPrimVar, Mean_Laminar_Viscosity, + Mean_Eddy_Viscosity); + + GetViscousProjFlux(Mean_PrimVar, Normal); + + /*--- Update viscous residual ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + val_residual[iVar] = Proj_Flux_Tensor[iVar]; + + /*--- Compute the implicit part ---*/ + + if (implicit) { + + if (dist_ij_2 == 0.0) { + for (iVar = 0; iVar < nVar; iVar++) { + for (jVar = 0; jVar < nVar; jVar++) { + val_Jacobian_i[iVar][jVar] = 0.0; + val_Jacobian_j[iVar][jVar] = 0.0; + } + } + } else { + const su2double dist_ij = sqrt(dist_ij_2); + SetTauJacobian(Mean_PrimVar, Mean_Laminar_Viscosity, Mean_Eddy_Viscosity, + dist_ij, UnitNormal); + SetHeatFluxJacobian(Mean_PrimVar, Mean_Laminar_Viscosity, + Mean_Eddy_Viscosity, dist_ij, UnitNormal); + GetViscousProjJacs(Mean_PrimVar, Area, Proj_Flux_Tensor, + val_Jacobian_i, val_Jacobian_j); + } + + } + + AD::SetPreaccOut(val_residual, nVar); + AD::EndPreacc(); + +} + + + +void CAvgGrad_Flow::SetHeatFluxVector(const su2double* const *val_gradprimvar, + const su2double val_laminar_viscosity, + const su2double val_eddy_viscosity) { + + const su2double Cp = (Gamma / Gamma_Minus_One) * Gas_Constant; + const su2double heat_flux_factor = Cp * (val_laminar_viscosity/Prandtl_Lam + val_eddy_viscosity/Prandtl_Turb); + + /*--- Gradient of primitive variables -> [Temp vel_x vel_y vel_z Pressure] ---*/ + + for (unsigned short iDim = 0; iDim < nDim; iDim++) { + heat_flux_vector[iDim] = heat_flux_factor*val_gradprimvar[0][iDim]; + } +} + +void CAvgGrad_Flow::SetHeatFluxJacobian(const su2double *val_Mean_PrimVar, + const su2double val_laminar_viscosity, + const su2double val_eddy_viscosity, + const su2double val_dist_ij, + const su2double *val_normal) { + su2double sqvel = 0.0; + + for (unsigned short iDim = 0; iDim < nDim; iDim++) { + sqvel += val_Mean_PrimVar[iDim+1]*val_Mean_PrimVar[iDim+1]; + } + + const su2double Density = val_Mean_PrimVar[nDim+2]; + const su2double Pressure = val_Mean_PrimVar[nDim+1]; + const su2double phi = Gamma_Minus_One/Density; + + /*--- R times partial derivatives of temp. ---*/ + + const su2double R_dTdu0 = -Pressure/(Density*Density) + 0.5*sqvel*phi; + const su2double R_dTdu1 = -phi*val_Mean_PrimVar[1]; + const su2double R_dTdu2 = -phi*val_Mean_PrimVar[2]; + + const su2double heat_flux_factor = val_laminar_viscosity/Prandtl_Lam + val_eddy_viscosity/Prandtl_Turb; + const su2double cpoR = Gamma/Gamma_Minus_One; // cp over R + const su2double conductivity_over_Rd = cpoR*heat_flux_factor/val_dist_ij; + + heat_flux_jac_i[0] = conductivity_over_Rd * R_dTdu0; + heat_flux_jac_i[1] = conductivity_over_Rd * R_dTdu1; + heat_flux_jac_i[2] = conductivity_over_Rd * R_dTdu2; + + if (nDim == 2) { + + const su2double R_dTdu3 = phi; + heat_flux_jac_i[3] = conductivity_over_Rd * R_dTdu3; + + } else { + + const su2double R_dTdu3 = -phi*val_Mean_PrimVar[3]; + const su2double R_dTdu4 = phi; + heat_flux_jac_i[3] = conductivity_over_Rd * R_dTdu3; + heat_flux_jac_i[4] = conductivity_over_Rd * R_dTdu4; + + } +} + diff --git a/SU2_CFD/src/numerics/flow/diffusion/CGeneralAvgGrad_Flow.cpp b/SU2_CFD/src/numerics/flow/diffusion/CGeneralAvgGrad_Flow.cpp new file mode 100644 index 000000000000..d60a1910b218 --- /dev/null +++ b/SU2_CFD/src/numerics/flow/diffusion/CGeneralAvgGrad_Flow.cpp @@ -0,0 +1,232 @@ +/*! + * \file CGeneralAvgGrad_Flow.cpp + * \brief Implementation of numerics class CGeneralAvgGrad_Flow. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../../include/numerics/flow/diffusion/CGeneralAvgGrad_Flow.hpp" + +CGeneralAvgGrad_Flow::CGeneralAvgGrad_Flow(unsigned short val_nDim, + unsigned short val_nVar, + bool val_correct_grad, + CConfig *config) + : CAvgGrad_Base(val_nDim, val_nVar, val_nDim+4, val_correct_grad, config) { + + Mean_SecVar = new su2double [2]; + +} + +CGeneralAvgGrad_Flow::~CGeneralAvgGrad_Flow(void) { + + delete [] Mean_SecVar; + +} + +void CGeneralAvgGrad_Flow::SetHeatFluxVector(const su2double* const *val_gradprimvar, + const su2double val_laminar_viscosity, + const su2double val_eddy_viscosity, + const su2double val_thermal_conductivity, + const su2double val_heat_capacity_cp) { + + const su2double heat_flux_factor = val_thermal_conductivity + val_heat_capacity_cp*val_eddy_viscosity/Prandtl_Turb; + + /*--- Gradient of primitive variables -> [Temp vel_x vel_y vel_z Pressure] ---*/ + for (unsigned short iDim = 0; iDim < nDim; iDim++) { + heat_flux_vector[iDim] = heat_flux_factor*val_gradprimvar[0][iDim]; + } +} + +void CGeneralAvgGrad_Flow::SetHeatFluxJacobian(const su2double *val_Mean_PrimVar, + const su2double *val_Mean_SecVar, + const su2double val_eddy_viscosity, + const su2double val_thermal_conductivity, + const su2double val_heat_capacity_cp, + const su2double val_dist_ij) { + /* Viscous flux Jacobians for arbitrary equations of state */ + + //order of val_mean_primitives: T, vx, vy, vz, P, rho, ht + //order of secondary:dTdrho_e, dTde_rho + + su2double sqvel = 0.0; + for (unsigned short iDim = 0; iDim < nDim; iDim++) { + sqvel += val_Mean_PrimVar[iDim+1]*val_Mean_PrimVar[iDim+1]; + } + + su2double rho = val_Mean_PrimVar[nDim+2]; + su2double P= val_Mean_PrimVar[nDim+1]; + su2double h= val_Mean_PrimVar[nDim+3]; + su2double dTdrho_e= val_Mean_SecVar[0]; + su2double dTde_rho= val_Mean_SecVar[1]; + + su2double dTdu0= dTdrho_e + dTde_rho*(-(h-P/rho) + sqvel)*(1/rho); + su2double dTdu1= dTde_rho*(-val_Mean_PrimVar[1])*(1/rho); + su2double dTdu2= dTde_rho*(-val_Mean_PrimVar[2])*(1/rho); + + su2double total_conductivity = val_thermal_conductivity + val_heat_capacity_cp*val_eddy_viscosity/Prandtl_Turb; + su2double factor2 = total_conductivity/val_dist_ij; + + heat_flux_jac_i[0] = factor2*dTdu0; + heat_flux_jac_i[1] = factor2*dTdu1; + heat_flux_jac_i[2] = factor2*dTdu2; + + if (nDim == 2) { + + su2double dTdu3= dTde_rho*(1/rho); + heat_flux_jac_i[3] = factor2*dTdu3; + + } else { + + su2double dTdu3= dTde_rho*(-val_Mean_PrimVar[3])*(1/rho); + su2double dTdu4= dTde_rho*(1/rho); + heat_flux_jac_i[3] = factor2*dTdu3; + heat_flux_jac_i[4] = factor2*dTdu4; + + } + +} + +void CGeneralAvgGrad_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { + + AD::StartPreacc(); + AD::SetPreaccIn(V_i, nDim+9); AD::SetPreaccIn(V_j, nDim+9); + AD::SetPreaccIn(Coord_i, nDim); AD::SetPreaccIn(Coord_j, nDim); + AD::SetPreaccIn(S_i, 4); AD::SetPreaccIn(S_j, 4); + AD::SetPreaccIn(PrimVar_Grad_i, nDim+1, nDim); + AD::SetPreaccIn(PrimVar_Grad_j, nDim+1, nDim); + AD::SetPreaccIn(turb_ke_i); AD::SetPreaccIn(turb_ke_j); + AD::SetPreaccIn(Normal, nDim); + + unsigned short iVar, jVar, iDim; + + /*--- Normalized normal vector ---*/ + + 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; + + /*--- Mean primitive variables ---*/ + + for (iVar = 0; iVar < nPrimVar; iVar++) { + PrimVar_i[iVar] = V_i[iVar]; + PrimVar_j[iVar] = V_j[iVar]; + Mean_PrimVar[iVar] = 0.5*(PrimVar_i[iVar]+PrimVar_j[iVar]); + } + + /*--- Compute vector going from iPoint to jPoint ---*/ + + dist_ij_2 = 0.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]; + } + + /*--- Laminar and Eddy viscosity ---*/ + + Laminar_Viscosity_i = V_i[nDim+5]; Laminar_Viscosity_j = V_j[nDim+5]; + Eddy_Viscosity_i = V_i[nDim+6]; Eddy_Viscosity_j = V_j[nDim+6]; + Thermal_Conductivity_i = V_i[nDim+7]; Thermal_Conductivity_j = V_j[nDim+7]; + Cp_i = V_i[nDim+8]; Cp_j = V_j[nDim+8]; + + /*--- Mean secondary variables ---*/ + + for (iVar = 0; iVar < 2; iVar++) { + Mean_SecVar[iVar] = 0.5*(S_i[iVar+2]+S_j[iVar+2]); + } + + /*--- Mean Viscosities and turbulent kinetic energy---*/ + + Mean_Laminar_Viscosity = 0.5*(Laminar_Viscosity_i + Laminar_Viscosity_j); + Mean_Eddy_Viscosity = 0.5*(Eddy_Viscosity_i + Eddy_Viscosity_j); + Mean_turb_ke = 0.5*(turb_ke_i + turb_ke_j); + Mean_Thermal_Conductivity = 0.5*(Thermal_Conductivity_i + Thermal_Conductivity_j); + Mean_Cp = 0.5*(Cp_i + Cp_j); + + /*--- Mean gradient approximation ---*/ + + for (iVar = 0; iVar < nDim+1; iVar++) { + for (iDim = 0; iDim < nDim; iDim++) { + Mean_GradPrimVar[iVar][iDim] = 0.5*(PrimVar_Grad_i[iVar][iDim] + PrimVar_Grad_j[iVar][iDim]); + } + } + + /*--- Projection of the mean gradient in the direction of the edge ---*/ + + if (correct_gradient && dist_ij_2 != 0.0) { + CorrectGradient(Mean_GradPrimVar, PrimVar_i, PrimVar_j, Edge_Vector, + dist_ij_2, nDim+1); + } + + /* --- If using UQ methodology, set Reynolds Stress tensor and perform perturbation--- */ + + if (using_uq){ + SetReynoldsStressMatrix(Mean_turb_ke); + SetPerturbedRSM(Mean_turb_ke, config); + } + + /*--- Get projected flux tensor ---*/ + + SetStressTensor(Mean_PrimVar, Mean_GradPrimVar, Mean_turb_ke, + Mean_Laminar_Viscosity, Mean_Eddy_Viscosity); + + SetHeatFluxVector(Mean_GradPrimVar, Mean_Laminar_Viscosity, + Mean_Eddy_Viscosity, Mean_Thermal_Conductivity, Mean_Cp); + + GetViscousProjFlux(Mean_PrimVar, Normal); + + /*--- Update viscous residual ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + val_residual[iVar] = Proj_Flux_Tensor[iVar]; + + /*--- Compute the implicit part ---*/ + + if (implicit) { + + if (dist_ij_2 == 0.0) { + for (iVar = 0; iVar < nVar; iVar++) { + for (jVar = 0; jVar < nVar; jVar++) { + val_Jacobian_i[iVar][jVar] = 0.0; + val_Jacobian_j[iVar][jVar] = 0.0; + } + } + } else { + const su2double dist_ij = sqrt(dist_ij_2); + SetTauJacobian(Mean_PrimVar, Mean_Laminar_Viscosity, Mean_Eddy_Viscosity, + dist_ij, UnitNormal); + SetHeatFluxJacobian(Mean_PrimVar, Mean_SecVar, Mean_Eddy_Viscosity, + Mean_Thermal_Conductivity, Mean_Cp, dist_ij); + GetViscousProjJacs(Mean_PrimVar, Area, Proj_Flux_Tensor, + val_Jacobian_i, val_Jacobian_j); + } + + } + + AD::SetPreaccOut(val_residual, nVar); + AD::EndPreacc(); + +} diff --git a/SU2_CFD/src/numerics/flow/sources/CSourceAxisymmetric_Flow.cpp b/SU2_CFD/src/numerics/flow/sources/CSourceAxisymmetric_Flow.cpp new file mode 100644 index 000000000000..e9fda3c6eb8b --- /dev/null +++ b/SU2_CFD/src/numerics/flow/sources/CSourceAxisymmetric_Flow.cpp @@ -0,0 +1,107 @@ +/*! + * \file CSourceAxisymmetric_Flow.cpp + * \brief Implementation of numerics class CSourceAxisymmetric_Flow. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../../include/numerics/flow/sources/CSourceAxisymmetric_Flow.hpp" + +CSourceAxisymmetric_Flow::CSourceAxisymmetric_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + +} + +CSourceAxisymmetric_Flow::~CSourceAxisymmetric_Flow(void) { } + +void CSourceAxisymmetric_Flow::ComputeResidual(su2double *val_residual, su2double **Jacobian_i, CConfig *config) { + + su2double yinv, Pressure_i, Enthalpy_i, Velocity_i, sq_vel; + unsigned short iDim, iVar, jVar; + + bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + + if (Coord_i[1] > EPS) { + + yinv = 1.0/Coord_i[1]; + + sq_vel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + Velocity_i = U_i[iDim+1] / U_i[0]; + sq_vel += Velocity_i *Velocity_i; + } + + Pressure_i = (Gamma-1.0)*U_i[0]*(U_i[nDim+1]/U_i[0]-0.5*sq_vel); + Enthalpy_i = (U_i[nDim+1] + Pressure_i) / U_i[0]; + + val_residual[0] = yinv*Volume*U_i[2]; + val_residual[1] = yinv*Volume*U_i[1]*U_i[2]/U_i[0]; + val_residual[2] = yinv*Volume*(U_i[2]*U_i[2]/U_i[0]); + val_residual[3] = yinv*Volume*Enthalpy_i*U_i[2]; + + if (implicit) { + Jacobian_i[0][0] = 0.0; + Jacobian_i[0][1] = 0.0; + Jacobian_i[0][2] = 1.0; + Jacobian_i[0][3] = 0.0; + + Jacobian_i[1][0] = -U_i[1]*U_i[2]/(U_i[0]*U_i[0]); + Jacobian_i[1][1] = U_i[2]/U_i[0]; + Jacobian_i[1][2] = U_i[1]/U_i[0]; + Jacobian_i[1][3] = 0.0; + + Jacobian_i[2][0] = -U_i[2]*U_i[2]/(U_i[0]*U_i[0]); + Jacobian_i[2][1] = 0.0; + Jacobian_i[2][2] = 2*U_i[2]/U_i[0]; + Jacobian_i[2][3] = 0.0; + + Jacobian_i[3][0] = -Gamma*U_i[2]*U_i[3]/(U_i[0]*U_i[0]) + (Gamma-1)*U_i[2]*(U_i[1]*U_i[1]+U_i[2]*U_i[2])/(U_i[0]*U_i[0]*U_i[0]); + Jacobian_i[3][1] = -(Gamma-1)*U_i[2]*U_i[1]/(U_i[0]*U_i[0]); + Jacobian_i[3][2] = Gamma*U_i[3]/U_i[0] - 1/2*(Gamma-1)*( (U_i[1]*U_i[1]+U_i[2]*U_i[2])/(U_i[0]*U_i[0]) + 2*U_i[2]*U_i[2]/(U_i[0]*U_i[0]) ); + Jacobian_i[3][3] = Gamma*U_i[2]/U_i[0]; + + for (iVar=0; iVar < nVar; iVar++) + for (jVar=0; jVar < nVar; jVar++) + Jacobian_i[iVar][jVar] *= yinv*Volume; + + } + + } + + else { + + for (iVar=0; iVar < nVar; iVar++) + val_residual[iVar] = 0.0; + + if (implicit) { + for (iVar=0; iVar < nVar; iVar++) { + for (jVar=0; jVar < nVar; jVar++) + Jacobian_i[iVar][jVar] = 0.0; + } + } + + } + +} diff --git a/SU2_CFD/src/numerics/flow/sources/CSourceBodyForce.cpp b/SU2_CFD/src/numerics/flow/sources/CSourceBodyForce.cpp new file mode 100644 index 000000000000..792fc6ee8cfb --- /dev/null +++ b/SU2_CFD/src/numerics/flow/sources/CSourceBodyForce.cpp @@ -0,0 +1,66 @@ +/*! + * \file CSourceBodyForce.cpp + * \brief Implementation of numerics class CSourceBodyForce. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../../include/numerics/flow/sources/CSourceBodyForce.hpp" + +CSourceBodyForce::CSourceBodyForce(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + /*--- Store the pointer to the constant body force vector. ---*/ + + Body_Force_Vector = new su2double[nDim]; + for (unsigned short iDim = 0; iDim < nDim; iDim++) + Body_Force_Vector[iDim] = config->GetBody_Force_Vector()[iDim]; + +} + +CSourceBodyForce::~CSourceBodyForce(void) { + + if (Body_Force_Vector != NULL) delete [] Body_Force_Vector; + +} + +void CSourceBodyForce::ComputeResidual(su2double *val_residual, CConfig *config) { + + unsigned short iDim; + su2double Force_Ref = config->GetForce_Ref(); + + /*--- Zero the continuity contribution ---*/ + + val_residual[0] = 0.0; + + /*--- Momentum contribution ---*/ + + for (iDim = 0; iDim < nDim; iDim++) + val_residual[iDim+1] = -Volume * U_i[0] * Body_Force_Vector[iDim] / Force_Ref; + + /*--- Energy contribution ---*/ + + val_residual[nDim+1] = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + val_residual[nDim+1] += -Volume * U_i[iDim+1] * Body_Force_Vector[iDim] / Force_Ref; + +} diff --git a/SU2_CFD/src/numerics/flow/sources/CSourceBoussinesq.cpp b/SU2_CFD/src/numerics/flow/sources/CSourceBoussinesq.cpp new file mode 100644 index 000000000000..0a263c25aa92 --- /dev/null +++ b/SU2_CFD/src/numerics/flow/sources/CSourceBoussinesq.cpp @@ -0,0 +1,72 @@ +/*! + * \file CSourceBoussinesq.cpp + * \brief Implementation of numerics class CSourceBoussinesq. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../../include/numerics/flow/sources/CSourceBoussinesq.hpp" + +CSourceBoussinesq::CSourceBoussinesq(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + /*--- Store the pointer to the constant body force vector. ---*/ + + Gravity_Vector = new su2double[nDim]; + for (unsigned short iDim = 0; iDim < nDim; iDim++) + Gravity_Vector[iDim] = 0.0; + + /*--- Gravity is downward in y-dir for 2D and downward z-dir for 3D. ---*/ + + Gravity_Vector[nDim-1] = -STANDARD_GRAVITY; + +} + +CSourceBoussinesq::~CSourceBoussinesq(void) { + + if (Gravity_Vector != NULL) delete [] Gravity_Vector; + +} + +void CSourceBoussinesq::ComputeResidual(su2double *val_residual, CConfig *config) { + + unsigned short iDim; + su2double Force_Ref = config->GetForce_Ref(); + su2double T0 = config->GetTemperature_FreeStreamND(); + su2double Beta = config->GetThermal_Expansion_CoeffND(); + + /*--- Zero the continuity contribution ---*/ + + val_residual[0] = 0.0; + + /*--- Momentum contribution. Note that this form assumes we have + subtracted the operating density * gravity, i.e., removed the + hydrostatic pressure component (important for pressure BCs). ---*/ + + for (iDim = 0; iDim < nDim; iDim++) + val_residual[iDim+1] = Volume * DensityInc_i * ( Beta * (U_i[nDim+1] - T0)) * Gravity_Vector[iDim] / Force_Ref; + + /*--- Zero the energy contribution ---*/ + + val_residual[nDim+1] = 0.0; + +} diff --git a/SU2_CFD/src/numerics/flow/sources/CSourceGravity.cpp b/SU2_CFD/src/numerics/flow/sources/CSourceGravity.cpp new file mode 100644 index 000000000000..fc0e18a4c9dd --- /dev/null +++ b/SU2_CFD/src/numerics/flow/sources/CSourceGravity.cpp @@ -0,0 +1,45 @@ +/*! + * \file CSourceGravity.cpp + * \brief Implementation of numerics class CSourceGravity. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../../include/numerics/flow/sources/CSourceGravity.hpp" + +CSourceGravity::CSourceGravity(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + +} + +CSourceGravity::~CSourceGravity(void) { } + +void CSourceGravity::ComputeResidual(su2double *val_residual, CConfig *config) { + unsigned short iVar; + + for (iVar = 0; iVar < nVar; iVar++) + val_residual[iVar] = 0.0; + + /*--- Evaluate the source term ---*/ + val_residual[nDim] = Volume * U_i[0] * STANDARD_GRAVITY; + +} diff --git a/SU2_CFD/src/numerics/flow/sources/CSourceIncAxisymmetric_Flow.cpp b/SU2_CFD/src/numerics/flow/sources/CSourceIncAxisymmetric_Flow.cpp new file mode 100644 index 000000000000..84f196d639e2 --- /dev/null +++ b/SU2_CFD/src/numerics/flow/sources/CSourceIncAxisymmetric_Flow.cpp @@ -0,0 +1,154 @@ +/*! + * \file CSourceIncAxisymmetric_Flow.cpp + * \brief Implementation of numerics class CSourceIncAxisymmetric_Flow. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../../include/numerics/flow/sources/CSourceIncAxisymmetric_Flow.hpp" + +CSourceIncAxisymmetric_Flow::CSourceIncAxisymmetric_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + energy = config->GetEnergy_Equation(); + viscous = config->GetViscous(); + +} + +CSourceIncAxisymmetric_Flow::~CSourceIncAxisymmetric_Flow(void) { } + +void CSourceIncAxisymmetric_Flow::ComputeResidual(su2double *val_residual, su2double **Jacobian_i, CConfig *config) { + + su2double yinv, Velocity_i[3]; + unsigned short iDim, jDim, iVar, jVar; + + if (Coord_i[1] > EPS) { + + yinv = 1.0/Coord_i[1]; + + /*--- Set primitive variables at points iPoint. ---*/ + + Pressure_i = V_i[0]; + Temp_i = V_i[nDim+1]; + DensityInc_i = V_i[nDim+2]; + BetaInc2_i = V_i[nDim+3]; + Cp_i = V_i[nDim+7]; + Enthalpy_i = Cp_i*Temp_i; + + for (iDim = 0; iDim < nDim; iDim++) + Velocity_i[iDim] = V_i[iDim+1]; + + /*--- Inviscid component of the source term. ---*/ + + val_residual[0] = yinv*Volume*DensityInc_i*Velocity_i[1]; + val_residual[1] = yinv*Volume*DensityInc_i*Velocity_i[0]*Velocity_i[1]; + val_residual[2] = yinv*Volume*DensityInc_i*Velocity_i[1]*Velocity_i[1]; + val_residual[3] = yinv*Volume*DensityInc_i*Enthalpy_i*Velocity_i[1]; + + if (implicit) { + + Jacobian_i[0][0] = 0.0; + Jacobian_i[0][1] = 0.0; + Jacobian_i[0][2] = 1.0; + Jacobian_i[0][3] = 0.0; + + Jacobian_i[1][0] = 0.0; + Jacobian_i[1][1] = Velocity_i[1]; + Jacobian_i[1][2] = Velocity_i[0]; + Jacobian_i[1][3] = 0.0; + + Jacobian_i[2][0] = 0.0; + Jacobian_i[2][1] = 0.0; + Jacobian_i[2][2] = 2.0*Velocity_i[1]; + Jacobian_i[2][3] = 0.0; + + Jacobian_i[3][0] = 0.0; + Jacobian_i[3][1] = 0.0; + Jacobian_i[3][2] = Enthalpy_i; + Jacobian_i[3][3] = Cp_i*Velocity_i[1]; + + for (iVar=0; iVar < nVar; iVar++) + for (jVar=0; jVar < nVar; jVar++) + Jacobian_i[iVar][jVar] *= yinv*Volume*DensityInc_i; + + } + + /*--- Add the viscous terms if necessary. ---*/ + + if (viscous) { + + Laminar_Viscosity_i = V_i[nDim+4]; + Eddy_Viscosity_i = V_i[nDim+5]; + Thermal_Conductivity_i = V_i[nDim+6]; + + su2double total_viscosity, div_vel; + + total_viscosity = (Laminar_Viscosity_i + Eddy_Viscosity_i); + + /*--- The full stress tensor is needed for variable density ---*/ + + div_vel = 0.0; + for (iDim = 0 ; iDim < nDim; iDim++) + div_vel += PrimVar_Grad_i[iDim+1][iDim]; + + for (iDim = 0 ; iDim < nDim; iDim++) + for (jDim = 0 ; jDim < nDim; jDim++) + tau[iDim][jDim] = (total_viscosity*(PrimVar_Grad_i[jDim+1][iDim] + + PrimVar_Grad_i[iDim+1][jDim] ) + -TWO3*total_viscosity*div_vel*delta[iDim][jDim]); + + /*--- Viscous terms. ---*/ + + val_residual[0] -= 0.0; + val_residual[1] -= Volume*(yinv*tau[0][1] - TWO3*AuxVar_Grad_i[0]); + val_residual[2] -= Volume*(yinv*2.0*total_viscosity*PrimVar_Grad_i[2][1] - + yinv*yinv*2.0*total_viscosity*Velocity_i[1] - + TWO3*AuxVar_Grad_i[1]); + val_residual[3] -= Volume*yinv*Thermal_Conductivity_i*PrimVar_Grad_i[nDim+1][1]; + + } + + } else { + + for (iVar=0; iVar < nVar; iVar++) + val_residual[iVar] = 0.0; + + if (implicit) { + for (iVar=0; iVar < nVar; iVar++) { + for (jVar=0; jVar < nVar; jVar++) + Jacobian_i[iVar][jVar] = 0.0; + } + } + + } + + if (!energy) { + val_residual[nDim+1] = 0.0; + if (implicit) { + for (iVar = 0; iVar < nVar; iVar++) { + Jacobian_i[iVar][nDim+1] = 0.0; + Jacobian_i[nDim+1][iVar] = 0.0; + } + } + } +} diff --git a/SU2_CFD/src/numerics/flow/sources/CSourceIncBodyForce.cpp b/SU2_CFD/src/numerics/flow/sources/CSourceIncBodyForce.cpp new file mode 100644 index 000000000000..223764c3d22d --- /dev/null +++ b/SU2_CFD/src/numerics/flow/sources/CSourceIncBodyForce.cpp @@ -0,0 +1,73 @@ +/*! + * \file CSourceIncBodyForce.cpp + * \brief Implementation of numerics class CSourceIncBodyForce. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../../include/numerics/flow/sources/CSourceIncBodyForce.hpp" + +CSourceIncBodyForce::CSourceIncBodyForce(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + /*--- Store the pointer to the constant body force vector. ---*/ + + Body_Force_Vector = new su2double[nDim]; + for (unsigned short iDim = 0; iDim < nDim; iDim++) + Body_Force_Vector[iDim] = config->GetBody_Force_Vector()[iDim]; + +} + +CSourceIncBodyForce::~CSourceIncBodyForce(void) { + + if (Body_Force_Vector != NULL) delete [] Body_Force_Vector; + +} + +void CSourceIncBodyForce::ComputeResidual(su2double *val_residual, CConfig *config) { + + unsigned short iDim; + su2double DensityInc_0 = 0.0; + su2double Force_Ref = config->GetForce_Ref(); + bool variable_density = (config->GetKind_DensityModel() == VARIABLE); + + /*--- Check for variable density. If we have a variable density + problem, we should subtract out the hydrostatic pressure component. ---*/ + + if (variable_density) DensityInc_0 = config->GetDensity_FreeStreamND(); + + /*--- Zero the continuity contribution ---*/ + + val_residual[0] = 0.0; + + /*--- Momentum contribution. Note that this form assumes we have + subtracted the operating density * gravity, i.e., removed the + hydrostatic pressure component (important for pressure BCs). ---*/ + + for (iDim = 0; iDim < nDim; iDim++) + val_residual[iDim+1] = -Volume * (DensityInc_i - DensityInc_0) * Body_Force_Vector[iDim] / Force_Ref; + + /*--- Zero the temperature contribution ---*/ + + val_residual[nDim+1] = 0.0; + +} diff --git a/SU2_CFD/src/numerics/flow/sources/CSourceIncRotatingFrame_Flow.cpp b/SU2_CFD/src/numerics/flow/sources/CSourceIncRotatingFrame_Flow.cpp new file mode 100644 index 000000000000..9a66acffcfde --- /dev/null +++ b/SU2_CFD/src/numerics/flow/sources/CSourceIncRotatingFrame_Flow.cpp @@ -0,0 +1,94 @@ +/*! + * \file CSourceIncRotatingFrame_Flow.cpp + * \brief Implementation of numerics class CSourceIncRotatingFrame_Flow. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../../include/numerics/flow/sources/CSourceIncRotatingFrame_Flow.hpp" + +CSourceIncRotatingFrame_Flow::CSourceIncRotatingFrame_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + + /*--- Retrieve the angular velocity vector from config. ---*/ + for (unsigned short iDim = 0; iDim < 3; iDim++) + Omega[iDim] = config->GetRotation_Rate(iDim)/config->GetOmega_Ref(); + +} + +CSourceIncRotatingFrame_Flow::~CSourceIncRotatingFrame_Flow(void) { } + +void CSourceIncRotatingFrame_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config) { + + unsigned short iDim, iVar, jVar; + su2double Momentum[3] = {0,0,0}, + Velocity_i[3] = {0,0,0}; + + /*--- Primitive variables plus momentum at the node (point i) ---*/ + + DensityInc_i = V_i[nDim+2]; + + for (iDim = 0; iDim < nDim; iDim++) { + Velocity_i[iDim] = V_i[iDim+1]; + Momentum[iDim] = DensityInc_i*Velocity_i[iDim]; + } + + /*--- Calculate rotating frame source term residual as ( Omega X Rho-U ) ---*/ + + if (nDim == 2) { + val_residual[0] = 0.0; + val_residual[1] = (Omega[1]*Momentum[2] - Omega[2]*Momentum[1])*Volume; + val_residual[2] = (Omega[2]*Momentum[0] - Omega[0]*Momentum[2])*Volume; + val_residual[3] = 0.0; + } else { + val_residual[0] = 0.0; + val_residual[1] = (Omega[1]*Momentum[2] - Omega[2]*Momentum[1])*Volume; + val_residual[2] = (Omega[2]*Momentum[0] - Omega[0]*Momentum[2])*Volume; + val_residual[3] = (Omega[0]*Momentum[1] - Omega[1]*Momentum[0])*Volume; + val_residual[4] = 0.0; + } + + /*--- Calculate the source term Jacobian ---*/ + + if (implicit) { + for (iVar = 0; iVar < nVar; iVar++) + for (jVar = 0; jVar < nVar; jVar++) + val_Jacobian_i[iVar][jVar] = 0.0; + if (nDim == 2) { + val_Jacobian_i[1][2] = -DensityInc_i*Omega[2]*Volume; + val_Jacobian_i[2][1] = DensityInc_i*Omega[2]*Volume; + } else { + val_Jacobian_i[1][2] = -DensityInc_i*Omega[2]*Volume; + val_Jacobian_i[1][3] = DensityInc_i*Omega[1]*Volume; + val_Jacobian_i[2][1] = DensityInc_i*Omega[2]*Volume; + val_Jacobian_i[2][3] = -DensityInc_i*Omega[0]*Volume; + val_Jacobian_i[3][1] = -DensityInc_i*Omega[1]*Volume; + val_Jacobian_i[3][2] = DensityInc_i*Omega[0]*Volume; + } + } + +} diff --git a/SU2_CFD/src/numerics/flow/sources/CSourceRotatingFrame_Flow.cpp b/SU2_CFD/src/numerics/flow/sources/CSourceRotatingFrame_Flow.cpp new file mode 100644 index 000000000000..2f78531b4ec7 --- /dev/null +++ b/SU2_CFD/src/numerics/flow/sources/CSourceRotatingFrame_Flow.cpp @@ -0,0 +1,91 @@ +/*! + * \file CSourceRotatingFrame_Flow.cpp + * \brief Implementation of numerics class CSourceRotatingFrame_Flow. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../../include/numerics/flow/sources/CSourceRotatingFrame_Flow.hpp" + +CSourceRotatingFrame_Flow::CSourceRotatingFrame_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + +} + +CSourceRotatingFrame_Flow::~CSourceRotatingFrame_Flow(void) { } + +void CSourceRotatingFrame_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config) { + + unsigned short iDim, iVar, jVar; + su2double Omega[3] = {0,0,0}, Momentum[3] = {0,0,0}; + + bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + + /*--- Retrieve the angular velocity vector from config. ---*/ + + for (iDim = 0; iDim < 3; iDim++){ + Omega[iDim] = config->GetRotation_Rate(iDim)/config->GetOmega_Ref(); + } + + /*--- Get the momentum vector at the current node. ---*/ + + for (iDim = 0; iDim < nDim; iDim++) + Momentum[iDim] = U_i[iDim+1]; + + /*--- Calculate rotating frame source term as ( Omega X Rho-U ) ---*/ + + if (nDim == 2) { + val_residual[0] = 0.0; + val_residual[1] = (Omega[1]*Momentum[2] - Omega[2]*Momentum[1])*Volume; + val_residual[2] = (Omega[2]*Momentum[0] - Omega[0]*Momentum[2])*Volume; + val_residual[3] = 0.0; + } else { + val_residual[0] = 0.0; + val_residual[1] = (Omega[1]*Momentum[2] - Omega[2]*Momentum[1])*Volume; + val_residual[2] = (Omega[2]*Momentum[0] - Omega[0]*Momentum[2])*Volume; + val_residual[3] = (Omega[0]*Momentum[1] - Omega[1]*Momentum[0])*Volume; + val_residual[4] = 0.0; + } + + /*--- Calculate the source term Jacobian ---*/ + + if (implicit) { + for (iVar = 0; iVar < nVar; iVar++) + for (jVar = 0; jVar < nVar; jVar++) + val_Jacobian_i[iVar][jVar] = 0.0; + if (nDim == 2) { + val_Jacobian_i[1][2] = -Omega[2]*Volume; + val_Jacobian_i[2][1] = Omega[2]*Volume; + } else { + val_Jacobian_i[1][2] = -Omega[2]*Volume; + val_Jacobian_i[1][3] = Omega[1]*Volume; + val_Jacobian_i[2][1] = Omega[2]*Volume; + val_Jacobian_i[2][3] = -Omega[0]*Volume; + val_Jacobian_i[3][1] = -Omega[1]*Volume; + val_Jacobian_i[3][2] = Omega[0]*Volume; + } + } + +} diff --git a/SU2_CFD/src/numerics/flow/sources/CSourceWindGust.cpp b/SU2_CFD/src/numerics/flow/sources/CSourceWindGust.cpp new file mode 100644 index 000000000000..2896a45ca27b --- /dev/null +++ b/SU2_CFD/src/numerics/flow/sources/CSourceWindGust.cpp @@ -0,0 +1,93 @@ +/*! + * \file CSourceWindGust.cpp + * \brief Implementation of numerics class CSourceWindGust. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../../include/numerics/flow/sources/CSourceWindGust.hpp" + +CSourceWindGust::CSourceWindGust(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + +} + +CSourceWindGust::~CSourceWindGust(void) { } + +void CSourceWindGust::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config) { + + su2double u_gust, v_gust, du_gust_dx, du_gust_dy, du_gust_dt, dv_gust_dx, dv_gust_dy, dv_gust_dt, smx, smy, se, rho, u, v, p; + unsigned short GustDir = config->GetGust_Dir(); //Gust direction + + u_gust = WindGust_i[0]; + v_gust = WindGust_i[1]; + + if (GustDir == X_DIR) { + du_gust_dx = WindGustDer_i[0]; + du_gust_dy = WindGustDer_i[1]; + du_gust_dt = WindGustDer_i[2]; + dv_gust_dx = 0.0; + dv_gust_dy = 0.0; + dv_gust_dt = 0.0; + } else { + du_gust_dx = 0.0; + du_gust_dy = 0.0; + du_gust_dt = 0.0; + dv_gust_dx = WindGustDer_i[0]; + dv_gust_dy = WindGustDer_i[1]; + dv_gust_dt = WindGustDer_i[2]; + + } + + /*--- Primitive variables at point i ---*/ + u = V_i[1]; + v = V_i[2]; + p = V_i[nDim+1]; + rho = V_i[nDim+2]; + + /*--- Source terms ---*/ + smx = rho*(du_gust_dt + (u+u_gust)*du_gust_dx + (v+v_gust)*du_gust_dy); + smy = rho*(dv_gust_dt + (u+u_gust)*dv_gust_dx + (v+v_gust)*dv_gust_dy); + se = u*smx + v*smy + p*(du_gust_dx + dv_gust_dy); + + if (nDim == 2) { + val_residual[0] = 0.0; + val_residual[1] = smx*Volume; + val_residual[2] = smy*Volume; + val_residual[3] = se*Volume; + } else { + SU2_MPI::Error("You should only be in the gust source term in two dimensions", CURRENT_FUNCTION); + } + + /*--- For now the source term Jacobian is just set to zero ---*/ + + unsigned short iVar, jVar; + bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + + /*--- Calculate the source term Jacobian ---*/ + + if (implicit) { + for (iVar = 0; iVar < nVar; iVar++) + for (jVar = 0; jVar < nVar; jVar++) + val_Jacobian_i[iVar][jVar] = 0.0; + } +} diff --git a/SU2_CFD/src/numerics/heat/CAvgGradCorrected_Heat.cpp b/SU2_CFD/src/numerics/heat/CAvgGradCorrected_Heat.cpp new file mode 100644 index 000000000000..5e6446ea9815 --- /dev/null +++ b/SU2_CFD/src/numerics/heat/CAvgGradCorrected_Heat.cpp @@ -0,0 +1,107 @@ +/*! + * \file CAvgGradCorrected_Heat.cpp + * \brief Implementation of numerics class CAvgGradCorrected_Heat. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../include/numerics/heat/CAvgGradCorrected_Heat.hpp" + +CAvgGradCorrected_Heat::CAvgGradCorrected_Heat(unsigned short val_nDim, unsigned short val_nVar, + CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + implicit = (config->GetKind_TimeIntScheme_Heat() == EULER_IMPLICIT); + + Edge_Vector = new su2double [nDim]; + Proj_Mean_GradHeatVar_Edge = new su2double [nVar]; + Proj_Mean_GradHeatVar_Kappa = new su2double [nVar]; + Proj_Mean_GradHeatVar_Corrected = new su2double [nVar]; + Mean_GradHeatVar = new su2double* [nVar]; + for (iVar = 0; iVar < nVar; iVar++) + Mean_GradHeatVar[iVar] = new su2double [nDim]; + +} + +CAvgGradCorrected_Heat::~CAvgGradCorrected_Heat(void) { + + delete [] Edge_Vector; + delete [] Proj_Mean_GradHeatVar_Edge; + delete [] Proj_Mean_GradHeatVar_Kappa; + delete [] Proj_Mean_GradHeatVar_Corrected; + for (iVar = 0; iVar < nVar; iVar++) + delete [] Mean_GradHeatVar[iVar]; + delete [] Mean_GradHeatVar; + +} + +void CAvgGradCorrected_Heat::ComputeResidual(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config) { + + AD::StartPreacc(); + AD::SetPreaccIn(Coord_i, nDim); AD::SetPreaccIn(Coord_j, nDim); + AD::SetPreaccIn(Normal, nDim); + AD::SetPreaccIn(Temp_i); AD::SetPreaccIn(Temp_j); + AD::SetPreaccIn(ConsVar_Grad_i[0],nDim); AD::SetPreaccIn(ConsVar_Grad_j[0],nDim); + AD::SetPreaccIn(Thermal_Diffusivity_i); AD::SetPreaccIn(Thermal_Diffusivity_j); + + Thermal_Diffusivity_Mean = 0.5*(Thermal_Diffusivity_i + Thermal_Diffusivity_j); + + /*--- Compute vector going from iPoint to jPoint ---*/ + + 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; + + /*--- Mean gradient approximation. Projection of the mean gradient + in the direction of the edge ---*/ + + for (iVar = 0; iVar < nVar; iVar++) { + Proj_Mean_GradHeatVar_Edge[iVar] = 0.0; + Proj_Mean_GradHeatVar_Kappa[iVar] = 0.0; + + for (iDim = 0; iDim < nDim; iDim++) { + Mean_GradHeatVar[iVar][iDim] = 0.5*(ConsVar_Grad_i[iVar][iDim] + ConsVar_Grad_j[iVar][iDim]); + Proj_Mean_GradHeatVar_Kappa[iVar] += Mean_GradHeatVar[iVar][iDim]*Normal[iDim]; + Proj_Mean_GradHeatVar_Edge[iVar] += Mean_GradHeatVar[iVar][iDim]*Edge_Vector[iDim]; + } + Proj_Mean_GradHeatVar_Corrected[iVar] = Proj_Mean_GradHeatVar_Kappa[iVar]; + Proj_Mean_GradHeatVar_Corrected[iVar] -= Proj_Mean_GradHeatVar_Edge[iVar]*proj_vector_ij - + (Temp_j-Temp_i)*proj_vector_ij; + } + + val_residual[0] = Thermal_Diffusivity_Mean*Proj_Mean_GradHeatVar_Corrected[0]; + + /*--- For Jacobians -> Use of TSL approx. to compute derivatives of the gradients ---*/ + + if (implicit) { + Jacobian_i[0][0] = -Thermal_Diffusivity_Mean*proj_vector_ij; + Jacobian_j[0][0] = Thermal_Diffusivity_Mean*proj_vector_ij; + } + + AD::SetPreaccOut(val_residual, nVar); + AD::EndPreacc(); +} diff --git a/SU2_CFD/src/numerics/heat/CAvgGrad_Heat.cpp b/SU2_CFD/src/numerics/heat/CAvgGrad_Heat.cpp new file mode 100644 index 000000000000..75c06279fc3a --- /dev/null +++ b/SU2_CFD/src/numerics/heat/CAvgGrad_Heat.cpp @@ -0,0 +1,99 @@ +/*! + * \file CAvgGrad_Heat.cpp + * \brief Implementation of numerics class CAvgGrad_Heat. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../include/numerics/heat/CAvgGrad_Heat.hpp" + +CAvgGrad_Heat::CAvgGrad_Heat(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + implicit = (config->GetKind_TimeIntScheme_Heat() == EULER_IMPLICIT); + + Edge_Vector = new su2double [nDim]; + Proj_Mean_GradHeatVar_Normal = new su2double [nVar]; + Proj_Mean_GradHeatVar_Corrected = new su2double [nVar]; + Mean_GradHeatVar = new su2double* [nVar]; + for (iVar = 0; iVar < nVar; iVar++) + Mean_GradHeatVar[iVar] = new su2double [nDim]; + +} + +CAvgGrad_Heat::~CAvgGrad_Heat(void) { + + delete [] Edge_Vector; + delete [] Proj_Mean_GradHeatVar_Normal; + delete [] Proj_Mean_GradHeatVar_Corrected; + for (iVar = 0; iVar < nVar; iVar++) + delete [] Mean_GradHeatVar[iVar]; + delete [] Mean_GradHeatVar; + +} + +void CAvgGrad_Heat::ComputeResidual(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config) { + + AD::StartPreacc(); + AD::SetPreaccIn(Coord_i, nDim); AD::SetPreaccIn(Coord_j, nDim); + AD::SetPreaccIn(Normal, nDim); + AD::SetPreaccIn(Temp_i); AD::SetPreaccIn(Temp_j); + AD::SetPreaccIn(ConsVar_Grad_i[0],nDim); AD::SetPreaccIn(ConsVar_Grad_j[0],nDim); + AD::SetPreaccIn(Thermal_Diffusivity_i); AD::SetPreaccIn(Thermal_Conductivity_j); + + Thermal_Diffusivity_Mean = 0.5*(Thermal_Diffusivity_i + Thermal_Diffusivity_j); + + /*--- Compute vector going from iPoint to jPoint ---*/ + + 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; + + /*--- Mean gradient approximation. Projection of the mean gradient in the direction of the edge ---*/ + for (iVar = 0; iVar < nVar; iVar++) { + Proj_Mean_GradHeatVar_Normal[iVar] = 0.0; + Proj_Mean_GradHeatVar_Corrected[iVar] = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + Mean_GradHeatVar[iVar][iDim] = 0.5*(ConsVar_Grad_i[iVar][iDim] + ConsVar_Grad_j[iVar][iDim]); + Proj_Mean_GradHeatVar_Normal[iVar] += Mean_GradHeatVar[iVar][iDim]*Normal[iDim]; + } + Proj_Mean_GradHeatVar_Corrected[iVar] = Proj_Mean_GradHeatVar_Normal[iVar]; + } + + val_residual[0] = Thermal_Diffusivity_Mean*Proj_Mean_GradHeatVar_Corrected[0]; + + /*--- For Jacobians -> Use of TSL approx. to compute derivatives of the gradients ---*/ + if (implicit) { + Jacobian_i[0][0] = -Thermal_Diffusivity_Mean*proj_vector_ij; + Jacobian_j[0][0] = Thermal_Diffusivity_Mean*proj_vector_ij; + } + + AD::SetPreaccOut(val_residual, nVar); + AD::EndPreacc(); + +} + diff --git a/SU2_CFD/src/numerics/heat/CCentSca_Heat.cpp b/SU2_CFD/src/numerics/heat/CCentSca_Heat.cpp new file mode 100644 index 000000000000..f04075b47d05 --- /dev/null +++ b/SU2_CFD/src/numerics/heat/CCentSca_Heat.cpp @@ -0,0 +1,114 @@ +/*! + * \file CCentSca_Heat.cpp + * \brief Implementation of numerics class CCentSca_Heat. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../include/numerics/heat/CCentSca_Heat.hpp" + +CCentSca_Heat::CCentSca_Heat(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + implicit = (config->GetKind_TimeIntScheme_Turb() == EULER_IMPLICIT); + /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ + dynamic_grid = config->GetDynamic_Grid(); + + MeanVelocity = new su2double [nDim]; + + Laminar_Viscosity_i = config->GetViscosity_FreeStreamND(); + Laminar_Viscosity_j = config->GetViscosity_FreeStreamND(); + + Param_Kappa_4 = config->GetKappa_4th_Heat(); + Diff_Lapl = new su2double [nVar]; +} + +CCentSca_Heat::~CCentSca_Heat(void) { + + delete [] MeanVelocity; + delete [] Diff_Lapl; + +} + +void CCentSca_Heat::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { + + AD::StartPreacc(); + AD::SetPreaccIn(V_i, nDim+3); AD::SetPreaccIn(V_j, nDim+3); + AD::SetPreaccIn(Temp_i); AD::SetPreaccIn(Temp_j); + AD::SetPreaccIn(Und_Lapl_i, nVar); AD::SetPreaccIn(Und_Lapl_j, nVar); + AD::SetPreaccIn(Normal, nDim); + if (dynamic_grid) { + AD::SetPreaccIn(GridVel_i, nDim); AD::SetPreaccIn(GridVel_j, nDim); + } + + /*--- Primitive variables at point i and j ---*/ + + Pressure_i = V_i[0]; Pressure_j = V_j[0]; + DensityInc_i = V_i[nDim+2]; DensityInc_j = V_j[nDim+2]; + BetaInc2_i = V_i[nDim+3]; BetaInc2_j = V_j[nDim+3]; + + /*--- Projected velocities at the current edge ---*/ + + ProjVelocity = 0.0; ProjVelocity_i = 0.0; ProjVelocity_j = 0.0; Area = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + ProjVelocity_i += V_i[iDim+1]*Normal[iDim]; + ProjVelocity_j += V_j[iDim+1]*Normal[iDim]; + Area += Normal[iDim]*Normal[iDim]; + } + Area = sqrt(Area); + + /*--- Computing the second order centered scheme part ---*/ + + ProjVelocity = 0.5*(ProjVelocity_i+ProjVelocity_j); + + val_residual[0] = 0.5*(Temp_i + Temp_j)*ProjVelocity; + + if (implicit) { + val_Jacobian_i[0][0] = 0.5*ProjVelocity; + val_Jacobian_j[0][0] = 0.5*ProjVelocity; + } + + /*--- Adding artificial dissipation to stabilize the centered scheme ---*/ + + Diff_Lapl[0] = Und_Lapl_i[0]-Und_Lapl_j[0]; + + SoundSpeed_i = sqrt(ProjVelocity_i*ProjVelocity_i + (BetaInc2_i/DensityInc_i)*Area*Area); + SoundSpeed_j = sqrt(ProjVelocity_j*ProjVelocity_j + (BetaInc2_j/DensityInc_j)*Area*Area); + + Local_Lambda_i = fabs(ProjVelocity_i)+SoundSpeed_i; + Local_Lambda_j = fabs(ProjVelocity_j)+SoundSpeed_j; + MeanLambda = 0.5*(Local_Lambda_i+Local_Lambda_j); + + val_residual[0] += -Param_Kappa_4*Diff_Lapl[0]*MeanLambda; + + if (implicit) { + cte_0 = Param_Kappa_4*su2double(Neighbor_i+1)*MeanLambda; + cte_1 = Param_Kappa_4*su2double(Neighbor_j+1)*MeanLambda; + + val_Jacobian_i[0][0] += cte_0; + val_Jacobian_j[0][0] -= cte_1; + } + + AD::SetPreaccOut(val_residual[0]); + AD::EndPreacc(); + +} diff --git a/SU2_CFD/src/numerics/heat/CUpwSca_Heat.cpp b/SU2_CFD/src/numerics/heat/CUpwSca_Heat.cpp new file mode 100644 index 000000000000..ff2057724e84 --- /dev/null +++ b/SU2_CFD/src/numerics/heat/CUpwSca_Heat.cpp @@ -0,0 +1,80 @@ +/*! + * \file CUpwSca_Heat.cpp + * \brief Implementation of numerics class CUpwSca_Heat. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../include/numerics/heat/CUpwSca_Heat.hpp" + +CUpwSca_Heat::CUpwSca_Heat(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + implicit = (config->GetKind_TimeIntScheme_Turb() == EULER_IMPLICIT); + /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ + dynamic_grid = config->GetDynamic_Grid(); + + Velocity_i = new su2double [nDim]; + Velocity_j = new su2double [nDim]; + + Laminar_Viscosity_i = config->GetViscosity_FreeStreamND(); + Laminar_Viscosity_j = config->GetViscosity_FreeStreamND(); +} + +CUpwSca_Heat::~CUpwSca_Heat(void) { + + delete [] Velocity_i; + delete [] Velocity_j; + +} + +void CUpwSca_Heat::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { + + q_ij = 0.0; + + AD::StartPreacc(); + AD::SetPreaccIn(V_i, nDim+1); AD::SetPreaccIn(V_j, nDim+1); + AD::SetPreaccIn(Temp_i); AD::SetPreaccIn(Temp_j); + AD::SetPreaccIn(Normal, nDim); + if (dynamic_grid) { + AD::SetPreaccIn(GridVel_i, nDim); AD::SetPreaccIn(GridVel_j, nDim); + } + + for (iDim = 0; iDim < nDim; iDim++) { + Velocity_i[iDim] = V_i[iDim+1]; + Velocity_j[iDim] = V_j[iDim+1]; + q_ij += 0.5*(Velocity_i[iDim]+Velocity_j[iDim])*Normal[iDim]; + } + + a0 = 0.5*(q_ij+fabs(q_ij)); + a1 = 0.5*(q_ij-fabs(q_ij)); + val_residual[0] = a0*Temp_i+a1*Temp_j; + + if (implicit) { + val_Jacobian_i[0][0] = a0; + val_Jacobian_j[0][0] = a1; + } + + AD::SetPreaccOut(val_residual[0]); + AD::EndPreacc(); + +} diff --git a/SU2_CFD/src/numerics_template.cpp b/SU2_CFD/src/numerics/template/CConvective_Template.cpp similarity index 89% rename from SU2_CFD/src/numerics_template.cpp rename to SU2_CFD/src/numerics/template/CConvective_Template.cpp index 6cea877e3a6a..0131ce07c85d 100644 --- a/SU2_CFD/src/numerics_template.cpp +++ b/SU2_CFD/src/numerics/template/CConvective_Template.cpp @@ -1,12 +1,12 @@ /*! - * \file numerics_template.cpp - * \brief This file contains all the convective term discretization. - * \author F. Palacios + * \file CConvective_Template.cpp + * \brief Implementation of numerics class CConvective_Template. + * \author F. Palacios, T. Economon * \version 7.0.0 "Blackbird" * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -25,9 +25,7 @@ * License along with SU2. If not, see . */ - -#include "../include/numerics_structure.hpp" -#include +#include "../../../include/numerics/template/CConvective_Template.hpp" CConvective_Template::CConvective_Template(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { @@ -216,18 +214,3 @@ void CConvective_Template::ComputeResidual(su2double *val_residual, su2double ** } } } - -CSource_Template::CSource_Template(unsigned short val_nDim, unsigned short val_nVar, - CConfig *config) : CNumerics(val_nDim, val_nVar, config) {} - -CSource_Template::~CSource_Template(void) { - -} - -void CSource_Template::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config) {} - -CViscous_Template::CViscous_Template(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { } - -CViscous_Template::~CViscous_Template(void) { } - -void CViscous_Template::ComputeResidual(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config) { } diff --git a/SU2_CFD/src/numerics/template/CSource_Template.cpp b/SU2_CFD/src/numerics/template/CSource_Template.cpp new file mode 100644 index 000000000000..1d95822bb8fc --- /dev/null +++ b/SU2_CFD/src/numerics/template/CSource_Template.cpp @@ -0,0 +1,37 @@ +/*! + * \file CSource_Template.cpp + * \brief Implementation of numerics class CSource_Template. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../include/numerics/template/CSource_Template.hpp" + +CSource_Template::CSource_Template(unsigned short val_nDim, unsigned short val_nVar, + CConfig *config) : CNumerics(val_nDim, val_nVar, config) {} + +CSource_Template::~CSource_Template(void) { + +} + +void CSource_Template::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config) {} diff --git a/SU2_CFD/src/numerics/template/CViscous_Template.cpp b/SU2_CFD/src/numerics/template/CViscous_Template.cpp new file mode 100644 index 000000000000..afdec7585921 --- /dev/null +++ b/SU2_CFD/src/numerics/template/CViscous_Template.cpp @@ -0,0 +1,35 @@ +/*! + * \file CViscous_Template.cpp + * \brief Implementation of numerics class CViscous_Template. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../include/numerics/template/CViscous_Template.hpp" + +CViscous_Template::CViscous_Template(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { } + +CViscous_Template::~CViscous_Template(void) { } + +void CViscous_Template::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { } + diff --git a/SU2_CFD/src/numerics/transition/CAvgGradCorrected_TransLM.cpp b/SU2_CFD/src/numerics/transition/CAvgGradCorrected_TransLM.cpp new file mode 100644 index 000000000000..afed7b4c5c20 --- /dev/null +++ b/SU2_CFD/src/numerics/transition/CAvgGradCorrected_TransLM.cpp @@ -0,0 +1,108 @@ +/*! + * \file CAvgGradCorrected_TransLM.cpp + * \brief Implementation of numerics class CAvgGradCorrected_TransLM. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../include/numerics/transition/CAvgGradCorrected_TransLM.hpp" + +CAvgGradCorrected_TransLM::CAvgGradCorrected_TransLM(unsigned short val_nDim, unsigned short val_nVar, + CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + unsigned short iVar; + + implicit = (config->GetKind_TimeIntScheme_Turb() == EULER_IMPLICIT); + incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + + sigma = 2./3.; + + Edge_Vector = new su2double [nDim]; + Proj_Mean_GradTurbVar_Kappa = new su2double [nVar]; + Proj_Mean_GradTurbVar_Edge = new su2double [nVar]; + Proj_Mean_GradTurbVar_Corrected = new su2double [nVar]; + Mean_GradTurbVar = new su2double* [nVar]; + for (iVar = 0; iVar < nVar; iVar++) + Mean_GradTurbVar[iVar] = new su2double [nDim]; +} + +CAvgGradCorrected_TransLM::~CAvgGradCorrected_TransLM(void) { + + unsigned short iVar; + + delete [] Edge_Vector; + delete [] Proj_Mean_GradTurbVar_Kappa; + delete [] Proj_Mean_GradTurbVar_Edge; + delete [] Proj_Mean_GradTurbVar_Corrected; + for (iVar = 0; iVar < nVar; iVar++) + delete [] Mean_GradTurbVar[iVar]; + delete [] Mean_GradTurbVar; +} + +void CAvgGradCorrected_TransLM::ComputeResidual(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config) { + + // switch (config->GetKind_Turb_Model()) { + // case SA : + // /*--- Compute mean effective viscosity ---*/ + // nu_i = Laminar_Viscosity_i/U_i[0]; + // nu_j = Laminar_Viscosity_j/U_j[0]; + // nu_e = 0.5*(nu_i+nu_j+TurbVar_i[0]+TurbVar_j[0]); + // + // /*--- Compute vector going from iPoint to jPoint ---*/ + // 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]; + // } + // proj_vector_ij = proj_vector_ij/dist_ij_2; + // + // /*--- Mean gradient approximation. Projection of the mean gradient + // in the direction of the edge ---*/ + // for (iVar = 0; iVar < nVar; iVar++) { + // Proj_Mean_GradTurbVar_Kappa[iVar] = 0.0; + // Proj_Mean_GradTurbVar_Edge[iVar] = 0.0; + // for (iDim = 0; iDim < nDim; iDim++) { + // Mean_GradTurbVar[iVar][iDim] = 0.5*(TurbVar_Grad_i[iVar][iDim] + TurbVar_Grad_j[iVar][iDim]); + // Proj_Mean_GradTurbVar_Kappa[iVar] += Mean_GradTurbVar[iVar][iDim]*Normal[iDim]; + // Proj_Mean_GradTurbVar_Edge[iVar] += Mean_GradTurbVar[iVar][iDim]*Edge_Vector[iDim]; + // } + // Proj_Mean_GradTurbVar_Corrected[iVar] = Proj_Mean_GradTurbVar_Kappa[iVar]; + // Proj_Mean_GradTurbVar_Corrected[iVar] -= Proj_Mean_GradTurbVar_Edge[iVar]*proj_vector_ij - + // (TurbVar_j[iVar]-TurbVar_i[iVar])*proj_vector_ij; + // } + // + // val_residual[0] = nu_e*Proj_Mean_GradTurbVar_Corrected[0]/sigma; + // + // /*--- For Jacobians -> Use of TSL approx. to compute derivatives of the gradients ---*/ + // if (implicit) { + // Jacobian_i[0][0] = (0.5*Proj_Mean_GradTurbVar_Corrected[0]-nu_e*proj_vector_ij)/sigma; + // Jacobian_j[0][0] = (0.5*Proj_Mean_GradTurbVar_Corrected[0]+nu_e*proj_vector_ij)/sigma; + // } + // break; + // + // } +} diff --git a/SU2_CFD/src/numerics/transition/CAvgGrad_TransLM.cpp b/SU2_CFD/src/numerics/transition/CAvgGrad_TransLM.cpp new file mode 100644 index 000000000000..06ec045f7e17 --- /dev/null +++ b/SU2_CFD/src/numerics/transition/CAvgGrad_TransLM.cpp @@ -0,0 +1,139 @@ +/*! + * \file CAvgGrad_TransLM.cpp + * \brief Implementation of numerics class CAvgGrad_TransLM. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../include/numerics/transition/CAvgGrad_TransLM.hpp" + +CAvgGrad_TransLM::CAvgGrad_TransLM(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + unsigned short iVar; + + implicit = (config->GetKind_TimeIntScheme_Turb() == EULER_IMPLICIT); + incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + + sigma = 2./3.; + + Edge_Vector = new su2double [nDim]; + Proj_Mean_GradTransVar_Kappa = new su2double [nVar]; + Proj_Mean_GradTransVar_Edge = new su2double [nVar]; + Mean_GradTransVar = new su2double* [nVar]; + for (iVar = 0; iVar < nVar; iVar++) + Mean_GradTransVar[iVar] = new su2double [nDim]; +} + +CAvgGrad_TransLM::~CAvgGrad_TransLM(void) { + + unsigned short iVar; + + delete [] Edge_Vector; + delete [] Proj_Mean_GradTransVar_Kappa; + delete [] Proj_Mean_GradTransVar_Edge; + for (iVar = 0; iVar < nVar; iVar++) + delete [] Mean_GradTransVar[iVar]; + delete [] Mean_GradTransVar; +} + +void CAvgGrad_TransLM::ComputeResidual(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config) { + /*--- This section is commented out on 04/11/2016 + after review of the static scan ---*/ + // su2double *Density_Grad_i = new su2double[nDim]; + // su2double *Density_Grad_j = new su2double[nDim]; + // su2double *Conservative_Grad_i = new su2double[nDim]; + // su2double *Conservative_Grad_j = new su2double[nDim]; + // su2double *Primitive_Grad_i = new su2double[nDim]; + // su2double *Primitive_Grad_j = new su2double[nDim]; + // + // /*--- Intermediate values for combining viscosities ---*/ + // su2double Inter_Viscosity_i, Inter_Viscosity_j, REth_Viscosity_i, REth_Viscosity_j, Inter_Viscosity_Mean, REth_Viscosity_Mean; + // + // /*--- Model constants---*/ + // su2double sigmaf = 1.0; + // su2double sigma_thetat = 2.0; + // + // /*--- Get density ---*/ + // Density_i = U_i[0]; + // Density_j = U_j[0]; + // + // /*--- Construct combinations of viscosity ---*/ + // Inter_Viscosity_i = (Laminar_Viscosity_i+Eddy_Viscosity_i/sigmaf); + // Inter_Viscosity_j = (Laminar_Viscosity_j+Eddy_Viscosity_j/sigmaf); + // Inter_Viscosity_Mean = 0.5*(Inter_Viscosity_i+Inter_Viscosity_j); + // REth_Viscosity_i = sigma_thetat*(Laminar_Viscosity_i+Eddy_Viscosity_i); + // REth_Viscosity_j = sigma_thetat*(Laminar_Viscosity_j+Eddy_Viscosity_j); + // REth_Viscosity_Mean = 0.5*(REth_Viscosity_i+REth_Viscosity_j); + // + ///*--- Compute vector going from iPoint to jPoint ---*/ + //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]; + //} + //proj_vector_ij = proj_vector_ij/dist_ij_2; // to normalize vectors + // + ///*--- Mean gradient approximation ---*/ + //for (iVar = 0; iVar < nVar; iVar++) { + // Proj_Mean_GradTransVar_Kappa[iVar] = 0.0; + // // Proj_Mean_GradTransVar_Edge[iVar] = 0.0; + // for (iDim = 0; iDim < nDim; iDim++) { + // + // /* -- Compute primitive grad using chain rule -- */ + // Density_Grad_i[iDim] = ConsVar_Grad_i[0][iDim]; + // Density_Grad_j[iDim] = ConsVar_Grad_j[0][iDim]; + // Conservative_Grad_i[iDim] = TransVar_Grad_i[iVar][iDim]; + // Conservative_Grad_j[iDim] = TransVar_Grad_j[iVar][iDim]; + // Primitive_Grad_i[iDim] = 1./Density_i*(Conservative_Grad_i[iDim]-TransVar_i[iVar]*Density_Grad_i[iDim]); + // Primitive_Grad_j[iDim] = 1./Density_j*(Conservative_Grad_j[iDim]-TransVar_j[iVar]*Density_Grad_j[iDim]); + // + // /*--- Compute the average primitive gradient and project it in the normal direction ---*/ + // Mean_GradTransVar[iVar][iDim] = 0.5*(Primitive_Grad_i[iDim] + Primitive_Grad_j[iDim]); + // Proj_Mean_GradTransVar_Kappa[iVar] += Mean_GradTransVar[iVar][iDim]*Normal[iDim]; + // } + //} + // + //val_residual[0] = Inter_Viscosity_Mean*Proj_Mean_GradTransVar_Kappa[0]; + //val_residual[1] = REth_Viscosity_Mean*Proj_Mean_GradTransVar_Kappa[1]; + // + ///*--- For Jacobians -> Use of TSL approx. to compute derivatives of the gradients ---*/ + //if (implicit) { + // Jacobian_i[0][0] = (0.5*Proj_Mean_GradTransVar_Kappa[0]-Inter_Viscosity_Mean*proj_vector_ij); + // Jacobian_j[0][0] = (0.5*Proj_Mean_GradTransVar_Kappa[0]+Inter_Viscosity_Mean*proj_vector_ij); + // Jacobian_i[1][1] = (0.5*Proj_Mean_GradTransVar_Kappa[1]-REth_Viscosity_Mean*proj_vector_ij); + // Jacobian_j[1][1] = (0.5*Proj_Mean_GradTransVar_Kappa[1]+REth_Viscosity_Mean*proj_vector_ij); + //} + // + // /*--- Free locally allocated memory. For efficiency, these arrays + // should really be allocated/deallocated in the constructor/destructor. ---*/ + // delete [] Density_Grad_i; + // delete [] Density_Grad_j; + // delete [] Conservative_Grad_i; + // delete [] Conservative_Grad_j; + // delete [] Primitive_Grad_i; + // delete [] Primitive_Grad_j; + // +} diff --git a/SU2_CFD/src/numerics_direct_transition.cpp b/SU2_CFD/src/numerics/transition/CSourcePieceWise_TransLM.cpp similarity index 60% rename from SU2_CFD/src/numerics_direct_transition.cpp rename to SU2_CFD/src/numerics/transition/CSourcePieceWise_TransLM.cpp index 56b8c177bfcf..5469edb69bc6 100644 --- a/SU2_CFD/src/numerics_direct_transition.cpp +++ b/SU2_CFD/src/numerics/transition/CSourcePieceWise_TransLM.cpp @@ -1,12 +1,12 @@ /*! - * \file numerics_direct_transition.cpp - * \brief This file contains all the convective term discretization. - * \author A. Aranake + * \file CSourcePieceWise_TransLM.cpp + * \brief Implementation of numerics class CSourcePieceWise_TransLM. + * \author F. Palacios, T. Economon * \version 7.0.0 "Blackbird" * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -25,290 +25,7 @@ * License along with SU2. If not, see . */ - -#include "../include/numerics_structure.hpp" -#include - -CUpwLin_TransLM::CUpwLin_TransLM(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_Turb() == EULER_IMPLICIT); - incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; - -} - -CUpwLin_TransLM::~CUpwLin_TransLM(void) { - delete [] Velocity_i; - delete [] Velocity_j; -} - -void CUpwLin_TransLM::ComputeResidual (su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - - Density_i = U_i[0]; - Density_j = U_j[0]; - - q_ij = 0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = U_i[iDim+1]/Density_i; - Velocity_j[iDim] = U_j[iDim+1]/Density_j; - q_ij += 0.5*(Velocity_i[iDim]+Velocity_j[iDim])*Normal[iDim]; - } - - a0 = 0.5*(q_ij+fabs(q_ij)); - a1 = 0.5*(q_ij-fabs(q_ij)); - val_residual[0] = a0*TransVar_i[0]+a1*TransVar_j[0]; - val_residual[1] = a0*TransVar_i[1]+a1*TransVar_j[1]; - // cout << "Velicity x: " << Velocity_i[0] << ", " << Velocity_j[0] << endl; - // cout << "Velicity y: " << Velocity_i[1] << ", " << Velocity_j[1] << endl; - // cout << "val_resid: " << val_residual[0] << ", " << val_residual[1] << endl; - - - if (implicit) { - val_Jacobian_i[0][0] = a0; - val_Jacobian_i[1][1] = a0; - } -} - -CUpwSca_TransLM::CUpwSca_TransLM(unsigned short val_nDim, unsigned short val_nVar, - CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_Turb() == EULER_IMPLICIT); - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; -} - -CUpwSca_TransLM::~CUpwSca_TransLM(void) { - delete [] Velocity_i; - delete [] Velocity_j; -} - -void CUpwSca_TransLM::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - q_ij = 0; - for (iDim = 0; iDim < nDim; iDim++) { - q_ij += 0.5*(U_i[iDim]+U_j[iDim])*Normal[iDim]; - } - - a0 = 0.5*(q_ij+fabs(q_ij)); - a1 = 0.5*(q_ij-fabs(q_ij)); - val_residual[0] = a0*TransVar_i[0]+a1*TransVar_j[0]; - val_residual[1] = a0*TransVar_i[1]+a1*TransVar_j[1]; - - if (implicit) { - val_Jacobian_i[0][0] = a0; - val_Jacobian_j[0][0] = a1; - val_Jacobian_i[1][1] = a0; - val_Jacobian_j[1][1] = a1; - - /*--- Zero out off-diagonal terms just in case ---*/ - val_Jacobian_i[0][1] = 0; - val_Jacobian_j[0][1] = 0; - val_Jacobian_i[1][0] = 0; - val_Jacobian_j[1][0] = 0; - } - -} - -CAvgGrad_TransLM::CAvgGrad_TransLM(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - unsigned short iVar; - - implicit = (config->GetKind_TimeIntScheme_Turb() == EULER_IMPLICIT); - incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - sigma = 2./3.; - - Edge_Vector = new su2double [nDim]; - Proj_Mean_GradTransVar_Kappa = new su2double [nVar]; - Proj_Mean_GradTransVar_Edge = new su2double [nVar]; - Mean_GradTransVar = new su2double* [nVar]; - for (iVar = 0; iVar < nVar; iVar++) - Mean_GradTransVar[iVar] = new su2double [nDim]; -} - -CAvgGrad_TransLM::~CAvgGrad_TransLM(void) { - - unsigned short iVar; - - delete [] Edge_Vector; - delete [] Proj_Mean_GradTransVar_Kappa; - delete [] Proj_Mean_GradTransVar_Edge; - for (iVar = 0; iVar < nVar; iVar++) - delete [] Mean_GradTransVar[iVar]; - delete [] Mean_GradTransVar; -} - -void CAvgGrad_TransLM::ComputeResidual(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config) { - /*--- This section is commented out on 04/11/2016 - after review of the static scan ---*/ - // su2double *Density_Grad_i = new su2double[nDim]; - // su2double *Density_Grad_j = new su2double[nDim]; - // su2double *Conservative_Grad_i = new su2double[nDim]; - // su2double *Conservative_Grad_j = new su2double[nDim]; - // su2double *Primitive_Grad_i = new su2double[nDim]; - // su2double *Primitive_Grad_j = new su2double[nDim]; - // - // /*--- Intermediate values for combining viscosities ---*/ - // su2double Inter_Viscosity_i, Inter_Viscosity_j, REth_Viscosity_i, REth_Viscosity_j, Inter_Viscosity_Mean, REth_Viscosity_Mean; - // - // /*--- Model constants---*/ - // su2double sigmaf = 1.0; - // su2double sigma_thetat = 2.0; - // - // /*--- Get density ---*/ - // Density_i = U_i[0]; - // Density_j = U_j[0]; - // - // /*--- Construct combinations of viscosity ---*/ - // Inter_Viscosity_i = (Laminar_Viscosity_i+Eddy_Viscosity_i/sigmaf); - // Inter_Viscosity_j = (Laminar_Viscosity_j+Eddy_Viscosity_j/sigmaf); - // Inter_Viscosity_Mean = 0.5*(Inter_Viscosity_i+Inter_Viscosity_j); - // REth_Viscosity_i = sigma_thetat*(Laminar_Viscosity_i+Eddy_Viscosity_i); - // REth_Viscosity_j = sigma_thetat*(Laminar_Viscosity_j+Eddy_Viscosity_j); - // REth_Viscosity_Mean = 0.5*(REth_Viscosity_i+REth_Viscosity_j); - // - ///*--- Compute vector going from iPoint to jPoint ---*/ - //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]; - //} - //proj_vector_ij = proj_vector_ij/dist_ij_2; // to normalize vectors - // - ///*--- Mean gradient approximation ---*/ - //for (iVar = 0; iVar < nVar; iVar++) { - // Proj_Mean_GradTransVar_Kappa[iVar] = 0.0; - // // Proj_Mean_GradTransVar_Edge[iVar] = 0.0; - // for (iDim = 0; iDim < nDim; iDim++) { - // - // /* -- Compute primitive grad using chain rule -- */ - // Density_Grad_i[iDim] = ConsVar_Grad_i[0][iDim]; - // Density_Grad_j[iDim] = ConsVar_Grad_j[0][iDim]; - // Conservative_Grad_i[iDim] = TransVar_Grad_i[iVar][iDim]; - // Conservative_Grad_j[iDim] = TransVar_Grad_j[iVar][iDim]; - // Primitive_Grad_i[iDim] = 1./Density_i*(Conservative_Grad_i[iDim]-TransVar_i[iVar]*Density_Grad_i[iDim]); - // Primitive_Grad_j[iDim] = 1./Density_j*(Conservative_Grad_j[iDim]-TransVar_j[iVar]*Density_Grad_j[iDim]); - // - // /*--- Compute the average primitive gradient and project it in the normal direction ---*/ - // Mean_GradTransVar[iVar][iDim] = 0.5*(Primitive_Grad_i[iDim] + Primitive_Grad_j[iDim]); - // Proj_Mean_GradTransVar_Kappa[iVar] += Mean_GradTransVar[iVar][iDim]*Normal[iDim]; - // } - //} - // - //val_residual[0] = Inter_Viscosity_Mean*Proj_Mean_GradTransVar_Kappa[0]; - //val_residual[1] = REth_Viscosity_Mean*Proj_Mean_GradTransVar_Kappa[1]; - // - ///*--- For Jacobians -> Use of TSL approx. to compute derivatives of the gradients ---*/ - //if (implicit) { - // Jacobian_i[0][0] = (0.5*Proj_Mean_GradTransVar_Kappa[0]-Inter_Viscosity_Mean*proj_vector_ij); - // Jacobian_j[0][0] = (0.5*Proj_Mean_GradTransVar_Kappa[0]+Inter_Viscosity_Mean*proj_vector_ij); - // Jacobian_i[1][1] = (0.5*Proj_Mean_GradTransVar_Kappa[1]-REth_Viscosity_Mean*proj_vector_ij); - // Jacobian_j[1][1] = (0.5*Proj_Mean_GradTransVar_Kappa[1]+REth_Viscosity_Mean*proj_vector_ij); - //} - // - // /*--- Free locally allocated memory. For efficiency, these arrays - // should really be allocated/deallocated in the constructor/destructor. ---*/ - // delete [] Density_Grad_i; - // delete [] Density_Grad_j; - // delete [] Conservative_Grad_i; - // delete [] Conservative_Grad_j; - // delete [] Primitive_Grad_i; - // delete [] Primitive_Grad_j; - // -} - -CAvgGradCorrected_TransLM::CAvgGradCorrected_TransLM(unsigned short val_nDim, unsigned short val_nVar, - CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - unsigned short iVar; - - implicit = (config->GetKind_TimeIntScheme_Turb() == EULER_IMPLICIT); - incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - sigma = 2./3.; - - Edge_Vector = new su2double [nDim]; - Proj_Mean_GradTurbVar_Kappa = new su2double [nVar]; - Proj_Mean_GradTurbVar_Edge = new su2double [nVar]; - Proj_Mean_GradTurbVar_Corrected = new su2double [nVar]; - Mean_GradTurbVar = new su2double* [nVar]; - for (iVar = 0; iVar < nVar; iVar++) - Mean_GradTurbVar[iVar] = new su2double [nDim]; -} - -CAvgGradCorrected_TransLM::~CAvgGradCorrected_TransLM(void) { - - unsigned short iVar; - - delete [] Edge_Vector; - delete [] Proj_Mean_GradTurbVar_Kappa; - delete [] Proj_Mean_GradTurbVar_Edge; - delete [] Proj_Mean_GradTurbVar_Corrected; - for (iVar = 0; iVar < nVar; iVar++) - delete [] Mean_GradTurbVar[iVar]; - delete [] Mean_GradTurbVar; -} - -void CAvgGradCorrected_TransLM::ComputeResidual(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config) { - - // switch (config->GetKind_Turb_Model()) { - // case SA : - // /*--- Compute mean effective viscosity ---*/ - // nu_i = Laminar_Viscosity_i/U_i[0]; - // nu_j = Laminar_Viscosity_j/U_j[0]; - // nu_e = 0.5*(nu_i+nu_j+TurbVar_i[0]+TurbVar_j[0]); - // - // /*--- Compute vector going from iPoint to jPoint ---*/ - // 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]; - // } - // proj_vector_ij = proj_vector_ij/dist_ij_2; - // - // /*--- Mean gradient approximation. Projection of the mean gradient - // in the direction of the edge ---*/ - // for (iVar = 0; iVar < nVar; iVar++) { - // Proj_Mean_GradTurbVar_Kappa[iVar] = 0.0; - // Proj_Mean_GradTurbVar_Edge[iVar] = 0.0; - // for (iDim = 0; iDim < nDim; iDim++) { - // Mean_GradTurbVar[iVar][iDim] = 0.5*(TurbVar_Grad_i[iVar][iDim] + TurbVar_Grad_j[iVar][iDim]); - // Proj_Mean_GradTurbVar_Kappa[iVar] += Mean_GradTurbVar[iVar][iDim]*Normal[iDim]; - // Proj_Mean_GradTurbVar_Edge[iVar] += Mean_GradTurbVar[iVar][iDim]*Edge_Vector[iDim]; - // } - // Proj_Mean_GradTurbVar_Corrected[iVar] = Proj_Mean_GradTurbVar_Kappa[iVar]; - // Proj_Mean_GradTurbVar_Corrected[iVar] -= Proj_Mean_GradTurbVar_Edge[iVar]*proj_vector_ij - - // (TurbVar_j[iVar]-TurbVar_i[iVar])*proj_vector_ij; - // } - // - // val_residual[0] = nu_e*Proj_Mean_GradTurbVar_Corrected[0]/sigma; - // - // /*--- For Jacobians -> Use of TSL approx. to compute derivatives of the gradients ---*/ - // if (implicit) { - // Jacobian_i[0][0] = (0.5*Proj_Mean_GradTurbVar_Corrected[0]-nu_e*proj_vector_ij)/sigma; - // Jacobian_j[0][0] = (0.5*Proj_Mean_GradTurbVar_Corrected[0]+nu_e*proj_vector_ij)/sigma; - // } - // break; - // - // } -} +#include "../../../include/numerics/transition/CSourcePieceWise_TransLM.hpp" CSourcePieceWise_TransLM::CSourcePieceWise_TransLM(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { @@ -747,5 +464,4 @@ void CSourcePieceWise_TransLM::CSourcePieceWise_TransLM__ComputeResidual_TransLM TransVar_i[1]); } else *val_residuald = 0.0; - } diff --git a/SU2_CFD/src/numerics/transition/CUpwLin_TransLM.cpp b/SU2_CFD/src/numerics/transition/CUpwLin_TransLM.cpp new file mode 100644 index 000000000000..fae509edecbf --- /dev/null +++ b/SU2_CFD/src/numerics/transition/CUpwLin_TransLM.cpp @@ -0,0 +1,74 @@ +/*! + * \file CUpwLin_TransLM.cpp + * \brief Implementation of numerics class CUpwLin_TransLM. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../include/numerics/transition/CUpwLin_TransLM.hpp" + +CUpwLin_TransLM::CUpwLin_TransLM(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + implicit = (config->GetKind_TimeIntScheme_Turb() == EULER_IMPLICIT); + incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + + Velocity_i = new su2double [nDim]; + Velocity_j = new su2double [nDim]; + +} + +CUpwLin_TransLM::~CUpwLin_TransLM(void) { + delete [] Velocity_i; + delete [] Velocity_j; +} + +void CUpwLin_TransLM::ComputeResidual (su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { + + + Density_i = U_i[0]; + Density_j = U_j[0]; + + q_ij = 0; + for (iDim = 0; iDim < nDim; iDim++) { + Velocity_i[iDim] = U_i[iDim+1]/Density_i; + Velocity_j[iDim] = U_j[iDim+1]/Density_j; + q_ij += 0.5*(Velocity_i[iDim]+Velocity_j[iDim])*Normal[iDim]; + } + + a0 = 0.5*(q_ij+fabs(q_ij)); + a1 = 0.5*(q_ij-fabs(q_ij)); + val_residual[0] = a0*TransVar_i[0]+a1*TransVar_j[0]; + val_residual[1] = a0*TransVar_i[1]+a1*TransVar_j[1]; + // cout << "Velicity x: " << Velocity_i[0] << ", " << Velocity_j[0] << endl; + // cout << "Velicity y: " << Velocity_i[1] << ", " << Velocity_j[1] << endl; + // cout << "val_resid: " << val_residual[0] << ", " << val_residual[1] << endl; + + + if (implicit) { + val_Jacobian_i[0][0] = a0; + val_Jacobian_i[1][1] = a0; + } +} diff --git a/SU2_CFD/src/numerics/transition/CUpwSca_TransLM.cpp b/SU2_CFD/src/numerics/transition/CUpwSca_TransLM.cpp new file mode 100644 index 000000000000..1c081ebf67a0 --- /dev/null +++ b/SU2_CFD/src/numerics/transition/CUpwSca_TransLM.cpp @@ -0,0 +1,72 @@ +/*! + * \file CUpwSca_TransLM.cpp + * \brief Implementation of numerics class CUpwSca_TransLM. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../include/numerics/transition/CUpwSca_TransLM.hpp" + +CUpwSca_TransLM::CUpwSca_TransLM(unsigned short val_nDim, unsigned short val_nVar, + CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + implicit = (config->GetKind_TimeIntScheme_Turb() == EULER_IMPLICIT); + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + + Velocity_i = new su2double [nDim]; + Velocity_j = new su2double [nDim]; +} + +CUpwSca_TransLM::~CUpwSca_TransLM(void) { + delete [] Velocity_i; + delete [] Velocity_j; +} + +void CUpwSca_TransLM::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { + + q_ij = 0; + for (iDim = 0; iDim < nDim; iDim++) { + q_ij += 0.5*(U_i[iDim]+U_j[iDim])*Normal[iDim]; + } + + a0 = 0.5*(q_ij+fabs(q_ij)); + a1 = 0.5*(q_ij-fabs(q_ij)); + val_residual[0] = a0*TransVar_i[0]+a1*TransVar_j[0]; + val_residual[1] = a0*TransVar_i[1]+a1*TransVar_j[1]; + + if (implicit) { + val_Jacobian_i[0][0] = a0; + val_Jacobian_j[0][0] = a1; + val_Jacobian_i[1][1] = a0; + val_Jacobian_j[1][1] = a1; + + /*--- Zero out off-diagonal terms just in case ---*/ + val_Jacobian_i[0][1] = 0; + val_Jacobian_j[0][1] = 0; + val_Jacobian_i[1][0] = 0; + val_Jacobian_j[1][0] = 0; + } + +} diff --git a/SU2_CFD/src/numerics/turbulent/CAvgGrad_Scalar.cpp b/SU2_CFD/src/numerics/turbulent/CAvgGrad_Scalar.cpp new file mode 100644 index 000000000000..d2dec6f5d65d --- /dev/null +++ b/SU2_CFD/src/numerics/turbulent/CAvgGrad_Scalar.cpp @@ -0,0 +1,126 @@ +/*! + * \file CAvgGrad_Scalar.cpp + * \brief Implementation of numerics class CAvgGrad_Scalar. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../include/numerics/turbulent/CAvgGrad_Scalar.hpp" + +CAvgGrad_Scalar::CAvgGrad_Scalar(unsigned short val_nDim, + unsigned short val_nVar, + bool correct_grad, + CConfig *config) + : CNumerics(val_nDim, val_nVar, config), correct_gradient(correct_grad) { + + implicit = (config->GetKind_TimeIntScheme_Turb() == EULER_IMPLICIT); + incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); + + Edge_Vector = new su2double [nDim]; + Proj_Mean_GradTurbVar_Normal = new su2double [nVar]; + Proj_Mean_GradTurbVar_Edge = new su2double [nVar]; + Proj_Mean_GradTurbVar = new su2double [nVar]; + Mean_GradTurbVar = new su2double* [nVar]; + for (iVar = 0; iVar < nVar; iVar++) + Mean_GradTurbVar[iVar] = new su2double [nDim]; + +} + +CAvgGrad_Scalar::~CAvgGrad_Scalar(void) { + + delete [] Edge_Vector; + delete [] Proj_Mean_GradTurbVar_Normal; + delete [] Proj_Mean_GradTurbVar_Edge; + delete [] Proj_Mean_GradTurbVar; + for (iVar = 0; iVar < nVar; iVar++) + delete [] Mean_GradTurbVar[iVar]; + delete [] Mean_GradTurbVar; + +} + +void CAvgGrad_Scalar::ComputeResidual(su2double *val_residual, + su2double **Jacobian_i, + su2double **Jacobian_j, + CConfig *config) { + + AD::StartPreacc(); + AD::SetPreaccIn(Coord_i, nDim); AD::SetPreaccIn(Coord_j, nDim); + AD::SetPreaccIn(Normal, nDim); + AD::SetPreaccIn(TurbVar_Grad_i, nVar, nDim); + AD::SetPreaccIn(TurbVar_Grad_j, nVar, nDim); + if (correct_gradient) { + AD::SetPreaccIn(TurbVar_i, nVar); AD::SetPreaccIn(TurbVar_j ,nVar); + } + ExtraADPreaccIn(); + + if (incompressible) { + AD::SetPreaccIn(V_i, nDim+6); AD::SetPreaccIn(V_j, nDim+6); + + Density_i = V_i[nDim+2]; Density_j = V_j[nDim+2]; + Laminar_Viscosity_i = V_i[nDim+4]; Laminar_Viscosity_j = V_j[nDim+4]; + Eddy_Viscosity_i = V_i[nDim+5]; Eddy_Viscosity_j = V_j[nDim+5]; + } + else { + AD::SetPreaccIn(V_i, nDim+7); AD::SetPreaccIn(V_j, nDim+7); + + Density_i = V_i[nDim+2]; Density_j = V_j[nDim+2]; + Laminar_Viscosity_i = V_i[nDim+5]; Laminar_Viscosity_j = V_j[nDim+5]; + Eddy_Viscosity_i = V_i[nDim+6]; Eddy_Viscosity_j = V_j[nDim+6]; + } + + /*--- Compute vector going from iPoint to jPoint ---*/ + + 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; + + /*--- Mean gradient approximation ---*/ + for (iVar = 0; iVar < nVar; iVar++) { + Proj_Mean_GradTurbVar_Normal[iVar] = 0.0; + Proj_Mean_GradTurbVar_Edge[iVar] = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + Mean_GradTurbVar[iVar][iDim] = 0.5*(TurbVar_Grad_i[iVar][iDim] + + TurbVar_Grad_j[iVar][iDim]); + Proj_Mean_GradTurbVar_Normal[iVar] += Mean_GradTurbVar[iVar][iDim] * + Normal[iDim]; + if (correct_gradient) + Proj_Mean_GradTurbVar_Edge[iVar] += Mean_GradTurbVar[iVar][iDim]*Edge_Vector[iDim]; + } + Proj_Mean_GradTurbVar[iVar] = Proj_Mean_GradTurbVar_Normal[iVar]; + if (correct_gradient) { + Proj_Mean_GradTurbVar[iVar] -= Proj_Mean_GradTurbVar_Edge[iVar]*proj_vector_ij - + (TurbVar_j[iVar]-TurbVar_i[iVar])*proj_vector_ij; + } + } + + FinishResidualCalc(val_residual, Jacobian_i, Jacobian_j, config); + + AD::SetPreaccOut(val_residual, nVar); + AD::EndPreacc(); + +} diff --git a/SU2_CFD/src/numerics/turbulent/CAvgGrad_TurbSA.cpp b/SU2_CFD/src/numerics/turbulent/CAvgGrad_TurbSA.cpp new file mode 100644 index 000000000000..b23825a5fb8f --- /dev/null +++ b/SU2_CFD/src/numerics/turbulent/CAvgGrad_TurbSA.cpp @@ -0,0 +1,59 @@ +/*! + * \file CAvgGrad_TurbSA.cpp + * \brief Implementation of numerics class CAvgGrad_TurbSA. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../include/numerics/turbulent/CAvgGrad_TurbSA.hpp" + +CAvgGrad_TurbSA::CAvgGrad_TurbSA(unsigned short val_nDim, + unsigned short val_nVar, bool correct_grad, + CConfig *config) + : CAvgGrad_Scalar(val_nDim, val_nVar, correct_grad, config), sigma(2./3.) { +} + +CAvgGrad_TurbSA::~CAvgGrad_TurbSA(void) { +} + +void CAvgGrad_TurbSA::ExtraADPreaccIn() { +} + +void CAvgGrad_TurbSA::FinishResidualCalc(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config) { + + /*--- Compute mean effective viscosity ---*/ + + nu_i = Laminar_Viscosity_i/Density_i; + nu_j = Laminar_Viscosity_j/Density_j; + nu_e = 0.5*(nu_i+nu_j+TurbVar_i[0]+TurbVar_j[0]); + + val_residual[0] = nu_e*Proj_Mean_GradTurbVar[0]/sigma; + + /*--- For Jacobians -> Use of TSL approx. to compute derivatives of the gradients ---*/ + + if (implicit) { + Jacobian_i[0][0] = (0.5*Proj_Mean_GradTurbVar[0]-nu_e*proj_vector_ij)/sigma; + Jacobian_j[0][0] = (0.5*Proj_Mean_GradTurbVar[0]+nu_e*proj_vector_ij)/sigma; + } + +} diff --git a/SU2_CFD/src/numerics/turbulent/CAvgGrad_TurbSA_Neg.cpp b/SU2_CFD/src/numerics/turbulent/CAvgGrad_TurbSA_Neg.cpp new file mode 100644 index 000000000000..887650efcba8 --- /dev/null +++ b/SU2_CFD/src/numerics/turbulent/CAvgGrad_TurbSA_Neg.cpp @@ -0,0 +1,76 @@ +/*! + * \file CAvgGrad_TurbSA_Neg.cpp + * \brief Implementation of numerics class CAvgGrad_TurbSA_Neg. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../include/numerics/turbulent/CAvgGrad_TurbSA_Neg.hpp" + +CAvgGrad_TurbSA_Neg::CAvgGrad_TurbSA_Neg(unsigned short val_nDim, + unsigned short val_nVar, + bool correct_grad, + CConfig *config) + : CAvgGrad_Scalar(val_nDim, val_nVar, correct_grad, config), + sigma(2./3.), cn1(16.0), fn(0.0) { +} + +CAvgGrad_TurbSA_Neg::~CAvgGrad_TurbSA_Neg(void) { +} + +void CAvgGrad_TurbSA_Neg::ExtraADPreaccIn() { +} + +void CAvgGrad_TurbSA_Neg::FinishResidualCalc(su2double *val_residual, + su2double **Jacobian_i, + su2double **Jacobian_j, + CConfig *config) { + + /*--- Compute mean effective viscosity ---*/ + + nu_i = Laminar_Viscosity_i/Density_i; + nu_j = Laminar_Viscosity_j/Density_j; + + nu_ij = 0.5*(nu_i+nu_j); + nu_tilde_ij = 0.5*(TurbVar_i[0]+TurbVar_j[0]); + + Xi = nu_tilde_ij/nu_ij; + + if (nu_tilde_ij > 0.0) { + nu_e = nu_ij + nu_tilde_ij; + } + else { + fn = (cn1 + Xi*Xi*Xi)/(cn1 - Xi*Xi*Xi); + nu_e = nu_ij + fn*nu_tilde_ij; + } + + val_residual[0] = nu_e*Proj_Mean_GradTurbVar_Normal[0]/sigma; + + /*--- For Jacobians -> Use of TSL approx. to compute derivatives of the gradients ---*/ + + if (implicit) { + Jacobian_i[0][0] = (0.5*Proj_Mean_GradTurbVar[0]-nu_e*proj_vector_ij)/sigma; + Jacobian_j[0][0] = (0.5*Proj_Mean_GradTurbVar[0]+nu_e*proj_vector_ij)/sigma; + } + +} diff --git a/SU2_CFD/src/numerics/turbulent/CAvgGrad_TurbSST.cpp b/SU2_CFD/src/numerics/turbulent/CAvgGrad_TurbSST.cpp new file mode 100644 index 000000000000..431f4b3c59dd --- /dev/null +++ b/SU2_CFD/src/numerics/turbulent/CAvgGrad_TurbSST.cpp @@ -0,0 +1,87 @@ +/*! + * \file CAvgGrad_TurbSST.cpp + * \brief Implementation of numerics class CAvgGrad_TurbSST. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../include/numerics/turbulent/CAvgGrad_TurbSST.hpp" + +CAvgGrad_TurbSST::CAvgGrad_TurbSST(unsigned short val_nDim, + unsigned short val_nVar, + const su2double *constants, + bool correct_grad, + CConfig *config) + : CAvgGrad_Scalar(val_nDim, val_nVar, correct_grad, config) { + + sigma_k1 = constants[0]; + sigma_om1 = constants[2]; + sigma_k2 = constants[1]; + sigma_om2 = constants[3]; + + F1_i = 0.0; F1_j = 0.0; + diff_kine = 0.0; + diff_omega = 0.0; + +} + +CAvgGrad_TurbSST::~CAvgGrad_TurbSST(void) { +} + +void CAvgGrad_TurbSST::ExtraADPreaccIn() { + AD::SetPreaccIn(F1_i); AD::SetPreaccIn(F1_j); +} + +void CAvgGrad_TurbSST::FinishResidualCalc(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config) { + + su2double sigma_kine_i, sigma_kine_j, sigma_omega_i, sigma_omega_j; + su2double diff_i_kine, diff_i_omega, diff_j_kine, diff_j_omega; + + /*--- Compute the blended constant for the viscous terms ---*/ + sigma_kine_i = F1_i*sigma_k1 + (1.0 - F1_i)*sigma_k2; + sigma_kine_j = F1_j*sigma_k1 + (1.0 - F1_j)*sigma_k2; + sigma_omega_i = F1_i*sigma_om1 + (1.0 - F1_i)*sigma_om2; + sigma_omega_j = F1_j*sigma_om1 + (1.0 - F1_j)*sigma_om2; + + /*--- Compute mean effective viscosity ---*/ + diff_i_kine = Laminar_Viscosity_i + sigma_kine_i*Eddy_Viscosity_i; + diff_j_kine = Laminar_Viscosity_j + sigma_kine_j*Eddy_Viscosity_j; + diff_i_omega = Laminar_Viscosity_i + sigma_omega_i*Eddy_Viscosity_i; + diff_j_omega = Laminar_Viscosity_j + sigma_omega_j*Eddy_Viscosity_j; + + diff_kine = 0.5*(diff_i_kine + diff_j_kine); // Could instead use weighted average! + diff_omega = 0.5*(diff_i_omega + diff_j_omega); + + val_residual[0] = diff_kine*Proj_Mean_GradTurbVar[0]; + val_residual[1] = diff_omega*Proj_Mean_GradTurbVar[1]; + + /*--- For Jacobians -> Use of TSL approx. to compute derivatives of the gradients ---*/ + if (implicit) { + Jacobian_i[0][0] = -diff_kine*proj_vector_ij/Density_i; Jacobian_i[0][1] = 0.0; + Jacobian_i[1][0] = 0.0; Jacobian_i[1][1] = -diff_omega*proj_vector_ij/Density_i; + + Jacobian_j[0][0] = diff_kine*proj_vector_ij/Density_j; Jacobian_j[0][1] = 0.0; + Jacobian_j[1][0] = 0.0; Jacobian_j[1][1] = diff_omega*proj_vector_ij/Density_j; + } + +} diff --git a/SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSA.cpp b/SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSA.cpp new file mode 100644 index 000000000000..3de331cdfa82 --- /dev/null +++ b/SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSA.cpp @@ -0,0 +1,202 @@ +/*! + * \file CSourcePieceWise_TurbSA.cpp + * \brief Implementation of numerics class CSourcePieceWise_TurbSA. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../include/numerics/turbulent/CSourcePieceWise_TurbSA.hpp" + +CSourcePieceWise_TurbSA::CSourcePieceWise_TurbSA(unsigned short val_nDim, unsigned short val_nVar, + CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); + rotating_frame = config->GetRotating_Frame(); + transition = (config->GetKind_Trans_Model() == BC); + + /*--- Spalart-Allmaras closure constants ---*/ + + cv1_3 = pow(7.1, 3.0); + k2 = pow(0.41, 2.0); + cb1 = 0.1355; + cw2 = 0.3; + ct3 = 1.2; + ct4 = 0.5; + cw3_6 = pow(2.0, 6.0); + sigma = 2./3.; + cb2 = 0.622; + cb2_sigma = cb2/sigma; + cw1 = cb1/k2+(1.0+cb2)/sigma; + +} + +CSourcePieceWise_TurbSA::~CSourcePieceWise_TurbSA(void) { } + +void CSourcePieceWise_TurbSA::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { + +// AD::StartPreacc(); +// AD::SetPreaccIn(V_i, nDim+6); +// AD::SetPreaccIn(Vorticity_i, nDim); +// AD::SetPreaccIn(StrainMag_i); +// AD::SetPreaccIn(TurbVar_i[0]); +// AD::SetPreaccIn(TurbVar_Grad_i[0], nDim); +// AD::SetPreaccIn(Volume); AD::SetPreaccIn(dist_i); + +// BC Transition Model variables + su2double vmag, rey, re_theta, re_theta_t, re_v; + su2double tu , nu_cr, nu_t, nu_BC, chi_1, chi_2, term1, term2, term_exponential; + + if (incompressible) { + Density_i = V_i[nDim+2]; + Laminar_Viscosity_i = V_i[nDim+4]; + } + else { + Density_i = V_i[nDim+2]; + Laminar_Viscosity_i = V_i[nDim+5]; + } + + val_residual[0] = 0.0; + Production = 0.0; + Destruction = 0.0; + CrossProduction = 0.0; + val_Jacobian_i[0][0] = 0.0; + + gamma_BC = 0.0; + vmag = 0.0; + tu = config->GetTurbulenceIntensity_FreeStream(); + rey = config->GetReynolds(); + + if (nDim==2) { + vmag = sqrt(V_i[1]*V_i[1]+V_i[2]*V_i[2]); + } + else if (nDim==3) { + vmag = sqrt(V_i[1]*V_i[1]+V_i[2]*V_i[2]+V_i[3]*V_i[3]); + } + + /*--- Evaluate Omega ---*/ + + Omega = sqrt(Vorticity_i[0]*Vorticity_i[0] + Vorticity_i[1]*Vorticity_i[1] + Vorticity_i[2]*Vorticity_i[2]); + + /*--- Rotational correction term ---*/ + + if (rotating_frame) { Omega += 2.0*min(0.0, StrainMag_i-Omega); } + + if (dist_i > 1e-10) { + + /*--- Production term ---*/ + + dist_i_2 = dist_i*dist_i; + nu = Laminar_Viscosity_i/Density_i; + Ji = TurbVar_i[0]/nu; + Ji_2 = Ji*Ji; + Ji_3 = Ji_2*Ji; + fv1 = Ji_3/(Ji_3+cv1_3); + fv2 = 1.0 - Ji/(1.0+Ji*fv1); + ft2 = ct3*exp(-ct4*Ji_2); + S = Omega; + inv_k2_d2 = 1.0/(k2*dist_i_2); + + Shat = S + TurbVar_i[0]*fv2*inv_k2_d2; + Shat = max(Shat, 1.0e-10); + inv_Shat = 1.0/Shat; + +// Original SA model +// Production = cb1*(1.0-ft2)*Shat*TurbVar_i[0]*Volume; + + if (transition) { + +// BC model constants + chi_1 = 0.002; + chi_2 = 5.0; + + nu_t = (TurbVar_i[0]*fv1); //S-A variable + nu_cr = chi_2/rey; + nu_BC = (nu_t)/(vmag*dist_i); + + re_v = ((Density_i*pow(dist_i,2.))/(Laminar_Viscosity_i))*Omega; + re_theta = re_v/2.193; + re_theta_t = (803.73 * pow((tu + 0.6067),-1.027)); //MENTER correlation + //re_theta_t = 163.0 + exp(6.91-tu); //ABU-GHANNAM & SHAW correlation + + term1 = sqrt(max(re_theta-re_theta_t,0.)/(chi_1*re_theta_t)); + term2 = sqrt(max(nu_BC-nu_cr,0.)/(nu_cr)); + term_exponential = (term1 + term2); + gamma_BC = 1.0 - exp(-term_exponential); + + Production = gamma_BC*cb1*Shat*TurbVar_i[0]*Volume; + } + else { + Production = cb1*Shat*TurbVar_i[0]*Volume; + } + + /*--- Destruction term ---*/ + + r = min(TurbVar_i[0]*inv_Shat*inv_k2_d2,10.0); + g = r + cw2*(pow(r,6.0)-r); + g_6 = pow(g,6.0); + glim = pow((1.0+cw3_6)/(g_6+cw3_6),1.0/6.0); + fw = g*glim; + +// Original SA model +// Destruction = (cw1*fw-cb1*ft2/k2)*TurbVar_i[0]*TurbVar_i[0]/dist_i_2*Volume; + + Destruction = cw1*fw*TurbVar_i[0]*TurbVar_i[0]/dist_i_2*Volume; + + /*--- Diffusion term ---*/ + + norm2_Grad = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + norm2_Grad += TurbVar_Grad_i[0][iDim]*TurbVar_Grad_i[0][iDim]; + + CrossProduction = cb2_sigma*norm2_Grad*Volume; + + val_residual[0] = Production - Destruction + CrossProduction; + + /*--- Implicit part, production term ---*/ + + dfv1 = 3.0*Ji_2*cv1_3/(nu*pow(Ji_3+cv1_3,2.)); + dfv2 = -(1/nu-Ji_2*dfv1)/pow(1.+Ji*fv1,2.); + if ( Shat <= 1.0e-10 ) dShat = 0.0; + else dShat = (fv2+TurbVar_i[0]*dfv2)*inv_k2_d2; + + if (transition) { + val_Jacobian_i[0][0] += gamma_BC*cb1*(TurbVar_i[0]*dShat+Shat)*Volume; + } + else { + val_Jacobian_i[0][0] += cb1*(TurbVar_i[0]*dShat+Shat)*Volume; + } + + /*--- Implicit part, destruction term ---*/ + + dr = (Shat-TurbVar_i[0]*dShat)*inv_Shat*inv_Shat*inv_k2_d2; + if (r == 10.0) dr = 0.0; + dg = dr*(1.+cw2*(6.0*pow(r,5.0)-1.0)); + dfw = dg*glim*(1.-g_6/(g_6+cw3_6)); + val_Jacobian_i[0][0] -= cw1*(dfw*TurbVar_i[0] + 2.0*fw)*TurbVar_i[0]/dist_i_2*Volume; + + } + +// AD::SetPreaccOut(val_residual[0]); +// AD::EndPreacc(); + +} diff --git a/SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSA_COMP.cpp b/SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSA_COMP.cpp new file mode 100644 index 000000000000..7ff78236672d --- /dev/null +++ b/SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSA_COMP.cpp @@ -0,0 +1,166 @@ +/*! + * \file CSourcePieceWise_TurbSA_COMP.cpp + * \brief Implementation of numerics class CSourcePieceWise_TurbSA_COMP. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../include/numerics/turbulent/CSourcePieceWise_TurbSA_COMP.hpp" + +CSourcePieceWise_TurbSA_COMP::CSourcePieceWise_TurbSA_COMP(unsigned short val_nDim, unsigned short val_nVar, + CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); + rotating_frame = config->GetRotating_Frame(); + + /*--- Spalart-Allmaras closure constants ---*/ + + cv1_3 = pow(7.1, 3.0); + k2 = pow(0.41, 2.0); + cb1 = 0.1355; + cw2 = 0.3; + ct3 = 1.2; + ct4 = 0.5; + cw3_6 = pow(2.0, 6.0); + sigma = 2./3.; + cb2 = 0.622; + cb2_sigma = cb2/sigma; + cw1 = cb1/k2+(1.0+cb2)/sigma; + c5 = 3.5; + +} + +CSourcePieceWise_TurbSA_COMP::~CSourcePieceWise_TurbSA_COMP(void) { } + +void CSourcePieceWise_TurbSA_COMP::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { + + // AD::StartPreacc(); + // AD::SetPreaccIn(V_i, nDim+6); + // AD::SetPreaccIn(Vorticity_i, nDim); + // AD::SetPreaccIn(StrainMag_i); + // AD::SetPreaccIn(TurbVar_i[0]); + // AD::SetPreaccIn(TurbVar_Grad_i[0], nDim); + // AD::SetPreaccIn(Volume); AD::SetPreaccIn(dist_i); + + if (incompressible) { + Density_i = V_i[nDim+2]; + Laminar_Viscosity_i = V_i[nDim+4]; + } + else { + Density_i = V_i[nDim+2]; + Laminar_Viscosity_i = V_i[nDim+5]; + } + + val_residual[0] = 0.0; + Production = 0.0; + Destruction = 0.0; + CrossProduction = 0.0; + val_Jacobian_i[0][0] = 0.0; + + /*--- Evaluate Omega ---*/ + + Omega = sqrt(Vorticity_i[0]*Vorticity_i[0] + Vorticity_i[1]*Vorticity_i[1] + Vorticity_i[2]*Vorticity_i[2]); + + /*--- Rotational correction term ---*/ + + if (rotating_frame) { Omega += 2.0*min(0.0, StrainMag_i-Omega); } + + if (dist_i > 1e-10) { + + /*--- Production term ---*/ + + dist_i_2 = dist_i*dist_i; + nu = Laminar_Viscosity_i/Density_i; + Ji = TurbVar_i[0]/nu; + Ji_2 = Ji*Ji; + Ji_3 = Ji_2*Ji; + fv1 = Ji_3/(Ji_3+cv1_3); + fv2 = 1.0 - Ji/(1.0+Ji*fv1); + ft2 = ct3*exp(-ct4*Ji_2); + S = Omega; + inv_k2_d2 = 1.0/(k2*dist_i_2); + + Shat = S + TurbVar_i[0]*fv2*inv_k2_d2; + Shat = max(Shat, 1.0e-10); + inv_Shat = 1.0/Shat; + + /*--- Production term ---*/; + + Production = cb1*Shat*TurbVar_i[0]*Volume; + + /*--- Destruction term ---*/ + + r = min(TurbVar_i[0]*inv_Shat*inv_k2_d2,10.0); + g = r + cw2*(pow(r,6.0)-r); + g_6 = pow(g,6.0); + glim = pow((1.0+cw3_6)/(g_6+cw3_6),1.0/6.0); + fw = g*glim; + + Destruction = cw1*fw*TurbVar_i[0]*TurbVar_i[0]/dist_i_2*Volume; + + /*--- Diffusion term ---*/ + + norm2_Grad = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + norm2_Grad += TurbVar_Grad_i[0][iDim]*TurbVar_Grad_i[0][iDim]; + + CrossProduction = cb2_sigma*norm2_Grad*Volume; + + val_residual[0] = Production - Destruction + CrossProduction; + + /*--- Compressibility Correction term ---*/ + Pressure_i = V_i[nDim+1]; + SoundSpeed_i = sqrt(Pressure_i*Gamma/Density_i); + aux_cc=0; + for(iDim=0;iDim. + */ + +#include "../../../include/numerics/turbulent/CSourcePieceWise_TurbSA_E.hpp" + +CSourcePieceWise_TurbSA_E::CSourcePieceWise_TurbSA_E(unsigned short val_nDim, unsigned short val_nVar, + CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); + rotating_frame = config->GetRotating_Frame(); + + /*--- Spalart-Allmaras closure constants ---*/ + + cv1_3 = pow(7.1, 3.0); + k2 = pow(0.41, 2.0); + cb1 = 0.1355; + cw2 = 0.3; + ct3 = 1.2; + ct4 = 0.5; + cw3_6 = pow(2.0, 6.0); + sigma = 2./3.; + cb2 = 0.622; + cb2_sigma = cb2/sigma; + cw1 = cb1/k2+(1.0+cb2)/sigma; + +} + +CSourcePieceWise_TurbSA_E::~CSourcePieceWise_TurbSA_E(void) { } + +void CSourcePieceWise_TurbSA_E::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { + + // AD::StartPreacc(); + // AD::SetPreaccIn(V_i, nDim+6); + // AD::SetPreaccIn(Vorticity_i, nDim); + // AD::SetPreaccIn(StrainMag_i); + // AD::SetPreaccIn(TurbVar_i[0]); + // AD::SetPreaccIn(TurbVar_Grad_i[0], nDim); + // AD::SetPreaccIn(Volume); AD::SetPreaccIn(dist_i); + + if (incompressible) { + Density_i = V_i[nDim+2]; + Laminar_Viscosity_i = V_i[nDim+4]; + } + else { + Density_i = V_i[nDim+2]; + Laminar_Viscosity_i = V_i[nDim+5]; + } + + val_residual[0] = 0.0; + Production = 0.0; + Destruction = 0.0; + CrossProduction = 0.0; + val_Jacobian_i[0][0] = 0.0; + + + /* + From NASA Turbulence model site. http://turbmodels.larc.nasa.gov/spalart.html + This form was developed primarily to improve the near-wall numerical behavior of the model (i.e., the goal was to improve the convergence behavior). The reference is: + Edwards, J. R. and Chandra, S. "Comparison of Eddy Viscosity-Transport Turbulence Models for Three-Dimensional, Shock-Separated Flowfields," AIAA Journal, Vol. 34, No. 4, 1996, pp. 756-763. + In this modificaton Omega is replaced by Strain Rate + */ + + /*--- Evaluate Omega, here Omega is the Strain Rate ---*/ + + Sbar = 0.0; + for(iDim=0;iDim 1e-10) { + + /*--- Production term ---*/ + + dist_i_2 = dist_i*dist_i; + nu = Laminar_Viscosity_i/Density_i; + Ji = TurbVar_i[0]/nu; + Ji_2 = Ji*Ji; + Ji_3 = Ji_2*Ji; + fv1 = Ji_3/(Ji_3+cv1_3); + fv2 = 1.0 - Ji/(1.0+Ji*fv1); + ft2 = ct3*exp(-ct4*Ji_2); + S = Omega; + inv_k2_d2 = 1.0/(k2*dist_i_2); + + //Shat = S + TurbVar_i[0]*fv2*inv_k2_d2; + Shat = max(S*((1.0/max(Ji,1.0e-16))+fv1),1.0e-16); + + Shat = max(Shat, 1.0e-10); + inv_Shat = 1.0/Shat; + + /*--- Production term ---*/; + + Production = cb1*Shat*TurbVar_i[0]*Volume; + + /*--- Destruction term ---*/ + + r = min(TurbVar_i[0]*inv_Shat*inv_k2_d2,10.0); + r=tanh(r)/tanh(1.0); + + g = r + cw2*(pow(r,6.0)-r); + g_6 = pow(g,6.0); + glim = pow((1.0+cw3_6)/(g_6+cw3_6),1.0/6.0); + fw = g*glim; + + Destruction = cw1*fw*TurbVar_i[0]*TurbVar_i[0]/dist_i_2*Volume; + + /*--- Diffusion term ---*/ + + norm2_Grad = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + norm2_Grad += TurbVar_Grad_i[0][iDim]*TurbVar_Grad_i[0][iDim]; + + CrossProduction = cb2_sigma*norm2_Grad*Volume; + + val_residual[0] = Production - Destruction + CrossProduction; + + /*--- Implicit part, production term ---*/ + + dfv1 = 3.0*Ji_2*cv1_3/(nu*pow(Ji_3+cv1_3,2.)); + dfv2 = -(1/nu-Ji_2*dfv1)/pow(1.+Ji*fv1,2.); + + if ( Shat <= 1.0e-10 ) dShat = 0.0; + else dShat = -S*pow(Ji,-2.0)/nu + S*dfv1; + val_Jacobian_i[0][0] += cb1*(TurbVar_i[0]*dShat+Shat)*Volume; + + /*--- Implicit part, destruction term ---*/ + + dr = (Shat-TurbVar_i[0]*dShat)*inv_Shat*inv_Shat*inv_k2_d2; + dr=(1-pow(tanh(r),2.0))*(dr)/tanh(1.0); + dg = dr*(1.+cw2*(6.0*pow(r,5.0)-1.0)); + dfw = dg*glim*(1.-g_6/(g_6+cw3_6)); + val_Jacobian_i[0][0] -= cw1*(dfw*TurbVar_i[0] + 2.0*fw)*TurbVar_i[0]/dist_i_2*Volume; + + } + + // AD::SetPreaccOut(val_residual[0]); + // AD::EndPreacc(); + +} diff --git a/SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSA_E_COMP.cpp b/SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSA_E_COMP.cpp new file mode 100644 index 000000000000..056a76500a3b --- /dev/null +++ b/SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSA_E_COMP.cpp @@ -0,0 +1,183 @@ +/*! + * \file CSourcePieceWise_TurbSA_E_COMP.cpp + * \brief Implementation of numerics class CSourcePieceWise_TurbSA_E_COMP. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../include/numerics/turbulent/CSourcePieceWise_TurbSA_E_COMP.hpp" + +CSourcePieceWise_TurbSA_E_COMP::CSourcePieceWise_TurbSA_E_COMP(unsigned short val_nDim, unsigned short val_nVar, + CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); + rotating_frame = config->GetRotating_Frame(); + + /*--- Spalart-Allmaras closure constants ---*/ + + cv1_3 = pow(7.1, 3.0); + k2 = pow(0.41, 2.0); + cb1 = 0.1355; + cw2 = 0.3; + ct3 = 1.2; + ct4 = 0.5; + cw3_6 = pow(2.0, 6.0); + sigma = 2./3.; + cb2 = 0.622; + cb2_sigma = cb2/sigma; + cw1 = cb1/k2+(1.0+cb2)/sigma; + +} + +CSourcePieceWise_TurbSA_E_COMP::~CSourcePieceWise_TurbSA_E_COMP(void) { } + +void CSourcePieceWise_TurbSA_E_COMP::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { + + // AD::StartPreacc(); + // AD::SetPreaccIn(V_i, nDim+6); + // AD::SetPreaccIn(Vorticity_i, nDim); + // AD::SetPreaccIn(StrainMag_i); + // AD::SetPreaccIn(TurbVar_i[0]); + // AD::SetPreaccIn(TurbVar_Grad_i[0], nDim); + // AD::SetPreaccIn(Volume); AD::SetPreaccIn(dist_i); + + if (incompressible) { + Density_i = V_i[nDim+2]; + Laminar_Viscosity_i = V_i[nDim+4]; + } + else { + Density_i = V_i[nDim+2]; + Laminar_Viscosity_i = V_i[nDim+5]; + } + + val_residual[0] = 0.0; + Production = 0.0; + Destruction = 0.0; + CrossProduction = 0.0; + val_Jacobian_i[0][0] = 0.0; + + /* + From NASA Turbulence model site. http://turbmodels.larc.nasa.gov/spalart.html + This form was developed primarily to improve the near-wall numerical behavior of the model (i.e., the goal was to improve the convergence behavior). The reference is: + Edwards, J. R. and Chandra, S. "Comparison of Eddy Viscosity-Transport Turbulence Models for Three-Dimensional, Shock-Separated Flowfields," AIAA Journal, Vol. 34, No. 4, 1996, pp. 756-763. + In this modificaton Omega is replaced by Strain Rate + */ + + /*--- Evaluate Omega, here Omega is the Strain Rate ---*/ + + Sbar = 0.0; + for(iDim=0;iDim 1e-10) { + + /*--- Production term ---*/ + + dist_i_2 = dist_i*dist_i; + nu = Laminar_Viscosity_i/Density_i; + Ji = TurbVar_i[0]/nu; + Ji_2 = Ji*Ji; + Ji_3 = Ji_2*Ji; + fv1 = Ji_3/(Ji_3+cv1_3); + fv2 = 1.0 - Ji/(1.0+Ji*fv1); + ft2 = ct3*exp(-ct4*Ji_2); + S = Omega; + inv_k2_d2 = 1.0/(k2*dist_i_2); + + Shat = max(S*((1.0/max(Ji,1.0e-16))+fv1),1.0e-16); + + Shat = max(Shat, 1.0e-10); + inv_Shat = 1.0/Shat; + + /*--- Production term ---*/; + + Production = cb1*Shat*TurbVar_i[0]*Volume; + + /*--- Destruction term ---*/ + + r = min(TurbVar_i[0]*inv_Shat*inv_k2_d2,10.0); + r=tanh(r)/tanh(1.0); + + g = r + cw2*(pow(r,6.0)-r); + g_6 = pow(g,6.0); + glim = pow((1.0+cw3_6)/(g_6+cw3_6),1.0/6.0); + fw = g*glim; + + Destruction = cw1*fw*TurbVar_i[0]*TurbVar_i[0]/dist_i_2*Volume; + + /*--- Diffusion term ---*/ + + norm2_Grad = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + norm2_Grad += TurbVar_Grad_i[0][iDim]*TurbVar_Grad_i[0][iDim]; + + CrossProduction = cb2_sigma*norm2_Grad*Volume; + + val_residual[0] = Production - Destruction + CrossProduction; + + /*--- Compressibility Correction term ---*/ + Pressure_i = V_i[nDim+1]; + SoundSpeed_i = sqrt(Pressure_i*Gamma/Density_i); + aux_cc=0; + for(iDim=0;iDim. + */ + +#include "../../../include/numerics/turbulent/CSourcePieceWise_TurbSA_Neg.hpp" + +CSourcePieceWise_TurbSA_Neg::CSourcePieceWise_TurbSA_Neg(unsigned short val_nDim, unsigned short val_nVar, + CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); + rotating_frame = config->GetRotating_Frame(); + + /*--- Negative Spalart-Allmaras closure constants ---*/ + + cv1_3 = pow(7.1, 3.0); + k2 = pow(0.41, 2.0); + cb1 = 0.1355; + cw2 = 0.3; + ct3 = 1.2; + ct4 = 0.5; + cw3_6 = pow(2.0, 6.0); + sigma = 2./3.; + cb2 = 0.622; + cb2_sigma = cb2/sigma; + cw1 = cb1/k2+(1.0+cb2)/sigma; + +} + +CSourcePieceWise_TurbSA_Neg::~CSourcePieceWise_TurbSA_Neg(void) { + +} + +void CSourcePieceWise_TurbSA_Neg::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { + +// AD::StartPreacc(); +// AD::SetPreaccIn(V_i, nDim+6); +// AD::SetPreaccIn(Vorticity_i, nDim); +// AD::SetPreaccIn(StrainMag_i); +// AD::SetPreaccIn(TurbVar_i[0]); +// AD::SetPreaccIn(TurbVar_Grad_i[0], nDim); +// AD::SetPreaccIn(Volume); AD::SetPreaccIn(dist_i); + + if (incompressible) { + Density_i = V_i[nDim+2]; + Laminar_Viscosity_i = V_i[nDim+4]; + } + else { + Density_i = V_i[nDim+2]; + Laminar_Viscosity_i = V_i[nDim+5]; + } + + val_residual[0] = 0.0; + Production = 0.0; + Destruction = 0.0; + CrossProduction = 0.0; + val_Jacobian_i[0][0] = 0.0; + + /*--- Evaluate Omega ---*/ + + Omega = sqrt(Vorticity_i[0]*Vorticity_i[0] + Vorticity_i[1]*Vorticity_i[1] + Vorticity_i[2]*Vorticity_i[2]); + + /*--- Rotational correction term ---*/ + + if (rotating_frame) { Omega += 2.0*min(0.0, StrainMag_i-Omega); } + + if (dist_i > 1e-10) { + + if (TurbVar_i[0] > 0.0) { + + /*--- Production term ---*/ + + dist_i_2 = dist_i*dist_i; + nu = Laminar_Viscosity_i/Density_i; + Ji = TurbVar_i[0]/nu; + Ji_2 = Ji*Ji; + Ji_3 = Ji_2*Ji; + fv1 = Ji_3/(Ji_3+cv1_3); + fv2 = 1.0 - Ji/(1.0+Ji*fv1); + ft2 = ct3*exp(-ct4*Ji_2); + S = Omega; + inv_k2_d2 = 1.0/(k2*dist_i_2); + + Shat = S + TurbVar_i[0]*fv2*inv_k2_d2; + Shat = max(Shat, 1.0e-10); + inv_Shat = 1.0/Shat; + + /*--- Production term ---*/; + + // Original SA model + // Production = cb1*(1.0-ft2)*Shat*TurbVar_i[0]*Volume; + + Production = cb1*Shat*TurbVar_i[0]*Volume; + + /*--- Destruction term ---*/ + + r = min(TurbVar_i[0]*inv_Shat*inv_k2_d2,10.0); + g = r + cw2*(pow(r,6.0)-r); + g_6 = pow(g,6.0); + glim = pow((1.0+cw3_6)/(g_6+cw3_6),1.0/6.0); + fw = g*glim; + + Destruction = cw1*fw*TurbVar_i[0]*TurbVar_i[0]/dist_i_2*Volume; + + /*--- Diffusion term ---*/ + + norm2_Grad = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + norm2_Grad += TurbVar_Grad_i[0][iDim]*TurbVar_Grad_i[0][iDim]; + + CrossProduction = cb2_sigma*norm2_Grad*Volume; + + val_residual[0] = Production - Destruction + CrossProduction; + + /*--- Implicit part, production term ---*/ + + dfv1 = 3.0*Ji_2*cv1_3/(nu*pow(Ji_3+cv1_3,2.)); + dfv2 = -(1/nu-Ji_2*dfv1)/pow(1.+Ji*fv1,2.); + if ( Shat <= 1.0e-10 ) dShat = 0.0; + else dShat = (fv2+TurbVar_i[0]*dfv2)*inv_k2_d2; + val_Jacobian_i[0][0] += cb1*(TurbVar_i[0]*dShat+Shat)*Volume; + + /*--- Implicit part, destruction term ---*/ + + dr = (Shat-TurbVar_i[0]*dShat)*inv_Shat*inv_Shat*inv_k2_d2; + if (r == 10.0) dr = 0.0; + dg = dr*(1.+cw2*(6.0*pow(r,5.0)-1.0)); + dfw = dg*glim*(1.-g_6/(g_6+cw3_6)); + val_Jacobian_i[0][0] -= cw1*(dfw*TurbVar_i[0] + 2.0*fw)*TurbVar_i[0]/dist_i_2*Volume; + + } + + else { + + /*--- Production term ---*/ + + dist_i_2 = dist_i*dist_i; + + /*--- Production term ---*/; + + Production = cb1*(1.0-ct3)*Omega*TurbVar_i[0]*Volume; + + /*--- Destruction term ---*/ + + Destruction = cw1*TurbVar_i[0]*TurbVar_i[0]/dist_i_2*Volume; + + /*--- Diffusion term ---*/ + + norm2_Grad = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + norm2_Grad += TurbVar_Grad_i[0][iDim]*TurbVar_Grad_i[0][iDim]; + + CrossProduction = cb2_sigma*norm2_Grad*Volume; + + val_residual[0] = Production + Destruction + CrossProduction; + + /*--- Implicit part, production term ---*/ + + val_Jacobian_i[0][0] += cb1*(1.0-ct3)*Omega*Volume; + + /*--- Implicit part, destruction term ---*/ + + val_Jacobian_i[0][0] += 2.0*cw1*TurbVar_i[0]/dist_i_2*Volume; + + } + + } + +// AD::SetPreaccOut(val_residual, nVar); +// AD::EndPreacc(); +} diff --git a/SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSST.cpp b/SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSST.cpp new file mode 100644 index 000000000000..9a294e5e890a --- /dev/null +++ b/SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSST.cpp @@ -0,0 +1,371 @@ +/*! + * \file CSourcePieceWise_TurbSST.cpp + * \brief Implementation of numerics class CSourcePieceWise_TurbSST. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../include/numerics/turbulent/CSourcePieceWise_TurbSST.hpp" + +CSourcePieceWise_TurbSST::CSourcePieceWise_TurbSST(unsigned short val_nDim, unsigned short val_nVar, const su2double *constants, + su2double val_kine_Inf, su2double val_omega_Inf, CConfig *config) + : CNumerics(val_nDim, val_nVar, config) { + + incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); + sustaining_terms = (config->GetKind_Turb_Model() == SST_SUST); + + /*--- Closure constants ---*/ + beta_star = constants[6]; + sigma_omega_1 = constants[2]; + sigma_omega_2 = constants[3]; + beta_1 = constants[4]; + beta_2 = constants[5]; + alfa_1 = constants[8]; + alfa_2 = constants[9]; + a1 = constants[7]; + + /*--- Set the ambient values of k and omega to the free stream values. ---*/ + kAmb = val_kine_Inf; + omegaAmb = val_omega_Inf; +} + +CSourcePieceWise_TurbSST::~CSourcePieceWise_TurbSST(void) { } + +void CSourcePieceWise_TurbSST::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { + + AD::StartPreacc(); + AD::SetPreaccIn(StrainMag_i); + AD::SetPreaccIn(TurbVar_i, nVar); + AD::SetPreaccIn(TurbVar_Grad_i, nVar, nDim); + AD::SetPreaccIn(Volume); AD::SetPreaccIn(dist_i); + AD::SetPreaccIn(F1_i); AD::SetPreaccIn(F2_i); AD::SetPreaccIn(CDkw_i); + AD::SetPreaccIn(PrimVar_Grad_i, nDim+1, nDim); + + unsigned short iDim; + su2double alfa_blended, beta_blended; + su2double diverg, pk, pw, zeta; + + if (incompressible) { + AD::SetPreaccIn(V_i, nDim+6); + + Density_i = V_i[nDim+2]; + Laminar_Viscosity_i = V_i[nDim+4]; + Eddy_Viscosity_i = V_i[nDim+5]; + } + else { + AD::SetPreaccIn(V_i, nDim+7); + + Density_i = V_i[nDim+2]; + Laminar_Viscosity_i = V_i[nDim+5]; + Eddy_Viscosity_i = V_i[nDim+6]; + } + + val_residual[0] = 0.0; val_residual[1] = 0.0; + val_Jacobian_i[0][0] = 0.0; val_Jacobian_i[0][1] = 0.0; + val_Jacobian_i[1][0] = 0.0; val_Jacobian_i[1][1] = 0.0; + + /*--- Computation of blended constants for the source terms---*/ + + alfa_blended = F1_i*alfa_1 + (1.0 - F1_i)*alfa_2; + beta_blended = F1_i*beta_1 + (1.0 - F1_i)*beta_2; + + if (dist_i > 1e-10) { + + /*--- Production ---*/ + + diverg = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + diverg += PrimVar_Grad_i[iDim+1][iDim]; + + /* if using UQ methodolgy, calculate production using perturbed Reynolds stress matrix */ + + if (using_uq){ + SetReynoldsStressMatrix(TurbVar_i[0]); + SetPerturbedRSM(TurbVar_i[0], config); + SetPerturbedStrainMag(TurbVar_i[0]); + pk = Eddy_Viscosity_i*PerturbedStrainMag*PerturbedStrainMag + - 2.0/3.0*Density_i*TurbVar_i[0]*diverg; + } + else { + pk = Eddy_Viscosity_i*StrainMag_i*StrainMag_i - 2.0/3.0*Density_i*TurbVar_i[0]*diverg; + } + + + pk = min(pk,20.0*beta_star*Density_i*TurbVar_i[1]*TurbVar_i[0]); + pk = max(pk,0.0); + + zeta = max(TurbVar_i[1], StrainMag_i*F2_i/a1); + + /* if using UQ methodolgy, calculate production using perturbed Reynolds stress matrix */ + + if (using_uq){ + pw = PerturbedStrainMag * PerturbedStrainMag - 2.0/3.0*zeta*diverg; + } + else { + pw = StrainMag_i*StrainMag_i - 2.0/3.0*zeta*diverg; + } + pw = alfa_blended*Density_i*max(pw,0.0); + + /*--- Sustaining terms, if desired. Note that if the production terms are + larger equal than the sustaining terms, the original formulation is + obtained again. This is in contrast to the version in literature + where the sustaining terms are simply added. This latter approach could + lead to problems for very big values of the free-stream turbulence + intensity. ---*/ + + if ( sustaining_terms ) { + const su2double sust_k = beta_star*Density_i*kAmb*omegaAmb; + const su2double sust_w = beta_blended*Density_i*omegaAmb*omegaAmb; + + pk = max(pk, sust_k); + pw = max(pw, sust_w); + } + + /*--- Add the production terms to the residuals. ---*/ + + val_residual[0] += pk*Volume; + val_residual[1] += pw*Volume; + + /*--- Dissipation ---*/ + + val_residual[0] -= beta_star*Density_i*TurbVar_i[1]*TurbVar_i[0]*Volume; + val_residual[1] -= beta_blended*Density_i*TurbVar_i[1]*TurbVar_i[1]*Volume; + + /*--- Cross diffusion ---*/ + + val_residual[1] += (1.0 - F1_i)*CDkw_i*Volume; + + /*--- Implicit part ---*/ + + val_Jacobian_i[0][0] = -beta_star*TurbVar_i[1]*Volume; + val_Jacobian_i[0][1] = -beta_star*TurbVar_i[0]*Volume; + val_Jacobian_i[1][0] = 0.0; + val_Jacobian_i[1][1] = -2.0*beta_blended*TurbVar_i[1]*Volume; + } + + AD::SetPreaccOut(val_residual, nVar); + AD::EndPreacc(); + +} + +void CSourcePieceWise_TurbSST::GetMeanRateOfStrainMatrix(su2double **S_ij) +{ + /* --- Calculate the rate of strain tensor, using mean velocity gradients --- */ + + if (nDim == 3){ + S_ij[0][0] = PrimVar_Grad_i[1][0]; + S_ij[1][1] = PrimVar_Grad_i[2][1]; + S_ij[2][2] = PrimVar_Grad_i[3][2]; + S_ij[0][1] = 0.5 * (PrimVar_Grad_i[1][1] + PrimVar_Grad_i[2][0]); + S_ij[0][2] = 0.5 * (PrimVar_Grad_i[1][2] + PrimVar_Grad_i[3][0]); + S_ij[1][2] = 0.5 * (PrimVar_Grad_i[2][2] + PrimVar_Grad_i[3][1]); + S_ij[1][0] = S_ij[0][1]; + S_ij[2][1] = S_ij[1][2]; + S_ij[2][0] = S_ij[0][2]; + } + else { + S_ij[0][0] = PrimVar_Grad_i[1][0]; + S_ij[1][1] = PrimVar_Grad_i[2][1]; + S_ij[2][2] = 0.0; + S_ij[0][1] = 0.5 * (PrimVar_Grad_i[1][1] + PrimVar_Grad_i[2][0]); + S_ij[0][2] = 0.0; + S_ij[1][2] = 0.0; + S_ij[1][0] = S_ij[0][1]; + S_ij[2][1] = S_ij[1][2]; + S_ij[2][0] = S_ij[0][2]; + + } +} + +void CSourcePieceWise_TurbSST::SetReynoldsStressMatrix(su2double turb_ke){ + unsigned short iDim, jDim; + su2double **S_ij = new su2double* [3]; + su2double divVel = 0; + su2double TWO3 = 2.0/3.0; + + + + for (iDim = 0; iDim < 3; iDim++){ + S_ij[iDim] = new su2double [3]; + } + + GetMeanRateOfStrainMatrix(S_ij); + + /* --- Using rate of strain matrix, calculate Reynolds stress tensor --- */ + + for (iDim = 0; iDim < 3; iDim++){ + divVel += S_ij[iDim][iDim]; + } + + for (iDim = 0; iDim < 3; iDim++){ + for (jDim = 0; jDim < 3; jDim++){ + MeanReynoldsStress[iDim][jDim] = TWO3 * turb_ke * delta3[iDim][jDim] + - Eddy_Viscosity_i / Density_i * (2 * S_ij[iDim][jDim] - TWO3 * divVel * delta3[iDim][jDim]); + } + } + + for (iDim = 0; iDim < 3; iDim++) + delete [] S_ij[iDim]; + delete [] S_ij; +} + +void CSourcePieceWise_TurbSST::SetPerturbedRSM(su2double turb_ke, CConfig *config){ + + unsigned short iDim,jDim; + + /* --- Calculate anisotropic part of Reynolds Stress tensor --- */ + + for (iDim = 0; iDim< 3; iDim++){ + for (jDim = 0; jDim < 3; jDim++){ + A_ij[iDim][jDim] = .5 * MeanReynoldsStress[iDim][jDim] / turb_ke - delta3[iDim][jDim] / 3.0; + Eig_Vec[iDim][jDim] = A_ij[iDim][jDim]; + } + } + + /* --- Get ordered eigenvectors and eigenvalues of A_ij --- */ + + EigenDecomposition(A_ij, Eig_Vec, Eig_Val, 3); + + /* compute convex combination coefficients */ + su2double c1c = Eig_Val[2] - Eig_Val[1]; + su2double c2c = 2.0 * (Eig_Val[1] - Eig_Val[0]); + su2double c3c = 3.0 * Eig_Val[0] + 1.0; + + /* define barycentric traingle corner points */ + Corners[0][0] = 1.0; + Corners[0][1] = 0.0; + Corners[1][0] = 0.0; + Corners[1][1] = 0.0; + Corners[2][0] = 0.5; + Corners[2][1] = 0.866025; + + /* define barycentric coordinates */ + Barycentric_Coord[0] = Corners[0][0] * c1c + Corners[1][0] * c2c + Corners[2][0] * c3c; + Barycentric_Coord[1] = Corners[0][1] * c1c + Corners[1][1] * c2c + Corners[2][1] * c3c; + + if (Eig_Val_Comp == 1) { + /* 1C turbulence */ + New_Coord[0] = Corners[0][0]; + New_Coord[1] = Corners[0][1]; + } + else if (Eig_Val_Comp == 2) { + /* 2C turbulence */ + New_Coord[0] = Corners[1][0]; + New_Coord[1] = Corners[1][1]; + } + else if (Eig_Val_Comp == 3) { + /* 3C turbulence */ + New_Coord[0] = Corners[2][0]; + New_Coord[1] = Corners[2][1]; + } + else { + /* 2C turbulence */ + New_Coord[0] = Corners[1][0]; + New_Coord[1] = Corners[1][1]; + } + /* calculate perturbed barycentric coordinates */ + + Barycentric_Coord[0] = Barycentric_Coord[0] + (uq_delta_b) * (New_Coord[0] - Barycentric_Coord[0]); + Barycentric_Coord[1] = Barycentric_Coord[1] + (uq_delta_b) * (New_Coord[1] - Barycentric_Coord[1]); + + /* rebuild c1c,c2c,c3c based on new barycentric coordinates */ + c3c = Barycentric_Coord[1] / Corners[2][1]; + c1c = Barycentric_Coord[0] - Corners[2][0] * c3c; + c2c = 1 - c1c - c3c; + + /* build new anisotropy eigenvalues */ + Eig_Val[0] = (c3c - 1) / 3.0; + Eig_Val[1] = 0.5 *c2c + Eig_Val[0]; + Eig_Val[2] = c1c + Eig_Val[1]; + + /* permute eigenvectors if required */ + if (uq_permute) { + for (iDim=0; iDim<3; iDim++) { + for (jDim=0; jDim<3; jDim++) { + New_Eig_Vec[iDim][jDim] = Eig_Vec[2-iDim][jDim]; + } + } + } + + else { + for (iDim=0; iDim<3; iDim++) { + for (jDim=0; jDim<3; jDim++) { + New_Eig_Vec[iDim][jDim] = Eig_Vec[iDim][jDim]; + } + } + } + + EigenRecomposition(newA_ij, New_Eig_Vec, Eig_Val, 3); + + /* compute perturbed Reynolds stress matrix; use under-relaxation factor (urlx)*/ + for (iDim = 0; iDim< 3; iDim++){ + for (jDim = 0; jDim < 3; jDim++){ + MeanPerturbedRSM[iDim][jDim] = 2.0 * turb_ke * (newA_ij[iDim][jDim] + 1.0/3.0 * delta3[iDim][jDim]); + MeanPerturbedRSM[iDim][jDim] = MeanReynoldsStress[iDim][jDim] + + uq_urlx*(MeanPerturbedRSM[iDim][jDim] - MeanReynoldsStress[iDim][jDim]); + } + } + +} + +void CSourcePieceWise_TurbSST::SetPerturbedStrainMag(su2double turb_ke){ + unsigned short iDim, jDim; + PerturbedStrainMag = 0; + su2double **StrainRate = new su2double* [nDim]; + for (iDim= 0; iDim< nDim; iDim++){ + StrainRate[iDim] = new su2double [nDim]; + } + + /* compute perturbed strain rate tensor */ + + for (iDim = 0; iDim < nDim; iDim++){ + for (jDim =0; jDim < nDim; jDim++){ + StrainRate[iDim][jDim] = MeanPerturbedRSM[iDim][jDim] + - TWO3 * turb_ke * delta[iDim][jDim]; + StrainRate[iDim][jDim] = - StrainRate[iDim][jDim] * Density_i / (2 * Eddy_Viscosity_i); + } + } + + /*--- Add diagonal part ---*/ + + for (iDim = 0; iDim < nDim; iDim++) { + PerturbedStrainMag += pow(StrainRate[iDim][iDim], 2.0); + } + + /*--- Add off diagonals ---*/ + + PerturbedStrainMag += 2.0*pow(StrainRate[1][0], 2.0); + + if (nDim == 3) { + PerturbedStrainMag += 2.0*pow(StrainRate[0][2], 2.0); + PerturbedStrainMag += 2.0*pow(StrainRate[1][2], 2.0); + } + + PerturbedStrainMag = sqrt(2.0*PerturbedStrainMag); + + for (iDim= 0; iDim< nDim; iDim++){ + delete [] StrainRate[iDim]; + } + + delete [] StrainRate; +} diff --git a/SU2_CFD/src/numerics/turbulent/CUpwSca_TurbSA.cpp b/SU2_CFD/src/numerics/turbulent/CUpwSca_TurbSA.cpp new file mode 100644 index 000000000000..06e7b14e5103 --- /dev/null +++ b/SU2_CFD/src/numerics/turbulent/CUpwSca_TurbSA.cpp @@ -0,0 +1,51 @@ +/*! + * \file CUpwSca_TurbSA.cpp + * \brief Implementation of numerics class CUpwSca_TurbSA. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../include/numerics/turbulent/CUpwSca_TurbSA.hpp" + +CUpwSca_TurbSA::CUpwSca_TurbSA(unsigned short val_nDim, + unsigned short val_nVar, + CConfig *config) + : CUpwScalar(val_nDim, val_nVar, config) { +} + +CUpwSca_TurbSA::~CUpwSca_TurbSA(void) { +} + +void CUpwSca_TurbSA::ExtraADPreaccIn() { + AD::SetPreaccIn(V_i, nDim+1); AD::SetPreaccIn(V_j, nDim+1); +} + +void CUpwSca_TurbSA::FinishResidualCalc(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { + + val_residual[0] = a0*TurbVar_i[0]+a1*TurbVar_j[0]; + + if (implicit) { + val_Jacobian_i[0][0] = a0; + val_Jacobian_j[0][0] = a1; + } +} diff --git a/SU2_CFD/src/numerics/turbulent/CUpwSca_TurbSST.cpp b/SU2_CFD/src/numerics/turbulent/CUpwSca_TurbSST.cpp new file mode 100644 index 000000000000..6ce09ba78530 --- /dev/null +++ b/SU2_CFD/src/numerics/turbulent/CUpwSca_TurbSST.cpp @@ -0,0 +1,61 @@ +/*! + * \file CUpwSca_TurbSST.cpp + * \brief Implementation of numerics class CUpwSca_TurbSST. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../include/numerics/turbulent/CUpwSca_TurbSST.hpp" + +CUpwSca_TurbSST::CUpwSca_TurbSST(unsigned short val_nDim, + unsigned short val_nVar, + CConfig *config) + : CUpwScalar(val_nDim, val_nVar, config) { +} + +CUpwSca_TurbSST::~CUpwSca_TurbSST(void) { +} + +void CUpwSca_TurbSST::ExtraADPreaccIn() { + + AD::SetPreaccIn(V_i, nDim+3); + AD::SetPreaccIn(V_j, nDim+3); + +} + +void CUpwSca_TurbSST::FinishResidualCalc(su2double *val_residual, + su2double **val_Jacobian_i, + su2double **val_Jacobian_j, + CConfig *config) { + + val_residual[0] = a0*Density_i*TurbVar_i[0]+a1*Density_j*TurbVar_j[0]; + val_residual[1] = a0*Density_i*TurbVar_i[1]+a1*Density_j*TurbVar_j[1]; + + if (implicit) { + val_Jacobian_i[0][0] = a0; val_Jacobian_i[0][1] = 0.0; + val_Jacobian_i[1][0] = 0.0; val_Jacobian_i[1][1] = a0; + + val_Jacobian_j[0][0] = a1; val_Jacobian_j[0][1] = 0.0; + val_Jacobian_j[1][0] = 0.0; val_Jacobian_j[1][1] = a1; + } +} diff --git a/SU2_CFD/src/numerics/turbulent/CUpwScalar.cpp b/SU2_CFD/src/numerics/turbulent/CUpwScalar.cpp new file mode 100644 index 000000000000..784b95938dc3 --- /dev/null +++ b/SU2_CFD/src/numerics/turbulent/CUpwScalar.cpp @@ -0,0 +1,94 @@ +/*! + * \file CUpwScalar.cpp + * \brief Implementation of numerics class CUpwScalar. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../include/numerics/turbulent/CUpwScalar.hpp" + +CUpwScalar::CUpwScalar(unsigned short val_nDim, + unsigned short val_nVar, + CConfig *config) + : CNumerics(val_nDim, val_nVar, config) { + + implicit = (config->GetKind_TimeIntScheme_Turb() == EULER_IMPLICIT); + incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); + /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ + dynamic_grid = config->GetDynamic_Grid(); + + Velocity_i = new su2double [nDim]; + Velocity_j = new su2double [nDim]; + +} + +CUpwScalar::~CUpwScalar(void) { + + delete [] Velocity_i; + delete [] Velocity_j; + +} + +void CUpwScalar::ComputeResidual(su2double *val_residual, + su2double **val_Jacobian_i, + su2double **val_Jacobian_j, + CConfig *config) { + + AD::StartPreacc(); + AD::SetPreaccIn(Normal, nDim); + AD::SetPreaccIn(TurbVar_i, nVar); AD::SetPreaccIn(TurbVar_j, nVar); + if (dynamic_grid) { + AD::SetPreaccIn(GridVel_i, nDim); AD::SetPreaccIn(GridVel_j, nDim); + } + + ExtraADPreaccIn(); + + Density_i = V_i[nDim+2]; + Density_j = V_j[nDim+2]; + + q_ij = 0.0; + if (dynamic_grid) { + for (iDim = 0; iDim < nDim; iDim++) { + Velocity_i[iDim] = V_i[iDim+1] - GridVel_i[iDim]; + Velocity_j[iDim] = V_j[iDim+1] - GridVel_j[iDim]; + q_ij += 0.5*(Velocity_i[iDim]+Velocity_j[iDim])*Normal[iDim]; + } + } + else { + for (iDim = 0; iDim < nDim; iDim++) { + Velocity_i[iDim] = V_i[iDim+1]; + Velocity_j[iDim] = V_j[iDim+1]; + q_ij += 0.5*(Velocity_i[iDim]+Velocity_j[iDim])*Normal[iDim]; + } + } + + a0 = 0.5*(q_ij+fabs(q_ij)); + a1 = 0.5*(q_ij-fabs(q_ij)); + + FinishResidualCalc(val_residual, val_Jacobian_i, val_Jacobian_j, config); + + + AD::SetPreaccOut(val_residual, nVar); + AD::EndPreacc(); + +} diff --git a/SU2_CFD/src/numerics_adjoint_mean.cpp b/SU2_CFD/src/numerics_adjoint_mean.cpp deleted file mode 100644 index bf6e2963fdd5..000000000000 --- a/SU2_CFD/src/numerics_adjoint_mean.cpp +++ /dev/null @@ -1,1598 +0,0 @@ -/*! - * \file numerics_adjoint_mean.cpp - * \brief This file contains the numerical methods for adjoint compressible flow. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - - -#include "../include/numerics_structure.hpp" -#include - -CUpwRoe_AdjFlow::CUpwRoe_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_AdjFlow() == EULER_IMPLICIT); - grid_movement = config->GetGrid_Movement(); - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - Residual_Roe = new su2double [nVar]; - RoeVelocity = new su2double [nDim]; - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; - Lambda = new su2double [nVar]; - P_Tensor = new su2double* [nVar]; - invP_Tensor = new su2double* [nVar]; - ProjFlux_i = new su2double*[nVar]; - ProjFlux_j = new su2double*[nVar]; - Proj_ModJac_Tensor = new su2double*[nVar]; - for (iVar = 0; iVar < nVar; iVar++) { - P_Tensor[iVar] = new su2double [nVar]; - invP_Tensor[iVar] = new su2double [nVar]; - ProjFlux_i[iVar] = new su2double[nVar]; - ProjFlux_j[iVar] = new su2double[nVar]; - Proj_ModJac_Tensor[iVar] = new su2double[nVar]; - } - -} - -CUpwRoe_AdjFlow::~CUpwRoe_AdjFlow(void) { - - delete [] Residual_Roe; - delete [] RoeVelocity; - delete [] Velocity_i; - delete [] Velocity_j; - delete [] Lambda; - for (iVar = 0; iVar < nVar; iVar++) { - delete [] P_Tensor[iVar]; - delete [] invP_Tensor[iVar]; - delete [] ProjFlux_i[iVar]; - delete [] ProjFlux_j[iVar]; - delete [] Proj_ModJac_Tensor[iVar]; - } - delete [] P_Tensor; - delete [] invP_Tensor; - delete [] ProjFlux_i; - delete [] ProjFlux_j; - delete [] Proj_ModJac_Tensor; - -} - -void CUpwRoe_AdjFlow::ComputeResidual (su2double *val_residual_i, su2double *val_residual_j, su2double **val_Jacobian_ii, - su2double **val_Jacobian_ij, su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config) { - - /*--- Compute the area ---*/ - - area = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - area += Normal[iDim]*Normal[iDim]; - area = sqrt(area); - rarea = 1.0 / area; - - /*--- Components of the normal & unit normal vector of the current face ---*/ - - Sx = Normal[0]; - Sy = Normal[1]; - Sz = 0.0; if (nDim == 3) Sz = Normal[2]; - nx = Sx * rarea; - ny = Sy * rarea; - nz = Sz * rarea; - - /*--- Flow variable states at point i (left, _l) and j (right, _r)---*/ - - rho_l = V_i[nDim+2]; rho_r = V_j[nDim+2]; - u_l = V_i[1]; v_l = V_i[2]; w_l = 0.0; if (nDim == 3) w_l = V_i[3]; - u_r = V_j[1]; v_r = V_j[2]; w_r = 0.0; if (nDim == 3) w_r = V_j[3]; - h_l = V_i[nDim+3]; h_r = V_j[nDim+3]; - - /*--- One-half speed squared ---*/ - - q_l = ONE2 * ((u_l*u_l) + (v_l*v_l) + (w_l*w_l)); - q_r = ONE2 * ((u_r*u_r) + (v_r*v_r) + (w_r*w_r)); - - /*--- Projected velocity ---*/ - - Q_l = (u_l * Sx) + (v_l * Sy) + (w_l * Sz); - Q_r = (u_r * Sx) + (v_r * Sy) + (w_r * Sz); - - /*--- Mean adjoint variables ---*/ - - psi1 = ONE2 * (Psi_i[0] + Psi_j[0]); - psi2 = ONE2 * (Psi_i[1] + Psi_j[1]); - psi3 = ONE2 * (Psi_i[2] + Psi_j[2]); - psi4 = 0.0; if (nDim == 3) psi4 = ONE2 * (Psi_i[3] + Psi_j[3]); - psi5 = ONE2 * (Psi_i[nVar-1] + Psi_j[nVar-1]); - - /*--- Left state ---*/ - - l1psi = (Sx * psi2) + (Sy * psi3) + (Sz * psi4) + (Q_l * psi5); - l2psi = psi1 + (u_l * psi2) + (v_l * psi3) + (w_l * psi4) + (h_l * psi5); - - val_residual_i[0] = Q_l * psi1 - l2psi * Q_l + l1psi * Gamma_Minus_One * q_l; - val_residual_i[1] = Q_l * psi2 + l2psi * Sx - l1psi * Gamma_Minus_One * u_l; - val_residual_i[2] = Q_l * psi3 + l2psi * Sy - l1psi * Gamma_Minus_One * v_l; - if (nDim == 3) val_residual_i[3] = Q_l * psi4 + l2psi * Sz - l1psi * Gamma_Minus_One * w_l; - val_residual_i[nVar-1] = Q_l * psi5 + l1psi * Gamma_Minus_One; - - /*--- Right state ---*/ - - l1psi = (Sx * psi2) + (Sy * psi3) + (Sz * psi4) + (Q_r * psi5); - l2psi = psi1 + (u_r * psi2) + (v_r * psi3) + (w_r * psi4) + (h_r * psi5); - - val_residual_j[0] = -(Q_r * psi1 - l2psi * Q_r + l1psi * Gamma_Minus_One * q_r); - val_residual_j[1] = -(Q_r * psi2 + l2psi * Sx - l1psi * Gamma_Minus_One * u_r); - val_residual_j[2] = -(Q_r * psi3 + l2psi * Sy - l1psi * Gamma_Minus_One * v_r); - if (nDim == 3) val_residual_j[3] = -(Q_r * psi4 + l2psi * Sz - l1psi * Gamma_Minus_One * w_r); - val_residual_j[nVar-1] = -(Q_r * psi5 + l1psi * Gamma_Minus_One); - - - /*--- f_{roe} = P^{-T} |lambda| P^T \delta \psi ---*/ - - psi1_l = Psi_i[0]; - psi2_l = Psi_i[1]; - psi3_l = Psi_i[2]; - psi4_l = 0.0; if (nDim == 3) psi4_l = Psi_i[3]; - psi5_l = Psi_i[nVar-1]; - - psi1_r = Psi_j[0]; - psi2_r = Psi_j[1]; - psi3_r = Psi_j[2]; - psi4_r = 0.0; if (nDim == 3) psi4_r = Psi_j[3]; - psi5_r = Psi_j[nVar-1]; - - /*--- Roe averaging ---*/ - - rrho_l = 1.0 / rho_l; - weight = sqrt(rho_r * rrho_l); - rweight1 = 1.0 / (1.0 + weight); - weight *= rweight1; - - h = h_l * rweight1 + weight * h_r; - u = u_l * rweight1 + weight * u_r; - v = v_l * rweight1 + weight * v_r; - w = w_l * rweight1 + weight * w_r; - - psi1 = ONE2 * (psi1_r - psi1_l); - psi2 = ONE2 * (psi2_r - psi2_l); - psi3 = ONE2 * (psi3_r - psi3_l); - psi4 = ONE2 * (psi4_r - psi4_l); - psi5 = ONE2 * (psi5_r - psi5_l); - - q2 = (u*u) + (v*v) + (w*w); - Q = (u * Sx) + (v * Sy) + (w * Sz); - vn = nx * u + ny * v + nz * w; - cc = Gamma_Minus_One * h - 0.5 * Gamma_Minus_One * q2; - c = sqrt(cc); - - /*--- Contribution to velocity projection due to grid movement ---*/ - - if (grid_movement) { - su2double ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - Q -= ProjGridVel; - } - - /*--- Eigenvalues from the primal solution ---*/ - - absQ = fabs(Q); - absQp = fabs(Q + c * area); - absQm = fabs(Q - c * area); - - alpha = ONE2 * Gamma_Minus_One * q2 / cc; - beta_u = psi2 + u * psi5; - beta_v = psi3 + v * psi5; - beta_w = psi4 + w * psi5; - eta = Gamma_Minus_One / cc; - l1psi = (nx * psi2) + (ny * psi3) + (nz * psi4) + (vn * psi5); - l2psi = psi1 + (u * psi2) + (v * psi3) + (w * psi4) + (h * psi5); - l1l2p = (l2psi + c * l1psi) * absQp; - l1l2m = (l2psi - c * l1psi) * absQm; - - /*--- adjoint flux computation in the x, y and z coordinate system ---*/ - - Residual_Roe[0] = ((1.0-alpha)*l2psi - (1.0-alpha)*cc/Gamma_Minus_One*psi5 - - u*beta_u*(1.0-(nx*nx)) - v*beta_v*(1.0-(ny*ny)) - - w*beta_w*(1.0-(nz*nz)) + ny*nz*(w*beta_v + v*beta_w) - + nx*nz*(w*beta_u + u*beta_w) + ny*nx*(v*beta_u + u*beta_v) ) * absQ - - ONE2 / c * vn * (l1l2p - l1l2m) + ONE2 * alpha * (l1l2p + l1l2m); - - Residual_Roe[1] = (l2psi*u*eta - u*psi5 + beta_u*(1.0-(nx*nx)) - - nx*(beta_v*ny + beta_w*nz) ) * absQ + ONE2*nx/c * (l1l2p - l1l2m ) - - ONE2*eta*u * (l1l2p + l1l2m ); - - Residual_Roe[2] = (l2psi*v*eta - v*psi5 + beta_v*(1.0-(ny*ny)) - - ny*(beta_w*nz + beta_u*nx) ) * absQ + ONE2*ny/c * (l1l2p - l1l2m ) - - ONE2*eta*v * (l1l2p + l1l2m ); - - if (nDim == 3) Residual_Roe[3] = (l2psi*w*eta - w*psi5 + beta_w*(1.0-(nz*nz)) - nz*(beta_u*nx + beta_v*ny) ) * absQ - + ONE2*nz/c * (l1l2p - l1l2m ) - ONE2*eta*w * (l1l2p + l1l2m ); - - Residual_Roe[nVar-1] = (psi5 - l2psi*eta) * absQ + ONE2*eta*(l1l2p + l1l2m); - - for (iVar = 0; iVar < nVar; iVar++) { - val_residual_i[iVar] += Residual_Roe[iVar]; - val_residual_j[iVar] -= Residual_Roe[iVar]; - } - - /*--- Flux contribution due to grid movement ---*/ - - if (grid_movement) { - su2double ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - for (iVar = 0; iVar < nVar; iVar++) { - val_residual_i[iVar] -= ProjGridVel * 0.5*(Psi_i[iVar]+Psi_j[iVar]); - val_residual_j[iVar] += ProjGridVel * 0.5*(Psi_i[iVar]+Psi_j[iVar]); - } - } - - /*--- Implicit Contributions ---*/ - - if (implicit) { - - /*--- Prepare variables for use in matrix routines ---*/ - - RoeDensity = V_i[nDim+2]*sqrt(V_j[nDim+2]/V_i[nDim+2]); - RoeSoundSpeed = c; - UnitNormal[0] = nx; UnitNormal[1] = ny; if (nDim == 3 ) UnitNormal[2] = nz; - RoeVelocity[0] = u; RoeVelocity[1] = v; if (nDim == 3 ) RoeVelocity[2] = w; - Velocity_i[0] = u_l; Velocity_i[1] = v_l; if (nDim == 3 ) Velocity_i[2] = w_l; - Velocity_j[0] = u_r; Velocity_j[1] = v_r; if (nDim == 3 ) Velocity_j[2] = w_r; - - Pressure_i = V_i[nDim+1]; - Density_i = V_i[nDim+2]; - Enthalpy_i = V_i[nDim+3]; - Energy_i = Enthalpy_i - Pressure_i/Density_i; - - Pressure_j = V_i[nDim+1]; - Density_j = V_i[nDim+2]; - Enthalpy_j = V_i[nDim+3]; - Energy_j = Enthalpy_j - Pressure_j/Density_j; - - /*--- Jacobians of the inviscid flux, scaled by - 0.5 because val_resconv ~ 0.5*(fc_i+fc_j)*Normal ---*/ - - GetInviscidProjJac(Velocity_i, &Energy_i, Normal, 0.5, ProjFlux_i); - GetInviscidProjJac(Velocity_j, &Energy_j, Normal, 0.5, ProjFlux_j); - - /*--- Compute P, inverse P, and store eigenvalues ---*/ - - GetPMatrix_inv(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, invP_Tensor); - GetPMatrix(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, P_Tensor); - - /*--- Flow eigenvalues ---*/ - - for (iDim = 0; iDim < nDim; iDim++) - Lambda[iDim] = absQ; - Lambda[nVar-2] = absQp; - Lambda[nVar-1] = absQm; - - /*--- Roe's Flux approximation ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - Proj_ModJac_Tensor_ij = 0.0; - - /*--- Compute |Proj_ModJac_Tensor| = P x |Lambda| x inverse P ---*/ - - for (kVar = 0; kVar < nVar; kVar++) - Proj_ModJac_Tensor_ij += P_Tensor[iVar][kVar]*Lambda[kVar]*invP_Tensor[kVar][jVar]; - Proj_ModJac_Tensor[iVar][jVar] = 0.5*Proj_ModJac_Tensor_ij*area; - } - } - - /*--- Transpose the matrices and store the Jacobians. Note the negative - sign for the ji and jj Jacobians bc the normal direction is flipped. ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - val_Jacobian_ii[jVar][iVar] = ProjFlux_i[iVar][jVar] - Proj_ModJac_Tensor[iVar][jVar]; - val_Jacobian_ij[jVar][iVar] = ProjFlux_i[iVar][jVar] + Proj_ModJac_Tensor[iVar][jVar]; - val_Jacobian_ji[jVar][iVar] = -(ProjFlux_j[iVar][jVar] - Proj_ModJac_Tensor[iVar][jVar]); - val_Jacobian_jj[jVar][iVar] = -(ProjFlux_j[iVar][jVar] + Proj_ModJac_Tensor[iVar][jVar]); - } - } - - /*--- Jacobian contribution due to grid movement ---*/ - - if (grid_movement) { - su2double ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - for (iVar = 0; iVar < nVar; iVar++) { - - /*--- Adjust Jacobian main diagonal ---*/ - - val_Jacobian_ii[iVar][iVar] -= 0.5*ProjGridVel; - val_Jacobian_ij[iVar][iVar] -= 0.5*ProjGridVel; - val_Jacobian_ji[iVar][iVar] += 0.5*ProjGridVel; - val_Jacobian_jj[iVar][iVar] += 0.5*ProjGridVel; - } - } - - } -} - -CCentJST_AdjFlow::CCentJST_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - grid_movement = config->GetGrid_Movement(); - - Diff_Psi = new su2double [nVar]; Diff_Lapl = new su2double [nVar]; - Velocity_i = new su2double [nDim]; Velocity_j = new su2double [nDim]; - MeanPhi = new su2double [nDim]; - - Param_p = 0.3; - Param_Kappa_2 = config->GetKappa_2nd_AdjFlow(); - Param_Kappa_4 = config->GetKappa_4th_AdjFlow(); - implicit = (config->GetKind_TimeIntScheme_AdjFlow() == EULER_IMPLICIT); - -} - -CCentJST_AdjFlow::~CCentJST_AdjFlow(void) { - - delete [] Diff_Psi; delete [] Diff_Lapl; - delete [] Velocity_i; delete [] Velocity_j; - delete [] MeanPhi; -} - -void CCentJST_AdjFlow::ComputeResidual (su2double *val_resconv_i, su2double *val_resvisc_i, su2double *val_resconv_j, su2double *val_resvisc_j, - su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, - CConfig *config) { - - /*--- Mean Values ---*/ - - MeanPsiRho = 0.5*(Psi_i[0]+Psi_j[0]); - for (iDim = 0; iDim < nDim; iDim++) - MeanPhi[iDim] = 0.5*(Psi_i[iDim+1]+Psi_j[iDim+1]); - MeanPsiE = 0.5*(Psi_i[nVar-1]+Psi_j[nVar-1]); - - /*--- Point i convective residual evaluation ---*/ - - ProjVelocity_i = 0; ProjPhi = 0; ProjPhi_Vel = 0; sq_vel = 0; Area = 0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = U_i[iDim+1] / U_i[0]; - ProjVelocity_i += Velocity_i[iDim]*Normal[iDim]; - ProjPhi += MeanPhi[iDim]*Normal[iDim]; - ProjPhi_Vel += MeanPhi[iDim]*Velocity_i[iDim]; - sq_vel += 0.5*Velocity_i[iDim]*Velocity_i[iDim]; - Area += Normal[iDim]*Normal[iDim]; - } - Area = sqrt(Area); - phis1 = ProjPhi + ProjVelocity_i*MeanPsiE; - phis2 = MeanPsiRho + ProjPhi_Vel + Enthalpy_i*MeanPsiE; - - val_resconv_i[0] = ProjVelocity_i*MeanPsiRho - phis2*ProjVelocity_i + Gamma_Minus_One*phis1*sq_vel; - for (iDim = 0; iDim < nDim; iDim++) - val_resconv_i[iDim+1] = ProjVelocity_i*MeanPhi[iDim] + phis2*Normal[iDim] - Gamma_Minus_One*phis1*Velocity_i[iDim]; - val_resconv_i[nVar-1] = ProjVelocity_i*MeanPsiE + Gamma_Minus_One*phis1; - - /*--- Flux contributions due to grid movement at point i ---*/ - - if (grid_movement) { - su2double ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - val_resconv_i[0] -= ProjGridVel*MeanPsiRho; - for (iDim = 0; iDim < nDim; iDim++) - val_resconv_i[iDim+1] -= ProjGridVel*MeanPhi[iDim]; - val_resconv_i[nVar-1] -= ProjGridVel*MeanPsiE; - } - - /*--- Jacobians of the inviscid flux ---*/ - - if (implicit) { - val_Jacobian_ii[0][0] = 0.0; - for (jDim = 0; jDim < nDim; jDim++) - val_Jacobian_ii[0][jDim+1] = -0.5*ProjVelocity_i*Velocity_i[jDim] + Gamma_Minus_One*sq_vel*0.5*Normal[jDim]; - val_Jacobian_ii[0][nVar-1] = 0.5*ProjVelocity_i*(Gamma_Minus_One*sq_vel - Enthalpy_i); - for (iDim = 0; iDim < nDim; iDim++) { - val_Jacobian_ii[iDim+1][0] = 0.5*Normal[iDim]; - for (jDim = 0; jDim < nDim; jDim++) - val_Jacobian_ii[iDim+1][jDim+1] = 0.5*Normal[iDim]*Velocity_i[jDim] - 0.5*Gamma_Minus_One*Velocity_i[iDim]*Normal[jDim]; - val_Jacobian_ii[iDim+1][iDim+1] += 0.5*ProjVelocity_i; - val_Jacobian_ii[iDim+1][nVar-1] = 0.5*Enthalpy_i*Normal[iDim] - 0.5*Gamma_Minus_One*Velocity_i[iDim]*ProjVelocity_i; - } - val_Jacobian_ii[nVar-1][0] = 0; - for (jDim = 0; jDim < nDim; jDim++) - val_Jacobian_ii[nVar-1][jDim+1] = 0.5*Gamma_Minus_One*Normal[jDim]; - val_Jacobian_ii[nVar-1][nVar-1] = 0.5*Gamma*ProjVelocity_i; - - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_ij[iVar][jVar] = val_Jacobian_ii[iVar][jVar]; - - /*--- Jacobian contributions due to grid movement at point i ---*/ - - if (grid_movement) { - su2double ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - for (iVar = 0; iVar < nVar; iVar++) { - val_Jacobian_ii[iVar][iVar] -= 0.5*ProjGridVel; - val_Jacobian_ij[iVar][iVar] -= 0.5*ProjGridVel; - } - } - } - - - /*--- Point j convective residual evaluation ---*/ - - ProjVelocity_j = 0; ProjPhi_Vel = 0; sq_vel = 0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_j[iDim] = U_j[iDim+1] / U_j[0]; - ProjVelocity_j += Velocity_j[iDim]*Normal[iDim]; - ProjPhi_Vel += MeanPhi[iDim]*Velocity_j[iDim]; - sq_vel += 0.5*Velocity_j[iDim]*Velocity_j[iDim]; - } - - phis1 = ProjPhi + ProjVelocity_j*MeanPsiE; - phis2 = MeanPsiRho + ProjPhi_Vel + Enthalpy_j*MeanPsiE; - - val_resconv_j[0] = -(ProjVelocity_j*MeanPsiRho - phis2*ProjVelocity_j + Gamma_Minus_One*phis1*sq_vel); - for (iDim = 0; iDim < nDim; iDim++) - val_resconv_j[iDim+1] = -(ProjVelocity_j*MeanPhi[iDim] + phis2*Normal[iDim] - Gamma_Minus_One*phis1*Velocity_j[iDim]); - val_resconv_j[nVar-1] = -(ProjVelocity_j*MeanPsiE + Gamma_Minus_One*phis1); - - /*--- Flux contributions due to grid motion at point j ---*/ - - if (grid_movement) { - su2double ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - val_resconv_j[0] += ProjGridVel*MeanPsiRho; - for (iDim = 0; iDim < nDim; iDim++) - val_resconv_j[iDim+1] += ProjGridVel*MeanPhi[iDim]; - val_resconv_j[nVar-1] += ProjGridVel*MeanPsiE; - } - - /*--- Jacobians of the inviscid flux ---*/ - - if (implicit) { - val_Jacobian_jj[0][0] = 0.0; - for (jDim = 0; jDim < nDim; jDim++) - val_Jacobian_jj[0][jDim+1] = 0.5*ProjVelocity_j*Velocity_j[jDim] - Gamma_Minus_One*sq_vel*0.5*Normal[jDim]; - val_Jacobian_jj[0][nVar-1] = -0.5*ProjVelocity_j*(Gamma_Minus_One*sq_vel - Enthalpy_j); - for (iDim = 0; iDim < nDim; iDim++) { - val_Jacobian_jj[iDim+1][0] = -0.5*Normal[iDim]; - for (jDim = 0; jDim < nDim; jDim++) - val_Jacobian_jj[iDim+1][jDim+1] = -0.5*Normal[iDim]*Velocity_j[jDim] + 0.5*Gamma_Minus_One*Velocity_j[iDim]*Normal[jDim]; - val_Jacobian_jj[iDim+1][iDim+1] -= 0.5*ProjVelocity_j; - val_Jacobian_jj[iDim+1][nVar-1] = -0.5*Enthalpy_j*Normal[iDim] + 0.5*Gamma_Minus_One*Velocity_j[iDim]*ProjVelocity_j; - } - val_Jacobian_jj[nVar-1][0] = 0; - for (jDim = 0; jDim < nDim; jDim++) - val_Jacobian_jj[nVar-1][jDim+1] = -0.5*Gamma_Minus_One*Normal[jDim]; - val_Jacobian_jj[nVar-1][nVar-1] = -0.5*Gamma*ProjVelocity_j; - - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_ji[iVar][jVar] = val_Jacobian_jj[iVar][jVar]; - - /*--- Jacobian contributions due to grid motion at point j ---*/ - - if (grid_movement) { - su2double ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - for (iVar = 0; iVar < nVar; iVar++) { - val_Jacobian_jj[iVar][iVar] += 0.5*ProjGridVel; - val_Jacobian_ji[iVar][iVar] += 0.5*ProjGridVel; - } - } - } - - /*--- Computes differences btw. variables and Laplacians ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - Diff_Lapl[iVar] = Und_Lapl_i[iVar]-Und_Lapl_j[iVar]; - Diff_Psi[iVar] = Psi_i[iVar]-Psi_j[iVar]; - } - - /*--- Adjustment to projected velocity due to grid motion ---*/ - - if (grid_movement) { - su2double ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - } - ProjVelocity_i -= ProjGridVel; - ProjVelocity_j += ProjGridVel; - } - - /*--- Compute the spectral radius and stretching factor ---*/ - - Local_Lambda_i = (fabs(ProjVelocity_i)+SoundSpeed_i*Area); - Local_Lambda_j = (fabs(ProjVelocity_j)+SoundSpeed_j*Area); - MeanLambda = 0.5*(Local_Lambda_i+Local_Lambda_j); - - Phi_i = pow(Lambda_i/(4.0*MeanLambda), Param_p); - Phi_j = pow(Lambda_j/(4.0*MeanLambda), Param_p); - StretchingFactor = 4.0*Phi_i*Phi_j/(Phi_i+Phi_j); - - su2double sc2 = 3.0*(su2double(Neighbor_i)+su2double(Neighbor_j))/(su2double(Neighbor_i)*su2double(Neighbor_j)); - sc4 = sc2*sc2/4.0; - Epsilon_2 = Param_Kappa_2*0.5*(Sensor_i+Sensor_j)*sc2; - Epsilon_4 = max(0.0, Param_Kappa_4-Epsilon_2)*sc4; - - /*--- Compute viscous residual 1st- & 3rd-order dissipation ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - Residual = (Epsilon_2*Diff_Psi[iVar]-Epsilon_4*Diff_Lapl[iVar])*StretchingFactor*MeanLambda; - val_resvisc_i[iVar] = -Residual; - val_resvisc_j[iVar] = Residual; - if (implicit) { - val_Jacobian_ii[iVar][iVar] -= Epsilon_2 + su2double(Neighbor_i+1)*Epsilon_4*StretchingFactor*MeanLambda; - val_Jacobian_ij[iVar][iVar] += Epsilon_2 + su2double(Neighbor_j+1)*Epsilon_4*StretchingFactor*MeanLambda; - val_Jacobian_ji[iVar][iVar] += Epsilon_2 + su2double(Neighbor_i+1)*Epsilon_4*StretchingFactor*MeanLambda; - val_Jacobian_jj[iVar][iVar] -= Epsilon_2 + su2double(Neighbor_j+1)*Epsilon_4*StretchingFactor*MeanLambda; - } - } - -} - -CCentLax_AdjFlow::CCentLax_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - Diff_Psi = new su2double [nVar]; MeanPhi = new su2double [nDim]; - Velocity_i = new su2double [nDim]; Velocity_j = new su2double [nDim]; - - implicit = (config->GetKind_TimeIntScheme_AdjFlow() == EULER_IMPLICIT); - - grid_movement = config->GetGrid_Movement(); - - Param_p = 0.3; - Param_Kappa_0 = config->GetKappa_1st_AdjFlow(); - -} - -CCentLax_AdjFlow::~CCentLax_AdjFlow(void) { - - delete [] Diff_Psi; delete [] MeanPhi; - delete [] Velocity_i; delete [] Velocity_j; - -} - -void CCentLax_AdjFlow::ComputeResidual (su2double *val_resconv_i, su2double *val_resvisc_i, su2double *val_resconv_j, su2double *val_resvisc_j, - su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, - CConfig *config) { - - /*--- Mean value of the adjoint variables ---*/ - MeanPsiRho = 0.5*(Psi_i[0]+Psi_j[0]); - for (iDim = 0; iDim < nDim; iDim++) - MeanPhi[iDim] = 0.5*(Psi_i[iDim+1]+Psi_j[iDim+1]); - MeanPsiE = 0.5*(Psi_i[nVar-1]+Psi_j[nVar-1]); - - /*--- Evaluation at point i ---*/ - ProjVelocity_i = 0; ProjPhi = 0; ProjPhi_Vel = 0; sq_vel = 0; Area = 0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = U_i[iDim+1] / U_i[0]; - ProjVelocity_i += Velocity_i[iDim]*Normal[iDim]; - ProjPhi += MeanPhi[iDim]*Normal[iDim]; - ProjPhi_Vel += MeanPhi[iDim]*Velocity_i[iDim]; - sq_vel += 0.5*Velocity_i[iDim]*Velocity_i[iDim]; - Area += Normal[iDim]*Normal[iDim]; - } - Area = sqrt(Area); - phis1 = ProjPhi + ProjVelocity_i*MeanPsiE; - phis2 = MeanPsiRho + ProjPhi_Vel + Enthalpy_i*MeanPsiE; - - /*--- Compute inviscid residual at point i ---*/ - val_resconv_i[0] = ProjVelocity_i*MeanPsiRho - phis2*ProjVelocity_i + Gamma_Minus_One*phis1*sq_vel; - for (iDim = 0; iDim < nDim; iDim++) - val_resconv_i[iDim+1] = ProjVelocity_i*MeanPhi[iDim] + phis2*Normal[iDim] - Gamma_Minus_One*phis1*Velocity_i[iDim]; - val_resconv_i[nVar-1] = ProjVelocity_i*MeanPsiE + Gamma_Minus_One*phis1; - - /*--- Flux contributions due to grid motion at point i ---*/ - if (grid_movement) { - su2double ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - val_resconv_i[0] -= ProjGridVel*MeanPsiRho; - for (iDim = 0; iDim < nDim; iDim++) - val_resconv_i[iDim+1] -= ProjGridVel*MeanPhi[iDim]; - val_resconv_i[nVar-1] -= ProjGridVel*MeanPsiE; - } - - /*--- Inviscid contribution to the implicit part ---*/ - if (implicit) { - val_Jacobian_ii[0][0] = 0.0; - for (jDim = 0; jDim < nDim; jDim++) - val_Jacobian_ii[0][jDim+1] = -0.5*ProjVelocity_i*Velocity_i[jDim] + Gamma_Minus_One*sq_vel*0.5*Normal[jDim]; - val_Jacobian_ii[0][nVar-1] = 0.5*ProjVelocity_i*(Gamma_Minus_One*sq_vel - Enthalpy_i); - for (iDim = 0; iDim < nDim; iDim++) { - val_Jacobian_ii[iDim+1][0] = 0.5*Normal[iDim]; - for (jDim = 0; jDim < nDim; jDim++) - val_Jacobian_ii[iDim+1][jDim+1] = 0.5*Normal[iDim]*Velocity_i[jDim] - 0.5*Gamma_Minus_One*Velocity_i[iDim]*Normal[jDim]; - val_Jacobian_ii[iDim+1][iDim+1] += 0.5*ProjVelocity_i; - val_Jacobian_ii[iDim+1][nVar-1] = 0.5*Enthalpy_i*Normal[iDim] - 0.5*Gamma_Minus_One*Velocity_i[iDim]*ProjVelocity_i; - } - val_Jacobian_ii[nVar-1][0] = 0; - for (jDim = 0; jDim < nDim; jDim++) - val_Jacobian_ii[nVar-1][jDim+1] = 0.5*Gamma_Minus_One*Normal[jDim]; - val_Jacobian_ii[nVar-1][nVar-1] = 0.5*Gamma*ProjVelocity_i; - - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_ij[iVar][jVar] = val_Jacobian_ii[iVar][jVar]; - - /*--- Jacobian contributions due to grid motion at point i ---*/ - if (grid_movement) { - su2double ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - for (iVar = 0; iVar < nVar; iVar++) { - val_Jacobian_ii[iVar][iVar] -= 0.5*ProjGridVel; - val_Jacobian_ij[iVar][iVar] -= 0.5*ProjGridVel; - } - } - } - - /*--- Evaluation at point j ---*/ - ProjVelocity_j = 0; ProjPhi_Vel = 0; sq_vel = 0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_j[iDim] = U_j[iDim+1] / U_j[0]; - ProjVelocity_j += Velocity_j[iDim]*Normal[iDim]; - ProjPhi_Vel += MeanPhi[iDim]*Velocity_j[iDim]; - sq_vel += 0.5*Velocity_j[iDim]*Velocity_j[iDim]; - } - - phis1 = ProjPhi + ProjVelocity_j*MeanPsiE; - phis2 = MeanPsiRho + ProjPhi_Vel + Enthalpy_j*MeanPsiE; - - /*--- Compute inviscid residual at point j ---*/ - val_resconv_j[0] = -(ProjVelocity_j*MeanPsiRho - phis2*ProjVelocity_j + Gamma_Minus_One*phis1*sq_vel); - for (iDim = 0; iDim < nDim; iDim++) - val_resconv_j[iDim+1] = -(ProjVelocity_j*MeanPhi[iDim] + phis2*Normal[iDim] - Gamma_Minus_One*phis1*Velocity_j[iDim]); - val_resconv_j[nVar-1] = -(ProjVelocity_j*MeanPsiE + Gamma_Minus_One*phis1); - - /*--- Flux contributions due to grid movement at point j ---*/ - if (grid_movement) { - su2double ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - val_resconv_j[0] += ProjGridVel*MeanPsiRho; - for (iDim = 0; iDim < nDim; iDim++) - val_resconv_j[iDim+1] += ProjGridVel*MeanPhi[iDim]; - val_resconv_j[nVar-1] += ProjGridVel*MeanPsiE; - } - - /*--- Inviscid contribution to the implicit part ---*/ - if (implicit) { - val_Jacobian_jj[0][0] = 0.0; - for (jDim = 0; jDim < nDim; jDim++) - val_Jacobian_jj[0][jDim+1] = 0.5*ProjVelocity_j*Velocity_j[jDim] - Gamma_Minus_One*sq_vel*0.5*Normal[jDim]; - val_Jacobian_jj[0][nVar-1] = -0.5*ProjVelocity_j*(Gamma_Minus_One*sq_vel - Enthalpy_j); - for (iDim = 0; iDim < nDim; iDim++) { - val_Jacobian_jj[iDim+1][0] = -0.5*Normal[iDim]; - for (jDim = 0; jDim < nDim; jDim++) - val_Jacobian_jj[iDim+1][jDim+1] = -0.5*Normal[iDim]*Velocity_j[jDim] + 0.5*Gamma_Minus_One*Velocity_j[iDim]*Normal[jDim]; - val_Jacobian_jj[iDim+1][iDim+1] -= 0.5*ProjVelocity_j; - val_Jacobian_jj[iDim+1][nVar-1] = -0.5*Enthalpy_j*Normal[iDim] + 0.5*Gamma_Minus_One*Velocity_j[iDim]*ProjVelocity_j; - } - val_Jacobian_jj[nVar-1][0] = 0; - for (jDim = 0; jDim < nDim; jDim++) - val_Jacobian_jj[nVar-1][jDim+1] = -0.5*Gamma_Minus_One*Normal[jDim]; - val_Jacobian_jj[nVar-1][nVar-1] = -0.5*Gamma*ProjVelocity_j; - - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_ji[iVar][jVar] = val_Jacobian_jj[iVar][jVar]; - - /*--- Jacobian contributions due to grid movement at point j ---*/ - if (grid_movement) { - su2double ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - for (iVar = 0; iVar < nVar; iVar++) { - val_Jacobian_jj[iVar][iVar] += 0.5*ProjGridVel; - val_Jacobian_ji[iVar][iVar] += 0.5*ProjGridVel; - } - } - } - - /*--- Computes differences btw. variables ---*/ - for (iVar = 0; iVar < nVar; iVar++) - Diff_Psi[iVar] = Psi_i[iVar]-Psi_j[iVar]; - - /*--- Adjustment to projected velocity due to grid motion ---*/ - if (grid_movement) { - su2double ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - ProjVelocity_i -= ProjGridVel; - ProjVelocity_j += ProjGridVel; - } - - /*--- Compute spectral radius ---*/ - Local_Lambda_i = (fabs(ProjVelocity_i)+SoundSpeed_i*Area); - Local_Lambda_j = (fabs(ProjVelocity_j)+SoundSpeed_j*Area); - MeanLambda = 0.5*(Local_Lambda_i+Local_Lambda_j); - - /*--- Compute streching factor ---*/ - Phi_i = pow(Lambda_i/(4.0*MeanLambda), Param_p); - Phi_j = pow(Lambda_j/(4.0*MeanLambda), Param_p); - StretchingFactor = 4.0*Phi_i*Phi_j/(Phi_i+Phi_j); - - sc2 = 3.0*(su2double(Neighbor_i)+su2double(Neighbor_j))/(su2double(Neighbor_i)*su2double(Neighbor_j)); - Epsilon_0 = Param_Kappa_0*sc2*su2double(nDim)/3.0; - - /*--- Artifical dissipation evaluation ---*/ - for (iVar = 0; iVar < nVar; iVar++) { - Residual = Epsilon_0*StretchingFactor*MeanLambda*Diff_Psi[iVar]; - val_resvisc_i[iVar] = -Residual; - val_resvisc_j[iVar] = Residual; - } - - /*--- Contribution to implicit part ---*/ - if (implicit) { - for (iVar = 0; iVar < nVar; iVar++) { - val_Jacobian_ii[iVar][iVar] -= Epsilon_0*StretchingFactor*MeanLambda; - val_Jacobian_ij[iVar][iVar] += Epsilon_0*StretchingFactor*MeanLambda; - val_Jacobian_ji[iVar][iVar] += Epsilon_0*StretchingFactor*MeanLambda; - val_Jacobian_jj[iVar][iVar] -= Epsilon_0*StretchingFactor*MeanLambda; - } - } - -} - -CAvgGrad_AdjFlow::CAvgGrad_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - unsigned short iDim; - - implicit = (config->GetKind_TimeIntScheme_AdjFlow() == EULER_IMPLICIT); - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; - Mean_Velocity = new su2double [nDim]; - Mean_GradPhi = new su2double* [nDim]; - for (iDim = 0; iDim < nDim; iDim++) - Mean_GradPhi[iDim] = new su2double [nDim]; - Mean_GradPsiE = new su2double [nDim]; - Edge_Vector = new su2double [nDim]; - -} - -CAvgGrad_AdjFlow::~CAvgGrad_AdjFlow(void) { - delete [] Velocity_i; - delete [] Velocity_j; - delete [] Mean_Velocity; - delete [] Edge_Vector; - delete [] Mean_GradPsiE; - for (unsigned short iDim = 0; iDim < nDim; iDim++) - delete [] Mean_GradPhi[iDim]; -} - -void CAvgGrad_AdjFlow::ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, - su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, - su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config) { - unsigned short iDim, jDim; - su2double sq_vel_i, ViscDens_i, XiDens_i; - su2double sq_vel_j, ViscDens_j, XiDens_j; - su2double dist_ij_2, dPhiE_dn; - - su2double Prandtl_Lam = config->GetPrandtl_Lam(); - su2double Prandtl_Turb = config->GetPrandtl_Turb(); - - /*--- States in point i ---*/ - - sq_vel_i = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = V_i[iDim+1]; - sq_vel_i += 0.5*Velocity_i[iDim]*Velocity_i[iDim]; - } - Pressure_i = V_i[nDim+1]; - Density_i = V_i[nDim+2]; - Enthalpy_i = V_i[nDim+3]; - SoundSpeed_i = sqrt(fabs(Pressure_i*Gamma/Density_i)); - - /*--- Laminar and Eddy viscosity ---*/ - - Laminar_Viscosity_i = V_i[nDim+5]; - Eddy_Viscosity_i = V_i[nDim+6]; - - ViscDens_i = (Laminar_Viscosity_i + Eddy_Viscosity_i) / Density_i; - XiDens_i = Gamma*(Laminar_Viscosity_i/Prandtl_Lam + Eddy_Viscosity_i/Prandtl_Turb) / Density_i; - - /*--- States in point j ---*/ - - sq_vel_j = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_j[iDim] = V_j[iDim+1]; - sq_vel_j += 0.5*Velocity_j[iDim]*Velocity_j[iDim]; - } - Pressure_j = V_j[nDim+1]; - Density_j = V_j[nDim+2]; - Enthalpy_j = V_j[nDim+3]; - SoundSpeed_j = sqrt(fabs(Pressure_j*Gamma/Density_j)); - - /*--- Laminar and Eddy viscosity ---*/ - - Laminar_Viscosity_j = V_j[nDim+5]; - Eddy_Viscosity_j = V_j[nDim+6]; - - ViscDens_j = (Laminar_Viscosity_j + Eddy_Viscosity_j) / Density_j; - XiDens_j = Gamma*(Laminar_Viscosity_j/Prandtl_Lam + Eddy_Viscosity_j/Prandtl_Turb) / Density_j; - - /*--- Compute vector going from iPoint to jPoint ---*/ - - dist_ij_2 = 0.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]; - } - - /*--- Average of the derivatives of the adjoint variables ---*/ - - for (iDim = 0; iDim < nDim; iDim++) { - Mean_GradPsiE[iDim] = 0.5*(PsiVar_Grad_i[nVar-1][iDim]+PsiVar_Grad_j[nVar-1][iDim]); - for (jDim = 0; jDim < nDim; jDim++) - Mean_GradPhi[iDim][jDim] = 0.5*(PsiVar_Grad_i[iDim+1][jDim]+PsiVar_Grad_j[iDim+1][jDim]); - } - - dPhiE_dn = 0; - for (iDim = 0; iDim < nDim; iDim++) - dPhiE_dn += Mean_GradPsiE[iDim]*Normal[iDim]; - - /*--- Compute the viscous residual and jacobian ---*/ - - GetAdjViscousFlux_Jac(Pressure_i, Pressure_j, Density_i, Density_j, - ViscDens_i, ViscDens_j, Velocity_i, Velocity_j, sq_vel_i, sq_vel_j, - XiDens_i, XiDens_j, Mean_GradPhi, Mean_GradPsiE, - dPhiE_dn, Normal, Edge_Vector, dist_ij_2, val_residual_i, val_residual_j, - val_Jacobian_ii, val_Jacobian_ij, val_Jacobian_ji, val_Jacobian_jj, - implicit); - -} - -CAvgGradCorrected_AdjFlow::CAvgGradCorrected_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_AdjFlow() == EULER_IMPLICIT); - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; - Mean_Velocity = new su2double [nDim]; - - Mean_GradPsiVar = new su2double* [nVar]; - for (unsigned short iVar = 0; iVar < nVar; iVar++) - Mean_GradPsiVar[iVar] = new su2double [nDim]; - - Edge_Vector = new su2double [nDim]; - Proj_Mean_GradPsiVar_Edge = new su2double [nVar]; - - Mean_GradPhi = new su2double* [nDim]; - for (unsigned short iDim = 0; iDim < nDim; iDim++) - Mean_GradPhi[iDim] = new su2double [nDim]; - Mean_GradPsiE = new su2double [nDim]; - -} - -CAvgGradCorrected_AdjFlow::~CAvgGradCorrected_AdjFlow(void) { - - delete [] Velocity_i; - delete [] Velocity_j; - delete [] Mean_Velocity; - delete [] Edge_Vector; - delete [] Proj_Mean_GradPsiVar_Edge; - - for (unsigned short iVar = 0; iVar < nVar; iVar++) - delete [] Mean_GradPsiVar[iVar]; - delete [] Mean_GradPsiVar; - - for (unsigned short iDim = 0; iDim < nDim; iDim++) - delete [] Mean_GradPhi[iDim]; - delete [] Mean_GradPhi; - delete [] Mean_GradPsiE; - -} - -void CAvgGradCorrected_AdjFlow::ComputeResidual(su2double *val_residual_i, - su2double *val_residual_j, - su2double **val_Jacobian_ii, - su2double **val_Jacobian_ij, - su2double **val_Jacobian_ji, - su2double **val_Jacobian_jj, - CConfig *config) { - - unsigned short iVar, iDim, jDim; - su2double Density_i, sq_vel_i, Pressure_i, ViscDens_i, XiDens_i; - su2double Density_j, sq_vel_j, Pressure_j, ViscDens_j, XiDens_j; - su2double dist_ij_2, dPhiE_dn; - - su2double Prandtl_Lam = config->GetPrandtl_Lam(); - su2double Prandtl_Turb = config->GetPrandtl_Turb(); - - /*--- States in point i ---*/ - - sq_vel_i = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = V_i[iDim+1]; - sq_vel_i += 0.5*Velocity_i[iDim]*Velocity_i[iDim]; - } - Pressure_i = V_i[nDim+1]; - Density_i = V_i[nDim+2]; - Enthalpy_i = V_i[nDim+3]; - - /*--- Laminar and Eddy viscosity ---*/ - - Laminar_Viscosity_i = V_i[nDim+5]; - Eddy_Viscosity_i = V_i[nDim+6]; - - ViscDens_i = (Laminar_Viscosity_i + Eddy_Viscosity_i) / Density_i; - XiDens_i = Gamma*(Laminar_Viscosity_i/Prandtl_Lam + - Eddy_Viscosity_i/Prandtl_Turb) / Density_i; - - /*--- States in point j ---*/ - - sq_vel_j = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_j[iDim] = V_j[iDim+1]; - sq_vel_j += 0.5*Velocity_j[iDim]*Velocity_j[iDim]; - } - Pressure_j = V_j[nDim+1]; - Density_j = V_j[nDim+2]; - Enthalpy_j = V_j[nDim+3]; - - /*--- Laminar and Eddy viscosity ---*/ - - Laminar_Viscosity_j = V_j[nDim+5]; - Eddy_Viscosity_j = V_j[nDim+6]; - - ViscDens_j = (Laminar_Viscosity_j + Eddy_Viscosity_j) / Density_j; - XiDens_j = Gamma*(Laminar_Viscosity_j/Prandtl_Lam + - Eddy_Viscosity_j/Prandtl_Turb) / Density_j; - - /*--- Compute vector going from iPoint to jPoint ---*/ - - dist_ij_2 = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Mean_Velocity[iDim] = 0.5*(Velocity_i[iDim]+Velocity_j[iDim]); - Edge_Vector[iDim] = Coord_j[iDim]-Coord_i[iDim]; - dist_ij_2 += Edge_Vector[iDim]*Edge_Vector[iDim]; - } - - /*--- Mean gradient approximation. Projection of the mean gradient in the direction of the edge, weiss correction ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - Proj_Mean_GradPsiVar_Edge[iVar] = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Mean_GradPsiVar[iVar][iDim] = 0.5*(PsiVar_Grad_i[iVar][iDim] + PsiVar_Grad_j[iVar][iDim]); - Proj_Mean_GradPsiVar_Edge[iVar] += Mean_GradPsiVar[iVar][iDim]*Edge_Vector[iDim]; - } - for (iDim = 0; iDim < nDim; iDim++) - Mean_GradPsiVar[iVar][iDim] -= (Proj_Mean_GradPsiVar_Edge[iVar] - - (Psi_j[iVar]-Psi_i[iVar]))*Edge_Vector[iDim]/dist_ij_2; - } - - /*--- Average of the derivatives of the adjoint variables ---*/ - - for (iDim = 0; iDim < nDim; iDim++) { - Mean_GradPsiE[iDim] = Mean_GradPsiVar[nVar-1][iDim]; - for (jDim = 0; jDim < nDim; jDim++) - Mean_GradPhi[iDim][jDim] = Mean_GradPsiVar[iDim+1][jDim]; - } - - dPhiE_dn = 0; - for (iDim = 0; iDim < nDim; iDim++) - dPhiE_dn += Mean_GradPsiE[iDim]*Normal[iDim]; - - /*--- Compute the viscous residual and jacobian ---*/ - - GetAdjViscousFlux_Jac(Pressure_i, Pressure_j, Density_i, Density_j, - ViscDens_i, ViscDens_j, Velocity_i, Velocity_j, sq_vel_i, sq_vel_j, - XiDens_i, XiDens_j, Mean_GradPhi, Mean_GradPsiE, - dPhiE_dn, Normal, Edge_Vector, dist_ij_2, val_residual_i, val_residual_j, - val_Jacobian_ii, val_Jacobian_ij, val_Jacobian_ji, val_Jacobian_jj, - implicit); - -} - -CSourceViscous_AdjFlow::CSourceViscous_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - unsigned short iDim; - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - Velocity = new su2double [nVar]; - GradDensity = new su2double [nDim]; - GradInvDensity = new su2double [nDim]; - dPoDensity2 = new su2double [nDim]; - alpha = new su2double [nDim]; - beta = new su2double [nDim]; - Sigma_5_vec = new su2double [nDim]; - - GradVel_o_Rho = new su2double* [nDim]; - sigma = new su2double* [nDim]; - Sigma_phi = new su2double* [nDim]; - Sigma_5_Tensor = new su2double* [nDim]; - Sigma = new su2double* [nDim]; - - for (iDim = 0; iDim < nDim; iDim++) { - GradVel_o_Rho[iDim] = new su2double [nDim]; - sigma[iDim] = new su2double [nDim]; - Sigma_phi[iDim] = new su2double [nDim]; - Sigma_5_Tensor[iDim] = new su2double [nDim]; - Sigma[iDim] = new su2double [nDim]; - } - -} - -CSourceViscous_AdjFlow::~CSourceViscous_AdjFlow(void) { - unsigned short iDim; - - for (iDim = 0; iDim < nDim; iDim++) { - delete [] GradVel_o_Rho[iDim]; - delete [] sigma[iDim]; - delete [] Sigma_phi[iDim]; - delete [] Sigma_5_Tensor[iDim]; - delete [] Sigma[iDim]; - } - - delete [] GradVel_o_Rho; - delete [] sigma; - delete [] Sigma_phi; - delete [] Sigma_5_Tensor; - delete [] Sigma; - - delete [] Velocity; - delete [] GradDensity; - delete [] GradInvDensity; - delete [] dPoDensity2; - delete [] alpha; - delete [] beta; - delete [] Sigma_5_vec; - -} - -void CSourceViscous_AdjFlow::ComputeResidual (su2double *val_residual, CConfig *config) { - - unsigned short iDim, jDim; - -// su2double Temperature = V_i[0]; - su2double Pressure = V_i[nDim+1]; - su2double Density = V_i[nDim+2]; -// su2double Enthalpy = V_i[nDim+3]; - su2double Laminar_Viscosity = V_i[nDim+5]; - su2double Eddy_Viscosity = V_i[nDim+6]; - -// su2double Energy = Enthalpy - Pressure/Density; - su2double invDensity = 1.0/Density; - su2double invDensitysq = invDensity*invDensity; - su2double invDensitycube = invDensitysq*invDensity; - su2double Prandtl_Lam = config->GetPrandtl_Lam(); - su2double Prandtl_Turb = config->GetPrandtl_Turb(); - su2double mu_tot_1 = Laminar_Viscosity + Eddy_Viscosity; - su2double mu_tot_2 = Laminar_Viscosity/Prandtl_Lam + Eddy_Viscosity/Prandtl_Turb; -// su2double Gas_Constant = config->GetGas_ConstantND(); - - /*--- Required gradients of the flow variables, point j ---*/ - - for (iDim = 0; iDim < nDim; iDim++) { - - /*--- Gradient density ---*/ - - GradDensity[iDim] = PrimVar_Grad_i[nDim+2][iDim]; - - /*--- Gradient (1/rho) ---*/ - - GradInvDensity[iDim] = -GradDensity[iDim]*invDensitysq; - - /*--- Computation of the derivatives of P/(Density^2) ---*/ - - dPoDensity2[iDim] = (PrimVar_Grad_i[nVar-1][iDim]*Density - 2.0*GradDensity[iDim]*Pressure)*invDensitycube; - - /*--- Abbreviations: alpha, beta, sigma_5_vec ---*/ - - alpha[iDim] = Gamma*mu_tot_2*GradInvDensity[iDim]; - beta[iDim] = Gamma*mu_tot_2*dPoDensity2[iDim]/Gamma_Minus_One; - Sigma_5_vec[iDim] = Gamma*mu_tot_2*PsiVar_Grad_i[nVar-1][iDim]; - - } - - /*--- Definition of tensors and derivatives of velocity over density ---*/ - - su2double div_vel = 0.0, div_phi = 0.0, vel_gradpsi5 = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - div_vel += PrimVar_Grad_i[iDim+1][iDim]; - div_phi += PsiVar_Grad_i[iDim+1][iDim]; - vel_gradpsi5 += V_i[iDim+1]*PsiVar_Grad_i[nVar-1][iDim]; - for (jDim = 0; jDim < nDim; jDim++) { - sigma[iDim][jDim] = mu_tot_1*(PrimVar_Grad_i[iDim+1][jDim]+PrimVar_Grad_i[jDim+1][iDim]); - Sigma_phi[iDim][jDim] = mu_tot_1*(PsiVar_Grad_i[iDim+1][jDim]+PsiVar_Grad_i[jDim+1][iDim]); - Sigma_5_Tensor[iDim][jDim] = mu_tot_1*(V_i[jDim+1]*PsiVar_Grad_i[nVar-1][iDim]+V_i[iDim+1]*PsiVar_Grad_i[nVar-1][jDim]); - GradVel_o_Rho[iDim][jDim] = (PrimVar_Grad_i[iDim+1][jDim]*Density - V_i[iDim+1]*GradDensity[jDim])*invDensitysq; - } - } - - for (iDim = 0; iDim < nDim; iDim++) { - sigma[iDim][iDim] -= TWO3*mu_tot_1*div_vel; - Sigma_phi[iDim][iDim] -= TWO3*mu_tot_1*div_phi; - Sigma_5_Tensor[iDim][iDim] -= TWO3*mu_tot_1*vel_gradpsi5; - } - - for (iDim = 0; iDim < nDim; iDim++) { - for (jDim = 0; jDim < nDim; jDim++) { - Sigma[iDim][jDim] = Sigma_phi[iDim][jDim] + Sigma_5_Tensor[iDim][jDim]; - } - } - - /*--- Vector-Tensors products ---*/ - - su2double gradT_gradpsi5 = 0.0, sigma_gradpsi = 0.0, vel_sigma_gradpsi5 = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - gradT_gradpsi5 += PrimVar_Grad_i[0][iDim]*PsiVar_Grad_i[nVar-1][iDim]; - for (jDim = 0; jDim < nDim; jDim++) { - sigma_gradpsi += sigma[iDim][jDim]*PsiVar_Grad_i[jDim+1][iDim]; - vel_sigma_gradpsi5 += V_i[iDim+1]*sigma[iDim][jDim]*PsiVar_Grad_i[nVar-1][jDim]; - } - } - - /*--- Residuals ---*/ - - su2double alpha_gradpsi5 = 0.0, beta_gradpsi5 = 0.0, Sigma_gradvel_o_rho = 0.0, Sigma5_vel_gradvel = 0.0, sq_vel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - alpha_gradpsi5 += alpha[iDim]*PsiVar_Grad_i[nVar-1][iDim]; - beta_gradpsi5 += beta[iDim]*PsiVar_Grad_i[nVar-1][iDim]; - for (jDim = 0; jDim < nDim; jDim++) { - Sigma_gradvel_o_rho += Sigma[iDim][jDim]*GradVel_o_Rho[iDim][jDim]; - Sigma5_vel_gradvel += Sigma_5_vec[iDim]*(V_i[jDim+1]*PrimVar_Grad_i[jDim+1][iDim]); - } - sq_vel += V_i[iDim+1]*V_i[iDim+1]; - } - - val_residual[0] = (-vel_sigma_gradpsi5*invDensity + 0.5*sq_vel*alpha_gradpsi5 - - beta_gradpsi5) * Volume; - for (iDim = 0; iDim < nDim; iDim++) { - val_residual[iDim+1] = 0.0; - for (jDim = 0; jDim < nDim; jDim++) { - val_residual[iDim+1] += (sigma[iDim][jDim]*PsiVar_Grad_i[nVar-1][jDim]*invDensity - V_i[iDim+1]*alpha[jDim]*PsiVar_Grad_i[nVar-1][jDim]) * Volume; - } - } - val_residual[nVar-1] = alpha_gradpsi5 * Volume; - -// val_residual[0] += (Sigma5_vel_gradvel*invDensity - Sigma_gradvel_o_rho) * Volume; -// for (iDim = 0; iDim < nDim; iDim++) { -// for (jDim = 0; jDim < nDim; jDim++) { -// val_residual[iDim+1] += (Sigma[iDim][jDim]*GradInvDensity[jDim] - -// Sigma_5_vec[jDim]*PrimVar_Grad_i[iDim+1][jDim]*invDensity) * Volume; -// } -// } - - /*--- Laminar viscosity sensitivity for NS ---*/ - - if (config->GetKind_Solver() != ADJ_RANS) { - -// su2double Temperature_Ref = config->GetTemperature_Ref(); -// su2double Temperature_Dim = Temperature*Temperature_Ref; -// -// su2double S = 0.0; -// if (config->GetSystemMeasurements() == SI) { S = 110.4; } -// if (config->GetSystemMeasurements() == US) { S = 198.72; } -// su2double dVisc_T = ((Laminar_Viscosity)/(2.0*Temperature_Dim*(Temperature_Dim + S)))*(Temperature_Dim + 3.0*S)*Temperature_Ref; -// -// su2double Cp = (Gamma/Gamma_Minus_One)*Gas_Constant; -// su2double kappa_psi = (sigma_gradpsi + vel_sigma_gradpsi5)/mu_tot_1; -// su2double theta = (kappa_psi + Cp/Prandtl_Lam*gradT_gradpsi5)*dVisc_T*Gamma_Minus_One/(Gas_Constant*Density); -// -// val_residual[0] += (theta*(sq_vel-Energy))*Volume; -// for (iDim = 0; iDim < nDim; iDim++) -// val_residual[iDim+1] -= theta*V_i[iDim+1]*Volume; -// val_residual[nVar-1] += theta*Volume; - - } - -// /*--- Coupling terms coming from the continuous adjoint turbulent equations ---*/ -// -// if ((config->GetKind_Solver() == ADJ_RANS) && (!config->GetFrozen_Visc_Cont())) { -// -// /*--- Closure constants ---*/ -// -// su2double cv1_3 = 7.1*7.1*7.1; -// su2double k2 = 0.41*0.41; -// su2double cb1 = 0.1355; -// su2double cw2 = 0.3; -// su2double cw3_6 = pow(2.0,6.0); -// su2double sigma = 2./3.; -// su2double cb2 = 0.622; -// su2double cw1 = cb1/k2+(1+cb2)/sigma; -// -// su2double nu, Ji, Ji_2, Ji_3, fv1; -// nu = Laminar_Viscosity/Density; -// Ji = TurbVar_i[0]/nu; -// Ji_2 = Ji*Ji; -// Ji_3 = Ji_2*Ji; -// fv1 = Ji_3/(Ji_3+cv1_3); -// -// /*--- Contributions due to variation of viscosities ---*/ -// -// su2double Temperature_Ref = config->GetTemperature_Ref(); -// su2double Temperature_Dim = Temperature*Temperature_Ref; -// -// su2double S = 0.0; -// if (config->GetSystemMeasurements() == SI) { S = 110.4; } -// if (config->GetSystemMeasurements() == US) { S = 198.72; } -// su2double dVisc_T = ((Laminar_Viscosity)/(2.0*Temperature_Dim*(Temperature_Dim + S)))*(Temperature_Dim + 3.0*S)*Temperature_Ref; -// -// su2double Cp = (Gamma/Gamma_Minus_One)*Gas_Constant; -// su2double kappa_psi = (sigma_gradpsi + vel_sigma_gradpsi5)/mu_tot_1 + Cp/Prandtl_Turb*gradT_gradpsi5; -// su2double cv1_const = 3.0*cv1_3/(Ji_3+cv1_3); -// su2double theta = (kappa_psi*(1.0-Eddy_Viscosity/Laminar_Viscosity*cv1_const) - -// Cp/Prandtl_Turb*gradT_gradpsi5*(1.0-Prandtl_Turb/Prandtl_Lam))*dVisc_T*Gamma_Minus_One/(Gas_Constant*Density); -// su2double xi = kappa_psi*(1.0+cv1_const)*Eddy_Viscosity/Density; -// -// val_residual[0] += (theta*(sq_vel-Energy) + xi)*Volume; -// for (iDim = 0; iDim < nDim; iDim++) -// val_residual[iDim+1] -= theta*V_i[iDim+1]*Volume; -// val_residual[nVar-1] += theta*Volume; -// -// /*--- Coupling residuals ---*/ -// -// if (dist_i > 0.0) { -// su2double fv2, Omega, Shat, dist_0_2, one_o_oneplusJifv1; -// su2double r, g, g_6, glim, fw; -// su2double dfw_g, dg_r, dr_nuhat, dr_Shat; -// su2double dShat_fv2, dfv2_fv1, dfv1_Ji, dJi_nu, dJi_nuhat, dfv2_Ji; -// -// /*--- Vorticity ---*/ -// Omega = (PrimVar_Grad_i[1][1]-PrimVar_Grad_i[2][0])*(PrimVar_Grad_i[1][1]-PrimVar_Grad_i[2][0]); -// if (nDim == 3) Omega += (PrimVar_Grad_i[1][2]-PrimVar_Grad_i[3][0])*(PrimVar_Grad_i[1][2]-PrimVar_Grad_i[3][0]) + -// (PrimVar_Grad_i[2][2]-PrimVar_Grad_i[3][1])*(PrimVar_Grad_i[2][2]-PrimVar_Grad_i[3][1]); -// Omega = sqrt(Omega); -// -// dist_0_2 = dist_i*dist_i; -// one_o_oneplusJifv1 = 1.0/(1.0+Ji*fv1); -// fv2 = 1.0 - Ji*one_o_oneplusJifv1; -// Shat = max(Omega + TurbVar_i[0]*fv2/(k2*dist_0_2), TURB_EPS); -// -// r = min(TurbVar_i[0]/(Shat*k2*dist_0_2), 10.); -// g = r + cw2*(pow(r,6.)-r); -// g_6 = pow(g,6.); -// glim = pow((1+cw3_6)/(g_6+cw3_6),1./6.); -// fw = g*glim; -// -// dfw_g = glim*cw3_6/(g_6+cw3_6); -// dg_r = 1.0 + cw2*(6.0*pow(r,5.0)-1.0); -// dr_nuhat = 1.0/(Shat*k2*dist_0_2); -// dr_Shat = -dr_nuhat*TurbVar_i[0]/Shat; -// -// dShat_fv2 = TurbVar_i[0]/(k2*dist_0_2); -// dfv2_fv1 = Ji_2*one_o_oneplusJifv1*one_o_oneplusJifv1; -// dfv1_Ji = 3.0*cv1_3*Ji_2/((Ji_3+cv1_3)*(Ji_3+cv1_3)); -// dJi_nuhat = 1.0/nu; -// dJi_nu = -Ji/nu; -// dfv2_Ji = -one_o_oneplusJifv1*one_o_oneplusJifv1; -// -// /*--- Terms 1 & 2: -Fcv\B7nabla(TurbPsi_i) - Fs\B7TurbPsi_i ---*/ -// -// su2double gradTurbVar_gradTurbPsi = 0, vel_gradTurbPsi = 0; -// for (iDim = 0; iDim < nDim; iDim++) { -// gradTurbVar_gradTurbPsi += TurbVar_Grad_i[0][iDim]*TurbPsi_Grad_i[0][iDim]; -// vel_gradTurbPsi += V_i[iDim+1]*TurbPsi_Grad_i[0][iDim]; -// } -// -// su2double alpha_coeff = Gamma_Minus_One/(Gas_Constant*Density)*dVisc_T; -// su2double beta_coeff = alpha_coeff*(sq_vel-Energy)-Laminar_Viscosity_i/Density; -// su2double Fs_coeff = TurbPsi_i[0]*(cb1*TurbVar_i[0]-cw1*TurbVar_i[0]*TurbVar_i[0]/dist_0_2*dfw_g*dg_r*dr_Shat)* -// dShat_fv2*(dfv2_Ji+dfv2_fv1*dfv1_Ji)*dJi_nu; -// su2double Gamma = Fs_coeff - gradTurbVar_gradTurbPsi/sigma; -// -// val_residual[0] -= (Gamma*beta_coeff - TurbVar_i[0]*vel_gradTurbPsi)/Density*Volume; -// for (iDim = 0; iDim < nDim; iDim++) -// val_residual[iDim+1] += (Gamma*alpha_coeff*V_i[iDim+1] - TurbVar_i[0]*TurbPsi_Grad_i[0][iDim])/Density*Volume; -// val_residual[nVar-1] -= (Gamma*alpha_coeff)/Density*Volume; -// -// // this should improve stability (when commented): -// /*--- Terms 3: -partial{T^s}_GradVel x GradN ---*/ -// // su2double Ms_coeff = (cb1*TurbVar_i[0]-cw1*TurbVar_i[0]*TurbVar_i[0]/dist_0_2*dfw_g*dg_r*dr_Shat); -// // Ms_coeff *= TurbPsi_i[0]/(Omega + TURB_EPS); -// // -// // for (iDim = 0; iDim < nDim; iDim++) { -// // for (jDim = 0; jDim < nDim; jDim++) { -// // val_residual[0] += Ms_coeff*(PrimVar_Grad_i[iDim+1][jDim]-PrimVar_Grad_i[jDim+1][iDim])* -// // GradVel_o_Rho[iDim][jDim]*dV; -// // val_residual[iDim+1] -= Ms_coeff*(PrimVar_Grad_i[iDim+1][jDim]-PrimVar_Grad_i[jDim+1][iDim])* -// // GradInvDensity[jDim]*dV; -// // } -// // } -// -// } -// } - -} - -CSourceConservative_AdjFlow::CSourceConservative_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - Velocity = new su2double [nDim]; - Residual_i = new su2double [nVar]; - Residual_j = new su2double [nVar]; - Mean_Residual = new su2double [nVar]; - - Mean_PrimVar_Grad = new su2double* [nVar]; - for (unsigned short iVar = 0; iVar < nVar; iVar++) - Mean_PrimVar_Grad[iVar] = new su2double [nDim]; -} - -CSourceConservative_AdjFlow::~CSourceConservative_AdjFlow(void) { - delete [] Mean_Residual; - delete [] Residual_j; - delete [] Residual_i; - delete [] Velocity; - - for (unsigned short iVar = 0; iVar < nVar; iVar++) - delete [] Mean_PrimVar_Grad[iVar]; - delete [] Mean_PrimVar_Grad; -} - -void CSourceConservative_AdjFlow::ComputeResidual (su2double *val_residual, CConfig *config) { - unsigned short iDim, jDim, iVar; - su2double rho, nu, Ji, fv1, fv2, Omega, Shat, dist_sq, Ji_2, Ji_3, one_o_oneplusJifv1; - su2double r, g, g_6, glim, dfw_g, dg_r, dr_nuhat, dr_Shat, Ms_coeff, invOmega; - - su2double cv1_3 = 7.1*7.1*7.1; - su2double k2 = 0.41*0.41; - su2double cb1 = 0.1355; - su2double cw2 = 0.3; - su2double cw3_6 = pow(2.0,6.0); - su2double sigma = 2./3.; - su2double cb2 = 0.622; - su2double cw1 = cb1/k2+(1+cb2)/sigma; - - for (iVar = 0; iVar < nVar; iVar++) { - Residual_i[iVar] = 0.0; - Residual_j[iVar] = 0.0; - } - - /*--- iPoint ---*/ - - /*--- Density and velocities ---*/ - - rho = U_i[0]; - for (iDim = 0; iDim < nDim; iDim++) - Velocity[iDim] = U_i[iDim+1]/rho; - - /*--- Vorticity ---*/ - - Omega = (PrimVar_Grad_i[1][1]-PrimVar_Grad_i[2][0])*(PrimVar_Grad_i[1][1]-PrimVar_Grad_i[2][0]); - if (nDim == 3) Omega += (PrimVar_Grad_i[1][2]-PrimVar_Grad_i[3][0])*(PrimVar_Grad_i[1][2]-PrimVar_Grad_i[3][0]) + - (PrimVar_Grad_i[2][2]-PrimVar_Grad_i[3][1])*(PrimVar_Grad_i[2][2]-PrimVar_Grad_i[3][1]); - Omega = sqrt(Omega); - invOmega = 1.0/(Omega + TURB_EPS); - - /*--- Compute Ms_coeff -> coming from partial derivatives ---*/ - - Ms_coeff = 0.0; - if (dist_i > 0) { - dist_sq = dist_i*dist_i; - nu = Laminar_Viscosity_i/rho; - Ji = TurbVar_i[0]/nu; - Ji_2 = Ji*Ji; - Ji_3 = Ji_2*Ji; - fv1 = Ji_3/(Ji_3+cv1_3); - one_o_oneplusJifv1 = 1.0/(1.0+Ji*fv1); - fv2 = 1.0 - Ji*one_o_oneplusJifv1; - Shat = max(Omega + TurbVar_i[0]*fv2/(k2*dist_sq), TURB_EPS); - - r = min(TurbVar_i[0]/(Shat*k2*dist_sq),10.); - g = r + cw2*(pow(r,6.)-r); - g_6 = pow(g,6.); - glim = pow((1+cw3_6)/(g_6+cw3_6),1./6.); - - dfw_g = glim*cw3_6/(g_6+cw3_6); - dg_r = 1.0 + cw2*(6.0*pow(r,5.0)-1.0); - dr_nuhat = 1.0/(Shat*k2*dist_sq); - dr_Shat = -dr_nuhat*TurbVar_i[0]/Shat; - - Ms_coeff = (cb1*TurbVar_i[0]-cw1*TurbVar_i[0]*TurbVar_i[0]/dist_sq*dfw_g*dg_r*dr_Shat); - } - Ms_coeff *= TurbPsi_i[0]*invOmega/rho; - - /*--- Compute residual of iPoint ---*/ - - for (iDim = 0; iDim < nDim; iDim++) { - for (jDim = 0; jDim < nDim; jDim++) { - Residual_i[0] -= Ms_coeff*(Velocity[jDim]*PrimVar_Grad_i[jDim+1][iDim]*Normal[iDim] - - Velocity[jDim]*PrimVar_Grad_i[iDim+1][jDim]*Normal[iDim]); - Residual_i[iDim+1] += Ms_coeff*(PrimVar_Grad_i[iDim+1][jDim]*Normal[jDim] - - PrimVar_Grad_i[jDim+1][iDim]*Normal[jDim]); - } - } - - /*--- jPoint ---*/ - - /*--- Density and velocities ---*/ - - rho = U_j[0]; - for (iDim = 0; iDim < nDim; iDim++) - Velocity[iDim] = U_j[iDim+1]/rho; - - /*--- Vorticity ---*/ - - Omega = (PrimVar_Grad_j[1][1]-PrimVar_Grad_j[2][0])*(PrimVar_Grad_j[1][1]-PrimVar_Grad_j[2][0]); - if (nDim == 3) Omega += (PrimVar_Grad_j[1][2]-PrimVar_Grad_j[3][0])*(PrimVar_Grad_j[1][2]-PrimVar_Grad_j[3][0]) + - (PrimVar_Grad_j[2][2]-PrimVar_Grad_j[3][1])*(PrimVar_Grad_j[2][2]-PrimVar_Grad_j[3][1]); - Omega = sqrt(Omega); - invOmega = 1.0/(Omega + TURB_EPS); - - /*--- Compute Ms_coeff -> coming from partial derivatives ---*/ - - Ms_coeff = 0.0; - if (dist_j > 0) { - dist_sq = dist_j*dist_j; - nu = Laminar_Viscosity_j/rho; - Ji = TurbVar_j[0]/nu; - Ji_2 = Ji*Ji; - Ji_3 = Ji_2*Ji; - fv1 = Ji_3/(Ji_3+cv1_3); - one_o_oneplusJifv1 = 1.0/(1.0+Ji*fv1); - fv2 = 1.0 - Ji*one_o_oneplusJifv1; - Shat = max(Omega + TurbVar_j[0]*fv2/(k2*dist_sq), TURB_EPS); - - r = min(TurbVar_j[0]/(Shat*k2*dist_sq),10.); - g = r + cw2*(pow(r,6.)-r); - g_6 = pow(g,6.); - glim = pow((1+cw3_6)/(g_6+cw3_6),1./6.); - - dfw_g = glim*cw3_6/(g_6+cw3_6); - dg_r = 1.0 + cw2*(6.0*pow(r,5.0)-1.0); - dr_nuhat = 1.0/(Shat*k2*dist_sq); - dr_Shat = -dr_nuhat*TurbVar_j[0]/Shat; - - Ms_coeff = (cb1*TurbVar_j[0]-cw1*TurbVar_j[0]*TurbVar_j[0]/dist_sq*dfw_g*dg_r*dr_Shat); - } - Ms_coeff *= TurbPsi_j[0]*invOmega/rho; - - /*--- Compute residual of jPoint ---*/ - - for (iDim = 0; iDim < nDim; iDim++) { - for (jDim = 0; jDim < nDim; jDim++) { - Residual_j[0] -= Ms_coeff*(Velocity[jDim]*PrimVar_Grad_j[jDim+1][iDim]*Normal[iDim] - - Velocity[jDim]*PrimVar_Grad_j[iDim+1][jDim]*Normal[iDim]); - Residual_j[iDim+1] += Ms_coeff*(PrimVar_Grad_j[iDim+1][jDim]*Normal[jDim] - - PrimVar_Grad_j[jDim+1][iDim]*Normal[jDim]); - } - } - - /*--- Compute the mean residual ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_residual[iVar] = 0.5*(Residual_i[iVar] + Residual_j[iVar]); - -} - -CSourceRotatingFrame_AdjFlow::CSourceRotatingFrame_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { } - -CSourceRotatingFrame_AdjFlow::~CSourceRotatingFrame_AdjFlow(void) { } - -void CSourceRotatingFrame_AdjFlow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config) { - - unsigned short iDim, iVar, jVar; - su2double Omega[3] = {0,0,0}, Phi[3] = {0,0,0}; - bool implicit = (config->GetKind_TimeIntScheme_AdjFlow() == EULER_IMPLICIT); - - /*--- Retrieve the angular velocity vector from config. ---*/ - - for (iDim = 0; iDim < 3; iDim++){ - Omega[iDim] = config->GetRotation_Rate(iDim)/config->GetOmega_Ref(); - } - - /*--- Get the adjoint velocity vector at the current node. ---*/ - - for (iDim = 0; iDim < nDim; iDim++) - Phi[iDim] = Psi_i[iDim+1]; - - /*--- Compute the source term as the Jacobian of the rotating frame - source term multiplied by the adjoint state and the dual cell volume. ---*/ - - if (nDim == 2) { - val_residual[0] = 0.0; - val_residual[1] = Omega[2]*Phi[1]*Volume; - val_residual[2] = -Omega[2]*Phi[0]*Volume; - val_residual[3] = 0.0; - } else { - val_residual[0] = 0.0; - val_residual[1] = (Omega[2]*Phi[1] - Omega[1]*Phi[2])*Volume; - val_residual[2] = (Omega[0]*Phi[2] - Omega[2]*Phi[0])*Volume; - val_residual[3] = (Omega[1]*Phi[0] - Omega[0]*Phi[1])*Volume; - val_residual[4] = 0.0; - } - - /*--- Calculate the source term Jacobian ---*/ - - if (implicit) { - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_i[iVar][jVar] = 0.0; - if (nDim == 2) { - val_Jacobian_i[1][2] = Omega[2]*Volume; - val_Jacobian_i[2][1] = -Omega[2]*Volume; - } else { - val_Jacobian_i[1][2] = Omega[2]*Volume; - val_Jacobian_i[1][3] = -Omega[1]*Volume; - val_Jacobian_i[2][1] = -Omega[2]*Volume; - val_Jacobian_i[2][3] = Omega[0]*Volume; - val_Jacobian_i[3][1] = Omega[1]*Volume; - val_Jacobian_i[3][2] = -Omega[0]*Volume; - } - } - -} - -CSourceAxisymmetric_AdjFlow::CSourceAxisymmetric_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { } - -CSourceAxisymmetric_AdjFlow::~CSourceAxisymmetric_AdjFlow(void) { } - -void CSourceAxisymmetric_AdjFlow::ComputeResidual(su2double *val_residual, su2double **Jacobian_ii, CConfig *config) { - - su2double yinv; - su2double Jacobian_Axisymmetric[4][4]; - - if (Coord_i[1] > 0.0) yinv = 1.0/Coord_i[1]; - else yinv = 0.0; - - Jacobian_Axisymmetric[0][0] = 0; - Jacobian_Axisymmetric[0][1] = 0; - Jacobian_Axisymmetric[0][2] = 1.; - Jacobian_Axisymmetric[0][3] = 0; - - Jacobian_Axisymmetric[1][0] = -U_i[1]*U_i[2]/(U_i[0]*U_i[0]); - Jacobian_Axisymmetric[1][1] = U_i[2]/U_i[0]; - Jacobian_Axisymmetric[1][2] = U_i[1]/U_i[0]; - Jacobian_Axisymmetric[1][3] = 0; - - Jacobian_Axisymmetric[2][0] = -U_i[2]*U_i[2]/(U_i[0]*U_i[0]); - Jacobian_Axisymmetric[2][1] = 0; - Jacobian_Axisymmetric[2][2] = 2*U_i[2]/U_i[0]; - Jacobian_Axisymmetric[2][3] = 0; - - Jacobian_Axisymmetric[3][0] = -Gamma*U_i[2]*U_i[3]/(U_i[0]*U_i[0]) + (Gamma-1)*U_i[2]*(U_i[1]*U_i[1]+U_i[2]*U_i[2])/(U_i[0]*U_i[0]*U_i[0]); - Jacobian_Axisymmetric[3][1] = -(Gamma-1)*U_i[2]*U_i[1]/(U_i[0]*U_i[0]); - Jacobian_Axisymmetric[3][2] = Gamma*U_i[3]/U_i[0] - 1/2*(Gamma-1)*( (U_i[1]*U_i[1]+U_i[2]*U_i[2])/(U_i[0]*U_i[0]) + 2*U_i[2]*U_i[2]/(U_i[0]*U_i[0]) ); - Jacobian_Axisymmetric[3][3] = Gamma*U_i[2]/U_i[0]; - - for (int iVar=0; iVar<4; iVar++) - for (int jVar=0; jVar<4; jVar++) - Jacobian_Axisymmetric[iVar][jVar] *= yinv*Volume; - - /* -- Residual = transpose(Jacobian) * psi --*/ - for (int iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] = 0.0; - for (int jVar = 0; jVar < nVar; jVar++) { - val_residual[iVar] += Jacobian_Axisymmetric[jVar][iVar]*Psi_i[jVar]; - Jacobian_ii[iVar][jVar] = Jacobian_Axisymmetric[jVar][iVar]; - } - } -} diff --git a/SU2_CFD/src/numerics_adjoint_turbulent.cpp b/SU2_CFD/src/numerics_adjoint_turbulent.cpp deleted file mode 100644 index 4fa3e4128a1a..000000000000 --- a/SU2_CFD/src/numerics_adjoint_turbulent.cpp +++ /dev/null @@ -1,538 +0,0 @@ -/*! - * \file numerics_adjoint_turbulent.cpp - * \brief This file contains all the convective term discretization. - * \author F. Palacios, A. Bueno - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - - -#include "../include/numerics_structure.hpp" -#include - -CUpwLin_AdjTurb::CUpwLin_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - Velocity_i = new su2double [nDim]; -} - -CUpwLin_AdjTurb::~CUpwLin_AdjTurb(void) { - delete [] Velocity_i; -} - -void CUpwLin_AdjTurb::ComputeResidual (su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - bool implicit = (config->GetKind_TimeIntScheme_AdjTurb() == EULER_IMPLICIT); - - /*--- Non-conservative term --> -\nabla \psi_\mu B^{cv} - B^{cv} = -v ---*/ - - unsigned short iDim; - su2double proj_conv_flux = 0; - - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = U_i[iDim+1]/U_i[0]; - proj_conv_flux += Velocity_i[iDim]*Normal[iDim]; // projection of convective flux at iPoint - } - su2double psinu0 = TurbPsi_i[0]; - su2double psinu1; - if (proj_conv_flux > 0) - psinu1 = psinu0 + proj_conv_flux; - else - psinu1 = psinu0; - - val_residual[0] = 0.5*( proj_conv_flux*(psinu0+psinu1)-fabs(proj_conv_flux)*(psinu1-psinu0)); - if (implicit) { - val_Jacobian_i[0][0] = 0.5*( proj_conv_flux + fabs(proj_conv_flux)); - } -} - -CUpwSca_AdjTurb::CUpwSca_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; -} - -CUpwSca_AdjTurb::~CUpwSca_AdjTurb(void) { - delete [] Velocity_i; - delete [] Velocity_j; -} - -void CUpwSca_AdjTurb::ComputeResidual (su2double *val_residual_i, su2double *val_residual_j, - su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, - su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config) { - - bool implicit = (config->GetKind_TimeIntScheme_AdjTurb() == EULER_IMPLICIT); - - /*--- Non-conservative term --> -\nabla \psi_\mu B^{cv} - B^{cv} = -\nabla \hat{nu}/\sigma + v ---*/ - - unsigned short iDim; - su2double proj_conv_flux_i = 0, proj_conv_flux_j = 0, proj_conv_flux_ij = 0; - su2double sigma = 2./3.; - - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = U_i[iDim+1]/U_i[0]; - Velocity_j[iDim] = U_j[iDim+1]/U_j[0]; - proj_conv_flux_i += (TurbVar_Grad_i[0][iDim]/sigma - Velocity_i[iDim])*Normal[iDim]; // projection of convective flux at iPoint - proj_conv_flux_j += (TurbVar_Grad_j[0][iDim]/sigma - Velocity_j[iDim])*Normal[iDim]; // projection of convective flux at jPoint - } - proj_conv_flux_ij = 0.5*fabs(proj_conv_flux_i+proj_conv_flux_j); // projection of average convective flux - - val_residual_i[0] = 0.5*( proj_conv_flux_i*(TurbPsi_i[0]+TurbPsi_j[0])-proj_conv_flux_ij*(TurbPsi_j[0]-TurbPsi_i[0])); - val_residual_j[0] = 0.5*(-proj_conv_flux_j*(TurbPsi_j[0]+TurbPsi_i[0])-proj_conv_flux_ij*(TurbPsi_i[0]-TurbPsi_j[0])); - if (implicit) { - val_Jacobian_ii[0][0] = 0.5*( proj_conv_flux_i+proj_conv_flux_ij); - val_Jacobian_ij[0][0] = 0.5*( proj_conv_flux_i-proj_conv_flux_ij); - val_Jacobian_ji[0][0] = 0.5*(-proj_conv_flux_j-proj_conv_flux_ij); - val_Jacobian_jj[0][0] = 0.5*(-proj_conv_flux_j+proj_conv_flux_ij); - } - -} - -CAvgGradCorrected_AdjTurb::CAvgGradCorrected_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - Edge_Vector = new su2double [nDim]; - Mean_GradTurbPsi = new su2double* [nVar]; - Proj_Mean_GradTurbPsi_Kappa = new su2double [nVar]; - Proj_Mean_GradTurbPsi_Edge = new su2double [nVar]; - Proj_Mean_GradTurbPsi_Corrected = new su2double [nVar]; - for (unsigned short iVar = 0; iVar < nVar; iVar++) - Mean_GradTurbPsi[iVar] = new su2double [nDim]; -} - -CAvgGradCorrected_AdjTurb::~CAvgGradCorrected_AdjTurb(void) { - delete [] Edge_Vector; - delete [] Proj_Mean_GradTurbPsi_Kappa; - delete [] Proj_Mean_GradTurbPsi_Edge; - delete [] Proj_Mean_GradTurbPsi_Corrected; - for (unsigned short iVar = 0; iVar < nVar; iVar++) { - delete [] Mean_GradTurbPsi[iVar]; - } - delete [] Mean_GradTurbPsi; -} - -void CAvgGradCorrected_AdjTurb::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, - su2double **val_Jacobian_j, CConfig *config) { - - bool implicit = (config->GetKind_TimeIntScheme_AdjTurb() == EULER_IMPLICIT); - - su2double sigma = 2./3.; - su2double nu_i, nu_j, nu_e; - su2double dist_ij_2 = 0; - su2double proj_vector_ij = 0; - unsigned short iVar, iDim; - - /*--- Compute mean effective viscosity ---*/ - nu_i = Laminar_Viscosity_i/U_i[0]; - nu_j = Laminar_Viscosity_j/U_j[0]; - nu_e = 0.5*(nu_i+nu_j+TurbVar_i[0]+TurbVar_j[0])/sigma; - - /*--- Compute vector going from iPoint to jPoint ---*/ - 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]; - } - proj_vector_ij = proj_vector_ij/dist_ij_2; - - /*--- Mean gradient approximation ---*/ - for (iVar = 0; iVar < nVar; iVar++) { - Proj_Mean_GradTurbPsi_Edge[iVar] = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Mean_GradTurbPsi[iVar][iDim] = 0.5*(TurbPsi_Grad_i[iVar][iDim] + TurbPsi_Grad_j[iVar][iDim]); - Proj_Mean_GradTurbPsi_Edge[iVar] += Mean_GradTurbPsi[iVar][iDim]*Edge_Vector[iDim]; - } - - for (iDim = 0; iDim < nDim; iDim++) - Mean_GradTurbPsi[iVar][iDim] -= (Proj_Mean_GradTurbPsi_Edge[iVar] - (TurbPsi_j[iVar]-TurbPsi_i[iVar]))*Edge_Vector[iDim]/dist_ij_2; - - /*--- Projection of the corrected gradient ---*/ - Proj_Mean_GradTurbPsi_Corrected[iVar] = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - Proj_Mean_GradTurbPsi_Corrected[iVar] += Mean_GradTurbPsi[iVar][iDim]*Normal[iDim]; - } - - val_residual[0] = -nu_e*Proj_Mean_GradTurbPsi_Corrected[0]; - - if (implicit) { - val_Jacobian_i[0][0] = nu_e*proj_vector_ij; - val_Jacobian_j[0][0] = -nu_e*proj_vector_ij; - } - -} - -void CAvgGradCorrected_AdjTurb::ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, - su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, - su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config) { - - bool implicit = (config->GetKind_TimeIntScheme_AdjTurb() == EULER_IMPLICIT); - - su2double sigma = 2./3.; - su2double nu_i, nu_j, nu_e_i, nu_e_j; - su2double dist_ij_2 = 0; - su2double proj_vector_ij = 0; - unsigned short iVar, iDim; - - /*--- Compute mean effective viscosity ---*/ - nu_i = Laminar_Viscosity_i/U_i[0]; - nu_j = Laminar_Viscosity_j/U_j[0]; - nu_e_i = (nu_i+TurbVar_i[0])/sigma; - nu_e_j = (nu_j+TurbVar_j[0])/sigma; - - /*--- Compute vector going from iPoint to jPoint ---*/ - 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]; - } - proj_vector_ij = proj_vector_ij/dist_ij_2; // to normalize vectors - - /*--- Mean gradient approximation ---*/ - for (iVar = 0; iVar < nVar; iVar++) { - Proj_Mean_GradTurbPsi_Edge[iVar] = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Mean_GradTurbPsi[iVar][iDim] = 0.5*(TurbPsi_Grad_i[iVar][iDim] + TurbPsi_Grad_j[iVar][iDim]); - Proj_Mean_GradTurbPsi_Edge[iVar] += Mean_GradTurbPsi[iVar][iDim]*Edge_Vector[iDim]; - } - - for (iDim = 0; iDim < nDim; iDim++) - Mean_GradTurbPsi[iVar][iDim] -= (Proj_Mean_GradTurbPsi_Edge[iVar] - - (TurbPsi_j[iVar]-TurbPsi_i[iVar]))*Edge_Vector[iDim]/dist_ij_2; - - /*--- Projection of the corrected gradient ---*/ - Proj_Mean_GradTurbPsi_Corrected[iVar] = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - Proj_Mean_GradTurbPsi_Corrected[iVar] += Mean_GradTurbPsi[iVar][iDim]*Normal[iDim]; - } - - val_residual_i[0] = -nu_e_i*Proj_Mean_GradTurbPsi_Corrected[0]; - val_residual_j[0] = nu_e_j*Proj_Mean_GradTurbPsi_Corrected[0]; - - if (implicit) { - val_Jacobian_ii[0][0] = nu_e_i*proj_vector_ij; - val_Jacobian_ij[0][0] = -nu_e_i*proj_vector_ij; - val_Jacobian_ji[0][0] = -nu_e_j*proj_vector_ij; - val_Jacobian_jj[0][0] = nu_e_j*proj_vector_ij; - } - -} - -CAvgGrad_AdjTurb::CAvgGrad_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - Edge_Vector = new su2double [nDim]; - Mean_GradTurbPsi = new su2double* [nVar]; - Proj_Mean_GradTurbPsi_Kappa = new su2double [nVar]; - Proj_Mean_GradTurbPsi_Edge = new su2double [nVar]; - Proj_Mean_GradTurbPsi_Corrected = new su2double [nVar]; - for (unsigned short iVar = 0; iVar < nVar; iVar++) - Mean_GradTurbPsi[iVar] = new su2double [nDim]; -} - -CAvgGrad_AdjTurb::~CAvgGrad_AdjTurb(void) { - delete [] Edge_Vector; - delete [] Proj_Mean_GradTurbPsi_Kappa; - delete [] Proj_Mean_GradTurbPsi_Edge; - delete [] Proj_Mean_GradTurbPsi_Corrected; - for (unsigned short iVar = 0; iVar < nVar; iVar++) { - delete [] Mean_GradTurbPsi[iVar]; - } - delete [] Mean_GradTurbPsi; -} - -void CAvgGrad_AdjTurb::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, - su2double **val_Jacobian_j, CConfig *config) { - - bool implicit = (config->GetKind_TimeIntScheme_AdjTurb() == EULER_IMPLICIT); - - su2double sigma = 2./3.; - su2double nu_i, nu_j, nu_e; - su2double dist_ij_2 = 0; - su2double proj_vector_ij = 0; - unsigned short iVar, iDim; - - /*--- Compute mean effective viscosity ---*/ - nu_i = Laminar_Viscosity_i/U_i[0]; - nu_j = Laminar_Viscosity_j/U_j[0]; - nu_e = 0.5*(nu_i+nu_j+TurbVar_i[0]+TurbVar_j[0])/sigma; - - /*--- Compute vector going from iPoint to jPoint ---*/ - 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]; - } - proj_vector_ij = proj_vector_ij/dist_ij_2; - - /*--- Mean gradient approximation ---*/ - for (iVar = 0; iVar < nVar; iVar++) { - Proj_Mean_GradTurbPsi_Edge[iVar] = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Mean_GradTurbPsi[iVar][iDim] = 0.5*(TurbPsi_Grad_i[iVar][iDim] + TurbPsi_Grad_j[iVar][iDim]); - } - - /*--- Projection of the corrected gradient ---*/ - Proj_Mean_GradTurbPsi_Corrected[iVar] = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - Proj_Mean_GradTurbPsi_Corrected[iVar] += Mean_GradTurbPsi[iVar][iDim]*Normal[iDim]; - } - - val_residual[0] = -nu_e*Proj_Mean_GradTurbPsi_Corrected[0]; - - if (implicit) { - val_Jacobian_i[0][0] = nu_e*proj_vector_ij; - val_Jacobian_j[0][0] = -nu_e*proj_vector_ij; - } - -} - -void CAvgGrad_AdjTurb::ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, - su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, - su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config) { - - bool implicit = (config->GetKind_TimeIntScheme_AdjTurb() == EULER_IMPLICIT); - - su2double sigma = 2./3.; - su2double nu_i, nu_j, nu_e_i, nu_e_j; - su2double dist_ij_2 = 0; - su2double proj_vector_ij = 0; - unsigned short iVar, iDim; - - /*--- Compute mean effective viscosity ---*/ - nu_i = Laminar_Viscosity_i/U_i[0]; - nu_j = Laminar_Viscosity_j/U_j[0]; - nu_e_i = (nu_i+TurbVar_i[0])/sigma; - nu_e_j = (nu_j+TurbVar_j[0])/sigma; - - /*--- Compute vector going from iPoint to jPoint ---*/ - 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]; - } - proj_vector_ij = proj_vector_ij/dist_ij_2; // to normalize vectors - - /*--- Mean gradient approximation ---*/ - for (iVar = 0; iVar < nVar; iVar++) { - Proj_Mean_GradTurbPsi_Edge[iVar] = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Mean_GradTurbPsi[iVar][iDim] = 0.5*(TurbPsi_Grad_i[iVar][iDim] + TurbPsi_Grad_j[iVar][iDim]); - } - - /*--- Projection of the corrected gradient ---*/ - Proj_Mean_GradTurbPsi_Corrected[iVar] = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - Proj_Mean_GradTurbPsi_Corrected[iVar] += Mean_GradTurbPsi[iVar][iDim]*Normal[iDim]; - } - - val_residual_i[0] = -nu_e_i*Proj_Mean_GradTurbPsi_Corrected[0]; - val_residual_j[0] = nu_e_j*Proj_Mean_GradTurbPsi_Corrected[0]; - - if (implicit) { - val_Jacobian_ii[0][0] = nu_e_i*proj_vector_ij; - val_Jacobian_ij[0][0] = -nu_e_i*proj_vector_ij; - val_Jacobian_ji[0][0] = -nu_e_j*proj_vector_ij; - val_Jacobian_jj[0][0] = nu_e_j*proj_vector_ij; - } - -} - -CSourcePieceWise_AdjTurb::CSourcePieceWise_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - Velocity = new su2double [nDim]; - tau = new su2double* [nDim]; - for (unsigned short iDim = 0; iDim < nDim; iDim++) - tau[iDim] = new su2double [nDim]; -} - -CSourcePieceWise_AdjTurb::~CSourcePieceWise_AdjTurb(void) { - delete [] Velocity; - - for (unsigned short iDim = 0; iDim < nDim; iDim++) - delete [] tau[iDim]; - delete [] tau; -} - -void CSourcePieceWise_AdjTurb::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - unsigned short iDim, jDim; - - bool implicit = (config->GetKind_TimeIntScheme_AdjTurb() == EULER_IMPLICIT); - su2double Prandtl_Turb = config->GetPrandtl_Turb(); - - val_residual[0] = 0.0; - if (implicit) - val_Jacobian_i[0][0] = 0.0; - - if (dist_i > 0.0) { - - /*--- Computation of Vorticity and Divergence of velocity ---*/ - su2double div_vel = 0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity[iDim] = U_i[iDim+1]/U_i[0]; - div_vel += PrimVar_Grad_i[iDim+1][iDim]; - } - - su2double Vorticity = (PrimVar_Grad_i[2][0]-PrimVar_Grad_i[1][1])*(PrimVar_Grad_i[2][0]-PrimVar_Grad_i[1][1]); - if (nDim == 3) - Vorticity += ( (PrimVar_Grad_i[3][1]-PrimVar_Grad_i[2][2])*(PrimVar_Grad_i[3][1]-PrimVar_Grad_i[2][2]) + - (PrimVar_Grad_i[1][2]-PrimVar_Grad_i[3][0])*(PrimVar_Grad_i[1][2]-PrimVar_Grad_i[3][0]) ); - Vorticity = sqrt(Vorticity); - - /*--- FIRST PART: -Bs*TurbPsi_i ---*/ - /*--- CLOUSURE CONSTANTS ---*/ - su2double cv1 = 7.1; - su2double cv1_3 = cv1*cv1*cv1; - su2double k = 0.41; - su2double k2 = k*k; - su2double cb1 = 0.1355; - su2double cw2 = 0.3; - su2double cw3_6 = pow(2.0,6.0); - su2double sigma = 2./3.; - su2double cb2 = 0.622; - su2double cw1 = cb1/k2+(1+cb2)/sigma; - - su2double nu, Ji, fv1, fv2, Shat, dist_0_2, Ji_2, Ji_3, one_o_oneplusJifv1; - su2double r, g, g_6, glim, fw; - su2double dTs_nuhat, dTs_Shat, dShat_nuhat, dTs_fw, dfw_g, dg_r, dr_nuhat, dr_Shat; - su2double dShat_fv2, dfv2_fv1, dfv1_Ji, dJi_nuhat, dfv2_Ji; - su2double Bs; - - dist_0_2 = dist_i*dist_i; - nu = Laminar_Viscosity_i/U_i[0]; - Ji = TurbVar_i[0]/nu; - Ji_2 = Ji*Ji; - Ji_3 = Ji_2*Ji; - fv1 = Ji_3/(Ji_3+cv1_3); - one_o_oneplusJifv1 = 1.0/(1.0+Ji*fv1); - fv2 = 1.0 - Ji*one_o_oneplusJifv1; - Shat = max(Vorticity + TurbVar_i[0]*fv2/(k2*dist_0_2), TURB_EPS); - - // r = TurbVar_i[0]/(Shat*k2*dist_0_2); - r = min(TurbVar_i[0]/(Shat*k2*dist_0_2),10.); - g = r + cw2*(pow(r,6.)-r); - g_6 = pow(g,6.); - glim = pow((1+cw3_6)/(g_6+cw3_6),1./6.); - fw = g*glim; - - dTs_nuhat = cb1*Shat-2.0*cw1*fw*TurbVar_i[0]/dist_0_2; - dTs_Shat = cb1*TurbVar_i[0]; - dTs_fw = -cw1*TurbVar_i[0]*TurbVar_i[0]/dist_0_2; - dfw_g = glim*cw3_6/(g_6+cw3_6); - dg_r = 1.0 + cw2*(6.0*pow(r,5.0)-1.0); - dr_nuhat = 1.0/(Shat*k2*dist_0_2); - dr_Shat = -dr_nuhat*TurbVar_i[0]/Shat; - - dShat_nuhat = fv2/(k2*dist_0_2); - dShat_fv2 = TurbVar_i[0]/(k2*dist_0_2); - dfv2_fv1 = Ji_2*one_o_oneplusJifv1*one_o_oneplusJifv1; - dfv1_Ji = 3.0*cv1_3*Ji_2/((Ji_3+cv1_3)*(Ji_3+cv1_3)); - dJi_nuhat = 1.0/nu; - dfv2_Ji = -one_o_oneplusJifv1*one_o_oneplusJifv1; - dShat_nuhat += dShat_fv2*(dfv2_fv1*dfv1_Ji+dfv2_Ji)*dJi_nuhat; - - Bs = dTs_nuhat; // nu_hat term - Bs += dTs_Shat*dShat_nuhat; // S_hat term - Bs += dTs_fw*dfw_g*dg_r*(dr_nuhat+dr_Shat*dShat_nuhat); // fw terms - - val_residual[0] = -Bs*TurbPsi_i[0]*Volume; - - if (implicit) - val_Jacobian_i[0][0] = -Bs*Volume; - - /*---SECOND PART: \partial_nu_hat mu^k F^{vk} cdot \grad Psi ---*/ - su2double dEddyVisc_nuhat; - if (!config->GetFrozen_Visc_Cont()) - dEddyVisc_nuhat = U_i[0]*fv1*(1.0 + 3.0*cv1_3/(Ji_3+cv1_3)); - else - dEddyVisc_nuhat = 0; - - for (iDim = 0; iDim < nDim; iDim++) { - for (jDim = 0; jDim < nDim; jDim++) - tau[iDim][jDim] = PrimVar_Grad_i[iDim+1][jDim] + PrimVar_Grad_i[jDim+1][iDim]; - tau[iDim][iDim] -= TWO3*div_vel; - } - - su2double Gas_Constant = config->GetGas_ConstantND(); - su2double Cp = (Gamma/Gamma_Minus_One)*Gas_Constant; - su2double tau_gradphi = 0.0, vel_tau_gradpsi5 = 0.0, gradT_gradpsi5 = 0.0; - - for (iDim = 0; iDim < nDim; iDim++) { - gradT_gradpsi5 += PrimVar_Grad_i[0][iDim]*PsiVar_Grad_i[nVar-1][iDim]; - for (jDim = 0; jDim < nDim; jDim++) { - tau_gradphi += tau[iDim][jDim]*PsiVar_Grad_i[iDim+1][jDim]; - vel_tau_gradpsi5 += Velocity[iDim]*tau[iDim][jDim]*PsiVar_Grad_i[nVar-1][jDim]; - } - } - val_residual[0] += (tau_gradphi + vel_tau_gradpsi5 + Cp/Prandtl_Turb*gradT_gradpsi5)*dEddyVisc_nuhat*Volume; - - } -} - -CSourceConservative_AdjTurb::CSourceConservative_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - -} - -CSourceConservative_AdjTurb::~CSourceConservative_AdjTurb(void) { -} - -void CSourceConservative_AdjTurb::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - /*--- SOURCE term --> \nabla ( \psi_\mu \B7 E^{s} ) - E^{s} = 2 c_{b2}/\sigma \nabla \hat{nu} ---*/ - - unsigned short iDim; - bool implicit = (config->GetKind_TimeIntScheme_AdjTurb() == EULER_IMPLICIT); - - su2double cb2 = 0.622; - su2double sigma = 2./3.; - su2double coeff = 2.0*cb2/sigma; - su2double E_ij, proj_TurbVar_Grad_i, proj_TurbVar_Grad_j; - - E_ij = 0.0; proj_TurbVar_Grad_i = 0.0; proj_TurbVar_Grad_j = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - proj_TurbVar_Grad_i += coeff*TurbVar_Grad_i[0][iDim]*Normal[iDim]; - proj_TurbVar_Grad_j += coeff*TurbVar_Grad_j[0][iDim]*Normal[iDim]; - E_ij += 0.5*(TurbPsi_i[0]*proj_TurbVar_Grad_i + TurbPsi_j[0]*proj_TurbVar_Grad_j); - } - - val_residual[0] = E_ij; - - if (implicit) { - val_Jacobian_i[0][0] = 0.5*proj_TurbVar_Grad_i; - val_Jacobian_j[0][0] = 0.5*proj_TurbVar_Grad_j; - } - -} diff --git a/SU2_CFD/src/numerics_direct_heat.cpp b/SU2_CFD/src/numerics_direct_heat.cpp deleted file mode 100644 index 98631c46e58e..000000000000 --- a/SU2_CFD/src/numerics_direct_heat.cpp +++ /dev/null @@ -1,318 +0,0 @@ -/*! - * \file numerics_direct_heat.cpp - * \brief This file contains all the convective term discretization. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - - -#include "../include/numerics_structure.hpp" -#include - -CUpwSca_Heat::CUpwSca_Heat(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_Turb() == EULER_IMPLICIT); - /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ - dynamic_grid = config->GetDynamic_Grid(); - - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; - - Laminar_Viscosity_i = config->GetViscosity_FreeStreamND(); - Laminar_Viscosity_j = config->GetViscosity_FreeStreamND(); -} - -CUpwSca_Heat::~CUpwSca_Heat(void) { - - delete [] Velocity_i; - delete [] Velocity_j; - -} - -void CUpwSca_Heat::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - q_ij = 0.0; - - AD::StartPreacc(); - AD::SetPreaccIn(V_i, nDim+1); AD::SetPreaccIn(V_j, nDim+1); - AD::SetPreaccIn(Temp_i); AD::SetPreaccIn(Temp_j); - AD::SetPreaccIn(Normal, nDim); - if (dynamic_grid) { - AD::SetPreaccIn(GridVel_i, nDim); AD::SetPreaccIn(GridVel_j, nDim); - } - - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = V_i[iDim+1]; - Velocity_j[iDim] = V_j[iDim+1]; - q_ij += 0.5*(Velocity_i[iDim]+Velocity_j[iDim])*Normal[iDim]; - } - - a0 = 0.5*(q_ij+fabs(q_ij)); - a1 = 0.5*(q_ij-fabs(q_ij)); - val_residual[0] = a0*Temp_i+a1*Temp_j; - - if (implicit) { - val_Jacobian_i[0][0] = a0; - val_Jacobian_j[0][0] = a1; - } - - AD::SetPreaccOut(val_residual[0]); - AD::EndPreacc(); - -} - -CCentSca_Heat::CCentSca_Heat(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_Turb() == EULER_IMPLICIT); - /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ - dynamic_grid = config->GetDynamic_Grid(); - - MeanVelocity = new su2double [nDim]; - - Laminar_Viscosity_i = config->GetViscosity_FreeStreamND(); - Laminar_Viscosity_j = config->GetViscosity_FreeStreamND(); - - Param_Kappa_4 = config->GetKappa_4th_Heat(); - Diff_Lapl = new su2double [nVar]; -} - -CCentSca_Heat::~CCentSca_Heat(void) { - - delete [] MeanVelocity; - delete [] Diff_Lapl; - -} - -void CCentSca_Heat::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - AD::StartPreacc(); - AD::SetPreaccIn(V_i, nDim+3); AD::SetPreaccIn(V_j, nDim+3); - AD::SetPreaccIn(Temp_i); AD::SetPreaccIn(Temp_j); - AD::SetPreaccIn(Und_Lapl_i, nVar); AD::SetPreaccIn(Und_Lapl_j, nVar); - AD::SetPreaccIn(Normal, nDim); - if (dynamic_grid) { - AD::SetPreaccIn(GridVel_i, nDim); AD::SetPreaccIn(GridVel_j, nDim); - } - - /*--- Primitive variables at point i and j ---*/ - - Pressure_i = V_i[0]; Pressure_j = V_j[0]; - DensityInc_i = V_i[nDim+2]; DensityInc_j = V_j[nDim+2]; - BetaInc2_i = V_i[nDim+3]; BetaInc2_j = V_j[nDim+3]; - - /*--- Projected velocities at the current edge ---*/ - - ProjVelocity = 0.0; ProjVelocity_i = 0.0; ProjVelocity_j = 0.0; Area = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - ProjVelocity_i += V_i[iDim+1]*Normal[iDim]; - ProjVelocity_j += V_j[iDim+1]*Normal[iDim]; - Area += Normal[iDim]*Normal[iDim]; - } - Area = sqrt(Area); - - /*--- Computing the second order centered scheme part ---*/ - - ProjVelocity = 0.5*(ProjVelocity_i+ProjVelocity_j); - - val_residual[0] = 0.5*(Temp_i + Temp_j)*ProjVelocity; - - if (implicit) { - val_Jacobian_i[0][0] = 0.5*ProjVelocity; - val_Jacobian_j[0][0] = 0.5*ProjVelocity; - } - - /*--- Adding artificial dissipation to stabilize the centered scheme ---*/ - - Diff_Lapl[0] = Und_Lapl_i[0]-Und_Lapl_j[0]; - - SoundSpeed_i = sqrt(ProjVelocity_i*ProjVelocity_i + (BetaInc2_i/DensityInc_i)*Area*Area); - SoundSpeed_j = sqrt(ProjVelocity_j*ProjVelocity_j + (BetaInc2_j/DensityInc_j)*Area*Area); - - Local_Lambda_i = fabs(ProjVelocity_i)+SoundSpeed_i; - Local_Lambda_j = fabs(ProjVelocity_j)+SoundSpeed_j; - MeanLambda = 0.5*(Local_Lambda_i+Local_Lambda_j); - - val_residual[0] += -Param_Kappa_4*Diff_Lapl[0]*MeanLambda; - - if (implicit) { - cte_0 = Param_Kappa_4*su2double(Neighbor_i+1)*MeanLambda; - cte_1 = Param_Kappa_4*su2double(Neighbor_j+1)*MeanLambda; - - val_Jacobian_i[0][0] += cte_0; - val_Jacobian_j[0][0] -= cte_1; - } - - AD::SetPreaccOut(val_residual[0]); - AD::EndPreacc(); - -} - -CAvgGrad_Heat::CAvgGrad_Heat(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_Heat() == EULER_IMPLICIT); - - Edge_Vector = new su2double [nDim]; - Proj_Mean_GradHeatVar_Normal = new su2double [nVar]; - Proj_Mean_GradHeatVar_Corrected = new su2double [nVar]; - Mean_GradHeatVar = new su2double* [nVar]; - for (iVar = 0; iVar < nVar; iVar++) - Mean_GradHeatVar[iVar] = new su2double [nDim]; - -} - -CAvgGrad_Heat::~CAvgGrad_Heat(void) { - - delete [] Edge_Vector; - delete [] Proj_Mean_GradHeatVar_Normal; - delete [] Proj_Mean_GradHeatVar_Corrected; - for (iVar = 0; iVar < nVar; iVar++) - delete [] Mean_GradHeatVar[iVar]; - delete [] Mean_GradHeatVar; - -} - -void CAvgGrad_Heat::ComputeResidual(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config) { - - AD::StartPreacc(); - AD::SetPreaccIn(Coord_i, nDim); AD::SetPreaccIn(Coord_j, nDim); - AD::SetPreaccIn(Normal, nDim); - AD::SetPreaccIn(Temp_i); AD::SetPreaccIn(Temp_j); - AD::SetPreaccIn(ConsVar_Grad_i[0],nDim); AD::SetPreaccIn(ConsVar_Grad_j[0],nDim); - AD::SetPreaccIn(Thermal_Diffusivity_i); AD::SetPreaccIn(Thermal_Conductivity_j); - - Thermal_Diffusivity_Mean = 0.5*(Thermal_Diffusivity_i + Thermal_Diffusivity_j); - - /*--- Compute vector going from iPoint to jPoint ---*/ - - 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; - - /*--- Mean gradient approximation. Projection of the mean gradient in the direction of the edge ---*/ - for (iVar = 0; iVar < nVar; iVar++) { - Proj_Mean_GradHeatVar_Normal[iVar] = 0.0; - Proj_Mean_GradHeatVar_Corrected[iVar] = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Mean_GradHeatVar[iVar][iDim] = 0.5*(ConsVar_Grad_i[iVar][iDim] + ConsVar_Grad_j[iVar][iDim]); - Proj_Mean_GradHeatVar_Normal[iVar] += Mean_GradHeatVar[iVar][iDim]*Normal[iDim]; - } - Proj_Mean_GradHeatVar_Corrected[iVar] = Proj_Mean_GradHeatVar_Normal[iVar]; - } - - val_residual[0] = Thermal_Diffusivity_Mean*Proj_Mean_GradHeatVar_Corrected[0]; - - /*--- For Jacobians -> Use of TSL approx. to compute derivatives of the gradients ---*/ - if (implicit) { - Jacobian_i[0][0] = -Thermal_Diffusivity_Mean*proj_vector_ij; - Jacobian_j[0][0] = Thermal_Diffusivity_Mean*proj_vector_ij; - } - - AD::SetPreaccOut(val_residual, nVar); - AD::EndPreacc(); - -} - - -CAvgGradCorrected_Heat::CAvgGradCorrected_Heat(unsigned short val_nDim, unsigned short val_nVar, - CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_Heat() == EULER_IMPLICIT); - - Edge_Vector = new su2double [nDim]; - Proj_Mean_GradHeatVar_Edge = new su2double [nVar]; - Proj_Mean_GradHeatVar_Kappa = new su2double [nVar]; - Proj_Mean_GradHeatVar_Corrected = new su2double [nVar]; - Mean_GradHeatVar = new su2double* [nVar]; - for (iVar = 0; iVar < nVar; iVar++) - Mean_GradHeatVar[iVar] = new su2double [nDim]; - -} - -CAvgGradCorrected_Heat::~CAvgGradCorrected_Heat(void) { - - delete [] Edge_Vector; - delete [] Proj_Mean_GradHeatVar_Edge; - delete [] Proj_Mean_GradHeatVar_Kappa; - delete [] Proj_Mean_GradHeatVar_Corrected; - for (iVar = 0; iVar < nVar; iVar++) - delete [] Mean_GradHeatVar[iVar]; - delete [] Mean_GradHeatVar; - -} - -void CAvgGradCorrected_Heat::ComputeResidual(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config) { - - AD::StartPreacc(); - AD::SetPreaccIn(Coord_i, nDim); AD::SetPreaccIn(Coord_j, nDim); - AD::SetPreaccIn(Normal, nDim); - AD::SetPreaccIn(Temp_i); AD::SetPreaccIn(Temp_j); - AD::SetPreaccIn(ConsVar_Grad_i[0],nDim); AD::SetPreaccIn(ConsVar_Grad_j[0],nDim); - AD::SetPreaccIn(Thermal_Diffusivity_i); AD::SetPreaccIn(Thermal_Diffusivity_j); - - Thermal_Diffusivity_Mean = 0.5*(Thermal_Diffusivity_i + Thermal_Diffusivity_j); - - /*--- Compute vector going from iPoint to jPoint ---*/ - - 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; - - /*--- Mean gradient approximation. Projection of the mean gradient - in the direction of the edge ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - Proj_Mean_GradHeatVar_Edge[iVar] = 0.0; - Proj_Mean_GradHeatVar_Kappa[iVar] = 0.0; - - for (iDim = 0; iDim < nDim; iDim++) { - Mean_GradHeatVar[iVar][iDim] = 0.5*(ConsVar_Grad_i[iVar][iDim] + ConsVar_Grad_j[iVar][iDim]); - Proj_Mean_GradHeatVar_Kappa[iVar] += Mean_GradHeatVar[iVar][iDim]*Normal[iDim]; - Proj_Mean_GradHeatVar_Edge[iVar] += Mean_GradHeatVar[iVar][iDim]*Edge_Vector[iDim]; - } - Proj_Mean_GradHeatVar_Corrected[iVar] = Proj_Mean_GradHeatVar_Kappa[iVar]; - Proj_Mean_GradHeatVar_Corrected[iVar] -= Proj_Mean_GradHeatVar_Edge[iVar]*proj_vector_ij - - (Temp_j-Temp_i)*proj_vector_ij; - } - - val_residual[0] = Thermal_Diffusivity_Mean*Proj_Mean_GradHeatVar_Corrected[0]; - - /*--- For Jacobians -> Use of TSL approx. to compute derivatives of the gradients ---*/ - - if (implicit) { - Jacobian_i[0][0] = -Thermal_Diffusivity_Mean*proj_vector_ij; - Jacobian_j[0][0] = Thermal_Diffusivity_Mean*proj_vector_ij; - } - - AD::SetPreaccOut(val_residual, nVar); - AD::EndPreacc(); -} diff --git a/SU2_CFD/src/numerics_direct_mean.cpp b/SU2_CFD/src/numerics_direct_mean.cpp deleted file mode 100644 index eceb139e226e..000000000000 --- a/SU2_CFD/src/numerics_direct_mean.cpp +++ /dev/null @@ -1,5210 +0,0 @@ -/*! - * \file numerics_direct_mean.cpp - * \brief This file contains the numerical methods for compressible flow. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - - -#include "../include/numerics_structure.hpp" -#include - -CCentBase_Flow::CCentBase_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : - CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ - dynamic_grid = config->GetDynamic_Grid(); - fix_factor = config->GetCent_Jac_Fix_Factor(); - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - /*--- Allocate required structures ---*/ - Diff_U = new su2double [nVar]; - Diff_Lapl = new su2double [nVar]; - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; - MeanVelocity = new su2double [nDim]; - ProjFlux = new su2double [nVar]; -} - -CCentBase_Flow::~CCentBase_Flow(void) { - delete [] Diff_U; - delete [] Diff_Lapl; - delete [] Velocity_i; - delete [] Velocity_j; - delete [] MeanVelocity; - delete [] ProjFlux; -} - -void CCentBase_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, - CConfig *config) { - - su2double U_i[5] = {0.0,0.0,0.0,0.0,0.0}, U_j[5] = {0.0,0.0,0.0,0.0,0.0}; - - bool preacc = SetPreaccInVars(); - - if (preacc) { - AD::SetPreaccIn(Normal, nDim); - AD::SetPreaccIn(V_i, nDim+5); AD::SetPreaccIn(V_j, nDim+5); - AD::SetPreaccIn(Lambda_i); AD::SetPreaccIn(Lambda_j); - if (dynamic_grid) { - AD::SetPreaccIn(GridVel_i, nDim); AD::SetPreaccIn(GridVel_j, nDim); - } - } - - /*--- Pressure, density, enthalpy, energy, and velocity at points i and j ---*/ - - Pressure_i = V_i[nDim+1]; Pressure_j = V_j[nDim+1]; - Density_i = V_i[nDim+2]; Density_j = V_j[nDim+2]; - Enthalpy_i = V_i[nDim+3]; Enthalpy_j = V_j[nDim+3]; - SoundSpeed_i = V_i[nDim+4]; SoundSpeed_j = V_j[nDim+4]; - Energy_i = Enthalpy_i - Pressure_i/Density_i; Energy_j = Enthalpy_j - Pressure_j/Density_j; - - sq_vel_i = 0.0; sq_vel_j = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = V_i[iDim+1]; - Velocity_j[iDim] = V_j[iDim+1]; - sq_vel_i += 0.5*Velocity_i[iDim]*Velocity_i[iDim]; - sq_vel_j += 0.5*Velocity_j[iDim]*Velocity_j[iDim]; - } - - /*--- Recompute conservative variables ---*/ - - U_i[0] = Density_i; U_j[0] = Density_j; - for (iDim = 0; iDim < nDim; iDim++) { - U_i[iDim+1] = Density_i*Velocity_i[iDim]; U_j[iDim+1] = Density_j*Velocity_j[iDim]; - } - U_i[nDim+1] = Density_i*Energy_i; U_j[nDim+1] = Density_j*Energy_j; - - /*--- Compute mean values of the variables ---*/ - - MeanDensity = 0.5*(Density_i+Density_j); - MeanPressure = 0.5*(Pressure_i+Pressure_j); - MeanEnthalpy = 0.5*(Enthalpy_i+Enthalpy_j); - for (iDim = 0; iDim < nDim; iDim++) - MeanVelocity[iDim] = 0.5*(Velocity_i[iDim]+Velocity_j[iDim]); - MeanEnergy = 0.5*(Energy_i+Energy_j); - - /*--- Get projected flux tensor ---*/ - - GetInviscidProjFlux(&MeanDensity, MeanVelocity, &MeanPressure, &MeanEnthalpy, Normal, ProjFlux); - - /*--- Residual of the inviscid flux ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_residual[iVar] = ProjFlux[iVar]; - - /*--- Jacobians of the inviscid flux, scale = 0.5 because val_residual ~ 0.5*(fc_i+fc_j)*Normal ---*/ - - if (implicit) { - GetInviscidProjJac(MeanVelocity, &MeanEnergy, Normal, 0.5, val_Jacobian_i); - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_j[iVar][jVar] = val_Jacobian_i[iVar][jVar]; - } - - /*--- Adjustment due to grid motion ---*/ - - if (dynamic_grid) { - ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] -= ProjGridVel * 0.5*(U_i[iVar] + U_j[iVar]); - if (implicit) { - val_Jacobian_i[iVar][iVar] -= 0.5*ProjGridVel; - val_Jacobian_j[iVar][iVar] -= 0.5*ProjGridVel; - } - } - } - - /*--- Compute the local spectral radius and the stretching factor ---*/ - - ProjVelocity_i = 0.0; ProjVelocity_j = 0.0; Area = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - ProjVelocity_i += Velocity_i[iDim]*Normal[iDim]; - ProjVelocity_j += Velocity_j[iDim]*Normal[iDim]; - Area += Normal[iDim]*Normal[iDim]; - } - Area = sqrt(Area); - - /*--- Adjustment due to mesh motion ---*/ - - if (dynamic_grid) { - ProjVelocity_i -= ProjGridVel; - ProjVelocity_j -= ProjGridVel; - } - - /*--- Dissipation term ---*/ - - Local_Lambda_i = (fabs(ProjVelocity_i)+SoundSpeed_i*Area); - Local_Lambda_j = (fabs(ProjVelocity_j)+SoundSpeed_j*Area); - MeanLambda = 0.5*(Local_Lambda_i+Local_Lambda_j); - - Phi_i = pow(Lambda_i/(4.0*MeanLambda), Param_p); - Phi_j = pow(Lambda_j/(4.0*MeanLambda), Param_p); - StretchingFactor = 4.0*Phi_i*Phi_j/(Phi_i+Phi_j); - - /*--- Compute differences btw. conservative variables, with a correction for enthalpy ---*/ - - for (iVar = 0; iVar < nVar-1; iVar++) { - Diff_U[iVar] = U_i[iVar]-U_j[iVar]; - } - Diff_U[nVar-1] = Density_i*Enthalpy_i-Density_j*Enthalpy_j; - - DissipationTerm(val_residual, val_Jacobian_i, val_Jacobian_j); - - if (preacc) { - AD::SetPreaccOut(val_residual, nVar); - AD::EndPreacc(); - } -} - -void CCentBase_Flow::ScalarDissipationJacobian(su2double **val_Jacobian_i, su2double **val_Jacobian_j) { - - /*--- n-1 diagonal entries ---*/ - - for (iVar = 0; iVar < (nVar-1); iVar++) { - val_Jacobian_i[iVar][iVar] += fix_factor*cte_0; - val_Jacobian_j[iVar][iVar] -= fix_factor*cte_1; - } - - /*--- Last row of Jacobian_i ---*/ - - val_Jacobian_i[nVar-1][0] += fix_factor*cte_0*Gamma_Minus_One*sq_vel_i; - for (iDim = 0; iDim < nDim; iDim++) - val_Jacobian_i[nVar-1][iDim+1] -= fix_factor*cte_0*Gamma_Minus_One*Velocity_i[iDim]; - val_Jacobian_i[nVar-1][nVar-1] += fix_factor*cte_0*Gamma; - - /*--- Last row of Jacobian_j ---*/ - - val_Jacobian_j[nVar-1][0] -= fix_factor*cte_1*Gamma_Minus_One*sq_vel_j; - for (iDim = 0; iDim < nDim; iDim++) - val_Jacobian_j[nVar-1][iDim+1] += fix_factor*cte_1*Gamma_Minus_One*Velocity_j[iDim]; - val_Jacobian_j[nVar-1][nVar-1] -= fix_factor*cte_1*Gamma; - -} - -CCentJST_Flow::CCentJST_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : - CCentBase_Flow(val_nDim, val_nVar, config) { - - /*--- Artifical dissipation parameters ---*/ - Param_p = 0.3; - Param_Kappa_2 = config->GetKappa_2nd_Flow(); - Param_Kappa_4 = config->GetKappa_4th_Flow(); - -} - -CCentJST_Flow::~CCentJST_Flow(void) { - -} - -void CCentJST_Flow::DissipationTerm(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j) { - - /*--- Compute differences btw. Laplacians ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - Diff_Lapl[iVar] = Und_Lapl_i[iVar]-Und_Lapl_j[iVar]; - } - - /*--- Compute dissipation coefficients ---*/ - - sc2 = 3.0*(su2double(Neighbor_i)+su2double(Neighbor_j))/(su2double(Neighbor_i)*su2double(Neighbor_j)); - sc4 = sc2*sc2/4.0; - - Epsilon_2 = Param_Kappa_2*0.5*(Sensor_i+Sensor_j)*sc2; - Epsilon_4 = max(0.0, Param_Kappa_4-Epsilon_2)*sc4; - - /*--- Compute viscous part of the residual ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_residual[iVar] += (Epsilon_2*Diff_U[iVar] - Epsilon_4*Diff_Lapl[iVar])*StretchingFactor*MeanLambda; - - /*--- Jacobian computation ---*/ - - if (implicit) { - - cte_0 = (Epsilon_2 + Epsilon_4*su2double(Neighbor_i+1))*StretchingFactor*MeanLambda; - cte_1 = (Epsilon_2 + Epsilon_4*su2double(Neighbor_j+1))*StretchingFactor*MeanLambda; - - ScalarDissipationJacobian(val_Jacobian_i, val_Jacobian_j); - } -} - -bool CCentJST_Flow::SetPreaccInVars(void) { - AD::StartPreacc(); - AD::SetPreaccIn(Sensor_i); AD::SetPreaccIn(Und_Lapl_i, nVar); - AD::SetPreaccIn(Sensor_j); AD::SetPreaccIn(Und_Lapl_j, nVar); - return true; -} - -CCentJST_KE_Flow::CCentJST_KE_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : - CCentBase_Flow(val_nDim, val_nVar, config) { - - /*--- Artifical dissipation parameters ---*/ - Param_p = 0.3; - Param_Kappa_2 = config->GetKappa_2nd_Flow(); - -} - -CCentJST_KE_Flow::~CCentJST_KE_Flow(void) { - -} - -void CCentJST_KE_Flow::DissipationTerm(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j) { - - /*--- Compute dissipation coefficient ---*/ - - sc2 = 3.0*(su2double(Neighbor_i)+su2double(Neighbor_j))/(su2double(Neighbor_i)*su2double(Neighbor_j)); - Epsilon_2 = Param_Kappa_2*0.5*(Sensor_i+Sensor_j)*sc2; - - /*--- Compute viscous part of the residual ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_residual[iVar] += Epsilon_2*(Diff_U[iVar])*StretchingFactor*MeanLambda; - - /*--- Jacobian computation ---*/ - - if (implicit) { - - cte_0 = Epsilon_2*StretchingFactor*MeanLambda; - cte_1 = cte_0; - - ScalarDissipationJacobian(val_Jacobian_i, val_Jacobian_j); - } -} - -bool CCentJST_KE_Flow::SetPreaccInVars(void) { - AD::StartPreacc(); - AD::SetPreaccIn(Sensor_i); AD::SetPreaccIn(Sensor_j); - return true; -} - -CCentLax_Flow::CCentLax_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : - CCentBase_Flow(val_nDim, val_nVar, config) { - - /*--- Artifical dissipation parameters ---*/ - Param_p = 0.3; - Param_Kappa_0 = config->GetKappa_1st_Flow(); - -} - -CCentLax_Flow::~CCentLax_Flow(void) { - -} - -void CCentLax_Flow::DissipationTerm(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j) { - - /*--- Compute dissipation coefficient ---*/ - - sc0 = 3.0*(su2double(Neighbor_i)+su2double(Neighbor_j))/(su2double(Neighbor_i)*su2double(Neighbor_j)); - Epsilon_0 = Param_Kappa_0*sc0*su2double(nDim)/3.0; - - /*--- Compute viscous part of the residual ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_residual[iVar] += Epsilon_0*Diff_U[iVar]*StretchingFactor*MeanLambda; - - /*--- Jacobian computation ---*/ - - if (implicit) { - - cte_0 = Epsilon_0*StretchingFactor*MeanLambda; - cte_1 = cte_0; - - ScalarDissipationJacobian(val_Jacobian_i, val_Jacobian_j); - } -} - -bool CCentLax_Flow::SetPreaccInVars(void) { - AD::StartPreacc(); - return true; -} - -CUpwCUSP_Flow::CUpwCUSP_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - if (config->GetDynamic_Grid() && (SU2_MPI::GetRank() == MASTER_NODE)) - cout << "WARNING: Grid velocities are NOT yet considered by the CUSP scheme." << endl; - - /*--- Allocate some structures ---*/ - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; - ProjFlux_i = new su2double [nVar]; - ProjFlux_j = new su2double [nVar]; -} - -CUpwCUSP_Flow::~CUpwCUSP_Flow(void) { - delete [] Velocity_i; - delete [] Velocity_j; - delete [] ProjFlux_i; - delete [] ProjFlux_j; -} - -void CUpwCUSP_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, - CConfig *config) { - - unsigned short iDim, iVar; - su2double Diff_U[5] = {0.0,0.0,0.0,0.0,0.0}; - - AD::SetPreaccIn(Normal, nDim); - AD::SetPreaccIn(V_i, nDim+4); - AD::SetPreaccIn(V_j, nDim+4); - - /*--- Pressure, density, enthalpy, energy, and velocity at points i and j ---*/ - - Pressure_i = V_i[nDim+1]; Pressure_j = V_j[nDim+1]; - Density_i = V_i[nDim+2]; Density_j = V_j[nDim+2]; - Enthalpy_i = V_i[nDim+3]; Enthalpy_j = V_j[nDim+3]; - su2double Energy_i = Enthalpy_i - Pressure_i/Density_i; - su2double Energy_j = Enthalpy_j - Pressure_j/Density_j; - - su2double sq_vel_i = 0.0, sq_vel_j = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = V_i[iDim+1]; - Velocity_j[iDim] = V_j[iDim+1]; - sq_vel_i += Velocity_i[iDim]*Velocity_i[iDim]; - sq_vel_j += Velocity_j[iDim]*Velocity_j[iDim]; - } - - /*-- Face area and unit normal ---*/ - - 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; - - /*--- Computes differences of conservative variables, with a correction for the enthalpy ---*/ - - Diff_U[0] = Density_i - Density_j; - for (iDim = 0; iDim < nDim; iDim++) - Diff_U[iDim+1] = Density_i*Velocity_i[iDim] - Density_j*Velocity_j[iDim]; - Diff_U[nVar-1] = Density_i*Enthalpy_i - Density_j*Enthalpy_j; - - /*--- Get left and right fluxes ---*/ - - GetInviscidProjFlux(&Density_i, Velocity_i, &Pressure_i, &Enthalpy_i, UnitNormal, ProjFlux_i); - GetInviscidProjFlux(&Density_j, Velocity_j, &Pressure_j, &Enthalpy_j, UnitNormal, ProjFlux_j); - - /*--- Compute dissipation parameters based on Roe-averaged values ---*/ - - su2double Beta, Nu_c; - - su2double R = sqrt(Density_j/Density_i), ProjVelocity = 0.0, sq_vel = 0.0; - - for (iDim = 0; iDim < nDim; iDim++) { - su2double MeanVel = (R*Velocity_j[iDim]+Velocity_i[iDim])/(R+1.0); - ProjVelocity += MeanVel*UnitNormal[iDim]; - sq_vel += MeanVel*MeanVel; - } - su2double MeanEnthalpy = (R*Enthalpy_j+Enthalpy_i)/(R+1.0); - su2double MeanSoundSpeed = sqrt(Gamma_Minus_One*fabs(MeanEnthalpy-0.5*sq_vel)); - - su2double Mach = ProjVelocity / MeanSoundSpeed; - - su2double tmp1 = 0.5*(Gamma+1.0)/Gamma*ProjVelocity; - su2double tmp2 = sqrt(pow(tmp1-ProjVelocity/Gamma, 2.0) + pow(MeanSoundSpeed,2.0)/Gamma); - su2double LamdaNeg = tmp1 - tmp2, LamdaPos = tmp1 + tmp2; - - if (fabs(Mach) >= 1.0) Beta = Mach/fabs(Mach); - else if (Mach >= 0.0) Beta = max(0.0, (ProjVelocity + LamdaNeg)/(ProjVelocity - LamdaNeg)); - else Beta =-max(0.0, (ProjVelocity + LamdaPos)/(ProjVelocity - LamdaPos)); - - if (fabs(Mach) >= 1.0) Nu_c = 0.0; - else { - if (Beta > 0.0) Nu_c =-(1.0+Beta)*LamdaNeg; - else if (Beta < 0.0) Nu_c = (1.0-Beta)*LamdaPos; - /*--- Limit the minimum scalar dissipation ---*/ - else Nu_c = max(fabs(ProjVelocity), config->GetEntropyFix_Coeff()*MeanSoundSpeed); - } - - /*--- Compute the residual ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_residual[iVar] = 0.5*((1.0+Beta)*ProjFlux_i[iVar] + (1.0-Beta)*ProjFlux_j[iVar] + Nu_c*Diff_U[iVar])*Area; - - /*--- Jacobian computation ---*/ - - if (implicit) { - - /*--- Flux average and difference contributions ---*/ - - GetInviscidProjJac(Velocity_i, &Energy_i, Normal, 0.5*(1.0+Beta), val_Jacobian_i); - GetInviscidProjJac(Velocity_j, &Energy_j, Normal, 0.5*(1.0-Beta), val_Jacobian_j); - - /*--- Solution difference (scalar dissipation) contribution ---*/ - - su2double cte_0 = 0.5*Nu_c*Area*config->GetCent_Jac_Fix_Factor(); - - /*--- n-1 diagonal entries ---*/ - - for (iVar = 0; iVar < (nVar-1); iVar++) { - val_Jacobian_i[iVar][iVar] += cte_0; - val_Jacobian_j[iVar][iVar] -= cte_0; - } - - /*--- Last rows ---*/ - - val_Jacobian_i[nVar-1][0] += cte_0*Gamma_Minus_One*0.5*sq_vel_i; - for (iDim = 0; iDim < nDim; iDim++) - val_Jacobian_i[nVar-1][iDim+1] -= cte_0*Gamma_Minus_One*Velocity_i[iDim]; - val_Jacobian_i[nVar-1][nVar-1] += cte_0*Gamma; - - val_Jacobian_j[nVar-1][0] -= cte_0*Gamma_Minus_One*0.5*sq_vel_j; - for (iDim = 0; iDim < nDim; iDim++) - val_Jacobian_j[nVar-1][iDim+1] += cte_0*Gamma_Minus_One*Velocity_j[iDim]; - val_Jacobian_j[nVar-1][nVar-1] -= cte_0*Gamma; - - } - - AD::SetPreaccOut(val_residual, nVar); - AD::EndPreacc(); -} - -CUpwAUSM_Flow::CUpwAUSM_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - if (config->GetDynamic_Grid() && (SU2_MPI::GetRank() == MASTER_NODE)) - cout << "WARNING: Grid velocities are NOT yet considered in AUSM-type schemes." << endl; - - implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - Diff_U = new su2double [nVar]; - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; - RoeVelocity = new su2double [nDim]; - delta_vel = new su2double [nDim]; - delta_wave = new su2double [nVar]; - ProjFlux_i = new su2double [nVar]; - ProjFlux_j = new su2double [nVar]; - Lambda = new su2double [nVar]; - Epsilon = new su2double [nVar]; - P_Tensor = new su2double* [nVar]; - invP_Tensor = new su2double* [nVar]; - for (iVar = 0; iVar < nVar; iVar++) { - P_Tensor[iVar] = new su2double [nVar]; - invP_Tensor[iVar] = new su2double [nVar]; - } -} - -CUpwAUSM_Flow::~CUpwAUSM_Flow(void) { - - delete [] Diff_U; - delete [] Velocity_i; - delete [] Velocity_j; - delete [] RoeVelocity; - delete [] delta_vel; - delete [] delta_wave; - delete [] ProjFlux_i; - delete [] ProjFlux_j; - delete [] Lambda; - delete [] Epsilon; - for (iVar = 0; iVar < nVar; iVar++) { - delete [] P_Tensor[iVar]; - delete [] invP_Tensor[iVar]; - } - delete [] P_Tensor; - delete [] invP_Tensor; - -} - -void CUpwAUSM_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - AD::StartPreacc(); - AD::SetPreaccIn(Normal, nDim); - AD::SetPreaccIn(V_i, nDim+4); - AD::SetPreaccIn(V_j, nDim+4); - - /*--- Face area (norm or the normal vector) ---*/ - Area = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - Area += Normal[iDim]*Normal[iDim]; - Area = sqrt(Area); - - /*-- Unit Normal ---*/ - for (iDim = 0; iDim < nDim; iDim++) - UnitNormal[iDim] = Normal[iDim]/Area; - - /*--- Primitive variables at point i ---*/ - sq_vel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = V_i[iDim+1]; - sq_vel += Velocity_i[iDim]*Velocity_i[iDim]; - } - Pressure_i = V_i[nDim+1]; - Density_i = V_i[nDim+2]; - Enthalpy_i = V_i[nDim+3]; - Energy_i = Enthalpy_i - Pressure_i/Density_i; - SoundSpeed_i = sqrt(fabs(Gamma*Gamma_Minus_One*(Energy_i-0.5*sq_vel))); - - /*--- Primitive variables at point j ---*/ - sq_vel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_j[iDim] = V_j[iDim+1]; - sq_vel += Velocity_j[iDim]*Velocity_j[iDim]; - } - Pressure_j = V_j[nDim+1]; - Density_j = V_j[nDim+2]; - Enthalpy_j = V_j[nDim+3]; - Energy_j = Enthalpy_j - Pressure_j/Density_j; - SoundSpeed_j = sqrt(fabs(Gamma*Gamma_Minus_One*(Energy_j-0.5*sq_vel))); - - /*--- Projected velocities ---*/ - ProjVelocity_i = 0.0; ProjVelocity_j = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - ProjVelocity_i += Velocity_i[iDim]*UnitNormal[iDim]; - ProjVelocity_j += Velocity_j[iDim]*UnitNormal[iDim]; - } - - mL = ProjVelocity_i/SoundSpeed_i; - mR = ProjVelocity_j/SoundSpeed_j; - - if (fabs(mL) <= 1.0) mLP = 0.25*(mL+1.0)*(mL+1.0); - else mLP = 0.5*(mL+fabs(mL)); - - if (fabs(mR) <= 1.0) mRM = -0.25*(mR-1.0)*(mR-1.0); - else mRM = 0.5*(mR-fabs(mR)); - - mF = mLP + mRM; - - if (fabs(mL) <= 1.0) pLP = 0.25*Pressure_i*(mL+1.0)*(mL+1.0)*(2.0-mL); - else pLP = 0.5*Pressure_i*(mL+fabs(mL))/mL; - - if (fabs(mR) <= 1.0) pRM = 0.25*Pressure_j*(mR-1.0)*(mR-1.0)*(2.0+mR); - else pRM = 0.5*Pressure_j*(mR-fabs(mR))/mR; - - pF = pLP + pRM; - Phi = fabs(mF); - - val_residual[0] = 0.5*(mF*((Density_i*SoundSpeed_i)+(Density_j*SoundSpeed_j))-Phi*((Density_j*SoundSpeed_j)-(Density_i*SoundSpeed_i))); - for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = 0.5*(mF*((Density_i*SoundSpeed_i*Velocity_i[iDim])+(Density_j*SoundSpeed_j*Velocity_j[iDim])) - -Phi*((Density_j*SoundSpeed_j*Velocity_j[iDim])-(Density_i*SoundSpeed_i*Velocity_i[iDim])))+UnitNormal[iDim]*pF; - val_residual[nVar-1] = 0.5*(mF*((Density_i*SoundSpeed_i*Enthalpy_i)+(Density_j*SoundSpeed_j*Enthalpy_j))-Phi*((Density_j*SoundSpeed_j*Enthalpy_j)-(Density_i*SoundSpeed_i*Enthalpy_i))); - - for (iVar = 0; iVar < nVar; iVar++) - val_residual[iVar] *= Area; - - AD::SetPreaccOut(val_residual, nVar); - AD::EndPreacc(); - - /*--- Roe's Jacobian for AUSM (this must be fixed) ---*/ - if (implicit) { - - /*--- Mean Roe variables iPoint and jPoint ---*/ - R = sqrt(fabs(Density_j/Density_i)); - RoeDensity = R*Density_i; - sq_vel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - RoeVelocity[iDim] = (R*Velocity_j[iDim]+Velocity_i[iDim])/(R+1); - sq_vel += RoeVelocity[iDim]*RoeVelocity[iDim]; - } - RoeEnthalpy = (R*Enthalpy_j+Enthalpy_i)/(R+1); - RoeSoundSpeed = sqrt(fabs((Gamma-1)*(RoeEnthalpy-0.5*sq_vel))); - - /*--- Compute P and Lambda (do it with the Normal) ---*/ - GetPMatrix(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, P_Tensor); - - ProjVelocity = 0.0; ProjVelocity_i = 0.0; ProjVelocity_j = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - ProjVelocity += RoeVelocity[iDim]*UnitNormal[iDim]; - ProjVelocity_i += Velocity_i[iDim]*UnitNormal[iDim]; - ProjVelocity_j += Velocity_j[iDim]*UnitNormal[iDim]; - } - - /*--- Flow eigenvalues and Entropy correctors ---*/ - for (iDim = 0; iDim < nDim; iDim++) - Lambda[iDim] = ProjVelocity; - Lambda[nVar-2] = ProjVelocity + RoeSoundSpeed; - Lambda[nVar-1] = ProjVelocity - RoeSoundSpeed; - - /*--- Compute inverse P ---*/ - GetPMatrix_inv(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, invP_Tensor); - - /*--- Jacobias of the inviscid flux, scale = 0.5 because val_residual ~ 0.5*(fc_i+fc_j)*Normal ---*/ - GetInviscidProjJac(Velocity_i, &Energy_i, Normal, 0.5, val_Jacobian_i); - GetInviscidProjJac(Velocity_j, &Energy_j, Normal, 0.5, val_Jacobian_j); - - /*--- Roe's Flux approximation ---*/ - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - Proj_ModJac_Tensor_ij = 0.0; - /*--- Compute |Proj_ModJac_Tensor| = P x |Lambda| x inverse P ---*/ - for (kVar = 0; kVar < nVar; kVar++) - Proj_ModJac_Tensor_ij += P_Tensor[iVar][kVar]*fabs(Lambda[kVar])*invP_Tensor[kVar][jVar]; - val_Jacobian_i[iVar][jVar] += 0.5*Proj_ModJac_Tensor_ij*Area; - val_Jacobian_j[iVar][jVar] -= 0.5*Proj_ModJac_Tensor_ij*Area; - } - } - } -} - -CUpwAUSMPLUS_SLAU_Base_Flow::CUpwAUSMPLUS_SLAU_Base_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : - CNumerics(val_nDim, val_nVar, config) { - - if (config->GetDynamic_Grid() && (SU2_MPI::GetRank() == MASTER_NODE)) - cout << "WARNING: Grid velocities are NOT yet considered in AUSM-type schemes." << endl; - - implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - UseAccurateJacobian = config->GetUse_Accurate_Jacobians(); - HasAnalyticalDerivatives = false; - FinDiffStep = 1e-4; - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; - psi_i = new su2double [nVar]; - psi_j = new su2double [nVar]; - - RoeVelocity = new su2double [nDim]; - Lambda = new su2double [nVar]; - Epsilon = new su2double [nVar]; - P_Tensor = new su2double* [nVar]; - invP_Tensor = new su2double* [nVar]; - for (unsigned short iVar = 0; iVar < nVar; iVar++) { - P_Tensor[iVar] = new su2double [nVar]; - invP_Tensor[iVar] = new su2double [nVar]; - } -} - -CUpwAUSMPLUS_SLAU_Base_Flow::~CUpwAUSMPLUS_SLAU_Base_Flow(void) { - - delete [] Velocity_i; - delete [] Velocity_j; - delete [] psi_i; - delete [] psi_j; - - delete [] RoeVelocity; - delete [] Lambda; - delete [] Epsilon; - for (unsigned short iVar = 0; iVar < nVar; iVar++) { - delete [] P_Tensor[iVar]; - delete [] invP_Tensor[iVar]; - } - delete [] P_Tensor; - delete [] invP_Tensor; - -} - -void CUpwAUSMPLUS_SLAU_Base_Flow::ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure) -{ - /*--- For schemes that fit in the general form of AUSM+up and SLAU schemes you can inherit from this class - and implement only the specifics, which should be the face mass flux (per unit area) and the face pressure. - For implicit solution methods this class can either approximate the flux Jacobians (using those of the Roe - scheme) or compute accurate ones. This is done either numerically, differentiating "mdot" and "pressure" - using 1st order finite differences, or analytically if you use this function to set the values of - "dmdot_dVi/j", "dpres_dVi/j" and set "HasAnalyticalDerivatives" to true in the ctor of the derived class. - For accurate numerical differentiation "mdot" and "pressure" can be functions of, at most, the velocities, - pressures, densities, and enthalpies at nodes i/j. This is also the order expected for the partial derivatives - of "mdot" and "pressure" in "d?_dVi/j" (in case they are known analytically, see the AUSM+up implementation). - ---*/ -} - -void CUpwAUSMPLUS_SLAU_Base_Flow::ApproximateJacobian(su2double **val_Jacobian_i, su2double **val_Jacobian_j) { - - unsigned short iDim, iVar, jVar, kVar; - su2double R, RoeDensity, RoeEnthalpy, RoeSoundSpeed, ProjVelocity, sq_vel, Energy_i, Energy_j; - - Energy_i = Enthalpy_i - Pressure_i/Density_i; - Energy_j = Enthalpy_j - Pressure_j/Density_j; - - /*--- Mean Roe variables iPoint and jPoint ---*/ - - R = sqrt(fabs(Density_j/Density_i)); - RoeDensity = R*Density_i; - ProjVelocity = 0.0; - sq_vel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - RoeVelocity[iDim] = (R*Velocity_j[iDim]+Velocity_i[iDim])/(R+1); - ProjVelocity += RoeVelocity[iDim]*UnitNormal[iDim]; - sq_vel += RoeVelocity[iDim]*RoeVelocity[iDim]; - } - RoeEnthalpy = (R*Enthalpy_j+Enthalpy_i)/(R+1); - RoeSoundSpeed = sqrt(fabs((Gamma-1)*(RoeEnthalpy-0.5*sq_vel))); - - /*--- Compute P and Lambda (do it with the Normal) ---*/ - - GetPMatrix(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, P_Tensor); - - /*--- Flow eigenvalues and Entropy correctors ---*/ - - for (iDim = 0; iDim < nDim; iDim++) - Lambda[iDim] = ProjVelocity; - Lambda[nVar-2] = ProjVelocity + RoeSoundSpeed; - Lambda[nVar-1] = ProjVelocity - RoeSoundSpeed; - - /*--- Compute inverse P ---*/ - GetPMatrix_inv(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, invP_Tensor); - - /*--- Jacobians of the inviscid flux, scale = 0.5 because val_residual ~ 0.5*(fc_i+fc_j)*Normal ---*/ - GetInviscidProjJac(Velocity_i, &Energy_i, Normal, 0.5, val_Jacobian_i); - GetInviscidProjJac(Velocity_j, &Energy_j, Normal, 0.5, val_Jacobian_j); - - /*--- Roe's Flux approximation ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - su2double Proj_ModJac_Tensor_ij = 0.0; - /*--- Compute |Proj_ModJac_Tensor| = P x |Lambda| x inverse P ---*/ - for (kVar = 0; kVar < nVar; kVar++) - Proj_ModJac_Tensor_ij += P_Tensor[iVar][kVar]*fabs(Lambda[kVar])*invP_Tensor[kVar][jVar]; - val_Jacobian_i[iVar][jVar] += 0.5*Proj_ModJac_Tensor_ij*Area; - val_Jacobian_j[iVar][jVar] -= 0.5*Proj_ModJac_Tensor_ij*Area; - } - } - -} - -void CUpwAUSMPLUS_SLAU_Base_Flow::AccurateJacobian(CConfig *config, su2double **val_Jacobian_i, su2double **val_Jacobian_j) { - - /*--- Compute Jacobians using a mixed (numerical/analytical) formulation ---*/ - - unsigned short iDim, iVar, jVar; - - /*--- If not computed analytically, numerically differentiate the fluxes wrt primitives ---*/ - - if (!HasAnalyticalDerivatives) { - - /*--- Create arrays of pointers to the primitive variables so - we can loop through and perturb them in a general way. ---*/ - - su2double *primitives_i[6], *primitives_j[6]; - - for (iDim = 0; iDim < nDim; ++iDim) { - primitives_i[iDim] = &Velocity_i[iDim]; - primitives_j[iDim] = &Velocity_j[iDim]; - } - primitives_i[ nDim ] = &Pressure_i; primitives_j[ nDim ] = &Pressure_j; - primitives_i[nDim+1] = &Density_i; primitives_j[nDim+1] = &Density_j; - primitives_i[nDim+2] = &Enthalpy_i; primitives_j[nDim+2] = &Enthalpy_j; - - /*--- Initialize the gradient arrays with the negative of the quantity, - then for forward finite differences we add to it and divide. ---*/ - - for (iVar = 0; iVar < 6; ++iVar) { - dmdot_dVi[iVar] = -MassFlux; dpres_dVi[iVar] = -Pressure; - dmdot_dVj[iVar] = -MassFlux; dpres_dVj[iVar] = -Pressure; - } - - for (iVar = 0; iVar < nDim+3; ++iVar) { - /*--- Perturb side i ---*/ - su2double epsilon = FinDiffStep * max(1.0, fabs(*primitives_i[iVar])); - *primitives_i[iVar] += epsilon; - ComputeMassAndPressureFluxes(config, MassFlux, Pressure); - dmdot_dVi[iVar] += MassFlux; dpres_dVi[iVar] += Pressure; - dmdot_dVi[iVar] /= epsilon; dpres_dVi[iVar] /= epsilon; - *primitives_i[iVar] -= epsilon; - - /*--- Perturb side j ---*/ - epsilon = FinDiffStep * max(1.0, fabs(*primitives_j[iVar])); - *primitives_j[iVar] += epsilon; - ComputeMassAndPressureFluxes(config, MassFlux, Pressure); - dmdot_dVj[iVar] += MassFlux; dpres_dVj[iVar] += Pressure; - dmdot_dVj[iVar] /= epsilon; dpres_dVj[iVar] /= epsilon; - *primitives_j[iVar] -= epsilon; - } - } - - /*--- Differentiation of fluxes wrt conservatives assuming ideal gas ---*/ - - su2double dmdot_dUi[5], dmdot_dUj[5], dpres_dUi[5], dpres_dUj[5]; - su2double sq_veli = 0.0, sq_velj = 0.0, dHi_drhoi = 0.0, dHj_drhoj = 0.0; - su2double oneOnRhoi = 1.0/Density_i, oneOnRhoj = 1.0/Density_j; - - for (jVar = 0; jVar < nVar; ++jVar) { - - /*--- Partial derivatives of the primitives wrt conservative "jVar" ---*/ - su2double dVi_dUi[6] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; - su2double dVj_dUj[6] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; - - if (jVar == 0) { // Density - for (iDim = 0; iDim < nDim; ++iDim) { - // -u,v,w / rho - dVi_dUi[iDim] = -Velocity_i[iDim] * oneOnRhoi; - dVj_dUj[iDim] = -Velocity_j[iDim] * oneOnRhoj; - // ||V||^2 - sq_veli += Velocity_i[iDim] * Velocity_i[iDim]; - sq_velj += Velocity_j[iDim] * Velocity_j[iDim]; - } - dVi_dUi[nDim] = 0.5*Gamma_Minus_One*sq_veli; - dVj_dUj[nDim] = 0.5*Gamma_Minus_One*sq_velj; - - dVi_dUi[nDim+1] = dVj_dUj[nDim+1] = 1.0; - - dHi_drhoi = 0.5*(Gamma-2.0)*sq_veli - Gamma*Pressure_i/((Gamma-1.0)*Density_i); - dHj_drhoj = 0.5*(Gamma-2.0)*sq_velj - Gamma*Pressure_j/((Gamma-1.0)*Density_j); - dVi_dUi[nDim+2] = dHi_drhoi * oneOnRhoi; - dVj_dUj[nDim+2] = dHj_drhoj * oneOnRhoj; - } - else if (jVar == nVar-1) { // rho*Energy - dVi_dUi[nDim] = dVj_dUj[nDim] = Gamma_Minus_One; - dVi_dUi[nDim+2] = Gamma * oneOnRhoi; - dVj_dUj[nDim+2] = Gamma * oneOnRhoj; - } - else { // Momentum - dVi_dUi[jVar-1] = oneOnRhoi; - dVj_dUj[jVar-1] = oneOnRhoj; - - dVi_dUi[nDim] = -Gamma_Minus_One*Velocity_i[jVar-1]; - dVj_dUj[nDim] = -Gamma_Minus_One*Velocity_j[jVar-1]; - - dVi_dUi[nDim+2] = dVi_dUi[nDim] * oneOnRhoi; - dVj_dUj[nDim+2] = dVj_dUj[nDim] * oneOnRhoj; - } - - /*--- Dot product to complete chain rule ---*/ - dmdot_dUi[jVar] = 0.0; dpres_dUi[jVar] = 0.0; - dmdot_dUj[jVar] = 0.0; dpres_dUj[jVar] = 0.0; - for (iVar = 0; iVar < 6; ++iVar) { - dmdot_dUi[jVar] += dmdot_dVi[iVar]*dVi_dUi[iVar]; - dpres_dUi[jVar] += dpres_dVi[iVar]*dVi_dUi[iVar]; - dmdot_dUj[jVar] += dmdot_dVj[iVar]*dVj_dUj[iVar]; - dpres_dUj[jVar] += dpres_dVj[iVar]*dVj_dUj[iVar]; - } - } - - /*--- Assemble final Jacobians (assuming phi = |mdot|) ---*/ - - su2double mdot_hat, psi_hat[5]; - - if (MassFlux > 0.0) { - mdot_hat = Area*MassFlux*oneOnRhoi; - for (iVar = 0; iVar < nVar; ++iVar) psi_hat[iVar] = Area*psi_i[iVar]; - } - else { - mdot_hat = Area*MassFlux*oneOnRhoj; - for (iVar = 0; iVar < nVar; ++iVar) psi_hat[iVar] = Area*psi_j[iVar]; - } - - /*--- Contribution from the mass flux derivatives ---*/ - for (iVar = 0; iVar < nVar; ++iVar) { - for (jVar = 0; jVar < nVar; ++jVar) { - val_Jacobian_i[iVar][jVar] = psi_hat[iVar] * dmdot_dUi[jVar]; - val_Jacobian_j[iVar][jVar] = psi_hat[iVar] * dmdot_dUj[jVar]; - } - } - - /*--- Contribution from the pressure derivatives ---*/ - for (iDim = 0; iDim < nDim; ++iDim) { - for (jVar = 0; jVar < nVar; ++jVar) { - val_Jacobian_i[iDim+1][jVar] += Normal[iDim] * dpres_dUi[jVar]; - val_Jacobian_j[iDim+1][jVar] += Normal[iDim] * dpres_dUj[jVar]; - } - } - - /*--- Contributions from the derivatives of PSI wrt the conservatives ---*/ - if (MassFlux > 0.0) { - /*--- Velocity terms ---*/ - for (iDim = 0; iDim < nDim; ++iDim) { - val_Jacobian_i[iDim+1][0] -= mdot_hat*Velocity_i[iDim]; - val_Jacobian_i[iDim+1][iDim+1] += mdot_hat; - val_Jacobian_i[nVar-1][iDim+1] -= mdot_hat*Gamma_Minus_One*Velocity_i[iDim]; - } - /*--- Energy terms ---*/ - val_Jacobian_i[nVar-1][0] += mdot_hat*dHi_drhoi; - val_Jacobian_i[nVar-1][nVar-1] += mdot_hat*Gamma; - } - else { - /*--- Velocity terms ---*/ - for (iDim = 0; iDim < nDim; ++iDim) { - val_Jacobian_j[iDim+1][0] -= mdot_hat*Velocity_j[iDim]; - val_Jacobian_j[iDim+1][iDim+1] += mdot_hat; - val_Jacobian_j[nVar-1][iDim+1] -= mdot_hat*Gamma_Minus_One*Velocity_j[iDim]; - } - /*--- Energy terms ---*/ - val_Jacobian_j[nVar-1][0] += mdot_hat*dHj_drhoj; - val_Jacobian_j[nVar-1][nVar-1] += mdot_hat*Gamma; - } - -} - -void CUpwAUSMPLUS_SLAU_Base_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - unsigned short iDim, iVar; - - /*--- Space to start preaccumulation ---*/ - - AD::StartPreacc(); - AD::SetPreaccIn(Normal, nDim); - AD::SetPreaccIn(V_i, nDim+4); - AD::SetPreaccIn(V_j, nDim+4); - - /*--- Variables for the general form and primitives for mass flux and pressure calculation. ---*/ - /*--- F_{1/2} = ||A|| ( 0.5 * mdot * (psi_i+psi_j) - 0.5 * |mdot| * (psi_i-psi_j) + N * pf ) ---*/ - - psi_i[0] = 1.0; psi_j[0] = 1.0; - - for (iDim = 0; iDim < nDim; iDim++) { - /*--- Velocities ---*/ - Velocity_i[iDim] = psi_i[iDim+1] = V_i[iDim+1]; - Velocity_j[iDim] = psi_j[iDim+1] = V_j[iDim+1]; - } - - /*--- Pressure and Density ---*/ - Pressure_i = V_i[nDim+1]; Pressure_j = V_j[nDim+1]; - Density_i = V_i[nDim+2]; Density_j = V_j[nDim+2]; - - /*--- Enthalpy ---*/ - Enthalpy_i = psi_i[nVar-1] = V_i[nDim+3]; - Enthalpy_j = psi_j[nVar-1] = V_j[nDim+3]; - - /*--- Face area (norm or the normal vector) ---*/ - - Area = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - Area += Normal[iDim]*Normal[iDim]; - Area = sqrt(Area); - - /*-- Unit Normal ---*/ - for (iDim = 0; iDim < nDim; iDim++) - UnitNormal[iDim] = Normal[iDim]/Area; - - /*--- Mass and pressure fluxes defined by derived classes ---*/ - - ComputeMassAndPressureFluxes(config, MassFlux, Pressure); - DissFlux = fabs(MassFlux); - - val_residual[0] = MassFlux; - - for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = 0.5*MassFlux*(psi_i[iDim+1]+psi_j[iDim+1]) + - 0.5*DissFlux*(psi_i[iDim+1]-psi_j[iDim+1]) + - UnitNormal[iDim]*Pressure; - - val_residual[nVar-1] = 0.5*MassFlux*(psi_i[nVar-1]+psi_j[nVar-1]) + - 0.5*DissFlux*(psi_i[nVar-1]-psi_j[nVar-1]); - - for (iVar = 0; iVar < nVar; iVar++) val_residual[iVar] *= Area; - - /*--- Space to end preaccumulation ---*/ - - AD::SetPreaccOut(val_residual, nVar); - AD::EndPreacc(); - - /*--- If required, compute Jacobians, either approximately (Roe) or numerically ---*/ - - if (!implicit) return; - - if (UseAccurateJacobian) - AccurateJacobian(config, val_Jacobian_i, val_Jacobian_j); - else - ApproximateJacobian(val_Jacobian_i, val_Jacobian_j); - -} - - -CUpwAUSMPLUSUP_Flow::CUpwAUSMPLUSUP_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : - CUpwAUSMPLUS_SLAU_Base_Flow(val_nDim, val_nVar, config) { - - HasAnalyticalDerivatives = true; - Minf = config->GetMach(); - 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) { - -} - -void CUpwAUSMPLUSUP_Flow::ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure) { - - /*--- Projected velocities ---*/ - - su2double ProjVelocity_i = 0.0, ProjVelocity_j = 0.0; - - for (unsigned short iDim = 0; iDim < nDim; iDim++) { - ProjVelocity_i += Velocity_i[iDim]*UnitNormal[iDim]; - ProjVelocity_j += Velocity_j[iDim]*UnitNormal[iDim]; - } - - /*--- Compute interface speed of sound (aF) ---*/ - - su2double astarL = sqrt(2.0*(Gamma-1.0)/(Gamma+1.0)*Enthalpy_i); - su2double astarR = sqrt(2.0*(Gamma-1.0)/(Gamma+1.0)*Enthalpy_j); - - su2double ahatL = astarL*astarL/max(astarL, ProjVelocity_i); - su2double ahatR = astarR*astarR/max(astarR,-ProjVelocity_j); - - su2double aF = min(ahatL,ahatR); - - /*--- Left and right pressures and Mach numbers ---*/ - - su2double mLP, betaLP, mRM, betaRM; - - su2double mL = ProjVelocity_i/aF; - su2double mR = ProjVelocity_j/aF; - - su2double MFsq = 0.5*(mL*mL+mR*mR); - su2double param1 = max(MFsq, Minf*Minf); - su2double Mrefsq = min(1.0, param1); - - su2double fa = 2.0*sqrt(Mrefsq)-Mrefsq; - - su2double alpha = 3.0/16.0*(-4.0+5.0*fa*fa); - su2double beta = 1.0/8.0; - - if (fabs(mL) <= 1.0) { - su2double p1 = 0.25*(mL+1.0)*(mL+1.0); - su2double p2 = (mL*mL-1.0)*(mL*mL-1.0); - - mLP = p1 + beta*p2; - betaLP = p1*(2.0-mL) + alpha*mL*p2; - } - else { - mLP = 0.5*(mL+fabs(mL)); - betaLP = mLP/mL; - } - - if (fabs(mR) <= 1.0) { - su2double p1 = 0.25*(mR-1.0)*(mR-1.0); - su2double p2 = (mR*mR-1.0)*(mR*mR-1.0); - - mRM = -p1 - beta*p2; - betaRM = p1*(2.0+mR) - alpha*mR*p2; - } - else { - mRM = 0.5*(mR-fabs(mR)); - betaRM = mRM/mR; - } - - /*--- Pressure and velocity diffusion terms ---*/ - - su2double rhoF = 0.5*(Density_i+Density_j); - su2double Mp = -(Kp/fa)*max((1.0-sigma*MFsq),0.0)*(Pressure_j-Pressure_i)/(rhoF*aF*aF); - - su2double Pu = -Ku*fa*betaLP*betaRM*2.0*rhoF*aF*(ProjVelocity_j-ProjVelocity_i); - - /*--- Finally the fluxes ---*/ - - su2double mF = mLP + mRM + Mp; - mdot = aF * (max(mF,0.0)*Density_i + min(mF,0.0)*Density_j); - - pressure = betaLP*Pressure_i + betaRM*Pressure_j + Pu; - - if (!implicit || !UseAccurateJacobian) return; - - /*--- Analytical differentiation of the face mass flux and - pressure (in reverse mode, "?_b" denotes dmot_d?). ---*/ - - /*--- limited mean Mach number (used in division...) ---*/ - su2double MF = max(numeric_limits::epsilon(),sqrt(MFsq)); - - for (int outVar=0; outVar<2; ++outVar) { - - su2double aF_b = 0.0, mF_b = 0.0, MF_b = 0.0, rhoF_b = 0.0, fa_b = 0.0, alpha_b = 0.0, - rho_i_b = 0.0, rho_j_b = 0.0, p_i_b = 0.0, p_j_b = 0.0, Vn_i_b = 0.0, Vn_j_b = 0.0, - mR_b = 0.0, mL_b = 0.0, betaLP_b = 0.0, betaRM_b = 0.0, tmp = 0.0; - - if (outVar==0) { - /*--- mdot = ... ---*/ - if (mF > 0.0) { - aF_b += mF*Density_i; - mF_b += aF*Density_i; - rho_i_b += mF*aF; - } - else { - aF_b += mF*Density_j; - mF_b += aF*Density_j; - rho_j_b += mF*aF; - } - - /*--- Mp = ... ---*/ - if (sigma*MFsq < 1.0) { - rhoF_b -= Mp/rhoF * mF_b; - fa_b -= Mp/fa * mF_b; - aF_b -= 2.0*Mp/aF * mF_b; - MF_b += 2.0*sigma*MF*(Kp/fa)*(Pressure_j-Pressure_i)/(rhoF*aF*aF) * mF_b; - tmp = -(Kp/fa)*(1.0-sigma*MFsq)/(rhoF*aF*aF); - p_i_b -= tmp * mF_b; - p_j_b += tmp * mF_b; - } - - /*--- rhoF = ... ---*/ - rho_i_b += 0.5*rhoF_b; rho_j_b += 0.5*rhoF_b; - - /*--- mRM = ... ---*/ - if (fabs(mR) < 1.0) mR_b += (1.0-mR)*(0.5+4.0*beta*mR*(mR+1.0)) * mF_b; - else if (mR <=-1.0) mR_b += mF_b; - - /*--- mLP = ... ---*/ - if (fabs(mL) < 1.0) mL_b += (1.0+mL)*(0.5+4.0*beta*mL*(mL-1.0)) * mF_b; - else if (mL >= 1.0) mL_b += mF_b; - } - else { - /*--- pressure = ... ---*/ - p_i_b += betaLP; betaLP_b += Pressure_i; - p_j_b += betaRM; betaRM_b += Pressure_j; - - /*--- Pu = ... ---*/ - rhoF_b += Pu/rhoF; - fa_b += Pu/fa; - aF_b += Pu/aF; - tmp = -Ku*fa*2.0*rhoF*aF*(ProjVelocity_j-ProjVelocity_i); - betaLP_b += tmp*betaRM; - betaRM_b += tmp*betaLP; - tmp = -Ku*fa*betaLP*betaRM*2.0*rhoF*aF; - Vn_i_b -= tmp; - Vn_j_b += tmp; - - /*--- rhoF = ... ---*/ - rho_i_b += 0.5*rhoF_b; rho_j_b += 0.5*rhoF_b; - - /*--- betaRM = ... ---*/ - if (fabs(mR) < 1.0) { - tmp = mR*mR-1.0; - mR_b += tmp*(0.75-alpha*(5.0*tmp+4.0)) * betaRM_b; - alpha_b -= mR*tmp*tmp * betaRM_b; - } - - /*--- betaLP = ... ---*/ - if (fabs(mL) < 1.0) { - tmp = mL*mL-1.0; - mL_b -= tmp*(0.75-alpha*(5.0*tmp+4.0)) * betaLP_b; - alpha_b += mL*tmp*tmp * betaLP_b; - } - - /*--- alpha = ... ---*/ - fa_b += 1.875*fa * alpha_b; - } - - /*--- steps shared by both ---*/ - /*--- fa = ... ---*/ - su2double Mref_b = 2.0*(1.0-sqrt(Mrefsq)) * fa_b; - - /*--- Mrefsq = ... ---*/ - if (MF < 1.0 && MF > Minf) MF_b += Mref_b; - - /*--- MFsq = ... ---*/ - mL_b += 0.5*mL/MF * MF_b; mR_b += 0.5*mR/MF * MF_b; - - /*--- mL/R = ... ---*/ - Vn_i_b += mL_b/aF; Vn_j_b += mR_b/aF; - aF_b -= (mL*mL_b+mR*mR_b)/aF; - - /*--- aF,ahat,astar = f(H_i,H_j) ---*/ - su2double astar_b = aF_b, H_i_b, H_j_b; - - if (ahatL < ahatR) { - if (astarL <= ProjVelocity_i) { - tmp = astarL/ProjVelocity_i; - astar_b *= 2.0*tmp; - Vn_i_b -= tmp*tmp * aF_b; - } - H_i_b = sqrt(0.5*(Gamma-1.0)/((Gamma+1.0)*Enthalpy_i)) * astar_b; - H_j_b = 0.0; - } - else { - if (astarR <= -ProjVelocity_j) { - tmp = -astarR/ProjVelocity_j; - astar_b *= 2.0*tmp; - Vn_j_b += tmp*tmp * aF_b; - } - H_j_b = sqrt(0.5*(Gamma-1.0)/((Gamma+1.0)*Enthalpy_j)) * astar_b; - H_i_b = 0.0; - } - - /*--- store derivatives ---*/ - su2double *target_i = (outVar==0 ? dmdot_dVi : dpres_dVi), - *target_j = (outVar==0 ? dmdot_dVj : dpres_dVj); - target_i[5] = target_j[5] = 0.0; - - /*--- ProjVelocity = ... ---*/ - for (unsigned short iDim = 0; iDim < nDim; ++iDim) { - target_i[iDim] = UnitNormal[iDim] * Vn_i_b; - target_j[iDim] = UnitNormal[iDim] * Vn_j_b; - } - target_i[ nDim ] = p_i_b; target_j[ nDim ] = p_j_b; - target_i[nDim+1] = rho_i_b; target_j[nDim+1] = rho_j_b; - target_i[nDim+2] = H_i_b; target_j[nDim+2] = H_j_b; - } -} - -CUpwAUSMPLUSUP2_Flow::CUpwAUSMPLUSUP2_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : - CUpwAUSMPLUS_SLAU_Base_Flow(val_nDim, val_nVar, config) { - - 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) { - -} - -void CUpwAUSMPLUSUP2_Flow::ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure) { - - /*--- Projected velocities and squared magnitude ---*/ - - su2double ProjVelocity_i = 0.0, ProjVelocity_j = 0.0, sq_vel = 0.0; - - for (unsigned short iDim = 0; iDim < nDim; iDim++) { - ProjVelocity_i += Velocity_i[iDim]*UnitNormal[iDim]; - ProjVelocity_j += Velocity_j[iDim]*UnitNormal[iDim]; - - sq_vel += 0.5*(Velocity_i[iDim]*Velocity_i[iDim] + Velocity_j[iDim]*Velocity_j[iDim]); - } - - /*--- Compute interface speed of sound (aF) ---*/ - - su2double astarL = sqrt(2.0*(Gamma-1.0)/(Gamma+1.0)*Enthalpy_i); - su2double astarR = sqrt(2.0*(Gamma-1.0)/(Gamma+1.0)*Enthalpy_j); - - su2double ahatL = astarL*astarL/max(astarL, ProjVelocity_i); - su2double ahatR = astarR*astarR/max(astarR,-ProjVelocity_j); - - su2double aF = min(ahatL,ahatR); - - /*--- Left and right pressure functions and Mach numbers ---*/ - - su2double mLP, pLP, mRM, pRM; - - su2double mL = ProjVelocity_i/aF; - su2double mR = ProjVelocity_j/aF; - - su2double MFsq = 0.5*(mL*mL+mR*mR); - su2double param1 = max(MFsq, Minf*Minf); - su2double Mrefsq = min(1.0, param1); - - su2double fa = 2.0*sqrt(Mrefsq)-Mrefsq; - - su2double alpha = 3.0/16.0*(-4.0+5.0*fa*fa); - su2double beta = 1.0/8.0; - - if (fabs(mL) <= 1.0) { - su2double p1 = 0.25*(mL+1.0)*(mL+1.0); - su2double p2 = (mL*mL-1.0)*(mL*mL-1.0); - - mLP = p1 + beta*p2; - pLP = p1*(2.0-mL) + alpha*mL*p2; - } - else { - mLP = 0.5*(mL+fabs(mL)); - pLP = mLP/mL; - } - - if (fabs(mR) <= 1.0) { - su2double p1 = 0.25*(mR-1.0)*(mR-1.0); - su2double p2 = (mR*mR-1.0)*(mR*mR-1.0); - - mRM = -p1 - beta*p2; - pRM = p1*(2.0+mR) - alpha*mR*p2; - } - else { - mRM = 0.5*(mR-fabs(mR)); - pRM = mRM/mR; - } - - /*--- Mass flux with pressure diffusion term ---*/ - - su2double rhoF = 0.5*(Density_i+Density_j); - su2double Mp = -(Kp/fa)*max((1.0-sigma*MFsq),0.0)*(Pressure_j-Pressure_i)/(rhoF*aF*aF); - - su2double mF = mLP + mRM + Mp; - mdot = aF * (max(mF,0.0)*Density_i + min(mF,0.0)*Density_j); - - /*--- Modified pressure flux ---*/ - - pressure = 0.5*(Pressure_j+Pressure_i) + 0.5*(pLP-pRM)*(Pressure_i-Pressure_j) + sqrt(sq_vel)*(pLP+pRM-1.0)*rhoF*aF; - -} - -CUpwSLAU_Flow::CUpwSLAU_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, bool val_low_dissipation) : - CUpwAUSMPLUS_SLAU_Base_Flow(val_nDim, val_nVar, config) { - - slau_low_diss = val_low_dissipation; - slau2 = false; -} - -CUpwSLAU_Flow::~CUpwSLAU_Flow(void) { - -} - -void CUpwSLAU_Flow::ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure) { - - /*--- Project velocities and speed of sound ---*/ - - su2double ProjVelocity_i = 0.0, ProjVelocity_j = 0.0, sq_veli = 0.0, sq_velj = 0.0; - - for (unsigned short iDim = 0; iDim < nDim; iDim++) { - ProjVelocity_i += Velocity_i[iDim]*UnitNormal[iDim]; - ProjVelocity_j += Velocity_j[iDim]*UnitNormal[iDim]; - - sq_veli += Velocity_i[iDim]*Velocity_i[iDim]; - sq_velj += Velocity_j[iDim]*Velocity_j[iDim]; - } - - su2double Energy_i = Enthalpy_i - Pressure_i/Density_i; - SoundSpeed_i = sqrt(fabs(Gamma*Gamma_Minus_One*(Energy_i-0.5*sq_veli))); - - su2double Energy_j = Enthalpy_j - Pressure_j/Density_j; - SoundSpeed_j = sqrt(fabs(Gamma*Gamma_Minus_One*(Energy_j-0.5*sq_velj))); - - /*--- Compute interface speed of sound (aF), and left/right Mach number ---*/ - - su2double aF = 0.5 * (SoundSpeed_i + SoundSpeed_j); - su2double mL = ProjVelocity_i/aF; - su2double mR = ProjVelocity_j/aF; - - /*--- Smooth function of the local Mach number---*/ - - su2double Mach_tilde = min(1.0, (1.0/aF) * sqrt(0.5*(sq_veli+sq_velj))); - su2double Chi = pow((1.0 - Mach_tilde),2.0); - su2double f_rho = -max(min(mL,0.0),-1.0) * min(max(mR,0.0),1.0); - - /*--- Mean normal velocity with density weighting ---*/ - - su2double Vn_Mag = (Density_i*fabs(ProjVelocity_i) + Density_j*fabs(ProjVelocity_j)) / (Density_i + Density_j); - su2double Vn_MagL= (1.0 - f_rho)*Vn_Mag + f_rho*fabs(ProjVelocity_i); - su2double Vn_MagR= (1.0 - f_rho)*Vn_Mag + f_rho*fabs(ProjVelocity_j); - - /*--- Mass flux function ---*/ - - mdot = 0.5 * (Density_i*(ProjVelocity_i+Vn_MagL) + Density_j*(ProjVelocity_j-Vn_MagR) - (Chi/aF)*(Pressure_j-Pressure_i)); - - /*--- Pressure function ---*/ - - su2double BetaL, BetaR, Dissipation_ij; - - if (fabs(mL) < 1.0) BetaL = 0.25*(2.0-mL)*pow((mL+1.0),2.0); - else if (mL >= 0) BetaL = 1.0; - else BetaL = 0.0; - - if (fabs(mR) < 1.0) BetaR = 0.25*(2.0+mR)*pow((mR-1.0),2.0); - else if (mR >= 0) BetaR = 0.0; - else BetaR = 1.0; - - if (slau_low_diss) - SetRoe_Dissipation(Dissipation_i, Dissipation_j, Sensor_i, Sensor_j, Dissipation_ij, config); - else - Dissipation_ij = 1.0; - - pressure = 0.5*(Pressure_i+Pressure_j) + 0.5*(BetaL-BetaR)*(Pressure_i-Pressure_j); - - if (!slau2) pressure += Dissipation_ij*(1.0-Chi)*(BetaL+BetaR-1.0)*0.5*(Pressure_i+Pressure_j); - else pressure += Dissipation_ij*sqrt(0.5*(sq_veli+sq_velj))*(BetaL+BetaR-1.0)*aF*0.5*(Density_i+Density_j); - -} - -CUpwSLAU2_Flow::CUpwSLAU2_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, bool val_low_dissipation) : - CUpwSLAU_Flow(val_nDim, val_nVar, config, val_low_dissipation) { - - /*--- The difference between SLAU and SLAU2 is minimal, so we derive from SLAU and set this flag - so that the ComputeMassAndPressureFluxes function modifies the pressure according to SLAU2. - This is safe since this constructor is guaranteed to execute after SLAU's one. ---*/ - slau2 = true; -} - -CUpwSLAU2_Flow::~CUpwSLAU2_Flow(void) { - -} - -CUpwHLLC_Flow::CUpwHLLC_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - kappa = config->GetRoe_Kappa(); - /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ - dynamic_grid = config->GetDynamic_Grid(); - - Gamma = config->GetGamma(); - - Gamma_Minus_One = Gamma - 1.0; - - IntermediateState = new su2double [nVar]; - dSm_dU = new su2double [nVar]; - dPI_dU = new su2double [nVar]; - drhoStar_dU = new su2double [nVar]; - dpStar_dU = new su2double [nVar]; - dEStar_dU = new su2double [nVar]; - - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; - RoeVelocity = new su2double [nDim]; - -} - -CUpwHLLC_Flow::~CUpwHLLC_Flow(void) { - - delete [] IntermediateState; - delete [] dSm_dU; - delete [] dPI_dU; - delete [] drhoStar_dU; - delete [] dpStar_dU; - delete [] dEStar_dU; - - delete [] Velocity_i; - delete [] Velocity_j; - delete [] RoeVelocity; - -} - -void CUpwHLLC_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - /*--- Face area (norm or the normal vector) ---*/ - - Area = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - Area += Normal[iDim] * Normal[iDim]; - - Area = sqrt(Area); - - /*-- Unit Normal ---*/ - - for (iDim = 0; iDim < nDim; iDim++) - UnitNormal[iDim] = Normal[iDim] / Area; - - /*-- Fluid velocity at node i,j ---*/ - - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = V_i[iDim+1]; - Velocity_j[iDim] = V_j[iDim+1]; - } - - /*--- Primitive variables at point i ---*/ - - Pressure_i = V_i[nDim+1]; - Density_i = V_i[nDim+2]; - Enthalpy_i = V_i[nDim+3]; - - /*--- Primitive variables at point j ---*/ - - Pressure_j = V_j[nDim+1]; - Density_j = V_j[nDim+2]; - Enthalpy_j = V_j[nDim+3]; - - - sq_vel_i = 0.0; - sq_vel_j = 0.0; - - for (iDim = 0; iDim < nDim; iDim++) { - sq_vel_i += Velocity_i[iDim] * Velocity_i[iDim]; - sq_vel_j += Velocity_j[iDim] * Velocity_j[iDim]; - } - - Energy_i = Enthalpy_i - Pressure_i / Density_i; - Energy_j = Enthalpy_j - Pressure_j / Density_j; - - SoundSpeed_i = sqrt( (Enthalpy_i - 0.5 * sq_vel_i) * Gamma_Minus_One ); - SoundSpeed_j = sqrt( (Enthalpy_j - 0.5 * sq_vel_j) * Gamma_Minus_One ); - - /*--- Projected velocities ---*/ - - ProjVelocity_i = 0; - ProjVelocity_j = 0; - - for (iDim = 0; iDim < nDim; iDim++) { - ProjVelocity_i += Velocity_i[iDim] * UnitNormal[iDim]; - ProjVelocity_j += Velocity_j[iDim] * UnitNormal[iDim]; - } - - /*--- Projected Grid Velocity ---*/ - - ProjInterfaceVel = 0; - - if (dynamic_grid) { - - for (iDim = 0; iDim < nDim; iDim++) - ProjInterfaceVel += 0.5 * ( GridVel_i[iDim] + GridVel_j[iDim] )*UnitNormal[iDim]; - - SoundSpeed_i -= ProjInterfaceVel; - SoundSpeed_j += ProjInterfaceVel; - - ProjVelocity_i -= ProjInterfaceVel; - ProjVelocity_j -= ProjInterfaceVel; - } - - /*--- Roe's averaging ---*/ - - Rrho = ( sqrt(Density_i) + sqrt(Density_j) ); - - sq_velRoe = 0.0; - RoeProjVelocity = - ProjInterfaceVel; - - for (iDim = 0; iDim < nDim; iDim++) { - RoeVelocity[iDim] = ( Velocity_i[iDim] * sqrt(Density_i) + Velocity_j[iDim] * sqrt(Density_j) ) / Rrho; - sq_velRoe += RoeVelocity[iDim] * RoeVelocity[iDim]; - RoeProjVelocity += RoeVelocity[iDim] * UnitNormal[iDim]; - } - - /*--- Mean Roe variables iPoint and jPoint ---*/ - - RoeDensity = sqrt( Density_i * Density_j ); - RoeEnthalpy = ( sqrt(Density_j) * Enthalpy_j + sqrt(Density_i) * Enthalpy_i) / Rrho; - - /*--- Roe-averaged speed of sound ---*/ - - //RoeSoundSpeed2 = Gamma_Minus_One * ( RoeEnthalpy - 0.5 * sq_velRoe ); - RoeSoundSpeed = sqrt( Gamma_Minus_One * ( RoeEnthalpy - 0.5 * sq_velRoe ) ) - ProjInterfaceVel; - - - /*--- Speed of sound at L and R ---*/ - - sL = min( RoeProjVelocity - RoeSoundSpeed, ProjVelocity_i - SoundSpeed_i); - sR = max( RoeProjVelocity + RoeSoundSpeed, ProjVelocity_j + SoundSpeed_j); - - /*--- speed of contact surface ---*/ - - RHO = Density_j * (sR - ProjVelocity_j) - Density_i * (sL - ProjVelocity_i); - sM = ( Pressure_i - Pressure_j - Density_i * ProjVelocity_i * ( sL - ProjVelocity_i ) + Density_j * ProjVelocity_j * ( sR - ProjVelocity_j ) ) / RHO; - - /*--- Pressure at right and left (Pressure_j=Pressure_i) side of contact surface ---*/ - - pStar = Density_j * ( ProjVelocity_j - sR ) * ( ProjVelocity_j - sM ) + Pressure_j; - - -if (sM > 0.0) { - - if (sL > 0.0) { - - /*--- Compute Left Flux ---*/ - - val_residual[0] = Density_i * ProjVelocity_i; - for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = Density_i * Velocity_i[iDim] * ProjVelocity_i + Pressure_i * UnitNormal[iDim]; - val_residual[nVar-1] = Enthalpy_i * Density_i * ProjVelocity_i; - } - else { - - /*--- Compute Flux Left Star from Left Star State ---*/ - - rhoSL = ( sL - ProjVelocity_i ) / ( sL - sM ); - - IntermediateState[0] = rhoSL * Density_i; - for (iDim = 0; iDim < nDim; iDim++) - IntermediateState[iDim+1] = rhoSL * ( Density_i * Velocity_i[iDim] + ( pStar - Pressure_i ) / ( sL - ProjVelocity_i ) * UnitNormal[iDim] ) ; - IntermediateState[nVar-1] = rhoSL * ( Density_i * Energy_i - ( Pressure_i * ProjVelocity_i - pStar * sM) / ( sL - ProjVelocity_i ) ); - - - val_residual[0] = sM * IntermediateState[0]; - for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = sM * IntermediateState[iDim+1] + pStar * UnitNormal[iDim]; - val_residual[nVar-1] = sM * ( IntermediateState[nVar-1] + pStar ) + pStar * ProjInterfaceVel; - } - } - else { - - if (sR < 0.0) { - - /*--- Compute Right Flux ---*/ - - val_residual[0] = Density_j * ProjVelocity_j; - for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = Density_j * Velocity_j[iDim] * ProjVelocity_j + Pressure_j * UnitNormal[iDim]; - val_residual[nVar-1] = Enthalpy_j * Density_j * ProjVelocity_j; - } - else { - - /*--- Compute Flux Right Star from Right Star State ---*/ - - rhoSR = ( sR - ProjVelocity_j ) / ( sR - sM ); - - IntermediateState[0] = rhoSR * Density_j; - for (iDim = 0; iDim < nDim; iDim++) - IntermediateState[iDim+1] = rhoSR * ( Density_j * Velocity_j[iDim] + ( pStar - Pressure_j ) / ( sR - ProjVelocity_j ) * UnitNormal[iDim] ) ; - IntermediateState[nVar-1] = rhoSR * ( Density_j * Energy_j - ( Pressure_j * ProjVelocity_j - pStar * sM ) / ( sR - ProjVelocity_j ) ); - - - val_residual[0] = sM * IntermediateState[0]; - for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = sM * IntermediateState[iDim+1] + pStar * UnitNormal[iDim]; - val_residual[nVar-1] = sM * (IntermediateState[nVar-1] + pStar ) + pStar * ProjInterfaceVel; - } - } - - - for (iVar = 0; iVar < nVar; iVar++) - val_residual[iVar] *= Area; - - - if (implicit) { - - if (sM > 0.0) { - - if (sL > 0.0) { - - /*--- Compute Jacobian based on Left State ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_j[iVar][jVar] = 0; - - GetInviscidProjJac(Velocity_i, &Energy_i, UnitNormal, 1.0, val_Jacobian_i); - - } - else { - /*--- Compute Jacobian based on Left Star State ---*/ - - EStar = IntermediateState[nVar-1]; - Omega = 1/(sL-sM); - OmegaSM = Omega * sM; - - - /*--------- Left Jacobian ---------*/ - - - /*--- Computing pressure derivatives d/dU_L (PI) ---*/ - - dPI_dU[0] = 0.5 * Gamma_Minus_One * sq_vel_i; - for (iDim = 0; iDim < nDim; iDim++) - dPI_dU[iDim+1] = - Gamma_Minus_One * Velocity_i[iDim]; - dPI_dU[nVar-1] = Gamma_Minus_One; - - - /*--- Computing d/dU_L (Sm) ---*/ - - dSm_dU[0] = ( - ProjVelocity_i * ProjVelocity_i + sM * sL + dPI_dU[0] ) / RHO; - for (iDim = 0; iDim < nDim; iDim++) - dSm_dU[iDim+1] = ( UnitNormal[iDim] * ( 2 * ProjVelocity_i - sL - sM ) + dPI_dU[iDim+1] ) / RHO; - dSm_dU[nVar-1] = dPI_dU[nVar-1] / RHO; - - - /*--- Computing d/dU_L (rhoStar) ---*/ - - drhoStar_dU[0] = Omega * ( sL + IntermediateState[0] * dSm_dU[0] ); - for (iDim = 0; iDim < nDim; iDim++) - drhoStar_dU[iDim+1] = Omega * ( - UnitNormal[iDim] + IntermediateState[0] * dSm_dU[iDim+1] ); - drhoStar_dU[nVar-1] = Omega * IntermediateState[0] * dSm_dU[nVar-1]; - - - /*--- Computing d/dU_L (pStar) ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - dpStar_dU[iVar] = Density_i * (sR - ProjVelocity_j) * dSm_dU[iVar]; - - - /*--- Computing d/dU_L (EStar) ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); - - dEStar_dU[0] += Omega * ProjVelocity_i * ( Enthalpy_i - dPI_dU[0] ); - for (iDim = 0; iDim < nDim; iDim++) - dEStar_dU[iDim+1] += Omega * ( - UnitNormal[iDim] * Enthalpy_i - ProjVelocity_i * dPI_dU[iDim+1] ); - dEStar_dU[nVar-1] += Omega * ( sL - ProjVelocity_i - ProjVelocity_i * dPI_dU[nVar-1] ); - - - - /*--- Jacobian First Row ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[0][iVar] = sM * drhoStar_dU[iVar] + IntermediateState[0] * dSm_dU[iVar]; - - /*--- Jacobian Middle Rows ---*/ - - for (jDim = 0; jDim < nDim; jDim++) { - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[jDim+1][iVar] = ( OmegaSM + 1 ) * ( UnitNormal[jDim] * dpStar_dU[iVar] + IntermediateState[jDim+1] * dSm_dU[iVar] ); - - val_Jacobian_i[jDim+1][0] += OmegaSM * Velocity_i[jDim] * ProjVelocity_i; - - val_Jacobian_i[jDim+1][jDim+1] += OmegaSM * (sL - ProjVelocity_i); - - for (iDim = 0; iDim < nDim; iDim++) - val_Jacobian_i[jDim+1][iDim+1] -= OmegaSM * Velocity_i[jDim] * UnitNormal[iDim]; - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[jDim+1][iVar] -= OmegaSM * dPI_dU[iVar] * UnitNormal[jDim]; - } - - /*--- Jacobian Last Row ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[nVar-1][iVar] = sM * ( dEStar_dU[iVar] + dpStar_dU[iVar] ) + ( EStar + pStar ) * dSm_dU[iVar]; - - - - - /*--------- Right Jacobian ---------*/ - - - /*--- Computing d/dU_R (Sm) ---*/ - - dSm_dU[0] = ( ProjVelocity_j * ProjVelocity_j - sM * sR - 0.5 * Gamma_Minus_One * sq_vel_j ) / RHO; - for (iDim = 0; iDim < nDim; iDim++) - dSm_dU[iDim+1] = - ( UnitNormal[iDim] * ( 2 * ProjVelocity_j - sR - sM) - Gamma_Minus_One * Velocity_j[iDim] ) / RHO; - dSm_dU[nVar-1] = - Gamma_Minus_One / RHO; - - - /*--- Computing d/dU_R (pStar) ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - dpStar_dU[iVar] = Density_j * (sL - ProjVelocity_i) * dSm_dU[iVar]; - - - /*--- Computing d/dU_R (EStar) ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); - - - - /*--- Jacobian First Row ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[0][iVar] = IntermediateState[0] * ( OmegaSM + 1 ) * dSm_dU[iVar]; - - /*--- Jacobian Middle Rows ---*/ - - for (iDim = 0; iDim < nDim; iDim++) { - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[iDim+1][iVar] = ( OmegaSM + 1 ) * ( IntermediateState[iDim+1] * dSm_dU[iVar] + UnitNormal[iDim] * dpStar_dU[iVar] ); - } - - /*--- Jacobian Last Row ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[nVar-1][iVar] = sM * (dEStar_dU[iVar] + dpStar_dU[iVar]) + (EStar + pStar) * dSm_dU[iVar]; - } - } - else { - if (sR < 0.0) { - - /*--- Compute Jacobian based on Right State ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_i[iVar][jVar] = 0; - - GetInviscidProjJac(Velocity_j, &Energy_j, UnitNormal, 1.0, val_Jacobian_j); - - } - else { - /*--- Compute Jacobian based on Right Star State ---*/ - - EStar = IntermediateState[nVar-1]; - Omega = 1/(sR-sM); - OmegaSM = Omega * sM; - - - /*--------- Left Jacobian ---------*/ - - - /*--- Computing d/dU_L (Sm) ---*/ - - dSm_dU[0] = ( - ProjVelocity_i * ProjVelocity_i + sM * sL + 0.5 * Gamma_Minus_One * sq_vel_i ) / RHO; - for (iDim = 0; iDim < nDim; iDim++) - dSm_dU[iDim+1] = ( UnitNormal[iDim] * ( 2 * ProjVelocity_i - sL - sM ) - Gamma_Minus_One * Velocity_i[iDim] ) / RHO; - dSm_dU[nVar-1] = Gamma_Minus_One / RHO; - - - /*--- Computing d/dU_L (pStar) ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - dpStar_dU[iVar] = Density_i * (sR - ProjVelocity_j) * dSm_dU[iVar]; - - - /*--- Computing d/dU_L (EStar) ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); - - - - /*--- Jacobian First Row ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[0][iVar] = IntermediateState[0] * ( OmegaSM + 1 ) * dSm_dU[iVar]; - - /*--- Jacobian Middle Rows ---*/ - - for (iDim = 0; iDim < nDim; iDim++) { - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[iDim+1][iVar] = (OmegaSM + 1) * ( IntermediateState[iDim+1] * dSm_dU[iVar] + UnitNormal[iDim] * dpStar_dU[iVar] ); - } - - /*--- Jacobian Last Row ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[nVar-1][iVar] = sM * (dEStar_dU[iVar] + dpStar_dU[iVar]) + (EStar + pStar) * dSm_dU[iVar]; - - - - /*--------- Right Jacobian ---------*/ - - - /*--- Computing pressure derivatives d/dU_R (PI) ---*/ - - dPI_dU[0] = 0.5 * Gamma_Minus_One * sq_vel_j; - for (iDim = 0; iDim < nDim; iDim++) - dPI_dU[iDim+1] = - Gamma_Minus_One * Velocity_j[iDim]; - dPI_dU[nVar-1] = Gamma_Minus_One; - - - - /*--- Computing d/dU_R (Sm) ---*/ - - dSm_dU[0] = - ( - ProjVelocity_j * ProjVelocity_j + sM * sR + dPI_dU[0] ) / RHO; - for (iDim = 0; iDim < nDim; iDim++) - dSm_dU[iDim+1] = - ( UnitNormal[iDim] * ( 2 * ProjVelocity_j - sR - sM) + dPI_dU[iDim+1] ) / RHO; - dSm_dU[nVar-1] = - dPI_dU[nVar-1] / RHO; - - - /*--- Computing d/dU_R (pStar) ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - dpStar_dU[iVar] = Density_j * (sL - ProjVelocity_i) * dSm_dU[iVar]; - - - /*--- Computing d/dU_R (rhoStar) ---*/ - - drhoStar_dU[0] = Omega * ( sR + IntermediateState[0] * dSm_dU[0] ); - for (iDim = 0; iDim < nDim; iDim++) - drhoStar_dU[iDim+1] = Omega * ( - UnitNormal[iDim] + IntermediateState[0] * dSm_dU[iDim+1] ); - drhoStar_dU[nVar-1] = Omega * IntermediateState[0] * dSm_dU[nVar-1]; - - - /*--- Computing d/dU_R (EStar) ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); - - dEStar_dU[0] += Omega * ProjVelocity_j * ( Enthalpy_j - dPI_dU[0] ); - for (iDim = 0; iDim < nDim; iDim++) - dEStar_dU[iDim+1] += Omega * ( - UnitNormal[iDim] * Enthalpy_j - ProjVelocity_j * dPI_dU[iDim+1] ); - dEStar_dU[nVar-1] += Omega * ( sR - ProjVelocity_j - ProjVelocity_j * dPI_dU[nVar-1] ); - - - - /*--- Jacobian First Row ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[0][iVar] = sM * drhoStar_dU[iVar] + IntermediateState[0] * dSm_dU[iVar]; - - /*--- Jacobian Middle Rows ---*/ - - for (jDim = 0; jDim < nDim; jDim++) { - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[jDim+1][iVar] = ( OmegaSM + 1 ) * ( UnitNormal[jDim] * dpStar_dU[iVar] + IntermediateState[jDim+1] * dSm_dU[iVar] ); - - val_Jacobian_j[jDim+1][0] += OmegaSM * Velocity_j[jDim] * ProjVelocity_j; - - val_Jacobian_j[jDim+1][jDim+1] += OmegaSM * (sR - ProjVelocity_j); - - for (iDim = 0; iDim < nDim; iDim++) - val_Jacobian_j[jDim+1][iDim+1] -= OmegaSM * Velocity_j[jDim] * UnitNormal[iDim]; - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[jDim+1][iVar] -= OmegaSM * dPI_dU[iVar] * UnitNormal[jDim]; - } - - /*--- Jacobian Last Row ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[nVar-1][iVar] = sM * ( dEStar_dU[iVar] + dpStar_dU[iVar] ) + ( EStar + pStar ) * dSm_dU[iVar]; - - } - } - - - /*--- Jacobians of the inviscid flux, scale = k because val_residual ~ 0.5*(fc_i+fc_j)*Normal ---*/ - - Area *= kappa; - - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - val_Jacobian_i[iVar][jVar] *= Area; - val_Jacobian_j[iVar][jVar] *= Area; - } - } -} - -} - -CUpwGeneralHLLC_Flow::CUpwGeneralHLLC_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - kappa = config->GetRoe_Kappa(); - /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ - dynamic_grid = config->GetDynamic_Grid(); - - Gamma = config->GetGamma(); - - IntermediateState = new su2double [nVar]; - dSm_dU = new su2double [nVar]; - dPI_dU = new su2double [nVar]; - drhoStar_dU = new su2double [nVar]; - dpStar_dU = new su2double [nVar]; - dEStar_dU = new su2double [nVar]; - - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; - RoeVelocity = new su2double [nDim]; - -} - -CUpwGeneralHLLC_Flow::~CUpwGeneralHLLC_Flow(void) { - - delete [] IntermediateState; - delete [] dSm_dU; - delete [] dPI_dU; - delete [] drhoStar_dU; - delete [] dpStar_dU; - delete [] dEStar_dU; - - delete [] Velocity_i; - delete [] Velocity_j; - delete [] RoeVelocity; - -} - -void CUpwGeneralHLLC_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - /*--- Face area (norm or the normal vector) ---*/ - - Area = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - Area += Normal[iDim] * Normal[iDim]; - - Area = sqrt(Area); - - /*-- Unit Normal ---*/ - - for (iDim = 0; iDim < nDim; iDim++) - UnitNormal[iDim] = Normal[iDim] / Area; - - /*-- Fluid velocity at node i,j ---*/ - - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = V_i[iDim+1]; - Velocity_j[iDim] = V_j[iDim+1]; - } - - /*--- Primitive variables at point i ---*/ - - Pressure_i = V_i[nDim+1]; - Density_i = V_i[nDim+2]; - Enthalpy_i = V_i[nDim+3]; - - /*--- Primitive variables at point j ---*/ - - Pressure_j = V_j[nDim+1]; - Density_j = V_j[nDim+2]; - Enthalpy_j = V_j[nDim+3]; - - - sq_vel_i = 0.0; - sq_vel_j = 0.0; - - for (iDim = 0; iDim < nDim; iDim++) { - sq_vel_i += Velocity_i[iDim] * Velocity_i[iDim]; - sq_vel_j += Velocity_j[iDim] * Velocity_j[iDim]; - } - - Energy_i = Enthalpy_i - Pressure_i / Density_i; - StaticEnthalpy_i = Enthalpy_i - 0.5 * sq_vel_i; - StaticEnergy_i = Energy_i - 0.5 * sq_vel_i; - - Kappa_i = S_i[1] / Density_i; - Chi_i = S_i[0] - Kappa_i * StaticEnergy_i; - SoundSpeed_i = sqrt(Chi_i + StaticEnthalpy_i * Kappa_i); - - - Energy_j = Enthalpy_j - Pressure_j / Density_j; - StaticEnthalpy_j = Enthalpy_j - 0.5 * sq_vel_j; - StaticEnergy_j = Energy_j - 0.5 * sq_vel_j; - - Kappa_j = S_j[1] / Density_j; - Chi_j = S_j[0] - Kappa_j * StaticEnergy_j; - SoundSpeed_j = sqrt(Chi_j + StaticEnthalpy_j * Kappa_j); - - /*--- Projected velocities ---*/ - - ProjVelocity_i = 0.0; - ProjVelocity_j = 0.0; - - for (iDim = 0; iDim < nDim; iDim++) { - ProjVelocity_i += Velocity_i[iDim] * UnitNormal[iDim]; - ProjVelocity_j += Velocity_j[iDim] * UnitNormal[iDim]; - } - - - /*--- Projected Grid Velocity ---*/ - - ProjInterfaceVel = 0; - - if (dynamic_grid) { - - for (iDim = 0; iDim < nDim; iDim++) - ProjInterfaceVel += 0.5 * ( GridVel_i[iDim] + GridVel_j[iDim] )*UnitNormal[iDim]; - - SoundSpeed_i -= ProjInterfaceVel; - SoundSpeed_j += ProjInterfaceVel; - - ProjVelocity_i -= ProjInterfaceVel; - ProjVelocity_j -= ProjInterfaceVel; - } - - /*--- Roe's averaging ---*/ - - Rrho = ( sqrt(Density_i) + sqrt(Density_j) ); - - sq_velRoe = 0.0; - RoeProjVelocity = - ProjInterfaceVel; - - for (iDim = 0; iDim < nDim; iDim++) { - RoeVelocity[iDim] = ( Velocity_i[iDim] * sqrt(Density_i) + Velocity_j[iDim] * sqrt(Density_j) ) / Rrho; - sq_velRoe += RoeVelocity[iDim] * RoeVelocity[iDim]; - RoeProjVelocity += RoeVelocity[iDim] * UnitNormal[iDim]; - } - - /*--- Mean Roe variables iPoint and jPoint ---*/ - - RoeKappa = 0.5 * ( Kappa_i + Kappa_j ); - RoeChi = 0.5 * ( Chi_i + Chi_j ); - RoeDensity = sqrt( Density_i * Density_j ); - RoeEnthalpy = ( sqrt(Density_j) * Enthalpy_j + sqrt(Density_i) * Enthalpy_i) / Rrho; - - VinokurMontagne(); - - /*--- Roe-averaged speed of sound ---*/ - - //RoeSoundSpeed2 = RoeChi + RoeKappa * ( RoeEnthalpy - 0.5 * sq_velRoe ); - RoeSoundSpeed = sqrt( RoeChi + RoeKappa * ( RoeEnthalpy - 0.5 * sq_velRoe ) ) - ProjInterfaceVel; - - /*--- Speed of sound at L and R ---*/ - - sL = min( RoeProjVelocity - RoeSoundSpeed, ProjVelocity_i - SoundSpeed_i ); - sR = max( RoeProjVelocity + RoeSoundSpeed, ProjVelocity_j + SoundSpeed_j ); - - /*--- speed of contact surface ---*/ - - RHO = Density_j * (sR - ProjVelocity_j) - Density_i * (sL - ProjVelocity_i); - sM = ( Pressure_i - Pressure_j - Density_i * ProjVelocity_i * ( sL - ProjVelocity_i ) + Density_j * ProjVelocity_j * ( sR - ProjVelocity_j ) ) / RHO; - - /*--- Pressure at right and left (Pressure_j=Pressure_i) side of contact surface ---*/ - - pStar = Density_j * ( ProjVelocity_j - sR ) * ( ProjVelocity_j - sM ) + Pressure_j; - - -if (sM > 0.0) { - - if (sL > 0.0) { - - /*--- Compute Left Flux ---*/ - - val_residual[0] = Density_i * ProjVelocity_i; - for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = Density_i * Velocity_i[iDim] * ProjVelocity_i + Pressure_i * UnitNormal[iDim]; - val_residual[nVar-1] = Enthalpy_i * Density_i * ProjVelocity_i; - } - else { - - /*--- Compute Flux Left Star from Left Star State ---*/ - - rhoSL = ( sL - ProjVelocity_i ) / ( sL - sM ); - - IntermediateState[0] = rhoSL * Density_i; - for (iDim = 0; iDim < nDim; iDim++) - IntermediateState[iDim+1] = rhoSL * ( Density_i * Velocity_i[iDim] + ( pStar - Pressure_i ) / ( sL - ProjVelocity_i ) * UnitNormal[iDim] ) ; - IntermediateState[nVar-1] = rhoSL * ( Density_i * Energy_i - ( Pressure_i * ProjVelocity_i - pStar * sM) / ( sL - ProjVelocity_i ) ); - - - val_residual[0] = sM * IntermediateState[0]; - for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = sM * IntermediateState[iDim+1] + pStar * UnitNormal[iDim]; - val_residual[nVar-1] = sM * ( IntermediateState[nVar-1] + pStar ) + pStar * ProjInterfaceVel; - } - } - else { - - if (sR < 0.0) { - - /*--- Compute Right Flux ---*/ - - val_residual[0] = Density_j * ProjVelocity_j; - for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = Density_j * Velocity_j[iDim] * ProjVelocity_j + Pressure_j * UnitNormal[iDim]; - val_residual[nVar-1] = Enthalpy_j * Density_j * ProjVelocity_j; - } - else { - - /*--- Compute Flux Right Star from Right Star State ---*/ - - rhoSR = ( sR - ProjVelocity_j ) / ( sR - sM ); - - IntermediateState[0] = rhoSR * Density_j; - for (iDim = 0; iDim < nDim; iDim++) - IntermediateState[iDim+1] = rhoSR * ( Density_j * Velocity_j[iDim] + ( pStar - Pressure_j ) / ( sR - ProjVelocity_j ) * UnitNormal[iDim] ) ; - IntermediateState[nVar-1] = rhoSR * ( Density_j * Energy_j - ( Pressure_j * ProjVelocity_j - pStar * sM ) / ( sR - ProjVelocity_j ) ); - - - val_residual[0] = sM * IntermediateState[0]; - for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = sM * IntermediateState[iDim+1] + pStar * UnitNormal[iDim]; - val_residual[nVar-1] = sM * (IntermediateState[nVar-1] + pStar ) + pStar * ProjInterfaceVel; - } - } - - for (iVar = 0; iVar < nVar; iVar++) - val_residual[iVar] *= Area; - - - if (implicit) { - - if (sM > 0.0) { - - if (sL > 0.0) { - - /*--- Compute Jacobian based on Left State ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_j[iVar][jVar] = 0; - - - GetInviscidProjJac(Velocity_i, &Enthalpy_i, &Chi_i, &Kappa_i, UnitNormal, 1.0, val_Jacobian_i); - - } - else { - /*--- Compute Jacobian based on Left Star State ---*/ - - EStar = IntermediateState[nVar-1]; - Omega = 1/(sL-sM); - OmegaSM = Omega * sM; - - - /*--------- Left Jacobian ---------*/ - - - /*--- Computing pressure derivatives d/dU_L (PI) ---*/ - - dPI_dU[0] = Chi_i - 0.5 * Kappa_i * sq_vel_i; - for (iDim = 0; iDim < nDim; iDim++) - dPI_dU[iDim+1] = - Kappa_i * Velocity_i[iDim]; - dPI_dU[nVar-1] = Kappa_i; - - - /*--- Computing d/dU_L (Sm) ---*/ - - dSm_dU[0] = ( - ProjVelocity_i * ProjVelocity_i + sM * sL + dPI_dU[0] ) / RHO; - for (iDim = 0; iDim < nDim; iDim++) - dSm_dU[iDim+1] = ( UnitNormal[iDim] * ( 2 * ProjVelocity_i - sL - sM ) + dPI_dU[iDim+1] ) / RHO; - dSm_dU[nVar-1] = dPI_dU[nVar-1] / RHO; - - - /*--- Computing d/dU_L (rhoStar) ---*/ - - drhoStar_dU[0] = Omega * ( sL + IntermediateState[0] * dSm_dU[0] ); - for (iDim = 0; iDim < nDim; iDim++) - drhoStar_dU[iDim+1] = Omega * ( - UnitNormal[iDim] + IntermediateState[0] * dSm_dU[iDim+1] ); - drhoStar_dU[nVar-1] = Omega * IntermediateState[0] * dSm_dU[nVar-1]; - - - /*--- Computing d/dU_L (pStar) ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - dpStar_dU[iVar] = Density_i * (sR - ProjVelocity_j) * dSm_dU[iVar]; - - - /*--- Computing d/dU_L (EStar) ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); - - dEStar_dU[0] += Omega * ProjVelocity_i * ( Enthalpy_i - dPI_dU[0] ); - for (iDim = 0; iDim < nDim; iDim++) - dEStar_dU[iDim+1] += Omega * ( - UnitNormal[iDim] * Enthalpy_i - ProjVelocity_i * dPI_dU[iDim+1] ); - dEStar_dU[nVar-1] += Omega * ( sL - ProjVelocity_i - ProjVelocity_i * dPI_dU[nVar-1] ); - - - - /*--- Jacobian First Row ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[0][iVar] = sM * drhoStar_dU[iVar] + IntermediateState[0] * dSm_dU[iVar]; - - /*--- Jacobian Middle Rows ---*/ - - for (jDim = 0; jDim < nDim; jDim++) { - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[jDim+1][iVar] = ( OmegaSM + 1 ) * ( UnitNormal[jDim] * dpStar_dU[iVar] + IntermediateState[jDim+1] * dSm_dU[iVar] ); - - val_Jacobian_i[jDim+1][0] += OmegaSM * Velocity_i[jDim] * ProjVelocity_i; - - val_Jacobian_i[jDim+1][jDim+1] += OmegaSM * (sL - ProjVelocity_i); - - for (iDim = 0; iDim < nDim; iDim++) - val_Jacobian_i[jDim+1][iDim+1] -= OmegaSM * Velocity_i[jDim] * UnitNormal[iDim]; - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[jDim+1][iVar] -= OmegaSM * dPI_dU[iVar] * UnitNormal[jDim]; - } - - /*--- Jacobian Last Row ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[nVar-1][iVar] = sM * ( dEStar_dU[iVar] + dpStar_dU[iVar] ) + ( EStar + pStar ) * dSm_dU[iVar]; - - - - - /*--------- Right Jacobian ---------*/ - - - /*--- Computing pressure derivatives d/dU_R (PI) ---*/ - - dPI_dU[0] = Chi_j - 0.5 * Kappa_j * sq_vel_j; - for (iDim = 0; iDim < nDim; iDim++) - dPI_dU[iDim+1] = - Kappa_j * Velocity_j[iDim]; - dPI_dU[nVar-1] = Kappa_j; - - - /*--- Computing d/dU_R (Sm) ---*/ - - dSm_dU[0] = ( ProjVelocity_j * ProjVelocity_j - sM * sR - dPI_dU[0] ) / RHO; - for (iDim = 0; iDim < nDim; iDim++) - dSm_dU[iDim+1] = - ( UnitNormal[iDim] * ( 2 * ProjVelocity_j - sR - sM) + dPI_dU[iDim+1] ) / RHO; - dSm_dU[nVar-1] = - dPI_dU[nVar-1] / RHO; - - - /*--- Computing d/dU_R (pStar) ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - dpStar_dU[iVar] = Density_j * (sL - ProjVelocity_i) * dSm_dU[iVar]; - - - /*--- Computing d/dU_R (EStar) ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); - - - - /*--- Jacobian First Row ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[0][iVar] = IntermediateState[0] * ( OmegaSM + 1 ) * dSm_dU[iVar]; - - /*--- Jacobian Middle Rows ---*/ - - for (iDim = 0; iDim < nDim; iDim++) { - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[iDim+1][iVar] = ( OmegaSM + 1 ) * ( IntermediateState[iDim+1] * dSm_dU[iVar] + UnitNormal[iDim] * dpStar_dU[iVar] ); - } - - /*--- Jacobian Last Row ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[nVar-1][iVar] = sM * (dEStar_dU[iVar] + dpStar_dU[iVar]) + (EStar + pStar) * dSm_dU[iVar]; - } - } - else { - if (sR < 0.0) { - - /*--- Compute Jacobian based on Right State ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_i[iVar][jVar] = 0; - - GetInviscidProjJac(Velocity_j, &Enthalpy_j, &Chi_j, &Kappa_j, UnitNormal, 1.0, val_Jacobian_j); - - } - else { - /*--- Compute Jacobian based on Right Star State ---*/ - - EStar = IntermediateState[nVar-1]; - Omega = 1/(sR-sM); - OmegaSM = Omega * sM; - - - /*--------- Left Jacobian ---------*/ - - - /*--- Computing pressure derivatives d/dU_L (PI) ---*/ - - dPI_dU[0] = Chi_i - 0.5 * Kappa_i * sq_vel_i; - for (iDim = 0; iDim < nDim; iDim++) - dPI_dU[iDim+1] = - Kappa_i * Velocity_i[iDim]; - dPI_dU[nVar-1] = Kappa_i; - - - /*--- Computing d/dU_L (Sm) ---*/ - - dSm_dU[0] = ( - ProjVelocity_i * ProjVelocity_i + sM * sL + dPI_dU[0] ) / RHO; - for (iDim = 0; iDim < nDim; iDim++) - dSm_dU[iDim+1] = ( UnitNormal[iDim] * ( 2 * ProjVelocity_i - sL - sM ) + dPI_dU[iDim+1] ) / RHO; - dSm_dU[nVar-1] = dPI_dU[nVar-1] / RHO; - - - /*--- Computing d/dU_L (pStar) ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - dpStar_dU[iVar] = Density_i * (sR - ProjVelocity_j) * dSm_dU[iVar]; - - - /*--- Computing d/dU_L (EStar) ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); - - - - /*--- Jacobian First Row ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[0][iVar] = IntermediateState[0] * ( OmegaSM + 1 ) * dSm_dU[iVar]; - - /*--- Jacobian Middle Rows ---*/ - - for (iDim = 0; iDim < nDim; iDim++) { - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[iDim+1][iVar] = (OmegaSM + 1) * ( IntermediateState[iDim+1] * dSm_dU[iVar] + UnitNormal[iDim] * dpStar_dU[iVar] ); - } - - /*--- Jacobian Last Row ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[nVar-1][iVar] = sM * (dEStar_dU[iVar] + dpStar_dU[iVar]) + (EStar + pStar) * dSm_dU[iVar]; - - - - /*--------- Right Jacobian ---------*/ - - - /*--- Computing pressure derivatives d/dU_R (PI) ---*/ - - dPI_dU[0] = Chi_j - 0.5 * Kappa_j * sq_vel_j; - for (iDim = 0; iDim < nDim; iDim++) - dPI_dU[iDim+1] = - Kappa_j * Velocity_j[iDim]; - dPI_dU[nVar-1] = Kappa_j; - - - /*--- Computing d/dU_R (Sm) ---*/ - - dSm_dU[0] = - ( - ProjVelocity_j * ProjVelocity_j + sM * sR + dPI_dU[0] ) / RHO; - for (iDim = 0; iDim < nDim; iDim++) - dSm_dU[iDim+1] = - ( UnitNormal[iDim] * ( 2 * ProjVelocity_j - sR - sM) + dPI_dU[iDim+1] ) / RHO; - dSm_dU[nVar-1] = - dPI_dU[nVar-1] / RHO; - - - /*--- Computing d/dU_R (pStar) ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - dpStar_dU[iVar] = Density_j * (sL - ProjVelocity_i) * dSm_dU[iVar]; - - - /*--- Computing d/dU_R (rhoStar) ---*/ - - drhoStar_dU[0] = Omega * ( sR + IntermediateState[0] * dSm_dU[0] ); - for (iDim = 0; iDim < nDim; iDim++) - drhoStar_dU[iDim+1] = Omega * ( - UnitNormal[iDim] + IntermediateState[0] * dSm_dU[iDim+1] ); - drhoStar_dU[nVar-1] = Omega * IntermediateState[0] * dSm_dU[nVar-1]; - - - /*--- Computing d/dU_R (EStar) ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); - - dEStar_dU[0] += Omega * ProjVelocity_j * ( Enthalpy_j - dPI_dU[0] ); - for (iDim = 0; iDim < nDim; iDim++) - dEStar_dU[iDim+1] += Omega * ( - UnitNormal[iDim] * Enthalpy_j - ProjVelocity_j * dPI_dU[iDim+1] ); - dEStar_dU[nVar-1] += Omega * ( sR - ProjVelocity_j - ProjVelocity_j * dPI_dU[nVar-1] ); - - - - /*--- Jacobian First Row ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[0][iVar] = sM * drhoStar_dU[iVar] + IntermediateState[0] * dSm_dU[iVar]; - - /*--- Jacobian Middle Rows ---*/ - - for (jDim = 0; jDim < nDim; jDim++) { - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[jDim+1][iVar] = ( OmegaSM + 1 ) * ( UnitNormal[jDim] * dpStar_dU[iVar] + IntermediateState[jDim+1] * dSm_dU[iVar] ); - - val_Jacobian_j[jDim+1][0] += OmegaSM * Velocity_j[jDim] * ProjVelocity_j; - - val_Jacobian_j[jDim+1][jDim+1] += OmegaSM * (sR - ProjVelocity_j); - - for (iDim = 0; iDim < nDim; iDim++) - val_Jacobian_j[jDim+1][iDim+1] -= OmegaSM * Velocity_j[jDim] * UnitNormal[iDim]; - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[jDim+1][iVar] -= OmegaSM * dPI_dU[iVar] * UnitNormal[jDim]; - } - - /*--- Jacobian Last Row ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[nVar-1][iVar] = sM * ( dEStar_dU[iVar] + dpStar_dU[iVar] ) + ( EStar + pStar ) * dSm_dU[iVar]; - } - } - - - /*--- Jacobians of the inviscid flux, scale = kappa because val_residual ~ 0.5*(fc_i+fc_j)*Normal ---*/ - - Area *= kappa; - - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - val_Jacobian_i[iVar][jVar] *= Area; - val_Jacobian_j[iVar][jVar] *= Area; - } - } - - } - -} - -void CUpwGeneralHLLC_Flow::VinokurMontagne() { - - su2double delta_rhoStaticEnergy, delta_rho, delta_p, err_P, s, D; - - delta_rho = Density_j - Density_i; - delta_p = Pressure_j - Pressure_i; - - RoeKappaStaticEnthalpy = 0.5 * ( StaticEnthalpy_i * Kappa_i + StaticEnthalpy_j * Kappa_j ); - - s = RoeChi + RoeKappaStaticEnthalpy; - - D = s*s * delta_rho * delta_rho + delta_p * delta_p; - - delta_rhoStaticEnergy = Density_j * StaticEnergy_j - Density_i * StaticEnergy_i; - - err_P = delta_p - RoeChi * delta_rho - RoeKappa * delta_rhoStaticEnergy; - - if (abs((D - delta_p*err_P)/Density_i) > 1e-3 && abs(delta_rho/Density_i) > 1e-3 && s/Density_i > 1e-3) { - - RoeKappa = ( D * RoeKappa ) / ( D - delta_p * err_P ); - RoeChi = ( D * RoeChi+ s*s * delta_rho * err_P ) / ( D - delta_p * err_P ); - - } -} - -#ifdef CHECK - -int UgpWithCvCompFlow::calcEulerFluxMatrices_HLLC(su2double (*val_Jacobian_i)[5], su2double (*val_Jacobian_j)[5], su2double (*val_Jacobian_i_Scal)[6], su2double (*val_Jacobian_j_Scal)[6], - const su2double Density_i, const su2double *uL, const su2double pL, const su2double TL, const su2double h0, const su2double RL, const su2double gammaL, const su2double *scalL, const su2double kL, - const su2double Density_j, const su2double *uR, const su2double pR, const su2double TR, const su2double h1, const su2double RR, const su2double gammaR, const su2double *scalR, const su2double kR, - const su2double area, const su2double *nVec, const int nScal, const su2double surfVeloc) -{ - - su2double unL = vecDotVec3d(uL, nVec); - su2double uLuL = vecDotVec3d(uL, uL); - su2double cL = sqrt(gammaL*pL/Density_i); - su2double hL = gammaL/(gammaL-1.0)*pL/Density_i + 0.5*uLuL + kL; - // su2double hL = h0 + 0.5*uLuL + kL; - su2double eL = hL*Density_i-pL; - - su2double unR = vecDotVec3d(uR, nVec); - su2double uRuR = vecDotVec3d(uR, uR); - su2double cR = sqrt(gammaR*pR/Density_j); - su2double hR = gammaR/(gammaR-1.0)*pR/Density_j + 0.5*uRuR + kR; - // su2double hR = h1 + 0.5*uRuR + kR; - su2double eR = hR*Density_j-pR; - - - // Roe's aveaging - su2double Rrho = sqrt(Density_j/Density_i); - su2double tmp = 1.0/(1.0+Rrho); - su2double velRoe[3]; - for (int i=0; i<3; i++) - velRoe[i] = tmp*(uL[i] + uR[i]*Rrho); - su2double uRoe = vecDotVec3d(velRoe, nVec); - su2double hRoe = tmp*(hL + hR*Rrho); - - // su2double cRoe = sqrt((gammaL-1.0)*(hRoe- 0.5*vecDotVec3d(velRoe, velRoe))); - su2double gamPdivRho = tmp*((gammaL*pL/Density_i+0.5*(gammaL-1.0)*uLuL) + (gammaR*pR/Density_j+0.5*(gammaR-1.0)*uRuR)*Rrho); - su2double cRoe = sqrt(gamPdivRho - ((gammaL+gammaR)*0.5-1.0)*0.5*vecDotVec3d(velRoe, velRoe)); - - // speed of sound at L and R - su2double sL = min(uRoe-cRoe, unL-cL); - su2double sR = max(uRoe+cRoe, unR+cR); - - // speed of contact surface - su2double sM = (pL-pR-Density_i*unL*(sL-unL)+Density_j*unR*(sR-unR))/(Density_j*(sR-unR)-Density_i*(sL-unL)); - - // pressure at right and left (pR=pL) side of contact surface - su2double pStar = Density_j*(unR-sR)*(unR-sM)+pR; - - if (sM >= 0.0) { - - if (sL > 0.0) { - - su2double nVecArea[3]; - for (int i=0; i<3; i++) nVecArea[i] = nVec[i]*area; - - calcJacobianA(val_Jacobian_i, uL, pL, Density_i, nVecArea, 0.5*(gammaL+gammaR), 0.0); - - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_j[i][j] = 0.0; - - } - else { - - su2double invSLmSs = 1.0/(sL-sM); - su2double sLmuL = sL-unL; - su2double rhoSL = Density_i*sLmuL*invSLmSs; - su2double rhouSL[3]; - - for (int i=0; i<3; i++) - rhouSL[i] = (Density_i*uL[i]*sLmuL+(pStar-pL)*nVec[i])*invSLmSs; - - su2double eSL = (sLmuL*eL-pL*unL+pStar*sM)*invSLmSs; - su2double gammaLM1 = (gammaL-1.0); - su2double gammaRM1 = (gammaR-1.0); - su2double invrhotld = 1.0/(Density_j*(sR-unR)-Density_i*(sL-unL)); - - su2double dSMdUL[5], dSMdUR[5]; - su2double dpsdUL[5], dpsdUR[5]; - - dSMdUL[0] = -unL*unL + uLuL*gammaLM1/2.0 + sM*sL; - dSMdUL[1] = nVec[0]*(2.0*unL-sL-sM) - gammaLM1*uL[0]; - dSMdUL[2] = nVec[1]*(2.0*unL-sL-sM) - gammaLM1*uL[1]; - dSMdUL[3] = nVec[2]*(2.0*unL-sL-sM) - gammaLM1*uL[2]; - dSMdUL[4] = gammaLM1; - - for (iVar = 0; iVar < nVar; iVar++) - { - dSMdUL[i] *= invrhotld; - dpsdUL[i] = Density_j*(sR-unR)*dSMdUL[i]; - } - - dSMdUR[0] = unR*unR - uRuR*gammaRM1/2.0 - sM*sR; - dSMdUR[1] = -nVec[0]*(2.0*unR-sR-sM) + gammaRM1*uR[0]; - dSMdUR[2] = -nVec[1]*(2.0*unR-sR-sM) + gammaRM1*uR[1]; - dSMdUR[3] = -nVec[2]*(2.0*unR-sR-sM) + gammaRM1*uR[2]; - dSMdUR[4] = -gammaRM1; - - for (iVar = 0; iVar < nVar; iVar++) - { - dSMdUR[i] *= invrhotld; - dpsdUR[i] = Density_i*(sL-unL)*dSMdUR[i]; - } - - calcSubSonicJacobeanHLLC(val_Jacobian_i, val_Jacobian_j, - Density_i, uL, pL, eL, unL, uLuL, sL, - rhoSL, rhouSL, eSL, dSMdUL, - dSMdUR, dpsdUL, dpsdUR, sM, pStar, 0.5*(gammaL+gammaR), nVec); - - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[0][i] = val_Jacobian_i[0][i]*sM + dSMdUL[i]*rhoSL; - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[1][i] = val_Jacobian_i[1][i]*sM + dSMdUL[i]*rhouSL[0] + dpsdUL[i]*nVec[0]; - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[2][i] = val_Jacobian_i[2][i]*sM + dSMdUL[i]*rhouSL[1] + dpsdUL[i]*nVec[1]; - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[3][i] = val_Jacobian_i[3][i]*sM + dSMdUL[i]*rhouSL[2] + dpsdUL[i]*nVec[2]; - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[4][i] = (val_Jacobian_i[4][i]+dpsdUL[i])*sM + (eSL+pStar)*dSMdUL[i]; - - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_i[i][j] *= area; - - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[0][i] = val_Jacobian_j[0][i]*sM + dSMdUR[i]*rhoSL; - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[1][i] = val_Jacobian_j[1][i]*sM + dSMdUR[i]*rhouSL[0] + dpsdUR[i]*nVec[0]; - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[2][i] = val_Jacobian_j[2][i]*sM + dSMdUR[i]*rhouSL[1] + dpsdUR[i]*nVec[1]; - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[3][i] = val_Jacobian_j[3][i]*sM + dSMdUR[i]*rhouSL[2] + dpsdUR[i]*nVec[2]; - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[4][i] = (val_Jacobian_j[4][i]+dpsdUR[i])*sM + (eSL+pStar)*dSMdUR[i]; - - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_j[i][j] *= area; - - } - } - - else { - - if (sR >= 0.0) { - - su2double invSRmSs = 1.0/(sR-sM); - su2double sRmuR = sR-unR; - su2double rhoSR = Density_j*sRmuR*invSRmSs; - su2double rhouSR[3]; - for (int i=0; i<3; i++) - rhouSR[i] = (Density_j*uR[i]*sRmuR+(pStar-pR)*nVec[i])*invSRmSs; - su2double eSR = (sRmuR*eR-pR*unR+pStar*sM)*invSRmSs; - su2double gammaLM1 = (gammaL-1.0); - su2double gammaRM1 = (gammaR-1.0); - su2double invrhotld = 1.0/(Density_j*(sR-unR)-Density_i*(sL-unL)); - - su2double dSMdUL[5], dSMdUR[5]; - su2double dpsdUL[5], dpsdUR[5]; - - dSMdUL[0] = -unL*unL + uLuL*gammaLM1/2.0 + sM*sL; - dSMdUL[1] = nVec[0]*(2.0*unL-sL-sM) - gammaLM1*uL[0]; - dSMdUL[2] = nVec[1]*(2.0*unL-sL-sM) - gammaLM1*uL[1]; - dSMdUL[3] = nVec[2]*(2.0*unL-sL-sM) - gammaLM1*uL[2]; - dSMdUL[4] = gammaLM1; - - for (iVar = 0; iVar < nVar; iVar++) { - dSMdUL[i] *= invrhotld; - dpsdUL[i] = Density_j*(sR-unR)*dSMdUL[i]; - } - - dSMdUR[0] = unR*unR - uRuR*gammaRM1/2.0 - sM*sR; - dSMdUR[1] = -nVec[0]*(2.0*unR-sR-sM) + gammaRM1*uR[0]; - dSMdUR[2] = -nVec[1]*(2.0*unR-sR-sM) + gammaRM1*uR[1]; - dSMdUR[3] = -nVec[2]*(2.0*unR-sR-sM) + gammaRM1*uR[2]; - dSMdUR[4] = -gammaRM1; - - for (iVar = 0; iVar < nVar; iVar++) { - dSMdUR[i] *= invrhotld; - dpsdUR[i] = Density_i*(sL-unL)*dSMdUR[i]; - } - - calcSubSonicJacobeanHLLC(val_Jacobian_j, val_Jacobian_i, - Density_j, uR, pR, eR, unR, uRuR, sR, - rhoSR, rhouSR, eSR, - dSMdUR, dSMdUL, dpsdUR, dpsdUL, sM, pStar, 0.5*(gammaL+gammaR), nVec); - - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[0][i] = val_Jacobian_i[0][i]*sM + dSMdUL[i]*rhoSR; - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[1][i] = val_Jacobian_i[1][i]*sM + dSMdUL[i]*rhouSR[0] + dpsdUL[i]*nVec[0]; - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[2][i] = val_Jacobian_i[2][i]*sM + dSMdUL[i]*rhouSR[1] + dpsdUL[i]*nVec[1]; - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[3][i] = val_Jacobian_i[3][i]*sM + dSMdUL[i]*rhouSR[2] + dpsdUL[i]*nVec[2]; - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[4][i] = (val_Jacobian_i[4][i]+dpsdUL[i])*sM + (eSR+pStar)*dSMdUL[i]; - - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_i[i][j] *= area; - - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[0][i] = val_Jacobian_j[0][i]*sM + dSMdUR[i]*rhoSR; - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[1][i] = val_Jacobian_j[1][i]*sM + dSMdUR[i]*rhouSR[0] + dpsdUR[i]*nVec[0]; - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[2][i] = val_Jacobian_j[2][i]*sM + dSMdUR[i]*rhouSR[1] + dpsdUR[i]*nVec[1]; - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[3][i] = val_Jacobian_j[3][i]*sM + dSMdUR[i]*rhouSR[2] + dpsdUR[i]*nVec[2]; - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[4][i] = (val_Jacobian_j[4][i]+dpsdUR[i])*sM + (eSR+pStar)*dSMdUR[i]; - - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_j[i][j] *= area; - - } - - else { - - su2double nVecArea[3]; - for (int i=0; i<3; i++) nVecArea[i] = nVec[i]*area; - calcJacobianA(val_Jacobian_j, uR, pR, Density_j, nVecArea, 0.5*(gammaL+gammaR), 0.0); - - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_i[i][j] = 0.0; - - } - - } - -} - -void UgpWithCvCompFlow::calcSubSonicJacobeanHLLC(su2double (*AL)[5], su2double (*AR)[5], - su2double Density_i, const su2double *uL, su2double pL, su2double eL, su2double qL, su2double psiL, su2double SL, - su2double rhoSL, su2double *rhouSL, su2double eSL, - su2double *dSMdUL, su2double *dSMdUR, su2double *dpsdUL, su2double *dpsdUR, su2double SM, su2double pS, - su2double gamma, const su2double *nV) // nV is not normalized -{ - - su2double gammaMinus1 = (gamma-1.0); - su2double omL = 1.0/(SL-SM); - - AL[0][0] = SL + rhoSL*dSMdUL[0]; - AL[0][1] = -nV[0] + rhoSL*dSMdUL[1]; - AL[0][2] = -nV[1] + rhoSL*dSMdUL[2]; - AL[0][3] = -nV[2] + rhoSL*dSMdUL[3]; - AL[0][4] = + rhoSL*dSMdUL[4]; - - AL[1][0] = qL*uL[0] - nV[0]*psiL*gammaMinus1/2.0 + nV[0]*dpsdUL[0] + rhouSL[0]*dSMdUL[0]; - AL[1][1] = SL - qL + nV[0]*(gamma-2.0)*uL[0] + nV[0]*dpsdUL[1] + rhouSL[0]*dSMdUL[1]; - AL[1][2] = - uL[0]*nV[1] + nV[0]*gammaMinus1*uL[1] + nV[0]*dpsdUL[2] + rhouSL[0]*dSMdUL[2]; - AL[1][3] = - uL[0]*nV[2] + nV[0]*gammaMinus1*uL[2] + nV[0]*dpsdUL[3] + rhouSL[0]*dSMdUL[3]; - AL[1][4] = -gammaMinus1*nV[0] + nV[0]*dpsdUL[4] + rhouSL[0]*dSMdUL[4]; - - AL[2][0] = qL*uL[1] - nV[1]*psiL*gammaMinus1/2.0 + nV[1]*dpsdUL[0] + rhouSL[1]*dSMdUL[0]; - AL[2][1] = - uL[1]*nV[0] + nV[1]*gammaMinus1*uL[0] + nV[1]*dpsdUL[1] + rhouSL[1]*dSMdUL[1]; - AL[2][2] = SL - qL + nV[1]*(gamma-2.0)*uL[1] + nV[1]*dpsdUL[2] + rhouSL[1]*dSMdUL[2]; - AL[2][3] = - uL[1]*nV[2] + nV[1]*gammaMinus1*uL[2] + nV[1]*dpsdUL[3] + rhouSL[1]*dSMdUL[3]; - AL[2][4] = -gammaMinus1*nV[1] + nV[1]*dpsdUL[4] + rhouSL[1]*dSMdUL[4]; - - AL[3][0] = qL*uL[2] - nV[2]*psiL*gammaMinus1/2.0 + nV[2]*dpsdUL[0] + rhouSL[2]*dSMdUL[0]; - AL[3][1] = - uL[2]*nV[0] + nV[2]*gammaMinus1*uL[0] + nV[2]*dpsdUL[1] + rhouSL[2]*dSMdUL[1]; - AL[3][2] = - uL[2]*nV[1] + nV[2]*gammaMinus1*uL[1] + nV[2]*dpsdUL[2] + rhouSL[2]*dSMdUL[2]; - AL[3][3] = SL - qL + nV[2]*(gamma-2.0)*uL[2] + nV[2]*dpsdUL[3] + rhouSL[2]*dSMdUL[3]; - AL[3][4] = -gammaMinus1*nV[2] + nV[2]*dpsdUL[4] + rhouSL[2]*dSMdUL[4]; - - AL[4][0] = qL*(eL+pL)/Density_i - qL*psiL*(gamma-1.0)/2.0 + SM*dpsdUL[0] + (pS+eSL)*dSMdUL[0]; - AL[4][1] = - nV[0]*(eL+pL)/Density_i + gammaMinus1*uL[0]*qL + SM*dpsdUL[1] + (pS+eSL)*dSMdUL[1]; - AL[4][2] = - nV[1]*(eL+pL)/Density_i + gammaMinus1*uL[1]*qL + SM*dpsdUL[2] + (pS+eSL)*dSMdUL[2]; - AL[4][3] = - nV[2]*(eL+pL)/Density_i + gammaMinus1*uL[2]*qL + SM*dpsdUL[3] + (pS+eSL)*dSMdUL[3]; - AL[4][4] = SL-qL*gamma + SM*dpsdUL[4] + (pS+eSL)*dSMdUL[4]; - - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - AL[i][j] *= omL; - - for (iVar = 0; iVar < nVar; iVar++) AR[0][i] = omL*rhoSL*dSMdUR[i]; - for (iVar = 0; iVar < nVar; iVar++) AR[1][i] = omL*(nV[0]*dpsdUR[i]+rhouSL[0]*dSMdUR[i]); - for (iVar = 0; iVar < nVar; iVar++) AR[2][i] = omL*(nV[1]*dpsdUR[i]+rhouSL[1]*dSMdUR[i]); - for (iVar = 0; iVar < nVar; iVar++) AR[3][i] = omL*(nV[2]*dpsdUR[i]+rhouSL[2]*dSMdUR[i]); - for (iVar = 0; iVar < nVar; iVar++) AR[4][i] = omL*(dpsdUR[i]*SM+(pS+eSL)*dSMdUR[i]); - -} - -void UgpWithCvCompFlow::calcJacobianA(su2double (*A)[5], const su2double *vel, su2double pp, su2double rrho, const su2double *nV, su2double gamma, su2double surfVeloc) // nV is not normalized -{ - - su2double kapm1 = (gamma - 1.0); - - su2double nVel[3]; - nVel[0] = vel[0]*nV[0]; - nVel[1] = vel[1]*nV[1]; - nVel[2] = vel[2]*nV[2]; - su2double U_k = nVel[0]+nVel[1]+nVel[2]; - su2double vSquHlf = 0.5*vecDotVec3d(vel, vel); - su2double c = sqrt(gamma*pp/rrho); - su2double inv_kap_m1 = 1.0/kapm1; - - A[0][0] =-surfVeloc; - A[0][1] = nV[0]; - A[0][2] = nV[1]; - A[0][3] = nV[2]; - A[0][4] = 0.0; - - A[1][0] = -vel[0]*(nVel[1]+nVel[2])+nV[0]*(kapm1*vSquHlf-vel[0]*vel[0]); - A[1][1] = (2.-gamma)*nVel[0]+U_k-surfVeloc; - A[1][2] = vel[0]*nV[1]-kapm1*vel[1]*nV[0]; - A[1][3] = vel[0]*nV[2]-kapm1*vel[2]*nV[0]; - A[1][4] = kapm1*nV[0]; - - A[2][0] = -vel[1]*(nVel[0]+nVel[2])+nV[1]*(kapm1*vSquHlf-vel[1]*vel[1]); - A[2][1] = -kapm1*vel[0]*nV[1]+ vel[1]*nV[0]; - A[2][2] = (2.-gamma)*nVel[1]+U_k-surfVeloc; - A[2][3] = vel[1]*nV[2]-kapm1*vel[2]*nV[1]; - A[2][4] = kapm1*nV[1]; - - A[3][0] = -vel[2]*(nVel[0]+nVel[1])+nV[2]*(kapm1*vSquHlf-vel[2]*vel[2]); - A[3][1] = -kapm1*vel[0]*nV[2]+vel[2]*nV[0]; - A[3][2] = -kapm1*vel[1]*nV[2]+vel[2]*nV[1]; - A[3][3] = (2.-gamma)*nVel[2]+U_k-surfVeloc; - A[3][4] = kapm1*nV[2]; - - A[4][0] = U_k*((gamma-2.)*vSquHlf-c*c*inv_kap_m1); - A[4][1] = c*c*inv_kap_m1*nV[0]-kapm1*vel[0]*(nVel[1]+nVel[2])-(kapm1*vel[0]*vel[0]-vSquHlf)*nV[0]; - A[4][2] = c*c*inv_kap_m1*nV[1]-kapm1*vel[1]*(nVel[0]+nVel[2])-(kapm1*vel[1]*vel[1]-vSquHlf)*nV[1]; - A[4][3] = c*c*inv_kap_m1*nV[2]-kapm1*vel[2]*(nVel[0]+nVel[1])-(kapm1*vel[2]*vel[2]-vSquHlf)*nV[2]; - A[4][4] = gamma*U_k-surfVeloc; - -} - - -#endif - - -CUpwRoeBase_Flow::CUpwRoeBase_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, - bool val_low_dissipation) : CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ - dynamic_grid = config->GetDynamic_Grid(); - kappa = config->GetRoe_Kappa(); // 1 is unstable - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - roe_low_dissipation = val_low_dissipation; - - Diff_U = new su2double [nVar]; - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; - RoeVelocity = new su2double [nDim]; - ProjFlux_i = new su2double [nVar]; - ProjFlux_j = new su2double [nVar]; - Conservatives_i = new su2double [nVar]; - Conservatives_j = new su2double [nVar]; - Lambda = new su2double [nVar]; - P_Tensor = new su2double* [nVar]; - invP_Tensor = new su2double* [nVar]; - for (unsigned short iVar = 0; iVar < nVar; iVar++) { - P_Tensor[iVar] = new su2double [nVar]; - invP_Tensor[iVar] = new su2double [nVar]; - } -} - -CUpwRoeBase_Flow::~CUpwRoeBase_Flow(void) { - - delete [] Diff_U; - delete [] Velocity_i; - delete [] Velocity_j; - delete [] RoeVelocity; - delete [] ProjFlux_i; - delete [] ProjFlux_j; - delete [] Conservatives_i; - delete [] Conservatives_j; - delete [] Lambda; - for (unsigned short iVar = 0; iVar < nVar; iVar++) { - delete [] P_Tensor[iVar]; - delete [] invP_Tensor[iVar]; - } - delete [] P_Tensor; - delete [] invP_Tensor; - -} - -void CUpwRoeBase_Flow::FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { -/*--- - CUpwRoeBase_Flow::ComputeResidual initializes the residual (flux) and its Jacobians with the standard Roe averaging - fc_{1/2} = kappa*(fc_i+fc_j)*Normal. It then calls this method, which derived classes specialize, to account for - the dissipation part. ----*/ -} - -void CUpwRoeBase_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - unsigned short iVar, jVar, iDim; - su2double ProjGridVel = 0.0, Energy_i, Energy_j; - - AD::StartPreacc(); - AD::SetPreaccIn(V_i, nDim+4); AD::SetPreaccIn(V_j, nDim+4); AD::SetPreaccIn(Normal, nDim); - if (dynamic_grid) { - AD::SetPreaccIn(GridVel_i, nDim); AD::SetPreaccIn(GridVel_j, nDim); - } - if (roe_low_dissipation){ - AD::SetPreaccIn(Sensor_i); AD::SetPreaccIn(Sensor_j); - AD::SetPreaccIn(Dissipation_i); AD::SetPreaccIn(Dissipation_j); - } - - /*--- Face area (norm or the normal vector) and unit normal ---*/ - - 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; - - /*--- Primitive variables at point i ---*/ - - for (iDim = 0; iDim < nDim; iDim++) - Velocity_i[iDim] = V_i[iDim+1]; - Pressure_i = V_i[nDim+1]; - Density_i = V_i[nDim+2]; - Enthalpy_i = V_i[nDim+3]; - Energy_i = Enthalpy_i - Pressure_i/Density_i; - - /*--- Primitive variables at point j ---*/ - - for (iDim = 0; iDim < nDim; iDim++) - Velocity_j[iDim] = V_j[iDim+1]; - Pressure_j = V_j[nDim+1]; - Density_j = V_j[nDim+2]; - Enthalpy_j = V_j[nDim+3]; - Energy_j = Enthalpy_j - Pressure_j/Density_j; - - /*--- Compute variables that are common to the derived schemes ---*/ - - /*--- Roe-averaged variables at interface between i & j ---*/ - - su2double R = sqrt(fabs(Density_j/Density_i)); - RoeDensity = R*Density_i; - su2double sq_vel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - RoeVelocity[iDim] = (R*Velocity_j[iDim]+Velocity_i[iDim])/(R+1); - sq_vel += RoeVelocity[iDim]*RoeVelocity[iDim]; - } - RoeEnthalpy = (R*Enthalpy_j+Enthalpy_i)/(R+1); - RoeSoundSpeed2 = (Gamma-1)*(RoeEnthalpy-0.5*sq_vel); - - /*--- Negative RoeSoundSpeed^2, the jump variables is too large, clear fluxes and exit. ---*/ - - if (RoeSoundSpeed2 <= 0.0) { - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] = 0.0; - if (implicit){ - for (jVar = 0; jVar < nVar; jVar++) { - val_Jacobian_i[iVar][jVar] = 0.0; - val_Jacobian_j[iVar][jVar] = 0.0; - } - } - } - AD::SetPreaccOut(val_residual, nVar); - AD::EndPreacc(); - return; - } - - RoeSoundSpeed = sqrt(RoeSoundSpeed2); - - /*--- P tensor ---*/ - - GetPMatrix(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, P_Tensor); - - /*--- Projected velocity adjusted for mesh motion ---*/ - - ProjVelocity = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjVelocity += RoeVelocity[iDim]*UnitNormal[iDim]; - - if (dynamic_grid) { - for (iDim = 0; iDim < nDim; iDim++) - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*UnitNormal[iDim]; - ProjVelocity -= ProjGridVel; - } - - /*--- Flow eigenvalues ---*/ - - for (iDim = 0; iDim < nDim; iDim++) - Lambda[iDim] = ProjVelocity; - - Lambda[nVar-2] = ProjVelocity + RoeSoundSpeed; - Lambda[nVar-1] = ProjVelocity - RoeSoundSpeed; - - /*--- Apply Mavriplis' entropy correction to eigenvalues ---*/ - - su2double MaxLambda = fabs(ProjVelocity) + RoeSoundSpeed; - - for (iVar = 0; iVar < nVar; iVar++) - Lambda[iVar] = max(fabs(Lambda[iVar]), config->GetEntropyFix_Coeff()*MaxLambda); - - /*--- Reconstruct conservative variables ---*/ - - Conservatives_i[0] = Density_i; - Conservatives_j[0] = Density_j; - - for (iDim = 0; iDim < nDim; iDim++) { - Conservatives_i[iDim+1] = Density_i*Velocity_i[iDim]; - Conservatives_j[iDim+1] = Density_j*Velocity_j[iDim]; - } - Conservatives_i[nDim+1] = Density_i*Energy_i; - Conservatives_j[nDim+1] = Density_j*Energy_j; - - /*--- Compute left and right fluxes ---*/ - - GetInviscidProjFlux(&Density_i, Velocity_i, &Pressure_i, &Enthalpy_i, Normal, ProjFlux_i); - GetInviscidProjFlux(&Density_j, Velocity_j, &Pressure_j, &Enthalpy_j, Normal, ProjFlux_j); - - /*--- Initialize residual (flux) and Jacobians ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_residual[iVar] = kappa*(ProjFlux_i[iVar]+ProjFlux_j[iVar]); - - if (implicit) { - GetInviscidProjJac(Velocity_i, &Energy_i, Normal, kappa, val_Jacobian_i); - GetInviscidProjJac(Velocity_j, &Energy_j, Normal, kappa, val_Jacobian_j); - } - - /*--- Finalize in children class ---*/ - - FinalizeResidual(val_residual, val_Jacobian_i, val_Jacobian_j, config); - - /*--- Correct for grid motion ---*/ - - if (dynamic_grid) { - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] -= ProjGridVel*Area * 0.5*(Conservatives_i[iVar]+Conservatives_j[iVar]); - - if (implicit) { - val_Jacobian_i[iVar][iVar] -= 0.5*ProjGridVel*Area; - val_Jacobian_j[iVar][iVar] -= 0.5*ProjGridVel*Area; - } - } - } - - AD::SetPreaccOut(val_residual, nVar); - AD::EndPreacc(); - -} - -CUpwRoe_Flow::CUpwRoe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, - bool val_low_dissipation) : CUpwRoeBase_Flow(val_nDim, val_nVar, config, val_low_dissipation) {} - -CUpwRoe_Flow::~CUpwRoe_Flow() {} - -void CUpwRoe_Flow::FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, - su2double **val_Jacobian_j, CConfig *config) { - - unsigned short iVar, jVar, kVar; - - /*--- Compute inverse P tensor ---*/ - GetPMatrix_inv(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, invP_Tensor); - - /*--- Diference between conservative variables at jPoint and iPoint ---*/ - for (iVar = 0; iVar < nVar; iVar++) - Diff_U[iVar] = Conservatives_j[iVar]-Conservatives_i[iVar]; - - /*--- Low dissipation formulation ---*/ - if (roe_low_dissipation) - SetRoe_Dissipation(Dissipation_i, Dissipation_j, Sensor_i, Sensor_j, Dissipation_ij, config); - else - Dissipation_ij = 1.0; - - /*--- Standard Roe "dissipation" ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - /*--- Compute |Proj_ModJac_Tensor| = P x |Lambda| x inverse P ---*/ - su2double Proj_ModJac_Tensor_ij = 0.0; - for (kVar = 0; kVar < nVar; kVar++) - Proj_ModJac_Tensor_ij += P_Tensor[iVar][kVar]*Lambda[kVar]*invP_Tensor[kVar][jVar]; - - /*--- Update residual and Jacobians ---*/ - val_residual[iVar] -= (1.0-kappa)*Proj_ModJac_Tensor_ij*Diff_U[jVar]*Area*Dissipation_ij; - - if(implicit){ - val_Jacobian_i[iVar][jVar] += (1.0-kappa)*Proj_ModJac_Tensor_ij*Area; - val_Jacobian_j[iVar][jVar] -= (1.0-kappa)*Proj_ModJac_Tensor_ij*Area; - } - } - } - -} - -CUpwL2Roe_Flow::CUpwL2Roe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : - CUpwRoeBase_Flow(val_nDim, val_nVar, config, false) {} - -CUpwL2Roe_Flow::~CUpwL2Roe_Flow() {} - -void CUpwL2Roe_Flow::FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, - su2double **val_Jacobian_j, CConfig *config) { - - /*--- L2Roe: a low dissipation version of Roe's approximate Riemann solver for low Mach numbers. IJNMF 2015 ---*/ - - unsigned short iVar, jVar, kVar, iDim; - - /*--- Clamped Mach number ---*/ - - su2double M_i = 0.0, M_j = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - M_i += Velocity_i[iDim]*Velocity_i[iDim]; - M_j += Velocity_j[iDim]*Velocity_j[iDim]; - } - M_i = sqrt(M_i / fabs(Pressure_i*Gamma/Density_i)); - M_j = sqrt(M_j / fabs(Pressure_j*Gamma/Density_j)); - - su2double zeta = max(0.05,min(max(M_i,M_j),1.0)); - - /*--- Compute wave amplitudes (characteristics) ---*/ - - su2double proj_delta_vel = 0.0, delta_vel[3]; - for (iDim = 0; iDim < nDim; iDim++) { - delta_vel[iDim] = Velocity_j[iDim] - Velocity_i[iDim]; - proj_delta_vel += delta_vel[iDim]*UnitNormal[iDim]; - } - proj_delta_vel *= zeta; - su2double delta_p = Pressure_j - Pressure_i; - su2double delta_rho = Density_j - Density_i; - - su2double delta_wave[5] = {0.0, 0.0, 0.0, 0.0, 0.0}; - if (nDim == 2) { - delta_wave[0] = delta_rho - delta_p/RoeSoundSpeed2; - delta_wave[1] = (UnitNormal[1]*delta_vel[0]-UnitNormal[0]*delta_vel[1])*zeta; - delta_wave[2] = proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); - delta_wave[3] = -proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); - } else { - delta_wave[0] = delta_rho - delta_p/RoeSoundSpeed2; - delta_wave[1] = (UnitNormal[0]*delta_vel[2]-UnitNormal[2]*delta_vel[0])*zeta; - delta_wave[2] = (UnitNormal[1]*delta_vel[0]-UnitNormal[0]*delta_vel[1])*zeta; - delta_wave[3] = proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); - delta_wave[4] = -proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); - } - - /*--- Update residual ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - for (kVar = 0; kVar < nVar; kVar++) - val_residual[iVar] -= (1.0-kappa)*Lambda[kVar]*delta_wave[kVar]*P_Tensor[iVar][kVar]*Area; - - if (!implicit) return; - - /*--- If implicit use the Jacobians of the standard Roe scheme as an approximation ---*/ - - GetPMatrix_inv(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, invP_Tensor); - - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - /*--- Compute |Proj_ModJac_Tensor| = P x |Lambda| x inverse P ---*/ - su2double Proj_ModJac_Tensor_ij = 0.0; - for (kVar = 0; kVar < nVar; kVar++) - Proj_ModJac_Tensor_ij += P_Tensor[iVar][kVar]*Lambda[kVar]*invP_Tensor[kVar][jVar]; - - val_Jacobian_i[iVar][jVar] += (1.0-kappa)*Proj_ModJac_Tensor_ij*Area; - val_Jacobian_j[iVar][jVar] -= (1.0-kappa)*Proj_ModJac_Tensor_ij*Area; - } - } - -} - -CUpwLMRoe_Flow::CUpwLMRoe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : - CUpwRoeBase_Flow(val_nDim, val_nVar, config, false) {} - -CUpwLMRoe_Flow::~CUpwLMRoe_Flow() {} - -void CUpwLMRoe_Flow::FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, - su2double **val_Jacobian_j, CConfig *config) { - - /*--- Rieper, A low-Mach number fix for Roe's approximate Riemman Solver, JCP 2011 ---*/ - - unsigned short iVar, jVar, kVar, iDim; - - /*--- Clamped Mach number ---*/ - - su2double M_i = 0.0, M_j = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - M_i += Velocity_i[iDim]*Velocity_i[iDim]; - M_j += Velocity_j[iDim]*Velocity_j[iDim]; - } - M_i = sqrt(M_i / fabs(Pressure_i*Gamma/Density_i)); - M_j = sqrt(M_j / fabs(Pressure_j*Gamma/Density_j)); - - su2double zeta = max(0.05,min(max(M_i,M_j),1.0)); - - /*--- Compute wave amplitudes (characteristics) ---*/ - - su2double proj_delta_vel = 0.0, delta_vel[3]; - for (iDim = 0; iDim < nDim; iDim++) { - delta_vel[iDim] = Velocity_j[iDim] - Velocity_i[iDim]; - proj_delta_vel += delta_vel[iDim]*UnitNormal[iDim]; - } - proj_delta_vel *= zeta; - su2double delta_p = Pressure_j - Pressure_i; - su2double delta_rho = Density_j - Density_i; - - su2double delta_wave[5] = {0.0, 0.0, 0.0, 0.0, 0.0}; - if (nDim == 2) { - delta_wave[0] = delta_rho - delta_p/RoeSoundSpeed2; - delta_wave[1] = (UnitNormal[1]*delta_vel[0]-UnitNormal[0]*delta_vel[1]); - delta_wave[2] = proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); - delta_wave[3] = -proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); - } else { - delta_wave[0] = delta_rho - delta_p/RoeSoundSpeed2; - delta_wave[1] = (UnitNormal[0]*delta_vel[2]-UnitNormal[2]*delta_vel[0]); - delta_wave[2] = (UnitNormal[1]*delta_vel[0]-UnitNormal[0]*delta_vel[1]); - delta_wave[3] = proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); - delta_wave[4] = -proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); - } - - /*--- Update residual ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - for (kVar = 0; kVar < nVar; kVar++) - val_residual[iVar] -= (1.0-kappa)*Lambda[kVar]*delta_wave[kVar]*P_Tensor[iVar][kVar]*Area; - - if (!implicit) return; - - /*--- If implicit use the Jacobians of the standard Roe scheme as an approximation ---*/ - - GetPMatrix_inv(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, invP_Tensor); - - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - /*--- Compute |Proj_ModJac_Tensor| = P x |Lambda| x inverse P ---*/ - su2double Proj_ModJac_Tensor_ij = 0.0; - for (kVar = 0; kVar < nVar; kVar++) - Proj_ModJac_Tensor_ij += P_Tensor[iVar][kVar]*Lambda[kVar]*invP_Tensor[kVar][jVar]; - - val_Jacobian_i[iVar][jVar] += (1.0-kappa)*Proj_ModJac_Tensor_ij*Area; - val_Jacobian_j[iVar][jVar] -= (1.0-kappa)*Proj_ModJac_Tensor_ij*Area; - } - } - -} - -CUpwGeneralRoe_Flow::CUpwGeneralRoe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ - dynamic_grid = config->GetDynamic_Grid(); - kappa = config->GetRoe_Kappa(); // 1 is unstable - - - Diff_U = new su2double [nVar]; - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; - RoeVelocity = new su2double [nDim]; - delta_vel = new su2double [nDim]; - delta_wave = new su2double [nVar]; - ProjFlux_i = new su2double [nVar]; - ProjFlux_j = new su2double [nVar]; - Lambda = new su2double [nVar]; - Epsilon = new su2double [nVar]; - P_Tensor = new su2double* [nVar]; - invP_Tensor = new su2double* [nVar]; - - for (iVar = 0; iVar < nVar; iVar++) { - P_Tensor[iVar] = new su2double [nVar]; - invP_Tensor[iVar] = new su2double [nVar]; - } -} - -CUpwGeneralRoe_Flow::~CUpwGeneralRoe_Flow(void) { - - delete [] Diff_U; - delete [] Velocity_i; - delete [] Velocity_j; - delete [] RoeVelocity; - delete [] delta_vel; - delete [] delta_wave; - delete [] ProjFlux_i; - delete [] ProjFlux_j; - delete [] Lambda; - delete [] Epsilon; - for (iVar = 0; iVar < nVar; iVar++) { - delete [] P_Tensor[iVar]; - delete [] invP_Tensor[iVar]; - } - delete [] P_Tensor; - delete [] invP_Tensor; - -} - -void CUpwGeneralRoe_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - AD::StartPreacc(); - AD::SetPreaccIn(V_i, nDim+4); AD::SetPreaccIn(V_j, nDim+4); AD::SetPreaccIn(Normal, nDim); - AD::SetPreaccIn(S_i, 2); AD::SetPreaccIn(S_j, 2); - if (dynamic_grid) { - AD::SetPreaccIn(GridVel_i, nDim); AD::SetPreaccIn(GridVel_j, nDim); - } - su2double U_i[5] = {0.0,0.0,0.0,0.0,0.0}, U_j[5] = {0.0,0.0,0.0,0.0,0.0}; - - /*--- Face area (norm or the normal vector) ---*/ - - Area = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - Area += Normal[iDim]*Normal[iDim]; - Area = sqrt(Area); - - /*-- Unit Normal ---*/ - - for (iDim = 0; iDim < nDim; iDim++) - UnitNormal[iDim] = Normal[iDim]/Area; - - /*--- Primitive variables at point i ---*/ - - Velocity2_i = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = V_i[iDim+1]; - Velocity2_i += Velocity_i[iDim]*Velocity_i[iDim]; - } - - Pressure_i = V_i[nDim+1]; - Density_i = V_i[nDim+2]; - Enthalpy_i = V_i[nDim+3]; - Energy_i = Enthalpy_i - Pressure_i/Density_i; - StaticEnthalpy_i = Enthalpy_i - 0.5*Velocity2_i; - StaticEnergy_i = StaticEnthalpy_i - Pressure_i/Density_i; - - Kappa_i = S_i[1]/Density_i; - Chi_i = S_i[0] - Kappa_i*StaticEnergy_i; - SoundSpeed_i = sqrt(Chi_i + StaticEnthalpy_i*Kappa_i); - - /*--- Primitive variables at point j ---*/ - - - Velocity2_j = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_j[iDim] = V_j[iDim+1]; - Velocity2_j += Velocity_j[iDim]*Velocity_j[iDim]; - } - - Pressure_j = V_j[nDim+1]; - Density_j = V_j[nDim+2]; - Enthalpy_j = V_j[nDim+3]; - Energy_j = Enthalpy_j - Pressure_j/Density_j; - - StaticEnthalpy_j = Enthalpy_j - 0.5*Velocity2_j; - StaticEnergy_j = StaticEnthalpy_j - Pressure_j/Density_j; - - Kappa_j = S_j[1]/Density_j; - Chi_j = S_j[0] - Kappa_j*StaticEnergy_j; - SoundSpeed_j = sqrt(Chi_j + StaticEnthalpy_j*Kappa_j); - - /*--- Recompute conservative variables ---*/ - - U_i[0] = Density_i; U_j[0] = Density_j; - for (iDim = 0; iDim < nDim; iDim++) { - U_i[iDim+1] = Density_i*Velocity_i[iDim]; U_j[iDim+1] = Density_j*Velocity_j[iDim]; - } - U_i[nDim+1] = Density_i*Energy_i; U_j[nDim+1] = Density_j*Energy_j; - -// /*--- Roe-averaged variables at interface between i & j ---*/ - - ComputeRoeAverage(); - - if (RoeSoundSpeed2 <= 0.0) { - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] = 0.0; - for (jVar = 0; jVar < nVar; jVar++) { - val_Jacobian_i[iVar][iVar] = 0.0; - val_Jacobian_j[iVar][iVar] = 0.0; - } - } - return; - } - - RoeSoundSpeed = sqrt(RoeSoundSpeed2); - - /*--- Compute ProjFlux_i ---*/ - GetInviscidProjFlux(&Density_i, Velocity_i, &Pressure_i, &Enthalpy_i, Normal, ProjFlux_i); - - /*--- Compute ProjFlux_j ---*/ - GetInviscidProjFlux(&Density_j, Velocity_j, &Pressure_j, &Enthalpy_j, Normal, ProjFlux_j); - - /*--- Compute P and Lambda (do it with the Normal) ---*/ - - GetPMatrix(&RoeDensity, RoeVelocity, &RoeSoundSpeed, &RoeEnthalpy, &RoeChi, &RoeKappa, UnitNormal, P_Tensor); - - ProjVelocity = 0.0; ProjVelocity_i = 0.0; ProjVelocity_j = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - ProjVelocity += RoeVelocity[iDim]*UnitNormal[iDim]; - ProjVelocity_i += Velocity_i[iDim]*UnitNormal[iDim]; - ProjVelocity_j += Velocity_j[iDim]*UnitNormal[iDim]; - } - - /*--- Projected velocity adjustment due to mesh motion ---*/ - if (dynamic_grid) { - su2double ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*UnitNormal[iDim]; - } - ProjVelocity -= ProjGridVel; - ProjVelocity_i -= ProjGridVel; - ProjVelocity_j -= ProjGridVel; - } - - /*--- Flow eigenvalues and entropy correctors ---*/ - for (iDim = 0; iDim < nDim; iDim++) - Lambda[iDim] = ProjVelocity; - - Lambda[nVar-2] = ProjVelocity + RoeSoundSpeed; - Lambda[nVar-1] = ProjVelocity - RoeSoundSpeed; - - /*--- Compute absolute value with Mavriplis' entropy correction ---*/ - - MaxLambda = fabs(ProjVelocity) + RoeSoundSpeed; - Delta = config->GetEntropyFix_Coeff(); - - for (iVar = 0; iVar < nVar; iVar++) { - Lambda[iVar] = max(fabs(Lambda[iVar]), Delta*MaxLambda); - } - -// /*--- Harten and Hyman (1983) entropy correction ---*/ -// for (iDim = 0; iDim < nDim; iDim++) -// Epsilon[iDim] = 4.0*max(0.0, max(Lambda[iDim]-ProjVelocity_i, ProjVelocity_j-Lambda[iDim])); -// -// Epsilon[nVar-2] = 4.0*max(0.0, max(Lambda[nVar-2]-(ProjVelocity_i+SoundSpeed_i),(ProjVelocity_j+SoundSpeed_j)-Lambda[nVar-2])); -// Epsilon[nVar-1] = 4.0*max(0.0, max(Lambda[nVar-1]-(ProjVelocity_i-SoundSpeed_i),(ProjVelocity_j-SoundSpeed_j)-Lambda[nVar-1])); -// -// for (iVar = 0; iVar < nVar; iVar++) -// if ( fabs(Lambda[iVar]) < Epsilon[iVar] ) -// Lambda[iVar] = (Lambda[iVar]*Lambda[iVar] + Epsilon[iVar]*Epsilon[iVar])/(2.0*Epsilon[iVar]); -// else -// Lambda[iVar] = fabs(Lambda[iVar]); - -// for (iVar = 0; iVar < nVar; iVar++) -// Lambda[iVar] = fabs(Lambda[iVar]); - - if (!implicit) { - - /*--- Compute wave amplitudes (characteristics) ---*/ - proj_delta_vel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - delta_vel[iDim] = Velocity_j[iDim] - Velocity_i[iDim]; - proj_delta_vel += delta_vel[iDim]*Normal[iDim]; - } - delta_p = Pressure_j - Pressure_i; - delta_rho = Density_j - Density_i; - proj_delta_vel = proj_delta_vel/Area; - - if (nDim == 2) { - delta_wave[0] = delta_rho - delta_p/(RoeSoundSpeed*RoeSoundSpeed); - delta_wave[1] = UnitNormal[1]*delta_vel[0]-UnitNormal[0]*delta_vel[1]; - delta_wave[2] = proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); - delta_wave[3] = -proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); - } else { - delta_wave[0] = delta_rho - delta_p/(RoeSoundSpeed*RoeSoundSpeed); - delta_wave[1] = UnitNormal[0]*delta_vel[2]-UnitNormal[2]*delta_vel[0]; - delta_wave[2] = UnitNormal[1]*delta_vel[0]-UnitNormal[0]*delta_vel[1]; - delta_wave[3] = proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); - delta_wave[4] = -proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); - } - - /*--- Roe's Flux approximation ---*/ - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] = 0.5*(ProjFlux_i[iVar]+ProjFlux_j[iVar]); - for (jVar = 0; jVar < nVar; jVar++) - val_residual[iVar] -= 0.5*Lambda[jVar]*delta_wave[jVar]*P_Tensor[iVar][jVar]*Area; - } - - /*--- Flux contribution due to grid motion ---*/ - if (dynamic_grid) { - ProjVelocity = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjVelocity += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] -= ProjVelocity * 0.5*(U_i[iVar]+U_j[iVar]); - } - } - } - else { - - /*--- Compute inverse P ---*/ - - GetPMatrix_inv(invP_Tensor, &RoeDensity, RoeVelocity, &RoeSoundSpeed, &RoeChi , &RoeKappa, UnitNormal); - - /*--- Jacobians of the inviscid flux, scaled by - kappa because val_resconv ~ kappa*(fc_i+fc_j)*Normal ---*/ - - GetInviscidProjJac(Velocity_i, &Enthalpy_i, &Chi_i, &Kappa_i, Normal, kappa, val_Jacobian_i); - - GetInviscidProjJac(Velocity_j, &Enthalpy_j, &Chi_j, &Kappa_j, Normal, kappa, val_Jacobian_j); - - - /*--- Diference variables iPoint and jPoint ---*/ - for (iVar = 0; iVar < nVar; iVar++) - Diff_U[iVar] = U_j[iVar]-U_i[iVar]; - - /*--- Roe's Flux approximation ---*/ - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] = kappa*(ProjFlux_i[iVar]+ProjFlux_j[iVar]); - for (jVar = 0; jVar < nVar; jVar++) { - Proj_ModJac_Tensor_ij = 0.0; - - /*--- Compute |Proj_ModJac_Tensor| = P x |Lambda| x inverse P ---*/ - - for (kVar = 0; kVar < nVar; kVar++) - Proj_ModJac_Tensor_ij += P_Tensor[iVar][kVar]*Lambda[kVar]*invP_Tensor[kVar][jVar]; - - val_residual[iVar] -= (1.0-kappa)*Proj_ModJac_Tensor_ij*Diff_U[jVar]*Area; - val_Jacobian_i[iVar][jVar] += (1.0-kappa)*Proj_ModJac_Tensor_ij*Area; - val_Jacobian_j[iVar][jVar] -= (1.0-kappa)*Proj_ModJac_Tensor_ij*Area; - } - } - - /*--- Jacobian contributions due to grid motion ---*/ - if (dynamic_grid) { - ProjVelocity = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjVelocity += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] -= ProjVelocity * 0.5*(U_i[iVar]+U_j[iVar]); - /*--- Implicit terms ---*/ - val_Jacobian_i[iVar][iVar] -= 0.5*ProjVelocity; - val_Jacobian_j[iVar][iVar] -= 0.5*ProjVelocity; - } - } - - } - - AD::SetPreaccOut(val_residual, nVar); - AD::EndPreacc(); -} - - -void CUpwGeneralRoe_Flow::ComputeRoeAverage() { - - //su2double delta_rhoStaticEnergy, err_P, s, D; - // su2double tol = 10-6; - - R = sqrt(fabs(Density_j/Density_i)); - RoeDensity = R*Density_i; - sq_vel = 0; for (iDim = 0; iDim < nDim; iDim++) { - RoeVelocity[iDim] = (R*Velocity_j[iDim]+Velocity_i[iDim])/(R+1); - sq_vel += RoeVelocity[iDim]*RoeVelocity[iDim]; - } - - RoeEnthalpy = (R*Enthalpy_j+Enthalpy_i)/(R+1); - delta_rho = Density_j - Density_i; - delta_p = Pressure_j - Pressure_i; - RoeKappa = 0.5*(Kappa_i + Kappa_j); - RoeKappa = (Kappa_i + Kappa_j + 4*RoeKappa)/6; - RoeChi = 0.5*(Chi_i + Chi_j); - RoeChi = (Chi_i + Chi_j + 4*RoeChi)/6; - - -// RoeKappaStaticEnthalpy = 0.5*(StaticEnthalpy_i*Kappa_i + StaticEnthalpy_j*Kappa_j); -// RoeKappaStaticEnthalpy = (StaticEnthalpy_i*Kappa_i + StaticEnthalpy_j*Kappa_j + 4*RoeKappaStaticEnthalpy)/6; -// s = RoeChi + RoeKappaStaticEnthalpy; -// D = s*s*delta_rho*delta_rho + delta_p*delta_p; -// delta_rhoStaticEnergy = Density_j*StaticEnergy_j - Density_i*StaticEnergy_i; -// err_P = delta_p - RoeChi*delta_rho - RoeKappa*delta_rhoStaticEnergy; -// -// -// if (abs((D - delta_p*err_P)/Density_i)>1e-3 && abs(delta_rho/Density_i)>1e-3 && s/Density_i > 1e-3) { -// -// RoeKappa = (D*RoeKappa)/(D - delta_p*err_P); -// RoeChi = (D*RoeChi+ s*s*delta_rho*err_P)/(D - delta_p*err_P); -// -// } - - RoeSoundSpeed2 = RoeChi + RoeKappa*(RoeEnthalpy-0.5*sq_vel); - -} - -CUpwMSW_Flow::CUpwMSW_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - if (config->GetDynamic_Grid() && (SU2_MPI::GetRank() == MASTER_NODE)) - cout << "WARNING: Grid velocities are NOT yet considered in the MSW scheme." << endl; - - /*--- Set booleans from CConfig settings ---*/ - implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - - /*--- Allocate arrays ---*/ - Diff_U = new su2double [nVar]; - Fc_i = new su2double [nVar]; - Fc_j = new su2double [nVar]; - Lambda_i = new su2double [nVar]; - Lambda_j = new su2double [nVar]; - - u_i = new su2double [nDim]; - u_j = new su2double [nDim]; - ust_i = new su2double [nDim]; - ust_j = new su2double [nDim]; - Vst_i = new su2double [nPrimVar]; - Vst_j = new su2double [nPrimVar]; - Ust_i = new su2double [nVar]; - Ust_j = new su2double [nVar]; - - Velst_i = new su2double [nDim]; - Velst_j = new su2double [nDim]; - - P_Tensor = new su2double* [nVar]; - invP_Tensor = new su2double* [nVar]; - for (unsigned short iVar = 0; iVar < nVar; iVar++) { - P_Tensor[iVar] = new su2double [nVar]; - invP_Tensor[iVar] = new su2double [nVar]; - } - -} - -CUpwMSW_Flow::~CUpwMSW_Flow(void) { - - delete [] Diff_U; - delete [] Fc_i; - delete [] Fc_j; - delete [] Lambda_i; - delete [] Lambda_j; - - delete [] u_i; - delete [] u_j; - delete [] ust_i; - delete [] ust_j; - delete [] Ust_i; - delete [] Vst_i; - delete [] Ust_j; - delete [] Vst_j; - delete [] Velst_i; - delete [] Velst_j; - - for (unsigned short iVar = 0; iVar < nVar; iVar++) { - delete [] P_Tensor[iVar]; - delete [] invP_Tensor[iVar]; - } - delete [] P_Tensor; - delete [] invP_Tensor; - -} - -void CUpwMSW_Flow::ComputeResidual(su2double *val_residual, - su2double **val_Jacobian_i, - su2double **val_Jacobian_j, CConfig *config) { - - unsigned short iDim, iVar, jVar, kVar; - su2double P_i, P_j; - su2double ProjVel_i, ProjVel_j, ProjVelst_i, ProjVelst_j; - su2double sqvel_i, sqvel_j; - su2double alpha, w, dp, onemw; - su2double Proj_ModJac_Tensor_i, Proj_ModJac_Tensor_j; - - /*--- Set parameters in the numerical method ---*/ - alpha = 6.0; - - /*--- Calculate supporting geometry parameters ---*/ - - Area = 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; - - /*--- Initialize flux & Jacobian vectors ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - Fc_i[iVar] = 0.0; - Fc_j[iVar] = 0.0; - } - if (implicit) { - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - val_Jacobian_i[iVar][jVar] = 0.0; - val_Jacobian_j[iVar][jVar] = 0.0; - } - } - } - - /*--- Load variables from nodes i & j ---*/ - - rhos_i = V_i[0]; - rhos_j = V_j[0]; - for (iDim = 0; iDim < nDim; iDim++) { - u_i[iDim] = V_i[iDim+1]; - u_j[iDim] = V_j[iDim+1]; - } - P_i = V_i[nDim+1]; - P_j = V_j[nDim+1]; - - /*--- Calculate supporting quantities ---*/ - - sqvel_i = 0.0; sqvel_j = 0.0; - ProjVel_i = 0.0; ProjVel_j = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - sqvel_i += u_i[iDim]*u_i[iDim]; - sqvel_j += u_j[iDim]*u_j[iDim]; - ProjVel_i += u_i[iDim]*UnitNormal[iDim]; - ProjVel_j += u_j[iDim]*UnitNormal[iDim]; - } - - /*--- Calculate the state weighting function ---*/ - - dp = fabs(P_j-P_i) / min(P_j, P_i); - w = 0.5 * (1.0/(pow(alpha*dp,2.0) +1.0)); - onemw = 1.0 - w; - - /*--- Calculate weighted state vector (*) for i & j ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - Ust_i[iVar] = onemw*U_i[iVar] + w*U_j[iVar]; - Ust_j[iVar] = onemw*U_j[iVar] + w*U_i[iVar]; - } - for (iVar = 0; iVar < nDim+5; iVar++) { - Vst_i[iVar] = onemw*V_i[iVar] + w*V_j[iVar]; - Vst_j[iVar] = onemw*V_j[iVar] + w*V_i[iVar]; - } - ProjVelst_i = onemw*ProjVel_i + w*ProjVel_j; - ProjVelst_j = onemw*ProjVel_j + w*ProjVel_i; - - for (iDim = 0; iDim < nDim; iDim++) { - Velst_i[iDim] = Vst_i[iDim+1]; - Velst_j[iDim] = Vst_j[iDim+1]; - } - - /*--- Flow eigenvalues at i (Lambda+) ---*/ - - for (iDim = 0; iDim < nDim; iDim++) { - Lambda_i[iDim] = 0.5*(ProjVelst_i + fabs(ProjVelst_i)); - } - - Lambda_i[nDim] = 0.5*( ProjVelst_i + Vst_i[nDim+4] + fabs(ProjVelst_i + Vst_i[nDim+4]) ); - Lambda_i[nDim+1] = 0.5*( ProjVelst_i - Vst_i[nDim+4] + fabs(ProjVelst_i - Vst_i[nDim+4]) ); - - /*--- Compute projected P, invP, and Lambda ---*/ - - GetPMatrix(&Vst_i[nDim+2], Velst_i, &Vst_i[nDim+4], UnitNormal, P_Tensor); - GetPMatrix_inv(&Vst_i[nDim+2], Velst_i, &Vst_i[nDim+4], UnitNormal, invP_Tensor); - - /*--- Projected flux (f+) at i ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - Proj_ModJac_Tensor_i = 0.0; - - /*--- Compute Proj_ModJac_Tensor = P x Lambda+ x inverse P ---*/ - - for (kVar = 0; kVar < nVar; kVar++) - Proj_ModJac_Tensor_i += P_Tensor[iVar][kVar]*Lambda_i[kVar]*invP_Tensor[kVar][jVar]; - Fc_i[iVar] += Proj_ModJac_Tensor_i*U_i[jVar]*Area; - if (implicit) - val_Jacobian_i[iVar][jVar] += Proj_ModJac_Tensor_i*Area; - } - } - - /*--- Flow eigenvalues at j (Lambda-) ---*/ - - for (iDim = 0; iDim < nDim; iDim++) { - Lambda_j[iDim] = 0.5*(ProjVelst_j - fabs(ProjVelst_j)); - } - Lambda_j[nDim] = 0.5*( ProjVelst_j + Vst_j[nDim+4] - - fabs(ProjVelst_j + Vst_j[nDim+4]) ); - Lambda_j[nDim+1] = 0.5*( ProjVelst_j - Vst_j[nDim+4] - - fabs(ProjVelst_j - Vst_j[nDim+4]) ); - - /*--- Compute projected P, invP, and Lambda ---*/ - - GetPMatrix(&Vst_j[nDim+2], Velst_j, &Vst_j[nDim+4], UnitNormal, P_Tensor); - GetPMatrix_inv(&Vst_j[nDim+2], Velst_j, &Vst_j[nDim+4], UnitNormal, invP_Tensor); - - /*--- Projected flux (f-) ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - Proj_ModJac_Tensor_j = 0.0; - /*--- Compute Proj_ModJac_Tensor = P x Lambda- x inverse P ---*/ - for (kVar = 0; kVar < nVar; kVar++) - Proj_ModJac_Tensor_j += P_Tensor[iVar][kVar]*Lambda_j[kVar]*invP_Tensor[kVar][jVar]; - Fc_j[iVar] += Proj_ModJac_Tensor_j*U_j[jVar]*Area; - if (implicit) - val_Jacobian_j[iVar][jVar] += Proj_ModJac_Tensor_j*Area; - } - } - - /*--- Flux splitting ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] = Fc_i[iVar]+Fc_j[iVar]; - } - -} - -CUpwTurkel_Flow::CUpwTurkel_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ - dynamic_grid = config->GetDynamic_Grid(); - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - Beta_min = config->GetminTurkelBeta(); - Beta_max = config->GetmaxTurkelBeta(); - - Diff_U = new su2double [nVar]; - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; - RoeVelocity = new su2double [nDim]; - ProjFlux_i = new su2double [nVar]; - ProjFlux_j = new su2double [nVar]; - Lambda = new su2double [nVar]; - Epsilon = new su2double [nVar]; - absPeJac = new su2double* [nVar]; - invRinvPe = new su2double* [nVar]; - R_Tensor = new su2double* [nVar]; - Matrix = new su2double* [nVar]; - Art_Visc = new su2double* [nVar]; - for (iVar = 0; iVar < nVar; iVar++) { - absPeJac[iVar] = new su2double [nVar]; - invRinvPe[iVar] = new su2double [nVar]; - Matrix[iVar] = new su2double [nVar]; - Art_Visc[iVar] = new su2double [nVar]; - R_Tensor[iVar] = new su2double [nVar]; - } -} - -CUpwTurkel_Flow::~CUpwTurkel_Flow(void) { - - delete [] Diff_U; - delete [] Velocity_i; - delete [] Velocity_j; - delete [] RoeVelocity; - delete [] ProjFlux_i; - delete [] ProjFlux_j; - delete [] Lambda; - delete [] Epsilon; - for (iVar = 0; iVar < nVar; iVar++) { - delete [] absPeJac[iVar]; - delete [] invRinvPe[iVar]; - delete [] Matrix[iVar]; - delete [] Art_Visc[iVar]; - delete [] R_Tensor[iVar]; - } - delete [] Matrix; - delete [] Art_Visc; - delete [] absPeJac; - delete [] invRinvPe; - delete [] R_Tensor; - -} - -void CUpwTurkel_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - su2double U_i[5] = {0.0,0.0,0.0,0.0,0.0}, U_j[5] = {0.0,0.0,0.0,0.0,0.0}; - - /*--- Face area (norm or the normal vector) ---*/ - - Area = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - Area += Normal[iDim]*Normal[iDim]; - Area = sqrt(Area); - - /*-- Unit Normal ---*/ - - for (iDim = 0; iDim < nDim; iDim++) - UnitNormal[iDim] = Normal[iDim]/Area; - - /*--- Primitive variables at point i ---*/ - - for (iDim = 0; iDim < nDim; iDim++) - Velocity_i[iDim] = V_i[iDim+1]; - Pressure_i = V_i[nDim+1]; - Density_i = V_i[nDim+2]; - Enthalpy_i = V_i[nDim+3]; - Energy_i = Enthalpy_i - Pressure_i/Density_i; - SoundSpeed_i = sqrt(fabs(Pressure_i*Gamma/Density_i)); - - /*--- Primitive variables at point j ---*/ - - for (iDim = 0; iDim < nDim; iDim++) - Velocity_j[iDim] = V_j[iDim+1]; - Pressure_j = V_j[nDim+1]; - Density_j = V_j[nDim+2]; - Enthalpy_j = V_j[nDim+3]; - Energy_j = Enthalpy_j - Pressure_j/Density_j; - SoundSpeed_j = sqrt(fabs(Pressure_j*Gamma/Density_j)); - - /*--- Recompute conservative variables ---*/ - - U_i[0] = Density_i; U_j[0] = Density_j; - for (iDim = 0; iDim < nDim; iDim++) { - U_i[iDim+1] = Density_i*Velocity_i[iDim]; U_j[iDim+1] = Density_j*Velocity_j[iDim]; - } - U_i[nDim+1] = Density_i*Energy_i; U_j[nDim+1] = Density_j*Energy_j; - - /*--- Roe-averaged variables at interface between i & j ---*/ - - R = sqrt(fabs(Density_j/Density_i)); - RoeDensity = R*Density_i; - sq_vel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - RoeVelocity[iDim] = (R*Velocity_j[iDim]+Velocity_i[iDim])/(R+1); - sq_vel += RoeVelocity[iDim]*RoeVelocity[iDim]; - } - RoeEnthalpy = (R*Enthalpy_j+Enthalpy_i)/(R+1); - RoeSoundSpeed = sqrt(fabs((Gamma-1)*(RoeEnthalpy-0.5*sq_vel))); - RoePressure = RoeDensity/Gamma*RoeSoundSpeed*RoeSoundSpeed; - - /*--- Compute ProjFlux_i ---*/ - GetInviscidProjFlux(&Density_i, Velocity_i, &Pressure_i, &Enthalpy_i, Normal, ProjFlux_i); - - /*--- Compute ProjFlux_j ---*/ - GetInviscidProjFlux(&Density_j, Velocity_j, &Pressure_j, &Enthalpy_j, Normal, ProjFlux_j); - - ProjVelocity = 0.0; ProjVelocity_i = 0.0; ProjVelocity_j = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - ProjVelocity += RoeVelocity[iDim]*UnitNormal[iDim]; - ProjVelocity_i += Velocity_i[iDim]*UnitNormal[iDim]; - ProjVelocity_j += Velocity_j[iDim]*UnitNormal[iDim]; - } - - /*--- Projected velocity adjustment due to mesh motion ---*/ - if (dynamic_grid) { - su2double ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*UnitNormal[iDim]; - } - ProjVelocity -= ProjGridVel; - ProjVelocity_i -= ProjGridVel; - ProjVelocity_j -= ProjGridVel; - } - - /*--- First few flow eigenvalues of A.Normal with the normal---*/ - for (iDim = 0; iDim < nDim; iDim++) - Lambda[iDim] = ProjVelocity; - - local_Mach = sqrt(sq_vel)/RoeSoundSpeed; - Beta = max(Beta_min, min(local_Mach, Beta_max)); - Beta2 = Beta*Beta; - - one_m_Betasqr = 1.0 - Beta2; // 1-Beta*Beta - one_p_Betasqr = 1.0 + Beta2; // 1+Beta*Beta - sqr_one_m_Betasqr_Lam1 = pow((one_m_Betasqr*Lambda[0]),2); // [(1-Beta^2)*Lambda[0]]^2 - sqr_two_Beta_c_Area = pow(2.0*Beta*RoeSoundSpeed*Area,2); // [2*Beta*c*Area]^2 - - /*--- The rest of the flow eigenvalues of preconditioned matrix---*/ - Lambda[nVar-2] = 0.5 * ( one_p_Betasqr*Lambda[0] + sqrt( sqr_one_m_Betasqr_Lam1 + sqr_two_Beta_c_Area)); - Lambda[nVar-1] = 0.5 * ( one_p_Betasqr*Lambda[0] - sqrt( sqr_one_m_Betasqr_Lam1 + sqr_two_Beta_c_Area)); - - s_hat = 1.0/Area * (Lambda[nVar-1] - Lambda[0]*Beta2); - r_hat = 1.0/Area * (Lambda[nVar-2] - Lambda[0]*Beta2); - t_hat = 0.5/Area * (Lambda[nVar-1] - Lambda[nVar-2]); - rhoB2a2 = RoeDensity*Beta2*RoeSoundSpeed*RoeSoundSpeed; - - /*--- Diference variables iPoint and jPoint and absolute value of the eigen values---*/ - for (iVar = 0; iVar < nVar; iVar++) { - Diff_U[iVar] = U_j[iVar]-U_i[iVar]; - Lambda[iVar] = fabs(Lambda[iVar]); - } - - /*--- Compute the absolute Preconditioned Jacobian in entropic Variables (do it with the Unitary Normal) ---*/ - GetPrecondJacobian(Beta2, r_hat, s_hat, t_hat, rhoB2a2, Lambda, UnitNormal, absPeJac); - - /*--- Compute the matrix from entropic variables to conserved variables ---*/ - GetinvRinvPe(Beta2, RoeEnthalpy, RoeSoundSpeed, RoeDensity, RoeVelocity, invRinvPe); - - /*--- Compute the matrix from entropic variables to conserved variables ---*/ - GetRMatrix(RoePressure, RoeSoundSpeed, RoeDensity, RoeVelocity, R_Tensor); - - if (implicit) { - /*--- Jacobians of the inviscid flux, scaled by - 0.5 because val_residual ~ 0.5*(fc_i+fc_j)*Normal ---*/ - GetInviscidProjJac(Velocity_i, &Energy_i, Normal, 0.5, val_Jacobian_i); - GetInviscidProjJac(Velocity_j, &Energy_j, Normal, 0.5, val_Jacobian_j); - } - - for (iVar = 0; iVar < nVar; iVar ++) { - for (jVar = 0; jVar < nVar; jVar ++) { - Matrix[iVar][jVar] = 0.0; - for (kVar = 0; kVar < nVar; kVar++) - Matrix[iVar][jVar] += absPeJac[iVar][kVar]*R_Tensor[kVar][jVar]; - } - } - - for (iVar = 0; iVar < nVar; iVar ++) { - for (jVar = 0; jVar < nVar; jVar ++) { - Art_Visc[iVar][jVar] = 0.0; - for (kVar = 0; kVar < nVar; kVar++) - Art_Visc[iVar][jVar] += invRinvPe[iVar][kVar]*Matrix[kVar][jVar]; - } - } - - /*--- Roe's Flux approximation ---*/ - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] = 0.5*(ProjFlux_i[iVar]+ProjFlux_j[iVar]); - for (jVar = 0; jVar < nVar; jVar++) { - val_residual[iVar] -= 0.5*Art_Visc[iVar][jVar]*Diff_U[jVar]; - if (implicit) { - val_Jacobian_i[iVar][jVar] += 0.5*Art_Visc[iVar][jVar]; - val_Jacobian_j[iVar][jVar] -= 0.5*Art_Visc[iVar][jVar]; - } - } - } - - /*--- Contributions due to mesh motion---*/ - if (dynamic_grid) { - ProjVelocity = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjVelocity += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*UnitNormal[iDim]; - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] -= ProjVelocity * 0.5*(U_i[iVar]+U_j[iVar]); - /*--- Implicit terms ---*/ - if (implicit) { - val_Jacobian_i[iVar][iVar] -= 0.5*ProjVelocity; - val_Jacobian_j[iVar][iVar] -= 0.5*ProjVelocity; - } - } - } - -} - -CAvgGrad_Base::CAvgGrad_Base(unsigned short val_nDim, - unsigned short val_nVar, - unsigned short val_nPrimVar, - bool val_correct_grad, - CConfig *config) - : CNumerics(val_nDim, val_nVar, config), - nPrimVar(val_nPrimVar), - correct_gradient(val_correct_grad) { - - unsigned short iVar, iDim; - - implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - - TauWall_i = 0; TauWall_j = 0; - - PrimVar_i = new su2double [nPrimVar]; - PrimVar_j = new su2double [nPrimVar]; - Mean_PrimVar = new su2double [nPrimVar]; - - Mean_GradPrimVar = new su2double* [nPrimVar]; - for (iVar = 0; iVar < nPrimVar; iVar++) - Mean_GradPrimVar[iVar] = new su2double [nDim]; - - Edge_Vector = new su2double[nDim]; - - if (correct_gradient) { - Proj_Mean_GradPrimVar_Edge = new su2double[val_nPrimVar]; - } else { - Proj_Mean_GradPrimVar_Edge = NULL; - } - - tau_jacobian_i = new su2double* [nDim]; - for (iDim = 0; iDim < nDim; iDim++) { - tau_jacobian_i[iDim] = new su2double [nVar]; - } - heat_flux_vector = new su2double[nDim]; - heat_flux_jac_i = new su2double[nVar]; - -} - -CAvgGrad_Base::~CAvgGrad_Base() { - - delete [] PrimVar_i; - delete [] PrimVar_j; - delete [] Mean_PrimVar; - for (unsigned short iVar = 0; iVar < nPrimVar; iVar++) - delete [] Mean_GradPrimVar[iVar]; - delete [] Mean_GradPrimVar; - - if (tau_jacobian_i != NULL) { - for (unsigned short iDim = 0; iDim < nDim; iDim++) { - delete [] tau_jacobian_i[iDim]; - } - delete [] tau_jacobian_i; - } - if (heat_flux_vector != NULL) { - delete [] heat_flux_vector; - } - if (heat_flux_jac_i != NULL) { - delete [] heat_flux_jac_i; - } - - delete [] Edge_Vector; - if (Proj_Mean_GradPrimVar_Edge != NULL) - delete [] Proj_Mean_GradPrimVar_Edge; -} - -void CAvgGrad_Base::CorrectGradient(su2double** GradPrimVar, - const su2double* val_PrimVar_i, - const su2double* val_PrimVar_j, - const su2double* val_edge_vector, - const su2double val_dist_ij_2, - const unsigned short val_nPrimVar) { - for (unsigned short iVar = 0; iVar < val_nPrimVar; iVar++) { - Proj_Mean_GradPrimVar_Edge[iVar] = 0.0; - for (unsigned short iDim = 0; iDim < nDim; iDim++) { - Proj_Mean_GradPrimVar_Edge[iVar] += GradPrimVar[iVar][iDim]*val_edge_vector[iDim]; - } - for (unsigned short iDim = 0; iDim < nDim; iDim++) { - GradPrimVar[iVar][iDim] -= (Proj_Mean_GradPrimVar_Edge[iVar] - - (val_PrimVar_j[iVar]-val_PrimVar_i[iVar]))*val_edge_vector[iDim] / val_dist_ij_2; - } - } -} - -void CAvgGrad_Base::SetStressTensor(const su2double *val_primvar, - const su2double* const *val_gradprimvar, - const su2double val_turb_ke, - const su2double val_laminar_viscosity, - const su2double val_eddy_viscosity) { - - unsigned short iDim, jDim; - const su2double Density = val_primvar[nDim+2]; - const su2double total_viscosity = val_laminar_viscosity + val_eddy_viscosity; - - su2double div_vel = 0.0; - for (iDim = 0 ; iDim < nDim; iDim++) - div_vel += val_gradprimvar[iDim+1][iDim]; - - /* --- If UQ methodology is used, calculate tau using the perturbed reynolds stress tensor --- */ - - if (using_uq){ - for (iDim = 0 ; iDim < nDim; iDim++) - for (jDim = 0 ; jDim < nDim; jDim++) - tau[iDim][jDim] = val_laminar_viscosity*( val_gradprimvar[jDim+1][iDim] + val_gradprimvar[iDim+1][jDim] ) - - TWO3*val_laminar_viscosity*div_vel*delta[iDim][jDim] - Density * MeanPerturbedRSM[iDim][jDim]; - - } else { - - 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]; - } -} - -void CAvgGrad_Base::AddQCR(const su2double* const *val_gradprimvar) { - - su2double den_aux, c_cr1= 0.3, O_ik, O_jk; - unsigned short iDim, jDim, kDim; - - /*--- Denominator Antisymmetric normalized rotation tensor ---*/ - - den_aux = 0.0; - for (iDim = 0 ; iDim < nDim; iDim++) - for (jDim = 0 ; jDim < nDim; jDim++) - den_aux += val_gradprimvar[iDim+1][jDim] * val_gradprimvar[iDim+1][jDim]; - den_aux = sqrt(max(den_aux,1E-10)); - - /*--- Adding the QCR contribution ---*/ - - for (iDim = 0 ; iDim < nDim; iDim++){ - for (jDim = 0 ; jDim < nDim; jDim++){ - for (kDim = 0 ; kDim < nDim; kDim++){ - O_ik = (val_gradprimvar[iDim+1][kDim] - val_gradprimvar[kDim+1][iDim])/ den_aux; - O_jk = (val_gradprimvar[jDim+1][kDim] - val_gradprimvar[kDim+1][jDim])/ den_aux; - tau[iDim][jDim] -= c_cr1 * ((O_ik * tau[jDim][kDim]) + (O_jk * tau[iDim][kDim])); - } - } - } -} - -void CAvgGrad_Base::AddTauWall(const su2double *val_normal, - const su2double val_tau_wall) { - - unsigned short iDim, jDim; - su2double TauNormal, TauElem[3], TauTangent[3], WallShearStress, Area, UnitNormal[3]; - - Area = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - Area += val_normal[iDim]*val_normal[iDim]; - Area = sqrt(Area); - - for (iDim = 0; iDim < nDim; iDim++) - UnitNormal[iDim] = val_normal[iDim]/Area; - - /*--- First, compute wall shear stress as the magnitude of the wall-tangential - component of the shear stress tensor---*/ - - for (iDim = 0; iDim < nDim; iDim++) { - TauElem[iDim] = 0.0; - for (jDim = 0; jDim < nDim; jDim++) - TauElem[iDim] += tau[iDim][jDim]*UnitNormal[jDim]; - } - - TauNormal = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - TauNormal += TauElem[iDim] * UnitNormal[iDim]; - - for (iDim = 0; iDim < nDim; iDim++) - TauTangent[iDim] = TauElem[iDim] - TauNormal * UnitNormal[iDim]; - - WallShearStress = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - WallShearStress += TauTangent[iDim]*TauTangent[iDim]; - WallShearStress = sqrt(WallShearStress); - - /*--- Scale the stress tensor by the ratio of the wall shear stress - to the computed representation of the shear stress ---*/ - - for (iDim = 0 ; iDim < nDim; iDim++) - for (jDim = 0 ; jDim < nDim; jDim++) - tau[iDim][jDim] = tau[iDim][jDim]*(val_tau_wall/WallShearStress); -} - -void CAvgGrad_Base::GetMeanRateOfStrainMatrix(su2double **S_ij) const -{ - /* --- Calculate the rate of strain tensor, using mean velocity gradients --- */ - - if (nDim == 3){ - S_ij[0][0] = Mean_GradPrimVar[1][0]; - S_ij[1][1] = Mean_GradPrimVar[2][1]; - S_ij[2][2] = Mean_GradPrimVar[3][2]; - S_ij[0][1] = 0.5 * (Mean_GradPrimVar[1][1] + Mean_GradPrimVar[2][0]); - S_ij[0][2] = 0.5 * (Mean_GradPrimVar[1][2] + Mean_GradPrimVar[3][0]); - S_ij[1][2] = 0.5 * (Mean_GradPrimVar[2][2] + Mean_GradPrimVar[3][1]); - S_ij[1][0] = S_ij[0][1]; - S_ij[2][1] = S_ij[1][2]; - S_ij[2][0] = S_ij[0][2]; - } - else { - S_ij[0][0] = Mean_GradPrimVar[1][0]; - S_ij[1][1] = Mean_GradPrimVar[2][1]; - S_ij[2][2] = 0.0; - S_ij[0][1] = 0.5 * (Mean_GradPrimVar[1][1] + Mean_GradPrimVar[2][0]); - S_ij[0][2] = 0.0; - S_ij[1][2] = 0.0; - S_ij[1][0] = S_ij[0][1]; - S_ij[2][1] = S_ij[1][2]; - S_ij[2][0] = S_ij[0][2]; - - } -} - -void CAvgGrad_Base::SetReynoldsStressMatrix(su2double turb_ke){ - unsigned short iDim, jDim; - su2double **S_ij = new su2double* [3]; - su2double muT = Mean_Eddy_Viscosity; - su2double divVel = 0; - su2double density; - su2double TWO3 = 2.0/3.0; - density = Mean_PrimVar[nDim+2]; - - for (iDim = 0; iDim < 3; iDim++){ - S_ij[iDim] = new su2double [3]; - } - - - GetMeanRateOfStrainMatrix(S_ij); - - /* --- Using rate of strain matrix, calculate Reynolds stress tensor --- */ - - for (iDim = 0; iDim < 3; iDim++){ - divVel += S_ij[iDim][iDim]; - } - - for (iDim = 0; iDim < 3; iDim++){ - for (jDim = 0; jDim < 3; jDim++){ - MeanReynoldsStress[iDim][jDim] = TWO3 * turb_ke * delta3[iDim][jDim] - - muT / density * (2 * S_ij[iDim][jDim] - TWO3 * divVel * delta3[iDim][jDim]); - } - } - - for (iDim = 0; iDim < 3; iDim++) - delete [] S_ij[iDim]; - delete [] S_ij; -} - -void CAvgGrad_Base::SetPerturbedRSM(su2double turb_ke, CConfig *config){ - - unsigned short iDim,jDim; - - /* --- Calculate anisotropic part of Reynolds Stress tensor --- */ - - for (iDim = 0; iDim< 3; iDim++){ - for (jDim = 0; jDim < 3; jDim++){ - A_ij[iDim][jDim] = .5 * MeanReynoldsStress[iDim][jDim] / turb_ke - delta3[iDim][jDim] / 3.0; - Eig_Vec[iDim][jDim] = A_ij[iDim][jDim]; - } - } - - /* --- Get ordered eigenvectors and eigenvalues of A_ij --- */ - - EigenDecomposition(A_ij, Eig_Vec, Eig_Val, 3); - - /* compute convex combination coefficients */ - su2double c1c = Eig_Val[2] - Eig_Val[1]; - su2double c2c = 2.0 * (Eig_Val[1] - Eig_Val[0]); - su2double c3c = 3.0 * Eig_Val[0] + 1.0; - - /* define barycentric traingle corner points */ - Corners[0][0] = 1.0; - Corners[0][1] = 0.0; - Corners[1][0] = 0.0; - Corners[1][1] = 0.0; - Corners[2][0] = 0.5; - Corners[2][1] = 0.866025; - - /* define barycentric coordinates */ - Barycentric_Coord[0] = Corners[0][0] * c1c + Corners[1][0] * c2c + Corners[2][0] * c3c; - Barycentric_Coord[1] = Corners[0][1] * c1c + Corners[1][1] * c2c + Corners[2][1] * c3c; - - if (Eig_Val_Comp == 1) { - /* 1C turbulence */ - New_Coord[0] = Corners[0][0]; - New_Coord[1] = Corners[0][1]; - } - else if (Eig_Val_Comp== 2) { - /* 2C turbulence */ - New_Coord[0] = Corners[1][0]; - New_Coord[1] = Corners[1][1]; - } - else if (Eig_Val_Comp == 3) { - /* 3C turbulence */ - New_Coord[0] = Corners[2][0]; - New_Coord[1] = Corners[2][1]; - } - else { - /* 2C turbulence */ - New_Coord[0] = Corners[1][0]; - New_Coord[1] = Corners[1][1]; - } - - /* calculate perturbed barycentric coordinates */ - Barycentric_Coord[0] = Barycentric_Coord[0] + (uq_delta_b) * (New_Coord[0] - Barycentric_Coord[0]); - Barycentric_Coord[1] = Barycentric_Coord[1] + (uq_delta_b) * (New_Coord[1] - Barycentric_Coord[1]); - - /* rebuild c1c,c2c,c3c based on perturbed barycentric coordinates */ - c3c = Barycentric_Coord[1] / Corners[2][1]; - c1c = Barycentric_Coord[0] - Corners[2][0] * c3c; - c2c = 1 - c1c - c3c; - - /* build new anisotropy eigenvalues */ - Eig_Val[0] = (c3c - 1) / 3.0; - Eig_Val[1] = 0.5 *c2c + Eig_Val[0]; - Eig_Val[2] = c1c + Eig_Val[1]; - - /* permute eigenvectors if required */ - if (uq_permute) { - for (iDim=0; iDim<3; iDim++) { - for (jDim=0; jDim<3; jDim++) { - New_Eig_Vec[iDim][jDim] = Eig_Vec[2-iDim][jDim]; - } - } - } - - else { - for (iDim=0; iDim<3; iDim++) { - for (jDim=0; jDim<3; jDim++) { - New_Eig_Vec[iDim][jDim] = Eig_Vec[iDim][jDim]; - } - } - } - - EigenRecomposition(newA_ij, New_Eig_Vec, Eig_Val, 3); - - /* compute perturbed Reynolds stress matrix; use under-relaxation factor (uq_urlx)*/ - for (iDim = 0; iDim< 3; iDim++){ - for (jDim = 0; jDim < 3; jDim++){ - MeanPerturbedRSM[iDim][jDim] = 2.0 * turb_ke * (newA_ij[iDim][jDim] + 1.0/3.0 * delta3[iDim][jDim]); - MeanPerturbedRSM[iDim][jDim] = MeanReynoldsStress[iDim][jDim] + - uq_urlx*(MeanPerturbedRSM[iDim][jDim] - MeanReynoldsStress[iDim][jDim]); - } - } - -} - - -void CAvgGrad_Base::SetTauJacobian(const su2double *val_Mean_PrimVar, - const su2double val_laminar_viscosity, - const su2double val_eddy_viscosity, - const su2double val_dist_ij, - const su2double *val_normal) { - - /*--- QCR and wall functions are **not** accounted for here ---*/ - - const su2double Density = val_Mean_PrimVar[nDim+2]; - const su2double total_viscosity = val_laminar_viscosity + val_eddy_viscosity; - const su2double xi = total_viscosity/(Density*val_dist_ij); - - for (unsigned short iDim = 0; iDim < nDim; iDim++) { - for (unsigned short jDim = 0; jDim < nDim; jDim++) { - // Jacobian w.r.t. momentum - tau_jacobian_i[iDim][jDim+1] = -xi*(delta[iDim][jDim] + val_normal[iDim]*val_normal[jDim]/3.0); - } - // Jacobian w.r.t. density - tau_jacobian_i[iDim][0] = 0; - for (unsigned short jDim = 0; jDim < nDim; jDim++) { - tau_jacobian_i[iDim][0] -= tau_jacobian_i[iDim][jDim+1]*val_Mean_PrimVar[jDim+1]; - } - // Jacobian w.r.t. energy - tau_jacobian_i[iDim][nDim+1] = 0; - } -} - -void CAvgGrad_Base::SetIncTauJacobian(const su2double val_laminar_viscosity, - const su2double val_eddy_viscosity, - const su2double val_dist_ij, - const su2double *val_normal) { - - const su2double total_viscosity = val_laminar_viscosity + val_eddy_viscosity; - const su2double xi = total_viscosity/val_dist_ij; - - for (unsigned short iDim = 0; iDim < nDim; iDim++) { - tau_jacobian_i[iDim][0] = 0; - for (unsigned short jDim = 0; jDim < nDim; jDim++) { - tau_jacobian_i[iDim][jDim+1] = -xi*(delta[iDim][jDim] + val_normal[iDim]*val_normal[jDim]/3.0); - } - tau_jacobian_i[iDim][nDim+1] = 0; - } -} - -void CAvgGrad_Base::GetViscousProjFlux(const su2double *val_primvar, - const su2double *val_normal) { - - /*--- Primitive variables -> [Temp vel_x vel_y vel_z Pressure] ---*/ - - if (nDim == 2) { - Flux_Tensor[0][0] = 0.0; - Flux_Tensor[1][0] = tau[0][0]; - Flux_Tensor[2][0] = tau[0][1]; - Flux_Tensor[3][0] = tau[0][0]*val_primvar[1] + tau[0][1]*val_primvar[2]+ - heat_flux_vector[0]; - Flux_Tensor[0][1] = 0.0; - Flux_Tensor[1][1] = tau[1][0]; - Flux_Tensor[2][1] = tau[1][1]; - Flux_Tensor[3][1] = tau[1][0]*val_primvar[1] + tau[1][1]*val_primvar[2]+ - heat_flux_vector[1]; - } else { - Flux_Tensor[0][0] = 0.0; - Flux_Tensor[1][0] = tau[0][0]; - Flux_Tensor[2][0] = tau[0][1]; - Flux_Tensor[3][0] = tau[0][2]; - Flux_Tensor[4][0] = tau[0][0]*val_primvar[1] + tau[0][1]*val_primvar[2] + tau[0][2]*val_primvar[3] + - heat_flux_vector[0]; - Flux_Tensor[0][1] = 0.0; - Flux_Tensor[1][1] = tau[1][0]; - Flux_Tensor[2][1] = tau[1][1]; - Flux_Tensor[3][1] = tau[1][2]; - Flux_Tensor[4][1] = tau[1][0]*val_primvar[1] + tau[1][1]*val_primvar[2] + tau[1][2]*val_primvar[3] + - heat_flux_vector[1]; - Flux_Tensor[0][2] = 0.0; - Flux_Tensor[1][2] = tau[2][0]; - Flux_Tensor[2][2] = tau[2][1]; - Flux_Tensor[3][2] = tau[2][2]; - Flux_Tensor[4][2] = tau[2][0]*val_primvar[1] + tau[2][1]*val_primvar[2] + tau[2][2]*val_primvar[3] + - heat_flux_vector[2]; - } - - for (unsigned short iVar = 0; iVar < nVar; iVar++) { - Proj_Flux_Tensor[iVar] = 0.0; - for (unsigned short iDim = 0; iDim < nDim; iDim++) - Proj_Flux_Tensor[iVar] += Flux_Tensor[iVar][iDim] * val_normal[iDim]; - } - -} - -void CAvgGrad_Base::GetViscousProjJacs(const su2double *val_Mean_PrimVar, - const su2double val_dS, - const su2double *val_Proj_Visc_Flux, - su2double **val_Proj_Jac_Tensor_i, - su2double **val_Proj_Jac_Tensor_j) { - - const su2double Density = val_Mean_PrimVar[nDim+2]; - const su2double factor = 0.5/Density; - - if (nDim == 2) { - - val_Proj_Jac_Tensor_i[0][0] = 0.0; - val_Proj_Jac_Tensor_i[0][1] = 0.0; - val_Proj_Jac_Tensor_i[0][2] = 0.0; - val_Proj_Jac_Tensor_i[0][3] = 0.0; - val_Proj_Jac_Tensor_i[1][0] = val_dS*tau_jacobian_i[0][0]; - val_Proj_Jac_Tensor_i[1][1] = val_dS*tau_jacobian_i[0][1]; - val_Proj_Jac_Tensor_i[1][2] = val_dS*tau_jacobian_i[0][2]; - val_Proj_Jac_Tensor_i[1][3] = val_dS*tau_jacobian_i[0][3]; - val_Proj_Jac_Tensor_i[2][0] = val_dS*tau_jacobian_i[1][0]; - val_Proj_Jac_Tensor_i[2][1] = val_dS*tau_jacobian_i[1][1]; - val_Proj_Jac_Tensor_i[2][2] = val_dS*tau_jacobian_i[1][2]; - val_Proj_Jac_Tensor_i[2][3] = val_dS*tau_jacobian_i[1][3]; - const su2double contraction = tau_jacobian_i[0][0]*val_Mean_PrimVar[1] + - tau_jacobian_i[1][0]*val_Mean_PrimVar[2]; - val_Proj_Jac_Tensor_i[3][0] = val_dS*(contraction - heat_flux_jac_i[0]); - val_Proj_Jac_Tensor_i[3][1] = -val_dS*(tau_jacobian_i[0][0] + heat_flux_jac_i[1]); - val_Proj_Jac_Tensor_i[3][2] = -val_dS*(tau_jacobian_i[1][0] + heat_flux_jac_i[2]); - val_Proj_Jac_Tensor_i[3][3] = -val_dS*heat_flux_jac_i[3]; - - for (unsigned short iVar = 0; iVar < nVar; iVar++) - for (unsigned short jVar = 0; jVar < nVar; jVar++) - val_Proj_Jac_Tensor_j[iVar][jVar] = -val_Proj_Jac_Tensor_i[iVar][jVar]; - - const su2double proj_viscousflux_vel= val_Proj_Visc_Flux[1]*val_Mean_PrimVar[1] + - val_Proj_Visc_Flux[2]*val_Mean_PrimVar[2]; - val_Proj_Jac_Tensor_i[3][0] -= factor*proj_viscousflux_vel; - val_Proj_Jac_Tensor_j[3][0] -= factor*proj_viscousflux_vel; - val_Proj_Jac_Tensor_i[3][1] += factor*val_Proj_Visc_Flux[1]; - val_Proj_Jac_Tensor_j[3][1] += factor*val_Proj_Visc_Flux[1]; - val_Proj_Jac_Tensor_i[3][2] += factor*val_Proj_Visc_Flux[2]; - val_Proj_Jac_Tensor_j[3][2] += factor*val_Proj_Visc_Flux[2]; - - - } else { - - val_Proj_Jac_Tensor_i[0][0] = 0.0; - val_Proj_Jac_Tensor_i[0][1] = 0.0; - val_Proj_Jac_Tensor_i[0][2] = 0.0; - val_Proj_Jac_Tensor_i[0][3] = 0.0; - val_Proj_Jac_Tensor_i[0][4] = 0.0; - val_Proj_Jac_Tensor_i[1][0] = val_dS*tau_jacobian_i[0][0]; - val_Proj_Jac_Tensor_i[1][1] = val_dS*tau_jacobian_i[0][1]; - val_Proj_Jac_Tensor_i[1][2] = val_dS*tau_jacobian_i[0][2]; - val_Proj_Jac_Tensor_i[1][3] = val_dS*tau_jacobian_i[0][3]; - val_Proj_Jac_Tensor_i[1][4] = val_dS*tau_jacobian_i[0][4]; - val_Proj_Jac_Tensor_i[2][0] = val_dS*tau_jacobian_i[1][0]; - val_Proj_Jac_Tensor_i[2][1] = val_dS*tau_jacobian_i[1][1]; - val_Proj_Jac_Tensor_i[2][2] = val_dS*tau_jacobian_i[1][2]; - val_Proj_Jac_Tensor_i[2][3] = val_dS*tau_jacobian_i[1][3]; - val_Proj_Jac_Tensor_i[2][4] = val_dS*tau_jacobian_i[1][4]; - val_Proj_Jac_Tensor_i[3][0] = val_dS*tau_jacobian_i[2][0]; - val_Proj_Jac_Tensor_i[3][1] = val_dS*tau_jacobian_i[2][1]; - val_Proj_Jac_Tensor_i[3][2] = val_dS*tau_jacobian_i[2][2]; - val_Proj_Jac_Tensor_i[3][3] = val_dS*tau_jacobian_i[2][3]; - val_Proj_Jac_Tensor_i[3][4] = val_dS*tau_jacobian_i[2][4]; - const su2double contraction = tau_jacobian_i[0][0]*val_Mean_PrimVar[1] + - tau_jacobian_i[1][0]*val_Mean_PrimVar[2] + - tau_jacobian_i[2][0]*val_Mean_PrimVar[3]; - val_Proj_Jac_Tensor_i[4][0] = val_dS*(contraction - heat_flux_jac_i[0]); - val_Proj_Jac_Tensor_i[4][1] = -val_dS*(tau_jacobian_i[0][0] + heat_flux_jac_i[1]); - val_Proj_Jac_Tensor_i[4][2] = -val_dS*(tau_jacobian_i[1][0] + heat_flux_jac_i[2]); - val_Proj_Jac_Tensor_i[4][3] = -val_dS*(tau_jacobian_i[2][0] + heat_flux_jac_i[3]); - val_Proj_Jac_Tensor_i[4][4] = -val_dS*heat_flux_jac_i[4]; - - for (unsigned short iVar = 0; iVar < nVar; iVar++) - for (unsigned short jVar = 0; jVar < nVar; jVar++) - val_Proj_Jac_Tensor_j[iVar][jVar] = -val_Proj_Jac_Tensor_i[iVar][jVar]; - - const su2double proj_viscousflux_vel= val_Proj_Visc_Flux[1]*val_Mean_PrimVar[1] + - val_Proj_Visc_Flux[2]*val_Mean_PrimVar[2] + - val_Proj_Visc_Flux[3]*val_Mean_PrimVar[3]; - val_Proj_Jac_Tensor_i[4][0] -= factor*proj_viscousflux_vel; - val_Proj_Jac_Tensor_j[4][0] -= factor*proj_viscousflux_vel; - val_Proj_Jac_Tensor_i[4][1] += factor*val_Proj_Visc_Flux[1]; - val_Proj_Jac_Tensor_j[4][1] += factor*val_Proj_Visc_Flux[1]; - val_Proj_Jac_Tensor_i[4][2] += factor*val_Proj_Visc_Flux[2]; - val_Proj_Jac_Tensor_j[4][2] += factor*val_Proj_Visc_Flux[2]; - val_Proj_Jac_Tensor_i[4][3] += factor*val_Proj_Visc_Flux[3]; - val_Proj_Jac_Tensor_j[4][3] += factor*val_Proj_Visc_Flux[3]; - - } - -} - -CAvgGrad_Flow::CAvgGrad_Flow(unsigned short val_nDim, - unsigned short val_nVar, - bool val_correct_grad, - CConfig *config) - : CAvgGrad_Base(val_nDim, val_nVar, val_nDim+3, val_correct_grad, config) { - -} - -CAvgGrad_Flow::~CAvgGrad_Flow(void) { - -} - -void CAvgGrad_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - AD::StartPreacc(); - AD::SetPreaccIn(V_i, nDim+9); AD::SetPreaccIn(V_j, nDim+9); - AD::SetPreaccIn(Coord_i, nDim); AD::SetPreaccIn(Coord_j, nDim); - AD::SetPreaccIn(PrimVar_Grad_i, nDim+1, nDim); - AD::SetPreaccIn(PrimVar_Grad_j, nDim+1, nDim); - AD::SetPreaccIn(turb_ke_i); AD::SetPreaccIn(turb_ke_j); - AD::SetPreaccIn(Normal, nDim); - - unsigned short iVar, jVar, iDim; - - /*--- Normalized normal vector ---*/ - - 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; - - for (iVar = 0; iVar < nPrimVar; iVar++) { - PrimVar_i[iVar] = V_i[iVar]; - PrimVar_j[iVar] = V_j[iVar]; - Mean_PrimVar[iVar] = 0.5*(PrimVar_i[iVar]+PrimVar_j[iVar]); - } - - - /*--- Compute vector going from iPoint to jPoint ---*/ - - dist_ij_2 = 0.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]; - } - - /*--- Laminar and Eddy viscosity ---*/ - - Laminar_Viscosity_i = V_i[nDim+5]; Laminar_Viscosity_j = V_j[nDim+5]; - Eddy_Viscosity_i = V_i[nDim+6]; Eddy_Viscosity_j = V_j[nDim+6]; - - /*--- Mean Viscosities and turbulent kinetic energy---*/ - - Mean_Laminar_Viscosity = 0.5*(Laminar_Viscosity_i + Laminar_Viscosity_j); - Mean_Eddy_Viscosity = 0.5*(Eddy_Viscosity_i + Eddy_Viscosity_j); - Mean_turb_ke = 0.5*(turb_ke_i + turb_ke_j); - - /*--- Mean gradient approximation ---*/ - - for (iVar = 0; iVar < nDim+1; iVar++) { - for (iDim = 0; iDim < nDim; iDim++) { - Mean_GradPrimVar[iVar][iDim] = 0.5*(PrimVar_Grad_i[iVar][iDim] + PrimVar_Grad_j[iVar][iDim]); - } - } - - /*--- Projection of the mean gradient in the direction of the edge ---*/ - - if (correct_gradient && dist_ij_2 != 0.0) { - CorrectGradient(Mean_GradPrimVar, PrimVar_i, PrimVar_j, Edge_Vector, - dist_ij_2, nDim+1); - } - - /*--- Wall shear stress values (wall functions) ---*/ - - if (TauWall_i > 0.0 && TauWall_j > 0.0) Mean_TauWall = 0.5*(TauWall_i + TauWall_j); - else if (TauWall_i > 0.0) Mean_TauWall = TauWall_i; - else if (TauWall_j > 0.0) Mean_TauWall = TauWall_j; - else Mean_TauWall = -1.0; - - /* --- If using UQ methodology, set Reynolds Stress tensor and perform perturbation--- */ - - if (using_uq){ - SetReynoldsStressMatrix(Mean_turb_ke); - SetPerturbedRSM(Mean_turb_ke, config); - } - - /*--- Get projected flux tensor ---*/ - - SetStressTensor(Mean_PrimVar, Mean_GradPrimVar, Mean_turb_ke, - Mean_Laminar_Viscosity, Mean_Eddy_Viscosity); - if (config->GetQCR()) AddQCR(Mean_GradPrimVar); - if (Mean_TauWall > 0) AddTauWall(Normal, Mean_TauWall); - - SetHeatFluxVector(Mean_GradPrimVar, Mean_Laminar_Viscosity, - Mean_Eddy_Viscosity); - - GetViscousProjFlux(Mean_PrimVar, Normal); - - /*--- Update viscous residual ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_residual[iVar] = Proj_Flux_Tensor[iVar]; - - /*--- Compute the implicit part ---*/ - - if (implicit) { - - if (dist_ij_2 == 0.0) { - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - val_Jacobian_i[iVar][jVar] = 0.0; - val_Jacobian_j[iVar][jVar] = 0.0; - } - } - } else { - const su2double dist_ij = sqrt(dist_ij_2); - SetTauJacobian(Mean_PrimVar, Mean_Laminar_Viscosity, Mean_Eddy_Viscosity, - dist_ij, UnitNormal); - SetHeatFluxJacobian(Mean_PrimVar, Mean_Laminar_Viscosity, - Mean_Eddy_Viscosity, dist_ij, UnitNormal); - GetViscousProjJacs(Mean_PrimVar, Area, Proj_Flux_Tensor, - val_Jacobian_i, val_Jacobian_j); - } - - } - - AD::SetPreaccOut(val_residual, nVar); - AD::EndPreacc(); - -} - - - -void CAvgGrad_Flow::SetHeatFluxVector(const su2double* const *val_gradprimvar, - const su2double val_laminar_viscosity, - const su2double val_eddy_viscosity) { - - const su2double Cp = (Gamma / Gamma_Minus_One) * Gas_Constant; - const su2double heat_flux_factor = Cp * (val_laminar_viscosity/Prandtl_Lam + val_eddy_viscosity/Prandtl_Turb); - - /*--- Gradient of primitive variables -> [Temp vel_x vel_y vel_z Pressure] ---*/ - - for (unsigned short iDim = 0; iDim < nDim; iDim++) { - heat_flux_vector[iDim] = heat_flux_factor*val_gradprimvar[0][iDim]; - } -} - -void CAvgGrad_Flow::SetHeatFluxJacobian(const su2double *val_Mean_PrimVar, - const su2double val_laminar_viscosity, - const su2double val_eddy_viscosity, - const su2double val_dist_ij, - const su2double *val_normal) { - su2double sqvel = 0.0; - - for (unsigned short iDim = 0; iDim < nDim; iDim++) { - sqvel += val_Mean_PrimVar[iDim+1]*val_Mean_PrimVar[iDim+1]; - } - - const su2double Density = val_Mean_PrimVar[nDim+2]; - const su2double Pressure = val_Mean_PrimVar[nDim+1]; - const su2double phi = Gamma_Minus_One/Density; - - /*--- R times partial derivatives of temp. ---*/ - - const su2double R_dTdu0 = -Pressure/(Density*Density) + 0.5*sqvel*phi; - const su2double R_dTdu1 = -phi*val_Mean_PrimVar[1]; - const su2double R_dTdu2 = -phi*val_Mean_PrimVar[2]; - - const su2double heat_flux_factor = val_laminar_viscosity/Prandtl_Lam + val_eddy_viscosity/Prandtl_Turb; - const su2double cpoR = Gamma/Gamma_Minus_One; // cp over R - const su2double conductivity_over_Rd = cpoR*heat_flux_factor/val_dist_ij; - - heat_flux_jac_i[0] = conductivity_over_Rd * R_dTdu0; - heat_flux_jac_i[1] = conductivity_over_Rd * R_dTdu1; - heat_flux_jac_i[2] = conductivity_over_Rd * R_dTdu2; - - if (nDim == 2) { - - const su2double R_dTdu3 = phi; - heat_flux_jac_i[3] = conductivity_over_Rd * R_dTdu3; - - } else { - - const su2double R_dTdu3 = -phi*val_Mean_PrimVar[3]; - const su2double R_dTdu4 = phi; - heat_flux_jac_i[3] = conductivity_over_Rd * R_dTdu3; - heat_flux_jac_i[4] = conductivity_over_Rd * R_dTdu4; - - } -} - - -CGeneralAvgGrad_Flow::CGeneralAvgGrad_Flow(unsigned short val_nDim, - unsigned short val_nVar, - bool val_correct_grad, - CConfig *config) - : CAvgGrad_Base(val_nDim, val_nVar, val_nDim+4, val_correct_grad, config) { - - Mean_SecVar = new su2double [2]; - -} - -CGeneralAvgGrad_Flow::~CGeneralAvgGrad_Flow(void) { - - delete [] Mean_SecVar; - -} - -void CGeneralAvgGrad_Flow::SetHeatFluxVector(const su2double* const *val_gradprimvar, - const su2double val_laminar_viscosity, - const su2double val_eddy_viscosity, - const su2double val_thermal_conductivity, - const su2double val_heat_capacity_cp) { - - const su2double heat_flux_factor = val_thermal_conductivity + val_heat_capacity_cp*val_eddy_viscosity/Prandtl_Turb; - - /*--- Gradient of primitive variables -> [Temp vel_x vel_y vel_z Pressure] ---*/ - for (unsigned short iDim = 0; iDim < nDim; iDim++) { - heat_flux_vector[iDim] = heat_flux_factor*val_gradprimvar[0][iDim]; - } -} - -void CGeneralAvgGrad_Flow::SetHeatFluxJacobian(const su2double *val_Mean_PrimVar, - const su2double *val_Mean_SecVar, - const su2double val_eddy_viscosity, - const su2double val_thermal_conductivity, - const su2double val_heat_capacity_cp, - const su2double val_dist_ij) { - /* Viscous flux Jacobians for arbitrary equations of state */ - - //order of val_mean_primitives: T, vx, vy, vz, P, rho, ht - //order of secondary:dTdrho_e, dTde_rho - - su2double sqvel = 0.0; - for (unsigned short iDim = 0; iDim < nDim; iDim++) { - sqvel += val_Mean_PrimVar[iDim+1]*val_Mean_PrimVar[iDim+1]; - } - - su2double rho = val_Mean_PrimVar[nDim+2]; - su2double P= val_Mean_PrimVar[nDim+1]; - su2double h= val_Mean_PrimVar[nDim+3]; - su2double dTdrho_e= val_Mean_SecVar[0]; - su2double dTde_rho= val_Mean_SecVar[1]; - - su2double dTdu0= dTdrho_e + dTde_rho*(-(h-P/rho) + sqvel)*(1/rho); - su2double dTdu1= dTde_rho*(-val_Mean_PrimVar[1])*(1/rho); - su2double dTdu2= dTde_rho*(-val_Mean_PrimVar[2])*(1/rho); - - su2double total_conductivity = val_thermal_conductivity + val_heat_capacity_cp*val_eddy_viscosity/Prandtl_Turb; - su2double factor2 = total_conductivity/val_dist_ij; - - heat_flux_jac_i[0] = factor2*dTdu0; - heat_flux_jac_i[1] = factor2*dTdu1; - heat_flux_jac_i[2] = factor2*dTdu2; - - if (nDim == 2) { - - su2double dTdu3= dTde_rho*(1/rho); - heat_flux_jac_i[3] = factor2*dTdu3; - - } else { - - su2double dTdu3= dTde_rho*(-val_Mean_PrimVar[3])*(1/rho); - su2double dTdu4= dTde_rho*(1/rho); - heat_flux_jac_i[3] = factor2*dTdu3; - heat_flux_jac_i[4] = factor2*dTdu4; - - } - -} - -void CGeneralAvgGrad_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - AD::StartPreacc(); - AD::SetPreaccIn(V_i, nDim+9); AD::SetPreaccIn(V_j, nDim+9); - AD::SetPreaccIn(Coord_i, nDim); AD::SetPreaccIn(Coord_j, nDim); - AD::SetPreaccIn(S_i, 4); AD::SetPreaccIn(S_j, 4); - AD::SetPreaccIn(PrimVar_Grad_i, nDim+1, nDim); - AD::SetPreaccIn(PrimVar_Grad_j, nDim+1, nDim); - AD::SetPreaccIn(turb_ke_i); AD::SetPreaccIn(turb_ke_j); - AD::SetPreaccIn(Normal, nDim); - - unsigned short iVar, jVar, iDim; - - /*--- Normalized normal vector ---*/ - - 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; - - /*--- Mean primitive variables ---*/ - - for (iVar = 0; iVar < nPrimVar; iVar++) { - PrimVar_i[iVar] = V_i[iVar]; - PrimVar_j[iVar] = V_j[iVar]; - Mean_PrimVar[iVar] = 0.5*(PrimVar_i[iVar]+PrimVar_j[iVar]); - } - - /*--- Compute vector going from iPoint to jPoint ---*/ - - dist_ij_2 = 0.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]; - } - - /*--- Laminar and Eddy viscosity ---*/ - - Laminar_Viscosity_i = V_i[nDim+5]; Laminar_Viscosity_j = V_j[nDim+5]; - Eddy_Viscosity_i = V_i[nDim+6]; Eddy_Viscosity_j = V_j[nDim+6]; - Thermal_Conductivity_i = V_i[nDim+7]; Thermal_Conductivity_j = V_j[nDim+7]; - Cp_i = V_i[nDim+8]; Cp_j = V_j[nDim+8]; - - /*--- Mean secondary variables ---*/ - - for (iVar = 0; iVar < 2; iVar++) { - Mean_SecVar[iVar] = 0.5*(S_i[iVar+2]+S_j[iVar+2]); - } - - /*--- Mean Viscosities and turbulent kinetic energy---*/ - - Mean_Laminar_Viscosity = 0.5*(Laminar_Viscosity_i + Laminar_Viscosity_j); - Mean_Eddy_Viscosity = 0.5*(Eddy_Viscosity_i + Eddy_Viscosity_j); - Mean_turb_ke = 0.5*(turb_ke_i + turb_ke_j); - Mean_Thermal_Conductivity = 0.5*(Thermal_Conductivity_i + Thermal_Conductivity_j); - Mean_Cp = 0.5*(Cp_i + Cp_j); - - /*--- Mean gradient approximation ---*/ - - for (iVar = 0; iVar < nDim+1; iVar++) { - for (iDim = 0; iDim < nDim; iDim++) { - Mean_GradPrimVar[iVar][iDim] = 0.5*(PrimVar_Grad_i[iVar][iDim] + PrimVar_Grad_j[iVar][iDim]); - } - } - - /*--- Projection of the mean gradient in the direction of the edge ---*/ - - if (correct_gradient && dist_ij_2 != 0.0) { - CorrectGradient(Mean_GradPrimVar, PrimVar_i, PrimVar_j, Edge_Vector, - dist_ij_2, nDim+1); - } - - /* --- If using UQ methodology, set Reynolds Stress tensor and perform perturbation--- */ - - if (using_uq){ - SetReynoldsStressMatrix(Mean_turb_ke); - SetPerturbedRSM(Mean_turb_ke, config); - } - - /*--- Get projected flux tensor ---*/ - - SetStressTensor(Mean_PrimVar, Mean_GradPrimVar, Mean_turb_ke, - Mean_Laminar_Viscosity, Mean_Eddy_Viscosity); - - SetHeatFluxVector(Mean_GradPrimVar, Mean_Laminar_Viscosity, - Mean_Eddy_Viscosity, Mean_Thermal_Conductivity, Mean_Cp); - - GetViscousProjFlux(Mean_PrimVar, Normal); - - /*--- Update viscous residual ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_residual[iVar] = Proj_Flux_Tensor[iVar]; - - /*--- Compute the implicit part ---*/ - - if (implicit) { - - if (dist_ij_2 == 0.0) { - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - val_Jacobian_i[iVar][jVar] = 0.0; - val_Jacobian_j[iVar][jVar] = 0.0; - } - } - } else { - const su2double dist_ij = sqrt(dist_ij_2); - SetTauJacobian(Mean_PrimVar, Mean_Laminar_Viscosity, Mean_Eddy_Viscosity, - dist_ij, UnitNormal); - SetHeatFluxJacobian(Mean_PrimVar, Mean_SecVar, Mean_Eddy_Viscosity, - Mean_Thermal_Conductivity, Mean_Cp, dist_ij); - GetViscousProjJacs(Mean_PrimVar, Area, Proj_Flux_Tensor, - val_Jacobian_i, val_Jacobian_j); - } - - } - - AD::SetPreaccOut(val_residual, nVar); - AD::EndPreacc(); - -} - -CSourceGravity::CSourceGravity(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - -} - -CSourceGravity::~CSourceGravity(void) { } - -void CSourceGravity::ComputeResidual(su2double *val_residual, CConfig *config) { - unsigned short iVar; - - for (iVar = 0; iVar < nVar; iVar++) - val_residual[iVar] = 0.0; - - /*--- Evaluate the source term ---*/ - val_residual[nDim] = Volume * U_i[0] * STANDARD_GRAVITY; - -} - -CSourceBodyForce::CSourceBodyForce(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - /*--- Store the pointer to the constant body force vector. ---*/ - - Body_Force_Vector = new su2double[nDim]; - for (unsigned short iDim = 0; iDim < nDim; iDim++) - Body_Force_Vector[iDim] = config->GetBody_Force_Vector()[iDim]; - -} - -CSourceBodyForce::~CSourceBodyForce(void) { - - if (Body_Force_Vector != NULL) delete [] Body_Force_Vector; - -} - -void CSourceBodyForce::ComputeResidual(su2double *val_residual, CConfig *config) { - - unsigned short iDim; - su2double Force_Ref = config->GetForce_Ref(); - - /*--- Zero the continuity contribution ---*/ - - val_residual[0] = 0.0; - - /*--- Momentum contribution ---*/ - - for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = -Volume * U_i[0] * Body_Force_Vector[iDim] / Force_Ref; - - /*--- Energy contribution ---*/ - - val_residual[nDim+1] = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - val_residual[nDim+1] += -Volume * U_i[iDim+1] * Body_Force_Vector[iDim] / Force_Ref; - -} - -CSourceRotatingFrame_Flow::CSourceRotatingFrame_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - -} - -CSourceRotatingFrame_Flow::~CSourceRotatingFrame_Flow(void) { } - -void CSourceRotatingFrame_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config) { - - unsigned short iDim, iVar, jVar; - su2double Omega[3] = {0,0,0}, Momentum[3] = {0,0,0}; - - bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - - /*--- Retrieve the angular velocity vector from config. ---*/ - - for (iDim = 0; iDim < 3; iDim++){ - Omega[iDim] = config->GetRotation_Rate(iDim)/config->GetOmega_Ref(); - } - - /*--- Get the momentum vector at the current node. ---*/ - - for (iDim = 0; iDim < nDim; iDim++) - Momentum[iDim] = U_i[iDim+1]; - - /*--- Calculate rotating frame source term as ( Omega X Rho-U ) ---*/ - - if (nDim == 2) { - val_residual[0] = 0.0; - val_residual[1] = (Omega[1]*Momentum[2] - Omega[2]*Momentum[1])*Volume; - val_residual[2] = (Omega[2]*Momentum[0] - Omega[0]*Momentum[2])*Volume; - val_residual[3] = 0.0; - } else { - val_residual[0] = 0.0; - val_residual[1] = (Omega[1]*Momentum[2] - Omega[2]*Momentum[1])*Volume; - val_residual[2] = (Omega[2]*Momentum[0] - Omega[0]*Momentum[2])*Volume; - val_residual[3] = (Omega[0]*Momentum[1] - Omega[1]*Momentum[0])*Volume; - val_residual[4] = 0.0; - } - - /*--- Calculate the source term Jacobian ---*/ - - if (implicit) { - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_i[iVar][jVar] = 0.0; - if (nDim == 2) { - val_Jacobian_i[1][2] = -Omega[2]*Volume; - val_Jacobian_i[2][1] = Omega[2]*Volume; - } else { - val_Jacobian_i[1][2] = -Omega[2]*Volume; - val_Jacobian_i[1][3] = Omega[1]*Volume; - val_Jacobian_i[2][1] = Omega[2]*Volume; - val_Jacobian_i[2][3] = -Omega[0]*Volume; - val_Jacobian_i[3][1] = -Omega[1]*Volume; - val_Jacobian_i[3][2] = Omega[0]*Volume; - } - } - -} - -CSourceAxisymmetric_Flow::CSourceAxisymmetric_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - -} - -CSourceAxisymmetric_Flow::~CSourceAxisymmetric_Flow(void) { } - -void CSourceAxisymmetric_Flow::ComputeResidual(su2double *val_residual, su2double **Jacobian_i, CConfig *config) { - - su2double yinv, Pressure_i, Enthalpy_i, Velocity_i, sq_vel; - unsigned short iDim, iVar, jVar; - - bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - - if (Coord_i[1] > EPS) { - - yinv = 1.0/Coord_i[1]; - - sq_vel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i = U_i[iDim+1] / U_i[0]; - sq_vel += Velocity_i *Velocity_i; - } - - Pressure_i = (Gamma-1.0)*U_i[0]*(U_i[nDim+1]/U_i[0]-0.5*sq_vel); - Enthalpy_i = (U_i[nDim+1] + Pressure_i) / U_i[0]; - - val_residual[0] = yinv*Volume*U_i[2]; - val_residual[1] = yinv*Volume*U_i[1]*U_i[2]/U_i[0]; - val_residual[2] = yinv*Volume*(U_i[2]*U_i[2]/U_i[0]); - val_residual[3] = yinv*Volume*Enthalpy_i*U_i[2]; - - if (implicit) { - Jacobian_i[0][0] = 0.0; - Jacobian_i[0][1] = 0.0; - Jacobian_i[0][2] = 1.0; - Jacobian_i[0][3] = 0.0; - - Jacobian_i[1][0] = -U_i[1]*U_i[2]/(U_i[0]*U_i[0]); - Jacobian_i[1][1] = U_i[2]/U_i[0]; - Jacobian_i[1][2] = U_i[1]/U_i[0]; - Jacobian_i[1][3] = 0.0; - - Jacobian_i[2][0] = -U_i[2]*U_i[2]/(U_i[0]*U_i[0]); - Jacobian_i[2][1] = 0.0; - Jacobian_i[2][2] = 2*U_i[2]/U_i[0]; - Jacobian_i[2][3] = 0.0; - - Jacobian_i[3][0] = -Gamma*U_i[2]*U_i[3]/(U_i[0]*U_i[0]) + (Gamma-1)*U_i[2]*(U_i[1]*U_i[1]+U_i[2]*U_i[2])/(U_i[0]*U_i[0]*U_i[0]); - Jacobian_i[3][1] = -(Gamma-1)*U_i[2]*U_i[1]/(U_i[0]*U_i[0]); - Jacobian_i[3][2] = Gamma*U_i[3]/U_i[0] - 1/2*(Gamma-1)*( (U_i[1]*U_i[1]+U_i[2]*U_i[2])/(U_i[0]*U_i[0]) + 2*U_i[2]*U_i[2]/(U_i[0]*U_i[0]) ); - Jacobian_i[3][3] = Gamma*U_i[2]/U_i[0]; - - for (iVar=0; iVar < nVar; iVar++) - for (jVar=0; jVar < nVar; jVar++) - Jacobian_i[iVar][jVar] *= yinv*Volume; - - } - - } - - else { - - for (iVar=0; iVar < nVar; iVar++) - val_residual[iVar] = 0.0; - - if (implicit) { - for (iVar=0; iVar < nVar; iVar++) { - for (jVar=0; jVar < nVar; jVar++) - Jacobian_i[iVar][jVar] = 0.0; - } - } - - } - -} - -CSourceWindGust::CSourceWindGust(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - -} - -CSourceWindGust::~CSourceWindGust(void) { } - -void CSourceWindGust::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config) { - - su2double u_gust, v_gust, du_gust_dx, du_gust_dy, du_gust_dt, dv_gust_dx, dv_gust_dy, dv_gust_dt, smx, smy, se, rho, u, v, p; - unsigned short GustDir = config->GetGust_Dir(); //Gust direction - - u_gust = WindGust_i[0]; - v_gust = WindGust_i[1]; - - if (GustDir == X_DIR) { - du_gust_dx = WindGustDer_i[0]; - du_gust_dy = WindGustDer_i[1]; - du_gust_dt = WindGustDer_i[2]; - dv_gust_dx = 0.0; - dv_gust_dy = 0.0; - dv_gust_dt = 0.0; - } else { - du_gust_dx = 0.0; - du_gust_dy = 0.0; - du_gust_dt = 0.0; - dv_gust_dx = WindGustDer_i[0]; - dv_gust_dy = WindGustDer_i[1]; - dv_gust_dt = WindGustDer_i[2]; - - } - - /*--- Primitive variables at point i ---*/ - u = V_i[1]; - v = V_i[2]; - p = V_i[nDim+1]; - rho = V_i[nDim+2]; - - /*--- Source terms ---*/ - smx = rho*(du_gust_dt + (u+u_gust)*du_gust_dx + (v+v_gust)*du_gust_dy); - smy = rho*(dv_gust_dt + (u+u_gust)*dv_gust_dx + (v+v_gust)*dv_gust_dy); - se = u*smx + v*smy + p*(du_gust_dx + dv_gust_dy); - - if (nDim == 2) { - val_residual[0] = 0.0; - val_residual[1] = smx*Volume; - val_residual[2] = smy*Volume; - val_residual[3] = se*Volume; - } else { - SU2_MPI::Error("You should only be in the gust source term in two dimensions", CURRENT_FUNCTION); - } - - /*--- For now the source term Jacobian is just set to zero ---*/ - - unsigned short iVar, jVar; - bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - - /*--- Calculate the source term Jacobian ---*/ - - if (implicit) { - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_i[iVar][jVar] = 0.0; - } - -} diff --git a/SU2_CFD/src/numerics_direct_mean_inc.cpp b/SU2_CFD/src/numerics_direct_mean_inc.cpp deleted file mode 100644 index 5437f1b37c7a..000000000000 --- a/SU2_CFD/src/numerics_direct_mean_inc.cpp +++ /dev/null @@ -1,1219 +0,0 @@ -/*! - * \file numerics_direct_mean_inc.cpp - * \brief This file contains the numerical methods for incompressible flow. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - - -#include "../include/numerics_structure.hpp" -#include - -CUpwFDSInc_Flow::CUpwFDSInc_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - variable_density = (config->GetKind_DensityModel() == VARIABLE); - energy = config->GetEnergy_Equation(); - /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ - dynamic_grid = config->GetDynamic_Grid(); - - Diff_V = new su2double[nVar]; - Velocity_i = new su2double[nDim]; - Velocity_j = new su2double[nDim]; - MeanVelocity = new su2double[nDim]; - ProjFlux_i = new su2double[nVar]; - ProjFlux_j = new su2double[nVar]; - Lambda = new su2double[nVar]; - Epsilon = new su2double[nVar]; - Precon = new su2double*[nVar]; - invPrecon_A = new su2double*[nVar]; - - for (iVar = 0; iVar < nVar; iVar++) { - Precon[iVar] = new su2double[nVar]; - invPrecon_A[iVar] = new su2double[nVar]; - } - -} - -CUpwFDSInc_Flow::~CUpwFDSInc_Flow(void) { - - delete [] Diff_V; - delete [] Velocity_i; - delete [] Velocity_j; - delete [] MeanVelocity; - delete [] ProjFlux_i; - delete [] ProjFlux_j; - delete [] Lambda; - delete [] Epsilon; - - for (iVar = 0; iVar < nVar; iVar++) { - delete [] Precon[iVar]; - delete [] invPrecon_A[iVar]; - } - delete [] Precon; - delete [] invPrecon_A; - -} - -void CUpwFDSInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - su2double U_i[5] = {0.0,0.0,0.0,0.0,0.0}, U_j[5] = {0.0,0.0,0.0,0.0,0.0}; - su2double ProjGridVel = 0.0; - - AD::StartPreacc(); - AD::SetPreaccIn(V_i, nDim+9); AD::SetPreaccIn(V_j, nDim+9); AD::SetPreaccIn(Normal, nDim); - if (dynamic_grid) { - AD::SetPreaccIn(GridVel_i, nDim); - AD::SetPreaccIn(GridVel_j, nDim); - } - - /*--- Face area (norm or the normal vector) ---*/ - - Area = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - Area += Normal[iDim]*Normal[iDim]; - Area = sqrt(Area); - - /*--- Compute and unitary normal vector ---*/ - - for (iDim = 0; iDim < nDim; iDim++) { - UnitNormal[iDim] = Normal[iDim]/Area; - if (fabs(UnitNormal[iDim]) < EPS) UnitNormal[iDim] = EPS; - } - - /*--- Set primitive variables at points iPoint and jPoint ---*/ - - Pressure_i = V_i[0]; Pressure_j = V_j[0]; - Temperature_i = V_i[nDim+1]; Temperature_j = V_j[nDim+1]; - DensityInc_i = V_i[nDim+2]; DensityInc_j = V_j[nDim+2]; - BetaInc2_i = V_i[nDim+3]; BetaInc2_j = V_j[nDim+3]; - Cp_i = V_i[nDim+7]; Cp_j = V_j[nDim+7]; - Enthalpy_i = Cp_i*Temperature_i; Enthalpy_j = Cp_j*Temperature_j; - - ProjVelocity = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = V_i[iDim+1]; - Velocity_j[iDim] = V_j[iDim+1]; - MeanVelocity[iDim] = 0.5*(Velocity_i[iDim] + Velocity_j[iDim]); - ProjVelocity += MeanVelocity[iDim]*Normal[iDim]; - } - - /*--- Projected velocity adjustment due to mesh motion ---*/ - - if (dynamic_grid) { - ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - } - ProjVelocity -= ProjGridVel; - } - - /*--- Mean variables at points iPoint and jPoint ---*/ - - MeanDensity = 0.5*(DensityInc_i + DensityInc_j); - MeanPressure = 0.5*(Pressure_i + Pressure_j); - MeanBetaInc2 = 0.5*(BetaInc2_i + BetaInc2_j); - MeanEnthalpy = 0.5*(Enthalpy_i + Enthalpy_j); - MeanCp = 0.5*(Cp_i + Cp_j); - MeanTemperature = 0.5*(Temperature_i + Temperature_j); - - /*--- Artificial sound speed based on eigs of preconditioned system ---*/ - - MeanSoundSpeed = sqrt(MeanBetaInc2*Area*Area); - - /*--- We need the derivative of the equation of state to build the - preconditioning matrix. For now, the only option is the ideal gas - law, but in the future, dRhodT should be in the fluid model. ---*/ - - MeandRhodT = 0.0; dRhodT_i = 0.0; dRhodT_j = 0.0; - if (variable_density) { - MeandRhodT = -MeanDensity/MeanTemperature; - dRhodT_i = -DensityInc_i/Temperature_i; - dRhodT_j = -DensityInc_j/Temperature_j; - } - - /*--- Compute ProjFlux_i ---*/ - - GetInviscidIncProjFlux(&DensityInc_i, Velocity_i, &Pressure_i, &BetaInc2_i, &Enthalpy_i, Normal, ProjFlux_i); - - /*--- Compute ProjFlux_j ---*/ - - GetInviscidIncProjFlux(&DensityInc_j, Velocity_j, &Pressure_j, &BetaInc2_j, &Enthalpy_j, Normal, ProjFlux_j); - - /*--- Eigenvalues of the preconditioned system ---*/ - - if (nDim == 2) { - Lambda[0] = ProjVelocity; - Lambda[1] = ProjVelocity; - Lambda[2] = ProjVelocity - MeanSoundSpeed; - Lambda[3] = ProjVelocity + MeanSoundSpeed; - } - if (nDim == 3) { - Lambda[0] = ProjVelocity; - Lambda[1] = ProjVelocity; - Lambda[2] = ProjVelocity; - Lambda[3] = ProjVelocity - MeanSoundSpeed; - Lambda[4] = ProjVelocity + MeanSoundSpeed; - } - - /*--- Absolute value of the eigenvalues ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - Lambda[iVar] = fabs(Lambda[iVar]); - - /*--- Build the preconditioning matrix using mean values ---*/ - - GetPreconditioner(&MeanDensity, MeanVelocity, &MeanBetaInc2, &MeanCp, &MeanTemperature, &MeandRhodT, Precon); - - /*--- Build the absolute value of the preconditioned Jacobian, i.e., - |A_precon| = P x |Lambda| x inv(P), where P diagonalizes the matrix - inv(Precon) x dF/dV and Lambda is the diag. matrix of its eigenvalues. ---*/ - - GetPreconditionedProjJac(&MeanDensity, Lambda, &MeanBetaInc2, UnitNormal, invPrecon_A); - - /*--- Difference of primitive variables at iPoint and jPoint ---*/ - - Diff_V[0] = Pressure_j - Pressure_i; - for (iDim = 0; iDim < nDim; iDim++) - Diff_V[iDim+1] = Velocity_j[iDim] - Velocity_i[iDim]; - Diff_V[nDim+1] = Temperature_j - Temperature_i; - - /*--- Build the inviscid Jacobian w.r.t. the primitive variables ---*/ - - if (implicit) { - GetInviscidIncProjJac(&DensityInc_i, Velocity_i, &BetaInc2_i, &Cp_i, &Temperature_i, &dRhodT_i, Normal, 0.5, val_Jacobian_i); - GetInviscidIncProjJac(&DensityInc_j, Velocity_j, &BetaInc2_j, &Cp_j, &Temperature_j, &dRhodT_j, Normal, 0.5, val_Jacobian_j); - } - - /*--- Compute dissipation as Precon x |A_precon| x dV. If implicit, - store Precon x |A_precon| from dissipation term. ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] = 0.5*(ProjFlux_i[iVar]+ProjFlux_j[iVar]); - for (jVar = 0; jVar < nVar; jVar++) { - Proj_ModJac_Tensor_ij = 0.0; - for (kVar = 0; kVar < nVar; kVar++) - Proj_ModJac_Tensor_ij += Precon[iVar][kVar]*invPrecon_A[kVar][jVar]; - val_residual[iVar] -= 0.5*Proj_ModJac_Tensor_ij*Diff_V[jVar]; - if (implicit) { - val_Jacobian_i[iVar][jVar] += 0.5*Proj_ModJac_Tensor_ij; - val_Jacobian_j[iVar][jVar] -= 0.5*Proj_ModJac_Tensor_ij; - } - } - } - - /*--- Corrections due to grid motion ---*/ - if (dynamic_grid) { - - /*--- Recompute conservative variables ---*/ - - U_i[0] = DensityInc_i; U_j[0] = DensityInc_j; - for (iDim = 0; iDim < nDim; iDim++) { - U_i[iDim+1] = DensityInc_i*Velocity_i[iDim]; U_j[iDim+1] = DensityInc_j*Velocity_j[iDim]; - } - U_i[nDim+1] = DensityInc_i*Enthalpy_i; U_j[nDim+1] = DensityInc_j*Enthalpy_j; - - ProjVelocity = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjVelocity += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - - /*--- Residual contributions ---*/ - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] -= ProjVelocity * 0.5*(U_i[iVar]+U_j[iVar]); - - /*--- Jacobian contributions ---*/ - /*--- Implicit terms ---*/ - if (implicit) { - for (iDim = 0; iDim < nDim; iDim++){ - val_Jacobian_i[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_i; - val_Jacobian_j[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_j; - } - val_Jacobian_i[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_i*Cp_i; - val_Jacobian_j[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_j*Cp_j; - } - } - } - - if (!energy) { - val_residual[nDim+1] = 0.0; - if (implicit) { - for (iVar = 0; iVar < nVar; iVar++) { - val_Jacobian_i[iVar][nDim+1] = 0.0; - val_Jacobian_j[iVar][nDim+1] = 0.0; - - val_Jacobian_i[nDim+1][iVar] = 0.0; - val_Jacobian_j[nDim+1][iVar] = 0.0; - } - } - } - - AD::SetPreaccOut(val_residual, nVar); - AD::EndPreacc(); -} - -CCentJSTInc_Flow::CCentJSTInc_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - variable_density = (config->GetKind_DensityModel() == VARIABLE); - energy = config->GetEnergy_Equation(); - /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ - dynamic_grid = config->GetDynamic_Grid(); - - /*--- Artifical dissipation part ---*/ - - Param_p = 0.3; - Param_Kappa_2 = config->GetKappa_2nd_Flow(); - Param_Kappa_4 = config->GetKappa_4th_Flow(); - - /*--- Allocate some structures ---*/ - - Diff_V = new su2double [nVar]; - Diff_Lapl = new su2double [nVar]; - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; - MeanVelocity = new su2double [nDim]; - ProjFlux = new su2double [nVar]; - Precon = new su2double*[nVar]; - - for (iVar = 0; iVar < nVar; iVar++) - Precon[iVar] = new su2double[nVar]; - -} - -CCentJSTInc_Flow::~CCentJSTInc_Flow(void) { - - delete [] Diff_V; - delete [] Diff_Lapl; - delete [] Velocity_i; - delete [] Velocity_j; - delete [] MeanVelocity; - delete [] ProjFlux; - - for (iVar = 0; iVar < nVar; iVar++) - delete [] Precon[iVar]; - delete [] Precon; - -} - -void CCentJSTInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - su2double U_i[5] = {0.0,0.0,0.0,0.0,0.0}, U_j[5] = {0.0,0.0,0.0,0.0,0.0}; - su2double ProjGridVel = 0.0; - - /*--- Primitive variables at point i and j ---*/ - - Pressure_i = V_i[0]; Pressure_j = V_j[0]; - Temperature_i = V_i[nDim+1]; Temperature_j = V_j[nDim+1]; - DensityInc_i = V_i[nDim+2]; DensityInc_j = V_j[nDim+2]; - BetaInc2_i = V_i[nDim+3]; BetaInc2_j = V_j[nDim+3]; - Cp_i = V_i[nDim+7]; Cp_j = V_j[nDim+7]; - Enthalpy_i = Cp_i*Temperature_i; Enthalpy_j = Cp_j*Temperature_j; - - Area = 0.0; - sq_vel_i = 0.0; sq_vel_j = 0.0; ProjVelocity_i = 0.0; ProjVelocity_j = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = V_i[iDim+1]; - Velocity_j[iDim] = V_j[iDim+1]; - MeanVelocity[iDim] = 0.5*(Velocity_i[iDim]+Velocity_j[iDim]); - sq_vel_i += 0.5*Velocity_i[iDim]*Velocity_i[iDim]; - sq_vel_j += 0.5*Velocity_j[iDim]*Velocity_j[iDim]; - ProjVelocity_i += Velocity_i[iDim]*Normal[iDim]; - ProjVelocity_j += Velocity_j[iDim]*Normal[iDim]; - Area += Normal[iDim]*Normal[iDim]; - } - Area = sqrt(Area); - - /*--- Compute mean values of the variables ---*/ - - MeanDensity = 0.5*(DensityInc_i + DensityInc_j); - MeanPressure = 0.5*(Pressure_i + Pressure_j); - MeanBetaInc2 = 0.5*(BetaInc2_i + BetaInc2_j); - MeanEnthalpy = 0.5*(Enthalpy_i + Enthalpy_j); - MeanCp = 0.5*(Cp_i + Cp_j); - MeanTemperature = 0.5*(Temperature_i + Temperature_j); - - /*--- We need the derivative of the equation of state to build the - preconditioning matrix. For now, the only option is the ideal gas - law, but in the future, dRhodT should be in the fluid model. ---*/ - - MeandRhodT = 0.0; - if (variable_density) { - MeandRhodT = -MeanDensity/MeanTemperature; - } - - /*--- Get projected flux tensor ---*/ - - GetInviscidIncProjFlux(&MeanDensity, MeanVelocity, &MeanPressure, &MeanBetaInc2, &MeanEnthalpy, Normal, ProjFlux); - - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] = ProjFlux[iVar]; - } - - /*--- Jacobians of the inviscid flux ---*/ - - if (implicit) { - GetInviscidIncProjJac(&MeanDensity, MeanVelocity, &MeanBetaInc2, &MeanCp, &MeanTemperature, &MeandRhodT, Normal, 0.5, val_Jacobian_i); - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - val_Jacobian_j[iVar][jVar] = val_Jacobian_i[iVar][jVar]; - } - } - } - - /*--- Corrections due to grid motion ---*/ - if (dynamic_grid) { - - /*--- Recompute conservative variables ---*/ - - U_i[0] = DensityInc_i; U_j[0] = DensityInc_j; - for (iDim = 0; iDim < nDim; iDim++) { - U_i[iDim+1] = DensityInc_i*Velocity_i[iDim]; U_j[iDim+1] = DensityInc_j*Velocity_j[iDim]; - } - U_i[nDim+1] = DensityInc_i*Enthalpy_i; U_j[nDim+1] = DensityInc_j*Enthalpy_j; - - su2double ProjVelocity = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjVelocity += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - - /*--- Residual contributions ---*/ - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] -= ProjVelocity * 0.5*(U_i[iVar]+U_j[iVar]); - - /*--- Jacobian contributions ---*/ - /*--- Implicit terms ---*/ - if (implicit) { - for (iDim = 0; iDim < nDim; iDim++){ - val_Jacobian_i[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_i; - val_Jacobian_j[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_j; - } - val_Jacobian_i[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_i*Cp_i; - val_Jacobian_j[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_j*Cp_j; - } - } - } - - /*--- Computes differences between Laplacians and conservative variables ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - Diff_Lapl[iVar] = Und_Lapl_i[iVar]-Und_Lapl_j[iVar]; - Diff_V[iVar] = V_i[iVar]-V_j[iVar]; - } - - /*--- Build the preconditioning matrix using mean values ---*/ - - GetPreconditioner(&MeanDensity, MeanVelocity, &MeanBetaInc2, &MeanCp, &MeanTemperature, &MeandRhodT, Precon); - - /*--- Compute the local spectral radius of the preconditioned system - and the stretching factor. ---*/ - - /*--- Projected velocity adjustment due to mesh motion ---*/ - - if (dynamic_grid) { - ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - } - ProjVelocity_i -= ProjGridVel; - ProjVelocity_j -= ProjGridVel; - } - - SoundSpeed_i = sqrt(BetaInc2_i*Area*Area); - SoundSpeed_j = sqrt(BetaInc2_j*Area*Area); - - Local_Lambda_i = fabs(ProjVelocity_i)+SoundSpeed_i; - Local_Lambda_j = fabs(ProjVelocity_j)+SoundSpeed_j; - - MeanLambda = 0.5*(Local_Lambda_i+Local_Lambda_j); - - Phi_i = pow(Lambda_i/(4.0*MeanLambda), Param_p); - Phi_j = pow(Lambda_j/(4.0*MeanLambda), Param_p); - - StretchingFactor = 4.0*Phi_i*Phi_j/(Phi_i+Phi_j); - - sc2 = 3.0*(su2double(Neighbor_i)+su2double(Neighbor_j))/(su2double(Neighbor_i)*su2double(Neighbor_j)); - sc4 = sc2*sc2/4.0; - - Epsilon_2 = Param_Kappa_2*0.5*(Sensor_i+Sensor_j)*sc2; - Epsilon_4 = max(0.0, Param_Kappa_4-Epsilon_2)*sc4; - - /*--- Compute viscous part of the residual ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - val_residual[iVar] += Precon[iVar][jVar]*(Epsilon_2*Diff_V[jVar] - Epsilon_4*Diff_Lapl[jVar])*StretchingFactor*MeanLambda; - if (implicit) { - val_Jacobian_i[iVar][jVar] += Precon[iVar][jVar]*(Epsilon_2 + Epsilon_4*su2double(Neighbor_i+1))*StretchingFactor*MeanLambda; - val_Jacobian_j[iVar][jVar] -= Precon[iVar][jVar]*(Epsilon_2 + Epsilon_4*su2double(Neighbor_j+1))*StretchingFactor*MeanLambda; - } - } - } - - /*--- Remove energy contributions if not solving the energy equation. ---*/ - - if (!energy) { - val_residual[nDim+1] = 0.0; - if (implicit) { - for (iVar = 0; iVar < nVar; iVar++) { - val_Jacobian_i[iVar][nDim+1] = 0.0; - val_Jacobian_j[iVar][nDim+1] = 0.0; - - val_Jacobian_i[nDim+1][iVar] = 0.0; - val_Jacobian_j[nDim+1][iVar] = 0.0; - } - } - } -} - -CCentLaxInc_Flow::CCentLaxInc_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - variable_density = (config->GetKind_DensityModel() == VARIABLE); - /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ - dynamic_grid = config->GetDynamic_Grid(); - energy = config->GetEnergy_Equation(); - - /*--- Artificial dissipation part ---*/ - - Param_p = 0.3; - Param_Kappa_0 = config->GetKappa_1st_Flow(); - - /*--- Allocate some structures ---*/ - - Diff_V = new su2double[nVar]; - Velocity_i = new su2double[nDim]; - Velocity_j = new su2double[nDim]; - MeanVelocity = new su2double[nDim]; - ProjFlux = new su2double[nVar]; - Precon = new su2double*[nVar]; - - for (iVar = 0; iVar < nVar; iVar++) - Precon[iVar] = new su2double[nVar]; - -} - -CCentLaxInc_Flow::~CCentLaxInc_Flow(void) { - - delete [] Diff_V; - delete [] Velocity_i; - delete [] Velocity_j; - delete [] MeanVelocity; - delete [] ProjFlux; - - for (iVar = 0; iVar < nVar; iVar++) - delete [] Precon[iVar]; - delete [] Precon; - -} - -void CCentLaxInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - su2double U_i[5] = {0.0,0.0,0.0,0.0,0.0}, U_j[5] = {0.0,0.0,0.0,0.0,0.0}; - su2double ProjGridVel = 0.0, ProjVelocity = 0.0; - - /*--- Primitive variables at point i and j ---*/ - - Pressure_i = V_i[0]; Pressure_j = V_j[0]; - Temperature_i = V_i[nDim+1]; Temperature_j = V_j[nDim+1]; - DensityInc_i = V_i[nDim+2]; DensityInc_j = V_j[nDim+2]; - BetaInc2_i = V_i[nDim+3]; BetaInc2_j = V_j[nDim+3]; - Cp_i = V_i[nDim+7]; Cp_j = V_j[nDim+7]; - Enthalpy_i = Cp_i*Temperature_i; Enthalpy_j = Cp_j*Temperature_j; - - Area = 0.0; - sq_vel_i = 0.0; sq_vel_j = 0.0; ProjVelocity_i = 0.0; ProjVelocity_j = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = V_i[iDim+1]; - Velocity_j[iDim] = V_j[iDim+1]; - MeanVelocity[iDim] = 0.5*(Velocity_i[iDim]+Velocity_j[iDim]); - sq_vel_i += 0.5*Velocity_i[iDim]*Velocity_i[iDim]; - sq_vel_j += 0.5*Velocity_j[iDim]*Velocity_j[iDim]; - ProjVelocity_i += Velocity_i[iDim]*Normal[iDim]; - ProjVelocity_j += Velocity_j[iDim]*Normal[iDim]; - Area += Normal[iDim]*Normal[iDim]; - } - Area = sqrt(Area); - - /*--- Compute mean values of the variables ---*/ - - MeanDensity = 0.5*(DensityInc_i + DensityInc_j); - MeanPressure = 0.5*(Pressure_i + Pressure_j); - MeanBetaInc2 = 0.5*(BetaInc2_i + BetaInc2_j); - MeanEnthalpy = 0.5*(Enthalpy_i + Enthalpy_j); - MeanCp = 0.5*(Cp_i + Cp_j); - MeanTemperature = 0.5*(Temperature_i + Temperature_j); - - /*--- We need the derivative of the equation of state to build the - preconditioning matrix. For now, the only option is the ideal gas - law, but in the future, dRhodT should be in the fluid model. ---*/ - - MeandRhodT = 0.0; - if (variable_density) { - MeandRhodT = -MeanDensity/MeanTemperature; - } - - /*--- Get projected flux tensor ---*/ - - GetInviscidIncProjFlux(&MeanDensity, MeanVelocity, &MeanPressure, &MeanBetaInc2, &MeanEnthalpy, Normal, ProjFlux); - - /*--- Compute inviscid residual ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] = ProjFlux[iVar]; - } - - /*--- Jacobians of the inviscid flux ---*/ - - if (implicit) { - GetInviscidIncProjJac(&MeanDensity, MeanVelocity, &MeanBetaInc2, &MeanCp, &MeanTemperature, &MeandRhodT, Normal, 0.5, val_Jacobian_i); - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - val_Jacobian_j[iVar][jVar] = val_Jacobian_i[iVar][jVar]; - } - } - } - - /*--- Corrections due to grid motion ---*/ - if (dynamic_grid) { - - /*--- Recompute conservative variables ---*/ - - U_i[0] = DensityInc_i; U_j[0] = DensityInc_j; - for (iDim = 0; iDim < nDim; iDim++) { - U_i[iDim+1] = DensityInc_i*Velocity_i[iDim]; U_j[iDim+1] = DensityInc_j*Velocity_j[iDim]; - } - U_i[nDim+1] = DensityInc_i*Enthalpy_i; U_j[nDim+1] = DensityInc_j*Enthalpy_j; - - for (iDim = 0; iDim < nDim; iDim++) - ProjVelocity += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - - /*--- Residual contributions ---*/ - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] -= ProjVelocity * 0.5*(U_i[iVar]+U_j[iVar]); - - /*--- Jacobian contributions ---*/ - /*--- Implicit terms ---*/ - if (implicit) { - for (iDim = 0; iDim < nDim; iDim++){ - val_Jacobian_i[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_i; - val_Jacobian_j[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_j; - } - val_Jacobian_i[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_i*Cp_i; - val_Jacobian_j[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_j*Cp_j; - } - } - } - - /*--- Computes differences btw. conservative variables ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - Diff_V[iVar] = V_i[iVar]-V_j[iVar]; - - /*--- Build the preconditioning matrix using mean values ---*/ - - GetPreconditioner(&MeanDensity, MeanVelocity, &MeanBetaInc2, &MeanCp, &MeanTemperature, &MeandRhodT, Precon); - - /*--- Compute the local espectral radius of the preconditioned system - and the stretching factor. ---*/ - - SoundSpeed_i = sqrt(BetaInc2_i*Area*Area); - SoundSpeed_j = sqrt(BetaInc2_j*Area*Area); - - /*--- Projected velocity adjustment due to mesh motion ---*/ - - if (dynamic_grid) { - ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - } - ProjVelocity_i -= ProjGridVel; - ProjVelocity_j -= ProjGridVel; - } - - Local_Lambda_i = fabs(ProjVelocity_i)+SoundSpeed_i; - Local_Lambda_j = fabs(ProjVelocity_j)+SoundSpeed_j; - - MeanLambda = 0.5*(Local_Lambda_i+Local_Lambda_j); - - Phi_i = pow(Lambda_i/(4.0*MeanLambda), Param_p); - Phi_j = pow(Lambda_j/(4.0*MeanLambda), Param_p); - - StretchingFactor = 4.0*Phi_i*Phi_j/(Phi_i+Phi_j); - - sc0 = 3.0*(su2double(Neighbor_i)+su2double(Neighbor_j))/(su2double(Neighbor_i)*su2double(Neighbor_j)); - Epsilon_0 = Param_Kappa_0*sc0*su2double(nDim)/3.0; - - /*--- Compute viscous part of the residual ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - val_residual[iVar] += Precon[iVar][jVar]*Epsilon_0*Diff_V[jVar]*StretchingFactor*MeanLambda; - if (implicit) { - val_Jacobian_i[iVar][jVar] += Precon[iVar][jVar]*Epsilon_0*StretchingFactor*MeanLambda; - val_Jacobian_j[iVar][jVar] -= Precon[iVar][jVar]*Epsilon_0*StretchingFactor*MeanLambda; - } - } - } - - /*--- Remove energy contributions if we aren't solving the energy equation. ---*/ - - if (!energy) { - val_residual[nDim+1] = 0.0; - if (implicit) { - for (iVar = 0; iVar < nVar; iVar++) { - val_Jacobian_i[iVar][nDim+1] = 0.0; - val_Jacobian_j[iVar][nDim+1] = 0.0; - - val_Jacobian_i[nDim+1][iVar] = 0.0; - val_Jacobian_j[nDim+1][iVar] = 0.0; - } - } - } -} - -CAvgGradInc_Flow::CAvgGradInc_Flow(unsigned short val_nDim, - unsigned short val_nVar, - bool val_correct_grad, CConfig *config) - : CAvgGrad_Base(val_nDim, val_nVar, val_nDim+3, val_correct_grad, config) { - - energy = config->GetEnergy_Equation(); - -} - -CAvgGradInc_Flow::~CAvgGradInc_Flow(void) { -} - -void CAvgGradInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - AD::StartPreacc(); - AD::SetPreaccIn(V_i, nDim+9); AD::SetPreaccIn(V_j, nDim+9); - AD::SetPreaccIn(Coord_i, nDim); AD::SetPreaccIn(Coord_j, nDim); - AD::SetPreaccIn(PrimVar_Grad_i, nVar, nDim); - AD::SetPreaccIn(PrimVar_Grad_j, nVar, nDim); - AD::SetPreaccIn(turb_ke_i); AD::SetPreaccIn(turb_ke_j); - AD::SetPreaccIn(Normal, nDim); - - unsigned short iVar, jVar, iDim; - - /*--- Normalized normal vector ---*/ - - 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; - - for (iVar = 0; iVar < nPrimVar; iVar++) { - PrimVar_i[iVar] = V_i[iVar]; - PrimVar_j[iVar] = V_j[iVar]; - Mean_PrimVar[iVar] = 0.5*(PrimVar_i[iVar]+PrimVar_j[iVar]); - } - - /*--- Compute vector going from iPoint to jPoint ---*/ - - dist_ij_2 = 0.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]; - } - - /*--- Density and transport properties ---*/ - - Laminar_Viscosity_i = V_i[nDim+4]; Laminar_Viscosity_j = V_j[nDim+4]; - Eddy_Viscosity_i = V_i[nDim+5]; Eddy_Viscosity_j = V_j[nDim+5]; - Thermal_Conductivity_i = V_i[nDim+6]; Thermal_Conductivity_j = V_j[nDim+6]; - - /*--- Mean transport properties ---*/ - - Mean_Laminar_Viscosity = 0.5*(Laminar_Viscosity_i + Laminar_Viscosity_j); - Mean_Eddy_Viscosity = 0.5*(Eddy_Viscosity_i + Eddy_Viscosity_j); - Mean_turb_ke = 0.5*(turb_ke_i + turb_ke_j); - Mean_Thermal_Conductivity = 0.5*(Thermal_Conductivity_i + Thermal_Conductivity_j); - - /*--- Mean gradient approximation ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - for (iDim = 0; iDim < nDim; iDim++) - Mean_GradPrimVar[iVar][iDim] = 0.5*(PrimVar_Grad_i[iVar][iDim] + PrimVar_Grad_j[iVar][iDim]); - - /*--- Projection of the mean gradient in the direction of the edge ---*/ - - if (correct_gradient && dist_ij_2 != 0.0) { - CorrectGradient(Mean_GradPrimVar, PrimVar_i, PrimVar_j, Edge_Vector, - dist_ij_2, nVar); - } - - /*--- Get projected flux tensor ---*/ - SetStressTensor(Mean_PrimVar, Mean_GradPrimVar, Mean_turb_ke, - Mean_Laminar_Viscosity, Mean_Eddy_Viscosity); - GetViscousIncProjFlux(Mean_GradPrimVar, Normal, Mean_Thermal_Conductivity); - - /*--- Update viscous residual ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] = Proj_Flux_Tensor[iVar]; - } - - /*--- Implicit part ---*/ - - if (implicit) { - - if (dist_ij_2 == 0.0) { - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - val_Jacobian_i[iVar][jVar] = 0.0; - val_Jacobian_j[iVar][jVar] = 0.0; - } - } - } else { - - const su2double dist_ij = sqrt(dist_ij_2); - SetIncTauJacobian(Mean_Laminar_Viscosity, Mean_Eddy_Viscosity, - dist_ij, UnitNormal); - GetViscousIncProjJacs(Area, val_Jacobian_i, val_Jacobian_j); - - /*--- Include the temperature equation Jacobian. ---*/ - su2double proj_vector_ij = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - proj_vector_ij += (Coord_j[iDim]-Coord_i[iDim])*Normal[iDim]; - } - proj_vector_ij = proj_vector_ij/dist_ij_2; - val_Jacobian_i[nDim+1][nDim+1] = -Mean_Thermal_Conductivity*proj_vector_ij; - val_Jacobian_j[nDim+1][nDim+1] = Mean_Thermal_Conductivity*proj_vector_ij; - } - - } - - if (!energy) { - val_residual[nDim+1] = 0.0; - if (implicit) { - for (iVar = 0; iVar < nVar; iVar++) { - val_Jacobian_i[iVar][nDim+1] = 0.0; - val_Jacobian_j[iVar][nDim+1] = 0.0; - - val_Jacobian_i[nDim+1][iVar] = 0.0; - val_Jacobian_j[nDim+1][iVar] = 0.0; - } - } - } - - AD::SetPreaccOut(val_residual, nVar); - AD::EndPreacc(); - -} - -void CAvgGradInc_Flow::GetViscousIncProjFlux(const su2double* const *val_gradprimvar, - const su2double *val_normal, - su2double val_thermal_conductivity) { - - /*--- Gradient of primitive variables -> [Pressure vel_x vel_y vel_z Temperature] ---*/ - - if (nDim == 2) { - Flux_Tensor[0][0] = 0.0; - Flux_Tensor[1][0] = tau[0][0]; - Flux_Tensor[2][0] = tau[0][1]; - Flux_Tensor[3][0] = val_thermal_conductivity*val_gradprimvar[nDim+1][0]; - - Flux_Tensor[0][1] = 0.0; - Flux_Tensor[1][1] = tau[1][0]; - Flux_Tensor[2][1] = tau[1][1]; - Flux_Tensor[3][1] = val_thermal_conductivity*val_gradprimvar[nDim+1][1]; - - } else { - - Flux_Tensor[0][0] = 0.0; - Flux_Tensor[1][0] = tau[0][0]; - Flux_Tensor[2][0] = tau[0][1]; - Flux_Tensor[3][0] = tau[0][2]; - Flux_Tensor[4][0] = val_thermal_conductivity*val_gradprimvar[nDim+1][0]; - - Flux_Tensor[0][1] = 0.0; - Flux_Tensor[1][1] = tau[1][0]; - Flux_Tensor[2][1] = tau[1][1]; - Flux_Tensor[3][1] = tau[1][2]; - Flux_Tensor[4][1] = val_thermal_conductivity*val_gradprimvar[nDim+1][1]; - - Flux_Tensor[0][2] = 0.0; - Flux_Tensor[1][2] = tau[2][0]; - Flux_Tensor[2][2] = tau[2][1]; - Flux_Tensor[3][2] = tau[2][2]; - Flux_Tensor[4][2] = val_thermal_conductivity*val_gradprimvar[nDim+1][2]; - - } - - for (unsigned short iVar = 0; iVar < nVar; iVar++) { - Proj_Flux_Tensor[iVar] = 0.0; - for (unsigned short iDim = 0; iDim < nDim; iDim++) - Proj_Flux_Tensor[iVar] += Flux_Tensor[iVar][iDim] * val_normal[iDim]; - } - -} - -void CAvgGradInc_Flow::GetViscousIncProjJacs(su2double val_dS, - su2double **val_Proj_Jac_Tensor_i, - su2double **val_Proj_Jac_Tensor_j) { - - if (nDim == 2) { - - val_Proj_Jac_Tensor_i[0][0] = 0.0; - val_Proj_Jac_Tensor_i[0][1] = 0.0; - val_Proj_Jac_Tensor_i[0][2] = 0.0; - val_Proj_Jac_Tensor_i[0][3] = 0.0; - - val_Proj_Jac_Tensor_i[1][0] = val_dS*tau_jacobian_i[0][0]; - val_Proj_Jac_Tensor_i[1][1] = val_dS*tau_jacobian_i[0][1]; - val_Proj_Jac_Tensor_i[1][2] = val_dS*tau_jacobian_i[0][2]; - val_Proj_Jac_Tensor_i[1][3] = val_dS*tau_jacobian_i[0][3]; - - val_Proj_Jac_Tensor_i[2][0] = val_dS*tau_jacobian_i[1][0]; - val_Proj_Jac_Tensor_i[2][1] = val_dS*tau_jacobian_i[1][1]; - val_Proj_Jac_Tensor_i[2][2] = val_dS*tau_jacobian_i[1][2]; - val_Proj_Jac_Tensor_i[2][3] = val_dS*tau_jacobian_i[1][3]; - - val_Proj_Jac_Tensor_i[3][0] = 0.0; - val_Proj_Jac_Tensor_i[3][1] = 0.0; - val_Proj_Jac_Tensor_i[3][2] = 0.0; - val_Proj_Jac_Tensor_i[3][3] = 0.0; - - } else { - - val_Proj_Jac_Tensor_i[0][0] = 0.0; - val_Proj_Jac_Tensor_i[0][1] = 0.0; - val_Proj_Jac_Tensor_i[0][2] = 0.0; - val_Proj_Jac_Tensor_i[0][3] = 0.0; - val_Proj_Jac_Tensor_i[0][4] = 0.0; - - val_Proj_Jac_Tensor_i[1][0] = val_dS*tau_jacobian_i[0][0]; - val_Proj_Jac_Tensor_i[1][1] = val_dS*tau_jacobian_i[0][1]; - val_Proj_Jac_Tensor_i[1][2] = val_dS*tau_jacobian_i[0][2]; - val_Proj_Jac_Tensor_i[1][3] = val_dS*tau_jacobian_i[0][3]; - val_Proj_Jac_Tensor_i[1][4] = val_dS*tau_jacobian_i[0][4]; - - val_Proj_Jac_Tensor_i[2][0] = val_dS*tau_jacobian_i[1][0]; - val_Proj_Jac_Tensor_i[2][1] = val_dS*tau_jacobian_i[1][1]; - val_Proj_Jac_Tensor_i[2][2] = val_dS*tau_jacobian_i[1][2]; - val_Proj_Jac_Tensor_i[2][3] = val_dS*tau_jacobian_i[1][3]; - val_Proj_Jac_Tensor_i[2][4] = val_dS*tau_jacobian_i[1][4]; - - val_Proj_Jac_Tensor_i[3][0] = val_dS*tau_jacobian_i[2][0]; - val_Proj_Jac_Tensor_i[3][1] = val_dS*tau_jacobian_i[2][1]; - val_Proj_Jac_Tensor_i[3][2] = val_dS*tau_jacobian_i[2][2]; - val_Proj_Jac_Tensor_i[3][3] = val_dS*tau_jacobian_i[2][3]; - val_Proj_Jac_Tensor_i[3][4] = val_dS*tau_jacobian_i[2][4]; - - val_Proj_Jac_Tensor_i[4][0] = 0.0; - val_Proj_Jac_Tensor_i[4][1] = 0.0; - val_Proj_Jac_Tensor_i[4][2] = 0.0; - val_Proj_Jac_Tensor_i[4][3] = 0.0; - val_Proj_Jac_Tensor_i[4][4] = 0.0; - - } - - for (unsigned short iVar = 0; iVar < nVar; iVar++) - for (unsigned short jVar = 0; jVar < nVar; jVar++) - val_Proj_Jac_Tensor_j[iVar][jVar] = -val_Proj_Jac_Tensor_i[iVar][jVar]; - -} - -CSourceIncBodyForce::CSourceIncBodyForce(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - /*--- Store the pointer to the constant body force vector. ---*/ - - Body_Force_Vector = new su2double[nDim]; - for (unsigned short iDim = 0; iDim < nDim; iDim++) - Body_Force_Vector[iDim] = config->GetBody_Force_Vector()[iDim]; - -} - -CSourceIncBodyForce::~CSourceIncBodyForce(void) { - - if (Body_Force_Vector != NULL) delete [] Body_Force_Vector; - -} - -void CSourceIncBodyForce::ComputeResidual(su2double *val_residual, CConfig *config) { - - unsigned short iDim; - su2double DensityInc_0 = 0.0; - su2double Force_Ref = config->GetForce_Ref(); - bool variable_density = (config->GetKind_DensityModel() == VARIABLE); - - /*--- Check for variable density. If we have a variable density - problem, we should subtract out the hydrostatic pressure component. ---*/ - - if (variable_density) DensityInc_0 = config->GetDensity_FreeStreamND(); - - /*--- Zero the continuity contribution ---*/ - - val_residual[0] = 0.0; - - /*--- Momentum contribution. Note that this form assumes we have - subtracted the operating density * gravity, i.e., removed the - hydrostatic pressure component (important for pressure BCs). ---*/ - - for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = -Volume * (DensityInc_i - DensityInc_0) * Body_Force_Vector[iDim] / Force_Ref; - - /*--- Zero the temperature contribution ---*/ - - val_residual[nDim+1] = 0.0; - -} - -CSourceIncRotatingFrame_Flow::CSourceIncRotatingFrame_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - /*--- Retrieve the angular velocity vector from config. ---*/ - for (unsigned short iDim = 0; iDim < 3; iDim++) - Omega[iDim] = config->GetRotation_Rate(iDim)/config->GetOmega_Ref(); - -} - -CSourceIncRotatingFrame_Flow::~CSourceIncRotatingFrame_Flow(void) { } - -void CSourceIncRotatingFrame_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config) { - - unsigned short iDim, iVar, jVar; - su2double Momentum[3] = {0,0,0}, - Velocity_i[3] = {0,0,0}; - - /*--- Primitive variables plus momentum at the node (point i) ---*/ - - DensityInc_i = V_i[nDim+2]; - - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = V_i[iDim+1]; - Momentum[iDim] = DensityInc_i*Velocity_i[iDim]; - } - - /*--- Calculate rotating frame source term residual as ( Omega X Rho-U ) ---*/ - - if (nDim == 2) { - val_residual[0] = 0.0; - val_residual[1] = (Omega[1]*Momentum[2] - Omega[2]*Momentum[1])*Volume; - val_residual[2] = (Omega[2]*Momentum[0] - Omega[0]*Momentum[2])*Volume; - val_residual[3] = 0.0; - } else { - val_residual[0] = 0.0; - val_residual[1] = (Omega[1]*Momentum[2] - Omega[2]*Momentum[1])*Volume; - val_residual[2] = (Omega[2]*Momentum[0] - Omega[0]*Momentum[2])*Volume; - val_residual[3] = (Omega[0]*Momentum[1] - Omega[1]*Momentum[0])*Volume; - val_residual[4] = 0.0; - } - - /*--- Calculate the source term Jacobian ---*/ - - if (implicit) { - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_i[iVar][jVar] = 0.0; - if (nDim == 2) { - val_Jacobian_i[1][2] = -DensityInc_i*Omega[2]*Volume; - val_Jacobian_i[2][1] = DensityInc_i*Omega[2]*Volume; - } else { - val_Jacobian_i[1][2] = -DensityInc_i*Omega[2]*Volume; - val_Jacobian_i[1][3] = DensityInc_i*Omega[1]*Volume; - val_Jacobian_i[2][1] = DensityInc_i*Omega[2]*Volume; - val_Jacobian_i[2][3] = -DensityInc_i*Omega[0]*Volume; - val_Jacobian_i[3][1] = -DensityInc_i*Omega[1]*Volume; - val_Jacobian_i[3][2] = DensityInc_i*Omega[0]*Volume; - } - } - -} - -CSourceBoussinesq::CSourceBoussinesq(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - /*--- Store the pointer to the constant body force vector. ---*/ - - Gravity_Vector = new su2double[nDim]; - for (unsigned short iDim = 0; iDim < nDim; iDim++) - Gravity_Vector[iDim] = 0.0; - - /*--- Gravity is downward in y-dir for 2D and downward z-dir for 3D. ---*/ - - Gravity_Vector[nDim-1] = -STANDARD_GRAVITY; - -} - -CSourceBoussinesq::~CSourceBoussinesq(void) { - - if (Gravity_Vector != NULL) delete [] Gravity_Vector; - -} - -void CSourceBoussinesq::ComputeResidual(su2double *val_residual, CConfig *config) { - - unsigned short iDim; - su2double Force_Ref = config->GetForce_Ref(); - su2double T0 = config->GetTemperature_FreeStreamND(); - su2double Beta = config->GetThermal_Expansion_CoeffND(); - - /*--- Zero the continuity contribution ---*/ - - val_residual[0] = 0.0; - - /*--- Momentum contribution. Note that this form assumes we have - subtracted the operating density * gravity, i.e., removed the - hydrostatic pressure component (important for pressure BCs). ---*/ - - for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = Volume * DensityInc_i * ( Beta * (U_i[nDim+1] - T0)) * Gravity_Vector[iDim] / Force_Ref; - - /*--- Zero the energy contribution ---*/ - - val_residual[nDim+1] = 0.0; - -} - -CSourceIncAxisymmetric_Flow::CSourceIncAxisymmetric_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - energy = config->GetEnergy_Equation(); - viscous = config->GetViscous(); - -} - -CSourceIncAxisymmetric_Flow::~CSourceIncAxisymmetric_Flow(void) { } - -void CSourceIncAxisymmetric_Flow::ComputeResidual(su2double *val_residual, su2double **Jacobian_i, CConfig *config) { - - su2double yinv, Velocity_i[3]; - unsigned short iDim, jDim, iVar, jVar; - - if (Coord_i[1] > EPS) { - - yinv = 1.0/Coord_i[1]; - - /*--- Set primitive variables at points iPoint. ---*/ - - Pressure_i = V_i[0]; - Temp_i = V_i[nDim+1]; - DensityInc_i = V_i[nDim+2]; - BetaInc2_i = V_i[nDim+3]; - Cp_i = V_i[nDim+7]; - Enthalpy_i = Cp_i*Temp_i; - - for (iDim = 0; iDim < nDim; iDim++) - Velocity_i[iDim] = V_i[iDim+1]; - - /*--- Inviscid component of the source term. ---*/ - - val_residual[0] = yinv*Volume*DensityInc_i*Velocity_i[1]; - val_residual[1] = yinv*Volume*DensityInc_i*Velocity_i[0]*Velocity_i[1]; - val_residual[2] = yinv*Volume*DensityInc_i*Velocity_i[1]*Velocity_i[1]; - val_residual[3] = yinv*Volume*DensityInc_i*Enthalpy_i*Velocity_i[1]; - - if (implicit) { - - Jacobian_i[0][0] = 0.0; - Jacobian_i[0][1] = 0.0; - Jacobian_i[0][2] = 1.0; - Jacobian_i[0][3] = 0.0; - - Jacobian_i[1][0] = 0.0; - Jacobian_i[1][1] = Velocity_i[1]; - Jacobian_i[1][2] = Velocity_i[0]; - Jacobian_i[1][3] = 0.0; - - Jacobian_i[2][0] = 0.0; - Jacobian_i[2][1] = 0.0; - Jacobian_i[2][2] = 2.0*Velocity_i[1]; - Jacobian_i[2][3] = 0.0; - - Jacobian_i[3][0] = 0.0; - Jacobian_i[3][1] = 0.0; - Jacobian_i[3][2] = Enthalpy_i; - Jacobian_i[3][3] = Cp_i*Velocity_i[1]; - - for (iVar=0; iVar < nVar; iVar++) - for (jVar=0; jVar < nVar; jVar++) - Jacobian_i[iVar][jVar] *= yinv*Volume*DensityInc_i; - - } - - /*--- Add the viscous terms if necessary. ---*/ - - if (viscous) { - - Laminar_Viscosity_i = V_i[nDim+4]; - Eddy_Viscosity_i = V_i[nDim+5]; - Thermal_Conductivity_i = V_i[nDim+6]; - - su2double total_viscosity, div_vel; - - total_viscosity = (Laminar_Viscosity_i + Eddy_Viscosity_i); - - /*--- The full stress tensor is needed for variable density ---*/ - - div_vel = 0.0; - for (iDim = 0 ; iDim < nDim; iDim++) - div_vel += PrimVar_Grad_i[iDim+1][iDim]; - - for (iDim = 0 ; iDim < nDim; iDim++) - for (jDim = 0 ; jDim < nDim; jDim++) - tau[iDim][jDim] = (total_viscosity*(PrimVar_Grad_i[jDim+1][iDim] + - PrimVar_Grad_i[iDim+1][jDim] ) - -TWO3*total_viscosity*div_vel*delta[iDim][jDim]); - - /*--- Viscous terms. ---*/ - - val_residual[0] -= 0.0; - val_residual[1] -= Volume*(yinv*tau[0][1] - TWO3*AuxVar_Grad_i[0]); - val_residual[2] -= Volume*(yinv*2.0*total_viscosity*PrimVar_Grad_i[2][1] - - yinv*yinv*2.0*total_viscosity*Velocity_i[1] - - TWO3*AuxVar_Grad_i[1]); - val_residual[3] -= Volume*yinv*Thermal_Conductivity_i*PrimVar_Grad_i[nDim+1][1]; - - } - - } else { - - for (iVar=0; iVar < nVar; iVar++) - val_residual[iVar] = 0.0; - - if (implicit) { - for (iVar=0; iVar < nVar; iVar++) { - for (jVar=0; jVar < nVar; jVar++) - Jacobian_i[iVar][jVar] = 0.0; - } - } - - } - - if (!energy) { - val_residual[nDim+1] = 0.0; - if (implicit) { - for (iVar = 0; iVar < nVar; iVar++) { - Jacobian_i[iVar][nDim+1] = 0.0; - Jacobian_i[nDim+1][iVar] = 0.0; - } - } - } - -} diff --git a/SU2_CFD/src/numerics_direct_turbulent.cpp b/SU2_CFD/src/numerics_direct_turbulent.cpp deleted file mode 100644 index 3a2bab6fe51e..000000000000 --- a/SU2_CFD/src/numerics_direct_turbulent.cpp +++ /dev/null @@ -1,1506 +0,0 @@ -/*! - * \file numerics_direct_turbulent.cpp - * \brief This file contains all the convective term discretization. - * \author F. Palacios, A. Bueno - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - - -#include "../include/numerics_structure.hpp" -#include - -CUpwScalar::CUpwScalar(unsigned short val_nDim, - unsigned short val_nVar, - CConfig *config) - : CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_Turb() == EULER_IMPLICIT); - incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); - /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ - dynamic_grid = config->GetDynamic_Grid(); - - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; - -} - -CUpwScalar::~CUpwScalar(void) { - - delete [] Velocity_i; - delete [] Velocity_j; - -} - -void CUpwScalar::ComputeResidual(su2double *val_residual, - su2double **val_Jacobian_i, - su2double **val_Jacobian_j, - CConfig *config) { - - AD::StartPreacc(); - AD::SetPreaccIn(Normal, nDim); - AD::SetPreaccIn(TurbVar_i, nVar); AD::SetPreaccIn(TurbVar_j, nVar); - if (dynamic_grid) { - AD::SetPreaccIn(GridVel_i, nDim); AD::SetPreaccIn(GridVel_j, nDim); - } - - ExtraADPreaccIn(); - - Density_i = V_i[nDim+2]; - Density_j = V_j[nDim+2]; - - q_ij = 0.0; - if (dynamic_grid) { - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = V_i[iDim+1] - GridVel_i[iDim]; - Velocity_j[iDim] = V_j[iDim+1] - GridVel_j[iDim]; - q_ij += 0.5*(Velocity_i[iDim]+Velocity_j[iDim])*Normal[iDim]; - } - } - else { - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = V_i[iDim+1]; - Velocity_j[iDim] = V_j[iDim+1]; - q_ij += 0.5*(Velocity_i[iDim]+Velocity_j[iDim])*Normal[iDim]; - } - } - - a0 = 0.5*(q_ij+fabs(q_ij)); - a1 = 0.5*(q_ij-fabs(q_ij)); - - FinishResidualCalc(val_residual, val_Jacobian_i, val_Jacobian_j, config); - - - AD::SetPreaccOut(val_residual, nVar); - AD::EndPreacc(); - -} - -CUpwSca_TurbSA::CUpwSca_TurbSA(unsigned short val_nDim, - unsigned short val_nVar, - CConfig *config) - : CUpwScalar(val_nDim, val_nVar, config) { -} - -CUpwSca_TurbSA::~CUpwSca_TurbSA(void) { -} - -void CUpwSca_TurbSA::ExtraADPreaccIn() { - AD::SetPreaccIn(V_i, nDim+1); AD::SetPreaccIn(V_j, nDim+1); -} - -void CUpwSca_TurbSA::FinishResidualCalc(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - val_residual[0] = a0*TurbVar_i[0]+a1*TurbVar_j[0]; - - if (implicit) { - val_Jacobian_i[0][0] = a0; - val_Jacobian_j[0][0] = a1; - } -} - -CAvgGrad_Scalar::CAvgGrad_Scalar(unsigned short val_nDim, - unsigned short val_nVar, - bool correct_grad, - CConfig *config) - : CNumerics(val_nDim, val_nVar, config), correct_gradient(correct_grad) { - - implicit = (config->GetKind_TimeIntScheme_Turb() == EULER_IMPLICIT); - incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); - - Edge_Vector = new su2double [nDim]; - Proj_Mean_GradTurbVar_Normal = new su2double [nVar]; - Proj_Mean_GradTurbVar_Edge = new su2double [nVar]; - Proj_Mean_GradTurbVar = new su2double [nVar]; - Mean_GradTurbVar = new su2double* [nVar]; - for (iVar = 0; iVar < nVar; iVar++) - Mean_GradTurbVar[iVar] = new su2double [nDim]; - -} - -CAvgGrad_Scalar::~CAvgGrad_Scalar(void) { - - delete [] Edge_Vector; - delete [] Proj_Mean_GradTurbVar_Normal; - delete [] Proj_Mean_GradTurbVar_Edge; - delete [] Proj_Mean_GradTurbVar; - for (iVar = 0; iVar < nVar; iVar++) - delete [] Mean_GradTurbVar[iVar]; - delete [] Mean_GradTurbVar; - -} - -void CAvgGrad_Scalar::ComputeResidual(su2double *val_residual, - su2double **Jacobian_i, - su2double **Jacobian_j, - CConfig *config) { - - AD::StartPreacc(); - AD::SetPreaccIn(Coord_i, nDim); AD::SetPreaccIn(Coord_j, nDim); - AD::SetPreaccIn(Normal, nDim); - AD::SetPreaccIn(TurbVar_Grad_i, nVar, nDim); - AD::SetPreaccIn(TurbVar_Grad_j, nVar, nDim); - if (correct_gradient) { - AD::SetPreaccIn(TurbVar_i, nVar); AD::SetPreaccIn(TurbVar_j ,nVar); - } - ExtraADPreaccIn(); - - if (incompressible) { - AD::SetPreaccIn(V_i, nDim+6); AD::SetPreaccIn(V_j, nDim+6); - - Density_i = V_i[nDim+2]; Density_j = V_j[nDim+2]; - Laminar_Viscosity_i = V_i[nDim+4]; Laminar_Viscosity_j = V_j[nDim+4]; - Eddy_Viscosity_i = V_i[nDim+5]; Eddy_Viscosity_j = V_j[nDim+5]; - } - else { - AD::SetPreaccIn(V_i, nDim+7); AD::SetPreaccIn(V_j, nDim+7); - - Density_i = V_i[nDim+2]; Density_j = V_j[nDim+2]; - Laminar_Viscosity_i = V_i[nDim+5]; Laminar_Viscosity_j = V_j[nDim+5]; - Eddy_Viscosity_i = V_i[nDim+6]; Eddy_Viscosity_j = V_j[nDim+6]; - } - - /*--- Compute vector going from iPoint to jPoint ---*/ - - 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; - - /*--- Mean gradient approximation ---*/ - for (iVar = 0; iVar < nVar; iVar++) { - Proj_Mean_GradTurbVar_Normal[iVar] = 0.0; - Proj_Mean_GradTurbVar_Edge[iVar] = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Mean_GradTurbVar[iVar][iDim] = 0.5*(TurbVar_Grad_i[iVar][iDim] + - TurbVar_Grad_j[iVar][iDim]); - Proj_Mean_GradTurbVar_Normal[iVar] += Mean_GradTurbVar[iVar][iDim] * - Normal[iDim]; - if (correct_gradient) - Proj_Mean_GradTurbVar_Edge[iVar] += Mean_GradTurbVar[iVar][iDim]*Edge_Vector[iDim]; - } - Proj_Mean_GradTurbVar[iVar] = Proj_Mean_GradTurbVar_Normal[iVar]; - if (correct_gradient) { - Proj_Mean_GradTurbVar[iVar] -= Proj_Mean_GradTurbVar_Edge[iVar]*proj_vector_ij - - (TurbVar_j[iVar]-TurbVar_i[iVar])*proj_vector_ij; - } - } - - FinishResidualCalc(val_residual, Jacobian_i, Jacobian_j, config); - - AD::SetPreaccOut(val_residual, nVar); - AD::EndPreacc(); - -} - -CAvgGrad_TurbSA::CAvgGrad_TurbSA(unsigned short val_nDim, - unsigned short val_nVar, bool correct_grad, - CConfig *config) - : CAvgGrad_Scalar(val_nDim, val_nVar, correct_grad, config), sigma(2./3.) { -} - -CAvgGrad_TurbSA::~CAvgGrad_TurbSA(void) { -} - -void CAvgGrad_TurbSA::ExtraADPreaccIn() { -} - -void CAvgGrad_TurbSA::FinishResidualCalc(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config) { - - /*--- Compute mean effective viscosity ---*/ - - nu_i = Laminar_Viscosity_i/Density_i; - nu_j = Laminar_Viscosity_j/Density_j; - nu_e = 0.5*(nu_i+nu_j+TurbVar_i[0]+TurbVar_j[0]); - - val_residual[0] = nu_e*Proj_Mean_GradTurbVar[0]/sigma; - - /*--- For Jacobians -> Use of TSL approx. to compute derivatives of the gradients ---*/ - - if (implicit) { - Jacobian_i[0][0] = (0.5*Proj_Mean_GradTurbVar[0]-nu_e*proj_vector_ij)/sigma; - Jacobian_j[0][0] = (0.5*Proj_Mean_GradTurbVar[0]+nu_e*proj_vector_ij)/sigma; - } - -} - -CAvgGrad_TurbSA_Neg::CAvgGrad_TurbSA_Neg(unsigned short val_nDim, - unsigned short val_nVar, - bool correct_grad, - CConfig *config) - : CAvgGrad_Scalar(val_nDim, val_nVar, correct_grad, config), - sigma(2./3.), cn1(16.0), fn(0.0) { -} - -CAvgGrad_TurbSA_Neg::~CAvgGrad_TurbSA_Neg(void) { -} - -void CAvgGrad_TurbSA_Neg::ExtraADPreaccIn() { -} - -void CAvgGrad_TurbSA_Neg::FinishResidualCalc(su2double *val_residual, - su2double **Jacobian_i, - su2double **Jacobian_j, - CConfig *config) { - - /*--- Compute mean effective viscosity ---*/ - - nu_i = Laminar_Viscosity_i/Density_i; - nu_j = Laminar_Viscosity_j/Density_j; - - nu_ij = 0.5*(nu_i+nu_j); - nu_tilde_ij = 0.5*(TurbVar_i[0]+TurbVar_j[0]); - - Xi = nu_tilde_ij/nu_ij; - - if (nu_tilde_ij > 0.0) { - nu_e = nu_ij + nu_tilde_ij; - } - else { - fn = (cn1 + Xi*Xi*Xi)/(cn1 - Xi*Xi*Xi); - nu_e = nu_ij + fn*nu_tilde_ij; - } - - val_residual[0] = nu_e*Proj_Mean_GradTurbVar_Normal[0]/sigma; - - /*--- For Jacobians -> Use of TSL approx. to compute derivatives of the gradients ---*/ - - if (implicit) { - Jacobian_i[0][0] = (0.5*Proj_Mean_GradTurbVar[0]-nu_e*proj_vector_ij)/sigma; - Jacobian_j[0][0] = (0.5*Proj_Mean_GradTurbVar[0]+nu_e*proj_vector_ij)/sigma; - } - -} - -CSourcePieceWise_TurbSA::CSourcePieceWise_TurbSA(unsigned short val_nDim, unsigned short val_nVar, - CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); - rotating_frame = config->GetRotating_Frame(); - transition = (config->GetKind_Trans_Model() == BC); - - /*--- Spalart-Allmaras closure constants ---*/ - - cv1_3 = pow(7.1, 3.0); - k2 = pow(0.41, 2.0); - cb1 = 0.1355; - cw2 = 0.3; - ct3 = 1.2; - ct4 = 0.5; - cw3_6 = pow(2.0, 6.0); - sigma = 2./3.; - cb2 = 0.622; - cb2_sigma = cb2/sigma; - cw1 = cb1/k2+(1.0+cb2)/sigma; - -} - -CSourcePieceWise_TurbSA::~CSourcePieceWise_TurbSA(void) { } - -void CSourcePieceWise_TurbSA::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - -// AD::StartPreacc(); -// AD::SetPreaccIn(V_i, nDim+6); -// AD::SetPreaccIn(Vorticity_i, nDim); -// AD::SetPreaccIn(StrainMag_i); -// AD::SetPreaccIn(TurbVar_i[0]); -// AD::SetPreaccIn(TurbVar_Grad_i[0], nDim); -// AD::SetPreaccIn(Volume); AD::SetPreaccIn(dist_i); - -// BC Transition Model variables - su2double vmag, rey, re_theta, re_theta_t, re_v; - su2double tu , nu_cr, nu_t, nu_BC, chi_1, chi_2, term1, term2, term_exponential; - - if (incompressible) { - Density_i = V_i[nDim+2]; - Laminar_Viscosity_i = V_i[nDim+4]; - } - else { - Density_i = V_i[nDim+2]; - Laminar_Viscosity_i = V_i[nDim+5]; - } - - val_residual[0] = 0.0; - Production = 0.0; - Destruction = 0.0; - CrossProduction = 0.0; - val_Jacobian_i[0][0] = 0.0; - - gamma_BC = 0.0; - vmag = 0.0; - tu = config->GetTurbulenceIntensity_FreeStream(); - rey = config->GetReynolds(); - - if (nDim==2) { - vmag = sqrt(V_i[1]*V_i[1]+V_i[2]*V_i[2]); - } - else if (nDim==3) { - vmag = sqrt(V_i[1]*V_i[1]+V_i[2]*V_i[2]+V_i[3]*V_i[3]); - } - - /*--- Evaluate Omega ---*/ - - Omega = sqrt(Vorticity_i[0]*Vorticity_i[0] + Vorticity_i[1]*Vorticity_i[1] + Vorticity_i[2]*Vorticity_i[2]); - - /*--- Rotational correction term ---*/ - - if (rotating_frame) { Omega += 2.0*min(0.0, StrainMag_i-Omega); } - - if (dist_i > 1e-10) { - - /*--- Production term ---*/ - - dist_i_2 = dist_i*dist_i; - nu = Laminar_Viscosity_i/Density_i; - Ji = TurbVar_i[0]/nu; - Ji_2 = Ji*Ji; - Ji_3 = Ji_2*Ji; - fv1 = Ji_3/(Ji_3+cv1_3); - fv2 = 1.0 - Ji/(1.0+Ji*fv1); - ft2 = ct3*exp(-ct4*Ji_2); - S = Omega; - inv_k2_d2 = 1.0/(k2*dist_i_2); - - Shat = S + TurbVar_i[0]*fv2*inv_k2_d2; - Shat = max(Shat, 1.0e-10); - inv_Shat = 1.0/Shat; - -// Original SA model -// Production = cb1*(1.0-ft2)*Shat*TurbVar_i[0]*Volume; - - if (transition) { - -// BC model constants - chi_1 = 0.002; - chi_2 = 5.0; - - nu_t = (TurbVar_i[0]*fv1); //S-A variable - nu_cr = chi_2/rey; - nu_BC = (nu_t)/(vmag*dist_i); - - re_v = ((Density_i*pow(dist_i,2.))/(Laminar_Viscosity_i))*Omega; - re_theta = re_v/2.193; - re_theta_t = (803.73 * pow((tu + 0.6067),-1.027)); //MENTER correlation - //re_theta_t = 163.0 + exp(6.91-tu); //ABU-GHANNAM & SHAW correlation - - term1 = sqrt(max(re_theta-re_theta_t,0.)/(chi_1*re_theta_t)); - term2 = sqrt(max(nu_BC-nu_cr,0.)/(nu_cr)); - term_exponential = (term1 + term2); - gamma_BC = 1.0 - exp(-term_exponential); - - Production = gamma_BC*cb1*Shat*TurbVar_i[0]*Volume; - } - else { - Production = cb1*Shat*TurbVar_i[0]*Volume; - } - - /*--- Destruction term ---*/ - - r = min(TurbVar_i[0]*inv_Shat*inv_k2_d2,10.0); - g = r + cw2*(pow(r,6.0)-r); - g_6 = pow(g,6.0); - glim = pow((1.0+cw3_6)/(g_6+cw3_6),1.0/6.0); - fw = g*glim; - -// Original SA model -// Destruction = (cw1*fw-cb1*ft2/k2)*TurbVar_i[0]*TurbVar_i[0]/dist_i_2*Volume; - - Destruction = cw1*fw*TurbVar_i[0]*TurbVar_i[0]/dist_i_2*Volume; - - /*--- Diffusion term ---*/ - - norm2_Grad = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - norm2_Grad += TurbVar_Grad_i[0][iDim]*TurbVar_Grad_i[0][iDim]; - - CrossProduction = cb2_sigma*norm2_Grad*Volume; - - val_residual[0] = Production - Destruction + CrossProduction; - - /*--- Implicit part, production term ---*/ - - dfv1 = 3.0*Ji_2*cv1_3/(nu*pow(Ji_3+cv1_3,2.)); - dfv2 = -(1/nu-Ji_2*dfv1)/pow(1.+Ji*fv1,2.); - if ( Shat <= 1.0e-10 ) dShat = 0.0; - else dShat = (fv2+TurbVar_i[0]*dfv2)*inv_k2_d2; - - if (transition) { - val_Jacobian_i[0][0] += gamma_BC*cb1*(TurbVar_i[0]*dShat+Shat)*Volume; - } - else { - val_Jacobian_i[0][0] += cb1*(TurbVar_i[0]*dShat+Shat)*Volume; - } - - /*--- Implicit part, destruction term ---*/ - - dr = (Shat-TurbVar_i[0]*dShat)*inv_Shat*inv_Shat*inv_k2_d2; - if (r == 10.0) dr = 0.0; - dg = dr*(1.+cw2*(6.0*pow(r,5.0)-1.0)); - dfw = dg*glim*(1.-g_6/(g_6+cw3_6)); - val_Jacobian_i[0][0] -= cw1*(dfw*TurbVar_i[0] + 2.0*fw)*TurbVar_i[0]/dist_i_2*Volume; - - } - -// AD::SetPreaccOut(val_residual[0]); -// AD::EndPreacc(); - -} - -CSourcePieceWise_TurbSA_E::CSourcePieceWise_TurbSA_E(unsigned short val_nDim, unsigned short val_nVar, - CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); - rotating_frame = config->GetRotating_Frame(); - - /*--- Spalart-Allmaras closure constants ---*/ - - cv1_3 = pow(7.1, 3.0); - k2 = pow(0.41, 2.0); - cb1 = 0.1355; - cw2 = 0.3; - ct3 = 1.2; - ct4 = 0.5; - cw3_6 = pow(2.0, 6.0); - sigma = 2./3.; - cb2 = 0.622; - cb2_sigma = cb2/sigma; - cw1 = cb1/k2+(1.0+cb2)/sigma; - -} - -CSourcePieceWise_TurbSA_E::~CSourcePieceWise_TurbSA_E(void) { } - -void CSourcePieceWise_TurbSA_E::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - // AD::StartPreacc(); - // AD::SetPreaccIn(V_i, nDim+6); - // AD::SetPreaccIn(Vorticity_i, nDim); - // AD::SetPreaccIn(StrainMag_i); - // AD::SetPreaccIn(TurbVar_i[0]); - // AD::SetPreaccIn(TurbVar_Grad_i[0], nDim); - // AD::SetPreaccIn(Volume); AD::SetPreaccIn(dist_i); - - if (incompressible) { - Density_i = V_i[nDim+2]; - Laminar_Viscosity_i = V_i[nDim+4]; - } - else { - Density_i = V_i[nDim+2]; - Laminar_Viscosity_i = V_i[nDim+5]; - } - - val_residual[0] = 0.0; - Production = 0.0; - Destruction = 0.0; - CrossProduction = 0.0; - val_Jacobian_i[0][0] = 0.0; - - - /* - From NASA Turbulence model site. http://turbmodels.larc.nasa.gov/spalart.html - This form was developed primarily to improve the near-wall numerical behavior of the model (i.e., the goal was to improve the convergence behavior). The reference is: - Edwards, J. R. and Chandra, S. "Comparison of Eddy Viscosity-Transport Turbulence Models for Three-Dimensional, Shock-Separated Flowfields," AIAA Journal, Vol. 34, No. 4, 1996, pp. 756-763. - In this modificaton Omega is replaced by Strain Rate - */ - - /*--- Evaluate Omega, here Omega is the Strain Rate ---*/ - - Sbar = 0.0; - for(iDim=0;iDim 1e-10) { - - /*--- Production term ---*/ - - dist_i_2 = dist_i*dist_i; - nu = Laminar_Viscosity_i/Density_i; - Ji = TurbVar_i[0]/nu; - Ji_2 = Ji*Ji; - Ji_3 = Ji_2*Ji; - fv1 = Ji_3/(Ji_3+cv1_3); - fv2 = 1.0 - Ji/(1.0+Ji*fv1); - ft2 = ct3*exp(-ct4*Ji_2); - S = Omega; - inv_k2_d2 = 1.0/(k2*dist_i_2); - - //Shat = S + TurbVar_i[0]*fv2*inv_k2_d2; - Shat = max(S*((1.0/max(Ji,1.0e-16))+fv1),1.0e-16); - - Shat = max(Shat, 1.0e-10); - inv_Shat = 1.0/Shat; - - /*--- Production term ---*/; - - Production = cb1*Shat*TurbVar_i[0]*Volume; - - /*--- Destruction term ---*/ - - r = min(TurbVar_i[0]*inv_Shat*inv_k2_d2,10.0); - r=tanh(r)/tanh(1.0); - - g = r + cw2*(pow(r,6.0)-r); - g_6 = pow(g,6.0); - glim = pow((1.0+cw3_6)/(g_6+cw3_6),1.0/6.0); - fw = g*glim; - - Destruction = cw1*fw*TurbVar_i[0]*TurbVar_i[0]/dist_i_2*Volume; - - /*--- Diffusion term ---*/ - - norm2_Grad = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - norm2_Grad += TurbVar_Grad_i[0][iDim]*TurbVar_Grad_i[0][iDim]; - - CrossProduction = cb2_sigma*norm2_Grad*Volume; - - val_residual[0] = Production - Destruction + CrossProduction; - - /*--- Implicit part, production term ---*/ - - dfv1 = 3.0*Ji_2*cv1_3/(nu*pow(Ji_3+cv1_3,2.)); - dfv2 = -(1/nu-Ji_2*dfv1)/pow(1.+Ji*fv1,2.); - - if ( Shat <= 1.0e-10 ) dShat = 0.0; - else dShat = -S*pow(Ji,-2.0)/nu + S*dfv1; - val_Jacobian_i[0][0] += cb1*(TurbVar_i[0]*dShat+Shat)*Volume; - - /*--- Implicit part, destruction term ---*/ - - dr = (Shat-TurbVar_i[0]*dShat)*inv_Shat*inv_Shat*inv_k2_d2; - dr=(1-pow(tanh(r),2.0))*(dr)/tanh(1.0); - dg = dr*(1.+cw2*(6.0*pow(r,5.0)-1.0)); - dfw = dg*glim*(1.-g_6/(g_6+cw3_6)); - val_Jacobian_i[0][0] -= cw1*(dfw*TurbVar_i[0] + 2.0*fw)*TurbVar_i[0]/dist_i_2*Volume; - - } - - // AD::SetPreaccOut(val_residual[0]); - // AD::EndPreacc(); - -} - -CSourcePieceWise_TurbSA_COMP::CSourcePieceWise_TurbSA_COMP(unsigned short val_nDim, unsigned short val_nVar, - CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); - rotating_frame = config->GetRotating_Frame(); - - /*--- Spalart-Allmaras closure constants ---*/ - - cv1_3 = pow(7.1, 3.0); - k2 = pow(0.41, 2.0); - cb1 = 0.1355; - cw2 = 0.3; - ct3 = 1.2; - ct4 = 0.5; - cw3_6 = pow(2.0, 6.0); - sigma = 2./3.; - cb2 = 0.622; - cb2_sigma = cb2/sigma; - cw1 = cb1/k2+(1.0+cb2)/sigma; - c5 = 3.5; - -} - -CSourcePieceWise_TurbSA_COMP::~CSourcePieceWise_TurbSA_COMP(void) { } - -void CSourcePieceWise_TurbSA_COMP::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - // AD::StartPreacc(); - // AD::SetPreaccIn(V_i, nDim+6); - // AD::SetPreaccIn(Vorticity_i, nDim); - // AD::SetPreaccIn(StrainMag_i); - // AD::SetPreaccIn(TurbVar_i[0]); - // AD::SetPreaccIn(TurbVar_Grad_i[0], nDim); - // AD::SetPreaccIn(Volume); AD::SetPreaccIn(dist_i); - - if (incompressible) { - Density_i = V_i[nDim+2]; - Laminar_Viscosity_i = V_i[nDim+4]; - } - else { - Density_i = V_i[nDim+2]; - Laminar_Viscosity_i = V_i[nDim+5]; - } - - val_residual[0] = 0.0; - Production = 0.0; - Destruction = 0.0; - CrossProduction = 0.0; - val_Jacobian_i[0][0] = 0.0; - - /*--- Evaluate Omega ---*/ - - Omega = sqrt(Vorticity_i[0]*Vorticity_i[0] + Vorticity_i[1]*Vorticity_i[1] + Vorticity_i[2]*Vorticity_i[2]); - - /*--- Rotational correction term ---*/ - - if (rotating_frame) { Omega += 2.0*min(0.0, StrainMag_i-Omega); } - - if (dist_i > 1e-10) { - - /*--- Production term ---*/ - - dist_i_2 = dist_i*dist_i; - nu = Laminar_Viscosity_i/Density_i; - Ji = TurbVar_i[0]/nu; - Ji_2 = Ji*Ji; - Ji_3 = Ji_2*Ji; - fv1 = Ji_3/(Ji_3+cv1_3); - fv2 = 1.0 - Ji/(1.0+Ji*fv1); - ft2 = ct3*exp(-ct4*Ji_2); - S = Omega; - inv_k2_d2 = 1.0/(k2*dist_i_2); - - Shat = S + TurbVar_i[0]*fv2*inv_k2_d2; - Shat = max(Shat, 1.0e-10); - inv_Shat = 1.0/Shat; - - /*--- Production term ---*/; - - Production = cb1*Shat*TurbVar_i[0]*Volume; - - /*--- Destruction term ---*/ - - r = min(TurbVar_i[0]*inv_Shat*inv_k2_d2,10.0); - g = r + cw2*(pow(r,6.0)-r); - g_6 = pow(g,6.0); - glim = pow((1.0+cw3_6)/(g_6+cw3_6),1.0/6.0); - fw = g*glim; - - Destruction = cw1*fw*TurbVar_i[0]*TurbVar_i[0]/dist_i_2*Volume; - - /*--- Diffusion term ---*/ - - norm2_Grad = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - norm2_Grad += TurbVar_Grad_i[0][iDim]*TurbVar_Grad_i[0][iDim]; - - CrossProduction = cb2_sigma*norm2_Grad*Volume; - - val_residual[0] = Production - Destruction + CrossProduction; - - /*--- Compressibility Correction term ---*/ - Pressure_i = V_i[nDim+1]; - SoundSpeed_i = sqrt(Pressure_i*Gamma/Density_i); - aux_cc=0; - for(iDim=0;iDimGetKind_Regime() == INCOMPRESSIBLE); - rotating_frame = config->GetRotating_Frame(); - - /*--- Spalart-Allmaras closure constants ---*/ - - cv1_3 = pow(7.1, 3.0); - k2 = pow(0.41, 2.0); - cb1 = 0.1355; - cw2 = 0.3; - ct3 = 1.2; - ct4 = 0.5; - cw3_6 = pow(2.0, 6.0); - sigma = 2./3.; - cb2 = 0.622; - cb2_sigma = cb2/sigma; - cw1 = cb1/k2+(1.0+cb2)/sigma; - -} - -CSourcePieceWise_TurbSA_E_COMP::~CSourcePieceWise_TurbSA_E_COMP(void) { } - -void CSourcePieceWise_TurbSA_E_COMP::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - // AD::StartPreacc(); - // AD::SetPreaccIn(V_i, nDim+6); - // AD::SetPreaccIn(Vorticity_i, nDim); - // AD::SetPreaccIn(StrainMag_i); - // AD::SetPreaccIn(TurbVar_i[0]); - // AD::SetPreaccIn(TurbVar_Grad_i[0], nDim); - // AD::SetPreaccIn(Volume); AD::SetPreaccIn(dist_i); - - if (incompressible) { - Density_i = V_i[nDim+2]; - Laminar_Viscosity_i = V_i[nDim+4]; - } - else { - Density_i = V_i[nDim+2]; - Laminar_Viscosity_i = V_i[nDim+5]; - } - - val_residual[0] = 0.0; - Production = 0.0; - Destruction = 0.0; - CrossProduction = 0.0; - val_Jacobian_i[0][0] = 0.0; - - /* - From NASA Turbulence model site. http://turbmodels.larc.nasa.gov/spalart.html - This form was developed primarily to improve the near-wall numerical behavior of the model (i.e., the goal was to improve the convergence behavior). The reference is: - Edwards, J. R. and Chandra, S. "Comparison of Eddy Viscosity-Transport Turbulence Models for Three-Dimensional, Shock-Separated Flowfields," AIAA Journal, Vol. 34, No. 4, 1996, pp. 756-763. - In this modificaton Omega is replaced by Strain Rate - */ - - /*--- Evaluate Omega, here Omega is the Strain Rate ---*/ - - Sbar = 0.0; - for(iDim=0;iDim 1e-10) { - - /*--- Production term ---*/ - - dist_i_2 = dist_i*dist_i; - nu = Laminar_Viscosity_i/Density_i; - Ji = TurbVar_i[0]/nu; - Ji_2 = Ji*Ji; - Ji_3 = Ji_2*Ji; - fv1 = Ji_3/(Ji_3+cv1_3); - fv2 = 1.0 - Ji/(1.0+Ji*fv1); - ft2 = ct3*exp(-ct4*Ji_2); - S = Omega; - inv_k2_d2 = 1.0/(k2*dist_i_2); - - Shat = max(S*((1.0/max(Ji,1.0e-16))+fv1),1.0e-16); - - Shat = max(Shat, 1.0e-10); - inv_Shat = 1.0/Shat; - - /*--- Production term ---*/; - - Production = cb1*Shat*TurbVar_i[0]*Volume; - - /*--- Destruction term ---*/ - - r = min(TurbVar_i[0]*inv_Shat*inv_k2_d2,10.0); - r=tanh(r)/tanh(1.0); - - g = r + cw2*(pow(r,6.0)-r); - g_6 = pow(g,6.0); - glim = pow((1.0+cw3_6)/(g_6+cw3_6),1.0/6.0); - fw = g*glim; - - Destruction = cw1*fw*TurbVar_i[0]*TurbVar_i[0]/dist_i_2*Volume; - - /*--- Diffusion term ---*/ - - norm2_Grad = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - norm2_Grad += TurbVar_Grad_i[0][iDim]*TurbVar_Grad_i[0][iDim]; - - CrossProduction = cb2_sigma*norm2_Grad*Volume; - - val_residual[0] = Production - Destruction + CrossProduction; - - /*--- Compressibility Correction term ---*/ - Pressure_i = V_i[nDim+1]; - SoundSpeed_i = sqrt(Pressure_i*Gamma/Density_i); - aux_cc=0; - for(iDim=0;iDimGetKind_Regime() == INCOMPRESSIBLE); - rotating_frame = config->GetRotating_Frame(); - - /*--- Negative Spalart-Allmaras closure constants ---*/ - - cv1_3 = pow(7.1, 3.0); - k2 = pow(0.41, 2.0); - cb1 = 0.1355; - cw2 = 0.3; - ct3 = 1.2; - ct4 = 0.5; - cw3_6 = pow(2.0, 6.0); - sigma = 2./3.; - cb2 = 0.622; - cb2_sigma = cb2/sigma; - cw1 = cb1/k2+(1.0+cb2)/sigma; - -} - -CSourcePieceWise_TurbSA_Neg::~CSourcePieceWise_TurbSA_Neg(void) { - -} - -void CSourcePieceWise_TurbSA_Neg::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - -// AD::StartPreacc(); -// AD::SetPreaccIn(V_i, nDim+6); -// AD::SetPreaccIn(Vorticity_i, nDim); -// AD::SetPreaccIn(StrainMag_i); -// AD::SetPreaccIn(TurbVar_i[0]); -// AD::SetPreaccIn(TurbVar_Grad_i[0], nDim); -// AD::SetPreaccIn(Volume); AD::SetPreaccIn(dist_i); - - if (incompressible) { - Density_i = V_i[nDim+2]; - Laminar_Viscosity_i = V_i[nDim+4]; - } - else { - Density_i = V_i[nDim+2]; - Laminar_Viscosity_i = V_i[nDim+5]; - } - - val_residual[0] = 0.0; - Production = 0.0; - Destruction = 0.0; - CrossProduction = 0.0; - val_Jacobian_i[0][0] = 0.0; - - /*--- Evaluate Omega ---*/ - - Omega = sqrt(Vorticity_i[0]*Vorticity_i[0] + Vorticity_i[1]*Vorticity_i[1] + Vorticity_i[2]*Vorticity_i[2]); - - /*--- Rotational correction term ---*/ - - if (rotating_frame) { Omega += 2.0*min(0.0, StrainMag_i-Omega); } - - if (dist_i > 1e-10) { - - if (TurbVar_i[0] > 0.0) { - - /*--- Production term ---*/ - - dist_i_2 = dist_i*dist_i; - nu = Laminar_Viscosity_i/Density_i; - Ji = TurbVar_i[0]/nu; - Ji_2 = Ji*Ji; - Ji_3 = Ji_2*Ji; - fv1 = Ji_3/(Ji_3+cv1_3); - fv2 = 1.0 - Ji/(1.0+Ji*fv1); - ft2 = ct3*exp(-ct4*Ji_2); - S = Omega; - inv_k2_d2 = 1.0/(k2*dist_i_2); - - Shat = S + TurbVar_i[0]*fv2*inv_k2_d2; - Shat = max(Shat, 1.0e-10); - inv_Shat = 1.0/Shat; - - /*--- Production term ---*/; - - // Original SA model - // Production = cb1*(1.0-ft2)*Shat*TurbVar_i[0]*Volume; - - Production = cb1*Shat*TurbVar_i[0]*Volume; - - /*--- Destruction term ---*/ - - r = min(TurbVar_i[0]*inv_Shat*inv_k2_d2,10.0); - g = r + cw2*(pow(r,6.0)-r); - g_6 = pow(g,6.0); - glim = pow((1.0+cw3_6)/(g_6+cw3_6),1.0/6.0); - fw = g*glim; - - Destruction = cw1*fw*TurbVar_i[0]*TurbVar_i[0]/dist_i_2*Volume; - - /*--- Diffusion term ---*/ - - norm2_Grad = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - norm2_Grad += TurbVar_Grad_i[0][iDim]*TurbVar_Grad_i[0][iDim]; - - CrossProduction = cb2_sigma*norm2_Grad*Volume; - - val_residual[0] = Production - Destruction + CrossProduction; - - /*--- Implicit part, production term ---*/ - - dfv1 = 3.0*Ji_2*cv1_3/(nu*pow(Ji_3+cv1_3,2.)); - dfv2 = -(1/nu-Ji_2*dfv1)/pow(1.+Ji*fv1,2.); - if ( Shat <= 1.0e-10 ) dShat = 0.0; - else dShat = (fv2+TurbVar_i[0]*dfv2)*inv_k2_d2; - val_Jacobian_i[0][0] += cb1*(TurbVar_i[0]*dShat+Shat)*Volume; - - /*--- Implicit part, destruction term ---*/ - - dr = (Shat-TurbVar_i[0]*dShat)*inv_Shat*inv_Shat*inv_k2_d2; - if (r == 10.0) dr = 0.0; - dg = dr*(1.+cw2*(6.0*pow(r,5.0)-1.0)); - dfw = dg*glim*(1.-g_6/(g_6+cw3_6)); - val_Jacobian_i[0][0] -= cw1*(dfw*TurbVar_i[0] + 2.0*fw)*TurbVar_i[0]/dist_i_2*Volume; - - } - - else { - - /*--- Production term ---*/ - - dist_i_2 = dist_i*dist_i; - - /*--- Production term ---*/; - - Production = cb1*(1.0-ct3)*Omega*TurbVar_i[0]*Volume; - - /*--- Destruction term ---*/ - - Destruction = cw1*TurbVar_i[0]*TurbVar_i[0]/dist_i_2*Volume; - - /*--- Diffusion term ---*/ - - norm2_Grad = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - norm2_Grad += TurbVar_Grad_i[0][iDim]*TurbVar_Grad_i[0][iDim]; - - CrossProduction = cb2_sigma*norm2_Grad*Volume; - - val_residual[0] = Production + Destruction + CrossProduction; - - /*--- Implicit part, production term ---*/ - - val_Jacobian_i[0][0] += cb1*(1.0-ct3)*Omega*Volume; - - /*--- Implicit part, destruction term ---*/ - - val_Jacobian_i[0][0] += 2.0*cw1*TurbVar_i[0]/dist_i_2*Volume; - - } - - } - -// AD::SetPreaccOut(val_residual, nVar); -// AD::EndPreacc(); -} - -CUpwSca_TurbSST::CUpwSca_TurbSST(unsigned short val_nDim, - unsigned short val_nVar, - CConfig *config) - : CUpwScalar(val_nDim, val_nVar, config) { -} - -CUpwSca_TurbSST::~CUpwSca_TurbSST(void) { -} - -void CUpwSca_TurbSST::ExtraADPreaccIn() { - - AD::SetPreaccIn(V_i, nDim+3); - AD::SetPreaccIn(V_j, nDim+3); - -} - -void CUpwSca_TurbSST::FinishResidualCalc(su2double *val_residual, - su2double **val_Jacobian_i, - su2double **val_Jacobian_j, - CConfig *config) { - - val_residual[0] = a0*Density_i*TurbVar_i[0]+a1*Density_j*TurbVar_j[0]; - val_residual[1] = a0*Density_i*TurbVar_i[1]+a1*Density_j*TurbVar_j[1]; - - if (implicit) { - val_Jacobian_i[0][0] = a0; val_Jacobian_i[0][1] = 0.0; - val_Jacobian_i[1][0] = 0.0; val_Jacobian_i[1][1] = a0; - - val_Jacobian_j[0][0] = a1; val_Jacobian_j[0][1] = 0.0; - val_Jacobian_j[1][0] = 0.0; val_Jacobian_j[1][1] = a1; - } -} - -CAvgGrad_TurbSST::CAvgGrad_TurbSST(unsigned short val_nDim, - unsigned short val_nVar, - const su2double *constants, - bool correct_grad, - CConfig *config) - : CAvgGrad_Scalar(val_nDim, val_nVar, correct_grad, config) { - - sigma_k1 = constants[0]; - sigma_om1 = constants[2]; - sigma_k2 = constants[1]; - sigma_om2 = constants[3]; - - F1_i = 0.0; F1_j = 0.0; - diff_kine = 0.0; - diff_omega = 0.0; - -} - -CAvgGrad_TurbSST::~CAvgGrad_TurbSST(void) { -} - -void CAvgGrad_TurbSST::ExtraADPreaccIn() { - AD::SetPreaccIn(F1_i); AD::SetPreaccIn(F1_j); -} - -void CAvgGrad_TurbSST::FinishResidualCalc(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config) { - - su2double sigma_kine_i, sigma_kine_j, sigma_omega_i, sigma_omega_j; - su2double diff_i_kine, diff_i_omega, diff_j_kine, diff_j_omega; - - /*--- Compute the blended constant for the viscous terms ---*/ - sigma_kine_i = F1_i*sigma_k1 + (1.0 - F1_i)*sigma_k2; - sigma_kine_j = F1_j*sigma_k1 + (1.0 - F1_j)*sigma_k2; - sigma_omega_i = F1_i*sigma_om1 + (1.0 - F1_i)*sigma_om2; - sigma_omega_j = F1_j*sigma_om1 + (1.0 - F1_j)*sigma_om2; - - /*--- Compute mean effective viscosity ---*/ - diff_i_kine = Laminar_Viscosity_i + sigma_kine_i*Eddy_Viscosity_i; - diff_j_kine = Laminar_Viscosity_j + sigma_kine_j*Eddy_Viscosity_j; - diff_i_omega = Laminar_Viscosity_i + sigma_omega_i*Eddy_Viscosity_i; - diff_j_omega = Laminar_Viscosity_j + sigma_omega_j*Eddy_Viscosity_j; - - diff_kine = 0.5*(diff_i_kine + diff_j_kine); // Could instead use weighted average! - diff_omega = 0.5*(diff_i_omega + diff_j_omega); - - val_residual[0] = diff_kine*Proj_Mean_GradTurbVar[0]; - val_residual[1] = diff_omega*Proj_Mean_GradTurbVar[1]; - - /*--- For Jacobians -> Use of TSL approx. to compute derivatives of the gradients ---*/ - if (implicit) { - Jacobian_i[0][0] = -diff_kine*proj_vector_ij/Density_i; Jacobian_i[0][1] = 0.0; - Jacobian_i[1][0] = 0.0; Jacobian_i[1][1] = -diff_omega*proj_vector_ij/Density_i; - - Jacobian_j[0][0] = diff_kine*proj_vector_ij/Density_j; Jacobian_j[0][1] = 0.0; - Jacobian_j[1][0] = 0.0; Jacobian_j[1][1] = diff_omega*proj_vector_ij/Density_j; - } - -} - -CSourcePieceWise_TurbSST::CSourcePieceWise_TurbSST(unsigned short val_nDim, unsigned short val_nVar, const su2double *constants, - su2double val_kine_Inf, su2double val_omega_Inf, CConfig *config) - : CNumerics(val_nDim, val_nVar, config) { - - incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); - sustaining_terms = (config->GetKind_Turb_Model() == SST_SUST); - - /*--- Closure constants ---*/ - beta_star = constants[6]; - sigma_omega_1 = constants[2]; - sigma_omega_2 = constants[3]; - beta_1 = constants[4]; - beta_2 = constants[5]; - alfa_1 = constants[8]; - alfa_2 = constants[9]; - a1 = constants[7]; - - /*--- Set the ambient values of k and omega to the free stream values. ---*/ - kAmb = val_kine_Inf; - omegaAmb = val_omega_Inf; -} - -CSourcePieceWise_TurbSST::~CSourcePieceWise_TurbSST(void) { } - -void CSourcePieceWise_TurbSST::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - AD::StartPreacc(); - AD::SetPreaccIn(StrainMag_i); - AD::SetPreaccIn(TurbVar_i, nVar); - AD::SetPreaccIn(TurbVar_Grad_i, nVar, nDim); - AD::SetPreaccIn(Volume); AD::SetPreaccIn(dist_i); - AD::SetPreaccIn(F1_i); AD::SetPreaccIn(F2_i); AD::SetPreaccIn(CDkw_i); - AD::SetPreaccIn(PrimVar_Grad_i, nDim+1, nDim); - - unsigned short iDim; - su2double alfa_blended, beta_blended; - su2double diverg, pk, pw, zeta; - - if (incompressible) { - AD::SetPreaccIn(V_i, nDim+6); - - Density_i = V_i[nDim+2]; - Laminar_Viscosity_i = V_i[nDim+4]; - Eddy_Viscosity_i = V_i[nDim+5]; - } - else { - AD::SetPreaccIn(V_i, nDim+7); - - Density_i = V_i[nDim+2]; - Laminar_Viscosity_i = V_i[nDim+5]; - Eddy_Viscosity_i = V_i[nDim+6]; - } - - val_residual[0] = 0.0; val_residual[1] = 0.0; - val_Jacobian_i[0][0] = 0.0; val_Jacobian_i[0][1] = 0.0; - val_Jacobian_i[1][0] = 0.0; val_Jacobian_i[1][1] = 0.0; - - /*--- Computation of blended constants for the source terms---*/ - - alfa_blended = F1_i*alfa_1 + (1.0 - F1_i)*alfa_2; - beta_blended = F1_i*beta_1 + (1.0 - F1_i)*beta_2; - - if (dist_i > 1e-10) { - - /*--- Production ---*/ - - diverg = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - diverg += PrimVar_Grad_i[iDim+1][iDim]; - - /* if using UQ methodolgy, calculate production using perturbed Reynolds stress matrix */ - - if (using_uq){ - SetReynoldsStressMatrix(TurbVar_i[0]); - SetPerturbedRSM(TurbVar_i[0], config); - SetPerturbedStrainMag(TurbVar_i[0]); - pk = Eddy_Viscosity_i*PerturbedStrainMag*PerturbedStrainMag - - 2.0/3.0*Density_i*TurbVar_i[0]*diverg; - } - else { - pk = Eddy_Viscosity_i*StrainMag_i*StrainMag_i - 2.0/3.0*Density_i*TurbVar_i[0]*diverg; - } - - - pk = min(pk,20.0*beta_star*Density_i*TurbVar_i[1]*TurbVar_i[0]); - pk = max(pk,0.0); - - zeta = max(TurbVar_i[1], StrainMag_i*F2_i/a1); - - /* if using UQ methodolgy, calculate production using perturbed Reynolds stress matrix */ - - if (using_uq){ - pw = PerturbedStrainMag * PerturbedStrainMag - 2.0/3.0*zeta*diverg; - } - else { - pw = StrainMag_i*StrainMag_i - 2.0/3.0*zeta*diverg; - } - pw = alfa_blended*Density_i*max(pw,0.0); - - /*--- Sustaining terms, if desired. Note that if the production terms are - larger equal than the sustaining terms, the original formulation is - obtained again. This is in contrast to the version in literature - where the sustaining terms are simply added. This latter approach could - lead to problems for very big values of the free-stream turbulence - intensity. ---*/ - - if ( sustaining_terms ) { - const su2double sust_k = beta_star*Density_i*kAmb*omegaAmb; - const su2double sust_w = beta_blended*Density_i*omegaAmb*omegaAmb; - - pk = max(pk, sust_k); - pw = max(pw, sust_w); - } - - /*--- Add the production terms to the residuals. ---*/ - - val_residual[0] += pk*Volume; - val_residual[1] += pw*Volume; - - /*--- Dissipation ---*/ - - val_residual[0] -= beta_star*Density_i*TurbVar_i[1]*TurbVar_i[0]*Volume; - val_residual[1] -= beta_blended*Density_i*TurbVar_i[1]*TurbVar_i[1]*Volume; - - /*--- Cross diffusion ---*/ - - val_residual[1] += (1.0 - F1_i)*CDkw_i*Volume; - - /*--- Implicit part ---*/ - - val_Jacobian_i[0][0] = -beta_star*TurbVar_i[1]*Volume; - val_Jacobian_i[0][1] = -beta_star*TurbVar_i[0]*Volume; - val_Jacobian_i[1][0] = 0.0; - val_Jacobian_i[1][1] = -2.0*beta_blended*TurbVar_i[1]*Volume; - } - - AD::SetPreaccOut(val_residual, nVar); - AD::EndPreacc(); - -} - -void CSourcePieceWise_TurbSST::GetMeanRateOfStrainMatrix(su2double **S_ij) -{ - /* --- Calculate the rate of strain tensor, using mean velocity gradients --- */ - - if (nDim == 3){ - S_ij[0][0] = PrimVar_Grad_i[1][0]; - S_ij[1][1] = PrimVar_Grad_i[2][1]; - S_ij[2][2] = PrimVar_Grad_i[3][2]; - S_ij[0][1] = 0.5 * (PrimVar_Grad_i[1][1] + PrimVar_Grad_i[2][0]); - S_ij[0][2] = 0.5 * (PrimVar_Grad_i[1][2] + PrimVar_Grad_i[3][0]); - S_ij[1][2] = 0.5 * (PrimVar_Grad_i[2][2] + PrimVar_Grad_i[3][1]); - S_ij[1][0] = S_ij[0][1]; - S_ij[2][1] = S_ij[1][2]; - S_ij[2][0] = S_ij[0][2]; - } - else { - S_ij[0][0] = PrimVar_Grad_i[1][0]; - S_ij[1][1] = PrimVar_Grad_i[2][1]; - S_ij[2][2] = 0.0; - S_ij[0][1] = 0.5 * (PrimVar_Grad_i[1][1] + PrimVar_Grad_i[2][0]); - S_ij[0][2] = 0.0; - S_ij[1][2] = 0.0; - S_ij[1][0] = S_ij[0][1]; - S_ij[2][1] = S_ij[1][2]; - S_ij[2][0] = S_ij[0][2]; - - } -} - -void CSourcePieceWise_TurbSST::SetReynoldsStressMatrix(su2double turb_ke){ - unsigned short iDim, jDim; - su2double **S_ij = new su2double* [3]; - su2double divVel = 0; - su2double TWO3 = 2.0/3.0; - - - - for (iDim = 0; iDim < 3; iDim++){ - S_ij[iDim] = new su2double [3]; - } - - GetMeanRateOfStrainMatrix(S_ij); - - /* --- Using rate of strain matrix, calculate Reynolds stress tensor --- */ - - for (iDim = 0; iDim < 3; iDim++){ - divVel += S_ij[iDim][iDim]; - } - - for (iDim = 0; iDim < 3; iDim++){ - for (jDim = 0; jDim < 3; jDim++){ - MeanReynoldsStress[iDim][jDim] = TWO3 * turb_ke * delta3[iDim][jDim] - - Eddy_Viscosity_i / Density_i * (2 * S_ij[iDim][jDim] - TWO3 * divVel * delta3[iDim][jDim]); - } - } - - for (iDim = 0; iDim < 3; iDim++) - delete [] S_ij[iDim]; - delete [] S_ij; -} - -void CSourcePieceWise_TurbSST::SetPerturbedRSM(su2double turb_ke, CConfig *config){ - - unsigned short iDim,jDim; - - /* --- Calculate anisotropic part of Reynolds Stress tensor --- */ - - for (iDim = 0; iDim< 3; iDim++){ - for (jDim = 0; jDim < 3; jDim++){ - A_ij[iDim][jDim] = .5 * MeanReynoldsStress[iDim][jDim] / turb_ke - delta3[iDim][jDim] / 3.0; - Eig_Vec[iDim][jDim] = A_ij[iDim][jDim]; - } - } - - /* --- Get ordered eigenvectors and eigenvalues of A_ij --- */ - - EigenDecomposition(A_ij, Eig_Vec, Eig_Val, 3); - - /* compute convex combination coefficients */ - su2double c1c = Eig_Val[2] - Eig_Val[1]; - su2double c2c = 2.0 * (Eig_Val[1] - Eig_Val[0]); - su2double c3c = 3.0 * Eig_Val[0] + 1.0; - - /* define barycentric traingle corner points */ - Corners[0][0] = 1.0; - Corners[0][1] = 0.0; - Corners[1][0] = 0.0; - Corners[1][1] = 0.0; - Corners[2][0] = 0.5; - Corners[2][1] = 0.866025; - - /* define barycentric coordinates */ - Barycentric_Coord[0] = Corners[0][0] * c1c + Corners[1][0] * c2c + Corners[2][0] * c3c; - Barycentric_Coord[1] = Corners[0][1] * c1c + Corners[1][1] * c2c + Corners[2][1] * c3c; - - if (Eig_Val_Comp == 1) { - /* 1C turbulence */ - New_Coord[0] = Corners[0][0]; - New_Coord[1] = Corners[0][1]; - } - else if (Eig_Val_Comp == 2) { - /* 2C turbulence */ - New_Coord[0] = Corners[1][0]; - New_Coord[1] = Corners[1][1]; - } - else if (Eig_Val_Comp == 3) { - /* 3C turbulence */ - New_Coord[0] = Corners[2][0]; - New_Coord[1] = Corners[2][1]; - } - else { - /* 2C turbulence */ - New_Coord[0] = Corners[1][0]; - New_Coord[1] = Corners[1][1]; - } - /* calculate perturbed barycentric coordinates */ - - Barycentric_Coord[0] = Barycentric_Coord[0] + (uq_delta_b) * (New_Coord[0] - Barycentric_Coord[0]); - Barycentric_Coord[1] = Barycentric_Coord[1] + (uq_delta_b) * (New_Coord[1] - Barycentric_Coord[1]); - - /* rebuild c1c,c2c,c3c based on new barycentric coordinates */ - c3c = Barycentric_Coord[1] / Corners[2][1]; - c1c = Barycentric_Coord[0] - Corners[2][0] * c3c; - c2c = 1 - c1c - c3c; - - /* build new anisotropy eigenvalues */ - Eig_Val[0] = (c3c - 1) / 3.0; - Eig_Val[1] = 0.5 *c2c + Eig_Val[0]; - Eig_Val[2] = c1c + Eig_Val[1]; - - /* permute eigenvectors if required */ - if (uq_permute) { - for (iDim=0; iDim<3; iDim++) { - for (jDim=0; jDim<3; jDim++) { - New_Eig_Vec[iDim][jDim] = Eig_Vec[2-iDim][jDim]; - } - } - } - - else { - for (iDim=0; iDim<3; iDim++) { - for (jDim=0; jDim<3; jDim++) { - New_Eig_Vec[iDim][jDim] = Eig_Vec[iDim][jDim]; - } - } - } - - EigenRecomposition(newA_ij, New_Eig_Vec, Eig_Val, 3); - - /* compute perturbed Reynolds stress matrix; use under-relaxation factor (urlx)*/ - for (iDim = 0; iDim< 3; iDim++){ - for (jDim = 0; jDim < 3; jDim++){ - MeanPerturbedRSM[iDim][jDim] = 2.0 * turb_ke * (newA_ij[iDim][jDim] + 1.0/3.0 * delta3[iDim][jDim]); - MeanPerturbedRSM[iDim][jDim] = MeanReynoldsStress[iDim][jDim] + - uq_urlx*(MeanPerturbedRSM[iDim][jDim] - MeanReynoldsStress[iDim][jDim]); - } - } - -} - -void CSourcePieceWise_TurbSST::SetPerturbedStrainMag(su2double turb_ke){ - unsigned short iDim, jDim; - PerturbedStrainMag = 0; - su2double **StrainRate = new su2double* [nDim]; - for (iDim= 0; iDim< nDim; iDim++){ - StrainRate[iDim] = new su2double [nDim]; - } - - /* compute perturbed strain rate tensor */ - - for (iDim = 0; iDim < nDim; iDim++){ - for (jDim =0; jDim < nDim; jDim++){ - StrainRate[iDim][jDim] = MeanPerturbedRSM[iDim][jDim] - - TWO3 * turb_ke * delta[iDim][jDim]; - StrainRate[iDim][jDim] = - StrainRate[iDim][jDim] * Density_i / (2 * Eddy_Viscosity_i); - } - } - - /*--- Add diagonal part ---*/ - - for (iDim = 0; iDim < nDim; iDim++) { - PerturbedStrainMag += pow(StrainRate[iDim][iDim], 2.0); - } - - /*--- Add off diagonals ---*/ - - PerturbedStrainMag += 2.0*pow(StrainRate[1][0], 2.0); - - if (nDim == 3) { - PerturbedStrainMag += 2.0*pow(StrainRate[0][2], 2.0); - PerturbedStrainMag += 2.0*pow(StrainRate[1][2], 2.0); - } - - PerturbedStrainMag = sqrt(2.0*PerturbedStrainMag); - - for (iDim= 0; iDim< nDim; iDim++){ - delete [] StrainRate[iDim]; - } - - delete [] StrainRate; -} From 6ec4a40008d75b40d0913f8f097840511c31b01a Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Sun, 26 Jan 2020 12:21:50 +0000 Subject: [PATCH 008/118] spaces and tabs --- SU2_CFD/include/numerics/CNumerics.hpp | 30 +-- .../CAvgGradCorrected_AdjFlow.hpp | 8 +- .../CAvgGradCorrected_AdjTurb.hpp | 12 +- .../continuous_adjoint/CAvgGrad_AdjFlow.hpp | 8 +- .../continuous_adjoint/CAvgGrad_AdjTurb.hpp | 12 +- .../continuous_adjoint/CCentJST_AdjFlow.hpp | 8 +- .../continuous_adjoint/CCentLax_AdjFlow.hpp | 8 +- .../CSourceAxisymmetric_AdjFlow.hpp | 6 +- .../CSourceConservative_AdjFlow.hpp | 8 +- .../CSourceConservative_AdjTurb.hpp | 6 +- .../CSourcePieceWise_AdjTurb.hpp | 8 +- .../CSourceRotatingFrame_AdjFlow.hpp | 6 +- .../CSourceViscous_AdjFlow.hpp | 10 +- .../continuous_adjoint/CUpwLin_AdjTurb.hpp | 8 +- .../continuous_adjoint/CUpwRoe_AdjFlow.hpp | 8 +- .../continuous_adjoint/CUpwSca_AdjTurb.hpp | 8 +- .../elasticity/CFEALinearElasticity.hpp | 2 +- .../elasticity/CFEAMeshElasticity.hpp | 2 +- .../elasticity/CFEANonlinearElasticity.hpp | 2 +- .../elasticity/CFEM_DielectricElastomer.hpp | 2 +- .../numerics/elasticity/CFEM_IdealDE.hpp | 2 +- .../elasticity/CFEM_Knowles_NearInc.hpp | 2 +- .../elasticity/CFEM_NeoHookean_Comp.hpp | 2 +- .../convection_centered/CCentJSTInc_Flow.hpp | 8 +- .../convection_centered/CCentJST_Flow.hpp | 2 +- .../convection_centered/CCentLaxInc_Flow.hpp | 8 +- .../CUpwAUSMPLUSUP2_Flow.hpp | 10 +- .../convection_upwind/CUpwAUSMPLUSUP_Flow.hpp | 8 +- .../CUpwAUSMPLUS_SLAU_Base_Flow.hpp | 18 +- .../flow/convection_upwind/CUpwAUSM_Flow.hpp | 8 +- .../flow/convection_upwind/CUpwCUSP_Flow.hpp | 10 +- .../convection_upwind/CUpwFDSInc_Flow.hpp | 8 +- .../CUpwGeneralHLLC_Flow.hpp | 12 +- .../convection_upwind/CUpwGeneralRoe_Flow.hpp | 10 +- .../flow/convection_upwind/CUpwHLLC_Flow.hpp | 12 +- .../flow/convection_upwind/CUpwL2Roe_Flow.hpp | 2 +- .../flow/convection_upwind/CUpwLMRoe_Flow.hpp | 2 +- .../flow/convection_upwind/CUpwMSW_Flow.hpp | 10 +- .../convection_upwind/CUpwRoeBase_Flow.hpp | 12 +- .../flow/convection_upwind/CUpwRoe_Flow.hpp | 8 +- .../flow/convection_upwind/CUpwSLAU_Flow.hpp | 10 +- .../convection_upwind/CUpwTurkel_Flow.hpp | 8 +- .../flow/sources/CSourceAxisymmetric_Flow.hpp | 8 +- .../numerics/flow/sources/CSourceGravity.hpp | 8 +- .../flow/sources/CSourceIncBodyForce.hpp | 2 +- .../sources/CSourceRotatingFrame_Flow.hpp | 6 +- .../numerics/flow/sources/CSourceWindGust.hpp | 6 +- .../template/CConvective_Template.hpp | 10 +- .../numerics/template/CSource_Template.hpp | 8 +- .../numerics/template/CViscous_Template.hpp | 8 +- .../transition/CAvgGradCorrected_TransLM.hpp | 8 +- .../numerics/transition/CAvgGrad_TransLM.hpp | 8 +- .../transition/CSourcePieceWise_TransLM.hpp | 16 +- .../numerics/transition/CUpwLin_TransLM.hpp | 8 +- .../numerics/transition/CUpwSca_TransLM.hpp | 8 +- .../turbulent/CSourcePieceWise_TurbSA.hpp | 22 +- .../CSourcePieceWise_TurbSA_COMP.hpp | 22 +- .../turbulent/CSourcePieceWise_TurbSA_E.hpp | 22 +- .../CSourcePieceWise_TurbSA_E_COMP.hpp | 22 +- .../turbulent/CSourcePieceWise_TurbSA_Neg.hpp | 22 +- .../turbulent/CSourcePieceWise_TurbSST.hpp | 22 +- SU2_CFD/src/numerics/CNumerics.cpp | 2 +- .../CAvgGradCorrected_AdjFlow.cpp | 62 ++--- .../CAvgGradCorrected_AdjTurb.cpp | 42 +-- .../continuous_adjoint/CAvgGrad_AdjFlow.cpp | 44 ++-- .../continuous_adjoint/CAvgGrad_AdjTurb.cpp | 38 +-- .../continuous_adjoint/CCentJST_AdjFlow.cpp | 80 +++--- .../continuous_adjoint/CCentLax_AdjFlow.cpp | 54 ++-- .../CSourceAxisymmetric_AdjFlow.cpp | 16 +- .../CSourceConservative_AdjFlow.cpp | 66 ++--- .../CSourceConservative_AdjTurb.cpp | 16 +- .../CSourcePieceWise_AdjTurb.cpp | 44 ++-- .../CSourceRotatingFrame_AdjFlow.cpp | 16 +- .../CSourceViscous_AdjFlow.cpp | 126 ++++----- .../continuous_adjoint/CUpwLin_AdjTurb.cpp | 12 +- .../continuous_adjoint/CUpwRoe_AdjFlow.cpp | 138 +++++----- .../continuous_adjoint/CUpwSca_AdjTurb.cpp | 16 +- .../numerics/elasticity/CFEAElasticity.cpp | 2 +- .../elasticity/CFEALinearElasticity.cpp | 2 +- .../elasticity/CFEAMeshElasticity.cpp | 2 +- .../elasticity/CFEANonlinearElasticity.cpp | 2 +- .../elasticity/CFEM_DielectricElastomer.cpp | 2 +- .../src/numerics/elasticity/CFEM_IdealDE.cpp | 2 +- .../elasticity/CFEM_Knowles_NearInc.cpp | 2 +- .../elasticity/CFEM_NeoHookean_Comp.cpp | 2 +- .../convection_centered/CCentBase_Flow.cpp | 48 ++-- .../convection_centered/CCentJSTInc_Flow.cpp | 28 +- .../convection_centered/CCentJST_Flow.cpp | 12 +- .../convection_centered/CCentLaxInc_Flow.cpp | 22 +- .../convection_centered/CCentLax_Flow.cpp | 10 +- .../CUpwAUSMPLUSUP2_Flow.cpp | 2 +- .../convection_upwind/CUpwAUSMPLUSUP_Flow.cpp | 50 ++-- .../CUpwAUSMPLUS_SLAU_Base_Flow.cpp | 90 +++---- .../flow/convection_upwind/CUpwAUSM_Flow.cpp | 58 ++--- .../flow/convection_upwind/CUpwCUSP_Flow.cpp | 72 +++--- .../convection_upwind/CUpwFDSInc_Flow.cpp | 50 ++-- .../CUpwGeneralHLLC_Flow.cpp | 240 +++++++++--------- .../flow/convection_upwind/CUpwHLLC_Flow.cpp | 120 ++++----- .../flow/convection_upwind/CUpwL2Roe_Flow.cpp | 28 +- .../flow/convection_upwind/CUpwLMRoe_Flow.cpp | 26 +- .../flow/convection_upwind/CUpwMSW_Flow.cpp | 84 +++--- .../convection_upwind/CUpwRoeBase_Flow.cpp | 90 +++---- .../flow/convection_upwind/CUpwRoe_Flow.cpp | 12 +- .../flow/convection_upwind/CUpwSLAU_Flow.cpp | 4 +- .../convection_upwind/CUpwTurkel_Flow.cpp | 70 ++--- .../flow/diffusion/CAvgGradInc_Flow.cpp | 28 +- .../numerics/flow/diffusion/CAvgGrad_Base.cpp | 28 +- .../numerics/flow/diffusion/CAvgGrad_Flow.cpp | 32 +-- .../flow/diffusion/CGeneralAvgGrad_Flow.cpp | 46 ++-- .../flow/sources/CSourceAxisymmetric_Flow.cpp | 42 +-- .../flow/sources/CSourceBodyForce.cpp | 16 +- .../flow/sources/CSourceBoussinesq.cpp | 2 +- .../numerics/flow/sources/CSourceGravity.cpp | 8 +- .../sources/CSourceIncAxisymmetric_Flow.cpp | 8 +- .../sources/CSourceIncRotatingFrame_Flow.cpp | 4 +- .../sources/CSourceRotatingFrame_Flow.cpp | 26 +- .../numerics/flow/sources/CSourceWindGust.cpp | 24 +- .../template/CConvective_Template.cpp | 48 ++-- .../numerics/template/CSource_Template.cpp | 2 +- .../transition/CAvgGradCorrected_TransLM.cpp | 16 +- .../numerics/transition/CAvgGrad_TransLM.cpp | 36 +-- .../transition/CSourcePieceWise_TransLM.cpp | 96 +++---- .../numerics/transition/CUpwLin_TransLM.cpp | 20 +- .../numerics/transition/CUpwSca_TransLM.cpp | 16 +- .../numerics/turbulent/CAvgGrad_TurbSA.cpp | 10 +- .../turbulent/CAvgGrad_TurbSA_Neg.cpp | 12 +- .../numerics/turbulent/CAvgGrad_TurbSST.cpp | 22 +- .../turbulent/CSourcePieceWise_TurbSA.cpp | 62 ++--- .../CSourcePieceWise_TurbSA_COMP.cpp | 72 +++--- .../turbulent/CSourcePieceWise_TurbSA_E.cpp | 78 +++--- .../CSourcePieceWise_TurbSA_E_COMP.cpp | 80 +++--- .../turbulent/CSourcePieceWise_TurbSA_Neg.cpp | 94 +++---- .../turbulent/CSourcePieceWise_TurbSST.cpp | 20 +- .../src/numerics/turbulent/CUpwSca_TurbSA.cpp | 4 +- .../numerics/turbulent/CUpwSca_TurbSST.cpp | 8 +- 135 files changed, 1717 insertions(+), 1717 deletions(-) diff --git a/SU2_CFD/include/numerics/CNumerics.hpp b/SU2_CFD/include/numerics/CNumerics.hpp index 535166461607..0d948617dcfd 100644 --- a/SU2_CFD/include/numerics/CNumerics.hpp +++ b/SU2_CFD/include/numerics/CNumerics.hpp @@ -1126,21 +1126,21 @@ class CNumerics { void GetRMatrix(su2double val_pressure, su2double val_soundspeed, su2double val_density, su2double* val_velocity, su2double** val_invR_invPe); - /*! - * \brief Computation of the matrix R. - * \param[in] val_soundspeed - value of the sound speed. - * \param[in] val_density - value of the density. - * \param[out] R_Matrix - Pointer to the matrix of conversion from entropic to conserved variables. - */ - void GetRMatrix(su2double val_soundspeed, su2double val_density, su2double **R_Matrix); - - /*! - * \brief Computation of the matrix R. - * \param[in] val_soundspeed - value of the sound speed. - * \param[in] val_density - value of the density. - * \param[out] L_Matrix - Pointer to the matrix of conversion from conserved to entropic variables. - */ - void GetLMatrix(su2double val_soundspeed, su2double val_density, su2double **L_Matrix); + /*! + * \brief Computation of the matrix R. + * \param[in] val_soundspeed - value of the sound speed. + * \param[in] val_density - value of the density. + * \param[out] R_Matrix - Pointer to the matrix of conversion from entropic to conserved variables. + */ + void GetRMatrix(su2double val_soundspeed, su2double val_density, su2double **R_Matrix); + + /*! + * \brief Computation of the matrix R. + * \param[in] val_soundspeed - value of the sound speed. + * \param[in] val_density - value of the density. + * \param[out] L_Matrix - Pointer to the matrix of conversion from conserved to entropic variables. + */ + void GetLMatrix(su2double val_soundspeed, su2double val_density, su2double **L_Matrix); /*! * \brief Computation of the flow Residual Jacoboan Matrix for Non Reflecting BC. diff --git a/SU2_CFD/include/numerics/continuous_adjoint/CAvgGradCorrected_AdjFlow.hpp b/SU2_CFD/include/numerics/continuous_adjoint/CAvgGradCorrected_AdjFlow.hpp index 8d15e342e7f4..7ae8ad317621 100644 --- a/SU2_CFD/include/numerics/continuous_adjoint/CAvgGradCorrected_AdjFlow.hpp +++ b/SU2_CFD/include/numerics/continuous_adjoint/CAvgGradCorrected_AdjFlow.hpp @@ -47,9 +47,9 @@ class CAvgGradCorrected_AdjFlow : public CNumerics { su2double *Mean_GradPsiE; /*!< \brief Counter for dimensions of the problem. */ su2double **Mean_GradPhi; /*!< \brief Counter for dimensions of the problem. */ bool implicit; /*!< \brief Boolean controlling Jacobian calculations. */ - + public: - + /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. @@ -57,12 +57,12 @@ class CAvgGradCorrected_AdjFlow : public CNumerics { * \param[in] config - Definition of the particular problem. */ CAvgGradCorrected_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - + /*! * \brief Destructor of the class. */ ~CAvgGradCorrected_AdjFlow(void); - + /*! * \brief Compute the adjoint flow viscous residual in a non-conservative way using an average of gradients and derivative correction. * \param[out] val_residual_i - Pointer to the viscous residual at point i. diff --git a/SU2_CFD/include/numerics/continuous_adjoint/CAvgGradCorrected_AdjTurb.hpp b/SU2_CFD/include/numerics/continuous_adjoint/CAvgGradCorrected_AdjTurb.hpp index 89d1232288eb..0e207275d28f 100644 --- a/SU2_CFD/include/numerics/continuous_adjoint/CAvgGradCorrected_AdjTurb.hpp +++ b/SU2_CFD/include/numerics/continuous_adjoint/CAvgGradCorrected_AdjTurb.hpp @@ -41,9 +41,9 @@ class CAvgGradCorrected_AdjTurb : public CNumerics { su2double **Mean_GradTurbPsi; su2double *Proj_Mean_GradTurbPsi_Kappa, *Proj_Mean_GradTurbPsi_Edge, *Proj_Mean_GradTurbPsi_Corrected; su2double *Edge_Vector; - + public: - + /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. @@ -51,12 +51,12 @@ class CAvgGradCorrected_AdjTurb : public CNumerics { * \param[in] config - Definition of the particular problem. */ CAvgGradCorrected_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - + /*! * \brief Destructor of the class. */ ~CAvgGradCorrected_AdjTurb(void); - + /*! * \brief Compute the adjoint turbulent residual using average of gradients and a derivative correction. * \param[out] val_residual - Pointer to the total residual. @@ -64,9 +64,9 @@ class CAvgGradCorrected_AdjTurb : public CNumerics { * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). * \param[in] config - Definition of the particular problem. */ - + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - + /*! * \overload * \param[out] val_residual_i - Pointer to the total residual at point i. diff --git a/SU2_CFD/include/numerics/continuous_adjoint/CAvgGrad_AdjFlow.hpp b/SU2_CFD/include/numerics/continuous_adjoint/CAvgGrad_AdjFlow.hpp index e563a9517d8f..69a38e9c85c8 100644 --- a/SU2_CFD/include/numerics/continuous_adjoint/CAvgGrad_AdjFlow.hpp +++ b/SU2_CFD/include/numerics/continuous_adjoint/CAvgGrad_AdjFlow.hpp @@ -45,9 +45,9 @@ class CAvgGrad_AdjFlow : public CNumerics { su2double **Mean_GradPhi; /*!< \brief Counter for dimensions of the problem. */ su2double *Edge_Vector; /*!< \brief Vector going from node i to node j. */ bool implicit; /*!< \brief Implicit calculus. */ - + public: - + /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. @@ -55,12 +55,12 @@ class CAvgGrad_AdjFlow : public CNumerics { * \param[in] config - Definition of the particular problem. */ CAvgGrad_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - + /*! * \brief Destructor of the class. */ ~CAvgGrad_AdjFlow(void); - + /*! * \brief Residual computation. * \param[out] val_residual_i - Pointer to the total residual at point i. diff --git a/SU2_CFD/include/numerics/continuous_adjoint/CAvgGrad_AdjTurb.hpp b/SU2_CFD/include/numerics/continuous_adjoint/CAvgGrad_AdjTurb.hpp index 829a4006e7cc..b416cc370d13 100644 --- a/SU2_CFD/include/numerics/continuous_adjoint/CAvgGrad_AdjTurb.hpp +++ b/SU2_CFD/include/numerics/continuous_adjoint/CAvgGrad_AdjTurb.hpp @@ -41,9 +41,9 @@ class CAvgGrad_AdjTurb : public CNumerics { su2double **Mean_GradTurbPsi; su2double *Proj_Mean_GradTurbPsi_Kappa, *Proj_Mean_GradTurbPsi_Edge, *Proj_Mean_GradTurbPsi_Corrected; su2double *Edge_Vector; - + public: - + /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. @@ -51,12 +51,12 @@ class CAvgGrad_AdjTurb : public CNumerics { * \param[in] config - Definition of the particular problem. */ CAvgGrad_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - + /*! * \brief Destructor of the class. */ ~CAvgGrad_AdjTurb(void); - + /*! * \brief Compute the adjoint turbulent residual using average of gradients and a derivative correction. * \param[out] val_residual - Pointer to the total residual. @@ -64,9 +64,9 @@ class CAvgGrad_AdjTurb : public CNumerics { * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). * \param[in] config - Definition of the particular problem. */ - + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - + /*! * \overload * \param[out] val_residual_i - Pointer to the total residual at point i. diff --git a/SU2_CFD/include/numerics/continuous_adjoint/CCentJST_AdjFlow.hpp b/SU2_CFD/include/numerics/continuous_adjoint/CCentJST_AdjFlow.hpp index 3d7bf4f8d117..ece76ebaa4c9 100644 --- a/SU2_CFD/include/numerics/continuous_adjoint/CCentJST_AdjFlow.hpp +++ b/SU2_CFD/include/numerics/continuous_adjoint/CCentJST_AdjFlow.hpp @@ -46,9 +46,9 @@ class CCentJST_AdjFlow : public CNumerics { su2double MeanPsiRho, MeanPsiE, Param_p, Param_Kappa_4, Param_Kappa_2, Local_Lambda_i, Local_Lambda_j, MeanLambda; su2double Phi_i, Phi_j, sc4, StretchingFactor, Epsilon_4, Epsilon_2; bool implicit, grid_movement; - + public: - + /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. @@ -56,12 +56,12 @@ class CCentJST_AdjFlow : public CNumerics { * \param[in] config - Definition of the particular problem. */ CCentJST_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - + /*! * \brief Destructor of the class. */ ~CCentJST_AdjFlow(void); - + /*! * \brief Compute the adjoint flow residual using a JST method. * \param[out] val_resconv_i - Pointer to the convective residual at point i. diff --git a/SU2_CFD/include/numerics/continuous_adjoint/CCentLax_AdjFlow.hpp b/SU2_CFD/include/numerics/continuous_adjoint/CCentLax_AdjFlow.hpp index f67886abb244..8be0b0c83956 100644 --- a/SU2_CFD/include/numerics/continuous_adjoint/CCentLax_AdjFlow.hpp +++ b/SU2_CFD/include/numerics/continuous_adjoint/CCentLax_AdjFlow.hpp @@ -46,9 +46,9 @@ class CCentLax_AdjFlow : public CNumerics { MeanPsiRho, MeanPsiE, Param_p, Param_Kappa_0, Local_Lambda_i, Local_Lambda_j, MeanLambda, Phi_i, Phi_j, sc2, StretchingFactor, Epsilon_0; bool implicit, grid_movement; - + public: - + /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. @@ -56,12 +56,12 @@ class CCentLax_AdjFlow : public CNumerics { * \param[in] config - Definition of the particular problem. */ CCentLax_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - + /*! * \brief Destructor of the class. */ ~CCentLax_AdjFlow(void); - + /*! * \brief Compute the adjoint flow residual using a Lax method. * \param[out] val_resconv_i - Pointer to the convective residual at point i. diff --git a/SU2_CFD/include/numerics/continuous_adjoint/CSourceAxisymmetric_AdjFlow.hpp b/SU2_CFD/include/numerics/continuous_adjoint/CSourceAxisymmetric_AdjFlow.hpp index 2fc39bced4aa..ed2bde3ffac7 100644 --- a/SU2_CFD/include/numerics/continuous_adjoint/CSourceAxisymmetric_AdjFlow.hpp +++ b/SU2_CFD/include/numerics/continuous_adjoint/CSourceAxisymmetric_AdjFlow.hpp @@ -38,7 +38,7 @@ */ class CSourceAxisymmetric_AdjFlow : public CNumerics { public: - + /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. @@ -46,12 +46,12 @@ class CSourceAxisymmetric_AdjFlow : public CNumerics { * \param[in] config - Definition of the particular problem. */ CSourceAxisymmetric_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - + /*! * \brief Destructor of the class. */ ~CSourceAxisymmetric_AdjFlow(void); - + /*! * \brief Residual of the rotational frame source term. * \param[out] val_residual - Pointer to the total residual. diff --git a/SU2_CFD/include/numerics/continuous_adjoint/CSourceConservative_AdjFlow.hpp b/SU2_CFD/include/numerics/continuous_adjoint/CSourceConservative_AdjFlow.hpp index 44d2158214ea..382ef3fcd495 100644 --- a/SU2_CFD/include/numerics/continuous_adjoint/CSourceConservative_AdjFlow.hpp +++ b/SU2_CFD/include/numerics/continuous_adjoint/CSourceConservative_AdjFlow.hpp @@ -34,9 +34,9 @@ class CSourceConservative_AdjFlow : public CNumerics { private: su2double *Velocity, *Residual_i, *Residual_j, *Mean_Residual; su2double **Mean_PrimVar_Grad; - + public: - + /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. @@ -44,12 +44,12 @@ class CSourceConservative_AdjFlow : public CNumerics { * \param[in] config - Definition of the particular problem. */ CSourceConservative_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - + /*! * \brief Destructor of the class. */ ~CSourceConservative_AdjFlow(void); - + /*! * \brief Source term integration using a conservative scheme. * \param[out] val_residual - Pointer to the total residual. diff --git a/SU2_CFD/include/numerics/continuous_adjoint/CSourceConservative_AdjTurb.hpp b/SU2_CFD/include/numerics/continuous_adjoint/CSourceConservative_AdjTurb.hpp index 626721f2c61a..b06639ad4423 100644 --- a/SU2_CFD/include/numerics/continuous_adjoint/CSourceConservative_AdjTurb.hpp +++ b/SU2_CFD/include/numerics/continuous_adjoint/CSourceConservative_AdjTurb.hpp @@ -38,7 +38,7 @@ */ class CSourceConservative_AdjTurb : public CNumerics { public: - + /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. @@ -46,12 +46,12 @@ class CSourceConservative_AdjTurb : public CNumerics { * \param[in] config - Definition of the particular problem. */ CSourceConservative_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - + /*! * \brief Destructor of the class. */ ~CSourceConservative_AdjTurb(void); - + /*! * \brief Source term integration using a conservative scheme. * \param[out] val_residual - Pointer to the total residual. diff --git a/SU2_CFD/include/numerics/continuous_adjoint/CSourcePieceWise_AdjTurb.hpp b/SU2_CFD/include/numerics/continuous_adjoint/CSourcePieceWise_AdjTurb.hpp index 9ea4c3db6c81..f13e64d45d77 100644 --- a/SU2_CFD/include/numerics/continuous_adjoint/CSourcePieceWise_AdjTurb.hpp +++ b/SU2_CFD/include/numerics/continuous_adjoint/CSourcePieceWise_AdjTurb.hpp @@ -39,9 +39,9 @@ class CSourcePieceWise_AdjTurb : public CNumerics { private: su2double **tau, *Velocity; - + public: - + /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. @@ -49,12 +49,12 @@ class CSourcePieceWise_AdjTurb : public CNumerics { * \param[in] config - Definition of the particular problem. */ CSourcePieceWise_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - + /*! * \brief Destructor of the class. */ ~CSourcePieceWise_AdjTurb(void); - + /*! * \brief Source term integration of the adjoint turbulence equation. * \param[out] val_residual - Pointer to the total residual. diff --git a/SU2_CFD/include/numerics/continuous_adjoint/CSourceRotatingFrame_AdjFlow.hpp b/SU2_CFD/include/numerics/continuous_adjoint/CSourceRotatingFrame_AdjFlow.hpp index ddaf0a7f4a60..a1901a79dfd6 100644 --- a/SU2_CFD/include/numerics/continuous_adjoint/CSourceRotatingFrame_AdjFlow.hpp +++ b/SU2_CFD/include/numerics/continuous_adjoint/CSourceRotatingFrame_AdjFlow.hpp @@ -38,7 +38,7 @@ */ class CSourceRotatingFrame_AdjFlow : public CNumerics { public: - + /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. @@ -46,12 +46,12 @@ class CSourceRotatingFrame_AdjFlow : public CNumerics { * \param[in] config - Definition of the particular problem. */ CSourceRotatingFrame_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - + /*! * \brief Destructor of the class. */ ~CSourceRotatingFrame_AdjFlow(void); - + /*! * \brief Residual of the adjoint rotating frame source term. * \param[out] val_residual - Pointer to the total residual. diff --git a/SU2_CFD/include/numerics/continuous_adjoint/CSourceViscous_AdjFlow.hpp b/SU2_CFD/include/numerics/continuous_adjoint/CSourceViscous_AdjFlow.hpp index 96e74d16e913..8b762d595858 100644 --- a/SU2_CFD/include/numerics/continuous_adjoint/CSourceViscous_AdjFlow.hpp +++ b/SU2_CFD/include/numerics/continuous_adjoint/CSourceViscous_AdjFlow.hpp @@ -40,9 +40,9 @@ class CSourceViscous_AdjFlow : public CNumerics { private: su2double *Velocity, *GradDensity, *GradInvDensity, *dPoDensity2, *alpha, *beta, *Sigma_5_vec; su2double **GradVel_o_Rho, **sigma, **Sigma_phi, **Sigma_5_Tensor, **Sigma; - + public: - + /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. @@ -50,17 +50,17 @@ class CSourceViscous_AdjFlow : public CNumerics { * \param[in] config - Definition of the particular problem. */ CSourceViscous_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - + /*! * \brief Destructor of the class. */ ~CSourceViscous_AdjFlow(void); - + /*! * \brief Source term integration of the flow adjoint equation. * \param[out] val_residual - Pointer to the total residual. * \param[in] config - Definition of the particular problem. */ void ComputeResidual (su2double *val_residual, CConfig *config); - + }; diff --git a/SU2_CFD/include/numerics/continuous_adjoint/CUpwLin_AdjTurb.hpp b/SU2_CFD/include/numerics/continuous_adjoint/CUpwLin_AdjTurb.hpp index 839c988ab3d7..66dd41f00526 100644 --- a/SU2_CFD/include/numerics/continuous_adjoint/CUpwLin_AdjTurb.hpp +++ b/SU2_CFD/include/numerics/continuous_adjoint/CUpwLin_AdjTurb.hpp @@ -39,9 +39,9 @@ class CUpwLin_AdjTurb : public CNumerics { private: su2double *Velocity_i; - + public: - + /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. @@ -49,12 +49,12 @@ class CUpwLin_AdjTurb : public CNumerics { * \param[in] config - Definition of the particular problem. */ CUpwLin_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - + /*! * \brief Destructor of the class. */ ~CUpwLin_AdjTurb(void); - + /*! * \brief Compute the adjoint upwind flux between two nodes i and j. * \param[out] val_residual - Pointer to the total residual. diff --git a/SU2_CFD/include/numerics/continuous_adjoint/CUpwRoe_AdjFlow.hpp b/SU2_CFD/include/numerics/continuous_adjoint/CUpwRoe_AdjFlow.hpp index f517257c012c..a9619fa1efa5 100644 --- a/SU2_CFD/include/numerics/continuous_adjoint/CUpwRoe_AdjFlow.hpp +++ b/SU2_CFD/include/numerics/continuous_adjoint/CUpwRoe_AdjFlow.hpp @@ -50,9 +50,9 @@ class CUpwRoe_AdjFlow : public CNumerics { Proj_ModJac_Tensor_ij, **Proj_ModJac_Tensor, Energy_i, Energy_j, **P_Tensor, **invP_Tensor; unsigned short iDim, iVar, jVar, kVar; bool implicit, grid_movement; - + public: - + /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. @@ -60,12 +60,12 @@ class CUpwRoe_AdjFlow : public CNumerics { * \param[in] config - Definition of the particular problem. */ CUpwRoe_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - + /*! * \brief Destructor of the class. */ ~CUpwRoe_AdjFlow(void); - + /*! * \brief Compute the adjoint Roe's flux between two nodes i and j. * \param[out] val_residual_i - Pointer to the total residual at point i. diff --git a/SU2_CFD/include/numerics/continuous_adjoint/CUpwSca_AdjTurb.hpp b/SU2_CFD/include/numerics/continuous_adjoint/CUpwSca_AdjTurb.hpp index eee40de14311..dab23d664dca 100644 --- a/SU2_CFD/include/numerics/continuous_adjoint/CUpwSca_AdjTurb.hpp +++ b/SU2_CFD/include/numerics/continuous_adjoint/CUpwSca_AdjTurb.hpp @@ -39,9 +39,9 @@ class CUpwSca_AdjTurb : public CNumerics { private: su2double *Velocity_i, *Velocity_j; - + public: - + /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. @@ -49,12 +49,12 @@ class CUpwSca_AdjTurb : public CNumerics { * \param[in] config - Definition of the particular problem. */ CUpwSca_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - + /*! * \brief Destructor of the class. */ ~CUpwSca_AdjTurb(void); - + /*! * \param[out] val_residual_i - Pointer to the total residual at point i. * \param[out] val_residual_j - Pointer to the total viscosity residual at point j. diff --git a/SU2_CFD/include/numerics/elasticity/CFEALinearElasticity.hpp b/SU2_CFD/include/numerics/elasticity/CFEALinearElasticity.hpp index bfa3006fdd2a..9440618e9639 100644 --- a/SU2_CFD/include/numerics/elasticity/CFEALinearElasticity.hpp +++ b/SU2_CFD/include/numerics/elasticity/CFEALinearElasticity.hpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) diff --git a/SU2_CFD/include/numerics/elasticity/CFEAMeshElasticity.hpp b/SU2_CFD/include/numerics/elasticity/CFEAMeshElasticity.hpp index 9cf8b54e1dac..47ef485f27f4 100644 --- a/SU2_CFD/include/numerics/elasticity/CFEAMeshElasticity.hpp +++ b/SU2_CFD/include/numerics/elasticity/CFEAMeshElasticity.hpp @@ -7,7 +7,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) diff --git a/SU2_CFD/include/numerics/elasticity/CFEANonlinearElasticity.hpp b/SU2_CFD/include/numerics/elasticity/CFEANonlinearElasticity.hpp index d29f80631e8e..9023c071c4f6 100644 --- a/SU2_CFD/include/numerics/elasticity/CFEANonlinearElasticity.hpp +++ b/SU2_CFD/include/numerics/elasticity/CFEANonlinearElasticity.hpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) diff --git a/SU2_CFD/include/numerics/elasticity/CFEM_DielectricElastomer.hpp b/SU2_CFD/include/numerics/elasticity/CFEM_DielectricElastomer.hpp index 5b4ed56eae58..6719ce6b7054 100644 --- a/SU2_CFD/include/numerics/elasticity/CFEM_DielectricElastomer.hpp +++ b/SU2_CFD/include/numerics/elasticity/CFEM_DielectricElastomer.hpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) diff --git a/SU2_CFD/include/numerics/elasticity/CFEM_IdealDE.hpp b/SU2_CFD/include/numerics/elasticity/CFEM_IdealDE.hpp index c18730c2723d..e1c59dc23a1f 100644 --- a/SU2_CFD/include/numerics/elasticity/CFEM_IdealDE.hpp +++ b/SU2_CFD/include/numerics/elasticity/CFEM_IdealDE.hpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) diff --git a/SU2_CFD/include/numerics/elasticity/CFEM_Knowles_NearInc.hpp b/SU2_CFD/include/numerics/elasticity/CFEM_Knowles_NearInc.hpp index 7aaa00d1a619..c54fa2f78455 100644 --- a/SU2_CFD/include/numerics/elasticity/CFEM_Knowles_NearInc.hpp +++ b/SU2_CFD/include/numerics/elasticity/CFEM_Knowles_NearInc.hpp @@ -7,7 +7,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) diff --git a/SU2_CFD/include/numerics/elasticity/CFEM_NeoHookean_Comp.hpp b/SU2_CFD/include/numerics/elasticity/CFEM_NeoHookean_Comp.hpp index fdf6f61298ce..e7a1afe604f2 100644 --- a/SU2_CFD/include/numerics/elasticity/CFEM_NeoHookean_Comp.hpp +++ b/SU2_CFD/include/numerics/elasticity/CFEM_NeoHookean_Comp.hpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) diff --git a/SU2_CFD/include/numerics/flow/convection_centered/CCentJSTInc_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_centered/CCentJSTInc_Flow.hpp index 8e3a926a2e9b..d5c0cc97ebc0 100644 --- a/SU2_CFD/include/numerics/flow/convection_centered/CCentJSTInc_Flow.hpp +++ b/SU2_CFD/include/numerics/flow/convection_centered/CCentJSTInc_Flow.hpp @@ -37,7 +37,7 @@ * \author F. Palacios, T. Economon */ class CCentJSTInc_Flow : public CNumerics { - + private: unsigned short iDim, iVar, jVar; /*!< \brief Iteration on dimension and variables. */ su2double *Diff_V, *Diff_Lapl, /*!< \brief Diference of primitive variables and undivided laplacians. */ @@ -65,7 +65,7 @@ class CCentJSTInc_Flow : public CNumerics { energy; /*!< \brief computation with the energy equation. */ public: - + /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimension of the problem. @@ -73,12 +73,12 @@ class CCentJSTInc_Flow : public CNumerics { * \param[in] config - Definition of the particular problem. */ CCentJSTInc_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - + /*! * \brief Destructor of the class. */ ~CCentJSTInc_Flow(void); - + /*! * \brief Compute the flow residual using a JST method. * \param[out] val_residual - Pointer to the residual array. diff --git a/SU2_CFD/include/numerics/flow/convection_centered/CCentJST_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_centered/CCentJST_Flow.hpp index 05cc611d99c4..db6a76396924 100644 --- a/SU2_CFD/include/numerics/flow/convection_centered/CCentJST_Flow.hpp +++ b/SU2_CFD/include/numerics/flow/convection_centered/CCentJST_Flow.hpp @@ -37,7 +37,7 @@ * \author F. Palacios */ class CCentJST_Flow : public CCentBase_Flow { - + private: su2double Param_Kappa_2, Param_Kappa_4; /*!< \brief Artificial dissipation parameters. */ su2double sc2, sc4; /*!< \brief Streching parameters. */ diff --git a/SU2_CFD/include/numerics/flow/convection_centered/CCentLaxInc_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_centered/CCentLaxInc_Flow.hpp index 8a998fdb90ed..1fbf680d343e 100644 --- a/SU2_CFD/include/numerics/flow/convection_centered/CCentLaxInc_Flow.hpp +++ b/SU2_CFD/include/numerics/flow/convection_centered/CCentLaxInc_Flow.hpp @@ -61,9 +61,9 @@ class CCentLaxInc_Flow : public CNumerics { dynamic_grid, /*!< \brief Modification for grid movement. */ variable_density, /*!< \brief Variable density incompressible flows. */ energy; /*!< \brief computation with the energy equation. */ - + public: - + /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimension of the problem. @@ -71,12 +71,12 @@ class CCentLaxInc_Flow : public CNumerics { * \param[in] config - Definition of the particular problem. */ CCentLaxInc_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - + /*! * \brief Destructor of the class. */ ~CCentLaxInc_Flow(void); - + /*! * \brief Compute the flow residual using a Lax method. * \param[out] val_residual - Pointer to the residual array. diff --git a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwAUSMPLUSUP2_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwAUSMPLUSUP2_Flow.hpp index 9bf82919fde5..8a85b23a0b2c 100644 --- a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwAUSMPLUSUP2_Flow.hpp +++ b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwAUSMPLUSUP2_Flow.hpp @@ -39,7 +39,7 @@ class CUpwAUSMPLUSUP2_Flow : public CUpwAUSMPLUS_SLAU_Base_Flow { private: su2double Kp, sigma; - + /*! * \brief Mass flux and pressure for the AUSM+up2 scheme. * \param[in] config - Definition of the particular problem. @@ -47,9 +47,9 @@ class CUpwAUSMPLUSUP2_Flow : public CUpwAUSMPLUS_SLAU_Base_Flow { * \param[out] pressure - The pressure at the control volume face. */ void ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure); - + public: - + /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. @@ -57,10 +57,10 @@ class CUpwAUSMPLUSUP2_Flow : public CUpwAUSMPLUS_SLAU_Base_Flow { * \param[in] config - Definition of the particular problem. */ CUpwAUSMPLUSUP2_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - + /*! * \brief Destructor of the class. */ ~CUpwAUSMPLUSUP2_Flow(void); - + }; diff --git a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwAUSMPLUSUP_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwAUSMPLUSUP_Flow.hpp index f9ded3d836cc..60aa4074dd90 100644 --- a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwAUSMPLUSUP_Flow.hpp +++ b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwAUSMPLUSUP_Flow.hpp @@ -39,7 +39,7 @@ class CUpwAUSMPLUSUP_Flow : public CUpwAUSMPLUS_SLAU_Base_Flow { private: su2double Kp, Ku, sigma; - + /*! * \brief Mass flux and pressure for the AUSM+up scheme. * \param[in] config - Definition of the particular problem. @@ -47,9 +47,9 @@ class CUpwAUSMPLUSUP_Flow : public CUpwAUSMPLUS_SLAU_Base_Flow { * \param[out] pressure - The pressure at the control volume face. */ void ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure); - + public: - + /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. @@ -57,7 +57,7 @@ class CUpwAUSMPLUSUP_Flow : public CUpwAUSMPLUS_SLAU_Base_Flow { * \param[in] config - Definition of the particular problem. */ CUpwAUSMPLUSUP_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - + /*! * \brief Destructor of the class. */ diff --git a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwAUSMPLUS_SLAU_Base_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwAUSMPLUS_SLAU_Base_Flow.hpp index 57d26196019c..c5155e01bf32 100644 --- a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwAUSMPLUS_SLAU_Base_Flow.hpp +++ b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwAUSMPLUS_SLAU_Base_Flow.hpp @@ -42,15 +42,15 @@ class CUpwAUSMPLUS_SLAU_Base_Flow : public CNumerics { bool UseAccurateJacobian; bool HasAnalyticalDerivatives; su2double FinDiffStep; - + su2double MassFlux, DissFlux, Pressure; su2double *Velocity_i, *Velocity_j; su2double *psi_i, *psi_j; su2double dmdot_dVi[6], dmdot_dVj[6], dpres_dVi[6], dpres_dVj[6]; - + /*--- Roe variables (for approximate Jacobian) ---*/ su2double *Lambda, *Epsilon, *RoeVelocity, **P_Tensor, **invP_Tensor; - + /*! * \brief Compute the mass flux and pressure based on Primitives_i/j, derived classes must implement this method. * \note See the body of the (empty) default implementation for instructions on how to implement the method. @@ -59,23 +59,23 @@ class CUpwAUSMPLUS_SLAU_Base_Flow : public CNumerics { * \param[out] pressure - The pressure at the control volume face. */ virtual void ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure) = 0; - + /*! * \brief Compute the flux Jacobians of the Roe scheme to use as an approximation. * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). */ void ApproximateJacobian(su2double **val_Jacobian_i, su2double **val_Jacobian_j); - + /*! * \brief Compute the flux Jacobians using a mix of finite differences and manual differentiation. * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). */ void AccurateJacobian(CConfig *config, su2double **val_Jacobian_i, su2double **val_Jacobian_j); - + public: - + /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. @@ -83,12 +83,12 @@ class CUpwAUSMPLUS_SLAU_Base_Flow : public CNumerics { * \param[in] config - Definition of the particular problem. */ CUpwAUSMPLUS_SLAU_Base_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - + /*! * \brief Destructor of the class. */ ~CUpwAUSMPLUS_SLAU_Base_Flow(void); - + /*! * \brief Compute the AUSM+ and SLAU family of schemes. * \param[out] val_residual - Pointer to the total residual. diff --git a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwAUSM_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwAUSM_Flow.hpp index 196f1040bb03..337a65943d06 100644 --- a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwAUSM_Flow.hpp +++ b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwAUSM_Flow.hpp @@ -50,9 +50,9 @@ class CUpwAUSM_Flow : public CNumerics { ProjVelocity, ProjVelocity_i, ProjVelocity_j; unsigned short iDim, iVar, jVar, kVar; su2double mL, mR, mLP, mRM, mF, pLP, pRM, pF, Phi; - + public: - + /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. @@ -60,12 +60,12 @@ class CUpwAUSM_Flow : public CNumerics { * \param[in] config - Definition of the particular problem. */ CUpwAUSM_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - + /*! * \brief Destructor of the class. */ ~CUpwAUSM_Flow(void); - + /*! * \brief Compute the Roe's flux between two nodes i and j. * \param[out] val_residual - Pointer to the total residual. diff --git a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwCUSP_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwCUSP_Flow.hpp index 3f77d81bd6f9..755c8d4d4575 100644 --- a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwCUSP_Flow.hpp +++ b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwCUSP_Flow.hpp @@ -37,13 +37,13 @@ * \author F. Palacios */ class CUpwCUSP_Flow : public CNumerics { - + private: su2double *Velocity_i, *Velocity_j, *ProjFlux_i, *ProjFlux_j; bool implicit; - + public: - + /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimension of the problem. @@ -51,12 +51,12 @@ class CUpwCUSP_Flow : public CNumerics { * \param[in] config - Definition of the particular problem. */ CUpwCUSP_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - + /*! * \brief Destructor of the class. */ ~CUpwCUSP_Flow(void); - + /*! * \brief Compute the flow residual using a JST method. * \param[out] val_residual - Pointer to the residual. diff --git a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwFDSInc_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwFDSInc_Flow.hpp index ce3d233345b1..ff8cf428dc57 100644 --- a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwFDSInc_Flow.hpp +++ b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwFDSInc_Flow.hpp @@ -53,9 +53,9 @@ class CUpwFDSInc_Flow : public CNumerics { Temperature_i, Temperature_j, /*!< \brief Temperature at node 0 and 1. */ MeanDensity, MeanPressure, MeanSoundSpeed, MeanBetaInc2, MeanEnthalpy, MeanCp, MeanTemperature; /*!< \brief Mean values of primitive variables. */ unsigned short iDim, iVar, jVar, kVar; - + public: - + /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. @@ -63,12 +63,12 @@ class CUpwFDSInc_Flow : public CNumerics { * \param[in] config - Definition of the particular problem. */ CUpwFDSInc_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - + /*! * \brief Destructor of the class. */ ~CUpwFDSInc_Flow(void); - + /*! * \brief Compute the upwind flux between two nodes i and j. * \param[out] val_residual - Pointer to the residual array. diff --git a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwGeneralHLLC_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwGeneralHLLC_Flow.hpp index 4a2ac443476b..129e71e78f8d 100644 --- a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwGeneralHLLC_Flow.hpp +++ b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwGeneralHLLC_Flow.hpp @@ -41,13 +41,13 @@ class CUpwGeneralHLLC_Flow : public CNumerics { private: bool implicit, dynamic_grid; unsigned short iDim, jDim, iVar, jVar; - + su2double *IntermediateState; su2double *Velocity_i, *Velocity_j, *RoeVelocity; su2double sq_vel_i, Density_i, Energy_i, SoundSpeed_i, Pressure_i, Enthalpy_i, ProjVelocity_i, StaticEnthalpy_i, StaticEnergy_i; su2double sq_vel_j, Density_j, Energy_j, SoundSpeed_j, Pressure_j, Enthalpy_j, ProjVelocity_j, StaticEnthalpy_j, StaticEnergy_j; - + su2double sq_velRoe, RoeDensity, RoeEnthalpy, RoeSoundSpeed, RoeProjVelocity, ProjInterfaceVel; su2double Kappa_i, Kappa_j, Chi_i, Chi_j, RoeKappa, RoeChi, RoeKappaStaticEnthalpy; @@ -56,9 +56,9 @@ class CUpwGeneralHLLC_Flow : public CNumerics { su2double Omega, RHO, OmegaSM; su2double *dSm_dU, *dPI_dU, *drhoStar_dU, *dpStar_dU, *dEStar_dU; - + public: - + /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. @@ -66,12 +66,12 @@ class CUpwGeneralHLLC_Flow : public CNumerics { * \param[in] config - Definition of the particular problem. */ CUpwGeneralHLLC_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - + /*! * \brief Destructor of the class. */ ~CUpwGeneralHLLC_Flow(void); - + /*! * \brief Compute the Roe's flux between two nodes i and j. diff --git a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwGeneralRoe_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwGeneralRoe_Flow.hpp index 109634af5bb3..8ad80d3194f7 100644 --- a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwGeneralRoe_Flow.hpp +++ b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwGeneralRoe_Flow.hpp @@ -58,7 +58,7 @@ class CUpwGeneralRoe_Flow : public CNumerics { su2double RoeKappa, RoeChi; public: - + /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. @@ -66,12 +66,12 @@ class CUpwGeneralRoe_Flow : public CNumerics { * \param[in] config - Definition of the particular problem. */ CUpwGeneralRoe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - + /*! * \brief Destructor of the class. */ ~CUpwGeneralRoe_Flow(void); - + /*! * \brief Compute the Roe's flux between two nodes i and j. * \param[out] val_residual - Pointer to the total residual. @@ -80,11 +80,11 @@ class CUpwGeneralRoe_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 Compute the Average for a general fluid flux between two nodes i and j. * Using the approach of Vinokur and Montagne' */ - + void ComputeRoeAverage(); }; diff --git a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwHLLC_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwHLLC_Flow.hpp index 49e8e4c044a4..8e64ef3324f0 100644 --- a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwHLLC_Flow.hpp +++ b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwHLLC_Flow.hpp @@ -41,22 +41,22 @@ class CUpwHLLC_Flow : public CNumerics { private: bool implicit, dynamic_grid; unsigned short iDim, jDim, iVar, jVar; - + su2double *IntermediateState; su2double *Velocity_i, *Velocity_j, *RoeVelocity; su2double sq_vel_i, Density_i, Energy_i, SoundSpeed_i, Pressure_i, Enthalpy_i, ProjVelocity_i; su2double sq_vel_j, Density_j, Energy_j, SoundSpeed_j, Pressure_j, Enthalpy_j, ProjVelocity_j; - + su2double sq_velRoe, RoeDensity, RoeEnthalpy, RoeSoundSpeed, RoeProjVelocity, ProjInterfaceVel; su2double sL, sR, sM, pStar, EStar, rhoSL, rhoSR, Rrho, kappa; su2double Omega, RHO, OmegaSM; su2double *dSm_dU, *dPI_dU, *drhoStar_dU, *dpStar_dU, *dEStar_dU; - + public: - + /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. @@ -64,12 +64,12 @@ class CUpwHLLC_Flow : public CNumerics { * \param[in] config - Definition of the particular problem. */ CUpwHLLC_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - + /*! * \brief Destructor of the class. */ ~CUpwHLLC_Flow(void); - + /*! * \brief Compute the Roe's flux between two nodes i and j. * \param[out] val_residual - Pointer to the total residual. diff --git a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwL2Roe_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwL2Roe_Flow.hpp index 9e1fcca2b74d..713d4462e10b 100644 --- a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwL2Roe_Flow.hpp +++ b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwL2Roe_Flow.hpp @@ -47,7 +47,7 @@ class CUpwL2Roe_Flow : public CUpwRoeBase_Flow { * \param[in] config - Definition of the particular problem. */ void FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - + public: /*! * \brief Constructor of the class. diff --git a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwLMRoe_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwLMRoe_Flow.hpp index 157a8a44b1f8..e15dac9dd0a1 100644 --- a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwLMRoe_Flow.hpp +++ b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwLMRoe_Flow.hpp @@ -47,7 +47,7 @@ class CUpwLMRoe_Flow : public CUpwRoeBase_Flow { * \param[in] config - Definition of the particular problem. */ void FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - + public: /*! * \brief Constructor of the class. diff --git a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwMSW_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwMSW_Flow.hpp index 6ccc8137ce2b..4d33560e32cc 100644 --- a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwMSW_Flow.hpp +++ b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwMSW_Flow.hpp @@ -47,9 +47,9 @@ class CUpwMSW_Flow : public CNumerics { su2double *Ust_i, *Ust_j, *Vst_i, *Vst_j, *Velst_i, *Velst_j; su2double **P_Tensor, **invP_Tensor; unsigned short nPrimVar, nVar, nDim; - + public: - + /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. @@ -57,12 +57,12 @@ class CUpwMSW_Flow : public CNumerics { * \param[in] config - Definition of the particular problem. */ CUpwMSW_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - + /*! * \brief Destructor of the class. */ ~CUpwMSW_Flow(void); - + /*! * \brief Compute the Roe's flux between two nodes i and j. * \param[out] val_residual - Pointer to the total residual. @@ -71,5 +71,5 @@ class CUpwMSW_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); - + }; diff --git a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwRoeBase_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwRoeBase_Flow.hpp index d861e37cc5c9..defec59c391a 100644 --- a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwRoeBase_Flow.hpp +++ b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwRoeBase_Flow.hpp @@ -42,7 +42,7 @@ class CUpwRoeBase_Flow : public CNumerics { su2double *Velocity_i, *Velocity_j, *ProjFlux_i, *ProjFlux_j, *Conservatives_i, *Conservatives_j; su2double *Diff_U, *Lambda, **P_Tensor, **invP_Tensor; su2double *RoeVelocity, RoeDensity, RoeEnthalpy, RoeSoundSpeed, ProjVelocity, RoeSoundSpeed2, kappa; - + /*! * \brief Derived classes must specialize this method to add the specifics of the scheme they implement (e.g. low-Mach precond.). * \param[out] val_residual - Convective flux. @@ -51,9 +51,9 @@ class CUpwRoeBase_Flow : public CNumerics { * \param[in] config - Definition of the particular problem. */ virtual void FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) = 0; - + public: - + /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. @@ -62,12 +62,12 @@ class CUpwRoeBase_Flow : public CNumerics { * \param[in] val_low_dissipation - Use a low dissipation formulation. */ CUpwRoeBase_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, bool val_low_dissipation); - + /*! * \brief Destructor of the class. */ ~CUpwRoeBase_Flow(void); - + /*! * \brief Compute the flux from node i to node j, part common to most Roe schemes. * \param[out] val_residual - Convective flux. @@ -76,5 +76,5 @@ class CUpwRoeBase_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); - + }; diff --git a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwRoe_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwRoe_Flow.hpp index a4113f0627b9..f8a3f6534894 100644 --- a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwRoe_Flow.hpp +++ b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwRoe_Flow.hpp @@ -46,9 +46,9 @@ class CUpwRoe_Flow : public CUpwRoeBase_Flow { * \param[in] config - Definition of the particular problem. */ void FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - + public: - + /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. @@ -57,10 +57,10 @@ class CUpwRoe_Flow : public CUpwRoeBase_Flow { * \param[in] val_low_dissipation - Use a low dissipation formulation. */ CUpwRoe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, bool val_low_dissipation); - + /*! * \brief Destructor of the class. */ ~CUpwRoe_Flow(void); - + }; diff --git a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwSLAU_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwSLAU_Flow.hpp index 0ac781ec818b..6d7d225cca27 100644 --- a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwSLAU_Flow.hpp +++ b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwSLAU_Flow.hpp @@ -40,7 +40,7 @@ class CUpwSLAU_Flow : public CUpwAUSMPLUS_SLAU_Base_Flow { protected: bool slau_low_diss; bool slau2; - + /*! * \brief Mass flux and pressure for the SLAU and SLAU2 schemes. * \param[in] config - Definition of the particular problem. @@ -48,9 +48,9 @@ class CUpwSLAU_Flow : public CUpwAUSMPLUS_SLAU_Base_Flow { * \param[out] pressure - The pressure at the control volume face. */ void ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure); - + public: - + /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. @@ -58,7 +58,7 @@ class CUpwSLAU_Flow : public CUpwAUSMPLUS_SLAU_Base_Flow { * \param[in] config - Definition of the particular problem. */ CUpwSLAU_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, bool val_low_dissipation); - + /*! * \brief Destructor of the class. */ @@ -81,7 +81,7 @@ class CUpwSLAU2_Flow : public CUpwSLAU_Flow { * \param[in] config - Definition of the particular problem. */ CUpwSLAU2_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, bool val_low_dissipation); - + /*! * \brief Destructor of the class. */ diff --git a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwTurkel_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwTurkel_Flow.hpp index 642291e7c499..acbac532f204 100644 --- a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwTurkel_Flow.hpp +++ b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwTurkel_Flow.hpp @@ -52,9 +52,9 @@ class CUpwTurkel_Flow : public CNumerics { su2double r_hat, s_hat, t_hat, rhoB2a2, sqr_one_m_Betasqr_Lam1; su2double Beta2, one_m_Betasqr, one_p_Betasqr, sqr_two_Beta_c_Area; su2double local_Mach; - + public: - + /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. @@ -62,12 +62,12 @@ class CUpwTurkel_Flow : public CNumerics { * \param[in] config - Definition of the particular problem. */ CUpwTurkel_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - + /*! * \brief Destructor of the class. */ ~CUpwTurkel_Flow(void); - + /*! * \brief Compute the Roe's flux between two nodes i and j. * \param[out] val_residual - Pointer to the total residual. diff --git a/SU2_CFD/include/numerics/flow/sources/CSourceAxisymmetric_Flow.hpp b/SU2_CFD/include/numerics/flow/sources/CSourceAxisymmetric_Flow.hpp index 75ab05033a1d..e7497e061fbd 100644 --- a/SU2_CFD/include/numerics/flow/sources/CSourceAxisymmetric_Flow.hpp +++ b/SU2_CFD/include/numerics/flow/sources/CSourceAxisymmetric_Flow.hpp @@ -38,7 +38,7 @@ */ class CSourceAxisymmetric_Flow : public CNumerics { public: - + /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. @@ -46,17 +46,17 @@ class CSourceAxisymmetric_Flow : public CNumerics { * \param[in] config - Definition of the particular problem. */ CSourceAxisymmetric_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - + /*! * \brief Destructor of the class. */ ~CSourceAxisymmetric_Flow(void); - + /*! * \brief Residual of the rotational frame source term. * \param[out] val_residual - Pointer to the total residual. * \param[in] config - Definition of the particular problem. */ void ComputeResidual(su2double *val_residual, su2double **Jacobian_i, CConfig *config); - + }; diff --git a/SU2_CFD/include/numerics/flow/sources/CSourceGravity.hpp b/SU2_CFD/include/numerics/flow/sources/CSourceGravity.hpp index 5edd870cec20..252656f150e3 100644 --- a/SU2_CFD/include/numerics/flow/sources/CSourceGravity.hpp +++ b/SU2_CFD/include/numerics/flow/sources/CSourceGravity.hpp @@ -37,21 +37,21 @@ * \author F. Palacios */ class CSourceGravity : public CNumerics { - + public: - + /*! * \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. */ CSourceGravity(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - + /*! * \brief Destructor of the class. */ ~CSourceGravity(void); - + /*! * \brief Source term integration for the poissonal potential. * \param[out] val_residual - Pointer to the total residual. diff --git a/SU2_CFD/include/numerics/flow/sources/CSourceIncBodyForce.hpp b/SU2_CFD/include/numerics/flow/sources/CSourceIncBodyForce.hpp index d392cd75eb71..bae1e83192af 100644 --- a/SU2_CFD/include/numerics/flow/sources/CSourceIncBodyForce.hpp +++ b/SU2_CFD/include/numerics/flow/sources/CSourceIncBodyForce.hpp @@ -60,5 +60,5 @@ class CSourceIncBodyForce : public CNumerics { * \param[in] config - Definition of the particular problem. */ void ComputeResidual(su2double *val_residual, CConfig *config); - + }; diff --git a/SU2_CFD/include/numerics/flow/sources/CSourceRotatingFrame_Flow.hpp b/SU2_CFD/include/numerics/flow/sources/CSourceRotatingFrame_Flow.hpp index b0a4766b9038..7fa5c6ce89a2 100644 --- a/SU2_CFD/include/numerics/flow/sources/CSourceRotatingFrame_Flow.hpp +++ b/SU2_CFD/include/numerics/flow/sources/CSourceRotatingFrame_Flow.hpp @@ -38,7 +38,7 @@ */ class CSourceRotatingFrame_Flow : public CNumerics { public: - + /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. @@ -46,12 +46,12 @@ class CSourceRotatingFrame_Flow : public CNumerics { * \param[in] config - Definition of the particular problem. */ CSourceRotatingFrame_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - + /*! * \brief Destructor of the class. */ ~CSourceRotatingFrame_Flow(void); - + /*! * \brief Residual of the rotational frame source term. * \param[out] val_residual - Pointer to the total residual. diff --git a/SU2_CFD/include/numerics/flow/sources/CSourceWindGust.hpp b/SU2_CFD/include/numerics/flow/sources/CSourceWindGust.hpp index e296724455e4..73bb0bd76e69 100644 --- a/SU2_CFD/include/numerics/flow/sources/CSourceWindGust.hpp +++ b/SU2_CFD/include/numerics/flow/sources/CSourceWindGust.hpp @@ -38,7 +38,7 @@ */ class CSourceWindGust : public CNumerics { public: - + /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. @@ -46,12 +46,12 @@ class CSourceWindGust : public CNumerics { * \param[in] config - Definition of the particular problem. */ CSourceWindGust(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - + /*! * \brief Destructor of the class. */ ~CSourceWindGust(void); - + /*! * \brief Residual of the wind gust source term. * \param[out] val_residual - Pointer to the total residual. diff --git a/SU2_CFD/include/numerics/template/CConvective_Template.hpp b/SU2_CFD/include/numerics/template/CConvective_Template.hpp index 2d44c6fbcd12..4342710265cf 100644 --- a/SU2_CFD/include/numerics/template/CConvective_Template.hpp +++ b/SU2_CFD/include/numerics/template/CConvective_Template.hpp @@ -38,7 +38,7 @@ */ class CConvective_Template : public CNumerics { private: - + /* define private variables here */ bool implicit; su2double *Diff_U; @@ -51,9 +51,9 @@ class CConvective_Template : public CNumerics { Density_j, Energy_j, SoundSpeed_j, Pressure_j, Enthalpy_j, R, RoeDensity, RoeEnthalpy, RoeSoundSpeed, ProjVelocity, ProjVelocity_i, ProjVelocity_j, proj_delta_vel, delta_p, delta_rho; unsigned short iDim, iVar, jVar, kVar; - + public: - + /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. @@ -61,12 +61,12 @@ class CConvective_Template : public CNumerics { * \param[in] config - Definition of the particular problem. */ CConvective_Template(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - + /*! * \brief Destructor of the class. */ ~CConvective_Template(void); - + /*! * \brief Compute the Roe's flux between two nodes i and j. * \param[out] val_residual - Pointer to the total residual. diff --git a/SU2_CFD/include/numerics/template/CSource_Template.hpp b/SU2_CFD/include/numerics/template/CSource_Template.hpp index 5bd09a2898b6..06c530af452b 100644 --- a/SU2_CFD/include/numerics/template/CSource_Template.hpp +++ b/SU2_CFD/include/numerics/template/CSource_Template.hpp @@ -38,7 +38,7 @@ */ class CSource_Template : public CNumerics { public: - + /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. @@ -47,8 +47,8 @@ class CSource_Template : public CNumerics { * */ CSource_Template(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - + + /*! * \brief Residual for source term integration. * \param[out] val_residual - Pointer to the total residual. @@ -56,7 +56,7 @@ class CSource_Template : public CNumerics { * \param[in] config - Definition of the particular problem. */ void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config); - + /*! * \brief Destructor of the class. */ diff --git a/SU2_CFD/include/numerics/template/CViscous_Template.hpp b/SU2_CFD/include/numerics/template/CViscous_Template.hpp index 49cf2ae0bb05..d41dd8268dc1 100644 --- a/SU2_CFD/include/numerics/template/CViscous_Template.hpp +++ b/SU2_CFD/include/numerics/template/CViscous_Template.hpp @@ -38,9 +38,9 @@ */ class CViscous_Template : public CNumerics { private: - + public: - + /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimension of the problem. @@ -48,12 +48,12 @@ class CViscous_Template : public CNumerics { * \param[in] config - Definition of the particular problem. */ CViscous_Template(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - + /*! * \brief Destructor of the class. */ ~CViscous_Template(void); - + /*! * \brief Compute the viscous flow residual using an average of gradients. * \param[out] val_residual - Pointer to the total residual. diff --git a/SU2_CFD/include/numerics/transition/CAvgGradCorrected_TransLM.hpp b/SU2_CFD/include/numerics/transition/CAvgGradCorrected_TransLM.hpp index 6073bf2f006b..e8b0551cd005 100644 --- a/SU2_CFD/include/numerics/transition/CAvgGradCorrected_TransLM.hpp +++ b/SU2_CFD/include/numerics/transition/CAvgGradCorrected_TransLM.hpp @@ -43,9 +43,9 @@ class CAvgGradCorrected_TransLM : public CNumerics { su2double *Edge_Vector; bool implicit, incompressible; su2double sigma; - + public: - + /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. @@ -53,12 +53,12 @@ class CAvgGradCorrected_TransLM : public CNumerics { * \param[in] config - Definition of the particular problem. */ CAvgGradCorrected_TransLM(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - + /*! * \brief Destructor of the class. */ ~CAvgGradCorrected_TransLM(void); - + /*! * \brief Compute the viscous turbulent residual using an average of gradients with correction. * \param[out] val_residual - Pointer to the total residual. diff --git a/SU2_CFD/include/numerics/transition/CAvgGrad_TransLM.hpp b/SU2_CFD/include/numerics/transition/CAvgGrad_TransLM.hpp index 56db3e8438ae..834c07147e3d 100644 --- a/SU2_CFD/include/numerics/transition/CAvgGrad_TransLM.hpp +++ b/SU2_CFD/include/numerics/transition/CAvgGrad_TransLM.hpp @@ -46,9 +46,9 @@ class CAvgGrad_TransLM : public CNumerics { //su2double dist_ij_2; //su2double proj_vector_ij; //unsigned short iVar, iDim; - + public: - + /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. @@ -56,12 +56,12 @@ class CAvgGrad_TransLM : public CNumerics { * \param[in] config - Definition of the particular problem. */ CAvgGrad_TransLM(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - + /*! * \brief Destructor of the class. */ ~CAvgGrad_TransLM(void); - + /*! * \brief Compute the viscous turbulence terms residual using an average of gradients. * \param[out] val_residual - Pointer to the total residual. diff --git a/SU2_CFD/include/numerics/transition/CSourcePieceWise_TransLM.hpp b/SU2_CFD/include/numerics/transition/CSourcePieceWise_TransLM.hpp index d75748145389..e2efe9a0912e 100644 --- a/SU2_CFD/include/numerics/transition/CSourcePieceWise_TransLM.hpp +++ b/SU2_CFD/include/numerics/transition/CSourcePieceWise_TransLM.hpp @@ -38,7 +38,7 @@ */ class CSourcePieceWise_TransLM : public CNumerics { private: - + /*-- SA model constants --*/ su2double cv1_3; su2double k2; @@ -48,7 +48,7 @@ class CSourcePieceWise_TransLM : public CNumerics { su2double sigma; su2double cb2; su2double cw1; - + /*-- gamma-theta model constants --*/ su2double c_e1; su2double c_a1; @@ -58,17 +58,17 @@ class CSourcePieceWise_TransLM : public CNumerics { su2double s1; su2double c_theta; su2double sigmat; - + /*-- Correlation constants --*/ su2double flen_global; su2double alpha_global; su2double Vorticity; bool implicit; - + public: bool debugme; // For debugging only, remove this. -AA - + /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. @@ -76,12 +76,12 @@ class CSourcePieceWise_TransLM : public CNumerics { * \param[in] config - Definition of the particular problem. */ CSourcePieceWise_TransLM(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - + /*! * \brief Destructor of the class. */ ~CSourcePieceWise_TransLM(void); - + /*! * \brief Residual for source term integration. * \param[out] val_residual - Pointer to the total residual. @@ -90,6 +90,6 @@ class CSourcePieceWise_TransLM : public CNumerics { * \param[in] config - Definition of the particular problem. */ void ComputeResidual_TransLM(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config, su2double &gamma_sep); - + void CSourcePieceWise_TransLM__ComputeResidual_TransLM_d(su2double *TransVar_i, su2double *TransVar_id, su2double *val_residual, su2double *val_residuald, CConfig *config); }; diff --git a/SU2_CFD/include/numerics/transition/CUpwLin_TransLM.hpp b/SU2_CFD/include/numerics/transition/CUpwLin_TransLM.hpp index 0983493e19ea..3847341c721b 100644 --- a/SU2_CFD/include/numerics/transition/CUpwLin_TransLM.hpp +++ b/SU2_CFD/include/numerics/transition/CUpwLin_TransLM.hpp @@ -43,9 +43,9 @@ class CUpwLin_TransLM : public CNumerics { bool implicit, incompressible; su2double Density_i, Density_j, q_ij, a0, a1; unsigned short iDim; - + public: - + /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. @@ -53,12 +53,12 @@ class CUpwLin_TransLM : public CNumerics { * \param[in] config - Definition of the particular problem. */ CUpwLin_TransLM(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - + /*! * \brief Destructor of the class. */ ~CUpwLin_TransLM(void); - + /*! * \brief Compute the upwind flux between two nodes i and j. * \param[out] val_residual - Pointer to the total residual. diff --git a/SU2_CFD/include/numerics/transition/CUpwSca_TransLM.hpp b/SU2_CFD/include/numerics/transition/CUpwSca_TransLM.hpp index dcb65dfa4a45..c68cabe20333 100644 --- a/SU2_CFD/include/numerics/transition/CUpwSca_TransLM.hpp +++ b/SU2_CFD/include/numerics/transition/CUpwSca_TransLM.hpp @@ -42,9 +42,9 @@ class CUpwSca_TransLM : public CNumerics { bool implicit; su2double q_ij, a0, a1; unsigned short iDim; - + public: - + /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. @@ -52,12 +52,12 @@ class CUpwSca_TransLM : public CNumerics { * \param[in] config - Definition of the particular problem. */ CUpwSca_TransLM(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - + /*! * \brief Destructor of the class. */ ~CUpwSca_TransLM(void); - + /*! * \brief Compute the scalar upwind flux between two nodes i and j. * \param[out] val_residual - Pointer to the total residual. diff --git a/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA.hpp b/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA.hpp index c03710aadce2..839f581a3417 100644 --- a/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA.hpp +++ b/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA.hpp @@ -61,9 +61,9 @@ class CSourcePieceWise_TurbSA : public CNumerics { su2double gamma_BC; su2double intermittency; su2double Production, Destruction, CrossProduction; - + public: - + /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. @@ -71,12 +71,12 @@ class CSourcePieceWise_TurbSA : public CNumerics { * \param[in] config - Definition of the particular problem. */ CSourcePieceWise_TurbSA(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - + /*! * \brief Destructor of the class. */ ~CSourcePieceWise_TurbSA(void); - + /*! * \brief Residual for source term integration. * \param[out] val_residual - Pointer to the total residual. @@ -85,31 +85,31 @@ class CSourcePieceWise_TurbSA : 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 Residual for source term integration. * \param[in] intermittency_in - Value of the intermittency. */ inline void SetIntermittency(su2double intermittency_in) { intermittency = intermittency_in; } - + /*! * \brief Residual for source term integration. * \param[in] val_production - Value of the Production. */ inline void SetProduction(su2double val_production) { Production = val_production; } - + /*! * \brief Residual for source term integration. * \param[in] val_destruction - Value of the Destruction. */ inline void SetDestruction(su2double val_destruction) { Destruction = val_destruction; } - + /*! * \brief Residual for source term integration. * \param[in] val_crossproduction - Value of the CrossProduction. */ inline void SetCrossProduction(su2double val_crossproduction) { CrossProduction = val_crossproduction; } - + /*! * \brief ______________. */ @@ -120,12 +120,12 @@ class CSourcePieceWise_TurbSA : public CNumerics { * \return Value of the intermittency. */ inline su2double GetGammaBC(void) { return gamma_BC; } - + /*! * \brief ______________. */ inline su2double GetDestruction(void) { return Destruction; } - + /*! * \brief ______________. */ diff --git a/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA_COMP.hpp b/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA_COMP.hpp index 38ef713a9fb3..f9d46eec267f 100644 --- a/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA_COMP.hpp +++ b/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA_COMP.hpp @@ -62,9 +62,9 @@ class CSourcePieceWise_TurbSA_COMP : public CNumerics { su2double Production, Destruction, CrossProduction; su2double aux_cc, CompCorrection, c5; unsigned short jDim; - + public: - + /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. @@ -72,12 +72,12 @@ class CSourcePieceWise_TurbSA_COMP : public CNumerics { * \param[in] config - Definition of the particular problem. */ CSourcePieceWise_TurbSA_COMP(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - + /*! * \brief Destructor of the class. */ ~CSourcePieceWise_TurbSA_COMP(void); - + /*! * \brief Residual for source term integration. * \param[out] val_residual - Pointer to the total residual. @@ -86,41 +86,41 @@ class CSourcePieceWise_TurbSA_COMP : 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 Residual for source term integration. * \param[in] intermittency_in - Value of the intermittency. */ inline void SetIntermittency(su2double intermittency_in) { intermittency = intermittency_in; } - + /*! * \brief Residual for source term integration. * \param[in] val_production - Value of the Production. */ inline void SetProduction(su2double val_production) { Production = val_production; } - + /*! * \brief Residual for source term integration. * \param[in] val_destruction - Value of the Destruction. */ inline void SetDestruction(su2double val_destruction) { Destruction = val_destruction; } - + /*! * \brief Residual for source term integration. * \param[in] val_crossproduction - Value of the CrossProduction. */ inline void SetCrossProduction(su2double val_crossproduction) { CrossProduction = val_crossproduction; } - + /*! * \brief ______________. */ inline su2double GetProduction(void) { return Production; } - + /*! * \brief ______________. */ inline su2double GetDestruction(void) { return Destruction; } - + /*! * \brief ______________. */ diff --git a/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA_E.hpp b/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA_E.hpp index b735b226d2e3..5e1ef5f37d47 100644 --- a/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA_E.hpp +++ b/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA_E.hpp @@ -62,9 +62,9 @@ class CSourcePieceWise_TurbSA_E : public CNumerics { su2double Production, Destruction, CrossProduction; su2double Sbar; unsigned short jDim; - + public: - + /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. @@ -72,12 +72,12 @@ class CSourcePieceWise_TurbSA_E : public CNumerics { * \param[in] config - Definition of the particular problem. */ CSourcePieceWise_TurbSA_E(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - + /*! * \brief Destructor of the class. */ ~CSourcePieceWise_TurbSA_E(void); - + /*! * \brief Residual for source term integration. * \param[out] val_residual - Pointer to the total residual. @@ -86,41 +86,41 @@ class CSourcePieceWise_TurbSA_E : 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 Residual for source term integration. * \param[in] intermittency_in - Value of the intermittency. */ inline void SetIntermittency(su2double intermittency_in) { intermittency = intermittency_in; } - + /*! * \brief Residual for source term integration. * \param[in] val_production - Value of the Production. */ inline void SetProduction(su2double val_production) { Production = val_production; } - + /*! * \brief Residual for source term integration. * \param[in] val_destruction - Value of the Destruction. */ inline void SetDestruction(su2double val_destruction) { Destruction = val_destruction; } - + /*! * \brief Residual for source term integration. * \param[in] val_crossproduction - Value of the CrossProduction. */ inline void SetCrossProduction(su2double val_crossproduction) { CrossProduction = val_crossproduction; } - + /*! * \brief ______________. */ inline su2double GetProduction(void) { return Production; } - + /*! * \brief ______________. */ inline su2double GetDestruction(void) { return Destruction; } - + /*! * \brief ______________. */ diff --git a/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA_E_COMP.hpp b/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA_E_COMP.hpp index 651f8a47f57e..2b842720320a 100644 --- a/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA_E_COMP.hpp +++ b/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA_E_COMP.hpp @@ -63,9 +63,9 @@ class CSourcePieceWise_TurbSA_E_COMP : public CNumerics { su2double Sbar; unsigned short jDim; su2double aux_cc, CompCorrection, c5; - + public: - + /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. @@ -73,12 +73,12 @@ class CSourcePieceWise_TurbSA_E_COMP : public CNumerics { * \param[in] config - Definition of the particular problem. */ CSourcePieceWise_TurbSA_E_COMP(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - + /*! * \brief Destructor of the class. */ ~CSourcePieceWise_TurbSA_E_COMP(void); - + /*! * \brief Residual for source term integration. * \param[out] val_residual - Pointer to the total residual. @@ -87,41 +87,41 @@ class CSourcePieceWise_TurbSA_E_COMP : 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 Residual for source term integration. * \param[in] intermittency_in - Value of the intermittency. */ inline void SetIntermittency(su2double intermittency_in) { intermittency = intermittency_in; } - + /*! * \brief Residual for source term integration. * \param[in] val_production - Value of the Production. */ inline void SetProduction(su2double val_production) { Production = val_production; } - + /*! * \brief Residual for source term integration. * \param[in] val_destruction - Value of the Destruction. */ inline void SetDestruction(su2double val_destruction) { Destruction = val_destruction; } - + /*! * \brief Residual for source term integration. * \param[in] val_crossproduction - Value of the CrossProduction. */ inline void SetCrossProduction(su2double val_crossproduction) { CrossProduction = val_crossproduction; } - + /*! * \brief ______________. */ inline su2double GetProduction(void) { return Production; } - + /*! * \brief ______________. */ inline su2double GetDestruction(void) { return Destruction; } - + /*! * \brief ______________. */ diff --git a/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA_Neg.hpp b/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA_Neg.hpp index 70d0dabe21ae..f37abddc9b93 100644 --- a/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA_Neg.hpp +++ b/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA_Neg.hpp @@ -59,9 +59,9 @@ class CSourcePieceWise_TurbSA_Neg : public CNumerics { bool rotating_frame; su2double intermittency; su2double Production, Destruction, CrossProduction; - + public: - + /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. @@ -69,12 +69,12 @@ class CSourcePieceWise_TurbSA_Neg : public CNumerics { * \param[in] config - Definition of the particular problem. */ CSourcePieceWise_TurbSA_Neg(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - + /*! * \brief Destructor of the class. */ ~CSourcePieceWise_TurbSA_Neg(void); - + /*! * \brief Residual for source term integration. * \param[out] val_residual - Pointer to the total residual. @@ -83,41 +83,41 @@ class CSourcePieceWise_TurbSA_Neg : 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 Residual for source term integration. * \param[in] intermittency_in - Value of the intermittency. */ inline void SetIntermittency(su2double intermittency_in) { intermittency = intermittency_in; } - + /*! * \brief Residual for source term integration. * \param[in] val_production - Value of the Production. */ inline void SetProduction(su2double val_production) { Production = val_production; } - + /*! * \brief Residual for source term integration. * \param[in] val_destruction - Value of the Destruction. */ inline void SetDestruction(su2double val_destruction) { Destruction = val_destruction; } - + /*! * \brief Residual for source term integration. * \param[in] val_crossproduction - Value of the CrossProduction. */ inline void SetCrossProduction(su2double val_crossproduction) { CrossProduction = val_crossproduction; } - + /*! * \brief ______________. */ inline su2double GetProduction(void) { return Production; } - + /*! * \brief ______________. */ inline su2double GetDestruction(void) { return Destruction; } - + /*! * \brief ______________. */ diff --git a/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSST.hpp b/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSST.hpp index 7e1200554b6e..26aa5e1278fb 100644 --- a/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSST.hpp +++ b/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSST.hpp @@ -42,7 +42,7 @@ class CSourcePieceWise_TurbSST : public CNumerics { F1_j, F2_i, F2_j; - + su2double alfa_1, alfa_2, beta_1, @@ -51,16 +51,16 @@ class CSourcePieceWise_TurbSST : public CNumerics { sigma_omega_2, beta_star, a1; - + su2double CDkw_i, CDkw_j; su2double kAmb, omegaAmb; - + bool incompressible; bool sustaining_terms; - + public: - + /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. @@ -69,12 +69,12 @@ class CSourcePieceWise_TurbSST : public CNumerics { */ CSourcePieceWise_TurbSST(unsigned short val_nDim, unsigned short val_nVar, const su2double* constants, su2double val_kine_Inf, su2double val_omega_Inf, CConfig *config); - + /*! * \brief Destructor of the class. */ ~CSourcePieceWise_TurbSST(void); - + /*! * \brief Set the value of the first blending function. * \param[in] val_F1_i - Value of the first blending function at point i. @@ -84,7 +84,7 @@ class CSourcePieceWise_TurbSST : public CNumerics { F1_i = val_F1_i; F1_j = val_F1_j; } - + /*! * \brief Set the value of the second blending function. * \param[in] val_F2_i - Value of the second blending function at point i. @@ -94,7 +94,7 @@ class CSourcePieceWise_TurbSST : public CNumerics { F2_i = val_F2_i; F2_j = val_F2_j; } - + /*! * \brief Set the value of the cross diffusion for the SST model. * \param[in] val_CDkw_i - Value of the cross diffusion at point i. @@ -104,7 +104,7 @@ class CSourcePieceWise_TurbSST : public CNumerics { CDkw_i = val_CDkw_i; CDkw_j = val_CDkw_j; } - + /*! * \brief Residual for source term integration. * \param[out] val_residual - Pointer to the total residual. @@ -113,7 +113,7 @@ class CSourcePieceWise_TurbSST : 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 Initialize the Reynolds Stress Matrix * \param[in] turb_ke turbulent kinetic energy of node diff --git a/SU2_CFD/src/numerics/CNumerics.cpp b/SU2_CFD/src/numerics/CNumerics.cpp index b41295e127ef..43bd59f73415 100644 --- a/SU2_CFD/src/numerics/CNumerics.cpp +++ b/SU2_CFD/src/numerics/CNumerics.cpp @@ -1288,7 +1288,7 @@ void CNumerics::GetCharJump(su2double val_soundspeed, su2double val_density, su2 if (nDim == 2) { delta_char[0] = -cc*delta_prim[0] + delta_prim[3]; delta_char[1] = rhoc*delta_prim[2]; - delta_char[2] = rhoc*delta_prim[1] + delta_prim[3]; ; + delta_char[2] = rhoc*delta_prim[1] + delta_prim[3]; ; delta_char[3] = -rhoc*delta_prim[1] + delta_prim[3]; }else { delta_char[0] = -cc*delta_prim[0] + delta_prim[4]; diff --git a/SU2_CFD/src/numerics/continuous_adjoint/CAvgGradCorrected_AdjFlow.cpp b/SU2_CFD/src/numerics/continuous_adjoint/CAvgGradCorrected_AdjFlow.cpp index a01251b4bd0e..e2b0573ac8dd 100644 --- a/SU2_CFD/src/numerics/continuous_adjoint/CAvgGradCorrected_AdjFlow.cpp +++ b/SU2_CFD/src/numerics/continuous_adjoint/CAvgGradCorrected_AdjFlow.cpp @@ -28,47 +28,47 @@ #include "../../../include/numerics/continuous_adjoint/CAvgGradCorrected_AdjFlow.hpp" CAvgGradCorrected_AdjFlow::CAvgGradCorrected_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - + implicit = (config->GetKind_TimeIntScheme_AdjFlow() == EULER_IMPLICIT); - + Gamma = config->GetGamma(); Gamma_Minus_One = Gamma - 1.0; - + Velocity_i = new su2double [nDim]; Velocity_j = new su2double [nDim]; Mean_Velocity = new su2double [nDim]; - + Mean_GradPsiVar = new su2double* [nVar]; for (unsigned short iVar = 0; iVar < nVar; iVar++) Mean_GradPsiVar[iVar] = new su2double [nDim]; - + Edge_Vector = new su2double [nDim]; Proj_Mean_GradPsiVar_Edge = new su2double [nVar]; - + Mean_GradPhi = new su2double* [nDim]; for (unsigned short iDim = 0; iDim < nDim; iDim++) Mean_GradPhi[iDim] = new su2double [nDim]; Mean_GradPsiE = new su2double [nDim]; - + } CAvgGradCorrected_AdjFlow::~CAvgGradCorrected_AdjFlow(void) { - + delete [] Velocity_i; delete [] Velocity_j; delete [] Mean_Velocity; delete [] Edge_Vector; delete [] Proj_Mean_GradPsiVar_Edge; - + for (unsigned short iVar = 0; iVar < nVar; iVar++) delete [] Mean_GradPsiVar[iVar]; delete [] Mean_GradPsiVar; - + for (unsigned short iDim = 0; iDim < nDim; iDim++) delete [] Mean_GradPhi[iDim]; delete [] Mean_GradPhi; delete [] Mean_GradPsiE; - + } void CAvgGradCorrected_AdjFlow::ComputeResidual(su2double *val_residual_i, @@ -78,17 +78,17 @@ void CAvgGradCorrected_AdjFlow::ComputeResidual(su2double *val_residual_i, su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config) { - + unsigned short iVar, iDim, jDim; su2double Density_i, sq_vel_i, Pressure_i, ViscDens_i, XiDens_i; su2double Density_j, sq_vel_j, Pressure_j, ViscDens_j, XiDens_j; su2double dist_ij_2, dPhiE_dn; - + su2double Prandtl_Lam = config->GetPrandtl_Lam(); su2double Prandtl_Turb = config->GetPrandtl_Turb(); - + /*--- States in point i ---*/ - + sq_vel_i = 0.0; for (iDim = 0; iDim < nDim; iDim++) { Velocity_i[iDim] = V_i[iDim+1]; @@ -99,16 +99,16 @@ void CAvgGradCorrected_AdjFlow::ComputeResidual(su2double *val_residual_i, Enthalpy_i = V_i[nDim+3]; /*--- Laminar and Eddy viscosity ---*/ - + Laminar_Viscosity_i = V_i[nDim+5]; Eddy_Viscosity_i = V_i[nDim+6]; - + ViscDens_i = (Laminar_Viscosity_i + Eddy_Viscosity_i) / Density_i; XiDens_i = Gamma*(Laminar_Viscosity_i/Prandtl_Lam + Eddy_Viscosity_i/Prandtl_Turb) / Density_i; /*--- States in point j ---*/ - + sq_vel_j = 0.0; for (iDim = 0; iDim < nDim; iDim++) { Velocity_j[iDim] = V_j[iDim+1]; @@ -117,27 +117,27 @@ void CAvgGradCorrected_AdjFlow::ComputeResidual(su2double *val_residual_i, Pressure_j = V_j[nDim+1]; Density_j = V_j[nDim+2]; Enthalpy_j = V_j[nDim+3]; - + /*--- Laminar and Eddy viscosity ---*/ - + Laminar_Viscosity_j = V_j[nDim+5]; Eddy_Viscosity_j = V_j[nDim+6]; - + ViscDens_j = (Laminar_Viscosity_j + Eddy_Viscosity_j) / Density_j; XiDens_j = Gamma*(Laminar_Viscosity_j/Prandtl_Lam + Eddy_Viscosity_j/Prandtl_Turb) / Density_j; - + /*--- Compute vector going from iPoint to jPoint ---*/ - + dist_ij_2 = 0.0; for (iDim = 0; iDim < nDim; iDim++) { Mean_Velocity[iDim] = 0.5*(Velocity_i[iDim]+Velocity_j[iDim]); Edge_Vector[iDim] = Coord_j[iDim]-Coord_i[iDim]; dist_ij_2 += Edge_Vector[iDim]*Edge_Vector[iDim]; } - + /*--- Mean gradient approximation. Projection of the mean gradient in the direction of the edge, weiss correction ---*/ - + for (iVar = 0; iVar < nVar; iVar++) { Proj_Mean_GradPsiVar_Edge[iVar] = 0.0; for (iDim = 0; iDim < nDim; iDim++) { @@ -148,26 +148,26 @@ void CAvgGradCorrected_AdjFlow::ComputeResidual(su2double *val_residual_i, Mean_GradPsiVar[iVar][iDim] -= (Proj_Mean_GradPsiVar_Edge[iVar] - (Psi_j[iVar]-Psi_i[iVar]))*Edge_Vector[iDim]/dist_ij_2; } - + /*--- Average of the derivatives of the adjoint variables ---*/ - + for (iDim = 0; iDim < nDim; iDim++) { Mean_GradPsiE[iDim] = Mean_GradPsiVar[nVar-1][iDim]; for (jDim = 0; jDim < nDim; jDim++) Mean_GradPhi[iDim][jDim] = Mean_GradPsiVar[iDim+1][jDim]; } - + dPhiE_dn = 0; for (iDim = 0; iDim < nDim; iDim++) dPhiE_dn += Mean_GradPsiE[iDim]*Normal[iDim]; - + /*--- Compute the viscous residual and jacobian ---*/ - + GetAdjViscousFlux_Jac(Pressure_i, Pressure_j, Density_i, Density_j, ViscDens_i, ViscDens_j, Velocity_i, Velocity_j, sq_vel_i, sq_vel_j, XiDens_i, XiDens_j, Mean_GradPhi, Mean_GradPsiE, dPhiE_dn, Normal, Edge_Vector, dist_ij_2, val_residual_i, val_residual_j, val_Jacobian_ii, val_Jacobian_ij, val_Jacobian_ji, val_Jacobian_jj, implicit); - + } diff --git a/SU2_CFD/src/numerics/continuous_adjoint/CAvgGradCorrected_AdjTurb.cpp b/SU2_CFD/src/numerics/continuous_adjoint/CAvgGradCorrected_AdjTurb.cpp index d96dab0702b7..1ba0883004b0 100644 --- a/SU2_CFD/src/numerics/continuous_adjoint/CAvgGradCorrected_AdjTurb.cpp +++ b/SU2_CFD/src/numerics/continuous_adjoint/CAvgGradCorrected_AdjTurb.cpp @@ -28,7 +28,7 @@ #include "../../../include/numerics/continuous_adjoint/CAvgGradCorrected_AdjTurb.hpp" CAvgGradCorrected_AdjTurb::CAvgGradCorrected_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - + Gamma = config->GetGamma(); Gamma_Minus_One = Gamma - 1.0; Edge_Vector = new su2double [nDim]; @@ -53,20 +53,20 @@ CAvgGradCorrected_AdjTurb::~CAvgGradCorrected_AdjTurb(void) { void CAvgGradCorrected_AdjTurb::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - + bool implicit = (config->GetKind_TimeIntScheme_AdjTurb() == EULER_IMPLICIT); - + su2double sigma = 2./3.; su2double nu_i, nu_j, nu_e; su2double dist_ij_2 = 0; su2double proj_vector_ij = 0; unsigned short iVar, iDim; - + /*--- Compute mean effective viscosity ---*/ nu_i = Laminar_Viscosity_i/U_i[0]; nu_j = Laminar_Viscosity_j/U_j[0]; nu_e = 0.5*(nu_i+nu_j+TurbVar_i[0]+TurbVar_j[0])/sigma; - + /*--- Compute vector going from iPoint to jPoint ---*/ for (iDim = 0; iDim < nDim; iDim++) { Edge_Vector[iDim] = Coord_j[iDim]-Coord_i[iDim]; @@ -74,7 +74,7 @@ void CAvgGradCorrected_AdjTurb::ComputeResidual(su2double *val_residual, su2doub proj_vector_ij += Edge_Vector[iDim]*Normal[iDim]; } proj_vector_ij = proj_vector_ij/dist_ij_2; - + /*--- Mean gradient approximation ---*/ for (iVar = 0; iVar < nVar; iVar++) { Proj_Mean_GradTurbPsi_Edge[iVar] = 0.0; @@ -82,43 +82,43 @@ void CAvgGradCorrected_AdjTurb::ComputeResidual(su2double *val_residual, su2doub Mean_GradTurbPsi[iVar][iDim] = 0.5*(TurbPsi_Grad_i[iVar][iDim] + TurbPsi_Grad_j[iVar][iDim]); Proj_Mean_GradTurbPsi_Edge[iVar] += Mean_GradTurbPsi[iVar][iDim]*Edge_Vector[iDim]; } - + for (iDim = 0; iDim < nDim; iDim++) Mean_GradTurbPsi[iVar][iDim] -= (Proj_Mean_GradTurbPsi_Edge[iVar] - (TurbPsi_j[iVar]-TurbPsi_i[iVar]))*Edge_Vector[iDim]/dist_ij_2; - + /*--- Projection of the corrected gradient ---*/ Proj_Mean_GradTurbPsi_Corrected[iVar] = 0.0; for (iDim = 0; iDim < nDim; iDim++) Proj_Mean_GradTurbPsi_Corrected[iVar] += Mean_GradTurbPsi[iVar][iDim]*Normal[iDim]; } - + val_residual[0] = -nu_e*Proj_Mean_GradTurbPsi_Corrected[0]; - + if (implicit) { val_Jacobian_i[0][0] = nu_e*proj_vector_ij; val_Jacobian_j[0][0] = -nu_e*proj_vector_ij; } - + } void CAvgGradCorrected_AdjTurb::ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config) { - + bool implicit = (config->GetKind_TimeIntScheme_AdjTurb() == EULER_IMPLICIT); - + su2double sigma = 2./3.; su2double nu_i, nu_j, nu_e_i, nu_e_j; su2double dist_ij_2 = 0; su2double proj_vector_ij = 0; unsigned short iVar, iDim; - + /*--- Compute mean effective viscosity ---*/ nu_i = Laminar_Viscosity_i/U_i[0]; nu_j = Laminar_Viscosity_j/U_j[0]; nu_e_i = (nu_i+TurbVar_i[0])/sigma; nu_e_j = (nu_j+TurbVar_j[0])/sigma; - + /*--- Compute vector going from iPoint to jPoint ---*/ for (iDim = 0; iDim < nDim; iDim++) { Edge_Vector[iDim] = Coord_j[iDim]-Coord_i[iDim]; @@ -126,7 +126,7 @@ void CAvgGradCorrected_AdjTurb::ComputeResidual(su2double *val_residual_i, su2do proj_vector_ij += Edge_Vector[iDim]*Normal[iDim]; } proj_vector_ij = proj_vector_ij/dist_ij_2; // to normalize vectors - + /*--- Mean gradient approximation ---*/ for (iVar = 0; iVar < nVar; iVar++) { Proj_Mean_GradTurbPsi_Edge[iVar] = 0.0; @@ -134,25 +134,25 @@ void CAvgGradCorrected_AdjTurb::ComputeResidual(su2double *val_residual_i, su2do Mean_GradTurbPsi[iVar][iDim] = 0.5*(TurbPsi_Grad_i[iVar][iDim] + TurbPsi_Grad_j[iVar][iDim]); Proj_Mean_GradTurbPsi_Edge[iVar] += Mean_GradTurbPsi[iVar][iDim]*Edge_Vector[iDim]; } - + for (iDim = 0; iDim < nDim; iDim++) Mean_GradTurbPsi[iVar][iDim] -= (Proj_Mean_GradTurbPsi_Edge[iVar] - (TurbPsi_j[iVar]-TurbPsi_i[iVar]))*Edge_Vector[iDim]/dist_ij_2; - + /*--- Projection of the corrected gradient ---*/ Proj_Mean_GradTurbPsi_Corrected[iVar] = 0.0; for (iDim = 0; iDim < nDim; iDim++) Proj_Mean_GradTurbPsi_Corrected[iVar] += Mean_GradTurbPsi[iVar][iDim]*Normal[iDim]; } - + val_residual_i[0] = -nu_e_i*Proj_Mean_GradTurbPsi_Corrected[0]; val_residual_j[0] = nu_e_j*Proj_Mean_GradTurbPsi_Corrected[0]; - + if (implicit) { val_Jacobian_ii[0][0] = nu_e_i*proj_vector_ij; val_Jacobian_ij[0][0] = -nu_e_i*proj_vector_ij; val_Jacobian_ji[0][0] = -nu_e_j*proj_vector_ij; val_Jacobian_jj[0][0] = nu_e_j*proj_vector_ij; } - + } diff --git a/SU2_CFD/src/numerics/continuous_adjoint/CAvgGrad_AdjFlow.cpp b/SU2_CFD/src/numerics/continuous_adjoint/CAvgGrad_AdjFlow.cpp index 573fb535ef8e..f414ab83d525 100644 --- a/SU2_CFD/src/numerics/continuous_adjoint/CAvgGrad_AdjFlow.cpp +++ b/SU2_CFD/src/numerics/continuous_adjoint/CAvgGrad_AdjFlow.cpp @@ -29,12 +29,12 @@ CAvgGrad_AdjFlow::CAvgGrad_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { unsigned short iDim; - + implicit = (config->GetKind_TimeIntScheme_AdjFlow() == EULER_IMPLICIT); - + Gamma = config->GetGamma(); Gamma_Minus_One = Gamma - 1.0; - + Velocity_i = new su2double [nDim]; Velocity_j = new su2double [nDim]; Mean_Velocity = new su2double [nDim]; @@ -43,7 +43,7 @@ CAvgGrad_AdjFlow::CAvgGrad_AdjFlow(unsigned short val_nDim, unsigned short val_n Mean_GradPhi[iDim] = new su2double [nDim]; Mean_GradPsiE = new su2double [nDim]; Edge_Vector = new su2double [nDim]; - + } CAvgGrad_AdjFlow::~CAvgGrad_AdjFlow(void) { @@ -63,12 +63,12 @@ void CAvgGrad_AdjFlow::ComputeResidual(su2double *val_residual_i, su2double *val su2double sq_vel_i, ViscDens_i, XiDens_i; su2double sq_vel_j, ViscDens_j, XiDens_j; su2double dist_ij_2, dPhiE_dn; - + su2double Prandtl_Lam = config->GetPrandtl_Lam(); su2double Prandtl_Turb = config->GetPrandtl_Turb(); /*--- States in point i ---*/ - + sq_vel_i = 0.0; for (iDim = 0; iDim < nDim; iDim++) { Velocity_i[iDim] = V_i[iDim+1]; @@ -78,17 +78,17 @@ void CAvgGrad_AdjFlow::ComputeResidual(su2double *val_residual_i, su2double *val Density_i = V_i[nDim+2]; Enthalpy_i = V_i[nDim+3]; SoundSpeed_i = sqrt(fabs(Pressure_i*Gamma/Density_i)); - + /*--- Laminar and Eddy viscosity ---*/ - + Laminar_Viscosity_i = V_i[nDim+5]; Eddy_Viscosity_i = V_i[nDim+6]; - + ViscDens_i = (Laminar_Viscosity_i + Eddy_Viscosity_i) / Density_i; XiDens_i = Gamma*(Laminar_Viscosity_i/Prandtl_Lam + Eddy_Viscosity_i/Prandtl_Turb) / Density_i; - + /*--- States in point j ---*/ - + sq_vel_j = 0.0; for (iDim = 0; iDim < nDim; iDim++) { Velocity_j[iDim] = V_j[iDim+1]; @@ -98,42 +98,42 @@ void CAvgGrad_AdjFlow::ComputeResidual(su2double *val_residual_i, su2double *val Density_j = V_j[nDim+2]; Enthalpy_j = V_j[nDim+3]; SoundSpeed_j = sqrt(fabs(Pressure_j*Gamma/Density_j)); - + /*--- Laminar and Eddy viscosity ---*/ - + Laminar_Viscosity_j = V_j[nDim+5]; Eddy_Viscosity_j = V_j[nDim+6]; - + ViscDens_j = (Laminar_Viscosity_j + Eddy_Viscosity_j) / Density_j; XiDens_j = Gamma*(Laminar_Viscosity_j/Prandtl_Lam + Eddy_Viscosity_j/Prandtl_Turb) / Density_j; - + /*--- Compute vector going from iPoint to jPoint ---*/ - + dist_ij_2 = 0.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]; } - + /*--- Average of the derivatives of the adjoint variables ---*/ - + for (iDim = 0; iDim < nDim; iDim++) { Mean_GradPsiE[iDim] = 0.5*(PsiVar_Grad_i[nVar-1][iDim]+PsiVar_Grad_j[nVar-1][iDim]); for (jDim = 0; jDim < nDim; jDim++) Mean_GradPhi[iDim][jDim] = 0.5*(PsiVar_Grad_i[iDim+1][jDim]+PsiVar_Grad_j[iDim+1][jDim]); } - + dPhiE_dn = 0; for (iDim = 0; iDim < nDim; iDim++) dPhiE_dn += Mean_GradPsiE[iDim]*Normal[iDim]; - + /*--- Compute the viscous residual and jacobian ---*/ - + GetAdjViscousFlux_Jac(Pressure_i, Pressure_j, Density_i, Density_j, ViscDens_i, ViscDens_j, Velocity_i, Velocity_j, sq_vel_i, sq_vel_j, XiDens_i, XiDens_j, Mean_GradPhi, Mean_GradPsiE, dPhiE_dn, Normal, Edge_Vector, dist_ij_2, val_residual_i, val_residual_j, val_Jacobian_ii, val_Jacobian_ij, val_Jacobian_ji, val_Jacobian_jj, implicit); - + } diff --git a/SU2_CFD/src/numerics/continuous_adjoint/CAvgGrad_AdjTurb.cpp b/SU2_CFD/src/numerics/continuous_adjoint/CAvgGrad_AdjTurb.cpp index 61819d5d88b4..56db16f8591b 100644 --- a/SU2_CFD/src/numerics/continuous_adjoint/CAvgGrad_AdjTurb.cpp +++ b/SU2_CFD/src/numerics/continuous_adjoint/CAvgGrad_AdjTurb.cpp @@ -28,7 +28,7 @@ #include "../../../include/numerics/continuous_adjoint/CAvgGrad_AdjTurb.hpp" CAvgGrad_AdjTurb::CAvgGrad_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - + Gamma = config->GetGamma(); Gamma_Minus_One = Gamma - 1.0; Edge_Vector = new su2double [nDim]; @@ -53,20 +53,20 @@ CAvgGrad_AdjTurb::~CAvgGrad_AdjTurb(void) { void CAvgGrad_AdjTurb::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - + bool implicit = (config->GetKind_TimeIntScheme_AdjTurb() == EULER_IMPLICIT); - + su2double sigma = 2./3.; su2double nu_i, nu_j, nu_e; su2double dist_ij_2 = 0; su2double proj_vector_ij = 0; unsigned short iVar, iDim; - + /*--- Compute mean effective viscosity ---*/ nu_i = Laminar_Viscosity_i/U_i[0]; nu_j = Laminar_Viscosity_j/U_j[0]; nu_e = 0.5*(nu_i+nu_j+TurbVar_i[0]+TurbVar_j[0])/sigma; - + /*--- Compute vector going from iPoint to jPoint ---*/ for (iDim = 0; iDim < nDim; iDim++) { Edge_Vector[iDim] = Coord_j[iDim]-Coord_i[iDim]; @@ -74,47 +74,47 @@ void CAvgGrad_AdjTurb::ComputeResidual(su2double *val_residual, su2double **val_ proj_vector_ij += Edge_Vector[iDim]*Normal[iDim]; } proj_vector_ij = proj_vector_ij/dist_ij_2; - + /*--- Mean gradient approximation ---*/ for (iVar = 0; iVar < nVar; iVar++) { Proj_Mean_GradTurbPsi_Edge[iVar] = 0.0; for (iDim = 0; iDim < nDim; iDim++) { Mean_GradTurbPsi[iVar][iDim] = 0.5*(TurbPsi_Grad_i[iVar][iDim] + TurbPsi_Grad_j[iVar][iDim]); } - + /*--- Projection of the corrected gradient ---*/ Proj_Mean_GradTurbPsi_Corrected[iVar] = 0.0; for (iDim = 0; iDim < nDim; iDim++) Proj_Mean_GradTurbPsi_Corrected[iVar] += Mean_GradTurbPsi[iVar][iDim]*Normal[iDim]; } - + val_residual[0] = -nu_e*Proj_Mean_GradTurbPsi_Corrected[0]; - + if (implicit) { val_Jacobian_i[0][0] = nu_e*proj_vector_ij; val_Jacobian_j[0][0] = -nu_e*proj_vector_ij; } - + } void CAvgGrad_AdjTurb::ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config) { - + bool implicit = (config->GetKind_TimeIntScheme_AdjTurb() == EULER_IMPLICIT); - + su2double sigma = 2./3.; su2double nu_i, nu_j, nu_e_i, nu_e_j; su2double dist_ij_2 = 0; su2double proj_vector_ij = 0; unsigned short iVar, iDim; - + /*--- Compute mean effective viscosity ---*/ nu_i = Laminar_Viscosity_i/U_i[0]; nu_j = Laminar_Viscosity_j/U_j[0]; nu_e_i = (nu_i+TurbVar_i[0])/sigma; nu_e_j = (nu_j+TurbVar_j[0])/sigma; - + /*--- Compute vector going from iPoint to jPoint ---*/ for (iDim = 0; iDim < nDim; iDim++) { Edge_Vector[iDim] = Coord_j[iDim]-Coord_i[iDim]; @@ -122,28 +122,28 @@ void CAvgGrad_AdjTurb::ComputeResidual(su2double *val_residual_i, su2double *val proj_vector_ij += Edge_Vector[iDim]*Normal[iDim]; } proj_vector_ij = proj_vector_ij/dist_ij_2; // to normalize vectors - + /*--- Mean gradient approximation ---*/ for (iVar = 0; iVar < nVar; iVar++) { Proj_Mean_GradTurbPsi_Edge[iVar] = 0.0; for (iDim = 0; iDim < nDim; iDim++) { Mean_GradTurbPsi[iVar][iDim] = 0.5*(TurbPsi_Grad_i[iVar][iDim] + TurbPsi_Grad_j[iVar][iDim]); } - + /*--- Projection of the corrected gradient ---*/ Proj_Mean_GradTurbPsi_Corrected[iVar] = 0.0; for (iDim = 0; iDim < nDim; iDim++) Proj_Mean_GradTurbPsi_Corrected[iVar] += Mean_GradTurbPsi[iVar][iDim]*Normal[iDim]; } - + val_residual_i[0] = -nu_e_i*Proj_Mean_GradTurbPsi_Corrected[0]; val_residual_j[0] = nu_e_j*Proj_Mean_GradTurbPsi_Corrected[0]; - + if (implicit) { val_Jacobian_ii[0][0] = nu_e_i*proj_vector_ij; val_Jacobian_ij[0][0] = -nu_e_i*proj_vector_ij; val_Jacobian_ji[0][0] = -nu_e_j*proj_vector_ij; val_Jacobian_jj[0][0] = nu_e_j*proj_vector_ij; } - + } diff --git a/SU2_CFD/src/numerics/continuous_adjoint/CCentJST_AdjFlow.cpp b/SU2_CFD/src/numerics/continuous_adjoint/CCentJST_AdjFlow.cpp index f4c778e8c0b2..990b80195a96 100644 --- a/SU2_CFD/src/numerics/continuous_adjoint/CCentJST_AdjFlow.cpp +++ b/SU2_CFD/src/numerics/continuous_adjoint/CCentJST_AdjFlow.cpp @@ -28,25 +28,25 @@ #include "../../../include/numerics/continuous_adjoint/CCentJST_AdjFlow.hpp" CCentJST_AdjFlow::CCentJST_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - + Gamma = config->GetGamma(); Gamma_Minus_One = Gamma - 1.0; - + grid_movement = config->GetGrid_Movement(); - + Diff_Psi = new su2double [nVar]; Diff_Lapl = new su2double [nVar]; Velocity_i = new su2double [nDim]; Velocity_j = new su2double [nDim]; MeanPhi = new su2double [nDim]; - + Param_p = 0.3; Param_Kappa_2 = config->GetKappa_2nd_AdjFlow(); Param_Kappa_4 = config->GetKappa_4th_AdjFlow(); implicit = (config->GetKind_TimeIntScheme_AdjFlow() == EULER_IMPLICIT); - + } CCentJST_AdjFlow::~CCentJST_AdjFlow(void) { - + delete [] Diff_Psi; delete [] Diff_Lapl; delete [] Velocity_i; delete [] Velocity_j; delete [] MeanPhi; @@ -55,16 +55,16 @@ CCentJST_AdjFlow::~CCentJST_AdjFlow(void) { void CCentJST_AdjFlow::ComputeResidual (su2double *val_resconv_i, su2double *val_resvisc_i, su2double *val_resconv_j, su2double *val_resvisc_j, su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config) { - + /*--- Mean Values ---*/ - + MeanPsiRho = 0.5*(Psi_i[0]+Psi_j[0]); for (iDim = 0; iDim < nDim; iDim++) MeanPhi[iDim] = 0.5*(Psi_i[iDim+1]+Psi_j[iDim+1]); MeanPsiE = 0.5*(Psi_i[nVar-1]+Psi_j[nVar-1]); - + /*--- Point i convective residual evaluation ---*/ - + ProjVelocity_i = 0; ProjPhi = 0; ProjPhi_Vel = 0; sq_vel = 0; Area = 0; for (iDim = 0; iDim < nDim; iDim++) { Velocity_i[iDim] = U_i[iDim+1] / U_i[0]; @@ -77,14 +77,14 @@ void CCentJST_AdjFlow::ComputeResidual (su2double *val_resconv_i, su2double *val Area = sqrt(Area); phis1 = ProjPhi + ProjVelocity_i*MeanPsiE; phis2 = MeanPsiRho + ProjPhi_Vel + Enthalpy_i*MeanPsiE; - + val_resconv_i[0] = ProjVelocity_i*MeanPsiRho - phis2*ProjVelocity_i + Gamma_Minus_One*phis1*sq_vel; for (iDim = 0; iDim < nDim; iDim++) val_resconv_i[iDim+1] = ProjVelocity_i*MeanPhi[iDim] + phis2*Normal[iDim] - Gamma_Minus_One*phis1*Velocity_i[iDim]; val_resconv_i[nVar-1] = ProjVelocity_i*MeanPsiE + Gamma_Minus_One*phis1; - + /*--- Flux contributions due to grid movement at point i ---*/ - + if (grid_movement) { su2double ProjGridVel = 0.0; for (iDim = 0; iDim < nDim; iDim++) @@ -94,9 +94,9 @@ void CCentJST_AdjFlow::ComputeResidual (su2double *val_resconv_i, su2double *val val_resconv_i[iDim+1] -= ProjGridVel*MeanPhi[iDim]; val_resconv_i[nVar-1] -= ProjGridVel*MeanPsiE; } - + /*--- Jacobians of the inviscid flux ---*/ - + if (implicit) { val_Jacobian_ii[0][0] = 0.0; for (jDim = 0; jDim < nDim; jDim++) @@ -113,13 +113,13 @@ void CCentJST_AdjFlow::ComputeResidual (su2double *val_resconv_i, su2double *val for (jDim = 0; jDim < nDim; jDim++) val_Jacobian_ii[nVar-1][jDim+1] = 0.5*Gamma_Minus_One*Normal[jDim]; val_Jacobian_ii[nVar-1][nVar-1] = 0.5*Gamma*ProjVelocity_i; - + for (iVar = 0; iVar < nVar; iVar++) for (jVar = 0; jVar < nVar; jVar++) val_Jacobian_ij[iVar][jVar] = val_Jacobian_ii[iVar][jVar]; - + /*--- Jacobian contributions due to grid movement at point i ---*/ - + if (grid_movement) { su2double ProjGridVel = 0.0; for (iDim = 0; iDim < nDim; iDim++) @@ -130,10 +130,10 @@ void CCentJST_AdjFlow::ComputeResidual (su2double *val_resconv_i, su2double *val } } } - - + + /*--- Point j convective residual evaluation ---*/ - + ProjVelocity_j = 0; ProjPhi_Vel = 0; sq_vel = 0; for (iDim = 0; iDim < nDim; iDim++) { Velocity_j[iDim] = U_j[iDim+1] / U_j[0]; @@ -141,17 +141,17 @@ void CCentJST_AdjFlow::ComputeResidual (su2double *val_resconv_i, su2double *val ProjPhi_Vel += MeanPhi[iDim]*Velocity_j[iDim]; sq_vel += 0.5*Velocity_j[iDim]*Velocity_j[iDim]; } - + phis1 = ProjPhi + ProjVelocity_j*MeanPsiE; phis2 = MeanPsiRho + ProjPhi_Vel + Enthalpy_j*MeanPsiE; - + val_resconv_j[0] = -(ProjVelocity_j*MeanPsiRho - phis2*ProjVelocity_j + Gamma_Minus_One*phis1*sq_vel); for (iDim = 0; iDim < nDim; iDim++) val_resconv_j[iDim+1] = -(ProjVelocity_j*MeanPhi[iDim] + phis2*Normal[iDim] - Gamma_Minus_One*phis1*Velocity_j[iDim]); val_resconv_j[nVar-1] = -(ProjVelocity_j*MeanPsiE + Gamma_Minus_One*phis1); - + /*--- Flux contributions due to grid motion at point j ---*/ - + if (grid_movement) { su2double ProjGridVel = 0.0; for (iDim = 0; iDim < nDim; iDim++) @@ -161,9 +161,9 @@ void CCentJST_AdjFlow::ComputeResidual (su2double *val_resconv_i, su2double *val val_resconv_j[iDim+1] += ProjGridVel*MeanPhi[iDim]; val_resconv_j[nVar-1] += ProjGridVel*MeanPsiE; } - + /*--- Jacobians of the inviscid flux ---*/ - + if (implicit) { val_Jacobian_jj[0][0] = 0.0; for (jDim = 0; jDim < nDim; jDim++) @@ -180,13 +180,13 @@ void CCentJST_AdjFlow::ComputeResidual (su2double *val_resconv_i, su2double *val for (jDim = 0; jDim < nDim; jDim++) val_Jacobian_jj[nVar-1][jDim+1] = -0.5*Gamma_Minus_One*Normal[jDim]; val_Jacobian_jj[nVar-1][nVar-1] = -0.5*Gamma*ProjVelocity_j; - + for (iVar = 0; iVar < nVar; iVar++) for (jVar = 0; jVar < nVar; jVar++) val_Jacobian_ji[iVar][jVar] = val_Jacobian_jj[iVar][jVar]; - + /*--- Jacobian contributions due to grid motion at point j ---*/ - + if (grid_movement) { su2double ProjGridVel = 0.0; for (iDim = 0; iDim < nDim; iDim++) @@ -197,16 +197,16 @@ void CCentJST_AdjFlow::ComputeResidual (su2double *val_resconv_i, su2double *val } } } - + /*--- Computes differences btw. variables and Laplacians ---*/ - + for (iVar = 0; iVar < nVar; iVar++) { Diff_Lapl[iVar] = Und_Lapl_i[iVar]-Und_Lapl_j[iVar]; Diff_Psi[iVar] = Psi_i[iVar]-Psi_j[iVar]; } /*--- Adjustment to projected velocity due to grid motion ---*/ - + if (grid_movement) { su2double ProjGridVel = 0.0; for (iDim = 0; iDim < nDim; iDim++) { @@ -215,24 +215,24 @@ void CCentJST_AdjFlow::ComputeResidual (su2double *val_resconv_i, su2double *val ProjVelocity_i -= ProjGridVel; ProjVelocity_j += ProjGridVel; } - + /*--- Compute the spectral radius and stretching factor ---*/ - + Local_Lambda_i = (fabs(ProjVelocity_i)+SoundSpeed_i*Area); Local_Lambda_j = (fabs(ProjVelocity_j)+SoundSpeed_j*Area); MeanLambda = 0.5*(Local_Lambda_i+Local_Lambda_j); - + Phi_i = pow(Lambda_i/(4.0*MeanLambda), Param_p); Phi_j = pow(Lambda_j/(4.0*MeanLambda), Param_p); StretchingFactor = 4.0*Phi_i*Phi_j/(Phi_i+Phi_j); - + su2double sc2 = 3.0*(su2double(Neighbor_i)+su2double(Neighbor_j))/(su2double(Neighbor_i)*su2double(Neighbor_j)); sc4 = sc2*sc2/4.0; Epsilon_2 = Param_Kappa_2*0.5*(Sensor_i+Sensor_j)*sc2; Epsilon_4 = max(0.0, Param_Kappa_4-Epsilon_2)*sc4; - + /*--- Compute viscous residual 1st- & 3rd-order dissipation ---*/ - + for (iVar = 0; iVar < nVar; iVar++) { Residual = (Epsilon_2*Diff_Psi[iVar]-Epsilon_4*Diff_Lapl[iVar])*StretchingFactor*MeanLambda; val_resvisc_i[iVar] = -Residual; @@ -244,5 +244,5 @@ void CCentJST_AdjFlow::ComputeResidual (su2double *val_resconv_i, su2double *val val_Jacobian_jj[iVar][iVar] -= Epsilon_2 + su2double(Neighbor_j+1)*Epsilon_4*StretchingFactor*MeanLambda; } } - + } diff --git a/SU2_CFD/src/numerics/continuous_adjoint/CCentLax_AdjFlow.cpp b/SU2_CFD/src/numerics/continuous_adjoint/CCentLax_AdjFlow.cpp index e58e27983a6b..6737779e46f6 100644 --- a/SU2_CFD/src/numerics/continuous_adjoint/CCentLax_AdjFlow.cpp +++ b/SU2_CFD/src/numerics/continuous_adjoint/CCentLax_AdjFlow.cpp @@ -28,39 +28,39 @@ #include "../../../include/numerics/continuous_adjoint/CCentLax_AdjFlow.hpp" CCentLax_AdjFlow::CCentLax_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - + Gamma = config->GetGamma(); Gamma_Minus_One = Gamma - 1.0; - + Diff_Psi = new su2double [nVar]; MeanPhi = new su2double [nDim]; Velocity_i = new su2double [nDim]; Velocity_j = new su2double [nDim]; - + implicit = (config->GetKind_TimeIntScheme_AdjFlow() == EULER_IMPLICIT); grid_movement = config->GetGrid_Movement(); - + Param_p = 0.3; Param_Kappa_0 = config->GetKappa_1st_AdjFlow(); - + } CCentLax_AdjFlow::~CCentLax_AdjFlow(void) { - + delete [] Diff_Psi; delete [] MeanPhi; delete [] Velocity_i; delete [] Velocity_j; - + } void CCentLax_AdjFlow::ComputeResidual (su2double *val_resconv_i, su2double *val_resvisc_i, su2double *val_resconv_j, su2double *val_resvisc_j, su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config) { - + /*--- Mean value of the adjoint variables ---*/ MeanPsiRho = 0.5*(Psi_i[0]+Psi_j[0]); for (iDim = 0; iDim < nDim; iDim++) MeanPhi[iDim] = 0.5*(Psi_i[iDim+1]+Psi_j[iDim+1]); MeanPsiE = 0.5*(Psi_i[nVar-1]+Psi_j[nVar-1]); - + /*--- Evaluation at point i ---*/ ProjVelocity_i = 0; ProjPhi = 0; ProjPhi_Vel = 0; sq_vel = 0; Area = 0; for (iDim = 0; iDim < nDim; iDim++) { @@ -74,7 +74,7 @@ void CCentLax_AdjFlow::ComputeResidual (su2double *val_resconv_i, su2double *val Area = sqrt(Area); phis1 = ProjPhi + ProjVelocity_i*MeanPsiE; phis2 = MeanPsiRho + ProjPhi_Vel + Enthalpy_i*MeanPsiE; - + /*--- Compute inviscid residual at point i ---*/ val_resconv_i[0] = ProjVelocity_i*MeanPsiRho - phis2*ProjVelocity_i + Gamma_Minus_One*phis1*sq_vel; for (iDim = 0; iDim < nDim; iDim++) @@ -91,7 +91,7 @@ void CCentLax_AdjFlow::ComputeResidual (su2double *val_resconv_i, su2double *val val_resconv_i[iDim+1] -= ProjGridVel*MeanPhi[iDim]; val_resconv_i[nVar-1] -= ProjGridVel*MeanPsiE; } - + /*--- Inviscid contribution to the implicit part ---*/ if (implicit) { val_Jacobian_ii[0][0] = 0.0; @@ -109,7 +109,7 @@ void CCentLax_AdjFlow::ComputeResidual (su2double *val_resconv_i, su2double *val for (jDim = 0; jDim < nDim; jDim++) val_Jacobian_ii[nVar-1][jDim+1] = 0.5*Gamma_Minus_One*Normal[jDim]; val_Jacobian_ii[nVar-1][nVar-1] = 0.5*Gamma*ProjVelocity_i; - + for (iVar = 0; iVar < nVar; iVar++) for (jVar = 0; jVar < nVar; jVar++) val_Jacobian_ij[iVar][jVar] = val_Jacobian_ii[iVar][jVar]; @@ -125,7 +125,7 @@ void CCentLax_AdjFlow::ComputeResidual (su2double *val_resconv_i, su2double *val } } } - + /*--- Evaluation at point j ---*/ ProjVelocity_j = 0; ProjPhi_Vel = 0; sq_vel = 0; for (iDim = 0; iDim < nDim; iDim++) { @@ -134,16 +134,16 @@ void CCentLax_AdjFlow::ComputeResidual (su2double *val_resconv_i, su2double *val ProjPhi_Vel += MeanPhi[iDim]*Velocity_j[iDim]; sq_vel += 0.5*Velocity_j[iDim]*Velocity_j[iDim]; } - + phis1 = ProjPhi + ProjVelocity_j*MeanPsiE; phis2 = MeanPsiRho + ProjPhi_Vel + Enthalpy_j*MeanPsiE; - + /*--- Compute inviscid residual at point j ---*/ val_resconv_j[0] = -(ProjVelocity_j*MeanPsiRho - phis2*ProjVelocity_j + Gamma_Minus_One*phis1*sq_vel); for (iDim = 0; iDim < nDim; iDim++) val_resconv_j[iDim+1] = -(ProjVelocity_j*MeanPhi[iDim] + phis2*Normal[iDim] - Gamma_Minus_One*phis1*Velocity_j[iDim]); val_resconv_j[nVar-1] = -(ProjVelocity_j*MeanPsiE + Gamma_Minus_One*phis1); - + /*--- Flux contributions due to grid movement at point j ---*/ if (grid_movement) { su2double ProjGridVel = 0.0; @@ -154,7 +154,7 @@ void CCentLax_AdjFlow::ComputeResidual (su2double *val_resconv_i, su2double *val val_resconv_j[iDim+1] += ProjGridVel*MeanPhi[iDim]; val_resconv_j[nVar-1] += ProjGridVel*MeanPsiE; } - + /*--- Inviscid contribution to the implicit part ---*/ if (implicit) { val_Jacobian_jj[0][0] = 0.0; @@ -172,11 +172,11 @@ void CCentLax_AdjFlow::ComputeResidual (su2double *val_resconv_i, su2double *val for (jDim = 0; jDim < nDim; jDim++) val_Jacobian_jj[nVar-1][jDim+1] = -0.5*Gamma_Minus_One*Normal[jDim]; val_Jacobian_jj[nVar-1][nVar-1] = -0.5*Gamma*ProjVelocity_j; - + for (iVar = 0; iVar < nVar; iVar++) for (jVar = 0; jVar < nVar; jVar++) val_Jacobian_ji[iVar][jVar] = val_Jacobian_jj[iVar][jVar]; - + /*--- Jacobian contributions due to grid movement at point j ---*/ if (grid_movement) { su2double ProjGridVel = 0.0; @@ -188,11 +188,11 @@ void CCentLax_AdjFlow::ComputeResidual (su2double *val_resconv_i, su2double *val } } } - + /*--- Computes differences btw. variables ---*/ for (iVar = 0; iVar < nVar; iVar++) Diff_Psi[iVar] = Psi_i[iVar]-Psi_j[iVar]; - + /*--- Adjustment to projected velocity due to grid motion ---*/ if (grid_movement) { su2double ProjGridVel = 0.0; @@ -201,27 +201,27 @@ void CCentLax_AdjFlow::ComputeResidual (su2double *val_resconv_i, su2double *val ProjVelocity_i -= ProjGridVel; ProjVelocity_j += ProjGridVel; } - + /*--- Compute spectral radius ---*/ Local_Lambda_i = (fabs(ProjVelocity_i)+SoundSpeed_i*Area); Local_Lambda_j = (fabs(ProjVelocity_j)+SoundSpeed_j*Area); MeanLambda = 0.5*(Local_Lambda_i+Local_Lambda_j); - + /*--- Compute streching factor ---*/ Phi_i = pow(Lambda_i/(4.0*MeanLambda), Param_p); Phi_j = pow(Lambda_j/(4.0*MeanLambda), Param_p); StretchingFactor = 4.0*Phi_i*Phi_j/(Phi_i+Phi_j); - + sc2 = 3.0*(su2double(Neighbor_i)+su2double(Neighbor_j))/(su2double(Neighbor_i)*su2double(Neighbor_j)); Epsilon_0 = Param_Kappa_0*sc2*su2double(nDim)/3.0; - + /*--- Artifical dissipation evaluation ---*/ for (iVar = 0; iVar < nVar; iVar++) { Residual = Epsilon_0*StretchingFactor*MeanLambda*Diff_Psi[iVar]; val_resvisc_i[iVar] = -Residual; val_resvisc_j[iVar] = Residual; } - + /*--- Contribution to implicit part ---*/ if (implicit) { for (iVar = 0; iVar < nVar; iVar++) { @@ -231,5 +231,5 @@ void CCentLax_AdjFlow::ComputeResidual (su2double *val_resconv_i, su2double *val val_Jacobian_jj[iVar][iVar] -= Epsilon_0*StretchingFactor*MeanLambda; } } - + } diff --git a/SU2_CFD/src/numerics/continuous_adjoint/CSourceAxisymmetric_AdjFlow.cpp b/SU2_CFD/src/numerics/continuous_adjoint/CSourceAxisymmetric_AdjFlow.cpp index 7a30a454f35b..fc67713fa039 100644 --- a/SU2_CFD/src/numerics/continuous_adjoint/CSourceAxisymmetric_AdjFlow.cpp +++ b/SU2_CFD/src/numerics/continuous_adjoint/CSourceAxisymmetric_AdjFlow.cpp @@ -32,37 +32,37 @@ CSourceAxisymmetric_AdjFlow::CSourceAxisymmetric_AdjFlow(unsigned short val_nDim CSourceAxisymmetric_AdjFlow::~CSourceAxisymmetric_AdjFlow(void) { } void CSourceAxisymmetric_AdjFlow::ComputeResidual(su2double *val_residual, su2double **Jacobian_ii, CConfig *config) { - + su2double yinv; su2double Jacobian_Axisymmetric[4][4]; - + if (Coord_i[1] > 0.0) yinv = 1.0/Coord_i[1]; else yinv = 0.0; - + Jacobian_Axisymmetric[0][0] = 0; Jacobian_Axisymmetric[0][1] = 0; Jacobian_Axisymmetric[0][2] = 1.; Jacobian_Axisymmetric[0][3] = 0; - + Jacobian_Axisymmetric[1][0] = -U_i[1]*U_i[2]/(U_i[0]*U_i[0]); Jacobian_Axisymmetric[1][1] = U_i[2]/U_i[0]; Jacobian_Axisymmetric[1][2] = U_i[1]/U_i[0]; Jacobian_Axisymmetric[1][3] = 0; - + Jacobian_Axisymmetric[2][0] = -U_i[2]*U_i[2]/(U_i[0]*U_i[0]); Jacobian_Axisymmetric[2][1] = 0; Jacobian_Axisymmetric[2][2] = 2*U_i[2]/U_i[0]; Jacobian_Axisymmetric[2][3] = 0; - + Jacobian_Axisymmetric[3][0] = -Gamma*U_i[2]*U_i[3]/(U_i[0]*U_i[0]) + (Gamma-1)*U_i[2]*(U_i[1]*U_i[1]+U_i[2]*U_i[2])/(U_i[0]*U_i[0]*U_i[0]); Jacobian_Axisymmetric[3][1] = -(Gamma-1)*U_i[2]*U_i[1]/(U_i[0]*U_i[0]); Jacobian_Axisymmetric[3][2] = Gamma*U_i[3]/U_i[0] - 1/2*(Gamma-1)*( (U_i[1]*U_i[1]+U_i[2]*U_i[2])/(U_i[0]*U_i[0]) + 2*U_i[2]*U_i[2]/(U_i[0]*U_i[0]) ); Jacobian_Axisymmetric[3][3] = Gamma*U_i[2]/U_i[0]; - + for (int iVar=0; iVar<4; iVar++) for (int jVar=0; jVar<4; jVar++) Jacobian_Axisymmetric[iVar][jVar] *= yinv*Volume; - + /* -- Residual = transpose(Jacobian) * psi --*/ for (int iVar = 0; iVar < nVar; iVar++) { val_residual[iVar] = 0.0; diff --git a/SU2_CFD/src/numerics/continuous_adjoint/CSourceConservative_AdjFlow.cpp b/SU2_CFD/src/numerics/continuous_adjoint/CSourceConservative_AdjFlow.cpp index 340421c5ed8a..51bda829e181 100644 --- a/SU2_CFD/src/numerics/continuous_adjoint/CSourceConservative_AdjFlow.cpp +++ b/SU2_CFD/src/numerics/continuous_adjoint/CSourceConservative_AdjFlow.cpp @@ -28,15 +28,15 @@ #include "../../../include/numerics/continuous_adjoint/CSourceConservative_AdjFlow.hpp" CSourceConservative_AdjFlow::CSourceConservative_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - + Gamma = config->GetGamma(); Gamma_Minus_One = Gamma - 1.0; - + Velocity = new su2double [nDim]; Residual_i = new su2double [nVar]; Residual_j = new su2double [nVar]; Mean_Residual = new su2double [nVar]; - + Mean_PrimVar_Grad = new su2double* [nVar]; for (unsigned short iVar = 0; iVar < nVar; iVar++) Mean_PrimVar_Grad[iVar] = new su2double [nDim]; @@ -47,7 +47,7 @@ CSourceConservative_AdjFlow::~CSourceConservative_AdjFlow(void) { delete [] Residual_j; delete [] Residual_i; delete [] Velocity; - + for (unsigned short iVar = 0; iVar < nVar; iVar++) delete [] Mean_PrimVar_Grad[iVar]; delete [] Mean_PrimVar_Grad; @@ -57,7 +57,7 @@ void CSourceConservative_AdjFlow::ComputeResidual (su2double *val_residual, CCon unsigned short iDim, jDim, iVar; su2double rho, nu, Ji, fv1, fv2, Omega, Shat, dist_sq, Ji_2, Ji_3, one_o_oneplusJifv1; su2double r, g, g_6, glim, dfw_g, dg_r, dr_nuhat, dr_Shat, Ms_coeff, invOmega; - + su2double cv1_3 = 7.1*7.1*7.1; su2double k2 = 0.41*0.41; su2double cb1 = 0.1355; @@ -66,30 +66,30 @@ void CSourceConservative_AdjFlow::ComputeResidual (su2double *val_residual, CCon su2double sigma = 2./3.; su2double cb2 = 0.622; su2double cw1 = cb1/k2+(1+cb2)/sigma; - + for (iVar = 0; iVar < nVar; iVar++) { Residual_i[iVar] = 0.0; Residual_j[iVar] = 0.0; } - + /*--- iPoint ---*/ - + /*--- Density and velocities ---*/ - + rho = U_i[0]; for (iDim = 0; iDim < nDim; iDim++) Velocity[iDim] = U_i[iDim+1]/rho; - + /*--- Vorticity ---*/ - + Omega = (PrimVar_Grad_i[1][1]-PrimVar_Grad_i[2][0])*(PrimVar_Grad_i[1][1]-PrimVar_Grad_i[2][0]); if (nDim == 3) Omega += (PrimVar_Grad_i[1][2]-PrimVar_Grad_i[3][0])*(PrimVar_Grad_i[1][2]-PrimVar_Grad_i[3][0]) + (PrimVar_Grad_i[2][2]-PrimVar_Grad_i[3][1])*(PrimVar_Grad_i[2][2]-PrimVar_Grad_i[3][1]); Omega = sqrt(Omega); invOmega = 1.0/(Omega + TURB_EPS); - + /*--- Compute Ms_coeff -> coming from partial derivatives ---*/ - + Ms_coeff = 0.0; if (dist_i > 0) { dist_sq = dist_i*dist_i; @@ -101,23 +101,23 @@ void CSourceConservative_AdjFlow::ComputeResidual (su2double *val_residual, CCon one_o_oneplusJifv1 = 1.0/(1.0+Ji*fv1); fv2 = 1.0 - Ji*one_o_oneplusJifv1; Shat = max(Omega + TurbVar_i[0]*fv2/(k2*dist_sq), TURB_EPS); - + r = min(TurbVar_i[0]/(Shat*k2*dist_sq),10.); g = r + cw2*(pow(r,6.)-r); g_6 = pow(g,6.); glim = pow((1+cw3_6)/(g_6+cw3_6),1./6.); - + dfw_g = glim*cw3_6/(g_6+cw3_6); dg_r = 1.0 + cw2*(6.0*pow(r,5.0)-1.0); dr_nuhat = 1.0/(Shat*k2*dist_sq); dr_Shat = -dr_nuhat*TurbVar_i[0]/Shat; - + Ms_coeff = (cb1*TurbVar_i[0]-cw1*TurbVar_i[0]*TurbVar_i[0]/dist_sq*dfw_g*dg_r*dr_Shat); } Ms_coeff *= TurbPsi_i[0]*invOmega/rho; - + /*--- Compute residual of iPoint ---*/ - + for (iDim = 0; iDim < nDim; iDim++) { for (jDim = 0; jDim < nDim; jDim++) { Residual_i[0] -= Ms_coeff*(Velocity[jDim]*PrimVar_Grad_i[jDim+1][iDim]*Normal[iDim] - @@ -126,25 +126,25 @@ void CSourceConservative_AdjFlow::ComputeResidual (su2double *val_residual, CCon PrimVar_Grad_i[jDim+1][iDim]*Normal[jDim]); } } - + /*--- jPoint ---*/ - + /*--- Density and velocities ---*/ - + rho = U_j[0]; for (iDim = 0; iDim < nDim; iDim++) Velocity[iDim] = U_j[iDim+1]/rho; - + /*--- Vorticity ---*/ - + Omega = (PrimVar_Grad_j[1][1]-PrimVar_Grad_j[2][0])*(PrimVar_Grad_j[1][1]-PrimVar_Grad_j[2][0]); if (nDim == 3) Omega += (PrimVar_Grad_j[1][2]-PrimVar_Grad_j[3][0])*(PrimVar_Grad_j[1][2]-PrimVar_Grad_j[3][0]) + (PrimVar_Grad_j[2][2]-PrimVar_Grad_j[3][1])*(PrimVar_Grad_j[2][2]-PrimVar_Grad_j[3][1]); Omega = sqrt(Omega); invOmega = 1.0/(Omega + TURB_EPS); - + /*--- Compute Ms_coeff -> coming from partial derivatives ---*/ - + Ms_coeff = 0.0; if (dist_j > 0) { dist_sq = dist_j*dist_j; @@ -156,23 +156,23 @@ void CSourceConservative_AdjFlow::ComputeResidual (su2double *val_residual, CCon one_o_oneplusJifv1 = 1.0/(1.0+Ji*fv1); fv2 = 1.0 - Ji*one_o_oneplusJifv1; Shat = max(Omega + TurbVar_j[0]*fv2/(k2*dist_sq), TURB_EPS); - + r = min(TurbVar_j[0]/(Shat*k2*dist_sq),10.); g = r + cw2*(pow(r,6.)-r); g_6 = pow(g,6.); glim = pow((1+cw3_6)/(g_6+cw3_6),1./6.); - + dfw_g = glim*cw3_6/(g_6+cw3_6); dg_r = 1.0 + cw2*(6.0*pow(r,5.0)-1.0); dr_nuhat = 1.0/(Shat*k2*dist_sq); dr_Shat = -dr_nuhat*TurbVar_j[0]/Shat; - + Ms_coeff = (cb1*TurbVar_j[0]-cw1*TurbVar_j[0]*TurbVar_j[0]/dist_sq*dfw_g*dg_r*dr_Shat); } Ms_coeff *= TurbPsi_j[0]*invOmega/rho; - + /*--- Compute residual of jPoint ---*/ - + for (iDim = 0; iDim < nDim; iDim++) { for (jDim = 0; jDim < nDim; jDim++) { Residual_j[0] -= Ms_coeff*(Velocity[jDim]*PrimVar_Grad_j[jDim+1][iDim]*Normal[iDim] - @@ -181,10 +181,10 @@ void CSourceConservative_AdjFlow::ComputeResidual (su2double *val_residual, CCon PrimVar_Grad_j[jDim+1][iDim]*Normal[jDim]); } } - + /*--- Compute the mean residual ---*/ - + for (iVar = 0; iVar < nVar; iVar++) val_residual[iVar] = 0.5*(Residual_i[iVar] + Residual_j[iVar]); - + } diff --git a/SU2_CFD/src/numerics/continuous_adjoint/CSourceConservative_AdjTurb.cpp b/SU2_CFD/src/numerics/continuous_adjoint/CSourceConservative_AdjTurb.cpp index da6a7e674893..f6b5dc78ec9f 100644 --- a/SU2_CFD/src/numerics/continuous_adjoint/CSourceConservative_AdjTurb.cpp +++ b/SU2_CFD/src/numerics/continuous_adjoint/CSourceConservative_AdjTurb.cpp @@ -28,37 +28,37 @@ #include "../../../include/numerics/continuous_adjoint/CSourceConservative_AdjTurb.hpp" CSourceConservative_AdjTurb::CSourceConservative_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - + Gamma = config->GetGamma(); Gamma_Minus_One = Gamma - 1.0; - + } CSourceConservative_AdjTurb::~CSourceConservative_AdjTurb(void) { } void CSourceConservative_AdjTurb::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - + /*--- SOURCE term --> \nabla ( \psi_\mu \B7 E^{s} ) E^{s} = 2 c_{b2}/\sigma \nabla \hat{nu} ---*/ - + unsigned short iDim; bool implicit = (config->GetKind_TimeIntScheme_AdjTurb() == EULER_IMPLICIT); - + su2double cb2 = 0.622; su2double sigma = 2./3.; su2double coeff = 2.0*cb2/sigma; su2double E_ij, proj_TurbVar_Grad_i, proj_TurbVar_Grad_j; - + E_ij = 0.0; proj_TurbVar_Grad_i = 0.0; proj_TurbVar_Grad_j = 0.0; for (iDim = 0; iDim < nDim; iDim++) { proj_TurbVar_Grad_i += coeff*TurbVar_Grad_i[0][iDim]*Normal[iDim]; proj_TurbVar_Grad_j += coeff*TurbVar_Grad_j[0][iDim]*Normal[iDim]; E_ij += 0.5*(TurbPsi_i[0]*proj_TurbVar_Grad_i + TurbPsi_j[0]*proj_TurbVar_Grad_j); } - + val_residual[0] = E_ij; - + if (implicit) { val_Jacobian_i[0][0] = 0.5*proj_TurbVar_Grad_i; val_Jacobian_j[0][0] = 0.5*proj_TurbVar_Grad_j; diff --git a/SU2_CFD/src/numerics/continuous_adjoint/CSourcePieceWise_AdjTurb.cpp b/SU2_CFD/src/numerics/continuous_adjoint/CSourcePieceWise_AdjTurb.cpp index 89b869fbbe3c..ac467d1f28f5 100644 --- a/SU2_CFD/src/numerics/continuous_adjoint/CSourcePieceWise_AdjTurb.cpp +++ b/SU2_CFD/src/numerics/continuous_adjoint/CSourcePieceWise_AdjTurb.cpp @@ -28,10 +28,10 @@ #include "../../../include/numerics/continuous_adjoint/CSourcePieceWise_AdjTurb.hpp" CSourcePieceWise_AdjTurb::CSourcePieceWise_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - + Gamma = config->GetGamma(); Gamma_Minus_One = Gamma - 1.0; - + Velocity = new su2double [nDim]; tau = new su2double* [nDim]; for (unsigned short iDim = 0; iDim < nDim; iDim++) @@ -40,7 +40,7 @@ CSourcePieceWise_AdjTurb::CSourcePieceWise_AdjTurb(unsigned short val_nDim, unsi CSourcePieceWise_AdjTurb::~CSourcePieceWise_AdjTurb(void) { delete [] Velocity; - + for (unsigned short iDim = 0; iDim < nDim; iDim++) delete [] tau[iDim]; delete [] tau; @@ -48,29 +48,29 @@ CSourcePieceWise_AdjTurb::~CSourcePieceWise_AdjTurb(void) { void CSourcePieceWise_AdjTurb::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { unsigned short iDim, jDim; - + bool implicit = (config->GetKind_TimeIntScheme_AdjTurb() == EULER_IMPLICIT); su2double Prandtl_Turb = config->GetPrandtl_Turb(); - + val_residual[0] = 0.0; if (implicit) val_Jacobian_i[0][0] = 0.0; - + if (dist_i > 0.0) { - + /*--- Computation of Vorticity and Divergence of velocity ---*/ su2double div_vel = 0; for (iDim = 0; iDim < nDim; iDim++) { Velocity[iDim] = U_i[iDim+1]/U_i[0]; div_vel += PrimVar_Grad_i[iDim+1][iDim]; } - + su2double Vorticity = (PrimVar_Grad_i[2][0]-PrimVar_Grad_i[1][1])*(PrimVar_Grad_i[2][0]-PrimVar_Grad_i[1][1]); if (nDim == 3) Vorticity += ( (PrimVar_Grad_i[3][1]-PrimVar_Grad_i[2][2])*(PrimVar_Grad_i[3][1]-PrimVar_Grad_i[2][2]) + (PrimVar_Grad_i[1][2]-PrimVar_Grad_i[3][0])*(PrimVar_Grad_i[1][2]-PrimVar_Grad_i[3][0]) ); Vorticity = sqrt(Vorticity); - + /*--- FIRST PART: -Bs*TurbPsi_i ---*/ /*--- CLOUSURE CONSTANTS ---*/ su2double cv1 = 7.1; @@ -83,13 +83,13 @@ void CSourcePieceWise_AdjTurb::ComputeResidual(su2double *val_residual, su2doubl su2double sigma = 2./3.; su2double cb2 = 0.622; su2double cw1 = cb1/k2+(1+cb2)/sigma; - + su2double nu, Ji, fv1, fv2, Shat, dist_0_2, Ji_2, Ji_3, one_o_oneplusJifv1; su2double r, g, g_6, glim, fw; su2double dTs_nuhat, dTs_Shat, dShat_nuhat, dTs_fw, dfw_g, dg_r, dr_nuhat, dr_Shat; su2double dShat_fv2, dfv2_fv1, dfv1_Ji, dJi_nuhat, dfv2_Ji; su2double Bs; - + dist_0_2 = dist_i*dist_i; nu = Laminar_Viscosity_i/U_i[0]; Ji = TurbVar_i[0]/nu; @@ -99,14 +99,14 @@ void CSourcePieceWise_AdjTurb::ComputeResidual(su2double *val_residual, su2doubl one_o_oneplusJifv1 = 1.0/(1.0+Ji*fv1); fv2 = 1.0 - Ji*one_o_oneplusJifv1; Shat = max(Vorticity + TurbVar_i[0]*fv2/(k2*dist_0_2), TURB_EPS); - + // r = TurbVar_i[0]/(Shat*k2*dist_0_2); r = min(TurbVar_i[0]/(Shat*k2*dist_0_2),10.); g = r + cw2*(pow(r,6.)-r); g_6 = pow(g,6.); glim = pow((1+cw3_6)/(g_6+cw3_6),1./6.); fw = g*glim; - + dTs_nuhat = cb1*Shat-2.0*cw1*fw*TurbVar_i[0]/dist_0_2; dTs_Shat = cb1*TurbVar_i[0]; dTs_fw = -cw1*TurbVar_i[0]*TurbVar_i[0]/dist_0_2; @@ -114,7 +114,7 @@ void CSourcePieceWise_AdjTurb::ComputeResidual(su2double *val_residual, su2doubl dg_r = 1.0 + cw2*(6.0*pow(r,5.0)-1.0); dr_nuhat = 1.0/(Shat*k2*dist_0_2); dr_Shat = -dr_nuhat*TurbVar_i[0]/Shat; - + dShat_nuhat = fv2/(k2*dist_0_2); dShat_fv2 = TurbVar_i[0]/(k2*dist_0_2); dfv2_fv1 = Ji_2*one_o_oneplusJifv1*one_o_oneplusJifv1; @@ -122,33 +122,33 @@ void CSourcePieceWise_AdjTurb::ComputeResidual(su2double *val_residual, su2doubl dJi_nuhat = 1.0/nu; dfv2_Ji = -one_o_oneplusJifv1*one_o_oneplusJifv1; dShat_nuhat += dShat_fv2*(dfv2_fv1*dfv1_Ji+dfv2_Ji)*dJi_nuhat; - + Bs = dTs_nuhat; // nu_hat term Bs += dTs_Shat*dShat_nuhat; // S_hat term Bs += dTs_fw*dfw_g*dg_r*(dr_nuhat+dr_Shat*dShat_nuhat); // fw terms - + val_residual[0] = -Bs*TurbPsi_i[0]*Volume; - + if (implicit) val_Jacobian_i[0][0] = -Bs*Volume; - + /*---SECOND PART: \partial_nu_hat mu^k F^{vk} cdot \grad Psi ---*/ su2double dEddyVisc_nuhat; if (!config->GetFrozen_Visc_Cont()) dEddyVisc_nuhat = U_i[0]*fv1*(1.0 + 3.0*cv1_3/(Ji_3+cv1_3)); else dEddyVisc_nuhat = 0; - + for (iDim = 0; iDim < nDim; iDim++) { for (jDim = 0; jDim < nDim; jDim++) tau[iDim][jDim] = PrimVar_Grad_i[iDim+1][jDim] + PrimVar_Grad_i[jDim+1][iDim]; tau[iDim][iDim] -= TWO3*div_vel; } - + su2double Gas_Constant = config->GetGas_ConstantND(); su2double Cp = (Gamma/Gamma_Minus_One)*Gas_Constant; su2double tau_gradphi = 0.0, vel_tau_gradpsi5 = 0.0, gradT_gradpsi5 = 0.0; - + for (iDim = 0; iDim < nDim; iDim++) { gradT_gradpsi5 += PrimVar_Grad_i[0][iDim]*PsiVar_Grad_i[nVar-1][iDim]; for (jDim = 0; jDim < nDim; jDim++) { @@ -157,6 +157,6 @@ void CSourcePieceWise_AdjTurb::ComputeResidual(su2double *val_residual, su2doubl } } val_residual[0] += (tau_gradphi + vel_tau_gradpsi5 + Cp/Prandtl_Turb*gradT_gradpsi5)*dEddyVisc_nuhat*Volume; - + } } diff --git a/SU2_CFD/src/numerics/continuous_adjoint/CSourceRotatingFrame_AdjFlow.cpp b/SU2_CFD/src/numerics/continuous_adjoint/CSourceRotatingFrame_AdjFlow.cpp index 7669202ada3c..f893f72b4ce4 100644 --- a/SU2_CFD/src/numerics/continuous_adjoint/CSourceRotatingFrame_AdjFlow.cpp +++ b/SU2_CFD/src/numerics/continuous_adjoint/CSourceRotatingFrame_AdjFlow.cpp @@ -32,7 +32,7 @@ CSourceRotatingFrame_AdjFlow::CSourceRotatingFrame_AdjFlow(unsigned short val_nD CSourceRotatingFrame_AdjFlow::~CSourceRotatingFrame_AdjFlow(void) { } void CSourceRotatingFrame_AdjFlow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config) { - + unsigned short iDim, iVar, jVar; su2double Omega[3] = {0,0,0}, Phi[3] = {0,0,0}; bool implicit = (config->GetKind_TimeIntScheme_AdjFlow() == EULER_IMPLICIT); @@ -42,15 +42,15 @@ void CSourceRotatingFrame_AdjFlow::ComputeResidual(su2double *val_residual, su2d for (iDim = 0; iDim < 3; iDim++){ Omega[iDim] = config->GetRotation_Rate(iDim)/config->GetOmega_Ref(); } - + /*--- Get the adjoint velocity vector at the current node. ---*/ - + for (iDim = 0; iDim < nDim; iDim++) Phi[iDim] = Psi_i[iDim+1]; - + /*--- Compute the source term as the Jacobian of the rotating frame source term multiplied by the adjoint state and the dual cell volume. ---*/ - + if (nDim == 2) { val_residual[0] = 0.0; val_residual[1] = Omega[2]*Phi[1]*Volume; @@ -63,9 +63,9 @@ void CSourceRotatingFrame_AdjFlow::ComputeResidual(su2double *val_residual, su2d val_residual[3] = (Omega[1]*Phi[0] - Omega[0]*Phi[1])*Volume; val_residual[4] = 0.0; } - + /*--- Calculate the source term Jacobian ---*/ - + if (implicit) { for (iVar = 0; iVar < nVar; iVar++) for (jVar = 0; jVar < nVar; jVar++) @@ -82,5 +82,5 @@ void CSourceRotatingFrame_AdjFlow::ComputeResidual(su2double *val_residual, su2d val_Jacobian_i[3][2] = -Omega[0]*Volume; } } - + } diff --git a/SU2_CFD/src/numerics/continuous_adjoint/CSourceViscous_AdjFlow.cpp b/SU2_CFD/src/numerics/continuous_adjoint/CSourceViscous_AdjFlow.cpp index 47e7bf9f2c42..f792a8d0450f 100644 --- a/SU2_CFD/src/numerics/continuous_adjoint/CSourceViscous_AdjFlow.cpp +++ b/SU2_CFD/src/numerics/continuous_adjoint/CSourceViscous_AdjFlow.cpp @@ -29,10 +29,10 @@ CSourceViscous_AdjFlow::CSourceViscous_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { unsigned short iDim; - + Gamma = config->GetGamma(); Gamma_Minus_One = Gamma - 1.0; - + Velocity = new su2double [nVar]; GradDensity = new su2double [nDim]; GradInvDensity = new su2double [nDim]; @@ -40,13 +40,13 @@ CSourceViscous_AdjFlow::CSourceViscous_AdjFlow(unsigned short val_nDim, unsigned alpha = new su2double [nDim]; beta = new su2double [nDim]; Sigma_5_vec = new su2double [nDim]; - + GradVel_o_Rho = new su2double* [nDim]; sigma = new su2double* [nDim]; Sigma_phi = new su2double* [nDim]; Sigma_5_Tensor = new su2double* [nDim]; Sigma = new su2double* [nDim]; - + for (iDim = 0; iDim < nDim; iDim++) { GradVel_o_Rho[iDim] = new su2double [nDim]; sigma[iDim] = new su2double [nDim]; @@ -54,12 +54,12 @@ CSourceViscous_AdjFlow::CSourceViscous_AdjFlow(unsigned short val_nDim, unsigned Sigma_5_Tensor[iDim] = new su2double [nDim]; Sigma[iDim] = new su2double [nDim]; } - + } CSourceViscous_AdjFlow::~CSourceViscous_AdjFlow(void) { unsigned short iDim; - + for (iDim = 0; iDim < nDim; iDim++) { delete [] GradVel_o_Rho[iDim]; delete [] sigma[iDim]; @@ -67,13 +67,13 @@ CSourceViscous_AdjFlow::~CSourceViscous_AdjFlow(void) { delete [] Sigma_5_Tensor[iDim]; delete [] Sigma[iDim]; } - + delete [] GradVel_o_Rho; delete [] sigma; delete [] Sigma_phi; delete [] Sigma_5_Tensor; delete [] Sigma; - + delete [] Velocity; delete [] GradDensity; delete [] GradInvDensity; @@ -81,20 +81,20 @@ CSourceViscous_AdjFlow::~CSourceViscous_AdjFlow(void) { delete [] alpha; delete [] beta; delete [] Sigma_5_vec; - + } void CSourceViscous_AdjFlow::ComputeResidual (su2double *val_residual, CConfig *config) { - + unsigned short iDim, jDim; - + // su2double Temperature = V_i[0]; su2double Pressure = V_i[nDim+1]; su2double Density = V_i[nDim+2]; // su2double Enthalpy = V_i[nDim+3]; su2double Laminar_Viscosity = V_i[nDim+5]; su2double Eddy_Viscosity = V_i[nDim+6]; - + // su2double Energy = Enthalpy - Pressure/Density; su2double invDensity = 1.0/Density; su2double invDensitysq = invDensity*invDensity; @@ -104,33 +104,33 @@ void CSourceViscous_AdjFlow::ComputeResidual (su2double *val_residual, CConfig * su2double mu_tot_1 = Laminar_Viscosity + Eddy_Viscosity; su2double mu_tot_2 = Laminar_Viscosity/Prandtl_Lam + Eddy_Viscosity/Prandtl_Turb; // su2double Gas_Constant = config->GetGas_ConstantND(); - + /*--- Required gradients of the flow variables, point j ---*/ - + for (iDim = 0; iDim < nDim; iDim++) { - + /*--- Gradient density ---*/ - + GradDensity[iDim] = PrimVar_Grad_i[nDim+2][iDim]; - + /*--- Gradient (1/rho) ---*/ - + GradInvDensity[iDim] = -GradDensity[iDim]*invDensitysq; - + /*--- Computation of the derivatives of P/(Density^2) ---*/ - + dPoDensity2[iDim] = (PrimVar_Grad_i[nVar-1][iDim]*Density - 2.0*GradDensity[iDim]*Pressure)*invDensitycube; - + /*--- Abbreviations: alpha, beta, sigma_5_vec ---*/ - + alpha[iDim] = Gamma*mu_tot_2*GradInvDensity[iDim]; beta[iDim] = Gamma*mu_tot_2*dPoDensity2[iDim]/Gamma_Minus_One; Sigma_5_vec[iDim] = Gamma*mu_tot_2*PsiVar_Grad_i[nVar-1][iDim]; - + } - + /*--- Definition of tensors and derivatives of velocity over density ---*/ - + su2double div_vel = 0.0, div_phi = 0.0, vel_gradpsi5 = 0.0; for (iDim = 0; iDim < nDim; iDim++) { div_vel += PrimVar_Grad_i[iDim+1][iDim]; @@ -143,21 +143,21 @@ void CSourceViscous_AdjFlow::ComputeResidual (su2double *val_residual, CConfig * GradVel_o_Rho[iDim][jDim] = (PrimVar_Grad_i[iDim+1][jDim]*Density - V_i[iDim+1]*GradDensity[jDim])*invDensitysq; } } - + for (iDim = 0; iDim < nDim; iDim++) { sigma[iDim][iDim] -= TWO3*mu_tot_1*div_vel; Sigma_phi[iDim][iDim] -= TWO3*mu_tot_1*div_phi; Sigma_5_Tensor[iDim][iDim] -= TWO3*mu_tot_1*vel_gradpsi5; } - + for (iDim = 0; iDim < nDim; iDim++) { for (jDim = 0; jDim < nDim; jDim++) { Sigma[iDim][jDim] = Sigma_phi[iDim][jDim] + Sigma_5_Tensor[iDim][jDim]; } } - + /*--- Vector-Tensors products ---*/ - + su2double gradT_gradpsi5 = 0.0, sigma_gradpsi = 0.0, vel_sigma_gradpsi5 = 0.0; for (iDim = 0; iDim < nDim; iDim++) { gradT_gradpsi5 += PrimVar_Grad_i[0][iDim]*PsiVar_Grad_i[nVar-1][iDim]; @@ -166,9 +166,9 @@ void CSourceViscous_AdjFlow::ComputeResidual (su2double *val_residual, CConfig * vel_sigma_gradpsi5 += V_i[iDim+1]*sigma[iDim][jDim]*PsiVar_Grad_i[nVar-1][jDim]; } } - + /*--- Residuals ---*/ - + su2double alpha_gradpsi5 = 0.0, beta_gradpsi5 = 0.0, Sigma_gradvel_o_rho = 0.0, Sigma5_vel_gradvel = 0.0, sq_vel = 0.0; for (iDim = 0; iDim < nDim; iDim++) { alpha_gradpsi5 += alpha[iDim]*PsiVar_Grad_i[nVar-1][iDim]; @@ -179,7 +179,7 @@ void CSourceViscous_AdjFlow::ComputeResidual (su2double *val_residual, CConfig * } sq_vel += V_i[iDim+1]*V_i[iDim+1]; } - + val_residual[0] = (-vel_sigma_gradpsi5*invDensity + 0.5*sq_vel*alpha_gradpsi5 - beta_gradpsi5) * Volume; for (iDim = 0; iDim < nDim; iDim++) { @@ -189,7 +189,7 @@ void CSourceViscous_AdjFlow::ComputeResidual (su2double *val_residual, CConfig * } } val_residual[nVar-1] = alpha_gradpsi5 * Volume; - + // val_residual[0] += (Sigma5_vel_gradvel*invDensity - Sigma_gradvel_o_rho) * Volume; // for (iDim = 0; iDim < nDim; iDim++) { // for (jDim = 0; jDim < nDim; jDim++) { @@ -197,36 +197,36 @@ void CSourceViscous_AdjFlow::ComputeResidual (su2double *val_residual, CConfig * // Sigma_5_vec[jDim]*PrimVar_Grad_i[iDim+1][jDim]*invDensity) * Volume; // } // } - + /*--- Laminar viscosity sensitivity for NS ---*/ - + if (config->GetKind_Solver() != ADJ_RANS) { - + // su2double Temperature_Ref = config->GetTemperature_Ref(); // su2double Temperature_Dim = Temperature*Temperature_Ref; -// +// // su2double S = 0.0; // if (config->GetSystemMeasurements() == SI) { S = 110.4; } // if (config->GetSystemMeasurements() == US) { S = 198.72; } // su2double dVisc_T = ((Laminar_Viscosity)/(2.0*Temperature_Dim*(Temperature_Dim + S)))*(Temperature_Dim + 3.0*S)*Temperature_Ref; -// +// // su2double Cp = (Gamma/Gamma_Minus_One)*Gas_Constant; // su2double kappa_psi = (sigma_gradpsi + vel_sigma_gradpsi5)/mu_tot_1; // su2double theta = (kappa_psi + Cp/Prandtl_Lam*gradT_gradpsi5)*dVisc_T*Gamma_Minus_One/(Gas_Constant*Density); -// +// // val_residual[0] += (theta*(sq_vel-Energy))*Volume; // for (iDim = 0; iDim < nDim; iDim++) // val_residual[iDim+1] -= theta*V_i[iDim+1]*Volume; // val_residual[nVar-1] += theta*Volume; - + } - + // /*--- Coupling terms coming from the continuous adjoint turbulent equations ---*/ -// +// // if ((config->GetKind_Solver() == ADJ_RANS) && (!config->GetFrozen_Visc_Cont())) { -// +// // /*--- Closure constants ---*/ -// +// // su2double cv1_3 = 7.1*7.1*7.1; // su2double k2 = 0.41*0.41; // su2double cb1 = 0.1355; @@ -235,92 +235,92 @@ void CSourceViscous_AdjFlow::ComputeResidual (su2double *val_residual, CConfig * // su2double sigma = 2./3.; // su2double cb2 = 0.622; // su2double cw1 = cb1/k2+(1+cb2)/sigma; -// +// // su2double nu, Ji, Ji_2, Ji_3, fv1; // nu = Laminar_Viscosity/Density; // Ji = TurbVar_i[0]/nu; // Ji_2 = Ji*Ji; // Ji_3 = Ji_2*Ji; // fv1 = Ji_3/(Ji_3+cv1_3); -// +// // /*--- Contributions due to variation of viscosities ---*/ -// +// // su2double Temperature_Ref = config->GetTemperature_Ref(); // su2double Temperature_Dim = Temperature*Temperature_Ref; -// +// // su2double S = 0.0; // if (config->GetSystemMeasurements() == SI) { S = 110.4; } // if (config->GetSystemMeasurements() == US) { S = 198.72; } // su2double dVisc_T = ((Laminar_Viscosity)/(2.0*Temperature_Dim*(Temperature_Dim + S)))*(Temperature_Dim + 3.0*S)*Temperature_Ref; -// +// // su2double Cp = (Gamma/Gamma_Minus_One)*Gas_Constant; // su2double kappa_psi = (sigma_gradpsi + vel_sigma_gradpsi5)/mu_tot_1 + Cp/Prandtl_Turb*gradT_gradpsi5; // su2double cv1_const = 3.0*cv1_3/(Ji_3+cv1_3); // su2double theta = (kappa_psi*(1.0-Eddy_Viscosity/Laminar_Viscosity*cv1_const) - // Cp/Prandtl_Turb*gradT_gradpsi5*(1.0-Prandtl_Turb/Prandtl_Lam))*dVisc_T*Gamma_Minus_One/(Gas_Constant*Density); // su2double xi = kappa_psi*(1.0+cv1_const)*Eddy_Viscosity/Density; -// +// // val_residual[0] += (theta*(sq_vel-Energy) + xi)*Volume; // for (iDim = 0; iDim < nDim; iDim++) // val_residual[iDim+1] -= theta*V_i[iDim+1]*Volume; // val_residual[nVar-1] += theta*Volume; -// +// // /*--- Coupling residuals ---*/ -// +// // if (dist_i > 0.0) { // su2double fv2, Omega, Shat, dist_0_2, one_o_oneplusJifv1; // su2double r, g, g_6, glim, fw; // su2double dfw_g, dg_r, dr_nuhat, dr_Shat; // su2double dShat_fv2, dfv2_fv1, dfv1_Ji, dJi_nu, dJi_nuhat, dfv2_Ji; -// +// // /*--- Vorticity ---*/ // Omega = (PrimVar_Grad_i[1][1]-PrimVar_Grad_i[2][0])*(PrimVar_Grad_i[1][1]-PrimVar_Grad_i[2][0]); // if (nDim == 3) Omega += (PrimVar_Grad_i[1][2]-PrimVar_Grad_i[3][0])*(PrimVar_Grad_i[1][2]-PrimVar_Grad_i[3][0]) + // (PrimVar_Grad_i[2][2]-PrimVar_Grad_i[3][1])*(PrimVar_Grad_i[2][2]-PrimVar_Grad_i[3][1]); // Omega = sqrt(Omega); -// +// // dist_0_2 = dist_i*dist_i; // one_o_oneplusJifv1 = 1.0/(1.0+Ji*fv1); // fv2 = 1.0 - Ji*one_o_oneplusJifv1; // Shat = max(Omega + TurbVar_i[0]*fv2/(k2*dist_0_2), TURB_EPS); -// +// // r = min(TurbVar_i[0]/(Shat*k2*dist_0_2), 10.); // g = r + cw2*(pow(r,6.)-r); // g_6 = pow(g,6.); // glim = pow((1+cw3_6)/(g_6+cw3_6),1./6.); // fw = g*glim; -// +// // dfw_g = glim*cw3_6/(g_6+cw3_6); // dg_r = 1.0 + cw2*(6.0*pow(r,5.0)-1.0); // dr_nuhat = 1.0/(Shat*k2*dist_0_2); // dr_Shat = -dr_nuhat*TurbVar_i[0]/Shat; -// +// // dShat_fv2 = TurbVar_i[0]/(k2*dist_0_2); // dfv2_fv1 = Ji_2*one_o_oneplusJifv1*one_o_oneplusJifv1; // dfv1_Ji = 3.0*cv1_3*Ji_2/((Ji_3+cv1_3)*(Ji_3+cv1_3)); // dJi_nuhat = 1.0/nu; // dJi_nu = -Ji/nu; // dfv2_Ji = -one_o_oneplusJifv1*one_o_oneplusJifv1; -// +// // /*--- Terms 1 & 2: -Fcv\B7nabla(TurbPsi_i) - Fs\B7TurbPsi_i ---*/ -// +// // su2double gradTurbVar_gradTurbPsi = 0, vel_gradTurbPsi = 0; // for (iDim = 0; iDim < nDim; iDim++) { // gradTurbVar_gradTurbPsi += TurbVar_Grad_i[0][iDim]*TurbPsi_Grad_i[0][iDim]; // vel_gradTurbPsi += V_i[iDim+1]*TurbPsi_Grad_i[0][iDim]; // } -// +// // su2double alpha_coeff = Gamma_Minus_One/(Gas_Constant*Density)*dVisc_T; // su2double beta_coeff = alpha_coeff*(sq_vel-Energy)-Laminar_Viscosity_i/Density; // su2double Fs_coeff = TurbPsi_i[0]*(cb1*TurbVar_i[0]-cw1*TurbVar_i[0]*TurbVar_i[0]/dist_0_2*dfw_g*dg_r*dr_Shat)* // dShat_fv2*(dfv2_Ji+dfv2_fv1*dfv1_Ji)*dJi_nu; // su2double Gamma = Fs_coeff - gradTurbVar_gradTurbPsi/sigma; -// +// // val_residual[0] -= (Gamma*beta_coeff - TurbVar_i[0]*vel_gradTurbPsi)/Density*Volume; // for (iDim = 0; iDim < nDim; iDim++) // val_residual[iDim+1] += (Gamma*alpha_coeff*V_i[iDim+1] - TurbVar_i[0]*TurbPsi_Grad_i[0][iDim])/Density*Volume; // val_residual[nVar-1] -= (Gamma*alpha_coeff)/Density*Volume; -// +// // // this should improve stability (when commented): // /*--- Terms 3: -partial{T^s}_GradVel x GradN ---*/ // // su2double Ms_coeff = (cb1*TurbVar_i[0]-cw1*TurbVar_i[0]*TurbVar_i[0]/dist_0_2*dfw_g*dg_r*dr_Shat); @@ -334,7 +334,7 @@ void CSourceViscous_AdjFlow::ComputeResidual (su2double *val_residual, CConfig * // // GradInvDensity[jDim]*dV; // // } // // } -// +// // } // } diff --git a/SU2_CFD/src/numerics/continuous_adjoint/CUpwLin_AdjTurb.cpp b/SU2_CFD/src/numerics/continuous_adjoint/CUpwLin_AdjTurb.cpp index ee2f322a9fe2..30336106d98e 100644 --- a/SU2_CFD/src/numerics/continuous_adjoint/CUpwLin_AdjTurb.cpp +++ b/SU2_CFD/src/numerics/continuous_adjoint/CUpwLin_AdjTurb.cpp @@ -28,10 +28,10 @@ #include "../../../include/numerics/continuous_adjoint/CUpwLin_AdjTurb.hpp" CUpwLin_AdjTurb::CUpwLin_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - + Gamma = config->GetGamma(); Gamma_Minus_One = Gamma - 1.0; - + Velocity_i = new su2double [nDim]; } @@ -41,13 +41,13 @@ CUpwLin_AdjTurb::~CUpwLin_AdjTurb(void) { void CUpwLin_AdjTurb::ComputeResidual (su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { bool implicit = (config->GetKind_TimeIntScheme_AdjTurb() == EULER_IMPLICIT); - + /*--- Non-conservative term --> -\nabla \psi_\mu B^{cv} B^{cv} = -v ---*/ - + unsigned short iDim; su2double proj_conv_flux = 0; - + for (iDim = 0; iDim < nDim; iDim++) { Velocity_i[iDim] = U_i[iDim+1]/U_i[0]; proj_conv_flux += Velocity_i[iDim]*Normal[iDim]; // projection of convective flux at iPoint @@ -58,7 +58,7 @@ void CUpwLin_AdjTurb::ComputeResidual (su2double *val_residual, su2double **val_ psinu1 = psinu0 + proj_conv_flux; else psinu1 = psinu0; - + val_residual[0] = 0.5*( proj_conv_flux*(psinu0+psinu1)-fabs(proj_conv_flux)*(psinu1-psinu0)); if (implicit) { val_Jacobian_i[0][0] = 0.5*( proj_conv_flux + fabs(proj_conv_flux)); diff --git a/SU2_CFD/src/numerics/continuous_adjoint/CUpwRoe_AdjFlow.cpp b/SU2_CFD/src/numerics/continuous_adjoint/CUpwRoe_AdjFlow.cpp index 6c5e6530ceb2..89e1690b3e39 100644 --- a/SU2_CFD/src/numerics/continuous_adjoint/CUpwRoe_AdjFlow.cpp +++ b/SU2_CFD/src/numerics/continuous_adjoint/CUpwRoe_AdjFlow.cpp @@ -28,13 +28,13 @@ #include "../../../include/numerics/continuous_adjoint/CUpwRoe_AdjFlow.hpp" CUpwRoe_AdjFlow::CUpwRoe_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - + implicit = (config->GetKind_TimeIntScheme_AdjFlow() == EULER_IMPLICIT); grid_movement = config->GetGrid_Movement(); - + Gamma = config->GetGamma(); Gamma_Minus_One = Gamma - 1.0; - + Residual_Roe = new su2double [nVar]; RoeVelocity = new su2double [nDim]; Velocity_i = new su2double [nDim]; @@ -52,11 +52,11 @@ CUpwRoe_AdjFlow::CUpwRoe_AdjFlow(unsigned short val_nDim, unsigned short val_nVa ProjFlux_j[iVar] = new su2double[nVar]; Proj_ModJac_Tensor[iVar] = new su2double[nVar]; } - + } CUpwRoe_AdjFlow::~CUpwRoe_AdjFlow(void) { - + delete [] Residual_Roe; delete [] RoeVelocity; delete [] Velocity_i; @@ -74,130 +74,130 @@ CUpwRoe_AdjFlow::~CUpwRoe_AdjFlow(void) { delete [] ProjFlux_i; delete [] ProjFlux_j; delete [] Proj_ModJac_Tensor; - + } void CUpwRoe_AdjFlow::ComputeResidual (su2double *val_residual_i, su2double *val_residual_j, su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config) { - + /*--- Compute the area ---*/ - + area = 0.0; for (iDim = 0; iDim < nDim; iDim++) area += Normal[iDim]*Normal[iDim]; area = sqrt(area); rarea = 1.0 / area; - + /*--- Components of the normal & unit normal vector of the current face ---*/ - + Sx = Normal[0]; Sy = Normal[1]; Sz = 0.0; if (nDim == 3) Sz = Normal[2]; nx = Sx * rarea; ny = Sy * rarea; nz = Sz * rarea; - + /*--- Flow variable states at point i (left, _l) and j (right, _r)---*/ - + rho_l = V_i[nDim+2]; rho_r = V_j[nDim+2]; u_l = V_i[1]; v_l = V_i[2]; w_l = 0.0; if (nDim == 3) w_l = V_i[3]; u_r = V_j[1]; v_r = V_j[2]; w_r = 0.0; if (nDim == 3) w_r = V_j[3]; h_l = V_i[nDim+3]; h_r = V_j[nDim+3]; - + /*--- One-half speed squared ---*/ - + q_l = ONE2 * ((u_l*u_l) + (v_l*v_l) + (w_l*w_l)); q_r = ONE2 * ((u_r*u_r) + (v_r*v_r) + (w_r*w_r)); - + /*--- Projected velocity ---*/ - + Q_l = (u_l * Sx) + (v_l * Sy) + (w_l * Sz); Q_r = (u_r * Sx) + (v_r * Sy) + (w_r * Sz); - + /*--- Mean adjoint variables ---*/ - + psi1 = ONE2 * (Psi_i[0] + Psi_j[0]); psi2 = ONE2 * (Psi_i[1] + Psi_j[1]); psi3 = ONE2 * (Psi_i[2] + Psi_j[2]); psi4 = 0.0; if (nDim == 3) psi4 = ONE2 * (Psi_i[3] + Psi_j[3]); psi5 = ONE2 * (Psi_i[nVar-1] + Psi_j[nVar-1]); - + /*--- Left state ---*/ - + l1psi = (Sx * psi2) + (Sy * psi3) + (Sz * psi4) + (Q_l * psi5); l2psi = psi1 + (u_l * psi2) + (v_l * psi3) + (w_l * psi4) + (h_l * psi5); - + val_residual_i[0] = Q_l * psi1 - l2psi * Q_l + l1psi * Gamma_Minus_One * q_l; val_residual_i[1] = Q_l * psi2 + l2psi * Sx - l1psi * Gamma_Minus_One * u_l; val_residual_i[2] = Q_l * psi3 + l2psi * Sy - l1psi * Gamma_Minus_One * v_l; if (nDim == 3) val_residual_i[3] = Q_l * psi4 + l2psi * Sz - l1psi * Gamma_Minus_One * w_l; val_residual_i[nVar-1] = Q_l * psi5 + l1psi * Gamma_Minus_One; - + /*--- Right state ---*/ - + l1psi = (Sx * psi2) + (Sy * psi3) + (Sz * psi4) + (Q_r * psi5); l2psi = psi1 + (u_r * psi2) + (v_r * psi3) + (w_r * psi4) + (h_r * psi5); - + val_residual_j[0] = -(Q_r * psi1 - l2psi * Q_r + l1psi * Gamma_Minus_One * q_r); val_residual_j[1] = -(Q_r * psi2 + l2psi * Sx - l1psi * Gamma_Minus_One * u_r); val_residual_j[2] = -(Q_r * psi3 + l2psi * Sy - l1psi * Gamma_Minus_One * v_r); if (nDim == 3) val_residual_j[3] = -(Q_r * psi4 + l2psi * Sz - l1psi * Gamma_Minus_One * w_r); val_residual_j[nVar-1] = -(Q_r * psi5 + l1psi * Gamma_Minus_One); - - + + /*--- f_{roe} = P^{-T} |lambda| P^T \delta \psi ---*/ - + psi1_l = Psi_i[0]; psi2_l = Psi_i[1]; psi3_l = Psi_i[2]; psi4_l = 0.0; if (nDim == 3) psi4_l = Psi_i[3]; psi5_l = Psi_i[nVar-1]; - + psi1_r = Psi_j[0]; psi2_r = Psi_j[1]; psi3_r = Psi_j[2]; psi4_r = 0.0; if (nDim == 3) psi4_r = Psi_j[3]; psi5_r = Psi_j[nVar-1]; - + /*--- Roe averaging ---*/ - + rrho_l = 1.0 / rho_l; weight = sqrt(rho_r * rrho_l); rweight1 = 1.0 / (1.0 + weight); weight *= rweight1; - + h = h_l * rweight1 + weight * h_r; u = u_l * rweight1 + weight * u_r; v = v_l * rweight1 + weight * v_r; w = w_l * rweight1 + weight * w_r; - + psi1 = ONE2 * (psi1_r - psi1_l); psi2 = ONE2 * (psi2_r - psi2_l); psi3 = ONE2 * (psi3_r - psi3_l); psi4 = ONE2 * (psi4_r - psi4_l); psi5 = ONE2 * (psi5_r - psi5_l); - + q2 = (u*u) + (v*v) + (w*w); Q = (u * Sx) + (v * Sy) + (w * Sz); vn = nx * u + ny * v + nz * w; cc = Gamma_Minus_One * h - 0.5 * Gamma_Minus_One * q2; c = sqrt(cc); - + /*--- Contribution to velocity projection due to grid movement ---*/ - + if (grid_movement) { su2double ProjGridVel = 0.0; for (iDim = 0; iDim < nDim; iDim++) ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; Q -= ProjGridVel; } - + /*--- Eigenvalues from the primal solution ---*/ - + absQ = fabs(Q); absQp = fabs(Q + c * area); absQm = fabs(Q - c * area); - + alpha = ONE2 * Gamma_Minus_One * q2 / cc; beta_u = psi2 + u * psi5; beta_v = psi3 + v * psi5; @@ -207,35 +207,35 @@ void CUpwRoe_AdjFlow::ComputeResidual (su2double *val_residual_i, su2double *val l2psi = psi1 + (u * psi2) + (v * psi3) + (w * psi4) + (h * psi5); l1l2p = (l2psi + c * l1psi) * absQp; l1l2m = (l2psi - c * l1psi) * absQm; - + /*--- adjoint flux computation in the x, y and z coordinate system ---*/ - + Residual_Roe[0] = ((1.0-alpha)*l2psi - (1.0-alpha)*cc/Gamma_Minus_One*psi5 - u*beta_u*(1.0-(nx*nx)) - v*beta_v*(1.0-(ny*ny)) - w*beta_w*(1.0-(nz*nz)) + ny*nz*(w*beta_v + v*beta_w) + nx*nz*(w*beta_u + u*beta_w) + ny*nx*(v*beta_u + u*beta_v) ) * absQ - ONE2 / c * vn * (l1l2p - l1l2m) + ONE2 * alpha * (l1l2p + l1l2m); - + Residual_Roe[1] = (l2psi*u*eta - u*psi5 + beta_u*(1.0-(nx*nx)) - nx*(beta_v*ny + beta_w*nz) ) * absQ + ONE2*nx/c * (l1l2p - l1l2m ) - ONE2*eta*u * (l1l2p + l1l2m ); - + Residual_Roe[2] = (l2psi*v*eta - v*psi5 + beta_v*(1.0-(ny*ny)) - ny*(beta_w*nz + beta_u*nx) ) * absQ + ONE2*ny/c * (l1l2p - l1l2m ) - ONE2*eta*v * (l1l2p + l1l2m ); - + if (nDim == 3) Residual_Roe[3] = (l2psi*w*eta - w*psi5 + beta_w*(1.0-(nz*nz)) - nz*(beta_u*nx + beta_v*ny) ) * absQ + ONE2*nz/c * (l1l2p - l1l2m ) - ONE2*eta*w * (l1l2p + l1l2m ); - + Residual_Roe[nVar-1] = (psi5 - l2psi*eta) * absQ + ONE2*eta*(l1l2p + l1l2m); - + for (iVar = 0; iVar < nVar; iVar++) { val_residual_i[iVar] += Residual_Roe[iVar]; val_residual_j[iVar] -= Residual_Roe[iVar]; } - + /*--- Flux contribution due to grid movement ---*/ - + if (grid_movement) { su2double ProjGridVel = 0.0; for (iDim = 0; iDim < nDim; iDim++) @@ -245,20 +245,20 @@ void CUpwRoe_AdjFlow::ComputeResidual (su2double *val_residual_i, su2double *val val_residual_j[iVar] += ProjGridVel * 0.5*(Psi_i[iVar]+Psi_j[iVar]); } } - + /*--- Implicit Contributions ---*/ - + if (implicit) { - + /*--- Prepare variables for use in matrix routines ---*/ - + RoeDensity = V_i[nDim+2]*sqrt(V_j[nDim+2]/V_i[nDim+2]); RoeSoundSpeed = c; UnitNormal[0] = nx; UnitNormal[1] = ny; if (nDim == 3 ) UnitNormal[2] = nz; RoeVelocity[0] = u; RoeVelocity[1] = v; if (nDim == 3 ) RoeVelocity[2] = w; Velocity_i[0] = u_l; Velocity_i[1] = v_l; if (nDim == 3 ) Velocity_i[2] = w_l; Velocity_j[0] = u_r; Velocity_j[1] = v_r; if (nDim == 3 ) Velocity_j[2] = w_r; - + Pressure_i = V_i[nDim+1]; Density_i = V_i[nDim+2]; Enthalpy_i = V_i[nDim+3]; @@ -268,42 +268,42 @@ void CUpwRoe_AdjFlow::ComputeResidual (su2double *val_residual_i, su2double *val Density_j = V_i[nDim+2]; Enthalpy_j = V_i[nDim+3]; Energy_j = Enthalpy_j - Pressure_j/Density_j; - + /*--- Jacobians of the inviscid flux, scaled by 0.5 because val_resconv ~ 0.5*(fc_i+fc_j)*Normal ---*/ - + GetInviscidProjJac(Velocity_i, &Energy_i, Normal, 0.5, ProjFlux_i); GetInviscidProjJac(Velocity_j, &Energy_j, Normal, 0.5, ProjFlux_j); - + /*--- Compute P, inverse P, and store eigenvalues ---*/ - + GetPMatrix_inv(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, invP_Tensor); GetPMatrix(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, P_Tensor); - + /*--- Flow eigenvalues ---*/ - + for (iDim = 0; iDim < nDim; iDim++) Lambda[iDim] = absQ; Lambda[nVar-2] = absQp; Lambda[nVar-1] = absQm; - + /*--- Roe's Flux approximation ---*/ - + for (iVar = 0; iVar < nVar; iVar++) { for (jVar = 0; jVar < nVar; jVar++) { Proj_ModJac_Tensor_ij = 0.0; - + /*--- Compute |Proj_ModJac_Tensor| = P x |Lambda| x inverse P ---*/ - + for (kVar = 0; kVar < nVar; kVar++) Proj_ModJac_Tensor_ij += P_Tensor[iVar][kVar]*Lambda[kVar]*invP_Tensor[kVar][jVar]; Proj_ModJac_Tensor[iVar][jVar] = 0.5*Proj_ModJac_Tensor_ij*area; } } - + /*--- Transpose the matrices and store the Jacobians. Note the negative sign for the ji and jj Jacobians bc the normal direction is flipped. ---*/ - + for (iVar = 0; iVar < nVar; iVar++) { for (jVar = 0; jVar < nVar; jVar++) { val_Jacobian_ii[jVar][iVar] = ProjFlux_i[iVar][jVar] - Proj_ModJac_Tensor[iVar][jVar]; @@ -312,23 +312,23 @@ void CUpwRoe_AdjFlow::ComputeResidual (su2double *val_residual_i, su2double *val val_Jacobian_jj[jVar][iVar] = -(ProjFlux_j[iVar][jVar] + Proj_ModJac_Tensor[iVar][jVar]); } } - + /*--- Jacobian contribution due to grid movement ---*/ - + if (grid_movement) { su2double ProjGridVel = 0.0; for (iDim = 0; iDim < nDim; iDim++) ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; for (iVar = 0; iVar < nVar; iVar++) { - + /*--- Adjust Jacobian main diagonal ---*/ - + val_Jacobian_ii[iVar][iVar] -= 0.5*ProjGridVel; val_Jacobian_ij[iVar][iVar] -= 0.5*ProjGridVel; val_Jacobian_ji[iVar][iVar] += 0.5*ProjGridVel; val_Jacobian_jj[iVar][iVar] += 0.5*ProjGridVel; } } - + } } diff --git a/SU2_CFD/src/numerics/continuous_adjoint/CUpwSca_AdjTurb.cpp b/SU2_CFD/src/numerics/continuous_adjoint/CUpwSca_AdjTurb.cpp index cc3c9ee6ab9b..40d70c9a9c26 100644 --- a/SU2_CFD/src/numerics/continuous_adjoint/CUpwSca_AdjTurb.cpp +++ b/SU2_CFD/src/numerics/continuous_adjoint/CUpwSca_AdjTurb.cpp @@ -28,10 +28,10 @@ #include "../../../include/numerics/continuous_adjoint/CUpwSca_AdjTurb.hpp" CUpwSca_AdjTurb::CUpwSca_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - + Gamma = config->GetGamma(); Gamma_Minus_One = Gamma - 1.0; - + Velocity_i = new su2double [nDim]; Velocity_j = new su2double [nDim]; } @@ -44,16 +44,16 @@ CUpwSca_AdjTurb::~CUpwSca_AdjTurb(void) { void CUpwSca_AdjTurb::ComputeResidual (su2double *val_residual_i, su2double *val_residual_j, su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config) { - + bool implicit = (config->GetKind_TimeIntScheme_AdjTurb() == EULER_IMPLICIT); - + /*--- Non-conservative term --> -\nabla \psi_\mu B^{cv} B^{cv} = -\nabla \hat{nu}/\sigma + v ---*/ - + unsigned short iDim; su2double proj_conv_flux_i = 0, proj_conv_flux_j = 0, proj_conv_flux_ij = 0; su2double sigma = 2./3.; - + for (iDim = 0; iDim < nDim; iDim++) { Velocity_i[iDim] = U_i[iDim+1]/U_i[0]; Velocity_j[iDim] = U_j[iDim+1]/U_j[0]; @@ -61,7 +61,7 @@ void CUpwSca_AdjTurb::ComputeResidual (su2double *val_residual_i, su2double *val proj_conv_flux_j += (TurbVar_Grad_j[0][iDim]/sigma - Velocity_j[iDim])*Normal[iDim]; // projection of convective flux at jPoint } proj_conv_flux_ij = 0.5*fabs(proj_conv_flux_i+proj_conv_flux_j); // projection of average convective flux - + val_residual_i[0] = 0.5*( proj_conv_flux_i*(TurbPsi_i[0]+TurbPsi_j[0])-proj_conv_flux_ij*(TurbPsi_j[0]-TurbPsi_i[0])); val_residual_j[0] = 0.5*(-proj_conv_flux_j*(TurbPsi_j[0]+TurbPsi_i[0])-proj_conv_flux_ij*(TurbPsi_i[0]-TurbPsi_j[0])); if (implicit) { @@ -70,5 +70,5 @@ void CUpwSca_AdjTurb::ComputeResidual (su2double *val_residual_i, su2double *val val_Jacobian_ji[0][0] = 0.5*(-proj_conv_flux_j-proj_conv_flux_ij); val_Jacobian_jj[0][0] = 0.5*(-proj_conv_flux_j+proj_conv_flux_ij); } - + } diff --git a/SU2_CFD/src/numerics/elasticity/CFEAElasticity.cpp b/SU2_CFD/src/numerics/elasticity/CFEAElasticity.cpp index 3783546f03ee..8c3043767c01 100644 --- a/SU2_CFD/src/numerics/elasticity/CFEAElasticity.cpp +++ b/SU2_CFD/src/numerics/elasticity/CFEAElasticity.cpp @@ -7,7 +7,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) diff --git a/SU2_CFD/src/numerics/elasticity/CFEALinearElasticity.cpp b/SU2_CFD/src/numerics/elasticity/CFEALinearElasticity.cpp index 8245dbffd5c1..256ac0b963db 100644 --- a/SU2_CFD/src/numerics/elasticity/CFEALinearElasticity.cpp +++ b/SU2_CFD/src/numerics/elasticity/CFEALinearElasticity.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) diff --git a/SU2_CFD/src/numerics/elasticity/CFEAMeshElasticity.cpp b/SU2_CFD/src/numerics/elasticity/CFEAMeshElasticity.cpp index 149600387b27..1ccc8a46f3ec 100644 --- a/SU2_CFD/src/numerics/elasticity/CFEAMeshElasticity.cpp +++ b/SU2_CFD/src/numerics/elasticity/CFEAMeshElasticity.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) diff --git a/SU2_CFD/src/numerics/elasticity/CFEANonlinearElasticity.cpp b/SU2_CFD/src/numerics/elasticity/CFEANonlinearElasticity.cpp index 7236eb869631..2d12da7fcddc 100644 --- a/SU2_CFD/src/numerics/elasticity/CFEANonlinearElasticity.cpp +++ b/SU2_CFD/src/numerics/elasticity/CFEANonlinearElasticity.cpp @@ -7,7 +7,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) diff --git a/SU2_CFD/src/numerics/elasticity/CFEM_DielectricElastomer.cpp b/SU2_CFD/src/numerics/elasticity/CFEM_DielectricElastomer.cpp index 212165e87a90..45e1eff7a028 100644 --- a/SU2_CFD/src/numerics/elasticity/CFEM_DielectricElastomer.cpp +++ b/SU2_CFD/src/numerics/elasticity/CFEM_DielectricElastomer.cpp @@ -7,7 +7,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) diff --git a/SU2_CFD/src/numerics/elasticity/CFEM_IdealDE.cpp b/SU2_CFD/src/numerics/elasticity/CFEM_IdealDE.cpp index 4985d973172a..75cdd027b118 100644 --- a/SU2_CFD/src/numerics/elasticity/CFEM_IdealDE.cpp +++ b/SU2_CFD/src/numerics/elasticity/CFEM_IdealDE.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) diff --git a/SU2_CFD/src/numerics/elasticity/CFEM_Knowles_NearInc.cpp b/SU2_CFD/src/numerics/elasticity/CFEM_Knowles_NearInc.cpp index 2d99f15a45c3..d448ed133628 100644 --- a/SU2_CFD/src/numerics/elasticity/CFEM_Knowles_NearInc.cpp +++ b/SU2_CFD/src/numerics/elasticity/CFEM_Knowles_NearInc.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) diff --git a/SU2_CFD/src/numerics/elasticity/CFEM_NeoHookean_Comp.cpp b/SU2_CFD/src/numerics/elasticity/CFEM_NeoHookean_Comp.cpp index 6b25d4a36f50..136601e3ff0d 100644 --- a/SU2_CFD/src/numerics/elasticity/CFEM_NeoHookean_Comp.cpp +++ b/SU2_CFD/src/numerics/elasticity/CFEM_NeoHookean_Comp.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) diff --git a/SU2_CFD/src/numerics/flow/convection_centered/CCentBase_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_centered/CCentBase_Flow.cpp index b348935b4dbc..a5b512a63d10 100644 --- a/SU2_CFD/src/numerics/flow/convection_centered/CCentBase_Flow.cpp +++ b/SU2_CFD/src/numerics/flow/convection_centered/CCentBase_Flow.cpp @@ -73,13 +73,13 @@ void CCentBase_Flow::ComputeResidual(su2double *val_residual, su2double **val_Ja } /*--- Pressure, density, enthalpy, energy, and velocity at points i and j ---*/ - + Pressure_i = V_i[nDim+1]; Pressure_j = V_j[nDim+1]; Density_i = V_i[nDim+2]; Density_j = V_j[nDim+2]; Enthalpy_i = V_i[nDim+3]; Enthalpy_j = V_j[nDim+3]; SoundSpeed_i = V_i[nDim+4]; SoundSpeed_j = V_j[nDim+4]; Energy_i = Enthalpy_i - Pressure_i/Density_i; Energy_j = Enthalpy_j - Pressure_j/Density_j; - + sq_vel_i = 0.0; sq_vel_j = 0.0; for (iDim = 0; iDim < nDim; iDim++) { Velocity_i[iDim] = V_i[iDim+1]; @@ -89,31 +89,31 @@ void CCentBase_Flow::ComputeResidual(su2double *val_residual, su2double **val_Ja } /*--- Recompute conservative variables ---*/ - + U_i[0] = Density_i; U_j[0] = Density_j; for (iDim = 0; iDim < nDim; iDim++) { U_i[iDim+1] = Density_i*Velocity_i[iDim]; U_j[iDim+1] = Density_j*Velocity_j[iDim]; } U_i[nDim+1] = Density_i*Energy_i; U_j[nDim+1] = Density_j*Energy_j; - + /*--- Compute mean values of the variables ---*/ - + MeanDensity = 0.5*(Density_i+Density_j); MeanPressure = 0.5*(Pressure_i+Pressure_j); MeanEnthalpy = 0.5*(Enthalpy_i+Enthalpy_j); for (iDim = 0; iDim < nDim; iDim++) MeanVelocity[iDim] = 0.5*(Velocity_i[iDim]+Velocity_j[iDim]); MeanEnergy = 0.5*(Energy_i+Energy_j); - + /*--- Get projected flux tensor ---*/ - + GetInviscidProjFlux(&MeanDensity, MeanVelocity, &MeanPressure, &MeanEnthalpy, Normal, ProjFlux); - + /*--- Residual of the inviscid flux ---*/ for (iVar = 0; iVar < nVar; iVar++) val_residual[iVar] = ProjFlux[iVar]; - + /*--- Jacobians of the inviscid flux, scale = 0.5 because val_residual ~ 0.5*(fc_i+fc_j)*Normal ---*/ if (implicit) { @@ -124,7 +124,7 @@ void CCentBase_Flow::ComputeResidual(su2double *val_residual, su2double **val_Ja } /*--- Adjustment due to grid motion ---*/ - + if (dynamic_grid) { ProjGridVel = 0.0; for (iDim = 0; iDim < nDim; iDim++) @@ -138,9 +138,9 @@ void CCentBase_Flow::ComputeResidual(su2double *val_residual, su2double **val_Ja } } } - + /*--- Compute the local spectral radius and the stretching factor ---*/ - + ProjVelocity_i = 0.0; ProjVelocity_j = 0.0; Area = 0.0; for (iDim = 0; iDim < nDim; iDim++) { ProjVelocity_i += Velocity_i[iDim]*Normal[iDim]; @@ -148,31 +148,31 @@ void CCentBase_Flow::ComputeResidual(su2double *val_residual, su2double **val_Ja Area += Normal[iDim]*Normal[iDim]; } Area = sqrt(Area); - + /*--- Adjustment due to mesh motion ---*/ - + if (dynamic_grid) { ProjVelocity_i -= ProjGridVel; ProjVelocity_j -= ProjGridVel; } - + /*--- Dissipation term ---*/ - + Local_Lambda_i = (fabs(ProjVelocity_i)+SoundSpeed_i*Area); Local_Lambda_j = (fabs(ProjVelocity_j)+SoundSpeed_j*Area); MeanLambda = 0.5*(Local_Lambda_i+Local_Lambda_j); - + Phi_i = pow(Lambda_i/(4.0*MeanLambda), Param_p); Phi_j = pow(Lambda_j/(4.0*MeanLambda), Param_p); StretchingFactor = 4.0*Phi_i*Phi_j/(Phi_i+Phi_j); - + /*--- Compute differences btw. conservative variables, with a correction for enthalpy ---*/ - + for (iVar = 0; iVar < nVar-1; iVar++) { Diff_U[iVar] = U_i[iVar]-U_j[iVar]; } Diff_U[nVar-1] = Density_i*Enthalpy_i-Density_j*Enthalpy_j; - + DissipationTerm(val_residual, val_Jacobian_i, val_Jacobian_j); if (preacc) { @@ -189,16 +189,16 @@ void CCentBase_Flow::ScalarDissipationJacobian(su2double **val_Jacobian_i, su2do val_Jacobian_i[iVar][iVar] += fix_factor*cte_0; val_Jacobian_j[iVar][iVar] -= fix_factor*cte_1; } - + /*--- Last row of Jacobian_i ---*/ - + val_Jacobian_i[nVar-1][0] += fix_factor*cte_0*Gamma_Minus_One*sq_vel_i; for (iDim = 0; iDim < nDim; iDim++) val_Jacobian_i[nVar-1][iDim+1] -= fix_factor*cte_0*Gamma_Minus_One*Velocity_i[iDim]; val_Jacobian_i[nVar-1][nVar-1] += fix_factor*cte_0*Gamma; - + /*--- Last row of Jacobian_j ---*/ - + val_Jacobian_j[nVar-1][0] -= fix_factor*cte_1*Gamma_Minus_One*sq_vel_j; for (iDim = 0; iDim < nDim; iDim++) val_Jacobian_j[nVar-1][iDim+1] += fix_factor*cte_1*Gamma_Minus_One*Velocity_j[iDim]; diff --git a/SU2_CFD/src/numerics/flow/convection_centered/CCentJSTInc_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_centered/CCentJSTInc_Flow.cpp index e3489686ad66..cb1c9ca662af 100644 --- a/SU2_CFD/src/numerics/flow/convection_centered/CCentJSTInc_Flow.cpp +++ b/SU2_CFD/src/numerics/flow/convection_centered/CCentJSTInc_Flow.cpp @@ -28,7 +28,7 @@ #include "../../../../include/numerics/flow/convection_centered/CCentJSTInc_Flow.hpp" CCentJSTInc_Flow::CCentJSTInc_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - + implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); variable_density = (config->GetKind_DensityModel() == VARIABLE); energy = config->GetEnergy_Equation(); @@ -40,7 +40,7 @@ CCentJSTInc_Flow::CCentJSTInc_Flow(unsigned short val_nDim, unsigned short val_n Param_p = 0.3; Param_Kappa_2 = config->GetKappa_2nd_Flow(); Param_Kappa_4 = config->GetKappa_4th_Flow(); - + /*--- Allocate some structures ---*/ Diff_V = new su2double [nVar]; @@ -57,7 +57,7 @@ CCentJSTInc_Flow::CCentJSTInc_Flow(unsigned short val_nDim, unsigned short val_n } CCentJSTInc_Flow::~CCentJSTInc_Flow(void) { - + delete [] Diff_V; delete [] Diff_Lapl; delete [] Velocity_i; @@ -77,7 +77,7 @@ void CCentJSTInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_ su2double ProjGridVel = 0.0; /*--- Primitive variables at point i and j ---*/ - + Pressure_i = V_i[0]; Pressure_j = V_j[0]; Temperature_i = V_i[nDim+1]; Temperature_j = V_j[nDim+1]; DensityInc_i = V_i[nDim+2]; DensityInc_j = V_j[nDim+2]; @@ -98,9 +98,9 @@ void CCentJSTInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_ Area += Normal[iDim]*Normal[iDim]; } Area = sqrt(Area); - + /*--- Compute mean values of the variables ---*/ - + MeanDensity = 0.5*(DensityInc_i + DensityInc_j); MeanPressure = 0.5*(Pressure_i + Pressure_j); MeanBetaInc2 = 0.5*(BetaInc2_i + BetaInc2_j); @@ -120,13 +120,13 @@ void CCentJSTInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_ /*--- Get projected flux tensor ---*/ GetInviscidIncProjFlux(&MeanDensity, MeanVelocity, &MeanPressure, &MeanBetaInc2, &MeanEnthalpy, Normal, ProjFlux); - + for (iVar = 0; iVar < nVar; iVar++) { val_residual[iVar] = ProjFlux[iVar]; } /*--- Jacobians of the inviscid flux ---*/ - + if (implicit) { GetInviscidIncProjJac(&MeanDensity, MeanVelocity, &MeanBetaInc2, &MeanCp, &MeanTemperature, &MeandRhodT, Normal, 0.5, val_Jacobian_i); for (iVar = 0; iVar < nVar; iVar++) { @@ -169,7 +169,7 @@ void CCentJSTInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_ } /*--- Computes differences between Laplacians and conservative variables ---*/ - + for (iVar = 0; iVar < nVar; iVar++) { Diff_Lapl[iVar] = Und_Lapl_i[iVar]-Und_Lapl_j[iVar]; Diff_V[iVar] = V_i[iVar]-V_j[iVar]; @@ -195,23 +195,23 @@ void CCentJSTInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_ SoundSpeed_i = sqrt(BetaInc2_i*Area*Area); SoundSpeed_j = sqrt(BetaInc2_j*Area*Area); - + Local_Lambda_i = fabs(ProjVelocity_i)+SoundSpeed_i; Local_Lambda_j = fabs(ProjVelocity_j)+SoundSpeed_j; MeanLambda = 0.5*(Local_Lambda_i+Local_Lambda_j); - + Phi_i = pow(Lambda_i/(4.0*MeanLambda), Param_p); Phi_j = pow(Lambda_j/(4.0*MeanLambda), Param_p); StretchingFactor = 4.0*Phi_i*Phi_j/(Phi_i+Phi_j); - + sc2 = 3.0*(su2double(Neighbor_i)+su2double(Neighbor_j))/(su2double(Neighbor_i)*su2double(Neighbor_j)); sc4 = sc2*sc2/4.0; - + Epsilon_2 = Param_Kappa_2*0.5*(Sensor_i+Sensor_j)*sc2; Epsilon_4 = max(0.0, Param_Kappa_4-Epsilon_2)*sc4; - + /*--- Compute viscous part of the residual ---*/ for (iVar = 0; iVar < nVar; iVar++) { diff --git a/SU2_CFD/src/numerics/flow/convection_centered/CCentJST_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_centered/CCentJST_Flow.cpp index 964e1a319fa3..8c4c908422ab 100644 --- a/SU2_CFD/src/numerics/flow/convection_centered/CCentJST_Flow.cpp +++ b/SU2_CFD/src/numerics/flow/convection_centered/CCentJST_Flow.cpp @@ -44,7 +44,7 @@ CCentJST_Flow::~CCentJST_Flow(void) { void CCentJST_Flow::DissipationTerm(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j) { /*--- Compute differences btw. Laplacians ---*/ - + for (iVar = 0; iVar < nVar; iVar++) { Diff_Lapl[iVar] = Und_Lapl_i[iVar]-Und_Lapl_j[iVar]; } @@ -53,22 +53,22 @@ void CCentJST_Flow::DissipationTerm(su2double *val_residual, su2double **val_Jac sc2 = 3.0*(su2double(Neighbor_i)+su2double(Neighbor_j))/(su2double(Neighbor_i)*su2double(Neighbor_j)); sc4 = sc2*sc2/4.0; - + Epsilon_2 = Param_Kappa_2*0.5*(Sensor_i+Sensor_j)*sc2; Epsilon_4 = max(0.0, Param_Kappa_4-Epsilon_2)*sc4; - + /*--- Compute viscous part of the residual ---*/ - + for (iVar = 0; iVar < nVar; iVar++) val_residual[iVar] += (Epsilon_2*Diff_U[iVar] - Epsilon_4*Diff_Lapl[iVar])*StretchingFactor*MeanLambda; - + /*--- Jacobian computation ---*/ if (implicit) { cte_0 = (Epsilon_2 + Epsilon_4*su2double(Neighbor_i+1))*StretchingFactor*MeanLambda; cte_1 = (Epsilon_2 + Epsilon_4*su2double(Neighbor_j+1))*StretchingFactor*MeanLambda; - + ScalarDissipationJacobian(val_Jacobian_i, val_Jacobian_j); } } diff --git a/SU2_CFD/src/numerics/flow/convection_centered/CCentLaxInc_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_centered/CCentLaxInc_Flow.cpp index b8e38dbd553d..a3bdafebb94f 100644 --- a/SU2_CFD/src/numerics/flow/convection_centered/CCentLaxInc_Flow.cpp +++ b/SU2_CFD/src/numerics/flow/convection_centered/CCentLaxInc_Flow.cpp @@ -28,7 +28,7 @@ #include "../../../../include/numerics/flow/convection_centered/CCentLaxInc_Flow.hpp" CCentLaxInc_Flow::CCentLaxInc_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - + implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); variable_density = (config->GetKind_DensityModel() == VARIABLE); /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ @@ -39,7 +39,7 @@ CCentLaxInc_Flow::CCentLaxInc_Flow(unsigned short val_nDim, unsigned short val_n Param_p = 0.3; Param_Kappa_0 = config->GetKappa_1st_Flow(); - + /*--- Allocate some structures ---*/ Diff_V = new su2double[nVar]; @@ -51,11 +51,11 @@ CCentLaxInc_Flow::CCentLaxInc_Flow(unsigned short val_nDim, unsigned short val_n for (iVar = 0; iVar < nVar; iVar++) Precon[iVar] = new su2double[nVar]; - + } CCentLaxInc_Flow::~CCentLaxInc_Flow(void) { - + delete [] Diff_V; delete [] Velocity_i; delete [] Velocity_j; @@ -72,9 +72,9 @@ void CCentLaxInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_ su2double U_i[5] = {0.0,0.0,0.0,0.0,0.0}, U_j[5] = {0.0,0.0,0.0,0.0,0.0}; su2double ProjGridVel = 0.0, ProjVelocity = 0.0; - + /*--- Primitive variables at point i and j ---*/ - + Pressure_i = V_i[0]; Pressure_j = V_j[0]; Temperature_i = V_i[nDim+1]; Temperature_j = V_j[nDim+1]; DensityInc_i = V_i[nDim+2]; DensityInc_j = V_j[nDim+2]; @@ -119,7 +119,7 @@ void CCentLaxInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_ GetInviscidIncProjFlux(&MeanDensity, MeanVelocity, &MeanPressure, &MeanBetaInc2, &MeanEnthalpy, Normal, ProjFlux); /*--- Compute inviscid residual ---*/ - + for (iVar = 0; iVar < nVar; iVar++) { val_residual[iVar] = ProjFlux[iVar]; } @@ -167,7 +167,7 @@ void CCentLaxInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_ } /*--- Computes differences btw. conservative variables ---*/ - + for (iVar = 0; iVar < nVar; iVar++) Diff_V[iVar] = V_i[iVar]-V_j[iVar]; @@ -201,10 +201,10 @@ void CCentLaxInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_ Phi_j = pow(Lambda_j/(4.0*MeanLambda), Param_p); StretchingFactor = 4.0*Phi_i*Phi_j/(Phi_i+Phi_j); - + sc0 = 3.0*(su2double(Neighbor_i)+su2double(Neighbor_j))/(su2double(Neighbor_i)*su2double(Neighbor_j)); Epsilon_0 = Param_Kappa_0*sc0*su2double(nDim)/3.0; - + /*--- Compute viscous part of the residual ---*/ for (iVar = 0; iVar < nVar; iVar++) { @@ -216,7 +216,7 @@ void CCentLaxInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_ } } } - + /*--- Remove energy contributions if we aren't solving the energy equation. ---*/ if (!energy) { diff --git a/SU2_CFD/src/numerics/flow/convection_centered/CCentLax_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_centered/CCentLax_Flow.cpp index e621392a0bab..a2bc16c55e06 100644 --- a/SU2_CFD/src/numerics/flow/convection_centered/CCentLax_Flow.cpp +++ b/SU2_CFD/src/numerics/flow/convection_centered/CCentLax_Flow.cpp @@ -46,19 +46,19 @@ void CCentLax_Flow::DissipationTerm(su2double *val_residual, su2double **val_Jac sc0 = 3.0*(su2double(Neighbor_i)+su2double(Neighbor_j))/(su2double(Neighbor_i)*su2double(Neighbor_j)); Epsilon_0 = Param_Kappa_0*sc0*su2double(nDim)/3.0; - + /*--- Compute viscous part of the residual ---*/ - + for (iVar = 0; iVar < nVar; iVar++) val_residual[iVar] += Epsilon_0*Diff_U[iVar]*StretchingFactor*MeanLambda; - + /*--- Jacobian computation ---*/ if (implicit) { - + cte_0 = Epsilon_0*StretchingFactor*MeanLambda; cte_1 = cte_0; - + ScalarDissipationJacobian(val_Jacobian_i, val_Jacobian_j); } } diff --git a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwAUSMPLUSUP2_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwAUSMPLUSUP2_Flow.cpp index ab97186e2f87..c422a8f642cf 100644 --- a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwAUSMPLUSUP2_Flow.cpp +++ b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwAUSMPLUSUP2_Flow.cpp @@ -29,7 +29,7 @@ CUpwAUSMPLUSUP2_Flow::CUpwAUSMPLUSUP2_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CUpwAUSMPLUS_SLAU_Base_Flow(val_nDim, val_nVar, config) { - + Minf = config->GetMach(); Kp = 0.25; sigma = 1.0; diff --git a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwAUSMPLUSUP_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwAUSMPLUSUP_Flow.cpp index 35c0c77656c5..11f14140659e 100644 --- a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwAUSMPLUSUP_Flow.cpp +++ b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwAUSMPLUSUP_Flow.cpp @@ -55,7 +55,7 @@ void CUpwAUSMPLUSUP_Flow::ComputeMassAndPressureFluxes(CConfig *config, su2doubl ProjVelocity_j += Velocity_j[iDim]*UnitNormal[iDim]; } - /*--- Compute interface speed of sound (aF) ---*/ + /*--- Compute interface speed of sound (aF) ---*/ su2double astarL = sqrt(2.0*(Gamma-1.0)/(Gamma+1.0)*Enthalpy_i); su2double astarR = sqrt(2.0*(Gamma-1.0)/(Gamma+1.0)*Enthalpy_j); @@ -66,7 +66,7 @@ void CUpwAUSMPLUSUP_Flow::ComputeMassAndPressureFluxes(CConfig *config, su2doubl su2double aF = min(ahatL,ahatR); /*--- Left and right pressures and Mach numbers ---*/ - + su2double mLP, betaLP, mRM, betaRM; su2double mL = ProjVelocity_i/aF; @@ -118,21 +118,21 @@ void CUpwAUSMPLUSUP_Flow::ComputeMassAndPressureFluxes(CConfig *config, su2doubl mdot = aF * (max(mF,0.0)*Density_i + min(mF,0.0)*Density_j); pressure = betaLP*Pressure_i + betaRM*Pressure_j + Pu; - + if (!implicit || !UseAccurateJacobian) return; - + /*--- Analytical differentiation of the face mass flux and pressure (in reverse mode, "?_b" denotes dmot_d?). ---*/ - + /*--- limited mean Mach number (used in division...) ---*/ su2double MF = max(numeric_limits::epsilon(),sqrt(MFsq)); - + for (int outVar=0; outVar<2; ++outVar) { - + su2double aF_b = 0.0, mF_b = 0.0, MF_b = 0.0, rhoF_b = 0.0, fa_b = 0.0, alpha_b = 0.0, rho_i_b = 0.0, rho_j_b = 0.0, p_i_b = 0.0, p_j_b = 0.0, Vn_i_b = 0.0, Vn_j_b = 0.0, mR_b = 0.0, mL_b = 0.0, betaLP_b = 0.0, betaRM_b = 0.0, tmp = 0.0; - + if (outVar==0) { /*--- mdot = ... ---*/ if (mF > 0.0) { @@ -145,7 +145,7 @@ void CUpwAUSMPLUSUP_Flow::ComputeMassAndPressureFluxes(CConfig *config, su2doubl mF_b += aF*Density_j; rho_j_b += mF*aF; } - + /*--- Mp = ... ---*/ if (sigma*MFsq < 1.0) { rhoF_b -= Mp/rhoF * mF_b; @@ -156,14 +156,14 @@ void CUpwAUSMPLUSUP_Flow::ComputeMassAndPressureFluxes(CConfig *config, su2doubl p_i_b -= tmp * mF_b; p_j_b += tmp * mF_b; } - + /*--- rhoF = ... ---*/ rho_i_b += 0.5*rhoF_b; rho_j_b += 0.5*rhoF_b; - + /*--- mRM = ... ---*/ if (fabs(mR) < 1.0) mR_b += (1.0-mR)*(0.5+4.0*beta*mR*(mR+1.0)) * mF_b; else if (mR <=-1.0) mR_b += mF_b; - + /*--- mLP = ... ---*/ if (fabs(mL) < 1.0) mL_b += (1.0+mL)*(0.5+4.0*beta*mL*(mL-1.0)) * mF_b; else if (mL >= 1.0) mL_b += mF_b; @@ -172,7 +172,7 @@ void CUpwAUSMPLUSUP_Flow::ComputeMassAndPressureFluxes(CConfig *config, su2doubl /*--- pressure = ... ---*/ p_i_b += betaLP; betaLP_b += Pressure_i; p_j_b += betaRM; betaRM_b += Pressure_j; - + /*--- Pu = ... ---*/ rhoF_b += Pu/rhoF; fa_b += Pu/fa; @@ -183,45 +183,45 @@ void CUpwAUSMPLUSUP_Flow::ComputeMassAndPressureFluxes(CConfig *config, su2doubl tmp = -Ku*fa*betaLP*betaRM*2.0*rhoF*aF; Vn_i_b -= tmp; Vn_j_b += tmp; - + /*--- rhoF = ... ---*/ rho_i_b += 0.5*rhoF_b; rho_j_b += 0.5*rhoF_b; - + /*--- betaRM = ... ---*/ if (fabs(mR) < 1.0) { tmp = mR*mR-1.0; mR_b += tmp*(0.75-alpha*(5.0*tmp+4.0)) * betaRM_b; alpha_b -= mR*tmp*tmp * betaRM_b; } - + /*--- betaLP = ... ---*/ if (fabs(mL) < 1.0) { tmp = mL*mL-1.0; mL_b -= tmp*(0.75-alpha*(5.0*tmp+4.0)) * betaLP_b; alpha_b += mL*tmp*tmp * betaLP_b; } - + /*--- alpha = ... ---*/ fa_b += 1.875*fa * alpha_b; } - + /*--- steps shared by both ---*/ /*--- fa = ... ---*/ su2double Mref_b = 2.0*(1.0-sqrt(Mrefsq)) * fa_b; - + /*--- Mrefsq = ... ---*/ if (MF < 1.0 && MF > Minf) MF_b += Mref_b; - + /*--- MFsq = ... ---*/ mL_b += 0.5*mL/MF * MF_b; mR_b += 0.5*mR/MF * MF_b; - + /*--- mL/R = ... ---*/ Vn_i_b += mL_b/aF; Vn_j_b += mR_b/aF; aF_b -= (mL*mL_b+mR*mR_b)/aF; - + /*--- aF,ahat,astar = f(H_i,H_j) ---*/ su2double astar_b = aF_b, H_i_b, H_j_b; - + if (ahatL < ahatR) { if (astarL <= ProjVelocity_i) { tmp = astarL/ProjVelocity_i; @@ -240,12 +240,12 @@ void CUpwAUSMPLUSUP_Flow::ComputeMassAndPressureFluxes(CConfig *config, su2doubl H_j_b = sqrt(0.5*(Gamma-1.0)/((Gamma+1.0)*Enthalpy_j)) * astar_b; H_i_b = 0.0; } - + /*--- store derivatives ---*/ su2double *target_i = (outVar==0 ? dmdot_dVi : dpres_dVi), *target_j = (outVar==0 ? dmdot_dVj : dpres_dVj); target_i[5] = target_j[5] = 0.0; - + /*--- ProjVelocity = ... ---*/ for (unsigned short iDim = 0; iDim < nDim; ++iDim) { target_i[iDim] = UnitNormal[iDim] * Vn_i_b; diff --git a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwAUSMPLUS_SLAU_Base_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwAUSMPLUS_SLAU_Base_Flow.cpp index c5b69c9454eb..ed15245c8927 100644 --- a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwAUSMPLUS_SLAU_Base_Flow.cpp +++ b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwAUSMPLUS_SLAU_Base_Flow.cpp @@ -29,23 +29,23 @@ CUpwAUSMPLUS_SLAU_Base_Flow::CUpwAUSMPLUS_SLAU_Base_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - + if (config->GetDynamic_Grid() && (SU2_MPI::GetRank() == MASTER_NODE)) cout << "WARNING: Grid velocities are NOT yet considered in AUSM-type schemes." << endl; - + implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); UseAccurateJacobian = config->GetUse_Accurate_Jacobians(); HasAnalyticalDerivatives = false; FinDiffStep = 1e-4; - + Gamma = config->GetGamma(); Gamma_Minus_One = Gamma - 1.0; - + Velocity_i = new su2double [nDim]; Velocity_j = new su2double [nDim]; psi_i = new su2double [nVar]; psi_j = new su2double [nVar]; - + RoeVelocity = new su2double [nDim]; Lambda = new su2double [nVar]; Epsilon = new su2double [nVar]; @@ -58,12 +58,12 @@ CUpwAUSMPLUS_SLAU_Base_Flow::CUpwAUSMPLUS_SLAU_Base_Flow(unsigned short val_nDim } CUpwAUSMPLUS_SLAU_Base_Flow::~CUpwAUSMPLUS_SLAU_Base_Flow(void) { - + delete [] Velocity_i; delete [] Velocity_j; delete [] psi_i; delete [] psi_j; - + delete [] RoeVelocity; delete [] Lambda; delete [] Epsilon; @@ -73,7 +73,7 @@ CUpwAUSMPLUS_SLAU_Base_Flow::~CUpwAUSMPLUS_SLAU_Base_Flow(void) { } delete [] P_Tensor; delete [] invP_Tensor; - + } void CUpwAUSMPLUS_SLAU_Base_Flow::ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure) @@ -94,12 +94,12 @@ void CUpwAUSMPLUS_SLAU_Base_Flow::ApproximateJacobian(su2double **val_Jacobian_i unsigned short iDim, iVar, jVar, kVar; su2double R, RoeDensity, RoeEnthalpy, RoeSoundSpeed, ProjVelocity, sq_vel, Energy_i, Energy_j; - + Energy_i = Enthalpy_i - Pressure_i/Density_i; Energy_j = Enthalpy_j - Pressure_j/Density_j; /*--- Mean Roe variables iPoint and jPoint ---*/ - + R = sqrt(fabs(Density_j/Density_i)); RoeDensity = R*Density_i; ProjVelocity = 0.0; @@ -111,27 +111,27 @@ void CUpwAUSMPLUS_SLAU_Base_Flow::ApproximateJacobian(su2double **val_Jacobian_i } RoeEnthalpy = (R*Enthalpy_j+Enthalpy_i)/(R+1); RoeSoundSpeed = sqrt(fabs((Gamma-1)*(RoeEnthalpy-0.5*sq_vel))); - + /*--- Compute P and Lambda (do it with the Normal) ---*/ GetPMatrix(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, P_Tensor); /*--- Flow eigenvalues and Entropy correctors ---*/ - + for (iDim = 0; iDim < nDim; iDim++) Lambda[iDim] = ProjVelocity; Lambda[nVar-2] = ProjVelocity + RoeSoundSpeed; Lambda[nVar-1] = ProjVelocity - RoeSoundSpeed; - + /*--- Compute inverse P ---*/ GetPMatrix_inv(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, invP_Tensor); - + /*--- Jacobians of the inviscid flux, scale = 0.5 because val_residual ~ 0.5*(fc_i+fc_j)*Normal ---*/ GetInviscidProjJac(Velocity_i, &Energy_i, Normal, 0.5, val_Jacobian_i); GetInviscidProjJac(Velocity_j, &Energy_j, Normal, 0.5, val_Jacobian_j); - + /*--- Roe's Flux approximation ---*/ - + for (iVar = 0; iVar < nVar; iVar++) { for (jVar = 0; jVar < nVar; jVar++) { su2double Proj_ModJac_Tensor_ij = 0.0; @@ -148,18 +148,18 @@ void CUpwAUSMPLUS_SLAU_Base_Flow::ApproximateJacobian(su2double **val_Jacobian_i void CUpwAUSMPLUS_SLAU_Base_Flow::AccurateJacobian(CConfig *config, su2double **val_Jacobian_i, su2double **val_Jacobian_j) { /*--- Compute Jacobians using a mixed (numerical/analytical) formulation ---*/ - + unsigned short iDim, iVar, jVar; - + /*--- If not computed analytically, numerically differentiate the fluxes wrt primitives ---*/ - + if (!HasAnalyticalDerivatives) { - + /*--- Create arrays of pointers to the primitive variables so we can loop through and perturb them in a general way. ---*/ - + su2double *primitives_i[6], *primitives_j[6]; - + for (iDim = 0; iDim < nDim; ++iDim) { primitives_i[iDim] = &Velocity_i[iDim]; primitives_j[iDim] = &Velocity_j[iDim]; @@ -167,15 +167,15 @@ void CUpwAUSMPLUS_SLAU_Base_Flow::AccurateJacobian(CConfig *config, su2double ** primitives_i[ nDim ] = &Pressure_i; primitives_j[ nDim ] = &Pressure_j; primitives_i[nDim+1] = &Density_i; primitives_j[nDim+1] = &Density_j; primitives_i[nDim+2] = &Enthalpy_i; primitives_j[nDim+2] = &Enthalpy_j; - + /*--- Initialize the gradient arrays with the negative of the quantity, then for forward finite differences we add to it and divide. ---*/ - + for (iVar = 0; iVar < 6; ++iVar) { dmdot_dVi[iVar] = -MassFlux; dpres_dVi[iVar] = -Pressure; dmdot_dVj[iVar] = -MassFlux; dpres_dVj[iVar] = -Pressure; } - + for (iVar = 0; iVar < nDim+3; ++iVar) { /*--- Perturb side i ---*/ su2double epsilon = FinDiffStep * max(1.0, fabs(*primitives_i[iVar])); @@ -184,7 +184,7 @@ void CUpwAUSMPLUS_SLAU_Base_Flow::AccurateJacobian(CConfig *config, su2double ** dmdot_dVi[iVar] += MassFlux; dpres_dVi[iVar] += Pressure; dmdot_dVi[iVar] /= epsilon; dpres_dVi[iVar] /= epsilon; *primitives_i[iVar] -= epsilon; - + /*--- Perturb side j ---*/ epsilon = FinDiffStep * max(1.0, fabs(*primitives_j[iVar])); *primitives_j[iVar] += epsilon; @@ -196,17 +196,17 @@ void CUpwAUSMPLUS_SLAU_Base_Flow::AccurateJacobian(CConfig *config, su2double ** } /*--- Differentiation of fluxes wrt conservatives assuming ideal gas ---*/ - + su2double dmdot_dUi[5], dmdot_dUj[5], dpres_dUi[5], dpres_dUj[5]; su2double sq_veli = 0.0, sq_velj = 0.0, dHi_drhoi = 0.0, dHj_drhoj = 0.0; su2double oneOnRhoi = 1.0/Density_i, oneOnRhoj = 1.0/Density_j; - + for (jVar = 0; jVar < nVar; ++jVar) { /*--- Partial derivatives of the primitives wrt conservative "jVar" ---*/ su2double dVi_dUi[6] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; su2double dVj_dUj[6] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; - + if (jVar == 0) { // Density for (iDim = 0; iDim < nDim; ++iDim) { // -u,v,w / rho @@ -218,9 +218,9 @@ void CUpwAUSMPLUS_SLAU_Base_Flow::AccurateJacobian(CConfig *config, su2double ** } dVi_dUi[nDim] = 0.5*Gamma_Minus_One*sq_veli; dVj_dUj[nDim] = 0.5*Gamma_Minus_One*sq_velj; - + dVi_dUi[nDim+1] = dVj_dUj[nDim+1] = 1.0; - + dHi_drhoi = 0.5*(Gamma-2.0)*sq_veli - Gamma*Pressure_i/((Gamma-1.0)*Density_i); dHj_drhoj = 0.5*(Gamma-2.0)*sq_velj - Gamma*Pressure_j/((Gamma-1.0)*Density_j); dVi_dUi[nDim+2] = dHi_drhoi * oneOnRhoi; @@ -234,14 +234,14 @@ void CUpwAUSMPLUS_SLAU_Base_Flow::AccurateJacobian(CConfig *config, su2double ** else { // Momentum dVi_dUi[jVar-1] = oneOnRhoi; dVj_dUj[jVar-1] = oneOnRhoj; - + dVi_dUi[nDim] = -Gamma_Minus_One*Velocity_i[jVar-1]; dVj_dUj[nDim] = -Gamma_Minus_One*Velocity_j[jVar-1]; - + dVi_dUi[nDim+2] = dVi_dUi[nDim] * oneOnRhoi; dVj_dUj[nDim+2] = dVj_dUj[nDim] * oneOnRhoj; } - + /*--- Dot product to complete chain rule ---*/ dmdot_dUi[jVar] = 0.0; dpres_dUi[jVar] = 0.0; dmdot_dUj[jVar] = 0.0; dpres_dUj[jVar] = 0.0; @@ -252,11 +252,11 @@ void CUpwAUSMPLUS_SLAU_Base_Flow::AccurateJacobian(CConfig *config, su2double ** dpres_dUj[jVar] += dpres_dVj[iVar]*dVj_dUj[iVar]; } } - + /*--- Assemble final Jacobians (assuming phi = |mdot|) ---*/ - + su2double mdot_hat, psi_hat[5]; - + if (MassFlux > 0.0) { mdot_hat = Area*MassFlux*oneOnRhoi; for (iVar = 0; iVar < nVar; ++iVar) psi_hat[iVar] = Area*psi_i[iVar]; @@ -265,7 +265,7 @@ void CUpwAUSMPLUS_SLAU_Base_Flow::AccurateJacobian(CConfig *config, su2double ** mdot_hat = Area*MassFlux*oneOnRhoj; for (iVar = 0; iVar < nVar; ++iVar) psi_hat[iVar] = Area*psi_j[iVar]; } - + /*--- Contribution from the mass flux derivatives ---*/ for (iVar = 0; iVar < nVar; ++iVar) { for (jVar = 0; jVar < nVar; ++jVar) { @@ -273,7 +273,7 @@ void CUpwAUSMPLUS_SLAU_Base_Flow::AccurateJacobian(CConfig *config, su2double ** val_Jacobian_j[iVar][jVar] = psi_hat[iVar] * dmdot_dUj[jVar]; } } - + /*--- Contribution from the pressure derivatives ---*/ for (iDim = 0; iDim < nDim; ++iDim) { for (jVar = 0; jVar < nVar; ++jVar) { @@ -281,7 +281,7 @@ void CUpwAUSMPLUS_SLAU_Base_Flow::AccurateJacobian(CConfig *config, su2double ** val_Jacobian_j[iDim+1][jVar] += Normal[iDim] * dpres_dUj[jVar]; } } - + /*--- Contributions from the derivatives of PSI wrt the conservatives ---*/ if (MassFlux > 0.0) { /*--- Velocity terms ---*/ @@ -365,16 +365,16 @@ void CUpwAUSMPLUS_SLAU_Base_Flow::ComputeResidual(su2double *val_residual, su2do 0.5*DissFlux*(psi_i[nVar-1]-psi_j[nVar-1]); for (iVar = 0; iVar < nVar; iVar++) val_residual[iVar] *= Area; - + /*--- Space to end preaccumulation ---*/ - + AD::SetPreaccOut(val_residual, nVar); AD::EndPreacc(); - + /*--- If required, compute Jacobians, either approximately (Roe) or numerically ---*/ - + if (!implicit) return; - + if (UseAccurateJacobian) AccurateJacobian(config, val_Jacobian_i, val_Jacobian_j); else diff --git a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwAUSM_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwAUSM_Flow.cpp index 8bdd2886efd0..53b01072a13f 100644 --- a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwAUSM_Flow.cpp +++ b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwAUSM_Flow.cpp @@ -28,15 +28,15 @@ #include "../../../../include/numerics/flow/convection_upwind/CUpwAUSM_Flow.hpp" CUpwAUSM_Flow::CUpwAUSM_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - + if (config->GetDynamic_Grid() && (SU2_MPI::GetRank() == MASTER_NODE)) cout << "WARNING: Grid velocities are NOT yet considered in AUSM-type schemes." << endl; - + implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - + Gamma = config->GetGamma(); Gamma_Minus_One = Gamma - 1.0; - + Diff_U = new su2double [nVar]; Velocity_i = new su2double [nDim]; Velocity_j = new su2double [nDim]; @@ -56,7 +56,7 @@ CUpwAUSM_Flow::CUpwAUSM_Flow(unsigned short val_nDim, unsigned short val_nVar, C } CUpwAUSM_Flow::~CUpwAUSM_Flow(void) { - + delete [] Diff_U; delete [] Velocity_i; delete [] Velocity_j; @@ -73,26 +73,26 @@ CUpwAUSM_Flow::~CUpwAUSM_Flow(void) { } delete [] P_Tensor; delete [] invP_Tensor; - + } void CUpwAUSM_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - + AD::StartPreacc(); AD::SetPreaccIn(Normal, nDim); AD::SetPreaccIn(V_i, nDim+4); AD::SetPreaccIn(V_j, nDim+4); - + /*--- Face area (norm or the normal vector) ---*/ Area = 0.0; for (iDim = 0; iDim < nDim; iDim++) Area += Normal[iDim]*Normal[iDim]; Area = sqrt(Area); - + /*-- Unit Normal ---*/ for (iDim = 0; iDim < nDim; iDim++) UnitNormal[iDim] = Normal[iDim]/Area; - + /*--- Primitive variables at point i ---*/ sq_vel = 0.0; for (iDim = 0; iDim < nDim; iDim++) { @@ -104,7 +104,7 @@ void CUpwAUSM_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jac Enthalpy_i = V_i[nDim+3]; Energy_i = Enthalpy_i - Pressure_i/Density_i; SoundSpeed_i = sqrt(fabs(Gamma*Gamma_Minus_One*(Energy_i-0.5*sq_vel))); - + /*--- Primitive variables at point j ---*/ sq_vel = 0.0; for (iDim = 0; iDim < nDim; iDim++) { @@ -116,34 +116,34 @@ void CUpwAUSM_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jac Enthalpy_j = V_j[nDim+3]; Energy_j = Enthalpy_j - Pressure_j/Density_j; SoundSpeed_j = sqrt(fabs(Gamma*Gamma_Minus_One*(Energy_j-0.5*sq_vel))); - + /*--- Projected velocities ---*/ ProjVelocity_i = 0.0; ProjVelocity_j = 0.0; for (iDim = 0; iDim < nDim; iDim++) { ProjVelocity_i += Velocity_i[iDim]*UnitNormal[iDim]; ProjVelocity_j += Velocity_j[iDim]*UnitNormal[iDim]; } - + mL = ProjVelocity_i/SoundSpeed_i; mR = ProjVelocity_j/SoundSpeed_j; - + if (fabs(mL) <= 1.0) mLP = 0.25*(mL+1.0)*(mL+1.0); else mLP = 0.5*(mL+fabs(mL)); - + if (fabs(mR) <= 1.0) mRM = -0.25*(mR-1.0)*(mR-1.0); else mRM = 0.5*(mR-fabs(mR)); - + mF = mLP + mRM; - + if (fabs(mL) <= 1.0) pLP = 0.25*Pressure_i*(mL+1.0)*(mL+1.0)*(2.0-mL); else pLP = 0.5*Pressure_i*(mL+fabs(mL))/mL; - + if (fabs(mR) <= 1.0) pRM = 0.25*Pressure_j*(mR-1.0)*(mR-1.0)*(2.0+mR); else pRM = 0.5*Pressure_j*(mR-fabs(mR))/mR; - + pF = pLP + pRM; Phi = fabs(mF); - + val_residual[0] = 0.5*(mF*((Density_i*SoundSpeed_i)+(Density_j*SoundSpeed_j))-Phi*((Density_j*SoundSpeed_j)-(Density_i*SoundSpeed_i))); for (iDim = 0; iDim < nDim; iDim++) val_residual[iDim+1] = 0.5*(mF*((Density_i*SoundSpeed_i*Velocity_i[iDim])+(Density_j*SoundSpeed_j*Velocity_j[iDim])) @@ -152,13 +152,13 @@ void CUpwAUSM_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jac for (iVar = 0; iVar < nVar; iVar++) val_residual[iVar] *= Area; - + AD::SetPreaccOut(val_residual, nVar); AD::EndPreacc(); - + /*--- Roe's Jacobian for AUSM (this must be fixed) ---*/ if (implicit) { - + /*--- Mean Roe variables iPoint and jPoint ---*/ R = sqrt(fabs(Density_j/Density_i)); RoeDensity = R*Density_i; @@ -169,30 +169,30 @@ void CUpwAUSM_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jac } RoeEnthalpy = (R*Enthalpy_j+Enthalpy_i)/(R+1); RoeSoundSpeed = sqrt(fabs((Gamma-1)*(RoeEnthalpy-0.5*sq_vel))); - + /*--- Compute P and Lambda (do it with the Normal) ---*/ GetPMatrix(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, P_Tensor); - + ProjVelocity = 0.0; ProjVelocity_i = 0.0; ProjVelocity_j = 0.0; for (iDim = 0; iDim < nDim; iDim++) { ProjVelocity += RoeVelocity[iDim]*UnitNormal[iDim]; ProjVelocity_i += Velocity_i[iDim]*UnitNormal[iDim]; ProjVelocity_j += Velocity_j[iDim]*UnitNormal[iDim]; } - + /*--- Flow eigenvalues and Entropy correctors ---*/ for (iDim = 0; iDim < nDim; iDim++) Lambda[iDim] = ProjVelocity; Lambda[nVar-2] = ProjVelocity + RoeSoundSpeed; Lambda[nVar-1] = ProjVelocity - RoeSoundSpeed; - + /*--- Compute inverse P ---*/ GetPMatrix_inv(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, invP_Tensor); - + /*--- Jacobias of the inviscid flux, scale = 0.5 because val_residual ~ 0.5*(fc_i+fc_j)*Normal ---*/ GetInviscidProjJac(Velocity_i, &Energy_i, Normal, 0.5, val_Jacobian_i); GetInviscidProjJac(Velocity_j, &Energy_j, Normal, 0.5, val_Jacobian_j); - + /*--- Roe's Flux approximation ---*/ for (iVar = 0; iVar < nVar; iVar++) { for (jVar = 0; jVar < nVar; jVar++) { diff --git a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwCUSP_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwCUSP_Flow.cpp index f647a029a400..53566634229c 100644 --- a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwCUSP_Flow.cpp +++ b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwCUSP_Flow.cpp @@ -28,15 +28,15 @@ #include "../../../../include/numerics/flow/convection_upwind/CUpwCUSP_Flow.hpp" CUpwCUSP_Flow::CUpwCUSP_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - + implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - + Gamma = config->GetGamma(); Gamma_Minus_One = Gamma - 1.0; - + if (config->GetDynamic_Grid() && (SU2_MPI::GetRank() == MASTER_NODE)) cout << "WARNING: Grid velocities are NOT yet considered by the CUSP scheme." << endl; - + /*--- Allocate some structures ---*/ Velocity_i = new su2double [nDim]; Velocity_j = new su2double [nDim]; @@ -53,16 +53,16 @@ CUpwCUSP_Flow::~CUpwCUSP_Flow(void) { void CUpwCUSP_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - + unsigned short iDim, iVar; su2double Diff_U[5] = {0.0,0.0,0.0,0.0,0.0}; - + AD::SetPreaccIn(Normal, nDim); AD::SetPreaccIn(V_i, nDim+4); AD::SetPreaccIn(V_j, nDim+4); - + /*--- Pressure, density, enthalpy, energy, and velocity at points i and j ---*/ - + Pressure_i = V_i[nDim+1]; Pressure_j = V_j[nDim+1]; Density_i = V_i[nDim+2]; Density_j = V_j[nDim+2]; Enthalpy_i = V_i[nDim+3]; Enthalpy_j = V_j[nDim+3]; @@ -78,33 +78,33 @@ void CUpwCUSP_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jac } /*-- Face area and unit normal ---*/ - + 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; - + /*--- Computes differences of conservative variables, with a correction for the enthalpy ---*/ - + Diff_U[0] = Density_i - Density_j; for (iDim = 0; iDim < nDim; iDim++) Diff_U[iDim+1] = Density_i*Velocity_i[iDim] - Density_j*Velocity_j[iDim]; Diff_U[nVar-1] = Density_i*Enthalpy_i - Density_j*Enthalpy_j; - + /*--- Get left and right fluxes ---*/ - + GetInviscidProjFlux(&Density_i, Velocity_i, &Pressure_i, &Enthalpy_i, UnitNormal, ProjFlux_i); GetInviscidProjFlux(&Density_j, Velocity_j, &Pressure_j, &Enthalpy_j, UnitNormal, ProjFlux_j); - + /*--- Compute dissipation parameters based on Roe-averaged values ---*/ - + su2double Beta, Nu_c; - + su2double R = sqrt(Density_j/Density_i), ProjVelocity = 0.0, sq_vel = 0.0; - + for (iDim = 0; iDim < nDim; iDim++) { su2double MeanVel = (R*Velocity_j[iDim]+Velocity_i[iDim])/(R+1.0); ProjVelocity += MeanVel*UnitNormal[iDim]; @@ -112,64 +112,64 @@ void CUpwCUSP_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jac } su2double MeanEnthalpy = (R*Enthalpy_j+Enthalpy_i)/(R+1.0); su2double MeanSoundSpeed = sqrt(Gamma_Minus_One*fabs(MeanEnthalpy-0.5*sq_vel)); - + su2double Mach = ProjVelocity / MeanSoundSpeed; - + su2double tmp1 = 0.5*(Gamma+1.0)/Gamma*ProjVelocity; su2double tmp2 = sqrt(pow(tmp1-ProjVelocity/Gamma, 2.0) + pow(MeanSoundSpeed,2.0)/Gamma); su2double LamdaNeg = tmp1 - tmp2, LamdaPos = tmp1 + tmp2; - + if (fabs(Mach) >= 1.0) Beta = Mach/fabs(Mach); else if (Mach >= 0.0) Beta = max(0.0, (ProjVelocity + LamdaNeg)/(ProjVelocity - LamdaNeg)); else Beta =-max(0.0, (ProjVelocity + LamdaPos)/(ProjVelocity - LamdaPos)); - + if (fabs(Mach) >= 1.0) Nu_c = 0.0; else { if (Beta > 0.0) Nu_c =-(1.0+Beta)*LamdaNeg; else if (Beta < 0.0) Nu_c = (1.0-Beta)*LamdaPos; /*--- Limit the minimum scalar dissipation ---*/ else Nu_c = max(fabs(ProjVelocity), config->GetEntropyFix_Coeff()*MeanSoundSpeed); - } - + } + /*--- Compute the residual ---*/ - + for (iVar = 0; iVar < nVar; iVar++) val_residual[iVar] = 0.5*((1.0+Beta)*ProjFlux_i[iVar] + (1.0-Beta)*ProjFlux_j[iVar] + Nu_c*Diff_U[iVar])*Area; /*--- Jacobian computation ---*/ if (implicit) { - + /*--- Flux average and difference contributions ---*/ - + GetInviscidProjJac(Velocity_i, &Energy_i, Normal, 0.5*(1.0+Beta), val_Jacobian_i); GetInviscidProjJac(Velocity_j, &Energy_j, Normal, 0.5*(1.0-Beta), val_Jacobian_j); - + /*--- Solution difference (scalar dissipation) contribution ---*/ - + su2double cte_0 = 0.5*Nu_c*Area*config->GetCent_Jac_Fix_Factor(); - + /*--- n-1 diagonal entries ---*/ - + for (iVar = 0; iVar < (nVar-1); iVar++) { val_Jacobian_i[iVar][iVar] += cte_0; val_Jacobian_j[iVar][iVar] -= cte_0; } - + /*--- Last rows ---*/ - + val_Jacobian_i[nVar-1][0] += cte_0*Gamma_Minus_One*0.5*sq_vel_i; for (iDim = 0; iDim < nDim; iDim++) val_Jacobian_i[nVar-1][iDim+1] -= cte_0*Gamma_Minus_One*Velocity_i[iDim]; val_Jacobian_i[nVar-1][nVar-1] += cte_0*Gamma; - + val_Jacobian_j[nVar-1][0] -= cte_0*Gamma_Minus_One*0.5*sq_vel_j; for (iDim = 0; iDim < nDim; iDim++) val_Jacobian_j[nVar-1][iDim+1] += cte_0*Gamma_Minus_One*Velocity_j[iDim]; val_Jacobian_j[nVar-1][nVar-1] -= cte_0*Gamma; - + } - + AD::SetPreaccOut(val_residual, nVar); AD::EndPreacc(); } diff --git a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwFDSInc_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwFDSInc_Flow.cpp index ce9bc1813bf5..3ca76f62e904 100644 --- a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwFDSInc_Flow.cpp +++ b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwFDSInc_Flow.cpp @@ -28,7 +28,7 @@ #include "../../../../include/numerics/flow/convection_upwind/CUpwFDSInc_Flow.hpp" CUpwFDSInc_Flow::CUpwFDSInc_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - + implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); variable_density = (config->GetKind_DensityModel() == VARIABLE); energy = config->GetEnergy_Equation(); @@ -45,16 +45,16 @@ CUpwFDSInc_Flow::CUpwFDSInc_Flow(unsigned short val_nDim, unsigned short val_nVa Epsilon = new su2double[nVar]; Precon = new su2double*[nVar]; invPrecon_A = new su2double*[nVar]; - + for (iVar = 0; iVar < nVar; iVar++) { Precon[iVar] = new su2double[nVar]; invPrecon_A[iVar] = new su2double[nVar]; } - + } CUpwFDSInc_Flow::~CUpwFDSInc_Flow(void) { - + delete [] Diff_V; delete [] Velocity_i; delete [] Velocity_j; @@ -63,18 +63,18 @@ CUpwFDSInc_Flow::~CUpwFDSInc_Flow(void) { delete [] ProjFlux_j; delete [] Lambda; delete [] Epsilon; - + for (iVar = 0; iVar < nVar; iVar++) { delete [] Precon[iVar]; delete [] invPrecon_A[iVar]; } delete [] Precon; delete [] invPrecon_A; - + } void CUpwFDSInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - + su2double U_i[5] = {0.0,0.0,0.0,0.0,0.0}, U_j[5] = {0.0,0.0,0.0,0.0,0.0}; su2double ProjGridVel = 0.0; @@ -86,21 +86,21 @@ void CUpwFDSInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_J } /*--- Face area (norm or the normal vector) ---*/ - + Area = 0.0; for (iDim = 0; iDim < nDim; iDim++) Area += Normal[iDim]*Normal[iDim]; Area = sqrt(Area); - + /*--- Compute and unitary normal vector ---*/ - + for (iDim = 0; iDim < nDim; iDim++) { UnitNormal[iDim] = Normal[iDim]/Area; if (fabs(UnitNormal[iDim]) < EPS) UnitNormal[iDim] = EPS; } - + /*--- Set primitive variables at points iPoint and jPoint ---*/ - + Pressure_i = V_i[0]; Pressure_j = V_j[0]; Temperature_i = V_i[nDim+1]; Temperature_j = V_j[nDim+1]; DensityInc_i = V_i[nDim+2]; DensityInc_j = V_j[nDim+2]; @@ -115,19 +115,19 @@ void CUpwFDSInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_J MeanVelocity[iDim] = 0.5*(Velocity_i[iDim] + Velocity_j[iDim]); ProjVelocity += MeanVelocity[iDim]*Normal[iDim]; } - + /*--- Projected velocity adjustment due to mesh motion ---*/ - - if (dynamic_grid) { - ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - } - ProjVelocity -= ProjGridVel; + + if (dynamic_grid) { + ProjGridVel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; + } + ProjVelocity -= ProjGridVel; } /*--- Mean variables at points iPoint and jPoint ---*/ - + MeanDensity = 0.5*(DensityInc_i + DensityInc_j); MeanPressure = 0.5*(Pressure_i + Pressure_j); MeanBetaInc2 = 0.5*(BetaInc2_i + BetaInc2_j); @@ -153,13 +153,13 @@ void CUpwFDSInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_J /*--- Compute ProjFlux_i ---*/ GetInviscidIncProjFlux(&DensityInc_i, Velocity_i, &Pressure_i, &BetaInc2_i, &Enthalpy_i, Normal, ProjFlux_i); - + /*--- Compute ProjFlux_j ---*/ GetInviscidIncProjFlux(&DensityInc_j, Velocity_j, &Pressure_j, &BetaInc2_j, &Enthalpy_j, Normal, ProjFlux_j); /*--- Eigenvalues of the preconditioned system ---*/ - + if (nDim == 2) { Lambda[0] = ProjVelocity; Lambda[1] = ProjVelocity; @@ -173,9 +173,9 @@ void CUpwFDSInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_J Lambda[3] = ProjVelocity - MeanSoundSpeed; Lambda[4] = ProjVelocity + MeanSoundSpeed; } - + /*--- Absolute value of the eigenvalues ---*/ - + for (iVar = 0; iVar < nVar; iVar++) Lambda[iVar] = fabs(Lambda[iVar]); diff --git a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwGeneralHLLC_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwGeneralHLLC_Flow.cpp index e53c32efb963..b33d9f06057e 100644 --- a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwGeneralHLLC_Flow.cpp +++ b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwGeneralHLLC_Flow.cpp @@ -28,14 +28,14 @@ #include "../../../../include/numerics/flow/convection_upwind/CUpwGeneralHLLC_Flow.hpp" CUpwGeneralHLLC_Flow::CUpwGeneralHLLC_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - + implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); kappa = config->GetRoe_Kappa(); /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ dynamic_grid = config->GetDynamic_Grid(); - + Gamma = config->GetGamma(); - + IntermediateState = new su2double [nVar]; dSm_dU = new su2double [nVar]; dPI_dU = new su2double [nVar]; @@ -50,7 +50,7 @@ CUpwGeneralHLLC_Flow::CUpwGeneralHLLC_Flow(unsigned short val_nDim, unsigned sho } CUpwGeneralHLLC_Flow::~CUpwGeneralHLLC_Flow(void) { - + delete [] IntermediateState; delete [] dSm_dU; delete [] dPI_dU; @@ -67,15 +67,15 @@ CUpwGeneralHLLC_Flow::~CUpwGeneralHLLC_Flow(void) { void CUpwGeneralHLLC_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { /*--- Face area (norm or the normal vector) ---*/ - + Area = 0.0; for (iDim = 0; iDim < nDim; iDim++) Area += Normal[iDim] * Normal[iDim]; Area = sqrt(Area); - + /*-- Unit Normal ---*/ - + for (iDim = 0; iDim < nDim; iDim++) UnitNormal[iDim] = Normal[iDim] / Area; @@ -93,7 +93,7 @@ void CUpwGeneralHLLC_Flow::ComputeResidual(su2double *val_residual, su2double ** Enthalpy_i = V_i[nDim+3]; /*--- Primitive variables at point j ---*/ - + Pressure_j = V_j[nDim+1]; Density_j = V_j[nDim+2]; Enthalpy_j = V_j[nDim+3]; @@ -110,11 +110,11 @@ void CUpwGeneralHLLC_Flow::ComputeResidual(su2double *val_residual, su2double ** Energy_i = Enthalpy_i - Pressure_i / Density_i; StaticEnthalpy_i = Enthalpy_i - 0.5 * sq_vel_i; StaticEnergy_i = Energy_i - 0.5 * sq_vel_i; - + Kappa_i = S_i[1] / Density_i; Chi_i = S_i[0] - Kappa_i * StaticEnergy_i; SoundSpeed_i = sqrt(Chi_i + StaticEnthalpy_i * Kappa_i); - + Energy_j = Enthalpy_j - Pressure_j / Density_j; StaticEnthalpy_j = Enthalpy_j - 0.5 * sq_vel_j; @@ -123,17 +123,17 @@ void CUpwGeneralHLLC_Flow::ComputeResidual(su2double *val_residual, su2double ** Kappa_j = S_j[1] / Density_j; Chi_j = S_j[0] - Kappa_j * StaticEnergy_j; SoundSpeed_j = sqrt(Chi_j + StaticEnthalpy_j * Kappa_j); - + /*--- Projected velocities ---*/ - - ProjVelocity_i = 0.0; + + ProjVelocity_i = 0.0; ProjVelocity_j = 0.0; for (iDim = 0; iDim < nDim; iDim++) { ProjVelocity_i += Velocity_i[iDim] * UnitNormal[iDim]; ProjVelocity_j += Velocity_j[iDim] * UnitNormal[iDim]; } - + /*--- Projected Grid Velocity ---*/ @@ -147,9 +147,9 @@ void CUpwGeneralHLLC_Flow::ComputeResidual(su2double *val_residual, su2double ** SoundSpeed_i -= ProjInterfaceVel; SoundSpeed_j += ProjInterfaceVel; - ProjVelocity_i -= ProjInterfaceVel; + ProjVelocity_i -= ProjInterfaceVel; ProjVelocity_j -= ProjInterfaceVel; - } + } /*--- Roe's averaging ---*/ @@ -162,10 +162,10 @@ void CUpwGeneralHLLC_Flow::ComputeResidual(su2double *val_residual, su2double ** RoeVelocity[iDim] = ( Velocity_i[iDim] * sqrt(Density_i) + Velocity_j[iDim] * sqrt(Density_j) ) / Rrho; sq_velRoe += RoeVelocity[iDim] * RoeVelocity[iDim]; RoeProjVelocity += RoeVelocity[iDim] * UnitNormal[iDim]; - } + } /*--- Mean Roe variables iPoint and jPoint ---*/ - + RoeKappa = 0.5 * ( Kappa_i + Kappa_j ); RoeChi = 0.5 * ( Chi_i + Chi_j ); RoeDensity = sqrt( Density_i * Density_j ); @@ -179,17 +179,17 @@ void CUpwGeneralHLLC_Flow::ComputeResidual(su2double *val_residual, su2double ** RoeSoundSpeed = sqrt( RoeChi + RoeKappa * ( RoeEnthalpy - 0.5 * sq_velRoe ) ) - ProjInterfaceVel; /*--- Speed of sound at L and R ---*/ - + sL = min( RoeProjVelocity - RoeSoundSpeed, ProjVelocity_i - SoundSpeed_i ); sR = max( RoeProjVelocity + RoeSoundSpeed, ProjVelocity_j + SoundSpeed_j ); - + /*--- speed of contact surface ---*/ RHO = Density_j * (sR - ProjVelocity_j) - Density_i * (sL - ProjVelocity_i); sM = ( Pressure_i - Pressure_j - Density_i * ProjVelocity_i * ( sL - ProjVelocity_i ) + Density_j * ProjVelocity_j * ( sR - ProjVelocity_j ) ) / RHO; - + /*--- Pressure at right and left (Pressure_j=Pressure_i) side of contact surface ---*/ - + pStar = Density_j * ( ProjVelocity_j - sR ) * ( ProjVelocity_j - sM ) + Pressure_j; @@ -263,9 +263,9 @@ if (sM > 0.0) { if (sL > 0.0) { /*--- Compute Jacobian based on Left State ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) + + for (iVar = 0; iVar < nVar; iVar++) + for (jVar = 0; jVar < nVar; jVar++) val_Jacobian_j[iVar][jVar] = 0; @@ -286,11 +286,11 @@ if (sM > 0.0) { /*--- Computing pressure derivatives d/dU_L (PI) ---*/ dPI_dU[0] = Chi_i - 0.5 * Kappa_i * sq_vel_i; - for (iDim = 0; iDim < nDim; iDim++) + for (iDim = 0; iDim < nDim; iDim++) dPI_dU[iDim+1] = - Kappa_i * Velocity_i[iDim]; dPI_dU[nVar-1] = Kappa_i; - + /*--- Computing d/dU_L (Sm) ---*/ dSm_dU[0] = ( - ProjVelocity_i * ProjVelocity_i + sM * sL + dPI_dU[0] ) / RHO; @@ -306,7 +306,7 @@ if (sM > 0.0) { drhoStar_dU[iDim+1] = Omega * ( - UnitNormal[iDim] + IntermediateState[0] * dSm_dU[iDim+1] ); drhoStar_dU[nVar-1] = Omega * IntermediateState[0] * dSm_dU[nVar-1]; - + /*--- Computing d/dU_L (pStar) ---*/ for (iVar = 0; iVar < nVar; iVar++) @@ -317,7 +317,7 @@ if (sM > 0.0) { for (iVar = 0; iVar < nVar; iVar++) dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); - + dEStar_dU[0] += Omega * ProjVelocity_i * ( Enthalpy_i - dPI_dU[0] ); for (iDim = 0; iDim < nDim; iDim++) dEStar_dU[iDim+1] += Omega * ( - UnitNormal[iDim] * Enthalpy_i - ProjVelocity_i * dPI_dU[iDim+1] ); @@ -326,7 +326,7 @@ if (sM > 0.0) { /*--- Jacobian First Row ---*/ - + for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[0][iVar] = sM * drhoStar_dU[iVar] + IntermediateState[0] * dSm_dU[iVar]; @@ -340,7 +340,7 @@ if (sM > 0.0) { val_Jacobian_i[jDim+1][0] += OmegaSM * Velocity_i[jDim] * ProjVelocity_i; val_Jacobian_i[jDim+1][jDim+1] += OmegaSM * (sL - ProjVelocity_i); - + for (iDim = 0; iDim < nDim; iDim++) val_Jacobian_i[jDim+1][iDim+1] -= OmegaSM * Velocity_i[jDim] * UnitNormal[iDim]; @@ -349,7 +349,7 @@ if (sM > 0.0) { } /*--- Jacobian Last Row ---*/ - + for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[nVar-1][iVar] = sM * ( dEStar_dU[iVar] + dpStar_dU[iVar] ) + ( EStar + pStar ) * dSm_dU[iVar]; @@ -358,22 +358,22 @@ if (sM > 0.0) { /*--------- Right Jacobian ---------*/ - + /*--- Computing pressure derivatives d/dU_R (PI) ---*/ dPI_dU[0] = Chi_j - 0.5 * Kappa_j * sq_vel_j; - for (iDim = 0; iDim < nDim; iDim++) + for (iDim = 0; iDim < nDim; iDim++) dPI_dU[iDim+1] = - Kappa_j * Velocity_j[iDim]; dPI_dU[nVar-1] = Kappa_j; /*--- Computing d/dU_R (Sm) ---*/ - + dSm_dU[0] = ( ProjVelocity_j * ProjVelocity_j - sM * sR - dPI_dU[0] ) / RHO; for (iDim = 0; iDim < nDim; iDim++) dSm_dU[iDim+1] = - ( UnitNormal[iDim] * ( 2 * ProjVelocity_j - sR - sM) + dPI_dU[iDim+1] ) / RHO; dSm_dU[nVar-1] = - dPI_dU[nVar-1] / RHO; - + /*--- Computing d/dU_R (pStar) ---*/ @@ -385,7 +385,7 @@ if (sM > 0.0) { for (iVar = 0; iVar < nVar; iVar++) dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); - + /*--- Jacobian First Row ---*/ @@ -410,13 +410,13 @@ if (sM > 0.0) { if (sR < 0.0) { /*--- Compute Jacobian based on Right State ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) + + for (iVar = 0; iVar < nVar; iVar++) + for (jVar = 0; jVar < nVar; jVar++) val_Jacobian_i[iVar][jVar] = 0; GetInviscidProjJac(Velocity_j, &Enthalpy_j, &Chi_j, &Kappa_j, UnitNormal, 1.0, val_Jacobian_j); - + } else { /*--- Compute Jacobian based on Right Star State ---*/ @@ -432,7 +432,7 @@ if (sM > 0.0) { /*--- Computing pressure derivatives d/dU_L (PI) ---*/ dPI_dU[0] = Chi_i - 0.5 * Kappa_i * sq_vel_i; - for (iDim = 0; iDim < nDim; iDim++) + for (iDim = 0; iDim < nDim; iDim++) dPI_dU[iDim+1] = - Kappa_i * Velocity_i[iDim]; dPI_dU[nVar-1] = Kappa_i; @@ -443,8 +443,8 @@ if (sM > 0.0) { for (iDim = 0; iDim < nDim; iDim++) dSm_dU[iDim+1] = ( UnitNormal[iDim] * ( 2 * ProjVelocity_i - sL - sM ) + dPI_dU[iDim+1] ) / RHO; dSm_dU[nVar-1] = dPI_dU[nVar-1] / RHO; - - + + /*--- Computing d/dU_L (pStar) ---*/ for (iVar = 0; iVar < nVar; iVar++) @@ -455,7 +455,7 @@ if (sM > 0.0) { for (iVar = 0; iVar < nVar; iVar++) dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); - + /*--- Jacobian First Row ---*/ @@ -479,17 +479,17 @@ if (sM > 0.0) { /*--------- Right Jacobian ---------*/ - + /*--- Computing pressure derivatives d/dU_R (PI) ---*/ dPI_dU[0] = Chi_j - 0.5 * Kappa_j * sq_vel_j; - for (iDim = 0; iDim < nDim; iDim++) + for (iDim = 0; iDim < nDim; iDim++) dPI_dU[iDim+1] = - Kappa_j * Velocity_j[iDim]; dPI_dU[nVar-1] = Kappa_j; /*--- Computing d/dU_R (Sm) ---*/ - + dSm_dU[0] = - ( - ProjVelocity_j * ProjVelocity_j + sM * sR + dPI_dU[0] ) / RHO; for (iDim = 0; iDim < nDim; iDim++) dSm_dU[iDim+1] = - ( UnitNormal[iDim] * ( 2 * ProjVelocity_j - sR - sM) + dPI_dU[iDim+1] ) / RHO; @@ -501,7 +501,7 @@ if (sM > 0.0) { for (iVar = 0; iVar < nVar; iVar++) dpStar_dU[iVar] = Density_j * (sL - ProjVelocity_i) * dSm_dU[iVar]; - + /*--- Computing d/dU_R (rhoStar) ---*/ drhoStar_dU[0] = Omega * ( sR + IntermediateState[0] * dSm_dU[0] ); @@ -514,7 +514,7 @@ if (sM > 0.0) { for (iVar = 0; iVar < nVar; iVar++) dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); - + dEStar_dU[0] += Omega * ProjVelocity_j * ( Enthalpy_j - dPI_dU[0] ); for (iDim = 0; iDim < nDim; iDim++) dEStar_dU[iDim+1] += Omega * ( - UnitNormal[iDim] * Enthalpy_j - ProjVelocity_j * dPI_dU[iDim+1] ); @@ -523,7 +523,7 @@ if (sM > 0.0) { /*--- Jacobian First Row ---*/ - + for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[0][iVar] = sM * drhoStar_dU[iVar] + IntermediateState[0] * dSm_dU[iVar]; @@ -536,18 +536,18 @@ if (sM > 0.0) { val_Jacobian_j[jDim+1][0] += OmegaSM * Velocity_j[jDim] * ProjVelocity_j; val_Jacobian_j[jDim+1][jDim+1] += OmegaSM * (sR - ProjVelocity_j); - + for (iDim = 0; iDim < nDim; iDim++) val_Jacobian_j[jDim+1][iDim+1] -= OmegaSM * Velocity_j[jDim] * UnitNormal[iDim]; for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[jDim+1][iVar] -= OmegaSM * dPI_dU[iVar] * UnitNormal[jDim]; } - + /*--- Jacobian Last Row ---*/ - + for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[nVar-1][iVar] = sM * ( dEStar_dU[iVar] + dpStar_dU[iVar] ) + ( EStar + pStar ) * dSm_dU[iVar]; + val_Jacobian_j[nVar-1][iVar] = sM * ( dEStar_dU[iVar] + dpStar_dU[iVar] ) + ( EStar + pStar ) * dSm_dU[iVar]; } } @@ -555,7 +555,7 @@ if (sM > 0.0) { /*--- Jacobians of the inviscid flux, scale = kappa because val_residual ~ 0.5*(fc_i+fc_j)*Normal ---*/ Area *= kappa; - + for (iVar = 0; iVar < nVar; iVar++) { for (jVar = 0; jVar < nVar; jVar++) { val_Jacobian_i[iVar][jVar] *= Area; @@ -606,15 +606,15 @@ int UgpWithCvCompFlow::calcEulerFluxMatrices_HLLC(su2double (*val_Jacobian_i)[5] su2double hL = gammaL/(gammaL-1.0)*pL/Density_i + 0.5*uLuL + kL; // su2double hL = h0 + 0.5*uLuL + kL; su2double eL = hL*Density_i-pL; - + su2double unR = vecDotVec3d(uR, nVec); su2double uRuR = vecDotVec3d(uR, uR); su2double cR = sqrt(gammaR*pR/Density_j); su2double hR = gammaR/(gammaR-1.0)*pR/Density_j + 0.5*uRuR + kR; // su2double hR = h1 + 0.5*uRuR + kR; su2double eR = hR*Density_j-pR; - - + + // Roe's aveaging su2double Rrho = sqrt(Density_j/Density_i); su2double tmp = 1.0/(1.0+Rrho); @@ -623,109 +623,109 @@ int UgpWithCvCompFlow::calcEulerFluxMatrices_HLLC(su2double (*val_Jacobian_i)[5] velRoe[i] = tmp*(uL[i] + uR[i]*Rrho); su2double uRoe = vecDotVec3d(velRoe, nVec); su2double hRoe = tmp*(hL + hR*Rrho); - + // su2double cRoe = sqrt((gammaL-1.0)*(hRoe- 0.5*vecDotVec3d(velRoe, velRoe))); su2double gamPdivRho = tmp*((gammaL*pL/Density_i+0.5*(gammaL-1.0)*uLuL) + (gammaR*pR/Density_j+0.5*(gammaR-1.0)*uRuR)*Rrho); su2double cRoe = sqrt(gamPdivRho - ((gammaL+gammaR)*0.5-1.0)*0.5*vecDotVec3d(velRoe, velRoe)); - + // speed of sound at L and R su2double sL = min(uRoe-cRoe, unL-cL); su2double sR = max(uRoe+cRoe, unR+cR); - + // speed of contact surface su2double sM = (pL-pR-Density_i*unL*(sL-unL)+Density_j*unR*(sR-unR))/(Density_j*(sR-unR)-Density_i*(sL-unL)); - + // pressure at right and left (pR=pL) side of contact surface su2double pStar = Density_j*(unR-sR)*(unR-sM)+pR; - + if (sM >= 0.0) { - + if (sL > 0.0) { - + su2double nVecArea[3]; for (int i=0; i<3; i++) nVecArea[i] = nVec[i]*area; - + calcJacobianA(val_Jacobian_i, uL, pL, Density_i, nVecArea, 0.5*(gammaL+gammaR), 0.0); - + for (iVar = 0; iVar < nVar; iVar++) for (jVar = 0; jVar < nVar; jVar++) val_Jacobian_j[i][j] = 0.0; - + } else { - + su2double invSLmSs = 1.0/(sL-sM); su2double sLmuL = sL-unL; su2double rhoSL = Density_i*sLmuL*invSLmSs; su2double rhouSL[3]; - + for (int i=0; i<3; i++) rhouSL[i] = (Density_i*uL[i]*sLmuL+(pStar-pL)*nVec[i])*invSLmSs; - + su2double eSL = (sLmuL*eL-pL*unL+pStar*sM)*invSLmSs; su2double gammaLM1 = (gammaL-1.0); su2double gammaRM1 = (gammaR-1.0); su2double invrhotld = 1.0/(Density_j*(sR-unR)-Density_i*(sL-unL)); - + su2double dSMdUL[5], dSMdUR[5]; su2double dpsdUL[5], dpsdUR[5]; - + dSMdUL[0] = -unL*unL + uLuL*gammaLM1/2.0 + sM*sL; dSMdUL[1] = nVec[0]*(2.0*unL-sL-sM) - gammaLM1*uL[0]; dSMdUL[2] = nVec[1]*(2.0*unL-sL-sM) - gammaLM1*uL[1]; dSMdUL[3] = nVec[2]*(2.0*unL-sL-sM) - gammaLM1*uL[2]; dSMdUL[4] = gammaLM1; - + for (iVar = 0; iVar < nVar; iVar++) { dSMdUL[i] *= invrhotld; dpsdUL[i] = Density_j*(sR-unR)*dSMdUL[i]; } - + dSMdUR[0] = unR*unR - uRuR*gammaRM1/2.0 - sM*sR; dSMdUR[1] = -nVec[0]*(2.0*unR-sR-sM) + gammaRM1*uR[0]; dSMdUR[2] = -nVec[1]*(2.0*unR-sR-sM) + gammaRM1*uR[1]; dSMdUR[3] = -nVec[2]*(2.0*unR-sR-sM) + gammaRM1*uR[2]; dSMdUR[4] = -gammaRM1; - + for (iVar = 0; iVar < nVar; iVar++) { dSMdUR[i] *= invrhotld; dpsdUR[i] = Density_i*(sL-unL)*dSMdUR[i]; } - + calcSubSonicJacobeanHLLC(val_Jacobian_i, val_Jacobian_j, Density_i, uL, pL, eL, unL, uLuL, sL, rhoSL, rhouSL, eSL, dSMdUL, dSMdUR, dpsdUL, dpsdUR, sM, pStar, 0.5*(gammaL+gammaR), nVec); - + for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[0][i] = val_Jacobian_i[0][i]*sM + dSMdUL[i]*rhoSL; for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[1][i] = val_Jacobian_i[1][i]*sM + dSMdUL[i]*rhouSL[0] + dpsdUL[i]*nVec[0]; for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[2][i] = val_Jacobian_i[2][i]*sM + dSMdUL[i]*rhouSL[1] + dpsdUL[i]*nVec[1]; for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[3][i] = val_Jacobian_i[3][i]*sM + dSMdUL[i]*rhouSL[2] + dpsdUL[i]*nVec[2]; for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[4][i] = (val_Jacobian_i[4][i]+dpsdUL[i])*sM + (eSL+pStar)*dSMdUL[i]; - + for (iVar = 0; iVar < nVar; iVar++) for (jVar = 0; jVar < nVar; jVar++) val_Jacobian_i[i][j] *= area; - + for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[0][i] = val_Jacobian_j[0][i]*sM + dSMdUR[i]*rhoSL; for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[1][i] = val_Jacobian_j[1][i]*sM + dSMdUR[i]*rhouSL[0] + dpsdUR[i]*nVec[0]; for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[2][i] = val_Jacobian_j[2][i]*sM + dSMdUR[i]*rhouSL[1] + dpsdUR[i]*nVec[1]; for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[3][i] = val_Jacobian_j[3][i]*sM + dSMdUR[i]*rhouSL[2] + dpsdUR[i]*nVec[2]; for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[4][i] = (val_Jacobian_j[4][i]+dpsdUR[i])*sM + (eSL+pStar)*dSMdUR[i]; - + for (iVar = 0; iVar < nVar; iVar++) for (jVar = 0; jVar < nVar; jVar++) val_Jacobian_j[i][j] *= area; - + } } - + else { - + if (sR >= 0.0) { - + su2double invSRmSs = 1.0/(sR-sM); su2double sRmuR = sR-unR; su2double rhoSR = Density_j*sRmuR*invSRmSs; @@ -736,73 +736,73 @@ int UgpWithCvCompFlow::calcEulerFluxMatrices_HLLC(su2double (*val_Jacobian_i)[5] su2double gammaLM1 = (gammaL-1.0); su2double gammaRM1 = (gammaR-1.0); su2double invrhotld = 1.0/(Density_j*(sR-unR)-Density_i*(sL-unL)); - + su2double dSMdUL[5], dSMdUR[5]; su2double dpsdUL[5], dpsdUR[5]; - + dSMdUL[0] = -unL*unL + uLuL*gammaLM1/2.0 + sM*sL; dSMdUL[1] = nVec[0]*(2.0*unL-sL-sM) - gammaLM1*uL[0]; dSMdUL[2] = nVec[1]*(2.0*unL-sL-sM) - gammaLM1*uL[1]; dSMdUL[3] = nVec[2]*(2.0*unL-sL-sM) - gammaLM1*uL[2]; dSMdUL[4] = gammaLM1; - + for (iVar = 0; iVar < nVar; iVar++) { dSMdUL[i] *= invrhotld; dpsdUL[i] = Density_j*(sR-unR)*dSMdUL[i]; } - + dSMdUR[0] = unR*unR - uRuR*gammaRM1/2.0 - sM*sR; dSMdUR[1] = -nVec[0]*(2.0*unR-sR-sM) + gammaRM1*uR[0]; dSMdUR[2] = -nVec[1]*(2.0*unR-sR-sM) + gammaRM1*uR[1]; dSMdUR[3] = -nVec[2]*(2.0*unR-sR-sM) + gammaRM1*uR[2]; dSMdUR[4] = -gammaRM1; - + for (iVar = 0; iVar < nVar; iVar++) { dSMdUR[i] *= invrhotld; dpsdUR[i] = Density_i*(sL-unL)*dSMdUR[i]; } - + calcSubSonicJacobeanHLLC(val_Jacobian_j, val_Jacobian_i, Density_j, uR, pR, eR, unR, uRuR, sR, rhoSR, rhouSR, eSR, dSMdUR, dSMdUL, dpsdUR, dpsdUL, sM, pStar, 0.5*(gammaL+gammaR), nVec); - + for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[0][i] = val_Jacobian_i[0][i]*sM + dSMdUL[i]*rhoSR; for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[1][i] = val_Jacobian_i[1][i]*sM + dSMdUL[i]*rhouSR[0] + dpsdUL[i]*nVec[0]; for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[2][i] = val_Jacobian_i[2][i]*sM + dSMdUL[i]*rhouSR[1] + dpsdUL[i]*nVec[1]; for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[3][i] = val_Jacobian_i[3][i]*sM + dSMdUL[i]*rhouSR[2] + dpsdUL[i]*nVec[2]; for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[4][i] = (val_Jacobian_i[4][i]+dpsdUL[i])*sM + (eSR+pStar)*dSMdUL[i]; - + for (iVar = 0; iVar < nVar; iVar++) for (jVar = 0; jVar < nVar; jVar++) val_Jacobian_i[i][j] *= area; - + for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[0][i] = val_Jacobian_j[0][i]*sM + dSMdUR[i]*rhoSR; for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[1][i] = val_Jacobian_j[1][i]*sM + dSMdUR[i]*rhouSR[0] + dpsdUR[i]*nVec[0]; for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[2][i] = val_Jacobian_j[2][i]*sM + dSMdUR[i]*rhouSR[1] + dpsdUR[i]*nVec[1]; for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[3][i] = val_Jacobian_j[3][i]*sM + dSMdUR[i]*rhouSR[2] + dpsdUR[i]*nVec[2]; for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[4][i] = (val_Jacobian_j[4][i]+dpsdUR[i])*sM + (eSR+pStar)*dSMdUR[i]; - + for (iVar = 0; iVar < nVar; iVar++) for (jVar = 0; jVar < nVar; jVar++) val_Jacobian_j[i][j] *= area; - + } - + else { - + su2double nVecArea[3]; for (int i=0; i<3; i++) nVecArea[i] = nVec[i]*area; calcJacobianA(val_Jacobian_j, uR, pR, Density_j, nVecArea, 0.5*(gammaL+gammaR), 0.0); - + for (iVar = 0; iVar < nVar; iVar++) for (jVar = 0; jVar < nVar; jVar++) val_Jacobian_i[i][j] = 0.0; - + } - + } - + } void UgpWithCvCompFlow::calcSubSonicJacobeanHLLC(su2double (*AL)[5], su2double (*AR)[5], @@ -811,57 +811,57 @@ void UgpWithCvCompFlow::calcSubSonicJacobeanHLLC(su2double (*AL)[5], su2double ( su2double *dSMdUL, su2double *dSMdUR, su2double *dpsdUL, su2double *dpsdUR, su2double SM, su2double pS, su2double gamma, const su2double *nV) // nV is not normalized { - + su2double gammaMinus1 = (gamma-1.0); su2double omL = 1.0/(SL-SM); - + AL[0][0] = SL + rhoSL*dSMdUL[0]; AL[0][1] = -nV[0] + rhoSL*dSMdUL[1]; AL[0][2] = -nV[1] + rhoSL*dSMdUL[2]; AL[0][3] = -nV[2] + rhoSL*dSMdUL[3]; AL[0][4] = + rhoSL*dSMdUL[4]; - + AL[1][0] = qL*uL[0] - nV[0]*psiL*gammaMinus1/2.0 + nV[0]*dpsdUL[0] + rhouSL[0]*dSMdUL[0]; AL[1][1] = SL - qL + nV[0]*(gamma-2.0)*uL[0] + nV[0]*dpsdUL[1] + rhouSL[0]*dSMdUL[1]; AL[1][2] = - uL[0]*nV[1] + nV[0]*gammaMinus1*uL[1] + nV[0]*dpsdUL[2] + rhouSL[0]*dSMdUL[2]; AL[1][3] = - uL[0]*nV[2] + nV[0]*gammaMinus1*uL[2] + nV[0]*dpsdUL[3] + rhouSL[0]*dSMdUL[3]; AL[1][4] = -gammaMinus1*nV[0] + nV[0]*dpsdUL[4] + rhouSL[0]*dSMdUL[4]; - + AL[2][0] = qL*uL[1] - nV[1]*psiL*gammaMinus1/2.0 + nV[1]*dpsdUL[0] + rhouSL[1]*dSMdUL[0]; AL[2][1] = - uL[1]*nV[0] + nV[1]*gammaMinus1*uL[0] + nV[1]*dpsdUL[1] + rhouSL[1]*dSMdUL[1]; AL[2][2] = SL - qL + nV[1]*(gamma-2.0)*uL[1] + nV[1]*dpsdUL[2] + rhouSL[1]*dSMdUL[2]; AL[2][3] = - uL[1]*nV[2] + nV[1]*gammaMinus1*uL[2] + nV[1]*dpsdUL[3] + rhouSL[1]*dSMdUL[3]; AL[2][4] = -gammaMinus1*nV[1] + nV[1]*dpsdUL[4] + rhouSL[1]*dSMdUL[4]; - + AL[3][0] = qL*uL[2] - nV[2]*psiL*gammaMinus1/2.0 + nV[2]*dpsdUL[0] + rhouSL[2]*dSMdUL[0]; AL[3][1] = - uL[2]*nV[0] + nV[2]*gammaMinus1*uL[0] + nV[2]*dpsdUL[1] + rhouSL[2]*dSMdUL[1]; AL[3][2] = - uL[2]*nV[1] + nV[2]*gammaMinus1*uL[1] + nV[2]*dpsdUL[2] + rhouSL[2]*dSMdUL[2]; AL[3][3] = SL - qL + nV[2]*(gamma-2.0)*uL[2] + nV[2]*dpsdUL[3] + rhouSL[2]*dSMdUL[3]; AL[3][4] = -gammaMinus1*nV[2] + nV[2]*dpsdUL[4] + rhouSL[2]*dSMdUL[4]; - + AL[4][0] = qL*(eL+pL)/Density_i - qL*psiL*(gamma-1.0)/2.0 + SM*dpsdUL[0] + (pS+eSL)*dSMdUL[0]; AL[4][1] = - nV[0]*(eL+pL)/Density_i + gammaMinus1*uL[0]*qL + SM*dpsdUL[1] + (pS+eSL)*dSMdUL[1]; AL[4][2] = - nV[1]*(eL+pL)/Density_i + gammaMinus1*uL[1]*qL + SM*dpsdUL[2] + (pS+eSL)*dSMdUL[2]; AL[4][3] = - nV[2]*(eL+pL)/Density_i + gammaMinus1*uL[2]*qL + SM*dpsdUL[3] + (pS+eSL)*dSMdUL[3]; AL[4][4] = SL-qL*gamma + SM*dpsdUL[4] + (pS+eSL)*dSMdUL[4]; - + for (iVar = 0; iVar < nVar; iVar++) for (jVar = 0; jVar < nVar; jVar++) AL[i][j] *= omL; - + for (iVar = 0; iVar < nVar; iVar++) AR[0][i] = omL*rhoSL*dSMdUR[i]; for (iVar = 0; iVar < nVar; iVar++) AR[1][i] = omL*(nV[0]*dpsdUR[i]+rhouSL[0]*dSMdUR[i]); for (iVar = 0; iVar < nVar; iVar++) AR[2][i] = omL*(nV[1]*dpsdUR[i]+rhouSL[1]*dSMdUR[i]); for (iVar = 0; iVar < nVar; iVar++) AR[3][i] = omL*(nV[2]*dpsdUR[i]+rhouSL[2]*dSMdUR[i]); for (iVar = 0; iVar < nVar; iVar++) AR[4][i] = omL*(dpsdUR[i]*SM+(pS+eSL)*dSMdUR[i]); - + } void UgpWithCvCompFlow::calcJacobianA(su2double (*A)[5], const su2double *vel, su2double pp, su2double rrho, const su2double *nV, su2double gamma, su2double surfVeloc) // nV is not normalized { - + su2double kapm1 = (gamma - 1.0); - + su2double nVel[3]; nVel[0] = vel[0]*nV[0]; nVel[1] = vel[1]*nV[1]; @@ -870,37 +870,37 @@ void UgpWithCvCompFlow::calcJacobianA(su2double (*A)[5], const su2double *vel, s su2double vSquHlf = 0.5*vecDotVec3d(vel, vel); su2double c = sqrt(gamma*pp/rrho); su2double inv_kap_m1 = 1.0/kapm1; - + A[0][0] =-surfVeloc; A[0][1] = nV[0]; A[0][2] = nV[1]; A[0][3] = nV[2]; A[0][4] = 0.0; - + A[1][0] = -vel[0]*(nVel[1]+nVel[2])+nV[0]*(kapm1*vSquHlf-vel[0]*vel[0]); A[1][1] = (2.-gamma)*nVel[0]+U_k-surfVeloc; A[1][2] = vel[0]*nV[1]-kapm1*vel[1]*nV[0]; A[1][3] = vel[0]*nV[2]-kapm1*vel[2]*nV[0]; A[1][4] = kapm1*nV[0]; - + A[2][0] = -vel[1]*(nVel[0]+nVel[2])+nV[1]*(kapm1*vSquHlf-vel[1]*vel[1]); A[2][1] = -kapm1*vel[0]*nV[1]+ vel[1]*nV[0]; A[2][2] = (2.-gamma)*nVel[1]+U_k-surfVeloc; A[2][3] = vel[1]*nV[2]-kapm1*vel[2]*nV[1]; A[2][4] = kapm1*nV[1]; - + A[3][0] = -vel[2]*(nVel[0]+nVel[1])+nV[2]*(kapm1*vSquHlf-vel[2]*vel[2]); A[3][1] = -kapm1*vel[0]*nV[2]+vel[2]*nV[0]; A[3][2] = -kapm1*vel[1]*nV[2]+vel[2]*nV[1]; A[3][3] = (2.-gamma)*nVel[2]+U_k-surfVeloc; A[3][4] = kapm1*nV[2]; - + A[4][0] = U_k*((gamma-2.)*vSquHlf-c*c*inv_kap_m1); A[4][1] = c*c*inv_kap_m1*nV[0]-kapm1*vel[0]*(nVel[1]+nVel[2])-(kapm1*vel[0]*vel[0]-vSquHlf)*nV[0]; A[4][2] = c*c*inv_kap_m1*nV[1]-kapm1*vel[1]*(nVel[0]+nVel[2])-(kapm1*vel[1]*vel[1]-vSquHlf)*nV[1]; A[4][3] = c*c*inv_kap_m1*nV[2]-kapm1*vel[2]*(nVel[0]+nVel[1])-(kapm1*vel[2]*vel[2]-vSquHlf)*nV[2]; A[4][4] = gamma*U_k-surfVeloc; - + } diff --git a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwHLLC_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwHLLC_Flow.cpp index a926c9b9b5ef..d29af2fdbaee 100644 --- a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwHLLC_Flow.cpp +++ b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwHLLC_Flow.cpp @@ -28,16 +28,16 @@ #include "../../../../include/numerics/flow/convection_upwind/CUpwHLLC_Flow.hpp" CUpwHLLC_Flow::CUpwHLLC_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - + implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); kappa = config->GetRoe_Kappa(); /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ dynamic_grid = config->GetDynamic_Grid(); - + Gamma = config->GetGamma(); Gamma_Minus_One = Gamma - 1.0; - + IntermediateState = new su2double [nVar]; dSm_dU = new su2double [nVar]; dPI_dU = new su2double [nVar]; @@ -47,12 +47,12 @@ CUpwHLLC_Flow::CUpwHLLC_Flow(unsigned short val_nDim, unsigned short val_nVar, C Velocity_i = new su2double [nDim]; Velocity_j = new su2double [nDim]; - RoeVelocity = new su2double [nDim]; - + RoeVelocity = new su2double [nDim]; + } CUpwHLLC_Flow::~CUpwHLLC_Flow(void) { - + delete [] IntermediateState; delete [] dSm_dU; delete [] dPI_dU; @@ -63,25 +63,25 @@ CUpwHLLC_Flow::~CUpwHLLC_Flow(void) { delete [] Velocity_i; delete [] Velocity_j; delete [] RoeVelocity; - + } void CUpwHLLC_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - + /*--- Face area (norm or the normal vector) ---*/ - + Area = 0.0; for (iDim = 0; iDim < nDim; iDim++) Area += Normal[iDim] * Normal[iDim]; Area = sqrt(Area); - + /*-- Unit Normal ---*/ - + for (iDim = 0; iDim < nDim; iDim++) UnitNormal[iDim] = Normal[iDim] / Area; - /*-- Fluid velocity at node i,j ---*/ + /*-- Fluid velocity at node i,j ---*/ for (iDim = 0; iDim < nDim; iDim++) { Velocity_i[iDim] = V_i[iDim+1]; @@ -95,7 +95,7 @@ void CUpwHLLC_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jac Enthalpy_i = V_i[nDim+3]; /*--- Primitive variables at point j ---*/ - + Pressure_j = V_j[nDim+1]; Density_j = V_j[nDim+2]; Enthalpy_j = V_j[nDim+3]; @@ -114,10 +114,10 @@ void CUpwHLLC_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jac SoundSpeed_i = sqrt( (Enthalpy_i - 0.5 * sq_vel_i) * Gamma_Minus_One ); SoundSpeed_j = sqrt( (Enthalpy_j - 0.5 * sq_vel_j) * Gamma_Minus_One ); - + /*--- Projected velocities ---*/ - - ProjVelocity_i = 0; + + ProjVelocity_i = 0; ProjVelocity_j = 0; for (iDim = 0; iDim < nDim; iDim++) { @@ -137,10 +137,10 @@ void CUpwHLLC_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jac SoundSpeed_i -= ProjInterfaceVel; SoundSpeed_j += ProjInterfaceVel; - ProjVelocity_i -= ProjInterfaceVel; + ProjVelocity_i -= ProjInterfaceVel; ProjVelocity_j -= ProjInterfaceVel; - } - + } + /*--- Roe's averaging ---*/ Rrho = ( sqrt(Density_i) + sqrt(Density_j) ); @@ -152,10 +152,10 @@ void CUpwHLLC_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jac RoeVelocity[iDim] = ( Velocity_i[iDim] * sqrt(Density_i) + Velocity_j[iDim] * sqrt(Density_j) ) / Rrho; sq_velRoe += RoeVelocity[iDim] * RoeVelocity[iDim]; RoeProjVelocity += RoeVelocity[iDim] * UnitNormal[iDim]; - } + } /*--- Mean Roe variables iPoint and jPoint ---*/ - + RoeDensity = sqrt( Density_i * Density_j ); RoeEnthalpy = ( sqrt(Density_j) * Enthalpy_j + sqrt(Density_i) * Enthalpy_i) / Rrho; @@ -166,17 +166,17 @@ void CUpwHLLC_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jac /*--- Speed of sound at L and R ---*/ - + sL = min( RoeProjVelocity - RoeSoundSpeed, ProjVelocity_i - SoundSpeed_i); sR = max( RoeProjVelocity + RoeSoundSpeed, ProjVelocity_j + SoundSpeed_j); - + /*--- speed of contact surface ---*/ RHO = Density_j * (sR - ProjVelocity_j) - Density_i * (sL - ProjVelocity_i); sM = ( Pressure_i - Pressure_j - Density_i * ProjVelocity_i * ( sL - ProjVelocity_i ) + Density_j * ProjVelocity_j * ( sR - ProjVelocity_j ) ) / RHO; - + /*--- Pressure at right and left (Pressure_j=Pressure_i) side of contact surface ---*/ - + pStar = Density_j * ( ProjVelocity_j - sR ) * ( ProjVelocity_j - sM ) + Pressure_j; @@ -215,7 +215,7 @@ if (sM > 0.0) { /*--- Compute Right Flux ---*/ - val_residual[0] = Density_j * ProjVelocity_j; + val_residual[0] = Density_j * ProjVelocity_j; for (iDim = 0; iDim < nDim; iDim++) val_residual[iDim+1] = Density_j * Velocity_j[iDim] * ProjVelocity_j + Pressure_j * UnitNormal[iDim]; val_residual[nVar-1] = Enthalpy_j * Density_j * ProjVelocity_j; @@ -251,9 +251,9 @@ if (sM > 0.0) { if (sL > 0.0) { /*--- Compute Jacobian based on Left State ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) + + for (iVar = 0; iVar < nVar; iVar++) + for (jVar = 0; jVar < nVar; jVar++) val_Jacobian_j[iVar][jVar] = 0; GetInviscidProjJac(Velocity_i, &Energy_i, UnitNormal, 1.0, val_Jacobian_i); @@ -273,10 +273,10 @@ if (sM > 0.0) { /*--- Computing pressure derivatives d/dU_L (PI) ---*/ dPI_dU[0] = 0.5 * Gamma_Minus_One * sq_vel_i; - for (iDim = 0; iDim < nDim; iDim++) + for (iDim = 0; iDim < nDim; iDim++) dPI_dU[iDim+1] = - Gamma_Minus_One * Velocity_i[iDim]; dPI_dU[nVar-1] = Gamma_Minus_One; - + /*--- Computing d/dU_L (Sm) ---*/ @@ -285,14 +285,14 @@ if (sM > 0.0) { dSm_dU[iDim+1] = ( UnitNormal[iDim] * ( 2 * ProjVelocity_i - sL - sM ) + dPI_dU[iDim+1] ) / RHO; dSm_dU[nVar-1] = dPI_dU[nVar-1] / RHO; - + /*--- Computing d/dU_L (rhoStar) ---*/ drhoStar_dU[0] = Omega * ( sL + IntermediateState[0] * dSm_dU[0] ); for (iDim = 0; iDim < nDim; iDim++) drhoStar_dU[iDim+1] = Omega * ( - UnitNormal[iDim] + IntermediateState[0] * dSm_dU[iDim+1] ); drhoStar_dU[nVar-1] = Omega * IntermediateState[0] * dSm_dU[nVar-1]; - + /*--- Computing d/dU_L (pStar) ---*/ @@ -304,7 +304,7 @@ if (sM > 0.0) { for (iVar = 0; iVar < nVar; iVar++) dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); - + dEStar_dU[0] += Omega * ProjVelocity_i * ( Enthalpy_i - dPI_dU[0] ); for (iDim = 0; iDim < nDim; iDim++) dEStar_dU[iDim+1] += Omega * ( - UnitNormal[iDim] * Enthalpy_i - ProjVelocity_i * dPI_dU[iDim+1] ); @@ -313,7 +313,7 @@ if (sM > 0.0) { /*--- Jacobian First Row ---*/ - + for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[0][iVar] = sM * drhoStar_dU[iVar] + IntermediateState[0] * dSm_dU[iVar]; @@ -326,7 +326,7 @@ if (sM > 0.0) { val_Jacobian_i[jDim+1][0] += OmegaSM * Velocity_i[jDim] * ProjVelocity_i; val_Jacobian_i[jDim+1][jDim+1] += OmegaSM * (sL - ProjVelocity_i); - + for (iDim = 0; iDim < nDim; iDim++) val_Jacobian_i[jDim+1][iDim+1] -= OmegaSM * Velocity_i[jDim] * UnitNormal[iDim]; @@ -335,7 +335,7 @@ if (sM > 0.0) { } /*--- Jacobian Last Row ---*/ - + for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[nVar-1][iVar] = sM * ( dEStar_dU[iVar] + dpStar_dU[iVar] ) + ( EStar + pStar ) * dSm_dU[iVar]; @@ -346,13 +346,13 @@ if (sM > 0.0) { /*--- Computing d/dU_R (Sm) ---*/ - + dSm_dU[0] = ( ProjVelocity_j * ProjVelocity_j - sM * sR - 0.5 * Gamma_Minus_One * sq_vel_j ) / RHO; for (iDim = 0; iDim < nDim; iDim++) dSm_dU[iDim+1] = - ( UnitNormal[iDim] * ( 2 * ProjVelocity_j - sR - sM) - Gamma_Minus_One * Velocity_j[iDim] ) / RHO; dSm_dU[nVar-1] = - Gamma_Minus_One / RHO; - - + + /*--- Computing d/dU_R (pStar) ---*/ for (iVar = 0; iVar < nVar; iVar++) @@ -363,7 +363,7 @@ if (sM > 0.0) { for (iVar = 0; iVar < nVar; iVar++) dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); - + /*--- Jacobian First Row ---*/ @@ -388,13 +388,13 @@ if (sM > 0.0) { if (sR < 0.0) { /*--- Compute Jacobian based on Right State ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) + + for (iVar = 0; iVar < nVar; iVar++) + for (jVar = 0; jVar < nVar; jVar++) val_Jacobian_i[iVar][jVar] = 0; GetInviscidProjJac(Velocity_j, &Energy_j, UnitNormal, 1.0, val_Jacobian_j); - + } else { /*--- Compute Jacobian based on Right Star State ---*/ @@ -413,7 +413,7 @@ if (sM > 0.0) { for (iDim = 0; iDim < nDim; iDim++) dSm_dU[iDim+1] = ( UnitNormal[iDim] * ( 2 * ProjVelocity_i - sL - sM ) - Gamma_Minus_One * Velocity_i[iDim] ) / RHO; dSm_dU[nVar-1] = Gamma_Minus_One / RHO; - + /*--- Computing d/dU_L (pStar) ---*/ @@ -425,7 +425,7 @@ if (sM > 0.0) { for (iVar = 0; iVar < nVar; iVar++) dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); - + /*--- Jacobian First Row ---*/ @@ -448,30 +448,30 @@ if (sM > 0.0) { /*--------- Right Jacobian ---------*/ - - + + /*--- Computing pressure derivatives d/dU_R (PI) ---*/ dPI_dU[0] = 0.5 * Gamma_Minus_One * sq_vel_j; - for (iDim = 0; iDim < nDim; iDim++) + for (iDim = 0; iDim < nDim; iDim++) dPI_dU[iDim+1] = - Gamma_Minus_One * Velocity_j[iDim]; dPI_dU[nVar-1] = Gamma_Minus_One; /*--- Computing d/dU_R (Sm) ---*/ - + dSm_dU[0] = - ( - ProjVelocity_j * ProjVelocity_j + sM * sR + dPI_dU[0] ) / RHO; for (iDim = 0; iDim < nDim; iDim++) dSm_dU[iDim+1] = - ( UnitNormal[iDim] * ( 2 * ProjVelocity_j - sR - sM) + dPI_dU[iDim+1] ) / RHO; dSm_dU[nVar-1] = - dPI_dU[nVar-1] / RHO; - + /*--- Computing d/dU_R (pStar) ---*/ for (iVar = 0; iVar < nVar; iVar++) dpStar_dU[iVar] = Density_j * (sL - ProjVelocity_i) * dSm_dU[iVar]; - + /*--- Computing d/dU_R (rhoStar) ---*/ @@ -485,7 +485,7 @@ if (sM > 0.0) { for (iVar = 0; iVar < nVar; iVar++) dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); - + dEStar_dU[0] += Omega * ProjVelocity_j * ( Enthalpy_j - dPI_dU[0] ); for (iDim = 0; iDim < nDim; iDim++) dEStar_dU[iDim+1] += Omega * ( - UnitNormal[iDim] * Enthalpy_j - ProjVelocity_j * dPI_dU[iDim+1] ); @@ -494,7 +494,7 @@ if (sM > 0.0) { /*--- Jacobian First Row ---*/ - + for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[0][iVar] = sM * drhoStar_dU[iVar] + IntermediateState[0] * dSm_dU[iVar]; @@ -507,7 +507,7 @@ if (sM > 0.0) { val_Jacobian_j[jDim+1][0] += OmegaSM * Velocity_j[jDim] * ProjVelocity_j; val_Jacobian_j[jDim+1][jDim+1] += OmegaSM * (sR - ProjVelocity_j); - + for (iDim = 0; iDim < nDim; iDim++) val_Jacobian_j[jDim+1][iDim+1] -= OmegaSM * Velocity_j[jDim] * UnitNormal[iDim]; @@ -516,17 +516,17 @@ if (sM > 0.0) { } /*--- Jacobian Last Row ---*/ - + for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[nVar-1][iVar] = sM * ( dEStar_dU[iVar] + dpStar_dU[iVar] ) + ( EStar + pStar ) * dSm_dU[iVar]; - + } } /*--- Jacobians of the inviscid flux, scale = k because val_residual ~ 0.5*(fc_i+fc_j)*Normal ---*/ - - Area *= kappa; + + Area *= kappa; for (iVar = 0; iVar < nVar; iVar++) { for (jVar = 0; jVar < nVar; jVar++) { diff --git a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwL2Roe_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwL2Roe_Flow.cpp index 0c0cd9efb59a..e1473e9a26e5 100644 --- a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwL2Roe_Flow.cpp +++ b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwL2Roe_Flow.cpp @@ -36,11 +36,11 @@ void CUpwL2Roe_Flow::FinalizeResidual(su2double *val_residual, su2double **val_J su2double **val_Jacobian_j, CConfig *config) { /*--- L2Roe: a low dissipation version of Roe's approximate Riemann solver for low Mach numbers. IJNMF 2015 ---*/ - + unsigned short iVar, jVar, kVar, iDim; - + /*--- Clamped Mach number ---*/ - + su2double M_i = 0.0, M_j = 0.0; for (iDim = 0; iDim < nDim; iDim++) { M_i += Velocity_i[iDim]*Velocity_i[iDim]; @@ -48,11 +48,11 @@ void CUpwL2Roe_Flow::FinalizeResidual(su2double *val_residual, su2double **val_J } M_i = sqrt(M_i / fabs(Pressure_i*Gamma/Density_i)); M_j = sqrt(M_j / fabs(Pressure_j*Gamma/Density_j)); - + su2double zeta = max(0.05,min(max(M_i,M_j),1.0)); - + /*--- Compute wave amplitudes (characteristics) ---*/ - + su2double proj_delta_vel = 0.0, delta_vel[3]; for (iDim = 0; iDim < nDim; iDim++) { delta_vel[iDim] = Velocity_j[iDim] - Velocity_i[iDim]; @@ -61,7 +61,7 @@ void CUpwL2Roe_Flow::FinalizeResidual(su2double *val_residual, su2double **val_J proj_delta_vel *= zeta; su2double delta_p = Pressure_j - Pressure_i; su2double delta_rho = Density_j - Density_i; - + su2double delta_wave[5] = {0.0, 0.0, 0.0, 0.0, 0.0}; if (nDim == 2) { delta_wave[0] = delta_rho - delta_p/RoeSoundSpeed2; @@ -75,19 +75,19 @@ void CUpwL2Roe_Flow::FinalizeResidual(su2double *val_residual, su2double **val_J delta_wave[3] = proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); delta_wave[4] = -proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); } - + /*--- Update residual ---*/ - + for (iVar = 0; iVar < nVar; iVar++) for (kVar = 0; kVar < nVar; kVar++) val_residual[iVar] -= (1.0-kappa)*Lambda[kVar]*delta_wave[kVar]*P_Tensor[iVar][kVar]*Area; - + if (!implicit) return; - + /*--- If implicit use the Jacobians of the standard Roe scheme as an approximation ---*/ - + GetPMatrix_inv(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, invP_Tensor); - + for (iVar = 0; iVar < nVar; iVar++) { for (jVar = 0; jVar < nVar; jVar++) { /*--- Compute |Proj_ModJac_Tensor| = P x |Lambda| x inverse P ---*/ @@ -99,5 +99,5 @@ void CUpwL2Roe_Flow::FinalizeResidual(su2double *val_residual, su2double **val_J val_Jacobian_j[iVar][jVar] -= (1.0-kappa)*Proj_ModJac_Tensor_ij*Area; } } - + } diff --git a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwLMRoe_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwLMRoe_Flow.cpp index 618ee0668ffa..d47d245bf20d 100644 --- a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwLMRoe_Flow.cpp +++ b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwLMRoe_Flow.cpp @@ -36,11 +36,11 @@ void CUpwLMRoe_Flow::FinalizeResidual(su2double *val_residual, su2double **val_J su2double **val_Jacobian_j, CConfig *config) { /*--- Rieper, A low-Mach number fix for Roe's approximate Riemman Solver, JCP 2011 ---*/ - + unsigned short iVar, jVar, kVar, iDim; - + /*--- Clamped Mach number ---*/ - + su2double M_i = 0.0, M_j = 0.0; for (iDim = 0; iDim < nDim; iDim++) { M_i += Velocity_i[iDim]*Velocity_i[iDim]; @@ -48,11 +48,11 @@ void CUpwLMRoe_Flow::FinalizeResidual(su2double *val_residual, su2double **val_J } M_i = sqrt(M_i / fabs(Pressure_i*Gamma/Density_i)); M_j = sqrt(M_j / fabs(Pressure_j*Gamma/Density_j)); - + su2double zeta = max(0.05,min(max(M_i,M_j),1.0)); - + /*--- Compute wave amplitudes (characteristics) ---*/ - + su2double proj_delta_vel = 0.0, delta_vel[3]; for (iDim = 0; iDim < nDim; iDim++) { delta_vel[iDim] = Velocity_j[iDim] - Velocity_i[iDim]; @@ -61,7 +61,7 @@ void CUpwLMRoe_Flow::FinalizeResidual(su2double *val_residual, su2double **val_J proj_delta_vel *= zeta; su2double delta_p = Pressure_j - Pressure_i; su2double delta_rho = Density_j - Density_i; - + su2double delta_wave[5] = {0.0, 0.0, 0.0, 0.0, 0.0}; if (nDim == 2) { delta_wave[0] = delta_rho - delta_p/RoeSoundSpeed2; @@ -75,19 +75,19 @@ void CUpwLMRoe_Flow::FinalizeResidual(su2double *val_residual, su2double **val_J delta_wave[3] = proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); delta_wave[4] = -proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); } - + /*--- Update residual ---*/ - + for (iVar = 0; iVar < nVar; iVar++) for (kVar = 0; kVar < nVar; kVar++) val_residual[iVar] -= (1.0-kappa)*Lambda[kVar]*delta_wave[kVar]*P_Tensor[iVar][kVar]*Area; - + if (!implicit) return; - + /*--- If implicit use the Jacobians of the standard Roe scheme as an approximation ---*/ - + GetPMatrix_inv(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, invP_Tensor); - + for (iVar = 0; iVar < nVar; iVar++) { for (jVar = 0; jVar < nVar; jVar++) { /*--- Compute |Proj_ModJac_Tensor| = P x |Lambda| x inverse P ---*/ diff --git a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwMSW_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwMSW_Flow.cpp index a4904037681e..75ee9b0ae22b 100644 --- a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwMSW_Flow.cpp +++ b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwMSW_Flow.cpp @@ -28,20 +28,20 @@ #include "../../../../include/numerics/flow/convection_upwind/CUpwMSW_Flow.hpp" CUpwMSW_Flow::CUpwMSW_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - + if (config->GetDynamic_Grid() && (SU2_MPI::GetRank() == MASTER_NODE)) cout << "WARNING: Grid velocities are NOT yet considered in the MSW scheme." << endl; - + /*--- Set booleans from CConfig settings ---*/ implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - + /*--- Allocate arrays ---*/ Diff_U = new su2double [nVar]; Fc_i = new su2double [nVar]; Fc_j = new su2double [nVar]; Lambda_i = new su2double [nVar]; Lambda_j = new su2double [nVar]; - + u_i = new su2double [nDim]; u_j = new su2double [nDim]; ust_i = new su2double [nDim]; @@ -50,27 +50,27 @@ CUpwMSW_Flow::CUpwMSW_Flow(unsigned short val_nDim, unsigned short val_nVar, CCo Vst_j = new su2double [nPrimVar]; Ust_i = new su2double [nVar]; Ust_j = new su2double [nVar]; - + Velst_i = new su2double [nDim]; Velst_j = new su2double [nDim]; - + P_Tensor = new su2double* [nVar]; invP_Tensor = new su2double* [nVar]; for (unsigned short iVar = 0; iVar < nVar; iVar++) { P_Tensor[iVar] = new su2double [nVar]; invP_Tensor[iVar] = new su2double [nVar]; } - + } CUpwMSW_Flow::~CUpwMSW_Flow(void) { - + delete [] Diff_U; delete [] Fc_i; delete [] Fc_j; delete [] Lambda_i; delete [] Lambda_j; - + delete [] u_i; delete [] u_j; delete [] ust_i; @@ -81,7 +81,7 @@ CUpwMSW_Flow::~CUpwMSW_Flow(void) { delete [] Vst_j; delete [] Velst_i; delete [] Velst_j; - + for (unsigned short iVar = 0; iVar < nVar; iVar++) { delete [] P_Tensor[iVar]; delete [] invP_Tensor[iVar]; @@ -94,29 +94,29 @@ CUpwMSW_Flow::~CUpwMSW_Flow(void) { void CUpwMSW_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - + unsigned short iDim, iVar, jVar, kVar; su2double P_i, P_j; su2double ProjVel_i, ProjVel_j, ProjVelst_i, ProjVelst_j; su2double sqvel_i, sqvel_j; su2double alpha, w, dp, onemw; su2double Proj_ModJac_Tensor_i, Proj_ModJac_Tensor_j; - + /*--- Set parameters in the numerical method ---*/ alpha = 6.0; - + /*--- Calculate supporting geometry parameters ---*/ - + Area = 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; /*--- Initialize flux & Jacobian vectors ---*/ - + for (iVar = 0; iVar < nVar; iVar++) { Fc_i[iVar] = 0.0; Fc_j[iVar] = 0.0; @@ -129,9 +129,9 @@ void CUpwMSW_Flow::ComputeResidual(su2double *val_residual, } } } - + /*--- Load variables from nodes i & j ---*/ - + rhos_i = V_i[0]; rhos_j = V_j[0]; for (iDim = 0; iDim < nDim; iDim++) { @@ -140,9 +140,9 @@ void CUpwMSW_Flow::ComputeResidual(su2double *val_residual, } P_i = V_i[nDim+1]; P_j = V_j[nDim+1]; - + /*--- Calculate supporting quantities ---*/ - + sqvel_i = 0.0; sqvel_j = 0.0; ProjVel_i = 0.0; ProjVel_j = 0.0; for (iDim = 0; iDim < nDim; iDim++) { @@ -151,15 +151,15 @@ void CUpwMSW_Flow::ComputeResidual(su2double *val_residual, ProjVel_i += u_i[iDim]*UnitNormal[iDim]; ProjVel_j += u_j[iDim]*UnitNormal[iDim]; } - + /*--- Calculate the state weighting function ---*/ - + dp = fabs(P_j-P_i) / min(P_j, P_i); w = 0.5 * (1.0/(pow(alpha*dp,2.0) +1.0)); onemw = 1.0 - w; - + /*--- Calculate weighted state vector (*) for i & j ---*/ - + for (iVar = 0; iVar < nVar; iVar++) { Ust_i[iVar] = onemw*U_i[iVar] + w*U_j[iVar]; Ust_j[iVar] = onemw*U_j[iVar] + w*U_i[iVar]; @@ -170,34 +170,34 @@ void CUpwMSW_Flow::ComputeResidual(su2double *val_residual, } ProjVelst_i = onemw*ProjVel_i + w*ProjVel_j; ProjVelst_j = onemw*ProjVel_j + w*ProjVel_i; - + for (iDim = 0; iDim < nDim; iDim++) { Velst_i[iDim] = Vst_i[iDim+1]; Velst_j[iDim] = Vst_j[iDim+1]; } - + /*--- Flow eigenvalues at i (Lambda+) ---*/ - + for (iDim = 0; iDim < nDim; iDim++) { Lambda_i[iDim] = 0.5*(ProjVelst_i + fabs(ProjVelst_i)); } Lambda_i[nDim] = 0.5*( ProjVelst_i + Vst_i[nDim+4] + fabs(ProjVelst_i + Vst_i[nDim+4]) ); Lambda_i[nDim+1] = 0.5*( ProjVelst_i - Vst_i[nDim+4] + fabs(ProjVelst_i - Vst_i[nDim+4]) ); - + /*--- Compute projected P, invP, and Lambda ---*/ - + GetPMatrix(&Vst_i[nDim+2], Velst_i, &Vst_i[nDim+4], UnitNormal, P_Tensor); GetPMatrix_inv(&Vst_i[nDim+2], Velst_i, &Vst_i[nDim+4], UnitNormal, invP_Tensor); - + /*--- Projected flux (f+) at i ---*/ - + for (iVar = 0; iVar < nVar; iVar++) { for (jVar = 0; jVar < nVar; jVar++) { Proj_ModJac_Tensor_i = 0.0; - + /*--- Compute Proj_ModJac_Tensor = P x Lambda+ x inverse P ---*/ - + for (kVar = 0; kVar < nVar; kVar++) Proj_ModJac_Tensor_i += P_Tensor[iVar][kVar]*Lambda_i[kVar]*invP_Tensor[kVar][jVar]; Fc_i[iVar] += Proj_ModJac_Tensor_i*U_i[jVar]*Area; @@ -205,9 +205,9 @@ void CUpwMSW_Flow::ComputeResidual(su2double *val_residual, val_Jacobian_i[iVar][jVar] += Proj_ModJac_Tensor_i*Area; } } - + /*--- Flow eigenvalues at j (Lambda-) ---*/ - + for (iDim = 0; iDim < nDim; iDim++) { Lambda_j[iDim] = 0.5*(ProjVelst_j - fabs(ProjVelst_j)); } @@ -215,14 +215,14 @@ void CUpwMSW_Flow::ComputeResidual(su2double *val_residual, fabs(ProjVelst_j + Vst_j[nDim+4]) ); Lambda_j[nDim+1] = 0.5*( ProjVelst_j - Vst_j[nDim+4] - fabs(ProjVelst_j - Vst_j[nDim+4]) ); - + /*--- Compute projected P, invP, and Lambda ---*/ - + GetPMatrix(&Vst_j[nDim+2], Velst_j, &Vst_j[nDim+4], UnitNormal, P_Tensor); GetPMatrix_inv(&Vst_j[nDim+2], Velst_j, &Vst_j[nDim+4], UnitNormal, invP_Tensor); - + /*--- Projected flux (f-) ---*/ - + for (iVar = 0; iVar < nVar; iVar++) { for (jVar = 0; jVar < nVar; jVar++) { Proj_ModJac_Tensor_j = 0.0; @@ -234,11 +234,11 @@ void CUpwMSW_Flow::ComputeResidual(su2double *val_residual, val_Jacobian_j[iVar][jVar] += Proj_ModJac_Tensor_j*Area; } } - + /*--- Flux splitting ---*/ - + for (iVar = 0; iVar < nVar; iVar++) { val_residual[iVar] = Fc_i[iVar]+Fc_j[iVar]; } - + } diff --git a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwRoeBase_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwRoeBase_Flow.cpp index c74ce0d01e23..7b5cc491e2c1 100644 --- a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwRoeBase_Flow.cpp +++ b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwRoeBase_Flow.cpp @@ -29,7 +29,7 @@ CUpwRoeBase_Flow::CUpwRoeBase_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, bool val_low_dissipation) : CNumerics(val_nDim, val_nVar, config) { - + implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ dynamic_grid = config->GetDynamic_Grid(); @@ -37,9 +37,9 @@ CUpwRoeBase_Flow::CUpwRoeBase_Flow(unsigned short val_nDim, unsigned short val_n Gamma = config->GetGamma(); Gamma_Minus_One = Gamma - 1.0; - + roe_low_dissipation = val_low_dissipation; - + Diff_U = new su2double [nVar]; Velocity_i = new su2double [nDim]; Velocity_j = new su2double [nDim]; @@ -58,7 +58,7 @@ CUpwRoeBase_Flow::CUpwRoeBase_Flow(unsigned short val_nDim, unsigned short val_n } CUpwRoeBase_Flow::~CUpwRoeBase_Flow(void) { - + delete [] Diff_U; delete [] Velocity_i; delete [] Velocity_j; @@ -74,7 +74,7 @@ CUpwRoeBase_Flow::~CUpwRoeBase_Flow(void) { } delete [] P_Tensor; delete [] invP_Tensor; - + } void CUpwRoeBase_Flow::FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { @@ -86,7 +86,7 @@ void CUpwRoeBase_Flow::FinalizeResidual(su2double *val_residual, su2double **val } void CUpwRoeBase_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - + unsigned short iVar, jVar, iDim; su2double ProjGridVel = 0.0, Energy_i, Energy_j; @@ -99,39 +99,39 @@ void CUpwRoeBase_Flow::ComputeResidual(su2double *val_residual, su2double **val_ AD::SetPreaccIn(Sensor_i); AD::SetPreaccIn(Sensor_j); AD::SetPreaccIn(Dissipation_i); AD::SetPreaccIn(Dissipation_j); } - + /*--- Face area (norm or the normal vector) and unit normal ---*/ 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; - + /*--- Primitive variables at point i ---*/ - + for (iDim = 0; iDim < nDim; iDim++) Velocity_i[iDim] = V_i[iDim+1]; Pressure_i = V_i[nDim+1]; Density_i = V_i[nDim+2]; Enthalpy_i = V_i[nDim+3]; Energy_i = Enthalpy_i - Pressure_i/Density_i; - + /*--- Primitive variables at point j ---*/ - + for (iDim = 0; iDim < nDim; iDim++) Velocity_j[iDim] = V_j[iDim+1]; Pressure_j = V_j[nDim+1]; Density_j = V_j[nDim+2]; Enthalpy_j = V_j[nDim+3]; Energy_j = Enthalpy_j - Pressure_j/Density_j; - + /*--- Compute variables that are common to the derived schemes ---*/ - + /*--- Roe-averaged variables at interface between i & j ---*/ - + su2double R = sqrt(fabs(Density_j/Density_i)); RoeDensity = R*Density_i; su2double sq_vel = 0.0; @@ -141,9 +141,9 @@ void CUpwRoeBase_Flow::ComputeResidual(su2double *val_residual, su2double **val_ } RoeEnthalpy = (R*Enthalpy_j+Enthalpy_i)/(R+1); RoeSoundSpeed2 = (Gamma-1)*(RoeEnthalpy-0.5*sq_vel); - + /*--- Negative RoeSoundSpeed^2, the jump variables is too large, clear fluxes and exit. ---*/ - + if (RoeSoundSpeed2 <= 0.0) { for (iVar = 0; iVar < nVar; iVar++) { val_residual[iVar] = 0.0; @@ -158,85 +158,85 @@ void CUpwRoeBase_Flow::ComputeResidual(su2double *val_residual, su2double **val_ AD::EndPreacc(); return; } - + RoeSoundSpeed = sqrt(RoeSoundSpeed2); - + /*--- P tensor ---*/ - + GetPMatrix(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, P_Tensor); - + /*--- Projected velocity adjusted for mesh motion ---*/ - + ProjVelocity = 0.0; for (iDim = 0; iDim < nDim; iDim++) ProjVelocity += RoeVelocity[iDim]*UnitNormal[iDim]; - + if (dynamic_grid) { for (iDim = 0; iDim < nDim; iDim++) ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*UnitNormal[iDim]; ProjVelocity -= ProjGridVel; } - + /*--- Flow eigenvalues ---*/ - + for (iDim = 0; iDim < nDim; iDim++) Lambda[iDim] = ProjVelocity; - + Lambda[nVar-2] = ProjVelocity + RoeSoundSpeed; Lambda[nVar-1] = ProjVelocity - RoeSoundSpeed; - + /*--- Apply Mavriplis' entropy correction to eigenvalues ---*/ - + su2double MaxLambda = fabs(ProjVelocity) + RoeSoundSpeed; - - for (iVar = 0; iVar < nVar; iVar++) + + for (iVar = 0; iVar < nVar; iVar++) Lambda[iVar] = max(fabs(Lambda[iVar]), config->GetEntropyFix_Coeff()*MaxLambda); - + /*--- Reconstruct conservative variables ---*/ - + Conservatives_i[0] = Density_i; Conservatives_j[0] = Density_j; - + for (iDim = 0; iDim < nDim; iDim++) { Conservatives_i[iDim+1] = Density_i*Velocity_i[iDim]; Conservatives_j[iDim+1] = Density_j*Velocity_j[iDim]; } Conservatives_i[nDim+1] = Density_i*Energy_i; Conservatives_j[nDim+1] = Density_j*Energy_j; - + /*--- Compute left and right fluxes ---*/ - + GetInviscidProjFlux(&Density_i, Velocity_i, &Pressure_i, &Enthalpy_i, Normal, ProjFlux_i); GetInviscidProjFlux(&Density_j, Velocity_j, &Pressure_j, &Enthalpy_j, Normal, ProjFlux_j); - + /*--- Initialize residual (flux) and Jacobians ---*/ - + for (iVar = 0; iVar < nVar; iVar++) val_residual[iVar] = kappa*(ProjFlux_i[iVar]+ProjFlux_j[iVar]); - + if (implicit) { GetInviscidProjJac(Velocity_i, &Energy_i, Normal, kappa, val_Jacobian_i); GetInviscidProjJac(Velocity_j, &Energy_j, Normal, kappa, val_Jacobian_j); } - + /*--- Finalize in children class ---*/ - + FinalizeResidual(val_residual, val_Jacobian_i, val_Jacobian_j, config); - + /*--- Correct for grid motion ---*/ - + if (dynamic_grid) { for (iVar = 0; iVar < nVar; iVar++) { val_residual[iVar] -= ProjGridVel*Area * 0.5*(Conservatives_i[iVar]+Conservatives_j[iVar]); - + if (implicit) { val_Jacobian_i[iVar][iVar] -= 0.5*ProjGridVel*Area; val_Jacobian_j[iVar][iVar] -= 0.5*ProjGridVel*Area; } } } - + AD::SetPreaccOut(val_residual, nVar); AD::EndPreacc(); - + } diff --git a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwRoe_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwRoe_Flow.cpp index aef4808927f3..66bb00a75450 100644 --- a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwRoe_Flow.cpp +++ b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwRoe_Flow.cpp @@ -36,22 +36,22 @@ void CUpwRoe_Flow::FinalizeResidual(su2double *val_residual, su2double **val_Jac su2double **val_Jacobian_j, CConfig *config) { unsigned short iVar, jVar, kVar; - + /*--- Compute inverse P tensor ---*/ GetPMatrix_inv(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, invP_Tensor); - + /*--- Diference between conservative variables at jPoint and iPoint ---*/ for (iVar = 0; iVar < nVar; iVar++) Diff_U[iVar] = Conservatives_j[iVar]-Conservatives_i[iVar]; - + /*--- Low dissipation formulation ---*/ if (roe_low_dissipation) SetRoe_Dissipation(Dissipation_i, Dissipation_j, Sensor_i, Sensor_j, Dissipation_ij, config); else Dissipation_ij = 1.0; - + /*--- Standard Roe "dissipation" ---*/ - + for (iVar = 0; iVar < nVar; iVar++) { for (jVar = 0; jVar < nVar; jVar++) { /*--- Compute |Proj_ModJac_Tensor| = P x |Lambda| x inverse P ---*/ @@ -61,7 +61,7 @@ void CUpwRoe_Flow::FinalizeResidual(su2double *val_residual, su2double **val_Jac /*--- Update residual and Jacobians ---*/ val_residual[iVar] -= (1.0-kappa)*Proj_ModJac_Tensor_ij*Diff_U[jVar]*Area*Dissipation_ij; - + if(implicit){ val_Jacobian_i[iVar][jVar] += (1.0-kappa)*Proj_ModJac_Tensor_ij*Area; val_Jacobian_j[iVar][jVar] -= (1.0-kappa)*Proj_ModJac_Tensor_ij*Area; diff --git a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwSLAU_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwSLAU_Flow.cpp index 72f42417e73e..8f5db9396a9b 100644 --- a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwSLAU_Flow.cpp +++ b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwSLAU_Flow.cpp @@ -66,7 +66,7 @@ void CUpwSLAU_Flow::ComputeMassAndPressureFluxes(CConfig *config, su2double &mdo /*--- Smooth function of the local Mach number---*/ - su2double Mach_tilde = min(1.0, (1.0/aF) * sqrt(0.5*(sq_veli+sq_velj))); + su2double Mach_tilde = min(1.0, (1.0/aF) * sqrt(0.5*(sq_veli+sq_velj))); su2double Chi = pow((1.0 - Mach_tilde),2.0); su2double f_rho = -max(min(mL,0.0),-1.0) * min(max(mR,0.0),1.0); @@ -74,7 +74,7 @@ void CUpwSLAU_Flow::ComputeMassAndPressureFluxes(CConfig *config, su2double &mdo su2double Vn_Mag = (Density_i*fabs(ProjVelocity_i) + Density_j*fabs(ProjVelocity_j)) / (Density_i + Density_j); su2double Vn_MagL= (1.0 - f_rho)*Vn_Mag + f_rho*fabs(ProjVelocity_i); - su2double Vn_MagR= (1.0 - f_rho)*Vn_Mag + f_rho*fabs(ProjVelocity_j); + su2double Vn_MagR= (1.0 - f_rho)*Vn_Mag + f_rho*fabs(ProjVelocity_j); /*--- Mass flux function ---*/ diff --git a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwTurkel_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwTurkel_Flow.cpp index 985f77b2ea4e..331ba4e68ca6 100644 --- a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwTurkel_Flow.cpp +++ b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwTurkel_Flow.cpp @@ -28,17 +28,17 @@ #include "../../../../include/numerics/flow/convection_upwind/CUpwTurkel_Flow.hpp" CUpwTurkel_Flow::CUpwTurkel_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - + implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ dynamic_grid = config->GetDynamic_Grid(); - + Gamma = config->GetGamma(); Gamma_Minus_One = Gamma - 1.0; - + Beta_min = config->GetminTurkelBeta(); Beta_max = config->GetmaxTurkelBeta(); - + Diff_U = new su2double [nVar]; Velocity_i = new su2double [nDim]; Velocity_j = new su2double [nDim]; @@ -62,7 +62,7 @@ CUpwTurkel_Flow::CUpwTurkel_Flow(unsigned short val_nDim, unsigned short val_nVa } CUpwTurkel_Flow::~CUpwTurkel_Flow(void) { - + delete [] Diff_U; delete [] Velocity_i; delete [] Velocity_j; @@ -83,27 +83,27 @@ CUpwTurkel_Flow::~CUpwTurkel_Flow(void) { delete [] absPeJac; delete [] invRinvPe; delete [] R_Tensor; - + } void CUpwTurkel_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - + su2double U_i[5] = {0.0,0.0,0.0,0.0,0.0}, U_j[5] = {0.0,0.0,0.0,0.0,0.0}; /*--- Face area (norm or the normal vector) ---*/ - + Area = 0.0; for (iDim = 0; iDim < nDim; iDim++) Area += Normal[iDim]*Normal[iDim]; Area = sqrt(Area); - + /*-- Unit Normal ---*/ - + for (iDim = 0; iDim < nDim; iDim++) UnitNormal[iDim] = Normal[iDim]/Area; - + /*--- Primitive variables at point i ---*/ - + for (iDim = 0; iDim < nDim; iDim++) Velocity_i[iDim] = V_i[iDim+1]; Pressure_i = V_i[nDim+1]; @@ -113,7 +113,7 @@ void CUpwTurkel_Flow::ComputeResidual(su2double *val_residual, su2double **val_J SoundSpeed_i = sqrt(fabs(Pressure_i*Gamma/Density_i)); /*--- Primitive variables at point j ---*/ - + for (iDim = 0; iDim < nDim; iDim++) Velocity_j[iDim] = V_j[iDim+1]; Pressure_j = V_j[nDim+1]; @@ -123,15 +123,15 @@ void CUpwTurkel_Flow::ComputeResidual(su2double *val_residual, su2double **val_J SoundSpeed_j = sqrt(fabs(Pressure_j*Gamma/Density_j)); /*--- Recompute conservative variables ---*/ - + U_i[0] = Density_i; U_j[0] = Density_j; for (iDim = 0; iDim < nDim; iDim++) { U_i[iDim+1] = Density_i*Velocity_i[iDim]; U_j[iDim+1] = Density_j*Velocity_j[iDim]; } U_i[nDim+1] = Density_i*Energy_i; U_j[nDim+1] = Density_j*Energy_j; - + /*--- Roe-averaged variables at interface between i & j ---*/ - + R = sqrt(fabs(Density_j/Density_i)); RoeDensity = R*Density_i; sq_vel = 0.0; @@ -142,20 +142,20 @@ void CUpwTurkel_Flow::ComputeResidual(su2double *val_residual, su2double **val_J RoeEnthalpy = (R*Enthalpy_j+Enthalpy_i)/(R+1); RoeSoundSpeed = sqrt(fabs((Gamma-1)*(RoeEnthalpy-0.5*sq_vel))); RoePressure = RoeDensity/Gamma*RoeSoundSpeed*RoeSoundSpeed; - + /*--- Compute ProjFlux_i ---*/ GetInviscidProjFlux(&Density_i, Velocity_i, &Pressure_i, &Enthalpy_i, Normal, ProjFlux_i); - + /*--- Compute ProjFlux_j ---*/ GetInviscidProjFlux(&Density_j, Velocity_j, &Pressure_j, &Enthalpy_j, Normal, ProjFlux_j); - + ProjVelocity = 0.0; ProjVelocity_i = 0.0; ProjVelocity_j = 0.0; for (iDim = 0; iDim < nDim; iDim++) { ProjVelocity += RoeVelocity[iDim]*UnitNormal[iDim]; ProjVelocity_i += Velocity_i[iDim]*UnitNormal[iDim]; ProjVelocity_j += Velocity_j[iDim]*UnitNormal[iDim]; } - + /*--- Projected velocity adjustment due to mesh motion ---*/ if (dynamic_grid) { su2double ProjGridVel = 0.0; @@ -166,51 +166,51 @@ void CUpwTurkel_Flow::ComputeResidual(su2double *val_residual, su2double **val_J ProjVelocity_i -= ProjGridVel; ProjVelocity_j -= ProjGridVel; } - + /*--- First few flow eigenvalues of A.Normal with the normal---*/ for (iDim = 0; iDim < nDim; iDim++) Lambda[iDim] = ProjVelocity; - + local_Mach = sqrt(sq_vel)/RoeSoundSpeed; Beta = max(Beta_min, min(local_Mach, Beta_max)); Beta2 = Beta*Beta; - + one_m_Betasqr = 1.0 - Beta2; // 1-Beta*Beta one_p_Betasqr = 1.0 + Beta2; // 1+Beta*Beta sqr_one_m_Betasqr_Lam1 = pow((one_m_Betasqr*Lambda[0]),2); // [(1-Beta^2)*Lambda[0]]^2 sqr_two_Beta_c_Area = pow(2.0*Beta*RoeSoundSpeed*Area,2); // [2*Beta*c*Area]^2 - + /*--- The rest of the flow eigenvalues of preconditioned matrix---*/ Lambda[nVar-2] = 0.5 * ( one_p_Betasqr*Lambda[0] + sqrt( sqr_one_m_Betasqr_Lam1 + sqr_two_Beta_c_Area)); Lambda[nVar-1] = 0.5 * ( one_p_Betasqr*Lambda[0] - sqrt( sqr_one_m_Betasqr_Lam1 + sqr_two_Beta_c_Area)); - + s_hat = 1.0/Area * (Lambda[nVar-1] - Lambda[0]*Beta2); r_hat = 1.0/Area * (Lambda[nVar-2] - Lambda[0]*Beta2); t_hat = 0.5/Area * (Lambda[nVar-1] - Lambda[nVar-2]); rhoB2a2 = RoeDensity*Beta2*RoeSoundSpeed*RoeSoundSpeed; - + /*--- Diference variables iPoint and jPoint and absolute value of the eigen values---*/ for (iVar = 0; iVar < nVar; iVar++) { Diff_U[iVar] = U_j[iVar]-U_i[iVar]; Lambda[iVar] = fabs(Lambda[iVar]); } - + /*--- Compute the absolute Preconditioned Jacobian in entropic Variables (do it with the Unitary Normal) ---*/ GetPrecondJacobian(Beta2, r_hat, s_hat, t_hat, rhoB2a2, Lambda, UnitNormal, absPeJac); - + /*--- Compute the matrix from entropic variables to conserved variables ---*/ GetinvRinvPe(Beta2, RoeEnthalpy, RoeSoundSpeed, RoeDensity, RoeVelocity, invRinvPe); - + /*--- Compute the matrix from entropic variables to conserved variables ---*/ GetRMatrix(RoePressure, RoeSoundSpeed, RoeDensity, RoeVelocity, R_Tensor); - + if (implicit) { /*--- Jacobians of the inviscid flux, scaled by 0.5 because val_residual ~ 0.5*(fc_i+fc_j)*Normal ---*/ GetInviscidProjJac(Velocity_i, &Energy_i, Normal, 0.5, val_Jacobian_i); GetInviscidProjJac(Velocity_j, &Energy_j, Normal, 0.5, val_Jacobian_j); } - + for (iVar = 0; iVar < nVar; iVar ++) { for (jVar = 0; jVar < nVar; jVar ++) { Matrix[iVar][jVar] = 0.0; @@ -218,7 +218,7 @@ void CUpwTurkel_Flow::ComputeResidual(su2double *val_residual, su2double **val_J Matrix[iVar][jVar] += absPeJac[iVar][kVar]*R_Tensor[kVar][jVar]; } } - + for (iVar = 0; iVar < nVar; iVar ++) { for (jVar = 0; jVar < nVar; jVar ++) { Art_Visc[iVar][jVar] = 0.0; @@ -226,7 +226,7 @@ void CUpwTurkel_Flow::ComputeResidual(su2double *val_residual, su2double **val_J Art_Visc[iVar][jVar] += invRinvPe[iVar][kVar]*Matrix[kVar][jVar]; } } - + /*--- Roe's Flux approximation ---*/ for (iVar = 0; iVar < nVar; iVar++) { val_residual[iVar] = 0.5*(ProjFlux_i[iVar]+ProjFlux_j[iVar]); @@ -238,7 +238,7 @@ void CUpwTurkel_Flow::ComputeResidual(su2double *val_residual, su2double **val_J } } } - + /*--- Contributions due to mesh motion---*/ if (dynamic_grid) { ProjVelocity = 0.0; @@ -253,5 +253,5 @@ void CUpwTurkel_Flow::ComputeResidual(su2double *val_residual, su2double **val_J } } } - + } diff --git a/SU2_CFD/src/numerics/flow/diffusion/CAvgGradInc_Flow.cpp b/SU2_CFD/src/numerics/flow/diffusion/CAvgGradInc_Flow.cpp index a2c3a9eddf92..32227b9403c2 100644 --- a/SU2_CFD/src/numerics/flow/diffusion/CAvgGradInc_Flow.cpp +++ b/SU2_CFD/src/numerics/flow/diffusion/CAvgGradInc_Flow.cpp @@ -31,16 +31,16 @@ CAvgGradInc_Flow::CAvgGradInc_Flow(unsigned short val_nDim, unsigned short val_nVar, bool val_correct_grad, CConfig *config) : CAvgGrad_Base(val_nDim, val_nVar, val_nDim+3, val_correct_grad, config) { - + energy = config->GetEnergy_Equation(); - + } CAvgGradInc_Flow::~CAvgGradInc_Flow(void) { } void CAvgGradInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - + AD::StartPreacc(); AD::SetPreaccIn(V_i, nDim+9); AD::SetPreaccIn(V_j, nDim+9); AD::SetPreaccIn(Coord_i, nDim); AD::SetPreaccIn(Coord_j, nDim); @@ -52,12 +52,12 @@ void CAvgGradInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_ unsigned short iVar, jVar, iDim; /*--- Normalized normal vector ---*/ - + 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; @@ -76,20 +76,20 @@ void CAvgGradInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_ } /*--- Density and transport properties ---*/ - + Laminar_Viscosity_i = V_i[nDim+4]; Laminar_Viscosity_j = V_j[nDim+4]; Eddy_Viscosity_i = V_i[nDim+5]; Eddy_Viscosity_j = V_j[nDim+5]; Thermal_Conductivity_i = V_i[nDim+6]; Thermal_Conductivity_j = V_j[nDim+6]; /*--- Mean transport properties ---*/ - + Mean_Laminar_Viscosity = 0.5*(Laminar_Viscosity_i + Laminar_Viscosity_j); Mean_Eddy_Viscosity = 0.5*(Eddy_Viscosity_i + Eddy_Viscosity_j); Mean_turb_ke = 0.5*(turb_ke_i + turb_ke_j); Mean_Thermal_Conductivity = 0.5*(Thermal_Conductivity_i + Thermal_Conductivity_j); /*--- Mean gradient approximation ---*/ - + for (iVar = 0; iVar < nVar; iVar++) for (iDim = 0; iDim < nDim; iDim++) Mean_GradPrimVar[iVar][iDim] = 0.5*(PrimVar_Grad_i[iVar][iDim] + PrimVar_Grad_j[iVar][iDim]); @@ -100,22 +100,22 @@ void CAvgGradInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_ CorrectGradient(Mean_GradPrimVar, PrimVar_i, PrimVar_j, Edge_Vector, dist_ij_2, nVar); } - + /*--- Get projected flux tensor ---*/ SetStressTensor(Mean_PrimVar, Mean_GradPrimVar, Mean_turb_ke, Mean_Laminar_Viscosity, Mean_Eddy_Viscosity); GetViscousIncProjFlux(Mean_GradPrimVar, Normal, Mean_Thermal_Conductivity); - + /*--- Update viscous residual ---*/ - + for (iVar = 0; iVar < nVar; iVar++) { val_residual[iVar] = Proj_Flux_Tensor[iVar]; } /*--- Implicit part ---*/ - + if (implicit) { - + if (dist_ij_2 == 0.0) { for (iVar = 0; iVar < nVar; iVar++) { for (jVar = 0; jVar < nVar; jVar++) { @@ -139,7 +139,7 @@ void CAvgGradInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_ val_Jacobian_i[nDim+1][nDim+1] = -Mean_Thermal_Conductivity*proj_vector_ij; val_Jacobian_j[nDim+1][nDim+1] = Mean_Thermal_Conductivity*proj_vector_ij; } - + } if (!energy) { diff --git a/SU2_CFD/src/numerics/flow/diffusion/CAvgGrad_Base.cpp b/SU2_CFD/src/numerics/flow/diffusion/CAvgGrad_Base.cpp index d7e9d361616e..b15a0990f5d1 100644 --- a/SU2_CFD/src/numerics/flow/diffusion/CAvgGrad_Base.cpp +++ b/SU2_CFD/src/numerics/flow/diffusion/CAvgGrad_Base.cpp @@ -88,7 +88,7 @@ CAvgGrad_Base::~CAvgGrad_Base() { if (heat_flux_jac_i != NULL) { delete [] heat_flux_jac_i; } - + delete [] Edge_Vector; if (Proj_Mean_GradPrimVar_Edge != NULL) delete [] Proj_Mean_GradPrimVar_Edge; @@ -455,13 +455,13 @@ void CAvgGrad_Base::GetViscousProjFlux(const su2double *val_primvar, Flux_Tensor[4][2] = tau[2][0]*val_primvar[1] + tau[2][1]*val_primvar[2] + tau[2][2]*val_primvar[3] + heat_flux_vector[2]; } - + for (unsigned short iVar = 0; iVar < nVar; iVar++) { Proj_Flux_Tensor[iVar] = 0.0; for (unsigned short iDim = 0; iDim < nDim; iDim++) Proj_Flux_Tensor[iVar] += Flux_Tensor[iVar][iDim] * val_normal[iDim]; } - + } void CAvgGrad_Base::GetViscousProjJacs(const su2double *val_Mean_PrimVar, @@ -490,15 +490,15 @@ void CAvgGrad_Base::GetViscousProjJacs(const su2double *val_Mean_PrimVar, const su2double contraction = tau_jacobian_i[0][0]*val_Mean_PrimVar[1] + tau_jacobian_i[1][0]*val_Mean_PrimVar[2]; val_Proj_Jac_Tensor_i[3][0] = val_dS*(contraction - heat_flux_jac_i[0]); - val_Proj_Jac_Tensor_i[3][1] = -val_dS*(tau_jacobian_i[0][0] + heat_flux_jac_i[1]); - val_Proj_Jac_Tensor_i[3][2] = -val_dS*(tau_jacobian_i[1][0] + heat_flux_jac_i[2]); + val_Proj_Jac_Tensor_i[3][1] = -val_dS*(tau_jacobian_i[0][0] + heat_flux_jac_i[1]); + val_Proj_Jac_Tensor_i[3][2] = -val_dS*(tau_jacobian_i[1][0] + heat_flux_jac_i[2]); val_Proj_Jac_Tensor_i[3][3] = -val_dS*heat_flux_jac_i[3]; - + for (unsigned short iVar = 0; iVar < nVar; iVar++) for (unsigned short jVar = 0; jVar < nVar; jVar++) val_Proj_Jac_Tensor_j[iVar][jVar] = -val_Proj_Jac_Tensor_i[iVar][jVar]; - const su2double proj_viscousflux_vel= val_Proj_Visc_Flux[1]*val_Mean_PrimVar[1] + + const su2double proj_viscousflux_vel= val_Proj_Visc_Flux[1]*val_Mean_PrimVar[1] + val_Proj_Visc_Flux[2]*val_Mean_PrimVar[2]; val_Proj_Jac_Tensor_i[3][0] -= factor*proj_viscousflux_vel; val_Proj_Jac_Tensor_j[3][0] -= factor*proj_viscousflux_vel; @@ -506,8 +506,8 @@ void CAvgGrad_Base::GetViscousProjJacs(const su2double *val_Mean_PrimVar, val_Proj_Jac_Tensor_j[3][1] += factor*val_Proj_Visc_Flux[1]; val_Proj_Jac_Tensor_i[3][2] += factor*val_Proj_Visc_Flux[2]; val_Proj_Jac_Tensor_j[3][2] += factor*val_Proj_Visc_Flux[2]; - - + + } else { val_Proj_Jac_Tensor_i[0][0] = 0.0; @@ -534,16 +534,16 @@ void CAvgGrad_Base::GetViscousProjJacs(const su2double *val_Mean_PrimVar, tau_jacobian_i[1][0]*val_Mean_PrimVar[2] + tau_jacobian_i[2][0]*val_Mean_PrimVar[3]; val_Proj_Jac_Tensor_i[4][0] = val_dS*(contraction - heat_flux_jac_i[0]); - val_Proj_Jac_Tensor_i[4][1] = -val_dS*(tau_jacobian_i[0][0] + heat_flux_jac_i[1]); - val_Proj_Jac_Tensor_i[4][2] = -val_dS*(tau_jacobian_i[1][0] + heat_flux_jac_i[2]); - val_Proj_Jac_Tensor_i[4][3] = -val_dS*(tau_jacobian_i[2][0] + heat_flux_jac_i[3]); + val_Proj_Jac_Tensor_i[4][1] = -val_dS*(tau_jacobian_i[0][0] + heat_flux_jac_i[1]); + val_Proj_Jac_Tensor_i[4][2] = -val_dS*(tau_jacobian_i[1][0] + heat_flux_jac_i[2]); + val_Proj_Jac_Tensor_i[4][3] = -val_dS*(tau_jacobian_i[2][0] + heat_flux_jac_i[3]); val_Proj_Jac_Tensor_i[4][4] = -val_dS*heat_flux_jac_i[4]; for (unsigned short iVar = 0; iVar < nVar; iVar++) for (unsigned short jVar = 0; jVar < nVar; jVar++) val_Proj_Jac_Tensor_j[iVar][jVar] = -val_Proj_Jac_Tensor_i[iVar][jVar]; - - const su2double proj_viscousflux_vel= val_Proj_Visc_Flux[1]*val_Mean_PrimVar[1] + + + const su2double proj_viscousflux_vel= val_Proj_Visc_Flux[1]*val_Mean_PrimVar[1] + val_Proj_Visc_Flux[2]*val_Mean_PrimVar[2] + val_Proj_Visc_Flux[3]*val_Mean_PrimVar[3]; val_Proj_Jac_Tensor_i[4][0] -= factor*proj_viscousflux_vel; diff --git a/SU2_CFD/src/numerics/flow/diffusion/CAvgGrad_Flow.cpp b/SU2_CFD/src/numerics/flow/diffusion/CAvgGrad_Flow.cpp index ec6a04b9374b..8f3698c57d2a 100644 --- a/SU2_CFD/src/numerics/flow/diffusion/CAvgGrad_Flow.cpp +++ b/SU2_CFD/src/numerics/flow/diffusion/CAvgGrad_Flow.cpp @@ -52,24 +52,24 @@ void CAvgGrad_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jac unsigned short iVar, jVar, iDim; /*--- Normalized normal vector ---*/ - + 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; - + for (iVar = 0; iVar < nPrimVar; iVar++) { PrimVar_i[iVar] = V_i[iVar]; PrimVar_j[iVar] = V_j[iVar]; Mean_PrimVar[iVar] = 0.5*(PrimVar_i[iVar]+PrimVar_j[iVar]); } - + /*--- Compute vector going from iPoint to jPoint ---*/ - + dist_ij_2 = 0.0; for (iDim = 0; iDim < nDim; iDim++) { Edge_Vector[iDim] = Coord_j[iDim]-Coord_i[iDim]; @@ -77,16 +77,16 @@ void CAvgGrad_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jac } /*--- Laminar and Eddy viscosity ---*/ - + Laminar_Viscosity_i = V_i[nDim+5]; Laminar_Viscosity_j = V_j[nDim+5]; Eddy_Viscosity_i = V_i[nDim+6]; Eddy_Viscosity_j = V_j[nDim+6]; /*--- Mean Viscosities and turbulent kinetic energy---*/ - + Mean_Laminar_Viscosity = 0.5*(Laminar_Viscosity_i + Laminar_Viscosity_j); Mean_Eddy_Viscosity = 0.5*(Eddy_Viscosity_i + Eddy_Viscosity_j); Mean_turb_ke = 0.5*(turb_ke_i + turb_ke_j); - + /*--- Mean gradient approximation ---*/ for (iVar = 0; iVar < nDim+1; iVar++) { @@ -101,9 +101,9 @@ void CAvgGrad_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jac CorrectGradient(Mean_GradPrimVar, PrimVar_i, PrimVar_j, Edge_Vector, dist_ij_2, nDim+1); } - + /*--- Wall shear stress values (wall functions) ---*/ - + if (TauWall_i > 0.0 && TauWall_j > 0.0) Mean_TauWall = 0.5*(TauWall_i + TauWall_j); else if (TauWall_i > 0.0) Mean_TauWall = TauWall_i; else if (TauWall_j > 0.0) Mean_TauWall = TauWall_j; @@ -129,14 +129,14 @@ void CAvgGrad_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jac GetViscousProjFlux(Mean_PrimVar, Normal); /*--- Update viscous residual ---*/ - + for (iVar = 0; iVar < nVar; iVar++) val_residual[iVar] = Proj_Flux_Tensor[iVar]; - + /*--- Compute the implicit part ---*/ - + if (implicit) { - + if (dist_ij_2 == 0.0) { for (iVar = 0; iVar < nVar; iVar++) { for (jVar = 0; jVar < nVar; jVar++) { @@ -153,12 +153,12 @@ void CAvgGrad_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jac GetViscousProjJacs(Mean_PrimVar, Area, Proj_Flux_Tensor, val_Jacobian_i, val_Jacobian_j); } - + } AD::SetPreaccOut(val_residual, nVar); AD::EndPreacc(); - + } diff --git a/SU2_CFD/src/numerics/flow/diffusion/CGeneralAvgGrad_Flow.cpp b/SU2_CFD/src/numerics/flow/diffusion/CGeneralAvgGrad_Flow.cpp index d60a1910b218..99cecc196d5b 100644 --- a/SU2_CFD/src/numerics/flow/diffusion/CGeneralAvgGrad_Flow.cpp +++ b/SU2_CFD/src/numerics/flow/diffusion/CGeneralAvgGrad_Flow.cpp @@ -32,15 +32,15 @@ CGeneralAvgGrad_Flow::CGeneralAvgGrad_Flow(unsigned short val_nDim, bool val_correct_grad, CConfig *config) : CAvgGrad_Base(val_nDim, val_nVar, val_nDim+4, val_correct_grad, config) { - + Mean_SecVar = new su2double [2]; - + } CGeneralAvgGrad_Flow::~CGeneralAvgGrad_Flow(void) { - + delete [] Mean_SecVar; - + } void CGeneralAvgGrad_Flow::SetHeatFluxVector(const su2double* const *val_gradprimvar, @@ -120,17 +120,17 @@ void CGeneralAvgGrad_Flow::ComputeResidual(su2double *val_residual, su2double ** unsigned short iVar, jVar, iDim; /*--- Normalized normal vector ---*/ - + 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; /*--- Mean primitive variables ---*/ - + for (iVar = 0; iVar < nPrimVar; iVar++) { PrimVar_i[iVar] = V_i[iVar]; PrimVar_j[iVar] = V_j[iVar]; @@ -138,28 +138,28 @@ void CGeneralAvgGrad_Flow::ComputeResidual(su2double *val_residual, su2double ** } /*--- Compute vector going from iPoint to jPoint ---*/ - + dist_ij_2 = 0.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]; } - + /*--- Laminar and Eddy viscosity ---*/ - + Laminar_Viscosity_i = V_i[nDim+5]; Laminar_Viscosity_j = V_j[nDim+5]; Eddy_Viscosity_i = V_i[nDim+6]; Eddy_Viscosity_j = V_j[nDim+6]; Thermal_Conductivity_i = V_i[nDim+7]; Thermal_Conductivity_j = V_j[nDim+7]; Cp_i = V_i[nDim+8]; Cp_j = V_j[nDim+8]; /*--- Mean secondary variables ---*/ - + for (iVar = 0; iVar < 2; iVar++) { Mean_SecVar[iVar] = 0.5*(S_i[iVar+2]+S_j[iVar+2]); } - + /*--- Mean Viscosities and turbulent kinetic energy---*/ - + Mean_Laminar_Viscosity = 0.5*(Laminar_Viscosity_i + Laminar_Viscosity_j); Mean_Eddy_Viscosity = 0.5*(Eddy_Viscosity_i + Eddy_Viscosity_j); Mean_turb_ke = 0.5*(turb_ke_i + turb_ke_j); @@ -167,7 +167,7 @@ void CGeneralAvgGrad_Flow::ComputeResidual(su2double *val_residual, su2double ** Mean_Cp = 0.5*(Cp_i + Cp_j); /*--- Mean gradient approximation ---*/ - + for (iVar = 0; iVar < nDim+1; iVar++) { for (iDim = 0; iDim < nDim; iDim++) { Mean_GradPrimVar[iVar][iDim] = 0.5*(PrimVar_Grad_i[iVar][iDim] + PrimVar_Grad_j[iVar][iDim]); @@ -180,7 +180,7 @@ void CGeneralAvgGrad_Flow::ComputeResidual(su2double *val_residual, su2double ** CorrectGradient(Mean_GradPrimVar, PrimVar_i, PrimVar_j, Edge_Vector, dist_ij_2, nDim+1); } - + /* --- If using UQ methodology, set Reynolds Stress tensor and perform perturbation--- */ if (using_uq){ @@ -189,7 +189,7 @@ void CGeneralAvgGrad_Flow::ComputeResidual(su2double *val_residual, su2double ** } /*--- Get projected flux tensor ---*/ - + SetStressTensor(Mean_PrimVar, Mean_GradPrimVar, Mean_turb_ke, Mean_Laminar_Viscosity, Mean_Eddy_Viscosity); @@ -197,14 +197,14 @@ void CGeneralAvgGrad_Flow::ComputeResidual(su2double *val_residual, su2double ** Mean_Eddy_Viscosity, Mean_Thermal_Conductivity, Mean_Cp); GetViscousProjFlux(Mean_PrimVar, Normal); - + /*--- Update viscous residual ---*/ - + for (iVar = 0; iVar < nVar; iVar++) val_residual[iVar] = Proj_Flux_Tensor[iVar]; - + /*--- Compute the implicit part ---*/ - + if (implicit) { if (dist_ij_2 == 0.0) { @@ -223,10 +223,10 @@ void CGeneralAvgGrad_Flow::ComputeResidual(su2double *val_residual, su2double ** GetViscousProjJacs(Mean_PrimVar, Area, Proj_Flux_Tensor, val_Jacobian_i, val_Jacobian_j); } - + } - + AD::SetPreaccOut(val_residual, nVar); AD::EndPreacc(); - + } diff --git a/SU2_CFD/src/numerics/flow/sources/CSourceAxisymmetric_Flow.cpp b/SU2_CFD/src/numerics/flow/sources/CSourceAxisymmetric_Flow.cpp index e9fda3c6eb8b..5db5e70935da 100644 --- a/SU2_CFD/src/numerics/flow/sources/CSourceAxisymmetric_Flow.cpp +++ b/SU2_CFD/src/numerics/flow/sources/CSourceAxisymmetric_Flow.cpp @@ -28,80 +28,80 @@ #include "../../../../include/numerics/flow/sources/CSourceAxisymmetric_Flow.hpp" CSourceAxisymmetric_Flow::CSourceAxisymmetric_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - + Gamma = config->GetGamma(); Gamma_Minus_One = Gamma - 1.0; - + } CSourceAxisymmetric_Flow::~CSourceAxisymmetric_Flow(void) { } void CSourceAxisymmetric_Flow::ComputeResidual(su2double *val_residual, su2double **Jacobian_i, CConfig *config) { - + su2double yinv, Pressure_i, Enthalpy_i, Velocity_i, sq_vel; unsigned short iDim, iVar, jVar; - + bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - + if (Coord_i[1] > EPS) { - + yinv = 1.0/Coord_i[1]; - + sq_vel = 0.0; for (iDim = 0; iDim < nDim; iDim++) { Velocity_i = U_i[iDim+1] / U_i[0]; sq_vel += Velocity_i *Velocity_i; } - + Pressure_i = (Gamma-1.0)*U_i[0]*(U_i[nDim+1]/U_i[0]-0.5*sq_vel); Enthalpy_i = (U_i[nDim+1] + Pressure_i) / U_i[0]; - + val_residual[0] = yinv*Volume*U_i[2]; val_residual[1] = yinv*Volume*U_i[1]*U_i[2]/U_i[0]; val_residual[2] = yinv*Volume*(U_i[2]*U_i[2]/U_i[0]); val_residual[3] = yinv*Volume*Enthalpy_i*U_i[2]; - + if (implicit) { Jacobian_i[0][0] = 0.0; Jacobian_i[0][1] = 0.0; Jacobian_i[0][2] = 1.0; Jacobian_i[0][3] = 0.0; - + Jacobian_i[1][0] = -U_i[1]*U_i[2]/(U_i[0]*U_i[0]); Jacobian_i[1][1] = U_i[2]/U_i[0]; Jacobian_i[1][2] = U_i[1]/U_i[0]; Jacobian_i[1][3] = 0.0; - + Jacobian_i[2][0] = -U_i[2]*U_i[2]/(U_i[0]*U_i[0]); Jacobian_i[2][1] = 0.0; Jacobian_i[2][2] = 2*U_i[2]/U_i[0]; Jacobian_i[2][3] = 0.0; - + Jacobian_i[3][0] = -Gamma*U_i[2]*U_i[3]/(U_i[0]*U_i[0]) + (Gamma-1)*U_i[2]*(U_i[1]*U_i[1]+U_i[2]*U_i[2])/(U_i[0]*U_i[0]*U_i[0]); Jacobian_i[3][1] = -(Gamma-1)*U_i[2]*U_i[1]/(U_i[0]*U_i[0]); Jacobian_i[3][2] = Gamma*U_i[3]/U_i[0] - 1/2*(Gamma-1)*( (U_i[1]*U_i[1]+U_i[2]*U_i[2])/(U_i[0]*U_i[0]) + 2*U_i[2]*U_i[2]/(U_i[0]*U_i[0]) ); Jacobian_i[3][3] = Gamma*U_i[2]/U_i[0]; - + for (iVar=0; iVar < nVar; iVar++) for (jVar=0; jVar < nVar; jVar++) Jacobian_i[iVar][jVar] *= yinv*Volume; - + } - + } - + else { - + for (iVar=0; iVar < nVar; iVar++) val_residual[iVar] = 0.0; - + if (implicit) { for (iVar=0; iVar < nVar; iVar++) { for (jVar=0; jVar < nVar; jVar++) Jacobian_i[iVar][jVar] = 0.0; } } - + } - + } diff --git a/SU2_CFD/src/numerics/flow/sources/CSourceBodyForce.cpp b/SU2_CFD/src/numerics/flow/sources/CSourceBodyForce.cpp index 792fc6ee8cfb..4cf55b06632a 100644 --- a/SU2_CFD/src/numerics/flow/sources/CSourceBodyForce.cpp +++ b/SU2_CFD/src/numerics/flow/sources/CSourceBodyForce.cpp @@ -44,23 +44,23 @@ CSourceBodyForce::~CSourceBodyForce(void) { } void CSourceBodyForce::ComputeResidual(su2double *val_residual, CConfig *config) { - + unsigned short iDim; su2double Force_Ref = config->GetForce_Ref(); - + /*--- Zero the continuity contribution ---*/ - + val_residual[0] = 0.0; - + /*--- Momentum contribution ---*/ - + for (iDim = 0; iDim < nDim; iDim++) val_residual[iDim+1] = -Volume * U_i[0] * Body_Force_Vector[iDim] / Force_Ref; - + /*--- Energy contribution ---*/ - + val_residual[nDim+1] = 0.0; for (iDim = 0; iDim < nDim; iDim++) val_residual[nDim+1] += -Volume * U_i[iDim+1] * Body_Force_Vector[iDim] / Force_Ref; - + } diff --git a/SU2_CFD/src/numerics/flow/sources/CSourceBoussinesq.cpp b/SU2_CFD/src/numerics/flow/sources/CSourceBoussinesq.cpp index 0a263c25aa92..d62b0e17d285 100644 --- a/SU2_CFD/src/numerics/flow/sources/CSourceBoussinesq.cpp +++ b/SU2_CFD/src/numerics/flow/sources/CSourceBoussinesq.cpp @@ -63,7 +63,7 @@ void CSourceBoussinesq::ComputeResidual(su2double *val_residual, CConfig *config hydrostatic pressure component (important for pressure BCs). ---*/ for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = Volume * DensityInc_i * ( Beta * (U_i[nDim+1] - T0)) * Gravity_Vector[iDim] / Force_Ref; + val_residual[iDim+1] = Volume * DensityInc_i * ( Beta * (U_i[nDim+1] - T0)) * Gravity_Vector[iDim] / Force_Ref; /*--- Zero the energy contribution ---*/ diff --git a/SU2_CFD/src/numerics/flow/sources/CSourceGravity.cpp b/SU2_CFD/src/numerics/flow/sources/CSourceGravity.cpp index fc0e18a4c9dd..58d26d6b97ef 100644 --- a/SU2_CFD/src/numerics/flow/sources/CSourceGravity.cpp +++ b/SU2_CFD/src/numerics/flow/sources/CSourceGravity.cpp @@ -28,18 +28,18 @@ #include "../../../../include/numerics/flow/sources/CSourceGravity.hpp" CSourceGravity::CSourceGravity(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - + } CSourceGravity::~CSourceGravity(void) { } void CSourceGravity::ComputeResidual(su2double *val_residual, CConfig *config) { unsigned short iVar; - + for (iVar = 0; iVar < nVar; iVar++) val_residual[iVar] = 0.0; - + /*--- Evaluate the source term ---*/ val_residual[nDim] = Volume * U_i[0] * STANDARD_GRAVITY; - + } diff --git a/SU2_CFD/src/numerics/flow/sources/CSourceIncAxisymmetric_Flow.cpp b/SU2_CFD/src/numerics/flow/sources/CSourceIncAxisymmetric_Flow.cpp index 84f196d639e2..f6e9c1e52fca 100644 --- a/SU2_CFD/src/numerics/flow/sources/CSourceIncAxisymmetric_Flow.cpp +++ b/SU2_CFD/src/numerics/flow/sources/CSourceIncAxisymmetric_Flow.cpp @@ -90,7 +90,7 @@ void CSourceIncAxisymmetric_Flow::ComputeResidual(su2double *val_residual, su2do for (iVar=0; iVar < nVar; iVar++) for (jVar=0; jVar < nVar; jVar++) Jacobian_i[iVar][jVar] *= yinv*Volume*DensityInc_i; - + } /*--- Add the viscous terms if necessary. ---*/ @@ -116,7 +116,7 @@ void CSourceIncAxisymmetric_Flow::ComputeResidual(su2double *val_residual, su2do tau[iDim][jDim] = (total_viscosity*(PrimVar_Grad_i[jDim+1][iDim] + PrimVar_Grad_i[iDim+1][jDim] ) -TWO3*total_viscosity*div_vel*delta[iDim][jDim]); - + /*--- Viscous terms. ---*/ val_residual[0] -= 0.0; @@ -127,7 +127,7 @@ void CSourceIncAxisymmetric_Flow::ComputeResidual(su2double *val_residual, su2do val_residual[3] -= Volume*yinv*Thermal_Conductivity_i*PrimVar_Grad_i[nDim+1][1]; } - + } else { for (iVar=0; iVar < nVar; iVar++) @@ -139,7 +139,7 @@ void CSourceIncAxisymmetric_Flow::ComputeResidual(su2double *val_residual, su2do Jacobian_i[iVar][jVar] = 0.0; } } - + } if (!energy) { diff --git a/SU2_CFD/src/numerics/flow/sources/CSourceIncRotatingFrame_Flow.cpp b/SU2_CFD/src/numerics/flow/sources/CSourceIncRotatingFrame_Flow.cpp index 9a66acffcfde..e59cb0eb29ab 100644 --- a/SU2_CFD/src/numerics/flow/sources/CSourceIncRotatingFrame_Flow.cpp +++ b/SU2_CFD/src/numerics/flow/sources/CSourceIncRotatingFrame_Flow.cpp @@ -64,13 +64,13 @@ void CSourceIncRotatingFrame_Flow::ComputeResidual(su2double *val_residual, su2d val_residual[1] = (Omega[1]*Momentum[2] - Omega[2]*Momentum[1])*Volume; val_residual[2] = (Omega[2]*Momentum[0] - Omega[0]*Momentum[2])*Volume; val_residual[3] = 0.0; - } else { + } else { val_residual[0] = 0.0; val_residual[1] = (Omega[1]*Momentum[2] - Omega[2]*Momentum[1])*Volume; val_residual[2] = (Omega[2]*Momentum[0] - Omega[0]*Momentum[2])*Volume; val_residual[3] = (Omega[0]*Momentum[1] - Omega[1]*Momentum[0])*Volume; val_residual[4] = 0.0; - } + } /*--- Calculate the source term Jacobian ---*/ diff --git a/SU2_CFD/src/numerics/flow/sources/CSourceRotatingFrame_Flow.cpp b/SU2_CFD/src/numerics/flow/sources/CSourceRotatingFrame_Flow.cpp index 2f78531b4ec7..d63aaea8fa13 100644 --- a/SU2_CFD/src/numerics/flow/sources/CSourceRotatingFrame_Flow.cpp +++ b/SU2_CFD/src/numerics/flow/sources/CSourceRotatingFrame_Flow.cpp @@ -28,34 +28,34 @@ #include "../../../../include/numerics/flow/sources/CSourceRotatingFrame_Flow.hpp" CSourceRotatingFrame_Flow::CSourceRotatingFrame_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - + Gamma = config->GetGamma(); Gamma_Minus_One = Gamma - 1.0; - + } CSourceRotatingFrame_Flow::~CSourceRotatingFrame_Flow(void) { } void CSourceRotatingFrame_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config) { - + unsigned short iDim, iVar, jVar; su2double Omega[3] = {0,0,0}, Momentum[3] = {0,0,0}; - + bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - + /*--- Retrieve the angular velocity vector from config. ---*/ - + for (iDim = 0; iDim < 3; iDim++){ Omega[iDim] = config->GetRotation_Rate(iDim)/config->GetOmega_Ref(); } - + /*--- Get the momentum vector at the current node. ---*/ - + for (iDim = 0; iDim < nDim; iDim++) Momentum[iDim] = U_i[iDim+1]; - + /*--- Calculate rotating frame source term as ( Omega X Rho-U ) ---*/ - + if (nDim == 2) { val_residual[0] = 0.0; val_residual[1] = (Omega[1]*Momentum[2] - Omega[2]*Momentum[1])*Volume; @@ -68,9 +68,9 @@ void CSourceRotatingFrame_Flow::ComputeResidual(su2double *val_residual, su2doub val_residual[3] = (Omega[0]*Momentum[1] - Omega[1]*Momentum[0])*Volume; val_residual[4] = 0.0; } - + /*--- Calculate the source term Jacobian ---*/ - + if (implicit) { for (iVar = 0; iVar < nVar; iVar++) for (jVar = 0; jVar < nVar; jVar++) @@ -87,5 +87,5 @@ void CSourceRotatingFrame_Flow::ComputeResidual(su2double *val_residual, su2doub val_Jacobian_i[3][2] = Omega[0]*Volume; } } - + } diff --git a/SU2_CFD/src/numerics/flow/sources/CSourceWindGust.cpp b/SU2_CFD/src/numerics/flow/sources/CSourceWindGust.cpp index 2896a45ca27b..c8d8f360033c 100644 --- a/SU2_CFD/src/numerics/flow/sources/CSourceWindGust.cpp +++ b/SU2_CFD/src/numerics/flow/sources/CSourceWindGust.cpp @@ -28,19 +28,19 @@ #include "../../../../include/numerics/flow/sources/CSourceWindGust.hpp" CSourceWindGust::CSourceWindGust(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - + } CSourceWindGust::~CSourceWindGust(void) { } void CSourceWindGust::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config) { - + su2double u_gust, v_gust, du_gust_dx, du_gust_dy, du_gust_dt, dv_gust_dx, dv_gust_dy, dv_gust_dt, smx, smy, se, rho, u, v, p; unsigned short GustDir = config->GetGust_Dir(); //Gust direction - + u_gust = WindGust_i[0]; v_gust = WindGust_i[1]; - + if (GustDir == X_DIR) { du_gust_dx = WindGustDer_i[0]; du_gust_dy = WindGustDer_i[1]; @@ -55,20 +55,20 @@ void CSourceWindGust::ComputeResidual(su2double *val_residual, su2double **val_J dv_gust_dx = WindGustDer_i[0]; dv_gust_dy = WindGustDer_i[1]; dv_gust_dt = WindGustDer_i[2]; - + } - + /*--- Primitive variables at point i ---*/ u = V_i[1]; v = V_i[2]; p = V_i[nDim+1]; rho = V_i[nDim+2]; - + /*--- Source terms ---*/ smx = rho*(du_gust_dt + (u+u_gust)*du_gust_dx + (v+v_gust)*du_gust_dy); smy = rho*(dv_gust_dt + (u+u_gust)*dv_gust_dx + (v+v_gust)*dv_gust_dy); se = u*smx + v*smy + p*(du_gust_dx + dv_gust_dy); - + if (nDim == 2) { val_residual[0] = 0.0; val_residual[1] = smx*Volume; @@ -77,14 +77,14 @@ void CSourceWindGust::ComputeResidual(su2double *val_residual, su2double **val_J } else { SU2_MPI::Error("You should only be in the gust source term in two dimensions", CURRENT_FUNCTION); } - + /*--- For now the source term Jacobian is just set to zero ---*/ - + unsigned short iVar, jVar; bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - + /*--- Calculate the source term Jacobian ---*/ - + if (implicit) { for (iVar = 0; iVar < nVar; iVar++) for (jVar = 0; jVar < nVar; jVar++) diff --git a/SU2_CFD/src/numerics/template/CConvective_Template.cpp b/SU2_CFD/src/numerics/template/CConvective_Template.cpp index 0131ce07c85d..969c316a0f8b 100644 --- a/SU2_CFD/src/numerics/template/CConvective_Template.cpp +++ b/SU2_CFD/src/numerics/template/CConvective_Template.cpp @@ -28,13 +28,13 @@ #include "../../../include/numerics/template/CConvective_Template.hpp" CConvective_Template::CConvective_Template(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - + + implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - + Gamma = config->GetGamma(); Gamma_Minus_One = Gamma - 1.0; - + Diff_U = new su2double [nVar]; Velocity_i = new su2double [nDim]; Velocity_j = new su2double [nDim]; @@ -55,7 +55,7 @@ CConvective_Template::CConvective_Template(unsigned short val_nDim, unsigned sho CConvective_Template::~CConvective_Template(void) { unsigned short iVar; - + delete [] Diff_U; delete [] Velocity_i; delete [] Velocity_j; @@ -75,16 +75,16 @@ CConvective_Template::~CConvective_Template(void) { } void CConvective_Template::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - + Area = 0; for (iDim = 0; iDim < nDim; iDim++) /*!< \brief Normal: Normal vector, it norm is the area of the face. */ Area += Normal[iDim]*Normal[iDim]; Area = sqrt(Area); /*! Area of the face*/ - + for (iDim = 0; iDim < nDim; iDim++) UnitNormal[iDim] = Normal[iDim]/Area; /* ! Unit Normal*/ - + /*--- Point i, Needs to recompute SoundSpeed / Pressure / Enthalpy in case of 2nd order reconstruction ---*/ Density_i = U_i[0]; sq_vel = 0; @@ -96,7 +96,7 @@ void CConvective_Template::ComputeResidual(su2double *val_residual, su2double ** SoundSpeed_i = sqrt(Gamma*Gamma_Minus_One*(Energy_i-0.5*sq_vel)); Pressure_i = (SoundSpeed_i * SoundSpeed_i * Density_i) / Gamma; Enthalpy_i = (U_i[nDim+1] + Pressure_i) / Density_i; - + /*--- Point j, Needs to recompute SoundSpeed / Pressure / Enthalpy in case of 2nd order reconstruction ---*/ Density_j = U_j[0]; sq_vel = 0; @@ -108,7 +108,7 @@ void CConvective_Template::ComputeResidual(su2double *val_residual, su2double ** SoundSpeed_j = sqrt(Gamma*Gamma_Minus_One*(Energy_j-0.5*sq_vel)); Pressure_j = (SoundSpeed_j * SoundSpeed_j * Density_j) / Gamma; Enthalpy_j = (U_j[nDim+1] + Pressure_j) / Density_j; - + /*--- Mean Roe variables iPoint and jPoint ---*/ R = sqrt(Density_j/Density_i); RoeDensity = R*Density_i; @@ -119,23 +119,23 @@ void CConvective_Template::ComputeResidual(su2double *val_residual, su2double ** } RoeEnthalpy = (R*Enthalpy_j+Enthalpy_i)/(R+1); RoeSoundSpeed = sqrt((Gamma-1)*(RoeEnthalpy-0.5*sq_vel)); - + /*--- Compute ProjFlux_i ---*/ GetInviscidProjFlux(&Density_i, Velocity_i, &Pressure_i, &Enthalpy_i, Normal, ProjFlux_i); - + /*--- Compute ProjFlux_j ---*/ GetInviscidProjFlux(&Density_j, Velocity_j, &Pressure_j, &Enthalpy_j, Normal, ProjFlux_j); - + /*--- Compute P and Lambda (do it with the Normal) ---*/ GetPMatrix(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, P_Tensor); - + ProjVelocity = 0.0; ProjVelocity_i = 0.0; ProjVelocity_j = 0.0; for (iDim = 0; iDim < nDim; iDim++) { ProjVelocity += RoeVelocity[iDim]*UnitNormal[iDim]; ProjVelocity_i += Velocity_i[iDim]*UnitNormal[iDim]; ProjVelocity_j += Velocity_j[iDim]*UnitNormal[iDim]; } - + /*--- Flow eigenvalues and Entropy correctors ---*/ for (iDim = 0; iDim < nDim; iDim++) { Lambda[iDim] = ProjVelocity; @@ -145,15 +145,15 @@ void CConvective_Template::ComputeResidual(su2double *val_residual, su2double ** Epsilon[nVar-2] = 4.0*max(0.0, max(Lambda[nVar-2]-(ProjVelocity_i+SoundSpeed_i),(ProjVelocity_j+SoundSpeed_j)-Lambda[nVar-2])); Lambda[nVar-1] = ProjVelocity - RoeSoundSpeed; Epsilon[nVar-1] = 4.0*max(0.0, max(Lambda[nVar-1]-(ProjVelocity_i-SoundSpeed_i),(ProjVelocity_j-SoundSpeed_j)-Lambda[nVar-1])); - + /*--- Entropy correction ---*/ for (iVar = 0; iVar < nVar; iVar++) if ( fabs(Lambda[iVar]) < Epsilon[iVar] ) Lambda[iVar] = (Lambda[iVar]*Lambda[iVar] + Epsilon[iVar]*Epsilon[iVar])/(2.0*Epsilon[iVar]); else Lambda[iVar] = fabs(Lambda[iVar]); - - + + if (!implicit) { /*--- Compute wave amplitudes (characteristics) ---*/ proj_delta_vel = 0.0; @@ -164,7 +164,7 @@ void CConvective_Template::ComputeResidual(su2double *val_residual, su2double ** delta_p = Pressure_j - Pressure_i; delta_rho = Density_j - Density_i; proj_delta_vel = proj_delta_vel/Area; - + if (nDim == 3) { delta_wave[0] = delta_rho - delta_p/(RoeSoundSpeed*RoeSoundSpeed); delta_wave[1] = UnitNormal[0]*delta_vel[2]-UnitNormal[2]*delta_vel[0]; @@ -178,7 +178,7 @@ void CConvective_Template::ComputeResidual(su2double *val_residual, su2double ** delta_wave[2] = proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); delta_wave[3] = -proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); } - + /*--- Roe's Flux approximation ---*/ for (iVar = 0; iVar < nVar; iVar++) { val_residual[iVar] = 0.5*(ProjFlux_i[iVar]+ProjFlux_j[iVar]); @@ -187,18 +187,18 @@ void CConvective_Template::ComputeResidual(su2double *val_residual, su2double ** } } else { - + /*--- Compute inverse P ---*/ GetPMatrix_inv(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, invP_Tensor); - + /*--- Jacobias of the inviscid flux, scale = 0.5 because val_resconv ~ 0.5*(fc_i+fc_j)*Normal ---*/ GetInviscidProjJac(Velocity_i, &Energy_i, Normal, 0.5, val_Jacobian_i); GetInviscidProjJac(Velocity_j, &Energy_j, Normal, 0.5, val_Jacobian_j); - + /*--- Diference variables iPoint and jPoint ---*/ for (iVar = 0; iVar < nVar; iVar++) Diff_U[iVar] = U_j[iVar]-U_i[iVar]; - + /*--- Roe's Flux approximation ---*/ for (iVar = 0; iVar < nVar; iVar++) { val_residual[iVar] = 0.5*(ProjFlux_i[iVar]+ProjFlux_j[iVar]); diff --git a/SU2_CFD/src/numerics/template/CSource_Template.cpp b/SU2_CFD/src/numerics/template/CSource_Template.cpp index 1d95822bb8fc..d4847888c3a3 100644 --- a/SU2_CFD/src/numerics/template/CSource_Template.cpp +++ b/SU2_CFD/src/numerics/template/CSource_Template.cpp @@ -31,7 +31,7 @@ CSource_Template::CSource_Template(unsigned short val_nDim, unsigned short val_n CConfig *config) : CNumerics(val_nDim, val_nVar, config) {} CSource_Template::~CSource_Template(void) { - + } void CSource_Template::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config) {} diff --git a/SU2_CFD/src/numerics/transition/CAvgGradCorrected_TransLM.cpp b/SU2_CFD/src/numerics/transition/CAvgGradCorrected_TransLM.cpp index afed7b4c5c20..195e9d407ee2 100644 --- a/SU2_CFD/src/numerics/transition/CAvgGradCorrected_TransLM.cpp +++ b/SU2_CFD/src/numerics/transition/CAvgGradCorrected_TransLM.cpp @@ -29,17 +29,17 @@ CAvgGradCorrected_TransLM::CAvgGradCorrected_TransLM(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - + unsigned short iVar; - + implicit = (config->GetKind_TimeIntScheme_Turb() == EULER_IMPLICIT); incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); - + Gamma = config->GetGamma(); Gamma_Minus_One = Gamma - 1.0; - + sigma = 2./3.; - + Edge_Vector = new su2double [nDim]; Proj_Mean_GradTurbVar_Kappa = new su2double [nVar]; Proj_Mean_GradTurbVar_Edge = new su2double [nVar]; @@ -50,9 +50,9 @@ CAvgGradCorrected_TransLM::CAvgGradCorrected_TransLM(unsigned short val_nDim, un } CAvgGradCorrected_TransLM::~CAvgGradCorrected_TransLM(void) { - + unsigned short iVar; - + delete [] Edge_Vector; delete [] Proj_Mean_GradTurbVar_Kappa; delete [] Proj_Mean_GradTurbVar_Edge; @@ -63,7 +63,7 @@ CAvgGradCorrected_TransLM::~CAvgGradCorrected_TransLM(void) { } void CAvgGradCorrected_TransLM::ComputeResidual(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config) { - + // switch (config->GetKind_Turb_Model()) { // case SA : // /*--- Compute mean effective viscosity ---*/ diff --git a/SU2_CFD/src/numerics/transition/CAvgGrad_TransLM.cpp b/SU2_CFD/src/numerics/transition/CAvgGrad_TransLM.cpp index 06ec045f7e17..40c840ffe05e 100644 --- a/SU2_CFD/src/numerics/transition/CAvgGrad_TransLM.cpp +++ b/SU2_CFD/src/numerics/transition/CAvgGrad_TransLM.cpp @@ -29,15 +29,15 @@ CAvgGrad_TransLM::CAvgGrad_TransLM(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { unsigned short iVar; - + implicit = (config->GetKind_TimeIntScheme_Turb() == EULER_IMPLICIT); incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); Gamma = config->GetGamma(); Gamma_Minus_One = Gamma - 1.0; - + sigma = 2./3.; - + Edge_Vector = new su2double [nDim]; Proj_Mean_GradTransVar_Kappa = new su2double [nVar]; Proj_Mean_GradTransVar_Edge = new su2double [nVar]; @@ -47,9 +47,9 @@ CAvgGrad_TransLM::CAvgGrad_TransLM(unsigned short val_nDim, unsigned short val_n } CAvgGrad_TransLM::~CAvgGrad_TransLM(void) { - + unsigned short iVar; - + delete [] Edge_Vector; delete [] Proj_Mean_GradTransVar_Kappa; delete [] Proj_Mean_GradTransVar_Edge; @@ -59,7 +59,7 @@ CAvgGrad_TransLM::~CAvgGrad_TransLM(void) { } void CAvgGrad_TransLM::ComputeResidual(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config) { - /*--- This section is commented out on 04/11/2016 + /*--- This section is commented out on 04/11/2016 after review of the static scan ---*/ // su2double *Density_Grad_i = new su2double[nDim]; // su2double *Density_Grad_j = new su2double[nDim]; @@ -67,18 +67,18 @@ void CAvgGrad_TransLM::ComputeResidual(su2double *val_residual, su2double **Jaco // su2double *Conservative_Grad_j = new su2double[nDim]; // su2double *Primitive_Grad_i = new su2double[nDim]; // su2double *Primitive_Grad_j = new su2double[nDim]; - // + // // /*--- Intermediate values for combining viscosities ---*/ // su2double Inter_Viscosity_i, Inter_Viscosity_j, REth_Viscosity_i, REth_Viscosity_j, Inter_Viscosity_Mean, REth_Viscosity_Mean; - // + // // /*--- Model constants---*/ // su2double sigmaf = 1.0; // su2double sigma_thetat = 2.0; - // + // // /*--- Get density ---*/ // Density_i = U_i[0]; // Density_j = U_j[0]; - // + // // /*--- Construct combinations of viscosity ---*/ // Inter_Viscosity_i = (Laminar_Viscosity_i+Eddy_Viscosity_i/sigmaf); // Inter_Viscosity_j = (Laminar_Viscosity_j+Eddy_Viscosity_j/sigmaf); @@ -86,7 +86,7 @@ void CAvgGrad_TransLM::ComputeResidual(su2double *val_residual, su2double **Jaco // REth_Viscosity_i = sigma_thetat*(Laminar_Viscosity_i+Eddy_Viscosity_i); // REth_Viscosity_j = sigma_thetat*(Laminar_Viscosity_j+Eddy_Viscosity_j); // REth_Viscosity_Mean = 0.5*(REth_Viscosity_i+REth_Viscosity_j); - // + // ///*--- Compute vector going from iPoint to jPoint ---*/ //dist_ij_2 = 0; proj_vector_ij = 0; //for (iDim = 0; iDim < nDim; iDim++) { @@ -95,13 +95,13 @@ void CAvgGrad_TransLM::ComputeResidual(su2double *val_residual, su2double **Jaco // proj_vector_ij += Edge_Vector[iDim]*Normal[iDim]; //} //proj_vector_ij = proj_vector_ij/dist_ij_2; // to normalize vectors - // + // ///*--- Mean gradient approximation ---*/ //for (iVar = 0; iVar < nVar; iVar++) { // Proj_Mean_GradTransVar_Kappa[iVar] = 0.0; // // Proj_Mean_GradTransVar_Edge[iVar] = 0.0; // for (iDim = 0; iDim < nDim; iDim++) { - // + // // /* -- Compute primitive grad using chain rule -- */ // Density_Grad_i[iDim] = ConsVar_Grad_i[0][iDim]; // Density_Grad_j[iDim] = ConsVar_Grad_j[0][iDim]; @@ -109,16 +109,16 @@ void CAvgGrad_TransLM::ComputeResidual(su2double *val_residual, su2double **Jaco // Conservative_Grad_j[iDim] = TransVar_Grad_j[iVar][iDim]; // Primitive_Grad_i[iDim] = 1./Density_i*(Conservative_Grad_i[iDim]-TransVar_i[iVar]*Density_Grad_i[iDim]); // Primitive_Grad_j[iDim] = 1./Density_j*(Conservative_Grad_j[iDim]-TransVar_j[iVar]*Density_Grad_j[iDim]); - // + // // /*--- Compute the average primitive gradient and project it in the normal direction ---*/ // Mean_GradTransVar[iVar][iDim] = 0.5*(Primitive_Grad_i[iDim] + Primitive_Grad_j[iDim]); // Proj_Mean_GradTransVar_Kappa[iVar] += Mean_GradTransVar[iVar][iDim]*Normal[iDim]; // } //} - // + // //val_residual[0] = Inter_Viscosity_Mean*Proj_Mean_GradTransVar_Kappa[0]; //val_residual[1] = REth_Viscosity_Mean*Proj_Mean_GradTransVar_Kappa[1]; - // + // ///*--- For Jacobians -> Use of TSL approx. to compute derivatives of the gradients ---*/ //if (implicit) { // Jacobian_i[0][0] = (0.5*Proj_Mean_GradTransVar_Kappa[0]-Inter_Viscosity_Mean*proj_vector_ij); @@ -126,7 +126,7 @@ void CAvgGrad_TransLM::ComputeResidual(su2double *val_residual, su2double **Jaco // Jacobian_i[1][1] = (0.5*Proj_Mean_GradTransVar_Kappa[1]-REth_Viscosity_Mean*proj_vector_ij); // Jacobian_j[1][1] = (0.5*Proj_Mean_GradTransVar_Kappa[1]+REth_Viscosity_Mean*proj_vector_ij); //} - // + // // /*--- Free locally allocated memory. For efficiency, these arrays // should really be allocated/deallocated in the constructor/destructor. ---*/ // delete [] Density_Grad_i; @@ -135,5 +135,5 @@ void CAvgGrad_TransLM::ComputeResidual(su2double *val_residual, su2double **Jaco // delete [] Conservative_Grad_j; // delete [] Primitive_Grad_i; // delete [] Primitive_Grad_j; - // + // } diff --git a/SU2_CFD/src/numerics/transition/CSourcePieceWise_TransLM.cpp b/SU2_CFD/src/numerics/transition/CSourcePieceWise_TransLM.cpp index 5469edb69bc6..94d8289efa80 100644 --- a/SU2_CFD/src/numerics/transition/CSourcePieceWise_TransLM.cpp +++ b/SU2_CFD/src/numerics/transition/CSourcePieceWise_TransLM.cpp @@ -29,10 +29,10 @@ CSourcePieceWise_TransLM::CSourcePieceWise_TransLM(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - + Gamma = config->GetGamma(); Gamma_Minus_One = Gamma - 1.0; - + /*--- Spalart-Allmaras closure constants ---*/ cv1_3 = pow(7.1,3.0); k2 = pow(0.41,2.0); @@ -42,7 +42,7 @@ CSourcePieceWise_TransLM::CSourcePieceWise_TransLM(unsigned short val_nDim, unsi sigma = 2./3.; cb2 = 0.622; cw1 = cb1/k2+(1+cb2)/sigma; - + /*-- Gamma-theta closure constants --*/ c_e1 = 1.0; c_a1 = 2.0; @@ -52,11 +52,11 @@ CSourcePieceWise_TransLM::CSourcePieceWise_TransLM(unsigned short val_nDim, unsi s1 = 2.0; c_theta = 0.03; sigmat = 2.0; - + /*-- Correlation constants --*/ flen_global = 12.0; alpha_global = 0.85; - + /*-- For debugging -AA --*/ debugme = 0; } @@ -67,7 +67,7 @@ void CSourcePieceWise_TransLM::ComputeResidual_TransLM(su2double *val_residual, //************************************************// // Please do not delete //SU2_CPP2C comment lines // //************************************************// - + //SU2_CPP2C START CSourcePieceWise_TransLM::ComputeResidual_TransLM //SU2_CPP2C CALL_LIST START //SU2_CPP2C INVARS *TransVar_i @@ -75,30 +75,30 @@ void CSourcePieceWise_TransLM::ComputeResidual_TransLM(su2double *val_residual, //SU2_CPP2C VARS DOUBLE *U_i **PrimVar_Grad_i Laminar_Viscosity_i Eddy_Viscosity_i dist_i //SU2_CPP2C VARS DOUBLE SCALAR c_a1 c_e1 c_a2 c_e2 c_theta alpha_global flen_global //SU2_CPP2C CALL_LIST END - + //SU2_CPP2C DEFINE nDim - + //SU2_CPP2C DECL_LIST START //SU2_CPP2C VARS DOUBLE SCALAR Vorticity //SU2_CPP2C DECL_LIST END - + /*-- Local intermediate variables --*/ su2double rey_tc, flen, re_v, strain, f_onset1, f_onset2, f_onset3, f_onset, f_turb, tu; - + su2double prod, des; su2double f_lambda, re_theta = 0.0, re_theta_lim, r_t; su2double Velocity_Mag = 0.0, du_ds, theta, lambda, time_scale, var1, f_theta; su2double f_reattach; su2double dU_dx, dU_dy, dU_dz = 0.0; - + //SU2_CPP2C COMMENT START su2double val_residuald[2], TransVar_id[2]; - + //SU2_CPP2C COMMENT END - + val_residual[0] = 0.0; val_residual[1] = 0.0; - + //SU2_CPP2C COMMENT START implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); if (implicit) { @@ -108,7 +108,7 @@ void CSourcePieceWise_TransLM::ComputeResidual_TransLM(su2double *val_residual, val_Jacobian_i[1][1] = 0.0; } //SU2_CPP2C COMMENT END - + /* -- These lines included just so Tapenade doesn't complain --*/ // rey = 0.0; // mach = 0.0; @@ -119,73 +119,73 @@ void CSourcePieceWise_TransLM::ComputeResidual_TransLM(su2double *val_residual, // mach = config->GetMach(); tu = config->GetTurbulenceIntensity_FreeStream(); //SU2_CPP2C COMMENT END - + /*--- Compute vorticity and strain (TODO: Update for 3D) ---*/ Vorticity = fabs(PrimVar_Grad_i[1][1]-PrimVar_Grad_i[2][0]); - + /*-- Strain = sqrt(2*Sij*Sij) --*/ strain = sqrt(2.*( PrimVar_Grad_i[1][0]*PrimVar_Grad_i[1][0] + 0.5*pow(PrimVar_Grad_i[1][1]+PrimVar_Grad_i[2][0],2) + PrimVar_Grad_i[2][1]*PrimVar_Grad_i[2][1] )); - + /*-- Note: no incompressible for now! --*/ - + if (dist_i > 0.0) { // Only operate away from wall - + /*-- Intermittency eq.: --*/ - + rey_tc = (4.45*pow(tu,3) - 5.7*pow(tu,2) + 1.37*tu + 0.585)*TransVar_i[1]; flen = 0.171*pow(tu,2) - 0.0083*tu + 0.0306; - + re_v = U_i[0]*pow(dist_i,2.)/Laminar_Viscosity_i*strain; // Vorticity Reynolds number - + /*-- f_onset controls transition onset location --*/ r_t = Eddy_Viscosity_i/Laminar_Viscosity_i; f_onset1 = re_v / (2.193*rey_tc); f_onset2 = min(max(f_onset1, pow(f_onset1,4.)), 2.); f_onset3 = max(1. - pow(0.4*r_t,3),0.); f_onset = max(f_onset2 - f_onset3, 0.); - + f_turb = exp(-pow(0.25*r_t,4)); // Medida eq. 10 - + prod = flen*c_a1*U_i[0]*strain*sqrt(f_onset*TransVar_i[0]); prod = prod*(1. - c_e1*TransVar_i[0]); - + des = c_a2*U_i[0]*Vorticity*TransVar_i[0]*f_turb; des = des*(c_e2*TransVar_i[0] - 1.); - + val_residual[0] = prod - des; - + /*-- REtheta eq: --*/ if (nDim==2) { Velocity_Mag = sqrt(U_i[1]*U_i[1]+U_i[2]*U_i[2])/U_i[0]; } else if (nDim==3) { Velocity_Mag = sqrt(U_i[1]*U_i[1]+U_i[2]*U_i[2]+U_i[3]*U_i[3])/U_i[0]; } - + /*-- Gradient of velocity magnitude ---*/ dU_dx = 0.5*Velocity_Mag*( 2*U_i[1]/U_i[0]*PrimVar_Grad_i[1][0] +2*U_i[2]/U_i[0]*PrimVar_Grad_i[2][0]); if (nDim==3) dU_dx += 0.5*Velocity_Mag*( 2*U_i[3]/U_i[0]*PrimVar_Grad_i[3][0]); - + dU_dy = 0.5*Velocity_Mag*( 2*U_i[1]/U_i[0]*PrimVar_Grad_i[1][1] +2*U_i[2]/U_i[0]*PrimVar_Grad_i[2][1]); if (nDim==3) dU_dy += 0.5*Velocity_Mag*( 2*U_i[3]/U_i[0]*PrimVar_Grad_i[3][1]); - + if (nDim==3) dU_dz = 0.5*Velocity_Mag*( 2*U_i[1]/U_i[0]*PrimVar_Grad_i[1][2] +2*U_i[2]/U_i[0]*PrimVar_Grad_i[2][2] +2*U_i[3]/U_i[0]*PrimVar_Grad_i[3][2]); - + du_ds = U_i[1]/(U_i[0]*Velocity_Mag) * dU_dx + // Streamwise velocity derivative U_i[2]/(U_i[0]*Velocity_Mag) * dU_dy; if (nDim==3) du_ds += U_i[3]/(U_i[0]*Velocity_Mag) * dU_dz; - + re_theta_lim = 20.; - + /*-- Fixed-point iterations to solve REth correlation --*/ f_lambda = 1.; for (int iter=0; iter<10; iter++) { @@ -195,12 +195,12 @@ void CSourcePieceWise_TransLM::ComputeResidual_TransLM(su2double *val_residual, re_theta = 331.5 * f_lambda*pow(tu-0.5658,-0.671); } re_theta = max(re_theta, re_theta_lim); - + theta = re_theta * Laminar_Viscosity_i / (U_i[0]*Velocity_Mag); - + lambda = U_i[0]*theta*theta*du_ds / Laminar_Viscosity_i; lambda = min(max(-0.1, lambda),0.1); - + if (lambda<=0.0) { f_lambda = 1. - (-12.986*lambda - 123.66*lambda*lambda - 405.689*lambda*lambda*lambda)*exp(-pow(2./3*tu,1.5)); @@ -208,25 +208,25 @@ void CSourcePieceWise_TransLM::ComputeResidual_TransLM(su2double *val_residual, f_lambda = 1. + 0.275*(1.-exp(-35.*lambda))*exp(-2.*tu); } } - + /*-- Calculate blending function f_theta --*/ time_scale = 500.0*Laminar_Viscosity_i/(U_i[0]*Velocity_Mag*Velocity_Mag); - + // Deactivated the f_wake parameter... //theta_bl = TransVar_i[1]*Laminar_Viscosity_i / (U_i[0]*Velocity_Mag); //delta_bl = 7.5*theta_bl; //delta = 50.0*Vorticity*dist_i/Velocity_Mag*delta_bl + 1e-20; // //f_wake = 1.; - + var1 = (TransVar_i[0]-1./c_e2)/(1.0-1./c_e2); var1 = 1. - pow(var1,2); - + //f_theta = min(max(f_wake*exp(-pow(dist_i/delta,4)), var1),1.0); f_theta = min(var1,1.0); - + val_residual[1] = c_theta*U_i[0]/time_scale * (1.-f_theta) * (re_theta-TransVar_i[1]); - + //SU2_CPP2C COMMENT START cout << "val_res0: " << val_residual[0] << endl; cout << "val_res1: " << val_residual[1] << endl; @@ -249,23 +249,23 @@ void CSourcePieceWise_TransLM::ComputeResidual_TransLM(su2double *val_residual, cout << "r_t: " << r_t << endl; cout << "rey_tc: " << rey_tc << endl; cout << "re_theta: " << re_theta << endl; - + /*-- Calculate term for separation correction --*/ f_reattach = exp(-pow(0.05*r_t,4)); gamma_sep = s1*max(0., re_v/(3.235*rey_tc)-1.)*f_reattach; gamma_sep = min(gamma_sep,2.0)*f_theta; - + /*--- Implicit part ---*/ TransVar_id[0] = 1.0; TransVar_id[1] = 0.0; CSourcePieceWise_TransLM__ComputeResidual_TransLM_d(TransVar_i, TransVar_id, val_residual, val_residuald, config); val_Jacobian_i[0][0] = val_residuald[0]; val_Jacobian_i[1][0] = val_residuald[1]; - + TransVar_id[0] = 0.0; TransVar_id[1] = 1.0; CSourcePieceWise_TransLM__ComputeResidual_TransLM_d(TransVar_i, TransVar_id, val_residual, val_residuald, config); val_Jacobian_i[0][1] = val_residuald[0]; val_Jacobian_i[1][1] = val_residuald[1]; - + //SU2_CPP2C COMMENT END } //SU2_CPP2C END CSourcePieceWise_TransLM::ComputeResidual_TransLM @@ -446,7 +446,7 @@ void CSourcePieceWise_TransLM::CSourcePieceWise_TransLM__ComputeResidual_TransLM // //f_wake = 1.; var1d = TransVar_id[0]/(1.0-1./c_e2); - var1 = (TransVar_i[0]-1./c_e2)/(1.0-1./c_e2); + var1 = (TransVar_i[0]-1./c_e2)/(1.0-1./c_e2); result1 = pow(var1, 2.0); result1d = 2.0*var1d*pow(var1, 1.0); var1d = -result1d; diff --git a/SU2_CFD/src/numerics/transition/CUpwLin_TransLM.cpp b/SU2_CFD/src/numerics/transition/CUpwLin_TransLM.cpp index fae509edecbf..e2320ee3ecc3 100644 --- a/SU2_CFD/src/numerics/transition/CUpwLin_TransLM.cpp +++ b/SU2_CFD/src/numerics/transition/CUpwLin_TransLM.cpp @@ -28,16 +28,16 @@ #include "../../../include/numerics/transition/CUpwLin_TransLM.hpp" CUpwLin_TransLM::CUpwLin_TransLM(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - + implicit = (config->GetKind_TimeIntScheme_Turb() == EULER_IMPLICIT); incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); - + Gamma = config->GetGamma(); Gamma_Minus_One = Gamma - 1.0; - + Velocity_i = new su2double [nDim]; Velocity_j = new su2double [nDim]; - + } CUpwLin_TransLM::~CUpwLin_TransLM(void) { @@ -46,18 +46,18 @@ CUpwLin_TransLM::~CUpwLin_TransLM(void) { } void CUpwLin_TransLM::ComputeResidual (su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - + + Density_i = U_i[0]; Density_j = U_j[0]; - + q_ij = 0; for (iDim = 0; iDim < nDim; iDim++) { Velocity_i[iDim] = U_i[iDim+1]/Density_i; Velocity_j[iDim] = U_j[iDim+1]/Density_j; q_ij += 0.5*(Velocity_i[iDim]+Velocity_j[iDim])*Normal[iDim]; } - + a0 = 0.5*(q_ij+fabs(q_ij)); a1 = 0.5*(q_ij-fabs(q_ij)); val_residual[0] = a0*TransVar_i[0]+a1*TransVar_j[0]; @@ -65,8 +65,8 @@ void CUpwLin_TransLM::ComputeResidual (su2double *val_residual, su2double **val_ // cout << "Velicity x: " << Velocity_i[0] << ", " << Velocity_j[0] << endl; // cout << "Velicity y: " << Velocity_i[1] << ", " << Velocity_j[1] << endl; // cout << "val_resid: " << val_residual[0] << ", " << val_residual[1] << endl; - - + + if (implicit) { val_Jacobian_i[0][0] = a0; val_Jacobian_i[1][1] = a0; diff --git a/SU2_CFD/src/numerics/transition/CUpwSca_TransLM.cpp b/SU2_CFD/src/numerics/transition/CUpwSca_TransLM.cpp index 1c081ebf67a0..d258a17cffa4 100644 --- a/SU2_CFD/src/numerics/transition/CUpwSca_TransLM.cpp +++ b/SU2_CFD/src/numerics/transition/CUpwSca_TransLM.cpp @@ -29,12 +29,12 @@ CUpwSca_TransLM::CUpwSca_TransLM(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - + implicit = (config->GetKind_TimeIntScheme_Turb() == EULER_IMPLICIT); - + Gamma = config->GetGamma(); Gamma_Minus_One = Gamma - 1.0; - + Velocity_i = new su2double [nDim]; Velocity_j = new su2double [nDim]; } @@ -45,28 +45,28 @@ CUpwSca_TransLM::~CUpwSca_TransLM(void) { } void CUpwSca_TransLM::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - + q_ij = 0; for (iDim = 0; iDim < nDim; iDim++) { q_ij += 0.5*(U_i[iDim]+U_j[iDim])*Normal[iDim]; } - + a0 = 0.5*(q_ij+fabs(q_ij)); a1 = 0.5*(q_ij-fabs(q_ij)); val_residual[0] = a0*TransVar_i[0]+a1*TransVar_j[0]; val_residual[1] = a0*TransVar_i[1]+a1*TransVar_j[1]; - + if (implicit) { val_Jacobian_i[0][0] = a0; val_Jacobian_j[0][0] = a1; val_Jacobian_i[1][1] = a0; val_Jacobian_j[1][1] = a1; - + /*--- Zero out off-diagonal terms just in case ---*/ val_Jacobian_i[0][1] = 0; val_Jacobian_j[0][1] = 0; val_Jacobian_i[1][0] = 0; val_Jacobian_j[1][0] = 0; } - + } diff --git a/SU2_CFD/src/numerics/turbulent/CAvgGrad_TurbSA.cpp b/SU2_CFD/src/numerics/turbulent/CAvgGrad_TurbSA.cpp index b23825a5fb8f..c2867468a915 100644 --- a/SU2_CFD/src/numerics/turbulent/CAvgGrad_TurbSA.cpp +++ b/SU2_CFD/src/numerics/turbulent/CAvgGrad_TurbSA.cpp @@ -40,17 +40,17 @@ void CAvgGrad_TurbSA::ExtraADPreaccIn() { } void CAvgGrad_TurbSA::FinishResidualCalc(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config) { - + /*--- Compute mean effective viscosity ---*/ - + nu_i = Laminar_Viscosity_i/Density_i; nu_j = Laminar_Viscosity_j/Density_j; nu_e = 0.5*(nu_i+nu_j+TurbVar_i[0]+TurbVar_j[0]); - + val_residual[0] = nu_e*Proj_Mean_GradTurbVar[0]/sigma; - + /*--- For Jacobians -> Use of TSL approx. to compute derivatives of the gradients ---*/ - + if (implicit) { Jacobian_i[0][0] = (0.5*Proj_Mean_GradTurbVar[0]-nu_e*proj_vector_ij)/sigma; Jacobian_j[0][0] = (0.5*Proj_Mean_GradTurbVar[0]+nu_e*proj_vector_ij)/sigma; diff --git a/SU2_CFD/src/numerics/turbulent/CAvgGrad_TurbSA_Neg.cpp b/SU2_CFD/src/numerics/turbulent/CAvgGrad_TurbSA_Neg.cpp index 887650efcba8..708bed5d2afa 100644 --- a/SU2_CFD/src/numerics/turbulent/CAvgGrad_TurbSA_Neg.cpp +++ b/SU2_CFD/src/numerics/turbulent/CAvgGrad_TurbSA_Neg.cpp @@ -47,15 +47,15 @@ void CAvgGrad_TurbSA_Neg::FinishResidualCalc(su2double *val_residual, CConfig *config) { /*--- Compute mean effective viscosity ---*/ - + nu_i = Laminar_Viscosity_i/Density_i; nu_j = Laminar_Viscosity_j/Density_j; - + nu_ij = 0.5*(nu_i+nu_j); nu_tilde_ij = 0.5*(TurbVar_i[0]+TurbVar_j[0]); Xi = nu_tilde_ij/nu_ij; - + if (nu_tilde_ij > 0.0) { nu_e = nu_ij + nu_tilde_ij; } @@ -63,11 +63,11 @@ void CAvgGrad_TurbSA_Neg::FinishResidualCalc(su2double *val_residual, fn = (cn1 + Xi*Xi*Xi)/(cn1 - Xi*Xi*Xi); nu_e = nu_ij + fn*nu_tilde_ij; } - + val_residual[0] = nu_e*Proj_Mean_GradTurbVar_Normal[0]/sigma; - + /*--- For Jacobians -> Use of TSL approx. to compute derivatives of the gradients ---*/ - + if (implicit) { Jacobian_i[0][0] = (0.5*Proj_Mean_GradTurbVar[0]-nu_e*proj_vector_ij)/sigma; Jacobian_j[0][0] = (0.5*Proj_Mean_GradTurbVar[0]+nu_e*proj_vector_ij)/sigma; diff --git a/SU2_CFD/src/numerics/turbulent/CAvgGrad_TurbSST.cpp b/SU2_CFD/src/numerics/turbulent/CAvgGrad_TurbSST.cpp index 431f4b3c59dd..b29974db2930 100644 --- a/SU2_CFD/src/numerics/turbulent/CAvgGrad_TurbSST.cpp +++ b/SU2_CFD/src/numerics/turbulent/CAvgGrad_TurbSST.cpp @@ -33,16 +33,16 @@ CAvgGrad_TurbSST::CAvgGrad_TurbSST(unsigned short val_nDim, bool correct_grad, CConfig *config) : CAvgGrad_Scalar(val_nDim, val_nVar, correct_grad, config) { - + sigma_k1 = constants[0]; sigma_om1 = constants[2]; sigma_k2 = constants[1]; sigma_om2 = constants[3]; - + F1_i = 0.0; F1_j = 0.0; diff_kine = 0.0; diff_omega = 0.0; - + } CAvgGrad_TurbSST::~CAvgGrad_TurbSST(void) { @@ -53,35 +53,35 @@ void CAvgGrad_TurbSST::ExtraADPreaccIn() { } void CAvgGrad_TurbSST::FinishResidualCalc(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config) { - + su2double sigma_kine_i, sigma_kine_j, sigma_omega_i, sigma_omega_j; su2double diff_i_kine, diff_i_omega, diff_j_kine, diff_j_omega; - + /*--- Compute the blended constant for the viscous terms ---*/ sigma_kine_i = F1_i*sigma_k1 + (1.0 - F1_i)*sigma_k2; sigma_kine_j = F1_j*sigma_k1 + (1.0 - F1_j)*sigma_k2; sigma_omega_i = F1_i*sigma_om1 + (1.0 - F1_i)*sigma_om2; sigma_omega_j = F1_j*sigma_om1 + (1.0 - F1_j)*sigma_om2; - + /*--- Compute mean effective viscosity ---*/ diff_i_kine = Laminar_Viscosity_i + sigma_kine_i*Eddy_Viscosity_i; diff_j_kine = Laminar_Viscosity_j + sigma_kine_j*Eddy_Viscosity_j; diff_i_omega = Laminar_Viscosity_i + sigma_omega_i*Eddy_Viscosity_i; diff_j_omega = Laminar_Viscosity_j + sigma_omega_j*Eddy_Viscosity_j; - + diff_kine = 0.5*(diff_i_kine + diff_j_kine); // Could instead use weighted average! diff_omega = 0.5*(diff_i_omega + diff_j_omega); - + val_residual[0] = diff_kine*Proj_Mean_GradTurbVar[0]; val_residual[1] = diff_omega*Proj_Mean_GradTurbVar[1]; - + /*--- For Jacobians -> Use of TSL approx. to compute derivatives of the gradients ---*/ if (implicit) { Jacobian_i[0][0] = -diff_kine*proj_vector_ij/Density_i; Jacobian_i[0][1] = 0.0; Jacobian_i[1][0] = 0.0; Jacobian_i[1][1] = -diff_omega*proj_vector_ij/Density_i; - + Jacobian_j[0][0] = diff_kine*proj_vector_ij/Density_j; Jacobian_j[0][1] = 0.0; Jacobian_j[1][0] = 0.0; Jacobian_j[1][1] = diff_omega*proj_vector_ij/Density_j; } - + } diff --git a/SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSA.cpp b/SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSA.cpp index 3de331cdfa82..476e00129f69 100644 --- a/SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSA.cpp +++ b/SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSA.cpp @@ -29,13 +29,13 @@ CSourcePieceWise_TurbSA::CSourcePieceWise_TurbSA(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - + incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); rotating_frame = config->GetRotating_Frame(); transition = (config->GetKind_Trans_Model() == BC); - + /*--- Spalart-Allmaras closure constants ---*/ - + cv1_3 = pow(7.1, 3.0); k2 = pow(0.41, 2.0); cb1 = 0.1355; @@ -47,13 +47,13 @@ CSourcePieceWise_TurbSA::CSourcePieceWise_TurbSA(unsigned short val_nDim, unsign cb2 = 0.622; cb2_sigma = cb2/sigma; cw1 = cb1/k2+(1.0+cb2)/sigma; - + } CSourcePieceWise_TurbSA::~CSourcePieceWise_TurbSA(void) { } void CSourcePieceWise_TurbSA::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - + // AD::StartPreacc(); // AD::SetPreaccIn(V_i, nDim+6); // AD::SetPreaccIn(Vorticity_i, nDim); @@ -74,13 +74,13 @@ void CSourcePieceWise_TurbSA::ComputeResidual(su2double *val_residual, su2double Density_i = V_i[nDim+2]; Laminar_Viscosity_i = V_i[nDim+5]; } - + val_residual[0] = 0.0; Production = 0.0; Destruction = 0.0; CrossProduction = 0.0; val_Jacobian_i[0][0] = 0.0; - + gamma_BC = 0.0; vmag = 0.0; tu = config->GetTurbulenceIntensity_FreeStream(); @@ -92,19 +92,19 @@ void CSourcePieceWise_TurbSA::ComputeResidual(su2double *val_residual, su2double else if (nDim==3) { vmag = sqrt(V_i[1]*V_i[1]+V_i[2]*V_i[2]+V_i[3]*V_i[3]); } - + /*--- Evaluate Omega ---*/ - + Omega = sqrt(Vorticity_i[0]*Vorticity_i[0] + Vorticity_i[1]*Vorticity_i[1] + Vorticity_i[2]*Vorticity_i[2]); - + /*--- Rotational correction term ---*/ - + if (rotating_frame) { Omega += 2.0*min(0.0, StrainMag_i-Omega); } - + if (dist_i > 1e-10) { - + /*--- Production term ---*/ - + dist_i_2 = dist_i*dist_i; nu = Laminar_Viscosity_i/Density_i; Ji = TurbVar_i[0]/nu; @@ -115,17 +115,17 @@ void CSourcePieceWise_TurbSA::ComputeResidual(su2double *val_residual, su2double ft2 = ct3*exp(-ct4*Ji_2); S = Omega; inv_k2_d2 = 1.0/(k2*dist_i_2); - + Shat = S + TurbVar_i[0]*fv2*inv_k2_d2; Shat = max(Shat, 1.0e-10); inv_Shat = 1.0/Shat; // Original SA model // Production = cb1*(1.0-ft2)*Shat*TurbVar_i[0]*Volume; - + if (transition) { -// BC model constants +// BC model constants chi_1 = 0.002; chi_2 = 5.0; @@ -148,55 +148,55 @@ void CSourcePieceWise_TurbSA::ComputeResidual(su2double *val_residual, su2double else { Production = cb1*Shat*TurbVar_i[0]*Volume; } - + /*--- Destruction term ---*/ - + r = min(TurbVar_i[0]*inv_Shat*inv_k2_d2,10.0); g = r + cw2*(pow(r,6.0)-r); g_6 = pow(g,6.0); glim = pow((1.0+cw3_6)/(g_6+cw3_6),1.0/6.0); fw = g*glim; - + // Original SA model // Destruction = (cw1*fw-cb1*ft2/k2)*TurbVar_i[0]*TurbVar_i[0]/dist_i_2*Volume; - + Destruction = cw1*fw*TurbVar_i[0]*TurbVar_i[0]/dist_i_2*Volume; /*--- Diffusion term ---*/ - + norm2_Grad = 0.0; for (iDim = 0; iDim < nDim; iDim++) norm2_Grad += TurbVar_Grad_i[0][iDim]*TurbVar_Grad_i[0][iDim]; - + CrossProduction = cb2_sigma*norm2_Grad*Volume; - + val_residual[0] = Production - Destruction + CrossProduction; - + /*--- Implicit part, production term ---*/ - + dfv1 = 3.0*Ji_2*cv1_3/(nu*pow(Ji_3+cv1_3,2.)); dfv2 = -(1/nu-Ji_2*dfv1)/pow(1.+Ji*fv1,2.); if ( Shat <= 1.0e-10 ) dShat = 0.0; else dShat = (fv2+TurbVar_i[0]*dfv2)*inv_k2_d2; - + if (transition) { val_Jacobian_i[0][0] += gamma_BC*cb1*(TurbVar_i[0]*dShat+Shat)*Volume; } else { val_Jacobian_i[0][0] += cb1*(TurbVar_i[0]*dShat+Shat)*Volume; } - + /*--- Implicit part, destruction term ---*/ - + dr = (Shat-TurbVar_i[0]*dShat)*inv_Shat*inv_Shat*inv_k2_d2; if (r == 10.0) dr = 0.0; dg = dr*(1.+cw2*(6.0*pow(r,5.0)-1.0)); dfw = dg*glim*(1.-g_6/(g_6+cw3_6)); val_Jacobian_i[0][0] -= cw1*(dfw*TurbVar_i[0] + 2.0*fw)*TurbVar_i[0]/dist_i_2*Volume; - + } // AD::SetPreaccOut(val_residual[0]); // AD::EndPreacc(); - + } diff --git a/SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSA_COMP.cpp b/SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSA_COMP.cpp index 7ff78236672d..206121aa4f30 100644 --- a/SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSA_COMP.cpp +++ b/SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSA_COMP.cpp @@ -29,12 +29,12 @@ CSourcePieceWise_TurbSA_COMP::CSourcePieceWise_TurbSA_COMP(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - + incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); rotating_frame = config->GetRotating_Frame(); - + /*--- Spalart-Allmaras closure constants ---*/ - + cv1_3 = pow(7.1, 3.0); k2 = pow(0.41, 2.0); cb1 = 0.1355; @@ -47,13 +47,13 @@ CSourcePieceWise_TurbSA_COMP::CSourcePieceWise_TurbSA_COMP(unsigned short val_nD cb2_sigma = cb2/sigma; cw1 = cb1/k2+(1.0+cb2)/sigma; c5 = 3.5; - + } CSourcePieceWise_TurbSA_COMP::~CSourcePieceWise_TurbSA_COMP(void) { } void CSourcePieceWise_TurbSA_COMP::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - + // AD::StartPreacc(); // AD::SetPreaccIn(V_i, nDim+6); // AD::SetPreaccIn(Vorticity_i, nDim); @@ -61,7 +61,7 @@ void CSourcePieceWise_TurbSA_COMP::ComputeResidual(su2double *val_residual, su2d // AD::SetPreaccIn(TurbVar_i[0]); // AD::SetPreaccIn(TurbVar_Grad_i[0], nDim); // AD::SetPreaccIn(Volume); AD::SetPreaccIn(dist_i); - + if (incompressible) { Density_i = V_i[nDim+2]; Laminar_Viscosity_i = V_i[nDim+4]; @@ -70,25 +70,25 @@ void CSourcePieceWise_TurbSA_COMP::ComputeResidual(su2double *val_residual, su2d Density_i = V_i[nDim+2]; Laminar_Viscosity_i = V_i[nDim+5]; } - + val_residual[0] = 0.0; Production = 0.0; Destruction = 0.0; CrossProduction = 0.0; val_Jacobian_i[0][0] = 0.0; - + /*--- Evaluate Omega ---*/ - + Omega = sqrt(Vorticity_i[0]*Vorticity_i[0] + Vorticity_i[1]*Vorticity_i[1] + Vorticity_i[2]*Vorticity_i[2]); - + /*--- Rotational correction term ---*/ - + if (rotating_frame) { Omega += 2.0*min(0.0, StrainMag_i-Omega); } - + if (dist_i > 1e-10) { - + /*--- Production term ---*/ - + dist_i_2 = dist_i*dist_i; nu = Laminar_Viscosity_i/Density_i; Ji = TurbVar_i[0]/nu; @@ -99,35 +99,35 @@ void CSourcePieceWise_TurbSA_COMP::ComputeResidual(su2double *val_residual, su2d ft2 = ct3*exp(-ct4*Ji_2); S = Omega; inv_k2_d2 = 1.0/(k2*dist_i_2); - + Shat = S + TurbVar_i[0]*fv2*inv_k2_d2; Shat = max(Shat, 1.0e-10); inv_Shat = 1.0/Shat; - + /*--- Production term ---*/; - + Production = cb1*Shat*TurbVar_i[0]*Volume; - + /*--- Destruction term ---*/ - + r = min(TurbVar_i[0]*inv_Shat*inv_k2_d2,10.0); g = r + cw2*(pow(r,6.0)-r); - g_6 = pow(g,6.0); + g_6 = pow(g,6.0); glim = pow((1.0+cw3_6)/(g_6+cw3_6),1.0/6.0); fw = g*glim; - + Destruction = cw1*fw*TurbVar_i[0]*TurbVar_i[0]/dist_i_2*Volume; - + /*--- Diffusion term ---*/ - + norm2_Grad = 0.0; for (iDim = 0; iDim < nDim; iDim++) norm2_Grad += TurbVar_Grad_i[0][iDim]*TurbVar_Grad_i[0][iDim]; - + CrossProduction = cb2_sigma*norm2_Grad*Volume; - + val_residual[0] = Production - Destruction + CrossProduction; - + /*--- Compressibility Correction term ---*/ Pressure_i = V_i[nDim+1]; SoundSpeed_i = sqrt(Pressure_i*Gamma/Density_i); @@ -136,31 +136,31 @@ void CSourcePieceWise_TurbSA_COMP::ComputeResidual(su2double *val_residual, su2d for(jDim=0;jDimGetKind_Regime() == INCOMPRESSIBLE); rotating_frame = config->GetRotating_Frame(); - + /*--- Spalart-Allmaras closure constants ---*/ - + cv1_3 = pow(7.1, 3.0); k2 = pow(0.41, 2.0); cb1 = 0.1355; @@ -46,13 +46,13 @@ CSourcePieceWise_TurbSA_E::CSourcePieceWise_TurbSA_E(unsigned short val_nDim, un cb2 = 0.622; cb2_sigma = cb2/sigma; cw1 = cb1/k2+(1.0+cb2)/sigma; - + } CSourcePieceWise_TurbSA_E::~CSourcePieceWise_TurbSA_E(void) { } void CSourcePieceWise_TurbSA_E::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - + // AD::StartPreacc(); // AD::SetPreaccIn(V_i, nDim+6); // AD::SetPreaccIn(Vorticity_i, nDim); @@ -60,7 +60,7 @@ void CSourcePieceWise_TurbSA_E::ComputeResidual(su2double *val_residual, su2doub // AD::SetPreaccIn(TurbVar_i[0]); // AD::SetPreaccIn(TurbVar_Grad_i[0], nDim); // AD::SetPreaccIn(Volume); AD::SetPreaccIn(dist_i); - + if (incompressible) { Density_i = V_i[nDim+2]; Laminar_Viscosity_i = V_i[nDim+4]; @@ -69,40 +69,40 @@ void CSourcePieceWise_TurbSA_E::ComputeResidual(su2double *val_residual, su2doub Density_i = V_i[nDim+2]; Laminar_Viscosity_i = V_i[nDim+5]; } - + val_residual[0] = 0.0; Production = 0.0; Destruction = 0.0; CrossProduction = 0.0; val_Jacobian_i[0][0] = 0.0; - - + + /* From NASA Turbulence model site. http://turbmodels.larc.nasa.gov/spalart.html This form was developed primarily to improve the near-wall numerical behavior of the model (i.e., the goal was to improve the convergence behavior). The reference is: Edwards, J. R. and Chandra, S. "Comparison of Eddy Viscosity-Transport Turbulence Models for Three-Dimensional, Shock-Separated Flowfields," AIAA Journal, Vol. 34, No. 4, 1996, pp. 756-763. In this modificaton Omega is replaced by Strain Rate */ - + /*--- Evaluate Omega, here Omega is the Strain Rate ---*/ - + Sbar = 0.0; for(iDim=0;iDim 1e-10) { - + /*--- Production term ---*/ - + dist_i_2 = dist_i*dist_i; nu = Laminar_Viscosity_i/Density_i; Ji = TurbVar_i[0]/nu; @@ -113,59 +113,59 @@ void CSourcePieceWise_TurbSA_E::ComputeResidual(su2double *val_residual, su2doub ft2 = ct3*exp(-ct4*Ji_2); S = Omega; inv_k2_d2 = 1.0/(k2*dist_i_2); - + //Shat = S + TurbVar_i[0]*fv2*inv_k2_d2; Shat = max(S*((1.0/max(Ji,1.0e-16))+fv1),1.0e-16); - + Shat = max(Shat, 1.0e-10); inv_Shat = 1.0/Shat; - + /*--- Production term ---*/; - + Production = cb1*Shat*TurbVar_i[0]*Volume; - + /*--- Destruction term ---*/ - + r = min(TurbVar_i[0]*inv_Shat*inv_k2_d2,10.0); r=tanh(r)/tanh(1.0); - + g = r + cw2*(pow(r,6.0)-r); - g_6 = pow(g,6.0); + g_6 = pow(g,6.0); glim = pow((1.0+cw3_6)/(g_6+cw3_6),1.0/6.0); fw = g*glim; - + Destruction = cw1*fw*TurbVar_i[0]*TurbVar_i[0]/dist_i_2*Volume; - + /*--- Diffusion term ---*/ - + norm2_Grad = 0.0; for (iDim = 0; iDim < nDim; iDim++) norm2_Grad += TurbVar_Grad_i[0][iDim]*TurbVar_Grad_i[0][iDim]; - + CrossProduction = cb2_sigma*norm2_Grad*Volume; - + val_residual[0] = Production - Destruction + CrossProduction; - + /*--- Implicit part, production term ---*/ - + dfv1 = 3.0*Ji_2*cv1_3/(nu*pow(Ji_3+cv1_3,2.)); dfv2 = -(1/nu-Ji_2*dfv1)/pow(1.+Ji*fv1,2.); - + if ( Shat <= 1.0e-10 ) dShat = 0.0; else dShat = -S*pow(Ji,-2.0)/nu + S*dfv1; val_Jacobian_i[0][0] += cb1*(TurbVar_i[0]*dShat+Shat)*Volume; - + /*--- Implicit part, destruction term ---*/ - + dr = (Shat-TurbVar_i[0]*dShat)*inv_Shat*inv_Shat*inv_k2_d2; dr=(1-pow(tanh(r),2.0))*(dr)/tanh(1.0); dg = dr*(1.+cw2*(6.0*pow(r,5.0)-1.0)); dfw = dg*glim*(1.-g_6/(g_6+cw3_6)); - val_Jacobian_i[0][0] -= cw1*(dfw*TurbVar_i[0] + 2.0*fw)*TurbVar_i[0]/dist_i_2*Volume; - + val_Jacobian_i[0][0] -= cw1*(dfw*TurbVar_i[0] + 2.0*fw)*TurbVar_i[0]/dist_i_2*Volume; + } - + // AD::SetPreaccOut(val_residual[0]); // AD::EndPreacc(); - + } diff --git a/SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSA_E_COMP.cpp b/SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSA_E_COMP.cpp index 056a76500a3b..b217afde8140 100644 --- a/SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSA_E_COMP.cpp +++ b/SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSA_E_COMP.cpp @@ -29,12 +29,12 @@ CSourcePieceWise_TurbSA_E_COMP::CSourcePieceWise_TurbSA_E_COMP(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - + incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); rotating_frame = config->GetRotating_Frame(); - + /*--- Spalart-Allmaras closure constants ---*/ - + cv1_3 = pow(7.1, 3.0); k2 = pow(0.41, 2.0); cb1 = 0.1355; @@ -46,13 +46,13 @@ CSourcePieceWise_TurbSA_E_COMP::CSourcePieceWise_TurbSA_E_COMP(unsigned short va cb2 = 0.622; cb2_sigma = cb2/sigma; cw1 = cb1/k2+(1.0+cb2)/sigma; - + } CSourcePieceWise_TurbSA_E_COMP::~CSourcePieceWise_TurbSA_E_COMP(void) { } void CSourcePieceWise_TurbSA_E_COMP::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - + // AD::StartPreacc(); // AD::SetPreaccIn(V_i, nDim+6); // AD::SetPreaccIn(Vorticity_i, nDim); @@ -60,7 +60,7 @@ void CSourcePieceWise_TurbSA_E_COMP::ComputeResidual(su2double *val_residual, su // AD::SetPreaccIn(TurbVar_i[0]); // AD::SetPreaccIn(TurbVar_Grad_i[0], nDim); // AD::SetPreaccIn(Volume); AD::SetPreaccIn(dist_i); - + if (incompressible) { Density_i = V_i[nDim+2]; Laminar_Viscosity_i = V_i[nDim+4]; @@ -69,39 +69,39 @@ void CSourcePieceWise_TurbSA_E_COMP::ComputeResidual(su2double *val_residual, su Density_i = V_i[nDim+2]; Laminar_Viscosity_i = V_i[nDim+5]; } - + val_residual[0] = 0.0; Production = 0.0; Destruction = 0.0; CrossProduction = 0.0; val_Jacobian_i[0][0] = 0.0; - + /* From NASA Turbulence model site. http://turbmodels.larc.nasa.gov/spalart.html This form was developed primarily to improve the near-wall numerical behavior of the model (i.e., the goal was to improve the convergence behavior). The reference is: Edwards, J. R. and Chandra, S. "Comparison of Eddy Viscosity-Transport Turbulence Models for Three-Dimensional, Shock-Separated Flowfields," AIAA Journal, Vol. 34, No. 4, 1996, pp. 756-763. In this modificaton Omega is replaced by Strain Rate */ - + /*--- Evaluate Omega, here Omega is the Strain Rate ---*/ - + Sbar = 0.0; for(iDim=0;iDim 1e-10) { - + /*--- Production term ---*/ - + dist_i_2 = dist_i*dist_i; nu = Laminar_Viscosity_i/Density_i; Ji = TurbVar_i[0]/nu; @@ -112,38 +112,38 @@ void CSourcePieceWise_TurbSA_E_COMP::ComputeResidual(su2double *val_residual, su ft2 = ct3*exp(-ct4*Ji_2); S = Omega; inv_k2_d2 = 1.0/(k2*dist_i_2); - + Shat = max(S*((1.0/max(Ji,1.0e-16))+fv1),1.0e-16); - + Shat = max(Shat, 1.0e-10); inv_Shat = 1.0/Shat; - + /*--- Production term ---*/; - + Production = cb1*Shat*TurbVar_i[0]*Volume; - + /*--- Destruction term ---*/ - + r = min(TurbVar_i[0]*inv_Shat*inv_k2_d2,10.0); r=tanh(r)/tanh(1.0); - + g = r + cw2*(pow(r,6.0)-r); - g_6 = pow(g,6.0); + g_6 = pow(g,6.0); glim = pow((1.0+cw3_6)/(g_6+cw3_6),1.0/6.0); fw = g*glim; - + Destruction = cw1*fw*TurbVar_i[0]*TurbVar_i[0]/dist_i_2*Volume; - + /*--- Diffusion term ---*/ - + norm2_Grad = 0.0; for (iDim = 0; iDim < nDim; iDim++) norm2_Grad += TurbVar_Grad_i[0][iDim]*TurbVar_Grad_i[0][iDim]; - + CrossProduction = cb2_sigma*norm2_Grad*Volume; - + val_residual[0] = Production - Destruction + CrossProduction; - + /*--- Compressibility Correction term ---*/ Pressure_i = V_i[nDim+1]; SoundSpeed_i = sqrt(Pressure_i*Gamma/Density_i); @@ -152,32 +152,32 @@ void CSourcePieceWise_TurbSA_E_COMP::ComputeResidual(su2double *val_residual, su for(jDim=0;jDimGetKind_Regime() == INCOMPRESSIBLE); rotating_frame = config->GetRotating_Frame(); - + /*--- Negative Spalart-Allmaras closure constants ---*/ - + cv1_3 = pow(7.1, 3.0); k2 = pow(0.41, 2.0); cb1 = 0.1355; @@ -46,15 +46,15 @@ CSourcePieceWise_TurbSA_Neg::CSourcePieceWise_TurbSA_Neg(unsigned short val_nDim cb2 = 0.622; cb2_sigma = cb2/sigma; cw1 = cb1/k2+(1.0+cb2)/sigma; - + } CSourcePieceWise_TurbSA_Neg::~CSourcePieceWise_TurbSA_Neg(void) { - + } void CSourcePieceWise_TurbSA_Neg::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - + // AD::StartPreacc(); // AD::SetPreaccIn(V_i, nDim+6); // AD::SetPreaccIn(Vorticity_i, nDim); @@ -71,27 +71,27 @@ void CSourcePieceWise_TurbSA_Neg::ComputeResidual(su2double *val_residual, su2do Density_i = V_i[nDim+2]; Laminar_Viscosity_i = V_i[nDim+5]; } - + val_residual[0] = 0.0; Production = 0.0; Destruction = 0.0; CrossProduction = 0.0; val_Jacobian_i[0][0] = 0.0; - + /*--- Evaluate Omega ---*/ - + Omega = sqrt(Vorticity_i[0]*Vorticity_i[0] + Vorticity_i[1]*Vorticity_i[1] + Vorticity_i[2]*Vorticity_i[2]); /*--- Rotational correction term ---*/ - + if (rotating_frame) { Omega += 2.0*min(0.0, StrainMag_i-Omega); } - + if (dist_i > 1e-10) { - + if (TurbVar_i[0] > 0.0) { - + /*--- Production term ---*/ - + dist_i_2 = dist_i*dist_i; nu = Laminar_Viscosity_i/Density_i; Ji = TurbVar_i[0]/nu; @@ -102,90 +102,90 @@ void CSourcePieceWise_TurbSA_Neg::ComputeResidual(su2double *val_residual, su2do ft2 = ct3*exp(-ct4*Ji_2); S = Omega; inv_k2_d2 = 1.0/(k2*dist_i_2); - + Shat = S + TurbVar_i[0]*fv2*inv_k2_d2; Shat = max(Shat, 1.0e-10); inv_Shat = 1.0/Shat; - + /*--- Production term ---*/; - + // Original SA model // Production = cb1*(1.0-ft2)*Shat*TurbVar_i[0]*Volume; - + Production = cb1*Shat*TurbVar_i[0]*Volume; - + /*--- Destruction term ---*/ - + r = min(TurbVar_i[0]*inv_Shat*inv_k2_d2,10.0); g = r + cw2*(pow(r,6.0)-r); g_6 = pow(g,6.0); glim = pow((1.0+cw3_6)/(g_6+cw3_6),1.0/6.0); fw = g*glim; - + Destruction = cw1*fw*TurbVar_i[0]*TurbVar_i[0]/dist_i_2*Volume; - + /*--- Diffusion term ---*/ - + norm2_Grad = 0.0; for (iDim = 0; iDim < nDim; iDim++) norm2_Grad += TurbVar_Grad_i[0][iDim]*TurbVar_Grad_i[0][iDim]; - + CrossProduction = cb2_sigma*norm2_Grad*Volume; - + val_residual[0] = Production - Destruction + CrossProduction; - + /*--- Implicit part, production term ---*/ - + dfv1 = 3.0*Ji_2*cv1_3/(nu*pow(Ji_3+cv1_3,2.)); dfv2 = -(1/nu-Ji_2*dfv1)/pow(1.+Ji*fv1,2.); if ( Shat <= 1.0e-10 ) dShat = 0.0; else dShat = (fv2+TurbVar_i[0]*dfv2)*inv_k2_d2; val_Jacobian_i[0][0] += cb1*(TurbVar_i[0]*dShat+Shat)*Volume; - + /*--- Implicit part, destruction term ---*/ - + dr = (Shat-TurbVar_i[0]*dShat)*inv_Shat*inv_Shat*inv_k2_d2; if (r == 10.0) dr = 0.0; dg = dr*(1.+cw2*(6.0*pow(r,5.0)-1.0)); dfw = dg*glim*(1.-g_6/(g_6+cw3_6)); val_Jacobian_i[0][0] -= cw1*(dfw*TurbVar_i[0] + 2.0*fw)*TurbVar_i[0]/dist_i_2*Volume; - + } - + else { - + /*--- Production term ---*/ - + dist_i_2 = dist_i*dist_i; - + /*--- Production term ---*/; - + Production = cb1*(1.0-ct3)*Omega*TurbVar_i[0]*Volume; - + /*--- Destruction term ---*/ - + Destruction = cw1*TurbVar_i[0]*TurbVar_i[0]/dist_i_2*Volume; - + /*--- Diffusion term ---*/ - + norm2_Grad = 0.0; for (iDim = 0; iDim < nDim; iDim++) norm2_Grad += TurbVar_Grad_i[0][iDim]*TurbVar_Grad_i[0][iDim]; - + CrossProduction = cb2_sigma*norm2_Grad*Volume; - + val_residual[0] = Production + Destruction + CrossProduction; - + /*--- Implicit part, production term ---*/ - + val_Jacobian_i[0][0] += cb1*(1.0-ct3)*Omega*Volume; - + /*--- Implicit part, destruction term ---*/ - + val_Jacobian_i[0][0] += 2.0*cw1*TurbVar_i[0]/dist_i_2*Volume; - + } - + } // AD::SetPreaccOut(val_residual, nVar); diff --git a/SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSST.cpp b/SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSST.cpp index 9a294e5e890a..ab83d43330ed 100644 --- a/SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSST.cpp +++ b/SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSST.cpp @@ -30,10 +30,10 @@ CSourcePieceWise_TurbSST::CSourcePieceWise_TurbSST(unsigned short val_nDim, unsigned short val_nVar, const su2double *constants, su2double val_kine_Inf, su2double val_omega_Inf, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - + incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); sustaining_terms = (config->GetKind_Turb_Model() == SST_SUST); - + /*--- Closure constants ---*/ beta_star = constants[6]; sigma_omega_1 = constants[2]; @@ -52,7 +52,7 @@ CSourcePieceWise_TurbSST::CSourcePieceWise_TurbSST(unsigned short val_nDim, unsi CSourcePieceWise_TurbSST::~CSourcePieceWise_TurbSST(void) { } void CSourcePieceWise_TurbSST::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - + AD::StartPreacc(); AD::SetPreaccIn(StrainMag_i); AD::SetPreaccIn(TurbVar_i, nVar); @@ -64,7 +64,7 @@ void CSourcePieceWise_TurbSST::ComputeResidual(su2double *val_residual, su2doubl unsigned short iDim; su2double alfa_blended, beta_blended; su2double diverg, pk, pw, zeta; - + if (incompressible) { AD::SetPreaccIn(V_i, nDim+6); @@ -79,16 +79,16 @@ void CSourcePieceWise_TurbSST::ComputeResidual(su2double *val_residual, su2doubl Laminar_Viscosity_i = V_i[nDim+5]; Eddy_Viscosity_i = V_i[nDim+6]; } - + val_residual[0] = 0.0; val_residual[1] = 0.0; val_Jacobian_i[0][0] = 0.0; val_Jacobian_i[0][1] = 0.0; val_Jacobian_i[1][0] = 0.0; val_Jacobian_i[1][1] = 0.0; - + /*--- Computation of blended constants for the source terms---*/ - + alfa_blended = F1_i*alfa_1 + (1.0 - F1_i)*alfa_2; beta_blended = F1_i*beta_1 + (1.0 - F1_i)*beta_2; - + if (dist_i > 1e-10) { /*--- Production ---*/ @@ -96,7 +96,7 @@ void CSourcePieceWise_TurbSST::ComputeResidual(su2double *val_residual, su2doubl diverg = 0.0; for (iDim = 0; iDim < nDim; iDim++) diverg += PrimVar_Grad_i[iDim+1][iDim]; - + /* if using UQ methodolgy, calculate production using perturbed Reynolds stress matrix */ if (using_uq){ @@ -162,7 +162,7 @@ void CSourcePieceWise_TurbSST::ComputeResidual(su2double *val_residual, su2doubl val_Jacobian_i[1][0] = 0.0; val_Jacobian_i[1][1] = -2.0*beta_blended*TurbVar_i[1]*Volume; } - + AD::SetPreaccOut(val_residual, nVar); AD::EndPreacc(); diff --git a/SU2_CFD/src/numerics/turbulent/CUpwSca_TurbSA.cpp b/SU2_CFD/src/numerics/turbulent/CUpwSca_TurbSA.cpp index 06e7b14e5103..1df3b98b98de 100644 --- a/SU2_CFD/src/numerics/turbulent/CUpwSca_TurbSA.cpp +++ b/SU2_CFD/src/numerics/turbulent/CUpwSca_TurbSA.cpp @@ -41,9 +41,9 @@ void CUpwSca_TurbSA::ExtraADPreaccIn() { } void CUpwSca_TurbSA::FinishResidualCalc(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - + val_residual[0] = a0*TurbVar_i[0]+a1*TurbVar_j[0]; - + if (implicit) { val_Jacobian_i[0][0] = a0; val_Jacobian_j[0][0] = a1; diff --git a/SU2_CFD/src/numerics/turbulent/CUpwSca_TurbSST.cpp b/SU2_CFD/src/numerics/turbulent/CUpwSca_TurbSST.cpp index 6ce09ba78530..2efb07416803 100644 --- a/SU2_CFD/src/numerics/turbulent/CUpwSca_TurbSST.cpp +++ b/SU2_CFD/src/numerics/turbulent/CUpwSca_TurbSST.cpp @@ -40,21 +40,21 @@ void CUpwSca_TurbSST::ExtraADPreaccIn() { AD::SetPreaccIn(V_i, nDim+3); AD::SetPreaccIn(V_j, nDim+3); - + } void CUpwSca_TurbSST::FinishResidualCalc(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - + val_residual[0] = a0*Density_i*TurbVar_i[0]+a1*Density_j*TurbVar_j[0]; val_residual[1] = a0*Density_i*TurbVar_i[1]+a1*Density_j*TurbVar_j[1]; - + if (implicit) { val_Jacobian_i[0][0] = a0; val_Jacobian_i[0][1] = 0.0; val_Jacobian_i[1][0] = 0.0; val_Jacobian_i[1][1] = a0; - + val_Jacobian_j[0][0] = a1; val_Jacobian_j[0][1] = 0.0; val_Jacobian_j[1][0] = 0.0; val_Jacobian_j[1][1] = a1; } From 0cdac84031154568ca65a8b37851321e5af32550 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Sun, 26 Jan 2020 12:28:36 +0000 Subject: [PATCH 009/118] update meson --- SU2_CFD/src/meson.build | 91 +++++++++++++++++++++++++++++++++++------ 1 file changed, 79 insertions(+), 12 deletions(-) diff --git a/SU2_CFD/src/meson.build b/SU2_CFD/src/meson.build index 9b4a97977684..8056f6799a32 100644 --- a/SU2_CFD/src/meson.build +++ b/SU2_CFD/src/meson.build @@ -1,23 +1,14 @@ su2_cfd_src = files(['integration_structure.cpp', - 'numerics_adjoint_mean.cpp', 'transport_model.cpp', - 'numerics_adjoint_turbulent.cpp', 'fluid_model_pvdw.cpp', 'integration_time.cpp', 'fluid_model_pig.cpp', 'iteration_structure.cpp', 'fluid_model_inc.cpp', - 'numerics_direct_turbulent.cpp', - 'numerics_direct_transition.cpp', 'definition_structure.cpp', - 'numerics_direct_mean_inc.cpp', 'fluid_model.cpp', - 'numerics_direct_mean.cpp', - 'numerics_direct_heat.cpp', 'fluid_model_ppr.cpp', 'python_wrapper_structure.cpp', - 'numerics_structure.cpp', - 'numerics_template.cpp', 'CMarkerProfileReaderFVM.cpp', 'SU2_CFD.cpp']) @@ -102,14 +93,90 @@ su2_cfd_src += files(['solvers/CAdjEulerSolver.cpp', 'solvers/CTurbSASolver.cpp', 'solvers/CTurbSSTSolver.cpp']) -su2_cfd_src += files(['numerics/elasticity/CFEAElasticity.cpp', - 'numerics/elasticity/CFEALinearElasticity.cpp', +su2_cfd_src += files(['numerics/CNumerics.cpp', + 'numerics/template/CSource_Template.cpp', + 'numerics/template/CConvective_Template.cpp', + 'numerics/template/CViscous_Template.cpp', + 'numerics/transition/CAvgGradCorrected_TransLM.cpp', + 'numerics/transition/CUpwLin_TransLM.cpp', + 'numerics/transition/CAvgGrad_TransLM.cpp', + 'numerics/transition/CUpwSca_TransLM.cpp', + 'numerics/transition/CSourcePieceWise_TransLM.cpp', + 'numerics/heat/CCentSca_Heat.cpp', + 'numerics/heat/CUpwSca_Heat.cpp', + 'numerics/heat/CAvgGradCorrected_Heat.cpp', + 'numerics/heat/CAvgGrad_Heat.cpp', + 'numerics/flow/diffusion/CAvgGradInc_Flow.cpp', + 'numerics/flow/diffusion/CAvgGrad_Base.cpp', + 'numerics/flow/diffusion/CAvgGrad_Flow.cpp', + 'numerics/flow/diffusion/CGeneralAvgGrad_Flow.cpp', + 'numerics/flow/convection_upwind/CUpwCUSP_Flow.cpp', + 'numerics/flow/convection_upwind/CUpwMSW_Flow.cpp', + 'numerics/flow/convection_upwind/CUpwAUSMPLUS_SLAU_Base_Flow.cpp', + 'numerics/flow/convection_upwind/CUpwTurkel_Flow.cpp', + 'numerics/flow/convection_upwind/CUpwL2Roe_Flow.cpp', + 'numerics/flow/convection_upwind/CUpwFDSInc_Flow.cpp', + 'numerics/flow/convection_upwind/CUpwHLLC_Flow.cpp', + 'numerics/flow/convection_upwind/CUpwSLAU_Flow.cpp', + 'numerics/flow/convection_upwind/CUpwGeneralRoe_Flow.cpp', + 'numerics/flow/convection_upwind/CUpwAUSMPLUSUP_Flow.cpp', + 'numerics/flow/convection_upwind/CUpwGeneralHLLC_Flow.cpp', + 'numerics/flow/convection_upwind/CUpwRoe_Flow.cpp', + 'numerics/flow/convection_upwind/CUpwAUSMPLUSUP2_Flow.cpp', + 'numerics/flow/convection_upwind/CUpwRoeBase_Flow.cpp', + 'numerics/flow/convection_upwind/CUpwAUSM_Flow.cpp', + 'numerics/flow/convection_upwind/CUpwLMRoe_Flow.cpp', + 'numerics/flow/sources/CSourceWindGust.cpp', + 'numerics/flow/sources/CSourceRotatingFrame_Flow.cpp', + 'numerics/flow/sources/CSourceIncAxisymmetric_Flow.cpp', + 'numerics/flow/sources/CSourceIncBodyForce.cpp', + 'numerics/flow/sources/CSourceIncRotatingFrame_Flow.cpp', + 'numerics/flow/sources/CSourceGravity.cpp', + 'numerics/flow/sources/CSourceBodyForce.cpp', + 'numerics/flow/sources/CSourceAxisymmetric_Flow.cpp', + 'numerics/flow/sources/CSourceBoussinesq.cpp', + 'numerics/flow/convection_centered/CCentBase_Flow.cpp', + 'numerics/flow/convection_centered/CCentJSTInc_Flow.cpp', + 'numerics/flow/convection_centered/CCentJST_KE_Flow.cpp', + 'numerics/flow/convection_centered/CCentJST_Flow.cpp', + 'numerics/flow/convection_centered/CCentLaxInc_Flow.cpp', + 'numerics/flow/convection_centered/CCentLax_Flow.cpp', 'numerics/elasticity/CFEAMeshElasticity.cpp', + 'numerics/elasticity/CFEM_DielectricElastomer.cpp', + 'numerics/elasticity/CFEALinearElasticity.cpp', + 'numerics/elasticity/CFEAElasticity.cpp', 'numerics/elasticity/CFEANonlinearElasticity.cpp', 'numerics/elasticity/CFEM_NeoHookean_Comp.cpp', 'numerics/elasticity/CFEM_Knowles_NearInc.cpp', 'numerics/elasticity/CFEM_IdealDE.cpp', - 'numerics/elasticity/CFEM_DielectricElastomer.cpp']) + 'numerics/continuous_adjoint/CAvgGradCorrected_AdjFlow.cpp', + 'numerics/continuous_adjoint/CSourceRotatingFrame_AdjFlow.cpp', + 'numerics/continuous_adjoint/CUpwSca_AdjTurb.cpp', + 'numerics/continuous_adjoint/CAvgGradCorrected_AdjTurb.cpp', + 'numerics/continuous_adjoint/CSourceConservative_AdjFlow.cpp', + 'numerics/continuous_adjoint/CSourceAxisymmetric_AdjFlow.cpp', + 'numerics/continuous_adjoint/CSourceConservative_AdjTurb.cpp', + 'numerics/continuous_adjoint/CAvgGrad_AdjFlow.cpp', + 'numerics/continuous_adjoint/CUpwRoe_AdjFlow.cpp', + 'numerics/continuous_adjoint/CSourcePieceWise_AdjTurb.cpp', + 'numerics/continuous_adjoint/CCentLax_AdjFlow.cpp', + 'numerics/continuous_adjoint/CSourceViscous_AdjFlow.cpp', + 'numerics/continuous_adjoint/CAvgGrad_AdjTurb.cpp', + 'numerics/continuous_adjoint/CUpwLin_AdjTurb.cpp', + 'numerics/continuous_adjoint/CCentJST_AdjFlow.cpp', + 'numerics/turbulent/CUpwSca_TurbSST.cpp', + 'numerics/turbulent/CSourcePieceWise_TurbSA_E.cpp', + 'numerics/turbulent/CSourcePieceWise_TurbSA.cpp', + 'numerics/turbulent/CSourcePieceWise_TurbSA_Neg.cpp', + 'numerics/turbulent/CAvgGrad_TurbSA.cpp', + 'numerics/turbulent/CSourcePieceWise_TurbSA_E_COMP.cpp', + 'numerics/turbulent/CUpwScalar.cpp', + 'numerics/turbulent/CAvgGrad_TurbSA_Neg.cpp', + 'numerics/turbulent/CSourcePieceWise_TurbSST.cpp', + 'numerics/turbulent/CSourcePieceWise_TurbSA_COMP.cpp', + 'numerics/turbulent/CUpwSca_TurbSA.cpp', + 'numerics/turbulent/CAvgGrad_Scalar.cpp', + 'numerics/turbulent/CAvgGrad_TurbSST.cpp']) su2_cfd_src += files(['interfaces/CInterface.cpp', 'interfaces/cfd/CConservativeVarsInterface.cpp', From 64010eb88c7a71fc4802b0b03539a5b5116b704e Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Sun, 26 Jan 2020 16:38:11 +0000 Subject: [PATCH 010/118] removed unused functions / variables --- SU2_CFD/include/numerics/CNumerics.hpp | 428 ++---------------- SU2_CFD/include/solvers/CSolver.hpp | 20 +- SU2_CFD/src/numerics/CNumerics.cpp | 102 ++--- .../CAvgGradCorrected_AdjFlow.cpp | 2 +- .../CUpwGeneralHLLC_Flow.cpp | 315 ------------- .../transition/CSourcePieceWise_TransLM.cpp | 3 +- 6 files changed, 83 insertions(+), 787 deletions(-) diff --git a/SU2_CFD/include/numerics/CNumerics.hpp b/SU2_CFD/include/numerics/CNumerics.hpp index 0d948617dcfd..95649302c117 100644 --- a/SU2_CFD/include/numerics/CNumerics.hpp +++ b/SU2_CFD/include/numerics/CNumerics.hpp @@ -55,16 +55,11 @@ class CNumerics { su2double Minf; /*!< \brief Free stream Mach number . */ su2double Gas_Constant; /*!< \brief Gas constant. */ su2double *Vector; /*!< \brief Auxiliary vector. */ - su2double *Enthalpy_formation; /*!< \brief Enthalpy of formation. */ su2double Prandtl_Lam; /*!< \brief Laminar Prandtl's number. */ su2double Prandtl_Turb; /*!< \brief Turbulent Prandtl's number. */ - -public: - su2double **Flux_Tensor, /*!< \brief Flux tensor (used for viscous and inviscid purposes. */ *Proj_Flux_Tensor; /*!< \brief Flux tensor projected in a direction. */ - su2double **tau, /*!< \brief Viscous stress tensor. */ **delta, /*!< \brief Identity matrix. */ @@ -80,14 +75,11 @@ class CNumerics { su2double Thermal_Conductivity_i, /*!< \brief Thermal conductivity at point i. */ Thermal_Conductivity_j, /*!< \brief Thermal conductivity at point j. */ - Thermal_Conductivity_ve_i, /*!< \brief Thermal conductivity at point i. */ - Thermal_Conductivity_ve_j, /*!< \brief Thermal conductivity at point j. */ Thermal_Diffusivity_i, /*!< \brief Thermal diffusivity at point i. */ Thermal_Diffusivity_j; /*!< \brief Thermal diffusivity at point j. */ su2double Cp_i, /*!< \brief Cp at point i. */ Cp_j; /*!< \brief Cp at point j. */ - su2double *Theta_v; /*!< \brief Characteristic vibrational temperature */ su2double Eddy_Viscosity_i, /*!< \brief Eddy viscosity at point i. */ Eddy_Viscosity_j; /*!< \brief Eddy viscosity at point j. */ @@ -128,12 +120,6 @@ class CNumerics { Temp_i, /*!< \brief Temperature at point i. */ Temp_j; /*!< \brief Temperature at point j. */ su2double - *Temp_tr_i, /*!< \brief Temperature transl-rot at point i. */ - *Temp_tr_j; /*!< \brief Temperature transl-rot at point j. */ - su2double - *Temp_vib_i, /*!< \brief Temperature vibrational at point i. */ - *Temp_vib_j; /*!< \brief Temperature vibrational at point j. */ - su2double *Und_Lapl_i, /*!< \brief Undivided laplacians at point i. */ *Und_Lapl_j; /*!< \brief Undivided laplacians at point j. */ su2double @@ -145,14 +131,8 @@ class CNumerics { su2double *U_i, /*!< \brief Vector of conservative variables at point i. */ *U_id, /*!< \brief Vector of derivative of conservative variables at point i. */ - *UZeroOrder_i, /*!< \brief Vector of conservative variables at point i without reconstruction. */ *U_j, /*!< \brief Vector of conservative variables at point j. */ - *UZeroOrder_j, /*!< \brief Vector of conservative variables at point j without reconstruction. */ - *U_jd, /*!< \brief Vector of derivative of conservative variables at point j. */ - *U_0, /*!< \brief Vector of conservative variables at node 0. */ - *U_1, /*!< \brief Vector of conservative variables at node 1. */ - *U_2, /*!< \brief Vector of conservative variables at node 2. */ - *U_3; /*!< \brief Vector of conservative variables at node 3. */ + *U_jd; /*!< \brief Vector of derivative of conservative variables at point j. */ su2double *V_i, /*!< \brief Vector of primitive variables at point i. */ *V_j; /*!< \brief Vector of primitive variables at point j. */ @@ -179,10 +159,6 @@ class CNumerics { su2double **ConsVar_Grad_i, /*!< \brief Gradient of conservative variables at point i. */ **ConsVar_Grad_j, /*!< \brief Gradient of conservative variables at point j. */ - **ConsVar_Grad_0, /*!< \brief Gradient of conservative variables at point 0. */ - **ConsVar_Grad_1, /*!< \brief Gradient of conservative variables at point 1. */ - **ConsVar_Grad_2, /*!< \brief Gradient of conservative variables at point 2. */ - **ConsVar_Grad_3, /*!< \brief Gradient of conservative variables at point 3. */ **ConsVar_Grad; /*!< \brief Gradient of conservative variables which is a scalar. */ su2double **PrimVar_Grad_i, /*!< \brief Gradient of primitive variables at point i. */ @@ -204,30 +180,18 @@ class CNumerics { *AuxVar_Grad_j; /*!< \brief Gradient of an auxiliary variable at point i. */ su2double *Coord_i, /*!< \brief Cartesians coordinates of point i. */ - *Coord_j, /*!< \brief Cartesians coordinates of point j. */ - *Coord_0, /*!< \brief Cartesians coordinates of point 0 (Galerkin method, triangle). */ - *Coord_1, /*!< \brief Cartesians coordinates of point 1 (Galerkin method, tetrahedra). */ - *Coord_2, /*!< \brief Cartesians coordinates of point 2 (Galerkin method, triangle). */ - *Coord_3; /*!< \brief Cartesians coordinates of point 3 (Galerkin method, tetrahedra). */ + *Coord_j; /*!< \brief Cartesians coordinates of point j. */ unsigned short Neighbor_i, /*!< \brief Number of neighbors of the point i. */ Neighbor_j; /*!< \brief Number of neighbors of the point j. */ su2double - *Normal, /*!< \brief Normal vector, it norm is the area of the face. */ + *Normal, /*!< \brief Normal vector, its norm is the area of the face. */ *UnitNormal, /*!< \brief Unitary normal vector. */ - *UnitNormald; /*!< \brief derivatve of unitary normal vector. */ + *UnitNormald; /*!< \brief Derivative of unitary normal vector. */ su2double TimeStep, /*!< \brief Time step useful in dual time method. */ Area, /*!< \brief Area of the face i-j. */ Volume; /*!< \brief Volume of the control volume around point i. */ - su2double - Volume_n, /*!< \brief Volume of the control volume at time n. */ - Volume_nM1, /*!< \brief Volume of the control volume at time n-1. */ - Volume_nP1; /*!< \brief Volume of the control volume at time n+1. */ - su2double - *U_n, /*!< \brief Vector of conservative variables at time n. */ - *U_nM1, /*!< \brief Vector of conservative variables at time n-1. */ - *U_nP1; /*!< \brief Vector of conservative variables at time n+1. */ su2double vel2_inf; /*!< \brief value of the square of freestream speed. */ su2double *WindGust_i, /*!< \brief Wind gust at point i. */ @@ -255,6 +219,8 @@ class CNumerics { su2double **A_ij, **newA_ij, **Eig_Vec, **New_Eig_Vec, **Corners; su2double *Eig_Val, *Barycentric_Coord, *New_Coord; +public: + /*! * \brief Constructor of the class. */ @@ -276,7 +242,7 @@ class CNumerics { /*! * \brief Compute the determinant of a 3 by 3 matrix. * \param[in] val_matrix 3 by 3 matrix. - * \result Determinant of the matrix + * \return Determinant of the matrix */ inline static su2double Determinant_3x3(su2double A00, su2double A01, su2double A02, su2double A10, su2double A11, su2double A12, @@ -284,22 +250,6 @@ class CNumerics { return A00*(A11*A22-A12*A21) - A01*(A10*A22-A12*A20) + A02*(A10*A21-A11*A20); } - /*! - * \brief Set the solution at different times. - * \param[in] val_u_nM1 Conservative solution at time n-1. - * \param[in] val_u_n Conservative solution at time n. - * \param[in] val_u_nP1 Conservative solution at time n+1. - */ - void SetPastSol(su2double *val_u_nM1, su2double *val_u_n, su2double *val_u_nP1); - - /*! - * \brief Set the control volume at different times. - * \param[in] val_volume_nM1 - Control volume at time n-1. - * \param[in] val_volume_n - Control volume at time n. - * \param[in] val_volume_nP1 - Control volume at time n+1. - */ - void SetPastVolume(su2double val_volume_nM1, su2double val_volume_n, su2double val_volume_nP1); - /*! * \brief Set the time step. * \param[in] val_timestep - Value of the time step. @@ -341,16 +291,6 @@ class CNumerics { U_j = val_u_j; } - /*! - * \brief Set the value of the conservative variables withour reconstruction. - * \param[in] val_u_i - Value of the conservative variable at point i. - * \param[in] val_u_j - Value of the conservative variable at point j. - */ - inline void SetConservative_ZeroOrder(su2double *val_u_i, su2double *val_u_j) { - UZeroOrder_i = val_u_i; - UZeroOrder_j = val_u_j; - } - /*! * \brief Set the value of the primitive variables. * \param[in] val_v_i - Value of the primitive variable at point i. @@ -371,32 +311,6 @@ class CNumerics { S_j = val_s_j; } - /*! - * \brief Set the value of the conservative variables. - * \param[in] val_u_0 - Value of the conservative variable at point 0. - * \param[in] val_u_1 - Value of the conservative variable at point 1. - * \param[in] val_u_2 - Value of the conservative variable at point 2. - */ - inline void SetConservative(su2double *val_u_0, su2double *val_u_1, su2double *val_u_2) { - U_0 = val_u_0; - U_1 = val_u_1; - U_2 = val_u_2; - } - - /*! - * \brief Set the value of the conservative variables. - * \param[in] val_u_0 - Value of the conservative variable at point 0. - * \param[in] val_u_1 - Value of the conservative variable at point 1. - * \param[in] val_u_2 - Value of the conservative variable at point 2. - * \param[in] val_u_3 - Value of the conservative variable at point 3. - */ - inline void SetConservative(su2double *val_u_0, su2double *val_u_1, su2double *val_u_2, su2double *val_u_3) { - U_0 = val_u_0; - U_1 = val_u_1; - U_2 = val_u_2; - U_3 = val_u_3; - } - /*! * \brief Set the gradient of the conservative variables. * \param[in] val_consvar_grad_i - Gradient of the conservative variable at point i. @@ -408,37 +322,6 @@ class CNumerics { ConsVar_Grad_j = val_consvar_grad_j; } - /*! - * \brief Set the gradient of the conservative variables. - * \param[in] val_consvar_grad_0 - Gradient of the conservative variable at point 0. - * \param[in] val_consvar_grad_1 - Gradient of the conservative variable at point 1. - * \param[in] val_consvar_grad_2 - Gradient of the conservative variable at point 2. - */ - inline void SetConsVarGradient(su2double **val_consvar_grad_0, - su2double **val_consvar_grad_1, - su2double **val_consvar_grad_2) { - ConsVar_Grad_0 = val_consvar_grad_0; - ConsVar_Grad_1 = val_consvar_grad_1; - ConsVar_Grad_2 = val_consvar_grad_2; - } - - /*! - * \brief Set the gradient of the conservative variables. - * \param[in] val_consvar_grad_0 - Gradient of the conservative variable at point 0. - * \param[in] val_consvar_grad_1 - Gradient of the conservative variable at point 1. - * \param[in] val_consvar_grad_2 - Gradient of the conservative variable at point 2. - * \param[in] val_consvar_grad_3 - Gradient of the conservative variable at point 3. - */ - inline void SetConsVarGradient(su2double **val_consvar_grad_0, - su2double **val_consvar_grad_1, - su2double **val_consvar_grad_2, - su2double **val_consvar_grad_3) { - ConsVar_Grad_0 = val_consvar_grad_0; - ConsVar_Grad_1 = val_consvar_grad_1; - ConsVar_Grad_2 = val_consvar_grad_2; - ConsVar_Grad_3 = val_consvar_grad_3; - } - /*! * \brief Set the gradient of the conservative variables. * \param[in] val_consvar_grad - Gradient of the conservative variable which is a scalar. @@ -605,18 +488,6 @@ class CNumerics { Thermal_Conductivity_j = val_thermal_conductivity_j; } - /*! - * \brief Set the thermal conductivity (translational/rotational) - * \param[in] val_thermal_conductivity_i - Value of the thermal conductivity at point i. - * \param[in] val_thermal_conductivity_j - Value of the thermal conductivity at point j. - * \param[in] iSpecies - Value of the species. - */ - inline void SetThermalConductivity_ve(su2double val_thermal_conductivity_ve_i, - su2double val_thermal_conductivity_ve_j) { - Thermal_Conductivity_ve_i = val_thermal_conductivity_ve_i; - Thermal_Conductivity_ve_j = val_thermal_conductivity_ve_j; - } - /*! * \brief Set the thermal diffusivity (translational/rotational) * \param[in] val_thermal_diffusivity_i - Value of the thermal diffusivity at point i. @@ -670,34 +541,6 @@ class CNumerics { Coord_j = val_coord_j; } - /*! - * \overload - * \param[in] val_coord_0 - Coordinates of the point 0. - * \param[in] val_coord_1 - Coordinates of the point 1. - * \param[in] val_coord_2 - Coordinates of the point 2. - */ - inline void SetCoord(su2double *val_coord_0, su2double *val_coord_1, - su2double *val_coord_2) { - Coord_0 = val_coord_0; - Coord_1 = val_coord_1; - Coord_2 = val_coord_2; - } - - /*! - * \overload - * \param[in] val_coord_0 - Coordinates of the point 0. - * \param[in] val_coord_1 - Coordinates of the point 1. - * \param[in] val_coord_2 - Coordinates of the point 2. - * \param[in] val_coord_3 - Coordinates of the point 3. - */ - inline void SetCoord(su2double *val_coord_0, su2double *val_coord_1, - su2double *val_coord_2, su2double *val_coord_3) { - Coord_0 = val_coord_0; - Coord_1 = val_coord_1; - Coord_2 = val_coord_2; - Coord_3 = val_coord_3; - } - /*! * \brief Set the velocity of the computational grid. * \param[in] val_gridvel_i - Grid velocity of the point i. @@ -734,9 +577,9 @@ class CNumerics { * \param[in] val_pressure_j - Value of the pressure at point j. */ void SetPressure(su2double val_pressure_i, su2double val_pressure_j) { - Pressure_i = val_pressure_i; - Pressure_j = val_pressure_j; -} + Pressure_i = val_pressure_i; + Pressure_j = val_pressure_j; + } /*! * \brief Set the value of the density for the incompressible solver. @@ -840,84 +683,6 @@ class CNumerics { */ inline void SetVolume(su2double val_volume) { Volume = val_volume; } - /*! - * \brief Retrieves the value of the species density in the primitive variable vector. - * \param[in] iRho_s - */ - void SetRhosIndex(unsigned short val_Index); - - /*! - * \brief Retrieves the value of the species density in the primitive variable vector. - * \param[in] iRho_s - */ - void SetRhoIndex(unsigned short val_Index); - - /*! - * \brief Retrieves the value of the species density in the primitive variable vector. - * \param[in] iRho_s - */ - void SetPIndex(unsigned short val_Index); - - /*! - * \brief Retrieves the value of the species density in the primitive variable vector. - * \param[in] iRho_s - */ - void SetTIndex(unsigned short val_Index); - - /*! - * \brief Retrieves the value of the species density in the primitive variable vector. - * \param[in] iRho_s - */ - void SetTveIndex(unsigned short val_Index); - - /*! - * \brief Retrieves the value of the velocity index in the primitive variable vector. - * \param[in] i(rho*u) - */ - void SetVelIndex(unsigned short val_Index); - - /*! - * \brief Retrieves the value of the species density in the primitive variable vector. - * \param[in] iRho_s - */ - void SetHIndex(unsigned short val_Index); - - /*! - * \brief Retrieves the value of the species density in the primitive variable vector. - * \param[in] iRho_s - */ - void SetAIndex(unsigned short val_Index); - - /*! - * \brief Retrieves the value of the species density in the primitive variable vector. - * \param[in] iRho_s - */ - void SetRhoCvtrIndex(unsigned short val_Index); - - /*! - * \brief Retrieves the value of the species density in the primitive variable vector. - * \param[in] iRho_s - */ - void SetRhoCvveIndex(unsigned short val_Index); - - /*! - * \brief Sets the value of the derivative of pressure w.r.t. species density. - * \param[in] iRho_s - */ - void SetdPdU(su2double *val_dPdU_i, su2double *val_dPdU_j); - - /*! - * \brief Sets the value of the derivative of temperature w.r.t. species density. - * \param[in] iRho_s - */ - void SetdTdU(su2double *val_dTdU_i, su2double *val_dTdU_j); - - /*! - * \brief Sets the value of the derivative of vib-el. temperature w.r.t. species density. - * \param[in] iRho_s - */ - void SetdTvedU(su2double *val_dTvedU_i, su2double *val_dTvedU_j); - /*! * \brief Sets the values of the roe dissipation. * \param[in] diss_i - Dissipation value at node i @@ -991,9 +756,9 @@ class CNumerics { * \param[out] val_Proj_Jac_tensor - Pointer to the projected inviscid Jacobian. */ void GetInviscidIncProjJac(su2double *val_density, su2double *val_velocity, - su2double *val_betainc2, su2double *val_normal, - su2double val_scale, - su2double **val_Proj_Jac_tensor); + su2double *val_betainc2, su2double *val_normal, + su2double val_scale, + su2double **val_Proj_Jac_tensor); /*! * \brief Compute the projection of the inviscid Jacobian matrices (overload for low speed preconditioner version). @@ -1008,14 +773,14 @@ class CNumerics { * \param[out] val_Proj_Jac_tensor - Pointer to the projected inviscid Jacobian. */ void GetInviscidIncProjJac(su2double *val_density, - su2double *val_velocity, - su2double *val_betainc2, - su2double *val_cp, - su2double *val_temperature, - su2double *val_dRhodT, - su2double *val_normal, - su2double val_scale, - su2double **val_Proj_Jac_Tensor); + su2double *val_velocity, + su2double *val_betainc2, + su2double *val_cp, + su2double *val_temperature, + su2double *val_dRhodT, + su2double *val_normal, + su2double val_scale, + su2double **val_Proj_Jac_Tensor); /*! * \brief Compute the low speed preconditioning matrix. @@ -1085,7 +850,8 @@ class CNumerics { * \param[out] val_p_tensor - Pointer to the P matrix. */ void GetPMatrix(su2double *val_density, su2double *val_velocity, - su2double *val_soundspeed, su2double *val_enthalpy, su2double *val_chi, su2double *val_kappa, + su2double *val_soundspeed, su2double *val_enthalpy, + su2double *val_chi, su2double *val_kappa, su2double *val_normal, su2double **val_p_tensor); /*! @@ -1122,7 +888,6 @@ class CNumerics { * \param[in] val_velocity - value of the velocity. * \param[out] val_invR_invPe - Pointer to the matrix of conversion from entropic to conserved variables. */ - void GetRMatrix(su2double val_pressure, su2double val_soundspeed, su2double val_density, su2double* val_velocity, su2double** val_invR_invPe); @@ -1171,7 +936,7 @@ class CNumerics { * \param[in] val_soundspeed - value of the sound speed. * \param[in] val_density - value of the density. * \param[in] prim_jump - pointer to the vector containing the primitive variable jump (drho, dV, dp). - * \param[out]char_jump - pointer to the vector containing the characteristic variable jump. + * \param[out] char_jump - pointer to the vector containing the characteristic variable jump. */ void GetCharJump(su2double val_soundspeed, su2double val_density, su2double *prim_jump, su2double *char_jump); @@ -1187,8 +952,8 @@ class CNumerics { * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. * \param[out] val_absPeJac - Pointer to the Preconditioned Jacobian matrix. */ - void GetPrecondJacobian(su2double Beta2, su2double r_hat, su2double s_hat, su2double t_hat, su2double rB2a2, su2double* val_Lambda, su2double* val_normal, su2double** val_absPeJac); - + void GetPrecondJacobian(su2double Beta2, su2double r_hat, su2double s_hat, su2double t_hat, + su2double rB2a2, su2double* val_Lambda, su2double* val_normal, su2double** val_absPeJac); /*! * \brief Computation of the matrix P^{-1}, this matrix diagonalize the conservative Jacobians @@ -1246,26 +1011,6 @@ class CNumerics { */ inline virtual void ComputeResidual(su2double *val_residual, CConfig *config) { } - /*! - * \overload - * \param[out] val_residual_i - Pointer to the total residual at point i. - * \param[out] val_residual_j - Pointer to the total residual at point j. - */ - inline virtual void ComputeResidual(su2double *val_residual_i, su2double *val_residual_j) { } - - inline virtual void ComputeResidual_TransLM(su2double *val_residual, - su2double **val_Jacobian_i, - su2double **val_Jacobian_j, CConfig *config, - su2double &gamma_sep) { } - - /*! - * \overload - * \param[out] val_residual_i - Pointer to the total residual at point i. - * \param[out] val_residual_j - Pointer to the total residual at point j. - * \param[in] config - Definition of the particular problem. - */ - inline virtual void ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, CConfig *config) { } - /*! * \overload * \param[out] val_residual - Pointer to the total residual. @@ -1276,42 +1021,6 @@ class CNumerics { inline virtual void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { } - /*! - * \overload - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[out] val_JacobianMeanFlow_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_JacobianMeanFlow_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - inline virtual void ComputeResidual(su2double *val_residual, - su2double **val_Jacobian_i, - su2double **val_Jacobian_j, - su2double **val_JacobianMeanFlow_i, - su2double **val_JacobianMeanFlow_j, - CConfig *config) { } - - /*! - * \overload - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - inline virtual void ComputeResidual(su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { } - - /*! - * \overload - * \param[out] val_resconv - Pointer to the convective residual. - * \param[out] val_resvisc - Pointer to the artificial viscosity residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - inline virtual void ComputeResidual(su2double *val_resconv, su2double *val_resvisc, - su2double **val_Jacobian_i, su2double **val_Jacobian_j, - CConfig *config) { } - /*! * \overload * \param[out] val_residual_i - Pointer to the total residual at point i. @@ -1348,13 +1057,6 @@ class CNumerics { su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config) { } - /*! - * \overload - * \param[out] val_stiffmatrix_elem - Stiffness matrix for Galerkin computation. - * \param[in] config - Definition of the particular problem. - */ - inline virtual void ComputeResidual(su2double **val_stiffmatrix_elem, CConfig *config) { } - /*! * \overload * \param[in] config - Definition of the particular problem. @@ -1364,56 +1066,17 @@ class CNumerics { inline virtual void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config) { } /*! - * \overload - * \param[out] - Matrix for storing the constants to be used in the calculation of the equilibrium extent of reaction Keq. - * \param[in] config - Definition of the particular problem. - */ - inline virtual void GetEq_Rxn_Coefficients(su2double **EqnRxnConstants, CConfig *config) { } - - /*! - * \brief Residual for source term integration. - * \param[out] val_residual - Pointer to the source residual containing chemistry terms. - * \param[in] config - Definition of the particular problem. - */ - inline virtual void ComputeResidual_Axisymmetric(su2double *val_residual, CConfig *config) { } - - /*! - * \brief Residual for source term integration. - * \param[out] val_residual - Pointer to the source residual containing chemistry terms. - * \param[in] config - Definition of the particular problem. - */ - inline virtual void ComputeResidual_Axisymmetric_ad(su2double *val_residual, su2double *val_residuald, CConfig *config) { } - - /*! - * \brief Calculation of axisymmetric source term Jacobian + * \brief Residual for transition problems. + * \param[out] val_residual - Pointer to the total residual. * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). * \param[in] config - Definition of the particular problem. + * \param[out] gamma_sep */ - inline virtual void SetJacobian_Axisymmetric(su2double **val_Jacobian_i, CConfig *config) { } - - /*! - * \brief Calculation of the translational-vibrational energy exchange source term - * \param[in] config - Definition of the particular problem. - * \param[out] val_residual - residual of the source terms - * \param[out] val_Jacobian_i - Jacobian of the source terms - */ - inline virtual void ComputeVibRelaxation(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config) { } - - /*! - * \brief Calculation of the chemistry source term - * \param[in] config - Definition of the particular problem. - * \param[out] val_residual - residual of the source terms - * \param[out] val_Jacobian_i - Jacobian of the source terms - */ - inline virtual void ComputeChemistry(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config) { } - - /*! - * \brief Calculates constants used for Keq correlation. - * \param[out] A - Pointer to coefficient array. - * \param[in] val_reaction - Reaction number indicator. - * \param[in] config - Definition of the particular problem. - */ - inline virtual void GetKeqConstants(su2double *A, unsigned short val_reaction, CConfig *config) { } + inline virtual void ComputeResidual_TransLM(su2double *val_residual, + su2double **val_Jacobian_i, + su2double **val_Jacobian_j, CConfig *config, + su2double &gamma_sep) { } /*! * \brief Set intermittency for numerics (used in SA with LM transition model) @@ -1461,27 +1124,6 @@ class CNumerics { */ inline virtual su2double GetGammaBC(void) { return 0.0; } - /*! - * \overload - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i - * \param[in] config - Definition of the particular problem. - */ - inline virtual void ComputeResidual(su2double **val_Jacobian_i, - su2double *val_Jacobian_mui, - su2double ***val_Jacobian_gradi, CConfig *config) { } - - /*! - * \overload - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i - * \param[in] config - Definition of the particular problem. - */ - inline virtual void ComputeResidual(su2double **val_Jacobian_i, - su2double *val_Jacobian_mui, - su2double ***val_Jacobian_gradi, - su2double **val_Jacobian_j, - su2double *val_Jacobian_muj, - su2double ***val_Jacobian_gradj, CConfig *config) { } - /*! * \brief A virtual member to compute the tangent matrix in structural problems * \param[in] element_container - Element structure for the particular element integrated. @@ -1555,7 +1197,7 @@ class CNumerics { inline virtual void Compute_Averaged_NodalStress(CElement *element_container, CConfig *config) { } /*! - * \brief Computes a basis of orthogonal vectors from a suppled vector + * \brief Computes a basis of orthogonal vectors from a supplied vector * \param[in] config - Normal vector */ void CreateBasis(su2double *val_Normal); diff --git a/SU2_CFD/include/solvers/CSolver.hpp b/SU2_CFD/include/solvers/CSolver.hpp index 4fdc29531c98..7ab88741f723 100644 --- a/SU2_CFD/include/solvers/CSolver.hpp +++ b/SU2_CFD/include/solvers/CSolver.hpp @@ -66,12 +66,12 @@ 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 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. */ - vector NonLinRes_Series; /*!< \brief Vector holding the nonlinear residual indicator series. */ + 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. */ + vector 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. */ + 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. */ @@ -81,8 +81,8 @@ class CSolver { nDim; /*!< \brief Number of dimensions of the problem. */ unsigned long nPoint; /*!< \brief Number of points of the computational grid. */ 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_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. */ @@ -126,8 +126,8 @@ class CSolver { passivedouble *Restart_Data; /*!< \brief Auxiliary structure for holding the data values from a restart. */ unsigned short nOutputVariables; /*!< \brief Number of variables to write. */ - unsigned long nMarker, /*!< \brief Total number of markers using the grid information. */ - *nVertex; /*!< \brief Store nVertex at each marker for deallocation */ + unsigned long nMarker, /*!< \brief Total number of markers using the grid information. */ + *nVertex; /*!< \brief Store nVertex at each marker for deallocation */ 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. */ @@ -155,7 +155,7 @@ class CSolver { 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*. + most derived type possible, e.g. CEulerSolver 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. */ diff --git a/SU2_CFD/src/numerics/CNumerics.cpp b/SU2_CFD/src/numerics/CNumerics.cpp index 43bd59f73415..6f61a1506c1b 100644 --- a/SU2_CFD/src/numerics/CNumerics.cpp +++ b/SU2_CFD/src/numerics/CNumerics.cpp @@ -34,10 +34,6 @@ CNumerics::CNumerics(void) { UnitNormal = NULL; UnitNormald = NULL; - U_n = NULL; - U_nM1 = NULL; - U_nP1 = NULL; - Proj_Flux_Tensor = NULL; Flux_Tensor = NULL; @@ -50,9 +46,6 @@ CNumerics::CNumerics(void) { Vector = NULL; - Enthalpy_formation = NULL; - Theta_v = NULL; - l = NULL; m = NULL; @@ -69,10 +62,6 @@ CNumerics::CNumerics(unsigned short val_nDim, unsigned short val_nVar, UnitNormal = NULL; UnitNormald = NULL; - U_n = NULL; - U_nM1 = NULL; - U_nP1 = NULL; - Proj_Flux_Tensor = NULL; Flux_Tensor = NULL; @@ -83,9 +72,6 @@ CNumerics::CNumerics(unsigned short val_nDim, unsigned short val_nVar, Diffusion_Coeff_i = NULL; Diffusion_Coeff_j = NULL; - Enthalpy_formation = NULL; - Theta_v = NULL; - l = NULL; m = NULL; @@ -144,10 +130,6 @@ CNumerics::CNumerics(unsigned short val_nDim, unsigned short val_nVar, } } - U_n = new su2double [nVar]; - U_nM1 = new su2double [nVar]; - U_nP1 = new su2double [nVar]; - Proj_Flux_Tensor = new su2double [nVar]; turb_ke_i = 0.0; @@ -204,9 +186,9 @@ CNumerics::~CNumerics(void) { if (UnitNormal!= NULL) delete [] UnitNormal; if (UnitNormald!= NULL) delete [] UnitNormald; - if (U_n!= NULL) delete [] U_n; - if (U_nM1!= NULL) delete [] U_nM1; - if (U_nP1!= NULL) delete [] U_nP1; +// if (U_n!= NULL) delete [] U_n; +// if (U_nM1!= NULL) delete [] U_nM1; +// if (U_nP1!= NULL) delete [] U_nP1; // visc if (Proj_Flux_Tensor!= NULL) delete [] Proj_Flux_Tensor; @@ -243,9 +225,6 @@ CNumerics::~CNumerics(void) { if (Diffusion_Coeff_j != NULL) delete [] Diffusion_Coeff_j; if (Vector != NULL) delete [] Vector; - if(Enthalpy_formation != NULL) delete [] Enthalpy_formation; - if(Theta_v != NULL) delete [] Theta_v; - if (l != NULL) delete [] l; if (m != NULL) delete [] m; @@ -295,7 +274,7 @@ void CNumerics::GetInviscidFlux(su2double val_density, su2double *val_velocity, Flux_Tensor[4][2] = Flux_Tensor[0][2]*val_enthalpy; } - if (nDim == 2) { + else { Flux_Tensor[0][0] = val_density*val_velocity[0]; Flux_Tensor[1][0] = Flux_Tensor[0][0]*val_velocity[0]+val_pressure; Flux_Tensor[2][0] = Flux_Tensor[0][0]*val_velocity[1]; @@ -315,7 +294,7 @@ void CNumerics::GetInviscidProjFlux(su2double *val_density, su2double *val_normal, su2double *val_Proj_Flux) { - su2double rhou, rhov, rhow; + su2double rhou, rhov, rhow; if (nDim == 2) { @@ -537,7 +516,9 @@ void CNumerics::GetInviscidIncProjJac(su2double *val_density, su2double *val_vel AD_END_PASSIVE } -void CNumerics::GetPreconditioner(su2double *val_density, su2double *val_velocity, su2double *val_betainc2, su2double *val_cp, su2double *val_temperature, su2double *val_drhodt, su2double **val_Precon) { +void CNumerics::GetPreconditioner(su2double *val_density, su2double *val_velocity, + su2double *val_betainc2, su2double *val_cp, + su2double *val_temperature, su2double *val_drhodt, su2double **val_Precon) { unsigned short iDim, jDim; val_Precon[0][0] = 1.0/(*val_betainc2); @@ -561,7 +542,8 @@ void CNumerics::GetPreconditioner(su2double *val_density, su2double *val_velocit } -void CNumerics::GetPreconditionedProjJac(su2double *val_density, su2double *val_lambda, su2double *val_betainc2, su2double *val_normal, su2double **val_invPrecon_A) { +void CNumerics::GetPreconditionedProjJac(su2double *val_density, su2double *val_lambda, + su2double *val_betainc2, su2double *val_normal, su2double **val_invPrecon_A) { unsigned short iDim, jDim, kDim; val_invPrecon_A[0][0] = val_lambda[nDim]/2.0 + val_lambda[nDim+1]/2.0; @@ -592,23 +574,6 @@ void CNumerics::GetPreconditionedProjJac(su2double *val_density, su2double *val_ } -void CNumerics::SetPastSol (su2double *val_u_nM1, su2double *val_u_n, su2double *val_u_nP1) { - unsigned short iVar; - - for (iVar = 0; iVar < nVar; iVar++) { - U_nM1[iVar] = val_u_nM1[iVar]; - U_n[iVar] = val_u_n[iVar]; - U_nP1[iVar] = val_u_nP1[iVar]; - } - -} -void CNumerics::SetPastVolume (su2double val_volume_nM1, su2double val_volume_n, su2double val_volume_nP1) { - Volume_nM1 = val_volume_nM1; - Volume_n = val_volume_n; - Volume_nP1 = val_volume_nP1; -} - - void CNumerics::GetPMatrix(su2double *val_density, su2double *val_velocity, su2double *val_soundspeed, su2double *val_normal, su2double **val_p_tensor) { @@ -682,8 +647,9 @@ void CNumerics::GetPMatrix(su2double *val_density, su2double *val_velocity, } -void CNumerics::GetPMatrix(su2double *val_density, su2double *val_velocity, - su2double *val_soundspeed, su2double *val_enthalpy, su2double *val_chi, su2double *val_kappa, su2double *val_normal, su2double **val_p_tensor) { +void CNumerics::GetPMatrix(su2double *val_density, su2double *val_velocity, su2double *val_soundspeed, + su2double *val_enthalpy, su2double *val_chi, su2double *val_kappa, + su2double *val_normal, su2double **val_p_tensor) { su2double sqvel, rhooc, zeta; //su2double rhoxc, c2; @@ -754,7 +720,8 @@ void CNumerics::GetPMatrix(su2double *val_density, su2double *val_velocity, } void CNumerics::GetPMatrix_inv(su2double *val_density, su2double *val_velocity, - su2double *val_soundspeed, su2double *val_normal, su2double **val_invp_tensor) { + su2double *val_soundspeed, su2double *val_normal, + su2double **val_invp_tensor) { su2double rhoxc, c2, gm1, k0orho, k1orho, gm1_o_c2, gm1_o_rhoxc, sqvel; @@ -801,7 +768,7 @@ void CNumerics::GetPMatrix_inv(su2double *val_density, su2double *val_velocity, val_invp_tensor[4][4]=Gamma_Minus_One/rhoxc; } - if (nDim == 2) { + else { sqvel = val_velocity[0]*val_velocity[0]+val_velocity[1]*val_velocity[1]; @@ -828,8 +795,9 @@ void CNumerics::GetPMatrix_inv(su2double *val_density, su2double *val_velocity, } } -void CNumerics::GetPMatrix_inv(su2double **val_invp_tensor, su2double *val_density, su2double *val_velocity, - su2double *val_soundspeed, su2double *val_chi, su2double *val_kappa, su2double *val_normal) { +void CNumerics::GetPMatrix_inv(su2double **val_invp_tensor, su2double *val_density, + su2double *val_velocity, su2double *val_soundspeed, + su2double *val_chi, su2double *val_kappa, su2double *val_normal) { su2double rhoxc, c2, k0orho, k1orho, sqvel, k_o_c2, k_o_rhoxc, dp_drho; @@ -840,7 +808,6 @@ void CNumerics::GetPMatrix_inv(su2double **val_invp_tensor, su2double *val_densi k_o_c2 = (*val_kappa)/c2; k_o_rhoxc = (*val_kappa)/rhoxc; - if (nDim == 3) { sqvel = val_velocity[0]*val_velocity[0]+val_velocity[1]*val_velocity[1]+val_velocity[2]*val_velocity[2]; dp_drho = *val_chi + 0.5*sqvel*(*val_kappa); @@ -875,7 +842,7 @@ void CNumerics::GetPMatrix_inv(su2double **val_invp_tensor, su2double *val_densi val_invp_tensor[4][3]=-val_normal[2] / *val_density- val_velocity[2]*k_o_rhoxc; val_invp_tensor[4][4]= k_o_rhoxc; } - if (nDim == 2) { + else { sqvel = val_velocity[0]*val_velocity[0]+val_velocity[1]*val_velocity[1]; dp_drho = *val_chi + 0.5*sqvel*(*val_kappa); @@ -971,7 +938,8 @@ void CNumerics::GetinvRinvPe(su2double Beta2, su2double val_enthalpy, } -void CNumerics::GetRMatrix(su2double val_pressure, su2double val_soundspeed, su2double val_density, su2double* val_velocity, su2double **R_Matrix) { +void CNumerics::GetRMatrix(su2double val_pressure, su2double val_soundspeed, su2double val_density, + su2double* val_velocity, su2double **R_Matrix) { su2double sqvel; //su2double factor = 1.0/(val_soundspeed*val_soundspeed*1); @@ -1046,6 +1014,7 @@ void CNumerics::GetRMatrix(su2double val_soundspeed, su2double val_density, su2d su2double cc, rhoc; cc = val_soundspeed*val_soundspeed; rhoc = val_density*val_soundspeed; + if (nDim == 2) { R_Matrix[0][0] = -1.0/cc; R_Matrix[0][1] = 0.0; @@ -1100,7 +1069,7 @@ void CNumerics::GetRMatrix(su2double val_soundspeed, su2double val_density, su2d R_Matrix[4][3] = 0.5; R_Matrix[4][4] = 0.5; -} + } } @@ -1181,23 +1150,23 @@ void CNumerics::ComputeResJacobianGiles(CFluidModel *FluidModel, su2double press dsdrho_P = FluidModel->Getdsdrho_P(); dsdP_rho = FluidModel->GetdsdP_rho(); - if (nDim == 2){ + if (nDim == 2) { R_c[0][0] = -1/cc*dsdrho_P; //a11 - R_c[0][1] = 0.0; //a12 - R_c[0][2] = 0.5/cc*dsdrho_P + 0.5*dsdP_rho; //a13 + R_c[0][1] = 0.0; //a12 + R_c[0][2] = 0.5/cc*dsdrho_P + 0.5*dsdP_rho; //a13 - R_c[1][0] = 0.0; //a21 + R_c[1][0] = 0.0; //a21 R_c[1][1] = 1/rhoc; //a22 - R_c[1][2] = -0.5/rhoc*tan(alphaInBC); //a23 + R_c[1][2] = -0.5/rhoc*tan(alphaInBC); //a23 - R_c[2][0] = -1/cc*dhdrho_P; //a31 - R_c[2][1] = turboVel[1]/rhoc; //a32 + R_c[2][0] = -1/cc*dhdrho_P; //a31 + R_c[2][1] = turboVel[1]/rhoc; //a32 R_c[2][2] = 0.5/cc*dhdrho_P + 0.5*turboVel[0]/rhoc + 0.5*dhdP_rho; //a33 InvMatrix3D(R_c, R_c_inv); } - else{ + else { R_c[0][0] = -1/cc*dsdrho_P; //a11 R_c[0][1] = 0.0; //a12 R_c[0][2] = 0.0; //a13 @@ -1299,8 +1268,8 @@ void CNumerics::GetCharJump(su2double val_soundspeed, su2double val_density, su2 } } -void CNumerics::GetPrecondJacobian(su2double Beta2, su2double r_hat, su2double s_hat, su2double t_hat, su2double rB2a2, su2double* Lambda, su2double *val_normal, - su2double **val_absPeJac) { +void CNumerics::GetPrecondJacobian(su2double Beta2, su2double r_hat, su2double s_hat, su2double t_hat, + su2double rB2a2, su2double* Lambda, su2double *val_normal, su2double **val_absPeJac) { su2double lam1, lam2, lam3, lam4; lam1 = Lambda[0]; lam2 = Lambda[1]; lam3 = Lambda[2]; lam4 = Lambda[3]; @@ -1380,8 +1349,7 @@ void CNumerics::GetJacInviscidLambda_fabs(su2double *val_velocity, su2double val val_Lambda_Vector[3] = fabs(ProjVelocity + val_soundspeed); val_Lambda_Vector[4] = fabs(ProjVelocity - val_soundspeed); } - - if (nDim == 2) { + else { val_Lambda_Vector[0] = fabs(ProjVelocity); val_Lambda_Vector[1] = fabs(ProjVelocity); val_Lambda_Vector[2] = fabs(ProjVelocity + val_soundspeed); diff --git a/SU2_CFD/src/numerics/continuous_adjoint/CAvgGradCorrected_AdjFlow.cpp b/SU2_CFD/src/numerics/continuous_adjoint/CAvgGradCorrected_AdjFlow.cpp index e2b0573ac8dd..b8dbd479aef5 100644 --- a/SU2_CFD/src/numerics/continuous_adjoint/CAvgGradCorrected_AdjFlow.cpp +++ b/SU2_CFD/src/numerics/continuous_adjoint/CAvgGradCorrected_AdjFlow.cpp @@ -75,7 +75,7 @@ void CAvgGradCorrected_AdjFlow::ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, - su2double **val_Jacobian_ji, + su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config) { diff --git a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwGeneralHLLC_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwGeneralHLLC_Flow.cpp index b33d9f06057e..c57b4f599e20 100644 --- a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwGeneralHLLC_Flow.cpp +++ b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwGeneralHLLC_Flow.cpp @@ -591,318 +591,3 @@ void CUpwGeneralHLLC_Flow::VinokurMontagne() { } } - -#ifdef CHECK - -int UgpWithCvCompFlow::calcEulerFluxMatrices_HLLC(su2double (*val_Jacobian_i)[5], su2double (*val_Jacobian_j)[5], su2double (*val_Jacobian_i_Scal)[6], su2double (*val_Jacobian_j_Scal)[6], - const su2double Density_i, const su2double *uL, const su2double pL, const su2double TL, const su2double h0, const su2double RL, const su2double gammaL, const su2double *scalL, const su2double kL, - const su2double Density_j, const su2double *uR, const su2double pR, const su2double TR, const su2double h1, const su2double RR, const su2double gammaR, const su2double *scalR, const su2double kR, - const su2double area, const su2double *nVec, const int nScal, const su2double surfVeloc) -{ - - su2double unL = vecDotVec3d(uL, nVec); - su2double uLuL = vecDotVec3d(uL, uL); - su2double cL = sqrt(gammaL*pL/Density_i); - su2double hL = gammaL/(gammaL-1.0)*pL/Density_i + 0.5*uLuL + kL; - // su2double hL = h0 + 0.5*uLuL + kL; - su2double eL = hL*Density_i-pL; - - su2double unR = vecDotVec3d(uR, nVec); - su2double uRuR = vecDotVec3d(uR, uR); - su2double cR = sqrt(gammaR*pR/Density_j); - su2double hR = gammaR/(gammaR-1.0)*pR/Density_j + 0.5*uRuR + kR; - // su2double hR = h1 + 0.5*uRuR + kR; - su2double eR = hR*Density_j-pR; - - - // Roe's aveaging - su2double Rrho = sqrt(Density_j/Density_i); - su2double tmp = 1.0/(1.0+Rrho); - su2double velRoe[3]; - for (int i=0; i<3; i++) - velRoe[i] = tmp*(uL[i] + uR[i]*Rrho); - su2double uRoe = vecDotVec3d(velRoe, nVec); - su2double hRoe = tmp*(hL + hR*Rrho); - - // su2double cRoe = sqrt((gammaL-1.0)*(hRoe- 0.5*vecDotVec3d(velRoe, velRoe))); - su2double gamPdivRho = tmp*((gammaL*pL/Density_i+0.5*(gammaL-1.0)*uLuL) + (gammaR*pR/Density_j+0.5*(gammaR-1.0)*uRuR)*Rrho); - su2double cRoe = sqrt(gamPdivRho - ((gammaL+gammaR)*0.5-1.0)*0.5*vecDotVec3d(velRoe, velRoe)); - - // speed of sound at L and R - su2double sL = min(uRoe-cRoe, unL-cL); - su2double sR = max(uRoe+cRoe, unR+cR); - - // speed of contact surface - su2double sM = (pL-pR-Density_i*unL*(sL-unL)+Density_j*unR*(sR-unR))/(Density_j*(sR-unR)-Density_i*(sL-unL)); - - // pressure at right and left (pR=pL) side of contact surface - su2double pStar = Density_j*(unR-sR)*(unR-sM)+pR; - - if (sM >= 0.0) { - - if (sL > 0.0) { - - su2double nVecArea[3]; - for (int i=0; i<3; i++) nVecArea[i] = nVec[i]*area; - - calcJacobianA(val_Jacobian_i, uL, pL, Density_i, nVecArea, 0.5*(gammaL+gammaR), 0.0); - - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_j[i][j] = 0.0; - - } - else { - - su2double invSLmSs = 1.0/(sL-sM); - su2double sLmuL = sL-unL; - su2double rhoSL = Density_i*sLmuL*invSLmSs; - su2double rhouSL[3]; - - for (int i=0; i<3; i++) - rhouSL[i] = (Density_i*uL[i]*sLmuL+(pStar-pL)*nVec[i])*invSLmSs; - - su2double eSL = (sLmuL*eL-pL*unL+pStar*sM)*invSLmSs; - su2double gammaLM1 = (gammaL-1.0); - su2double gammaRM1 = (gammaR-1.0); - su2double invrhotld = 1.0/(Density_j*(sR-unR)-Density_i*(sL-unL)); - - su2double dSMdUL[5], dSMdUR[5]; - su2double dpsdUL[5], dpsdUR[5]; - - dSMdUL[0] = -unL*unL + uLuL*gammaLM1/2.0 + sM*sL; - dSMdUL[1] = nVec[0]*(2.0*unL-sL-sM) - gammaLM1*uL[0]; - dSMdUL[2] = nVec[1]*(2.0*unL-sL-sM) - gammaLM1*uL[1]; - dSMdUL[3] = nVec[2]*(2.0*unL-sL-sM) - gammaLM1*uL[2]; - dSMdUL[4] = gammaLM1; - - for (iVar = 0; iVar < nVar; iVar++) - { - dSMdUL[i] *= invrhotld; - dpsdUL[i] = Density_j*(sR-unR)*dSMdUL[i]; - } - - dSMdUR[0] = unR*unR - uRuR*gammaRM1/2.0 - sM*sR; - dSMdUR[1] = -nVec[0]*(2.0*unR-sR-sM) + gammaRM1*uR[0]; - dSMdUR[2] = -nVec[1]*(2.0*unR-sR-sM) + gammaRM1*uR[1]; - dSMdUR[3] = -nVec[2]*(2.0*unR-sR-sM) + gammaRM1*uR[2]; - dSMdUR[4] = -gammaRM1; - - for (iVar = 0; iVar < nVar; iVar++) - { - dSMdUR[i] *= invrhotld; - dpsdUR[i] = Density_i*(sL-unL)*dSMdUR[i]; - } - - calcSubSonicJacobeanHLLC(val_Jacobian_i, val_Jacobian_j, - Density_i, uL, pL, eL, unL, uLuL, sL, - rhoSL, rhouSL, eSL, dSMdUL, - dSMdUR, dpsdUL, dpsdUR, sM, pStar, 0.5*(gammaL+gammaR), nVec); - - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[0][i] = val_Jacobian_i[0][i]*sM + dSMdUL[i]*rhoSL; - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[1][i] = val_Jacobian_i[1][i]*sM + dSMdUL[i]*rhouSL[0] + dpsdUL[i]*nVec[0]; - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[2][i] = val_Jacobian_i[2][i]*sM + dSMdUL[i]*rhouSL[1] + dpsdUL[i]*nVec[1]; - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[3][i] = val_Jacobian_i[3][i]*sM + dSMdUL[i]*rhouSL[2] + dpsdUL[i]*nVec[2]; - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[4][i] = (val_Jacobian_i[4][i]+dpsdUL[i])*sM + (eSL+pStar)*dSMdUL[i]; - - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_i[i][j] *= area; - - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[0][i] = val_Jacobian_j[0][i]*sM + dSMdUR[i]*rhoSL; - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[1][i] = val_Jacobian_j[1][i]*sM + dSMdUR[i]*rhouSL[0] + dpsdUR[i]*nVec[0]; - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[2][i] = val_Jacobian_j[2][i]*sM + dSMdUR[i]*rhouSL[1] + dpsdUR[i]*nVec[1]; - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[3][i] = val_Jacobian_j[3][i]*sM + dSMdUR[i]*rhouSL[2] + dpsdUR[i]*nVec[2]; - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[4][i] = (val_Jacobian_j[4][i]+dpsdUR[i])*sM + (eSL+pStar)*dSMdUR[i]; - - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_j[i][j] *= area; - - } - } - - else { - - if (sR >= 0.0) { - - su2double invSRmSs = 1.0/(sR-sM); - su2double sRmuR = sR-unR; - su2double rhoSR = Density_j*sRmuR*invSRmSs; - su2double rhouSR[3]; - for (int i=0; i<3; i++) - rhouSR[i] = (Density_j*uR[i]*sRmuR+(pStar-pR)*nVec[i])*invSRmSs; - su2double eSR = (sRmuR*eR-pR*unR+pStar*sM)*invSRmSs; - su2double gammaLM1 = (gammaL-1.0); - su2double gammaRM1 = (gammaR-1.0); - su2double invrhotld = 1.0/(Density_j*(sR-unR)-Density_i*(sL-unL)); - - su2double dSMdUL[5], dSMdUR[5]; - su2double dpsdUL[5], dpsdUR[5]; - - dSMdUL[0] = -unL*unL + uLuL*gammaLM1/2.0 + sM*sL; - dSMdUL[1] = nVec[0]*(2.0*unL-sL-sM) - gammaLM1*uL[0]; - dSMdUL[2] = nVec[1]*(2.0*unL-sL-sM) - gammaLM1*uL[1]; - dSMdUL[3] = nVec[2]*(2.0*unL-sL-sM) - gammaLM1*uL[2]; - dSMdUL[4] = gammaLM1; - - for (iVar = 0; iVar < nVar; iVar++) { - dSMdUL[i] *= invrhotld; - dpsdUL[i] = Density_j*(sR-unR)*dSMdUL[i]; - } - - dSMdUR[0] = unR*unR - uRuR*gammaRM1/2.0 - sM*sR; - dSMdUR[1] = -nVec[0]*(2.0*unR-sR-sM) + gammaRM1*uR[0]; - dSMdUR[2] = -nVec[1]*(2.0*unR-sR-sM) + gammaRM1*uR[1]; - dSMdUR[3] = -nVec[2]*(2.0*unR-sR-sM) + gammaRM1*uR[2]; - dSMdUR[4] = -gammaRM1; - - for (iVar = 0; iVar < nVar; iVar++) { - dSMdUR[i] *= invrhotld; - dpsdUR[i] = Density_i*(sL-unL)*dSMdUR[i]; - } - - calcSubSonicJacobeanHLLC(val_Jacobian_j, val_Jacobian_i, - Density_j, uR, pR, eR, unR, uRuR, sR, - rhoSR, rhouSR, eSR, - dSMdUR, dSMdUL, dpsdUR, dpsdUL, sM, pStar, 0.5*(gammaL+gammaR), nVec); - - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[0][i] = val_Jacobian_i[0][i]*sM + dSMdUL[i]*rhoSR; - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[1][i] = val_Jacobian_i[1][i]*sM + dSMdUL[i]*rhouSR[0] + dpsdUL[i]*nVec[0]; - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[2][i] = val_Jacobian_i[2][i]*sM + dSMdUL[i]*rhouSR[1] + dpsdUL[i]*nVec[1]; - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[3][i] = val_Jacobian_i[3][i]*sM + dSMdUL[i]*rhouSR[2] + dpsdUL[i]*nVec[2]; - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[4][i] = (val_Jacobian_i[4][i]+dpsdUL[i])*sM + (eSR+pStar)*dSMdUL[i]; - - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_i[i][j] *= area; - - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[0][i] = val_Jacobian_j[0][i]*sM + dSMdUR[i]*rhoSR; - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[1][i] = val_Jacobian_j[1][i]*sM + dSMdUR[i]*rhouSR[0] + dpsdUR[i]*nVec[0]; - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[2][i] = val_Jacobian_j[2][i]*sM + dSMdUR[i]*rhouSR[1] + dpsdUR[i]*nVec[1]; - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[3][i] = val_Jacobian_j[3][i]*sM + dSMdUR[i]*rhouSR[2] + dpsdUR[i]*nVec[2]; - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[4][i] = (val_Jacobian_j[4][i]+dpsdUR[i])*sM + (eSR+pStar)*dSMdUR[i]; - - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_j[i][j] *= area; - - } - - else { - - su2double nVecArea[3]; - for (int i=0; i<3; i++) nVecArea[i] = nVec[i]*area; - calcJacobianA(val_Jacobian_j, uR, pR, Density_j, nVecArea, 0.5*(gammaL+gammaR), 0.0); - - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_i[i][j] = 0.0; - - } - - } - -} - -void UgpWithCvCompFlow::calcSubSonicJacobeanHLLC(su2double (*AL)[5], su2double (*AR)[5], - su2double Density_i, const su2double *uL, su2double pL, su2double eL, su2double qL, su2double psiL, su2double SL, - su2double rhoSL, su2double *rhouSL, su2double eSL, - su2double *dSMdUL, su2double *dSMdUR, su2double *dpsdUL, su2double *dpsdUR, su2double SM, su2double pS, - su2double gamma, const su2double *nV) // nV is not normalized -{ - - su2double gammaMinus1 = (gamma-1.0); - su2double omL = 1.0/(SL-SM); - - AL[0][0] = SL + rhoSL*dSMdUL[0]; - AL[0][1] = -nV[0] + rhoSL*dSMdUL[1]; - AL[0][2] = -nV[1] + rhoSL*dSMdUL[2]; - AL[0][3] = -nV[2] + rhoSL*dSMdUL[3]; - AL[0][4] = + rhoSL*dSMdUL[4]; - - AL[1][0] = qL*uL[0] - nV[0]*psiL*gammaMinus1/2.0 + nV[0]*dpsdUL[0] + rhouSL[0]*dSMdUL[0]; - AL[1][1] = SL - qL + nV[0]*(gamma-2.0)*uL[0] + nV[0]*dpsdUL[1] + rhouSL[0]*dSMdUL[1]; - AL[1][2] = - uL[0]*nV[1] + nV[0]*gammaMinus1*uL[1] + nV[0]*dpsdUL[2] + rhouSL[0]*dSMdUL[2]; - AL[1][3] = - uL[0]*nV[2] + nV[0]*gammaMinus1*uL[2] + nV[0]*dpsdUL[3] + rhouSL[0]*dSMdUL[3]; - AL[1][4] = -gammaMinus1*nV[0] + nV[0]*dpsdUL[4] + rhouSL[0]*dSMdUL[4]; - - AL[2][0] = qL*uL[1] - nV[1]*psiL*gammaMinus1/2.0 + nV[1]*dpsdUL[0] + rhouSL[1]*dSMdUL[0]; - AL[2][1] = - uL[1]*nV[0] + nV[1]*gammaMinus1*uL[0] + nV[1]*dpsdUL[1] + rhouSL[1]*dSMdUL[1]; - AL[2][2] = SL - qL + nV[1]*(gamma-2.0)*uL[1] + nV[1]*dpsdUL[2] + rhouSL[1]*dSMdUL[2]; - AL[2][3] = - uL[1]*nV[2] + nV[1]*gammaMinus1*uL[2] + nV[1]*dpsdUL[3] + rhouSL[1]*dSMdUL[3]; - AL[2][4] = -gammaMinus1*nV[1] + nV[1]*dpsdUL[4] + rhouSL[1]*dSMdUL[4]; - - AL[3][0] = qL*uL[2] - nV[2]*psiL*gammaMinus1/2.0 + nV[2]*dpsdUL[0] + rhouSL[2]*dSMdUL[0]; - AL[3][1] = - uL[2]*nV[0] + nV[2]*gammaMinus1*uL[0] + nV[2]*dpsdUL[1] + rhouSL[2]*dSMdUL[1]; - AL[3][2] = - uL[2]*nV[1] + nV[2]*gammaMinus1*uL[1] + nV[2]*dpsdUL[2] + rhouSL[2]*dSMdUL[2]; - AL[3][3] = SL - qL + nV[2]*(gamma-2.0)*uL[2] + nV[2]*dpsdUL[3] + rhouSL[2]*dSMdUL[3]; - AL[3][4] = -gammaMinus1*nV[2] + nV[2]*dpsdUL[4] + rhouSL[2]*dSMdUL[4]; - - AL[4][0] = qL*(eL+pL)/Density_i - qL*psiL*(gamma-1.0)/2.0 + SM*dpsdUL[0] + (pS+eSL)*dSMdUL[0]; - AL[4][1] = - nV[0]*(eL+pL)/Density_i + gammaMinus1*uL[0]*qL + SM*dpsdUL[1] + (pS+eSL)*dSMdUL[1]; - AL[4][2] = - nV[1]*(eL+pL)/Density_i + gammaMinus1*uL[1]*qL + SM*dpsdUL[2] + (pS+eSL)*dSMdUL[2]; - AL[4][3] = - nV[2]*(eL+pL)/Density_i + gammaMinus1*uL[2]*qL + SM*dpsdUL[3] + (pS+eSL)*dSMdUL[3]; - AL[4][4] = SL-qL*gamma + SM*dpsdUL[4] + (pS+eSL)*dSMdUL[4]; - - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - AL[i][j] *= omL; - - for (iVar = 0; iVar < nVar; iVar++) AR[0][i] = omL*rhoSL*dSMdUR[i]; - for (iVar = 0; iVar < nVar; iVar++) AR[1][i] = omL*(nV[0]*dpsdUR[i]+rhouSL[0]*dSMdUR[i]); - for (iVar = 0; iVar < nVar; iVar++) AR[2][i] = omL*(nV[1]*dpsdUR[i]+rhouSL[1]*dSMdUR[i]); - for (iVar = 0; iVar < nVar; iVar++) AR[3][i] = omL*(nV[2]*dpsdUR[i]+rhouSL[2]*dSMdUR[i]); - for (iVar = 0; iVar < nVar; iVar++) AR[4][i] = omL*(dpsdUR[i]*SM+(pS+eSL)*dSMdUR[i]); - -} - -void UgpWithCvCompFlow::calcJacobianA(su2double (*A)[5], const su2double *vel, su2double pp, su2double rrho, const su2double *nV, su2double gamma, su2double surfVeloc) // nV is not normalized -{ - - su2double kapm1 = (gamma - 1.0); - - su2double nVel[3]; - nVel[0] = vel[0]*nV[0]; - nVel[1] = vel[1]*nV[1]; - nVel[2] = vel[2]*nV[2]; - su2double U_k = nVel[0]+nVel[1]+nVel[2]; - su2double vSquHlf = 0.5*vecDotVec3d(vel, vel); - su2double c = sqrt(gamma*pp/rrho); - su2double inv_kap_m1 = 1.0/kapm1; - - A[0][0] =-surfVeloc; - A[0][1] = nV[0]; - A[0][2] = nV[1]; - A[0][3] = nV[2]; - A[0][4] = 0.0; - - A[1][0] = -vel[0]*(nVel[1]+nVel[2])+nV[0]*(kapm1*vSquHlf-vel[0]*vel[0]); - A[1][1] = (2.-gamma)*nVel[0]+U_k-surfVeloc; - A[1][2] = vel[0]*nV[1]-kapm1*vel[1]*nV[0]; - A[1][3] = vel[0]*nV[2]-kapm1*vel[2]*nV[0]; - A[1][4] = kapm1*nV[0]; - - A[2][0] = -vel[1]*(nVel[0]+nVel[2])+nV[1]*(kapm1*vSquHlf-vel[1]*vel[1]); - A[2][1] = -kapm1*vel[0]*nV[1]+ vel[1]*nV[0]; - A[2][2] = (2.-gamma)*nVel[1]+U_k-surfVeloc; - A[2][3] = vel[1]*nV[2]-kapm1*vel[2]*nV[1]; - A[2][4] = kapm1*nV[1]; - - A[3][0] = -vel[2]*(nVel[0]+nVel[1])+nV[2]*(kapm1*vSquHlf-vel[2]*vel[2]); - A[3][1] = -kapm1*vel[0]*nV[2]+vel[2]*nV[0]; - A[3][2] = -kapm1*vel[1]*nV[2]+vel[2]*nV[1]; - A[3][3] = (2.-gamma)*nVel[2]+U_k-surfVeloc; - A[3][4] = kapm1*nV[2]; - - A[4][0] = U_k*((gamma-2.)*vSquHlf-c*c*inv_kap_m1); - A[4][1] = c*c*inv_kap_m1*nV[0]-kapm1*vel[0]*(nVel[1]+nVel[2])-(kapm1*vel[0]*vel[0]-vSquHlf)*nV[0]; - A[4][2] = c*c*inv_kap_m1*nV[1]-kapm1*vel[1]*(nVel[0]+nVel[2])-(kapm1*vel[1]*vel[1]-vSquHlf)*nV[1]; - A[4][3] = c*c*inv_kap_m1*nV[2]-kapm1*vel[2]*(nVel[0]+nVel[1])-(kapm1*vel[2]*vel[2]-vSquHlf)*nV[2]; - A[4][4] = gamma*U_k-surfVeloc; - -} - - -#endif - diff --git a/SU2_CFD/src/numerics/transition/CSourcePieceWise_TransLM.cpp b/SU2_CFD/src/numerics/transition/CSourcePieceWise_TransLM.cpp index 94d8289efa80..45652e2c7fdf 100644 --- a/SU2_CFD/src/numerics/transition/CSourcePieceWise_TransLM.cpp +++ b/SU2_CFD/src/numerics/transition/CSourcePieceWise_TransLM.cpp @@ -63,7 +63,8 @@ CSourcePieceWise_TransLM::CSourcePieceWise_TransLM(unsigned short val_nDim, unsi CSourcePieceWise_TransLM::~CSourcePieceWise_TransLM(void) { } -void CSourcePieceWise_TransLM::ComputeResidual_TransLM(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config, su2double &gamma_sep) { +void CSourcePieceWise_TransLM::ComputeResidual_TransLM(su2double *val_residual, su2double **val_Jacobian_i, + su2double **val_Jacobian_j, CConfig *config, su2double &gamma_sep) { //************************************************// // Please do not delete //SU2_CPP2C comment lines // //************************************************// From 1d6939e95c0a053555abae78f63cd3a4e1f678b6 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Sun, 26 Jan 2020 16:45:12 +0000 Subject: [PATCH 011/118] more cleaning --- SU2_CFD/include/numerics/CNumerics.hpp | 7 ------- SU2_CFD/src/numerics/CNumerics.cpp | 11 ----------- 2 files changed, 18 deletions(-) diff --git a/SU2_CFD/include/numerics/CNumerics.hpp b/SU2_CFD/include/numerics/CNumerics.hpp index 95649302c117..844ab21a4394 100644 --- a/SU2_CFD/include/numerics/CNumerics.hpp +++ b/SU2_CFD/include/numerics/CNumerics.hpp @@ -1228,12 +1228,6 @@ class CNumerics { const su2double Sensor_i, const su2double Sensor_j, su2double& Dissipation_ij, CConfig *config); - /*! - * \brief Setting the UQ framework usage - * \param[in] val_using_uq - */ - inline void SetUsing_UQ(bool val_using_uq) { using_uq = val_using_uq; } - /*! * \brief Decomposes the symmetric matrix A_ij, into eigenvectors and eigenvalues * \param[in] A_i: symmetric matrix to be decomposed @@ -1267,7 +1261,6 @@ class CNumerics { * \param[in] d: array that will hold the ordered eigenvalues * \param[in] e: supplemental data structure * \param[in] n: order of matrix V - */ static void tql2(su2double **V, su2double *d, su2double *e, unsigned short n); diff --git a/SU2_CFD/src/numerics/CNumerics.cpp b/SU2_CFD/src/numerics/CNumerics.cpp index 6f61a1506c1b..95742007fa2e 100644 --- a/SU2_CFD/src/numerics/CNumerics.cpp +++ b/SU2_CFD/src/numerics/CNumerics.cpp @@ -75,17 +75,6 @@ CNumerics::CNumerics(unsigned short val_nDim, unsigned short val_nVar, l = NULL; m = NULL; - MeanReynoldsStress = NULL; - MeanPerturbedRSM = NULL; - A_ij = NULL; - Eig_Vec = NULL; - New_Eig_Vec = NULL; - newA_ij = NULL; - Corners = NULL; - Eig_Val = NULL; - Barycentric_Coord = NULL; - New_Coord = NULL; - nDim = val_nDim; nVar = val_nVar; Gamma = config->GetGamma(); From 4be6a0bb9908d3e2450dcc7b405633c99bb2cc5c Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Sun, 26 Jan 2020 17:04:44 +0000 Subject: [PATCH 012/118] reduce number of includes --- SU2_CFD/include/numerics/CNumerics.hpp | 4 +--- SU2_CFD/src/numerics/CNumerics.cpp | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/SU2_CFD/include/numerics/CNumerics.hpp b/SU2_CFD/include/numerics/CNumerics.hpp index 844ab21a4394..6ca817e419c3 100644 --- a/SU2_CFD/include/numerics/CNumerics.hpp +++ b/SU2_CFD/include/numerics/CNumerics.hpp @@ -28,19 +28,17 @@ #pragma once -#include "../../../Common/include/mpi_structure.hpp" - #include #include #include #include #include "../../../Common/include/config_structure.hpp" -#include "../fluid_model.hpp" using namespace std; class CElement; +class CFluidModel; /*! * \class CNumerics diff --git a/SU2_CFD/src/numerics/CNumerics.cpp b/SU2_CFD/src/numerics/CNumerics.cpp index 95742007fa2e..795ddb37cfaa 100644 --- a/SU2_CFD/src/numerics/CNumerics.cpp +++ b/SU2_CFD/src/numerics/CNumerics.cpp @@ -27,6 +27,7 @@ #include "../../include/numerics/CNumerics.hpp" +#include "../../include/fluid_model.hpp" CNumerics::CNumerics(void) { From b56b39ce48ea69303a48375eda8257750195f4f7 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Mon, 27 Jan 2020 12:55:27 +0000 Subject: [PATCH 013/118] fix some indentation and comments in CConfig --- Common/include/config_structure.hpp | 67 ++++++++++++++--------------- Common/include/config_structure.inl | 1 - 2 files changed, 33 insertions(+), 35 deletions(-) diff --git a/Common/include/config_structure.hpp b/Common/include/config_structure.hpp index 193b77c79439..9f0945fcd8bd 100644 --- a/Common/include/config_structure.hpp +++ b/Common/include/config_structure.hpp @@ -8661,7 +8661,6 @@ class CConfig { */ su2double* Get_Electric_Field_Dir(void); - /*! * \brief Check if the user wants to apply the load as a ramp. * \return TRUE means that the load is to be applied as a ramp. @@ -8692,31 +8691,32 @@ class CConfig { * \return The pointer to the sine load values. */ su2double* GetLoad_Sine(void); - /*! - * \brief Get the kind of load transfer method we want to use for dynamic problems - * \note This value is obtained from the config file, and it is constant - * during the computation. - * \return Kind of transfer method for multiphysics problems - */ - unsigned short GetDynamic_LoadTransfer(void); + + /*! + * \brief Get the kind of load transfer method we want to use for dynamic problems + * \note This value is obtained from the config file, and it is constant + * during the computation. + * \return Kind of transfer method for multiphysics problems + */ + unsigned short GetDynamic_LoadTransfer(void); - /*! - * \brief Get the penalty weight value for the objective function. - * \return Penalty weight value for the reference geometry objective function. - */ - su2double GetRefGeom_Penalty(void); + /*! + * \brief Get the penalty weight value for the objective function. + * \return Penalty weight value for the reference geometry objective function. + */ + su2double GetRefGeom_Penalty(void); - /*! - * \brief Get the penalty weight value for the objective function. - * \return Penalty weight value for the reference geometry objective function. - */ - su2double GetTotalDV_Penalty(void); + /*! + * \brief Get the penalty weight value for the objective function. + * \return Penalty weight value for the reference geometry objective function. + */ + su2double GetTotalDV_Penalty(void); - /*! - * \brief Get whether a predictor is used for FSI applications. - * \return Bool: determines if predictor is used or not - */ - bool GetPredictor(void); + /*! + * \brief Get whether a predictor is used for FSI applications. + * \return Bool: determines if predictor is used or not + */ + bool GetPredictor(void); /*! * \brief Get the order of the predictor for FSI applications. @@ -9131,7 +9131,7 @@ class CConfig { */ unsigned short GetComm_Level(void); - /* + /*! * \brief Check if the mesh read supports multiple zones. * \return YES if multiple zones can be contained in the mesh file. */ @@ -9197,9 +9197,9 @@ class CConfig { */ unsigned short GetnScreenOutput(void); - /* - * \brief Get the screen output field iField - */ + /*! + * \brief Get the screen output field iField + */ string GetScreenOutput_Field(unsigned short iField); /*! @@ -9207,9 +9207,9 @@ class CConfig { */ unsigned short GetnHistoryOutput(void); - /* - * \brief Get the history output field iField - */ + /*! + * \brief Get the history output field iField + */ string GetHistoryOutput_Field(unsigned short iField); /*! @@ -9217,9 +9217,9 @@ class CConfig { */ unsigned short GetnVolumeOutput(void); - /* - * \brief Get the history output field iField - */ + /*! + * \brief Get the history output field iField + */ string GetVolumeOutput_Field(unsigned short iField); /*! @@ -9228,7 +9228,6 @@ class CConfig { * return Field name for monitoring convergence */ string GetConv_Field(unsigned short iField); - /*! * \brief Get functional that is going to be used to evaluate the convergence of the windowed time average of the unsteady problem. diff --git a/Common/include/config_structure.inl b/Common/include/config_structure.inl index 01c99f8d31f7..5446ecf2a59e 100644 --- a/Common/include/config_structure.inl +++ b/Common/include/config_structure.inl @@ -26,7 +26,6 @@ */ #pragma once -#include "config_structure.hpp" inline su2double CConfig::GetHTP_Axis(unsigned short val_index) { return HTP_Axis[val_index]; } From 37b36e39eaa8c3b099f76dffdd78e12b8b674344 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Mon, 27 Jan 2020 13:45:37 +0000 Subject: [PATCH 014/118] faster (much) compilation by disabling map definition when not needed --- Common/include/config_structure.hpp | 273 +++++----------------------- Common/include/option_structure.hpp | 186 +++++++++++++++++++ Common/src/config_structure.cpp | 266 +++++++++++++++++++++++++++ 3 files changed, 499 insertions(+), 226 deletions(-) diff --git a/Common/include/config_structure.hpp b/Common/include/config_structure.hpp index 9f0945fcd8bd..a3d5a0d65537 100644 --- a/Common/include/config_structure.hpp +++ b/Common/include/config_structure.hpp @@ -1168,269 +1168,90 @@ class CConfig { /*!< \brief addDoubleOption creates a config file parser for an option with the given name whose value can be represented by a su2double.*/ - void addDoubleOption(const string name, su2double & option_field, su2double default_value) { - // Check if the key is already in the map. If this fails, it is coder error - // and not user error, so throw. - assert(option_map.find(name) == option_map.end()); - - // Add this option to the list of all the options - all_options.insert(pair(name, true)); - - // Create the parser for a su2double option with a reference to the option_field and the desired - // default value. This will take the string in the config file, convert it to a su2double, and - // place that su2double in the memory location specified by the reference. - COptionBase* val = new COptionDouble(name, option_field, default_value); - - // Create an association between the option name ("CFL") and the parser generated above. - // During configuration, the parsing script will get the option name, and use this map - // to find how to parse that option. - option_map.insert(pair(name, val)); - } - - void addStringOption(const string name, string & option_field, string default_value) { - assert(option_map.find(name) == option_map.end()); - all_options.insert(pair(name, true)); - COptionBase* val = new COptionString(name, option_field, default_value); - option_map.insert(pair(name, val)); - } - - void addIntegerOption(const string name, int & option_field, int default_value) { - assert(option_map.find(name) == option_map.end()); - all_options.insert(pair(name, true)); - COptionBase* val = new COptionInt(name, option_field, default_value); - option_map.insert(pair(name, val)); - } - - void addUnsignedLongOption(const string name, unsigned long & option_field, unsigned long default_value) { - assert(option_map.find(name) == option_map.end()); - all_options.insert(pair(name, true)); - COptionBase* val = new COptionULong(name, option_field, default_value); - option_map.insert(pair(name, val)); - } - - void addUnsignedShortOption(const string name, unsigned short & option_field, unsigned short default_value) { - assert(option_map.find(name) == option_map.end()); - all_options.insert(pair(name, true)); - COptionBase* val = new COptionUShort(name, option_field, default_value); - option_map.insert(pair(name, val)); - } - - void addLongOption(const string name, long & option_field, long default_value) { - assert(option_map.find(name) == option_map.end()); - all_options.insert(pair(name, true)); - COptionBase* val = new COptionLong(name, option_field, default_value); - option_map.insert(pair(name, val)); - } - - void addBoolOption(const string name, bool & option_field, bool default_value) { - assert(option_map.find(name) == option_map.end()); - all_options.insert(pair(name, true)); - COptionBase* val = new COptionBool(name, option_field, default_value); - option_map.insert(pair(name, val)); - } + void addDoubleOption(const string name, su2double & option_field, su2double default_value); + + void addStringOption(const string name, string & option_field, string default_value); + + void addIntegerOption(const string name, int & option_field, int default_value); + + void addUnsignedLongOption(const string name, unsigned long & option_field, unsigned long default_value); + + void addUnsignedShortOption(const string name, unsigned short & option_field, unsigned short default_value); + + void addLongOption(const string name, long & option_field, long default_value); + + void addBoolOption(const string name, bool & option_field, bool default_value); // enum types work differently than all of the others because there are a small number of valid // string entries for the type. One must also provide a list of all the valid strings of that type. template - void addEnumOption(const string name, unsigned short & option_field, const map & enum_map, Tenum default_value) { - assert(option_map.find(name) == option_map.end()); - all_options.insert(pair(name, true)); - COptionBase* val = new COptionEnum(name, enum_map, option_field, default_value); - option_map.insert(pair(name, val)); - return; - } - + void addEnumOption(const string name, unsigned short & option_field, const map & enum_map, Tenum default_value); // input_size is the number of options read in from the config file template - void addEnumListOption(const string name, unsigned short & input_size, unsigned short * & option_field, const map & enum_map) { - input_size = 0; - assert(option_map.find(name) == option_map.end()); - all_options.insert(pair(name, true)); - COptionBase* val = new COptionEnumList(name, enum_map, option_field, input_size); - option_map.insert( pair(name, val) ); - } - - void addDoubleArrayOption(const string name, const int size, su2double * & option_field, su2double * default_value) { - - // su2double * def = new su2double [size]; - // for (int i = 0; i < size; i++) { - // def[i] = default_value[i]; - // } - - assert(option_map.find(name) == option_map.end()); - all_options.insert(pair(name, true)); - COptionBase* val = new COptionDoubleArray(name, size, option_field, default_value); - option_map.insert(pair(name, val)); - } - - void addDoubleListOption(const string name, unsigned short & size, su2double * & option_field) { - assert(option_map.find(name) == option_map.end()); - all_options.insert(pair(name, true)); - COptionBase* val = new COptionDoubleList(name, size, option_field); - option_map.insert(pair(name, val)); - } - - void addShortListOption(const string name, unsigned short & size, short * & option_field) { - assert(option_map.find(name) == option_map.end()); - all_options.insert(pair(name, true)); - COptionBase* val = new COptionShortList(name, size, option_field); - option_map.insert(pair(name, val)); - } - - void addUShortListOption(const string name, unsigned short & size, unsigned short * & option_field) { - assert(option_map.find(name) == option_map.end()); - all_options.insert(pair(name, true)); - COptionBase* val = new COptionUShortList(name, size, option_field); - option_map.insert(pair(name, val)); - } - - void addStringListOption(const string name, unsigned short & num_marker, string* & option_field) { - assert(option_map.find(name) == option_map.end()); - all_options.insert(pair(name, true)); - COptionBase* val = new COptionStringList(name, num_marker, option_field); - option_map.insert(pair(name, val)); - } - - void addConvectOption(const string name, unsigned short & space_field, unsigned short & centered_field, unsigned short & upwind_field) { - assert(option_map.find(name) == option_map.end()); - all_options.insert(pair(name, true)); - COptionBase* val = new COptionConvect(name, space_field, centered_field, upwind_field); - option_map.insert(pair(name, val)); - } - - void addConvectFEMOption(const string name, unsigned short & space_field, unsigned short & fem_field) { - assert(option_map.find(name) == option_map.end()); - all_options.insert(pair(name, true)); - COptionBase* val = new COptionFEMConvect(name, space_field, fem_field); - option_map.insert(pair(name, val)); - } + void addEnumListOption(const string name, unsigned short & input_size, unsigned short * & option_field, const map & enum_map); + + void addDoubleArrayOption(const string name, const int size, su2double * & option_field, su2double * default_value); + + void addDoubleListOption(const string name, unsigned short & size, su2double * & option_field); + + void addShortListOption(const string name, unsigned short & size, short * & option_field); + + void addUShortListOption(const string name, unsigned short & size, unsigned short * & option_field); + + void addStringListOption(const string name, unsigned short & num_marker, string* & option_field); + + void addConvectOption(const string name, unsigned short & space_field, unsigned short & centered_field, unsigned short & upwind_field); + + void addConvectFEMOption(const string name, unsigned short & space_field, unsigned short & fem_field); void addMathProblemOption(const string name, bool & ContinuousAdjoint, const bool & ContinuousAdjoint_default, bool & DiscreteAdjoint, const bool & DiscreteAdjoint_default, - bool & Restart_Flow, const bool & Restart_Flow_default) { - assert(option_map.find(name) == option_map.end()); - all_options.insert(pair(name, true)); - COptionBase* val = new COptionMathProblem(name, ContinuousAdjoint, ContinuousAdjoint_default, DiscreteAdjoint, DiscreteAdjoint_default, Restart_Flow, Restart_Flow_default); - option_map.insert(pair(name, val)); - } + bool & Restart_Flow, const bool & Restart_Flow_default); void addDVParamOption(const string name, unsigned short & nDV_field, su2double** & paramDV, string* & FFDTag, - unsigned short* & design_variable) { - assert(option_map.find(name) == option_map.end()); - all_options.insert(pair(name, true)); - COptionBase* val = new COptionDVParam(name, nDV_field, paramDV, FFDTag, design_variable); - option_map.insert(pair(name, val)); - } + unsigned short* & design_variable); void addDVValueOption(const string name, unsigned short* & nDVValue_field, su2double** & valueDV, unsigned short & nDV_field, su2double** & paramDV, - unsigned short* & design_variable) { - assert(option_map.find(name) == option_map.end()); - all_options.insert(pair(name, true)); - COptionBase* val = new COptionDVValue(name, nDVValue_field, valueDV, nDV_field, paramDV, design_variable); - option_map.insert(pair(name, val)); - } - - void addFFDDefOption(const string name, unsigned short & nFFD_field, su2double** & coordFFD, string* & FFDTag) { - assert(option_map.find(name) == option_map.end()); - all_options.insert(pair(name, true)); - COptionBase* val = new COptionFFDDef(name, nFFD_field, coordFFD, FFDTag); - option_map.insert(pair(name, val)); - } - - void addFFDDegreeOption(const string name, unsigned short & nFFD_field, unsigned short** & degreeFFD) { - assert(option_map.find(name) == option_map.end()); - all_options.insert(pair(name, true)); - COptionBase* val = new COptionFFDDegree(name, nFFD_field, degreeFFD); - option_map.insert(pair(name, val)); - } + unsigned short* & design_variable); + + void addFFDDefOption(const string name, unsigned short & nFFD_field, su2double** & coordFFD, string* & FFDTag); + + void addFFDDegreeOption(const string name, unsigned short & nFFD_field, unsigned short** & degreeFFD); void addStringDoubleListOption(const string name, unsigned short & list_size, string * & string_field, - su2double* & double_field) { - assert(option_map.find(name) == option_map.end()); - all_options.insert(pair(name, true)); - COptionBase* val = new COptionStringDoubleList(name, list_size, string_field, double_field); - option_map.insert(pair(name, val)); - } + su2double* & double_field); void addInletOption(const string name, unsigned short & nMarker_Inlet, string * & Marker_Inlet, - su2double* & Ttotal, su2double* & Ptotal, su2double** & FlowDir) { - assert(option_map.find(name) == option_map.end()); - all_options.insert(pair(name, true)); - COptionBase* val = new COptionInlet(name, nMarker_Inlet, Marker_Inlet, Ttotal, Ptotal, FlowDir); - option_map.insert(pair(name, val)); - } + su2double* & Ttotal, su2double* & Ptotal, su2double** & FlowDir); template void addRiemannOption(const string name, unsigned short & nMarker_Riemann, string * & Marker_Riemann, unsigned short* & option_field, const map & enum_map, - su2double* & var1, su2double* & var2, su2double** & FlowDir) { - assert(option_map.find(name) == option_map.end()); - all_options.insert(pair(name, true)); - COptionBase* val = new COptionRiemann(name, nMarker_Riemann, Marker_Riemann, option_field, enum_map, var1, var2, FlowDir); - option_map.insert(pair(name, val)); - } + su2double* & var1, su2double* & var2, su2double** & FlowDir); template void addGilesOption(const string name, unsigned short & nMarker_Giles, string * & Marker_Giles, unsigned short* & option_field, const map & enum_map, - su2double* & var1, su2double* & var2, su2double** & FlowDir, su2double* & relaxfactor1, su2double* & relaxfactor2) { - assert(option_map.find(name) == option_map.end()); - all_options.insert(pair(name, true)); - COptionBase* val = new COptionGiles(name, nMarker_Giles, Marker_Giles, option_field, enum_map, var1, var2, FlowDir, relaxfactor1, relaxfactor2); - option_map.insert(pair(name, val)); - } + su2double* & var1, su2double* & var2, su2double** & FlowDir, su2double* & relaxfactor1, su2double* & relaxfactor2); void addExhaustOption(const string name, unsigned short & nMarker_Exhaust, string * & Marker_Exhaust, - su2double* & Ttotal, su2double* & Ptotal) { - assert(option_map.find(name) == option_map.end()); - all_options.insert(pair(name, true)); - COptionBase* val = new COptionExhaust(name, nMarker_Exhaust, Marker_Exhaust, Ttotal, Ptotal); - option_map.insert(pair(name, val)); - } + su2double* & Ttotal, su2double* & Ptotal); void addPeriodicOption(const string & name, unsigned short & nMarker_PerBound, string* & Marker_PerBound, string* & Marker_PerDonor, - su2double** & RotCenter, su2double** & RotAngles, su2double** & Translation) { - assert(option_map.find(name) == option_map.end()); - all_options.insert(pair(name, true)); - COptionBase* val = new COptionPeriodic(name, nMarker_PerBound, Marker_PerBound, Marker_PerDonor, RotCenter, RotAngles, Translation); - option_map.insert(pair(name, val)); - } + su2double** & RotCenter, su2double** & RotAngles, su2double** & Translation); void addTurboPerfOption(const string & name, unsigned short & nMarker_TurboPerf, - string* & Marker_TurboBoundIn, string* & Marker_TurboBoundOut) { - assert(option_map.find(name) == option_map.end()); - all_options.insert(pair(name, true)); - COptionBase* val = new COptionTurboPerformance(name, nMarker_TurboPerf, Marker_TurboBoundIn, Marker_TurboBoundOut); - option_map.insert(pair(name, val)); - } + string* & Marker_TurboBoundIn, string* & Marker_TurboBoundOut); void addActDiskOption(const string & name, unsigned short & nMarker_ActDiskInlet, unsigned short & nMarker_ActDiskOutlet, string* & Marker_ActDiskInlet, string* & Marker_ActDiskOutlet, - su2double** & ActDisk_PressJump, su2double** & ActDisk_TempJump, su2double** & ActDisk_Omega) { - assert(option_map.find(name) == option_map.end()); - all_options.insert(pair(name, true)); - COptionBase* val = new COptionActDisk(name, - nMarker_ActDiskInlet, nMarker_ActDiskOutlet, Marker_ActDiskInlet, Marker_ActDiskOutlet, - ActDisk_PressJump, ActDisk_TempJump, ActDisk_Omega); - option_map.insert(pair(name, val)); - } + su2double** & ActDisk_PressJump, su2double** & ActDisk_TempJump, su2double** & ActDisk_Omega); void addWallFunctionOption(const string &name, unsigned short &list_size, string* &string_field, unsigned short* &val_Kind_WF, - unsigned short** &val_IntInfo_WF, su2double** &val_DoubleInfo_WF) { - assert(option_map.find(name) == option_map.end()); - all_options.insert(pair(name, true)); - COptionBase* val = new COptionWallFunction(name, list_size, string_field, val_Kind_WF, - val_IntInfo_WF, val_DoubleInfo_WF); - option_map.insert(pair(name, val)); - } - - void addPythonOption(const string name) { - assert(option_map.find(name) == option_map.end()); - all_options.insert(pair(name, true)); - COptionBase* val = new COptionPython(name); - option_map.insert(pair(name, val)); - } + unsigned short** &val_IntInfo_WF, su2double** &val_DoubleInfo_WF); + + void addPythonOption(const string name); public: diff --git a/Common/include/option_structure.hpp b/Common/include/option_structure.hpp index 56bff1bd7e37..3a96ec319870 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -174,9 +174,11 @@ enum AVERAGE_TYPE { AVERAGE_AREA = 1, /*!< \brief Area-weighted average. */ AVERAGE_MASSFLUX = 2 /*!< \brief Mass-flux weighted average. */ }; +#ifdef ENABLE_MAPS static const map Average_Map = CCreateMap ("AREA", AVERAGE_AREA) ("MASSFLUX", AVERAGE_MASSFLUX); +#endif /*! * \brief different solver types for the CFD component @@ -214,6 +216,7 @@ enum ENUM_SOLVER { MULTIPHYSICS = 30 }; /* BEGIN_CONFIG_ENUMS */ +#ifdef ENABLE_MAPS static const map Solver_Map = CCreateMap ("NONE", NO_SOLVER) ("EULER", EULER) @@ -245,6 +248,7 @@ static const map Solver_Map = CCreateMap Multizone_Map = CCreateMap ("BLOCK_GAUSS_SEIDEL", MZ_BLOCK_GAUSS_SEIDEL) ("BLOCK_JACOBI", MZ_BLOCK_JACOBI); +#endif /*! * \brief types of fluid solvers @@ -267,11 +273,13 @@ enum ENUM_FSI_FLUID_PROBLEM { NAVIER_STOKES_FFSI = 2, /*!< \brief NS equations for the FSI problem */ RANS_FFSI = 3 /*!< \brief RANS equations for the FSI problem */ }; +#ifdef ENABLE_MAPS static const map FSI_Fluid_Solver_Map = CCreateMap ("NONE", NO_SOLVER_FFSI) ("EULER", EULER_FFSI) ("NAVIER_STOKES", NAVIER_STOKES_FFSI) ("RANS", RANS_FFSI); +#endif /*! * \brief types of structural solvers @@ -280,9 +288,11 @@ enum ENUM_FSI_STRUC_PROBLEM { NO_SOLVER_SFSI = 0, /*!< \brief Definition of no solver. */ FEM_ELASTICITY_SFSI = 9, /*!< \brief Nonlinear elasticity equations for the FSI problem */ }; +#ifdef ENABLE_MAPS static const map FSI_Struc_Solver_Map = CCreateMap ("NONE", NO_SOLVER_SFSI) ("ELASTICITY", FEM_ELASTICITY_SFSI); +#endif /*! * \brief Material geometric conditions @@ -291,9 +301,11 @@ enum ENUM_STRUCT_SOLVER { SMALL_DEFORMATIONS = 0, /*!< \brief Definition of linear elastic material. */ LARGE_DEFORMATIONS = 1, /*!< \brief Definition of Neo-Hookean material. */ }; +#ifdef ENABLE_MAPS static const map Struct_Map = CCreateMap ("SMALL_DEFORMATIONS", SMALL_DEFORMATIONS) ("LARGE_DEFORMATIONS", LARGE_DEFORMATIONS); +#endif /*! * \brief Material model @@ -304,11 +316,13 @@ enum ENUM_MATERIAL_MODEL { KNOWLES = 2, /*!< \brief Definition of Knowles stored-energy potential */ IDEAL_DE = 3 /*!< \brief Definition of ideal Dielectric Elastomer */ }; +#ifdef ENABLE_MAPS static const map Material_Map = CCreateMap ("LINEAR_ELASTIC", LINEAR_ELASTIC) ("NEO_HOOKEAN", NEO_HOOKEAN) ("KNOWLES", KNOWLES) ("IDEAL_DE", IDEAL_DE); +#endif /*! * \brief Material compressibility @@ -317,9 +331,11 @@ enum ENUM_MAT_COMPRESS { COMPRESSIBLE_MAT = 0, /*!< \brief Definition of compressible material. */ NEARLY_INCOMPRESSIBLE_MAT = 1, /*!< \brief Definition of nearly incompressible material. */ }; +#ifdef ENABLE_MAPS static const map MatComp_Map = CCreateMap ("COMPRESSIBLE", COMPRESSIBLE_MAT) ("NEARLY_INCOMPRESSIBLE", NEARLY_INCOMPRESSIBLE_MAT); +#endif /*! * \brief types of interpolators @@ -330,11 +346,13 @@ enum ENUM_INTERPOLATOR { WEIGHTED_AVERAGE = 3, /*!< \brief Sliding Mesh Approach E. Rinaldi 2015 */ RADIAL_BASIS_FUNCTION= 4, /*!< \brief Radial basis function interpolation. */ }; +#ifdef ENABLE_MAPS static const map Interpolator_Map = CCreateMap ("NEAREST_NEIGHBOR", NEAREST_NEIGHBOR) ("ISOPARAMETRIC", ISOPARAMETRIC) ("WEIGHTED_AVERAGE", WEIGHTED_AVERAGE) ("RADIAL_BASIS_FUNCTION", RADIAL_BASIS_FUNCTION); +#endif /*! * \brief types of radial basis functions @@ -346,12 +364,14 @@ enum ENUM_RADIALBASIS { THIN_PLATE_SPLINE = 3, /*!< \brief Thin plate spline. */ MULTI_QUADRIC = 4, /*!< \brief Multi quartic biharmonic spline. */ }; +#ifdef ENABLE_MAPS static const map RadialBasisFunction_Map = CCreateMap ("WENDLAND_C2", WENDLAND_C2) ("INV_MULTI_QUADRIC", INV_MULTI_QUADRIC) ("GAUSSIAN", GAUSSIAN) ("THIN_PLATE_SPLINE", THIN_PLATE_SPLINE) ("MULTI_QUADRIC", MULTI_QUADRIC); +#endif /*! * \brief types of (coupling) transfers between distinct physical zones @@ -393,6 +413,7 @@ enum ENUM_KIND_NONDIM { INITIAL_VALUES = 4, /*!< \brief Non-dimensional incompressible simulation based on intial values for external flow. */ REFERENCE_VALUES = 5 /*!< \brief Non-dimensional incompressible simulation based on custom reference values. */ }; +#ifdef ENABLE_MAPS static const map NonDim_Map = CCreateMap ("DIMENSIONAL", DIMENSIONAL) ("FREESTREAM_PRESS_EQ_ONE", FREESTREAM_PRESS_EQ_ONE) @@ -400,6 +421,7 @@ static const map NonDim_Map = CCreateMap Measurements_Map = CCreateMap ("SI", SI) ("US", US); +#endif /*! * \brief different types of systems @@ -482,10 +506,12 @@ enum ENUM_MATH_PROBLEM { CONTINUOUS_ADJOINT = 1, /*!< \brief Continuous adjoint problem */ DISCRETE_ADJOINT = 2 /*!< \brief AD-based discrete adjoint problem. */ }; +#ifdef ENABLE_MAPS static const map Math_Problem_Map = CCreateMap ("DIRECT", DIRECT) ("CONTINUOUS_ADJOINT", CONTINUOUS_ADJOINT) ("DISCRETE_ADJOINT", DISCRETE_ADJOINT); +#endif /*! * \brief types of spatial discretizations @@ -496,11 +522,13 @@ enum ENUM_SPACE { SPACE_UPWIND = 2, /*!< \brief Upwind convective numerical method. */ FINITE_ELEMENT = 3 /*!< \brief Finite element convective numerical method. */ }; +#ifdef ENABLE_MAPS static const map Space_Map = CCreateMap ("NONE", NO_CONVECTIVE) ("SPACE_CENTERED", SPACE_CENTERED) ("SPACE_UPWIND", SPACE_UPWIND) ("FINITE_ELEMENT", FINITE_ELEMENT); +#endif /*! * \brief types of fluid model @@ -514,6 +542,7 @@ enum ENUM_FLUIDMODEL { INC_IDEAL_GAS = 5, /*!< \brief Incompressible ideal gas model. */ INC_IDEAL_GAS_POLY = 6 /*!< \brief Inc. ideal gas, polynomial gas model. */ }; +#ifdef ENABLE_MAPS static const map FluidModel_Map = CCreateMap ("STANDARD_AIR", STANDARD_AIR) ("IDEAL_GAS", IDEAL_GAS) @@ -522,6 +551,7 @@ static const map FluidModel_Map = CCreateMap DensityModel_Map = CCreateMap ("CONSTANT", CONSTANT) ("BOUSSINESQ", BOUSSINESQ) ("VARIABLE", VARIABLE); +#endif /*! * \brief types of initialization option @@ -543,9 +575,11 @@ enum ENUM_INIT_OPTION { REYNOLDS = 0, /*!< \brief Reynold's number initalization. */ TD_CONDITIONS = 1 /*!< \brief Total conditions initalization. */ }; +#ifdef ENABLE_MAPS static const map InitOption_Map = CCreateMap ("REYNOLDS", REYNOLDS) ("TD_CONDITIONS", TD_CONDITIONS); +#endif /*! * \brief types of initialization option @@ -554,9 +588,11 @@ enum ENUM_FREESTREAM_OPTION { TEMPERATURE_FS = 0, /*!< \brief Temperature initialization. */ DENSITY_FS = 1 /*!< \brief Density initalization. */ }; +#ifdef ENABLE_MAPS static const map FreeStreamOption_Map = CCreateMap ("TEMPERATURE_FS", TEMPERATURE_FS) ("DENSITY_FS", DENSITY_FS); +#endif /*! * \brief types of viscosity model @@ -566,10 +602,12 @@ enum ENUM_VISCOSITYMODEL { SUTHERLAND = 1, /*!< \brief Sutherlands Law viscosity. */ POLYNOMIAL_VISCOSITY = 2 /*!< \brief Polynomial viscosity. */ }; +#ifdef ENABLE_MAPS static const map ViscosityModel_Map = CCreateMap ("CONSTANT_VISCOSITY", CONSTANT_VISCOSITY) ("SUTHERLAND", SUTHERLAND) ("POLYNOMIAL_VISCOSITY", POLYNOMIAL_VISCOSITY); +#endif /*! * \brief types of thermal conductivity model @@ -579,10 +617,12 @@ enum ENUM_CONDUCTIVITYMODEL { CONSTANT_PRANDTL = 1, /*!< \brief Constant Prandtl number. */ POLYNOMIAL_CONDUCTIVITY = 2 /*!< \brief Polynomial thermal conductivity. */ }; +#ifdef ENABLE_MAPS static const map ConductivityModel_Map = CCreateMap ("CONSTANT_CONDUCTIVITY", CONSTANT_CONDUCTIVITY) ("CONSTANT_PRANDTL", CONSTANT_PRANDTL) ("POLYNOMIAL_CONDUCTIVITY", POLYNOMIAL_CONDUCTIVITY); +#endif /*! * \brief types of turbulent thermal conductivity model @@ -591,9 +631,11 @@ enum ENUM_CONDUCTIVITYMODEL_TURB { NO_CONDUCTIVITY_TURB = 0, /*!< \brief No turbulent contribution to the effective thermal conductivity for RANS. */ CONSTANT_PRANDTL_TURB = 1 /*!< \brief Include contribution to effective conductivity using constant turbulent Prandtl number for RANS. */ }; +#ifdef ENABLE_MAPS static const map TurbConductivityModel_Map = CCreateMap ("NONE", NO_CONDUCTIVITY_TURB) ("CONSTANT_PRANDTL_TURB", CONSTANT_PRANDTL_TURB); +#endif /*! * \brief types of unsteady mesh motion @@ -607,6 +649,7 @@ enum ENUM_GRIDMOVEMENT { GUST = 12, /*!< \brief Simulation on a static mesh with a gust. */ MOVING_HTP = 13, /*!< \brief Simulation with moving HTP (rotation). */ }; +#ifdef ENABLE_MAPS static const map GridMovement_Map = CCreateMap ("NONE", NO_MOVEMENT) ("RIGID_MOTION", RIGID_MOTION) @@ -615,6 +658,7 @@ static const map GridMovement_Map = CCreateMap SurfaceMovement_Map = CCreateMap ("DEFORMING", DEFORMING) ("MOVING_WALL", MOVING_WALL) @@ -635,6 +680,7 @@ static const map SurfaceMovement_Map = CCreateMap< ("FLUID_STRUCTURE", FLUID_STRUCTURE) ("EXTERNAL", EXTERNAL) ("EXTERNAL_ROTATION", EXTERNAL_ROTATION); +#endif /*! * \brief type of wind gusts @@ -647,6 +693,7 @@ enum ENUM_GUST_TYPE { VORTEX = 4, /*!< \brief A gust made from vortices */ EOG = 5 /*!< \brief An extreme operating gust */ }; +#ifdef ENABLE_MAPS static const map Gust_Type_Map = CCreateMap ("NONE", NO_GUST) ("TOP_HAT", TOP_HAT) @@ -654,6 +701,7 @@ static const map Gust_Type_Map = CCreateMap Gust_Dir_Map = CCreateMap ("X_DIR", X_DIR) ("Y_DIR", Y_DIR); +#endif // If you add to ENUM_CENTERED, you must also add the option to ENUM_CONVECTIVE /*! @@ -676,11 +726,13 @@ enum ENUM_CENTERED { LAX = 2, /*!< \brief Lax-Friedrich centered numerical method. */ JST_KE = 4 /*!< \brief Kinetic Energy preserving Jameson-Smith-Turkel centered numerical method. */ }; +#ifdef ENABLE_MAPS static const map Centered_Map = CCreateMap ("NONE", NO_CENTERED) ("JST", JST) ("JST_KE", JST_KE) ("LAX-FRIEDRICH", LAX); +#endif // If you add to ENUM_UPWIND, you must also add the option to ENUM_CONVECTIVE @@ -707,6 +759,7 @@ enum ENUM_UPWIND { AUSMPLUSUP = 16, /*!< \brief AUSM+ -up numerical method (All Speed) */ AUSMPLUSUP2 = 17 /*!< \brief AUSM+ -up2 numerical method (All Speed) */ }; +#ifdef ENABLE_MAPS static const map Upwind_Map = CCreateMap ("NONE", NO_UPWIND) ("ROE", ROE) @@ -726,6 +779,7 @@ static const map Upwind_Map = CCreateMap FEM_Map = CCreateMap ("NONE", NO_FEM) ("DG", DG); +#endif /*! * \brief types of shock capturing method in Discontinuous Galerkin numerical method. @@ -745,9 +801,11 @@ enum ENUM_SHOCK_CAPTURING_DG { NO_SHOCK_CAPTURING = 0, /*!< \brief Shock capturing is not used. */ PERSSON = 1 /*!< \brief Per-Olof Persson's sub-cell shock capturing method. */ }; +#ifdef ENABLE_MAPS static const map ShockCapturingDG_Map = CCreateMap ("NONE", NO_SHOCK_CAPTURING) ("PERSSON", PERSSON); +#endif /*! * \brief types of matrix coloring to compute a sparse Jacobian matrix. @@ -756,9 +814,11 @@ enum ENUM_MATRIX_COLORING { GREEDY_COLORING = 0, /*!< \brief Greedy type of algorithm for the coloring. */ NATURAL_COLORING = 1 /*!< \brief One color for every DOF, very slow. Only to be used for debugging. */ }; +#ifdef ENABLE_MAPS static const map MatrixColoring_Map = CCreateMap ("GREEDY_COLORING", GREEDY_COLORING) ("NATURAL_COLORING", NATURAL_COLORING); +#endif /*! * \brief types of slope limiters @@ -772,6 +832,7 @@ enum ENUM_LIMITER { SHARP_EDGES = 5, /*!< \brief Slope limiter using sharp edges. */ WALL_DISTANCE = 6 /*!< \brief Slope limiter using wall distance. */ }; +#ifdef ENABLE_MAPS static const map Limiter_Map = CCreateMap ("NONE", NO_LIMITER) ("VENKATAKRISHNAN", VENKATAKRISHNAN) @@ -780,6 +841,7 @@ static const map Limiter_Map = CCreateMap Turb_Model_Map = CCreateMap ("NONE", NO_TURB_MODEL) ("SA", SA) @@ -803,6 +866,7 @@ static const map Turb_Model_Map = CCreateMap Trans_Model_Map = CCreateMap ("NONE", NO_TRANS_MODEL) ("LM", LM) ("BC", BC); //BAS-CAKMAKCIOGLU +#endif /*! * \brief types of subgrid scale models @@ -827,12 +893,14 @@ enum ENUM_SGS_MODEL { WALE = 3, /*!< \brief Wall-Adapting Local Eddy-viscosity SGS model. */ VREMAN = 4 /*!< \brief Vreman SGS model. */ }; +#ifdef ENABLE_MAPS static const map SGS_Model_Map = CCreateMap ("NONE", NO_SGS_MODEL) ("IMPLICIT_LES", IMPLICIT_LES) ("SMAGORINSKY", SMAGORINSKY) ("WALE", WALE) ("VREMAN", VREMAN); +#endif /*! @@ -845,11 +913,13 @@ enum WINDOW_FUNCTION { BUMP = 3, /*!< \brief bump type weight function (exponential order of convergence) */ }; +#ifdef ENABLE_MAPS static const map Window_Map = CCreateMap ("SQUARE", SQUARE) ("HANN", HANN) ("HANN_SQUARE", HANN_SQUARE) ("BUMP", BUMP); +#endif /*! * \brief types of hybrid RANS/LES models @@ -861,12 +931,14 @@ enum ENUM_HYBRIDRANSLES { SA_ZDES = 3, /*!< \brief Kind of Hybrid RANS/LES (SA - Delayed DES (DDES) with Vorticity based SGS like Zonal DES). */ SA_EDDES = 4 /*!< \brief Kind of Hybrid RANS/LES (SA - Delayed DES (DDES) with Shear Layer Adapted SGS: Enhanced DDES). */ }; +#ifdef ENABLE_MAPS static const map HybridRANSLES_Map = CCreateMap ("NONE", NO_HYBRIDRANSLES) ("SA_DES", SA_DES) ("SA_DDES", SA_DDES) ("SA_ZDES", SA_ZDES) ("SA_EDDES", SA_EDDES); +#endif /*! * \brief types of Roe Low Dissipation Schemes @@ -878,12 +950,14 @@ enum ENUM_ROELOWDISS { NTS_DUCROS = 3, /*!< \brief Numerical Blending of Travin and Shur + Ducros' Shock Sensor. */ FD_DUCROS = 4 /*!< \brief Numerical Blending based on DDES's F_d function + Ducros' Shock Sensor */ }; +#ifdef ENABLE_MAPS static const map RoeLowDiss_Map = CCreateMap ("NONE", NO_ROELOWDISS) ("FD", FD) ("NTS", NTS) ("NTS_DUCROS", NTS_DUCROS) ("FD_DUCROS", FD_DUCROS); +#endif /*! * \brief types of wall functions. @@ -897,6 +971,7 @@ enum ENUM_WALL_FUNCTIONS { NONEQUILIBRIUM_WALL_MODEL = 5, /*!< \brief Non-equilibrium wall model for LES. */ LOGARITHMIC_WALL_MODEL = 6 /*!< \brief Logarithmic law-of-the-wall model for LES. */ }; +#ifdef ENABLE_MAPS static const map Wall_Functions_Map = CCreateMap ("NO_WALL_FUNCTION", NO_WALL_FUNCTION) ("STANDARD_WALL_FUNCTION", STANDARD_WALL_FUNCTION) @@ -905,6 +980,7 @@ static const map Wall_Functions_Map = CCreateMap Time_Int_Map = CCreateMap ("RUNGE-KUTTA_EXPLICIT", RUNGE_KUTTA_EXPLICIT) ("EULER_EXPLICIT", EULER_EXPLICIT) ("EULER_IMPLICIT", EULER_IMPLICIT) ("CLASSICAL_RK4_EXPLICIT", CLASSICAL_RK4_EXPLICIT) ("ADER_DG", ADER_DG); +#endif /*! * \brief type of predictor for the ADER-DG time integration scheme. @@ -930,9 +1008,11 @@ enum ENUM_ADER_PREDICTOR { ADER_ALIASED_PREDICTOR = 1, /*!< \brief Aliased predictor, easiest to do. */ ADER_NON_ALIASED_PREDICTOR = 2 /*!< \brief Non-aliased predictor. Consistent, but more difficult. */ }; +#ifdef ENABLE_MAPS static const map Ader_Predictor_Map = CCreateMap ("ADER_ALIASED_PREDICTOR", ADER_ALIASED_PREDICTOR) ("ADER_NON_ALIASED_PREDICTOR", ADER_NON_ALIASED_PREDICTOR); +#endif /*! * \brief type of heat timestep calculation @@ -943,11 +1023,13 @@ enum ENUM_HEAT_TIMESTEP { VISCOUS = 3, /*!< \brief Local time stepping based on viscous spectral radius.*/ BYFLOW = 4, /*!< \brief Unsing the mean solvers time step. */ }; +#ifdef ENABLE_MAPS static const map Heat_TimeStep_Map = CCreateMap ("LOCAL", MINIMUM) ("CONVECTIVE", CONVECTIVE) ("VISCOUS", VISCOUS) ("BYFLOW", BYFLOW); +#endif /*! * \brief type of time integration schemes @@ -957,10 +1039,12 @@ enum ENUM_TIME_INT_FEA { NEWMARK_IMPLICIT = 2, /*!< \brief Implicit Newmark integration definition. */ GENERALIZED_ALPHA = 3 /*!< \brief Support for implementing another implicit method. */ }; +#ifdef ENABLE_MAPS static const map Time_Int_Map_FEA = CCreateMap ("CD_EXPLICIT", CD_EXPLICIT) ("NEWMARK_IMPLICIT", NEWMARK_IMPLICIT) ("GENERALIZED_ALPHA", GENERALIZED_ALPHA); +#endif /*! * \brief type of time integration schemes @@ -969,9 +1053,11 @@ enum ENUM_SPACE_ITE_FEA { NEWTON_RAPHSON = 1, /*!< \brief Full Newton-Rapshon method. */ MODIFIED_NEWTON_RAPHSON = 2 /*!< \brief Modified Newton-Raphson method. */ }; +#ifdef ENABLE_MAPS static const map Space_Ite_Map_FEA = CCreateMap ("NEWTON_RAPHSON", NEWTON_RAPHSON) ("MODIFIED_NEWTON_RAPHSON", MODIFIED_NEWTON_RAPHSON); +#endif /*! * \brief types of schemes to compute the flow gradient @@ -982,11 +1068,13 @@ enum ENUM_FLOW_GRADIENT { LEAST_SQUARES = 2, /*!< \brief Gradient computation using unweighted least squares. */ WEIGHTED_LEAST_SQUARES = 3 /*!< \brief Gradients computation using inverse-distance weighted least squares. */ }; +#ifdef ENABLE_MAPS static const map Gradient_Map = CCreateMap ("NONE", NO_GRADIENT) ("GREEN_GAUSS", GREEN_GAUSS) ("LEAST_SQUARES", LEAST_SQUARES) ("WEIGHTED_LEAST_SQUARES", WEIGHTED_LEAST_SQUARES); +#endif /*! * \brief types of action to take on a geometry structure @@ -1003,9 +1091,11 @@ enum GEOMETRY_MODE { FUNCTION = 0, /*!< \brief Geometrical analysis. */ GRADIENT = 1 /*!< \brief Geometrical analysis and gradient using finite differences. */ }; +#ifdef ENABLE_MAPS static const map GeometryMode_Map = CCreateMap ("FUNCTION", FUNCTION) ("GRADIENT", GRADIENT); +#endif /*! * \brief types of boundary conditions @@ -1056,9 +1146,11 @@ enum ENUM_2DFORM { PLANE_STRESS = 0, /*!< \brief Definition of plane stress solver. */ PLANE_STRAIN = 1 /*!< \brief Definition of plane strain solver. */ }; +#ifdef ENABLE_MAPS static const map ElasForm_2D = CCreateMap ("PLANE_STRESS", PLANE_STRESS) ("PLANE_STRAIN", PLANE_STRAIN); +#endif /*! * \brief Kinds of relaxation for FSI problem @@ -1068,10 +1160,12 @@ enum ENUM_AITKEN { FIXED_PARAMETER = 1, /*!< \brief Relaxation with a fixed parameter. */ AITKEN_DYNAMIC = 2 /*!< \brief Relaxation using Aitken's dynamic parameter. */ }; +#ifdef ENABLE_MAPS static const map AitkenForm_Map = CCreateMap ("NONE", NO_RELAXATION) ("FIXED_PARAMETER", FIXED_PARAMETER) ("AITKEN_DYNAMIC", AITKEN_DYNAMIC); +#endif /*! * \brief types of dynamic transfer methods @@ -1084,6 +1178,7 @@ enum ENUM_DYN_TRANSFER_METHOD { SIGMOID_10 = 5, /*!< \brief The load is transferred using a sigmoid with parameter 10 */ SIGMOID_20 = 6 /*!< \brief The load is transferred using a sigmoid with parameter 20 */ }; +#ifdef ENABLE_MAPS static const map Dyn_Transfer_Method_Map = CCreateMap ("INSTANTANEOUS", INSTANTANEOUS) ("RAMP", POL_ORDER_1) @@ -1091,6 +1186,7 @@ static const map Dyn_Transfer_Method_Map = CCr ("QUINTIC", POL_ORDER_5) ("SIGMOID_10", SIGMOID_10) ("SIGMOID_20", SIGMOID_20); +#endif /*! * \brief Kinds of Design Variables for FEA problems @@ -1103,6 +1199,7 @@ enum ENUM_DVFEA { DEAD_WEIGHT = 4, /*!< \brief Dead Weight (Rho_DL) as design variable. */ ELECTRIC_FIELD = 5 /*!< \brief Electric field (E) as design variable. */ }; +#ifdef ENABLE_MAPS static const map DVFEA_Map = CCreateMap ("NONE", NODV_FEA) ("YOUNG_MODULUS", YOUNG_MODULUS) @@ -1110,6 +1207,7 @@ static const map DVFEA_Map = CCreateMap ("DENSITY", DENSITY_VAL) ("DEAD_WEIGHT", DEAD_WEIGHT) ("ELECTRIC_FIELD", ELECTRIC_FIELD); +#endif /*! * \brief Kinds of coupling methods at CHT interfaces. @@ -1122,11 +1220,13 @@ enum ENUM_CHT_COUPLING { DIRECT_TEMPERATURE_ROBIN_HEATFLUX = 2, AVERAGED_TEMPERATURE_ROBIN_HEATFLUX = 3 }; +#ifdef ENABLE_MAPS static const map CHT_Coupling_Map = CCreateMap ("DIRECT_TEMPERATURE_NEUMANN_HEATFLUX", DIRECT_TEMPERATURE_NEUMANN_HEATFLUX) ("AVERAGED_TEMPERATURE_NEUMANN_HEATFLUX", AVERAGED_TEMPERATURE_NEUMANN_HEATFLUX) ("DIRECT_TEMPERATURE_ROBIN_HEATFLUX", DIRECT_TEMPERATURE_ROBIN_HEATFLUX) ("AVERAGED_TEMPERATURE_ROBIN_HEATFLUX", AVERAGED_TEMPERATURE_ROBIN_HEATFLUX); +#endif /*! * \brief types Riemann boundary treatments @@ -1148,6 +1248,7 @@ enum RIEMANN_TYPE { MIXING_OUT_1D =14 }; +#ifdef ENABLE_MAPS static const map Riemann_Map = CCreateMap ("TOTAL_CONDITIONS_PT", TOTAL_CONDITIONS_PT) ("DENSITY_VELOCITY", DENSITY_VELOCITY) @@ -1163,8 +1264,10 @@ static const map Riemann_Map = CCreateMap Giles_Map = CCreateMap ("TOTAL_CONDITIONS_PT", TOTAL_CONDITIONS_PT) ("DENSITY_VELOCITY", DENSITY_VELOCITY) @@ -1180,6 +1283,7 @@ static const map Giles_Map = CCreateMap AverageProcess_Map = CCreateMap ("ALGEBRAIC", ALGEBRAIC) ("AREA", AREA) ("MIXEDOUT", MIXEDOUT) ("MASSFLUX", MASSFLUX); +#endif /*! * \brief types of mixing process for averaging quantities at the boundaries. @@ -1204,10 +1310,12 @@ enum MIXINGPLANE_INTERFACE_TYPE { NEAREST_SPAN = 2, /*!< \brief an area average is computed at the boundary of interest. */ LINEAR_INTERPOLATION = 3 /*!< \brief an mixed-out average is computed at the boundary of interest. */ }; +#ifdef ENABLE_MAPS static const map MixingPlaneInterface_Map = CCreateMap ("MATCHING", MATCHING) ("NEAREST_SPAN", NEAREST_SPAN) ("LINEAR_INTERPOLATION", LINEAR_INTERPOLATION); +#endif /*! * \brief this option allow to compute the span-wise section in different ways. @@ -1216,9 +1324,11 @@ enum SPANWISE_TYPE { AUTOMATIC = 1, /*!< \brief number of span-wise section are computed automatically */ EQUISPACED = 2 /*!< \brief number of span-wise section are specified from the user */ }; +#ifdef ENABLE_MAPS static const map SpanWise_Map = CCreateMap ("AUTOMATIC", AUTOMATIC) ("EQUISPACED", EQUISPACED); +#endif /*! * \brief types of mixing process for averaging quantities at the boundaries. @@ -1230,12 +1340,14 @@ enum TURBOMACHINERY_TYPE { CENTRIPETAL_AXIAL = 4, /*!< \brief mixed flow turbine. */ AXIAL_CENTRIFUGAL = 5 /*!< \brief mixed flow turbine. */ }; +#ifdef ENABLE_MAPS static const map TurboMachinery_Map = CCreateMap ("AXIAL", AXIAL) ("CENTRIFUGAL", CENTRIFUGAL) ("CENTRIPETAL", CENTRIPETAL) ("CENTRIPETAL_AXIAL", CENTRIPETAL_AXIAL) ("AXIAL_CENTRIFUGAL", AXIAL_CENTRIFUGAL); +#endif /*! * \brief types of Turbomachinery performance flag. @@ -1255,12 +1367,14 @@ enum INLET_TYPE { VELOCITY_INLET = 4, /*!< \brief Velocity inlet for an incompressible flow. */ PRESSURE_INLET = 5 /*!< \brief Total pressure inlet for an incompressible flow. */ }; +#ifdef ENABLE_MAPS static const map Inlet_Map = CCreateMap ("TOTAL_CONDITIONS", TOTAL_CONDITIONS) ("MASS_FLOW", MASS_FLOW) ("INPUT_FILE", INPUT_FILE) ("VELOCITY_INLET", VELOCITY_INLET) ("PRESSURE_INLET", PRESSURE_INLET); +#endif /*! * \brief types outlet boundary treatments @@ -1269,9 +1383,11 @@ enum OUTLET_TYPE { PRESSURE_OUTLET = 1, /*!< \brief Gauge pressure outlet for incompressible flow */ MASS_FLOW_OUTLET = 2, /*!< \brief Mass flow outlet for incompressible flow. */ }; +#ifdef ENABLE_MAPS static const map Outlet_Map = CCreateMap ("PRESSURE_OUTLET", PRESSURE_OUTLET) ("MASS_FLOW_OUTLET", MASS_FLOW_OUTLET); +#endif /*! * \brief types engine inflow boundary treatments @@ -1281,10 +1397,12 @@ enum ENGINE_INFLOW_TYPE { FAN_FACE_MDOT = 2, /*!< \brief User specifies Static pressure. */ FAN_FACE_PRESSURE = 3 /*!< \brief User specifies Static pressure. */ }; +#ifdef ENABLE_MAPS static const map Engine_Inflow_Map = CCreateMap ("FAN_FACE_MACH", FAN_FACE_MACH) ("FAN_FACE_MDOT", FAN_FACE_MDOT) ("FAN_FACE_PRESSURE", FAN_FACE_PRESSURE); +#endif /*! * \brief types actuator disk boundary treatments @@ -1297,6 +1415,7 @@ enum ACTDISK_TYPE { MASSFLOW = 5, /*!< \brief User specifies the massflow. */ POWER = 6 /*!< \brief User specifies the power. */ }; +#ifdef ENABLE_MAPS static const map ActDisk_Map = CCreateMap ("VARIABLES_JUMP", VARIABLES_JUMP) ("BC_THRUST", BC_THRUST) @@ -1304,6 +1423,7 @@ static const map ActDisk_Map = CCreateMap Objective_Map = CCreateMap ("DRAG", DRAG_COEFFICIENT) ("LIFT", LIFT_COEFFICIENT) @@ -1421,6 +1542,7 @@ static const map Objective_Map = CCreateMap Residual_Map = CCreateMap ("RHO", RHO_RESIDUAL) ("RHO_ENERGY", RHO_ENERGY_RESIDUAL); +#endif /*! * \brief types of residual criteria for structural problems @@ -1440,9 +1564,11 @@ enum ENUM_RESFEM { RESFEM_RELATIVE = 1, /*!< \brief Relative criteria: Res/Res0. */ RESFEM_ABSOLUTE = 2 /*!< \brief Absolute criteria: abs(Res). */ }; +#ifdef ENABLE_MAPS static const map ResFem_Map = CCreateMap ("RELATIVE", RESFEM_RELATIVE) ("ABSOLUTE", RESFEM_ABSOLUTE); +#endif /*! * \brief types of sensitivities to compute @@ -1453,11 +1579,13 @@ enum ENUM_SENS { SENS_AOA = 3, /*!< \brief Angle of attack sensitivity. */ SENS_AOS = 4 /*!< \brief Angle of Sideslip sensitivity. */ }; +#ifdef ENABLE_MAPS static const map Sens_Map = CCreateMap ("SENS_GEOMETRY", SENS_GEOMETRY) ("SENS_MACH", SENS_MACH) ("SENS_AOA", SENS_AOA) ("SENS_AOS", SENS_AOS); +#endif /*! * \brief types of grid adaptation/refinement @@ -1477,6 +1605,7 @@ enum ENUM_ADAPT { SUPERSONIC_SHOCK = 15, /*!< \brief Do a grid smoothing. */ PERIODIC = 17 /*!< \brief Add the periodic halo cells. */ }; +#ifdef ENABLE_MAPS static const map Adapt_Map = CCreateMap ("NONE", NO_ADAPT) ("FULL", FULL) @@ -1491,6 +1620,7 @@ static const map Adapt_Map = CCreateMap ("SMOOTHING", SMOOTHING) ("SUPERSONIC_SHOCK", SUPERSONIC_SHOCK) ("PERIODIC", PERIODIC); +#endif /*! * \brief types of input file formats @@ -1501,11 +1631,13 @@ enum ENUM_INPUT { RECTANGLE = 3, /*!< \brief 2D rectangular mesh with N x M points of size Lx x Ly. */ BOX = 4 /*!< \brief 3D box mesh with N x M x L points of size Lx x Ly x Lz. */ }; +#ifdef ENABLE_MAPS static const map Input_Map = CCreateMap ("SU2", SU2) ("CGNS", CGNS_GRID) ("RECTANGLE", RECTANGLE) ("BOX", BOX); +#endif /*! * \brief type of solution output file formats @@ -1529,6 +1661,7 @@ enum ENUM_OUTPUT { STL_BINARY = 16 /*!< \brief STL binary format for surface solution output. Not implemented yet. */ }; +#ifdef ENABLE_MAPS static const map Output_Map = CCreateMap ("TECPLOT_ASCII", TECPLOT) ("TECPLOT", TECPLOT_BINARY) @@ -1545,6 +1678,7 @@ static const map Output_Map = CCreateMap TabOutput_Map = CCreateMap ("CSV", TAB_CSV) ("TECPLOT", TAB_TECPLOT); +#endif /*! * \brief type of volume sensitivity file formats (inout to SU2_DOT) @@ -1564,9 +1700,11 @@ enum ENUM_SENSITIVITY { SU2_NATIVE = 1, /*!< \brief SU2 native binary format for the volume sensitivity input. */ UNORDERED_ASCII = 2 /*!< \brief Unordered ASCII list (x,y,z,dJ/dx,dJ/dy/dJ/dz) format for the volume sensitivity input. */ }; +#ifdef ENABLE_MAPS static const map Sensitivity_Map = CCreateMap ("SU2_NATIVE", SU2_NATIVE) ("UNORDERED_ASCII", UNORDERED_ASCII); +#endif /*! * \brief type of jump definition @@ -1575,9 +1713,11 @@ enum JUMP_DEFINITION { DIFFERENCE = 1, /*!< \brief Jump given by a difference in values. */ RATIO = 2 /*!< \brief Jump given by a ratio. */ }; +#ifdef ENABLE_MAPS static const map Jump_Map = CCreateMap ("DIFFERENCE", DIFFERENCE) ("RATIO", RATIO); +#endif /*! * \brief type of multigrid cycle @@ -1587,10 +1727,12 @@ enum MG_CYCLE { W_CYCLE = 1, /*!< \brief W cycle. */ FULLMG_CYCLE = 2 /*!< \brief FullMG cycle. */ }; +#ifdef ENABLE_MAPS static const map MG_Cycle_Map = CCreateMap ("V_CYCLE", V_CYCLE) ("W_CYCLE", W_CYCLE) ("FULLMG_CYCLE", FULLMG_CYCLE); +#endif /*! * \brief type of solution output variables @@ -1606,6 +1748,7 @@ enum ENUM_OUTPUT_VARS { LAM_VISC = 8, /*!< \brief Laminar viscosity. */ EDDY_VISC = 9 /*!< \brief Eddy viscosity. */ }; +#ifdef ENABLE_MAPS static const map Output_Vars_Map = CCreateMap ("DENSITY", DENSITY) ("VEL_X", VEL_X) @@ -1616,6 +1759,7 @@ static const map Output_Vars_Map = CCreateMap Param_Map = CCreateMap ("FFD_SETTING", FFD_SETTING) ("FFD_CONTROL_POINT_2D", FFD_CONTROL_POINT_2D) @@ -1697,6 +1842,7 @@ static const map Param_Map = CCreateMap ("TRANSLATE_GRID", TRANSLATE_GRID) ("ROTATE_GRID", ROTATE_GRID) ("SCALE_GRID", SCALE_GRID) +#endif ; /*! @@ -1706,9 +1852,11 @@ enum ENUM_FFD_BLENDING{ BSPLINE_UNIFORM = 0, /*!< \brief BSpline blending */ BEZIER = 1, /*!< \brief Bezier blending */ }; +#ifdef ENABLE_MAPS static const map Blending_Map = CCreateMap ("BSPLINE_UNIFORM", BSPLINE_UNIFORM) ("BEZIER", BEZIER); +#endif /*! * \brief types of solvers for solving linear systems @@ -1725,6 +1873,7 @@ enum ENUM_LINEAR_SOLVER { PASTIX_LDLT = 9, /*!< \brief PaStiX LDLT (complete) factorization. */ PASTIX_LU = 10, /*!< \brief PaStiX LU (complete) factorization. */ }; +#ifdef ENABLE_MAPS static const map Linear_Solver_Map = CCreateMap ("STEEPEST_DESCENT", STEEPEST_DESCENT) ("NEWTON", NEWTON) @@ -1736,6 +1885,7 @@ static const map Linear_Solver_Map = CCreateMap Continuity_Map = CCreateMap ("NO_DERIVATIVE", DERIVATIVE_NONE) ("1ST_DERIVATIVE", DERIVATIVE_1ST) ("2ND_DERIVATIVE", DERIVATIVE_2ND) ("USER_INPUT", USER_INPUT); +#endif /*! * \brief types of coordinates systems for the FFD @@ -1761,11 +1913,13 @@ enum ENUM_FFD_COORD_SYSTEM { SPHERICAL = 2, /*!< \brief Spherical coordinate system. */ POLAR = 3 /*!< \brief Polar coordinate system. */ }; +#ifdef ENABLE_MAPS static const map CoordSystem_Map = CCreateMap ("CARTESIAN", CARTESIAN) ("CYLINDRICAL", CYLINDRICAL) ("SPHERICAL", SPHERICAL) ("POLAR", POLAR); +#endif /*! * \brief types of sensitivity smoothing @@ -1775,10 +1929,12 @@ enum ENUM_SENS_SMOOTHING { SOBOLEV = 1, /*!< \brief Sobolev gradient smoothing. */ BIGRID = 2 /*!< \brief Bi-grid technique smoothing. */ }; +#ifdef ENABLE_MAPS static const map Sens_Smoothing_Map = CCreateMap ("NONE", NO_SMOOTH) ("SOBOLEV", SOBOLEV) ("BIGRID", BIGRID); +#endif /*! * \brief types of preconditioners for the linear solver @@ -1792,6 +1948,7 @@ enum ENUM_LINEAR_SOLVER_PREC { PASTIX_LU_P= 6, /*!< \brief PaStiX LU as preconditioner. */ PASTIX_LDLT_P= 7, /*!< \brief PaStiX LDLT as preconditioner. */ }; +#ifdef ENABLE_MAPS static const map Linear_Solver_Prec_Map = CCreateMap ("JACOBI", JACOBI) ("LU_SGS", LU_SGS) @@ -1800,6 +1957,7 @@ static const map Linear_Solver_Prec_Map = CCrea ("PASTIX_ILU", PASTIX_ILU) ("PASTIX_LU", PASTIX_LU_P) ("PASTIX_LDLT", PASTIX_LDLT_P); +#endif /*! * \brief types of analytic definitions for various geometries @@ -1811,12 +1969,14 @@ enum ENUM_GEO_ANALYTIC { CYLINDER = 3, /*!< \brief Use the analytical definition of a cylinder for doing the grid adaptation. */ BIPARABOLIC = 4 /*!< \brief Use the analytical definition of a biparabolic airfoil for doing the grid adaptation. */ }; +#ifdef ENABLE_MAPS static const map Geo_Analytic_Map = CCreateMap ("NONE", NO_GEO_ANALYTIC) ("NACA0012_AIRFOIL", NACA0012_AIRFOIL) ("NACA4412_AIRFOIL", NACA4412_AIRFOIL) ("CYLINDER", CYLINDER) ("BIPARABOLIC", BIPARABOLIC); +#endif /*! * \brief types of axis orientation @@ -1827,11 +1987,13 @@ enum ENUM_GEO_DESCRIPTION { FUSELAGE = 2, /*!< \brief Fuselage analysis. */ NACELLE = 3 /*!< \brief Nacelle analysis. */ }; +#ifdef ENABLE_MAPS static const map Geo_Description_Map = CCreateMap ("AIRFOIL", TWOD_AIRFOIL) ("WING", WING) ("FUSELAGE", FUSELAGE) ("NACELLE", NACELLE); +#endif /*! * \brief types of schemes for unsteady computations @@ -1844,6 +2006,7 @@ enum ENUM_UNSTEADY { ROTATIONAL_FRAME = 4, /*!< \brief Use a rotational source term. */ HARMONIC_BALANCE = 5 /*!< \brief Use a harmonic balance source term. */ }; +#ifdef ENABLE_MAPS static const map TimeMarching_Map = CCreateMap ("NO", STEADY) ("TIME_STEPPING", TIME_STEPPING) @@ -1851,6 +2014,7 @@ static const map TimeMarching_Map = CCreateMap Converge_Crit_Map = CCreateMap ("CAUCHY", CAUCHY) ("RESIDUAL", RESIDUAL); +#endif /*! * \brief types of element stiffnesses imposed for FEA mesh deformation @@ -1871,10 +2037,12 @@ enum ENUM_DEFORM_STIFFNESS { INVERSE_VOLUME = 1, /*!< \brief Impose a stiffness for each element that is inversely proportional to cell volume. */ SOLID_WALL_DISTANCE = 2 /*!< \brief Impose a stiffness for each element that is proportional to the distance from the solid surface. */ }; +#ifdef ENABLE_MAPS static const map Deform_Stiffness_Map = CCreateMap ("CONSTANT_STIFFNESS", CONSTANT_STIFFNESS) ("INVERSE_VOLUME", INVERSE_VOLUME) ("WALL_DISTANCE", SOLID_WALL_DISTANCE); +#endif /*! * \brief The direct differentation variables. @@ -1897,6 +2065,7 @@ enum ENUM_DIRECTDIFF_VAR { D_RHO_DL = 14, /*!< \brief Derivative w.r.t. the density for dead loads */ D_EFIELD = 15 /*!< \brief Derivative w.r.t. the electric field */ }; +#ifdef ENABLE_MAPS static const map DirectDiff_Var_Map = CCreateMap ("NONE", NO_DERIVATIVE) ("MACH", D_MACH) @@ -1914,6 +2083,7 @@ static const map DirectDiff_Var_Map = CCreateMap Dynamic_Map = CCreateMap ("NO", STATIC) ("YES", DYNAMIC); +#endif /*! * \brief types of input file formats @@ -1946,9 +2118,11 @@ enum ENUM_INPUT_REF { SU2_REF = 1, /*!< \brief SU2 input format (from a restart). */ CUSTOM_REF = 2 /*!< \brief CGNS input format for the computational grid. */ }; +#ifdef ENABLE_MAPS static const map Input_Ref_Map = CCreateMap ("SU2", SU2_REF) ("CUSTOM", CUSTOM_REF); +#endif /*! * \brief Vertex-based quantities exchanged during periodic marker communications. @@ -2018,10 +2192,12 @@ enum COMM_LEVEL { COMM_MINIMAL = 1, /*!< \brief Perform only the minimal set of MPI communications for correctness. Disables many console and output comms. */ COMM_FULL = 2 /*!< \brief Perform all MPI communications. */ }; +#ifdef ENABLE_MAPS static const map Comm_Map = CCreateMap ("NONE", COMM_NONE) ("MINIMAL", COMM_MINIMAL) ("FULL", COMM_FULL); +#endif /* * \brief types of filter kernels, initially intended for structural topology optimization applications @@ -2033,12 +2209,14 @@ enum ENUM_FILTER_KERNEL { DILATE_MORPH_FILTER = 3, /*!< \brief Continuous version of the dilate morphology operator [Sigmund 2007]. */ ERODE_MORPH_FILTER = 4, /*!< \brief Continuous version of the erode morphology operator [Sigmund 2007].*/ }; +#ifdef ENABLE_MAPS static const map Filter_Kernel_Map = CCreateMap ("CONSTANT", CONSTANT_WEIGHT_FILTER) ("CONICAL" , CONICAL_WEIGHT_FILTER) ("GAUSSIAN", GAUSSIAN_WEIGHT_FILTER) ("DILATE" , DILATE_MORPH_FILTER) ("ERODE" , ERODE_MORPH_FILTER); +#endif /*! * \brief types of projection function, initially intended for structural topology optimization applications @@ -2048,10 +2226,12 @@ enum ENUM_PROJECTION_FUNCTION { HEAVISIDE_UP = 1, /*!< \brief Project values towards 1. */ HEAVISIDE_DOWN = 2, /*!< \brief Project values towards 0. */ }; +#ifdef ENABLE_MAPS static const map Projection_Function_Map = CCreateMap ("NO_PROJECTION" , NO_PROJECTION) ("HEAVISIDE_UP" , HEAVISIDE_UP) ("HEAVISIDE_DOWN", HEAVISIDE_DOWN); +#endif /*! * \brief the different validation solution @@ -2071,6 +2251,7 @@ enum ENUM_VERIFICATION_SOLUTIONS { MMS_INC_NS = 66, /*!< \brief Manufactured solution of the laminar incompressible Navier Stokes equations. */ USER_DEFINED_SOLUTION = 99, /*!< \brief User defined solution. */ }; +#ifdef ENABLE_MAPS static const map Verification_Solution_Map = CCreateMap ("NO_VERIFICATION_SOLUTION", NO_VERIFICATION_SOLUTION) ("INVISCID_VORTEX", INVISCID_VORTEX) @@ -2085,6 +2266,7 @@ static const map Verification_Solution_Map ("MMS_INC_EULER", MMS_INC_EULER) ("MMS_INC_NS", MMS_INC_NS) ("USER_DEFINED_SOLUTION", USER_DEFINED_SOLUTION); +#endif /* END_CONFIG_ENUMS */ @@ -2121,6 +2303,8 @@ class COptionBase { inline COptionBase::~COptionBase() {} +#ifdef ENABLE_MAPS + template class COptionEnum : public COptionBase { @@ -4241,3 +4425,5 @@ class COptionWallFunction : public COptionBase { this->doubleInfo = NULL; } }; + +#endif diff --git a/Common/src/config_structure.cpp b/Common/src/config_structure.cpp index de7133fcdcff..b674d968f20d 100644 --- a/Common/src/config_structure.cpp +++ b/Common/src/config_structure.cpp @@ -25,6 +25,8 @@ * License along with SU2. If not, see . */ +#define ENABLE_MAPS + #include "../include/config_structure.hpp" #include "../include/fem_gauss_jacobi_quadrature.hpp" #include "../include/fem_geometry_structure.hpp" @@ -248,6 +250,270 @@ void CConfig::SetMPICommunicator(SU2_MPI::Comm Communicator) { } +void CConfig::addDoubleOption(const string name, su2double & option_field, su2double default_value) { + // Check if the key is already in the map. If this fails, it is coder error + // and not user error, so throw. + assert(option_map.find(name) == option_map.end()); + + // Add this option to the list of all the options + all_options.insert(pair(name, true)); + + // Create the parser for a su2double option with a reference to the option_field and the desired + // default value. This will take the string in the config file, convert it to a su2double, and + // place that su2double in the memory location specified by the reference. + COptionBase* val = new COptionDouble(name, option_field, default_value); + + // Create an association between the option name ("CFL") and the parser generated above. + // During configuration, the parsing script will get the option name, and use this map + // to find how to parse that option. + option_map.insert(pair(name, val)); +} + +void CConfig::addStringOption(const string name, string & option_field, string default_value) { + assert(option_map.find(name) == option_map.end()); + all_options.insert(pair(name, true)); + COptionBase* val = new COptionString(name, option_field, default_value); + option_map.insert(pair(name, val)); +} + +void CConfig::addIntegerOption(const string name, int & option_field, int default_value) { + assert(option_map.find(name) == option_map.end()); + all_options.insert(pair(name, true)); + COptionBase* val = new COptionInt(name, option_field, default_value); + option_map.insert(pair(name, val)); +} + +void CConfig::addUnsignedLongOption(const string name, unsigned long & option_field, unsigned long default_value) { + assert(option_map.find(name) == option_map.end()); + all_options.insert(pair(name, true)); + COptionBase* val = new COptionULong(name, option_field, default_value); + option_map.insert(pair(name, val)); +} + +void CConfig::addUnsignedShortOption(const string name, unsigned short & option_field, unsigned short default_value) { + assert(option_map.find(name) == option_map.end()); + all_options.insert(pair(name, true)); + COptionBase* val = new COptionUShort(name, option_field, default_value); + option_map.insert(pair(name, val)); +} + +void CConfig::addLongOption(const string name, long & option_field, long default_value) { + assert(option_map.find(name) == option_map.end()); + all_options.insert(pair(name, true)); + COptionBase* val = new COptionLong(name, option_field, default_value); + option_map.insert(pair(name, val)); +} + +void CConfig::addBoolOption(const string name, bool & option_field, bool default_value) { + assert(option_map.find(name) == option_map.end()); + all_options.insert(pair(name, true)); + COptionBase* val = new COptionBool(name, option_field, default_value); + option_map.insert(pair(name, val)); +} + +// enum types work differently than all of the others because there are a small number of valid +// string entries for the type. One must also provide a list of all the valid strings of that type. +template +void CConfig::addEnumOption(const string name, unsigned short & option_field, const map & enum_map, Tenum default_value) { + assert(option_map.find(name) == option_map.end()); + all_options.insert(pair(name, true)); + COptionBase* val = new COptionEnum(name, enum_map, option_field, default_value); + option_map.insert(pair(name, val)); + return; +} + + +// input_size is the number of options read in from the config file +template +void CConfig::addEnumListOption(const string name, unsigned short & input_size, unsigned short * & option_field, const map & enum_map) { + input_size = 0; + assert(option_map.find(name) == option_map.end()); + all_options.insert(pair(name, true)); + COptionBase* val = new COptionEnumList(name, enum_map, option_field, input_size); + option_map.insert( pair(name, val) ); +} + +void CConfig::addDoubleArrayOption(const string name, const int size, su2double * & option_field, su2double * default_value) { + + // su2double * def = new su2double [size]; + // for (int i = 0; i < size; i++) { + // def[i] = default_value[i]; + // } + + assert(option_map.find(name) == option_map.end()); + all_options.insert(pair(name, true)); + COptionBase* val = new COptionDoubleArray(name, size, option_field, default_value); + option_map.insert(pair(name, val)); +} + +void CConfig::addDoubleListOption(const string name, unsigned short & size, su2double * & option_field) { + assert(option_map.find(name) == option_map.end()); + all_options.insert(pair(name, true)); + COptionBase* val = new COptionDoubleList(name, size, option_field); + option_map.insert(pair(name, val)); +} + +void CConfig::addShortListOption(const string name, unsigned short & size, short * & option_field) { + assert(option_map.find(name) == option_map.end()); + all_options.insert(pair(name, true)); + COptionBase* val = new COptionShortList(name, size, option_field); + option_map.insert(pair(name, val)); +} + +void CConfig::addUShortListOption(const string name, unsigned short & size, unsigned short * & option_field) { + assert(option_map.find(name) == option_map.end()); + all_options.insert(pair(name, true)); + COptionBase* val = new COptionUShortList(name, size, option_field); + option_map.insert(pair(name, val)); +} + +void CConfig::addStringListOption(const string name, unsigned short & num_marker, string* & option_field) { + assert(option_map.find(name) == option_map.end()); + all_options.insert(pair(name, true)); + COptionBase* val = new COptionStringList(name, num_marker, option_field); + option_map.insert(pair(name, val)); +} + +void CConfig::addConvectOption(const string name, unsigned short & space_field, unsigned short & centered_field, unsigned short & upwind_field) { + assert(option_map.find(name) == option_map.end()); + all_options.insert(pair(name, true)); + COptionBase* val = new COptionConvect(name, space_field, centered_field, upwind_field); + option_map.insert(pair(name, val)); +} + +void CConfig::addConvectFEMOption(const string name, unsigned short & space_field, unsigned short & fem_field) { + assert(option_map.find(name) == option_map.end()); + all_options.insert(pair(name, true)); + COptionBase* val = new COptionFEMConvect(name, space_field, fem_field); + option_map.insert(pair(name, val)); +} + +void CConfig::addMathProblemOption(const string name, bool & ContinuousAdjoint, const bool & ContinuousAdjoint_default, + bool & DiscreteAdjoint, const bool & DiscreteAdjoint_default, + bool & Restart_Flow, const bool & Restart_Flow_default) { + assert(option_map.find(name) == option_map.end()); + all_options.insert(pair(name, true)); + COptionBase* val = new COptionMathProblem(name, ContinuousAdjoint, ContinuousAdjoint_default, DiscreteAdjoint, DiscreteAdjoint_default, Restart_Flow, Restart_Flow_default); + option_map.insert(pair(name, val)); +} + +void CConfig::addDVParamOption(const string name, unsigned short & nDV_field, su2double** & paramDV, string* & FFDTag, + unsigned short* & design_variable) { + assert(option_map.find(name) == option_map.end()); + all_options.insert(pair(name, true)); + COptionBase* val = new COptionDVParam(name, nDV_field, paramDV, FFDTag, design_variable); + option_map.insert(pair(name, val)); +} + +void CConfig::addDVValueOption(const string name, unsigned short* & nDVValue_field, su2double** & valueDV, unsigned short & nDV_field, su2double** & paramDV, + unsigned short* & design_variable) { + assert(option_map.find(name) == option_map.end()); + all_options.insert(pair(name, true)); + COptionBase* val = new COptionDVValue(name, nDVValue_field, valueDV, nDV_field, paramDV, design_variable); + option_map.insert(pair(name, val)); +} + +void CConfig::addFFDDefOption(const string name, unsigned short & nFFD_field, su2double** & coordFFD, string* & FFDTag) { + assert(option_map.find(name) == option_map.end()); + all_options.insert(pair(name, true)); + COptionBase* val = new COptionFFDDef(name, nFFD_field, coordFFD, FFDTag); + option_map.insert(pair(name, val)); +} + +void CConfig::addFFDDegreeOption(const string name, unsigned short & nFFD_field, unsigned short** & degreeFFD) { + assert(option_map.find(name) == option_map.end()); + all_options.insert(pair(name, true)); + COptionBase* val = new COptionFFDDegree(name, nFFD_field, degreeFFD); + option_map.insert(pair(name, val)); +} + +void CConfig::addStringDoubleListOption(const string name, unsigned short & list_size, string * & string_field, + su2double* & double_field) { + assert(option_map.find(name) == option_map.end()); + all_options.insert(pair(name, true)); + COptionBase* val = new COptionStringDoubleList(name, list_size, string_field, double_field); + option_map.insert(pair(name, val)); +} + +void CConfig::addInletOption(const string name, unsigned short & nMarker_Inlet, string * & Marker_Inlet, + su2double* & Ttotal, su2double* & Ptotal, su2double** & FlowDir) { + assert(option_map.find(name) == option_map.end()); + all_options.insert(pair(name, true)); + COptionBase* val = new COptionInlet(name, nMarker_Inlet, Marker_Inlet, Ttotal, Ptotal, FlowDir); + option_map.insert(pair(name, val)); +} + +template +void CConfig::addRiemannOption(const string name, unsigned short & nMarker_Riemann, string * & Marker_Riemann, unsigned short* & option_field, const map & enum_map, + su2double* & var1, su2double* & var2, su2double** & FlowDir) { + assert(option_map.find(name) == option_map.end()); + all_options.insert(pair(name, true)); + COptionBase* val = new COptionRiemann(name, nMarker_Riemann, Marker_Riemann, option_field, enum_map, var1, var2, FlowDir); + option_map.insert(pair(name, val)); +} + +template +void CConfig::addGilesOption(const string name, unsigned short & nMarker_Giles, string * & Marker_Giles, unsigned short* & option_field, const map & enum_map, + su2double* & var1, su2double* & var2, su2double** & FlowDir, su2double* & relaxfactor1, su2double* & relaxfactor2) { + assert(option_map.find(name) == option_map.end()); + all_options.insert(pair(name, true)); + COptionBase* val = new COptionGiles(name, nMarker_Giles, Marker_Giles, option_field, enum_map, var1, var2, FlowDir, relaxfactor1, relaxfactor2); + option_map.insert(pair(name, val)); +} + +void CConfig::addExhaustOption(const string name, unsigned short & nMarker_Exhaust, string * & Marker_Exhaust, + su2double* & Ttotal, su2double* & Ptotal) { + assert(option_map.find(name) == option_map.end()); + all_options.insert(pair(name, true)); + COptionBase* val = new COptionExhaust(name, nMarker_Exhaust, Marker_Exhaust, Ttotal, Ptotal); + option_map.insert(pair(name, val)); +} + +void CConfig::addPeriodicOption(const string & name, unsigned short & nMarker_PerBound, + string* & Marker_PerBound, string* & Marker_PerDonor, + su2double** & RotCenter, su2double** & RotAngles, su2double** & Translation) { + assert(option_map.find(name) == option_map.end()); + all_options.insert(pair(name, true)); + COptionBase* val = new COptionPeriodic(name, nMarker_PerBound, Marker_PerBound, Marker_PerDonor, RotCenter, RotAngles, Translation); + option_map.insert(pair(name, val)); +} + +void CConfig::addTurboPerfOption(const string & name, unsigned short & nMarker_TurboPerf, + string* & Marker_TurboBoundIn, string* & Marker_TurboBoundOut) { + assert(option_map.find(name) == option_map.end()); + all_options.insert(pair(name, true)); + COptionBase* val = new COptionTurboPerformance(name, nMarker_TurboPerf, Marker_TurboBoundIn, Marker_TurboBoundOut); + option_map.insert(pair(name, val)); +} + +void CConfig::addActDiskOption(const string & name, + unsigned short & nMarker_ActDiskInlet, unsigned short & nMarker_ActDiskOutlet, string* & Marker_ActDiskInlet, string* & Marker_ActDiskOutlet, + su2double** & ActDisk_PressJump, su2double** & ActDisk_TempJump, su2double** & ActDisk_Omega) { + assert(option_map.find(name) == option_map.end()); + all_options.insert(pair(name, true)); + COptionBase* val = new COptionActDisk(name, + nMarker_ActDiskInlet, nMarker_ActDiskOutlet, Marker_ActDiskInlet, Marker_ActDiskOutlet, + ActDisk_PressJump, ActDisk_TempJump, ActDisk_Omega); + option_map.insert(pair(name, val)); +} + +void CConfig::addWallFunctionOption(const string &name, unsigned short &list_size, + string* &string_field, unsigned short* &val_Kind_WF, + unsigned short** &val_IntInfo_WF, su2double** &val_DoubleInfo_WF) { + assert(option_map.find(name) == option_map.end()); + all_options.insert(pair(name, true)); + COptionBase* val = new COptionWallFunction(name, list_size, string_field, val_Kind_WF, + val_IntInfo_WF, val_DoubleInfo_WF); + option_map.insert(pair(name, val)); +} + +void CConfig::addPythonOption(const string name) { + assert(option_map.find(name) == option_map.end()); + all_options.insert(pair(name, true)); + COptionBase* val = new COptionPython(name); + option_map.insert(pair(name, val)); +} + unsigned short CConfig::GetnZone(string val_mesh_filename, unsigned short val_format) { int nZone = 1; /* Default value if nothing is specified. */ From b6aa9ae78a91b4b751cd04743927ac5b341896d5 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Mon, 27 Jan 2020 13:46:46 +0000 Subject: [PATCH 015/118] fix un-init warning --- SU2_CFD/src/solvers/CEulerSolver.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index eccaf9686242..c1a6a82cac9d 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -3176,6 +3176,7 @@ void CEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, { Min_Delta_Time = min(Min_Delta_Time, minDt); Max_Delta_Time = max(Max_Delta_Time, maxDt); + Global_Delta_Time = Min_Delta_Time; } SU2_OMP_BARRIER } From 9172ca0bf72d59000c359221c013c6f82a4e85dd Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Mon, 27 Jan 2020 14:03:25 +0000 Subject: [PATCH 016/118] fix SU2_DOT compilation --- SU2_DOT/include/SU2_DOT.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/SU2_DOT/include/SU2_DOT.hpp b/SU2_DOT/include/SU2_DOT.hpp index c09084fd5f4a..528b467442f2 100644 --- a/SU2_DOT/include/SU2_DOT.hpp +++ b/SU2_DOT/include/SU2_DOT.hpp @@ -29,6 +29,9 @@ #pragma once +#define ENABLE_MAPS +#include "../../Common/include/config_structure.hpp" + #include "../../Common/include/mpi_structure.hpp" #include "../../Common/include/omp_structure.hpp" @@ -39,7 +42,6 @@ #include "../../Common/include/geometry/CPhysicalGeometry.hpp" #include "../../Common/include/fem_geometry_structure.hpp" -#include "../../Common/include/config_structure.hpp" #include "../../Common/include/grid_movement_structure.hpp" #include "../../SU2_CFD/include/output/CBaselineOutput.hpp" #include "../../SU2_CFD/include/solvers/CBaselineSolver.hpp" From 038769acd3d58836a5d3e11a8b104543368effcd Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Mon, 27 Jan 2020 15:50:54 +0000 Subject: [PATCH 017/118] fix some indentation in option_structure --- Common/include/option_structure.hpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Common/include/option_structure.hpp b/Common/include/option_structure.hpp index 3a96ec319870..9c032b88fe5b 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -184,19 +184,19 @@ static const map Average_Map = CCreateMap Date: Mon, 27 Jan 2020 16:27:29 +0000 Subject: [PATCH 018/118] reduce number of numerics files, difficult to understand inheritance structure with loose files --- Common/include/option_structure.hpp | 36 +- SU2_CFD/include/numerics/CNumerics.hpp | 3 +- .../CAvgGradCorrected_AdjFlow.hpp | 78 -- .../CAvgGradCorrected_AdjTurb.hpp | 82 -- .../continuous_adjoint/CAvgGrad_AdjFlow.hpp | 72 - .../continuous_adjoint/CAvgGrad_AdjTurb.hpp | 82 -- .../continuous_adjoint/CCentJST_AdjFlow.hpp | 80 -- .../continuous_adjoint/CCentLax_AdjFlow.hpp | 80 -- .../CSourceAxisymmetric_AdjFlow.hpp | 61 - .../CSourceConservative_AdjFlow.hpp | 59 - .../CSourceConservative_AdjTurb.hpp | 63 - .../CSourcePieceWise_AdjTurb.hpp | 66 - .../CSourceRotatingFrame_AdjFlow.hpp | 62 - .../CSourceViscous_AdjFlow.hpp | 66 - .../continuous_adjoint/CUpwLin_AdjTurb.hpp | 66 - .../continuous_adjoint/CUpwRoe_AdjFlow.hpp | 81 -- .../continuous_adjoint/CUpwSca_AdjTurb.hpp | 69 - .../continuous_adjoint/adj_convection.hpp | 254 ++++ .../continuous_adjoint/adj_diffusion.hpp | 224 ++++ .../continuous_adjoint/adj_sources.hpp | 220 +++ .../elasticity/CFEALinearElasticity.hpp | 56 + .../elasticity/CFEAMeshElasticity.hpp | 80 -- .../elasticity/CFEM_DielectricElastomer.hpp | 78 -- .../numerics/elasticity/CFEM_IdealDE.hpp | 79 -- .../elasticity/CFEM_Knowles_NearInc.hpp | 82 -- .../elasticity/CFEM_NeoHookean_Comp.hpp | 79 -- .../numerics/elasticity/nonlinear_models.hpp | 227 ++++ .../numerics/flow/convection/ausm_slau.hpp | 255 ++++ .../numerics/flow/convection/centered.hpp | 332 +++++ .../CUpwCUSP_Flow.hpp => convection/cusp.hpp} | 5 +- .../fds.hpp} | 6 +- .../CUpwMSW_Flow.hpp => convection/fvs.hpp} | 6 +- .../hllc.hpp} | 57 +- .../include/numerics/flow/convection/roe.hpp | 273 ++++ .../convection_centered/CCentBase_Flow.hpp | 106 -- .../convection_centered/CCentJSTInc_Flow.hpp | 90 -- .../convection_centered/CCentJST_Flow.hpp | 75 -- .../convection_centered/CCentJST_KE_Flow.hpp | 75 -- .../convection_centered/CCentLaxInc_Flow.hpp | 88 -- .../convection_centered/CCentLax_Flow.hpp | 74 - .../CUpwAUSMPLUSUP2_Flow.hpp | 66 - .../convection_upwind/CUpwAUSMPLUSUP_Flow.hpp | 65 - .../CUpwAUSMPLUS_SLAU_Base_Flow.hpp | 100 -- .../flow/convection_upwind/CUpwAUSM_Flow.hpp | 77 -- .../convection_upwind/CUpwGeneralRoe_Flow.hpp | 90 -- .../flow/convection_upwind/CUpwHLLC_Flow.hpp | 82 -- .../flow/convection_upwind/CUpwL2Roe_Flow.hpp | 64 - .../flow/convection_upwind/CUpwLMRoe_Flow.hpp | 64 - .../convection_upwind/CUpwRoeBase_Flow.hpp | 80 -- .../flow/convection_upwind/CUpwRoe_Flow.hpp | 66 - .../flow/convection_upwind/CUpwSLAU_Flow.hpp | 90 -- .../convection_upwind/CUpwTurkel_Flow.hpp | 80 -- .../flow/diffusion/CAvgGradInc_Flow.hpp | 97 -- .../numerics/flow/diffusion/CAvgGrad_Flow.hpp | 94 -- .../flow/diffusion/CGeneralAvgGrad_Flow.hpp | 103 -- .../CAvgGrad_Base.hpp => flow_diffusion.hpp} | 195 ++- .../include/numerics/flow/flow_sources.hpp | 268 ++++ .../flow/sources/CSourceAxisymmetric_Flow.hpp | 62 - .../flow/sources/CSourceBodyForce.hpp | 63 - .../flow/sources/CSourceBoussinesq.hpp | 64 - .../numerics/flow/sources/CSourceGravity.hpp | 61 - .../sources/CSourceIncAxisymmetric_Flow.hpp | 66 - .../flow/sources/CSourceIncBodyForce.hpp | 64 - .../sources/CSourceIncRotatingFrame_Flow.hpp | 67 - .../sources/CSourceRotatingFrame_Flow.hpp | 62 - .../numerics/flow/sources/CSourceWindGust.hpp | 62 - SU2_CFD/include/numerics/heat.hpp | 196 +++ .../numerics/heat/CAvgGradCorrected_Heat.hpp | 72 - .../include/numerics/heat/CAvgGrad_Heat.hpp | 72 - .../include/numerics/heat/CCentSca_Heat.hpp | 80 -- .../include/numerics/heat/CUpwSca_Heat.hpp | 70 - SU2_CFD/include/numerics/include_all.hpp | 84 -- SU2_CFD/include/numerics/template.hpp | 138 ++ .../template/CConvective_Template.hpp | 78 -- .../numerics/template/CSource_Template.hpp | 64 - .../numerics/template/CViscous_Template.hpp | 65 - SU2_CFD/include/numerics/transition.hpp | 252 ++++ .../transition/CAvgGradCorrected_TransLM.hpp | 70 - .../numerics/transition/CAvgGrad_TransLM.hpp | 73 - .../transition/CSourcePieceWise_TransLM.hpp | 95 -- .../numerics/transition/CUpwLin_TransLM.hpp | 70 - .../numerics/transition/CUpwSca_TransLM.hpp | 69 - .../numerics/turbulent/CAvgGrad_Scalar.hpp | 103 -- .../numerics/turbulent/CAvgGrad_TurbSA.hpp | 75 -- .../turbulent/CAvgGrad_TurbSA_Neg.hpp | 77 -- .../numerics/turbulent/CAvgGrad_TurbSST.hpp | 89 -- .../turbulent/CSourcePieceWise_TurbSA.hpp | 133 -- .../CSourcePieceWise_TurbSA_COMP.hpp | 128 -- .../turbulent/CSourcePieceWise_TurbSA_E.hpp | 128 -- .../CSourcePieceWise_TurbSA_E_COMP.hpp | 129 -- .../turbulent/CSourcePieceWise_TurbSA_Neg.hpp | 125 -- .../turbulent/CSourcePieceWise_TurbSST.hpp | 141 -- .../numerics/turbulent/CUpwSca_TurbSA.hpp | 71 - .../numerics/turbulent/CUpwSca_TurbSST.hpp | 71 - .../{CUpwScalar.hpp => turb_convection.hpp} | 86 +- .../numerics/turbulent/turb_diffusion.hpp | 251 ++++ .../numerics/turbulent/turb_sources.hpp | 629 +++++++++ SU2_CFD/src/drivers/CDriver.cpp | 23 +- SU2_CFD/src/numerics/CNumerics.cpp | 6 +- .../CAvgGradCorrected_AdjFlow.cpp | 173 --- .../CAvgGradCorrected_AdjTurb.cpp | 158 --- .../continuous_adjoint/CAvgGrad_AdjFlow.cpp | 139 -- .../continuous_adjoint/CAvgGrad_AdjTurb.cpp | 149 --- .../continuous_adjoint/CCentJST_AdjFlow.cpp | 248 ---- .../continuous_adjoint/CCentLax_AdjFlow.cpp | 235 ---- .../CSourceAxisymmetric_AdjFlow.cpp | 74 - .../CSourceConservative_AdjFlow.cpp | 190 --- .../CSourceConservative_AdjTurb.cpp | 66 - .../CSourcePieceWise_AdjTurb.cpp | 162 --- .../CSourceRotatingFrame_AdjFlow.cpp | 86 -- .../CSourceViscous_AdjFlow.cpp | 341 ----- .../continuous_adjoint/CUpwLin_AdjTurb.cpp | 66 - .../continuous_adjoint/CUpwRoe_AdjFlow.cpp | 334 ----- .../continuous_adjoint/CUpwSca_AdjTurb.cpp | 74 - .../continuous_adjoint/adj_convection.cpp | 846 ++++++++++++ .../continuous_adjoint/adj_diffusion.cpp | 537 ++++++++ .../continuous_adjoint/adj_sources.cpp | 782 +++++++++++ .../numerics/elasticity/CFEAElasticity.cpp | 17 +- .../elasticity/CFEALinearElasticity.cpp | 66 +- .../elasticity/CFEAMeshElasticity.cpp | 92 -- .../elasticity/CFEM_DielectricElastomer.cpp | 86 -- .../src/numerics/elasticity/CFEM_IdealDE.cpp | 112 -- .../elasticity/CFEM_Knowles_NearInc.cpp | 120 -- .../elasticity/CFEM_NeoHookean_Comp.cpp | 120 -- .../numerics/elasticity/nonlinear_models.cpp | 346 +++++ .../numerics/flow/convection/ausm_slau.cpp | 959 +++++++++++++ .../src/numerics/flow/convection/centered.cpp | 751 +++++++++++ .../CUpwCUSP_Flow.cpp => convection/cusp.cpp} | 6 +- .../fds.cpp} | 6 +- .../CUpwMSW_Flow.cpp => convection/fvs.cpp} | 6 +- SU2_CFD/src/numerics/flow/convection/hllc.cpp | 1102 +++++++++++++++ SU2_CFD/src/numerics/flow/convection/roe.cpp | 990 ++++++++++++++ .../convection_centered/CCentBase_Flow.cpp | 207 --- .../convection_centered/CCentJSTInc_Flow.cpp | 241 ---- .../convection_centered/CCentJST_Flow.cpp | 81 -- .../convection_centered/CCentJST_KE_Flow.cpp | 70 - .../convection_centered/CCentLaxInc_Flow.cpp | 234 ---- .../convection_centered/CCentLax_Flow.cpp | 69 - .../CUpwAUSMPLUSUP2_Flow.cpp | 120 -- .../convection_upwind/CUpwAUSMPLUSUP_Flow.cpp | 258 ---- .../CUpwAUSMPLUS_SLAU_Base_Flow.cpp | 384 ------ .../flow/convection_upwind/CUpwAUSM_Flow.cpp | 208 --- .../CUpwGeneralHLLC_Flow.cpp | 593 --------- .../convection_upwind/CUpwGeneralRoe_Flow.cpp | 360 ----- .../flow/convection_upwind/CUpwHLLC_Flow.cpp | 539 -------- .../flow/convection_upwind/CUpwL2Roe_Flow.cpp | 103 -- .../flow/convection_upwind/CUpwLMRoe_Flow.cpp | 103 -- .../convection_upwind/CUpwRoeBase_Flow.cpp | 242 ---- .../flow/convection_upwind/CUpwRoe_Flow.cpp | 72 - .../flow/convection_upwind/CUpwSLAU_Flow.cpp | 119 -- .../convection_upwind/CUpwTurkel_Flow.cpp | 257 ---- .../flow/diffusion/CAvgGradInc_Flow.cpp | 274 ---- .../numerics/flow/diffusion/CAvgGrad_Base.cpp | 560 -------- .../numerics/flow/diffusion/CAvgGrad_Flow.cpp | 223 ---- .../flow/diffusion/CGeneralAvgGrad_Flow.cpp | 232 ---- SU2_CFD/src/numerics/flow/flow_diffusion.cpp | 1186 +++++++++++++++++ SU2_CFD/src/numerics/flow/flow_sources.cpp | 541 ++++++++ .../flow/sources/CSourceAxisymmetric_Flow.cpp | 107 -- .../flow/sources/CSourceBodyForce.cpp | 66 - .../flow/sources/CSourceBoussinesq.cpp | 72 - .../numerics/flow/sources/CSourceGravity.cpp | 45 - .../sources/CSourceIncAxisymmetric_Flow.cpp | 154 --- .../flow/sources/CSourceIncBodyForce.cpp | 73 - .../sources/CSourceIncRotatingFrame_Flow.cpp | 94 -- .../sources/CSourceRotatingFrame_Flow.cpp | 91 -- .../numerics/flow/sources/CSourceWindGust.cpp | 93 -- SU2_CFD/src/numerics/heat.cpp | 322 +++++ .../numerics/heat/CAvgGradCorrected_Heat.cpp | 107 -- SU2_CFD/src/numerics/heat/CAvgGrad_Heat.cpp | 99 -- SU2_CFD/src/numerics/heat/CCentSca_Heat.cpp | 114 -- SU2_CFD/src/numerics/heat/CUpwSca_Heat.cpp | 80 -- SU2_CFD/src/numerics/template.cpp | 70 + .../template/CConvective_Template.cpp | 216 --- .../numerics/template/CSource_Template.cpp | 37 - .../numerics/template/CViscous_Template.cpp | 35 - ...cePieceWise_TransLM.cpp => transition.cpp} | 287 +++- .../transition/CAvgGradCorrected_TransLM.cpp | 108 -- .../numerics/transition/CAvgGrad_TransLM.cpp | 139 -- .../numerics/transition/CUpwLin_TransLM.cpp | 74 - .../numerics/transition/CUpwSca_TransLM.cpp | 72 - .../numerics/turbulent/CAvgGrad_Scalar.cpp | 126 -- .../numerics/turbulent/CAvgGrad_TurbSA.cpp | 59 - .../turbulent/CAvgGrad_TurbSA_Neg.cpp | 76 -- .../numerics/turbulent/CAvgGrad_TurbSST.cpp | 87 -- .../turbulent/CSourcePieceWise_TurbSA.cpp | 202 --- .../CSourcePieceWise_TurbSA_COMP.cpp | 166 --- .../turbulent/CSourcePieceWise_TurbSA_E.cpp | 171 --- .../CSourcePieceWise_TurbSA_E_COMP.cpp | 183 --- .../turbulent/CSourcePieceWise_TurbSA_Neg.cpp | 193 --- .../turbulent/CSourcePieceWise_TurbSST.cpp | 371 ------ .../src/numerics/turbulent/CUpwSca_TurbSA.cpp | 51 - .../numerics/turbulent/CUpwSca_TurbSST.cpp | 61 - .../{CUpwScalar.cpp => turb_convection.cpp} | 77 +- .../src/numerics/turbulent/turb_diffusion.cpp | 266 ++++ .../src/numerics/turbulent/turb_sources.cpp | 1152 ++++++++++++++++ SU2_CFD/src/output/COutput.cpp | 2 +- 196 files changed, 14237 insertions(+), 18268 deletions(-) delete mode 100644 SU2_CFD/include/numerics/continuous_adjoint/CAvgGradCorrected_AdjFlow.hpp delete mode 100644 SU2_CFD/include/numerics/continuous_adjoint/CAvgGradCorrected_AdjTurb.hpp delete mode 100644 SU2_CFD/include/numerics/continuous_adjoint/CAvgGrad_AdjFlow.hpp delete mode 100644 SU2_CFD/include/numerics/continuous_adjoint/CAvgGrad_AdjTurb.hpp delete mode 100644 SU2_CFD/include/numerics/continuous_adjoint/CCentJST_AdjFlow.hpp delete mode 100644 SU2_CFD/include/numerics/continuous_adjoint/CCentLax_AdjFlow.hpp delete mode 100644 SU2_CFD/include/numerics/continuous_adjoint/CSourceAxisymmetric_AdjFlow.hpp delete mode 100644 SU2_CFD/include/numerics/continuous_adjoint/CSourceConservative_AdjFlow.hpp delete mode 100644 SU2_CFD/include/numerics/continuous_adjoint/CSourceConservative_AdjTurb.hpp delete mode 100644 SU2_CFD/include/numerics/continuous_adjoint/CSourcePieceWise_AdjTurb.hpp delete mode 100644 SU2_CFD/include/numerics/continuous_adjoint/CSourceRotatingFrame_AdjFlow.hpp delete mode 100644 SU2_CFD/include/numerics/continuous_adjoint/CSourceViscous_AdjFlow.hpp delete mode 100644 SU2_CFD/include/numerics/continuous_adjoint/CUpwLin_AdjTurb.hpp delete mode 100644 SU2_CFD/include/numerics/continuous_adjoint/CUpwRoe_AdjFlow.hpp delete mode 100644 SU2_CFD/include/numerics/continuous_adjoint/CUpwSca_AdjTurb.hpp create mode 100644 SU2_CFD/include/numerics/continuous_adjoint/adj_convection.hpp create mode 100644 SU2_CFD/include/numerics/continuous_adjoint/adj_diffusion.hpp create mode 100644 SU2_CFD/include/numerics/continuous_adjoint/adj_sources.hpp delete mode 100644 SU2_CFD/include/numerics/elasticity/CFEAMeshElasticity.hpp delete mode 100644 SU2_CFD/include/numerics/elasticity/CFEM_DielectricElastomer.hpp delete mode 100644 SU2_CFD/include/numerics/elasticity/CFEM_IdealDE.hpp delete mode 100644 SU2_CFD/include/numerics/elasticity/CFEM_Knowles_NearInc.hpp delete mode 100644 SU2_CFD/include/numerics/elasticity/CFEM_NeoHookean_Comp.hpp create mode 100644 SU2_CFD/include/numerics/elasticity/nonlinear_models.hpp create mode 100644 SU2_CFD/include/numerics/flow/convection/ausm_slau.hpp create mode 100644 SU2_CFD/include/numerics/flow/convection/centered.hpp rename SU2_CFD/include/numerics/flow/{convection_upwind/CUpwCUSP_Flow.hpp => convection/cusp.hpp} (93%) rename SU2_CFD/include/numerics/flow/{convection_upwind/CUpwFDSInc_Flow.hpp => convection/fds.hpp} (95%) rename SU2_CFD/include/numerics/flow/{convection_upwind/CUpwMSW_Flow.hpp => convection/fvs.hpp} (94%) rename SU2_CFD/include/numerics/flow/{convection_upwind/CUpwGeneralHLLC_Flow.hpp => convection/hllc.hpp} (62%) create mode 100644 SU2_CFD/include/numerics/flow/convection/roe.hpp delete mode 100644 SU2_CFD/include/numerics/flow/convection_centered/CCentBase_Flow.hpp delete mode 100644 SU2_CFD/include/numerics/flow/convection_centered/CCentJSTInc_Flow.hpp delete mode 100644 SU2_CFD/include/numerics/flow/convection_centered/CCentJST_Flow.hpp delete mode 100644 SU2_CFD/include/numerics/flow/convection_centered/CCentJST_KE_Flow.hpp delete mode 100644 SU2_CFD/include/numerics/flow/convection_centered/CCentLaxInc_Flow.hpp delete mode 100644 SU2_CFD/include/numerics/flow/convection_centered/CCentLax_Flow.hpp delete mode 100644 SU2_CFD/include/numerics/flow/convection_upwind/CUpwAUSMPLUSUP2_Flow.hpp delete mode 100644 SU2_CFD/include/numerics/flow/convection_upwind/CUpwAUSMPLUSUP_Flow.hpp delete mode 100644 SU2_CFD/include/numerics/flow/convection_upwind/CUpwAUSMPLUS_SLAU_Base_Flow.hpp delete mode 100644 SU2_CFD/include/numerics/flow/convection_upwind/CUpwAUSM_Flow.hpp delete mode 100644 SU2_CFD/include/numerics/flow/convection_upwind/CUpwGeneralRoe_Flow.hpp delete mode 100644 SU2_CFD/include/numerics/flow/convection_upwind/CUpwHLLC_Flow.hpp delete mode 100644 SU2_CFD/include/numerics/flow/convection_upwind/CUpwL2Roe_Flow.hpp delete mode 100644 SU2_CFD/include/numerics/flow/convection_upwind/CUpwLMRoe_Flow.hpp delete mode 100644 SU2_CFD/include/numerics/flow/convection_upwind/CUpwRoeBase_Flow.hpp delete mode 100644 SU2_CFD/include/numerics/flow/convection_upwind/CUpwRoe_Flow.hpp delete mode 100644 SU2_CFD/include/numerics/flow/convection_upwind/CUpwSLAU_Flow.hpp delete mode 100644 SU2_CFD/include/numerics/flow/convection_upwind/CUpwTurkel_Flow.hpp delete mode 100644 SU2_CFD/include/numerics/flow/diffusion/CAvgGradInc_Flow.hpp delete mode 100644 SU2_CFD/include/numerics/flow/diffusion/CAvgGrad_Flow.hpp delete mode 100644 SU2_CFD/include/numerics/flow/diffusion/CGeneralAvgGrad_Flow.hpp rename SU2_CFD/include/numerics/flow/{diffusion/CAvgGrad_Base.hpp => flow_diffusion.hpp} (56%) create mode 100644 SU2_CFD/include/numerics/flow/flow_sources.hpp delete mode 100644 SU2_CFD/include/numerics/flow/sources/CSourceAxisymmetric_Flow.hpp delete mode 100644 SU2_CFD/include/numerics/flow/sources/CSourceBodyForce.hpp delete mode 100644 SU2_CFD/include/numerics/flow/sources/CSourceBoussinesq.hpp delete mode 100644 SU2_CFD/include/numerics/flow/sources/CSourceGravity.hpp delete mode 100644 SU2_CFD/include/numerics/flow/sources/CSourceIncAxisymmetric_Flow.hpp delete mode 100644 SU2_CFD/include/numerics/flow/sources/CSourceIncBodyForce.hpp delete mode 100644 SU2_CFD/include/numerics/flow/sources/CSourceIncRotatingFrame_Flow.hpp delete mode 100644 SU2_CFD/include/numerics/flow/sources/CSourceRotatingFrame_Flow.hpp delete mode 100644 SU2_CFD/include/numerics/flow/sources/CSourceWindGust.hpp create mode 100644 SU2_CFD/include/numerics/heat.hpp delete mode 100644 SU2_CFD/include/numerics/heat/CAvgGradCorrected_Heat.hpp delete mode 100644 SU2_CFD/include/numerics/heat/CAvgGrad_Heat.hpp delete mode 100644 SU2_CFD/include/numerics/heat/CCentSca_Heat.hpp delete mode 100644 SU2_CFD/include/numerics/heat/CUpwSca_Heat.hpp delete mode 100644 SU2_CFD/include/numerics/include_all.hpp create mode 100644 SU2_CFD/include/numerics/template.hpp delete mode 100644 SU2_CFD/include/numerics/template/CConvective_Template.hpp delete mode 100644 SU2_CFD/include/numerics/template/CSource_Template.hpp delete mode 100644 SU2_CFD/include/numerics/template/CViscous_Template.hpp create mode 100644 SU2_CFD/include/numerics/transition.hpp delete mode 100644 SU2_CFD/include/numerics/transition/CAvgGradCorrected_TransLM.hpp delete mode 100644 SU2_CFD/include/numerics/transition/CAvgGrad_TransLM.hpp delete mode 100644 SU2_CFD/include/numerics/transition/CSourcePieceWise_TransLM.hpp delete mode 100644 SU2_CFD/include/numerics/transition/CUpwLin_TransLM.hpp delete mode 100644 SU2_CFD/include/numerics/transition/CUpwSca_TransLM.hpp delete mode 100644 SU2_CFD/include/numerics/turbulent/CAvgGrad_Scalar.hpp delete mode 100644 SU2_CFD/include/numerics/turbulent/CAvgGrad_TurbSA.hpp delete mode 100644 SU2_CFD/include/numerics/turbulent/CAvgGrad_TurbSA_Neg.hpp delete mode 100644 SU2_CFD/include/numerics/turbulent/CAvgGrad_TurbSST.hpp delete mode 100644 SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA.hpp delete mode 100644 SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA_COMP.hpp delete mode 100644 SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA_E.hpp delete mode 100644 SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA_E_COMP.hpp delete mode 100644 SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA_Neg.hpp delete mode 100644 SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSST.hpp delete mode 100644 SU2_CFD/include/numerics/turbulent/CUpwSca_TurbSA.hpp delete mode 100644 SU2_CFD/include/numerics/turbulent/CUpwSca_TurbSST.hpp rename SU2_CFD/include/numerics/turbulent/{CUpwScalar.hpp => turb_convection.hpp} (59%) create mode 100644 SU2_CFD/include/numerics/turbulent/turb_diffusion.hpp create mode 100644 SU2_CFD/include/numerics/turbulent/turb_sources.hpp delete mode 100644 SU2_CFD/src/numerics/continuous_adjoint/CAvgGradCorrected_AdjFlow.cpp delete mode 100644 SU2_CFD/src/numerics/continuous_adjoint/CAvgGradCorrected_AdjTurb.cpp delete mode 100644 SU2_CFD/src/numerics/continuous_adjoint/CAvgGrad_AdjFlow.cpp delete mode 100644 SU2_CFD/src/numerics/continuous_adjoint/CAvgGrad_AdjTurb.cpp delete mode 100644 SU2_CFD/src/numerics/continuous_adjoint/CCentJST_AdjFlow.cpp delete mode 100644 SU2_CFD/src/numerics/continuous_adjoint/CCentLax_AdjFlow.cpp delete mode 100644 SU2_CFD/src/numerics/continuous_adjoint/CSourceAxisymmetric_AdjFlow.cpp delete mode 100644 SU2_CFD/src/numerics/continuous_adjoint/CSourceConservative_AdjFlow.cpp delete mode 100644 SU2_CFD/src/numerics/continuous_adjoint/CSourceConservative_AdjTurb.cpp delete mode 100644 SU2_CFD/src/numerics/continuous_adjoint/CSourcePieceWise_AdjTurb.cpp delete mode 100644 SU2_CFD/src/numerics/continuous_adjoint/CSourceRotatingFrame_AdjFlow.cpp delete mode 100644 SU2_CFD/src/numerics/continuous_adjoint/CSourceViscous_AdjFlow.cpp delete mode 100644 SU2_CFD/src/numerics/continuous_adjoint/CUpwLin_AdjTurb.cpp delete mode 100644 SU2_CFD/src/numerics/continuous_adjoint/CUpwRoe_AdjFlow.cpp delete mode 100644 SU2_CFD/src/numerics/continuous_adjoint/CUpwSca_AdjTurb.cpp create mode 100644 SU2_CFD/src/numerics/continuous_adjoint/adj_convection.cpp create mode 100644 SU2_CFD/src/numerics/continuous_adjoint/adj_diffusion.cpp create mode 100644 SU2_CFD/src/numerics/continuous_adjoint/adj_sources.cpp delete mode 100644 SU2_CFD/src/numerics/elasticity/CFEAMeshElasticity.cpp delete mode 100644 SU2_CFD/src/numerics/elasticity/CFEM_DielectricElastomer.cpp delete mode 100644 SU2_CFD/src/numerics/elasticity/CFEM_IdealDE.cpp delete mode 100644 SU2_CFD/src/numerics/elasticity/CFEM_Knowles_NearInc.cpp delete mode 100644 SU2_CFD/src/numerics/elasticity/CFEM_NeoHookean_Comp.cpp create mode 100644 SU2_CFD/src/numerics/elasticity/nonlinear_models.cpp create mode 100644 SU2_CFD/src/numerics/flow/convection/ausm_slau.cpp create mode 100644 SU2_CFD/src/numerics/flow/convection/centered.cpp rename SU2_CFD/src/numerics/flow/{convection_upwind/CUpwCUSP_Flow.cpp => convection/cusp.cpp} (97%) rename SU2_CFD/src/numerics/flow/{convection_upwind/CUpwFDSInc_Flow.cpp => convection/fds.cpp} (98%) rename SU2_CFD/src/numerics/flow/{convection_upwind/CUpwMSW_Flow.cpp => convection/fvs.cpp} (97%) create mode 100644 SU2_CFD/src/numerics/flow/convection/hllc.cpp create mode 100644 SU2_CFD/src/numerics/flow/convection/roe.cpp delete mode 100644 SU2_CFD/src/numerics/flow/convection_centered/CCentBase_Flow.cpp delete mode 100644 SU2_CFD/src/numerics/flow/convection_centered/CCentJSTInc_Flow.cpp delete mode 100644 SU2_CFD/src/numerics/flow/convection_centered/CCentJST_Flow.cpp delete mode 100644 SU2_CFD/src/numerics/flow/convection_centered/CCentJST_KE_Flow.cpp delete mode 100644 SU2_CFD/src/numerics/flow/convection_centered/CCentLaxInc_Flow.cpp delete mode 100644 SU2_CFD/src/numerics/flow/convection_centered/CCentLax_Flow.cpp delete mode 100644 SU2_CFD/src/numerics/flow/convection_upwind/CUpwAUSMPLUSUP2_Flow.cpp delete mode 100644 SU2_CFD/src/numerics/flow/convection_upwind/CUpwAUSMPLUSUP_Flow.cpp delete mode 100644 SU2_CFD/src/numerics/flow/convection_upwind/CUpwAUSMPLUS_SLAU_Base_Flow.cpp delete mode 100644 SU2_CFD/src/numerics/flow/convection_upwind/CUpwAUSM_Flow.cpp delete mode 100644 SU2_CFD/src/numerics/flow/convection_upwind/CUpwGeneralHLLC_Flow.cpp delete mode 100644 SU2_CFD/src/numerics/flow/convection_upwind/CUpwGeneralRoe_Flow.cpp delete mode 100644 SU2_CFD/src/numerics/flow/convection_upwind/CUpwHLLC_Flow.cpp delete mode 100644 SU2_CFD/src/numerics/flow/convection_upwind/CUpwL2Roe_Flow.cpp delete mode 100644 SU2_CFD/src/numerics/flow/convection_upwind/CUpwLMRoe_Flow.cpp delete mode 100644 SU2_CFD/src/numerics/flow/convection_upwind/CUpwRoeBase_Flow.cpp delete mode 100644 SU2_CFD/src/numerics/flow/convection_upwind/CUpwRoe_Flow.cpp delete mode 100644 SU2_CFD/src/numerics/flow/convection_upwind/CUpwSLAU_Flow.cpp delete mode 100644 SU2_CFD/src/numerics/flow/convection_upwind/CUpwTurkel_Flow.cpp delete mode 100644 SU2_CFD/src/numerics/flow/diffusion/CAvgGradInc_Flow.cpp delete mode 100644 SU2_CFD/src/numerics/flow/diffusion/CAvgGrad_Base.cpp delete mode 100644 SU2_CFD/src/numerics/flow/diffusion/CAvgGrad_Flow.cpp delete mode 100644 SU2_CFD/src/numerics/flow/diffusion/CGeneralAvgGrad_Flow.cpp create mode 100644 SU2_CFD/src/numerics/flow/flow_diffusion.cpp create mode 100644 SU2_CFD/src/numerics/flow/flow_sources.cpp delete mode 100644 SU2_CFD/src/numerics/flow/sources/CSourceAxisymmetric_Flow.cpp delete mode 100644 SU2_CFD/src/numerics/flow/sources/CSourceBodyForce.cpp delete mode 100644 SU2_CFD/src/numerics/flow/sources/CSourceBoussinesq.cpp delete mode 100644 SU2_CFD/src/numerics/flow/sources/CSourceGravity.cpp delete mode 100644 SU2_CFD/src/numerics/flow/sources/CSourceIncAxisymmetric_Flow.cpp delete mode 100644 SU2_CFD/src/numerics/flow/sources/CSourceIncBodyForce.cpp delete mode 100644 SU2_CFD/src/numerics/flow/sources/CSourceIncRotatingFrame_Flow.cpp delete mode 100644 SU2_CFD/src/numerics/flow/sources/CSourceRotatingFrame_Flow.cpp delete mode 100644 SU2_CFD/src/numerics/flow/sources/CSourceWindGust.cpp create mode 100644 SU2_CFD/src/numerics/heat.cpp delete mode 100644 SU2_CFD/src/numerics/heat/CAvgGradCorrected_Heat.cpp delete mode 100644 SU2_CFD/src/numerics/heat/CAvgGrad_Heat.cpp delete mode 100644 SU2_CFD/src/numerics/heat/CCentSca_Heat.cpp delete mode 100644 SU2_CFD/src/numerics/heat/CUpwSca_Heat.cpp create mode 100644 SU2_CFD/src/numerics/template.cpp delete mode 100644 SU2_CFD/src/numerics/template/CConvective_Template.cpp delete mode 100644 SU2_CFD/src/numerics/template/CSource_Template.cpp delete mode 100644 SU2_CFD/src/numerics/template/CViscous_Template.cpp rename SU2_CFD/src/numerics/{transition/CSourcePieceWise_TransLM.cpp => transition.cpp} (60%) delete mode 100644 SU2_CFD/src/numerics/transition/CAvgGradCorrected_TransLM.cpp delete mode 100644 SU2_CFD/src/numerics/transition/CAvgGrad_TransLM.cpp delete mode 100644 SU2_CFD/src/numerics/transition/CUpwLin_TransLM.cpp delete mode 100644 SU2_CFD/src/numerics/transition/CUpwSca_TransLM.cpp delete mode 100644 SU2_CFD/src/numerics/turbulent/CAvgGrad_Scalar.cpp delete mode 100644 SU2_CFD/src/numerics/turbulent/CAvgGrad_TurbSA.cpp delete mode 100644 SU2_CFD/src/numerics/turbulent/CAvgGrad_TurbSA_Neg.cpp delete mode 100644 SU2_CFD/src/numerics/turbulent/CAvgGrad_TurbSST.cpp delete mode 100644 SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSA.cpp delete mode 100644 SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSA_COMP.cpp delete mode 100644 SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSA_E.cpp delete mode 100644 SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSA_E_COMP.cpp delete mode 100644 SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSA_Neg.cpp delete mode 100644 SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSST.cpp delete mode 100644 SU2_CFD/src/numerics/turbulent/CUpwSca_TurbSA.cpp delete mode 100644 SU2_CFD/src/numerics/turbulent/CUpwSca_TurbSST.cpp rename SU2_CFD/src/numerics/turbulent/{CUpwScalar.cpp => turb_convection.cpp} (50%) create mode 100644 SU2_CFD/src/numerics/turbulent/turb_diffusion.cpp create mode 100644 SU2_CFD/src/numerics/turbulent/turb_sources.cpp diff --git a/Common/include/option_structure.hpp b/Common/include/option_structure.hpp index 9c032b88fe5b..30c217f8e41a 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -99,20 +99,20 @@ enum SU2_COMPONENT { SU2_SOL = 6 /*!< \brief Running the SU2_SOL software. */ }; -const unsigned int EXIT_DIVERGENCE = 2; /*!< \brief Exit code (divergence). */ +const unsigned int EXIT_DIVERGENCE = 2; /*!< \brief Exit code (divergence). */ -const unsigned int BUFSIZE = 3000000; /*!< \brief MPI buffer. */ -const unsigned int MAX_PARAMETERS = 10; /*!< \brief Maximum number of parameters for a design variable definition. */ +const unsigned int BUFSIZE = 3000000; /*!< \brief MPI buffer. */ +const unsigned int MAX_PARAMETERS = 10; /*!< \brief Maximum number of parameters for a design variable definition. */ const unsigned int MAX_NUMBER_PERIODIC = 10; /*!< \brief Maximum number of periodic boundary conditions. */ const unsigned int MAX_STRING_SIZE = 200; /*!< \brief Maximum number of domains. */ -const unsigned int MAX_NUMBER_FFD = 15; /*!< \brief Maximum number of FFDBoxes for the FFD. */ -const unsigned int MAX_SOLS = 10; /*!< \brief Maximum number of solutions at the same time (dimension of solution container array). */ -const unsigned int MAX_TERMS = 6; /*!< \brief Maximum number of terms in the numerical equations (dimension of solver container array). */ +const unsigned int MAX_NUMBER_FFD = 15; /*!< \brief Maximum number of FFDBoxes for the FFD. */ +const unsigned int MAX_SOLS = 10; /*!< \brief Maximum number of solutions at the same time (dimension of solution container array). */ +const unsigned int MAX_TERMS = 6; /*!< \brief Maximum number of terms in the numerical equations (dimension of solver container array). */ const unsigned int MAX_ZONES = 3; /*!< \brief Maximum number of zones. */ const unsigned int MAX_FE_KINDS = 4; /*!< \brief Maximum number of Finite Elements. */ -const unsigned int NO_RK_ITER = 0; /*!< \brief No Runge-Kutta iteration. */ +const unsigned int NO_RK_ITER = 0; /*!< \brief No Runge-Kutta iteration. */ -const unsigned int OVERHEAD = 4; /*!< \brief Overhead space above nMarker when allocating space for boundary elems (MPI + periodic). */ +const unsigned int OVERHEAD = 4; /*!< \brief Overhead space above nMarker when allocating space for boundary elems (MPI + periodic). */ const unsigned int MESH_0 = 0; /*!< \brief Definition of the finest grid level. */ const unsigned int MESH_1 = 1; /*!< \brief Definition of the finest grid level. */ @@ -121,13 +121,13 @@ const unsigned int ZONE_1 = 1; /*!< \brief Definition of the second grid domain const unsigned int INST_0 = 0; /*!< \brief Definition of the first instance per grid level. */ const su2double STANDARD_GRAVITY = 9.80665; /*!< \brief Acceleration due to gravity at surface of earth. */ -const su2double UNIVERSAL_GAS_CONSTANT = 8.3144598; /*!< \brief Universal gas constant in J/(mol*K) */ +const su2double UNIVERSAL_GAS_CONSTANT = 8.3144598; /*!< \brief Universal gas constant in J/(mol*K) */ -const su2double EPS = 1.0E-16; /*!< \brief Error scale. */ -const su2double TURB_EPS = 1.0E-16; /*!< \brief Turbulent Error scale. */ +const su2double EPS = 1.0E-16; /*!< \brief Error scale. */ +const su2double TURB_EPS = 1.0E-16; /*!< \brief Turbulent Error scale. */ -const su2double ONE2 = 0.5; /*!< \brief One divided by two. */ -const su2double TWO3 = 2.0 / 3.0; /*!< \brief Two divided by three. */ +const su2double ONE2 = 0.5; /*!< \brief One divided by two. */ +const su2double TWO3 = 2.0 / 3.0; /*!< \brief Two divided by three. */ const su2double FOUR3 = 4.0 / 3.0; /*!< \brief Four divided by three. */ const su2double PI_NUMBER = 4.0 * atan(1.0); /*!< \brief Pi number. */ @@ -164,7 +164,7 @@ const int SU2_CONN_SKIP = 2; /*!< \brief Offset to skip the globalID and VTK enum ANSWER { NONE = 0, NO = 0, /*!< \brief Boolean definition of no. */ - YES = 1 /*!< \brief Boolean definition of yes. */ + YES = 1 /*!< \brief Boolean definition of yes. */ }; /*! @@ -268,10 +268,10 @@ static const map Multizone_Map = CCreateMap FSI_Fluid_Solver_Map = CCreateMap diff --git a/SU2_CFD/include/numerics/CNumerics.hpp b/SU2_CFD/include/numerics/CNumerics.hpp index 6ca817e419c3..ea9e6a3529dd 100644 --- a/SU2_CFD/include/numerics/CNumerics.hpp +++ b/SU2_CFD/include/numerics/CNumerics.hpp @@ -1,6 +1,6 @@ /*! * \file CNumerics.hpp - * \brief Delaration of numerics class CNumerics, the + * \brief Delaration of the base numerics class, the * implementation is in the CNumerics.cpp file. * \author F. Palacios, T. Economon * \version 7.0.0 "Blackbird" @@ -1268,4 +1268,3 @@ class CNumerics { * /brief Alias for a "do nothing" source term class */ using CSourceNothing = CNumerics; - diff --git a/SU2_CFD/include/numerics/continuous_adjoint/CAvgGradCorrected_AdjFlow.hpp b/SU2_CFD/include/numerics/continuous_adjoint/CAvgGradCorrected_AdjFlow.hpp deleted file mode 100644 index 7ae8ad317621..000000000000 --- a/SU2_CFD/include/numerics/continuous_adjoint/CAvgGradCorrected_AdjFlow.hpp +++ /dev/null @@ -1,78 +0,0 @@ -/*! - * \file CAvgGradCorrected_AdjFlow.hpp - * \brief Delaration of numerics class CAvgGradCorrected_AdjFlow, the - * implementation is in the CAvgGradCorrected_AdjFlow.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../CNumerics.hpp" - -/*! - * \class CAvgGradCorrected_AdjFlow - * \brief Class for computing the adjoint viscous terms, including correction. - * \ingroup ViscDiscr - * \author A. Bueno. - */ -class CAvgGradCorrected_AdjFlow : public CNumerics { -private: - su2double *Velocity_i; /*!< \brief Auxiliary vector for storing the velocity of point i. */ - su2double *Velocity_j; /*!< \brief Auxiliary vector for storing the velocity of point j. */ - su2double *Mean_Velocity; - su2double **Mean_GradPsiVar; /*!< \brief Counter for dimensions of the problem. */ - su2double *Edge_Vector; /*!< \brief Vector going from node i to node j. */ - su2double *Proj_Mean_GradPsiVar_Edge; /*!< \brief Projection of Mean_GradPsiVar onto Edge_Vector. */ - su2double *Mean_GradPsiE; /*!< \brief Counter for dimensions of the problem. */ - su2double **Mean_GradPhi; /*!< \brief Counter for dimensions of the problem. */ - bool implicit; /*!< \brief Boolean controlling Jacobian calculations. */ - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CAvgGradCorrected_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CAvgGradCorrected_AdjFlow(void); - - /*! - * \brief Compute the adjoint flow viscous residual in a non-conservative way using an average of gradients and derivative correction. - * \param[out] val_residual_i - Pointer to the viscous residual at point i. - * \param[out] val_residual_j - Pointer to the viscous residual at point j. - * \param[out] val_Jacobian_ii - Jacobian of the numerical method at node i (implicit computation) from node i. - * \param[out] val_Jacobian_ij - Jacobian of the numerical method at node i (implicit computation) from node j. - * \param[out] val_Jacobian_ji - Jacobian of the numerical method at node j (implicit computation) from node i. - * \param[out] val_Jacobian_jj - Jacobian of the numerical method at node j (implicit computation) from node j. - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, - su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config); -}; diff --git a/SU2_CFD/include/numerics/continuous_adjoint/CAvgGradCorrected_AdjTurb.hpp b/SU2_CFD/include/numerics/continuous_adjoint/CAvgGradCorrected_AdjTurb.hpp deleted file mode 100644 index 0e207275d28f..000000000000 --- a/SU2_CFD/include/numerics/continuous_adjoint/CAvgGradCorrected_AdjTurb.hpp +++ /dev/null @@ -1,82 +0,0 @@ -/*! - * \file CAvgGradCorrected_AdjTurb.hpp - * \brief Delaration of numerics class CAvgGradCorrected_AdjTurb, the - * implementation is in the CAvgGradCorrected_AdjTurb.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../CNumerics.hpp" - -/*! - * \class CAvgGradCorrected_AdjTurb - * \brief Class for adjoint turbulent using average of gradients with a correction. - * \ingroup ViscDiscr - * \author A. Bueno. - */ -class CAvgGradCorrected_AdjTurb : public CNumerics { -private: - su2double **Mean_GradTurbPsi; - su2double *Proj_Mean_GradTurbPsi_Kappa, *Proj_Mean_GradTurbPsi_Edge, *Proj_Mean_GradTurbPsi_Corrected; - su2double *Edge_Vector; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CAvgGradCorrected_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CAvgGradCorrected_AdjTurb(void); - - /*! - * \brief Compute the adjoint turbulent residual using average of gradients and a derivative correction. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - - /*! - * \overload - * \param[out] val_residual_i - Pointer to the total residual at point i. - * \param[out] val_residual_j - Pointer to the total viscosity residual at point j. - * \param[out] val_Jacobian_ii - Jacobian of the numerical method at node i (implicit computation) from node i. - * \param[out] val_Jacobian_ij - Jacobian of the numerical method at node i (implicit computation) from node j. - * \param[out] val_Jacobian_ji - Jacobian of the numerical method at node j (implicit computation) from node i. - * \param[out] val_Jacobian_jj - Jacobian of the numerical method at node j (implicit computation) from node j. - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, - su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config); -}; diff --git a/SU2_CFD/include/numerics/continuous_adjoint/CAvgGrad_AdjFlow.hpp b/SU2_CFD/include/numerics/continuous_adjoint/CAvgGrad_AdjFlow.hpp deleted file mode 100644 index 69a38e9c85c8..000000000000 --- a/SU2_CFD/include/numerics/continuous_adjoint/CAvgGrad_AdjFlow.hpp +++ /dev/null @@ -1,72 +0,0 @@ -/*! - * \file CAvgGrad_AdjFlow.hpp - * \brief Delaration of numerics class CAvgGrad_AdjFlow, the - * implementation is in the CAvgGrad_AdjFlow.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../CNumerics.hpp" - -/*! - * \class CAvgGrad_AdjFlow - * \brief Class for computing the adjoint viscous terms. - * \ingroup ViscDiscr - * \author F. Palacios - */ -class CAvgGrad_AdjFlow : public CNumerics { -private: - su2double *Velocity_i; /*!< \brief Auxiliary vector for storing the velocity of point i. */ - su2double *Velocity_j; /*!< \brief Auxiliary vector for storing the velocity of point j. */ - su2double *Mean_Velocity; - su2double *Mean_GradPsiE; /*!< \brief Counter for dimensions of the problem. */ - su2double **Mean_GradPhi; /*!< \brief Counter for dimensions of the problem. */ - su2double *Edge_Vector; /*!< \brief Vector going from node i to node j. */ - bool implicit; /*!< \brief Implicit calculus. */ - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CAvgGrad_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CAvgGrad_AdjFlow(void); - - /*! - * \brief Residual computation. - * \param[out] val_residual_i - Pointer to the total residual at point i. - * \param[out] val_residual_j - Pointer to the total residual at point j. - */ - void ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, - su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, - su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config); -}; diff --git a/SU2_CFD/include/numerics/continuous_adjoint/CAvgGrad_AdjTurb.hpp b/SU2_CFD/include/numerics/continuous_adjoint/CAvgGrad_AdjTurb.hpp deleted file mode 100644 index b416cc370d13..000000000000 --- a/SU2_CFD/include/numerics/continuous_adjoint/CAvgGrad_AdjTurb.hpp +++ /dev/null @@ -1,82 +0,0 @@ -/*! - * \file CAvgGrad_AdjTurb.hpp - * \brief Delaration of numerics class CAvgGrad_AdjTurb, the - * implementation is in the CAvgGrad_AdjTurb.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../CNumerics.hpp" - -/*! - * \class CAvgGrad_AdjTurb - * \brief Class for adjoint turbulent using average of gradients with a correction. - * \ingroup ViscDiscr - * \author F. Palacios - */ -class CAvgGrad_AdjTurb : public CNumerics { -private: - su2double **Mean_GradTurbPsi; - su2double *Proj_Mean_GradTurbPsi_Kappa, *Proj_Mean_GradTurbPsi_Edge, *Proj_Mean_GradTurbPsi_Corrected; - su2double *Edge_Vector; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CAvgGrad_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CAvgGrad_AdjTurb(void); - - /*! - * \brief Compute the adjoint turbulent residual using average of gradients and a derivative correction. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - - /*! - * \overload - * \param[out] val_residual_i - Pointer to the total residual at point i. - * \param[out] val_residual_j - Pointer to the total viscosity residual at point j. - * \param[out] val_Jacobian_ii - Jacobian of the numerical method at node i (implicit computation) from node i. - * \param[out] val_Jacobian_ij - Jacobian of the numerical method at node i (implicit computation) from node j. - * \param[out] val_Jacobian_ji - Jacobian of the numerical method at node j (implicit computation) from node i. - * \param[out] val_Jacobian_jj - Jacobian of the numerical method at node j (implicit computation) from node j. - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, - su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config); -}; diff --git a/SU2_CFD/include/numerics/continuous_adjoint/CCentJST_AdjFlow.hpp b/SU2_CFD/include/numerics/continuous_adjoint/CCentJST_AdjFlow.hpp deleted file mode 100644 index ece76ebaa4c9..000000000000 --- a/SU2_CFD/include/numerics/continuous_adjoint/CCentJST_AdjFlow.hpp +++ /dev/null @@ -1,80 +0,0 @@ -/*! - * \file CCentJST_AdjFlow.hpp - * \brief Delaration of numerics class CCentJST_AdjFlow, the - * implementation is in the CCentJST_AdjFlow.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../CNumerics.hpp" - -/*! - * \class CCentJST_AdjFlow - * \brief Class for and adjoint centered scheme - JST. - * \ingroup ConvDiscr - * \author F. Palacios - */ -class CCentJST_AdjFlow : public CNumerics { -private: - su2double *Diff_Psi, *Diff_Lapl; - su2double *Velocity_i, *Velocity_j; - su2double *MeanPhi; - unsigned short iDim, jDim, iVar, jVar; - su2double Residual, ProjVelocity_i, ProjVelocity_j, ProjPhi, ProjPhi_Vel, sq_vel, phis1, phis2; - su2double MeanPsiRho, MeanPsiE, Param_p, Param_Kappa_4, Param_Kappa_2, Local_Lambda_i, Local_Lambda_j, MeanLambda; - su2double Phi_i, Phi_j, sc4, StretchingFactor, Epsilon_4, Epsilon_2; - bool implicit, grid_movement; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CCentJST_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CCentJST_AdjFlow(void); - - /*! - * \brief Compute the adjoint flow residual using a JST method. - * \param[out] val_resconv_i - Pointer to the convective residual at point i. - * \param[out] val_resvisc_i - Pointer to the artificial viscosity residual at point i. - * \param[out] val_resconv_j - Pointer to the convective residual at point j. - * \param[out] val_resvisc_j - Pointer to the artificial viscosity residual at point j. - * \param[out] val_Jacobian_ii - Jacobian of the numerical method at node i (implicit computation) from node i. - * \param[out] val_Jacobian_ij - Jacobian of the numerical method at node i (implicit computation) from node j. - * \param[out] val_Jacobian_ji - Jacobian of the numerical method at node j (implicit computation) from node i. - * \param[out] val_Jacobian_jj - Jacobian of the numerical method at node j (implicit computation) from node j. - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual (su2double *val_resconv_i, su2double *val_resvisc_i, su2double *val_resconv_j, su2double *val_resvisc_j, - su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, - CConfig *config); -}; diff --git a/SU2_CFD/include/numerics/continuous_adjoint/CCentLax_AdjFlow.hpp b/SU2_CFD/include/numerics/continuous_adjoint/CCentLax_AdjFlow.hpp deleted file mode 100644 index 8be0b0c83956..000000000000 --- a/SU2_CFD/include/numerics/continuous_adjoint/CCentLax_AdjFlow.hpp +++ /dev/null @@ -1,80 +0,0 @@ -/*! - * \file CCentLax_AdjFlow.hpp - * \brief Delaration of numerics class CCentLax_AdjFlow, the - * implementation is in the CCentLax_AdjFlow.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../CNumerics.hpp" - -/*! - * \class CCentLax_AdjFlow - * \brief Class for computing the Lax-Friedrich adjoint centered scheme. - * \ingroup ConvDiscr - * \author F. Palacios - */ -class CCentLax_AdjFlow : public CNumerics { -private: - su2double *Diff_Psi; - su2double *Velocity_i, *Velocity_j; - su2double *MeanPhi; - unsigned short iDim, jDim, iVar, jVar; - su2double Residual, ProjVelocity_i, ProjVelocity_j, ProjPhi, ProjPhi_Vel, sq_vel, phis1, phis2, - MeanPsiRho, MeanPsiE, Param_p, Param_Kappa_0, Local_Lambda_i, Local_Lambda_j, MeanLambda, - Phi_i, Phi_j, sc2, StretchingFactor, Epsilon_0; - bool implicit, grid_movement; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CCentLax_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CCentLax_AdjFlow(void); - - /*! - * \brief Compute the adjoint flow residual using a Lax method. - * \param[out] val_resconv_i - Pointer to the convective residual at point i. - * \param[out] val_resvisc_i - Pointer to the artificial viscosity residual at point i. - * \param[out] val_resconv_j - Pointer to the convective residual at point j. - * \param[out] val_resvisc_j - Pointer to the artificial viscosity residual at point j. - * \param[out] val_Jacobian_ii - Jacobian of the numerical method at node i (implicit computation) from node i. - * \param[out] val_Jacobian_ij - Jacobian of the numerical method at node i (implicit computation) from node j. - * \param[out] val_Jacobian_ji - Jacobian of the numerical method at node j (implicit computation) from node i. - * \param[out] val_Jacobian_jj - Jacobian of the numerical method at node j (implicit computation) from node j. - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual (su2double *val_resconv_i, su2double *val_resvisc_i, su2double *val_resconv_j, su2double *val_resvisc_j, - su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, - CConfig *config); -}; diff --git a/SU2_CFD/include/numerics/continuous_adjoint/CSourceAxisymmetric_AdjFlow.hpp b/SU2_CFD/include/numerics/continuous_adjoint/CSourceAxisymmetric_AdjFlow.hpp deleted file mode 100644 index ed2bde3ffac7..000000000000 --- a/SU2_CFD/include/numerics/continuous_adjoint/CSourceAxisymmetric_AdjFlow.hpp +++ /dev/null @@ -1,61 +0,0 @@ -/*! - * \file CSourceAxisymmetric_AdjFlow.hpp - * \brief Delaration of numerics class CSourceAxisymmetric_AdjFlow, the - * implementation is in the CSourceAxisymmetric_AdjFlow.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../CNumerics.hpp" - -/*! - * \class CSourceAxisymmetric_AdjFlow - * \brief Class for source term for solving axisymmetric problems. - * \ingroup SourceDiscr - * \author F. Palacios - */ -class CSourceAxisymmetric_AdjFlow : public CNumerics { -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourceAxisymmetric_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourceAxisymmetric_AdjFlow(void); - - /*! - * \brief Residual of the rotational frame source term. - * \param[out] val_residual - Pointer to the total residual. - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **Jacobian_i, CConfig *config); -}; diff --git a/SU2_CFD/include/numerics/continuous_adjoint/CSourceConservative_AdjFlow.hpp b/SU2_CFD/include/numerics/continuous_adjoint/CSourceConservative_AdjFlow.hpp deleted file mode 100644 index 382ef3fcd495..000000000000 --- a/SU2_CFD/include/numerics/continuous_adjoint/CSourceConservative_AdjFlow.hpp +++ /dev/null @@ -1,59 +0,0 @@ -/*! - * \file CSourceConservative_AdjFlow.hpp - * \brief Delaration of numerics class CSourceConservative_AdjFlow, the - * implementation is in the CSourceConservative_AdjFlow.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../CNumerics.hpp" - -class CSourceConservative_AdjFlow : public CNumerics { -private: - su2double *Velocity, *Residual_i, *Residual_j, *Mean_Residual; - su2double **Mean_PrimVar_Grad; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourceConservative_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourceConservative_AdjFlow(void); - - /*! - * \brief Source term integration using a conservative scheme. - * \param[out] val_residual - Pointer to the total residual. - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, CConfig *config); -}; diff --git a/SU2_CFD/include/numerics/continuous_adjoint/CSourceConservative_AdjTurb.hpp b/SU2_CFD/include/numerics/continuous_adjoint/CSourceConservative_AdjTurb.hpp deleted file mode 100644 index b06639ad4423..000000000000 --- a/SU2_CFD/include/numerics/continuous_adjoint/CSourceConservative_AdjTurb.hpp +++ /dev/null @@ -1,63 +0,0 @@ -/*! - * \file CSourceConservative_AdjTurb.hpp - * \brief Delaration of numerics class CSourceConservative_AdjTurb, the - * implementation is in the CSourceConservative_AdjTurb.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../CNumerics.hpp" - -/*! - * \class CSourceConservative_AdjTurb - * \brief Class for source term integration in adjoint turbulent problem using a conservative scheme. - * \ingroup SourceDiscr - * \author A. Bueno. - */ -class CSourceConservative_AdjTurb : public CNumerics { -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourceConservative_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourceConservative_AdjTurb(void); - - /*! - * \brief Source term integration using a conservative scheme. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); -}; diff --git a/SU2_CFD/include/numerics/continuous_adjoint/CSourcePieceWise_AdjTurb.hpp b/SU2_CFD/include/numerics/continuous_adjoint/CSourcePieceWise_AdjTurb.hpp deleted file mode 100644 index f13e64d45d77..000000000000 --- a/SU2_CFD/include/numerics/continuous_adjoint/CSourcePieceWise_AdjTurb.hpp +++ /dev/null @@ -1,66 +0,0 @@ -/*! - * \file CSourcePieceWise_AdjTurb.hpp - * \brief Delaration of numerics class CSourcePieceWise_AdjTurb, the - * implementation is in the CSourcePieceWise_AdjTurb.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../CNumerics.hpp" - -/*! - * \class CSourcePieceWise_AdjTurb - * \brief Class for source term integration of the adjoint turbulent equation. - * \ingroup SourceDiscr - * \author A. Bueno. - */ -class CSourcePieceWise_AdjTurb : public CNumerics { -private: - su2double **tau, *Velocity; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourcePieceWise_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourcePieceWise_AdjTurb(void); - - /*! - * \brief Source term integration of the adjoint turbulence equation. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); -}; diff --git a/SU2_CFD/include/numerics/continuous_adjoint/CSourceRotatingFrame_AdjFlow.hpp b/SU2_CFD/include/numerics/continuous_adjoint/CSourceRotatingFrame_AdjFlow.hpp deleted file mode 100644 index a1901a79dfd6..000000000000 --- a/SU2_CFD/include/numerics/continuous_adjoint/CSourceRotatingFrame_AdjFlow.hpp +++ /dev/null @@ -1,62 +0,0 @@ -/*! - * \file CSourceRotatingFrame_AdjFlow.hpp - * \brief Delaration of numerics class CSourceRotatingFrame_AdjFlow, the - * implementation is in the CSourceRotatingFrame_AdjFlow.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../CNumerics.hpp" - -/*! - * \class CSourceRotatingFrame_AdjFlow - * \brief Source term class for rotating frame adjoint. - * \ingroup SourceDiscr - * \author T. Economon. - */ -class CSourceRotatingFrame_AdjFlow : public CNumerics { -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourceRotatingFrame_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourceRotatingFrame_AdjFlow(void); - - /*! - * \brief Residual of the adjoint rotating frame source term. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config); -}; diff --git a/SU2_CFD/include/numerics/continuous_adjoint/CSourceViscous_AdjFlow.hpp b/SU2_CFD/include/numerics/continuous_adjoint/CSourceViscous_AdjFlow.hpp deleted file mode 100644 index 8b762d595858..000000000000 --- a/SU2_CFD/include/numerics/continuous_adjoint/CSourceViscous_AdjFlow.hpp +++ /dev/null @@ -1,66 +0,0 @@ -/*! - * \file CSourceViscous_AdjFlow.hpp - * \brief Delaration of numerics class CSourceViscous_AdjFlow, the - * implementation is in the CSourceViscous_AdjFlow.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../CNumerics.hpp" - -/*! - * \class CSourceViscous_AdjFlow - * \brief Class for source term integration in adjoint problem. - * \ingroup SourceDiscr - * \author F. Palacios - */ -class CSourceViscous_AdjFlow : public CNumerics { -private: - su2double *Velocity, *GradDensity, *GradInvDensity, *dPoDensity2, *alpha, *beta, *Sigma_5_vec; - su2double **GradVel_o_Rho, **sigma, **Sigma_phi, **Sigma_5_Tensor, **Sigma; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourceViscous_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourceViscous_AdjFlow(void); - - /*! - * \brief Source term integration of the flow adjoint equation. - * \param[out] val_residual - Pointer to the total residual. - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual (su2double *val_residual, CConfig *config); - -}; diff --git a/SU2_CFD/include/numerics/continuous_adjoint/CUpwLin_AdjTurb.hpp b/SU2_CFD/include/numerics/continuous_adjoint/CUpwLin_AdjTurb.hpp deleted file mode 100644 index 66dd41f00526..000000000000 --- a/SU2_CFD/include/numerics/continuous_adjoint/CUpwLin_AdjTurb.hpp +++ /dev/null @@ -1,66 +0,0 @@ -/*! - * \file CUpwLin_AdjTurb.hpp - * \brief Delaration of numerics class CUpwLin_AdjTurb, the - * implementation is in the CUpwLin_AdjTurb.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../CNumerics.hpp" - -/*! - * \class CUpwLin_AdjTurb - * \brief Class for performing a linear upwind solver for the adjoint turbulence equations. - * \ingroup ConvDiscr - * \author A. Bueno. - */ -class CUpwLin_AdjTurb : public CNumerics { -private: - su2double *Velocity_i; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwLin_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwLin_AdjTurb(void); - - /*! - * \brief Compute the adjoint upwind flux between two nodes i and j. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual (su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); -}; diff --git a/SU2_CFD/include/numerics/continuous_adjoint/CUpwRoe_AdjFlow.hpp b/SU2_CFD/include/numerics/continuous_adjoint/CUpwRoe_AdjFlow.hpp deleted file mode 100644 index a9619fa1efa5..000000000000 --- a/SU2_CFD/include/numerics/continuous_adjoint/CUpwRoe_AdjFlow.hpp +++ /dev/null @@ -1,81 +0,0 @@ -/*! - * \file CUpwRoe_AdjFlow.hpp - * \brief Delaration of numerics class CUpwRoe_AdjFlow, the - * implementation is in the CUpwRoe_AdjFlow.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../CNumerics.hpp" - -/*! - * \class CUpwRoe_AdjFlow - * \brief Class for solving an approximate Riemann solver of Roe - * for the adjoint flow equations. - * \ingroup ConvDiscr - * \author F. Palacios - */ -class CUpwRoe_AdjFlow : public CNumerics { -private: - su2double *Residual_Roe; - su2double area, Sx, Sy, Sz, rarea, nx, ny, nz, rho_l, u_l, v_l, w_l, h_l, rho_r, - u_r, v_r, w_r, h_r, psi1, psi2, psi3, psi4, psi5; - su2double h, u, v, w, c, psi1_l, psi2_l, psi3_l, psi4_l, psi5_l, - psi1_r, psi2_r, psi3_r, psi4_r, psi5_r, q_l, q_r, Q_l, Q_r, vn, - rrho_l, weight, rweight1, cc; - su2double l1psi, l2psi, absQ, absQp, absQm, q2, alpha, beta_u, beta_v, beta_w, Q, l1l2p, l1l2m, eta; - su2double RoeDensity, RoeSoundSpeed, *RoeVelocity, *Lambda, *Velocity_i, *Velocity_j, **ProjFlux_i, **ProjFlux_j, - Proj_ModJac_Tensor_ij, **Proj_ModJac_Tensor, Energy_i, Energy_j, **P_Tensor, **invP_Tensor; - unsigned short iDim, iVar, jVar, kVar; - bool implicit, grid_movement; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwRoe_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwRoe_AdjFlow(void); - - /*! - * \brief Compute the adjoint Roe's flux between two nodes i and j. - * \param[out] val_residual_i - Pointer to the total residual at point i. - * \param[out] val_residual_j - Pointer to the total residual at point j. - * \param[out] val_Jacobian_ii - Jacobian of the numerical method at node i (implicit computation) from node i. - * \param[out] val_Jacobian_ij - Jacobian of the numerical method at node i (implicit computation) from node j. - * \param[out] val_Jacobian_ji - Jacobian of the numerical method at node j (implicit computation) from node i. - * \param[out] val_Jacobian_jj - Jacobian of the numerical method at node j (implicit computation) from node j. - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, su2double **val_Jacobian_ii, - su2double **val_Jacobian_ij, su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config); -}; diff --git a/SU2_CFD/include/numerics/continuous_adjoint/CUpwSca_AdjTurb.hpp b/SU2_CFD/include/numerics/continuous_adjoint/CUpwSca_AdjTurb.hpp deleted file mode 100644 index dab23d664dca..000000000000 --- a/SU2_CFD/include/numerics/continuous_adjoint/CUpwSca_AdjTurb.hpp +++ /dev/null @@ -1,69 +0,0 @@ -/*! - * \file CUpwSca_AdjTurb.hpp - * \brief Delaration of numerics class CUpwSca_AdjTurb, the - * implementation is in the CUpwSca_AdjTurb.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../CNumerics.hpp" - -/*! - * \class CUpwSca_AdjTurb - * \brief Class for doing a scalar upwind solver for the adjoint turbulence equations. - * \ingroup ConvDiscr - * \author A. Bueno. - */ -class CUpwSca_AdjTurb : public CNumerics { -private: - su2double *Velocity_i, *Velocity_j; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwSca_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwSca_AdjTurb(void); - - /*! - * \param[out] val_residual_i - Pointer to the total residual at point i. - * \param[out] val_residual_j - Pointer to the total viscosity residual at point j. - * \param[out] val_Jacobian_ii - Jacobian of the numerical method at node i (implicit computation) from node i. - * \param[out] val_Jacobian_ij - Jacobian of the numerical method at node i (implicit computation) from node j. - * \param[out] val_Jacobian_ji - Jacobian of the numerical method at node j (implicit computation) from node i. - * \param[out] val_Jacobian_jj - Jacobian of the numerical method at node j (implicit computation) from node j. - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, - su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config); -}; diff --git a/SU2_CFD/include/numerics/continuous_adjoint/adj_convection.hpp b/SU2_CFD/include/numerics/continuous_adjoint/adj_convection.hpp new file mode 100644 index 000000000000..552be04ba394 --- /dev/null +++ b/SU2_CFD/include/numerics/continuous_adjoint/adj_convection.hpp @@ -0,0 +1,254 @@ +/*! + * \file adj_convection.hpp + * \brief Delarations of numerics classes for continuous adjoint + * convective discretization. Implemented in adj_convection.cpp. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../CNumerics.hpp" + +/*! + * \class CCentLax_AdjFlow + * \brief Class for computing the Lax-Friedrich adjoint centered scheme. + * \ingroup ConvDiscr + * \author F. Palacios + */ +class CCentLax_AdjFlow : public CNumerics { +private: + su2double *Diff_Psi; + su2double *Velocity_i, *Velocity_j; + su2double *MeanPhi; + unsigned short iDim, jDim, iVar, jVar; + su2double Residual, ProjVelocity_i, ProjVelocity_j, ProjPhi, ProjPhi_Vel, sq_vel, phis1, phis2, + MeanPsiRho, MeanPsiE, Param_p, Param_Kappa_0, Local_Lambda_i, Local_Lambda_j, MeanLambda, + Phi_i, Phi_j, sc2, StretchingFactor, Epsilon_0; + bool implicit, grid_movement; + +public: + /*! + * \brief Constructor of the class. + * \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. + */ + CCentLax_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CCentLax_AdjFlow(void); + + /*! + * \brief Compute the adjoint flow residual using a Lax method. + * \param[out] val_resconv_i - Pointer to the convective residual at point i. + * \param[out] val_resvisc_i - Pointer to the artificial viscosity residual at point i. + * \param[out] val_resconv_j - Pointer to the convective residual at point j. + * \param[out] val_resvisc_j - Pointer to the artificial viscosity residual at point j. + * \param[out] val_Jacobian_ii - Jacobian of the numerical method at node i (implicit computation) from node i. + * \param[out] val_Jacobian_ij - Jacobian of the numerical method at node i (implicit computation) from node j. + * \param[out] val_Jacobian_ji - Jacobian of the numerical method at node j (implicit computation) from node i. + * \param[out] val_Jacobian_jj - Jacobian of the numerical method at node j (implicit computation) from node j. + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual (su2double *val_resconv_i, su2double *val_resvisc_i, + su2double *val_resconv_j, su2double *val_resvisc_j, + su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, + su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, + CConfig *config); +}; + +/*! + * \class CCentJST_AdjFlow + * \brief Class for and adjoint centered scheme - JST. + * \ingroup ConvDiscr + * \author F. Palacios + */ +class CCentJST_AdjFlow : public CNumerics { +private: + su2double *Diff_Psi, *Diff_Lapl; + su2double *Velocity_i, *Velocity_j; + su2double *MeanPhi; + unsigned short iDim, jDim, iVar, jVar; + su2double Residual, ProjVelocity_i, ProjVelocity_j, ProjPhi, ProjPhi_Vel, sq_vel, phis1, phis2; + su2double MeanPsiRho, MeanPsiE, Param_p, Param_Kappa_4, Param_Kappa_2, Local_Lambda_i, Local_Lambda_j, MeanLambda; + su2double Phi_i, Phi_j, sc4, StretchingFactor, Epsilon_4, Epsilon_2; + bool implicit, grid_movement; + +public: + /*! + * \brief Constructor of the class. + * \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. + */ + CCentJST_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CCentJST_AdjFlow(void); + + /*! + * \brief Compute the adjoint flow residual using a JST method. + * \param[out] val_resconv_i - Pointer to the convective residual at point i. + * \param[out] val_resvisc_i - Pointer to the artificial viscosity residual at point i. + * \param[out] val_resconv_j - Pointer to the convective residual at point j. + * \param[out] val_resvisc_j - Pointer to the artificial viscosity residual at point j. + * \param[out] val_Jacobian_ii - Jacobian of the numerical method at node i (implicit computation) from node i. + * \param[out] val_Jacobian_ij - Jacobian of the numerical method at node i (implicit computation) from node j. + * \param[out] val_Jacobian_ji - Jacobian of the numerical method at node j (implicit computation) from node i. + * \param[out] val_Jacobian_jj - Jacobian of the numerical method at node j (implicit computation) from node j. + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual (su2double *val_resconv_i, su2double *val_resvisc_i, + su2double *val_resconv_j, su2double *val_resvisc_j, + su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, + su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, + CConfig *config); +}; + +/*! + * \class CUpwRoe_AdjFlow + * \brief Class for solving an approximate Riemann solver of Roe + * for the adjoint flow equations. + * \ingroup ConvDiscr + * \author F. Palacios + */ +class CUpwRoe_AdjFlow : public CNumerics { +private: + su2double *Residual_Roe; + su2double area, Sx, Sy, Sz, rarea, nx, ny, nz, rho_l, u_l, v_l, w_l, h_l, rho_r, + u_r, v_r, w_r, h_r, psi1, psi2, psi3, psi4, psi5; + su2double h, u, v, w, c, psi1_l, psi2_l, psi3_l, psi4_l, psi5_l, + psi1_r, psi2_r, psi3_r, psi4_r, psi5_r, q_l, q_r, Q_l, Q_r, vn, + rrho_l, weight, rweight1, cc; + su2double l1psi, l2psi, absQ, absQp, absQm, q2, alpha, beta_u, beta_v, beta_w, Q, l1l2p, l1l2m, eta; + su2double RoeDensity, RoeSoundSpeed, *RoeVelocity, *Lambda, *Velocity_i, *Velocity_j, **ProjFlux_i, **ProjFlux_j, + Proj_ModJac_Tensor_ij, **Proj_ModJac_Tensor, Energy_i, Energy_j, **P_Tensor, **invP_Tensor; + unsigned short iDim, iVar, jVar, kVar; + bool implicit, grid_movement; + +public: + /*! + * \brief Constructor of the class. + * \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. + */ + CUpwRoe_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CUpwRoe_AdjFlow(void); + + /*! + * \brief Compute the adjoint Roe's flux between two nodes i and j. + * \param[out] val_residual_i - Pointer to the total residual at point i. + * \param[out] val_residual_j - Pointer to the total residual at point j. + * \param[out] val_Jacobian_ii - Jacobian of the numerical method at node i (implicit computation) from node i. + * \param[out] val_Jacobian_ij - Jacobian of the numerical method at node i (implicit computation) from node j. + * \param[out] val_Jacobian_ji - Jacobian of the numerical method at node j (implicit computation) from node i. + * \param[out] val_Jacobian_jj - Jacobian of the numerical method at node j (implicit computation) from node j. + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, + su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, + su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config); +}; + +/*! + * \class CUpwLin_AdjTurb + * \brief Class for performing a linear upwind solver for the adjoint turbulence equations. + * \ingroup ConvDiscr + * \author A. Bueno. + */ +class CUpwLin_AdjTurb : public CNumerics { +private: + su2double *Velocity_i; + +public: + /*! + * \brief Constructor of the class. + * \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. + */ + CUpwLin_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CUpwLin_AdjTurb(void); + + /*! + * \brief Compute the adjoint upwind flux between two nodes i and j. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual (su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); +}; + +/*! + * \class CUpwSca_AdjTurb + * \brief Class for doing a scalar upwind solver for the adjoint turbulence equations. + * \ingroup ConvDiscr + * \author A. Bueno. + */ +class CUpwSca_AdjTurb : public CNumerics { +private: + su2double *Velocity_i, *Velocity_j; + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CUpwSca_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CUpwSca_AdjTurb(void); + + /*! + * \param[out] val_residual_i - Pointer to the total residual at point i. + * \param[out] val_residual_j - Pointer to the total viscosity residual at point j. + * \param[out] val_Jacobian_ii - Jacobian of the numerical method at node i (implicit computation) from node i. + * \param[out] val_Jacobian_ij - Jacobian of the numerical method at node i (implicit computation) from node j. + * \param[out] val_Jacobian_ji - Jacobian of the numerical method at node j (implicit computation) from node i. + * \param[out] val_Jacobian_jj - Jacobian of the numerical method at node j (implicit computation) from node j. + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, + su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, + su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config); +}; diff --git a/SU2_CFD/include/numerics/continuous_adjoint/adj_diffusion.hpp b/SU2_CFD/include/numerics/continuous_adjoint/adj_diffusion.hpp new file mode 100644 index 000000000000..8612c52223a3 --- /dev/null +++ b/SU2_CFD/include/numerics/continuous_adjoint/adj_diffusion.hpp @@ -0,0 +1,224 @@ +/*! + * \file adj_diffusion.hpp + * \brief Delarations of numerics classes for continuous adjoint + * diffusion discretization. Implemented in adj_diffusion.cpp. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../CNumerics.hpp" + +/*! + * \class CAvgGrad_AdjFlow + * \brief Class for computing the adjoint viscous terms. + * \ingroup ViscDiscr + * \author F. Palacios + */ +class CAvgGrad_AdjFlow : public CNumerics { +private: + su2double *Velocity_i; /*!< \brief Auxiliary vector for storing the velocity of point i. */ + su2double *Velocity_j; /*!< \brief Auxiliary vector for storing the velocity of point j. */ + su2double *Mean_Velocity; + su2double *Mean_GradPsiE; /*!< \brief Counter for dimensions of the problem. */ + su2double **Mean_GradPhi; /*!< \brief Counter for dimensions of the problem. */ + su2double *Edge_Vector; /*!< \brief Vector going from node i to node j. */ + bool implicit; /*!< \brief Implicit calculus. */ + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CAvgGrad_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CAvgGrad_AdjFlow(void); + + /*! + * \brief Residual computation. + * \param[out] val_residual_i - Pointer to the total residual at point i. + * \param[out] val_residual_j - Pointer to the total residual at point j. + */ + void ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, + su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, + su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config); +}; + +/*! + * \class CAvgGradCorrected_AdjFlow + * \brief Class for computing the adjoint viscous terms, including correction. + * \ingroup ViscDiscr + * \author A. Bueno. + */ +class CAvgGradCorrected_AdjFlow : public CNumerics { +private: + su2double *Velocity_i; /*!< \brief Auxiliary vector for storing the velocity of point i. */ + su2double *Velocity_j; /*!< \brief Auxiliary vector for storing the velocity of point j. */ + su2double *Mean_Velocity; + su2double **Mean_GradPsiVar; /*!< \brief Counter for dimensions of the problem. */ + su2double *Edge_Vector; /*!< \brief Vector going from node i to node j. */ + su2double *Proj_Mean_GradPsiVar_Edge; /*!< \brief Projection of Mean_GradPsiVar onto Edge_Vector. */ + su2double *Mean_GradPsiE; /*!< \brief Counter for dimensions of the problem. */ + su2double **Mean_GradPhi; /*!< \brief Counter for dimensions of the problem. */ + bool implicit; /*!< \brief Boolean controlling Jacobian calculations. */ + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CAvgGradCorrected_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CAvgGradCorrected_AdjFlow(void); + + /*! + * \brief Compute the adjoint flow viscous residual in a non-conservative way using an average of gradients and derivative correction. + * \param[out] val_residual_i - Pointer to the viscous residual at point i. + * \param[out] val_residual_j - Pointer to the viscous residual at point j. + * \param[out] val_Jacobian_ii - Jacobian of the numerical method at node i (implicit computation) from node i. + * \param[out] val_Jacobian_ij - Jacobian of the numerical method at node i (implicit computation) from node j. + * \param[out] val_Jacobian_ji - Jacobian of the numerical method at node j (implicit computation) from node i. + * \param[out] val_Jacobian_jj - Jacobian of the numerical method at node j (implicit computation) from node j. + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, + su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, + su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config); +}; + +/*! + * \class CAvgGrad_AdjTurb + * \brief Class for adjoint turbulent using average of gradients with a correction. + * \ingroup ViscDiscr + * \author F. Palacios + */ +class CAvgGrad_AdjTurb : public CNumerics { +private: + su2double **Mean_GradTurbPsi; + su2double *Proj_Mean_GradTurbPsi_Kappa, *Proj_Mean_GradTurbPsi_Edge, *Proj_Mean_GradTurbPsi_Corrected; + su2double *Edge_Vector; + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CAvgGrad_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CAvgGrad_AdjTurb(void); + + /*! + * \brief Compute the adjoint turbulent residual using average of gradients and a derivative correction. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + + /*! + * \overload + * \param[out] val_residual_i - Pointer to the total residual at point i. + * \param[out] val_residual_j - Pointer to the total viscosity residual at point j. + * \param[out] val_Jacobian_ii - Jacobian of the numerical method at node i (implicit computation) from node i. + * \param[out] val_Jacobian_ij - Jacobian of the numerical method at node i (implicit computation) from node j. + * \param[out] val_Jacobian_ji - Jacobian of the numerical method at node j (implicit computation) from node i. + * \param[out] val_Jacobian_jj - Jacobian of the numerical method at node j (implicit computation) from node j. + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, + su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, + su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config); +}; + +/*! + * \class CAvgGradCorrected_AdjTurb + * \brief Class for adjoint turbulent using average of gradients with a correction. + * \ingroup ViscDiscr + * \author A. Bueno. + */ +class CAvgGradCorrected_AdjTurb : public CNumerics { +private: + su2double **Mean_GradTurbPsi; + su2double *Proj_Mean_GradTurbPsi_Kappa, *Proj_Mean_GradTurbPsi_Edge, *Proj_Mean_GradTurbPsi_Corrected; + su2double *Edge_Vector; + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CAvgGradCorrected_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CAvgGradCorrected_AdjTurb(void); + + /*! + * \brief Compute the adjoint turbulent residual using average of gradients and a derivative correction. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + + /*! + * \overload + * \param[out] val_residual_i - Pointer to the total residual at point i. + * \param[out] val_residual_j - Pointer to the total viscosity residual at point j. + * \param[out] val_Jacobian_ii - Jacobian of the numerical method at node i (implicit computation) from node i. + * \param[out] val_Jacobian_ij - Jacobian of the numerical method at node i (implicit computation) from node j. + * \param[out] val_Jacobian_ji - Jacobian of the numerical method at node j (implicit computation) from node i. + * \param[out] val_Jacobian_jj - Jacobian of the numerical method at node j (implicit computation) from node j. + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, + su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, + su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config); +}; diff --git a/SU2_CFD/include/numerics/continuous_adjoint/adj_sources.hpp b/SU2_CFD/include/numerics/continuous_adjoint/adj_sources.hpp new file mode 100644 index 000000000000..95ce9a1fefe1 --- /dev/null +++ b/SU2_CFD/include/numerics/continuous_adjoint/adj_sources.hpp @@ -0,0 +1,220 @@ +/*! + * \file adj_sources.hpp + * \brief Delarations of numerics classes for continuous adjoint + * source term integration. Implemented in adj_sources.cpp. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../CNumerics.hpp" + +/*! + * \class CSourceAxisymmetric_AdjFlow + * \brief Class for source term for solving axisymmetric problems. + * \ingroup SourceDiscr + * \author F. Palacios + */ +class CSourceAxisymmetric_AdjFlow : public CNumerics { +public: + /*! + * \brief Constructor of the class. + * \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. + */ + CSourceAxisymmetric_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CSourceAxisymmetric_AdjFlow(void); + + /*! + * \brief Residual of the rotational frame source term. + * \param[out] val_residual - Pointer to the total residual. + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **Jacobian_i, CConfig *config); +}; + +class CSourceConservative_AdjFlow : public CNumerics { +private: + su2double *Velocity, *Residual_i, *Residual_j, *Mean_Residual; + su2double **Mean_PrimVar_Grad; + +public: + /*! + * \brief Constructor of the class. + * \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. + */ + CSourceConservative_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CSourceConservative_AdjFlow(void); + + /*! + * \brief Source term integration using a conservative scheme. + * \param[out] val_residual - Pointer to the total residual. + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, CConfig *config); +}; + +/*! + * \class CSourceRotatingFrame_AdjFlow + * \brief Source term class for rotating frame adjoint. + * \ingroup SourceDiscr + * \author T. Economon. + */ +class CSourceRotatingFrame_AdjFlow : public CNumerics { +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CSourceRotatingFrame_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CSourceRotatingFrame_AdjFlow(void); + + /*! + * \brief Residual of the adjoint rotating frame source term. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config); +}; + +/*! + * \class CSourceViscous_AdjFlow + * \brief Class for source term integration in adjoint problem. + * \ingroup SourceDiscr + * \author F. Palacios + */ +class CSourceViscous_AdjFlow : public CNumerics { +private: + su2double *Velocity, *GradDensity, *GradInvDensity, *dPoDensity2, *alpha, *beta, *Sigma_5_vec; + su2double **GradVel_o_Rho, **sigma, **Sigma_phi, **Sigma_5_Tensor, **Sigma; + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CSourceViscous_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CSourceViscous_AdjFlow(void); + + /*! + * \brief Source term integration of the flow adjoint equation. + * \param[out] val_residual - Pointer to the total residual. + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual (su2double *val_residual, CConfig *config); + +}; + +/*! + * \class CSourceConservative_AdjTurb + * \brief Class for source term integration in adjoint turbulent problem using a conservative scheme. + * \ingroup SourceDiscr + * \author A. Bueno. + */ +class CSourceConservative_AdjTurb : public CNumerics { +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CSourceConservative_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CSourceConservative_AdjTurb(void); + + /*! + * \brief Source term integration using a conservative scheme. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); +}; + +/*! + * \class CSourcePieceWise_AdjTurb + * \brief Class for source term integration of the adjoint turbulent equation. + * \ingroup SourceDiscr + * \author A. Bueno. + */ +class CSourcePieceWise_AdjTurb : public CNumerics { +private: + su2double **tau, *Velocity; + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CSourcePieceWise_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CSourcePieceWise_AdjTurb(void); + + /*! + * \brief Source term integration of the adjoint turbulence equation. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); +}; diff --git a/SU2_CFD/include/numerics/elasticity/CFEALinearElasticity.hpp b/SU2_CFD/include/numerics/elasticity/CFEALinearElasticity.hpp index 9440618e9639..b90eb5178ac9 100644 --- a/SU2_CFD/include/numerics/elasticity/CFEALinearElasticity.hpp +++ b/SU2_CFD/include/numerics/elasticity/CFEALinearElasticity.hpp @@ -83,3 +83,59 @@ class CFEALinearElasticity : public CFEAElasticity { void Compute_Constitutive_Matrix(CElement *element_container, CConfig *config) final; }; + + +/*! + * \class CFEAMeshElasticity + * \brief Particular case of linear elasticity used for mesh deformation. + * \ingroup FEM_Discr + * \author R.Sanchez + * \version 7.0.0 "Blackbird" + */ +class CFEAMeshElasticity final : public CFEALinearElasticity { + + bool element_based; + bool stiffness_set; + +public: + /*! + * \brief Default constructor deleted as instantiation with no argument would not allocate fields. + */ + CFEAMeshElasticity() = delete; + + /*! + * \brief Constructor of the class. + * \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. + */ + CFEAMeshElasticity(unsigned short val_nDim, unsigned short val_nVar, unsigned long val_nElem, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CFEAMeshElasticity(void) = default; + + /*! + * \brief Set the element-based local Young's modulus in mesh problems + * \param[in] iElem - Element index. + * \param[in] val_E - Value of elasticity modulus. + */ + inline void SetMeshElasticProperties(unsigned long iElem, su2double val_E) override { + if (element_based) E_i[iElem] = val_E; + } + +private: + /*! + * \brief Set element material properties. + * \param[in] element_container - Element defining the properties. + * \param[in] config - Definition of the problem. + */ + inline void SetElement_Properties(const CElement *element, CConfig *config) override { + if (element_based) { + E = E_i[element->Get_iProp()]; + Compute_Lame_Parameters(); + } + } + +}; diff --git a/SU2_CFD/include/numerics/elasticity/CFEAMeshElasticity.hpp b/SU2_CFD/include/numerics/elasticity/CFEAMeshElasticity.hpp deleted file mode 100644 index 47ef485f27f4..000000000000 --- a/SU2_CFD/include/numerics/elasticity/CFEAMeshElasticity.hpp +++ /dev/null @@ -1,80 +0,0 @@ -/*! - * \file CFEAMeshNumerics.hpp - * \brief Declaration and inlines of the class to compute - * the stiffness matrix of a linear, pseudo-elastic mesh problem. - * \author Ruben Sanchez - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "CFEALinearElasticity.hpp" - - -class CFEAMeshElasticity final : public CFEALinearElasticity { - - bool element_based; - bool stiffness_set; - -public: - /*! - * \brief Default constructor deleted as instantiation with no argument would not allocate fields. - */ - CFEAMeshElasticity() = delete; - - /*! - * \brief Constructor of the class. - * \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. - */ - CFEAMeshElasticity(unsigned short val_nDim, unsigned short val_nVar, unsigned long val_nElem, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CFEAMeshElasticity(void) = default; - - /*! - * \brief Set the element-based local Young's modulus in mesh problems - * \param[in] iElem - Element index. - * \param[in] val_E - Value of elasticity modulus. - */ - inline void SetMeshElasticProperties(unsigned long iElem, su2double val_E) override { - if (element_based) E_i[iElem] = val_E; - } - -private: - /*! - * \brief Set element material properties. - * \param[in] element_container - Element defining the properties. - * \param[in] config - Definition of the problem. - */ - inline void SetElement_Properties(const CElement *element, CConfig *config) override { - if (element_based) { - E = E_i[element->Get_iProp()]; - Compute_Lame_Parameters(); - } - } - -}; diff --git a/SU2_CFD/include/numerics/elasticity/CFEM_DielectricElastomer.hpp b/SU2_CFD/include/numerics/elasticity/CFEM_DielectricElastomer.hpp deleted file mode 100644 index 6719ce6b7054..000000000000 --- a/SU2_CFD/include/numerics/elasticity/CFEM_DielectricElastomer.hpp +++ /dev/null @@ -1,78 +0,0 @@ -/*! - * \file CFEM_DielectricElastomer.hpp - * \brief Class for computing the constitutive and stress tensors for a dielectric elastomer. - * \author Ruben Sanchez - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "CFEANonlinearElasticity.hpp" - - -/*! - * \class CFEM_DielectricElastomer - * \brief Class for computing the constitutive and stress tensors for a dielectric elastomer. - * \ingroup FEM_Discr - * \author R.Sanchez - * \version 7.0.0 "Blackbird" - */ -class CFEM_DielectricElastomer final : public CFEANonlinearElasticity { - -public: - /*! - * \brief Constructor of the class. - * \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. - */ - CFEM_DielectricElastomer(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CFEM_DielectricElastomer(void) = default; - -private: - /*! - * \brief Compute the plane stress term. - * \param[in,out] element_container - The finite element. - * \param[in] config - Definition of the problem. - */ - inline void Compute_Plane_Stress_Term(CElement *element_container, CConfig *config) override { }; - - /*! - * \brief Compute the constitutive matrix. - * \param[in,out] element_container - The finite element. - * \param[in] config - Definition of the problem. - */ - void Compute_Constitutive_Matrix(CElement *element_container, CConfig *config) override; - - /*! - * \brief Compute the stress tensor. - * \param[in,out] element_container - The finite element. - * \param[in] config - Definition of the problem. - */ - void Compute_Stress_Tensor(CElement *element_container, CConfig *config) override; - -}; diff --git a/SU2_CFD/include/numerics/elasticity/CFEM_IdealDE.hpp b/SU2_CFD/include/numerics/elasticity/CFEM_IdealDE.hpp deleted file mode 100644 index e1c59dc23a1f..000000000000 --- a/SU2_CFD/include/numerics/elasticity/CFEM_IdealDE.hpp +++ /dev/null @@ -1,79 +0,0 @@ -/*! - * \file CFEM_IdealDE.hpp - * \brief Class for computing the constitutive and stress tensors for a nearly-incompressible ideal DE. - * \author Ruben Sanchez - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "CFEANonlinearElasticity.hpp" - -/*! - * \class CFEM_IdealDE - * \brief Class for computing the constitutive and stress tensors for a nearly-incompressible ideal DE. - * \ingroup FEM_Discr - * \author R.Sanchez - * \version 7.0.0 "Blackbird" - */ -class CFEM_IdealDE final : public CFEANonlinearElasticity { - - su2double trbbar, Eg, Eg23, Ek, Pr; /*!< \brief Variables of the model calculation. */ - -public: - /*! - * \brief Constructor of the class. - * \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. - */ - CFEM_IdealDE(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CFEM_IdealDE(void) = default; - -private: - /*! - * \brief Compute the plane stress term. - * \param[in,out] element_container - The finite element. - * \param[in] config - Definition of the problem. - */ - void Compute_Plane_Stress_Term(CElement *element_container, CConfig *config) override; - - /*! - * \brief Compute the constitutive matrix. - * \param[in,out] element_container - The finite element. - * \param[in] config - Definition of the problem. - */ - void Compute_Constitutive_Matrix(CElement *element_container, CConfig *config) override; - - /*! - * \brief Compute the stress tensor. - * \param[in,out] element_container - The finite element. - * \param[in] config - Definition of the problem. - */ - void Compute_Stress_Tensor(CElement *element_container, CConfig *config) override; - -}; diff --git a/SU2_CFD/include/numerics/elasticity/CFEM_Knowles_NearInc.hpp b/SU2_CFD/include/numerics/elasticity/CFEM_Knowles_NearInc.hpp deleted file mode 100644 index c54fa2f78455..000000000000 --- a/SU2_CFD/include/numerics/elasticity/CFEM_Knowles_NearInc.hpp +++ /dev/null @@ -1,82 +0,0 @@ -/*! - * \file CFEM_Knowles_NearInc.hpp - * \brief Class for computing the constitutive and stress tensors - * for the Knowles nearly-incompressible material. - * \author Ruben Sanchez - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "CFEANonlinearElasticity.hpp" - - -/*! - * \class CFEM_NeoHookean_Comp - * \brief Constitutive and stress tensors for a Knowles stored-energy function, nearly incompressible. - * \ingroup FEM_Discr - * \author R.Sanchez - * \version 7.0.0 "Blackbird" - */ -class CFEM_Knowles_NearInc final : public CFEANonlinearElasticity { - - su2double trbbar, term1, term2, Ek, Pr; /*!< \brief Variables of the model calculation. */ - su2double Bk, Nk; /*!< \brief Parameters b and n of the model. */ - -public: - /*! - * \brief Constructor of the class. - * \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. - */ - CFEM_Knowles_NearInc(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CFEM_Knowles_NearInc(void) = default; - -private: - /*! - * \brief Compute the plane stress term. - * \param[in,out] element_container - The finite element. - * \param[in] config - Definition of the problem. - */ - void Compute_Plane_Stress_Term(CElement *element_container, CConfig *config) override; - - /*! - * \brief Compute the constitutive matrix. - * \param[in,out] element_container - The finite element. - * \param[in] config - Definition of the problem. - */ - void Compute_Constitutive_Matrix(CElement *element_container, CConfig *config) override; - - /*! - * \brief Compute the stress tensor. - * \param[in,out] element_container - The finite element. - * \param[in] config - Definition of the problem. - */ - void Compute_Stress_Tensor(CElement *element_container, CConfig *config) override; - -}; diff --git a/SU2_CFD/include/numerics/elasticity/CFEM_NeoHookean_Comp.hpp b/SU2_CFD/include/numerics/elasticity/CFEM_NeoHookean_Comp.hpp deleted file mode 100644 index e7a1afe604f2..000000000000 --- a/SU2_CFD/include/numerics/elasticity/CFEM_NeoHookean_Comp.hpp +++ /dev/null @@ -1,79 +0,0 @@ -/*! - * \file CFEM_NeoHookean_Comp.hpp - * \brief Compressible Neo-Hookean FE numerics class. - * \author Ruben Sanchez - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "CFEANonlinearElasticity.hpp" - - -/*! - * \class CFEM_NeoHookean_Comp - * \brief Class for computing the constitutive and stress tensors for a neo-Hookean material model, compressible. - * \ingroup FEM_Discr - * \author R.Sanchez - * \version 7.0.0 "Blackbird" - */ -class CFEM_NeoHookean_Comp final : public CFEANonlinearElasticity { - -public: - /*! - * \brief Constructor of the class. - * \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. - */ - CFEM_NeoHookean_Comp(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CFEM_NeoHookean_Comp(void) = default; - -private: - /*! - * \brief Compute the plane stress term. - * \param[in,out] element_container - The finite element. - * \param[in] config - Definition of the problem. - */ - void Compute_Plane_Stress_Term(CElement *element_container, CConfig *config) override; - - /*! - * \brief Compute the constitutive matrix. - * \param[in,out] element_container - The finite element. - * \param[in] config - Definition of the problem. - */ - void Compute_Constitutive_Matrix(CElement *element_container, CConfig *config) override; - - /*! - * \brief Compute the stress tensor. - * \param[in,out] element_container - The finite element. - * \param[in] config - Definition of the problem. - */ - void Compute_Stress_Tensor(CElement *element_container, CConfig *config) override; - -}; - diff --git a/SU2_CFD/include/numerics/elasticity/nonlinear_models.hpp b/SU2_CFD/include/numerics/elasticity/nonlinear_models.hpp new file mode 100644 index 000000000000..5777c0e84545 --- /dev/null +++ b/SU2_CFD/include/numerics/elasticity/nonlinear_models.hpp @@ -0,0 +1,227 @@ +/*! + * \file nonlinear_models.hpp + * \brief Declarations of nonlinear constitutive models. + * \author Ruben Sanchez + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "CFEANonlinearElasticity.hpp" + + +/*! + * \class CFEM_NeoHookean_Comp + * \brief Class for computing the constitutive and stress tensors for a neo-Hookean material model, compressible. + * \ingroup FEM_Discr + * \author R.Sanchez + * \version 7.0.0 "Blackbird" + */ +class CFEM_NeoHookean_Comp final : public CFEANonlinearElasticity { + +public: + /*! + * \brief Constructor of the class. + * \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. + */ + CFEM_NeoHookean_Comp(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CFEM_NeoHookean_Comp(void) = default; + +private: + /*! + * \brief Compute the plane stress term. + * \param[in,out] element_container - The finite element. + * \param[in] config - Definition of the problem. + */ + void Compute_Plane_Stress_Term(CElement *element_container, CConfig *config) override; + + /*! + * \brief Compute the constitutive matrix. + * \param[in,out] element_container - The finite element. + * \param[in] config - Definition of the problem. + */ + void Compute_Constitutive_Matrix(CElement *element_container, CConfig *config) override; + + /*! + * \brief Compute the stress tensor. + * \param[in,out] element_container - The finite element. + * \param[in] config - Definition of the problem. + */ + void Compute_Stress_Tensor(CElement *element_container, CConfig *config) override; + +}; + + +/*! + * \class CFEM_NeoHookean_Comp + * \brief Constitutive and stress tensors for a Knowles stored-energy function, nearly incompressible. + * \ingroup FEM_Discr + * \author R.Sanchez + * \version 7.0.0 "Blackbird" + */ +class CFEM_Knowles_NearInc final : public CFEANonlinearElasticity { + + su2double trbbar, term1, term2, Ek, Pr; /*!< \brief Variables of the model calculation. */ + su2double Bk, Nk; /*!< \brief Parameters b and n of the model. */ + +public: + /*! + * \brief Constructor of the class. + * \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. + */ + CFEM_Knowles_NearInc(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CFEM_Knowles_NearInc(void) = default; + +private: + /*! + * \brief Compute the plane stress term. + * \param[in,out] element_container - The finite element. + * \param[in] config - Definition of the problem. + */ + void Compute_Plane_Stress_Term(CElement *element_container, CConfig *config) override; + + /*! + * \brief Compute the constitutive matrix. + * \param[in,out] element_container - The finite element. + * \param[in] config - Definition of the problem. + */ + void Compute_Constitutive_Matrix(CElement *element_container, CConfig *config) override; + + /*! + * \brief Compute the stress tensor. + * \param[in,out] element_container - The finite element. + * \param[in] config - Definition of the problem. + */ + void Compute_Stress_Tensor(CElement *element_container, CConfig *config) override; + +}; + + +/*! + * \class CFEM_DielectricElastomer + * \brief Class for computing the constitutive and stress tensors for a dielectric elastomer. + * \ingroup FEM_Discr + * \author R.Sanchez + * \version 7.0.0 "Blackbird" + */ +class CFEM_DielectricElastomer final : public CFEANonlinearElasticity { + +public: + /*! + * \brief Constructor of the class. + * \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. + */ + CFEM_DielectricElastomer(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CFEM_DielectricElastomer(void) = default; + +private: + /*! + * \brief Compute the plane stress term. + * \param[in,out] element_container - The finite element. + * \param[in] config - Definition of the problem. + */ + inline void Compute_Plane_Stress_Term(CElement *element_container, CConfig *config) override { }; + + /*! + * \brief Compute the constitutive matrix. + * \param[in,out] element_container - The finite element. + * \param[in] config - Definition of the problem. + */ + void Compute_Constitutive_Matrix(CElement *element_container, CConfig *config) override; + + /*! + * \brief Compute the stress tensor. + * \param[in,out] element_container - The finite element. + * \param[in] config - Definition of the problem. + */ + void Compute_Stress_Tensor(CElement *element_container, CConfig *config) override; + +}; + + +/*! + * \class CFEM_IdealDE + * \brief Class for computing the constitutive and stress tensors for a nearly-incompressible ideal DE. + * \ingroup FEM_Discr + * \author R.Sanchez + * \version 7.0.0 "Blackbird" + */ +class CFEM_IdealDE final : public CFEANonlinearElasticity { + + su2double trbbar, Eg, Eg23, Ek, Pr; /*!< \brief Variables of the model calculation. */ + +public: + /*! + * \brief Constructor of the class. + * \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. + */ + CFEM_IdealDE(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CFEM_IdealDE(void) = default; + +private: + /*! + * \brief Compute the plane stress term. + * \param[in,out] element_container - The finite element. + * \param[in] config - Definition of the problem. + */ + void Compute_Plane_Stress_Term(CElement *element_container, CConfig *config) override; + + /*! + * \brief Compute the constitutive matrix. + * \param[in,out] element_container - The finite element. + * \param[in] config - Definition of the problem. + */ + void Compute_Constitutive_Matrix(CElement *element_container, CConfig *config) override; + + /*! + * \brief Compute the stress tensor. + * \param[in,out] element_container - The finite element. + * \param[in] config - Definition of the problem. + */ + void Compute_Stress_Tensor(CElement *element_container, CConfig *config) override; + +}; diff --git a/SU2_CFD/include/numerics/flow/convection/ausm_slau.hpp b/SU2_CFD/include/numerics/flow/convection/ausm_slau.hpp new file mode 100644 index 000000000000..2cafcff57ca4 --- /dev/null +++ b/SU2_CFD/include/numerics/flow/convection/ausm_slau.hpp @@ -0,0 +1,255 @@ +/*! + * \file ausm_slau.hpp + * \brief Declaration of numerics classes for the AUSM family of schemes, + * including SLAU. The implementation is in ausm.cpp. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../../CNumerics.hpp" + +/*! + * \class CUpwAUSMPLUS_SLAU_Base_Flow + * \brief Base class for AUSM+up(2) and SLAU(2) convective schemes. + * \ingroup ConvDiscr + * \author Amit Sachdeva + */ +class CUpwAUSMPLUS_SLAU_Base_Flow : public CNumerics { +protected: + bool implicit; + bool UseAccurateJacobian; + bool HasAnalyticalDerivatives; + su2double FinDiffStep; + + su2double MassFlux, DissFlux, Pressure; + su2double *Velocity_i, *Velocity_j; + su2double *psi_i, *psi_j; + su2double dmdot_dVi[6], dmdot_dVj[6], dpres_dVi[6], dpres_dVj[6]; + + /*--- Roe variables (for approximate Jacobian) ---*/ + su2double *Lambda, *Epsilon, *RoeVelocity, **P_Tensor, **invP_Tensor; + + /*! + * \brief Compute the mass flux and pressure based on Primitives_i/j, derived classes must implement this method. + * \note See the body of the (empty) default implementation for instructions on how to implement the method. + * \param[in] config - Definition of the particular problem. + * \param[out] mdot - The mass flux. + * \param[out] pressure - The pressure at the control volume face. + */ + virtual void ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure) = 0; + + /*! + * \brief Compute the flux Jacobians of the Roe scheme to use as an approximation. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + */ + void ApproximateJacobian(su2double **val_Jacobian_i, su2double **val_Jacobian_j); + + /*! + * \brief Compute the flux Jacobians using a mix of finite differences and manual differentiation. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + */ + void AccurateJacobian(CConfig *config, su2double **val_Jacobian_i, su2double **val_Jacobian_j); + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CUpwAUSMPLUS_SLAU_Base_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CUpwAUSMPLUS_SLAU_Base_Flow(void); + + /*! + * \brief Compute the AUSM+ and SLAU family of schemes. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); +}; + +/*! + * \class CUpwAUSMPLUSUP_Flow + * \brief Class for solving an approximate Riemann AUSM+ -up. + * \ingroup ConvDiscr + * \author Amit Sachdeva + */ +class CUpwAUSMPLUSUP_Flow : public CUpwAUSMPLUS_SLAU_Base_Flow { +private: + su2double Kp, Ku, sigma; + + /*! + * \brief Mass flux and pressure for the AUSM+up scheme. + * \param[in] config - Definition of the particular problem. + * \param[out] mdot - The mass flux. + * \param[out] pressure - The pressure at the control volume face. + */ + void ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure); + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CUpwAUSMPLUSUP_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + +}; + +/*! + * \class CUpwAUSMPLUSUP2_Flow + * \brief Class for solving an approximate Riemann AUSM+ -up. + * \ingroup ConvDiscr + * \author Amit Sachdeva + */ +class CUpwAUSMPLUSUP2_Flow : public CUpwAUSMPLUS_SLAU_Base_Flow { +private: + su2double Kp, sigma; + + /*! + * \brief Mass flux and pressure for the AUSM+up2 scheme. + * \param[in] config - Definition of the particular problem. + * \param[out] mdot - The mass flux. + * \param[out] pressure - The pressure at the control volume face. + */ + void ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure); + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CUpwAUSMPLUSUP2_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + +}; + +/*! + * \class CUpwSLAU_Flow + * \brief Class for solving the Low-Dissipation AUSM. + * \ingroup ConvDiscr + * \author E. Molina + */ +class CUpwSLAU_Flow : public CUpwAUSMPLUS_SLAU_Base_Flow { +protected: + bool slau_low_diss; + bool slau2; + + /*! + * \brief Mass flux and pressure for the SLAU and SLAU2 schemes. + * \param[in] config - Definition of the particular problem. + * \param[out] mdot - The mass flux. + * \param[out] pressure - The pressure at the control volume face. + */ + void ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure); + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CUpwSLAU_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, bool val_low_dissipation); + +}; + +/*! + * \class CUpwSLAU2_Flow + * \brief Class for solving the Simple Low-Dissipation AUSM 2. + * \ingroup ConvDiscr + * \author E. Molina + */ +class CUpwSLAU2_Flow : public CUpwSLAU_Flow { +public: + /*! + * \brief Constructor of the class. + * \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. + */ + CUpwSLAU2_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, bool val_low_dissipation); + +}; + +/*! + * \class CUpwAUSM_Flow + * \brief Class for solving an approximate Riemann AUSM. + * \ingroup ConvDiscr + * \author F. Palacios + */ +class CUpwAUSM_Flow : public CNumerics { +private: + bool implicit; + su2double *Diff_U; + su2double *Velocity_i, *Velocity_j, *RoeVelocity; + su2double *ProjFlux_i, *ProjFlux_j; + su2double *delta_wave, *delta_vel; + su2double *Lambda, *Epsilon; + su2double **P_Tensor, **invP_Tensor; + su2double sq_vel, Proj_ModJac_Tensor_ij, Density_i, Energy_i, SoundSpeed_i, Pressure_i, Enthalpy_i, + Density_j, Energy_j, SoundSpeed_j, Pressure_j, Enthalpy_j, R, RoeDensity, RoeEnthalpy, RoeSoundSpeed, + ProjVelocity, ProjVelocity_i, ProjVelocity_j; + unsigned short iDim, iVar, jVar, kVar; + su2double mL, mR, mLP, mRM, mF, pLP, pRM, pF, Phi; + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CUpwAUSM_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CUpwAUSM_Flow(void); + + /*! + * \brief Compute the Roe's flux between two nodes i and j. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); +}; diff --git a/SU2_CFD/include/numerics/flow/convection/centered.hpp b/SU2_CFD/include/numerics/flow/convection/centered.hpp new file mode 100644 index 000000000000..55e6c4a22c3e --- /dev/null +++ b/SU2_CFD/include/numerics/flow/convection/centered.hpp @@ -0,0 +1,332 @@ +/*! + * \file centered.hpp + * \brief Delaration of numerics classes for centered schemes, + * the implementation is in centered.cpp. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../../CNumerics.hpp" + +/*! + * \class CCentBase_Flow + * \brief Intermediate class to define centered schemes. + * \ingroup ConvDiscr + * \author F. Palacios + */ +class CCentBase_Flow : public CNumerics { + +protected: + unsigned short iDim, iVar, jVar; /*!< \brief Iteration on dimension and variables. */ + bool dynamic_grid; /*!< \brief Consider grid movement. */ + bool implicit; /*!< \brief Implicit calculation (compute Jacobians). */ + su2double fix_factor; /*!< \brief Fix factor for dissipation Jacobians (more diagonal dominance). */ + + su2double *Velocity_i, *Velocity_j, *MeanVelocity; /*!< \brief Velocity at nodes i and j and mean. */ + su2double ProjVelocity_i, ProjVelocity_j; /*!< \brief Velocities in the face normal direction. */ + su2double sq_vel_i, sq_vel_j; /*!< \brief Squared norm of the velocity vectors. */ + su2double Energy_i, Energy_j, MeanEnergy; /*!< \brief Energy at nodes i and j and mean. */ + su2double MeanDensity, MeanPressure, MeanEnthalpy; /*!< \brief Mean density, pressure, and enthalpy. */ + su2double *ProjFlux; /*!< \brief Projected inviscid flux. */ + + su2double *Diff_U, *Diff_Lapl; /*!< \brief Differences of conservatives and undiv. Laplacians. */ + su2double Local_Lambda_i, Local_Lambda_j, MeanLambda; /*!< \brief Local eingenvalues. */ + su2double Param_p, Phi_i, Phi_j, StretchingFactor; /*!< \brief Streching parameters. */ + su2double cte_0, cte_1; /*!< \brief Constants for the scalar dissipation Jacobian. */ + + su2double ProjGridVel; /*!< \brief Projected grid velocity. */ + + /*! + * \brief Hook method for derived classes to define preaccumulated variables, optional to implement. + * \return true if any variable was set as preacc. input, in which case the residual will be output. + */ + virtual bool SetPreaccInVars(void) {return false;} + + /*! + * \brief Derived classes must implement this method, called in ComputeResidual after inviscid part. + * \param[in,out] val_residual - Pointer to the convective flux contribution to the residual. + * \param[in,out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[in,out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + */ + virtual void DissipationTerm(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j) = 0; + + /*! + * \brief Add the contribution of a scalar dissipation term to the Jacobians. + * \param[in,out] val_Jacobian_i - Jacobian of the numerical method at node i. + * \param[in,out] val_Jacobian_j - Jacobian of the numerical method at node j. + */ + void ScalarDissipationJacobian(su2double **val_Jacobian_i, su2double **val_Jacobian_j); + +public: + /*! + * \brief Constructor of the class. + * \param[in] val_nDim - Number of dimension of the problem. + * \param[in] val_nVar - Number of variables of the problem. + * \param[in] config - Definition of the particular problem. + */ + CCentBase_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + virtual ~CCentBase_Flow(void); + + /*! + * \brief Compute the flow residual using a centered method with artificial dissipation. + * \param[out] val_residual - Pointer to the convective flux contribution to the residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + +}; + +/*! + * \class CCentLax_Flow + * \brief Class for computing the Lax-Friedrich centered scheme. + * \ingroup ConvDiscr + * \author F. Palacios + */ +class CCentLax_Flow : public CCentBase_Flow { +private: + su2double Param_Kappa_0; /*!< \brief Artificial dissipation parameter. */ + su2double sc0; /*!< \brief Streching parameter. */ + su2double Epsilon_0; /*!< \brief Artificial dissipation coefficient. */ + + /*! + * \brief Lax-Friedrich first order dissipation term. + * \param[in,out] val_residual - Pointer to the convective flux contribution to the residual. + * \param[in,out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[in,out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + */ + void DissipationTerm(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j); + + /*! + * \brief Set input variables for AD preaccumulation. + * \return true, as we will define inputs. + */ + bool SetPreaccInVars(void); + +public: + /*! + * \brief Constructor of the class. + * \param[in] val_nDim - Number of dimension of the problem. + * \param[in] val_nVar - Number of variables of the problem. + * \param[in] config - Definition of the particular problem. + */ + CCentLax_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + +}; + +/*! + * \class CCentJST_KE_Flow + * \brief Class for centered scheme - JST_KE (no 4th dissipation order term). + * \ingroup ConvDiscr + * \author F. Palacios + */ +class CCentJST_KE_Flow : public CCentBase_Flow { + +private: + su2double Param_Kappa_2; /*!< \brief Artificial dissipation parameter. */ + su2double sc2; /*!< \brief Streching parameter. */ + su2double Epsilon_2; /*!< \brief Artificial dissipation coefficient. */ + + /*! + * \brief JST_KE second order dissipation term. + * \param[in,out] val_residual - Pointer to the convective flux contribution to the residual. + * \param[in,out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[in,out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + */ + void DissipationTerm(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j); + + /*! + * \brief Set input variables for AD preaccumulation. + * \return true, as we will define inputs. + */ + bool SetPreaccInVars(void); + +public: + /*! + * \brief Constructor of the class. + * \param[in] val_nDim - Number of dimension of the problem. + * \param[in] val_nVar - Number of variables of the problem. + * \param[in] config - Definition of the particular problem. + */ + CCentJST_KE_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + +}; + +/*! + * \class CCentJST_Flow + * \brief Class for centered scheme - JST. + * \ingroup ConvDiscr + * \author F. Palacios + */ +class CCentJST_Flow : public CCentBase_Flow { + +private: + su2double Param_Kappa_2, Param_Kappa_4; /*!< \brief Artificial dissipation parameters. */ + su2double sc2, sc4; /*!< \brief Streching parameters. */ + su2double Epsilon_2, Epsilon_4; /*!< \brief Artificial dissipation coefficients. */ + + /*! + * \brief JST second and forth order dissipation terms. + * \param[in,out] val_residual - Pointer to the convective flux contribution to the residual. + * \param[in,out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[in,out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + */ + void DissipationTerm(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j); + + /*! + * \brief Set input variables for AD preaccumulation. + * \return true, as we will define inputs. + */ + bool SetPreaccInVars(void); + +public: + /*! + * \brief Constructor of the class. + * \param[in] val_nDim - Number of dimension of the problem. + * \param[in] val_nVar - Number of variables of the problem. + * \param[in] config - Definition of the particular problem. + */ + CCentJST_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + +}; + +/*! + * \class CCentLaxInc_Flow + * \brief Class for computing the Lax-Friedrich centered scheme (modified with incompressible preconditioning). + * \ingroup ConvDiscr + * \author F. Palacios, T. Economon + */ +class CCentLaxInc_Flow : public CNumerics { +private: + unsigned short iDim, iVar, jVar; /*!< \brief Iteration on dimension and variables. */ + su2double *Diff_V, /*!< \brief Difference of primitive variables. */ + *Velocity_i, *Velocity_j, /*!< \brief Velocity at node 0 and 1. */ + *MeanVelocity, ProjVelocity_i, + ProjVelocity_j, /*!< \brief Mean and projected velocities. */ + *ProjFlux, /*!< \brief Projected inviscid flux tensor. */ + sq_vel_i, sq_vel_j, /*!< \brief Modulus of the velocity and the normal vector. */ + Temperature_i, Temperature_j, /*!< \brief Temperature at node 0 and 1. */ + MeanDensity, MeanPressure, + MeanBetaInc2, MeanEnthalpy, + MeanCp, MeanTemperature, /*!< \brief Mean values of primitive variables. */ + MeandRhodT, /*!< \brief Derivative of density w.r.t. temperature (variable density flows). */ + Param_p, Param_Kappa_0, /*!< \brief Artificial dissipation parameters. */ + Local_Lambda_i, Local_Lambda_j, + MeanLambda, /*!< \brief Local eingenvalues. */ + Phi_i, Phi_j, sc0, + StretchingFactor, /*!< \brief Streching parameters. */ + Epsilon_0; /*!< \brief Artificial dissipation values. */ + su2double **Precon; + bool implicit, /*!< \brief Implicit calculation. */ + dynamic_grid, /*!< \brief Modification for grid movement. */ + variable_density, /*!< \brief Variable density incompressible flows. */ + energy; /*!< \brief computation with the energy equation. */ + +public: + /*! + * \brief Constructor of the class. + * \param[in] val_nDim - Number of dimension of the problem. + * \param[in] val_nVar - Number of variables of the problem. + * \param[in] config - Definition of the particular problem. + */ + CCentLaxInc_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CCentLaxInc_Flow(void); + + /*! + * \brief Compute the flow residual using a Lax method. + * \param[out] val_residual - Pointer to the residual array. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); +}; + +/*! + * \class CCentJSTInc_Flow + * \brief Class for centered scheme - modified JST with incompressible preconditioning. + * \ingroup ConvDiscr + * \author F. Palacios, T. Economon + */ +class CCentJSTInc_Flow : public CNumerics { + +private: + unsigned short iDim, iVar, jVar; /*!< \brief Iteration on dimension and variables. */ + su2double *Diff_V, *Diff_Lapl, /*!< \brief Diference of primitive variables and undivided laplacians. */ + *Velocity_i, *Velocity_j, /*!< \brief Velocity at node 0 and 1. */ + *MeanVelocity, ProjVelocity_i, + ProjVelocity_j, /*!< \brief Mean and projected velocities. */ + sq_vel_i, sq_vel_j, /*!< \brief Modulus of the velocity and the normal vector. */ + Temperature_i, Temperature_j, /*!< \brief Temperature at node 0 and 1. */ + MeanDensity, MeanPressure, + MeanBetaInc2, MeanEnthalpy, + MeanCp, MeanTemperature, /*!< \brief Mean values of primitive variables. */ + MeandRhodT, /*!< \brief Derivative of density w.r.t. temperature (variable density flows). */ + Param_p, Param_Kappa_2, + Param_Kappa_4, /*!< \brief Artificial dissipation parameters. */ + Local_Lambda_i, Local_Lambda_j, + MeanLambda, /*!< \brief Local eingenvalues. */ + Phi_i, Phi_j, sc2, sc4, + StretchingFactor, /*!< \brief Streching parameters. */ + *ProjFlux, /*!< \brief Projected inviscid flux tensor. */ + Epsilon_2, Epsilon_4; /*!< \brief Artificial dissipation values. */ + su2double **Precon; + bool implicit, /*!< \brief Implicit calculation. */ + dynamic_grid, /*!< \brief Modification for grid movement. */ + variable_density, /*!< \brief Variable density incompressible flows. */ + energy; /*!< \brief computation with the energy equation. */ + +public: + /*! + * \brief Constructor of the class. + * \param[in] val_nDim - Number of dimension of the problem. + * \param[in] val_nVar - Number of variables of the problem. + * \param[in] config - Definition of the particular problem. + */ + CCentJSTInc_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CCentJSTInc_Flow(void); + + /*! + * \brief Compute the flow residual using a JST method. + * \param[out] val_residual - Pointer to the residual array. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); +}; diff --git a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwCUSP_Flow.hpp b/SU2_CFD/include/numerics/flow/convection/cusp.hpp similarity index 93% rename from SU2_CFD/include/numerics/flow/convection_upwind/CUpwCUSP_Flow.hpp rename to SU2_CFD/include/numerics/flow/convection/cusp.hpp index 755c8d4d4575..82eff71a5453 100644 --- a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwCUSP_Flow.hpp +++ b/SU2_CFD/include/numerics/flow/convection/cusp.hpp @@ -1,7 +1,6 @@ /*! - * \file CUpwCUSP_Flow.hpp - * \brief Delaration of numerics class CUpwCUSP_Flow, the - * implementation is in the CUpwCUSP_Flow.cpp file. + * \file cusp.hpp + * \brief Declaration of the CUSP numerics class. * \author F. Palacios, T. Economon * \version 7.0.0 "Blackbird" * diff --git a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwFDSInc_Flow.hpp b/SU2_CFD/include/numerics/flow/convection/fds.hpp similarity index 95% rename from SU2_CFD/include/numerics/flow/convection_upwind/CUpwFDSInc_Flow.hpp rename to SU2_CFD/include/numerics/flow/convection/fds.hpp index ff8cf428dc57..4a36fc4b404c 100644 --- a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwFDSInc_Flow.hpp +++ b/SU2_CFD/include/numerics/flow/convection/fds.hpp @@ -1,7 +1,7 @@ /*! - * \file CUpwFDSInc_Flow.hpp - * \brief Delaration of numerics class CUpwFDSInc_Flow, the - * implementation is in the CUpwFDSInc_Flow.cpp file. + * \file fds.hpp + * \brief Declarations of classes for Flux-Difference-Spliting schemes, + * the implementations are in fds.cpp * \author F. Palacios, T. Economon * \version 7.0.0 "Blackbird" * diff --git a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwMSW_Flow.hpp b/SU2_CFD/include/numerics/flow/convection/fvs.hpp similarity index 94% rename from SU2_CFD/include/numerics/flow/convection_upwind/CUpwMSW_Flow.hpp rename to SU2_CFD/include/numerics/flow/convection/fvs.hpp index 4d33560e32cc..57b4a078008f 100644 --- a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwMSW_Flow.hpp +++ b/SU2_CFD/include/numerics/flow/convection/fvs.hpp @@ -1,7 +1,7 @@ /*! - * \file CUpwMSW_Flow.hpp - * \brief Delaration of numerics class CUpwMSW_Flow, the - * implementation is in the CUpwMSW_Flow.cpp file. + * \file fvs.hpp + * \brief Delarations of classes for Flux-Vector-Spliting schemes, + * the implementations are in fvs.cpp. * \author F. Palacios, T. Economon * \version 7.0.0 "Blackbird" * diff --git a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwGeneralHLLC_Flow.hpp b/SU2_CFD/include/numerics/flow/convection/hllc.hpp similarity index 62% rename from SU2_CFD/include/numerics/flow/convection_upwind/CUpwGeneralHLLC_Flow.hpp rename to SU2_CFD/include/numerics/flow/convection/hllc.hpp index 129e71e78f8d..79422a5d0db6 100644 --- a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwGeneralHLLC_Flow.hpp +++ b/SU2_CFD/include/numerics/flow/convection/hllc.hpp @@ -1,7 +1,6 @@ /*! - * \file CUpwGeneralHLLC_Flow.hpp - * \brief Delaration of numerics class CUpwGeneralHLLC_Flow, the - * implementation is in the CUpwGeneralHLLC_Flow.cpp file. + * \file hllc.hpp + * \brief Declaration of HLLC numerics classes, implemented in hllc.cpp. * \author F. Palacios, T. Economon * \version 7.0.0 "Blackbird" * @@ -30,6 +29,57 @@ #include "../../CNumerics.hpp" +/*! + * \class CUpwHLLC_Flow + * \brief Class for solving an approximate Riemann HLLC. + * \ingroup ConvDiscr + * \author G. Gori, Politecnico di Milano + * \version 7.0.0 "Blackbird" + */ +class CUpwHLLC_Flow : public CNumerics { +private: + bool implicit, dynamic_grid; + unsigned short iDim, jDim, iVar, jVar; + + su2double *IntermediateState; + su2double *Velocity_i, *Velocity_j, *RoeVelocity; + + su2double sq_vel_i, Density_i, Energy_i, SoundSpeed_i, Pressure_i, Enthalpy_i, ProjVelocity_i; + su2double sq_vel_j, Density_j, Energy_j, SoundSpeed_j, Pressure_j, Enthalpy_j, ProjVelocity_j; + + su2double sq_velRoe, RoeDensity, RoeEnthalpy, RoeSoundSpeed, RoeProjVelocity, ProjInterfaceVel; + + su2double sL, sR, sM, pStar, EStar, rhoSL, rhoSR, Rrho, kappa; + + su2double Omega, RHO, OmegaSM; + su2double *dSm_dU, *dPI_dU, *drhoStar_dU, *dpStar_dU, *dEStar_dU; + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CUpwHLLC_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CUpwHLLC_Flow(void); + + /*! + * \brief Compute the Roe's flux between two nodes i and j. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + +}; + /*! * \class CUpwGeneralHLLC_Flow * \brief Class for solving an approximate Riemann HLLC. @@ -73,7 +123,6 @@ class CUpwGeneralHLLC_Flow : public CNumerics { ~CUpwGeneralHLLC_Flow(void); /*! - * \brief Compute the Roe's flux between two nodes i and j. * \param[out] val_residual - Pointer to the total residual. * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). diff --git a/SU2_CFD/include/numerics/flow/convection/roe.hpp b/SU2_CFD/include/numerics/flow/convection/roe.hpp new file mode 100644 index 000000000000..e8ef64ebbb6b --- /dev/null +++ b/SU2_CFD/include/numerics/flow/convection/roe.hpp @@ -0,0 +1,273 @@ +/*! + * \file roe.hpp + * \brief Delarations of numerics classes for Roe-type schemes, + * implemented in roe.cpp. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../../CNumerics.hpp" + +/*! + * \class CUpwRoeBase_Flow + * \brief Intermediate base class for Roe schemes on ideal gas. + * \ingroup ConvDiscr + * \author A. Bueno, F. Palacios + */ +class CUpwRoeBase_Flow : public CNumerics { +protected: + bool implicit, dynamic_grid, roe_low_dissipation; + su2double *Velocity_i, *Velocity_j, *ProjFlux_i, *ProjFlux_j, *Conservatives_i, *Conservatives_j; + su2double *Diff_U, *Lambda, **P_Tensor, **invP_Tensor; + su2double *RoeVelocity, RoeDensity, RoeEnthalpy, RoeSoundSpeed, ProjVelocity, RoeSoundSpeed2, kappa; + + /*! + * \brief Derived classes must specialize this method to add the specifics of the scheme they implement (e.g. low-Mach precond.). + * \param[out] val_residual - Convective flux. + * \param[out] val_Jacobian_i - Flux Jacobian wrt node i conservatives (implicit computation). + * \param[out] val_Jacobian_j - Flux Jacobian wrt node j conservatives (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + virtual void FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) = 0; + +public: + /*! + * \brief Constructor of the class. + * \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. + * \param[in] val_low_dissipation - Use a low dissipation formulation. + */ + CUpwRoeBase_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, bool val_low_dissipation); + + /*! + * \brief Destructor of the class. + */ + virtual ~CUpwRoeBase_Flow(void); + + /*! + * \brief Compute the flux from node i to node j, part common to most Roe schemes. + * \param[out] val_residual - Convective flux. + * \param[out] val_Jacobian_i - Flux Jacobian wrt node i conservatives (implicit computation). + * \param[out] val_Jacobian_j - Flux Jacobian wrt node j conservatives (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + +}; + +/*! + * \class CUpwRoe_Flow + * \brief Class for solving an approximate Riemann solver of Roe for the flow equations. + * \ingroup ConvDiscr + * \author A. Bueno, F. Palacios + */ +class CUpwRoe_Flow : public CUpwRoeBase_Flow { +private: + /*! + * \brief Add standard Roe dissipation to the flux. + * \param[out] val_residual - Convective flux. + * \param[out] val_Jacobian_i - Flux Jacobian wrt node i conservatives (implicit computation). + * \param[out] val_Jacobian_j - Flux Jacobian wrt node j conservatives (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + +public: + /*! + * \brief Constructor of the class. + * \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. + * \param[in] val_low_dissipation - Use a low dissipation formulation. + */ + CUpwRoe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, bool val_low_dissipation); + +}; + +/*! + * \class CUpwL2Roe_Flow + * \brief Class for solving an approximate Riemann solver of L2Roe for the flow equations. + * \ingroup ConvDiscr + * \author E. Molina, A. Bueno, F. Palacios + * \version 7.0.0 "Blackbird" + */ +class CUpwL2Roe_Flow : public CUpwRoeBase_Flow { +private: + /*! + * \brief Add L^2 Roe dissipation to the flux (low-Mach scheme). + * \param[out] val_residual - Convective flux. + * \param[out] val_Jacobian_i - Flux Jacobian wrt node i conservatives (implicit computation). + * \param[out] val_Jacobian_j - Flux Jacobian wrt node j conservatives (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + +public: + /*! + * \brief Constructor of the class. + * \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. + */ + CUpwL2Roe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + +}; + +/*! + * \class CUpwLMRoe_Flow + * \brief Class for solving an approximate Riemann solver of LMRoe for the flow equations. + * \ingroup ConvDiscr + * \author E. Molina, A. Bueno, F. Palacios + * \version 7.0.0 "Blackbird" + */ +class CUpwLMRoe_Flow : public CUpwRoeBase_Flow { +private: + /*! + * \brief Add LMRoe dissipation to the flux (low-Mach scheme). + * \param[out] val_residual - Convective flux. + * \param[out] val_Jacobian_i - Flux Jacobian wrt node i conservatives (implicit computation). + * \param[out] val_Jacobian_j - Flux Jacobian wrt node j conservatives (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + +public: + /*! + * \brief Constructor of the class. + * \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. + */ + CUpwLMRoe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + +}; + +/*! + * \class CUpwTurkel_Flow + * \brief Class for solving an approximate Riemann solver of Roe with Turkel Preconditioning for the flow equations. + * \ingroup ConvDiscr + * \author A. K. Lonkar + */ +class CUpwTurkel_Flow : public CNumerics { +private: + bool implicit, dynamic_grid; + su2double *Diff_U; + su2double *Velocity_i, *Velocity_j, *RoeVelocity; + su2double *ProjFlux_i, *ProjFlux_j; + su2double *Lambda, *Epsilon; + su2double **absPeJac, **invRinvPe, **R_Tensor, **Matrix, **Art_Visc; + su2double sq_vel, Density_i, Energy_i, SoundSpeed_i, Pressure_i, Enthalpy_i, + Density_j, Energy_j, SoundSpeed_j, Pressure_j, Enthalpy_j, R, RoePressure, RoeDensity, RoeEnthalpy, RoeSoundSpeed, + ProjVelocity, ProjVelocity_i, ProjVelocity_j; + unsigned short iDim, iVar, jVar, kVar; + su2double Beta, Beta_min, Beta_max; + su2double r_hat, s_hat, t_hat, rhoB2a2, sqr_one_m_Betasqr_Lam1; + su2double Beta2, one_m_Betasqr, one_p_Betasqr, sqr_two_Beta_c_Area; + su2double local_Mach; + +public: + /*! + * \brief Constructor of the class. + * \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. + */ + CUpwTurkel_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CUpwTurkel_Flow(void); + + /*! + * \brief Compute the Roe's flux between two nodes i and j. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + +}; + +/*! + * \class CUpwGeneralRoe_Flow + * \brief Class for solving an approximate Riemann solver of Roe for the flow equations for a general fluid model. + * \ingroup ConvDiscr + * \author S.Vitale, G.Gori, M.Pini + */ +class CUpwGeneralRoe_Flow : public CNumerics { +private: + + bool implicit, dynamic_grid; + + su2double *Diff_U; + su2double *Velocity_i, *Velocity_j, *RoeVelocity; + su2double *ProjFlux_i, *ProjFlux_j; + su2double *delta_wave, *delta_vel; + su2double *Lambda, *Epsilon, MaxLambda, Delta; + su2double **P_Tensor, **invP_Tensor; + su2double sq_vel, Proj_ModJac_Tensor_ij, Density_i, Energy_i, SoundSpeed_i, Pressure_i, Enthalpy_i, + + Density_j, Energy_j, SoundSpeed_j, Pressure_j, Enthalpy_j, R, RoeDensity, RoeEnthalpy, RoeSoundSpeed, RoeSoundSpeed2, + ProjVelocity, ProjVelocity_i, ProjVelocity_j, proj_delta_vel, delta_p, delta_rho, kappa; + unsigned short iDim, iVar, jVar, kVar; + + + su2double StaticEnthalpy_i, StaticEnergy_i, StaticEnthalpy_j, StaticEnergy_j, Kappa_i, Kappa_j, Chi_i, Chi_j, Velocity2_i, Velocity2_j; + su2double RoeKappa, RoeChi; + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CUpwGeneralRoe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CUpwGeneralRoe_Flow(void); + + /*! + * \brief Compute the Roe's flux between two nodes i and j. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + + /*! + * \brief Compute the Average for a general fluid flux between two nodes i and j. + * Using the approach of Vinokur and Montagne' + */ + + void ComputeRoeAverage(); +}; diff --git a/SU2_CFD/include/numerics/flow/convection_centered/CCentBase_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_centered/CCentBase_Flow.hpp deleted file mode 100644 index 6892e8ac4fde..000000000000 --- a/SU2_CFD/include/numerics/flow/convection_centered/CCentBase_Flow.hpp +++ /dev/null @@ -1,106 +0,0 @@ -/*! - * \file CCentBase_Flow.hpp - * \brief Delaration of numerics class CCentBase_Flow, the - * implementation is in the CCentBase_Flow.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../../CNumerics.hpp" - -/*! - * \class CCentBase_Flow - * \brief Intermediate class to define centered schemes. - * \ingroup ConvDiscr - * \author F. Palacios - */ -class CCentBase_Flow : public CNumerics { - -protected: - unsigned short iDim, iVar, jVar; /*!< \brief Iteration on dimension and variables. */ - bool dynamic_grid; /*!< \brief Consider grid movement. */ - bool implicit; /*!< \brief Implicit calculation (compute Jacobians). */ - su2double fix_factor; /*!< \brief Fix factor for dissipation Jacobians (more diagonal dominance). */ - - su2double *Velocity_i, *Velocity_j, *MeanVelocity; /*!< \brief Velocity at nodes i and j and mean. */ - su2double ProjVelocity_i, ProjVelocity_j; /*!< \brief Velocities in the face normal direction. */ - su2double sq_vel_i, sq_vel_j; /*!< \brief Squared norm of the velocity vectors. */ - su2double Energy_i, Energy_j, MeanEnergy; /*!< \brief Energy at nodes i and j and mean. */ - su2double MeanDensity, MeanPressure, MeanEnthalpy; /*!< \brief Mean density, pressure, and enthalpy. */ - su2double *ProjFlux; /*!< \brief Projected inviscid flux. */ - - su2double *Diff_U, *Diff_Lapl; /*!< \brief Differences of conservatives and undiv. Laplacians. */ - su2double Local_Lambda_i, Local_Lambda_j, MeanLambda; /*!< \brief Local eingenvalues. */ - su2double Param_p, Phi_i, Phi_j, StretchingFactor; /*!< \brief Streching parameters. */ - su2double cte_0, cte_1; /*!< \brief Constants for the scalar dissipation Jacobian. */ - - su2double ProjGridVel; /*!< \brief Projected grid velocity. */ - - /*! - * \brief Hook method for derived classes to define preaccumulated variables, optional to implement. - * \return true if any variable was set as preacc. input, in which case the residual will be output. - */ - virtual bool SetPreaccInVars(void) {return false;} - - /*! - * \brief Derived classes must implement this method, called in ComputeResidual after inviscid part. - * \param[in,out] val_residual - Pointer to the convective flux contribution to the residual. - * \param[in,out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[in,out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - */ - virtual void DissipationTerm(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j) = 0; - - /*! - * \brief Add the contribution of a scalar dissipation term to the Jacobians. - * \param[in,out] val_Jacobian_i - Jacobian of the numerical method at node i. - * \param[in,out] val_Jacobian_j - Jacobian of the numerical method at node j. - */ - void ScalarDissipationJacobian(su2double **val_Jacobian_i, su2double **val_Jacobian_j); - -public: - - /*! - * \brief Constructor of the class. - * \param[in] val_nDim - Number of dimension of the problem. - * \param[in] val_nVar - Number of variables of the problem. - * \param[in] config - Definition of the particular problem. - */ - CCentBase_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - virtual ~CCentBase_Flow(void); - - /*! - * \brief Compute the flow residual using a centered method with artificial dissipation. - * \param[out] val_residual - Pointer to the convective flux contribution to the residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - -}; diff --git a/SU2_CFD/include/numerics/flow/convection_centered/CCentJSTInc_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_centered/CCentJSTInc_Flow.hpp deleted file mode 100644 index d5c0cc97ebc0..000000000000 --- a/SU2_CFD/include/numerics/flow/convection_centered/CCentJSTInc_Flow.hpp +++ /dev/null @@ -1,90 +0,0 @@ -/*! - * \file CCentJSTInc_Flow.hpp - * \brief Delaration of numerics class CCentJSTInc_Flow, the - * implementation is in the CCentJSTInc_Flow.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../../CNumerics.hpp" - -/*! - * \class CCentJSTInc_Flow - * \brief Class for centered scheme - modified JST with incompressible preconditioning. - * \ingroup ConvDiscr - * \author F. Palacios, T. Economon - */ -class CCentJSTInc_Flow : public CNumerics { - -private: - unsigned short iDim, iVar, jVar; /*!< \brief Iteration on dimension and variables. */ - su2double *Diff_V, *Diff_Lapl, /*!< \brief Diference of primitive variables and undivided laplacians. */ - *Velocity_i, *Velocity_j, /*!< \brief Velocity at node 0 and 1. */ - *MeanVelocity, ProjVelocity_i, - ProjVelocity_j, /*!< \brief Mean and projected velocities. */ - sq_vel_i, sq_vel_j, /*!< \brief Modulus of the velocity and the normal vector. */ - Temperature_i, Temperature_j, /*!< \brief Temperature at node 0 and 1. */ - MeanDensity, MeanPressure, - MeanBetaInc2, MeanEnthalpy, - MeanCp, MeanTemperature, /*!< \brief Mean values of primitive variables. */ - MeandRhodT, /*!< \brief Derivative of density w.r.t. temperature (variable density flows). */ - Param_p, Param_Kappa_2, - Param_Kappa_4, /*!< \brief Artificial dissipation parameters. */ - Local_Lambda_i, Local_Lambda_j, - MeanLambda, /*!< \brief Local eingenvalues. */ - Phi_i, Phi_j, sc2, sc4, - StretchingFactor, /*!< \brief Streching parameters. */ - *ProjFlux, /*!< \brief Projected inviscid flux tensor. */ - Epsilon_2, Epsilon_4; /*!< \brief Artificial dissipation values. */ - su2double **Precon; - bool implicit, /*!< \brief Implicit calculation. */ - dynamic_grid, /*!< \brief Modification for grid movement. */ - variable_density, /*!< \brief Variable density incompressible flows. */ - energy; /*!< \brief computation with the energy equation. */ - -public: - - /*! - * \brief Constructor of the class. - * \param[in] val_nDim - Number of dimension of the problem. - * \param[in] val_nVar - Number of variables of the problem. - * \param[in] config - Definition of the particular problem. - */ - CCentJSTInc_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CCentJSTInc_Flow(void); - - /*! - * \brief Compute the flow residual using a JST method. - * \param[out] val_residual - Pointer to the residual array. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); -}; diff --git a/SU2_CFD/include/numerics/flow/convection_centered/CCentJST_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_centered/CCentJST_Flow.hpp deleted file mode 100644 index db6a76396924..000000000000 --- a/SU2_CFD/include/numerics/flow/convection_centered/CCentJST_Flow.hpp +++ /dev/null @@ -1,75 +0,0 @@ -/*! - * \file CCentJST_Flow.hpp - * \brief Delaration of numerics class CCentJST_Flow, the - * implementation is in the CCentJST_Flow.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "CCentBase_Flow.hpp" - -/*! - * \class CCentJST_Flow - * \brief Class for centered scheme - JST. - * \ingroup ConvDiscr - * \author F. Palacios - */ -class CCentJST_Flow : public CCentBase_Flow { - -private: - su2double Param_Kappa_2, Param_Kappa_4; /*!< \brief Artificial dissipation parameters. */ - su2double sc2, sc4; /*!< \brief Streching parameters. */ - su2double Epsilon_2, Epsilon_4; /*!< \brief Artificial dissipation coefficients. */ - - /*! - * \brief JST second and forth order dissipation terms. - * \param[in,out] val_residual - Pointer to the convective flux contribution to the residual. - * \param[in,out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[in,out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - */ - void DissipationTerm(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j); - - /*! - * \brief Set input variables for AD preaccumulation. - * \return true, as we will define inputs. - */ - bool SetPreaccInVars(void); - -public: - - /*! - * \brief Constructor of the class. - * \param[in] val_nDim - Number of dimension of the problem. - * \param[in] val_nVar - Number of variables of the problem. - * \param[in] config - Definition of the particular problem. - */ - CCentJST_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CCentJST_Flow(void); - -}; diff --git a/SU2_CFD/include/numerics/flow/convection_centered/CCentJST_KE_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_centered/CCentJST_KE_Flow.hpp deleted file mode 100644 index 34f92df45669..000000000000 --- a/SU2_CFD/include/numerics/flow/convection_centered/CCentJST_KE_Flow.hpp +++ /dev/null @@ -1,75 +0,0 @@ -/*! - * \file CCentJST_KE_Flow.hpp - * \brief Delaration of numerics class CCentJST_KE_Flow, the - * implementation is in the CCentJST_KE_Flow.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "CCentBase_Flow.hpp" - -/*! - * \class CCentJST_KE_Flow - * \brief Class for centered scheme - JST_KE (no 4th dissipation order term). - * \ingroup ConvDiscr - * \author F. Palacios - */ -class CCentJST_KE_Flow : public CCentBase_Flow { - -private: - su2double Param_Kappa_2; /*!< \brief Artificial dissipation parameter. */ - su2double sc2; /*!< \brief Streching parameter. */ - su2double Epsilon_2; /*!< \brief Artificial dissipation coefficient. */ - - /*! - * \brief JST_KE second order dissipation term. - * \param[in,out] val_residual - Pointer to the convective flux contribution to the residual. - * \param[in,out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[in,out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - */ - void DissipationTerm(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j); - - /*! - * \brief Set input variables for AD preaccumulation. - * \return true, as we will define inputs. - */ - bool SetPreaccInVars(void); - -public: - - /*! - * \brief Constructor of the class. - * \param[in] val_nDim - Number of dimension of the problem. - * \param[in] val_nVar - Number of variables of the problem. - * \param[in] config - Definition of the particular problem. - */ - CCentJST_KE_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CCentJST_KE_Flow(void); - -}; diff --git a/SU2_CFD/include/numerics/flow/convection_centered/CCentLaxInc_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_centered/CCentLaxInc_Flow.hpp deleted file mode 100644 index 1fbf680d343e..000000000000 --- a/SU2_CFD/include/numerics/flow/convection_centered/CCentLaxInc_Flow.hpp +++ /dev/null @@ -1,88 +0,0 @@ -/*! - * \file CCentLaxInc_Flow.hpp - * \brief Delaration of numerics class CCentLaxInc_Flow, the - * implementation is in the CCentLaxInc_Flow.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../../CNumerics.hpp" - -/*! - * \class CCentLaxInc_Flow - * \brief Class for computing the Lax-Friedrich centered scheme (modified with incompressible preconditioning). - * \ingroup ConvDiscr - * \author F. Palacios, T. Economon - */ -class CCentLaxInc_Flow : public CNumerics { -private: - unsigned short iDim, iVar, jVar; /*!< \brief Iteration on dimension and variables. */ - su2double *Diff_V, /*!< \brief Difference of primitive variables. */ - *Velocity_i, *Velocity_j, /*!< \brief Velocity at node 0 and 1. */ - *MeanVelocity, ProjVelocity_i, - ProjVelocity_j, /*!< \brief Mean and projected velocities. */ - *ProjFlux, /*!< \brief Projected inviscid flux tensor. */ - sq_vel_i, sq_vel_j, /*!< \brief Modulus of the velocity and the normal vector. */ - Temperature_i, Temperature_j, /*!< \brief Temperature at node 0 and 1. */ - MeanDensity, MeanPressure, - MeanBetaInc2, MeanEnthalpy, - MeanCp, MeanTemperature, /*!< \brief Mean values of primitive variables. */ - MeandRhodT, /*!< \brief Derivative of density w.r.t. temperature (variable density flows). */ - Param_p, Param_Kappa_0, /*!< \brief Artificial dissipation parameters. */ - Local_Lambda_i, Local_Lambda_j, - MeanLambda, /*!< \brief Local eingenvalues. */ - Phi_i, Phi_j, sc0, - StretchingFactor, /*!< \brief Streching parameters. */ - Epsilon_0; /*!< \brief Artificial dissipation values. */ - su2double **Precon; - bool implicit, /*!< \brief Implicit calculation. */ - dynamic_grid, /*!< \brief Modification for grid movement. */ - variable_density, /*!< \brief Variable density incompressible flows. */ - energy; /*!< \brief computation with the energy equation. */ - -public: - - /*! - * \brief Constructor of the class. - * \param[in] val_nDim - Number of dimension of the problem. - * \param[in] val_nVar - Number of variables of the problem. - * \param[in] config - Definition of the particular problem. - */ - CCentLaxInc_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CCentLaxInc_Flow(void); - - /*! - * \brief Compute the flow residual using a Lax method. - * \param[out] val_residual - Pointer to the residual array. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); -}; diff --git a/SU2_CFD/include/numerics/flow/convection_centered/CCentLax_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_centered/CCentLax_Flow.hpp deleted file mode 100644 index 410a3355f8c0..000000000000 --- a/SU2_CFD/include/numerics/flow/convection_centered/CCentLax_Flow.hpp +++ /dev/null @@ -1,74 +0,0 @@ -/*! - * \file CCentLax_Flow.hpp - * \brief Delaration of numerics class CCentLax_Flow, the - * implementation is in the CCentLax_Flow.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "CCentBase_Flow.hpp" - -/*! - * \class CCentLax_Flow - * \brief Class for computing the Lax-Friedrich centered scheme. - * \ingroup ConvDiscr - * \author F. Palacios - */ -class CCentLax_Flow : public CCentBase_Flow { -private: - su2double Param_Kappa_0; /*!< \brief Artificial dissipation parameter. */ - su2double sc0; /*!< \brief Streching parameter. */ - su2double Epsilon_0; /*!< \brief Artificial dissipation coefficient. */ - - /*! - * \brief Lax-Friedrich first order dissipation term. - * \param[in,out] val_residual - Pointer to the convective flux contribution to the residual. - * \param[in,out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[in,out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - */ - void DissipationTerm(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j); - - /*! - * \brief Set input variables for AD preaccumulation. - * \return true, as we will define inputs. - */ - bool SetPreaccInVars(void); - -public: - - /*! - * \brief Constructor of the class. - * \param[in] val_nDim - Number of dimension of the problem. - * \param[in] val_nVar - Number of variables of the problem. - * \param[in] config - Definition of the particular problem. - */ - CCentLax_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CCentLax_Flow(void); - -}; diff --git a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwAUSMPLUSUP2_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwAUSMPLUSUP2_Flow.hpp deleted file mode 100644 index 8a85b23a0b2c..000000000000 --- a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwAUSMPLUSUP2_Flow.hpp +++ /dev/null @@ -1,66 +0,0 @@ -/*! - * \file CUpwAUSMPLUSUP2_Flow.hpp - * \brief Delaration of numerics class CUpwAUSMPLUSUP2_Flow, the - * implementation is in the CUpwAUSMPLUSUP2_Flow.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "CUpwAUSMPLUS_SLAU_Base_Flow.hpp" - -/*! - * \class CUpwAUSMPLUSUP2_Flow - * \brief Class for solving an approximate Riemann AUSM+ -up. - * \ingroup ConvDiscr - * \author Amit Sachdeva - */ -class CUpwAUSMPLUSUP2_Flow : public CUpwAUSMPLUS_SLAU_Base_Flow { -private: - su2double Kp, sigma; - - /*! - * \brief Mass flux and pressure for the AUSM+up2 scheme. - * \param[in] config - Definition of the particular problem. - * \param[out] mdot - The mass flux. - * \param[out] pressure - The pressure at the control volume face. - */ - void ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure); - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwAUSMPLUSUP2_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwAUSMPLUSUP2_Flow(void); - -}; diff --git a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwAUSMPLUSUP_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwAUSMPLUSUP_Flow.hpp deleted file mode 100644 index 60aa4074dd90..000000000000 --- a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwAUSMPLUSUP_Flow.hpp +++ /dev/null @@ -1,65 +0,0 @@ -/*! - * \file CUpwAUSMPLUSUP_Flow.hpp - * \brief Delaration of numerics class CUpwAUSMPLUSUP_Flow, the - * implementation is in the CUpwAUSMPLUSUP_Flow.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "CUpwAUSMPLUS_SLAU_Base_Flow.hpp" - -/*! - * \class CUpwAUSMPLUSUP_Flow - * \brief Class for solving an approximate Riemann AUSM+ -up. - * \ingroup ConvDiscr - * \author Amit Sachdeva - */ -class CUpwAUSMPLUSUP_Flow : public CUpwAUSMPLUS_SLAU_Base_Flow { -private: - su2double Kp, Ku, sigma; - - /*! - * \brief Mass flux and pressure for the AUSM+up scheme. - * \param[in] config - Definition of the particular problem. - * \param[out] mdot - The mass flux. - * \param[out] pressure - The pressure at the control volume face. - */ - void ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure); - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwAUSMPLUSUP_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwAUSMPLUSUP_Flow(void); -}; diff --git a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwAUSMPLUS_SLAU_Base_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwAUSMPLUS_SLAU_Base_Flow.hpp deleted file mode 100644 index c5155e01bf32..000000000000 --- a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwAUSMPLUS_SLAU_Base_Flow.hpp +++ /dev/null @@ -1,100 +0,0 @@ -/*! - * \file CUpwAUSMPLUS_SLAU_Base_Flow.hpp - * \brief Delaration of numerics class CUpwAUSMPLUS_SLAU_Base_Flow, the - * implementation is in the CUpwAUSMPLUS_SLAU_Base_Flow.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../../CNumerics.hpp" - -/*! - * \class CUpwAUSMPLUS_SLAU_Base_Flow - * \brief Base class for AUSM+up(2) and SLAU(2) convective schemes. - * \ingroup ConvDiscr - * \author Amit Sachdeva - */ -class CUpwAUSMPLUS_SLAU_Base_Flow : public CNumerics { -protected: - bool implicit; - bool UseAccurateJacobian; - bool HasAnalyticalDerivatives; - su2double FinDiffStep; - - su2double MassFlux, DissFlux, Pressure; - su2double *Velocity_i, *Velocity_j; - su2double *psi_i, *psi_j; - su2double dmdot_dVi[6], dmdot_dVj[6], dpres_dVi[6], dpres_dVj[6]; - - /*--- Roe variables (for approximate Jacobian) ---*/ - su2double *Lambda, *Epsilon, *RoeVelocity, **P_Tensor, **invP_Tensor; - - /*! - * \brief Compute the mass flux and pressure based on Primitives_i/j, derived classes must implement this method. - * \note See the body of the (empty) default implementation for instructions on how to implement the method. - * \param[in] config - Definition of the particular problem. - * \param[out] mdot - The mass flux. - * \param[out] pressure - The pressure at the control volume face. - */ - virtual void ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure) = 0; - - /*! - * \brief Compute the flux Jacobians of the Roe scheme to use as an approximation. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - */ - void ApproximateJacobian(su2double **val_Jacobian_i, su2double **val_Jacobian_j); - - /*! - * \brief Compute the flux Jacobians using a mix of finite differences and manual differentiation. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - */ - void AccurateJacobian(CConfig *config, su2double **val_Jacobian_i, su2double **val_Jacobian_j); - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwAUSMPLUS_SLAU_Base_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwAUSMPLUS_SLAU_Base_Flow(void); - - /*! - * \brief Compute the AUSM+ and SLAU family of schemes. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); -}; diff --git a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwAUSM_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwAUSM_Flow.hpp deleted file mode 100644 index 337a65943d06..000000000000 --- a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwAUSM_Flow.hpp +++ /dev/null @@ -1,77 +0,0 @@ -/*! - * \file CUpwAUSM_Flow.hpp - * \brief Delaration of numerics class CUpwAUSM_Flow, the - * implementation is in the CUpwAUSM_Flow.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../../CNumerics.hpp" - -/*! - * \class CUpwAUSM_Flow - * \brief Class for solving an approximate Riemann AUSM. - * \ingroup ConvDiscr - * \author F. Palacios - */ -class CUpwAUSM_Flow : public CNumerics { -private: - bool implicit; - su2double *Diff_U; - su2double *Velocity_i, *Velocity_j, *RoeVelocity; - su2double *ProjFlux_i, *ProjFlux_j; - su2double *delta_wave, *delta_vel; - su2double *Lambda, *Epsilon; - su2double **P_Tensor, **invP_Tensor; - su2double sq_vel, Proj_ModJac_Tensor_ij, Density_i, Energy_i, SoundSpeed_i, Pressure_i, Enthalpy_i, - Density_j, Energy_j, SoundSpeed_j, Pressure_j, Enthalpy_j, R, RoeDensity, RoeEnthalpy, RoeSoundSpeed, - ProjVelocity, ProjVelocity_i, ProjVelocity_j; - unsigned short iDim, iVar, jVar, kVar; - su2double mL, mR, mLP, mRM, mF, pLP, pRM, pF, Phi; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwAUSM_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwAUSM_Flow(void); - - /*! - * \brief Compute the Roe's flux between two nodes i and j. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); -}; diff --git a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwGeneralRoe_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwGeneralRoe_Flow.hpp deleted file mode 100644 index 8ad80d3194f7..000000000000 --- a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwGeneralRoe_Flow.hpp +++ /dev/null @@ -1,90 +0,0 @@ -/*! - * \file CUpwGeneralRoe_Flow.hpp - * \brief Delaration of numerics class CUpwGeneralRoe_Flow, the - * implementation is in the CUpwGeneralRoe_Flow.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../../CNumerics.hpp" - -/*! - * \class CUpwGeneralRoe_Flow - * \brief Class for solving an approximate Riemann solver of Roe for the flow equations for a general fluid model. - * \ingroup ConvDiscr - * \author S.Vitale, G.Gori, M.Pini - */ -class CUpwGeneralRoe_Flow : public CNumerics { -private: - - bool implicit, dynamic_grid; - - su2double *Diff_U; - su2double *Velocity_i, *Velocity_j, *RoeVelocity; - su2double *ProjFlux_i, *ProjFlux_j; - su2double *delta_wave, *delta_vel; - su2double *Lambda, *Epsilon, MaxLambda, Delta; - su2double **P_Tensor, **invP_Tensor; - su2double sq_vel, Proj_ModJac_Tensor_ij, Density_i, Energy_i, SoundSpeed_i, Pressure_i, Enthalpy_i, - - Density_j, Energy_j, SoundSpeed_j, Pressure_j, Enthalpy_j, R, RoeDensity, RoeEnthalpy, RoeSoundSpeed, RoeSoundSpeed2, - ProjVelocity, ProjVelocity_i, ProjVelocity_j, proj_delta_vel, delta_p, delta_rho, kappa; - unsigned short iDim, iVar, jVar, kVar; - - - su2double StaticEnthalpy_i, StaticEnergy_i, StaticEnthalpy_j, StaticEnergy_j, Kappa_i, Kappa_j, Chi_i, Chi_j, Velocity2_i, Velocity2_j; - su2double RoeKappa, RoeChi; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwGeneralRoe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwGeneralRoe_Flow(void); - - /*! - * \brief Compute the Roe's flux between two nodes i and j. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - - /*! - * \brief Compute the Average for a general fluid flux between two nodes i and j. - * Using the approach of Vinokur and Montagne' - */ - - void ComputeRoeAverage(); -}; diff --git a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwHLLC_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwHLLC_Flow.hpp deleted file mode 100644 index 8e64ef3324f0..000000000000 --- a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwHLLC_Flow.hpp +++ /dev/null @@ -1,82 +0,0 @@ -/*! - * \file CUpwHLLC_Flow.hpp - * \brief Delaration of numerics class CUpwHLLC_Flow, the - * implementation is in the CUpwHLLC_Flow.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../../CNumerics.hpp" - -/*! - * \class CUpwHLLC_Flow - * \brief Class for solving an approximate Riemann HLLC. - * \ingroup ConvDiscr - * \author G. Gori, Politecnico di Milano - * \version 7.0.0 "Blackbird" - */ -class CUpwHLLC_Flow : public CNumerics { -private: - bool implicit, dynamic_grid; - unsigned short iDim, jDim, iVar, jVar; - - su2double *IntermediateState; - su2double *Velocity_i, *Velocity_j, *RoeVelocity; - - su2double sq_vel_i, Density_i, Energy_i, SoundSpeed_i, Pressure_i, Enthalpy_i, ProjVelocity_i; - su2double sq_vel_j, Density_j, Energy_j, SoundSpeed_j, Pressure_j, Enthalpy_j, ProjVelocity_j; - - su2double sq_velRoe, RoeDensity, RoeEnthalpy, RoeSoundSpeed, RoeProjVelocity, ProjInterfaceVel; - - su2double sL, sR, sM, pStar, EStar, rhoSL, rhoSR, Rrho, kappa; - - su2double Omega, RHO, OmegaSM; - su2double *dSm_dU, *dPI_dU, *drhoStar_dU, *dpStar_dU, *dEStar_dU; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwHLLC_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwHLLC_Flow(void); - - /*! - * \brief Compute the Roe's flux between two nodes i and j. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - -}; diff --git a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwL2Roe_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwL2Roe_Flow.hpp deleted file mode 100644 index 713d4462e10b..000000000000 --- a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwL2Roe_Flow.hpp +++ /dev/null @@ -1,64 +0,0 @@ -/*! - * \file CUpwL2Roe_Flow.hpp - * \brief Delaration of numerics class CUpwL2Roe_Flow, the - * implementation is in the CUpwL2Roe_Flow.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "CUpwRoeBase_Flow.hpp" - -/*! - * \class CUpwL2Roe_Flow - * \brief Class for solving an approximate Riemann solver of L2Roe for the flow equations. - * \ingroup ConvDiscr - * \author E. Molina, A. Bueno, F. Palacios - * \version 7.0.0 "Blackbird" - */ -class CUpwL2Roe_Flow : public CUpwRoeBase_Flow { -private: - /*! - * \brief Add L^2 Roe dissipation to the flux (low-Mach scheme). - * \param[out] val_residual - Convective flux. - * \param[out] val_Jacobian_i - Flux Jacobian wrt node i conservatives (implicit computation). - * \param[out] val_Jacobian_j - Flux Jacobian wrt node j conservatives (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - -public: - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwL2Roe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwL2Roe_Flow(void); -}; diff --git a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwLMRoe_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwLMRoe_Flow.hpp deleted file mode 100644 index e15dac9dd0a1..000000000000 --- a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwLMRoe_Flow.hpp +++ /dev/null @@ -1,64 +0,0 @@ -/*! - * \file CUpwLMRoe_Flow.hpp - * \brief Delaration of numerics class CUpwLMRoe_Flow, the - * implementation is in the CUpwLMRoe_Flow.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "CUpwRoeBase_Flow.hpp" - -/*! - * \class CUpwLMRoe_Flow - * \brief Class for solving an approximate Riemann solver of LMRoe for the flow equations. - * \ingroup ConvDiscr - * \author E. Molina, A. Bueno, F. Palacios - * \version 7.0.0 "Blackbird" - */ -class CUpwLMRoe_Flow : public CUpwRoeBase_Flow { -private: - /*! - * \brief Add LMRoe dissipation to the flux (low-Mach scheme). - * \param[out] val_residual - Convective flux. - * \param[out] val_Jacobian_i - Flux Jacobian wrt node i conservatives (implicit computation). - * \param[out] val_Jacobian_j - Flux Jacobian wrt node j conservatives (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - -public: - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwLMRoe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwLMRoe_Flow(void); -}; diff --git a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwRoeBase_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwRoeBase_Flow.hpp deleted file mode 100644 index defec59c391a..000000000000 --- a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwRoeBase_Flow.hpp +++ /dev/null @@ -1,80 +0,0 @@ -/*! - * \file CUpwRoeBase_Flow.hpp - * \brief Delaration of numerics class CUpwRoeBase_Flow, the - * implementation is in the CUpwRoeBase_Flow.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../../CNumerics.hpp" - -/*! - * \class CUpwRoeBase_Flow - * \brief Intermediate base class for Roe schemes on ideal gas. - * \ingroup ConvDiscr - * \author A. Bueno, F. Palacios - */ -class CUpwRoeBase_Flow : public CNumerics { -protected: - bool implicit, dynamic_grid, roe_low_dissipation; - su2double *Velocity_i, *Velocity_j, *ProjFlux_i, *ProjFlux_j, *Conservatives_i, *Conservatives_j; - su2double *Diff_U, *Lambda, **P_Tensor, **invP_Tensor; - su2double *RoeVelocity, RoeDensity, RoeEnthalpy, RoeSoundSpeed, ProjVelocity, RoeSoundSpeed2, kappa; - - /*! - * \brief Derived classes must specialize this method to add the specifics of the scheme they implement (e.g. low-Mach precond.). - * \param[out] val_residual - Convective flux. - * \param[out] val_Jacobian_i - Flux Jacobian wrt node i conservatives (implicit computation). - * \param[out] val_Jacobian_j - Flux Jacobian wrt node j conservatives (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - virtual void FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) = 0; - -public: - - /*! - * \brief Constructor of the class. - * \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. - * \param[in] val_low_dissipation - Use a low dissipation formulation. - */ - CUpwRoeBase_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, bool val_low_dissipation); - - /*! - * \brief Destructor of the class. - */ - ~CUpwRoeBase_Flow(void); - - /*! - * \brief Compute the flux from node i to node j, part common to most Roe schemes. - * \param[out] val_residual - Convective flux. - * \param[out] val_Jacobian_i - Flux Jacobian wrt node i conservatives (implicit computation). - * \param[out] val_Jacobian_j - Flux Jacobian wrt node j conservatives (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - -}; diff --git a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwRoe_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwRoe_Flow.hpp deleted file mode 100644 index f8a3f6534894..000000000000 --- a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwRoe_Flow.hpp +++ /dev/null @@ -1,66 +0,0 @@ -/*! - * \file CUpwRoe_Flow.hpp - * \brief Delaration of numerics class CUpwRoe_Flow, the - * implementation is in the CUpwRoe_Flow.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "CUpwRoeBase_Flow.hpp" - -/*! - * \class CUpwRoe_Flow - * \brief Class for solving an approximate Riemann solver of Roe for the flow equations. - * \ingroup ConvDiscr - * \author A. Bueno, F. Palacios - */ -class CUpwRoe_Flow : public CUpwRoeBase_Flow { -private: - /*! - * \brief Add standard Roe dissipation to the flux. - * \param[out] val_residual - Convective flux. - * \param[out] val_Jacobian_i - Flux Jacobian wrt node i conservatives (implicit computation). - * \param[out] val_Jacobian_j - Flux Jacobian wrt node j conservatives (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - -public: - - /*! - * \brief Constructor of the class. - * \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. - * \param[in] val_low_dissipation - Use a low dissipation formulation. - */ - CUpwRoe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, bool val_low_dissipation); - - /*! - * \brief Destructor of the class. - */ - ~CUpwRoe_Flow(void); - -}; diff --git a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwSLAU_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwSLAU_Flow.hpp deleted file mode 100644 index 6d7d225cca27..000000000000 --- a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwSLAU_Flow.hpp +++ /dev/null @@ -1,90 +0,0 @@ -/*! - * \file CUpwSLAU_Flow.hpp - * \brief Delaration of numerics class CUpwSLAU_Flow, the - * implementation is in the CUpwSLAU_Flow.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "CUpwAUSMPLUS_SLAU_Base_Flow.hpp" - -/*! - * \class CUpwSLAU_Flow - * \brief Class for solving the Low-Dissipation AUSM. - * \ingroup ConvDiscr - * \author E. Molina - */ -class CUpwSLAU_Flow : public CUpwAUSMPLUS_SLAU_Base_Flow { -protected: - bool slau_low_diss; - bool slau2; - - /*! - * \brief Mass flux and pressure for the SLAU and SLAU2 schemes. - * \param[in] config - Definition of the particular problem. - * \param[out] mdot - The mass flux. - * \param[out] pressure - The pressure at the control volume face. - */ - void ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure); - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwSLAU_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, bool val_low_dissipation); - - /*! - * \brief Destructor of the class. - */ - ~CUpwSLAU_Flow(void); - -}; - -/*! - * \class CUpwSLAU2_Flow - * \brief Class for solving the Simple Low-Dissipation AUSM 2. - * \ingroup ConvDiscr - * \author E. Molina - */ -class CUpwSLAU2_Flow : public CUpwSLAU_Flow { -public: - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwSLAU2_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, bool val_low_dissipation); - - /*! - * \brief Destructor of the class. - */ - ~CUpwSLAU2_Flow(void); - -}; diff --git a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwTurkel_Flow.hpp b/SU2_CFD/include/numerics/flow/convection_upwind/CUpwTurkel_Flow.hpp deleted file mode 100644 index acbac532f204..000000000000 --- a/SU2_CFD/include/numerics/flow/convection_upwind/CUpwTurkel_Flow.hpp +++ /dev/null @@ -1,80 +0,0 @@ -/*! - * \file CUpwTurkel_Flow.hpp - * \brief Delaration of numerics class CUpwTurkel_Flow, the - * implementation is in the CUpwTurkel_Flow.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../../CNumerics.hpp" - -/*! - * \class CUpwTurkel_Flow - * \brief Class for solving an approximate Riemann solver of Roe with Turkel Preconditioning for the flow equations. - * \ingroup ConvDiscr - * \author A. K. Lonkar - */ -class CUpwTurkel_Flow : public CNumerics { -private: - bool implicit, dynamic_grid; - su2double *Diff_U; - su2double *Velocity_i, *Velocity_j, *RoeVelocity; - su2double *ProjFlux_i, *ProjFlux_j; - su2double *Lambda, *Epsilon; - su2double **absPeJac, **invRinvPe, **R_Tensor, **Matrix, **Art_Visc; - su2double sq_vel, Density_i, Energy_i, SoundSpeed_i, Pressure_i, Enthalpy_i, - Density_j, Energy_j, SoundSpeed_j, Pressure_j, Enthalpy_j, R, RoePressure, RoeDensity, RoeEnthalpy, RoeSoundSpeed, - ProjVelocity, ProjVelocity_i, ProjVelocity_j; - unsigned short iDim, iVar, jVar, kVar; - su2double Beta, Beta_min, Beta_max; - su2double r_hat, s_hat, t_hat, rhoB2a2, sqr_one_m_Betasqr_Lam1; - su2double Beta2, one_m_Betasqr, one_p_Betasqr, sqr_two_Beta_c_Area; - su2double local_Mach; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwTurkel_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwTurkel_Flow(void); - - /*! - * \brief Compute the Roe's flux between two nodes i and j. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - -}; diff --git a/SU2_CFD/include/numerics/flow/diffusion/CAvgGradInc_Flow.hpp b/SU2_CFD/include/numerics/flow/diffusion/CAvgGradInc_Flow.hpp deleted file mode 100644 index 68f0fcb4a8ac..000000000000 --- a/SU2_CFD/include/numerics/flow/diffusion/CAvgGradInc_Flow.hpp +++ /dev/null @@ -1,97 +0,0 @@ -/*! - * \file CAvgGradInc_Flow.hpp - * \brief Delaration of numerics class CAvgGradInc_Flow, the - * implementation is in the CAvgGradInc_Flow.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "CAvgGrad_Base.hpp" - -/*! - * \class CAvgGradInc_Flow - * \brief Class for computing viscous term using an average of gradients. - * \ingroup ViscDiscr - * \author A. Bueno, F. Palacios, T. Economon - */ -class CAvgGradInc_Flow : public CAvgGrad_Base { -private: - su2double Mean_Thermal_Conductivity; /*!< \brief Mean value of the effective thermal conductivity. */ - bool energy; /*!< \brief computation with the energy equation. */ - - /* - * \brief Compute the projection of the viscous fluxes into a direction - * - * The viscous + turbulent stress tensor must be calculated before calling - * this function. - * - * \param[in] val_gradprimvar - Gradient of the primitive variables. - * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. - * \param[in] val_thermal_conductivity - Thermal conductivity. - */ - void GetViscousIncProjFlux(const su2double* const *val_gradprimvar, - const su2double *val_normal, - su2double val_thermal_conductivity); - - /*! - * \brief Compute the projection of the viscous Jacobian matrices. - * - * The Jacobian of the stress tensor must be calculated before calling - * this function. - * - * \param[in] val_dS - Area of the face between two nodes. - * \param[out] val_Proj_Jac_Tensor_i - Pointer to the projected viscous Jacobian at point i. - * \param[out] val_Proj_Jac_Tensor_j - Pointer to the projected viscous Jacobian at point j. - */ - void GetViscousIncProjJacs(su2double val_dS, - su2double **val_Proj_Jac_Tensor_i, - su2double **val_Proj_Jac_Tensor_j); - -public: - - /*! - * \brief Constructor of the class. - * \param[in] val_nDim - Number of dimension of the problem. - * \param[in] val_nVar - Number of variables of the problem. - * \param[in] val_correct_grad - Apply a correction to the gradient - * \param[in] config - Definition of the particular problem. - */ - CAvgGradInc_Flow(unsigned short val_nDim, unsigned short val_nVar, - bool val_correct_grad, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CAvgGradInc_Flow(void); - - /*! - * \brief Compute the viscous flow residual using an average of gradients. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); -}; diff --git a/SU2_CFD/include/numerics/flow/diffusion/CAvgGrad_Flow.hpp b/SU2_CFD/include/numerics/flow/diffusion/CAvgGrad_Flow.hpp deleted file mode 100644 index cbda63710060..000000000000 --- a/SU2_CFD/include/numerics/flow/diffusion/CAvgGrad_Flow.hpp +++ /dev/null @@ -1,94 +0,0 @@ -/*! - * \file CAvgGrad_Flow.hpp - * \brief Delaration of numerics class CAvgGrad_Flow, the - * implementation is in the CAvgGrad_Flow.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "CAvgGrad_Base.hpp" - -/*! - * \class CAvgGrad_Flow - * \brief Class for computing viscous term using the average of gradients. - * \ingroup ViscDiscr - * \author A. Bueno, and F. Palacios - */ -class CAvgGrad_Flow : public CAvgGrad_Base { -public: - - /*! - * \brief Constructor of the class. - * \param[in] val_nDim - Number of dimension of the problem. - * \param[in] val_nVar - Number of variables of the problem. - * \param[in] val_correct_grad - Apply a correction to the gradient - * \param[in] config - Definition of the particular problem. - */ - CAvgGrad_Flow(unsigned short val_nDim, unsigned short val_nVar, - bool val_correct_grad, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CAvgGrad_Flow(void); - - /*! - * \brief Compute the viscous flow residual using an average of gradients. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - - /*! - * \brief Compute the heat flux due to molecular and turbulent diffusivity - * \param[in] val_gradprimvar - Gradient of the primitive variables. - * \param[in] val_laminar_viscosity - Laminar viscosity. - * \param[in] val_eddy_viscosity - Eddy viscosity. - */ - void SetHeatFluxVector(const su2double* const *val_gradprimvar, - su2double val_laminar_viscosity, - su2double val_eddy_viscosity); - - /*! - * \brief Compute the Jacobian of the heat flux vector - * - * This Jacobian is projected onto the normal vector, so it is of - * dimension nVar. - * - * \param[in] val_Mean_PrimVar - Mean value of the primitive variables. - * \param[in] val_gradprimvar - Mean value of the gradient of the primitive variables. - * \param[in] val_laminar_viscosity - Value of the laminar viscosity. - * \param[in] val_eddy_viscosity - Value of the eddy viscosity. - * \param[in] val_dist_ij - Distance between the points. - * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. - */ - void SetHeatFluxJacobian(const su2double *val_Mean_PrimVar, - su2double val_laminar_viscosity, - su2double val_eddy_viscosity, - su2double val_dist_ij, - const su2double *val_normal); -}; diff --git a/SU2_CFD/include/numerics/flow/diffusion/CGeneralAvgGrad_Flow.hpp b/SU2_CFD/include/numerics/flow/diffusion/CGeneralAvgGrad_Flow.hpp deleted file mode 100644 index 3b154ef93185..000000000000 --- a/SU2_CFD/include/numerics/flow/diffusion/CGeneralAvgGrad_Flow.hpp +++ /dev/null @@ -1,103 +0,0 @@ -/*! - * \file CGeneralAvgGrad_Flow.hpp - * \brief Delaration of numerics class CGeneralAvgGrad_Flow, the - * implementation is in the CGeneralAvgGrad_Flow.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "CAvgGrad_Base.hpp" - -/*! - * \class CGeneralAvgGrad_Flow - * \brief Class for computing viscous term using the average of gradients. - * \ingroup ViscDiscr - * \author M.Pini, S. Vitale - */ -class CGeneralAvgGrad_Flow : public CAvgGrad_Base { -private: - su2double *Mean_SecVar, /*!< \brief Mean secondary variables. */ - Mean_Thermal_Conductivity, /*!< \brief Mean value of the thermal conductivity. */ - Mean_Cp; /*!< \brief Mean value of the Cp. */ - - /*! - * \brief Compute the heat flux due to molecular and turbulent diffusivity - * \param[in] val_gradprimvar - Gradient of the primitive variables. - * \param[in] val_laminar_viscosity - Laminar viscosity. - * \param[in] val_eddy_viscosity - Eddy viscosity. - * \param[in] val_thermal_conductivity - Thermal Conductivity. - * \param[in] val_heat_capacity_cp - Heat Capacity at constant pressure. - */ - void SetHeatFluxVector(const su2double* const *val_gradprimvar, - su2double val_laminar_viscosity, - su2double val_eddy_viscosity, - su2double val_thermal_conductivity, - su2double val_heat_capacity_cp); - - /*! - * \brief Compute the Jacobian of the heat flux vector - * - * This Jacobian is projected onto the normal vector, so it is of - * dimension nVar. - * - * \param[in] val_Mean_PrimVar - Mean value of the primitive variables. - * \param[in] val_Mean_SecVar - Mean value of the secondary variables. - * \param[in] val_eddy_viscosity - Value of the eddy viscosity. - * \param[in] val_thermal_conductivity - Value of the thermal conductivity. - * \param[in] val_heat_capacity_cp - Value of the specific heat at constant pressure. - * \param[in] val_dist_ij - Distance between the points. - */ - void SetHeatFluxJacobian(const su2double *val_Mean_PrimVar, - const su2double *val_Mean_SecVar, - su2double val_eddy_viscosity, - su2double val_thermal_conductivity, - su2double val_heat_capacity_cp, - su2double val_dist_ij); - -public: - - /*! - * \brief Constructor of the class. - * \param[in] val_nDim - Number of dimension of the problem. - * \param[in] val_nVar - Number of variables of the problem. - * \param[in] val_correct_grad - Apply a correction to the gradient - * \param[in] config - Definition of the particular problem. - */ - CGeneralAvgGrad_Flow(unsigned short val_nDim, unsigned short val_nVar, bool val_correct_grad, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CGeneralAvgGrad_Flow(void); - - /*! - * \brief Compute the viscous flow residual using an average of gradients. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); -}; diff --git a/SU2_CFD/include/numerics/flow/diffusion/CAvgGrad_Base.hpp b/SU2_CFD/include/numerics/flow/flow_diffusion.hpp similarity index 56% rename from SU2_CFD/include/numerics/flow/diffusion/CAvgGrad_Base.hpp rename to SU2_CFD/include/numerics/flow/flow_diffusion.hpp index d72243085269..8c1e4807eef7 100644 --- a/SU2_CFD/include/numerics/flow/diffusion/CAvgGrad_Base.hpp +++ b/SU2_CFD/include/numerics/flow/flow_diffusion.hpp @@ -1,7 +1,6 @@ /*! - * \file CAvgGrad_Base.hpp - * \brief Delaration of numerics class CAvgGrad_Base, the - * implementation is in the CAvgGrad_Base.cpp file. + * \file flow_diffusion.hpp + * \brief Delarations of numerics classes for viscous flux computation. * \author F. Palacios, T. Economon * \version 7.0.0 "Blackbird" * @@ -28,7 +27,7 @@ #pragma once -#include "../../CNumerics.hpp" +#include "../CNumerics.hpp" /*! * \class CAvgGrad_Base @@ -62,8 +61,6 @@ class CAvgGrad_Base : public CNumerics { *Proj_Mean_GradPrimVar_Edge, /*!< \brief Inner product of the Mean gradient and the edge vector. */ *Edge_Vector; /*!< \brief Vector from point i to point j. */ - - /*! * \brief Add a correction using a Quadratic Constitutive Relation * @@ -253,3 +250,189 @@ class CAvgGrad_Base : public CNumerics { inline su2double GetHeatFluxVector(unsigned short iDim) const { return heat_flux_vector[iDim]; } }; + +/*! + * \class CAvgGrad_Flow + * \brief Class for computing viscous term using the average of gradients. + * \ingroup ViscDiscr + * \author A. Bueno, and F. Palacios + */ +class CAvgGrad_Flow : public CAvgGrad_Base { +public: + /*! + * \brief Constructor of the class. + * \param[in] val_nDim - Number of dimension of the problem. + * \param[in] val_nVar - Number of variables of the problem. + * \param[in] val_correct_grad - Apply a correction to the gradient + * \param[in] config - Definition of the particular problem. + */ + CAvgGrad_Flow(unsigned short val_nDim, unsigned short val_nVar, + bool val_correct_grad, CConfig *config); + + /*! + * \brief Compute the viscous flow residual using an average of gradients. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + + /*! + * \brief Compute the heat flux due to molecular and turbulent diffusivity + * \param[in] val_gradprimvar - Gradient of the primitive variables. + * \param[in] val_laminar_viscosity - Laminar viscosity. + * \param[in] val_eddy_viscosity - Eddy viscosity. + */ + void SetHeatFluxVector(const su2double* const *val_gradprimvar, + su2double val_laminar_viscosity, + su2double val_eddy_viscosity); + + /*! + * \brief Compute the Jacobian of the heat flux vector + * + * This Jacobian is projected onto the normal vector, so it is of + * dimension nVar. + * + * \param[in] val_Mean_PrimVar - Mean value of the primitive variables. + * \param[in] val_gradprimvar - Mean value of the gradient of the primitive variables. + * \param[in] val_laminar_viscosity - Value of the laminar viscosity. + * \param[in] val_eddy_viscosity - Value of the eddy viscosity. + * \param[in] val_dist_ij - Distance between the points. + * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. + */ + void SetHeatFluxJacobian(const su2double *val_Mean_PrimVar, + su2double val_laminar_viscosity, + su2double val_eddy_viscosity, + su2double val_dist_ij, + const su2double *val_normal); +}; + +/*! + * \class CAvgGradInc_Flow + * \brief Class for computing viscous term using an average of gradients. + * \ingroup ViscDiscr + * \author A. Bueno, F. Palacios, T. Economon + */ +class CAvgGradInc_Flow : public CAvgGrad_Base { +private: + su2double Mean_Thermal_Conductivity; /*!< \brief Mean value of the effective thermal conductivity. */ + bool energy; /*!< \brief computation with the energy equation. */ + + /*! + * \brief Compute the projection of the viscous fluxes into a direction + * + * The viscous + turbulent stress tensor must be calculated before calling + * this function. + * + * \param[in] val_gradprimvar - Gradient of the primitive variables. + * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. + * \param[in] val_thermal_conductivity - Thermal conductivity. + */ + void GetViscousIncProjFlux(const su2double* const *val_gradprimvar, + const su2double *val_normal, + su2double val_thermal_conductivity); + + /*! + * \brief Compute the projection of the viscous Jacobian matrices. + * + * The Jacobian of the stress tensor must be calculated before calling + * this function. + * + * \param[in] val_dS - Area of the face between two nodes. + * \param[out] val_Proj_Jac_Tensor_i - Pointer to the projected viscous Jacobian at point i. + * \param[out] val_Proj_Jac_Tensor_j - Pointer to the projected viscous Jacobian at point j. + */ + void GetViscousIncProjJacs(su2double val_dS, + su2double **val_Proj_Jac_Tensor_i, + su2double **val_Proj_Jac_Tensor_j); + +public: + + /*! + * \brief Constructor of the class. + * \param[in] val_nDim - Number of dimension of the problem. + * \param[in] val_nVar - Number of variables of the problem. + * \param[in] val_correct_grad - Apply a correction to the gradient + * \param[in] config - Definition of the particular problem. + */ + CAvgGradInc_Flow(unsigned short val_nDim, unsigned short val_nVar, + bool val_correct_grad, CConfig *config); + + /*! + * \brief Compute the viscous flow residual using an average of gradients. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); +}; + + +/*! + * \class CGeneralAvgGrad_Flow + * \brief Class for computing viscous term using the average of gradients. + * \ingroup ViscDiscr + * \author M.Pini, S. Vitale + */ +class CGeneralAvgGrad_Flow : public CAvgGrad_Base { +private: + su2double Mean_SecVar[2], /*!< \brief Mean secondary variables. */ + Mean_Thermal_Conductivity, /*!< \brief Mean value of the thermal conductivity. */ + Mean_Cp; /*!< \brief Mean value of the Cp. */ + + /*! + * \brief Compute the heat flux due to molecular and turbulent diffusivity + * \param[in] val_gradprimvar - Gradient of the primitive variables. + * \param[in] val_laminar_viscosity - Laminar viscosity. + * \param[in] val_eddy_viscosity - Eddy viscosity. + * \param[in] val_thermal_conductivity - Thermal Conductivity. + * \param[in] val_heat_capacity_cp - Heat Capacity at constant pressure. + */ + void SetHeatFluxVector(const su2double* const *val_gradprimvar, + su2double val_laminar_viscosity, + su2double val_eddy_viscosity, + su2double val_thermal_conductivity, + su2double val_heat_capacity_cp); + + /*! + * \brief Compute the Jacobian of the heat flux vector + * + * This Jacobian is projected onto the normal vector, so it is of + * dimension nVar. + * + * \param[in] val_Mean_PrimVar - Mean value of the primitive variables. + * \param[in] val_Mean_SecVar - Mean value of the secondary variables. + * \param[in] val_eddy_viscosity - Value of the eddy viscosity. + * \param[in] val_thermal_conductivity - Value of the thermal conductivity. + * \param[in] val_heat_capacity_cp - Value of the specific heat at constant pressure. + * \param[in] val_dist_ij - Distance between the points. + */ + void SetHeatFluxJacobian(const su2double *val_Mean_PrimVar, + const su2double *val_Mean_SecVar, + su2double val_eddy_viscosity, + su2double val_thermal_conductivity, + su2double val_heat_capacity_cp, + su2double val_dist_ij); + +public: + + /*! + * \brief Constructor of the class. + * \param[in] val_nDim - Number of dimension of the problem. + * \param[in] val_nVar - Number of variables of the problem. + * \param[in] val_correct_grad - Apply a correction to the gradient + * \param[in] config - Definition of the particular problem. + */ + CGeneralAvgGrad_Flow(unsigned short val_nDim, unsigned short val_nVar, bool val_correct_grad, CConfig *config); + + /*! + * \brief Compute the viscous flow residual using an average of gradients. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); +}; diff --git a/SU2_CFD/include/numerics/flow/flow_sources.hpp b/SU2_CFD/include/numerics/flow/flow_sources.hpp new file mode 100644 index 000000000000..13ccb68187e1 --- /dev/null +++ b/SU2_CFD/include/numerics/flow/flow_sources.hpp @@ -0,0 +1,268 @@ +/*! + * \file flow_sources.hpp + * \brief Delarations of numerics classes for source-term integration. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../CNumerics.hpp" + +/*! + * \class CSourceAxisymmetric_Flow + * \brief Class for source term for solving axisymmetric problems. + * \ingroup SourceDiscr + * \author F. Palacios + */ +class CSourceAxisymmetric_Flow : public CNumerics { +public: + /*! + * \brief Constructor of the class. + * \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. + */ + CSourceAxisymmetric_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Residual of the rotational frame source term. + * \param[out] val_residual - Pointer to the total residual. + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **Jacobian_i, CConfig *config); + +}; + +/*! + * \class CSourceIncAxisymmetric_Flow + * \brief Class for source term for solving incompressible axisymmetric problems. + * \ingroup SourceDiscr + * \author T. Economon + */ +class CSourceIncAxisymmetric_Flow : public CNumerics { + bool implicit, /*!< \brief Implicit calculation. */ + viscous, /*!< \brief Viscous incompressible flows. */ + energy; /*!< \brief computation with the energy equation. */ + +public: + /*! + * \brief Constructor of the class. + * \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. + */ + CSourceIncAxisymmetric_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Residual of the rotational frame source term. + * \param[out] val_residual - Pointer to the total residual. + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **Jacobian_i, CConfig *config); + +}; + +/*! + * \class CSourceBodyForce + * \brief Class for the source term integration of a body force. + * \ingroup SourceDiscr + * \author T. Economon + */ +class CSourceBodyForce : public CNumerics { + su2double Body_Force_Vector[3]; + +public: + + /*! + * \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. + */ + CSourceBodyForce(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Source term integration for a body force. + * \param[out] val_residual - Pointer to the residual vector. + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, CConfig *config); + +}; + +/*! + * \class CSourceIncBodyForce + * \brief Class for the source term integration of a body force in the incompressible solver. + * \ingroup SourceDiscr + * \author T. Economon + * \version 7.0.0 "Blackbird" + */ +class CSourceIncBodyForce : public CNumerics { + su2double Body_Force_Vector[3]; + +public: + /*! + * \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. + */ + CSourceIncBodyForce(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Source term integration for a body force. + * \param[out] val_residual - Pointer to the residual vector. + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, CConfig *config); + +}; + +/*! + * \class CSourceBoussinesq + * \brief Class for the source term integration of the Boussinesq approximation for incompressible flow. + * \ingroup SourceDiscr + * \author T. Economon + * \version 7.0.0 "Blackbird" + */ +class CSourceBoussinesq : public CNumerics { + su2double Gravity_Vector[3]; + +public: + /*! + * \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. + */ + CSourceBoussinesq(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Source term integration for the Boussinesq approximation. + * \param[out] val_residual - Pointer to the residual vector. + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, CConfig *config); + +}; + +/*! + * \class CSourceGravity + * \brief Class for the source term integration of the gravity force. + * \ingroup SourceDiscr + * \author F. Palacios + */ +class CSourceGravity : public CNumerics { +public: + /*! + * \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. + */ + CSourceGravity(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Source term integration for the poissonal potential. + * \param[out] val_residual - Pointer to the total residual. + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, CConfig *config); +}; + +/*! + * \class CSourceRotatingFrame_Flow + * \brief Class for a rotating frame source term. + * \ingroup SourceDiscr + * \author F. Palacios, T. Economon. + */ +class CSourceRotatingFrame_Flow : public CNumerics { +public: + /*! + * \brief Constructor of the class. + * \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. + */ + CSourceRotatingFrame_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Residual of the rotational frame source term. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config); +}; + +/*! + * \class CSourceIncRotatingFrame_Flow + * \brief Class for a rotating frame source term. + * \ingroup SourceDiscr + */ +class CSourceIncRotatingFrame_Flow : public CNumerics { + +private: + su2double Omega[3]; /*!< \brief Angular velocity */ + bool implicit; /*!< \brief Implicit calculation. */ + +public: + /*! + * \brief Constructor of the class. + * \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. + */ + CSourceIncRotatingFrame_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Residual of the rotational frame source term. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config); + +}; + +/*! + * \class CSourceWindGust + * \brief Class for a source term due to a wind gust. + * \ingroup SourceDiscr + * \author S. Padrón + */ +class CSourceWindGust : public CNumerics { +public: + /*! + * \brief Constructor of the class. + * \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. + */ + CSourceWindGust(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Residual of the wind gust source term. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config); +}; diff --git a/SU2_CFD/include/numerics/flow/sources/CSourceAxisymmetric_Flow.hpp b/SU2_CFD/include/numerics/flow/sources/CSourceAxisymmetric_Flow.hpp deleted file mode 100644 index e7497e061fbd..000000000000 --- a/SU2_CFD/include/numerics/flow/sources/CSourceAxisymmetric_Flow.hpp +++ /dev/null @@ -1,62 +0,0 @@ -/*! - * \file CSourceAxisymmetric_Flow.hpp - * \brief Delaration of numerics class CSourceAxisymmetric_Flow, the - * implementation is in the CSourceAxisymmetric_Flow.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../../CNumerics.hpp" - -/*! - * \class CSourceAxisymmetric_Flow - * \brief Class for source term for solving axisymmetric problems. - * \ingroup SourceDiscr - * \author F. Palacios - */ -class CSourceAxisymmetric_Flow : public CNumerics { -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourceAxisymmetric_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourceAxisymmetric_Flow(void); - - /*! - * \brief Residual of the rotational frame source term. - * \param[out] val_residual - Pointer to the total residual. - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **Jacobian_i, CConfig *config); - -}; diff --git a/SU2_CFD/include/numerics/flow/sources/CSourceBodyForce.hpp b/SU2_CFD/include/numerics/flow/sources/CSourceBodyForce.hpp deleted file mode 100644 index 4a49c43f2c20..000000000000 --- a/SU2_CFD/include/numerics/flow/sources/CSourceBodyForce.hpp +++ /dev/null @@ -1,63 +0,0 @@ -/*! - * \file CSourceBodyForce.hpp - * \brief Delaration of numerics class CSourceBodyForce, the - * implementation is in the CSourceBodyForce.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../../CNumerics.hpp" - -/*! - * \class CSourceBodyForce - * \brief Class for the source term integration of a body force. - * \ingroup SourceDiscr - * \author T. Economon - */ -class CSourceBodyForce : public CNumerics { - su2double *Body_Force_Vector; - -public: - - /*! - * \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. - */ - CSourceBodyForce(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourceBodyForce(void); - - /*! - * \brief Source term integration for a body force. - * \param[out] val_residual - Pointer to the residual vector. - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, CConfig *config); - -}; diff --git a/SU2_CFD/include/numerics/flow/sources/CSourceBoussinesq.hpp b/SU2_CFD/include/numerics/flow/sources/CSourceBoussinesq.hpp deleted file mode 100644 index 6ad6751f9512..000000000000 --- a/SU2_CFD/include/numerics/flow/sources/CSourceBoussinesq.hpp +++ /dev/null @@ -1,64 +0,0 @@ -/*! - * \file CSourceBoussinesq.hpp - * \brief Delaration of numerics class CSourceBoussinesq, the - * implementation is in the CSourceBoussinesq.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../../CNumerics.hpp" - -/*! - * \class CSourceBoussinesq - * \brief Class for the source term integration of the Boussinesq approximation for incompressible flow. - * \ingroup SourceDiscr - * \author T. Economon - * \version 7.0.0 "Blackbird" - */ -class CSourceBoussinesq : public CNumerics { - su2double *Gravity_Vector; - -public: - - /*! - * \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. - */ - CSourceBoussinesq(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourceBoussinesq(void); - - /*! - * \brief Source term integration for the Boussinesq approximation. - * \param[out] val_residual - Pointer to the residual vector. - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, CConfig *config); - -}; diff --git a/SU2_CFD/include/numerics/flow/sources/CSourceGravity.hpp b/SU2_CFD/include/numerics/flow/sources/CSourceGravity.hpp deleted file mode 100644 index 252656f150e3..000000000000 --- a/SU2_CFD/include/numerics/flow/sources/CSourceGravity.hpp +++ /dev/null @@ -1,61 +0,0 @@ -/*! - * \file CSourceGravity.hpp - * \brief Delaration of numerics class CSourceGravity, the - * implementation is in the CSourceGravity.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../../CNumerics.hpp" - -/*! - * \class CSourceGravity - * \brief Class for the source term integration of the gravity force. - * \ingroup SourceDiscr - * \author F. Palacios - */ -class CSourceGravity : public CNumerics { - -public: - - /*! - * \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. - */ - CSourceGravity(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourceGravity(void); - - /*! - * \brief Source term integration for the poissonal potential. - * \param[out] val_residual - Pointer to the total residual. - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, CConfig *config); -}; diff --git a/SU2_CFD/include/numerics/flow/sources/CSourceIncAxisymmetric_Flow.hpp b/SU2_CFD/include/numerics/flow/sources/CSourceIncAxisymmetric_Flow.hpp deleted file mode 100644 index caf38ae01b12..000000000000 --- a/SU2_CFD/include/numerics/flow/sources/CSourceIncAxisymmetric_Flow.hpp +++ /dev/null @@ -1,66 +0,0 @@ -/*! - * \file CSourceIncAxisymmetric_Flow.hpp - * \brief Delaration of numerics class CSourceIncAxisymmetric_Flow, the - * implementation is in the CSourceIncAxisymmetric_Flow.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../../CNumerics.hpp" - -/*! - * \class CSourceIncAxisymmetric_Flow - * \brief Class for source term for solving incompressible axisymmetric problems. - * \ingroup SourceDiscr - * \author T. Economon - */ -class CSourceIncAxisymmetric_Flow : public CNumerics { - bool implicit, /*!< \brief Implicit calculation. */ - viscous, /*!< \brief Viscous incompressible flows. */ - energy; /*!< \brief computation with the energy equation. */ - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourceIncAxisymmetric_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourceIncAxisymmetric_Flow(void); - - /*! - * \brief Residual of the rotational frame source term. - * \param[out] val_residual - Pointer to the total residual. - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **Jacobian_i, CConfig *config); - -}; diff --git a/SU2_CFD/include/numerics/flow/sources/CSourceIncBodyForce.hpp b/SU2_CFD/include/numerics/flow/sources/CSourceIncBodyForce.hpp deleted file mode 100644 index bae1e83192af..000000000000 --- a/SU2_CFD/include/numerics/flow/sources/CSourceIncBodyForce.hpp +++ /dev/null @@ -1,64 +0,0 @@ -/*! - * \file CSourceIncBodyForce.hpp - * \brief Delaration of numerics class CSourceIncBodyForce, the - * implementation is in the CSourceIncBodyForce.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../../CNumerics.hpp" - -/*! - * \class CSourceIncBodyForce - * \brief Class for the source term integration of a body force in the incompressible solver. - * \ingroup SourceDiscr - * \author T. Economon - * \version 7.0.0 "Blackbird" - */ -class CSourceIncBodyForce : public CNumerics { - su2double *Body_Force_Vector; - -public: - - /*! - * \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. - */ - CSourceIncBodyForce(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourceIncBodyForce(void); - - /*! - * \brief Source term integration for a body force. - * \param[out] val_residual - Pointer to the residual vector. - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, CConfig *config); - -}; diff --git a/SU2_CFD/include/numerics/flow/sources/CSourceIncRotatingFrame_Flow.hpp b/SU2_CFD/include/numerics/flow/sources/CSourceIncRotatingFrame_Flow.hpp deleted file mode 100644 index 4c8a8aa99873..000000000000 --- a/SU2_CFD/include/numerics/flow/sources/CSourceIncRotatingFrame_Flow.hpp +++ /dev/null @@ -1,67 +0,0 @@ -/*! - * \file CSourceIncRotatingFrame_Flow.hpp - * \brief Delaration of numerics class CSourceIncRotatingFrame_Flow, the - * implementation is in the CSourceIncRotatingFrame_Flow.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../../CNumerics.hpp" - -/*! - * \class CSourceIncRotatingFrame_Flow - * \brief Class for a rotating frame source term. - * \ingroup SourceDiscr - */ -class CSourceIncRotatingFrame_Flow : public CNumerics { - -private: - su2double Omega[3]; /*!< \brief Angular velocity */ - bool implicit; /*!< \brief Implicit calculation. */ - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourceIncRotatingFrame_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourceIncRotatingFrame_Flow(void); - - /*! - * \brief Residual of the rotational frame source term. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config); - -}; diff --git a/SU2_CFD/include/numerics/flow/sources/CSourceRotatingFrame_Flow.hpp b/SU2_CFD/include/numerics/flow/sources/CSourceRotatingFrame_Flow.hpp deleted file mode 100644 index 7fa5c6ce89a2..000000000000 --- a/SU2_CFD/include/numerics/flow/sources/CSourceRotatingFrame_Flow.hpp +++ /dev/null @@ -1,62 +0,0 @@ -/*! - * \file CSourceRotatingFrame_Flow.hpp - * \brief Delaration of numerics class CSourceRotatingFrame_Flow, the - * implementation is in the CSourceRotatingFrame_Flow.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../../CNumerics.hpp" - -/*! - * \class CSourceRotatingFrame_Flow - * \brief Class for a rotating frame source term. - * \ingroup SourceDiscr - * \author F. Palacios, T. Economon. - */ -class CSourceRotatingFrame_Flow : public CNumerics { -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourceRotatingFrame_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourceRotatingFrame_Flow(void); - - /*! - * \brief Residual of the rotational frame source term. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config); -}; diff --git a/SU2_CFD/include/numerics/flow/sources/CSourceWindGust.hpp b/SU2_CFD/include/numerics/flow/sources/CSourceWindGust.hpp deleted file mode 100644 index 73bb0bd76e69..000000000000 --- a/SU2_CFD/include/numerics/flow/sources/CSourceWindGust.hpp +++ /dev/null @@ -1,62 +0,0 @@ -/*! - * \file CSourceWindGust.hpp - * \brief Delaration of numerics class CSourceWindGust, the - * implementation is in the CSourceWindGust.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../../CNumerics.hpp" - -/*! - * \class CSourceWindGust - * \brief Class for a source term due to a wind gust. - * \ingroup SourceDiscr - * \author S. Padrón - */ -class CSourceWindGust : public CNumerics { -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourceWindGust(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourceWindGust(void); - - /*! - * \brief Residual of the wind gust source term. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config); -}; diff --git a/SU2_CFD/include/numerics/heat.hpp b/SU2_CFD/include/numerics/heat.hpp new file mode 100644 index 000000000000..3331403e9e59 --- /dev/null +++ b/SU2_CFD/include/numerics/heat.hpp @@ -0,0 +1,196 @@ +/*! + * \file heat.hpp + * \brief Delarations of numerics classes for heat transfer problems. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "CNumerics.hpp" + +/*! + * \class CCentSca_Heat + * \brief Class for scalar centered scheme. + * \ingroup ConvDiscr + * \author O. Burghardt + * \version 7.0.0 "Blackbird" + */ +class CCentSca_Heat : public CNumerics { + +private: + unsigned short iDim; /*!< \brief Iteration on dimension and variables. */ + su2double *Diff_Lapl, /*!< \brief Diference of conservative variables and undivided laplacians. */ + *MeanVelocity, ProjVelocity, + ProjVelocity_i, ProjVelocity_j, /*!< \brief Mean and projected velocities. */ + Param_Kappa_4, /*!< \brief Artificial dissipation parameters. */ + Local_Lambda_i, Local_Lambda_j, + MeanLambda, /*!< \brief Local eingenvalues. */ + cte_0, cte_1; /*!< \brief Artificial dissipation values. */ + bool implicit, /*!< \brief Implicit calculation. */ + dynamic_grid; /*!< \brief Modification for grid movement. */ + +public: + /*! + * \brief Constructor of the class. + * \param[in] val_nDim - Number of dimension of the problem. + * \param[in] val_nVar - Number of variables of the problem. + * \param[in] config - Definition of the particular problem. + */ + CCentSca_Heat(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CCentSca_Heat(void); + + /*! + * \brief Compute the flow residual using a JST method. + * \param[out] val_resconv - Pointer to the convective residual. + * \param[out] val_resvisc - Pointer to the artificial viscosity residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, + CConfig *config); +}; + +/*! + * \class CUpwSca_Heat + * \brief Class for doing a scalar upwind solver for the heat convection equation. + * \ingroup ConvDiscr + * \author O. Burghardt. + * \version 7.0.0 "Blackbird" + */ +class CUpwSca_Heat : public CNumerics { +private: + su2double *Velocity_i, *Velocity_j; + bool implicit, dynamic_grid; + su2double q_ij, a0, a1; + unsigned short iDim; + +public: + /*! + * \brief Constructor of the class. + * \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. + */ + CUpwSca_Heat(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CUpwSca_Heat(void); + + /*! + * \brief Compute the scalar upwind flux between two nodes i and j. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); +}; + +/*! + * \class CAvgGrad_Heat + * \brief Class for computing viscous term using average of gradients without correction (heat equation). + * \ingroup ViscDiscr + * \author O. Burghardt. + * \version 7.0.0 "Blackbird" + */ +class CAvgGrad_Heat : public CNumerics { +private: + su2double **Mean_GradHeatVar; + su2double *Proj_Mean_GradHeatVar_Normal, *Proj_Mean_GradHeatVar_Corrected; + su2double *Edge_Vector; + bool implicit; + su2double dist_ij_2, proj_vector_ij, Thermal_Diffusivity_Mean; + unsigned short iVar, iDim; + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CAvgGrad_Heat(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CAvgGrad_Heat(void); + + /*! + * \brief Compute the viscous heat residual using an average of gradients with correction. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config); +}; + +/*! + * \class CAvgGradCorrected_Heat + * \brief Class for computing viscous term using average of gradients with correction (heat equation). + * \ingroup ViscDiscr + * \author O. Burghardt. + * \version 7.0.0 "Blackbird" + */ +class CAvgGradCorrected_Heat : public CNumerics { +private: + su2double **Mean_GradHeatVar; + su2double *Proj_Mean_GradHeatVar_Kappa, *Proj_Mean_GradHeatVar_Edge, *Proj_Mean_GradHeatVar_Corrected; + su2double *Edge_Vector; + bool implicit; + su2double dist_ij_2, proj_vector_ij, Thermal_Diffusivity_Mean; + unsigned short iVar, iDim; + +public: + /*! + * \brief Constructor of the class. + * \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. + */ + CAvgGradCorrected_Heat(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CAvgGradCorrected_Heat(void); + + /*! + * \brief Compute the viscous heat residual using an average of gradients with correction. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config); +}; diff --git a/SU2_CFD/include/numerics/heat/CAvgGradCorrected_Heat.hpp b/SU2_CFD/include/numerics/heat/CAvgGradCorrected_Heat.hpp deleted file mode 100644 index 893abad44e54..000000000000 --- a/SU2_CFD/include/numerics/heat/CAvgGradCorrected_Heat.hpp +++ /dev/null @@ -1,72 +0,0 @@ -/*! - * \file CAvgGradCorrected_Heat.hpp - * \brief Delaration of numerics class CAvgGradCorrected_Heat, the - * implementation is in the CAvgGradCorrected_Heat.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../CNumerics.hpp" - -/*! - * \class CAvgGradCorrected_Heat - * \brief Class for computing viscous term using average of gradients with correction (heat equation). - * \ingroup ViscDiscr - * \author O. Burghardt. - * \version 7.0.0 "Blackbird" - */ -class CAvgGradCorrected_Heat : public CNumerics { -private: - su2double **Mean_GradHeatVar; - su2double *Proj_Mean_GradHeatVar_Kappa, *Proj_Mean_GradHeatVar_Edge, *Proj_Mean_GradHeatVar_Corrected; - su2double *Edge_Vector; - bool implicit; - su2double dist_ij_2, proj_vector_ij, Thermal_Diffusivity_Mean; - unsigned short iVar, iDim; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CAvgGradCorrected_Heat(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CAvgGradCorrected_Heat(void); - - /*! - * \brief Compute the viscous heat residual using an average of gradients with correction. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config); -}; diff --git a/SU2_CFD/include/numerics/heat/CAvgGrad_Heat.hpp b/SU2_CFD/include/numerics/heat/CAvgGrad_Heat.hpp deleted file mode 100644 index 742a0d7f3bb6..000000000000 --- a/SU2_CFD/include/numerics/heat/CAvgGrad_Heat.hpp +++ /dev/null @@ -1,72 +0,0 @@ -/*! - * \file CAvgGrad_Heat.hpp - * \brief Delaration of numerics class CAvgGrad_Heat, the - * implementation is in the CAvgGrad_Heat.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../CNumerics.hpp" - -/*! - * \class CAvgGrad_Heat - * \brief Class for computing viscous term using average of gradients without correction (heat equation). - * \ingroup ViscDiscr - * \author O. Burghardt. - * \version 7.0.0 "Blackbird" - */ -class CAvgGrad_Heat : public CNumerics { -private: - su2double **Mean_GradHeatVar; - su2double *Proj_Mean_GradHeatVar_Normal, *Proj_Mean_GradHeatVar_Corrected; - su2double *Edge_Vector; - bool implicit; - su2double dist_ij_2, proj_vector_ij, Thermal_Diffusivity_Mean; - unsigned short iVar, iDim; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CAvgGrad_Heat(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CAvgGrad_Heat(void); - - /*! - * \brief Compute the viscous heat residual using an average of gradients with correction. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config); -}; diff --git a/SU2_CFD/include/numerics/heat/CCentSca_Heat.hpp b/SU2_CFD/include/numerics/heat/CCentSca_Heat.hpp deleted file mode 100644 index ee6fa1f53a9b..000000000000 --- a/SU2_CFD/include/numerics/heat/CCentSca_Heat.hpp +++ /dev/null @@ -1,80 +0,0 @@ -/*! - * \file CCentSca_Heat.hpp - * \brief Delaration of numerics class CCentSca_Heat, the - * implementation is in the CCentSca_Heat.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../CNumerics.hpp" - -/*! - * \class CCentSca_Heat - * \brief Class for scalar centered scheme. - * \ingroup ConvDiscr - * \author O. Burghardt - * \version 7.0.0 "Blackbird" - */ -class CCentSca_Heat : public CNumerics { - -private: - unsigned short iDim; /*!< \brief Iteration on dimension and variables. */ - su2double *Diff_Lapl, /*!< \brief Diference of conservative variables and undivided laplacians. */ - *MeanVelocity, ProjVelocity, - ProjVelocity_i, ProjVelocity_j, /*!< \brief Mean and projected velocities. */ - Param_Kappa_4, /*!< \brief Artificial dissipation parameters. */ - Local_Lambda_i, Local_Lambda_j, - MeanLambda, /*!< \brief Local eingenvalues. */ - cte_0, cte_1; /*!< \brief Artificial dissipation values. */ - bool implicit, /*!< \brief Implicit calculation. */ - dynamic_grid; /*!< \brief Modification for grid movement. */ - - -public: - - /*! - * \brief Constructor of the class. - * \param[in] val_nDim - Number of dimension of the problem. - * \param[in] val_nVar - Number of variables of the problem. - * \param[in] config - Definition of the particular problem. - */ - CCentSca_Heat(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CCentSca_Heat(void); - - /*! - * \brief Compute the flow residual using a JST method. - * \param[out] val_resconv - Pointer to the convective residual. - * \param[out] val_resvisc - Pointer to the artificial viscosity residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, - CConfig *config); -}; diff --git a/SU2_CFD/include/numerics/heat/CUpwSca_Heat.hpp b/SU2_CFD/include/numerics/heat/CUpwSca_Heat.hpp deleted file mode 100644 index 046147726cfa..000000000000 --- a/SU2_CFD/include/numerics/heat/CUpwSca_Heat.hpp +++ /dev/null @@ -1,70 +0,0 @@ -/*! - * \file CUpwSca_Heat.hpp - * \brief Delaration of numerics class CUpwSca_Heat, the - * implementation is in the CUpwSca_Heat.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../CNumerics.hpp" - -/*! - * \class CUpwSca_Heat - * \brief Class for doing a scalar upwind solver for the heat convection equation. - * \ingroup ConvDiscr - * \author O. Burghardt. - * \version 7.0.0 "Blackbird" - */ -class CUpwSca_Heat : public CNumerics { -private: - su2double *Velocity_i, *Velocity_j; - bool implicit, dynamic_grid; - su2double q_ij, a0, a1; - unsigned short iDim; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwSca_Heat(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwSca_Heat(void); - - /*! - * \brief Compute the scalar upwind flux between two nodes i and j. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); -}; diff --git a/SU2_CFD/include/numerics/include_all.hpp b/SU2_CFD/include/numerics/include_all.hpp deleted file mode 100644 index a9337786e496..000000000000 --- a/SU2_CFD/include/numerics/include_all.hpp +++ /dev/null @@ -1,84 +0,0 @@ -#include "template/CViscous_Template.hpp" -#include "template/CConvective_Template.hpp" -#include "template/CSource_Template.hpp" -#include "transition/CUpwLin_TransLM.hpp" -#include "transition/CAvgGrad_TransLM.hpp" -#include "transition/CSourcePieceWise_TransLM.hpp" -#include "transition/CAvgGradCorrected_TransLM.hpp" -#include "transition/CUpwSca_TransLM.hpp" -#include "heat/CAvgGrad_Heat.hpp" -#include "heat/CCentSca_Heat.hpp" -#include "heat/CAvgGradCorrected_Heat.hpp" -#include "heat/CUpwSca_Heat.hpp" -#include "flow/diffusion/CAvgGrad_Base.hpp" -#include "flow/diffusion/CAvgGradInc_Flow.hpp" -#include "flow/diffusion/CAvgGrad_Flow.hpp" -#include "flow/diffusion/CGeneralAvgGrad_Flow.hpp" -#include "flow/convection_upwind/CUpwRoe_Flow.hpp" -#include "flow/convection_upwind/CUpwL2Roe_Flow.hpp" -#include "flow/convection_upwind/CUpwAUSMPLUS_SLAU_Base_Flow.hpp" -#include "flow/convection_upwind/CUpwHLLC_Flow.hpp" -#include "flow/convection_upwind/CUpwSLAU_Flow.hpp" -#include "flow/convection_upwind/CUpwGeneralRoe_Flow.hpp" -#include "flow/convection_upwind/CUpwLMRoe_Flow.hpp" -#include "flow/convection_upwind/CUpwAUSMPLUSUP_Flow.hpp" -#include "flow/convection_upwind/CUpwRoeBase_Flow.hpp" -#include "flow/convection_upwind/CUpwTurkel_Flow.hpp" -#include "flow/convection_upwind/CUpwGeneralHLLC_Flow.hpp" -#include "flow/convection_upwind/CUpwAUSM_Flow.hpp" -#include "flow/convection_upwind/CUpwCUSP_Flow.hpp" -#include "flow/convection_upwind/CUpwFDSInc_Flow.hpp" -#include "flow/convection_upwind/CUpwMSW_Flow.hpp" -#include "flow/convection_upwind/CUpwAUSMPLUSUP2_Flow.hpp" -#include "flow/sources/CSourceAxisymmetric_Flow.hpp" -#include "flow/sources/CSourceGravity.hpp" -#include "flow/sources/CSourceIncAxisymmetric_Flow.hpp" -#include "flow/sources/CSourceIncRotatingFrame_Flow.hpp" -#include "flow/sources/CSourceBodyForce.hpp" -#include "flow/sources/CSourceWindGust.hpp" -#include "flow/sources/CSourceRotatingFrame_Flow.hpp" -#include "flow/sources/CSourceIncBodyForce.hpp" -#include "flow/sources/CSourceBoussinesq.hpp" -#include "flow/convection_centered/CCentLaxInc_Flow.hpp" -#include "flow/convection_centered/CCentLax_Flow.hpp" -#include "flow/convection_centered/CCentBase_Flow.hpp" -#include "flow/convection_centered/CCentJST_KE_Flow.hpp" -#include "flow/convection_centered/CCentJSTInc_Flow.hpp" -#include "flow/convection_centered/CCentJST_Flow.hpp" -#include "elasticity/CFEALinearElasticity.hpp" -#include "elasticity/CFEM_IdealDE.hpp" -#include "elasticity/CFEM_NeoHookean_Comp.hpp" -#include "elasticity/CFEAElasticity.hpp" -#include "elasticity/CFEANonlinearElasticity.hpp" -#include "elasticity/CFEAMeshElasticity.hpp" -#include "elasticity/CFEM_Knowles_NearInc.hpp" -#include "elasticity/CFEM_DielectricElastomer.hpp" -#include "continuous_adjoint/CCentJST_AdjFlow.hpp" -#include "continuous_adjoint/CAvgGrad_AdjFlow.hpp" -#include "continuous_adjoint/CSourceRotatingFrame_AdjFlow.hpp" -#include "continuous_adjoint/CSourceConservative_AdjFlow.hpp" -#include "continuous_adjoint/CUpwSca_AdjTurb.hpp" -#include "continuous_adjoint/CSourceConservative_AdjTurb.hpp" -#include "continuous_adjoint/CSourceAxisymmetric_AdjFlow.hpp" -#include "continuous_adjoint/CAvgGrad_AdjTurb.hpp" -#include "continuous_adjoint/CSourcePieceWise_AdjTurb.hpp" -#include "continuous_adjoint/CCentLax_AdjFlow.hpp" -#include "continuous_adjoint/CUpwRoe_AdjFlow.hpp" -#include "continuous_adjoint/CSourceViscous_AdjFlow.hpp" -#include "continuous_adjoint/CAvgGradCorrected_AdjFlow.hpp" -#include "continuous_adjoint/CUpwLin_AdjTurb.hpp" -#include "continuous_adjoint/CAvgGradCorrected_AdjTurb.hpp" -#include "turbulent/CSourcePieceWise_TurbSA_E.hpp" -#include "turbulent/CAvgGrad_TurbSA_Neg.hpp" -#include "turbulent/CSourcePieceWise_TurbSA_E_COMP.hpp" -#include "turbulent/CSourcePieceWise_TurbSA.hpp" -#include "turbulent/CAvgGrad_TurbSST.hpp" -#include "turbulent/CSourcePieceWise_TurbSST.hpp" -#include "turbulent/CUpwSca_TurbSST.hpp" -#include "turbulent/CAvgGrad_TurbSA.hpp" -#include "turbulent/CAvgGrad_Scalar.hpp" -#include "turbulent/CSourcePieceWise_TurbSA_Neg.hpp" -#include "turbulent/CSourcePieceWise_TurbSA_COMP.hpp" -#include "turbulent/CUpwScalar.hpp" -#include "turbulent/CUpwSca_TurbSA.hpp" - diff --git a/SU2_CFD/include/numerics/template.hpp b/SU2_CFD/include/numerics/template.hpp new file mode 100644 index 000000000000..638fc38a5e01 --- /dev/null +++ b/SU2_CFD/include/numerics/template.hpp @@ -0,0 +1,138 @@ +/*! + * \file template.hpp + * \brief Declarations of template (empty) numerics classes, these give + * an idea of the methods that need to be defined to implement + * new schemes in SU2, in practice you should look for a similar + * scheme and try to re-use functionality (not by copy-paste). + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "CNumerics.hpp" + +/*! + * \class CConvectiveTemplate + * \brief Class for setting up new method for spatial discretization of convective terms in flow equations. + * \ingroup ConvDiscr + * \author A. Lonkar + */ +class CConvective_Template : public CNumerics { +private: + + /* define private variables here */ + +public: + /*! + * \brief Constructor of the class. + * \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. + */ + CConvective_Template(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CConvective_Template(void); + + /*! + * \brief Compute the Roe's flux between two nodes i and j. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); +}; + +/*! + * \class CViscous_Template + * \brief Class for computing viscous term using average of gradients. + * \ingroup ViscDiscr + * \author F. Palacios + */ +class CViscous_Template : public CNumerics { +private: + + /* define private variables here */ + +public: + /*! + * \brief Constructor of the class. + * \param[in] val_nDim - Number of dimension of the problem. + * \param[in] val_nVar - Number of variables of the problem. + * \param[in] config - Definition of the particular problem. + */ + CViscous_Template(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CViscous_Template(void); + + /*! + * \brief Compute the viscous flow residual using an average of gradients. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); +}; + +/*! + * \class CSource_Template + * \brief Dummy class. + * \ingroup SourceDiscr + * \author A. Lonkar. + */ +class CSource_Template : public CNumerics { +private: + + /* define private variables here */ + +public: + /*! + * \brief Constructor of the class. + * \param[in] val_nDim - Number of dimensions of the problem. + * \param[in] val_nVar - Number of variables of the problem. + * \param[in] config - Name of the input config file + * + */ + CSource_Template(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Residual for source term integration. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CSource_Template(void); +}; diff --git a/SU2_CFD/include/numerics/template/CConvective_Template.hpp b/SU2_CFD/include/numerics/template/CConvective_Template.hpp deleted file mode 100644 index 4342710265cf..000000000000 --- a/SU2_CFD/include/numerics/template/CConvective_Template.hpp +++ /dev/null @@ -1,78 +0,0 @@ -/*! - * \file CConvective_Template.hpp - * \brief Delaration of numerics class CConvective_Template, the - * implementation is in the CConvective_Template.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../CNumerics.hpp" - -/*! - * \class CConvectiveTemplate - * \brief Class for setting up new method for spatial discretization of convective terms in flow Equations - * \ingroup ConvDiscr - * \author A. Lonkar - */ -class CConvective_Template : public CNumerics { -private: - - /* define private variables here */ - bool implicit; - su2double *Diff_U; - su2double *Velocity_i, *Velocity_j, *RoeVelocity; - su2double *ProjFlux_i, *ProjFlux_j; - su2double *delta_wave, *delta_vel; - su2double *Lambda, *Epsilon; - su2double **P_Tensor, **invP_Tensor; - su2double sq_vel, Proj_ModJac_Tensor_ij, Density_i, Energy_i, SoundSpeed_i, Pressure_i, Enthalpy_i, - Density_j, Energy_j, SoundSpeed_j, Pressure_j, Enthalpy_j, R, RoeDensity, RoeEnthalpy, RoeSoundSpeed, - ProjVelocity, ProjVelocity_i, ProjVelocity_j, proj_delta_vel, delta_p, delta_rho; - unsigned short iDim, iVar, jVar, kVar; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CConvective_Template(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CConvective_Template(void); - - /*! - * \brief Compute the Roe's flux between two nodes i and j. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); -}; diff --git a/SU2_CFD/include/numerics/template/CSource_Template.hpp b/SU2_CFD/include/numerics/template/CSource_Template.hpp deleted file mode 100644 index 06c530af452b..000000000000 --- a/SU2_CFD/include/numerics/template/CSource_Template.hpp +++ /dev/null @@ -1,64 +0,0 @@ -/*! - * \file CSource_Template.hpp - * \brief Delaration of numerics class CSource_Template, the - * implementation is in the CSource_Template.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../CNumerics.hpp" - -/*! - * \class CSource_Template - * \brief Dummy class. - * \ingroup SourceDiscr - * \author A. Lonkar. - */ -class CSource_Template : public CNumerics { -public: - - /*! - * \brief Constructor of the class. - * \param[in] val_nDim - Number of dimensions of the problem. - * \param[in] val_nVar - Number of variables of the problem. - * \param[in] config - Name of the input config file - * - */ - CSource_Template(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - - /*! - * \brief Residual for source term integration. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSource_Template(void); -}; diff --git a/SU2_CFD/include/numerics/template/CViscous_Template.hpp b/SU2_CFD/include/numerics/template/CViscous_Template.hpp deleted file mode 100644 index d41dd8268dc1..000000000000 --- a/SU2_CFD/include/numerics/template/CViscous_Template.hpp +++ /dev/null @@ -1,65 +0,0 @@ -/*! - * \file CViscous_Template.hpp - * \brief Delaration of numerics class CViscous_Template, the - * implementation is in the CViscous_Template.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../CNumerics.hpp" - -/*! - * \class CViscous_Template - * \brief Class for computing viscous term using average of gradients. - * \ingroup ViscDiscr - * \author F. Palacios - */ -class CViscous_Template : public CNumerics { -private: - -public: - - /*! - * \brief Constructor of the class. - * \param[in] val_nDim - Number of dimension of the problem. - * \param[in] val_nVar - Number of variables of the problem. - * \param[in] config - Definition of the particular problem. - */ - CViscous_Template(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CViscous_Template(void); - - /*! - * \brief Compute the viscous flow residual using an average of gradients. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); -}; diff --git a/SU2_CFD/include/numerics/transition.hpp b/SU2_CFD/include/numerics/transition.hpp new file mode 100644 index 000000000000..40f207b3c622 --- /dev/null +++ b/SU2_CFD/include/numerics/transition.hpp @@ -0,0 +1,252 @@ +/*! + * \file transition.hpp + * \brief Delarations of numerics classes for transition problems. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "CNumerics.hpp" + +/*! + * \class CUpwLin_TransLM + * \brief Class for performing a linear upwind solver for the Spalart-Allmaras turbulence model equations with transition + * \ingroup ConvDiscr + * \author A. Aranake + */ +class CUpwLin_TransLM : public CNumerics { +private: + su2double *Velocity_i; + su2double *Velocity_j; + bool implicit, incompressible; + su2double Density_i, Density_j, q_ij, a0, a1; + unsigned short iDim; + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CUpwLin_TransLM(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CUpwLin_TransLM(void); + + /*! + * \brief Compute the upwind flux between two nodes i and j. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual (su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); +}; + +/*! + * \class CUpwSca_TransLM + * \brief Class for doing a scalar upwind solver for the Spalart-Allmaras turbulence model equations with transition. + * \ingroup ConvDiscr + * \author A. Aranake. + */ +class CUpwSca_TransLM : public CNumerics { +private: + su2double *Velocity_i, *Velocity_j; + bool implicit; + su2double q_ij, a0, a1; + unsigned short iDim; + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CUpwSca_TransLM(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CUpwSca_TransLM(void); + + /*! + * \brief Compute the scalar upwind flux between two nodes i and j. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); +}; + +/*! + * \class CAvgGrad_TransLM + * \brief Class for computing viscous term using average of gradients (Spalart-Allmaras Turbulence model). + * \ingroup ViscDiscr + * \author A. Bueno. + */ +class CAvgGrad_TransLM : public CNumerics { +private: + su2double **Mean_GradTransVar; + su2double *Proj_Mean_GradTransVar_Kappa, *Proj_Mean_GradTransVar_Edge; + su2double *Edge_Vector; + bool implicit, incompressible; + su2double sigma; + //su2double dist_ij_2; + //su2double proj_vector_ij; + //unsigned short iVar, iDim; + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CAvgGrad_TransLM(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CAvgGrad_TransLM(void); + + /*! + * \brief Compute the viscous turbulence terms residual using an average of gradients. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config); +}; + +/*! + * \class CAvgGradCorrected_TransLM + * \brief Class for computing viscous term using average of gradients with correction (Spalart-Allmaras turbulence model). + * \ingroup ViscDiscr + * \author A. Bueno. + */ +class CAvgGradCorrected_TransLM : public CNumerics { +private: + su2double **Mean_GradTurbVar; + su2double *Proj_Mean_GradTurbVar_Kappa, *Proj_Mean_GradTurbVar_Edge, *Proj_Mean_GradTurbVar_Corrected; + su2double *Edge_Vector; + bool implicit, incompressible; + su2double sigma; + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CAvgGradCorrected_TransLM(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CAvgGradCorrected_TransLM(void); + + /*! + * \brief Compute the viscous turbulent residual using an average of gradients with correction. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config); +}; + +/*! + * \class CSourcePieceWise_TransLM + * \brief Class for integrating the source terms of the Spalart-Allmaras turbulence model equation. + * \ingroup SourceDiscr + * \author A. Bueno. + */ +class CSourcePieceWise_TransLM : public CNumerics { +private: + + /*-- SA model constants --*/ + su2double cv1_3; + su2double k2; + su2double cb1; + su2double cw2; + su2double cw3_6; + su2double sigma; + su2double cb2; + su2double cw1; + + /*-- gamma-theta model constants --*/ + su2double c_e1; + su2double c_a1; + su2double c_e2; + su2double c_a2; + su2double sigmaf; + su2double s1; + su2double c_theta; + su2double sigmat; + + /*-- Correlation constants --*/ + su2double flen_global; + su2double alpha_global; + su2double Vorticity; + + bool implicit; + +public: + bool debugme; // For debugging only, remove this. -AA + + /*! + * \brief Constructor of the class. + * \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. + */ + CSourcePieceWise_TransLM(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CSourcePieceWise_TransLM(void); + + /*! + * \brief Residual for source term integration. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual_TransLM(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config, su2double &gamma_sep); + + void CSourcePieceWise_TransLM__ComputeResidual_TransLM_d(su2double *TransVar_i, su2double *TransVar_id, su2double *val_residual, su2double *val_residuald, CConfig *config); +}; diff --git a/SU2_CFD/include/numerics/transition/CAvgGradCorrected_TransLM.hpp b/SU2_CFD/include/numerics/transition/CAvgGradCorrected_TransLM.hpp deleted file mode 100644 index e8b0551cd005..000000000000 --- a/SU2_CFD/include/numerics/transition/CAvgGradCorrected_TransLM.hpp +++ /dev/null @@ -1,70 +0,0 @@ -/*! - * \file CAvgGradCorrected_TransLM.hpp - * \brief Delaration of numerics class CAvgGradCorrected_TransLM, the - * implementation is in the CAvgGradCorrected_TransLM.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../CNumerics.hpp" - -/*! - * \class CAvgGradCorrected_TransLM - * \brief Class for computing viscous term using average of gradients with correction (Spalart-Allmaras turbulence model). - * \ingroup ViscDiscr - * \author A. Bueno. - */ -class CAvgGradCorrected_TransLM : public CNumerics { -private: - su2double **Mean_GradTurbVar; - su2double *Proj_Mean_GradTurbVar_Kappa, *Proj_Mean_GradTurbVar_Edge, *Proj_Mean_GradTurbVar_Corrected; - su2double *Edge_Vector; - bool implicit, incompressible; - su2double sigma; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CAvgGradCorrected_TransLM(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CAvgGradCorrected_TransLM(void); - - /*! - * \brief Compute the viscous turbulent residual using an average of gradients with correction. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config); -}; diff --git a/SU2_CFD/include/numerics/transition/CAvgGrad_TransLM.hpp b/SU2_CFD/include/numerics/transition/CAvgGrad_TransLM.hpp deleted file mode 100644 index 834c07147e3d..000000000000 --- a/SU2_CFD/include/numerics/transition/CAvgGrad_TransLM.hpp +++ /dev/null @@ -1,73 +0,0 @@ -/*! - * \file CAvgGrad_TransLM.hpp - * \brief Delaration of numerics class CAvgGrad_TransLM, the - * implementation is in the CAvgGrad_TransLM.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../CNumerics.hpp" - -/*! - * \class CAvgGrad_TransLM - * \brief Class for computing viscous term using average of gradients (Spalart-Allmaras Turbulence model). - * \ingroup ViscDiscr - * \author A. Bueno. - */ -class CAvgGrad_TransLM : public CNumerics { -private: - su2double **Mean_GradTransVar; - su2double *Proj_Mean_GradTransVar_Kappa, *Proj_Mean_GradTransVar_Edge; - su2double *Edge_Vector; - bool implicit, incompressible; - su2double sigma; - //su2double dist_ij_2; - //su2double proj_vector_ij; - //unsigned short iVar, iDim; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CAvgGrad_TransLM(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CAvgGrad_TransLM(void); - - /*! - * \brief Compute the viscous turbulence terms residual using an average of gradients. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config); -}; diff --git a/SU2_CFD/include/numerics/transition/CSourcePieceWise_TransLM.hpp b/SU2_CFD/include/numerics/transition/CSourcePieceWise_TransLM.hpp deleted file mode 100644 index e2efe9a0912e..000000000000 --- a/SU2_CFD/include/numerics/transition/CSourcePieceWise_TransLM.hpp +++ /dev/null @@ -1,95 +0,0 @@ -/*! - * \file CSourcePieceWise_TransLM.hpp - * \brief Delaration of numerics class CSourcePieceWise_TransLM, the - * implementation is in the CSourcePieceWise_TransLM.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../CNumerics.hpp" - -/*! - * \class CSourcePieceWise_TransLM - * \brief Class for integrating the source terms of the Spalart-Allmaras turbulence model equation. - * \ingroup SourceDiscr - * \author A. Bueno. - */ -class CSourcePieceWise_TransLM : public CNumerics { -private: - - /*-- SA model constants --*/ - su2double cv1_3; - su2double k2; - su2double cb1; - su2double cw2; - su2double cw3_6; - su2double sigma; - su2double cb2; - su2double cw1; - - /*-- gamma-theta model constants --*/ - su2double c_e1; - su2double c_a1; - su2double c_e2; - su2double c_a2; - su2double sigmaf; - su2double s1; - su2double c_theta; - su2double sigmat; - - /*-- Correlation constants --*/ - su2double flen_global; - su2double alpha_global; - su2double Vorticity; - - bool implicit; - -public: - bool debugme; // For debugging only, remove this. -AA - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourcePieceWise_TransLM(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourcePieceWise_TransLM(void); - - /*! - * \brief Residual for source term integration. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual_TransLM(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config, su2double &gamma_sep); - - void CSourcePieceWise_TransLM__ComputeResidual_TransLM_d(su2double *TransVar_i, su2double *TransVar_id, su2double *val_residual, su2double *val_residuald, CConfig *config); -}; diff --git a/SU2_CFD/include/numerics/transition/CUpwLin_TransLM.hpp b/SU2_CFD/include/numerics/transition/CUpwLin_TransLM.hpp deleted file mode 100644 index 3847341c721b..000000000000 --- a/SU2_CFD/include/numerics/transition/CUpwLin_TransLM.hpp +++ /dev/null @@ -1,70 +0,0 @@ -/*! - * \file CUpwLin_TransLM.hpp - * \brief Delaration of numerics class CUpwLin_TransLM, the - * implementation is in the CUpwLin_TransLM.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../CNumerics.hpp" - -/*! - * \class CUpwLin_TransLM - * \brief Class for performing a linear upwind solver for the Spalart-Allmaras turbulence model equations with transition - * \ingroup ConvDiscr - * \author A. Aranake - */ -class CUpwLin_TransLM : public CNumerics { -private: - su2double *Velocity_i; - su2double *Velocity_j; - bool implicit, incompressible; - su2double Density_i, Density_j, q_ij, a0, a1; - unsigned short iDim; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwLin_TransLM(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwLin_TransLM(void); - - /*! - * \brief Compute the upwind flux between two nodes i and j. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual (su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); -}; diff --git a/SU2_CFD/include/numerics/transition/CUpwSca_TransLM.hpp b/SU2_CFD/include/numerics/transition/CUpwSca_TransLM.hpp deleted file mode 100644 index c68cabe20333..000000000000 --- a/SU2_CFD/include/numerics/transition/CUpwSca_TransLM.hpp +++ /dev/null @@ -1,69 +0,0 @@ -/*! - * \file CUpwSca_TransLM.hpp - * \brief Delaration of numerics class CUpwSca_TransLM, the - * implementation is in the CUpwSca_TransLM.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../CNumerics.hpp" - -/*! - * \class CUpwSca_TransLM - * \brief Class for doing a scalar upwind solver for the Spalart-Allmaras turbulence model equations with transition. - * \ingroup ConvDiscr - * \author A. Aranake. - */ -class CUpwSca_TransLM : public CNumerics { -private: - su2double *Velocity_i, *Velocity_j; - bool implicit; - su2double q_ij, a0, a1; - unsigned short iDim; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwSca_TransLM(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwSca_TransLM(void); - - /*! - * \brief Compute the scalar upwind flux between two nodes i and j. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); -}; diff --git a/SU2_CFD/include/numerics/turbulent/CAvgGrad_Scalar.hpp b/SU2_CFD/include/numerics/turbulent/CAvgGrad_Scalar.hpp deleted file mode 100644 index ebc40cdca52c..000000000000 --- a/SU2_CFD/include/numerics/turbulent/CAvgGrad_Scalar.hpp +++ /dev/null @@ -1,103 +0,0 @@ -/*! - * \file CAvgGrad_Scalar.hpp - * \brief Delaration of numerics class CAvgGrad_Scalar, the - * implementation is in the CAvgGrad_Scalar.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../CNumerics.hpp" - -/*! - * \class CAvgGrad_Scalar - * \brief Template class for computing viscous residual of scalar values - * \details This class serves as a template for the scalar viscous residual - * classes. The general structure of a viscous residual calculation is the - * same for many different models, which leads to a lot of repeated code. - * By using the template design pattern, these sections of repeated code are - * moved to a shared base class, and the specifics of each model - * are implemented by derived classes. In order to add a new residual - * calculation for a viscous residual, extend this class and implement - * the pure virtual functions with model-specific behavior. - * \ingroup ViscDiscr - * \author C. Pederson, A. Bueno, and F. Palacios - */ -class CAvgGrad_Scalar : public CNumerics { - private: - - /*! - * \brief A pure virtual function; Adds any extra variables to AD - */ - virtual void ExtraADPreaccIn() = 0; - - /*! - * \brief Model-specific steps in the ComputeResidual method - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - virtual void FinishResidualCalc(su2double *val_residual, - su2double **Jacobian_i, - su2double **Jacobian_j, - CConfig *config) = 0; - - protected: - bool implicit, incompressible; - bool correct_gradient; - unsigned short iVar, iDim; - su2double **Mean_GradTurbVar; /*!< \brief Average of gradients at cell face */ - su2double *Edge_Vector, /*!< \brief Vector from node i to node j. */ - *Proj_Mean_GradTurbVar_Normal, /*!< \brief Mean_gradTurbVar DOT normal */ - *Proj_Mean_GradTurbVar_Edge, /*!< \brief Mean_gradTurbVar DOT Edge_Vector */ - *Proj_Mean_GradTurbVar; /*!< \brief Mean_gradTurbVar DOT normal, corrected if required*/ - su2double dist_ij_2, /*!< \brief |Edge_Vector|^2 */ - proj_vector_ij; /*!< \brief (Edge_Vector DOT normal)/|Edge_Vector|^2 */ - - public: - /*! - * \brief Constructor of the class. - * \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. - */ - CAvgGrad_Scalar(unsigned short val_nDim, unsigned short val_nVar, - bool correct_gradient, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CAvgGrad_Scalar(void); - - /*! - * \brief Compute the viscous residual using an average of gradients without correction. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **Jacobian_i, - su2double **Jacobian_j, CConfig *config); -}; diff --git a/SU2_CFD/include/numerics/turbulent/CAvgGrad_TurbSA.hpp b/SU2_CFD/include/numerics/turbulent/CAvgGrad_TurbSA.hpp deleted file mode 100644 index faa75e21d134..000000000000 --- a/SU2_CFD/include/numerics/turbulent/CAvgGrad_TurbSA.hpp +++ /dev/null @@ -1,75 +0,0 @@ -/*! - * \file CAvgGrad_TurbSA.hpp - * \brief Delaration of numerics class CAvgGrad_TurbSA, the - * implementation is in the CAvgGrad_TurbSA.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "CAvgGrad_Scalar.hpp" - -/*! - * \class CAvgGrad_TurbSA - * \brief Class for computing viscous term using average of gradients (Spalart-Allmaras Turbulence model). - * \ingroup ViscDiscr - * \author A. Bueno. - */ -class CAvgGrad_TurbSA : public CAvgGrad_Scalar { -private: - - const su2double sigma; - su2double nu_i, nu_j, nu_e; - - /*! - * \brief Adds any extra variables to AD - */ - void ExtraADPreaccIn(void); - - /*! - * \brief SA specific steps in the ComputeResidual method - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void FinishResidualCalc(su2double *val_residual, su2double **Jacobian_i, - su2double **Jacobian_j, CConfig *config); - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CAvgGrad_TurbSA(unsigned short val_nDim, unsigned short val_nVar, - bool correct_grad, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CAvgGrad_TurbSA(void); -}; diff --git a/SU2_CFD/include/numerics/turbulent/CAvgGrad_TurbSA_Neg.hpp b/SU2_CFD/include/numerics/turbulent/CAvgGrad_TurbSA_Neg.hpp deleted file mode 100644 index 849bb534ec29..000000000000 --- a/SU2_CFD/include/numerics/turbulent/CAvgGrad_TurbSA_Neg.hpp +++ /dev/null @@ -1,77 +0,0 @@ -/*! - * \file CAvgGrad_TurbSA_Neg.hpp - * \brief Delaration of numerics class CAvgGrad_TurbSA_Neg, the - * implementation is in the CAvgGrad_TurbSA_Neg.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "CAvgGrad_Scalar.hpp" - -/*! - * \class CAvgGrad_TurbSA_Neg - * \brief Class for computing viscous term using average of gradients (Spalart-Allmaras Turbulence model). - * \ingroup ViscDiscr - * \author F. Palacios - */ -class CAvgGrad_TurbSA_Neg : public CAvgGrad_Scalar { -private: - - const su2double sigma; - const su2double cn1; - su2double fn, Xi; - su2double nu_i, nu_j, nu_ij, nu_tilde_ij, nu_e; - - /*! - * \brief Adds any extra variables to AD - */ - void ExtraADPreaccIn(void); - - /*! - * \brief SA specific steps in the ComputeResidual method - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void FinishResidualCalc(su2double *val_residual, su2double **Jacobian_i, - su2double **Jacobian_j, CConfig *config); - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CAvgGrad_TurbSA_Neg(unsigned short val_nDim, unsigned short val_nVar, - bool correct_grad, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CAvgGrad_TurbSA_Neg(void); -}; diff --git a/SU2_CFD/include/numerics/turbulent/CAvgGrad_TurbSST.hpp b/SU2_CFD/include/numerics/turbulent/CAvgGrad_TurbSST.hpp deleted file mode 100644 index 3f74a49c050d..000000000000 --- a/SU2_CFD/include/numerics/turbulent/CAvgGrad_TurbSST.hpp +++ /dev/null @@ -1,89 +0,0 @@ -/*! - * \file CAvgGrad_TurbSST.hpp - * \brief Delaration of numerics class CAvgGrad_TurbSST, the - * implementation is in the CAvgGrad_TurbSST.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "CAvgGrad_Scalar.hpp" - -/*! - * \class CAvgGrad_TurbSST - * \brief Class for computing viscous term using average of gradient with correction (Menter SST turbulence model). - * \ingroup ViscDiscr - * \author A. Bueno. - */ -class CAvgGrad_TurbSST : public CAvgGrad_Scalar { -private: - su2double sigma_k1, /*!< \brief Constants for the viscous terms, k-w (1), k-eps (2)*/ - sigma_k2, - sigma_om1, - sigma_om2; - - su2double diff_kine, /*!< \brief Diffusivity for viscous terms of tke eq */ - diff_omega; /*!< \brief Diffusivity for viscous terms of omega eq */ - - su2double F1_i, F1_j; /*!< \brief Menter's first blending function */ - - /*! - * \brief Adds any extra variables to AD - */ - void ExtraADPreaccIn(void); - - /*! - * \brief SST specific steps in the ComputeResidual method - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void FinishResidualCalc(su2double *val_residual, su2double **Jacobian_i, - su2double **Jacobian_j, CConfig *config); - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CAvgGrad_TurbSST(unsigned short val_nDim, unsigned short val_nVar, - const su2double* constants, bool correct_grad, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CAvgGrad_TurbSST(void); - - /*! - * \brief Sets value of first blending function. - */ - void SetF1blending(su2double val_F1_i, su2double val_F1_j) { - F1_i = val_F1_i; F1_j = val_F1_j; - } - -}; diff --git a/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA.hpp b/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA.hpp deleted file mode 100644 index 839f581a3417..000000000000 --- a/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA.hpp +++ /dev/null @@ -1,133 +0,0 @@ -/*! - * \file CSourcePieceWise_TurbSA.hpp - * \brief Delaration of numerics class CSourcePieceWise_TurbSA, the - * implementation is in the CSourcePieceWise_TurbSA.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../CNumerics.hpp" - -/*! - * \class CSourcePieceWise_TurbSA - * \brief Class for integrating the source terms of the Spalart-Allmaras turbulence model equation. - * \ingroup SourceDiscr - * \author A. Bueno. - */ -class CSourcePieceWise_TurbSA : public CNumerics { -private: - su2double cv1_3; - su2double k2; - su2double cb1; - su2double cw2; - su2double ct3; - su2double ct4; - su2double cw3_6; - su2double cb2_sigma; - su2double sigma; - su2double cb2; - su2double cw1; - unsigned short iDim; - su2double nu, Ji, fv1, fv2, ft2, Omega, S, Shat, inv_Shat, dist_i_2, Ji_2, Ji_3, inv_k2_d2; - su2double r, g, g_6, glim, fw; - su2double norm2_Grad; - su2double dfv1, dfv2, dShat; - su2double dr, dg, dfw; - bool incompressible; - bool rotating_frame; - bool transition; - su2double gamma_BC; - su2double intermittency; - su2double Production, Destruction, CrossProduction; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourcePieceWise_TurbSA(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourcePieceWise_TurbSA(void); - - /*! - * \brief Residual for source term integration. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - - /*! - * \brief Residual for source term integration. - * \param[in] intermittency_in - Value of the intermittency. - */ - inline void SetIntermittency(su2double intermittency_in) { intermittency = intermittency_in; } - - /*! - * \brief Residual for source term integration. - * \param[in] val_production - Value of the Production. - */ - inline void SetProduction(su2double val_production) { Production = val_production; } - - /*! - * \brief Residual for source term integration. - * \param[in] val_destruction - Value of the Destruction. - */ - inline void SetDestruction(su2double val_destruction) { Destruction = val_destruction; } - - /*! - * \brief Residual for source term integration. - * \param[in] val_crossproduction - Value of the CrossProduction. - */ - inline void SetCrossProduction(su2double val_crossproduction) { CrossProduction = val_crossproduction; } - - /*! - * \brief ______________. - */ - inline su2double GetProduction(void) { return Production; } - - /*! - * \brief Get the intermittency for the BC trans. model. - * \return Value of the intermittency. - */ - inline su2double GetGammaBC(void) { return gamma_BC; } - - /*! - * \brief ______________. - */ - inline su2double GetDestruction(void) { return Destruction; } - - /*! - * \brief ______________. - */ - inline su2double GetCrossProduction(void) { return CrossProduction; } -}; diff --git a/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA_COMP.hpp b/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA_COMP.hpp deleted file mode 100644 index f9d46eec267f..000000000000 --- a/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA_COMP.hpp +++ /dev/null @@ -1,128 +0,0 @@ -/*! - * \file CSourcePieceWise_TurbSA_COMP.hpp - * \brief Delaration of numerics class CSourcePieceWise_TurbSA_COMP, the - * implementation is in the CSourcePieceWise_TurbSA_COMP.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../CNumerics.hpp" - -/*! - * \class CSourcePieceWise_TurbSA_COMP - * \brief Class for integrating the source terms of the Spalart-Allmaras CC modification turbulence model equation. - * \ingroup SourceDiscr - * \author E.Molina, A. Bueno. - * \version 7.0.0 "Blackbird" - */ -class CSourcePieceWise_TurbSA_COMP : public CNumerics { -private: - su2double cv1_3; - su2double k2; - su2double cb1; - su2double cw2; - su2double ct3; - su2double ct4; - su2double cw3_6; - su2double cb2_sigma; - su2double sigma; - su2double cb2; - su2double cw1; - unsigned short iDim; - su2double nu, Ji, fv1, fv2, ft2, Omega, S, Shat, inv_Shat, dist_i_2, Ji_2, Ji_3, inv_k2_d2; - su2double r, g, g_6, glim, fw; - su2double norm2_Grad; - su2double dfv1, dfv2, dShat; - su2double dr, dg, dfw; - bool incompressible; - bool rotating_frame; - su2double intermittency; - su2double Production, Destruction, CrossProduction; - su2double aux_cc, CompCorrection, c5; - unsigned short jDim; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourcePieceWise_TurbSA_COMP(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourcePieceWise_TurbSA_COMP(void); - - /*! - * \brief Residual for source term integration. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - - /*! - * \brief Residual for source term integration. - * \param[in] intermittency_in - Value of the intermittency. - */ - inline void SetIntermittency(su2double intermittency_in) { intermittency = intermittency_in; } - - /*! - * \brief Residual for source term integration. - * \param[in] val_production - Value of the Production. - */ - inline void SetProduction(su2double val_production) { Production = val_production; } - - /*! - * \brief Residual for source term integration. - * \param[in] val_destruction - Value of the Destruction. - */ - inline void SetDestruction(su2double val_destruction) { Destruction = val_destruction; } - - /*! - * \brief Residual for source term integration. - * \param[in] val_crossproduction - Value of the CrossProduction. - */ - inline void SetCrossProduction(su2double val_crossproduction) { CrossProduction = val_crossproduction; } - - /*! - * \brief ______________. - */ - inline su2double GetProduction(void) { return Production; } - - /*! - * \brief ______________. - */ - inline su2double GetDestruction(void) { return Destruction; } - - /*! - * \brief ______________. - */ - inline su2double GetCrossProduction(void) { return CrossProduction; } -}; diff --git a/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA_E.hpp b/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA_E.hpp deleted file mode 100644 index 5e1ef5f37d47..000000000000 --- a/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA_E.hpp +++ /dev/null @@ -1,128 +0,0 @@ -/*! - * \file CSourcePieceWise_TurbSA_E.hpp - * \brief Delaration of numerics class CSourcePieceWise_TurbSA_E, the - * implementation is in the CSourcePieceWise_TurbSA_E.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../CNumerics.hpp" - -/*! - * \class CSourcePieceWise_TurbSA_E - * \brief Class for integrating the source terms of the Spalart-Allmaras Edwards modification turbulence model equation. - * \ingroup SourceDiscr - * \author E.Molina, A. Bueno. - * \version 7.0.0 "Blackbird" - */ -class CSourcePieceWise_TurbSA_E : public CNumerics { -private: - su2double cv1_3; - su2double k2; - su2double cb1; - su2double cw2; - su2double ct3; - su2double ct4; - su2double cw3_6; - su2double cb2_sigma; - su2double sigma; - su2double cb2; - su2double cw1; - unsigned short iDim; - su2double nu, Ji, fv1, fv2, ft2, Omega, S, Shat, inv_Shat, dist_i_2, Ji_2, Ji_3, inv_k2_d2; - su2double r, g, g_6, glim, fw; - su2double norm2_Grad; - su2double dfv1, dfv2, dShat; - su2double dr, dg, dfw; - bool incompressible; - bool rotating_frame; - su2double intermittency; - su2double Production, Destruction, CrossProduction; - su2double Sbar; - unsigned short jDim; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourcePieceWise_TurbSA_E(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourcePieceWise_TurbSA_E(void); - - /*! - * \brief Residual for source term integration. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - - /*! - * \brief Residual for source term integration. - * \param[in] intermittency_in - Value of the intermittency. - */ - inline void SetIntermittency(su2double intermittency_in) { intermittency = intermittency_in; } - - /*! - * \brief Residual for source term integration. - * \param[in] val_production - Value of the Production. - */ - inline void SetProduction(su2double val_production) { Production = val_production; } - - /*! - * \brief Residual for source term integration. - * \param[in] val_destruction - Value of the Destruction. - */ - inline void SetDestruction(su2double val_destruction) { Destruction = val_destruction; } - - /*! - * \brief Residual for source term integration. - * \param[in] val_crossproduction - Value of the CrossProduction. - */ - inline void SetCrossProduction(su2double val_crossproduction) { CrossProduction = val_crossproduction; } - - /*! - * \brief ______________. - */ - inline su2double GetProduction(void) { return Production; } - - /*! - * \brief ______________. - */ - inline su2double GetDestruction(void) { return Destruction; } - - /*! - * \brief ______________. - */ - inline su2double GetCrossProduction(void) { return CrossProduction; } -}; diff --git a/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA_E_COMP.hpp b/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA_E_COMP.hpp deleted file mode 100644 index 2b842720320a..000000000000 --- a/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA_E_COMP.hpp +++ /dev/null @@ -1,129 +0,0 @@ -/*! - * \file CSourcePieceWise_TurbSA_E_COMP.hpp - * \brief Delaration of numerics class CSourcePieceWise_TurbSA_E_COMP, the - * implementation is in the CSourcePieceWise_TurbSA_E_COMP.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../CNumerics.hpp" - -/*! - * \class CSourcePieceWise_TurbSA_E_COMP - * \brief Class for integrating the source terms of the Spalart-Allmaras Edwards modification with CC turbulence model equation. - * \ingroup SourceDiscr - * \author E.Molina, A. Bueno. - * \version 7.0.0 "Blackbird" - */ -class CSourcePieceWise_TurbSA_E_COMP : public CNumerics { -private: - su2double cv1_3; - su2double k2; - su2double cb1; - su2double cw2; - su2double ct3; - su2double ct4; - su2double cw3_6; - su2double cb2_sigma; - su2double sigma; - su2double cb2; - su2double cw1; - unsigned short iDim; - su2double nu, Ji, fv1, fv2, ft2, Omega, S, Shat, inv_Shat, dist_i_2, Ji_2, Ji_3, inv_k2_d2; - su2double r, g, g_6, glim, fw; - su2double norm2_Grad; - su2double dfv1, dfv2, dShat; - su2double dr, dg, dfw; - bool incompressible; - bool rotating_frame; - su2double intermittency; - su2double Production, Destruction, CrossProduction; - su2double Sbar; - unsigned short jDim; - su2double aux_cc, CompCorrection, c5; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourcePieceWise_TurbSA_E_COMP(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourcePieceWise_TurbSA_E_COMP(void); - - /*! - * \brief Residual for source term integration. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - - /*! - * \brief Residual for source term integration. - * \param[in] intermittency_in - Value of the intermittency. - */ - inline void SetIntermittency(su2double intermittency_in) { intermittency = intermittency_in; } - - /*! - * \brief Residual for source term integration. - * \param[in] val_production - Value of the Production. - */ - inline void SetProduction(su2double val_production) { Production = val_production; } - - /*! - * \brief Residual for source term integration. - * \param[in] val_destruction - Value of the Destruction. - */ - inline void SetDestruction(su2double val_destruction) { Destruction = val_destruction; } - - /*! - * \brief Residual for source term integration. - * \param[in] val_crossproduction - Value of the CrossProduction. - */ - inline void SetCrossProduction(su2double val_crossproduction) { CrossProduction = val_crossproduction; } - - /*! - * \brief ______________. - */ - inline su2double GetProduction(void) { return Production; } - - /*! - * \brief ______________. - */ - inline su2double GetDestruction(void) { return Destruction; } - - /*! - * \brief ______________. - */ - inline su2double GetCrossProduction(void) { return CrossProduction; } -}; diff --git a/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA_Neg.hpp b/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA_Neg.hpp deleted file mode 100644 index f37abddc9b93..000000000000 --- a/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSA_Neg.hpp +++ /dev/null @@ -1,125 +0,0 @@ -/*! - * \file CSourcePieceWise_TurbSA_Neg.hpp - * \brief Delaration of numerics class CSourcePieceWise_TurbSA_Neg, the - * implementation is in the CSourcePieceWise_TurbSA_Neg.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../CNumerics.hpp" - -/*! - * \class CSourcePieceWise_TurbSA_Neg - * \brief Class for integrating the source terms of the Spalart-Allmaras turbulence model equation. - * \ingroup SourceDiscr - * \author F. Palacios - */ -class CSourcePieceWise_TurbSA_Neg : public CNumerics { -private: - su2double cv1_3; - su2double k2; - su2double cb1; - su2double cw2; - su2double ct3; - su2double ct4; - su2double cw3_6; - su2double cb2_sigma; - su2double sigma; - su2double cb2; - su2double cw1; - unsigned short iDim; - su2double nu, Ji, fv1, fv2, ft2, Omega, S, Shat, inv_Shat, dist_i_2, Ji_2, Ji_3, inv_k2_d2; - su2double r, g, g_6, glim, fw; - su2double norm2_Grad; - su2double dfv1, dfv2, dShat; - su2double dr, dg, dfw; - bool incompressible; - bool rotating_frame; - su2double intermittency; - su2double Production, Destruction, CrossProduction; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourcePieceWise_TurbSA_Neg(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourcePieceWise_TurbSA_Neg(void); - - /*! - * \brief Residual for source term integration. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - - /*! - * \brief Residual for source term integration. - * \param[in] intermittency_in - Value of the intermittency. - */ - inline void SetIntermittency(su2double intermittency_in) { intermittency = intermittency_in; } - - /*! - * \brief Residual for source term integration. - * \param[in] val_production - Value of the Production. - */ - inline void SetProduction(su2double val_production) { Production = val_production; } - - /*! - * \brief Residual for source term integration. - * \param[in] val_destruction - Value of the Destruction. - */ - inline void SetDestruction(su2double val_destruction) { Destruction = val_destruction; } - - /*! - * \brief Residual for source term integration. - * \param[in] val_crossproduction - Value of the CrossProduction. - */ - inline void SetCrossProduction(su2double val_crossproduction) { CrossProduction = val_crossproduction; } - - /*! - * \brief ______________. - */ - inline su2double GetProduction(void) { return Production; } - - /*! - * \brief ______________. - */ - inline su2double GetDestruction(void) { return Destruction; } - - /*! - * \brief ______________. - */ - inline su2double GetCrossProduction(void) { return CrossProduction; } -}; diff --git a/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSST.hpp b/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSST.hpp deleted file mode 100644 index 26aa5e1278fb..000000000000 --- a/SU2_CFD/include/numerics/turbulent/CSourcePieceWise_TurbSST.hpp +++ /dev/null @@ -1,141 +0,0 @@ -/*! - * \file CSourcePieceWise_TurbSST.hpp - * \brief Delaration of numerics class CSourcePieceWise_TurbSST, the - * implementation is in the CSourcePieceWise_TurbSST.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../CNumerics.hpp" - -/*! - * \class CSourcePieceWise_TurbSST - * \brief Class for integrating the source terms of the Menter SST turbulence model equations. - * \ingroup SourceDiscr - * \author A. Campos. - */ -class CSourcePieceWise_TurbSST : public CNumerics { -private: - su2double F1_i, - F1_j, - F2_i, - F2_j; - - su2double alfa_1, - alfa_2, - beta_1, - beta_2, - sigma_omega_1, - sigma_omega_2, - beta_star, - a1; - - su2double CDkw_i, CDkw_j; - - su2double kAmb, omegaAmb; - - bool incompressible; - bool sustaining_terms; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourcePieceWise_TurbSST(unsigned short val_nDim, unsigned short val_nVar, const su2double* constants, - su2double val_kine_Inf, su2double val_omega_Inf, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourcePieceWise_TurbSST(void); - - /*! - * \brief Set the value of the first blending function. - * \param[in] val_F1_i - Value of the first blending function at point i. - * \param[in] val_F1_j - Value of the first blending function at point j. - */ - inline void SetF1blending(su2double val_F1_i, su2double val_F1_j) { - F1_i = val_F1_i; - F1_j = val_F1_j; - } - - /*! - * \brief Set the value of the second blending function. - * \param[in] val_F2_i - Value of the second blending function at point i. - * \param[in] val_F2_j - Value of the second blending function at point j. - */ - inline void SetF2blending(su2double val_F2_i, su2double val_F2_j) { - F2_i = val_F2_i; - F2_j = val_F2_j; - } - - /*! - * \brief Set the value of the cross diffusion for the SST model. - * \param[in] val_CDkw_i - Value of the cross diffusion at point i. - * \param[in] val_CDkw_j - Value of the cross diffusion at point j. - */ - inline void SetCrossDiff(su2double val_CDkw_i, su2double val_CDkw_j) override { - CDkw_i = val_CDkw_i; - CDkw_j = val_CDkw_j; - } - - /*! - * \brief Residual for source term integration. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - - /*! - * \brief Initialize the Reynolds Stress Matrix - * \param[in] turb_ke turbulent kinetic energy of node - */ - void SetReynoldsStressMatrix(su2double turb_ke); - - /*! - * \brief Perturb the Reynolds stress tensor based on parameters - * \param[in] turb_ke: turbulent kinetic energy of the noce - * \param[in] config: config file - */ - void SetPerturbedRSM(su2double turb_ke, CConfig *config); - /*! - * \brief A virtual member. Get strain magnitude based on perturbed reynolds stress matrix - * \param[in] turb_ke: turbulent kinetic energy of the node - */ - void SetPerturbedStrainMag(su2double turb_ke); - - /*! - * \brief Get the mean rate of strain matrix based on velocity gradients - * \param[in] S_ij - */ - void GetMeanRateOfStrainMatrix(su2double **S_ij); - -}; diff --git a/SU2_CFD/include/numerics/turbulent/CUpwSca_TurbSA.hpp b/SU2_CFD/include/numerics/turbulent/CUpwSca_TurbSA.hpp deleted file mode 100644 index 1bf8ff43b923..000000000000 --- a/SU2_CFD/include/numerics/turbulent/CUpwSca_TurbSA.hpp +++ /dev/null @@ -1,71 +0,0 @@ -/*! - * \file CUpwSca_TurbSA.hpp - * \brief Delaration of numerics class CUpwSca_TurbSA, the - * implementation is in the CUpwSca_TurbSA.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "CUpwScalar.hpp" - -/*! - * \class CUpwSca_TurbSA - * \brief Class for doing a scalar upwind solver for the Spalar-Allmaras turbulence model equations. - * \ingroup ConvDiscr - * \author A. Bueno. - */ -class CUpwSca_TurbSA : public CUpwScalar { -private: - - /*! - * \brief Adds any extra variables to AD - */ - void ExtraADPreaccIn(); - - /*! - * \brief SA specific steps in the ComputeResidual method - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void FinishResidualCalc(su2double *val_residual, su2double **Jacobian_i, - su2double **Jacobian_j, CConfig *config); - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwSca_TurbSA(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwSca_TurbSA(void); -}; diff --git a/SU2_CFD/include/numerics/turbulent/CUpwSca_TurbSST.hpp b/SU2_CFD/include/numerics/turbulent/CUpwSca_TurbSST.hpp deleted file mode 100644 index 17a5889888ec..000000000000 --- a/SU2_CFD/include/numerics/turbulent/CUpwSca_TurbSST.hpp +++ /dev/null @@ -1,71 +0,0 @@ -/*! - * \file CUpwSca_TurbSST.hpp - * \brief Delaration of numerics class CUpwSca_TurbSST, the - * implementation is in the CUpwSca_TurbSST.cpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "CUpwScalar.hpp" - -/*! - * \class CUpwSca_TurbSST - * \brief Class for doing a scalar upwind solver for the Menter SST turbulence model equations. - * \ingroup ConvDiscr - * \author A. Campos. - */ -class CUpwSca_TurbSST : public CUpwScalar { -private: - - /*! - * \brief Adds any extra variables to AD - */ - void ExtraADPreaccIn(); - - /*! - * \brief SST specific steps in the ComputeResidual method - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void FinishResidualCalc(su2double *val_residual, su2double **Jacobian_i, - su2double **Jacobian_j, CConfig *config); - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwSca_TurbSST(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwSca_TurbSST(void); -}; diff --git a/SU2_CFD/include/numerics/turbulent/CUpwScalar.hpp b/SU2_CFD/include/numerics/turbulent/turb_convection.hpp similarity index 59% rename from SU2_CFD/include/numerics/turbulent/CUpwScalar.hpp rename to SU2_CFD/include/numerics/turbulent/turb_convection.hpp index ced8eed03124..2d5af1de17f1 100644 --- a/SU2_CFD/include/numerics/turbulent/CUpwScalar.hpp +++ b/SU2_CFD/include/numerics/turbulent/turb_convection.hpp @@ -1,7 +1,7 @@ /*! - * \file CUpwScalar.hpp - * \brief Delaration of numerics class CUpwScalar, the - * implementation is in the CUpwScalar.cpp file. + * \file turb_convection.hpp + * \brief Delarations of numerics classes for discretization of + * convective fluxes in turbulence problems. * \author F. Palacios, T. Economon * \version 7.0.0 "Blackbird" * @@ -97,3 +97,83 @@ class CUpwScalar : public CNumerics { */ void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); }; + +/*! + * \class CUpwSca_TurbSA + * \brief Class for doing a scalar upwind solver for the Spalar-Allmaras turbulence model equations. + * \ingroup ConvDiscr + * \author A. Bueno. + */ +class CUpwSca_TurbSA : public CUpwScalar { +private: + + /*! + * \brief Adds any extra variables to AD + */ + void ExtraADPreaccIn(); + + /*! + * \brief SA specific steps in the ComputeResidual method + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void FinishResidualCalc(su2double *val_residual, su2double **Jacobian_i, + su2double **Jacobian_j, CConfig *config); + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CUpwSca_TurbSA(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CUpwSca_TurbSA(void); +}; + +/*! + * \class CUpwSca_TurbSST + * \brief Class for doing a scalar upwind solver for the Menter SST turbulence model equations. + * \ingroup ConvDiscr + * \author A. Campos. + */ +class CUpwSca_TurbSST : public CUpwScalar { +private: + + /*! + * \brief Adds any extra variables to AD + */ + void ExtraADPreaccIn(); + + /*! + * \brief SST specific steps in the ComputeResidual method + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void FinishResidualCalc(su2double *val_residual, su2double **Jacobian_i, + su2double **Jacobian_j, CConfig *config); + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CUpwSca_TurbSST(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CUpwSca_TurbSST(void); +}; diff --git a/SU2_CFD/include/numerics/turbulent/turb_diffusion.hpp b/SU2_CFD/include/numerics/turbulent/turb_diffusion.hpp new file mode 100644 index 000000000000..3a482bab8e0a --- /dev/null +++ b/SU2_CFD/include/numerics/turbulent/turb_diffusion.hpp @@ -0,0 +1,251 @@ +/*! + * \file turb_diffusion.hpp + * \brief Declarations of numerics classes for discretization of + * viscous fluxes in turbulence problems. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../CNumerics.hpp" + +/*! + * \class CAvgGrad_Scalar + * \brief Template class for computing viscous residual of scalar values + * \details This class serves as a template for the scalar viscous residual + * classes. The general structure of a viscous residual calculation is the + * same for many different models, which leads to a lot of repeated code. + * By using the template design pattern, these sections of repeated code are + * moved to a shared base class, and the specifics of each model + * are implemented by derived classes. In order to add a new residual + * calculation for a viscous residual, extend this class and implement + * the pure virtual functions with model-specific behavior. + * \ingroup ViscDiscr + * \author C. Pederson, A. Bueno, and F. Palacios + */ +class CAvgGrad_Scalar : public CNumerics { + private: + + /*! + * \brief A pure virtual function; Adds any extra variables to AD + */ + virtual void ExtraADPreaccIn() = 0; + + /*! + * \brief Model-specific steps in the ComputeResidual method + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + virtual void FinishResidualCalc(su2double *val_residual, + su2double **Jacobian_i, + su2double **Jacobian_j, + CConfig *config) = 0; + + protected: + bool implicit, incompressible; + bool correct_gradient; + unsigned short iVar, iDim; + su2double **Mean_GradTurbVar; /*!< \brief Average of gradients at cell face */ + su2double *Edge_Vector, /*!< \brief Vector from node i to node j. */ + *Proj_Mean_GradTurbVar_Normal, /*!< \brief Mean_gradTurbVar DOT normal */ + *Proj_Mean_GradTurbVar_Edge, /*!< \brief Mean_gradTurbVar DOT Edge_Vector */ + *Proj_Mean_GradTurbVar; /*!< \brief Mean_gradTurbVar DOT normal, corrected if required*/ + su2double dist_ij_2, /*!< \brief |Edge_Vector|^2 */ + proj_vector_ij; /*!< \brief (Edge_Vector DOT normal)/|Edge_Vector|^2 */ + + public: + /*! + * \brief Constructor of the class. + * \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. + */ + CAvgGrad_Scalar(unsigned short val_nDim, unsigned short val_nVar, + bool correct_gradient, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CAvgGrad_Scalar(void); + + /*! + * \brief Compute the viscous residual using an average of gradients without correction. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **Jacobian_i, + su2double **Jacobian_j, CConfig *config); +}; + +/*! + * \class CAvgGrad_TurbSA + * \brief Class for computing viscous term using average of gradients (Spalart-Allmaras Turbulence model). + * \ingroup ViscDiscr + * \author A. Bueno. + */ +class CAvgGrad_TurbSA : public CAvgGrad_Scalar { +private: + + const su2double sigma; + su2double nu_i, nu_j, nu_e; + + /*! + * \brief Adds any extra variables to AD + */ + void ExtraADPreaccIn(void); + + /*! + * \brief SA specific steps in the ComputeResidual method + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void FinishResidualCalc(su2double *val_residual, su2double **Jacobian_i, + su2double **Jacobian_j, CConfig *config); + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CAvgGrad_TurbSA(unsigned short val_nDim, unsigned short val_nVar, + bool correct_grad, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CAvgGrad_TurbSA(void); +}; + +/*! + * \class CAvgGrad_TurbSA_Neg + * \brief Class for computing viscous term using average of gradients (Spalart-Allmaras Turbulence model). + * \ingroup ViscDiscr + * \author F. Palacios + */ +class CAvgGrad_TurbSA_Neg : public CAvgGrad_Scalar { +private: + + const su2double sigma; + const su2double cn1; + su2double fn, Xi; + su2double nu_i, nu_j, nu_ij, nu_tilde_ij, nu_e; + + /*! + * \brief Adds any extra variables to AD + */ + void ExtraADPreaccIn(void); + + /*! + * \brief SA specific steps in the ComputeResidual method + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void FinishResidualCalc(su2double *val_residual, su2double **Jacobian_i, + su2double **Jacobian_j, CConfig *config); + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CAvgGrad_TurbSA_Neg(unsigned short val_nDim, unsigned short val_nVar, + bool correct_grad, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CAvgGrad_TurbSA_Neg(void); +}; + +/*! + * \class CAvgGrad_TurbSST + * \brief Class for computing viscous term using average of gradient with correction (Menter SST turbulence model). + * \ingroup ViscDiscr + * \author A. Bueno. + */ +class CAvgGrad_TurbSST : public CAvgGrad_Scalar { +private: + su2double sigma_k1, /*!< \brief Constants for the viscous terms, k-w (1), k-eps (2)*/ + sigma_k2, + sigma_om1, + sigma_om2; + + su2double diff_kine, /*!< \brief Diffusivity for viscous terms of tke eq */ + diff_omega; /*!< \brief Diffusivity for viscous terms of omega eq */ + + su2double F1_i, F1_j; /*!< \brief Menter's first blending function */ + + /*! + * \brief Adds any extra variables to AD + */ + void ExtraADPreaccIn(void); + + /*! + * \brief SST specific steps in the ComputeResidual method + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void FinishResidualCalc(su2double *val_residual, su2double **Jacobian_i, + su2double **Jacobian_j, CConfig *config); + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CAvgGrad_TurbSST(unsigned short val_nDim, unsigned short val_nVar, + const su2double* constants, bool correct_grad, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CAvgGrad_TurbSST(void); + + /*! + * \brief Sets value of first blending function. + */ + void SetF1blending(su2double val_F1_i, su2double val_F1_j) { + F1_i = val_F1_i; F1_j = val_F1_j; + } + +}; diff --git a/SU2_CFD/include/numerics/turbulent/turb_sources.hpp b/SU2_CFD/include/numerics/turbulent/turb_sources.hpp new file mode 100644 index 000000000000..31ec53f88ab3 --- /dev/null +++ b/SU2_CFD/include/numerics/turbulent/turb_sources.hpp @@ -0,0 +1,629 @@ +/*! + * \file turb_sources.hpp + * \brief Delarations of numerics classes for integration of source + * terms in turbulence problems. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "../CNumerics.hpp" + +/*! + * \class CSourcePieceWise_TurbSA + * \brief Class for integrating the source terms of the Spalart-Allmaras turbulence model equation. + * \ingroup SourceDiscr + * \author A. Bueno. + */ +class CSourcePieceWise_TurbSA : public CNumerics { +private: + su2double cv1_3; + su2double k2; + su2double cb1; + su2double cw2; + su2double ct3; + su2double ct4; + su2double cw3_6; + su2double cb2_sigma; + su2double sigma; + su2double cb2; + su2double cw1; + unsigned short iDim; + su2double nu, Ji, fv1, fv2, ft2, Omega, S, Shat, inv_Shat, dist_i_2, Ji_2, Ji_3, inv_k2_d2; + su2double r, g, g_6, glim, fw; + su2double norm2_Grad; + su2double dfv1, dfv2, dShat; + su2double dr, dg, dfw; + bool incompressible; + bool rotating_frame; + bool transition; + su2double gamma_BC; + su2double intermittency; + su2double Production, Destruction, CrossProduction; + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CSourcePieceWise_TurbSA(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CSourcePieceWise_TurbSA(void); + + /*! + * \brief Residual for source term integration. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + + /*! + * \brief Residual for source term integration. + * \param[in] intermittency_in - Value of the intermittency. + */ + inline void SetIntermittency(su2double intermittency_in) { intermittency = intermittency_in; } + + /*! + * \brief Residual for source term integration. + * \param[in] val_production - Value of the Production. + */ + inline void SetProduction(su2double val_production) { Production = val_production; } + + /*! + * \brief Residual for source term integration. + * \param[in] val_destruction - Value of the Destruction. + */ + inline void SetDestruction(su2double val_destruction) { Destruction = val_destruction; } + + /*! + * \brief Residual for source term integration. + * \param[in] val_crossproduction - Value of the CrossProduction. + */ + inline void SetCrossProduction(su2double val_crossproduction) { CrossProduction = val_crossproduction; } + + /*! + * \brief ______________. + */ + inline su2double GetProduction(void) { return Production; } + + /*! + * \brief Get the intermittency for the BC trans. model. + * \return Value of the intermittency. + */ + inline su2double GetGammaBC(void) { return gamma_BC; } + + /*! + * \brief ______________. + */ + inline su2double GetDestruction(void) { return Destruction; } + + /*! + * \brief ______________. + */ + inline su2double GetCrossProduction(void) { return CrossProduction; } +}; + +/*! + * \class CSourcePieceWise_TurbSA_COMP + * \brief Class for integrating the source terms of the Spalart-Allmaras CC modification turbulence model equation. + * \ingroup SourceDiscr + * \author E.Molina, A. Bueno. + * \version 7.0.0 "Blackbird" + */ +class CSourcePieceWise_TurbSA_COMP : public CNumerics { +private: + su2double cv1_3; + su2double k2; + su2double cb1; + su2double cw2; + su2double ct3; + su2double ct4; + su2double cw3_6; + su2double cb2_sigma; + su2double sigma; + su2double cb2; + su2double cw1; + unsigned short iDim; + su2double nu, Ji, fv1, fv2, ft2, Omega, S, Shat, inv_Shat, dist_i_2, Ji_2, Ji_3, inv_k2_d2; + su2double r, g, g_6, glim, fw; + su2double norm2_Grad; + su2double dfv1, dfv2, dShat; + su2double dr, dg, dfw; + bool incompressible; + bool rotating_frame; + su2double intermittency; + su2double Production, Destruction, CrossProduction; + su2double aux_cc, CompCorrection, c5; + unsigned short jDim; + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CSourcePieceWise_TurbSA_COMP(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CSourcePieceWise_TurbSA_COMP(void); + + /*! + * \brief Residual for source term integration. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + + /*! + * \brief Residual for source term integration. + * \param[in] intermittency_in - Value of the intermittency. + */ + inline void SetIntermittency(su2double intermittency_in) { intermittency = intermittency_in; } + + /*! + * \brief Residual for source term integration. + * \param[in] val_production - Value of the Production. + */ + inline void SetProduction(su2double val_production) { Production = val_production; } + + /*! + * \brief Residual for source term integration. + * \param[in] val_destruction - Value of the Destruction. + */ + inline void SetDestruction(su2double val_destruction) { Destruction = val_destruction; } + + /*! + * \brief Residual for source term integration. + * \param[in] val_crossproduction - Value of the CrossProduction. + */ + inline void SetCrossProduction(su2double val_crossproduction) { CrossProduction = val_crossproduction; } + + /*! + * \brief ______________. + */ + inline su2double GetProduction(void) { return Production; } + + /*! + * \brief ______________. + */ + inline su2double GetDestruction(void) { return Destruction; } + + /*! + * \brief ______________. + */ + inline su2double GetCrossProduction(void) { return CrossProduction; } +}; + +/*! + * \class CSourcePieceWise_TurbSA_E + * \brief Class for integrating the source terms of the Spalart-Allmaras Edwards modification turbulence model equation. + * \ingroup SourceDiscr + * \author E.Molina, A. Bueno. + * \version 7.0.0 "Blackbird" + */ +class CSourcePieceWise_TurbSA_E : public CNumerics { +private: + su2double cv1_3; + su2double k2; + su2double cb1; + su2double cw2; + su2double ct3; + su2double ct4; + su2double cw3_6; + su2double cb2_sigma; + su2double sigma; + su2double cb2; + su2double cw1; + unsigned short iDim; + su2double nu, Ji, fv1, fv2, ft2, Omega, S, Shat, inv_Shat, dist_i_2, Ji_2, Ji_3, inv_k2_d2; + su2double r, g, g_6, glim, fw; + su2double norm2_Grad; + su2double dfv1, dfv2, dShat; + su2double dr, dg, dfw; + bool incompressible; + bool rotating_frame; + su2double intermittency; + su2double Production, Destruction, CrossProduction; + su2double Sbar; + unsigned short jDim; + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CSourcePieceWise_TurbSA_E(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CSourcePieceWise_TurbSA_E(void); + + /*! + * \brief Residual for source term integration. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + + /*! + * \brief Residual for source term integration. + * \param[in] intermittency_in - Value of the intermittency. + */ + inline void SetIntermittency(su2double intermittency_in) { intermittency = intermittency_in; } + + /*! + * \brief Residual for source term integration. + * \param[in] val_production - Value of the Production. + */ + inline void SetProduction(su2double val_production) { Production = val_production; } + + /*! + * \brief Residual for source term integration. + * \param[in] val_destruction - Value of the Destruction. + */ + inline void SetDestruction(su2double val_destruction) { Destruction = val_destruction; } + + /*! + * \brief Residual for source term integration. + * \param[in] val_crossproduction - Value of the CrossProduction. + */ + inline void SetCrossProduction(su2double val_crossproduction) { CrossProduction = val_crossproduction; } + + /*! + * \brief ______________. + */ + inline su2double GetProduction(void) { return Production; } + + /*! + * \brief ______________. + */ + inline su2double GetDestruction(void) { return Destruction; } + + /*! + * \brief ______________. + */ + inline su2double GetCrossProduction(void) { return CrossProduction; } +}; + +/*! + * \class CSourcePieceWise_TurbSA_E_COMP + * \brief Class for integrating the source terms of the Spalart-Allmaras Edwards modification with CC turbulence model equation. + * \ingroup SourceDiscr + * \author E.Molina, A. Bueno. + * \version 7.0.0 "Blackbird" + */ +class CSourcePieceWise_TurbSA_E_COMP : public CNumerics { +private: + su2double cv1_3; + su2double k2; + su2double cb1; + su2double cw2; + su2double ct3; + su2double ct4; + su2double cw3_6; + su2double cb2_sigma; + su2double sigma; + su2double cb2; + su2double cw1; + unsigned short iDim; + su2double nu, Ji, fv1, fv2, ft2, Omega, S, Shat, inv_Shat, dist_i_2, Ji_2, Ji_3, inv_k2_d2; + su2double r, g, g_6, glim, fw; + su2double norm2_Grad; + su2double dfv1, dfv2, dShat; + su2double dr, dg, dfw; + bool incompressible; + bool rotating_frame; + su2double intermittency; + su2double Production, Destruction, CrossProduction; + su2double Sbar; + unsigned short jDim; + su2double aux_cc, CompCorrection, c5; + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CSourcePieceWise_TurbSA_E_COMP(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CSourcePieceWise_TurbSA_E_COMP(void); + + /*! + * \brief Residual for source term integration. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + + /*! + * \brief Residual for source term integration. + * \param[in] intermittency_in - Value of the intermittency. + */ + inline void SetIntermittency(su2double intermittency_in) { intermittency = intermittency_in; } + + /*! + * \brief Residual for source term integration. + * \param[in] val_production - Value of the Production. + */ + inline void SetProduction(su2double val_production) { Production = val_production; } + + /*! + * \brief Residual for source term integration. + * \param[in] val_destruction - Value of the Destruction. + */ + inline void SetDestruction(su2double val_destruction) { Destruction = val_destruction; } + + /*! + * \brief Residual for source term integration. + * \param[in] val_crossproduction - Value of the CrossProduction. + */ + inline void SetCrossProduction(su2double val_crossproduction) { CrossProduction = val_crossproduction; } + + /*! + * \brief ______________. + */ + inline su2double GetProduction(void) { return Production; } + + /*! + * \brief ______________. + */ + inline su2double GetDestruction(void) { return Destruction; } + + /*! + * \brief ______________. + */ + inline su2double GetCrossProduction(void) { return CrossProduction; } +}; + +/*! + * \class CSourcePieceWise_TurbSA_Neg + * \brief Class for integrating the source terms of the Spalart-Allmaras turbulence model equation. + * \ingroup SourceDiscr + * \author F. Palacios + */ +class CSourcePieceWise_TurbSA_Neg : public CNumerics { +private: + su2double cv1_3; + su2double k2; + su2double cb1; + su2double cw2; + su2double ct3; + su2double ct4; + su2double cw3_6; + su2double cb2_sigma; + su2double sigma; + su2double cb2; + su2double cw1; + unsigned short iDim; + su2double nu, Ji, fv1, fv2, ft2, Omega, S, Shat, inv_Shat, dist_i_2, Ji_2, Ji_3, inv_k2_d2; + su2double r, g, g_6, glim, fw; + su2double norm2_Grad; + su2double dfv1, dfv2, dShat; + su2double dr, dg, dfw; + bool incompressible; + bool rotating_frame; + su2double intermittency; + su2double Production, Destruction, CrossProduction; + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CSourcePieceWise_TurbSA_Neg(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CSourcePieceWise_TurbSA_Neg(void); + + /*! + * \brief Residual for source term integration. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + + /*! + * \brief Residual for source term integration. + * \param[in] intermittency_in - Value of the intermittency. + */ + inline void SetIntermittency(su2double intermittency_in) { intermittency = intermittency_in; } + + /*! + * \brief Residual for source term integration. + * \param[in] val_production - Value of the Production. + */ + inline void SetProduction(su2double val_production) { Production = val_production; } + + /*! + * \brief Residual for source term integration. + * \param[in] val_destruction - Value of the Destruction. + */ + inline void SetDestruction(su2double val_destruction) { Destruction = val_destruction; } + + /*! + * \brief Residual for source term integration. + * \param[in] val_crossproduction - Value of the CrossProduction. + */ + inline void SetCrossProduction(su2double val_crossproduction) { CrossProduction = val_crossproduction; } + + /*! + * \brief ______________. + */ + inline su2double GetProduction(void) { return Production; } + + /*! + * \brief ______________. + */ + inline su2double GetDestruction(void) { return Destruction; } + + /*! + * \brief ______________. + */ + inline su2double GetCrossProduction(void) { return CrossProduction; } +}; + +/*! + * \class CSourcePieceWise_TurbSST + * \brief Class for integrating the source terms of the Menter SST turbulence model equations. + * \ingroup SourceDiscr + * \author A. Campos. + */ +class CSourcePieceWise_TurbSST : public CNumerics { +private: + su2double F1_i, + F1_j, + F2_i, + F2_j; + + su2double alfa_1, + alfa_2, + beta_1, + beta_2, + sigma_omega_1, + sigma_omega_2, + beta_star, + a1; + + su2double CDkw_i, CDkw_j; + + su2double kAmb, omegaAmb; + + bool incompressible; + bool sustaining_terms; + +public: + + /*! + * \brief Constructor of the class. + * \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. + */ + CSourcePieceWise_TurbSST(unsigned short val_nDim, unsigned short val_nVar, const su2double* constants, + su2double val_kine_Inf, su2double val_omega_Inf, CConfig *config); + + /*! + * \brief Destructor of the class. + */ + ~CSourcePieceWise_TurbSST(void); + + /*! + * \brief Set the value of the first blending function. + * \param[in] val_F1_i - Value of the first blending function at point i. + * \param[in] val_F1_j - Value of the first blending function at point j. + */ + inline void SetF1blending(su2double val_F1_i, su2double val_F1_j) { + F1_i = val_F1_i; + F1_j = val_F1_j; + } + + /*! + * \brief Set the value of the second blending function. + * \param[in] val_F2_i - Value of the second blending function at point i. + * \param[in] val_F2_j - Value of the second blending function at point j. + */ + inline void SetF2blending(su2double val_F2_i, su2double val_F2_j) { + F2_i = val_F2_i; + F2_j = val_F2_j; + } + + /*! + * \brief Set the value of the cross diffusion for the SST model. + * \param[in] val_CDkw_i - Value of the cross diffusion at point i. + * \param[in] val_CDkw_j - Value of the cross diffusion at point j. + */ + inline void SetCrossDiff(su2double val_CDkw_i, su2double val_CDkw_j) override { + CDkw_i = val_CDkw_i; + CDkw_j = val_CDkw_j; + } + + /*! + * \brief Residual for source term integration. + * \param[out] val_residual - Pointer to the total residual. + * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + + /*! + * \brief Initialize the Reynolds Stress Matrix + * \param[in] turb_ke turbulent kinetic energy of node + */ + void SetReynoldsStressMatrix(su2double turb_ke); + + /*! + * \brief Perturb the Reynolds stress tensor based on parameters + * \param[in] turb_ke: turbulent kinetic energy of the noce + * \param[in] config: config file + */ + void SetPerturbedRSM(su2double turb_ke, CConfig *config); + /*! + * \brief A virtual member. Get strain magnitude based on perturbed reynolds stress matrix + * \param[in] turb_ke: turbulent kinetic energy of the node + */ + void SetPerturbedStrainMag(su2double turb_ke); + + /*! + * \brief Get the mean rate of strain matrix based on velocity gradients + * \param[in] S_ij + */ + void GetMeanRateOfStrainMatrix(su2double **S_ij); + +}; diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index a99180a040ed..295722a27fc4 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -62,7 +62,28 @@ #include "../../include/interfaces/fsi/CDisplacementsInterfaceLegacy.hpp" #include "../../include/interfaces/fsi/CDiscAdjDisplacementsInterfaceLegacy.hpp" -#include "../../include/numerics/include_all.hpp" +#include "../../include/numerics/template.hpp" +#include "../../include/numerics/transition.hpp" +#include "../../include/numerics/heat.hpp" +#include "../../include/numerics/flow/convection/roe.hpp" +#include "../../include/numerics/flow/convection/fds.hpp" +#include "../../include/numerics/flow/convection/fvs.hpp" +#include "../../include/numerics/flow/convection/cusp.hpp" +#include "../../include/numerics/flow/convection/hllc.hpp" +#include "../../include/numerics/flow/convection/ausm_slau.hpp" +#include "../../include/numerics/flow/convection/centered.hpp" +#include "../../include/numerics/flow/flow_diffusion.hpp" +#include "../../include/numerics/flow/flow_sources.hpp" +#include "../../include/numerics/continuous_adjoint/adj_convection.hpp" +#include "../../include/numerics/continuous_adjoint/adj_diffusion.hpp" +#include "../../include/numerics/continuous_adjoint/adj_sources.hpp" +#include "../../include/numerics/turbulent/turb_convection.hpp" +#include "../../include/numerics/turbulent/turb_diffusion.hpp" +#include "../../include/numerics/turbulent/turb_sources.hpp" +#include "../../include/numerics/elasticity/CFEAElasticity.hpp" +#include "../../include/numerics/elasticity/CFEALinearElasticity.hpp" +#include "../../include/numerics/elasticity/CFEANonlinearElasticity.hpp" +#include "../../include/numerics/elasticity/nonlinear_models.hpp" #include "../../../Common/include/omp_structure.hpp" diff --git a/SU2_CFD/src/numerics/CNumerics.cpp b/SU2_CFD/src/numerics/CNumerics.cpp index 795ddb37cfaa..49f89282fb46 100644 --- a/SU2_CFD/src/numerics/CNumerics.cpp +++ b/SU2_CFD/src/numerics/CNumerics.cpp @@ -1,6 +1,8 @@ /*! - * \file numerics_structure.cpp - * \brief This file contains all the numerical methods. + * \file CNumerics.cpp + * \brief Implementation of the base for all numerics classes. + * Contains methods for common tasks, e.g. compute flux + * Jacobians. * \author F. Palacios, T. Economon * \version 7.0.0 "Blackbird" * diff --git a/SU2_CFD/src/numerics/continuous_adjoint/CAvgGradCorrected_AdjFlow.cpp b/SU2_CFD/src/numerics/continuous_adjoint/CAvgGradCorrected_AdjFlow.cpp deleted file mode 100644 index b8dbd479aef5..000000000000 --- a/SU2_CFD/src/numerics/continuous_adjoint/CAvgGradCorrected_AdjFlow.cpp +++ /dev/null @@ -1,173 +0,0 @@ -/*! - * \file CAvgGradCorrected_AdjFlow.cpp - * \brief Implementation of numerics class CAvgGradCorrected_AdjFlow. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../include/numerics/continuous_adjoint/CAvgGradCorrected_AdjFlow.hpp" - -CAvgGradCorrected_AdjFlow::CAvgGradCorrected_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_AdjFlow() == EULER_IMPLICIT); - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; - Mean_Velocity = new su2double [nDim]; - - Mean_GradPsiVar = new su2double* [nVar]; - for (unsigned short iVar = 0; iVar < nVar; iVar++) - Mean_GradPsiVar[iVar] = new su2double [nDim]; - - Edge_Vector = new su2double [nDim]; - Proj_Mean_GradPsiVar_Edge = new su2double [nVar]; - - Mean_GradPhi = new su2double* [nDim]; - for (unsigned short iDim = 0; iDim < nDim; iDim++) - Mean_GradPhi[iDim] = new su2double [nDim]; - Mean_GradPsiE = new su2double [nDim]; - -} - -CAvgGradCorrected_AdjFlow::~CAvgGradCorrected_AdjFlow(void) { - - delete [] Velocity_i; - delete [] Velocity_j; - delete [] Mean_Velocity; - delete [] Edge_Vector; - delete [] Proj_Mean_GradPsiVar_Edge; - - for (unsigned short iVar = 0; iVar < nVar; iVar++) - delete [] Mean_GradPsiVar[iVar]; - delete [] Mean_GradPsiVar; - - for (unsigned short iDim = 0; iDim < nDim; iDim++) - delete [] Mean_GradPhi[iDim]; - delete [] Mean_GradPhi; - delete [] Mean_GradPsiE; - -} - -void CAvgGradCorrected_AdjFlow::ComputeResidual(su2double *val_residual_i, - su2double *val_residual_j, - su2double **val_Jacobian_ii, - su2double **val_Jacobian_ij, - su2double **val_Jacobian_ji, - su2double **val_Jacobian_jj, - CConfig *config) { - - unsigned short iVar, iDim, jDim; - su2double Density_i, sq_vel_i, Pressure_i, ViscDens_i, XiDens_i; - su2double Density_j, sq_vel_j, Pressure_j, ViscDens_j, XiDens_j; - su2double dist_ij_2, dPhiE_dn; - - su2double Prandtl_Lam = config->GetPrandtl_Lam(); - su2double Prandtl_Turb = config->GetPrandtl_Turb(); - - /*--- States in point i ---*/ - - sq_vel_i = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = V_i[iDim+1]; - sq_vel_i += 0.5*Velocity_i[iDim]*Velocity_i[iDim]; - } - Pressure_i = V_i[nDim+1]; - Density_i = V_i[nDim+2]; - Enthalpy_i = V_i[nDim+3]; - - /*--- Laminar and Eddy viscosity ---*/ - - Laminar_Viscosity_i = V_i[nDim+5]; - Eddy_Viscosity_i = V_i[nDim+6]; - - ViscDens_i = (Laminar_Viscosity_i + Eddy_Viscosity_i) / Density_i; - XiDens_i = Gamma*(Laminar_Viscosity_i/Prandtl_Lam + - Eddy_Viscosity_i/Prandtl_Turb) / Density_i; - - /*--- States in point j ---*/ - - sq_vel_j = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_j[iDim] = V_j[iDim+1]; - sq_vel_j += 0.5*Velocity_j[iDim]*Velocity_j[iDim]; - } - Pressure_j = V_j[nDim+1]; - Density_j = V_j[nDim+2]; - Enthalpy_j = V_j[nDim+3]; - - /*--- Laminar and Eddy viscosity ---*/ - - Laminar_Viscosity_j = V_j[nDim+5]; - Eddy_Viscosity_j = V_j[nDim+6]; - - ViscDens_j = (Laminar_Viscosity_j + Eddy_Viscosity_j) / Density_j; - XiDens_j = Gamma*(Laminar_Viscosity_j/Prandtl_Lam + - Eddy_Viscosity_j/Prandtl_Turb) / Density_j; - - /*--- Compute vector going from iPoint to jPoint ---*/ - - dist_ij_2 = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Mean_Velocity[iDim] = 0.5*(Velocity_i[iDim]+Velocity_j[iDim]); - Edge_Vector[iDim] = Coord_j[iDim]-Coord_i[iDim]; - dist_ij_2 += Edge_Vector[iDim]*Edge_Vector[iDim]; - } - - /*--- Mean gradient approximation. Projection of the mean gradient in the direction of the edge, weiss correction ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - Proj_Mean_GradPsiVar_Edge[iVar] = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Mean_GradPsiVar[iVar][iDim] = 0.5*(PsiVar_Grad_i[iVar][iDim] + PsiVar_Grad_j[iVar][iDim]); - Proj_Mean_GradPsiVar_Edge[iVar] += Mean_GradPsiVar[iVar][iDim]*Edge_Vector[iDim]; - } - for (iDim = 0; iDim < nDim; iDim++) - Mean_GradPsiVar[iVar][iDim] -= (Proj_Mean_GradPsiVar_Edge[iVar] - - (Psi_j[iVar]-Psi_i[iVar]))*Edge_Vector[iDim]/dist_ij_2; - } - - /*--- Average of the derivatives of the adjoint variables ---*/ - - for (iDim = 0; iDim < nDim; iDim++) { - Mean_GradPsiE[iDim] = Mean_GradPsiVar[nVar-1][iDim]; - for (jDim = 0; jDim < nDim; jDim++) - Mean_GradPhi[iDim][jDim] = Mean_GradPsiVar[iDim+1][jDim]; - } - - dPhiE_dn = 0; - for (iDim = 0; iDim < nDim; iDim++) - dPhiE_dn += Mean_GradPsiE[iDim]*Normal[iDim]; - - /*--- Compute the viscous residual and jacobian ---*/ - - GetAdjViscousFlux_Jac(Pressure_i, Pressure_j, Density_i, Density_j, - ViscDens_i, ViscDens_j, Velocity_i, Velocity_j, sq_vel_i, sq_vel_j, - XiDens_i, XiDens_j, Mean_GradPhi, Mean_GradPsiE, - dPhiE_dn, Normal, Edge_Vector, dist_ij_2, val_residual_i, val_residual_j, - val_Jacobian_ii, val_Jacobian_ij, val_Jacobian_ji, val_Jacobian_jj, - implicit); - -} diff --git a/SU2_CFD/src/numerics/continuous_adjoint/CAvgGradCorrected_AdjTurb.cpp b/SU2_CFD/src/numerics/continuous_adjoint/CAvgGradCorrected_AdjTurb.cpp deleted file mode 100644 index 1ba0883004b0..000000000000 --- a/SU2_CFD/src/numerics/continuous_adjoint/CAvgGradCorrected_AdjTurb.cpp +++ /dev/null @@ -1,158 +0,0 @@ -/*! - * \file CAvgGradCorrected_AdjTurb.cpp - * \brief Implementation of numerics class CAvgGradCorrected_AdjTurb. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../include/numerics/continuous_adjoint/CAvgGradCorrected_AdjTurb.hpp" - -CAvgGradCorrected_AdjTurb::CAvgGradCorrected_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - Edge_Vector = new su2double [nDim]; - Mean_GradTurbPsi = new su2double* [nVar]; - Proj_Mean_GradTurbPsi_Kappa = new su2double [nVar]; - Proj_Mean_GradTurbPsi_Edge = new su2double [nVar]; - Proj_Mean_GradTurbPsi_Corrected = new su2double [nVar]; - for (unsigned short iVar = 0; iVar < nVar; iVar++) - Mean_GradTurbPsi[iVar] = new su2double [nDim]; -} - -CAvgGradCorrected_AdjTurb::~CAvgGradCorrected_AdjTurb(void) { - delete [] Edge_Vector; - delete [] Proj_Mean_GradTurbPsi_Kappa; - delete [] Proj_Mean_GradTurbPsi_Edge; - delete [] Proj_Mean_GradTurbPsi_Corrected; - for (unsigned short iVar = 0; iVar < nVar; iVar++) { - delete [] Mean_GradTurbPsi[iVar]; - } - delete [] Mean_GradTurbPsi; -} - -void CAvgGradCorrected_AdjTurb::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, - su2double **val_Jacobian_j, CConfig *config) { - - bool implicit = (config->GetKind_TimeIntScheme_AdjTurb() == EULER_IMPLICIT); - - su2double sigma = 2./3.; - su2double nu_i, nu_j, nu_e; - su2double dist_ij_2 = 0; - su2double proj_vector_ij = 0; - unsigned short iVar, iDim; - - /*--- Compute mean effective viscosity ---*/ - nu_i = Laminar_Viscosity_i/U_i[0]; - nu_j = Laminar_Viscosity_j/U_j[0]; - nu_e = 0.5*(nu_i+nu_j+TurbVar_i[0]+TurbVar_j[0])/sigma; - - /*--- Compute vector going from iPoint to jPoint ---*/ - 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]; - } - proj_vector_ij = proj_vector_ij/dist_ij_2; - - /*--- Mean gradient approximation ---*/ - for (iVar = 0; iVar < nVar; iVar++) { - Proj_Mean_GradTurbPsi_Edge[iVar] = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Mean_GradTurbPsi[iVar][iDim] = 0.5*(TurbPsi_Grad_i[iVar][iDim] + TurbPsi_Grad_j[iVar][iDim]); - Proj_Mean_GradTurbPsi_Edge[iVar] += Mean_GradTurbPsi[iVar][iDim]*Edge_Vector[iDim]; - } - - for (iDim = 0; iDim < nDim; iDim++) - Mean_GradTurbPsi[iVar][iDim] -= (Proj_Mean_GradTurbPsi_Edge[iVar] - (TurbPsi_j[iVar]-TurbPsi_i[iVar]))*Edge_Vector[iDim]/dist_ij_2; - - /*--- Projection of the corrected gradient ---*/ - Proj_Mean_GradTurbPsi_Corrected[iVar] = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - Proj_Mean_GradTurbPsi_Corrected[iVar] += Mean_GradTurbPsi[iVar][iDim]*Normal[iDim]; - } - - val_residual[0] = -nu_e*Proj_Mean_GradTurbPsi_Corrected[0]; - - if (implicit) { - val_Jacobian_i[0][0] = nu_e*proj_vector_ij; - val_Jacobian_j[0][0] = -nu_e*proj_vector_ij; - } - -} - -void CAvgGradCorrected_AdjTurb::ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, - su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, - su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config) { - - bool implicit = (config->GetKind_TimeIntScheme_AdjTurb() == EULER_IMPLICIT); - - su2double sigma = 2./3.; - su2double nu_i, nu_j, nu_e_i, nu_e_j; - su2double dist_ij_2 = 0; - su2double proj_vector_ij = 0; - unsigned short iVar, iDim; - - /*--- Compute mean effective viscosity ---*/ - nu_i = Laminar_Viscosity_i/U_i[0]; - nu_j = Laminar_Viscosity_j/U_j[0]; - nu_e_i = (nu_i+TurbVar_i[0])/sigma; - nu_e_j = (nu_j+TurbVar_j[0])/sigma; - - /*--- Compute vector going from iPoint to jPoint ---*/ - 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]; - } - proj_vector_ij = proj_vector_ij/dist_ij_2; // to normalize vectors - - /*--- Mean gradient approximation ---*/ - for (iVar = 0; iVar < nVar; iVar++) { - Proj_Mean_GradTurbPsi_Edge[iVar] = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Mean_GradTurbPsi[iVar][iDim] = 0.5*(TurbPsi_Grad_i[iVar][iDim] + TurbPsi_Grad_j[iVar][iDim]); - Proj_Mean_GradTurbPsi_Edge[iVar] += Mean_GradTurbPsi[iVar][iDim]*Edge_Vector[iDim]; - } - - for (iDim = 0; iDim < nDim; iDim++) - Mean_GradTurbPsi[iVar][iDim] -= (Proj_Mean_GradTurbPsi_Edge[iVar] - - (TurbPsi_j[iVar]-TurbPsi_i[iVar]))*Edge_Vector[iDim]/dist_ij_2; - - /*--- Projection of the corrected gradient ---*/ - Proj_Mean_GradTurbPsi_Corrected[iVar] = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - Proj_Mean_GradTurbPsi_Corrected[iVar] += Mean_GradTurbPsi[iVar][iDim]*Normal[iDim]; - } - - val_residual_i[0] = -nu_e_i*Proj_Mean_GradTurbPsi_Corrected[0]; - val_residual_j[0] = nu_e_j*Proj_Mean_GradTurbPsi_Corrected[0]; - - if (implicit) { - val_Jacobian_ii[0][0] = nu_e_i*proj_vector_ij; - val_Jacobian_ij[0][0] = -nu_e_i*proj_vector_ij; - val_Jacobian_ji[0][0] = -nu_e_j*proj_vector_ij; - val_Jacobian_jj[0][0] = nu_e_j*proj_vector_ij; - } - -} diff --git a/SU2_CFD/src/numerics/continuous_adjoint/CAvgGrad_AdjFlow.cpp b/SU2_CFD/src/numerics/continuous_adjoint/CAvgGrad_AdjFlow.cpp deleted file mode 100644 index f414ab83d525..000000000000 --- a/SU2_CFD/src/numerics/continuous_adjoint/CAvgGrad_AdjFlow.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/*! - * \file CAvgGrad_AdjFlow.cpp - * \brief Implementation of numerics class CAvgGrad_AdjFlow. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../include/numerics/continuous_adjoint/CAvgGrad_AdjFlow.hpp" - -CAvgGrad_AdjFlow::CAvgGrad_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - unsigned short iDim; - - implicit = (config->GetKind_TimeIntScheme_AdjFlow() == EULER_IMPLICIT); - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; - Mean_Velocity = new su2double [nDim]; - Mean_GradPhi = new su2double* [nDim]; - for (iDim = 0; iDim < nDim; iDim++) - Mean_GradPhi[iDim] = new su2double [nDim]; - Mean_GradPsiE = new su2double [nDim]; - Edge_Vector = new su2double [nDim]; - -} - -CAvgGrad_AdjFlow::~CAvgGrad_AdjFlow(void) { - delete [] Velocity_i; - delete [] Velocity_j; - delete [] Mean_Velocity; - delete [] Edge_Vector; - delete [] Mean_GradPsiE; - for (unsigned short iDim = 0; iDim < nDim; iDim++) - delete [] Mean_GradPhi[iDim]; -} - -void CAvgGrad_AdjFlow::ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, - su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, - su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config) { - unsigned short iDim, jDim; - su2double sq_vel_i, ViscDens_i, XiDens_i; - su2double sq_vel_j, ViscDens_j, XiDens_j; - su2double dist_ij_2, dPhiE_dn; - - su2double Prandtl_Lam = config->GetPrandtl_Lam(); - su2double Prandtl_Turb = config->GetPrandtl_Turb(); - - /*--- States in point i ---*/ - - sq_vel_i = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = V_i[iDim+1]; - sq_vel_i += 0.5*Velocity_i[iDim]*Velocity_i[iDim]; - } - Pressure_i = V_i[nDim+1]; - Density_i = V_i[nDim+2]; - Enthalpy_i = V_i[nDim+3]; - SoundSpeed_i = sqrt(fabs(Pressure_i*Gamma/Density_i)); - - /*--- Laminar and Eddy viscosity ---*/ - - Laminar_Viscosity_i = V_i[nDim+5]; - Eddy_Viscosity_i = V_i[nDim+6]; - - ViscDens_i = (Laminar_Viscosity_i + Eddy_Viscosity_i) / Density_i; - XiDens_i = Gamma*(Laminar_Viscosity_i/Prandtl_Lam + Eddy_Viscosity_i/Prandtl_Turb) / Density_i; - - /*--- States in point j ---*/ - - sq_vel_j = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_j[iDim] = V_j[iDim+1]; - sq_vel_j += 0.5*Velocity_j[iDim]*Velocity_j[iDim]; - } - Pressure_j = V_j[nDim+1]; - Density_j = V_j[nDim+2]; - Enthalpy_j = V_j[nDim+3]; - SoundSpeed_j = sqrt(fabs(Pressure_j*Gamma/Density_j)); - - /*--- Laminar and Eddy viscosity ---*/ - - Laminar_Viscosity_j = V_j[nDim+5]; - Eddy_Viscosity_j = V_j[nDim+6]; - - ViscDens_j = (Laminar_Viscosity_j + Eddy_Viscosity_j) / Density_j; - XiDens_j = Gamma*(Laminar_Viscosity_j/Prandtl_Lam + Eddy_Viscosity_j/Prandtl_Turb) / Density_j; - - /*--- Compute vector going from iPoint to jPoint ---*/ - - dist_ij_2 = 0.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]; - } - - /*--- Average of the derivatives of the adjoint variables ---*/ - - for (iDim = 0; iDim < nDim; iDim++) { - Mean_GradPsiE[iDim] = 0.5*(PsiVar_Grad_i[nVar-1][iDim]+PsiVar_Grad_j[nVar-1][iDim]); - for (jDim = 0; jDim < nDim; jDim++) - Mean_GradPhi[iDim][jDim] = 0.5*(PsiVar_Grad_i[iDim+1][jDim]+PsiVar_Grad_j[iDim+1][jDim]); - } - - dPhiE_dn = 0; - for (iDim = 0; iDim < nDim; iDim++) - dPhiE_dn += Mean_GradPsiE[iDim]*Normal[iDim]; - - /*--- Compute the viscous residual and jacobian ---*/ - - GetAdjViscousFlux_Jac(Pressure_i, Pressure_j, Density_i, Density_j, - ViscDens_i, ViscDens_j, Velocity_i, Velocity_j, sq_vel_i, sq_vel_j, - XiDens_i, XiDens_j, Mean_GradPhi, Mean_GradPsiE, - dPhiE_dn, Normal, Edge_Vector, dist_ij_2, val_residual_i, val_residual_j, - val_Jacobian_ii, val_Jacobian_ij, val_Jacobian_ji, val_Jacobian_jj, - implicit); - -} diff --git a/SU2_CFD/src/numerics/continuous_adjoint/CAvgGrad_AdjTurb.cpp b/SU2_CFD/src/numerics/continuous_adjoint/CAvgGrad_AdjTurb.cpp deleted file mode 100644 index 56db16f8591b..000000000000 --- a/SU2_CFD/src/numerics/continuous_adjoint/CAvgGrad_AdjTurb.cpp +++ /dev/null @@ -1,149 +0,0 @@ -/*! - * \file CAvgGrad_AdjTurb.cpp - * \brief Implementation of numerics class CAvgGrad_AdjTurb. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../include/numerics/continuous_adjoint/CAvgGrad_AdjTurb.hpp" - -CAvgGrad_AdjTurb::CAvgGrad_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - Edge_Vector = new su2double [nDim]; - Mean_GradTurbPsi = new su2double* [nVar]; - Proj_Mean_GradTurbPsi_Kappa = new su2double [nVar]; - Proj_Mean_GradTurbPsi_Edge = new su2double [nVar]; - Proj_Mean_GradTurbPsi_Corrected = new su2double [nVar]; - for (unsigned short iVar = 0; iVar < nVar; iVar++) - Mean_GradTurbPsi[iVar] = new su2double [nDim]; -} - -CAvgGrad_AdjTurb::~CAvgGrad_AdjTurb(void) { - delete [] Edge_Vector; - delete [] Proj_Mean_GradTurbPsi_Kappa; - delete [] Proj_Mean_GradTurbPsi_Edge; - delete [] Proj_Mean_GradTurbPsi_Corrected; - for (unsigned short iVar = 0; iVar < nVar; iVar++) { - delete [] Mean_GradTurbPsi[iVar]; - } - delete [] Mean_GradTurbPsi; -} - -void CAvgGrad_AdjTurb::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, - su2double **val_Jacobian_j, CConfig *config) { - - bool implicit = (config->GetKind_TimeIntScheme_AdjTurb() == EULER_IMPLICIT); - - su2double sigma = 2./3.; - su2double nu_i, nu_j, nu_e; - su2double dist_ij_2 = 0; - su2double proj_vector_ij = 0; - unsigned short iVar, iDim; - - /*--- Compute mean effective viscosity ---*/ - nu_i = Laminar_Viscosity_i/U_i[0]; - nu_j = Laminar_Viscosity_j/U_j[0]; - nu_e = 0.5*(nu_i+nu_j+TurbVar_i[0]+TurbVar_j[0])/sigma; - - /*--- Compute vector going from iPoint to jPoint ---*/ - 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]; - } - proj_vector_ij = proj_vector_ij/dist_ij_2; - - /*--- Mean gradient approximation ---*/ - for (iVar = 0; iVar < nVar; iVar++) { - Proj_Mean_GradTurbPsi_Edge[iVar] = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Mean_GradTurbPsi[iVar][iDim] = 0.5*(TurbPsi_Grad_i[iVar][iDim] + TurbPsi_Grad_j[iVar][iDim]); - } - - /*--- Projection of the corrected gradient ---*/ - Proj_Mean_GradTurbPsi_Corrected[iVar] = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - Proj_Mean_GradTurbPsi_Corrected[iVar] += Mean_GradTurbPsi[iVar][iDim]*Normal[iDim]; - } - - val_residual[0] = -nu_e*Proj_Mean_GradTurbPsi_Corrected[0]; - - if (implicit) { - val_Jacobian_i[0][0] = nu_e*proj_vector_ij; - val_Jacobian_j[0][0] = -nu_e*proj_vector_ij; - } - -} - -void CAvgGrad_AdjTurb::ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, - su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, - su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config) { - - bool implicit = (config->GetKind_TimeIntScheme_AdjTurb() == EULER_IMPLICIT); - - su2double sigma = 2./3.; - su2double nu_i, nu_j, nu_e_i, nu_e_j; - su2double dist_ij_2 = 0; - su2double proj_vector_ij = 0; - unsigned short iVar, iDim; - - /*--- Compute mean effective viscosity ---*/ - nu_i = Laminar_Viscosity_i/U_i[0]; - nu_j = Laminar_Viscosity_j/U_j[0]; - nu_e_i = (nu_i+TurbVar_i[0])/sigma; - nu_e_j = (nu_j+TurbVar_j[0])/sigma; - - /*--- Compute vector going from iPoint to jPoint ---*/ - 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]; - } - proj_vector_ij = proj_vector_ij/dist_ij_2; // to normalize vectors - - /*--- Mean gradient approximation ---*/ - for (iVar = 0; iVar < nVar; iVar++) { - Proj_Mean_GradTurbPsi_Edge[iVar] = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Mean_GradTurbPsi[iVar][iDim] = 0.5*(TurbPsi_Grad_i[iVar][iDim] + TurbPsi_Grad_j[iVar][iDim]); - } - - /*--- Projection of the corrected gradient ---*/ - Proj_Mean_GradTurbPsi_Corrected[iVar] = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - Proj_Mean_GradTurbPsi_Corrected[iVar] += Mean_GradTurbPsi[iVar][iDim]*Normal[iDim]; - } - - val_residual_i[0] = -nu_e_i*Proj_Mean_GradTurbPsi_Corrected[0]; - val_residual_j[0] = nu_e_j*Proj_Mean_GradTurbPsi_Corrected[0]; - - if (implicit) { - val_Jacobian_ii[0][0] = nu_e_i*proj_vector_ij; - val_Jacobian_ij[0][0] = -nu_e_i*proj_vector_ij; - val_Jacobian_ji[0][0] = -nu_e_j*proj_vector_ij; - val_Jacobian_jj[0][0] = nu_e_j*proj_vector_ij; - } - -} diff --git a/SU2_CFD/src/numerics/continuous_adjoint/CCentJST_AdjFlow.cpp b/SU2_CFD/src/numerics/continuous_adjoint/CCentJST_AdjFlow.cpp deleted file mode 100644 index 990b80195a96..000000000000 --- a/SU2_CFD/src/numerics/continuous_adjoint/CCentJST_AdjFlow.cpp +++ /dev/null @@ -1,248 +0,0 @@ -/*! - * \file CCentJST_AdjFlow.cpp - * \brief Implementation of numerics class CCentJST_AdjFlow. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../include/numerics/continuous_adjoint/CCentJST_AdjFlow.hpp" - -CCentJST_AdjFlow::CCentJST_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - grid_movement = config->GetGrid_Movement(); - - Diff_Psi = new su2double [nVar]; Diff_Lapl = new su2double [nVar]; - Velocity_i = new su2double [nDim]; Velocity_j = new su2double [nDim]; - MeanPhi = new su2double [nDim]; - - Param_p = 0.3; - Param_Kappa_2 = config->GetKappa_2nd_AdjFlow(); - Param_Kappa_4 = config->GetKappa_4th_AdjFlow(); - implicit = (config->GetKind_TimeIntScheme_AdjFlow() == EULER_IMPLICIT); - -} - -CCentJST_AdjFlow::~CCentJST_AdjFlow(void) { - - delete [] Diff_Psi; delete [] Diff_Lapl; - delete [] Velocity_i; delete [] Velocity_j; - delete [] MeanPhi; -} - -void CCentJST_AdjFlow::ComputeResidual (su2double *val_resconv_i, su2double *val_resvisc_i, su2double *val_resconv_j, su2double *val_resvisc_j, - su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, - CConfig *config) { - - /*--- Mean Values ---*/ - - MeanPsiRho = 0.5*(Psi_i[0]+Psi_j[0]); - for (iDim = 0; iDim < nDim; iDim++) - MeanPhi[iDim] = 0.5*(Psi_i[iDim+1]+Psi_j[iDim+1]); - MeanPsiE = 0.5*(Psi_i[nVar-1]+Psi_j[nVar-1]); - - /*--- Point i convective residual evaluation ---*/ - - ProjVelocity_i = 0; ProjPhi = 0; ProjPhi_Vel = 0; sq_vel = 0; Area = 0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = U_i[iDim+1] / U_i[0]; - ProjVelocity_i += Velocity_i[iDim]*Normal[iDim]; - ProjPhi += MeanPhi[iDim]*Normal[iDim]; - ProjPhi_Vel += MeanPhi[iDim]*Velocity_i[iDim]; - sq_vel += 0.5*Velocity_i[iDim]*Velocity_i[iDim]; - Area += Normal[iDim]*Normal[iDim]; - } - Area = sqrt(Area); - phis1 = ProjPhi + ProjVelocity_i*MeanPsiE; - phis2 = MeanPsiRho + ProjPhi_Vel + Enthalpy_i*MeanPsiE; - - val_resconv_i[0] = ProjVelocity_i*MeanPsiRho - phis2*ProjVelocity_i + Gamma_Minus_One*phis1*sq_vel; - for (iDim = 0; iDim < nDim; iDim++) - val_resconv_i[iDim+1] = ProjVelocity_i*MeanPhi[iDim] + phis2*Normal[iDim] - Gamma_Minus_One*phis1*Velocity_i[iDim]; - val_resconv_i[nVar-1] = ProjVelocity_i*MeanPsiE + Gamma_Minus_One*phis1; - - /*--- Flux contributions due to grid movement at point i ---*/ - - if (grid_movement) { - su2double ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - val_resconv_i[0] -= ProjGridVel*MeanPsiRho; - for (iDim = 0; iDim < nDim; iDim++) - val_resconv_i[iDim+1] -= ProjGridVel*MeanPhi[iDim]; - val_resconv_i[nVar-1] -= ProjGridVel*MeanPsiE; - } - - /*--- Jacobians of the inviscid flux ---*/ - - if (implicit) { - val_Jacobian_ii[0][0] = 0.0; - for (jDim = 0; jDim < nDim; jDim++) - val_Jacobian_ii[0][jDim+1] = -0.5*ProjVelocity_i*Velocity_i[jDim] + Gamma_Minus_One*sq_vel*0.5*Normal[jDim]; - val_Jacobian_ii[0][nVar-1] = 0.5*ProjVelocity_i*(Gamma_Minus_One*sq_vel - Enthalpy_i); - for (iDim = 0; iDim < nDim; iDim++) { - val_Jacobian_ii[iDim+1][0] = 0.5*Normal[iDim]; - for (jDim = 0; jDim < nDim; jDim++) - val_Jacobian_ii[iDim+1][jDim+1] = 0.5*Normal[iDim]*Velocity_i[jDim] - 0.5*Gamma_Minus_One*Velocity_i[iDim]*Normal[jDim]; - val_Jacobian_ii[iDim+1][iDim+1] += 0.5*ProjVelocity_i; - val_Jacobian_ii[iDim+1][nVar-1] = 0.5*Enthalpy_i*Normal[iDim] - 0.5*Gamma_Minus_One*Velocity_i[iDim]*ProjVelocity_i; - } - val_Jacobian_ii[nVar-1][0] = 0; - for (jDim = 0; jDim < nDim; jDim++) - val_Jacobian_ii[nVar-1][jDim+1] = 0.5*Gamma_Minus_One*Normal[jDim]; - val_Jacobian_ii[nVar-1][nVar-1] = 0.5*Gamma*ProjVelocity_i; - - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_ij[iVar][jVar] = val_Jacobian_ii[iVar][jVar]; - - /*--- Jacobian contributions due to grid movement at point i ---*/ - - if (grid_movement) { - su2double ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - for (iVar = 0; iVar < nVar; iVar++) { - val_Jacobian_ii[iVar][iVar] -= 0.5*ProjGridVel; - val_Jacobian_ij[iVar][iVar] -= 0.5*ProjGridVel; - } - } - } - - - /*--- Point j convective residual evaluation ---*/ - - ProjVelocity_j = 0; ProjPhi_Vel = 0; sq_vel = 0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_j[iDim] = U_j[iDim+1] / U_j[0]; - ProjVelocity_j += Velocity_j[iDim]*Normal[iDim]; - ProjPhi_Vel += MeanPhi[iDim]*Velocity_j[iDim]; - sq_vel += 0.5*Velocity_j[iDim]*Velocity_j[iDim]; - } - - phis1 = ProjPhi + ProjVelocity_j*MeanPsiE; - phis2 = MeanPsiRho + ProjPhi_Vel + Enthalpy_j*MeanPsiE; - - val_resconv_j[0] = -(ProjVelocity_j*MeanPsiRho - phis2*ProjVelocity_j + Gamma_Minus_One*phis1*sq_vel); - for (iDim = 0; iDim < nDim; iDim++) - val_resconv_j[iDim+1] = -(ProjVelocity_j*MeanPhi[iDim] + phis2*Normal[iDim] - Gamma_Minus_One*phis1*Velocity_j[iDim]); - val_resconv_j[nVar-1] = -(ProjVelocity_j*MeanPsiE + Gamma_Minus_One*phis1); - - /*--- Flux contributions due to grid motion at point j ---*/ - - if (grid_movement) { - su2double ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - val_resconv_j[0] += ProjGridVel*MeanPsiRho; - for (iDim = 0; iDim < nDim; iDim++) - val_resconv_j[iDim+1] += ProjGridVel*MeanPhi[iDim]; - val_resconv_j[nVar-1] += ProjGridVel*MeanPsiE; - } - - /*--- Jacobians of the inviscid flux ---*/ - - if (implicit) { - val_Jacobian_jj[0][0] = 0.0; - for (jDim = 0; jDim < nDim; jDim++) - val_Jacobian_jj[0][jDim+1] = 0.5*ProjVelocity_j*Velocity_j[jDim] - Gamma_Minus_One*sq_vel*0.5*Normal[jDim]; - val_Jacobian_jj[0][nVar-1] = -0.5*ProjVelocity_j*(Gamma_Minus_One*sq_vel - Enthalpy_j); - for (iDim = 0; iDim < nDim; iDim++) { - val_Jacobian_jj[iDim+1][0] = -0.5*Normal[iDim]; - for (jDim = 0; jDim < nDim; jDim++) - val_Jacobian_jj[iDim+1][jDim+1] = -0.5*Normal[iDim]*Velocity_j[jDim] + 0.5*Gamma_Minus_One*Velocity_j[iDim]*Normal[jDim]; - val_Jacobian_jj[iDim+1][iDim+1] -= 0.5*ProjVelocity_j; - val_Jacobian_jj[iDim+1][nVar-1] = -0.5*Enthalpy_j*Normal[iDim] + 0.5*Gamma_Minus_One*Velocity_j[iDim]*ProjVelocity_j; - } - val_Jacobian_jj[nVar-1][0] = 0; - for (jDim = 0; jDim < nDim; jDim++) - val_Jacobian_jj[nVar-1][jDim+1] = -0.5*Gamma_Minus_One*Normal[jDim]; - val_Jacobian_jj[nVar-1][nVar-1] = -0.5*Gamma*ProjVelocity_j; - - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_ji[iVar][jVar] = val_Jacobian_jj[iVar][jVar]; - - /*--- Jacobian contributions due to grid motion at point j ---*/ - - if (grid_movement) { - su2double ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - for (iVar = 0; iVar < nVar; iVar++) { - val_Jacobian_jj[iVar][iVar] += 0.5*ProjGridVel; - val_Jacobian_ji[iVar][iVar] += 0.5*ProjGridVel; - } - } - } - - /*--- Computes differences btw. variables and Laplacians ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - Diff_Lapl[iVar] = Und_Lapl_i[iVar]-Und_Lapl_j[iVar]; - Diff_Psi[iVar] = Psi_i[iVar]-Psi_j[iVar]; - } - - /*--- Adjustment to projected velocity due to grid motion ---*/ - - if (grid_movement) { - su2double ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - } - ProjVelocity_i -= ProjGridVel; - ProjVelocity_j += ProjGridVel; - } - - /*--- Compute the spectral radius and stretching factor ---*/ - - Local_Lambda_i = (fabs(ProjVelocity_i)+SoundSpeed_i*Area); - Local_Lambda_j = (fabs(ProjVelocity_j)+SoundSpeed_j*Area); - MeanLambda = 0.5*(Local_Lambda_i+Local_Lambda_j); - - Phi_i = pow(Lambda_i/(4.0*MeanLambda), Param_p); - Phi_j = pow(Lambda_j/(4.0*MeanLambda), Param_p); - StretchingFactor = 4.0*Phi_i*Phi_j/(Phi_i+Phi_j); - - su2double sc2 = 3.0*(su2double(Neighbor_i)+su2double(Neighbor_j))/(su2double(Neighbor_i)*su2double(Neighbor_j)); - sc4 = sc2*sc2/4.0; - Epsilon_2 = Param_Kappa_2*0.5*(Sensor_i+Sensor_j)*sc2; - Epsilon_4 = max(0.0, Param_Kappa_4-Epsilon_2)*sc4; - - /*--- Compute viscous residual 1st- & 3rd-order dissipation ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - Residual = (Epsilon_2*Diff_Psi[iVar]-Epsilon_4*Diff_Lapl[iVar])*StretchingFactor*MeanLambda; - val_resvisc_i[iVar] = -Residual; - val_resvisc_j[iVar] = Residual; - if (implicit) { - val_Jacobian_ii[iVar][iVar] -= Epsilon_2 + su2double(Neighbor_i+1)*Epsilon_4*StretchingFactor*MeanLambda; - val_Jacobian_ij[iVar][iVar] += Epsilon_2 + su2double(Neighbor_j+1)*Epsilon_4*StretchingFactor*MeanLambda; - val_Jacobian_ji[iVar][iVar] += Epsilon_2 + su2double(Neighbor_i+1)*Epsilon_4*StretchingFactor*MeanLambda; - val_Jacobian_jj[iVar][iVar] -= Epsilon_2 + su2double(Neighbor_j+1)*Epsilon_4*StretchingFactor*MeanLambda; - } - } - -} diff --git a/SU2_CFD/src/numerics/continuous_adjoint/CCentLax_AdjFlow.cpp b/SU2_CFD/src/numerics/continuous_adjoint/CCentLax_AdjFlow.cpp deleted file mode 100644 index 6737779e46f6..000000000000 --- a/SU2_CFD/src/numerics/continuous_adjoint/CCentLax_AdjFlow.cpp +++ /dev/null @@ -1,235 +0,0 @@ -/*! - * \file CCentLax_AdjFlow.cpp - * \brief Implementation of numerics class CCentLax_AdjFlow. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../include/numerics/continuous_adjoint/CCentLax_AdjFlow.hpp" - -CCentLax_AdjFlow::CCentLax_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - Diff_Psi = new su2double [nVar]; MeanPhi = new su2double [nDim]; - Velocity_i = new su2double [nDim]; Velocity_j = new su2double [nDim]; - - implicit = (config->GetKind_TimeIntScheme_AdjFlow() == EULER_IMPLICIT); - - grid_movement = config->GetGrid_Movement(); - - Param_p = 0.3; - Param_Kappa_0 = config->GetKappa_1st_AdjFlow(); - -} - -CCentLax_AdjFlow::~CCentLax_AdjFlow(void) { - - delete [] Diff_Psi; delete [] MeanPhi; - delete [] Velocity_i; delete [] Velocity_j; - -} - -void CCentLax_AdjFlow::ComputeResidual (su2double *val_resconv_i, su2double *val_resvisc_i, su2double *val_resconv_j, su2double *val_resvisc_j, - su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, - CConfig *config) { - - /*--- Mean value of the adjoint variables ---*/ - MeanPsiRho = 0.5*(Psi_i[0]+Psi_j[0]); - for (iDim = 0; iDim < nDim; iDim++) - MeanPhi[iDim] = 0.5*(Psi_i[iDim+1]+Psi_j[iDim+1]); - MeanPsiE = 0.5*(Psi_i[nVar-1]+Psi_j[nVar-1]); - - /*--- Evaluation at point i ---*/ - ProjVelocity_i = 0; ProjPhi = 0; ProjPhi_Vel = 0; sq_vel = 0; Area = 0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = U_i[iDim+1] / U_i[0]; - ProjVelocity_i += Velocity_i[iDim]*Normal[iDim]; - ProjPhi += MeanPhi[iDim]*Normal[iDim]; - ProjPhi_Vel += MeanPhi[iDim]*Velocity_i[iDim]; - sq_vel += 0.5*Velocity_i[iDim]*Velocity_i[iDim]; - Area += Normal[iDim]*Normal[iDim]; - } - Area = sqrt(Area); - phis1 = ProjPhi + ProjVelocity_i*MeanPsiE; - phis2 = MeanPsiRho + ProjPhi_Vel + Enthalpy_i*MeanPsiE; - - /*--- Compute inviscid residual at point i ---*/ - val_resconv_i[0] = ProjVelocity_i*MeanPsiRho - phis2*ProjVelocity_i + Gamma_Minus_One*phis1*sq_vel; - for (iDim = 0; iDim < nDim; iDim++) - val_resconv_i[iDim+1] = ProjVelocity_i*MeanPhi[iDim] + phis2*Normal[iDim] - Gamma_Minus_One*phis1*Velocity_i[iDim]; - val_resconv_i[nVar-1] = ProjVelocity_i*MeanPsiE + Gamma_Minus_One*phis1; - - /*--- Flux contributions due to grid motion at point i ---*/ - if (grid_movement) { - su2double ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - val_resconv_i[0] -= ProjGridVel*MeanPsiRho; - for (iDim = 0; iDim < nDim; iDim++) - val_resconv_i[iDim+1] -= ProjGridVel*MeanPhi[iDim]; - val_resconv_i[nVar-1] -= ProjGridVel*MeanPsiE; - } - - /*--- Inviscid contribution to the implicit part ---*/ - if (implicit) { - val_Jacobian_ii[0][0] = 0.0; - for (jDim = 0; jDim < nDim; jDim++) - val_Jacobian_ii[0][jDim+1] = -0.5*ProjVelocity_i*Velocity_i[jDim] + Gamma_Minus_One*sq_vel*0.5*Normal[jDim]; - val_Jacobian_ii[0][nVar-1] = 0.5*ProjVelocity_i*(Gamma_Minus_One*sq_vel - Enthalpy_i); - for (iDim = 0; iDim < nDim; iDim++) { - val_Jacobian_ii[iDim+1][0] = 0.5*Normal[iDim]; - for (jDim = 0; jDim < nDim; jDim++) - val_Jacobian_ii[iDim+1][jDim+1] = 0.5*Normal[iDim]*Velocity_i[jDim] - 0.5*Gamma_Minus_One*Velocity_i[iDim]*Normal[jDim]; - val_Jacobian_ii[iDim+1][iDim+1] += 0.5*ProjVelocity_i; - val_Jacobian_ii[iDim+1][nVar-1] = 0.5*Enthalpy_i*Normal[iDim] - 0.5*Gamma_Minus_One*Velocity_i[iDim]*ProjVelocity_i; - } - val_Jacobian_ii[nVar-1][0] = 0; - for (jDim = 0; jDim < nDim; jDim++) - val_Jacobian_ii[nVar-1][jDim+1] = 0.5*Gamma_Minus_One*Normal[jDim]; - val_Jacobian_ii[nVar-1][nVar-1] = 0.5*Gamma*ProjVelocity_i; - - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_ij[iVar][jVar] = val_Jacobian_ii[iVar][jVar]; - - /*--- Jacobian contributions due to grid motion at point i ---*/ - if (grid_movement) { - su2double ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - for (iVar = 0; iVar < nVar; iVar++) { - val_Jacobian_ii[iVar][iVar] -= 0.5*ProjGridVel; - val_Jacobian_ij[iVar][iVar] -= 0.5*ProjGridVel; - } - } - } - - /*--- Evaluation at point j ---*/ - ProjVelocity_j = 0; ProjPhi_Vel = 0; sq_vel = 0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_j[iDim] = U_j[iDim+1] / U_j[0]; - ProjVelocity_j += Velocity_j[iDim]*Normal[iDim]; - ProjPhi_Vel += MeanPhi[iDim]*Velocity_j[iDim]; - sq_vel += 0.5*Velocity_j[iDim]*Velocity_j[iDim]; - } - - phis1 = ProjPhi + ProjVelocity_j*MeanPsiE; - phis2 = MeanPsiRho + ProjPhi_Vel + Enthalpy_j*MeanPsiE; - - /*--- Compute inviscid residual at point j ---*/ - val_resconv_j[0] = -(ProjVelocity_j*MeanPsiRho - phis2*ProjVelocity_j + Gamma_Minus_One*phis1*sq_vel); - for (iDim = 0; iDim < nDim; iDim++) - val_resconv_j[iDim+1] = -(ProjVelocity_j*MeanPhi[iDim] + phis2*Normal[iDim] - Gamma_Minus_One*phis1*Velocity_j[iDim]); - val_resconv_j[nVar-1] = -(ProjVelocity_j*MeanPsiE + Gamma_Minus_One*phis1); - - /*--- Flux contributions due to grid movement at point j ---*/ - if (grid_movement) { - su2double ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - val_resconv_j[0] += ProjGridVel*MeanPsiRho; - for (iDim = 0; iDim < nDim; iDim++) - val_resconv_j[iDim+1] += ProjGridVel*MeanPhi[iDim]; - val_resconv_j[nVar-1] += ProjGridVel*MeanPsiE; - } - - /*--- Inviscid contribution to the implicit part ---*/ - if (implicit) { - val_Jacobian_jj[0][0] = 0.0; - for (jDim = 0; jDim < nDim; jDim++) - val_Jacobian_jj[0][jDim+1] = 0.5*ProjVelocity_j*Velocity_j[jDim] - Gamma_Minus_One*sq_vel*0.5*Normal[jDim]; - val_Jacobian_jj[0][nVar-1] = -0.5*ProjVelocity_j*(Gamma_Minus_One*sq_vel - Enthalpy_j); - for (iDim = 0; iDim < nDim; iDim++) { - val_Jacobian_jj[iDim+1][0] = -0.5*Normal[iDim]; - for (jDim = 0; jDim < nDim; jDim++) - val_Jacobian_jj[iDim+1][jDim+1] = -0.5*Normal[iDim]*Velocity_j[jDim] + 0.5*Gamma_Minus_One*Velocity_j[iDim]*Normal[jDim]; - val_Jacobian_jj[iDim+1][iDim+1] -= 0.5*ProjVelocity_j; - val_Jacobian_jj[iDim+1][nVar-1] = -0.5*Enthalpy_j*Normal[iDim] + 0.5*Gamma_Minus_One*Velocity_j[iDim]*ProjVelocity_j; - } - val_Jacobian_jj[nVar-1][0] = 0; - for (jDim = 0; jDim < nDim; jDim++) - val_Jacobian_jj[nVar-1][jDim+1] = -0.5*Gamma_Minus_One*Normal[jDim]; - val_Jacobian_jj[nVar-1][nVar-1] = -0.5*Gamma*ProjVelocity_j; - - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_ji[iVar][jVar] = val_Jacobian_jj[iVar][jVar]; - - /*--- Jacobian contributions due to grid movement at point j ---*/ - if (grid_movement) { - su2double ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - for (iVar = 0; iVar < nVar; iVar++) { - val_Jacobian_jj[iVar][iVar] += 0.5*ProjGridVel; - val_Jacobian_ji[iVar][iVar] += 0.5*ProjGridVel; - } - } - } - - /*--- Computes differences btw. variables ---*/ - for (iVar = 0; iVar < nVar; iVar++) - Diff_Psi[iVar] = Psi_i[iVar]-Psi_j[iVar]; - - /*--- Adjustment to projected velocity due to grid motion ---*/ - if (grid_movement) { - su2double ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - ProjVelocity_i -= ProjGridVel; - ProjVelocity_j += ProjGridVel; - } - - /*--- Compute spectral radius ---*/ - Local_Lambda_i = (fabs(ProjVelocity_i)+SoundSpeed_i*Area); - Local_Lambda_j = (fabs(ProjVelocity_j)+SoundSpeed_j*Area); - MeanLambda = 0.5*(Local_Lambda_i+Local_Lambda_j); - - /*--- Compute streching factor ---*/ - Phi_i = pow(Lambda_i/(4.0*MeanLambda), Param_p); - Phi_j = pow(Lambda_j/(4.0*MeanLambda), Param_p); - StretchingFactor = 4.0*Phi_i*Phi_j/(Phi_i+Phi_j); - - sc2 = 3.0*(su2double(Neighbor_i)+su2double(Neighbor_j))/(su2double(Neighbor_i)*su2double(Neighbor_j)); - Epsilon_0 = Param_Kappa_0*sc2*su2double(nDim)/3.0; - - /*--- Artifical dissipation evaluation ---*/ - for (iVar = 0; iVar < nVar; iVar++) { - Residual = Epsilon_0*StretchingFactor*MeanLambda*Diff_Psi[iVar]; - val_resvisc_i[iVar] = -Residual; - val_resvisc_j[iVar] = Residual; - } - - /*--- Contribution to implicit part ---*/ - if (implicit) { - for (iVar = 0; iVar < nVar; iVar++) { - val_Jacobian_ii[iVar][iVar] -= Epsilon_0*StretchingFactor*MeanLambda; - val_Jacobian_ij[iVar][iVar] += Epsilon_0*StretchingFactor*MeanLambda; - val_Jacobian_ji[iVar][iVar] += Epsilon_0*StretchingFactor*MeanLambda; - val_Jacobian_jj[iVar][iVar] -= Epsilon_0*StretchingFactor*MeanLambda; - } - } - -} diff --git a/SU2_CFD/src/numerics/continuous_adjoint/CSourceAxisymmetric_AdjFlow.cpp b/SU2_CFD/src/numerics/continuous_adjoint/CSourceAxisymmetric_AdjFlow.cpp deleted file mode 100644 index fc67713fa039..000000000000 --- a/SU2_CFD/src/numerics/continuous_adjoint/CSourceAxisymmetric_AdjFlow.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/*! - * \file CSourceAxisymmetric_AdjFlow.cpp - * \brief Implementation of numerics class CSourceAxisymmetric_AdjFlow. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../include/numerics/continuous_adjoint/CSourceAxisymmetric_AdjFlow.hpp" - -CSourceAxisymmetric_AdjFlow::CSourceAxisymmetric_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { } - -CSourceAxisymmetric_AdjFlow::~CSourceAxisymmetric_AdjFlow(void) { } - -void CSourceAxisymmetric_AdjFlow::ComputeResidual(su2double *val_residual, su2double **Jacobian_ii, CConfig *config) { - - su2double yinv; - su2double Jacobian_Axisymmetric[4][4]; - - if (Coord_i[1] > 0.0) yinv = 1.0/Coord_i[1]; - else yinv = 0.0; - - Jacobian_Axisymmetric[0][0] = 0; - Jacobian_Axisymmetric[0][1] = 0; - Jacobian_Axisymmetric[0][2] = 1.; - Jacobian_Axisymmetric[0][3] = 0; - - Jacobian_Axisymmetric[1][0] = -U_i[1]*U_i[2]/(U_i[0]*U_i[0]); - Jacobian_Axisymmetric[1][1] = U_i[2]/U_i[0]; - Jacobian_Axisymmetric[1][2] = U_i[1]/U_i[0]; - Jacobian_Axisymmetric[1][3] = 0; - - Jacobian_Axisymmetric[2][0] = -U_i[2]*U_i[2]/(U_i[0]*U_i[0]); - Jacobian_Axisymmetric[2][1] = 0; - Jacobian_Axisymmetric[2][2] = 2*U_i[2]/U_i[0]; - Jacobian_Axisymmetric[2][3] = 0; - - Jacobian_Axisymmetric[3][0] = -Gamma*U_i[2]*U_i[3]/(U_i[0]*U_i[0]) + (Gamma-1)*U_i[2]*(U_i[1]*U_i[1]+U_i[2]*U_i[2])/(U_i[0]*U_i[0]*U_i[0]); - Jacobian_Axisymmetric[3][1] = -(Gamma-1)*U_i[2]*U_i[1]/(U_i[0]*U_i[0]); - Jacobian_Axisymmetric[3][2] = Gamma*U_i[3]/U_i[0] - 1/2*(Gamma-1)*( (U_i[1]*U_i[1]+U_i[2]*U_i[2])/(U_i[0]*U_i[0]) + 2*U_i[2]*U_i[2]/(U_i[0]*U_i[0]) ); - Jacobian_Axisymmetric[3][3] = Gamma*U_i[2]/U_i[0]; - - for (int iVar=0; iVar<4; iVar++) - for (int jVar=0; jVar<4; jVar++) - Jacobian_Axisymmetric[iVar][jVar] *= yinv*Volume; - - /* -- Residual = transpose(Jacobian) * psi --*/ - for (int iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] = 0.0; - for (int jVar = 0; jVar < nVar; jVar++) { - val_residual[iVar] += Jacobian_Axisymmetric[jVar][iVar]*Psi_i[jVar]; - Jacobian_ii[iVar][jVar] = Jacobian_Axisymmetric[jVar][iVar]; - } - } -} diff --git a/SU2_CFD/src/numerics/continuous_adjoint/CSourceConservative_AdjFlow.cpp b/SU2_CFD/src/numerics/continuous_adjoint/CSourceConservative_AdjFlow.cpp deleted file mode 100644 index 51bda829e181..000000000000 --- a/SU2_CFD/src/numerics/continuous_adjoint/CSourceConservative_AdjFlow.cpp +++ /dev/null @@ -1,190 +0,0 @@ -/*! - * \file CSourceConservative_AdjFlow.cpp - * \brief Implementation of numerics class CSourceConservative_AdjFlow. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../include/numerics/continuous_adjoint/CSourceConservative_AdjFlow.hpp" - -CSourceConservative_AdjFlow::CSourceConservative_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - Velocity = new su2double [nDim]; - Residual_i = new su2double [nVar]; - Residual_j = new su2double [nVar]; - Mean_Residual = new su2double [nVar]; - - Mean_PrimVar_Grad = new su2double* [nVar]; - for (unsigned short iVar = 0; iVar < nVar; iVar++) - Mean_PrimVar_Grad[iVar] = new su2double [nDim]; -} - -CSourceConservative_AdjFlow::~CSourceConservative_AdjFlow(void) { - delete [] Mean_Residual; - delete [] Residual_j; - delete [] Residual_i; - delete [] Velocity; - - for (unsigned short iVar = 0; iVar < nVar; iVar++) - delete [] Mean_PrimVar_Grad[iVar]; - delete [] Mean_PrimVar_Grad; -} - -void CSourceConservative_AdjFlow::ComputeResidual (su2double *val_residual, CConfig *config) { - unsigned short iDim, jDim, iVar; - su2double rho, nu, Ji, fv1, fv2, Omega, Shat, dist_sq, Ji_2, Ji_3, one_o_oneplusJifv1; - su2double r, g, g_6, glim, dfw_g, dg_r, dr_nuhat, dr_Shat, Ms_coeff, invOmega; - - su2double cv1_3 = 7.1*7.1*7.1; - su2double k2 = 0.41*0.41; - su2double cb1 = 0.1355; - su2double cw2 = 0.3; - su2double cw3_6 = pow(2.0,6.0); - su2double sigma = 2./3.; - su2double cb2 = 0.622; - su2double cw1 = cb1/k2+(1+cb2)/sigma; - - for (iVar = 0; iVar < nVar; iVar++) { - Residual_i[iVar] = 0.0; - Residual_j[iVar] = 0.0; - } - - /*--- iPoint ---*/ - - /*--- Density and velocities ---*/ - - rho = U_i[0]; - for (iDim = 0; iDim < nDim; iDim++) - Velocity[iDim] = U_i[iDim+1]/rho; - - /*--- Vorticity ---*/ - - Omega = (PrimVar_Grad_i[1][1]-PrimVar_Grad_i[2][0])*(PrimVar_Grad_i[1][1]-PrimVar_Grad_i[2][0]); - if (nDim == 3) Omega += (PrimVar_Grad_i[1][2]-PrimVar_Grad_i[3][0])*(PrimVar_Grad_i[1][2]-PrimVar_Grad_i[3][0]) + - (PrimVar_Grad_i[2][2]-PrimVar_Grad_i[3][1])*(PrimVar_Grad_i[2][2]-PrimVar_Grad_i[3][1]); - Omega = sqrt(Omega); - invOmega = 1.0/(Omega + TURB_EPS); - - /*--- Compute Ms_coeff -> coming from partial derivatives ---*/ - - Ms_coeff = 0.0; - if (dist_i > 0) { - dist_sq = dist_i*dist_i; - nu = Laminar_Viscosity_i/rho; - Ji = TurbVar_i[0]/nu; - Ji_2 = Ji*Ji; - Ji_3 = Ji_2*Ji; - fv1 = Ji_3/(Ji_3+cv1_3); - one_o_oneplusJifv1 = 1.0/(1.0+Ji*fv1); - fv2 = 1.0 - Ji*one_o_oneplusJifv1; - Shat = max(Omega + TurbVar_i[0]*fv2/(k2*dist_sq), TURB_EPS); - - r = min(TurbVar_i[0]/(Shat*k2*dist_sq),10.); - g = r + cw2*(pow(r,6.)-r); - g_6 = pow(g,6.); - glim = pow((1+cw3_6)/(g_6+cw3_6),1./6.); - - dfw_g = glim*cw3_6/(g_6+cw3_6); - dg_r = 1.0 + cw2*(6.0*pow(r,5.0)-1.0); - dr_nuhat = 1.0/(Shat*k2*dist_sq); - dr_Shat = -dr_nuhat*TurbVar_i[0]/Shat; - - Ms_coeff = (cb1*TurbVar_i[0]-cw1*TurbVar_i[0]*TurbVar_i[0]/dist_sq*dfw_g*dg_r*dr_Shat); - } - Ms_coeff *= TurbPsi_i[0]*invOmega/rho; - - /*--- Compute residual of iPoint ---*/ - - for (iDim = 0; iDim < nDim; iDim++) { - for (jDim = 0; jDim < nDim; jDim++) { - Residual_i[0] -= Ms_coeff*(Velocity[jDim]*PrimVar_Grad_i[jDim+1][iDim]*Normal[iDim] - - Velocity[jDim]*PrimVar_Grad_i[iDim+1][jDim]*Normal[iDim]); - Residual_i[iDim+1] += Ms_coeff*(PrimVar_Grad_i[iDim+1][jDim]*Normal[jDim] - - PrimVar_Grad_i[jDim+1][iDim]*Normal[jDim]); - } - } - - /*--- jPoint ---*/ - - /*--- Density and velocities ---*/ - - rho = U_j[0]; - for (iDim = 0; iDim < nDim; iDim++) - Velocity[iDim] = U_j[iDim+1]/rho; - - /*--- Vorticity ---*/ - - Omega = (PrimVar_Grad_j[1][1]-PrimVar_Grad_j[2][0])*(PrimVar_Grad_j[1][1]-PrimVar_Grad_j[2][0]); - if (nDim == 3) Omega += (PrimVar_Grad_j[1][2]-PrimVar_Grad_j[3][0])*(PrimVar_Grad_j[1][2]-PrimVar_Grad_j[3][0]) + - (PrimVar_Grad_j[2][2]-PrimVar_Grad_j[3][1])*(PrimVar_Grad_j[2][2]-PrimVar_Grad_j[3][1]); - Omega = sqrt(Omega); - invOmega = 1.0/(Omega + TURB_EPS); - - /*--- Compute Ms_coeff -> coming from partial derivatives ---*/ - - Ms_coeff = 0.0; - if (dist_j > 0) { - dist_sq = dist_j*dist_j; - nu = Laminar_Viscosity_j/rho; - Ji = TurbVar_j[0]/nu; - Ji_2 = Ji*Ji; - Ji_3 = Ji_2*Ji; - fv1 = Ji_3/(Ji_3+cv1_3); - one_o_oneplusJifv1 = 1.0/(1.0+Ji*fv1); - fv2 = 1.0 - Ji*one_o_oneplusJifv1; - Shat = max(Omega + TurbVar_j[0]*fv2/(k2*dist_sq), TURB_EPS); - - r = min(TurbVar_j[0]/(Shat*k2*dist_sq),10.); - g = r + cw2*(pow(r,6.)-r); - g_6 = pow(g,6.); - glim = pow((1+cw3_6)/(g_6+cw3_6),1./6.); - - dfw_g = glim*cw3_6/(g_6+cw3_6); - dg_r = 1.0 + cw2*(6.0*pow(r,5.0)-1.0); - dr_nuhat = 1.0/(Shat*k2*dist_sq); - dr_Shat = -dr_nuhat*TurbVar_j[0]/Shat; - - Ms_coeff = (cb1*TurbVar_j[0]-cw1*TurbVar_j[0]*TurbVar_j[0]/dist_sq*dfw_g*dg_r*dr_Shat); - } - Ms_coeff *= TurbPsi_j[0]*invOmega/rho; - - /*--- Compute residual of jPoint ---*/ - - for (iDim = 0; iDim < nDim; iDim++) { - for (jDim = 0; jDim < nDim; jDim++) { - Residual_j[0] -= Ms_coeff*(Velocity[jDim]*PrimVar_Grad_j[jDim+1][iDim]*Normal[iDim] - - Velocity[jDim]*PrimVar_Grad_j[iDim+1][jDim]*Normal[iDim]); - Residual_j[iDim+1] += Ms_coeff*(PrimVar_Grad_j[iDim+1][jDim]*Normal[jDim] - - PrimVar_Grad_j[jDim+1][iDim]*Normal[jDim]); - } - } - - /*--- Compute the mean residual ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_residual[iVar] = 0.5*(Residual_i[iVar] + Residual_j[iVar]); - -} diff --git a/SU2_CFD/src/numerics/continuous_adjoint/CSourceConservative_AdjTurb.cpp b/SU2_CFD/src/numerics/continuous_adjoint/CSourceConservative_AdjTurb.cpp deleted file mode 100644 index f6b5dc78ec9f..000000000000 --- a/SU2_CFD/src/numerics/continuous_adjoint/CSourceConservative_AdjTurb.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/*! - * \file CSourceConservative_AdjTurb.cpp - * \brief Implementation of numerics class CSourceConservative_AdjTurb. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../include/numerics/continuous_adjoint/CSourceConservative_AdjTurb.hpp" - -CSourceConservative_AdjTurb::CSourceConservative_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - -} - -CSourceConservative_AdjTurb::~CSourceConservative_AdjTurb(void) { -} - -void CSourceConservative_AdjTurb::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - /*--- SOURCE term --> \nabla ( \psi_\mu \B7 E^{s} ) - E^{s} = 2 c_{b2}/\sigma \nabla \hat{nu} ---*/ - - unsigned short iDim; - bool implicit = (config->GetKind_TimeIntScheme_AdjTurb() == EULER_IMPLICIT); - - su2double cb2 = 0.622; - su2double sigma = 2./3.; - su2double coeff = 2.0*cb2/sigma; - su2double E_ij, proj_TurbVar_Grad_i, proj_TurbVar_Grad_j; - - E_ij = 0.0; proj_TurbVar_Grad_i = 0.0; proj_TurbVar_Grad_j = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - proj_TurbVar_Grad_i += coeff*TurbVar_Grad_i[0][iDim]*Normal[iDim]; - proj_TurbVar_Grad_j += coeff*TurbVar_Grad_j[0][iDim]*Normal[iDim]; - E_ij += 0.5*(TurbPsi_i[0]*proj_TurbVar_Grad_i + TurbPsi_j[0]*proj_TurbVar_Grad_j); - } - - val_residual[0] = E_ij; - - if (implicit) { - val_Jacobian_i[0][0] = 0.5*proj_TurbVar_Grad_i; - val_Jacobian_j[0][0] = 0.5*proj_TurbVar_Grad_j; - } -} diff --git a/SU2_CFD/src/numerics/continuous_adjoint/CSourcePieceWise_AdjTurb.cpp b/SU2_CFD/src/numerics/continuous_adjoint/CSourcePieceWise_AdjTurb.cpp deleted file mode 100644 index ac467d1f28f5..000000000000 --- a/SU2_CFD/src/numerics/continuous_adjoint/CSourcePieceWise_AdjTurb.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/*! - * \file CSourcePieceWise_AdjTurb.cpp - * \brief Implementation of numerics class CSourcePieceWise_AdjTurb. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../include/numerics/continuous_adjoint/CSourcePieceWise_AdjTurb.hpp" - -CSourcePieceWise_AdjTurb::CSourcePieceWise_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - Velocity = new su2double [nDim]; - tau = new su2double* [nDim]; - for (unsigned short iDim = 0; iDim < nDim; iDim++) - tau[iDim] = new su2double [nDim]; -} - -CSourcePieceWise_AdjTurb::~CSourcePieceWise_AdjTurb(void) { - delete [] Velocity; - - for (unsigned short iDim = 0; iDim < nDim; iDim++) - delete [] tau[iDim]; - delete [] tau; -} - -void CSourcePieceWise_AdjTurb::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - unsigned short iDim, jDim; - - bool implicit = (config->GetKind_TimeIntScheme_AdjTurb() == EULER_IMPLICIT); - su2double Prandtl_Turb = config->GetPrandtl_Turb(); - - val_residual[0] = 0.0; - if (implicit) - val_Jacobian_i[0][0] = 0.0; - - if (dist_i > 0.0) { - - /*--- Computation of Vorticity and Divergence of velocity ---*/ - su2double div_vel = 0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity[iDim] = U_i[iDim+1]/U_i[0]; - div_vel += PrimVar_Grad_i[iDim+1][iDim]; - } - - su2double Vorticity = (PrimVar_Grad_i[2][0]-PrimVar_Grad_i[1][1])*(PrimVar_Grad_i[2][0]-PrimVar_Grad_i[1][1]); - if (nDim == 3) - Vorticity += ( (PrimVar_Grad_i[3][1]-PrimVar_Grad_i[2][2])*(PrimVar_Grad_i[3][1]-PrimVar_Grad_i[2][2]) + - (PrimVar_Grad_i[1][2]-PrimVar_Grad_i[3][0])*(PrimVar_Grad_i[1][2]-PrimVar_Grad_i[3][0]) ); - Vorticity = sqrt(Vorticity); - - /*--- FIRST PART: -Bs*TurbPsi_i ---*/ - /*--- CLOUSURE CONSTANTS ---*/ - su2double cv1 = 7.1; - su2double cv1_3 = cv1*cv1*cv1; - su2double k = 0.41; - su2double k2 = k*k; - su2double cb1 = 0.1355; - su2double cw2 = 0.3; - su2double cw3_6 = pow(2.0,6.0); - su2double sigma = 2./3.; - su2double cb2 = 0.622; - su2double cw1 = cb1/k2+(1+cb2)/sigma; - - su2double nu, Ji, fv1, fv2, Shat, dist_0_2, Ji_2, Ji_3, one_o_oneplusJifv1; - su2double r, g, g_6, glim, fw; - su2double dTs_nuhat, dTs_Shat, dShat_nuhat, dTs_fw, dfw_g, dg_r, dr_nuhat, dr_Shat; - su2double dShat_fv2, dfv2_fv1, dfv1_Ji, dJi_nuhat, dfv2_Ji; - su2double Bs; - - dist_0_2 = dist_i*dist_i; - nu = Laminar_Viscosity_i/U_i[0]; - Ji = TurbVar_i[0]/nu; - Ji_2 = Ji*Ji; - Ji_3 = Ji_2*Ji; - fv1 = Ji_3/(Ji_3+cv1_3); - one_o_oneplusJifv1 = 1.0/(1.0+Ji*fv1); - fv2 = 1.0 - Ji*one_o_oneplusJifv1; - Shat = max(Vorticity + TurbVar_i[0]*fv2/(k2*dist_0_2), TURB_EPS); - - // r = TurbVar_i[0]/(Shat*k2*dist_0_2); - r = min(TurbVar_i[0]/(Shat*k2*dist_0_2),10.); - g = r + cw2*(pow(r,6.)-r); - g_6 = pow(g,6.); - glim = pow((1+cw3_6)/(g_6+cw3_6),1./6.); - fw = g*glim; - - dTs_nuhat = cb1*Shat-2.0*cw1*fw*TurbVar_i[0]/dist_0_2; - dTs_Shat = cb1*TurbVar_i[0]; - dTs_fw = -cw1*TurbVar_i[0]*TurbVar_i[0]/dist_0_2; - dfw_g = glim*cw3_6/(g_6+cw3_6); - dg_r = 1.0 + cw2*(6.0*pow(r,5.0)-1.0); - dr_nuhat = 1.0/(Shat*k2*dist_0_2); - dr_Shat = -dr_nuhat*TurbVar_i[0]/Shat; - - dShat_nuhat = fv2/(k2*dist_0_2); - dShat_fv2 = TurbVar_i[0]/(k2*dist_0_2); - dfv2_fv1 = Ji_2*one_o_oneplusJifv1*one_o_oneplusJifv1; - dfv1_Ji = 3.0*cv1_3*Ji_2/((Ji_3+cv1_3)*(Ji_3+cv1_3)); - dJi_nuhat = 1.0/nu; - dfv2_Ji = -one_o_oneplusJifv1*one_o_oneplusJifv1; - dShat_nuhat += dShat_fv2*(dfv2_fv1*dfv1_Ji+dfv2_Ji)*dJi_nuhat; - - Bs = dTs_nuhat; // nu_hat term - Bs += dTs_Shat*dShat_nuhat; // S_hat term - Bs += dTs_fw*dfw_g*dg_r*(dr_nuhat+dr_Shat*dShat_nuhat); // fw terms - - val_residual[0] = -Bs*TurbPsi_i[0]*Volume; - - if (implicit) - val_Jacobian_i[0][0] = -Bs*Volume; - - /*---SECOND PART: \partial_nu_hat mu^k F^{vk} cdot \grad Psi ---*/ - su2double dEddyVisc_nuhat; - if (!config->GetFrozen_Visc_Cont()) - dEddyVisc_nuhat = U_i[0]*fv1*(1.0 + 3.0*cv1_3/(Ji_3+cv1_3)); - else - dEddyVisc_nuhat = 0; - - for (iDim = 0; iDim < nDim; iDim++) { - for (jDim = 0; jDim < nDim; jDim++) - tau[iDim][jDim] = PrimVar_Grad_i[iDim+1][jDim] + PrimVar_Grad_i[jDim+1][iDim]; - tau[iDim][iDim] -= TWO3*div_vel; - } - - su2double Gas_Constant = config->GetGas_ConstantND(); - su2double Cp = (Gamma/Gamma_Minus_One)*Gas_Constant; - su2double tau_gradphi = 0.0, vel_tau_gradpsi5 = 0.0, gradT_gradpsi5 = 0.0; - - for (iDim = 0; iDim < nDim; iDim++) { - gradT_gradpsi5 += PrimVar_Grad_i[0][iDim]*PsiVar_Grad_i[nVar-1][iDim]; - for (jDim = 0; jDim < nDim; jDim++) { - tau_gradphi += tau[iDim][jDim]*PsiVar_Grad_i[iDim+1][jDim]; - vel_tau_gradpsi5 += Velocity[iDim]*tau[iDim][jDim]*PsiVar_Grad_i[nVar-1][jDim]; - } - } - val_residual[0] += (tau_gradphi + vel_tau_gradpsi5 + Cp/Prandtl_Turb*gradT_gradpsi5)*dEddyVisc_nuhat*Volume; - - } -} diff --git a/SU2_CFD/src/numerics/continuous_adjoint/CSourceRotatingFrame_AdjFlow.cpp b/SU2_CFD/src/numerics/continuous_adjoint/CSourceRotatingFrame_AdjFlow.cpp deleted file mode 100644 index f893f72b4ce4..000000000000 --- a/SU2_CFD/src/numerics/continuous_adjoint/CSourceRotatingFrame_AdjFlow.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/*! - * \file CSourceRotatingFrame_AdjFlow.cpp - * \brief Implementation of numerics class CSourceRotatingFrame_AdjFlow. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../include/numerics/continuous_adjoint/CSourceRotatingFrame_AdjFlow.hpp" - -CSourceRotatingFrame_AdjFlow::CSourceRotatingFrame_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { } - -CSourceRotatingFrame_AdjFlow::~CSourceRotatingFrame_AdjFlow(void) { } - -void CSourceRotatingFrame_AdjFlow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config) { - - unsigned short iDim, iVar, jVar; - su2double Omega[3] = {0,0,0}, Phi[3] = {0,0,0}; - bool implicit = (config->GetKind_TimeIntScheme_AdjFlow() == EULER_IMPLICIT); - - /*--- Retrieve the angular velocity vector from config. ---*/ - - for (iDim = 0; iDim < 3; iDim++){ - Omega[iDim] = config->GetRotation_Rate(iDim)/config->GetOmega_Ref(); - } - - /*--- Get the adjoint velocity vector at the current node. ---*/ - - for (iDim = 0; iDim < nDim; iDim++) - Phi[iDim] = Psi_i[iDim+1]; - - /*--- Compute the source term as the Jacobian of the rotating frame - source term multiplied by the adjoint state and the dual cell volume. ---*/ - - if (nDim == 2) { - val_residual[0] = 0.0; - val_residual[1] = Omega[2]*Phi[1]*Volume; - val_residual[2] = -Omega[2]*Phi[0]*Volume; - val_residual[3] = 0.0; - } else { - val_residual[0] = 0.0; - val_residual[1] = (Omega[2]*Phi[1] - Omega[1]*Phi[2])*Volume; - val_residual[2] = (Omega[0]*Phi[2] - Omega[2]*Phi[0])*Volume; - val_residual[3] = (Omega[1]*Phi[0] - Omega[0]*Phi[1])*Volume; - val_residual[4] = 0.0; - } - - /*--- Calculate the source term Jacobian ---*/ - - if (implicit) { - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_i[iVar][jVar] = 0.0; - if (nDim == 2) { - val_Jacobian_i[1][2] = Omega[2]*Volume; - val_Jacobian_i[2][1] = -Omega[2]*Volume; - } else { - val_Jacobian_i[1][2] = Omega[2]*Volume; - val_Jacobian_i[1][3] = -Omega[1]*Volume; - val_Jacobian_i[2][1] = -Omega[2]*Volume; - val_Jacobian_i[2][3] = Omega[0]*Volume; - val_Jacobian_i[3][1] = Omega[1]*Volume; - val_Jacobian_i[3][2] = -Omega[0]*Volume; - } - } - -} diff --git a/SU2_CFD/src/numerics/continuous_adjoint/CSourceViscous_AdjFlow.cpp b/SU2_CFD/src/numerics/continuous_adjoint/CSourceViscous_AdjFlow.cpp deleted file mode 100644 index f792a8d0450f..000000000000 --- a/SU2_CFD/src/numerics/continuous_adjoint/CSourceViscous_AdjFlow.cpp +++ /dev/null @@ -1,341 +0,0 @@ -/*! - * \file CSourceViscous_AdjFlow.cpp - * \brief Implementation of numerics class CSourceViscous_AdjFlow. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../include/numerics/continuous_adjoint/CSourceViscous_AdjFlow.hpp" - -CSourceViscous_AdjFlow::CSourceViscous_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - unsigned short iDim; - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - Velocity = new su2double [nVar]; - GradDensity = new su2double [nDim]; - GradInvDensity = new su2double [nDim]; - dPoDensity2 = new su2double [nDim]; - alpha = new su2double [nDim]; - beta = new su2double [nDim]; - Sigma_5_vec = new su2double [nDim]; - - GradVel_o_Rho = new su2double* [nDim]; - sigma = new su2double* [nDim]; - Sigma_phi = new su2double* [nDim]; - Sigma_5_Tensor = new su2double* [nDim]; - Sigma = new su2double* [nDim]; - - for (iDim = 0; iDim < nDim; iDim++) { - GradVel_o_Rho[iDim] = new su2double [nDim]; - sigma[iDim] = new su2double [nDim]; - Sigma_phi[iDim] = new su2double [nDim]; - Sigma_5_Tensor[iDim] = new su2double [nDim]; - Sigma[iDim] = new su2double [nDim]; - } - -} - -CSourceViscous_AdjFlow::~CSourceViscous_AdjFlow(void) { - unsigned short iDim; - - for (iDim = 0; iDim < nDim; iDim++) { - delete [] GradVel_o_Rho[iDim]; - delete [] sigma[iDim]; - delete [] Sigma_phi[iDim]; - delete [] Sigma_5_Tensor[iDim]; - delete [] Sigma[iDim]; - } - - delete [] GradVel_o_Rho; - delete [] sigma; - delete [] Sigma_phi; - delete [] Sigma_5_Tensor; - delete [] Sigma; - - delete [] Velocity; - delete [] GradDensity; - delete [] GradInvDensity; - delete [] dPoDensity2; - delete [] alpha; - delete [] beta; - delete [] Sigma_5_vec; - -} - -void CSourceViscous_AdjFlow::ComputeResidual (su2double *val_residual, CConfig *config) { - - unsigned short iDim, jDim; - -// su2double Temperature = V_i[0]; - su2double Pressure = V_i[nDim+1]; - su2double Density = V_i[nDim+2]; -// su2double Enthalpy = V_i[nDim+3]; - su2double Laminar_Viscosity = V_i[nDim+5]; - su2double Eddy_Viscosity = V_i[nDim+6]; - -// su2double Energy = Enthalpy - Pressure/Density; - su2double invDensity = 1.0/Density; - su2double invDensitysq = invDensity*invDensity; - su2double invDensitycube = invDensitysq*invDensity; - su2double Prandtl_Lam = config->GetPrandtl_Lam(); - su2double Prandtl_Turb = config->GetPrandtl_Turb(); - su2double mu_tot_1 = Laminar_Viscosity + Eddy_Viscosity; - su2double mu_tot_2 = Laminar_Viscosity/Prandtl_Lam + Eddy_Viscosity/Prandtl_Turb; -// su2double Gas_Constant = config->GetGas_ConstantND(); - - /*--- Required gradients of the flow variables, point j ---*/ - - for (iDim = 0; iDim < nDim; iDim++) { - - /*--- Gradient density ---*/ - - GradDensity[iDim] = PrimVar_Grad_i[nDim+2][iDim]; - - /*--- Gradient (1/rho) ---*/ - - GradInvDensity[iDim] = -GradDensity[iDim]*invDensitysq; - - /*--- Computation of the derivatives of P/(Density^2) ---*/ - - dPoDensity2[iDim] = (PrimVar_Grad_i[nVar-1][iDim]*Density - 2.0*GradDensity[iDim]*Pressure)*invDensitycube; - - /*--- Abbreviations: alpha, beta, sigma_5_vec ---*/ - - alpha[iDim] = Gamma*mu_tot_2*GradInvDensity[iDim]; - beta[iDim] = Gamma*mu_tot_2*dPoDensity2[iDim]/Gamma_Minus_One; - Sigma_5_vec[iDim] = Gamma*mu_tot_2*PsiVar_Grad_i[nVar-1][iDim]; - - } - - /*--- Definition of tensors and derivatives of velocity over density ---*/ - - su2double div_vel = 0.0, div_phi = 0.0, vel_gradpsi5 = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - div_vel += PrimVar_Grad_i[iDim+1][iDim]; - div_phi += PsiVar_Grad_i[iDim+1][iDim]; - vel_gradpsi5 += V_i[iDim+1]*PsiVar_Grad_i[nVar-1][iDim]; - for (jDim = 0; jDim < nDim; jDim++) { - sigma[iDim][jDim] = mu_tot_1*(PrimVar_Grad_i[iDim+1][jDim]+PrimVar_Grad_i[jDim+1][iDim]); - Sigma_phi[iDim][jDim] = mu_tot_1*(PsiVar_Grad_i[iDim+1][jDim]+PsiVar_Grad_i[jDim+1][iDim]); - Sigma_5_Tensor[iDim][jDim] = mu_tot_1*(V_i[jDim+1]*PsiVar_Grad_i[nVar-1][iDim]+V_i[iDim+1]*PsiVar_Grad_i[nVar-1][jDim]); - GradVel_o_Rho[iDim][jDim] = (PrimVar_Grad_i[iDim+1][jDim]*Density - V_i[iDim+1]*GradDensity[jDim])*invDensitysq; - } - } - - for (iDim = 0; iDim < nDim; iDim++) { - sigma[iDim][iDim] -= TWO3*mu_tot_1*div_vel; - Sigma_phi[iDim][iDim] -= TWO3*mu_tot_1*div_phi; - Sigma_5_Tensor[iDim][iDim] -= TWO3*mu_tot_1*vel_gradpsi5; - } - - for (iDim = 0; iDim < nDim; iDim++) { - for (jDim = 0; jDim < nDim; jDim++) { - Sigma[iDim][jDim] = Sigma_phi[iDim][jDim] + Sigma_5_Tensor[iDim][jDim]; - } - } - - /*--- Vector-Tensors products ---*/ - - su2double gradT_gradpsi5 = 0.0, sigma_gradpsi = 0.0, vel_sigma_gradpsi5 = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - gradT_gradpsi5 += PrimVar_Grad_i[0][iDim]*PsiVar_Grad_i[nVar-1][iDim]; - for (jDim = 0; jDim < nDim; jDim++) { - sigma_gradpsi += sigma[iDim][jDim]*PsiVar_Grad_i[jDim+1][iDim]; - vel_sigma_gradpsi5 += V_i[iDim+1]*sigma[iDim][jDim]*PsiVar_Grad_i[nVar-1][jDim]; - } - } - - /*--- Residuals ---*/ - - su2double alpha_gradpsi5 = 0.0, beta_gradpsi5 = 0.0, Sigma_gradvel_o_rho = 0.0, Sigma5_vel_gradvel = 0.0, sq_vel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - alpha_gradpsi5 += alpha[iDim]*PsiVar_Grad_i[nVar-1][iDim]; - beta_gradpsi5 += beta[iDim]*PsiVar_Grad_i[nVar-1][iDim]; - for (jDim = 0; jDim < nDim; jDim++) { - Sigma_gradvel_o_rho += Sigma[iDim][jDim]*GradVel_o_Rho[iDim][jDim]; - Sigma5_vel_gradvel += Sigma_5_vec[iDim]*(V_i[jDim+1]*PrimVar_Grad_i[jDim+1][iDim]); - } - sq_vel += V_i[iDim+1]*V_i[iDim+1]; - } - - val_residual[0] = (-vel_sigma_gradpsi5*invDensity + 0.5*sq_vel*alpha_gradpsi5 - - beta_gradpsi5) * Volume; - for (iDim = 0; iDim < nDim; iDim++) { - val_residual[iDim+1] = 0.0; - for (jDim = 0; jDim < nDim; jDim++) { - val_residual[iDim+1] += (sigma[iDim][jDim]*PsiVar_Grad_i[nVar-1][jDim]*invDensity - V_i[iDim+1]*alpha[jDim]*PsiVar_Grad_i[nVar-1][jDim]) * Volume; - } - } - val_residual[nVar-1] = alpha_gradpsi5 * Volume; - -// val_residual[0] += (Sigma5_vel_gradvel*invDensity - Sigma_gradvel_o_rho) * Volume; -// for (iDim = 0; iDim < nDim; iDim++) { -// for (jDim = 0; jDim < nDim; jDim++) { -// val_residual[iDim+1] += (Sigma[iDim][jDim]*GradInvDensity[jDim] - -// Sigma_5_vec[jDim]*PrimVar_Grad_i[iDim+1][jDim]*invDensity) * Volume; -// } -// } - - /*--- Laminar viscosity sensitivity for NS ---*/ - - if (config->GetKind_Solver() != ADJ_RANS) { - -// su2double Temperature_Ref = config->GetTemperature_Ref(); -// su2double Temperature_Dim = Temperature*Temperature_Ref; -// -// su2double S = 0.0; -// if (config->GetSystemMeasurements() == SI) { S = 110.4; } -// if (config->GetSystemMeasurements() == US) { S = 198.72; } -// su2double dVisc_T = ((Laminar_Viscosity)/(2.0*Temperature_Dim*(Temperature_Dim + S)))*(Temperature_Dim + 3.0*S)*Temperature_Ref; -// -// su2double Cp = (Gamma/Gamma_Minus_One)*Gas_Constant; -// su2double kappa_psi = (sigma_gradpsi + vel_sigma_gradpsi5)/mu_tot_1; -// su2double theta = (kappa_psi + Cp/Prandtl_Lam*gradT_gradpsi5)*dVisc_T*Gamma_Minus_One/(Gas_Constant*Density); -// -// val_residual[0] += (theta*(sq_vel-Energy))*Volume; -// for (iDim = 0; iDim < nDim; iDim++) -// val_residual[iDim+1] -= theta*V_i[iDim+1]*Volume; -// val_residual[nVar-1] += theta*Volume; - - } - -// /*--- Coupling terms coming from the continuous adjoint turbulent equations ---*/ -// -// if ((config->GetKind_Solver() == ADJ_RANS) && (!config->GetFrozen_Visc_Cont())) { -// -// /*--- Closure constants ---*/ -// -// su2double cv1_3 = 7.1*7.1*7.1; -// su2double k2 = 0.41*0.41; -// su2double cb1 = 0.1355; -// su2double cw2 = 0.3; -// su2double cw3_6 = pow(2.0,6.0); -// su2double sigma = 2./3.; -// su2double cb2 = 0.622; -// su2double cw1 = cb1/k2+(1+cb2)/sigma; -// -// su2double nu, Ji, Ji_2, Ji_3, fv1; -// nu = Laminar_Viscosity/Density; -// Ji = TurbVar_i[0]/nu; -// Ji_2 = Ji*Ji; -// Ji_3 = Ji_2*Ji; -// fv1 = Ji_3/(Ji_3+cv1_3); -// -// /*--- Contributions due to variation of viscosities ---*/ -// -// su2double Temperature_Ref = config->GetTemperature_Ref(); -// su2double Temperature_Dim = Temperature*Temperature_Ref; -// -// su2double S = 0.0; -// if (config->GetSystemMeasurements() == SI) { S = 110.4; } -// if (config->GetSystemMeasurements() == US) { S = 198.72; } -// su2double dVisc_T = ((Laminar_Viscosity)/(2.0*Temperature_Dim*(Temperature_Dim + S)))*(Temperature_Dim + 3.0*S)*Temperature_Ref; -// -// su2double Cp = (Gamma/Gamma_Minus_One)*Gas_Constant; -// su2double kappa_psi = (sigma_gradpsi + vel_sigma_gradpsi5)/mu_tot_1 + Cp/Prandtl_Turb*gradT_gradpsi5; -// su2double cv1_const = 3.0*cv1_3/(Ji_3+cv1_3); -// su2double theta = (kappa_psi*(1.0-Eddy_Viscosity/Laminar_Viscosity*cv1_const) - -// Cp/Prandtl_Turb*gradT_gradpsi5*(1.0-Prandtl_Turb/Prandtl_Lam))*dVisc_T*Gamma_Minus_One/(Gas_Constant*Density); -// su2double xi = kappa_psi*(1.0+cv1_const)*Eddy_Viscosity/Density; -// -// val_residual[0] += (theta*(sq_vel-Energy) + xi)*Volume; -// for (iDim = 0; iDim < nDim; iDim++) -// val_residual[iDim+1] -= theta*V_i[iDim+1]*Volume; -// val_residual[nVar-1] += theta*Volume; -// -// /*--- Coupling residuals ---*/ -// -// if (dist_i > 0.0) { -// su2double fv2, Omega, Shat, dist_0_2, one_o_oneplusJifv1; -// su2double r, g, g_6, glim, fw; -// su2double dfw_g, dg_r, dr_nuhat, dr_Shat; -// su2double dShat_fv2, dfv2_fv1, dfv1_Ji, dJi_nu, dJi_nuhat, dfv2_Ji; -// -// /*--- Vorticity ---*/ -// Omega = (PrimVar_Grad_i[1][1]-PrimVar_Grad_i[2][0])*(PrimVar_Grad_i[1][1]-PrimVar_Grad_i[2][0]); -// if (nDim == 3) Omega += (PrimVar_Grad_i[1][2]-PrimVar_Grad_i[3][0])*(PrimVar_Grad_i[1][2]-PrimVar_Grad_i[3][0]) + -// (PrimVar_Grad_i[2][2]-PrimVar_Grad_i[3][1])*(PrimVar_Grad_i[2][2]-PrimVar_Grad_i[3][1]); -// Omega = sqrt(Omega); -// -// dist_0_2 = dist_i*dist_i; -// one_o_oneplusJifv1 = 1.0/(1.0+Ji*fv1); -// fv2 = 1.0 - Ji*one_o_oneplusJifv1; -// Shat = max(Omega + TurbVar_i[0]*fv2/(k2*dist_0_2), TURB_EPS); -// -// r = min(TurbVar_i[0]/(Shat*k2*dist_0_2), 10.); -// g = r + cw2*(pow(r,6.)-r); -// g_6 = pow(g,6.); -// glim = pow((1+cw3_6)/(g_6+cw3_6),1./6.); -// fw = g*glim; -// -// dfw_g = glim*cw3_6/(g_6+cw3_6); -// dg_r = 1.0 + cw2*(6.0*pow(r,5.0)-1.0); -// dr_nuhat = 1.0/(Shat*k2*dist_0_2); -// dr_Shat = -dr_nuhat*TurbVar_i[0]/Shat; -// -// dShat_fv2 = TurbVar_i[0]/(k2*dist_0_2); -// dfv2_fv1 = Ji_2*one_o_oneplusJifv1*one_o_oneplusJifv1; -// dfv1_Ji = 3.0*cv1_3*Ji_2/((Ji_3+cv1_3)*(Ji_3+cv1_3)); -// dJi_nuhat = 1.0/nu; -// dJi_nu = -Ji/nu; -// dfv2_Ji = -one_o_oneplusJifv1*one_o_oneplusJifv1; -// -// /*--- Terms 1 & 2: -Fcv\B7nabla(TurbPsi_i) - Fs\B7TurbPsi_i ---*/ -// -// su2double gradTurbVar_gradTurbPsi = 0, vel_gradTurbPsi = 0; -// for (iDim = 0; iDim < nDim; iDim++) { -// gradTurbVar_gradTurbPsi += TurbVar_Grad_i[0][iDim]*TurbPsi_Grad_i[0][iDim]; -// vel_gradTurbPsi += V_i[iDim+1]*TurbPsi_Grad_i[0][iDim]; -// } -// -// su2double alpha_coeff = Gamma_Minus_One/(Gas_Constant*Density)*dVisc_T; -// su2double beta_coeff = alpha_coeff*(sq_vel-Energy)-Laminar_Viscosity_i/Density; -// su2double Fs_coeff = TurbPsi_i[0]*(cb1*TurbVar_i[0]-cw1*TurbVar_i[0]*TurbVar_i[0]/dist_0_2*dfw_g*dg_r*dr_Shat)* -// dShat_fv2*(dfv2_Ji+dfv2_fv1*dfv1_Ji)*dJi_nu; -// su2double Gamma = Fs_coeff - gradTurbVar_gradTurbPsi/sigma; -// -// val_residual[0] -= (Gamma*beta_coeff - TurbVar_i[0]*vel_gradTurbPsi)/Density*Volume; -// for (iDim = 0; iDim < nDim; iDim++) -// val_residual[iDim+1] += (Gamma*alpha_coeff*V_i[iDim+1] - TurbVar_i[0]*TurbPsi_Grad_i[0][iDim])/Density*Volume; -// val_residual[nVar-1] -= (Gamma*alpha_coeff)/Density*Volume; -// -// // this should improve stability (when commented): -// /*--- Terms 3: -partial{T^s}_GradVel x GradN ---*/ -// // su2double Ms_coeff = (cb1*TurbVar_i[0]-cw1*TurbVar_i[0]*TurbVar_i[0]/dist_0_2*dfw_g*dg_r*dr_Shat); -// // Ms_coeff *= TurbPsi_i[0]/(Omega + TURB_EPS); -// // -// // for (iDim = 0; iDim < nDim; iDim++) { -// // for (jDim = 0; jDim < nDim; jDim++) { -// // val_residual[0] += Ms_coeff*(PrimVar_Grad_i[iDim+1][jDim]-PrimVar_Grad_i[jDim+1][iDim])* -// // GradVel_o_Rho[iDim][jDim]*dV; -// // val_residual[iDim+1] -= Ms_coeff*(PrimVar_Grad_i[iDim+1][jDim]-PrimVar_Grad_i[jDim+1][iDim])* -// // GradInvDensity[jDim]*dV; -// // } -// // } -// -// } -// } - -} diff --git a/SU2_CFD/src/numerics/continuous_adjoint/CUpwLin_AdjTurb.cpp b/SU2_CFD/src/numerics/continuous_adjoint/CUpwLin_AdjTurb.cpp deleted file mode 100644 index 30336106d98e..000000000000 --- a/SU2_CFD/src/numerics/continuous_adjoint/CUpwLin_AdjTurb.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/*! - * \file CUpwLin_AdjTurb.cpp - * \brief Implementation of numerics class CUpwLin_AdjTurb. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../include/numerics/continuous_adjoint/CUpwLin_AdjTurb.hpp" - -CUpwLin_AdjTurb::CUpwLin_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - Velocity_i = new su2double [nDim]; -} - -CUpwLin_AdjTurb::~CUpwLin_AdjTurb(void) { - delete [] Velocity_i; -} - -void CUpwLin_AdjTurb::ComputeResidual (su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - bool implicit = (config->GetKind_TimeIntScheme_AdjTurb() == EULER_IMPLICIT); - - /*--- Non-conservative term --> -\nabla \psi_\mu B^{cv} - B^{cv} = -v ---*/ - - unsigned short iDim; - su2double proj_conv_flux = 0; - - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = U_i[iDim+1]/U_i[0]; - proj_conv_flux += Velocity_i[iDim]*Normal[iDim]; // projection of convective flux at iPoint - } - su2double psinu0 = TurbPsi_i[0]; - su2double psinu1; - if (proj_conv_flux > 0) - psinu1 = psinu0 + proj_conv_flux; - else - psinu1 = psinu0; - - val_residual[0] = 0.5*( proj_conv_flux*(psinu0+psinu1)-fabs(proj_conv_flux)*(psinu1-psinu0)); - if (implicit) { - val_Jacobian_i[0][0] = 0.5*( proj_conv_flux + fabs(proj_conv_flux)); - } -} diff --git a/SU2_CFD/src/numerics/continuous_adjoint/CUpwRoe_AdjFlow.cpp b/SU2_CFD/src/numerics/continuous_adjoint/CUpwRoe_AdjFlow.cpp deleted file mode 100644 index 89e1690b3e39..000000000000 --- a/SU2_CFD/src/numerics/continuous_adjoint/CUpwRoe_AdjFlow.cpp +++ /dev/null @@ -1,334 +0,0 @@ -/*! - * \file CUpwRoe_AdjFlow.cpp - * \brief Implementation of numerics class CUpwRoe_AdjFlow. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../include/numerics/continuous_adjoint/CUpwRoe_AdjFlow.hpp" - -CUpwRoe_AdjFlow::CUpwRoe_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_AdjFlow() == EULER_IMPLICIT); - grid_movement = config->GetGrid_Movement(); - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - Residual_Roe = new su2double [nVar]; - RoeVelocity = new su2double [nDim]; - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; - Lambda = new su2double [nVar]; - P_Tensor = new su2double* [nVar]; - invP_Tensor = new su2double* [nVar]; - ProjFlux_i = new su2double*[nVar]; - ProjFlux_j = new su2double*[nVar]; - Proj_ModJac_Tensor = new su2double*[nVar]; - for (iVar = 0; iVar < nVar; iVar++) { - P_Tensor[iVar] = new su2double [nVar]; - invP_Tensor[iVar] = new su2double [nVar]; - ProjFlux_i[iVar] = new su2double[nVar]; - ProjFlux_j[iVar] = new su2double[nVar]; - Proj_ModJac_Tensor[iVar] = new su2double[nVar]; - } - -} - -CUpwRoe_AdjFlow::~CUpwRoe_AdjFlow(void) { - - delete [] Residual_Roe; - delete [] RoeVelocity; - delete [] Velocity_i; - delete [] Velocity_j; - delete [] Lambda; - for (iVar = 0; iVar < nVar; iVar++) { - delete [] P_Tensor[iVar]; - delete [] invP_Tensor[iVar]; - delete [] ProjFlux_i[iVar]; - delete [] ProjFlux_j[iVar]; - delete [] Proj_ModJac_Tensor[iVar]; - } - delete [] P_Tensor; - delete [] invP_Tensor; - delete [] ProjFlux_i; - delete [] ProjFlux_j; - delete [] Proj_ModJac_Tensor; - -} - -void CUpwRoe_AdjFlow::ComputeResidual (su2double *val_residual_i, su2double *val_residual_j, su2double **val_Jacobian_ii, - su2double **val_Jacobian_ij, su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config) { - - /*--- Compute the area ---*/ - - area = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - area += Normal[iDim]*Normal[iDim]; - area = sqrt(area); - rarea = 1.0 / area; - - /*--- Components of the normal & unit normal vector of the current face ---*/ - - Sx = Normal[0]; - Sy = Normal[1]; - Sz = 0.0; if (nDim == 3) Sz = Normal[2]; - nx = Sx * rarea; - ny = Sy * rarea; - nz = Sz * rarea; - - /*--- Flow variable states at point i (left, _l) and j (right, _r)---*/ - - rho_l = V_i[nDim+2]; rho_r = V_j[nDim+2]; - u_l = V_i[1]; v_l = V_i[2]; w_l = 0.0; if (nDim == 3) w_l = V_i[3]; - u_r = V_j[1]; v_r = V_j[2]; w_r = 0.0; if (nDim == 3) w_r = V_j[3]; - h_l = V_i[nDim+3]; h_r = V_j[nDim+3]; - - /*--- One-half speed squared ---*/ - - q_l = ONE2 * ((u_l*u_l) + (v_l*v_l) + (w_l*w_l)); - q_r = ONE2 * ((u_r*u_r) + (v_r*v_r) + (w_r*w_r)); - - /*--- Projected velocity ---*/ - - Q_l = (u_l * Sx) + (v_l * Sy) + (w_l * Sz); - Q_r = (u_r * Sx) + (v_r * Sy) + (w_r * Sz); - - /*--- Mean adjoint variables ---*/ - - psi1 = ONE2 * (Psi_i[0] + Psi_j[0]); - psi2 = ONE2 * (Psi_i[1] + Psi_j[1]); - psi3 = ONE2 * (Psi_i[2] + Psi_j[2]); - psi4 = 0.0; if (nDim == 3) psi4 = ONE2 * (Psi_i[3] + Psi_j[3]); - psi5 = ONE2 * (Psi_i[nVar-1] + Psi_j[nVar-1]); - - /*--- Left state ---*/ - - l1psi = (Sx * psi2) + (Sy * psi3) + (Sz * psi4) + (Q_l * psi5); - l2psi = psi1 + (u_l * psi2) + (v_l * psi3) + (w_l * psi4) + (h_l * psi5); - - val_residual_i[0] = Q_l * psi1 - l2psi * Q_l + l1psi * Gamma_Minus_One * q_l; - val_residual_i[1] = Q_l * psi2 + l2psi * Sx - l1psi * Gamma_Minus_One * u_l; - val_residual_i[2] = Q_l * psi3 + l2psi * Sy - l1psi * Gamma_Minus_One * v_l; - if (nDim == 3) val_residual_i[3] = Q_l * psi4 + l2psi * Sz - l1psi * Gamma_Minus_One * w_l; - val_residual_i[nVar-1] = Q_l * psi5 + l1psi * Gamma_Minus_One; - - /*--- Right state ---*/ - - l1psi = (Sx * psi2) + (Sy * psi3) + (Sz * psi4) + (Q_r * psi5); - l2psi = psi1 + (u_r * psi2) + (v_r * psi3) + (w_r * psi4) + (h_r * psi5); - - val_residual_j[0] = -(Q_r * psi1 - l2psi * Q_r + l1psi * Gamma_Minus_One * q_r); - val_residual_j[1] = -(Q_r * psi2 + l2psi * Sx - l1psi * Gamma_Minus_One * u_r); - val_residual_j[2] = -(Q_r * psi3 + l2psi * Sy - l1psi * Gamma_Minus_One * v_r); - if (nDim == 3) val_residual_j[3] = -(Q_r * psi4 + l2psi * Sz - l1psi * Gamma_Minus_One * w_r); - val_residual_j[nVar-1] = -(Q_r * psi5 + l1psi * Gamma_Minus_One); - - - /*--- f_{roe} = P^{-T} |lambda| P^T \delta \psi ---*/ - - psi1_l = Psi_i[0]; - psi2_l = Psi_i[1]; - psi3_l = Psi_i[2]; - psi4_l = 0.0; if (nDim == 3) psi4_l = Psi_i[3]; - psi5_l = Psi_i[nVar-1]; - - psi1_r = Psi_j[0]; - psi2_r = Psi_j[1]; - psi3_r = Psi_j[2]; - psi4_r = 0.0; if (nDim == 3) psi4_r = Psi_j[3]; - psi5_r = Psi_j[nVar-1]; - - /*--- Roe averaging ---*/ - - rrho_l = 1.0 / rho_l; - weight = sqrt(rho_r * rrho_l); - rweight1 = 1.0 / (1.0 + weight); - weight *= rweight1; - - h = h_l * rweight1 + weight * h_r; - u = u_l * rweight1 + weight * u_r; - v = v_l * rweight1 + weight * v_r; - w = w_l * rweight1 + weight * w_r; - - psi1 = ONE2 * (psi1_r - psi1_l); - psi2 = ONE2 * (psi2_r - psi2_l); - psi3 = ONE2 * (psi3_r - psi3_l); - psi4 = ONE2 * (psi4_r - psi4_l); - psi5 = ONE2 * (psi5_r - psi5_l); - - q2 = (u*u) + (v*v) + (w*w); - Q = (u * Sx) + (v * Sy) + (w * Sz); - vn = nx * u + ny * v + nz * w; - cc = Gamma_Minus_One * h - 0.5 * Gamma_Minus_One * q2; - c = sqrt(cc); - - /*--- Contribution to velocity projection due to grid movement ---*/ - - if (grid_movement) { - su2double ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - Q -= ProjGridVel; - } - - /*--- Eigenvalues from the primal solution ---*/ - - absQ = fabs(Q); - absQp = fabs(Q + c * area); - absQm = fabs(Q - c * area); - - alpha = ONE2 * Gamma_Minus_One * q2 / cc; - beta_u = psi2 + u * psi5; - beta_v = psi3 + v * psi5; - beta_w = psi4 + w * psi5; - eta = Gamma_Minus_One / cc; - l1psi = (nx * psi2) + (ny * psi3) + (nz * psi4) + (vn * psi5); - l2psi = psi1 + (u * psi2) + (v * psi3) + (w * psi4) + (h * psi5); - l1l2p = (l2psi + c * l1psi) * absQp; - l1l2m = (l2psi - c * l1psi) * absQm; - - /*--- adjoint flux computation in the x, y and z coordinate system ---*/ - - Residual_Roe[0] = ((1.0-alpha)*l2psi - (1.0-alpha)*cc/Gamma_Minus_One*psi5 - - u*beta_u*(1.0-(nx*nx)) - v*beta_v*(1.0-(ny*ny)) - - w*beta_w*(1.0-(nz*nz)) + ny*nz*(w*beta_v + v*beta_w) - + nx*nz*(w*beta_u + u*beta_w) + ny*nx*(v*beta_u + u*beta_v) ) * absQ - - ONE2 / c * vn * (l1l2p - l1l2m) + ONE2 * alpha * (l1l2p + l1l2m); - - Residual_Roe[1] = (l2psi*u*eta - u*psi5 + beta_u*(1.0-(nx*nx)) - - nx*(beta_v*ny + beta_w*nz) ) * absQ + ONE2*nx/c * (l1l2p - l1l2m ) - - ONE2*eta*u * (l1l2p + l1l2m ); - - Residual_Roe[2] = (l2psi*v*eta - v*psi5 + beta_v*(1.0-(ny*ny)) - - ny*(beta_w*nz + beta_u*nx) ) * absQ + ONE2*ny/c * (l1l2p - l1l2m ) - - ONE2*eta*v * (l1l2p + l1l2m ); - - if (nDim == 3) Residual_Roe[3] = (l2psi*w*eta - w*psi5 + beta_w*(1.0-(nz*nz)) - nz*(beta_u*nx + beta_v*ny) ) * absQ - + ONE2*nz/c * (l1l2p - l1l2m ) - ONE2*eta*w * (l1l2p + l1l2m ); - - Residual_Roe[nVar-1] = (psi5 - l2psi*eta) * absQ + ONE2*eta*(l1l2p + l1l2m); - - for (iVar = 0; iVar < nVar; iVar++) { - val_residual_i[iVar] += Residual_Roe[iVar]; - val_residual_j[iVar] -= Residual_Roe[iVar]; - } - - /*--- Flux contribution due to grid movement ---*/ - - if (grid_movement) { - su2double ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - for (iVar = 0; iVar < nVar; iVar++) { - val_residual_i[iVar] -= ProjGridVel * 0.5*(Psi_i[iVar]+Psi_j[iVar]); - val_residual_j[iVar] += ProjGridVel * 0.5*(Psi_i[iVar]+Psi_j[iVar]); - } - } - - /*--- Implicit Contributions ---*/ - - if (implicit) { - - /*--- Prepare variables for use in matrix routines ---*/ - - RoeDensity = V_i[nDim+2]*sqrt(V_j[nDim+2]/V_i[nDim+2]); - RoeSoundSpeed = c; - UnitNormal[0] = nx; UnitNormal[1] = ny; if (nDim == 3 ) UnitNormal[2] = nz; - RoeVelocity[0] = u; RoeVelocity[1] = v; if (nDim == 3 ) RoeVelocity[2] = w; - Velocity_i[0] = u_l; Velocity_i[1] = v_l; if (nDim == 3 ) Velocity_i[2] = w_l; - Velocity_j[0] = u_r; Velocity_j[1] = v_r; if (nDim == 3 ) Velocity_j[2] = w_r; - - Pressure_i = V_i[nDim+1]; - Density_i = V_i[nDim+2]; - Enthalpy_i = V_i[nDim+3]; - Energy_i = Enthalpy_i - Pressure_i/Density_i; - - Pressure_j = V_i[nDim+1]; - Density_j = V_i[nDim+2]; - Enthalpy_j = V_i[nDim+3]; - Energy_j = Enthalpy_j - Pressure_j/Density_j; - - /*--- Jacobians of the inviscid flux, scaled by - 0.5 because val_resconv ~ 0.5*(fc_i+fc_j)*Normal ---*/ - - GetInviscidProjJac(Velocity_i, &Energy_i, Normal, 0.5, ProjFlux_i); - GetInviscidProjJac(Velocity_j, &Energy_j, Normal, 0.5, ProjFlux_j); - - /*--- Compute P, inverse P, and store eigenvalues ---*/ - - GetPMatrix_inv(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, invP_Tensor); - GetPMatrix(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, P_Tensor); - - /*--- Flow eigenvalues ---*/ - - for (iDim = 0; iDim < nDim; iDim++) - Lambda[iDim] = absQ; - Lambda[nVar-2] = absQp; - Lambda[nVar-1] = absQm; - - /*--- Roe's Flux approximation ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - Proj_ModJac_Tensor_ij = 0.0; - - /*--- Compute |Proj_ModJac_Tensor| = P x |Lambda| x inverse P ---*/ - - for (kVar = 0; kVar < nVar; kVar++) - Proj_ModJac_Tensor_ij += P_Tensor[iVar][kVar]*Lambda[kVar]*invP_Tensor[kVar][jVar]; - Proj_ModJac_Tensor[iVar][jVar] = 0.5*Proj_ModJac_Tensor_ij*area; - } - } - - /*--- Transpose the matrices and store the Jacobians. Note the negative - sign for the ji and jj Jacobians bc the normal direction is flipped. ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - val_Jacobian_ii[jVar][iVar] = ProjFlux_i[iVar][jVar] - Proj_ModJac_Tensor[iVar][jVar]; - val_Jacobian_ij[jVar][iVar] = ProjFlux_i[iVar][jVar] + Proj_ModJac_Tensor[iVar][jVar]; - val_Jacobian_ji[jVar][iVar] = -(ProjFlux_j[iVar][jVar] - Proj_ModJac_Tensor[iVar][jVar]); - val_Jacobian_jj[jVar][iVar] = -(ProjFlux_j[iVar][jVar] + Proj_ModJac_Tensor[iVar][jVar]); - } - } - - /*--- Jacobian contribution due to grid movement ---*/ - - if (grid_movement) { - su2double ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - for (iVar = 0; iVar < nVar; iVar++) { - - /*--- Adjust Jacobian main diagonal ---*/ - - val_Jacobian_ii[iVar][iVar] -= 0.5*ProjGridVel; - val_Jacobian_ij[iVar][iVar] -= 0.5*ProjGridVel; - val_Jacobian_ji[iVar][iVar] += 0.5*ProjGridVel; - val_Jacobian_jj[iVar][iVar] += 0.5*ProjGridVel; - } - } - - } -} diff --git a/SU2_CFD/src/numerics/continuous_adjoint/CUpwSca_AdjTurb.cpp b/SU2_CFD/src/numerics/continuous_adjoint/CUpwSca_AdjTurb.cpp deleted file mode 100644 index 40d70c9a9c26..000000000000 --- a/SU2_CFD/src/numerics/continuous_adjoint/CUpwSca_AdjTurb.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/*! - * \file CUpwSca_AdjTurb.cpp - * \brief Implementation of numerics class CUpwSca_AdjTurb. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../include/numerics/continuous_adjoint/CUpwSca_AdjTurb.hpp" - -CUpwSca_AdjTurb::CUpwSca_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; -} - -CUpwSca_AdjTurb::~CUpwSca_AdjTurb(void) { - delete [] Velocity_i; - delete [] Velocity_j; -} - -void CUpwSca_AdjTurb::ComputeResidual (su2double *val_residual_i, su2double *val_residual_j, - su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, - su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config) { - - bool implicit = (config->GetKind_TimeIntScheme_AdjTurb() == EULER_IMPLICIT); - - /*--- Non-conservative term --> -\nabla \psi_\mu B^{cv} - B^{cv} = -\nabla \hat{nu}/\sigma + v ---*/ - - unsigned short iDim; - su2double proj_conv_flux_i = 0, proj_conv_flux_j = 0, proj_conv_flux_ij = 0; - su2double sigma = 2./3.; - - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = U_i[iDim+1]/U_i[0]; - Velocity_j[iDim] = U_j[iDim+1]/U_j[0]; - proj_conv_flux_i += (TurbVar_Grad_i[0][iDim]/sigma - Velocity_i[iDim])*Normal[iDim]; // projection of convective flux at iPoint - proj_conv_flux_j += (TurbVar_Grad_j[0][iDim]/sigma - Velocity_j[iDim])*Normal[iDim]; // projection of convective flux at jPoint - } - proj_conv_flux_ij = 0.5*fabs(proj_conv_flux_i+proj_conv_flux_j); // projection of average convective flux - - val_residual_i[0] = 0.5*( proj_conv_flux_i*(TurbPsi_i[0]+TurbPsi_j[0])-proj_conv_flux_ij*(TurbPsi_j[0]-TurbPsi_i[0])); - val_residual_j[0] = 0.5*(-proj_conv_flux_j*(TurbPsi_j[0]+TurbPsi_i[0])-proj_conv_flux_ij*(TurbPsi_i[0]-TurbPsi_j[0])); - if (implicit) { - val_Jacobian_ii[0][0] = 0.5*( proj_conv_flux_i+proj_conv_flux_ij); - val_Jacobian_ij[0][0] = 0.5*( proj_conv_flux_i-proj_conv_flux_ij); - val_Jacobian_ji[0][0] = 0.5*(-proj_conv_flux_j-proj_conv_flux_ij); - val_Jacobian_jj[0][0] = 0.5*(-proj_conv_flux_j+proj_conv_flux_ij); - } - -} diff --git a/SU2_CFD/src/numerics/continuous_adjoint/adj_convection.cpp b/SU2_CFD/src/numerics/continuous_adjoint/adj_convection.cpp new file mode 100644 index 000000000000..b1318c3f8614 --- /dev/null +++ b/SU2_CFD/src/numerics/continuous_adjoint/adj_convection.cpp @@ -0,0 +1,846 @@ +/*! + * \file adj_convection.cpp + * \brief Implementation of adjoint convection numerics classes. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../include/numerics/continuous_adjoint/adj_convection.hpp" + +CCentLax_AdjFlow::CCentLax_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + + Diff_Psi = new su2double [nVar]; MeanPhi = new su2double [nDim]; + Velocity_i = new su2double [nDim]; Velocity_j = new su2double [nDim]; + + implicit = (config->GetKind_TimeIntScheme_AdjFlow() == EULER_IMPLICIT); + + grid_movement = config->GetGrid_Movement(); + + Param_p = 0.3; + Param_Kappa_0 = config->GetKappa_1st_AdjFlow(); + +} + +CCentLax_AdjFlow::~CCentLax_AdjFlow(void) { + + delete [] Diff_Psi; delete [] MeanPhi; + delete [] Velocity_i; delete [] Velocity_j; + +} + +void CCentLax_AdjFlow::ComputeResidual (su2double *val_resconv_i, su2double *val_resvisc_i, su2double *val_resconv_j, su2double *val_resvisc_j, + su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, + CConfig *config) { + + /*--- Mean value of the adjoint variables ---*/ + MeanPsiRho = 0.5*(Psi_i[0]+Psi_j[0]); + for (iDim = 0; iDim < nDim; iDim++) + MeanPhi[iDim] = 0.5*(Psi_i[iDim+1]+Psi_j[iDim+1]); + MeanPsiE = 0.5*(Psi_i[nVar-1]+Psi_j[nVar-1]); + + /*--- Evaluation at point i ---*/ + ProjVelocity_i = 0; ProjPhi = 0; ProjPhi_Vel = 0; sq_vel = 0; Area = 0; + for (iDim = 0; iDim < nDim; iDim++) { + Velocity_i[iDim] = U_i[iDim+1] / U_i[0]; + ProjVelocity_i += Velocity_i[iDim]*Normal[iDim]; + ProjPhi += MeanPhi[iDim]*Normal[iDim]; + ProjPhi_Vel += MeanPhi[iDim]*Velocity_i[iDim]; + sq_vel += 0.5*Velocity_i[iDim]*Velocity_i[iDim]; + Area += Normal[iDim]*Normal[iDim]; + } + Area = sqrt(Area); + phis1 = ProjPhi + ProjVelocity_i*MeanPsiE; + phis2 = MeanPsiRho + ProjPhi_Vel + Enthalpy_i*MeanPsiE; + + /*--- Compute inviscid residual at point i ---*/ + val_resconv_i[0] = ProjVelocity_i*MeanPsiRho - phis2*ProjVelocity_i + Gamma_Minus_One*phis1*sq_vel; + for (iDim = 0; iDim < nDim; iDim++) + val_resconv_i[iDim+1] = ProjVelocity_i*MeanPhi[iDim] + phis2*Normal[iDim] - Gamma_Minus_One*phis1*Velocity_i[iDim]; + val_resconv_i[nVar-1] = ProjVelocity_i*MeanPsiE + Gamma_Minus_One*phis1; + + /*--- Flux contributions due to grid motion at point i ---*/ + if (grid_movement) { + su2double ProjGridVel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; + val_resconv_i[0] -= ProjGridVel*MeanPsiRho; + for (iDim = 0; iDim < nDim; iDim++) + val_resconv_i[iDim+1] -= ProjGridVel*MeanPhi[iDim]; + val_resconv_i[nVar-1] -= ProjGridVel*MeanPsiE; + } + + /*--- Inviscid contribution to the implicit part ---*/ + if (implicit) { + val_Jacobian_ii[0][0] = 0.0; + for (jDim = 0; jDim < nDim; jDim++) + val_Jacobian_ii[0][jDim+1] = -0.5*ProjVelocity_i*Velocity_i[jDim] + Gamma_Minus_One*sq_vel*0.5*Normal[jDim]; + val_Jacobian_ii[0][nVar-1] = 0.5*ProjVelocity_i*(Gamma_Minus_One*sq_vel - Enthalpy_i); + for (iDim = 0; iDim < nDim; iDim++) { + val_Jacobian_ii[iDim+1][0] = 0.5*Normal[iDim]; + for (jDim = 0; jDim < nDim; jDim++) + val_Jacobian_ii[iDim+1][jDim+1] = 0.5*Normal[iDim]*Velocity_i[jDim] - 0.5*Gamma_Minus_One*Velocity_i[iDim]*Normal[jDim]; + val_Jacobian_ii[iDim+1][iDim+1] += 0.5*ProjVelocity_i; + val_Jacobian_ii[iDim+1][nVar-1] = 0.5*Enthalpy_i*Normal[iDim] - 0.5*Gamma_Minus_One*Velocity_i[iDim]*ProjVelocity_i; + } + val_Jacobian_ii[nVar-1][0] = 0; + for (jDim = 0; jDim < nDim; jDim++) + val_Jacobian_ii[nVar-1][jDim+1] = 0.5*Gamma_Minus_One*Normal[jDim]; + val_Jacobian_ii[nVar-1][nVar-1] = 0.5*Gamma*ProjVelocity_i; + + for (iVar = 0; iVar < nVar; iVar++) + for (jVar = 0; jVar < nVar; jVar++) + val_Jacobian_ij[iVar][jVar] = val_Jacobian_ii[iVar][jVar]; + + /*--- Jacobian contributions due to grid motion at point i ---*/ + if (grid_movement) { + su2double ProjGridVel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; + for (iVar = 0; iVar < nVar; iVar++) { + val_Jacobian_ii[iVar][iVar] -= 0.5*ProjGridVel; + val_Jacobian_ij[iVar][iVar] -= 0.5*ProjGridVel; + } + } + } + + /*--- Evaluation at point j ---*/ + ProjVelocity_j = 0; ProjPhi_Vel = 0; sq_vel = 0; + for (iDim = 0; iDim < nDim; iDim++) { + Velocity_j[iDim] = U_j[iDim+1] / U_j[0]; + ProjVelocity_j += Velocity_j[iDim]*Normal[iDim]; + ProjPhi_Vel += MeanPhi[iDim]*Velocity_j[iDim]; + sq_vel += 0.5*Velocity_j[iDim]*Velocity_j[iDim]; + } + + phis1 = ProjPhi + ProjVelocity_j*MeanPsiE; + phis2 = MeanPsiRho + ProjPhi_Vel + Enthalpy_j*MeanPsiE; + + /*--- Compute inviscid residual at point j ---*/ + val_resconv_j[0] = -(ProjVelocity_j*MeanPsiRho - phis2*ProjVelocity_j + Gamma_Minus_One*phis1*sq_vel); + for (iDim = 0; iDim < nDim; iDim++) + val_resconv_j[iDim+1] = -(ProjVelocity_j*MeanPhi[iDim] + phis2*Normal[iDim] - Gamma_Minus_One*phis1*Velocity_j[iDim]); + val_resconv_j[nVar-1] = -(ProjVelocity_j*MeanPsiE + Gamma_Minus_One*phis1); + + /*--- Flux contributions due to grid movement at point j ---*/ + if (grid_movement) { + su2double ProjGridVel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; + val_resconv_j[0] += ProjGridVel*MeanPsiRho; + for (iDim = 0; iDim < nDim; iDim++) + val_resconv_j[iDim+1] += ProjGridVel*MeanPhi[iDim]; + val_resconv_j[nVar-1] += ProjGridVel*MeanPsiE; + } + + /*--- Inviscid contribution to the implicit part ---*/ + if (implicit) { + val_Jacobian_jj[0][0] = 0.0; + for (jDim = 0; jDim < nDim; jDim++) + val_Jacobian_jj[0][jDim+1] = 0.5*ProjVelocity_j*Velocity_j[jDim] - Gamma_Minus_One*sq_vel*0.5*Normal[jDim]; + val_Jacobian_jj[0][nVar-1] = -0.5*ProjVelocity_j*(Gamma_Minus_One*sq_vel - Enthalpy_j); + for (iDim = 0; iDim < nDim; iDim++) { + val_Jacobian_jj[iDim+1][0] = -0.5*Normal[iDim]; + for (jDim = 0; jDim < nDim; jDim++) + val_Jacobian_jj[iDim+1][jDim+1] = -0.5*Normal[iDim]*Velocity_j[jDim] + 0.5*Gamma_Minus_One*Velocity_j[iDim]*Normal[jDim]; + val_Jacobian_jj[iDim+1][iDim+1] -= 0.5*ProjVelocity_j; + val_Jacobian_jj[iDim+1][nVar-1] = -0.5*Enthalpy_j*Normal[iDim] + 0.5*Gamma_Minus_One*Velocity_j[iDim]*ProjVelocity_j; + } + val_Jacobian_jj[nVar-1][0] = 0; + for (jDim = 0; jDim < nDim; jDim++) + val_Jacobian_jj[nVar-1][jDim+1] = -0.5*Gamma_Minus_One*Normal[jDim]; + val_Jacobian_jj[nVar-1][nVar-1] = -0.5*Gamma*ProjVelocity_j; + + for (iVar = 0; iVar < nVar; iVar++) + for (jVar = 0; jVar < nVar; jVar++) + val_Jacobian_ji[iVar][jVar] = val_Jacobian_jj[iVar][jVar]; + + /*--- Jacobian contributions due to grid movement at point j ---*/ + if (grid_movement) { + su2double ProjGridVel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; + for (iVar = 0; iVar < nVar; iVar++) { + val_Jacobian_jj[iVar][iVar] += 0.5*ProjGridVel; + val_Jacobian_ji[iVar][iVar] += 0.5*ProjGridVel; + } + } + } + + /*--- Computes differences btw. variables ---*/ + for (iVar = 0; iVar < nVar; iVar++) + Diff_Psi[iVar] = Psi_i[iVar]-Psi_j[iVar]; + + /*--- Adjustment to projected velocity due to grid motion ---*/ + if (grid_movement) { + su2double ProjGridVel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; + ProjVelocity_i -= ProjGridVel; + ProjVelocity_j += ProjGridVel; + } + + /*--- Compute spectral radius ---*/ + Local_Lambda_i = (fabs(ProjVelocity_i)+SoundSpeed_i*Area); + Local_Lambda_j = (fabs(ProjVelocity_j)+SoundSpeed_j*Area); + MeanLambda = 0.5*(Local_Lambda_i+Local_Lambda_j); + + /*--- Compute streching factor ---*/ + Phi_i = pow(Lambda_i/(4.0*MeanLambda), Param_p); + Phi_j = pow(Lambda_j/(4.0*MeanLambda), Param_p); + StretchingFactor = 4.0*Phi_i*Phi_j/(Phi_i+Phi_j); + + sc2 = 3.0*(su2double(Neighbor_i)+su2double(Neighbor_j))/(su2double(Neighbor_i)*su2double(Neighbor_j)); + Epsilon_0 = Param_Kappa_0*sc2*su2double(nDim)/3.0; + + /*--- Artifical dissipation evaluation ---*/ + for (iVar = 0; iVar < nVar; iVar++) { + Residual = Epsilon_0*StretchingFactor*MeanLambda*Diff_Psi[iVar]; + val_resvisc_i[iVar] = -Residual; + val_resvisc_j[iVar] = Residual; + } + + /*--- Contribution to implicit part ---*/ + if (implicit) { + for (iVar = 0; iVar < nVar; iVar++) { + val_Jacobian_ii[iVar][iVar] -= Epsilon_0*StretchingFactor*MeanLambda; + val_Jacobian_ij[iVar][iVar] += Epsilon_0*StretchingFactor*MeanLambda; + val_Jacobian_ji[iVar][iVar] += Epsilon_0*StretchingFactor*MeanLambda; + val_Jacobian_jj[iVar][iVar] -= Epsilon_0*StretchingFactor*MeanLambda; + } + } + +} + +CCentJST_AdjFlow::CCentJST_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + + grid_movement = config->GetGrid_Movement(); + + Diff_Psi = new su2double [nVar]; Diff_Lapl = new su2double [nVar]; + Velocity_i = new su2double [nDim]; Velocity_j = new su2double [nDim]; + MeanPhi = new su2double [nDim]; + + Param_p = 0.3; + Param_Kappa_2 = config->GetKappa_2nd_AdjFlow(); + Param_Kappa_4 = config->GetKappa_4th_AdjFlow(); + implicit = (config->GetKind_TimeIntScheme_AdjFlow() == EULER_IMPLICIT); + +} + +CCentJST_AdjFlow::~CCentJST_AdjFlow(void) { + + delete [] Diff_Psi; delete [] Diff_Lapl; + delete [] Velocity_i; delete [] Velocity_j; + delete [] MeanPhi; +} + +void CCentJST_AdjFlow::ComputeResidual (su2double *val_resconv_i, su2double *val_resvisc_i, su2double *val_resconv_j, su2double *val_resvisc_j, + su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, + CConfig *config) { + + /*--- Mean Values ---*/ + + MeanPsiRho = 0.5*(Psi_i[0]+Psi_j[0]); + for (iDim = 0; iDim < nDim; iDim++) + MeanPhi[iDim] = 0.5*(Psi_i[iDim+1]+Psi_j[iDim+1]); + MeanPsiE = 0.5*(Psi_i[nVar-1]+Psi_j[nVar-1]); + + /*--- Point i convective residual evaluation ---*/ + + ProjVelocity_i = 0; ProjPhi = 0; ProjPhi_Vel = 0; sq_vel = 0; Area = 0; + for (iDim = 0; iDim < nDim; iDim++) { + Velocity_i[iDim] = U_i[iDim+1] / U_i[0]; + ProjVelocity_i += Velocity_i[iDim]*Normal[iDim]; + ProjPhi += MeanPhi[iDim]*Normal[iDim]; + ProjPhi_Vel += MeanPhi[iDim]*Velocity_i[iDim]; + sq_vel += 0.5*Velocity_i[iDim]*Velocity_i[iDim]; + Area += Normal[iDim]*Normal[iDim]; + } + Area = sqrt(Area); + phis1 = ProjPhi + ProjVelocity_i*MeanPsiE; + phis2 = MeanPsiRho + ProjPhi_Vel + Enthalpy_i*MeanPsiE; + + val_resconv_i[0] = ProjVelocity_i*MeanPsiRho - phis2*ProjVelocity_i + Gamma_Minus_One*phis1*sq_vel; + for (iDim = 0; iDim < nDim; iDim++) + val_resconv_i[iDim+1] = ProjVelocity_i*MeanPhi[iDim] + phis2*Normal[iDim] - Gamma_Minus_One*phis1*Velocity_i[iDim]; + val_resconv_i[nVar-1] = ProjVelocity_i*MeanPsiE + Gamma_Minus_One*phis1; + + /*--- Flux contributions due to grid movement at point i ---*/ + + if (grid_movement) { + su2double ProjGridVel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; + val_resconv_i[0] -= ProjGridVel*MeanPsiRho; + for (iDim = 0; iDim < nDim; iDim++) + val_resconv_i[iDim+1] -= ProjGridVel*MeanPhi[iDim]; + val_resconv_i[nVar-1] -= ProjGridVel*MeanPsiE; + } + + /*--- Jacobians of the inviscid flux ---*/ + + if (implicit) { + val_Jacobian_ii[0][0] = 0.0; + for (jDim = 0; jDim < nDim; jDim++) + val_Jacobian_ii[0][jDim+1] = -0.5*ProjVelocity_i*Velocity_i[jDim] + Gamma_Minus_One*sq_vel*0.5*Normal[jDim]; + val_Jacobian_ii[0][nVar-1] = 0.5*ProjVelocity_i*(Gamma_Minus_One*sq_vel - Enthalpy_i); + for (iDim = 0; iDim < nDim; iDim++) { + val_Jacobian_ii[iDim+1][0] = 0.5*Normal[iDim]; + for (jDim = 0; jDim < nDim; jDim++) + val_Jacobian_ii[iDim+1][jDim+1] = 0.5*Normal[iDim]*Velocity_i[jDim] - 0.5*Gamma_Minus_One*Velocity_i[iDim]*Normal[jDim]; + val_Jacobian_ii[iDim+1][iDim+1] += 0.5*ProjVelocity_i; + val_Jacobian_ii[iDim+1][nVar-1] = 0.5*Enthalpy_i*Normal[iDim] - 0.5*Gamma_Minus_One*Velocity_i[iDim]*ProjVelocity_i; + } + val_Jacobian_ii[nVar-1][0] = 0; + for (jDim = 0; jDim < nDim; jDim++) + val_Jacobian_ii[nVar-1][jDim+1] = 0.5*Gamma_Minus_One*Normal[jDim]; + val_Jacobian_ii[nVar-1][nVar-1] = 0.5*Gamma*ProjVelocity_i; + + for (iVar = 0; iVar < nVar; iVar++) + for (jVar = 0; jVar < nVar; jVar++) + val_Jacobian_ij[iVar][jVar] = val_Jacobian_ii[iVar][jVar]; + + /*--- Jacobian contributions due to grid movement at point i ---*/ + + if (grid_movement) { + su2double ProjGridVel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; + for (iVar = 0; iVar < nVar; iVar++) { + val_Jacobian_ii[iVar][iVar] -= 0.5*ProjGridVel; + val_Jacobian_ij[iVar][iVar] -= 0.5*ProjGridVel; + } + } + } + + + /*--- Point j convective residual evaluation ---*/ + + ProjVelocity_j = 0; ProjPhi_Vel = 0; sq_vel = 0; + for (iDim = 0; iDim < nDim; iDim++) { + Velocity_j[iDim] = U_j[iDim+1] / U_j[0]; + ProjVelocity_j += Velocity_j[iDim]*Normal[iDim]; + ProjPhi_Vel += MeanPhi[iDim]*Velocity_j[iDim]; + sq_vel += 0.5*Velocity_j[iDim]*Velocity_j[iDim]; + } + + phis1 = ProjPhi + ProjVelocity_j*MeanPsiE; + phis2 = MeanPsiRho + ProjPhi_Vel + Enthalpy_j*MeanPsiE; + + val_resconv_j[0] = -(ProjVelocity_j*MeanPsiRho - phis2*ProjVelocity_j + Gamma_Minus_One*phis1*sq_vel); + for (iDim = 0; iDim < nDim; iDim++) + val_resconv_j[iDim+1] = -(ProjVelocity_j*MeanPhi[iDim] + phis2*Normal[iDim] - Gamma_Minus_One*phis1*Velocity_j[iDim]); + val_resconv_j[nVar-1] = -(ProjVelocity_j*MeanPsiE + Gamma_Minus_One*phis1); + + /*--- Flux contributions due to grid motion at point j ---*/ + + if (grid_movement) { + su2double ProjGridVel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; + val_resconv_j[0] += ProjGridVel*MeanPsiRho; + for (iDim = 0; iDim < nDim; iDim++) + val_resconv_j[iDim+1] += ProjGridVel*MeanPhi[iDim]; + val_resconv_j[nVar-1] += ProjGridVel*MeanPsiE; + } + + /*--- Jacobians of the inviscid flux ---*/ + + if (implicit) { + val_Jacobian_jj[0][0] = 0.0; + for (jDim = 0; jDim < nDim; jDim++) + val_Jacobian_jj[0][jDim+1] = 0.5*ProjVelocity_j*Velocity_j[jDim] - Gamma_Minus_One*sq_vel*0.5*Normal[jDim]; + val_Jacobian_jj[0][nVar-1] = -0.5*ProjVelocity_j*(Gamma_Minus_One*sq_vel - Enthalpy_j); + for (iDim = 0; iDim < nDim; iDim++) { + val_Jacobian_jj[iDim+1][0] = -0.5*Normal[iDim]; + for (jDim = 0; jDim < nDim; jDim++) + val_Jacobian_jj[iDim+1][jDim+1] = -0.5*Normal[iDim]*Velocity_j[jDim] + 0.5*Gamma_Minus_One*Velocity_j[iDim]*Normal[jDim]; + val_Jacobian_jj[iDim+1][iDim+1] -= 0.5*ProjVelocity_j; + val_Jacobian_jj[iDim+1][nVar-1] = -0.5*Enthalpy_j*Normal[iDim] + 0.5*Gamma_Minus_One*Velocity_j[iDim]*ProjVelocity_j; + } + val_Jacobian_jj[nVar-1][0] = 0; + for (jDim = 0; jDim < nDim; jDim++) + val_Jacobian_jj[nVar-1][jDim+1] = -0.5*Gamma_Minus_One*Normal[jDim]; + val_Jacobian_jj[nVar-1][nVar-1] = -0.5*Gamma*ProjVelocity_j; + + for (iVar = 0; iVar < nVar; iVar++) + for (jVar = 0; jVar < nVar; jVar++) + val_Jacobian_ji[iVar][jVar] = val_Jacobian_jj[iVar][jVar]; + + /*--- Jacobian contributions due to grid motion at point j ---*/ + + if (grid_movement) { + su2double ProjGridVel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; + for (iVar = 0; iVar < nVar; iVar++) { + val_Jacobian_jj[iVar][iVar] += 0.5*ProjGridVel; + val_Jacobian_ji[iVar][iVar] += 0.5*ProjGridVel; + } + } + } + + /*--- Computes differences btw. variables and Laplacians ---*/ + + for (iVar = 0; iVar < nVar; iVar++) { + Diff_Lapl[iVar] = Und_Lapl_i[iVar]-Und_Lapl_j[iVar]; + Diff_Psi[iVar] = Psi_i[iVar]-Psi_j[iVar]; + } + + /*--- Adjustment to projected velocity due to grid motion ---*/ + + if (grid_movement) { + su2double ProjGridVel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; + } + ProjVelocity_i -= ProjGridVel; + ProjVelocity_j += ProjGridVel; + } + + /*--- Compute the spectral radius and stretching factor ---*/ + + Local_Lambda_i = (fabs(ProjVelocity_i)+SoundSpeed_i*Area); + Local_Lambda_j = (fabs(ProjVelocity_j)+SoundSpeed_j*Area); + MeanLambda = 0.5*(Local_Lambda_i+Local_Lambda_j); + + Phi_i = pow(Lambda_i/(4.0*MeanLambda), Param_p); + Phi_j = pow(Lambda_j/(4.0*MeanLambda), Param_p); + StretchingFactor = 4.0*Phi_i*Phi_j/(Phi_i+Phi_j); + + su2double sc2 = 3.0*(su2double(Neighbor_i)+su2double(Neighbor_j))/(su2double(Neighbor_i)*su2double(Neighbor_j)); + sc4 = sc2*sc2/4.0; + Epsilon_2 = Param_Kappa_2*0.5*(Sensor_i+Sensor_j)*sc2; + Epsilon_4 = max(0.0, Param_Kappa_4-Epsilon_2)*sc4; + + /*--- Compute viscous residual 1st- & 3rd-order dissipation ---*/ + + for (iVar = 0; iVar < nVar; iVar++) { + Residual = (Epsilon_2*Diff_Psi[iVar]-Epsilon_4*Diff_Lapl[iVar])*StretchingFactor*MeanLambda; + val_resvisc_i[iVar] = -Residual; + val_resvisc_j[iVar] = Residual; + if (implicit) { + val_Jacobian_ii[iVar][iVar] -= Epsilon_2 + su2double(Neighbor_i+1)*Epsilon_4*StretchingFactor*MeanLambda; + val_Jacobian_ij[iVar][iVar] += Epsilon_2 + su2double(Neighbor_j+1)*Epsilon_4*StretchingFactor*MeanLambda; + val_Jacobian_ji[iVar][iVar] += Epsilon_2 + su2double(Neighbor_i+1)*Epsilon_4*StretchingFactor*MeanLambda; + val_Jacobian_jj[iVar][iVar] -= Epsilon_2 + su2double(Neighbor_j+1)*Epsilon_4*StretchingFactor*MeanLambda; + } + } + +} + + +CUpwRoe_AdjFlow::CUpwRoe_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + implicit = (config->GetKind_TimeIntScheme_AdjFlow() == EULER_IMPLICIT); + grid_movement = config->GetGrid_Movement(); + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + + Residual_Roe = new su2double [nVar]; + RoeVelocity = new su2double [nDim]; + Velocity_i = new su2double [nDim]; + Velocity_j = new su2double [nDim]; + Lambda = new su2double [nVar]; + P_Tensor = new su2double* [nVar]; + invP_Tensor = new su2double* [nVar]; + ProjFlux_i = new su2double*[nVar]; + ProjFlux_j = new su2double*[nVar]; + Proj_ModJac_Tensor = new su2double*[nVar]; + for (iVar = 0; iVar < nVar; iVar++) { + P_Tensor[iVar] = new su2double [nVar]; + invP_Tensor[iVar] = new su2double [nVar]; + ProjFlux_i[iVar] = new su2double[nVar]; + ProjFlux_j[iVar] = new su2double[nVar]; + Proj_ModJac_Tensor[iVar] = new su2double[nVar]; + } + +} + +CUpwRoe_AdjFlow::~CUpwRoe_AdjFlow(void) { + + delete [] Residual_Roe; + delete [] RoeVelocity; + delete [] Velocity_i; + delete [] Velocity_j; + delete [] Lambda; + for (iVar = 0; iVar < nVar; iVar++) { + delete [] P_Tensor[iVar]; + delete [] invP_Tensor[iVar]; + delete [] ProjFlux_i[iVar]; + delete [] ProjFlux_j[iVar]; + delete [] Proj_ModJac_Tensor[iVar]; + } + delete [] P_Tensor; + delete [] invP_Tensor; + delete [] ProjFlux_i; + delete [] ProjFlux_j; + delete [] Proj_ModJac_Tensor; + +} + +void CUpwRoe_AdjFlow::ComputeResidual (su2double *val_residual_i, su2double *val_residual_j, su2double **val_Jacobian_ii, + su2double **val_Jacobian_ij, su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config) { + + /*--- Compute the area ---*/ + + area = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + area += Normal[iDim]*Normal[iDim]; + area = sqrt(area); + rarea = 1.0 / area; + + /*--- Components of the normal & unit normal vector of the current face ---*/ + + Sx = Normal[0]; + Sy = Normal[1]; + Sz = 0.0; if (nDim == 3) Sz = Normal[2]; + nx = Sx * rarea; + ny = Sy * rarea; + nz = Sz * rarea; + + /*--- Flow variable states at point i (left, _l) and j (right, _r)---*/ + + rho_l = V_i[nDim+2]; rho_r = V_j[nDim+2]; + u_l = V_i[1]; v_l = V_i[2]; w_l = 0.0; if (nDim == 3) w_l = V_i[3]; + u_r = V_j[1]; v_r = V_j[2]; w_r = 0.0; if (nDim == 3) w_r = V_j[3]; + h_l = V_i[nDim+3]; h_r = V_j[nDim+3]; + + /*--- One-half speed squared ---*/ + + q_l = ONE2 * ((u_l*u_l) + (v_l*v_l) + (w_l*w_l)); + q_r = ONE2 * ((u_r*u_r) + (v_r*v_r) + (w_r*w_r)); + + /*--- Projected velocity ---*/ + + Q_l = (u_l * Sx) + (v_l * Sy) + (w_l * Sz); + Q_r = (u_r * Sx) + (v_r * Sy) + (w_r * Sz); + + /*--- Mean adjoint variables ---*/ + + psi1 = ONE2 * (Psi_i[0] + Psi_j[0]); + psi2 = ONE2 * (Psi_i[1] + Psi_j[1]); + psi3 = ONE2 * (Psi_i[2] + Psi_j[2]); + psi4 = 0.0; if (nDim == 3) psi4 = ONE2 * (Psi_i[3] + Psi_j[3]); + psi5 = ONE2 * (Psi_i[nVar-1] + Psi_j[nVar-1]); + + /*--- Left state ---*/ + + l1psi = (Sx * psi2) + (Sy * psi3) + (Sz * psi4) + (Q_l * psi5); + l2psi = psi1 + (u_l * psi2) + (v_l * psi3) + (w_l * psi4) + (h_l * psi5); + + val_residual_i[0] = Q_l * psi1 - l2psi * Q_l + l1psi * Gamma_Minus_One * q_l; + val_residual_i[1] = Q_l * psi2 + l2psi * Sx - l1psi * Gamma_Minus_One * u_l; + val_residual_i[2] = Q_l * psi3 + l2psi * Sy - l1psi * Gamma_Minus_One * v_l; + if (nDim == 3) val_residual_i[3] = Q_l * psi4 + l2psi * Sz - l1psi * Gamma_Minus_One * w_l; + val_residual_i[nVar-1] = Q_l * psi5 + l1psi * Gamma_Minus_One; + + /*--- Right state ---*/ + + l1psi = (Sx * psi2) + (Sy * psi3) + (Sz * psi4) + (Q_r * psi5); + l2psi = psi1 + (u_r * psi2) + (v_r * psi3) + (w_r * psi4) + (h_r * psi5); + + val_residual_j[0] = -(Q_r * psi1 - l2psi * Q_r + l1psi * Gamma_Minus_One * q_r); + val_residual_j[1] = -(Q_r * psi2 + l2psi * Sx - l1psi * Gamma_Minus_One * u_r); + val_residual_j[2] = -(Q_r * psi3 + l2psi * Sy - l1psi * Gamma_Minus_One * v_r); + if (nDim == 3) val_residual_j[3] = -(Q_r * psi4 + l2psi * Sz - l1psi * Gamma_Minus_One * w_r); + val_residual_j[nVar-1] = -(Q_r * psi5 + l1psi * Gamma_Minus_One); + + + /*--- f_{roe} = P^{-T} |lambda| P^T \delta \psi ---*/ + + psi1_l = Psi_i[0]; + psi2_l = Psi_i[1]; + psi3_l = Psi_i[2]; + psi4_l = 0.0; if (nDim == 3) psi4_l = Psi_i[3]; + psi5_l = Psi_i[nVar-1]; + + psi1_r = Psi_j[0]; + psi2_r = Psi_j[1]; + psi3_r = Psi_j[2]; + psi4_r = 0.0; if (nDim == 3) psi4_r = Psi_j[3]; + psi5_r = Psi_j[nVar-1]; + + /*--- Roe averaging ---*/ + + rrho_l = 1.0 / rho_l; + weight = sqrt(rho_r * rrho_l); + rweight1 = 1.0 / (1.0 + weight); + weight *= rweight1; + + h = h_l * rweight1 + weight * h_r; + u = u_l * rweight1 + weight * u_r; + v = v_l * rweight1 + weight * v_r; + w = w_l * rweight1 + weight * w_r; + + psi1 = ONE2 * (psi1_r - psi1_l); + psi2 = ONE2 * (psi2_r - psi2_l); + psi3 = ONE2 * (psi3_r - psi3_l); + psi4 = ONE2 * (psi4_r - psi4_l); + psi5 = ONE2 * (psi5_r - psi5_l); + + q2 = (u*u) + (v*v) + (w*w); + Q = (u * Sx) + (v * Sy) + (w * Sz); + vn = nx * u + ny * v + nz * w; + cc = Gamma_Minus_One * h - 0.5 * Gamma_Minus_One * q2; + c = sqrt(cc); + + /*--- Contribution to velocity projection due to grid movement ---*/ + + if (grid_movement) { + su2double ProjGridVel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; + Q -= ProjGridVel; + } + + /*--- Eigenvalues from the primal solution ---*/ + + absQ = fabs(Q); + absQp = fabs(Q + c * area); + absQm = fabs(Q - c * area); + + alpha = ONE2 * Gamma_Minus_One * q2 / cc; + beta_u = psi2 + u * psi5; + beta_v = psi3 + v * psi5; + beta_w = psi4 + w * psi5; + eta = Gamma_Minus_One / cc; + l1psi = (nx * psi2) + (ny * psi3) + (nz * psi4) + (vn * psi5); + l2psi = psi1 + (u * psi2) + (v * psi3) + (w * psi4) + (h * psi5); + l1l2p = (l2psi + c * l1psi) * absQp; + l1l2m = (l2psi - c * l1psi) * absQm; + + /*--- adjoint flux computation in the x, y and z coordinate system ---*/ + + Residual_Roe[0] = ((1.0-alpha)*l2psi - (1.0-alpha)*cc/Gamma_Minus_One*psi5 + - u*beta_u*(1.0-(nx*nx)) - v*beta_v*(1.0-(ny*ny)) + - w*beta_w*(1.0-(nz*nz)) + ny*nz*(w*beta_v + v*beta_w) + + nx*nz*(w*beta_u + u*beta_w) + ny*nx*(v*beta_u + u*beta_v) ) * absQ + - ONE2 / c * vn * (l1l2p - l1l2m) + ONE2 * alpha * (l1l2p + l1l2m); + + Residual_Roe[1] = (l2psi*u*eta - u*psi5 + beta_u*(1.0-(nx*nx)) + - nx*(beta_v*ny + beta_w*nz) ) * absQ + ONE2*nx/c * (l1l2p - l1l2m ) + - ONE2*eta*u * (l1l2p + l1l2m ); + + Residual_Roe[2] = (l2psi*v*eta - v*psi5 + beta_v*(1.0-(ny*ny)) + - ny*(beta_w*nz + beta_u*nx) ) * absQ + ONE2*ny/c * (l1l2p - l1l2m ) + - ONE2*eta*v * (l1l2p + l1l2m ); + + if (nDim == 3) Residual_Roe[3] = (l2psi*w*eta - w*psi5 + beta_w*(1.0-(nz*nz)) - nz*(beta_u*nx + beta_v*ny) ) * absQ + + ONE2*nz/c * (l1l2p - l1l2m ) - ONE2*eta*w * (l1l2p + l1l2m ); + + Residual_Roe[nVar-1] = (psi5 - l2psi*eta) * absQ + ONE2*eta*(l1l2p + l1l2m); + + for (iVar = 0; iVar < nVar; iVar++) { + val_residual_i[iVar] += Residual_Roe[iVar]; + val_residual_j[iVar] -= Residual_Roe[iVar]; + } + + /*--- Flux contribution due to grid movement ---*/ + + if (grid_movement) { + su2double ProjGridVel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; + for (iVar = 0; iVar < nVar; iVar++) { + val_residual_i[iVar] -= ProjGridVel * 0.5*(Psi_i[iVar]+Psi_j[iVar]); + val_residual_j[iVar] += ProjGridVel * 0.5*(Psi_i[iVar]+Psi_j[iVar]); + } + } + + /*--- Implicit Contributions ---*/ + + if (implicit) { + + /*--- Prepare variables for use in matrix routines ---*/ + + RoeDensity = V_i[nDim+2]*sqrt(V_j[nDim+2]/V_i[nDim+2]); + RoeSoundSpeed = c; + UnitNormal[0] = nx; UnitNormal[1] = ny; if (nDim == 3 ) UnitNormal[2] = nz; + RoeVelocity[0] = u; RoeVelocity[1] = v; if (nDim == 3 ) RoeVelocity[2] = w; + Velocity_i[0] = u_l; Velocity_i[1] = v_l; if (nDim == 3 ) Velocity_i[2] = w_l; + Velocity_j[0] = u_r; Velocity_j[1] = v_r; if (nDim == 3 ) Velocity_j[2] = w_r; + + Pressure_i = V_i[nDim+1]; + Density_i = V_i[nDim+2]; + Enthalpy_i = V_i[nDim+3]; + Energy_i = Enthalpy_i - Pressure_i/Density_i; + + Pressure_j = V_i[nDim+1]; + Density_j = V_i[nDim+2]; + Enthalpy_j = V_i[nDim+3]; + Energy_j = Enthalpy_j - Pressure_j/Density_j; + + /*--- Jacobians of the inviscid flux, scaled by + 0.5 because val_resconv ~ 0.5*(fc_i+fc_j)*Normal ---*/ + + GetInviscidProjJac(Velocity_i, &Energy_i, Normal, 0.5, ProjFlux_i); + GetInviscidProjJac(Velocity_j, &Energy_j, Normal, 0.5, ProjFlux_j); + + /*--- Compute P, inverse P, and store eigenvalues ---*/ + + GetPMatrix_inv(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, invP_Tensor); + GetPMatrix(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, P_Tensor); + + /*--- Flow eigenvalues ---*/ + + for (iDim = 0; iDim < nDim; iDim++) + Lambda[iDim] = absQ; + Lambda[nVar-2] = absQp; + Lambda[nVar-1] = absQm; + + /*--- Roe's Flux approximation ---*/ + + for (iVar = 0; iVar < nVar; iVar++) { + for (jVar = 0; jVar < nVar; jVar++) { + Proj_ModJac_Tensor_ij = 0.0; + + /*--- Compute |Proj_ModJac_Tensor| = P x |Lambda| x inverse P ---*/ + + for (kVar = 0; kVar < nVar; kVar++) + Proj_ModJac_Tensor_ij += P_Tensor[iVar][kVar]*Lambda[kVar]*invP_Tensor[kVar][jVar]; + Proj_ModJac_Tensor[iVar][jVar] = 0.5*Proj_ModJac_Tensor_ij*area; + } + } + + /*--- Transpose the matrices and store the Jacobians. Note the negative + sign for the ji and jj Jacobians bc the normal direction is flipped. ---*/ + + for (iVar = 0; iVar < nVar; iVar++) { + for (jVar = 0; jVar < nVar; jVar++) { + val_Jacobian_ii[jVar][iVar] = ProjFlux_i[iVar][jVar] - Proj_ModJac_Tensor[iVar][jVar]; + val_Jacobian_ij[jVar][iVar] = ProjFlux_i[iVar][jVar] + Proj_ModJac_Tensor[iVar][jVar]; + val_Jacobian_ji[jVar][iVar] = -(ProjFlux_j[iVar][jVar] - Proj_ModJac_Tensor[iVar][jVar]); + val_Jacobian_jj[jVar][iVar] = -(ProjFlux_j[iVar][jVar] + Proj_ModJac_Tensor[iVar][jVar]); + } + } + + /*--- Jacobian contribution due to grid movement ---*/ + + if (grid_movement) { + su2double ProjGridVel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; + for (iVar = 0; iVar < nVar; iVar++) { + + /*--- Adjust Jacobian main diagonal ---*/ + + val_Jacobian_ii[iVar][iVar] -= 0.5*ProjGridVel; + val_Jacobian_ij[iVar][iVar] -= 0.5*ProjGridVel; + val_Jacobian_ji[iVar][iVar] += 0.5*ProjGridVel; + val_Jacobian_jj[iVar][iVar] += 0.5*ProjGridVel; + } + } + + } +} + +CUpwLin_AdjTurb::CUpwLin_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + + Velocity_i = new su2double [nDim]; +} + +CUpwLin_AdjTurb::~CUpwLin_AdjTurb(void) { + delete [] Velocity_i; +} + +void CUpwLin_AdjTurb::ComputeResidual (su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { + bool implicit = (config->GetKind_TimeIntScheme_AdjTurb() == EULER_IMPLICIT); + + /*--- Non-conservative term --> -\nabla \psi_\mu B^{cv} + B^{cv} = -v ---*/ + + unsigned short iDim; + su2double proj_conv_flux = 0; + + for (iDim = 0; iDim < nDim; iDim++) { + Velocity_i[iDim] = U_i[iDim+1]/U_i[0]; + proj_conv_flux += Velocity_i[iDim]*Normal[iDim]; // projection of convective flux at iPoint + } + su2double psinu0 = TurbPsi_i[0]; + su2double psinu1; + if (proj_conv_flux > 0) + psinu1 = psinu0 + proj_conv_flux; + else + psinu1 = psinu0; + + val_residual[0] = 0.5*( proj_conv_flux*(psinu0+psinu1)-fabs(proj_conv_flux)*(psinu1-psinu0)); + if (implicit) { + val_Jacobian_i[0][0] = 0.5*( proj_conv_flux + fabs(proj_conv_flux)); + } +} + +CUpwSca_AdjTurb::CUpwSca_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + + Velocity_i = new su2double [nDim]; + Velocity_j = new su2double [nDim]; +} + +CUpwSca_AdjTurb::~CUpwSca_AdjTurb(void) { + delete [] Velocity_i; + delete [] Velocity_j; +} + +void CUpwSca_AdjTurb::ComputeResidual (su2double *val_residual_i, su2double *val_residual_j, + su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, + su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config) { + + bool implicit = (config->GetKind_TimeIntScheme_AdjTurb() == EULER_IMPLICIT); + + /*--- Non-conservative term --> -\nabla \psi_\mu B^{cv} + B^{cv} = -\nabla \hat{nu}/\sigma + v ---*/ + + unsigned short iDim; + su2double proj_conv_flux_i = 0, proj_conv_flux_j = 0, proj_conv_flux_ij = 0; + su2double sigma = 2./3.; + + for (iDim = 0; iDim < nDim; iDim++) { + Velocity_i[iDim] = U_i[iDim+1]/U_i[0]; + Velocity_j[iDim] = U_j[iDim+1]/U_j[0]; + proj_conv_flux_i += (TurbVar_Grad_i[0][iDim]/sigma - Velocity_i[iDim])*Normal[iDim]; // projection of convective flux at iPoint + proj_conv_flux_j += (TurbVar_Grad_j[0][iDim]/sigma - Velocity_j[iDim])*Normal[iDim]; // projection of convective flux at jPoint + } + proj_conv_flux_ij = 0.5*fabs(proj_conv_flux_i+proj_conv_flux_j); // projection of average convective flux + + val_residual_i[0] = 0.5*( proj_conv_flux_i*(TurbPsi_i[0]+TurbPsi_j[0])-proj_conv_flux_ij*(TurbPsi_j[0]-TurbPsi_i[0])); + val_residual_j[0] = 0.5*(-proj_conv_flux_j*(TurbPsi_j[0]+TurbPsi_i[0])-proj_conv_flux_ij*(TurbPsi_i[0]-TurbPsi_j[0])); + if (implicit) { + val_Jacobian_ii[0][0] = 0.5*( proj_conv_flux_i+proj_conv_flux_ij); + val_Jacobian_ij[0][0] = 0.5*( proj_conv_flux_i-proj_conv_flux_ij); + val_Jacobian_ji[0][0] = 0.5*(-proj_conv_flux_j-proj_conv_flux_ij); + val_Jacobian_jj[0][0] = 0.5*(-proj_conv_flux_j+proj_conv_flux_ij); + } + +} diff --git a/SU2_CFD/src/numerics/continuous_adjoint/adj_diffusion.cpp b/SU2_CFD/src/numerics/continuous_adjoint/adj_diffusion.cpp new file mode 100644 index 000000000000..65beaad8f6f6 --- /dev/null +++ b/SU2_CFD/src/numerics/continuous_adjoint/adj_diffusion.cpp @@ -0,0 +1,537 @@ +/*! + * \file adj_diffusion.cpp + * \brief Implementation of adjoint diffusion numerics classes. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../include/numerics/continuous_adjoint/adj_diffusion.hpp" + +CAvgGrad_AdjFlow::CAvgGrad_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + unsigned short iDim; + + implicit = (config->GetKind_TimeIntScheme_AdjFlow() == EULER_IMPLICIT); + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + + Velocity_i = new su2double [nDim]; + Velocity_j = new su2double [nDim]; + Mean_Velocity = new su2double [nDim]; + Mean_GradPhi = new su2double* [nDim]; + for (iDim = 0; iDim < nDim; iDim++) + Mean_GradPhi[iDim] = new su2double [nDim]; + Mean_GradPsiE = new su2double [nDim]; + Edge_Vector = new su2double [nDim]; + +} + +CAvgGrad_AdjFlow::~CAvgGrad_AdjFlow(void) { + delete [] Velocity_i; + delete [] Velocity_j; + delete [] Mean_Velocity; + delete [] Edge_Vector; + delete [] Mean_GradPsiE; + for (unsigned short iDim = 0; iDim < nDim; iDim++) + delete [] Mean_GradPhi[iDim]; +} + +void CAvgGrad_AdjFlow::ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, + su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, + su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config) { + unsigned short iDim, jDim; + su2double sq_vel_i, ViscDens_i, XiDens_i; + su2double sq_vel_j, ViscDens_j, XiDens_j; + su2double dist_ij_2, dPhiE_dn; + + su2double Prandtl_Lam = config->GetPrandtl_Lam(); + su2double Prandtl_Turb = config->GetPrandtl_Turb(); + + /*--- States in point i ---*/ + + sq_vel_i = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + Velocity_i[iDim] = V_i[iDim+1]; + sq_vel_i += 0.5*Velocity_i[iDim]*Velocity_i[iDim]; + } + Pressure_i = V_i[nDim+1]; + Density_i = V_i[nDim+2]; + Enthalpy_i = V_i[nDim+3]; + SoundSpeed_i = sqrt(fabs(Pressure_i*Gamma/Density_i)); + + /*--- Laminar and Eddy viscosity ---*/ + + Laminar_Viscosity_i = V_i[nDim+5]; + Eddy_Viscosity_i = V_i[nDim+6]; + + ViscDens_i = (Laminar_Viscosity_i + Eddy_Viscosity_i) / Density_i; + XiDens_i = Gamma*(Laminar_Viscosity_i/Prandtl_Lam + Eddy_Viscosity_i/Prandtl_Turb) / Density_i; + + /*--- States in point j ---*/ + + sq_vel_j = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + Velocity_j[iDim] = V_j[iDim+1]; + sq_vel_j += 0.5*Velocity_j[iDim]*Velocity_j[iDim]; + } + Pressure_j = V_j[nDim+1]; + Density_j = V_j[nDim+2]; + Enthalpy_j = V_j[nDim+3]; + SoundSpeed_j = sqrt(fabs(Pressure_j*Gamma/Density_j)); + + /*--- Laminar and Eddy viscosity ---*/ + + Laminar_Viscosity_j = V_j[nDim+5]; + Eddy_Viscosity_j = V_j[nDim+6]; + + ViscDens_j = (Laminar_Viscosity_j + Eddy_Viscosity_j) / Density_j; + XiDens_j = Gamma*(Laminar_Viscosity_j/Prandtl_Lam + Eddy_Viscosity_j/Prandtl_Turb) / Density_j; + + /*--- Compute vector going from iPoint to jPoint ---*/ + + dist_ij_2 = 0.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]; + } + + /*--- Average of the derivatives of the adjoint variables ---*/ + + for (iDim = 0; iDim < nDim; iDim++) { + Mean_GradPsiE[iDim] = 0.5*(PsiVar_Grad_i[nVar-1][iDim]+PsiVar_Grad_j[nVar-1][iDim]); + for (jDim = 0; jDim < nDim; jDim++) + Mean_GradPhi[iDim][jDim] = 0.5*(PsiVar_Grad_i[iDim+1][jDim]+PsiVar_Grad_j[iDim+1][jDim]); + } + + dPhiE_dn = 0; + for (iDim = 0; iDim < nDim; iDim++) + dPhiE_dn += Mean_GradPsiE[iDim]*Normal[iDim]; + + /*--- Compute the viscous residual and jacobian ---*/ + + GetAdjViscousFlux_Jac(Pressure_i, Pressure_j, Density_i, Density_j, + ViscDens_i, ViscDens_j, Velocity_i, Velocity_j, sq_vel_i, sq_vel_j, + XiDens_i, XiDens_j, Mean_GradPhi, Mean_GradPsiE, + dPhiE_dn, Normal, Edge_Vector, dist_ij_2, val_residual_i, val_residual_j, + val_Jacobian_ii, val_Jacobian_ij, val_Jacobian_ji, val_Jacobian_jj, + implicit); + +} + + +CAvgGradCorrected_AdjFlow::CAvgGradCorrected_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + implicit = (config->GetKind_TimeIntScheme_AdjFlow() == EULER_IMPLICIT); + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + + Velocity_i = new su2double [nDim]; + Velocity_j = new su2double [nDim]; + Mean_Velocity = new su2double [nDim]; + + Mean_GradPsiVar = new su2double* [nVar]; + for (unsigned short iVar = 0; iVar < nVar; iVar++) + Mean_GradPsiVar[iVar] = new su2double [nDim]; + + Edge_Vector = new su2double [nDim]; + Proj_Mean_GradPsiVar_Edge = new su2double [nVar]; + + Mean_GradPhi = new su2double* [nDim]; + for (unsigned short iDim = 0; iDim < nDim; iDim++) + Mean_GradPhi[iDim] = new su2double [nDim]; + Mean_GradPsiE = new su2double [nDim]; + +} + +CAvgGradCorrected_AdjFlow::~CAvgGradCorrected_AdjFlow(void) { + + delete [] Velocity_i; + delete [] Velocity_j; + delete [] Mean_Velocity; + delete [] Edge_Vector; + delete [] Proj_Mean_GradPsiVar_Edge; + + for (unsigned short iVar = 0; iVar < nVar; iVar++) + delete [] Mean_GradPsiVar[iVar]; + delete [] Mean_GradPsiVar; + + for (unsigned short iDim = 0; iDim < nDim; iDim++) + delete [] Mean_GradPhi[iDim]; + delete [] Mean_GradPhi; + delete [] Mean_GradPsiE; + +} + +void CAvgGradCorrected_AdjFlow::ComputeResidual(su2double *val_residual_i, + su2double *val_residual_j, + su2double **val_Jacobian_ii, + su2double **val_Jacobian_ij, + su2double **val_Jacobian_ji, + su2double **val_Jacobian_jj, + CConfig *config) { + + unsigned short iVar, iDim, jDim; + su2double Density_i, sq_vel_i, Pressure_i, ViscDens_i, XiDens_i; + su2double Density_j, sq_vel_j, Pressure_j, ViscDens_j, XiDens_j; + su2double dist_ij_2, dPhiE_dn; + + su2double Prandtl_Lam = config->GetPrandtl_Lam(); + su2double Prandtl_Turb = config->GetPrandtl_Turb(); + + /*--- States in point i ---*/ + + sq_vel_i = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + Velocity_i[iDim] = V_i[iDim+1]; + sq_vel_i += 0.5*Velocity_i[iDim]*Velocity_i[iDim]; + } + Pressure_i = V_i[nDim+1]; + Density_i = V_i[nDim+2]; + Enthalpy_i = V_i[nDim+3]; + + /*--- Laminar and Eddy viscosity ---*/ + + Laminar_Viscosity_i = V_i[nDim+5]; + Eddy_Viscosity_i = V_i[nDim+6]; + + ViscDens_i = (Laminar_Viscosity_i + Eddy_Viscosity_i) / Density_i; + XiDens_i = Gamma*(Laminar_Viscosity_i/Prandtl_Lam + + Eddy_Viscosity_i/Prandtl_Turb) / Density_i; + + /*--- States in point j ---*/ + + sq_vel_j = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + Velocity_j[iDim] = V_j[iDim+1]; + sq_vel_j += 0.5*Velocity_j[iDim]*Velocity_j[iDim]; + } + Pressure_j = V_j[nDim+1]; + Density_j = V_j[nDim+2]; + Enthalpy_j = V_j[nDim+3]; + + /*--- Laminar and Eddy viscosity ---*/ + + Laminar_Viscosity_j = V_j[nDim+5]; + Eddy_Viscosity_j = V_j[nDim+6]; + + ViscDens_j = (Laminar_Viscosity_j + Eddy_Viscosity_j) / Density_j; + XiDens_j = Gamma*(Laminar_Viscosity_j/Prandtl_Lam + + Eddy_Viscosity_j/Prandtl_Turb) / Density_j; + + /*--- Compute vector going from iPoint to jPoint ---*/ + + dist_ij_2 = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + Mean_Velocity[iDim] = 0.5*(Velocity_i[iDim]+Velocity_j[iDim]); + Edge_Vector[iDim] = Coord_j[iDim]-Coord_i[iDim]; + dist_ij_2 += Edge_Vector[iDim]*Edge_Vector[iDim]; + } + + /*--- Mean gradient approximation. Projection of the mean gradient in the direction of the edge, weiss correction ---*/ + + for (iVar = 0; iVar < nVar; iVar++) { + Proj_Mean_GradPsiVar_Edge[iVar] = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + Mean_GradPsiVar[iVar][iDim] = 0.5*(PsiVar_Grad_i[iVar][iDim] + PsiVar_Grad_j[iVar][iDim]); + Proj_Mean_GradPsiVar_Edge[iVar] += Mean_GradPsiVar[iVar][iDim]*Edge_Vector[iDim]; + } + for (iDim = 0; iDim < nDim; iDim++) + Mean_GradPsiVar[iVar][iDim] -= (Proj_Mean_GradPsiVar_Edge[iVar] - + (Psi_j[iVar]-Psi_i[iVar]))*Edge_Vector[iDim]/dist_ij_2; + } + + /*--- Average of the derivatives of the adjoint variables ---*/ + + for (iDim = 0; iDim < nDim; iDim++) { + Mean_GradPsiE[iDim] = Mean_GradPsiVar[nVar-1][iDim]; + for (jDim = 0; jDim < nDim; jDim++) + Mean_GradPhi[iDim][jDim] = Mean_GradPsiVar[iDim+1][jDim]; + } + + dPhiE_dn = 0; + for (iDim = 0; iDim < nDim; iDim++) + dPhiE_dn += Mean_GradPsiE[iDim]*Normal[iDim]; + + /*--- Compute the viscous residual and jacobian ---*/ + + GetAdjViscousFlux_Jac(Pressure_i, Pressure_j, Density_i, Density_j, + ViscDens_i, ViscDens_j, Velocity_i, Velocity_j, sq_vel_i, sq_vel_j, + XiDens_i, XiDens_j, Mean_GradPhi, Mean_GradPsiE, + dPhiE_dn, Normal, Edge_Vector, dist_ij_2, val_residual_i, val_residual_j, + val_Jacobian_ii, val_Jacobian_ij, val_Jacobian_ji, val_Jacobian_jj, + implicit); + +} + + +CAvgGrad_AdjTurb::CAvgGrad_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + Edge_Vector = new su2double [nDim]; + Mean_GradTurbPsi = new su2double* [nVar]; + Proj_Mean_GradTurbPsi_Kappa = new su2double [nVar]; + Proj_Mean_GradTurbPsi_Edge = new su2double [nVar]; + Proj_Mean_GradTurbPsi_Corrected = new su2double [nVar]; + for (unsigned short iVar = 0; iVar < nVar; iVar++) + Mean_GradTurbPsi[iVar] = new su2double [nDim]; +} + +CAvgGrad_AdjTurb::~CAvgGrad_AdjTurb(void) { + delete [] Edge_Vector; + delete [] Proj_Mean_GradTurbPsi_Kappa; + delete [] Proj_Mean_GradTurbPsi_Edge; + delete [] Proj_Mean_GradTurbPsi_Corrected; + for (unsigned short iVar = 0; iVar < nVar; iVar++) { + delete [] Mean_GradTurbPsi[iVar]; + } + delete [] Mean_GradTurbPsi; +} + +void CAvgGrad_AdjTurb::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, + su2double **val_Jacobian_j, CConfig *config) { + + bool implicit = (config->GetKind_TimeIntScheme_AdjTurb() == EULER_IMPLICIT); + + su2double sigma = 2./3.; + su2double nu_i, nu_j, nu_e; + su2double dist_ij_2 = 0; + su2double proj_vector_ij = 0; + unsigned short iVar, iDim; + + /*--- Compute mean effective viscosity ---*/ + nu_i = Laminar_Viscosity_i/U_i[0]; + nu_j = Laminar_Viscosity_j/U_j[0]; + nu_e = 0.5*(nu_i+nu_j+TurbVar_i[0]+TurbVar_j[0])/sigma; + + /*--- Compute vector going from iPoint to jPoint ---*/ + 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]; + } + proj_vector_ij = proj_vector_ij/dist_ij_2; + + /*--- Mean gradient approximation ---*/ + for (iVar = 0; iVar < nVar; iVar++) { + Proj_Mean_GradTurbPsi_Edge[iVar] = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + Mean_GradTurbPsi[iVar][iDim] = 0.5*(TurbPsi_Grad_i[iVar][iDim] + TurbPsi_Grad_j[iVar][iDim]); + } + + /*--- Projection of the corrected gradient ---*/ + Proj_Mean_GradTurbPsi_Corrected[iVar] = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + Proj_Mean_GradTurbPsi_Corrected[iVar] += Mean_GradTurbPsi[iVar][iDim]*Normal[iDim]; + } + + val_residual[0] = -nu_e*Proj_Mean_GradTurbPsi_Corrected[0]; + + if (implicit) { + val_Jacobian_i[0][0] = nu_e*proj_vector_ij; + val_Jacobian_j[0][0] = -nu_e*proj_vector_ij; + } + +} + +void CAvgGrad_AdjTurb::ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, + su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, + su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config) { + + bool implicit = (config->GetKind_TimeIntScheme_AdjTurb() == EULER_IMPLICIT); + + su2double sigma = 2./3.; + su2double nu_i, nu_j, nu_e_i, nu_e_j; + su2double dist_ij_2 = 0; + su2double proj_vector_ij = 0; + unsigned short iVar, iDim; + + /*--- Compute mean effective viscosity ---*/ + nu_i = Laminar_Viscosity_i/U_i[0]; + nu_j = Laminar_Viscosity_j/U_j[0]; + nu_e_i = (nu_i+TurbVar_i[0])/sigma; + nu_e_j = (nu_j+TurbVar_j[0])/sigma; + + /*--- Compute vector going from iPoint to jPoint ---*/ + 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]; + } + proj_vector_ij = proj_vector_ij/dist_ij_2; // to normalize vectors + + /*--- Mean gradient approximation ---*/ + for (iVar = 0; iVar < nVar; iVar++) { + Proj_Mean_GradTurbPsi_Edge[iVar] = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + Mean_GradTurbPsi[iVar][iDim] = 0.5*(TurbPsi_Grad_i[iVar][iDim] + TurbPsi_Grad_j[iVar][iDim]); + } + + /*--- Projection of the corrected gradient ---*/ + Proj_Mean_GradTurbPsi_Corrected[iVar] = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + Proj_Mean_GradTurbPsi_Corrected[iVar] += Mean_GradTurbPsi[iVar][iDim]*Normal[iDim]; + } + + val_residual_i[0] = -nu_e_i*Proj_Mean_GradTurbPsi_Corrected[0]; + val_residual_j[0] = nu_e_j*Proj_Mean_GradTurbPsi_Corrected[0]; + + if (implicit) { + val_Jacobian_ii[0][0] = nu_e_i*proj_vector_ij; + val_Jacobian_ij[0][0] = -nu_e_i*proj_vector_ij; + val_Jacobian_ji[0][0] = -nu_e_j*proj_vector_ij; + val_Jacobian_jj[0][0] = nu_e_j*proj_vector_ij; + } + +} + +CAvgGradCorrected_AdjTurb::CAvgGradCorrected_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + Edge_Vector = new su2double [nDim]; + Mean_GradTurbPsi = new su2double* [nVar]; + Proj_Mean_GradTurbPsi_Kappa = new su2double [nVar]; + Proj_Mean_GradTurbPsi_Edge = new su2double [nVar]; + Proj_Mean_GradTurbPsi_Corrected = new su2double [nVar]; + for (unsigned short iVar = 0; iVar < nVar; iVar++) + Mean_GradTurbPsi[iVar] = new su2double [nDim]; +} + +CAvgGradCorrected_AdjTurb::~CAvgGradCorrected_AdjTurb(void) { + delete [] Edge_Vector; + delete [] Proj_Mean_GradTurbPsi_Kappa; + delete [] Proj_Mean_GradTurbPsi_Edge; + delete [] Proj_Mean_GradTurbPsi_Corrected; + for (unsigned short iVar = 0; iVar < nVar; iVar++) { + delete [] Mean_GradTurbPsi[iVar]; + } + delete [] Mean_GradTurbPsi; +} + +void CAvgGradCorrected_AdjTurb::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, + su2double **val_Jacobian_j, CConfig *config) { + + bool implicit = (config->GetKind_TimeIntScheme_AdjTurb() == EULER_IMPLICIT); + + su2double sigma = 2./3.; + su2double nu_i, nu_j, nu_e; + su2double dist_ij_2 = 0; + su2double proj_vector_ij = 0; + unsigned short iVar, iDim; + + /*--- Compute mean effective viscosity ---*/ + nu_i = Laminar_Viscosity_i/U_i[0]; + nu_j = Laminar_Viscosity_j/U_j[0]; + nu_e = 0.5*(nu_i+nu_j+TurbVar_i[0]+TurbVar_j[0])/sigma; + + /*--- Compute vector going from iPoint to jPoint ---*/ + 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]; + } + proj_vector_ij = proj_vector_ij/dist_ij_2; + + /*--- Mean gradient approximation ---*/ + for (iVar = 0; iVar < nVar; iVar++) { + Proj_Mean_GradTurbPsi_Edge[iVar] = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + Mean_GradTurbPsi[iVar][iDim] = 0.5*(TurbPsi_Grad_i[iVar][iDim] + TurbPsi_Grad_j[iVar][iDim]); + Proj_Mean_GradTurbPsi_Edge[iVar] += Mean_GradTurbPsi[iVar][iDim]*Edge_Vector[iDim]; + } + + for (iDim = 0; iDim < nDim; iDim++) + Mean_GradTurbPsi[iVar][iDim] -= (Proj_Mean_GradTurbPsi_Edge[iVar] - (TurbPsi_j[iVar]-TurbPsi_i[iVar]))*Edge_Vector[iDim]/dist_ij_2; + + /*--- Projection of the corrected gradient ---*/ + Proj_Mean_GradTurbPsi_Corrected[iVar] = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + Proj_Mean_GradTurbPsi_Corrected[iVar] += Mean_GradTurbPsi[iVar][iDim]*Normal[iDim]; + } + + val_residual[0] = -nu_e*Proj_Mean_GradTurbPsi_Corrected[0]; + + if (implicit) { + val_Jacobian_i[0][0] = nu_e*proj_vector_ij; + val_Jacobian_j[0][0] = -nu_e*proj_vector_ij; + } + +} + +void CAvgGradCorrected_AdjTurb::ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, + su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, + su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config) { + + bool implicit = (config->GetKind_TimeIntScheme_AdjTurb() == EULER_IMPLICIT); + + su2double sigma = 2./3.; + su2double nu_i, nu_j, nu_e_i, nu_e_j; + su2double dist_ij_2 = 0; + su2double proj_vector_ij = 0; + unsigned short iVar, iDim; + + /*--- Compute mean effective viscosity ---*/ + nu_i = Laminar_Viscosity_i/U_i[0]; + nu_j = Laminar_Viscosity_j/U_j[0]; + nu_e_i = (nu_i+TurbVar_i[0])/sigma; + nu_e_j = (nu_j+TurbVar_j[0])/sigma; + + /*--- Compute vector going from iPoint to jPoint ---*/ + 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]; + } + proj_vector_ij = proj_vector_ij/dist_ij_2; // to normalize vectors + + /*--- Mean gradient approximation ---*/ + for (iVar = 0; iVar < nVar; iVar++) { + Proj_Mean_GradTurbPsi_Edge[iVar] = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + Mean_GradTurbPsi[iVar][iDim] = 0.5*(TurbPsi_Grad_i[iVar][iDim] + TurbPsi_Grad_j[iVar][iDim]); + Proj_Mean_GradTurbPsi_Edge[iVar] += Mean_GradTurbPsi[iVar][iDim]*Edge_Vector[iDim]; + } + + for (iDim = 0; iDim < nDim; iDim++) + Mean_GradTurbPsi[iVar][iDim] -= (Proj_Mean_GradTurbPsi_Edge[iVar] - + (TurbPsi_j[iVar]-TurbPsi_i[iVar]))*Edge_Vector[iDim]/dist_ij_2; + + /*--- Projection of the corrected gradient ---*/ + Proj_Mean_GradTurbPsi_Corrected[iVar] = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + Proj_Mean_GradTurbPsi_Corrected[iVar] += Mean_GradTurbPsi[iVar][iDim]*Normal[iDim]; + } + + val_residual_i[0] = -nu_e_i*Proj_Mean_GradTurbPsi_Corrected[0]; + val_residual_j[0] = nu_e_j*Proj_Mean_GradTurbPsi_Corrected[0]; + + if (implicit) { + val_Jacobian_ii[0][0] = nu_e_i*proj_vector_ij; + val_Jacobian_ij[0][0] = -nu_e_i*proj_vector_ij; + val_Jacobian_ji[0][0] = -nu_e_j*proj_vector_ij; + val_Jacobian_jj[0][0] = nu_e_j*proj_vector_ij; + } + +} diff --git a/SU2_CFD/src/numerics/continuous_adjoint/adj_sources.cpp b/SU2_CFD/src/numerics/continuous_adjoint/adj_sources.cpp new file mode 100644 index 000000000000..60a75b5f1838 --- /dev/null +++ b/SU2_CFD/src/numerics/continuous_adjoint/adj_sources.cpp @@ -0,0 +1,782 @@ +/*! + * \file adj_sources.cpp + * \brief Implementation of adjoint source numerics classes. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../include/numerics/continuous_adjoint/adj_sources.hpp" + +CSourceAxisymmetric_AdjFlow::CSourceAxisymmetric_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { } + +CSourceAxisymmetric_AdjFlow::~CSourceAxisymmetric_AdjFlow(void) { } + +void CSourceAxisymmetric_AdjFlow::ComputeResidual(su2double *val_residual, su2double **Jacobian_ii, CConfig *config) { + + su2double yinv; + su2double Jacobian_Axisymmetric[4][4]; + + if (Coord_i[1] > 0.0) yinv = 1.0/Coord_i[1]; + else yinv = 0.0; + + Jacobian_Axisymmetric[0][0] = 0; + Jacobian_Axisymmetric[0][1] = 0; + Jacobian_Axisymmetric[0][2] = 1.; + Jacobian_Axisymmetric[0][3] = 0; + + Jacobian_Axisymmetric[1][0] = -U_i[1]*U_i[2]/(U_i[0]*U_i[0]); + Jacobian_Axisymmetric[1][1] = U_i[2]/U_i[0]; + Jacobian_Axisymmetric[1][2] = U_i[1]/U_i[0]; + Jacobian_Axisymmetric[1][3] = 0; + + Jacobian_Axisymmetric[2][0] = -U_i[2]*U_i[2]/(U_i[0]*U_i[0]); + Jacobian_Axisymmetric[2][1] = 0; + Jacobian_Axisymmetric[2][2] = 2*U_i[2]/U_i[0]; + Jacobian_Axisymmetric[2][3] = 0; + + Jacobian_Axisymmetric[3][0] = -Gamma*U_i[2]*U_i[3]/(U_i[0]*U_i[0]) + (Gamma-1)*U_i[2]*(U_i[1]*U_i[1]+U_i[2]*U_i[2])/(U_i[0]*U_i[0]*U_i[0]); + Jacobian_Axisymmetric[3][1] = -(Gamma-1)*U_i[2]*U_i[1]/(U_i[0]*U_i[0]); + Jacobian_Axisymmetric[3][2] = Gamma*U_i[3]/U_i[0] - 1/2*(Gamma-1)*( (U_i[1]*U_i[1]+U_i[2]*U_i[2])/(U_i[0]*U_i[0]) + 2*U_i[2]*U_i[2]/(U_i[0]*U_i[0]) ); + Jacobian_Axisymmetric[3][3] = Gamma*U_i[2]/U_i[0]; + + for (int iVar=0; iVar<4; iVar++) + for (int jVar=0; jVar<4; jVar++) + Jacobian_Axisymmetric[iVar][jVar] *= yinv*Volume; + + /* -- Residual = transpose(Jacobian) * psi --*/ + for (int iVar = 0; iVar < nVar; iVar++) { + val_residual[iVar] = 0.0; + for (int jVar = 0; jVar < nVar; jVar++) { + val_residual[iVar] += Jacobian_Axisymmetric[jVar][iVar]*Psi_i[jVar]; + Jacobian_ii[iVar][jVar] = Jacobian_Axisymmetric[jVar][iVar]; + } + } +} + +CSourceConservative_AdjFlow::CSourceConservative_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + + Velocity = new su2double [nDim]; + Residual_i = new su2double [nVar]; + Residual_j = new su2double [nVar]; + Mean_Residual = new su2double [nVar]; + + Mean_PrimVar_Grad = new su2double* [nVar]; + for (unsigned short iVar = 0; iVar < nVar; iVar++) + Mean_PrimVar_Grad[iVar] = new su2double [nDim]; +} + +CSourceConservative_AdjFlow::~CSourceConservative_AdjFlow(void) { + delete [] Mean_Residual; + delete [] Residual_j; + delete [] Residual_i; + delete [] Velocity; + + for (unsigned short iVar = 0; iVar < nVar; iVar++) + delete [] Mean_PrimVar_Grad[iVar]; + delete [] Mean_PrimVar_Grad; +} + +void CSourceConservative_AdjFlow::ComputeResidual (su2double *val_residual, CConfig *config) { + unsigned short iDim, jDim, iVar; + su2double rho, nu, Ji, fv1, fv2, Omega, Shat, dist_sq, Ji_2, Ji_3, one_o_oneplusJifv1; + su2double r, g, g_6, glim, dfw_g, dg_r, dr_nuhat, dr_Shat, Ms_coeff, invOmega; + + su2double cv1_3 = 7.1*7.1*7.1; + su2double k2 = 0.41*0.41; + su2double cb1 = 0.1355; + su2double cw2 = 0.3; + su2double cw3_6 = pow(2.0,6.0); + su2double sigma = 2./3.; + su2double cb2 = 0.622; + su2double cw1 = cb1/k2+(1+cb2)/sigma; + + for (iVar = 0; iVar < nVar; iVar++) { + Residual_i[iVar] = 0.0; + Residual_j[iVar] = 0.0; + } + + /*--- iPoint ---*/ + + /*--- Density and velocities ---*/ + + rho = U_i[0]; + for (iDim = 0; iDim < nDim; iDim++) + Velocity[iDim] = U_i[iDim+1]/rho; + + /*--- Vorticity ---*/ + + Omega = (PrimVar_Grad_i[1][1]-PrimVar_Grad_i[2][0])*(PrimVar_Grad_i[1][1]-PrimVar_Grad_i[2][0]); + if (nDim == 3) Omega += (PrimVar_Grad_i[1][2]-PrimVar_Grad_i[3][0])*(PrimVar_Grad_i[1][2]-PrimVar_Grad_i[3][0]) + + (PrimVar_Grad_i[2][2]-PrimVar_Grad_i[3][1])*(PrimVar_Grad_i[2][2]-PrimVar_Grad_i[3][1]); + Omega = sqrt(Omega); + invOmega = 1.0/(Omega + TURB_EPS); + + /*--- Compute Ms_coeff -> coming from partial derivatives ---*/ + + Ms_coeff = 0.0; + if (dist_i > 0) { + dist_sq = dist_i*dist_i; + nu = Laminar_Viscosity_i/rho; + Ji = TurbVar_i[0]/nu; + Ji_2 = Ji*Ji; + Ji_3 = Ji_2*Ji; + fv1 = Ji_3/(Ji_3+cv1_3); + one_o_oneplusJifv1 = 1.0/(1.0+Ji*fv1); + fv2 = 1.0 - Ji*one_o_oneplusJifv1; + Shat = max(Omega + TurbVar_i[0]*fv2/(k2*dist_sq), TURB_EPS); + + r = min(TurbVar_i[0]/(Shat*k2*dist_sq),10.); + g = r + cw2*(pow(r,6.)-r); + g_6 = pow(g,6.); + glim = pow((1+cw3_6)/(g_6+cw3_6),1./6.); + + dfw_g = glim*cw3_6/(g_6+cw3_6); + dg_r = 1.0 + cw2*(6.0*pow(r,5.0)-1.0); + dr_nuhat = 1.0/(Shat*k2*dist_sq); + dr_Shat = -dr_nuhat*TurbVar_i[0]/Shat; + + Ms_coeff = (cb1*TurbVar_i[0]-cw1*TurbVar_i[0]*TurbVar_i[0]/dist_sq*dfw_g*dg_r*dr_Shat); + } + Ms_coeff *= TurbPsi_i[0]*invOmega/rho; + + /*--- Compute residual of iPoint ---*/ + + for (iDim = 0; iDim < nDim; iDim++) { + for (jDim = 0; jDim < nDim; jDim++) { + Residual_i[0] -= Ms_coeff*(Velocity[jDim]*PrimVar_Grad_i[jDim+1][iDim]*Normal[iDim] - + Velocity[jDim]*PrimVar_Grad_i[iDim+1][jDim]*Normal[iDim]); + Residual_i[iDim+1] += Ms_coeff*(PrimVar_Grad_i[iDim+1][jDim]*Normal[jDim] - + PrimVar_Grad_i[jDim+1][iDim]*Normal[jDim]); + } + } + + /*--- jPoint ---*/ + + /*--- Density and velocities ---*/ + + rho = U_j[0]; + for (iDim = 0; iDim < nDim; iDim++) + Velocity[iDim] = U_j[iDim+1]/rho; + + /*--- Vorticity ---*/ + + Omega = (PrimVar_Grad_j[1][1]-PrimVar_Grad_j[2][0])*(PrimVar_Grad_j[1][1]-PrimVar_Grad_j[2][0]); + if (nDim == 3) Omega += (PrimVar_Grad_j[1][2]-PrimVar_Grad_j[3][0])*(PrimVar_Grad_j[1][2]-PrimVar_Grad_j[3][0]) + + (PrimVar_Grad_j[2][2]-PrimVar_Grad_j[3][1])*(PrimVar_Grad_j[2][2]-PrimVar_Grad_j[3][1]); + Omega = sqrt(Omega); + invOmega = 1.0/(Omega + TURB_EPS); + + /*--- Compute Ms_coeff -> coming from partial derivatives ---*/ + + Ms_coeff = 0.0; + if (dist_j > 0) { + dist_sq = dist_j*dist_j; + nu = Laminar_Viscosity_j/rho; + Ji = TurbVar_j[0]/nu; + Ji_2 = Ji*Ji; + Ji_3 = Ji_2*Ji; + fv1 = Ji_3/(Ji_3+cv1_3); + one_o_oneplusJifv1 = 1.0/(1.0+Ji*fv1); + fv2 = 1.0 - Ji*one_o_oneplusJifv1; + Shat = max(Omega + TurbVar_j[0]*fv2/(k2*dist_sq), TURB_EPS); + + r = min(TurbVar_j[0]/(Shat*k2*dist_sq),10.); + g = r + cw2*(pow(r,6.)-r); + g_6 = pow(g,6.); + glim = pow((1+cw3_6)/(g_6+cw3_6),1./6.); + + dfw_g = glim*cw3_6/(g_6+cw3_6); + dg_r = 1.0 + cw2*(6.0*pow(r,5.0)-1.0); + dr_nuhat = 1.0/(Shat*k2*dist_sq); + dr_Shat = -dr_nuhat*TurbVar_j[0]/Shat; + + Ms_coeff = (cb1*TurbVar_j[0]-cw1*TurbVar_j[0]*TurbVar_j[0]/dist_sq*dfw_g*dg_r*dr_Shat); + } + Ms_coeff *= TurbPsi_j[0]*invOmega/rho; + + /*--- Compute residual of jPoint ---*/ + + for (iDim = 0; iDim < nDim; iDim++) { + for (jDim = 0; jDim < nDim; jDim++) { + Residual_j[0] -= Ms_coeff*(Velocity[jDim]*PrimVar_Grad_j[jDim+1][iDim]*Normal[iDim] - + Velocity[jDim]*PrimVar_Grad_j[iDim+1][jDim]*Normal[iDim]); + Residual_j[iDim+1] += Ms_coeff*(PrimVar_Grad_j[iDim+1][jDim]*Normal[jDim] - + PrimVar_Grad_j[jDim+1][iDim]*Normal[jDim]); + } + } + + /*--- Compute the mean residual ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + val_residual[iVar] = 0.5*(Residual_i[iVar] + Residual_j[iVar]); + +} + +CSourceRotatingFrame_AdjFlow::CSourceRotatingFrame_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : + CNumerics(val_nDim, val_nVar, config) { } + +CSourceRotatingFrame_AdjFlow::~CSourceRotatingFrame_AdjFlow(void) { } + +void CSourceRotatingFrame_AdjFlow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config) { + + unsigned short iDim, iVar, jVar; + su2double Omega[3] = {0,0,0}, Phi[3] = {0,0,0}; + bool implicit = (config->GetKind_TimeIntScheme_AdjFlow() == EULER_IMPLICIT); + + /*--- Retrieve the angular velocity vector from config. ---*/ + + for (iDim = 0; iDim < 3; iDim++){ + Omega[iDim] = config->GetRotation_Rate(iDim)/config->GetOmega_Ref(); + } + + /*--- Get the adjoint velocity vector at the current node. ---*/ + + for (iDim = 0; iDim < nDim; iDim++) + Phi[iDim] = Psi_i[iDim+1]; + + /*--- Compute the source term as the Jacobian of the rotating frame + source term multiplied by the adjoint state and the dual cell volume. ---*/ + + if (nDim == 2) { + val_residual[0] = 0.0; + val_residual[1] = Omega[2]*Phi[1]*Volume; + val_residual[2] = -Omega[2]*Phi[0]*Volume; + val_residual[3] = 0.0; + } else { + val_residual[0] = 0.0; + val_residual[1] = (Omega[2]*Phi[1] - Omega[1]*Phi[2])*Volume; + val_residual[2] = (Omega[0]*Phi[2] - Omega[2]*Phi[0])*Volume; + val_residual[3] = (Omega[1]*Phi[0] - Omega[0]*Phi[1])*Volume; + val_residual[4] = 0.0; + } + + /*--- Calculate the source term Jacobian ---*/ + + if (implicit) { + for (iVar = 0; iVar < nVar; iVar++) + for (jVar = 0; jVar < nVar; jVar++) + val_Jacobian_i[iVar][jVar] = 0.0; + if (nDim == 2) { + val_Jacobian_i[1][2] = Omega[2]*Volume; + val_Jacobian_i[2][1] = -Omega[2]*Volume; + } else { + val_Jacobian_i[1][2] = Omega[2]*Volume; + val_Jacobian_i[1][3] = -Omega[1]*Volume; + val_Jacobian_i[2][1] = -Omega[2]*Volume; + val_Jacobian_i[2][3] = Omega[0]*Volume; + val_Jacobian_i[3][1] = Omega[1]*Volume; + val_Jacobian_i[3][2] = -Omega[0]*Volume; + } + } + +} + +CSourceViscous_AdjFlow::CSourceViscous_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : + CNumerics(val_nDim, val_nVar, config) { + unsigned short iDim; + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + + Velocity = new su2double [nVar]; + GradDensity = new su2double [nDim]; + GradInvDensity = new su2double [nDim]; + dPoDensity2 = new su2double [nDim]; + alpha = new su2double [nDim]; + beta = new su2double [nDim]; + Sigma_5_vec = new su2double [nDim]; + + GradVel_o_Rho = new su2double* [nDim]; + sigma = new su2double* [nDim]; + Sigma_phi = new su2double* [nDim]; + Sigma_5_Tensor = new su2double* [nDim]; + Sigma = new su2double* [nDim]; + + for (iDim = 0; iDim < nDim; iDim++) { + GradVel_o_Rho[iDim] = new su2double [nDim]; + sigma[iDim] = new su2double [nDim]; + Sigma_phi[iDim] = new su2double [nDim]; + Sigma_5_Tensor[iDim] = new su2double [nDim]; + Sigma[iDim] = new su2double [nDim]; + } + +} + +CSourceViscous_AdjFlow::~CSourceViscous_AdjFlow(void) { + unsigned short iDim; + + for (iDim = 0; iDim < nDim; iDim++) { + delete [] GradVel_o_Rho[iDim]; + delete [] sigma[iDim]; + delete [] Sigma_phi[iDim]; + delete [] Sigma_5_Tensor[iDim]; + delete [] Sigma[iDim]; + } + + delete [] GradVel_o_Rho; + delete [] sigma; + delete [] Sigma_phi; + delete [] Sigma_5_Tensor; + delete [] Sigma; + + delete [] Velocity; + delete [] GradDensity; + delete [] GradInvDensity; + delete [] dPoDensity2; + delete [] alpha; + delete [] beta; + delete [] Sigma_5_vec; + +} + +void CSourceViscous_AdjFlow::ComputeResidual (su2double *val_residual, CConfig *config) { + + unsigned short iDim, jDim; + +// su2double Temperature = V_i[0]; + su2double Pressure = V_i[nDim+1]; + su2double Density = V_i[nDim+2]; +// su2double Enthalpy = V_i[nDim+3]; + su2double Laminar_Viscosity = V_i[nDim+5]; + su2double Eddy_Viscosity = V_i[nDim+6]; + +// su2double Energy = Enthalpy - Pressure/Density; + su2double invDensity = 1.0/Density; + su2double invDensitysq = invDensity*invDensity; + su2double invDensitycube = invDensitysq*invDensity; + su2double Prandtl_Lam = config->GetPrandtl_Lam(); + su2double Prandtl_Turb = config->GetPrandtl_Turb(); + su2double mu_tot_1 = Laminar_Viscosity + Eddy_Viscosity; + su2double mu_tot_2 = Laminar_Viscosity/Prandtl_Lam + Eddy_Viscosity/Prandtl_Turb; +// su2double Gas_Constant = config->GetGas_ConstantND(); + + /*--- Required gradients of the flow variables, point j ---*/ + + for (iDim = 0; iDim < nDim; iDim++) { + + /*--- Gradient density ---*/ + + GradDensity[iDim] = PrimVar_Grad_i[nDim+2][iDim]; + + /*--- Gradient (1/rho) ---*/ + + GradInvDensity[iDim] = -GradDensity[iDim]*invDensitysq; + + /*--- Computation of the derivatives of P/(Density^2) ---*/ + + dPoDensity2[iDim] = (PrimVar_Grad_i[nVar-1][iDim]*Density - 2.0*GradDensity[iDim]*Pressure)*invDensitycube; + + /*--- Abbreviations: alpha, beta, sigma_5_vec ---*/ + + alpha[iDim] = Gamma*mu_tot_2*GradInvDensity[iDim]; + beta[iDim] = Gamma*mu_tot_2*dPoDensity2[iDim]/Gamma_Minus_One; + Sigma_5_vec[iDim] = Gamma*mu_tot_2*PsiVar_Grad_i[nVar-1][iDim]; + + } + + /*--- Definition of tensors and derivatives of velocity over density ---*/ + + su2double div_vel = 0.0, div_phi = 0.0, vel_gradpsi5 = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + div_vel += PrimVar_Grad_i[iDim+1][iDim]; + div_phi += PsiVar_Grad_i[iDim+1][iDim]; + vel_gradpsi5 += V_i[iDim+1]*PsiVar_Grad_i[nVar-1][iDim]; + for (jDim = 0; jDim < nDim; jDim++) { + sigma[iDim][jDim] = mu_tot_1*(PrimVar_Grad_i[iDim+1][jDim]+PrimVar_Grad_i[jDim+1][iDim]); + Sigma_phi[iDim][jDim] = mu_tot_1*(PsiVar_Grad_i[iDim+1][jDim]+PsiVar_Grad_i[jDim+1][iDim]); + Sigma_5_Tensor[iDim][jDim] = mu_tot_1*(V_i[jDim+1]*PsiVar_Grad_i[nVar-1][iDim]+V_i[iDim+1]*PsiVar_Grad_i[nVar-1][jDim]); + GradVel_o_Rho[iDim][jDim] = (PrimVar_Grad_i[iDim+1][jDim]*Density - V_i[iDim+1]*GradDensity[jDim])*invDensitysq; + } + } + + for (iDim = 0; iDim < nDim; iDim++) { + sigma[iDim][iDim] -= TWO3*mu_tot_1*div_vel; + Sigma_phi[iDim][iDim] -= TWO3*mu_tot_1*div_phi; + Sigma_5_Tensor[iDim][iDim] -= TWO3*mu_tot_1*vel_gradpsi5; + } + + for (iDim = 0; iDim < nDim; iDim++) { + for (jDim = 0; jDim < nDim; jDim++) { + Sigma[iDim][jDim] = Sigma_phi[iDim][jDim] + Sigma_5_Tensor[iDim][jDim]; + } + } + + /*--- Vector-Tensors products ---*/ + + su2double gradT_gradpsi5 = 0.0, sigma_gradpsi = 0.0, vel_sigma_gradpsi5 = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + gradT_gradpsi5 += PrimVar_Grad_i[0][iDim]*PsiVar_Grad_i[nVar-1][iDim]; + for (jDim = 0; jDim < nDim; jDim++) { + sigma_gradpsi += sigma[iDim][jDim]*PsiVar_Grad_i[jDim+1][iDim]; + vel_sigma_gradpsi5 += V_i[iDim+1]*sigma[iDim][jDim]*PsiVar_Grad_i[nVar-1][jDim]; + } + } + + /*--- Residuals ---*/ + + su2double alpha_gradpsi5 = 0.0, beta_gradpsi5 = 0.0, Sigma_gradvel_o_rho = 0.0, Sigma5_vel_gradvel = 0.0, sq_vel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + alpha_gradpsi5 += alpha[iDim]*PsiVar_Grad_i[nVar-1][iDim]; + beta_gradpsi5 += beta[iDim]*PsiVar_Grad_i[nVar-1][iDim]; + for (jDim = 0; jDim < nDim; jDim++) { + Sigma_gradvel_o_rho += Sigma[iDim][jDim]*GradVel_o_Rho[iDim][jDim]; + Sigma5_vel_gradvel += Sigma_5_vec[iDim]*(V_i[jDim+1]*PrimVar_Grad_i[jDim+1][iDim]); + } + sq_vel += V_i[iDim+1]*V_i[iDim+1]; + } + + val_residual[0] = (-vel_sigma_gradpsi5*invDensity + 0.5*sq_vel*alpha_gradpsi5 - + beta_gradpsi5) * Volume; + for (iDim = 0; iDim < nDim; iDim++) { + val_residual[iDim+1] = 0.0; + for (jDim = 0; jDim < nDim; jDim++) { + val_residual[iDim+1] += (sigma[iDim][jDim]*PsiVar_Grad_i[nVar-1][jDim]*invDensity - V_i[iDim+1]*alpha[jDim]*PsiVar_Grad_i[nVar-1][jDim]) * Volume; + } + } + val_residual[nVar-1] = alpha_gradpsi5 * Volume; + +// val_residual[0] += (Sigma5_vel_gradvel*invDensity - Sigma_gradvel_o_rho) * Volume; +// for (iDim = 0; iDim < nDim; iDim++) { +// for (jDim = 0; jDim < nDim; jDim++) { +// val_residual[iDim+1] += (Sigma[iDim][jDim]*GradInvDensity[jDim] - +// Sigma_5_vec[jDim]*PrimVar_Grad_i[iDim+1][jDim]*invDensity) * Volume; +// } +// } + + /*--- Laminar viscosity sensitivity for NS ---*/ + + if (config->GetKind_Solver() != ADJ_RANS) { + +// su2double Temperature_Ref = config->GetTemperature_Ref(); +// su2double Temperature_Dim = Temperature*Temperature_Ref; +// +// su2double S = 0.0; +// if (config->GetSystemMeasurements() == SI) { S = 110.4; } +// if (config->GetSystemMeasurements() == US) { S = 198.72; } +// su2double dVisc_T = ((Laminar_Viscosity)/(2.0*Temperature_Dim*(Temperature_Dim + S)))*(Temperature_Dim + 3.0*S)*Temperature_Ref; +// +// su2double Cp = (Gamma/Gamma_Minus_One)*Gas_Constant; +// su2double kappa_psi = (sigma_gradpsi + vel_sigma_gradpsi5)/mu_tot_1; +// su2double theta = (kappa_psi + Cp/Prandtl_Lam*gradT_gradpsi5)*dVisc_T*Gamma_Minus_One/(Gas_Constant*Density); +// +// val_residual[0] += (theta*(sq_vel-Energy))*Volume; +// for (iDim = 0; iDim < nDim; iDim++) +// val_residual[iDim+1] -= theta*V_i[iDim+1]*Volume; +// val_residual[nVar-1] += theta*Volume; + + } + +// /*--- Coupling terms coming from the continuous adjoint turbulent equations ---*/ +// +// if ((config->GetKind_Solver() == ADJ_RANS) && (!config->GetFrozen_Visc_Cont())) { +// +// /*--- Closure constants ---*/ +// +// su2double cv1_3 = 7.1*7.1*7.1; +// su2double k2 = 0.41*0.41; +// su2double cb1 = 0.1355; +// su2double cw2 = 0.3; +// su2double cw3_6 = pow(2.0,6.0); +// su2double sigma = 2./3.; +// su2double cb2 = 0.622; +// su2double cw1 = cb1/k2+(1+cb2)/sigma; +// +// su2double nu, Ji, Ji_2, Ji_3, fv1; +// nu = Laminar_Viscosity/Density; +// Ji = TurbVar_i[0]/nu; +// Ji_2 = Ji*Ji; +// Ji_3 = Ji_2*Ji; +// fv1 = Ji_3/(Ji_3+cv1_3); +// +// /*--- Contributions due to variation of viscosities ---*/ +// +// su2double Temperature_Ref = config->GetTemperature_Ref(); +// su2double Temperature_Dim = Temperature*Temperature_Ref; +// +// su2double S = 0.0; +// if (config->GetSystemMeasurements() == SI) { S = 110.4; } +// if (config->GetSystemMeasurements() == US) { S = 198.72; } +// su2double dVisc_T = ((Laminar_Viscosity)/(2.0*Temperature_Dim*(Temperature_Dim + S)))*(Temperature_Dim + 3.0*S)*Temperature_Ref; +// +// su2double Cp = (Gamma/Gamma_Minus_One)*Gas_Constant; +// su2double kappa_psi = (sigma_gradpsi + vel_sigma_gradpsi5)/mu_tot_1 + Cp/Prandtl_Turb*gradT_gradpsi5; +// su2double cv1_const = 3.0*cv1_3/(Ji_3+cv1_3); +// su2double theta = (kappa_psi*(1.0-Eddy_Viscosity/Laminar_Viscosity*cv1_const) - +// Cp/Prandtl_Turb*gradT_gradpsi5*(1.0-Prandtl_Turb/Prandtl_Lam))*dVisc_T*Gamma_Minus_One/(Gas_Constant*Density); +// su2double xi = kappa_psi*(1.0+cv1_const)*Eddy_Viscosity/Density; +// +// val_residual[0] += (theta*(sq_vel-Energy) + xi)*Volume; +// for (iDim = 0; iDim < nDim; iDim++) +// val_residual[iDim+1] -= theta*V_i[iDim+1]*Volume; +// val_residual[nVar-1] += theta*Volume; +// +// /*--- Coupling residuals ---*/ +// +// if (dist_i > 0.0) { +// su2double fv2, Omega, Shat, dist_0_2, one_o_oneplusJifv1; +// su2double r, g, g_6, glim, fw; +// su2double dfw_g, dg_r, dr_nuhat, dr_Shat; +// su2double dShat_fv2, dfv2_fv1, dfv1_Ji, dJi_nu, dJi_nuhat, dfv2_Ji; +// +// /*--- Vorticity ---*/ +// Omega = (PrimVar_Grad_i[1][1]-PrimVar_Grad_i[2][0])*(PrimVar_Grad_i[1][1]-PrimVar_Grad_i[2][0]); +// if (nDim == 3) Omega += (PrimVar_Grad_i[1][2]-PrimVar_Grad_i[3][0])*(PrimVar_Grad_i[1][2]-PrimVar_Grad_i[3][0]) + +// (PrimVar_Grad_i[2][2]-PrimVar_Grad_i[3][1])*(PrimVar_Grad_i[2][2]-PrimVar_Grad_i[3][1]); +// Omega = sqrt(Omega); +// +// dist_0_2 = dist_i*dist_i; +// one_o_oneplusJifv1 = 1.0/(1.0+Ji*fv1); +// fv2 = 1.0 - Ji*one_o_oneplusJifv1; +// Shat = max(Omega + TurbVar_i[0]*fv2/(k2*dist_0_2), TURB_EPS); +// +// r = min(TurbVar_i[0]/(Shat*k2*dist_0_2), 10.); +// g = r + cw2*(pow(r,6.)-r); +// g_6 = pow(g,6.); +// glim = pow((1+cw3_6)/(g_6+cw3_6),1./6.); +// fw = g*glim; +// +// dfw_g = glim*cw3_6/(g_6+cw3_6); +// dg_r = 1.0 + cw2*(6.0*pow(r,5.0)-1.0); +// dr_nuhat = 1.0/(Shat*k2*dist_0_2); +// dr_Shat = -dr_nuhat*TurbVar_i[0]/Shat; +// +// dShat_fv2 = TurbVar_i[0]/(k2*dist_0_2); +// dfv2_fv1 = Ji_2*one_o_oneplusJifv1*one_o_oneplusJifv1; +// dfv1_Ji = 3.0*cv1_3*Ji_2/((Ji_3+cv1_3)*(Ji_3+cv1_3)); +// dJi_nuhat = 1.0/nu; +// dJi_nu = -Ji/nu; +// dfv2_Ji = -one_o_oneplusJifv1*one_o_oneplusJifv1; +// +// /*--- Terms 1 & 2: -Fcv\B7nabla(TurbPsi_i) - Fs\B7TurbPsi_i ---*/ +// +// su2double gradTurbVar_gradTurbPsi = 0, vel_gradTurbPsi = 0; +// for (iDim = 0; iDim < nDim; iDim++) { +// gradTurbVar_gradTurbPsi += TurbVar_Grad_i[0][iDim]*TurbPsi_Grad_i[0][iDim]; +// vel_gradTurbPsi += V_i[iDim+1]*TurbPsi_Grad_i[0][iDim]; +// } +// +// su2double alpha_coeff = Gamma_Minus_One/(Gas_Constant*Density)*dVisc_T; +// su2double beta_coeff = alpha_coeff*(sq_vel-Energy)-Laminar_Viscosity_i/Density; +// su2double Fs_coeff = TurbPsi_i[0]*(cb1*TurbVar_i[0]-cw1*TurbVar_i[0]*TurbVar_i[0]/dist_0_2*dfw_g*dg_r*dr_Shat)* +// dShat_fv2*(dfv2_Ji+dfv2_fv1*dfv1_Ji)*dJi_nu; +// su2double Gamma = Fs_coeff - gradTurbVar_gradTurbPsi/sigma; +// +// val_residual[0] -= (Gamma*beta_coeff - TurbVar_i[0]*vel_gradTurbPsi)/Density*Volume; +// for (iDim = 0; iDim < nDim; iDim++) +// val_residual[iDim+1] += (Gamma*alpha_coeff*V_i[iDim+1] - TurbVar_i[0]*TurbPsi_Grad_i[0][iDim])/Density*Volume; +// val_residual[nVar-1] -= (Gamma*alpha_coeff)/Density*Volume; +// +// // this should improve stability (when commented): +// /*--- Terms 3: -partial{T^s}_GradVel x GradN ---*/ +// // su2double Ms_coeff = (cb1*TurbVar_i[0]-cw1*TurbVar_i[0]*TurbVar_i[0]/dist_0_2*dfw_g*dg_r*dr_Shat); +// // Ms_coeff *= TurbPsi_i[0]/(Omega + TURB_EPS); +// // +// // for (iDim = 0; iDim < nDim; iDim++) { +// // for (jDim = 0; jDim < nDim; jDim++) { +// // val_residual[0] += Ms_coeff*(PrimVar_Grad_i[iDim+1][jDim]-PrimVar_Grad_i[jDim+1][iDim])* +// // GradVel_o_Rho[iDim][jDim]*dV; +// // val_residual[iDim+1] -= Ms_coeff*(PrimVar_Grad_i[iDim+1][jDim]-PrimVar_Grad_i[jDim+1][iDim])* +// // GradInvDensity[jDim]*dV; +// // } +// // } +// +// } +// } + +} + +CSourceConservative_AdjTurb::CSourceConservative_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + +} + +CSourceConservative_AdjTurb::~CSourceConservative_AdjTurb(void) { +} + +void CSourceConservative_AdjTurb::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { + + /*--- SOURCE term --> \nabla ( \psi_\mu \B7 E^{s} ) + E^{s} = 2 c_{b2}/\sigma \nabla \hat{nu} ---*/ + + unsigned short iDim; + bool implicit = (config->GetKind_TimeIntScheme_AdjTurb() == EULER_IMPLICIT); + + su2double cb2 = 0.622; + su2double sigma = 2./3.; + su2double coeff = 2.0*cb2/sigma; + su2double E_ij, proj_TurbVar_Grad_i, proj_TurbVar_Grad_j; + + E_ij = 0.0; proj_TurbVar_Grad_i = 0.0; proj_TurbVar_Grad_j = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + proj_TurbVar_Grad_i += coeff*TurbVar_Grad_i[0][iDim]*Normal[iDim]; + proj_TurbVar_Grad_j += coeff*TurbVar_Grad_j[0][iDim]*Normal[iDim]; + E_ij += 0.5*(TurbPsi_i[0]*proj_TurbVar_Grad_i + TurbPsi_j[0]*proj_TurbVar_Grad_j); + } + + val_residual[0] = E_ij; + + if (implicit) { + val_Jacobian_i[0][0] = 0.5*proj_TurbVar_Grad_i; + val_Jacobian_j[0][0] = 0.5*proj_TurbVar_Grad_j; + } +} + + +CSourcePieceWise_AdjTurb::CSourcePieceWise_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + + Velocity = new su2double [nDim]; + tau = new su2double* [nDim]; + for (unsigned short iDim = 0; iDim < nDim; iDim++) + tau[iDim] = new su2double [nDim]; +} + +CSourcePieceWise_AdjTurb::~CSourcePieceWise_AdjTurb(void) { + delete [] Velocity; + + for (unsigned short iDim = 0; iDim < nDim; iDim++) + delete [] tau[iDim]; + delete [] tau; +} + +void CSourcePieceWise_AdjTurb::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { + unsigned short iDim, jDim; + + bool implicit = (config->GetKind_TimeIntScheme_AdjTurb() == EULER_IMPLICIT); + su2double Prandtl_Turb = config->GetPrandtl_Turb(); + + val_residual[0] = 0.0; + if (implicit) + val_Jacobian_i[0][0] = 0.0; + + if (dist_i > 0.0) { + + /*--- Computation of Vorticity and Divergence of velocity ---*/ + su2double div_vel = 0; + for (iDim = 0; iDim < nDim; iDim++) { + Velocity[iDim] = U_i[iDim+1]/U_i[0]; + div_vel += PrimVar_Grad_i[iDim+1][iDim]; + } + + su2double Vorticity = (PrimVar_Grad_i[2][0]-PrimVar_Grad_i[1][1])*(PrimVar_Grad_i[2][0]-PrimVar_Grad_i[1][1]); + if (nDim == 3) + Vorticity += ( (PrimVar_Grad_i[3][1]-PrimVar_Grad_i[2][2])*(PrimVar_Grad_i[3][1]-PrimVar_Grad_i[2][2]) + + (PrimVar_Grad_i[1][2]-PrimVar_Grad_i[3][0])*(PrimVar_Grad_i[1][2]-PrimVar_Grad_i[3][0]) ); + Vorticity = sqrt(Vorticity); + + /*--- FIRST PART: -Bs*TurbPsi_i ---*/ + /*--- CLOUSURE CONSTANTS ---*/ + su2double cv1 = 7.1; + su2double cv1_3 = cv1*cv1*cv1; + su2double k = 0.41; + su2double k2 = k*k; + su2double cb1 = 0.1355; + su2double cw2 = 0.3; + su2double cw3_6 = pow(2.0,6.0); + su2double sigma = 2./3.; + su2double cb2 = 0.622; + su2double cw1 = cb1/k2+(1+cb2)/sigma; + + su2double nu, Ji, fv1, fv2, Shat, dist_0_2, Ji_2, Ji_3, one_o_oneplusJifv1; + su2double r, g, g_6, glim, fw; + su2double dTs_nuhat, dTs_Shat, dShat_nuhat, dTs_fw, dfw_g, dg_r, dr_nuhat, dr_Shat; + su2double dShat_fv2, dfv2_fv1, dfv1_Ji, dJi_nuhat, dfv2_Ji; + su2double Bs; + + dist_0_2 = dist_i*dist_i; + nu = Laminar_Viscosity_i/U_i[0]; + Ji = TurbVar_i[0]/nu; + Ji_2 = Ji*Ji; + Ji_3 = Ji_2*Ji; + fv1 = Ji_3/(Ji_3+cv1_3); + one_o_oneplusJifv1 = 1.0/(1.0+Ji*fv1); + fv2 = 1.0 - Ji*one_o_oneplusJifv1; + Shat = max(Vorticity + TurbVar_i[0]*fv2/(k2*dist_0_2), TURB_EPS); + + // r = TurbVar_i[0]/(Shat*k2*dist_0_2); + r = min(TurbVar_i[0]/(Shat*k2*dist_0_2),10.); + g = r + cw2*(pow(r,6.)-r); + g_6 = pow(g,6.); + glim = pow((1+cw3_6)/(g_6+cw3_6),1./6.); + fw = g*glim; + + dTs_nuhat = cb1*Shat-2.0*cw1*fw*TurbVar_i[0]/dist_0_2; + dTs_Shat = cb1*TurbVar_i[0]; + dTs_fw = -cw1*TurbVar_i[0]*TurbVar_i[0]/dist_0_2; + dfw_g = glim*cw3_6/(g_6+cw3_6); + dg_r = 1.0 + cw2*(6.0*pow(r,5.0)-1.0); + dr_nuhat = 1.0/(Shat*k2*dist_0_2); + dr_Shat = -dr_nuhat*TurbVar_i[0]/Shat; + + dShat_nuhat = fv2/(k2*dist_0_2); + dShat_fv2 = TurbVar_i[0]/(k2*dist_0_2); + dfv2_fv1 = Ji_2*one_o_oneplusJifv1*one_o_oneplusJifv1; + dfv1_Ji = 3.0*cv1_3*Ji_2/((Ji_3+cv1_3)*(Ji_3+cv1_3)); + dJi_nuhat = 1.0/nu; + dfv2_Ji = -one_o_oneplusJifv1*one_o_oneplusJifv1; + dShat_nuhat += dShat_fv2*(dfv2_fv1*dfv1_Ji+dfv2_Ji)*dJi_nuhat; + + Bs = dTs_nuhat; // nu_hat term + Bs += dTs_Shat*dShat_nuhat; // S_hat term + Bs += dTs_fw*dfw_g*dg_r*(dr_nuhat+dr_Shat*dShat_nuhat); // fw terms + + val_residual[0] = -Bs*TurbPsi_i[0]*Volume; + + if (implicit) + val_Jacobian_i[0][0] = -Bs*Volume; + + /*---SECOND PART: \partial_nu_hat mu^k F^{vk} cdot \grad Psi ---*/ + su2double dEddyVisc_nuhat; + if (!config->GetFrozen_Visc_Cont()) + dEddyVisc_nuhat = U_i[0]*fv1*(1.0 + 3.0*cv1_3/(Ji_3+cv1_3)); + else + dEddyVisc_nuhat = 0; + + for (iDim = 0; iDim < nDim; iDim++) { + for (jDim = 0; jDim < nDim; jDim++) + tau[iDim][jDim] = PrimVar_Grad_i[iDim+1][jDim] + PrimVar_Grad_i[jDim+1][iDim]; + tau[iDim][iDim] -= TWO3*div_vel; + } + + su2double Gas_Constant = config->GetGas_ConstantND(); + su2double Cp = (Gamma/Gamma_Minus_One)*Gas_Constant; + su2double tau_gradphi = 0.0, vel_tau_gradpsi5 = 0.0, gradT_gradpsi5 = 0.0; + + for (iDim = 0; iDim < nDim; iDim++) { + gradT_gradpsi5 += PrimVar_Grad_i[0][iDim]*PsiVar_Grad_i[nVar-1][iDim]; + for (jDim = 0; jDim < nDim; jDim++) { + tau_gradphi += tau[iDim][jDim]*PsiVar_Grad_i[iDim+1][jDim]; + vel_tau_gradpsi5 += Velocity[iDim]*tau[iDim][jDim]*PsiVar_Grad_i[nVar-1][jDim]; + } + } + val_residual[0] += (tau_gradphi + vel_tau_gradpsi5 + Cp/Prandtl_Turb*gradT_gradpsi5)*dEddyVisc_nuhat*Volume; + + } +} diff --git a/SU2_CFD/src/numerics/elasticity/CFEAElasticity.cpp b/SU2_CFD/src/numerics/elasticity/CFEAElasticity.cpp index 8c3043767c01..af4b71011839 100644 --- a/SU2_CFD/src/numerics/elasticity/CFEAElasticity.cpp +++ b/SU2_CFD/src/numerics/elasticity/CFEAElasticity.cpp @@ -1,7 +1,6 @@ /*! * \file CFEAElasticity.cpp - * \brief This file contains the routines for setting the tangent matrix and - * residual of a FEM linear elastic structural problem. + * \brief Base class for all elasticity problems. * \author R. Sanchez * \version 7.0.0 "Blackbird" * @@ -167,15 +166,15 @@ CFEAElasticity::~CFEAElasticity(void) { delete [] GradNi_Ref_Mat; delete [] GradNi_Curr_Mat; - if (DV_Val != nullptr) delete[] DV_Val; + delete[] DV_Val; - if (FAux_Dead_Load != nullptr) delete [] FAux_Dead_Load; + delete [] FAux_Dead_Load; - if (E_i != nullptr) delete [] E_i; - if (Nu_i != nullptr) delete [] Nu_i; - if (Rho_s_i != nullptr) delete [] Rho_s_i; - if (Rho_s_DL_i != nullptr) delete [] Rho_s_DL_i; - if (Ni_Vec != nullptr) delete [] Ni_Vec; + delete [] E_i; + delete [] Nu_i; + delete [] Rho_s_i; + delete [] Rho_s_DL_i; + delete [] Ni_Vec; } diff --git a/SU2_CFD/src/numerics/elasticity/CFEALinearElasticity.cpp b/SU2_CFD/src/numerics/elasticity/CFEALinearElasticity.cpp index 256ac0b963db..deb41a4c01e3 100644 --- a/SU2_CFD/src/numerics/elasticity/CFEALinearElasticity.cpp +++ b/SU2_CFD/src/numerics/elasticity/CFEALinearElasticity.cpp @@ -1,6 +1,6 @@ /*! * \file CFEALinearElasticity.cpp - * \brief This file contains the routines for setting the FEM elastic structural problem. + * \brief Classes for linear elasticity problems. * \author R. Sanchez * \version 7.0.0 "Blackbird" * @@ -342,3 +342,67 @@ void CFEALinearElasticity::Compute_Averaged_NodalStress(CElement *element, CConf } } + + +CFEAMeshElasticity::CFEAMeshElasticity(unsigned short val_nDim, unsigned short val_nVar, + unsigned long val_nElem, CConfig *config) : + CFEALinearElasticity() { + DV_Val = NULL; + FAux_Dead_Load = NULL; + Rho_s_i = NULL; + Rho_s_DL_i = NULL; + Nu_i = NULL; + + nDim = val_nDim; + nVar = val_nVar; + + unsigned long iVar; + + E = config->GetDeform_ElasticityMod(); + Nu = config->GetDeform_PoissonRatio(); + Compute_Lame_Parameters(); + + switch (config->GetDeform_Stiffness_Type()) { + case INVERSE_VOLUME: + case SOLID_WALL_DISTANCE: + element_based = true; + Nu = config->GetDeform_Coeff(); + break; + case CONSTANT_STIFFNESS: + element_based = false; + break; + } + + E_i = NULL; + if (element_based){ + E_i = new su2double[val_nElem]; + for (iVar = 0; iVar < val_nElem; iVar++){ + E_i[iVar] = E; + } + } + + KAux_ab = new su2double* [nDim]; + for (iVar = 0; iVar < nDim; iVar++) { + KAux_ab[iVar] = new su2double[nDim]; + } + + unsigned short nStrain = (nDim==2) ? DIM_STRAIN_2D : DIM_STRAIN_3D; + unsigned short nNodes = (nDim==2) ? NNODES_2D : NNODES_3D; + + Ba_Mat = new su2double* [nStrain]; + Bb_Mat = new su2double* [nStrain]; + D_Mat = new su2double* [nStrain]; + Ni_Vec = new su2double [nNodes]; + GradNi_Ref_Mat = new su2double* [nNodes]; + GradNi_Curr_Mat = new su2double* [nNodes]; + for (iVar = 0; iVar < nStrain; iVar++) { + Ba_Mat[iVar] = new su2double[nDim]; + Bb_Mat[iVar] = new su2double[nDim]; + D_Mat[iVar] = new su2double[nStrain]; + } + for (iVar = 0; iVar < nNodes; iVar++) { + GradNi_Ref_Mat[iVar] = new su2double[nDim]; + GradNi_Curr_Mat[iVar] = new su2double[nDim]; + } + +} diff --git a/SU2_CFD/src/numerics/elasticity/CFEAMeshElasticity.cpp b/SU2_CFD/src/numerics/elasticity/CFEAMeshElasticity.cpp deleted file mode 100644 index 1ccc8a46f3ec..000000000000 --- a/SU2_CFD/src/numerics/elasticity/CFEAMeshElasticity.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/*! - * \file CFEAMeshElasticity.cpp - * \brief This file contains the routines for setting the mesh pseudo-elastic problem. - * \author Ruben Sanchez - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../include/numerics/elasticity/CFEAMeshElasticity.hpp" - - -CFEAMeshElasticity::CFEAMeshElasticity(unsigned short val_nDim, unsigned short val_nVar, - unsigned long val_nElem, CConfig *config) : - CFEALinearElasticity() { - DV_Val = NULL; - FAux_Dead_Load = NULL; - Rho_s_i = NULL; - Rho_s_DL_i = NULL; - Nu_i = NULL; - - nDim = val_nDim; - nVar = val_nVar; - - unsigned long iVar; - - E = config->GetDeform_ElasticityMod(); - Nu = config->GetDeform_PoissonRatio(); - Compute_Lame_Parameters(); - - switch (config->GetDeform_Stiffness_Type()) { - case INVERSE_VOLUME: - case SOLID_WALL_DISTANCE: - element_based = true; - Nu = config->GetDeform_Coeff(); - break; - case CONSTANT_STIFFNESS: - element_based = false; - break; - } - - E_i = NULL; - if (element_based){ - E_i = new su2double[val_nElem]; - for (iVar = 0; iVar < val_nElem; iVar++){ - E_i[iVar] = E; - } - } - - KAux_ab = new su2double* [nDim]; - for (iVar = 0; iVar < nDim; iVar++) { - KAux_ab[iVar] = new su2double[nDim]; - } - - unsigned short nStrain = (nDim==2) ? DIM_STRAIN_2D : DIM_STRAIN_3D; - unsigned short nNodes = (nDim==2) ? NNODES_2D : NNODES_3D; - - Ba_Mat = new su2double* [nStrain]; - Bb_Mat = new su2double* [nStrain]; - D_Mat = new su2double* [nStrain]; - Ni_Vec = new su2double [nNodes]; - GradNi_Ref_Mat = new su2double* [nNodes]; - GradNi_Curr_Mat = new su2double* [nNodes]; - for (iVar = 0; iVar < nStrain; iVar++) { - Ba_Mat[iVar] = new su2double[nDim]; - Bb_Mat[iVar] = new su2double[nDim]; - D_Mat[iVar] = new su2double[nStrain]; - } - for (iVar = 0; iVar < nNodes; iVar++) { - GradNi_Ref_Mat[iVar] = new su2double[nDim]; - GradNi_Curr_Mat[iVar] = new su2double[nDim]; - } - -} diff --git a/SU2_CFD/src/numerics/elasticity/CFEM_DielectricElastomer.cpp b/SU2_CFD/src/numerics/elasticity/CFEM_DielectricElastomer.cpp deleted file mode 100644 index 45e1eff7a028..000000000000 --- a/SU2_CFD/src/numerics/elasticity/CFEM_DielectricElastomer.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/*! - * \file CFEM_DielectricElastomer.cpp - * \brief This file contains the routines for setting the tangent matrix and residual - * of a FEM nonlinear elastic structural problem. - * \author R. Sanchez - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../include/numerics/elasticity/CFEM_DielectricElastomer.hpp" - - -CFEM_DielectricElastomer::CFEM_DielectricElastomer(unsigned short val_nDim, unsigned short val_nVar, - CConfig *config) : CFEANonlinearElasticity(val_nDim, val_nVar, config) {} - - -void CFEM_DielectricElastomer::Compute_Constitutive_Matrix(CElement *element, CConfig *config) { - - /*--- This reduces performance by now, but it is temporal ---*/ - - if (nDim == 2){ - D_Mat[0][0] = 0.0; D_Mat[0][1] = 0.0; D_Mat[0][2] = 0.0; - D_Mat[1][0] = 0.0; D_Mat[1][1] = 0.0; D_Mat[1][2] = 0.0; - D_Mat[2][0] = 0.0; D_Mat[2][1] = 0.0; D_Mat[2][2] = 0.0; - } - else { - D_Mat[0][0] = 0.0; D_Mat[0][1] = 0.0; D_Mat[0][2] = 0.0; D_Mat[0][3] = 0.0; D_Mat[0][4] = 0.0; D_Mat[0][5] = 0.0; - D_Mat[1][0] = 0.0; D_Mat[1][1] = 0.0; D_Mat[1][2] = 0.0; D_Mat[1][3] = 0.0; D_Mat[1][4] = 0.0; D_Mat[1][5] = 0.0; - D_Mat[2][0] = 0.0; D_Mat[2][1] = 0.0; D_Mat[2][2] = 0.0; D_Mat[2][3] = 0.0; D_Mat[2][4] = 0.0; D_Mat[2][5] = 0.0; - D_Mat[3][0] = 0.0; D_Mat[3][1] = 0.0; D_Mat[3][2] = 0.0; D_Mat[3][3] = 0.0; D_Mat[3][4] = 0.0; D_Mat[3][5] = 0.0; - D_Mat[4][0] = 0.0; D_Mat[4][1] = 0.0; D_Mat[4][2] = 0.0; D_Mat[4][3] = 0.0; D_Mat[4][4] = 0.0; D_Mat[4][5] = 0.0; - D_Mat[5][0] = 0.0; D_Mat[5][1] = 0.0; D_Mat[5][2] = 0.0; D_Mat[5][3] = 0.0; D_Mat[5][4] = 0.0; D_Mat[5][5] = 0.0; - } - - -} - -void CFEM_DielectricElastomer::Compute_Stress_Tensor(CElement *element, CConfig *config) { - - unsigned short iDim, jDim; - - su2double E0 = 0.0, E1 = 0.0, E2 = 0.0; - su2double E0_2 = 0.0, E1_2 = 0.0, E2_2 = 0.0; - su2double E_2 = 0.0; - - Compute_FmT_Mat(); - - for (iDim = 0; iDim < nDim; iDim++){ - EField_Curr_Unit[iDim] = 0.0; - for (jDim = 0; jDim < nDim; jDim++){ - EField_Curr_Unit[iDim] += FmT_Mat[iDim][jDim] * EField_Ref_Unit[jDim]; - } - } - - E0 = EFieldMod_Ref*EField_Curr_Unit[0]; E0_2 = pow(E0,2); - E1 = EFieldMod_Ref*EField_Curr_Unit[1]; E1_2 = pow(E1,2); - if (nDim == 3) {E2 = EFieldMod_Ref*EField_Curr_Unit[2]; E2_2 = pow(E2,2);} - - E_2 = E0_2+E1_2+E2_2; - - Stress_Tensor[0][0] = ke_DE*(E0_2-0.5*E_2); Stress_Tensor[0][1] = ke_DE*E0*E1; Stress_Tensor[0][2] = ke_DE*E0*E2; - Stress_Tensor[1][0] = ke_DE*E1*E0; Stress_Tensor[1][1] = ke_DE*(E1_2-0.5*E_2); Stress_Tensor[1][2] = ke_DE*E1*E2; - Stress_Tensor[2][0] = ke_DE*E2*E0; Stress_Tensor[2][1] = ke_DE*E2*E1; Stress_Tensor[2][2] = ke_DE*(E2_2-0.5*E_2); - - -} - diff --git a/SU2_CFD/src/numerics/elasticity/CFEM_IdealDE.cpp b/SU2_CFD/src/numerics/elasticity/CFEM_IdealDE.cpp deleted file mode 100644 index 75cdd027b118..000000000000 --- a/SU2_CFD/src/numerics/elasticity/CFEM_IdealDE.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/*! - * \file CFEM_IdealDE.cpp - * \brief Definition of ideal dielectric elastomer. - * \author R. Sanchez - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../include/numerics/elasticity/CFEM_IdealDE.hpp" - - -CFEM_IdealDE::CFEM_IdealDE(unsigned short val_nDim, unsigned short val_nVar, - CConfig *config) : CFEANonlinearElasticity(val_nDim, val_nVar, config) { - - /* -- The formulation adopted for this material model has been described by: - * -- - * -- Zhao, X. and Suo, Z., Method to analyze programmable deformation of - * -- dielectric elastomer layers, Applied Physics Letters 93, 251902 (2008). - * -- - * -- http://imechanica.org/node/4234 - */ - - trbbar = 0.0; - Eg = 0.0; - Eg23 = 0.0; - Ek = 0.0; - Pr = 0.0; - -} - -void CFEM_IdealDE::Compute_Plane_Stress_Term(CElement *element, CConfig *config) { - - SU2_MPI::Error("This material model cannot (yet) be used for plane stress.", CURRENT_FUNCTION); - -} - -void CFEM_IdealDE::Compute_Constitutive_Matrix(CElement *element, CConfig *config) { - - /* -- Zhao, X. and Suo, Z. (2008) (full reference in class constructor). ---*/ - - if (nDim == 2){ - - D_Mat[0][0] = Eg23*(b_Mat_Iso[0][0]+trbbar)+Ek; - D_Mat[1][1] = Eg23*(b_Mat_Iso[1][1]+trbbar)+Ek; - - D_Mat[0][1] = -Eg23*(b_Mat_Iso[0][0]+b_Mat_Iso[1][1]-trbbar)+Ek; - D_Mat[1][0] = -Eg23*(b_Mat_Iso[0][0]+b_Mat_Iso[1][1]-trbbar)+Ek; - - D_Mat[0][2] = Eg23*b_Mat_Iso[0][1]/2.0; - D_Mat[2][0] = Eg23*b_Mat_Iso[0][1]/2.0; - - D_Mat[1][2] = Eg23*b_Mat_Iso[0][1]/2.0; - D_Mat[2][1] = Eg23*b_Mat_Iso[0][1]/2.0; - - D_Mat[2][2] = Eg*(b_Mat_Iso[0][0]+b_Mat_Iso[1][1])/2.0; - - } - else { - SU2_MPI::Error("This material model cannot be used for 3D yet.", CURRENT_FUNCTION); - } - -} - -void CFEM_IdealDE::Compute_Stress_Tensor(CElement *element, CConfig *config) { - - /* -- Zhao, X. and Suo, Z. (2008) (full reference in class constructor). ---*/ - - unsigned short iVar, jVar; - su2double dij = 0.0; - - /*--- Compute the isochoric deformation gradient Fbar and left Cauchy-Green tensor bbar ---*/ - Compute_Isochoric_F_b(); - - // Stress terms - - trbbar = (b_Mat_Iso[0][0] + b_Mat_Iso[1][1] + b_Mat_Iso[2][2]) / 3.0; - Eg = Mu / J_F; - Ek = Kappa * (2.0 * J_F - 1.0); - Pr = Kappa * (J_F - 1.0); - Eg23 = 2.0 * Eg / 3.0; - - // Stress tensor - - for (iVar = 0; iVar < 3; iVar++){ - for (jVar = 0; jVar < 3; jVar++){ - if (iVar == jVar) dij = 1.0; - else if (iVar != jVar) dij = 0.0; - Stress_Tensor[iVar][jVar] = Eg * ( b_Mat_Iso[iVar][jVar] - dij * trbbar) + dij * Pr ; - } - } - -} - diff --git a/SU2_CFD/src/numerics/elasticity/CFEM_Knowles_NearInc.cpp b/SU2_CFD/src/numerics/elasticity/CFEM_Knowles_NearInc.cpp deleted file mode 100644 index d448ed133628..000000000000 --- a/SU2_CFD/src/numerics/elasticity/CFEM_Knowles_NearInc.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/*! - * \file CFEM_Knowles_NearInc.cpp - * \brief FE numerics for nearly incompressible Knowles material model. - * \author R. Sanchez - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../include/numerics/elasticity/CFEM_Knowles_NearInc.hpp" - - -CFEM_Knowles_NearInc::CFEM_Knowles_NearInc(unsigned short val_nDim, unsigned short val_nVar, - CConfig *config) : CFEANonlinearElasticity(val_nDim, val_nVar, config) { - - /* -- The formulation adopted for this material model has been described by: - * -- - * -- Suchocki, C., A Finite Element Implementation of Knowles stored-energy function: - * -- theory, coding and applications, Archive of Mechanical Engineering, Vol. 58, pp. 319-346 (2011). - * -- - * -- DOI: 10.2478/v10180-011-0021-7 - */ - - Bk = config->GetKnowles_B(); - Nk = config->GetKnowles_N(); - - trbbar = 0.0; - Ek = 0.0; - Pr = 0.0; - -} - -void CFEM_Knowles_NearInc::Compute_Plane_Stress_Term(CElement *element, CConfig *config) { - - SU2_MPI::Error("This material model cannot (yet) be used for plane stress.",CURRENT_FUNCTION); - -} - -void CFEM_Knowles_NearInc::Compute_Constitutive_Matrix(CElement *element, CConfig *config) { - - /* -- Suchocki (2011) (full reference in class constructor). ---*/ - - /*--- Computation of the tensor cijkl ---*/ - - unsigned short iVar, jVar, kVar, lVar; - - for (iVar = 0; iVar < 3; iVar++){ - for (jVar = 0; jVar < 3; jVar++){ - for (kVar = 0; kVar < 3; kVar++){ - for (lVar = 0; lVar < 3; lVar++){ - cijkl[iVar][jVar][kVar][lVar] = - term1 * ((1.0/2.0)*( deltaij(iVar,kVar)*b_Mat_Iso[jVar][lVar] - +deltaij(jVar,lVar)*b_Mat_Iso[iVar][kVar] - +deltaij(iVar,lVar)*b_Mat_Iso[jVar][kVar] - +deltaij(jVar,kVar)*b_Mat_Iso[iVar][lVar]) - +(2.0/3.0)*(trbbar*deltaij(iVar,jVar)*deltaij(kVar,lVar) - -b_Mat_Iso[iVar][jVar]*deltaij(kVar,lVar) - -deltaij(iVar,jVar)*b_Mat_Iso[kVar][lVar])) - +term2 * ( b_Mat_Iso[iVar][jVar]*b_Mat_Iso[kVar][lVar] - - trbbar*(b_Mat_Iso[iVar][jVar]*deltaij(kVar,lVar) - +deltaij(iVar,jVar)*b_Mat_Iso[kVar][lVar]) - + pow(trbbar,2.0) * deltaij(iVar,jVar) * deltaij(kVar,lVar)) - +Kappa * (2.0 * J_F - 1.0) * deltaij(iVar,jVar) * deltaij(kVar,lVar); - - } - } - } - } - - /*--- Reorganizing the tensor into the matrix D ---*/ - - Assign_cijkl_D_Mat(); - - -} - -void CFEM_Knowles_NearInc::Compute_Stress_Tensor(CElement *element, CConfig *config) { - - /* -- Suchocki (2011) (full reference in class constructor). ---*/ - - unsigned short iVar, jVar; - - /*--- Compute the isochoric deformation gradient Fbar and left Cauchy-Green tensor bbar ---*/ - Compute_Isochoric_F_b(); - - trbbar = (b_Mat_Iso[0][0] + b_Mat_Iso[1][1] + b_Mat_Iso[2][2]) / 3.0; - term1 = (Mu / J_F) * pow((1 + (Bk / Nk) * (3.0 * trbbar - 3.0)), (Nk-1.0)); - term2 = 2.0 * (Mu / J_F) * (Bk * (Nk - 1.0) / Nk) * - pow((1.0 + (Bk / Nk) * (3.0 * trbbar - 3.0)), (Nk-2.0)); - - Ek = Kappa * (2.0 * J_F - 1.0); - Pr = Kappa * (J_F - 1.0); - - for (iVar = 0; iVar < 3; iVar++){ - for (jVar = 0; jVar < 3; jVar++){ - Stress_Tensor[iVar][jVar] = term1 * (b_Mat_Iso[iVar][jVar] - deltaij(iVar,jVar)*trbbar) + - deltaij(iVar,jVar) * Pr; - } - } - -} - diff --git a/SU2_CFD/src/numerics/elasticity/CFEM_NeoHookean_Comp.cpp b/SU2_CFD/src/numerics/elasticity/CFEM_NeoHookean_Comp.cpp deleted file mode 100644 index 136601e3ff0d..000000000000 --- a/SU2_CFD/src/numerics/elasticity/CFEM_NeoHookean_Comp.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/*! - * \file CFEM_NeoHookean_Comp.cpp - * \brief Definition of Neo-Hookean compressible material. - * \author R. Sanchez - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../include/numerics/elasticity/CFEM_NeoHookean_Comp.hpp" - - -CFEM_NeoHookean_Comp::CFEM_NeoHookean_Comp(unsigned short val_nDim, - unsigned short val_nVar, - CConfig *config) : - CFEANonlinearElasticity(val_nDim, val_nVar, config) { -} - -void CFEM_NeoHookean_Comp::Compute_Plane_Stress_Term(CElement *element, CConfig *config) { - - su2double j_red = 1.0; - su2double fx = 0.0, fpx = 1.0; - su2double xkm1 = 1.0, xk = 1.0; - su2double cte = 0.0; - - unsigned short iNR, nNR; - su2double NRTOL; - - // Maximum number of iterations and tolerance (relative) - nNR = 10; - NRTOL = 1E-25; - - // j_red: reduced jacobian, for the 2x2 submatrix of F - j_red = F_Mat[0][0] * F_Mat[1][1] - F_Mat[1][0] * F_Mat[0][1]; - // cte: constant term in the NR method - cte = Lambda*log(j_red) - Mu; - - // f(f33) = mu*f33^2 + lambda*ln(f33) + (lambda*ln(j_red)-mu) = 0 - // f'(f33) = 2*mu*f33 + lambda/f33 - - for (iNR = 0; iNR < nNR; iNR++) { - fx = Mu*pow(xk,2.0) + Lambda*log(xk) + cte; - fpx = 2*Mu*xk + (Lambda / xk); - xkm1 = xk - fx / fpx; - if (((xkm1 - xk) / xk) < NRTOL) break; - xk = xkm1; - } - - f33 = xkm1; - -} - -void CFEM_NeoHookean_Comp::Compute_Constitutive_Matrix(CElement *element, CConfig *config) { - - su2double Mu_p = 0.0, Lambda_p = 0.0; - - /*--- This can be done in a better way ---*/ - if (J_F != 0.0) { - Mu_p = (Mu - Lambda*log(J_F))/J_F; - Lambda_p = Lambda/J_F; - } - - /*--- Assuming plane strain ---*/ - - su2double Lbd_2Mu = Lambda_p + 2.0 * Mu_p; - - if (nDim == 2) { - D_Mat[0][0] = Lbd_2Mu; D_Mat[0][1] = Lambda_p; D_Mat[0][2] = 0.0; - D_Mat[1][0] = Lambda_p; D_Mat[1][1] = Lbd_2Mu; D_Mat[1][2] = 0.0; - D_Mat[2][0] = 0.0; D_Mat[2][1] = 0.0; D_Mat[2][2] = Mu_p; - } - else { - D_Mat[0][0] = Lbd_2Mu; D_Mat[0][1] = Lambda_p; D_Mat[0][2] = Lambda_p; D_Mat[0][3] = 0.0; D_Mat[0][4] = 0.0; D_Mat[0][5] = 0.0; - D_Mat[1][0] = Lambda_p; D_Mat[1][1] = Lbd_2Mu; D_Mat[1][2] = Lambda_p; D_Mat[1][3] = 0.0; D_Mat[1][4] = 0.0; D_Mat[1][5] = 0.0; - D_Mat[2][0] = Lambda_p; D_Mat[2][1] = Lambda_p; D_Mat[2][2] = Lbd_2Mu; D_Mat[2][3] = 0.0; D_Mat[2][4] = 0.0; D_Mat[2][5] = 0.0; - D_Mat[3][0] = 0.0; D_Mat[3][1] = 0.0; D_Mat[3][2] = 0.0; D_Mat[3][3] = Mu_p; D_Mat[3][4] = 0.0; D_Mat[3][5] = 0.0; - D_Mat[4][0] = 0.0; D_Mat[4][1] = 0.0; D_Mat[4][2] = 0.0; D_Mat[4][3] = 0.0; D_Mat[4][4] = Mu_p; D_Mat[4][5] = 0.0; - D_Mat[5][0] = 0.0; D_Mat[5][1] = 0.0; D_Mat[5][2] = 0.0; D_Mat[5][3] = 0.0; D_Mat[5][4] = 0.0; D_Mat[5][5] = Mu_p; - } - -} - -void CFEM_NeoHookean_Comp::Compute_Stress_Tensor(CElement *element, CConfig *config) { - - unsigned short iVar,jVar; - su2double Mu_J = 0.0, Lambda_J = 0.0; - - /*--- This can be done in a better way ---*/ - if (J_F != 0.0) { - Mu_J = Mu/J_F; - Lambda_J = Lambda/J_F; - } - - for (iVar = 0; iVar < 3; iVar++) { - for (jVar = 0; jVar < 3; jVar++) { - su2double dij = deltaij(iVar,jVar); - Stress_Tensor[iVar][jVar] = Mu_J * (b_Mat[iVar][jVar] - dij) + Lambda_J * log(J_F) * dij; - } - } - -} - diff --git a/SU2_CFD/src/numerics/elasticity/nonlinear_models.cpp b/SU2_CFD/src/numerics/elasticity/nonlinear_models.cpp new file mode 100644 index 000000000000..331f67347bce --- /dev/null +++ b/SU2_CFD/src/numerics/elasticity/nonlinear_models.cpp @@ -0,0 +1,346 @@ +/*! + * \file nonlinear_models.cpp + * \brief Definition of nonlinear constitutive models. + * \author R. Sanchez + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../include/numerics/elasticity/nonlinear_models.hpp" + + +CFEM_NeoHookean_Comp::CFEM_NeoHookean_Comp(unsigned short val_nDim, + unsigned short val_nVar, + CConfig *config) : + CFEANonlinearElasticity(val_nDim, val_nVar, config) { +} + +void CFEM_NeoHookean_Comp::Compute_Plane_Stress_Term(CElement *element, CConfig *config) { + + su2double j_red = 1.0; + su2double fx = 0.0, fpx = 1.0; + su2double xkm1 = 1.0, xk = 1.0; + su2double cte = 0.0; + + unsigned short iNR, nNR; + su2double NRTOL; + + // Maximum number of iterations and tolerance (relative) + nNR = 10; + NRTOL = 1E-25; + + // j_red: reduced jacobian, for the 2x2 submatrix of F + j_red = F_Mat[0][0] * F_Mat[1][1] - F_Mat[1][0] * F_Mat[0][1]; + // cte: constant term in the NR method + cte = Lambda*log(j_red) - Mu; + + // f(f33) = mu*f33^2 + lambda*ln(f33) + (lambda*ln(j_red)-mu) = 0 + // f'(f33) = 2*mu*f33 + lambda/f33 + + for (iNR = 0; iNR < nNR; iNR++) { + fx = Mu*pow(xk,2.0) + Lambda*log(xk) + cte; + fpx = 2*Mu*xk + (Lambda / xk); + xkm1 = xk - fx / fpx; + if (((xkm1 - xk) / xk) < NRTOL) break; + xk = xkm1; + } + + f33 = xkm1; + +} + +void CFEM_NeoHookean_Comp::Compute_Constitutive_Matrix(CElement *element, CConfig *config) { + + su2double Mu_p = 0.0, Lambda_p = 0.0; + + /*--- This can be done in a better way ---*/ + if (J_F != 0.0) { + Mu_p = (Mu - Lambda*log(J_F))/J_F; + Lambda_p = Lambda/J_F; + } + + /*--- Assuming plane strain ---*/ + + su2double Lbd_2Mu = Lambda_p + 2.0 * Mu_p; + + if (nDim == 2) { + D_Mat[0][0] = Lbd_2Mu; D_Mat[0][1] = Lambda_p; D_Mat[0][2] = 0.0; + D_Mat[1][0] = Lambda_p; D_Mat[1][1] = Lbd_2Mu; D_Mat[1][2] = 0.0; + D_Mat[2][0] = 0.0; D_Mat[2][1] = 0.0; D_Mat[2][2] = Mu_p; + } + else { + D_Mat[0][0] = Lbd_2Mu; D_Mat[0][1] = Lambda_p; D_Mat[0][2] = Lambda_p; D_Mat[0][3] = 0.0; D_Mat[0][4] = 0.0; D_Mat[0][5] = 0.0; + D_Mat[1][0] = Lambda_p; D_Mat[1][1] = Lbd_2Mu; D_Mat[1][2] = Lambda_p; D_Mat[1][3] = 0.0; D_Mat[1][4] = 0.0; D_Mat[1][5] = 0.0; + D_Mat[2][0] = Lambda_p; D_Mat[2][1] = Lambda_p; D_Mat[2][2] = Lbd_2Mu; D_Mat[2][3] = 0.0; D_Mat[2][4] = 0.0; D_Mat[2][5] = 0.0; + D_Mat[3][0] = 0.0; D_Mat[3][1] = 0.0; D_Mat[3][2] = 0.0; D_Mat[3][3] = Mu_p; D_Mat[3][4] = 0.0; D_Mat[3][5] = 0.0; + D_Mat[4][0] = 0.0; D_Mat[4][1] = 0.0; D_Mat[4][2] = 0.0; D_Mat[4][3] = 0.0; D_Mat[4][4] = Mu_p; D_Mat[4][5] = 0.0; + D_Mat[5][0] = 0.0; D_Mat[5][1] = 0.0; D_Mat[5][2] = 0.0; D_Mat[5][3] = 0.0; D_Mat[5][4] = 0.0; D_Mat[5][5] = Mu_p; + } + +} + +void CFEM_NeoHookean_Comp::Compute_Stress_Tensor(CElement *element, CConfig *config) { + + unsigned short iVar,jVar; + su2double Mu_J = 0.0, Lambda_J = 0.0; + + /*--- This can be done in a better way ---*/ + if (J_F != 0.0) { + Mu_J = Mu/J_F; + Lambda_J = Lambda/J_F; + } + + for (iVar = 0; iVar < 3; iVar++) { + for (jVar = 0; jVar < 3; jVar++) { + su2double dij = deltaij(iVar,jVar); + Stress_Tensor[iVar][jVar] = Mu_J * (b_Mat[iVar][jVar] - dij) + Lambda_J * log(J_F) * dij; + } + } + +} + +CFEM_Knowles_NearInc::CFEM_Knowles_NearInc(unsigned short val_nDim, unsigned short val_nVar, + CConfig *config) : CFEANonlinearElasticity(val_nDim, val_nVar, config) { + + /* -- The formulation adopted for this material model has been described by: + * -- + * -- Suchocki, C., A Finite Element Implementation of Knowles stored-energy function: + * -- theory, coding and applications, Archive of Mechanical Engineering, Vol. 58, pp. 319-346 (2011). + * -- + * -- DOI: 10.2478/v10180-011-0021-7 + */ + + Bk = config->GetKnowles_B(); + Nk = config->GetKnowles_N(); + + trbbar = 0.0; + Ek = 0.0; + Pr = 0.0; + +} + +void CFEM_Knowles_NearInc::Compute_Plane_Stress_Term(CElement *element, CConfig *config) { + + SU2_MPI::Error("This material model cannot (yet) be used for plane stress.",CURRENT_FUNCTION); + +} + +void CFEM_Knowles_NearInc::Compute_Constitutive_Matrix(CElement *element, CConfig *config) { + + /* -- Suchocki (2011) (full reference in class constructor). ---*/ + + /*--- Computation of the tensor cijkl ---*/ + + unsigned short iVar, jVar, kVar, lVar; + + for (iVar = 0; iVar < 3; iVar++){ + for (jVar = 0; jVar < 3; jVar++){ + for (kVar = 0; kVar < 3; kVar++){ + for (lVar = 0; lVar < 3; lVar++){ + cijkl[iVar][jVar][kVar][lVar] = + term1 * ((1.0/2.0)*( deltaij(iVar,kVar)*b_Mat_Iso[jVar][lVar] + +deltaij(jVar,lVar)*b_Mat_Iso[iVar][kVar] + +deltaij(iVar,lVar)*b_Mat_Iso[jVar][kVar] + +deltaij(jVar,kVar)*b_Mat_Iso[iVar][lVar]) + +(2.0/3.0)*(trbbar*deltaij(iVar,jVar)*deltaij(kVar,lVar) + -b_Mat_Iso[iVar][jVar]*deltaij(kVar,lVar) + -deltaij(iVar,jVar)*b_Mat_Iso[kVar][lVar])) + +term2 * ( b_Mat_Iso[iVar][jVar]*b_Mat_Iso[kVar][lVar] + - trbbar*(b_Mat_Iso[iVar][jVar]*deltaij(kVar,lVar) + +deltaij(iVar,jVar)*b_Mat_Iso[kVar][lVar]) + + pow(trbbar,2.0) * deltaij(iVar,jVar) * deltaij(kVar,lVar)) + +Kappa * (2.0 * J_F - 1.0) * deltaij(iVar,jVar) * deltaij(kVar,lVar); + + } + } + } + } + + /*--- Reorganizing the tensor into the matrix D ---*/ + + Assign_cijkl_D_Mat(); + + +} + +void CFEM_Knowles_NearInc::Compute_Stress_Tensor(CElement *element, CConfig *config) { + + /* -- Suchocki (2011) (full reference in class constructor). ---*/ + + unsigned short iVar, jVar; + + /*--- Compute the isochoric deformation gradient Fbar and left Cauchy-Green tensor bbar ---*/ + Compute_Isochoric_F_b(); + + trbbar = (b_Mat_Iso[0][0] + b_Mat_Iso[1][1] + b_Mat_Iso[2][2]) / 3.0; + term1 = (Mu / J_F) * pow((1 + (Bk / Nk) * (3.0 * trbbar - 3.0)), (Nk-1.0)); + term2 = 2.0 * (Mu / J_F) * (Bk * (Nk - 1.0) / Nk) * + pow((1.0 + (Bk / Nk) * (3.0 * trbbar - 3.0)), (Nk-2.0)); + + Ek = Kappa * (2.0 * J_F - 1.0); + Pr = Kappa * (J_F - 1.0); + + for (iVar = 0; iVar < 3; iVar++){ + for (jVar = 0; jVar < 3; jVar++){ + Stress_Tensor[iVar][jVar] = term1 * (b_Mat_Iso[iVar][jVar] - deltaij(iVar,jVar)*trbbar) + + deltaij(iVar,jVar) * Pr; + } + } + +} + +CFEM_DielectricElastomer::CFEM_DielectricElastomer(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : + CFEANonlinearElasticity(val_nDim, val_nVar, config) { + +} + +void CFEM_DielectricElastomer::Compute_Constitutive_Matrix(CElement *element, CConfig *config) { + + /*--- This reduces performance by now, but it is temporal ---*/ + + if (nDim == 2){ + D_Mat[0][0] = 0.0; D_Mat[0][1] = 0.0; D_Mat[0][2] = 0.0; + D_Mat[1][0] = 0.0; D_Mat[1][1] = 0.0; D_Mat[1][2] = 0.0; + D_Mat[2][0] = 0.0; D_Mat[2][1] = 0.0; D_Mat[2][2] = 0.0; + } + else { + D_Mat[0][0] = 0.0; D_Mat[0][1] = 0.0; D_Mat[0][2] = 0.0; D_Mat[0][3] = 0.0; D_Mat[0][4] = 0.0; D_Mat[0][5] = 0.0; + D_Mat[1][0] = 0.0; D_Mat[1][1] = 0.0; D_Mat[1][2] = 0.0; D_Mat[1][3] = 0.0; D_Mat[1][4] = 0.0; D_Mat[1][5] = 0.0; + D_Mat[2][0] = 0.0; D_Mat[2][1] = 0.0; D_Mat[2][2] = 0.0; D_Mat[2][3] = 0.0; D_Mat[2][4] = 0.0; D_Mat[2][5] = 0.0; + D_Mat[3][0] = 0.0; D_Mat[3][1] = 0.0; D_Mat[3][2] = 0.0; D_Mat[3][3] = 0.0; D_Mat[3][4] = 0.0; D_Mat[3][5] = 0.0; + D_Mat[4][0] = 0.0; D_Mat[4][1] = 0.0; D_Mat[4][2] = 0.0; D_Mat[4][3] = 0.0; D_Mat[4][4] = 0.0; D_Mat[4][5] = 0.0; + D_Mat[5][0] = 0.0; D_Mat[5][1] = 0.0; D_Mat[5][2] = 0.0; D_Mat[5][3] = 0.0; D_Mat[5][4] = 0.0; D_Mat[5][5] = 0.0; + } + + +} + +void CFEM_DielectricElastomer::Compute_Stress_Tensor(CElement *element, CConfig *config) { + + unsigned short iDim, jDim; + + su2double E0 = 0.0, E1 = 0.0, E2 = 0.0; + su2double E0_2 = 0.0, E1_2 = 0.0, E2_2 = 0.0; + su2double E_2 = 0.0; + + Compute_FmT_Mat(); + + for (iDim = 0; iDim < nDim; iDim++){ + EField_Curr_Unit[iDim] = 0.0; + for (jDim = 0; jDim < nDim; jDim++){ + EField_Curr_Unit[iDim] += FmT_Mat[iDim][jDim] * EField_Ref_Unit[jDim]; + } + } + + E0 = EFieldMod_Ref*EField_Curr_Unit[0]; E0_2 = pow(E0,2); + E1 = EFieldMod_Ref*EField_Curr_Unit[1]; E1_2 = pow(E1,2); + if (nDim == 3) {E2 = EFieldMod_Ref*EField_Curr_Unit[2]; E2_2 = pow(E2,2);} + + E_2 = E0_2+E1_2+E2_2; + + Stress_Tensor[0][0] = ke_DE*(E0_2-0.5*E_2); Stress_Tensor[0][1] = ke_DE*E0*E1; Stress_Tensor[0][2] = ke_DE*E0*E2; + Stress_Tensor[1][0] = ke_DE*E1*E0; Stress_Tensor[1][1] = ke_DE*(E1_2-0.5*E_2); Stress_Tensor[1][2] = ke_DE*E1*E2; + Stress_Tensor[2][0] = ke_DE*E2*E0; Stress_Tensor[2][1] = ke_DE*E2*E1; Stress_Tensor[2][2] = ke_DE*(E2_2-0.5*E_2); + +} + +CFEM_IdealDE::CFEM_IdealDE(unsigned short val_nDim, unsigned short val_nVar, + CConfig *config) : CFEANonlinearElasticity(val_nDim, val_nVar, config) { + + /* -- The formulation adopted for this material model has been described by: + * -- + * -- Zhao, X. and Suo, Z., Method to analyze programmable deformation of + * -- dielectric elastomer layers, Applied Physics Letters 93, 251902 (2008). + * -- + * -- http://imechanica.org/node/4234 + */ + + trbbar = 0.0; + Eg = 0.0; + Eg23 = 0.0; + Ek = 0.0; + Pr = 0.0; + +} + +void CFEM_IdealDE::Compute_Plane_Stress_Term(CElement *element, CConfig *config) { + + SU2_MPI::Error("This material model cannot (yet) be used for plane stress.", CURRENT_FUNCTION); + +} + +void CFEM_IdealDE::Compute_Constitutive_Matrix(CElement *element, CConfig *config) { + + /* -- Zhao, X. and Suo, Z. (2008) (full reference in class constructor). ---*/ + + if (nDim == 2){ + + D_Mat[0][0] = Eg23*(b_Mat_Iso[0][0]+trbbar)+Ek; + D_Mat[1][1] = Eg23*(b_Mat_Iso[1][1]+trbbar)+Ek; + + D_Mat[0][1] = -Eg23*(b_Mat_Iso[0][0]+b_Mat_Iso[1][1]-trbbar)+Ek; + D_Mat[1][0] = -Eg23*(b_Mat_Iso[0][0]+b_Mat_Iso[1][1]-trbbar)+Ek; + + D_Mat[0][2] = Eg23*b_Mat_Iso[0][1]/2.0; + D_Mat[2][0] = Eg23*b_Mat_Iso[0][1]/2.0; + + D_Mat[1][2] = Eg23*b_Mat_Iso[0][1]/2.0; + D_Mat[2][1] = Eg23*b_Mat_Iso[0][1]/2.0; + + D_Mat[2][2] = Eg*(b_Mat_Iso[0][0]+b_Mat_Iso[1][1])/2.0; + + } + else { + SU2_MPI::Error("This material model cannot be used for 3D yet.", CURRENT_FUNCTION); + } + +} + +void CFEM_IdealDE::Compute_Stress_Tensor(CElement *element, CConfig *config) { + + /* -- Zhao, X. and Suo, Z. (2008) (full reference in class constructor). ---*/ + + unsigned short iVar, jVar; + su2double dij = 0.0; + + /*--- Compute the isochoric deformation gradient Fbar and left Cauchy-Green tensor bbar ---*/ + Compute_Isochoric_F_b(); + + // Stress terms + + trbbar = (b_Mat_Iso[0][0] + b_Mat_Iso[1][1] + b_Mat_Iso[2][2]) / 3.0; + Eg = Mu / J_F; + Ek = Kappa * (2.0 * J_F - 1.0); + Pr = Kappa * (J_F - 1.0); + Eg23 = 2.0 * Eg / 3.0; + + // Stress tensor + + for (iVar = 0; iVar < 3; iVar++){ + for (jVar = 0; jVar < 3; jVar++){ + if (iVar == jVar) dij = 1.0; + else if (iVar != jVar) dij = 0.0; + Stress_Tensor[iVar][jVar] = Eg * ( b_Mat_Iso[iVar][jVar] - dij * trbbar) + dij * Pr ; + } + } + +} diff --git a/SU2_CFD/src/numerics/flow/convection/ausm_slau.cpp b/SU2_CFD/src/numerics/flow/convection/ausm_slau.cpp new file mode 100644 index 000000000000..ac1e4ac97e54 --- /dev/null +++ b/SU2_CFD/src/numerics/flow/convection/ausm_slau.cpp @@ -0,0 +1,959 @@ +/*! + * \file ausm_slau.cpp + * \brief Implementations of the AUSM-family of schemes. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../../include/numerics/flow/convection/ausm_slau.hpp" + +CUpwAUSMPLUS_SLAU_Base_Flow::CUpwAUSMPLUS_SLAU_Base_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : + CNumerics(val_nDim, val_nVar, config) { + + if (config->GetDynamic_Grid() && (SU2_MPI::GetRank() == MASTER_NODE)) + cout << "WARNING: Grid velocities are NOT yet considered in AUSM-type schemes." << endl; + + implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + UseAccurateJacobian = config->GetUse_Accurate_Jacobians(); + HasAnalyticalDerivatives = false; + FinDiffStep = 1e-4; + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + + Velocity_i = new su2double [nDim]; + Velocity_j = new su2double [nDim]; + psi_i = new su2double [nVar]; + psi_j = new su2double [nVar]; + + RoeVelocity = new su2double [nDim]; + Lambda = new su2double [nVar]; + Epsilon = new su2double [nVar]; + P_Tensor = new su2double* [nVar]; + invP_Tensor = new su2double* [nVar]; + for (unsigned short iVar = 0; iVar < nVar; iVar++) { + P_Tensor[iVar] = new su2double [nVar]; + invP_Tensor[iVar] = new su2double [nVar]; + } +} + +CUpwAUSMPLUS_SLAU_Base_Flow::~CUpwAUSMPLUS_SLAU_Base_Flow(void) { + + delete [] Velocity_i; + delete [] Velocity_j; + delete [] psi_i; + delete [] psi_j; + + delete [] RoeVelocity; + delete [] Lambda; + delete [] Epsilon; + for (unsigned short iVar = 0; iVar < nVar; iVar++) { + delete [] P_Tensor[iVar]; + delete [] invP_Tensor[iVar]; + } + delete [] P_Tensor; + delete [] invP_Tensor; + +} + +void CUpwAUSMPLUS_SLAU_Base_Flow::ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure) +{ + /*--- For schemes that fit in the general form of AUSM+up and SLAU schemes you can inherit from this class + and implement only the specifics, which should be the face mass flux (per unit area) and the face pressure. + For implicit solution methods this class can either approximate the flux Jacobians (using those of the Roe + scheme) or compute accurate ones. This is done either numerically, differentiating "mdot" and "pressure" + using 1st order finite differences, or analytically if you use this function to set the values of + "dmdot_dVi/j", "dpres_dVi/j" and set "HasAnalyticalDerivatives" to true in the ctor of the derived class. + For accurate numerical differentiation "mdot" and "pressure" can be functions of, at most, the velocities, + pressures, densities, and enthalpies at nodes i/j. This is also the order expected for the partial derivatives + of "mdot" and "pressure" in "d?_dVi/j" (in case they are known analytically, see the AUSM+up implementation). + ---*/ +} + +void CUpwAUSMPLUS_SLAU_Base_Flow::ApproximateJacobian(su2double **val_Jacobian_i, su2double **val_Jacobian_j) { + + unsigned short iDim, iVar, jVar, kVar; + su2double R, RoeDensity, RoeEnthalpy, RoeSoundSpeed, ProjVelocity, sq_vel, Energy_i, Energy_j; + + Energy_i = Enthalpy_i - Pressure_i/Density_i; + Energy_j = Enthalpy_j - Pressure_j/Density_j; + + /*--- Mean Roe variables iPoint and jPoint ---*/ + + R = sqrt(fabs(Density_j/Density_i)); + RoeDensity = R*Density_i; + ProjVelocity = 0.0; + sq_vel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + RoeVelocity[iDim] = (R*Velocity_j[iDim]+Velocity_i[iDim])/(R+1); + ProjVelocity += RoeVelocity[iDim]*UnitNormal[iDim]; + sq_vel += RoeVelocity[iDim]*RoeVelocity[iDim]; + } + RoeEnthalpy = (R*Enthalpy_j+Enthalpy_i)/(R+1); + RoeSoundSpeed = sqrt(fabs((Gamma-1)*(RoeEnthalpy-0.5*sq_vel))); + + /*--- Compute P and Lambda (do it with the Normal) ---*/ + + GetPMatrix(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, P_Tensor); + + /*--- Flow eigenvalues and Entropy correctors ---*/ + + for (iDim = 0; iDim < nDim; iDim++) + Lambda[iDim] = ProjVelocity; + Lambda[nVar-2] = ProjVelocity + RoeSoundSpeed; + Lambda[nVar-1] = ProjVelocity - RoeSoundSpeed; + + /*--- Compute inverse P ---*/ + GetPMatrix_inv(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, invP_Tensor); + + /*--- Jacobians of the inviscid flux, scale = 0.5 because val_residual ~ 0.5*(fc_i+fc_j)*Normal ---*/ + GetInviscidProjJac(Velocity_i, &Energy_i, Normal, 0.5, val_Jacobian_i); + GetInviscidProjJac(Velocity_j, &Energy_j, Normal, 0.5, val_Jacobian_j); + + /*--- Roe's Flux approximation ---*/ + + for (iVar = 0; iVar < nVar; iVar++) { + for (jVar = 0; jVar < nVar; jVar++) { + su2double Proj_ModJac_Tensor_ij = 0.0; + /*--- Compute |Proj_ModJac_Tensor| = P x |Lambda| x inverse P ---*/ + for (kVar = 0; kVar < nVar; kVar++) + Proj_ModJac_Tensor_ij += P_Tensor[iVar][kVar]*fabs(Lambda[kVar])*invP_Tensor[kVar][jVar]; + val_Jacobian_i[iVar][jVar] += 0.5*Proj_ModJac_Tensor_ij*Area; + val_Jacobian_j[iVar][jVar] -= 0.5*Proj_ModJac_Tensor_ij*Area; + } + } + +} + +void CUpwAUSMPLUS_SLAU_Base_Flow::AccurateJacobian(CConfig *config, su2double **val_Jacobian_i, su2double **val_Jacobian_j) { + + /*--- Compute Jacobians using a mixed (numerical/analytical) formulation ---*/ + + unsigned short iDim, iVar, jVar; + + /*--- If not computed analytically, numerically differentiate the fluxes wrt primitives ---*/ + + if (!HasAnalyticalDerivatives) { + + /*--- Create arrays of pointers to the primitive variables so + we can loop through and perturb them in a general way. ---*/ + + su2double *primitives_i[6], *primitives_j[6]; + + for (iDim = 0; iDim < nDim; ++iDim) { + primitives_i[iDim] = &Velocity_i[iDim]; + primitives_j[iDim] = &Velocity_j[iDim]; + } + primitives_i[ nDim ] = &Pressure_i; primitives_j[ nDim ] = &Pressure_j; + primitives_i[nDim+1] = &Density_i; primitives_j[nDim+1] = &Density_j; + primitives_i[nDim+2] = &Enthalpy_i; primitives_j[nDim+2] = &Enthalpy_j; + + /*--- Initialize the gradient arrays with the negative of the quantity, + then for forward finite differences we add to it and divide. ---*/ + + for (iVar = 0; iVar < 6; ++iVar) { + dmdot_dVi[iVar] = -MassFlux; dpres_dVi[iVar] = -Pressure; + dmdot_dVj[iVar] = -MassFlux; dpres_dVj[iVar] = -Pressure; + } + + for (iVar = 0; iVar < nDim+3; ++iVar) { + /*--- Perturb side i ---*/ + su2double epsilon = FinDiffStep * max(1.0, fabs(*primitives_i[iVar])); + *primitives_i[iVar] += epsilon; + ComputeMassAndPressureFluxes(config, MassFlux, Pressure); + dmdot_dVi[iVar] += MassFlux; dpres_dVi[iVar] += Pressure; + dmdot_dVi[iVar] /= epsilon; dpres_dVi[iVar] /= epsilon; + *primitives_i[iVar] -= epsilon; + + /*--- Perturb side j ---*/ + epsilon = FinDiffStep * max(1.0, fabs(*primitives_j[iVar])); + *primitives_j[iVar] += epsilon; + ComputeMassAndPressureFluxes(config, MassFlux, Pressure); + dmdot_dVj[iVar] += MassFlux; dpres_dVj[iVar] += Pressure; + dmdot_dVj[iVar] /= epsilon; dpres_dVj[iVar] /= epsilon; + *primitives_j[iVar] -= epsilon; + } + } + + /*--- Differentiation of fluxes wrt conservatives assuming ideal gas ---*/ + + su2double dmdot_dUi[5], dmdot_dUj[5], dpres_dUi[5], dpres_dUj[5]; + su2double sq_veli = 0.0, sq_velj = 0.0, dHi_drhoi = 0.0, dHj_drhoj = 0.0; + su2double oneOnRhoi = 1.0/Density_i, oneOnRhoj = 1.0/Density_j; + + for (jVar = 0; jVar < nVar; ++jVar) { + + /*--- Partial derivatives of the primitives wrt conservative "jVar" ---*/ + su2double dVi_dUi[6] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; + su2double dVj_dUj[6] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; + + if (jVar == 0) { // Density + for (iDim = 0; iDim < nDim; ++iDim) { + // -u,v,w / rho + dVi_dUi[iDim] = -Velocity_i[iDim] * oneOnRhoi; + dVj_dUj[iDim] = -Velocity_j[iDim] * oneOnRhoj; + // ||V||^2 + sq_veli += Velocity_i[iDim] * Velocity_i[iDim]; + sq_velj += Velocity_j[iDim] * Velocity_j[iDim]; + } + dVi_dUi[nDim] = 0.5*Gamma_Minus_One*sq_veli; + dVj_dUj[nDim] = 0.5*Gamma_Minus_One*sq_velj; + + dVi_dUi[nDim+1] = dVj_dUj[nDim+1] = 1.0; + + dHi_drhoi = 0.5*(Gamma-2.0)*sq_veli - Gamma*Pressure_i/((Gamma-1.0)*Density_i); + dHj_drhoj = 0.5*(Gamma-2.0)*sq_velj - Gamma*Pressure_j/((Gamma-1.0)*Density_j); + dVi_dUi[nDim+2] = dHi_drhoi * oneOnRhoi; + dVj_dUj[nDim+2] = dHj_drhoj * oneOnRhoj; + } + else if (jVar == nVar-1) { // rho*Energy + dVi_dUi[nDim] = dVj_dUj[nDim] = Gamma_Minus_One; + dVi_dUi[nDim+2] = Gamma * oneOnRhoi; + dVj_dUj[nDim+2] = Gamma * oneOnRhoj; + } + else { // Momentum + dVi_dUi[jVar-1] = oneOnRhoi; + dVj_dUj[jVar-1] = oneOnRhoj; + + dVi_dUi[nDim] = -Gamma_Minus_One*Velocity_i[jVar-1]; + dVj_dUj[nDim] = -Gamma_Minus_One*Velocity_j[jVar-1]; + + dVi_dUi[nDim+2] = dVi_dUi[nDim] * oneOnRhoi; + dVj_dUj[nDim+2] = dVj_dUj[nDim] * oneOnRhoj; + } + + /*--- Dot product to complete chain rule ---*/ + dmdot_dUi[jVar] = 0.0; dpres_dUi[jVar] = 0.0; + dmdot_dUj[jVar] = 0.0; dpres_dUj[jVar] = 0.0; + for (iVar = 0; iVar < 6; ++iVar) { + dmdot_dUi[jVar] += dmdot_dVi[iVar]*dVi_dUi[iVar]; + dpres_dUi[jVar] += dpres_dVi[iVar]*dVi_dUi[iVar]; + dmdot_dUj[jVar] += dmdot_dVj[iVar]*dVj_dUj[iVar]; + dpres_dUj[jVar] += dpres_dVj[iVar]*dVj_dUj[iVar]; + } + } + + /*--- Assemble final Jacobians (assuming phi = |mdot|) ---*/ + + su2double mdot_hat, psi_hat[5]; + + if (MassFlux > 0.0) { + mdot_hat = Area*MassFlux*oneOnRhoi; + for (iVar = 0; iVar < nVar; ++iVar) psi_hat[iVar] = Area*psi_i[iVar]; + } + else { + mdot_hat = Area*MassFlux*oneOnRhoj; + for (iVar = 0; iVar < nVar; ++iVar) psi_hat[iVar] = Area*psi_j[iVar]; + } + + /*--- Contribution from the mass flux derivatives ---*/ + for (iVar = 0; iVar < nVar; ++iVar) { + for (jVar = 0; jVar < nVar; ++jVar) { + val_Jacobian_i[iVar][jVar] = psi_hat[iVar] * dmdot_dUi[jVar]; + val_Jacobian_j[iVar][jVar] = psi_hat[iVar] * dmdot_dUj[jVar]; + } + } + + /*--- Contribution from the pressure derivatives ---*/ + for (iDim = 0; iDim < nDim; ++iDim) { + for (jVar = 0; jVar < nVar; ++jVar) { + val_Jacobian_i[iDim+1][jVar] += Normal[iDim] * dpres_dUi[jVar]; + val_Jacobian_j[iDim+1][jVar] += Normal[iDim] * dpres_dUj[jVar]; + } + } + + /*--- Contributions from the derivatives of PSI wrt the conservatives ---*/ + if (MassFlux > 0.0) { + /*--- Velocity terms ---*/ + for (iDim = 0; iDim < nDim; ++iDim) { + val_Jacobian_i[iDim+1][0] -= mdot_hat*Velocity_i[iDim]; + val_Jacobian_i[iDim+1][iDim+1] += mdot_hat; + val_Jacobian_i[nVar-1][iDim+1] -= mdot_hat*Gamma_Minus_One*Velocity_i[iDim]; + } + /*--- Energy terms ---*/ + val_Jacobian_i[nVar-1][0] += mdot_hat*dHi_drhoi; + val_Jacobian_i[nVar-1][nVar-1] += mdot_hat*Gamma; + } + else { + /*--- Velocity terms ---*/ + for (iDim = 0; iDim < nDim; ++iDim) { + val_Jacobian_j[iDim+1][0] -= mdot_hat*Velocity_j[iDim]; + val_Jacobian_j[iDim+1][iDim+1] += mdot_hat; + val_Jacobian_j[nVar-1][iDim+1] -= mdot_hat*Gamma_Minus_One*Velocity_j[iDim]; + } + /*--- Energy terms ---*/ + val_Jacobian_j[nVar-1][0] += mdot_hat*dHj_drhoj; + val_Jacobian_j[nVar-1][nVar-1] += mdot_hat*Gamma; + } + +} + +void CUpwAUSMPLUS_SLAU_Base_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { + + unsigned short iDim, iVar; + + /*--- Space to start preaccumulation ---*/ + + AD::StartPreacc(); + AD::SetPreaccIn(Normal, nDim); + AD::SetPreaccIn(V_i, nDim+4); + AD::SetPreaccIn(V_j, nDim+4); + + /*--- Variables for the general form and primitives for mass flux and pressure calculation. ---*/ + /*--- F_{1/2} = ||A|| ( 0.5 * mdot * (psi_i+psi_j) - 0.5 * |mdot| * (psi_i-psi_j) + N * pf ) ---*/ + + psi_i[0] = 1.0; psi_j[0] = 1.0; + + for (iDim = 0; iDim < nDim; iDim++) { + /*--- Velocities ---*/ + Velocity_i[iDim] = psi_i[iDim+1] = V_i[iDim+1]; + Velocity_j[iDim] = psi_j[iDim+1] = V_j[iDim+1]; + } + + /*--- Pressure and Density ---*/ + Pressure_i = V_i[nDim+1]; Pressure_j = V_j[nDim+1]; + Density_i = V_i[nDim+2]; Density_j = V_j[nDim+2]; + + /*--- Enthalpy ---*/ + Enthalpy_i = psi_i[nVar-1] = V_i[nDim+3]; + Enthalpy_j = psi_j[nVar-1] = V_j[nDim+3]; + + /*--- Face area (norm or the normal vector) ---*/ + + Area = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + Area += Normal[iDim]*Normal[iDim]; + Area = sqrt(Area); + + /*-- Unit Normal ---*/ + for (iDim = 0; iDim < nDim; iDim++) + UnitNormal[iDim] = Normal[iDim]/Area; + + /*--- Mass and pressure fluxes defined by derived classes ---*/ + + ComputeMassAndPressureFluxes(config, MassFlux, Pressure); + DissFlux = fabs(MassFlux); + + val_residual[0] = MassFlux; + + for (iDim = 0; iDim < nDim; iDim++) + val_residual[iDim+1] = 0.5*MassFlux*(psi_i[iDim+1]+psi_j[iDim+1]) + + 0.5*DissFlux*(psi_i[iDim+1]-psi_j[iDim+1]) + + UnitNormal[iDim]*Pressure; + + val_residual[nVar-1] = 0.5*MassFlux*(psi_i[nVar-1]+psi_j[nVar-1]) + + 0.5*DissFlux*(psi_i[nVar-1]-psi_j[nVar-1]); + + for (iVar = 0; iVar < nVar; iVar++) val_residual[iVar] *= Area; + + /*--- Space to end preaccumulation ---*/ + + AD::SetPreaccOut(val_residual, nVar); + AD::EndPreacc(); + + /*--- If required, compute Jacobians, either approximately (Roe) or numerically ---*/ + + if (!implicit) return; + + if (UseAccurateJacobian) + AccurateJacobian(config, val_Jacobian_i, val_Jacobian_j); + else + ApproximateJacobian(val_Jacobian_i, val_Jacobian_j); + +} + +CUpwAUSMPLUSUP_Flow::CUpwAUSMPLUSUP_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : + CUpwAUSMPLUS_SLAU_Base_Flow(val_nDim, val_nVar, config) { + + HasAnalyticalDerivatives = true; + Minf = config->GetMach(); + 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); +} + +void CUpwAUSMPLUSUP_Flow::ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure) { + + /*--- Projected velocities ---*/ + + su2double ProjVelocity_i = 0.0, ProjVelocity_j = 0.0; + + for (unsigned short iDim = 0; iDim < nDim; iDim++) { + ProjVelocity_i += Velocity_i[iDim]*UnitNormal[iDim]; + ProjVelocity_j += Velocity_j[iDim]*UnitNormal[iDim]; + } + + /*--- Compute interface speed of sound (aF) ---*/ + + su2double astarL = sqrt(2.0*(Gamma-1.0)/(Gamma+1.0)*Enthalpy_i); + su2double astarR = sqrt(2.0*(Gamma-1.0)/(Gamma+1.0)*Enthalpy_j); + + su2double ahatL = astarL*astarL/max(astarL, ProjVelocity_i); + su2double ahatR = astarR*astarR/max(astarR,-ProjVelocity_j); + + su2double aF = min(ahatL,ahatR); + + /*--- Left and right pressures and Mach numbers ---*/ + + su2double mLP, betaLP, mRM, betaRM; + + su2double mL = ProjVelocity_i/aF; + su2double mR = ProjVelocity_j/aF; + + su2double MFsq = 0.5*(mL*mL+mR*mR); + su2double param1 = max(MFsq, Minf*Minf); + su2double Mrefsq = min(1.0, param1); + + su2double fa = 2.0*sqrt(Mrefsq)-Mrefsq; + + su2double alpha = 3.0/16.0*(-4.0+5.0*fa*fa); + su2double beta = 1.0/8.0; + + if (fabs(mL) <= 1.0) { + su2double p1 = 0.25*(mL+1.0)*(mL+1.0); + su2double p2 = (mL*mL-1.0)*(mL*mL-1.0); + + mLP = p1 + beta*p2; + betaLP = p1*(2.0-mL) + alpha*mL*p2; + } + else { + mLP = 0.5*(mL+fabs(mL)); + betaLP = mLP/mL; + } + + if (fabs(mR) <= 1.0) { + su2double p1 = 0.25*(mR-1.0)*(mR-1.0); + su2double p2 = (mR*mR-1.0)*(mR*mR-1.0); + + mRM = -p1 - beta*p2; + betaRM = p1*(2.0+mR) - alpha*mR*p2; + } + else { + mRM = 0.5*(mR-fabs(mR)); + betaRM = mRM/mR; + } + + /*--- Pressure and velocity diffusion terms ---*/ + + su2double rhoF = 0.5*(Density_i+Density_j); + su2double Mp = -(Kp/fa)*max((1.0-sigma*MFsq),0.0)*(Pressure_j-Pressure_i)/(rhoF*aF*aF); + + su2double Pu = -Ku*fa*betaLP*betaRM*2.0*rhoF*aF*(ProjVelocity_j-ProjVelocity_i); + + /*--- Finally the fluxes ---*/ + + su2double mF = mLP + mRM + Mp; + mdot = aF * (max(mF,0.0)*Density_i + min(mF,0.0)*Density_j); + + pressure = betaLP*Pressure_i + betaRM*Pressure_j + Pu; + + if (!implicit || !UseAccurateJacobian) return; + + /*--- Analytical differentiation of the face mass flux and + pressure (in reverse mode, "?_b" denotes dmot_d?). ---*/ + + /*--- limited mean Mach number (used in division...) ---*/ + su2double MF = max(numeric_limits::epsilon(),sqrt(MFsq)); + + for (int outVar=0; outVar<2; ++outVar) { + + su2double aF_b = 0.0, mF_b = 0.0, MF_b = 0.0, rhoF_b = 0.0, fa_b = 0.0, alpha_b = 0.0, + rho_i_b = 0.0, rho_j_b = 0.0, p_i_b = 0.0, p_j_b = 0.0, Vn_i_b = 0.0, Vn_j_b = 0.0, + mR_b = 0.0, mL_b = 0.0, betaLP_b = 0.0, betaRM_b = 0.0, tmp = 0.0; + + if (outVar==0) { + /*--- mdot = ... ---*/ + if (mF > 0.0) { + aF_b += mF*Density_i; + mF_b += aF*Density_i; + rho_i_b += mF*aF; + } + else { + aF_b += mF*Density_j; + mF_b += aF*Density_j; + rho_j_b += mF*aF; + } + + /*--- Mp = ... ---*/ + if (sigma*MFsq < 1.0) { + rhoF_b -= Mp/rhoF * mF_b; + fa_b -= Mp/fa * mF_b; + aF_b -= 2.0*Mp/aF * mF_b; + MF_b += 2.0*sigma*MF*(Kp/fa)*(Pressure_j-Pressure_i)/(rhoF*aF*aF) * mF_b; + tmp = -(Kp/fa)*(1.0-sigma*MFsq)/(rhoF*aF*aF); + p_i_b -= tmp * mF_b; + p_j_b += tmp * mF_b; + } + + /*--- rhoF = ... ---*/ + rho_i_b += 0.5*rhoF_b; rho_j_b += 0.5*rhoF_b; + + /*--- mRM = ... ---*/ + if (fabs(mR) < 1.0) mR_b += (1.0-mR)*(0.5+4.0*beta*mR*(mR+1.0)) * mF_b; + else if (mR <=-1.0) mR_b += mF_b; + + /*--- mLP = ... ---*/ + if (fabs(mL) < 1.0) mL_b += (1.0+mL)*(0.5+4.0*beta*mL*(mL-1.0)) * mF_b; + else if (mL >= 1.0) mL_b += mF_b; + } + else { + /*--- pressure = ... ---*/ + p_i_b += betaLP; betaLP_b += Pressure_i; + p_j_b += betaRM; betaRM_b += Pressure_j; + + /*--- Pu = ... ---*/ + rhoF_b += Pu/rhoF; + fa_b += Pu/fa; + aF_b += Pu/aF; + tmp = -Ku*fa*2.0*rhoF*aF*(ProjVelocity_j-ProjVelocity_i); + betaLP_b += tmp*betaRM; + betaRM_b += tmp*betaLP; + tmp = -Ku*fa*betaLP*betaRM*2.0*rhoF*aF; + Vn_i_b -= tmp; + Vn_j_b += tmp; + + /*--- rhoF = ... ---*/ + rho_i_b += 0.5*rhoF_b; rho_j_b += 0.5*rhoF_b; + + /*--- betaRM = ... ---*/ + if (fabs(mR) < 1.0) { + tmp = mR*mR-1.0; + mR_b += tmp*(0.75-alpha*(5.0*tmp+4.0)) * betaRM_b; + alpha_b -= mR*tmp*tmp * betaRM_b; + } + + /*--- betaLP = ... ---*/ + if (fabs(mL) < 1.0) { + tmp = mL*mL-1.0; + mL_b -= tmp*(0.75-alpha*(5.0*tmp+4.0)) * betaLP_b; + alpha_b += mL*tmp*tmp * betaLP_b; + } + + /*--- alpha = ... ---*/ + fa_b += 1.875*fa * alpha_b; + } + + /*--- steps shared by both ---*/ + /*--- fa = ... ---*/ + su2double Mref_b = 2.0*(1.0-sqrt(Mrefsq)) * fa_b; + + /*--- Mrefsq = ... ---*/ + if (MF < 1.0 && MF > Minf) MF_b += Mref_b; + + /*--- MFsq = ... ---*/ + mL_b += 0.5*mL/MF * MF_b; mR_b += 0.5*mR/MF * MF_b; + + /*--- mL/R = ... ---*/ + Vn_i_b += mL_b/aF; Vn_j_b += mR_b/aF; + aF_b -= (mL*mL_b+mR*mR_b)/aF; + + /*--- aF,ahat,astar = f(H_i,H_j) ---*/ + su2double astar_b = aF_b, H_i_b, H_j_b; + + if (ahatL < ahatR) { + if (astarL <= ProjVelocity_i) { + tmp = astarL/ProjVelocity_i; + astar_b *= 2.0*tmp; + Vn_i_b -= tmp*tmp * aF_b; + } + H_i_b = sqrt(0.5*(Gamma-1.0)/((Gamma+1.0)*Enthalpy_i)) * astar_b; + H_j_b = 0.0; + } + else { + if (astarR <= -ProjVelocity_j) { + tmp = -astarR/ProjVelocity_j; + astar_b *= 2.0*tmp; + Vn_j_b += tmp*tmp * aF_b; + } + H_j_b = sqrt(0.5*(Gamma-1.0)/((Gamma+1.0)*Enthalpy_j)) * astar_b; + H_i_b = 0.0; + } + + /*--- store derivatives ---*/ + su2double *target_i = (outVar==0 ? dmdot_dVi : dpres_dVi), + *target_j = (outVar==0 ? dmdot_dVj : dpres_dVj); + target_i[5] = target_j[5] = 0.0; + + /*--- ProjVelocity = ... ---*/ + for (unsigned short iDim = 0; iDim < nDim; ++iDim) { + target_i[iDim] = UnitNormal[iDim] * Vn_i_b; + target_j[iDim] = UnitNormal[iDim] * Vn_j_b; + } + target_i[ nDim ] = p_i_b; target_j[ nDim ] = p_j_b; + target_i[nDim+1] = rho_i_b; target_j[nDim+1] = rho_j_b; + target_i[nDim+2] = H_i_b; target_j[nDim+2] = H_j_b; + } +} + +CUpwAUSMPLUSUP2_Flow::CUpwAUSMPLUSUP2_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : + CUpwAUSMPLUS_SLAU_Base_Flow(val_nDim, val_nVar, config) { + + 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); +} + +void CUpwAUSMPLUSUP2_Flow::ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure) { + + /*--- Projected velocities and squared magnitude ---*/ + + su2double ProjVelocity_i = 0.0, ProjVelocity_j = 0.0, sq_vel = 0.0; + + for (unsigned short iDim = 0; iDim < nDim; iDim++) { + ProjVelocity_i += Velocity_i[iDim]*UnitNormal[iDim]; + ProjVelocity_j += Velocity_j[iDim]*UnitNormal[iDim]; + + sq_vel += 0.5*(Velocity_i[iDim]*Velocity_i[iDim] + Velocity_j[iDim]*Velocity_j[iDim]); + } + + /*--- Compute interface speed of sound (aF) ---*/ + + su2double astarL = sqrt(2.0*(Gamma-1.0)/(Gamma+1.0)*Enthalpy_i); + su2double astarR = sqrt(2.0*(Gamma-1.0)/(Gamma+1.0)*Enthalpy_j); + + su2double ahatL = astarL*astarL/max(astarL, ProjVelocity_i); + su2double ahatR = astarR*astarR/max(astarR,-ProjVelocity_j); + + su2double aF = min(ahatL,ahatR); + + /*--- Left and right pressure functions and Mach numbers ---*/ + + su2double mLP, pLP, mRM, pRM; + + su2double mL = ProjVelocity_i/aF; + su2double mR = ProjVelocity_j/aF; + + su2double MFsq = 0.5*(mL*mL+mR*mR); + su2double param1 = max(MFsq, Minf*Minf); + su2double Mrefsq = min(1.0, param1); + + su2double fa = 2.0*sqrt(Mrefsq)-Mrefsq; + + su2double alpha = 3.0/16.0*(-4.0+5.0*fa*fa); + su2double beta = 1.0/8.0; + + if (fabs(mL) <= 1.0) { + su2double p1 = 0.25*(mL+1.0)*(mL+1.0); + su2double p2 = (mL*mL-1.0)*(mL*mL-1.0); + + mLP = p1 + beta*p2; + pLP = p1*(2.0-mL) + alpha*mL*p2; + } + else { + mLP = 0.5*(mL+fabs(mL)); + pLP = mLP/mL; + } + + if (fabs(mR) <= 1.0) { + su2double p1 = 0.25*(mR-1.0)*(mR-1.0); + su2double p2 = (mR*mR-1.0)*(mR*mR-1.0); + + mRM = -p1 - beta*p2; + pRM = p1*(2.0+mR) - alpha*mR*p2; + } + else { + mRM = 0.5*(mR-fabs(mR)); + pRM = mRM/mR; + } + + /*--- Mass flux with pressure diffusion term ---*/ + + su2double rhoF = 0.5*(Density_i+Density_j); + su2double Mp = -(Kp/fa)*max((1.0-sigma*MFsq),0.0)*(Pressure_j-Pressure_i)/(rhoF*aF*aF); + + su2double mF = mLP + mRM + Mp; + mdot = aF * (max(mF,0.0)*Density_i + min(mF,0.0)*Density_j); + + /*--- Modified pressure flux ---*/ + + pressure = 0.5*(Pressure_j+Pressure_i) + 0.5*(pLP-pRM)*(Pressure_i-Pressure_j) + sqrt(sq_vel)*(pLP+pRM-1.0)*rhoF*aF; + +} + +CUpwSLAU_Flow::CUpwSLAU_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, bool val_low_dissipation) : + CUpwAUSMPLUS_SLAU_Base_Flow(val_nDim, val_nVar, config) { + + slau_low_diss = val_low_dissipation; + slau2 = false; +} + +CUpwSLAU2_Flow::CUpwSLAU2_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, bool val_low_dissipation) : + CUpwSLAU_Flow(val_nDim, val_nVar, config, val_low_dissipation) { + + /*--- The difference between SLAU and SLAU2 is minimal, so we derive from SLAU and set this flag + so that the ComputeMassAndPressureFluxes function modifies the pressure according to SLAU2. + This is safe since this constructor is guaranteed to execute after SLAU's one. ---*/ + slau2 = true; +} + +void CUpwSLAU_Flow::ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure) { + + /*--- Project velocities and speed of sound ---*/ + + su2double ProjVelocity_i = 0.0, ProjVelocity_j = 0.0, sq_veli = 0.0, sq_velj = 0.0; + + for (unsigned short iDim = 0; iDim < nDim; iDim++) { + ProjVelocity_i += Velocity_i[iDim]*UnitNormal[iDim]; + ProjVelocity_j += Velocity_j[iDim]*UnitNormal[iDim]; + + sq_veli += Velocity_i[iDim]*Velocity_i[iDim]; + sq_velj += Velocity_j[iDim]*Velocity_j[iDim]; + } + + su2double Energy_i = Enthalpy_i - Pressure_i/Density_i; + SoundSpeed_i = sqrt(fabs(Gamma*Gamma_Minus_One*(Energy_i-0.5*sq_veli))); + + su2double Energy_j = Enthalpy_j - Pressure_j/Density_j; + SoundSpeed_j = sqrt(fabs(Gamma*Gamma_Minus_One*(Energy_j-0.5*sq_velj))); + + /*--- Compute interface speed of sound (aF), and left/right Mach number ---*/ + + su2double aF = 0.5 * (SoundSpeed_i + SoundSpeed_j); + su2double mL = ProjVelocity_i/aF; + su2double mR = ProjVelocity_j/aF; + + /*--- Smooth function of the local Mach number---*/ + + su2double Mach_tilde = min(1.0, (1.0/aF) * sqrt(0.5*(sq_veli+sq_velj))); + su2double Chi = pow((1.0 - Mach_tilde),2.0); + su2double f_rho = -max(min(mL,0.0),-1.0) * min(max(mR,0.0),1.0); + + /*--- Mean normal velocity with density weighting ---*/ + + su2double Vn_Mag = (Density_i*fabs(ProjVelocity_i) + Density_j*fabs(ProjVelocity_j)) / (Density_i + Density_j); + su2double Vn_MagL= (1.0 - f_rho)*Vn_Mag + f_rho*fabs(ProjVelocity_i); + su2double Vn_MagR= (1.0 - f_rho)*Vn_Mag + f_rho*fabs(ProjVelocity_j); + + /*--- Mass flux function ---*/ + + mdot = 0.5 * (Density_i*(ProjVelocity_i+Vn_MagL) + Density_j*(ProjVelocity_j-Vn_MagR) - (Chi/aF)*(Pressure_j-Pressure_i)); + + /*--- Pressure function ---*/ + + su2double BetaL, BetaR, Dissipation_ij; + + if (fabs(mL) < 1.0) BetaL = 0.25*(2.0-mL)*pow((mL+1.0),2.0); + else if (mL >= 0) BetaL = 1.0; + else BetaL = 0.0; + + if (fabs(mR) < 1.0) BetaR = 0.25*(2.0+mR)*pow((mR-1.0),2.0); + else if (mR >= 0) BetaR = 0.0; + else BetaR = 1.0; + + if (slau_low_diss) + SetRoe_Dissipation(Dissipation_i, Dissipation_j, Sensor_i, Sensor_j, Dissipation_ij, config); + else + Dissipation_ij = 1.0; + + pressure = 0.5*(Pressure_i+Pressure_j) + 0.5*(BetaL-BetaR)*(Pressure_i-Pressure_j); + + if (!slau2) pressure += Dissipation_ij*(1.0-Chi)*(BetaL+BetaR-1.0)*0.5*(Pressure_i+Pressure_j); + else pressure += Dissipation_ij*sqrt(0.5*(sq_veli+sq_velj))*(BetaL+BetaR-1.0)*aF*0.5*(Density_i+Density_j); + +} + +CUpwAUSM_Flow::CUpwAUSM_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + if (config->GetDynamic_Grid() && (SU2_MPI::GetRank() == MASTER_NODE)) + cout << "WARNING: Grid velocities are NOT yet considered in AUSM-type schemes." << endl; + + implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + + Diff_U = new su2double [nVar]; + Velocity_i = new su2double [nDim]; + Velocity_j = new su2double [nDim]; + RoeVelocity = new su2double [nDim]; + delta_vel = new su2double [nDim]; + delta_wave = new su2double [nVar]; + ProjFlux_i = new su2double [nVar]; + ProjFlux_j = new su2double [nVar]; + Lambda = new su2double [nVar]; + Epsilon = new su2double [nVar]; + P_Tensor = new su2double* [nVar]; + invP_Tensor = new su2double* [nVar]; + for (iVar = 0; iVar < nVar; iVar++) { + P_Tensor[iVar] = new su2double [nVar]; + invP_Tensor[iVar] = new su2double [nVar]; + } +} + +CUpwAUSM_Flow::~CUpwAUSM_Flow(void) { + + delete [] Diff_U; + delete [] Velocity_i; + delete [] Velocity_j; + delete [] RoeVelocity; + delete [] delta_vel; + delete [] delta_wave; + delete [] ProjFlux_i; + delete [] ProjFlux_j; + delete [] Lambda; + delete [] Epsilon; + for (iVar = 0; iVar < nVar; iVar++) { + delete [] P_Tensor[iVar]; + delete [] invP_Tensor[iVar]; + } + delete [] P_Tensor; + delete [] invP_Tensor; + +} + +void CUpwAUSM_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { + + AD::StartPreacc(); + AD::SetPreaccIn(Normal, nDim); + AD::SetPreaccIn(V_i, nDim+4); + AD::SetPreaccIn(V_j, nDim+4); + + /*--- Face area (norm or the normal vector) ---*/ + Area = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + Area += Normal[iDim]*Normal[iDim]; + Area = sqrt(Area); + + /*-- Unit Normal ---*/ + for (iDim = 0; iDim < nDim; iDim++) + UnitNormal[iDim] = Normal[iDim]/Area; + + /*--- Primitive variables at point i ---*/ + sq_vel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + Velocity_i[iDim] = V_i[iDim+1]; + sq_vel += Velocity_i[iDim]*Velocity_i[iDim]; + } + Pressure_i = V_i[nDim+1]; + Density_i = V_i[nDim+2]; + Enthalpy_i = V_i[nDim+3]; + Energy_i = Enthalpy_i - Pressure_i/Density_i; + SoundSpeed_i = sqrt(fabs(Gamma*Gamma_Minus_One*(Energy_i-0.5*sq_vel))); + + /*--- Primitive variables at point j ---*/ + sq_vel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + Velocity_j[iDim] = V_j[iDim+1]; + sq_vel += Velocity_j[iDim]*Velocity_j[iDim]; + } + Pressure_j = V_j[nDim+1]; + Density_j = V_j[nDim+2]; + Enthalpy_j = V_j[nDim+3]; + Energy_j = Enthalpy_j - Pressure_j/Density_j; + SoundSpeed_j = sqrt(fabs(Gamma*Gamma_Minus_One*(Energy_j-0.5*sq_vel))); + + /*--- Projected velocities ---*/ + ProjVelocity_i = 0.0; ProjVelocity_j = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + ProjVelocity_i += Velocity_i[iDim]*UnitNormal[iDim]; + ProjVelocity_j += Velocity_j[iDim]*UnitNormal[iDim]; + } + + mL = ProjVelocity_i/SoundSpeed_i; + mR = ProjVelocity_j/SoundSpeed_j; + + if (fabs(mL) <= 1.0) mLP = 0.25*(mL+1.0)*(mL+1.0); + else mLP = 0.5*(mL+fabs(mL)); + + if (fabs(mR) <= 1.0) mRM = -0.25*(mR-1.0)*(mR-1.0); + else mRM = 0.5*(mR-fabs(mR)); + + mF = mLP + mRM; + + if (fabs(mL) <= 1.0) pLP = 0.25*Pressure_i*(mL+1.0)*(mL+1.0)*(2.0-mL); + else pLP = 0.5*Pressure_i*(mL+fabs(mL))/mL; + + if (fabs(mR) <= 1.0) pRM = 0.25*Pressure_j*(mR-1.0)*(mR-1.0)*(2.0+mR); + else pRM = 0.5*Pressure_j*(mR-fabs(mR))/mR; + + pF = pLP + pRM; + Phi = fabs(mF); + + val_residual[0] = 0.5*(mF*((Density_i*SoundSpeed_i)+(Density_j*SoundSpeed_j))-Phi*((Density_j*SoundSpeed_j)-(Density_i*SoundSpeed_i))); + for (iDim = 0; iDim < nDim; iDim++) + val_residual[iDim+1] = 0.5*(mF*((Density_i*SoundSpeed_i*Velocity_i[iDim])+(Density_j*SoundSpeed_j*Velocity_j[iDim])) + -Phi*((Density_j*SoundSpeed_j*Velocity_j[iDim])-(Density_i*SoundSpeed_i*Velocity_i[iDim])))+UnitNormal[iDim]*pF; + val_residual[nVar-1] = 0.5*(mF*((Density_i*SoundSpeed_i*Enthalpy_i)+(Density_j*SoundSpeed_j*Enthalpy_j))-Phi*((Density_j*SoundSpeed_j*Enthalpy_j)-(Density_i*SoundSpeed_i*Enthalpy_i))); + + for (iVar = 0; iVar < nVar; iVar++) + val_residual[iVar] *= Area; + + AD::SetPreaccOut(val_residual, nVar); + AD::EndPreacc(); + + /*--- Roe's Jacobian for AUSM (this must be fixed) ---*/ + if (implicit) { + + /*--- Mean Roe variables iPoint and jPoint ---*/ + R = sqrt(fabs(Density_j/Density_i)); + RoeDensity = R*Density_i; + sq_vel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + RoeVelocity[iDim] = (R*Velocity_j[iDim]+Velocity_i[iDim])/(R+1); + sq_vel += RoeVelocity[iDim]*RoeVelocity[iDim]; + } + RoeEnthalpy = (R*Enthalpy_j+Enthalpy_i)/(R+1); + RoeSoundSpeed = sqrt(fabs((Gamma-1)*(RoeEnthalpy-0.5*sq_vel))); + + /*--- Compute P and Lambda (do it with the Normal) ---*/ + GetPMatrix(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, P_Tensor); + + ProjVelocity = 0.0; ProjVelocity_i = 0.0; ProjVelocity_j = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + ProjVelocity += RoeVelocity[iDim]*UnitNormal[iDim]; + ProjVelocity_i += Velocity_i[iDim]*UnitNormal[iDim]; + ProjVelocity_j += Velocity_j[iDim]*UnitNormal[iDim]; + } + + /*--- Flow eigenvalues and Entropy correctors ---*/ + for (iDim = 0; iDim < nDim; iDim++) + Lambda[iDim] = ProjVelocity; + Lambda[nVar-2] = ProjVelocity + RoeSoundSpeed; + Lambda[nVar-1] = ProjVelocity - RoeSoundSpeed; + + /*--- Compute inverse P ---*/ + GetPMatrix_inv(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, invP_Tensor); + + /*--- Jacobias of the inviscid flux, scale = 0.5 because val_residual ~ 0.5*(fc_i+fc_j)*Normal ---*/ + GetInviscidProjJac(Velocity_i, &Energy_i, Normal, 0.5, val_Jacobian_i); + GetInviscidProjJac(Velocity_j, &Energy_j, Normal, 0.5, val_Jacobian_j); + + /*--- Roe's Flux approximation ---*/ + for (iVar = 0; iVar < nVar; iVar++) { + for (jVar = 0; jVar < nVar; jVar++) { + Proj_ModJac_Tensor_ij = 0.0; + /*--- Compute |Proj_ModJac_Tensor| = P x |Lambda| x inverse P ---*/ + for (kVar = 0; kVar < nVar; kVar++) + Proj_ModJac_Tensor_ij += P_Tensor[iVar][kVar]*fabs(Lambda[kVar])*invP_Tensor[kVar][jVar]; + val_Jacobian_i[iVar][jVar] += 0.5*Proj_ModJac_Tensor_ij*Area; + val_Jacobian_j[iVar][jVar] -= 0.5*Proj_ModJac_Tensor_ij*Area; + } + } + } +} diff --git a/SU2_CFD/src/numerics/flow/convection/centered.cpp b/SU2_CFD/src/numerics/flow/convection/centered.cpp new file mode 100644 index 000000000000..8273a4d53842 --- /dev/null +++ b/SU2_CFD/src/numerics/flow/convection/centered.cpp @@ -0,0 +1,751 @@ +/*! + * \file centered.cpp + * \brief Implementations of centered schemes. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../../include/numerics/flow/convection/centered.hpp" + +CCentBase_Flow::CCentBase_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : + CNumerics(val_nDim, val_nVar, config) { + + implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ + dynamic_grid = config->GetDynamic_Grid(); + fix_factor = config->GetCent_Jac_Fix_Factor(); + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + + /*--- Allocate required structures ---*/ + Diff_U = new su2double [nVar]; + Diff_Lapl = new su2double [nVar]; + Velocity_i = new su2double [nDim]; + Velocity_j = new su2double [nDim]; + MeanVelocity = new su2double [nDim]; + ProjFlux = new su2double [nVar]; +} + +CCentBase_Flow::~CCentBase_Flow(void) { + delete [] Diff_U; + delete [] Diff_Lapl; + delete [] Velocity_i; + delete [] Velocity_j; + delete [] MeanVelocity; + delete [] ProjFlux; +} + +void CCentBase_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, + CConfig *config) { + + su2double U_i[5] = {0.0,0.0,0.0,0.0,0.0}, U_j[5] = {0.0,0.0,0.0,0.0,0.0}; + + bool preacc = SetPreaccInVars(); + + if (preacc) { + AD::SetPreaccIn(Normal, nDim); + AD::SetPreaccIn(V_i, nDim+5); AD::SetPreaccIn(V_j, nDim+5); + AD::SetPreaccIn(Lambda_i); AD::SetPreaccIn(Lambda_j); + if (dynamic_grid) { + AD::SetPreaccIn(GridVel_i, nDim); AD::SetPreaccIn(GridVel_j, nDim); + } + } + + /*--- Pressure, density, enthalpy, energy, and velocity at points i and j ---*/ + + Pressure_i = V_i[nDim+1]; Pressure_j = V_j[nDim+1]; + Density_i = V_i[nDim+2]; Density_j = V_j[nDim+2]; + Enthalpy_i = V_i[nDim+3]; Enthalpy_j = V_j[nDim+3]; + SoundSpeed_i = V_i[nDim+4]; SoundSpeed_j = V_j[nDim+4]; + Energy_i = Enthalpy_i - Pressure_i/Density_i; Energy_j = Enthalpy_j - Pressure_j/Density_j; + + sq_vel_i = 0.0; sq_vel_j = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + Velocity_i[iDim] = V_i[iDim+1]; + Velocity_j[iDim] = V_j[iDim+1]; + sq_vel_i += 0.5*Velocity_i[iDim]*Velocity_i[iDim]; + sq_vel_j += 0.5*Velocity_j[iDim]*Velocity_j[iDim]; + } + + /*--- Recompute conservative variables ---*/ + + U_i[0] = Density_i; U_j[0] = Density_j; + for (iDim = 0; iDim < nDim; iDim++) { + U_i[iDim+1] = Density_i*Velocity_i[iDim]; U_j[iDim+1] = Density_j*Velocity_j[iDim]; + } + U_i[nDim+1] = Density_i*Energy_i; U_j[nDim+1] = Density_j*Energy_j; + + /*--- Compute mean values of the variables ---*/ + + MeanDensity = 0.5*(Density_i+Density_j); + MeanPressure = 0.5*(Pressure_i+Pressure_j); + MeanEnthalpy = 0.5*(Enthalpy_i+Enthalpy_j); + for (iDim = 0; iDim < nDim; iDim++) + MeanVelocity[iDim] = 0.5*(Velocity_i[iDim]+Velocity_j[iDim]); + MeanEnergy = 0.5*(Energy_i+Energy_j); + + /*--- Get projected flux tensor ---*/ + + GetInviscidProjFlux(&MeanDensity, MeanVelocity, &MeanPressure, &MeanEnthalpy, Normal, ProjFlux); + + /*--- Residual of the inviscid flux ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + val_residual[iVar] = ProjFlux[iVar]; + + /*--- Jacobians of the inviscid flux, scale = 0.5 because val_residual ~ 0.5*(fc_i+fc_j)*Normal ---*/ + + if (implicit) { + GetInviscidProjJac(MeanVelocity, &MeanEnergy, Normal, 0.5, val_Jacobian_i); + for (iVar = 0; iVar < nVar; iVar++) + for (jVar = 0; jVar < nVar; jVar++) + val_Jacobian_j[iVar][jVar] = val_Jacobian_i[iVar][jVar]; + } + + /*--- Adjustment due to grid motion ---*/ + + if (dynamic_grid) { + ProjGridVel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; + + for (iVar = 0; iVar < nVar; iVar++) { + val_residual[iVar] -= ProjGridVel * 0.5*(U_i[iVar] + U_j[iVar]); + if (implicit) { + val_Jacobian_i[iVar][iVar] -= 0.5*ProjGridVel; + val_Jacobian_j[iVar][iVar] -= 0.5*ProjGridVel; + } + } + } + + /*--- Compute the local spectral radius and the stretching factor ---*/ + + ProjVelocity_i = 0.0; ProjVelocity_j = 0.0; Area = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + ProjVelocity_i += Velocity_i[iDim]*Normal[iDim]; + ProjVelocity_j += Velocity_j[iDim]*Normal[iDim]; + Area += Normal[iDim]*Normal[iDim]; + } + Area = sqrt(Area); + + /*--- Adjustment due to mesh motion ---*/ + + if (dynamic_grid) { + ProjVelocity_i -= ProjGridVel; + ProjVelocity_j -= ProjGridVel; + } + + /*--- Dissipation term ---*/ + + Local_Lambda_i = (fabs(ProjVelocity_i)+SoundSpeed_i*Area); + Local_Lambda_j = (fabs(ProjVelocity_j)+SoundSpeed_j*Area); + MeanLambda = 0.5*(Local_Lambda_i+Local_Lambda_j); + + Phi_i = pow(Lambda_i/(4.0*MeanLambda), Param_p); + Phi_j = pow(Lambda_j/(4.0*MeanLambda), Param_p); + StretchingFactor = 4.0*Phi_i*Phi_j/(Phi_i+Phi_j); + + /*--- Compute differences btw. conservative variables, with a correction for enthalpy ---*/ + + for (iVar = 0; iVar < nVar-1; iVar++) { + Diff_U[iVar] = U_i[iVar]-U_j[iVar]; + } + Diff_U[nVar-1] = Density_i*Enthalpy_i-Density_j*Enthalpy_j; + + DissipationTerm(val_residual, val_Jacobian_i, val_Jacobian_j); + + if (preacc) { + AD::SetPreaccOut(val_residual, nVar); + AD::EndPreacc(); + } +} + +void CCentBase_Flow::ScalarDissipationJacobian(su2double **val_Jacobian_i, su2double **val_Jacobian_j) { + + /*--- n-1 diagonal entries ---*/ + + for (iVar = 0; iVar < (nVar-1); iVar++) { + val_Jacobian_i[iVar][iVar] += fix_factor*cte_0; + val_Jacobian_j[iVar][iVar] -= fix_factor*cte_1; + } + + /*--- Last row of Jacobian_i ---*/ + + val_Jacobian_i[nVar-1][0] += fix_factor*cte_0*Gamma_Minus_One*sq_vel_i; + for (iDim = 0; iDim < nDim; iDim++) + val_Jacobian_i[nVar-1][iDim+1] -= fix_factor*cte_0*Gamma_Minus_One*Velocity_i[iDim]; + val_Jacobian_i[nVar-1][nVar-1] += fix_factor*cte_0*Gamma; + + /*--- Last row of Jacobian_j ---*/ + + val_Jacobian_j[nVar-1][0] -= fix_factor*cte_1*Gamma_Minus_One*sq_vel_j; + for (iDim = 0; iDim < nDim; iDim++) + val_Jacobian_j[nVar-1][iDim+1] += fix_factor*cte_1*Gamma_Minus_One*Velocity_j[iDim]; + val_Jacobian_j[nVar-1][nVar-1] -= fix_factor*cte_1*Gamma; + +} + +CCentLax_Flow::CCentLax_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : + CCentBase_Flow(val_nDim, val_nVar, config) { + + /*--- Artifical dissipation parameters ---*/ + Param_p = 0.3; + Param_Kappa_0 = config->GetKappa_1st_Flow(); + +} + +void CCentLax_Flow::DissipationTerm(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j) { + + /*--- Compute dissipation coefficient ---*/ + + sc0 = 3.0*(su2double(Neighbor_i)+su2double(Neighbor_j))/(su2double(Neighbor_i)*su2double(Neighbor_j)); + Epsilon_0 = Param_Kappa_0*sc0*su2double(nDim)/3.0; + + /*--- Compute viscous part of the residual ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + val_residual[iVar] += Epsilon_0*Diff_U[iVar]*StretchingFactor*MeanLambda; + + /*--- Jacobian computation ---*/ + + if (implicit) { + + cte_0 = Epsilon_0*StretchingFactor*MeanLambda; + cte_1 = cte_0; + + ScalarDissipationJacobian(val_Jacobian_i, val_Jacobian_j); + } +} + +bool CCentLax_Flow::SetPreaccInVars(void) { + AD::StartPreacc(); + return true; +} + +CCentJST_KE_Flow::CCentJST_KE_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : + CCentBase_Flow(val_nDim, val_nVar, config) { + + /*--- Artifical dissipation parameters ---*/ + Param_p = 0.3; + Param_Kappa_2 = config->GetKappa_2nd_Flow(); + +} + +void CCentJST_KE_Flow::DissipationTerm(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j) { + + /*--- Compute dissipation coefficient ---*/ + + sc2 = 3.0*(su2double(Neighbor_i)+su2double(Neighbor_j))/(su2double(Neighbor_i)*su2double(Neighbor_j)); + Epsilon_2 = Param_Kappa_2*0.5*(Sensor_i+Sensor_j)*sc2; + + /*--- Compute viscous part of the residual ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + val_residual[iVar] += Epsilon_2*(Diff_U[iVar])*StretchingFactor*MeanLambda; + + /*--- Jacobian computation ---*/ + + if (implicit) { + + cte_0 = Epsilon_2*StretchingFactor*MeanLambda; + cte_1 = cte_0; + + ScalarDissipationJacobian(val_Jacobian_i, val_Jacobian_j); + } +} + +bool CCentJST_KE_Flow::SetPreaccInVars(void) { + AD::StartPreacc(); + AD::SetPreaccIn(Sensor_i); AD::SetPreaccIn(Sensor_j); + return true; +} + +CCentJST_Flow::CCentJST_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : + CCentBase_Flow(val_nDim, val_nVar, config) { + + /*--- Artifical dissipation parameters ---*/ + Param_p = 0.3; + Param_Kappa_2 = config->GetKappa_2nd_Flow(); + Param_Kappa_4 = config->GetKappa_4th_Flow(); + +} + +void CCentJST_Flow::DissipationTerm(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j) { + + /*--- Compute differences btw. Laplacians ---*/ + + for (iVar = 0; iVar < nVar; iVar++) { + Diff_Lapl[iVar] = Und_Lapl_i[iVar]-Und_Lapl_j[iVar]; + } + + /*--- Compute dissipation coefficients ---*/ + + sc2 = 3.0*(su2double(Neighbor_i)+su2double(Neighbor_j))/(su2double(Neighbor_i)*su2double(Neighbor_j)); + sc4 = sc2*sc2/4.0; + + Epsilon_2 = Param_Kappa_2*0.5*(Sensor_i+Sensor_j)*sc2; + Epsilon_4 = max(0.0, Param_Kappa_4-Epsilon_2)*sc4; + + /*--- Compute viscous part of the residual ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + val_residual[iVar] += (Epsilon_2*Diff_U[iVar] - Epsilon_4*Diff_Lapl[iVar])*StretchingFactor*MeanLambda; + + /*--- Jacobian computation ---*/ + + if (implicit) { + + cte_0 = (Epsilon_2 + Epsilon_4*su2double(Neighbor_i+1))*StretchingFactor*MeanLambda; + cte_1 = (Epsilon_2 + Epsilon_4*su2double(Neighbor_j+1))*StretchingFactor*MeanLambda; + + ScalarDissipationJacobian(val_Jacobian_i, val_Jacobian_j); + } +} + +bool CCentJST_Flow::SetPreaccInVars(void) { + AD::StartPreacc(); + AD::SetPreaccIn(Sensor_i); AD::SetPreaccIn(Und_Lapl_i, nVar); + AD::SetPreaccIn(Sensor_j); AD::SetPreaccIn(Und_Lapl_j, nVar); + return true; +} + +CCentLaxInc_Flow::CCentLaxInc_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + variable_density = (config->GetKind_DensityModel() == VARIABLE); + /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ + dynamic_grid = config->GetDynamic_Grid(); + energy = config->GetEnergy_Equation(); + + /*--- Artificial dissipation part ---*/ + + Param_p = 0.3; + Param_Kappa_0 = config->GetKappa_1st_Flow(); + + /*--- Allocate some structures ---*/ + + Diff_V = new su2double[nVar]; + Velocity_i = new su2double[nDim]; + Velocity_j = new su2double[nDim]; + MeanVelocity = new su2double[nDim]; + ProjFlux = new su2double[nVar]; + Precon = new su2double*[nVar]; + + for (iVar = 0; iVar < nVar; iVar++) + Precon[iVar] = new su2double[nVar]; + +} + +CCentLaxInc_Flow::~CCentLaxInc_Flow(void) { + + delete [] Diff_V; + delete [] Velocity_i; + delete [] Velocity_j; + delete [] MeanVelocity; + delete [] ProjFlux; + + for (iVar = 0; iVar < nVar; iVar++) + delete [] Precon[iVar]; + delete [] Precon; + +} + +void CCentLaxInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { + + su2double U_i[5] = {0.0,0.0,0.0,0.0,0.0}, U_j[5] = {0.0,0.0,0.0,0.0,0.0}; + su2double ProjGridVel = 0.0, ProjVelocity = 0.0; + + /*--- Primitive variables at point i and j ---*/ + + Pressure_i = V_i[0]; Pressure_j = V_j[0]; + Temperature_i = V_i[nDim+1]; Temperature_j = V_j[nDim+1]; + DensityInc_i = V_i[nDim+2]; DensityInc_j = V_j[nDim+2]; + BetaInc2_i = V_i[nDim+3]; BetaInc2_j = V_j[nDim+3]; + Cp_i = V_i[nDim+7]; Cp_j = V_j[nDim+7]; + Enthalpy_i = Cp_i*Temperature_i; Enthalpy_j = Cp_j*Temperature_j; + + Area = 0.0; + sq_vel_i = 0.0; sq_vel_j = 0.0; ProjVelocity_i = 0.0; ProjVelocity_j = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + Velocity_i[iDim] = V_i[iDim+1]; + Velocity_j[iDim] = V_j[iDim+1]; + MeanVelocity[iDim] = 0.5*(Velocity_i[iDim]+Velocity_j[iDim]); + sq_vel_i += 0.5*Velocity_i[iDim]*Velocity_i[iDim]; + sq_vel_j += 0.5*Velocity_j[iDim]*Velocity_j[iDim]; + ProjVelocity_i += Velocity_i[iDim]*Normal[iDim]; + ProjVelocity_j += Velocity_j[iDim]*Normal[iDim]; + Area += Normal[iDim]*Normal[iDim]; + } + Area = sqrt(Area); + + /*--- Compute mean values of the variables ---*/ + + MeanDensity = 0.5*(DensityInc_i + DensityInc_j); + MeanPressure = 0.5*(Pressure_i + Pressure_j); + MeanBetaInc2 = 0.5*(BetaInc2_i + BetaInc2_j); + MeanEnthalpy = 0.5*(Enthalpy_i + Enthalpy_j); + MeanCp = 0.5*(Cp_i + Cp_j); + MeanTemperature = 0.5*(Temperature_i + Temperature_j); + + /*--- We need the derivative of the equation of state to build the + preconditioning matrix. For now, the only option is the ideal gas + law, but in the future, dRhodT should be in the fluid model. ---*/ + + MeandRhodT = 0.0; + if (variable_density) { + MeandRhodT = -MeanDensity/MeanTemperature; + } + + /*--- Get projected flux tensor ---*/ + + GetInviscidIncProjFlux(&MeanDensity, MeanVelocity, &MeanPressure, &MeanBetaInc2, &MeanEnthalpy, Normal, ProjFlux); + + /*--- Compute inviscid residual ---*/ + + for (iVar = 0; iVar < nVar; iVar++) { + val_residual[iVar] = ProjFlux[iVar]; + } + + /*--- Jacobians of the inviscid flux ---*/ + + if (implicit) { + GetInviscidIncProjJac(&MeanDensity, MeanVelocity, &MeanBetaInc2, &MeanCp, &MeanTemperature, &MeandRhodT, Normal, 0.5, val_Jacobian_i); + for (iVar = 0; iVar < nVar; iVar++) { + for (jVar = 0; jVar < nVar; jVar++) { + val_Jacobian_j[iVar][jVar] = val_Jacobian_i[iVar][jVar]; + } + } + } + + /*--- Corrections due to grid motion ---*/ + if (dynamic_grid) { + + /*--- Recompute conservative variables ---*/ + + U_i[0] = DensityInc_i; U_j[0] = DensityInc_j; + for (iDim = 0; iDim < nDim; iDim++) { + U_i[iDim+1] = DensityInc_i*Velocity_i[iDim]; U_j[iDim+1] = DensityInc_j*Velocity_j[iDim]; + } + U_i[nDim+1] = DensityInc_i*Enthalpy_i; U_j[nDim+1] = DensityInc_j*Enthalpy_j; + + for (iDim = 0; iDim < nDim; iDim++) + ProjVelocity += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; + + /*--- Residual contributions ---*/ + for (iVar = 0; iVar < nVar; iVar++) { + val_residual[iVar] -= ProjVelocity * 0.5*(U_i[iVar]+U_j[iVar]); + + /*--- Jacobian contributions ---*/ + /*--- Implicit terms ---*/ + if (implicit) { + for (iDim = 0; iDim < nDim; iDim++){ + val_Jacobian_i[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_i; + val_Jacobian_j[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_j; + } + val_Jacobian_i[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_i*Cp_i; + val_Jacobian_j[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_j*Cp_j; + } + } + } + + /*--- Computes differences btw. conservative variables ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + Diff_V[iVar] = V_i[iVar]-V_j[iVar]; + + /*--- Build the preconditioning matrix using mean values ---*/ + + GetPreconditioner(&MeanDensity, MeanVelocity, &MeanBetaInc2, &MeanCp, &MeanTemperature, &MeandRhodT, Precon); + + /*--- Compute the local espectral radius of the preconditioned system + and the stretching factor. ---*/ + + SoundSpeed_i = sqrt(BetaInc2_i*Area*Area); + SoundSpeed_j = sqrt(BetaInc2_j*Area*Area); + + /*--- Projected velocity adjustment due to mesh motion ---*/ + + if (dynamic_grid) { + ProjGridVel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; + } + ProjVelocity_i -= ProjGridVel; + ProjVelocity_j -= ProjGridVel; + } + + Local_Lambda_i = fabs(ProjVelocity_i)+SoundSpeed_i; + Local_Lambda_j = fabs(ProjVelocity_j)+SoundSpeed_j; + + MeanLambda = 0.5*(Local_Lambda_i+Local_Lambda_j); + + Phi_i = pow(Lambda_i/(4.0*MeanLambda), Param_p); + Phi_j = pow(Lambda_j/(4.0*MeanLambda), Param_p); + + StretchingFactor = 4.0*Phi_i*Phi_j/(Phi_i+Phi_j); + + sc0 = 3.0*(su2double(Neighbor_i)+su2double(Neighbor_j))/(su2double(Neighbor_i)*su2double(Neighbor_j)); + Epsilon_0 = Param_Kappa_0*sc0*su2double(nDim)/3.0; + + /*--- Compute viscous part of the residual ---*/ + + for (iVar = 0; iVar < nVar; iVar++) { + for (jVar = 0; jVar < nVar; jVar++) { + val_residual[iVar] += Precon[iVar][jVar]*Epsilon_0*Diff_V[jVar]*StretchingFactor*MeanLambda; + if (implicit) { + val_Jacobian_i[iVar][jVar] += Precon[iVar][jVar]*Epsilon_0*StretchingFactor*MeanLambda; + val_Jacobian_j[iVar][jVar] -= Precon[iVar][jVar]*Epsilon_0*StretchingFactor*MeanLambda; + } + } + } + + /*--- Remove energy contributions if we aren't solving the energy equation. ---*/ + + if (!energy) { + val_residual[nDim+1] = 0.0; + if (implicit) { + for (iVar = 0; iVar < nVar; iVar++) { + val_Jacobian_i[iVar][nDim+1] = 0.0; + val_Jacobian_j[iVar][nDim+1] = 0.0; + + val_Jacobian_i[nDim+1][iVar] = 0.0; + val_Jacobian_j[nDim+1][iVar] = 0.0; + } + } + } +} + + +CCentJSTInc_Flow::CCentJSTInc_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + variable_density = (config->GetKind_DensityModel() == VARIABLE); + energy = config->GetEnergy_Equation(); + /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ + dynamic_grid = config->GetDynamic_Grid(); + + /*--- Artifical dissipation part ---*/ + + Param_p = 0.3; + Param_Kappa_2 = config->GetKappa_2nd_Flow(); + Param_Kappa_4 = config->GetKappa_4th_Flow(); + + /*--- Allocate some structures ---*/ + + Diff_V = new su2double [nVar]; + Diff_Lapl = new su2double [nVar]; + Velocity_i = new su2double [nDim]; + Velocity_j = new su2double [nDim]; + MeanVelocity = new su2double [nDim]; + ProjFlux = new su2double [nVar]; + Precon = new su2double*[nVar]; + + for (iVar = 0; iVar < nVar; iVar++) + Precon[iVar] = new su2double[nVar]; + +} + +CCentJSTInc_Flow::~CCentJSTInc_Flow(void) { + + delete [] Diff_V; + delete [] Diff_Lapl; + delete [] Velocity_i; + delete [] Velocity_j; + delete [] MeanVelocity; + delete [] ProjFlux; + + for (iVar = 0; iVar < nVar; iVar++) + delete [] Precon[iVar]; + delete [] Precon; + +} + +void CCentJSTInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { + + su2double U_i[5] = {0.0,0.0,0.0,0.0,0.0}, U_j[5] = {0.0,0.0,0.0,0.0,0.0}; + su2double ProjGridVel = 0.0; + + /*--- Primitive variables at point i and j ---*/ + + Pressure_i = V_i[0]; Pressure_j = V_j[0]; + Temperature_i = V_i[nDim+1]; Temperature_j = V_j[nDim+1]; + DensityInc_i = V_i[nDim+2]; DensityInc_j = V_j[nDim+2]; + BetaInc2_i = V_i[nDim+3]; BetaInc2_j = V_j[nDim+3]; + Cp_i = V_i[nDim+7]; Cp_j = V_j[nDim+7]; + Enthalpy_i = Cp_i*Temperature_i; Enthalpy_j = Cp_j*Temperature_j; + + Area = 0.0; + sq_vel_i = 0.0; sq_vel_j = 0.0; ProjVelocity_i = 0.0; ProjVelocity_j = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + Velocity_i[iDim] = V_i[iDim+1]; + Velocity_j[iDim] = V_j[iDim+1]; + MeanVelocity[iDim] = 0.5*(Velocity_i[iDim]+Velocity_j[iDim]); + sq_vel_i += 0.5*Velocity_i[iDim]*Velocity_i[iDim]; + sq_vel_j += 0.5*Velocity_j[iDim]*Velocity_j[iDim]; + ProjVelocity_i += Velocity_i[iDim]*Normal[iDim]; + ProjVelocity_j += Velocity_j[iDim]*Normal[iDim]; + Area += Normal[iDim]*Normal[iDim]; + } + Area = sqrt(Area); + + /*--- Compute mean values of the variables ---*/ + + MeanDensity = 0.5*(DensityInc_i + DensityInc_j); + MeanPressure = 0.5*(Pressure_i + Pressure_j); + MeanBetaInc2 = 0.5*(BetaInc2_i + BetaInc2_j); + MeanEnthalpy = 0.5*(Enthalpy_i + Enthalpy_j); + MeanCp = 0.5*(Cp_i + Cp_j); + MeanTemperature = 0.5*(Temperature_i + Temperature_j); + + /*--- We need the derivative of the equation of state to build the + preconditioning matrix. For now, the only option is the ideal gas + law, but in the future, dRhodT should be in the fluid model. ---*/ + + MeandRhodT = 0.0; + if (variable_density) { + MeandRhodT = -MeanDensity/MeanTemperature; + } + + /*--- Get projected flux tensor ---*/ + + GetInviscidIncProjFlux(&MeanDensity, MeanVelocity, &MeanPressure, &MeanBetaInc2, &MeanEnthalpy, Normal, ProjFlux); + + for (iVar = 0; iVar < nVar; iVar++) { + val_residual[iVar] = ProjFlux[iVar]; + } + + /*--- Jacobians of the inviscid flux ---*/ + + if (implicit) { + GetInviscidIncProjJac(&MeanDensity, MeanVelocity, &MeanBetaInc2, &MeanCp, &MeanTemperature, &MeandRhodT, Normal, 0.5, val_Jacobian_i); + for (iVar = 0; iVar < nVar; iVar++) { + for (jVar = 0; jVar < nVar; jVar++) { + val_Jacobian_j[iVar][jVar] = val_Jacobian_i[iVar][jVar]; + } + } + } + + /*--- Corrections due to grid motion ---*/ + if (dynamic_grid) { + + /*--- Recompute conservative variables ---*/ + + U_i[0] = DensityInc_i; U_j[0] = DensityInc_j; + for (iDim = 0; iDim < nDim; iDim++) { + U_i[iDim+1] = DensityInc_i*Velocity_i[iDim]; U_j[iDim+1] = DensityInc_j*Velocity_j[iDim]; + } + U_i[nDim+1] = DensityInc_i*Enthalpy_i; U_j[nDim+1] = DensityInc_j*Enthalpy_j; + + su2double ProjVelocity = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + ProjVelocity += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; + + /*--- Residual contributions ---*/ + for (iVar = 0; iVar < nVar; iVar++) { + val_residual[iVar] -= ProjVelocity * 0.5*(U_i[iVar]+U_j[iVar]); + + /*--- Jacobian contributions ---*/ + /*--- Implicit terms ---*/ + if (implicit) { + for (iDim = 0; iDim < nDim; iDim++){ + val_Jacobian_i[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_i; + val_Jacobian_j[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_j; + } + val_Jacobian_i[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_i*Cp_i; + val_Jacobian_j[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_j*Cp_j; + } + } + } + + /*--- Computes differences between Laplacians and conservative variables ---*/ + + for (iVar = 0; iVar < nVar; iVar++) { + Diff_Lapl[iVar] = Und_Lapl_i[iVar]-Und_Lapl_j[iVar]; + Diff_V[iVar] = V_i[iVar]-V_j[iVar]; + } + + /*--- Build the preconditioning matrix using mean values ---*/ + + GetPreconditioner(&MeanDensity, MeanVelocity, &MeanBetaInc2, &MeanCp, &MeanTemperature, &MeandRhodT, Precon); + + /*--- Compute the local spectral radius of the preconditioned system + and the stretching factor. ---*/ + + /*--- Projected velocity adjustment due to mesh motion ---*/ + + if (dynamic_grid) { + ProjGridVel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; + } + ProjVelocity_i -= ProjGridVel; + ProjVelocity_j -= ProjGridVel; + } + + SoundSpeed_i = sqrt(BetaInc2_i*Area*Area); + SoundSpeed_j = sqrt(BetaInc2_j*Area*Area); + + Local_Lambda_i = fabs(ProjVelocity_i)+SoundSpeed_i; + Local_Lambda_j = fabs(ProjVelocity_j)+SoundSpeed_j; + + MeanLambda = 0.5*(Local_Lambda_i+Local_Lambda_j); + + Phi_i = pow(Lambda_i/(4.0*MeanLambda), Param_p); + Phi_j = pow(Lambda_j/(4.0*MeanLambda), Param_p); + + StretchingFactor = 4.0*Phi_i*Phi_j/(Phi_i+Phi_j); + + sc2 = 3.0*(su2double(Neighbor_i)+su2double(Neighbor_j))/(su2double(Neighbor_i)*su2double(Neighbor_j)); + sc4 = sc2*sc2/4.0; + + Epsilon_2 = Param_Kappa_2*0.5*(Sensor_i+Sensor_j)*sc2; + Epsilon_4 = max(0.0, Param_Kappa_4-Epsilon_2)*sc4; + + /*--- Compute viscous part of the residual ---*/ + + for (iVar = 0; iVar < nVar; iVar++) { + for (jVar = 0; jVar < nVar; jVar++) { + val_residual[iVar] += Precon[iVar][jVar]*(Epsilon_2*Diff_V[jVar] - Epsilon_4*Diff_Lapl[jVar])*StretchingFactor*MeanLambda; + if (implicit) { + val_Jacobian_i[iVar][jVar] += Precon[iVar][jVar]*(Epsilon_2 + Epsilon_4*su2double(Neighbor_i+1))*StretchingFactor*MeanLambda; + val_Jacobian_j[iVar][jVar] -= Precon[iVar][jVar]*(Epsilon_2 + Epsilon_4*su2double(Neighbor_j+1))*StretchingFactor*MeanLambda; + } + } + } + + /*--- Remove energy contributions if not solving the energy equation. ---*/ + + if (!energy) { + val_residual[nDim+1] = 0.0; + if (implicit) { + for (iVar = 0; iVar < nVar; iVar++) { + val_Jacobian_i[iVar][nDim+1] = 0.0; + val_Jacobian_j[iVar][nDim+1] = 0.0; + + val_Jacobian_i[nDim+1][iVar] = 0.0; + val_Jacobian_j[nDim+1][iVar] = 0.0; + } + } + } +} diff --git a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwCUSP_Flow.cpp b/SU2_CFD/src/numerics/flow/convection/cusp.cpp similarity index 97% rename from SU2_CFD/src/numerics/flow/convection_upwind/CUpwCUSP_Flow.cpp rename to SU2_CFD/src/numerics/flow/convection/cusp.cpp index 53566634229c..28372cf570db 100644 --- a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwCUSP_Flow.cpp +++ b/SU2_CFD/src/numerics/flow/convection/cusp.cpp @@ -1,6 +1,6 @@ /*! - * \file CUpwCUSP_Flow.cpp - * \brief Implementation of numerics class CUpwCUSP_Flow. + * \file cusp.cpp + * \brief Implementation of the CUSP scheme. * \author F. Palacios, T. Economon * \version 7.0.0 "Blackbird" * @@ -25,7 +25,7 @@ * License along with SU2. If not, see . */ -#include "../../../../include/numerics/flow/convection_upwind/CUpwCUSP_Flow.hpp" +#include "../../../../include/numerics/flow/convection/cusp.hpp" CUpwCUSP_Flow::CUpwCUSP_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { diff --git a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwFDSInc_Flow.cpp b/SU2_CFD/src/numerics/flow/convection/fds.cpp similarity index 98% rename from SU2_CFD/src/numerics/flow/convection_upwind/CUpwFDSInc_Flow.cpp rename to SU2_CFD/src/numerics/flow/convection/fds.cpp index 3ca76f62e904..02cd8c7b834f 100644 --- a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwFDSInc_Flow.cpp +++ b/SU2_CFD/src/numerics/flow/convection/fds.cpp @@ -1,6 +1,6 @@ /*! - * \file CUpwFDSInc_Flow.cpp - * \brief Implementation of numerics class CUpwFDSInc_Flow. + * \file fds.cpp + * \brief Implementation of Flux-Difference-Splitting schemes. * \author F. Palacios, T. Economon * \version 7.0.0 "Blackbird" * @@ -25,7 +25,7 @@ * License along with SU2. If not, see . */ -#include "../../../../include/numerics/flow/convection_upwind/CUpwFDSInc_Flow.hpp" +#include "../../../../include/numerics/flow/convection/fds.hpp" CUpwFDSInc_Flow::CUpwFDSInc_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { diff --git a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwMSW_Flow.cpp b/SU2_CFD/src/numerics/flow/convection/fvs.cpp similarity index 97% rename from SU2_CFD/src/numerics/flow/convection_upwind/CUpwMSW_Flow.cpp rename to SU2_CFD/src/numerics/flow/convection/fvs.cpp index 75ee9b0ae22b..2639c482c66b 100644 --- a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwMSW_Flow.cpp +++ b/SU2_CFD/src/numerics/flow/convection/fvs.cpp @@ -1,6 +1,6 @@ /*! - * \file CUpwMSW_Flow.cpp - * \brief Implementation of numerics class CUpwMSW_Flow. + * \file fvs.cpp + * \brief Implementations of Flux-Vector-Splitting schemes. * \author F. Palacios, T. Economon * \version 7.0.0 "Blackbird" * @@ -25,7 +25,7 @@ * License along with SU2. If not, see . */ -#include "../../../../include/numerics/flow/convection_upwind/CUpwMSW_Flow.hpp" +#include "../../../../include/numerics/flow/convection/fvs.hpp" CUpwMSW_Flow::CUpwMSW_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { diff --git a/SU2_CFD/src/numerics/flow/convection/hllc.cpp b/SU2_CFD/src/numerics/flow/convection/hllc.cpp new file mode 100644 index 000000000000..ddf682d72471 --- /dev/null +++ b/SU2_CFD/src/numerics/flow/convection/hllc.cpp @@ -0,0 +1,1102 @@ +/*! + * \file hllc.cpp + * \brief Implementations of HLLC schemes. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../../include/numerics/flow/convection/hllc.hpp" + +CUpwHLLC_Flow::CUpwHLLC_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + kappa = config->GetRoe_Kappa(); + /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ + dynamic_grid = config->GetDynamic_Grid(); + + Gamma = config->GetGamma(); + + Gamma_Minus_One = Gamma - 1.0; + + IntermediateState = new su2double [nVar]; + dSm_dU = new su2double [nVar]; + dPI_dU = new su2double [nVar]; + drhoStar_dU = new su2double [nVar]; + dpStar_dU = new su2double [nVar]; + dEStar_dU = new su2double [nVar]; + + Velocity_i = new su2double [nDim]; + Velocity_j = new su2double [nDim]; + RoeVelocity = new su2double [nDim]; + +} + +CUpwHLLC_Flow::~CUpwHLLC_Flow(void) { + + delete [] IntermediateState; + delete [] dSm_dU; + delete [] dPI_dU; + delete [] drhoStar_dU; + delete [] dpStar_dU; + delete [] dEStar_dU; + + delete [] Velocity_i; + delete [] Velocity_j; + delete [] RoeVelocity; + +} + +void CUpwHLLC_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { + + /*--- Face area (norm or the normal vector) ---*/ + + Area = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + Area += Normal[iDim] * Normal[iDim]; + + Area = sqrt(Area); + + /*-- Unit Normal ---*/ + + for (iDim = 0; iDim < nDim; iDim++) + UnitNormal[iDim] = Normal[iDim] / Area; + + /*-- Fluid velocity at node i,j ---*/ + + for (iDim = 0; iDim < nDim; iDim++) { + Velocity_i[iDim] = V_i[iDim+1]; + Velocity_j[iDim] = V_j[iDim+1]; + } + + /*--- Primitive variables at point i ---*/ + + Pressure_i = V_i[nDim+1]; + Density_i = V_i[nDim+2]; + Enthalpy_i = V_i[nDim+3]; + + /*--- Primitive variables at point j ---*/ + + Pressure_j = V_j[nDim+1]; + Density_j = V_j[nDim+2]; + Enthalpy_j = V_j[nDim+3]; + + + sq_vel_i = 0.0; + sq_vel_j = 0.0; + + for (iDim = 0; iDim < nDim; iDim++) { + sq_vel_i += Velocity_i[iDim] * Velocity_i[iDim]; + sq_vel_j += Velocity_j[iDim] * Velocity_j[iDim]; + } + + Energy_i = Enthalpy_i - Pressure_i / Density_i; + Energy_j = Enthalpy_j - Pressure_j / Density_j; + + SoundSpeed_i = sqrt( (Enthalpy_i - 0.5 * sq_vel_i) * Gamma_Minus_One ); + SoundSpeed_j = sqrt( (Enthalpy_j - 0.5 * sq_vel_j) * Gamma_Minus_One ); + + /*--- Projected velocities ---*/ + + ProjVelocity_i = 0; + ProjVelocity_j = 0; + + for (iDim = 0; iDim < nDim; iDim++) { + ProjVelocity_i += Velocity_i[iDim] * UnitNormal[iDim]; + ProjVelocity_j += Velocity_j[iDim] * UnitNormal[iDim]; + } + + /*--- Projected Grid Velocity ---*/ + + ProjInterfaceVel = 0; + + if (dynamic_grid) { + + for (iDim = 0; iDim < nDim; iDim++) + ProjInterfaceVel += 0.5 * ( GridVel_i[iDim] + GridVel_j[iDim] )*UnitNormal[iDim]; + + SoundSpeed_i -= ProjInterfaceVel; + SoundSpeed_j += ProjInterfaceVel; + + ProjVelocity_i -= ProjInterfaceVel; + ProjVelocity_j -= ProjInterfaceVel; + } + + /*--- Roe's averaging ---*/ + + Rrho = ( sqrt(Density_i) + sqrt(Density_j) ); + + sq_velRoe = 0.0; + RoeProjVelocity = - ProjInterfaceVel; + + for (iDim = 0; iDim < nDim; iDim++) { + RoeVelocity[iDim] = ( Velocity_i[iDim] * sqrt(Density_i) + Velocity_j[iDim] * sqrt(Density_j) ) / Rrho; + sq_velRoe += RoeVelocity[iDim] * RoeVelocity[iDim]; + RoeProjVelocity += RoeVelocity[iDim] * UnitNormal[iDim]; + } + + /*--- Mean Roe variables iPoint and jPoint ---*/ + + RoeDensity = sqrt( Density_i * Density_j ); + RoeEnthalpy = ( sqrt(Density_j) * Enthalpy_j + sqrt(Density_i) * Enthalpy_i) / Rrho; + + /*--- Roe-averaged speed of sound ---*/ + + //RoeSoundSpeed2 = Gamma_Minus_One * ( RoeEnthalpy - 0.5 * sq_velRoe ); + RoeSoundSpeed = sqrt( Gamma_Minus_One * ( RoeEnthalpy - 0.5 * sq_velRoe ) ) - ProjInterfaceVel; + + + /*--- Speed of sound at L and R ---*/ + + sL = min( RoeProjVelocity - RoeSoundSpeed, ProjVelocity_i - SoundSpeed_i); + sR = max( RoeProjVelocity + RoeSoundSpeed, ProjVelocity_j + SoundSpeed_j); + + /*--- speed of contact surface ---*/ + + RHO = Density_j * (sR - ProjVelocity_j) - Density_i * (sL - ProjVelocity_i); + sM = ( Pressure_i - Pressure_j - Density_i * ProjVelocity_i * ( sL - ProjVelocity_i ) + Density_j * ProjVelocity_j * ( sR - ProjVelocity_j ) ) / RHO; + + /*--- Pressure at right and left (Pressure_j=Pressure_i) side of contact surface ---*/ + + pStar = Density_j * ( ProjVelocity_j - sR ) * ( ProjVelocity_j - sM ) + Pressure_j; + + + if (sM > 0.0) { + + if (sL > 0.0) { + + /*--- Compute Left Flux ---*/ + + val_residual[0] = Density_i * ProjVelocity_i; + for (iDim = 0; iDim < nDim; iDim++) + val_residual[iDim+1] = Density_i * Velocity_i[iDim] * ProjVelocity_i + Pressure_i * UnitNormal[iDim]; + val_residual[nVar-1] = Enthalpy_i * Density_i * ProjVelocity_i; + + } + else { + + /*--- Compute Flux Left Star from Left Star State ---*/ + + rhoSL = ( sL - ProjVelocity_i ) / ( sL - sM ); + + IntermediateState[0] = rhoSL * Density_i; + for (iDim = 0; iDim < nDim; iDim++) + IntermediateState[iDim+1] = rhoSL * ( Density_i * Velocity_i[iDim] + ( pStar - Pressure_i ) / ( sL - ProjVelocity_i ) * UnitNormal[iDim] ) ; + IntermediateState[nVar-1] = rhoSL * ( Density_i * Energy_i - ( Pressure_i * ProjVelocity_i - pStar * sM) / ( sL - ProjVelocity_i ) ); + + + val_residual[0] = sM * IntermediateState[0]; + for (iDim = 0; iDim < nDim; iDim++) + val_residual[iDim+1] = sM * IntermediateState[iDim+1] + pStar * UnitNormal[iDim]; + val_residual[nVar-1] = sM * ( IntermediateState[nVar-1] + pStar ) + pStar * ProjInterfaceVel; + } + } + else { + + if (sR < 0.0) { + + /*--- Compute Right Flux ---*/ + + val_residual[0] = Density_j * ProjVelocity_j; + for (iDim = 0; iDim < nDim; iDim++) + val_residual[iDim+1] = Density_j * Velocity_j[iDim] * ProjVelocity_j + Pressure_j * UnitNormal[iDim]; + val_residual[nVar-1] = Enthalpy_j * Density_j * ProjVelocity_j; + } + else { + + /*--- Compute Flux Right Star from Right Star State ---*/ + + rhoSR = ( sR - ProjVelocity_j ) / ( sR - sM ); + + IntermediateState[0] = rhoSR * Density_j; + for (iDim = 0; iDim < nDim; iDim++) + IntermediateState[iDim+1] = rhoSR * ( Density_j * Velocity_j[iDim] + ( pStar - Pressure_j ) / ( sR - ProjVelocity_j ) * UnitNormal[iDim] ) ; + IntermediateState[nVar-1] = rhoSR * ( Density_j * Energy_j - ( Pressure_j * ProjVelocity_j - pStar * sM ) / ( sR - ProjVelocity_j ) ); + + + val_residual[0] = sM * IntermediateState[0]; + for (iDim = 0; iDim < nDim; iDim++) + val_residual[iDim+1] = sM * IntermediateState[iDim+1] + pStar * UnitNormal[iDim]; + val_residual[nVar-1] = sM * (IntermediateState[nVar-1] + pStar ) + pStar * ProjInterfaceVel; + } + } + + + for (iVar = 0; iVar < nVar; iVar++) + val_residual[iVar] *= Area; + + + /*--- Return early if the Jacobians do not need to be computed. ---*/ + + if (!implicit) return; + + if (sM > 0.0) { + + if (sL > 0.0) { + + /*--- Compute Jacobian based on Left State ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + for (jVar = 0; jVar < nVar; jVar++) + val_Jacobian_j[iVar][jVar] = 0; + + GetInviscidProjJac(Velocity_i, &Energy_i, UnitNormal, 1.0, val_Jacobian_i); + + } + else { + /*--- Compute Jacobian based on Left Star State ---*/ + + EStar = IntermediateState[nVar-1]; + Omega = 1/(sL-sM); + OmegaSM = Omega * sM; + + + /*--------- Left Jacobian ---------*/ + + + /*--- Computing pressure derivatives d/dU_L (PI) ---*/ + + dPI_dU[0] = 0.5 * Gamma_Minus_One * sq_vel_i; + for (iDim = 0; iDim < nDim; iDim++) + dPI_dU[iDim+1] = - Gamma_Minus_One * Velocity_i[iDim]; + dPI_dU[nVar-1] = Gamma_Minus_One; + + + /*--- Computing d/dU_L (Sm) ---*/ + + dSm_dU[0] = ( - ProjVelocity_i * ProjVelocity_i + sM * sL + dPI_dU[0] ) / RHO; + for (iDim = 0; iDim < nDim; iDim++) + dSm_dU[iDim+1] = ( UnitNormal[iDim] * ( 2 * ProjVelocity_i - sL - sM ) + dPI_dU[iDim+1] ) / RHO; + dSm_dU[nVar-1] = dPI_dU[nVar-1] / RHO; + + + /*--- Computing d/dU_L (rhoStar) ---*/ + + drhoStar_dU[0] = Omega * ( sL + IntermediateState[0] * dSm_dU[0] ); + for (iDim = 0; iDim < nDim; iDim++) + drhoStar_dU[iDim+1] = Omega * ( - UnitNormal[iDim] + IntermediateState[0] * dSm_dU[iDim+1] ); + drhoStar_dU[nVar-1] = Omega * IntermediateState[0] * dSm_dU[nVar-1]; + + + /*--- Computing d/dU_L (pStar) ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + dpStar_dU[iVar] = Density_i * (sR - ProjVelocity_j) * dSm_dU[iVar]; + + + /*--- Computing d/dU_L (EStar) ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); + + dEStar_dU[0] += Omega * ProjVelocity_i * ( Enthalpy_i - dPI_dU[0] ); + for (iDim = 0; iDim < nDim; iDim++) + dEStar_dU[iDim+1] += Omega * ( - UnitNormal[iDim] * Enthalpy_i - ProjVelocity_i * dPI_dU[iDim+1] ); + dEStar_dU[nVar-1] += Omega * ( sL - ProjVelocity_i - ProjVelocity_i * dPI_dU[nVar-1] ); + + + + /*--- Jacobian First Row ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_i[0][iVar] = sM * drhoStar_dU[iVar] + IntermediateState[0] * dSm_dU[iVar]; + + /*--- Jacobian Middle Rows ---*/ + + for (jDim = 0; jDim < nDim; jDim++) { + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_i[jDim+1][iVar] = ( OmegaSM + 1 ) * ( UnitNormal[jDim] * dpStar_dU[iVar] + IntermediateState[jDim+1] * dSm_dU[iVar] ); + + val_Jacobian_i[jDim+1][0] += OmegaSM * Velocity_i[jDim] * ProjVelocity_i; + + val_Jacobian_i[jDim+1][jDim+1] += OmegaSM * (sL - ProjVelocity_i); + + for (iDim = 0; iDim < nDim; iDim++) + val_Jacobian_i[jDim+1][iDim+1] -= OmegaSM * Velocity_i[jDim] * UnitNormal[iDim]; + + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_i[jDim+1][iVar] -= OmegaSM * dPI_dU[iVar] * UnitNormal[jDim]; + } + + /*--- Jacobian Last Row ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_i[nVar-1][iVar] = sM * ( dEStar_dU[iVar] + dpStar_dU[iVar] ) + ( EStar + pStar ) * dSm_dU[iVar]; + + + /*--------- Right Jacobian ---------*/ + + + /*--- Computing d/dU_R (Sm) ---*/ + + dSm_dU[0] = ( ProjVelocity_j * ProjVelocity_j - sM * sR - 0.5 * Gamma_Minus_One * sq_vel_j ) / RHO; + for (iDim = 0; iDim < nDim; iDim++) + dSm_dU[iDim+1] = - ( UnitNormal[iDim] * ( 2 * ProjVelocity_j - sR - sM) - Gamma_Minus_One * Velocity_j[iDim] ) / RHO; + dSm_dU[nVar-1] = - Gamma_Minus_One / RHO; + + + /*--- Computing d/dU_R (pStar) ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + dpStar_dU[iVar] = Density_j * (sL - ProjVelocity_i) * dSm_dU[iVar]; + + + /*--- Computing d/dU_R (EStar) ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); + + + + /*--- Jacobian First Row ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_j[0][iVar] = IntermediateState[0] * ( OmegaSM + 1 ) * dSm_dU[iVar]; + + /*--- Jacobian Middle Rows ---*/ + + for (iDim = 0; iDim < nDim; iDim++) { + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_j[iDim+1][iVar] = ( OmegaSM + 1 ) * ( IntermediateState[iDim+1] * dSm_dU[iVar] + UnitNormal[iDim] * dpStar_dU[iVar] ); + } + + /*--- Jacobian Last Row ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_j[nVar-1][iVar] = sM * (dEStar_dU[iVar] + dpStar_dU[iVar]) + (EStar + pStar) * dSm_dU[iVar]; + } + } + else { + if (sR < 0.0) { + + /*--- Compute Jacobian based on Right State ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + for (jVar = 0; jVar < nVar; jVar++) + val_Jacobian_i[iVar][jVar] = 0; + + GetInviscidProjJac(Velocity_j, &Energy_j, UnitNormal, 1.0, val_Jacobian_j); + + } + else { + /*--- Compute Jacobian based on Right Star State ---*/ + + EStar = IntermediateState[nVar-1]; + Omega = 1/(sR-sM); + OmegaSM = Omega * sM; + + + /*--------- Left Jacobian ---------*/ + + + /*--- Computing d/dU_L (Sm) ---*/ + + dSm_dU[0] = ( - ProjVelocity_i * ProjVelocity_i + sM * sL + 0.5 * Gamma_Minus_One * sq_vel_i ) / RHO; + for (iDim = 0; iDim < nDim; iDim++) + dSm_dU[iDim+1] = ( UnitNormal[iDim] * ( 2 * ProjVelocity_i - sL - sM ) - Gamma_Minus_One * Velocity_i[iDim] ) / RHO; + dSm_dU[nVar-1] = Gamma_Minus_One / RHO; + + + /*--- Computing d/dU_L (pStar) ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + dpStar_dU[iVar] = Density_i * (sR - ProjVelocity_j) * dSm_dU[iVar]; + + + /*--- Computing d/dU_L (EStar) ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); + + + + /*--- Jacobian First Row ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_i[0][iVar] = IntermediateState[0] * ( OmegaSM + 1 ) * dSm_dU[iVar]; + + /*--- Jacobian Middle Rows ---*/ + + for (iDim = 0; iDim < nDim; iDim++) { + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_i[iDim+1][iVar] = (OmegaSM + 1) * ( IntermediateState[iDim+1] * dSm_dU[iVar] + UnitNormal[iDim] * dpStar_dU[iVar] ); + } + + /*--- Jacobian Last Row ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_i[nVar-1][iVar] = sM * (dEStar_dU[iVar] + dpStar_dU[iVar]) + (EStar + pStar) * dSm_dU[iVar]; + + + + /*--------- Right Jacobian ---------*/ + + + /*--- Computing pressure derivatives d/dU_R (PI) ---*/ + + dPI_dU[0] = 0.5 * Gamma_Minus_One * sq_vel_j; + for (iDim = 0; iDim < nDim; iDim++) + dPI_dU[iDim+1] = - Gamma_Minus_One * Velocity_j[iDim]; + dPI_dU[nVar-1] = Gamma_Minus_One; + + + + /*--- Computing d/dU_R (Sm) ---*/ + + dSm_dU[0] = - ( - ProjVelocity_j * ProjVelocity_j + sM * sR + dPI_dU[0] ) / RHO; + for (iDim = 0; iDim < nDim; iDim++) + dSm_dU[iDim+1] = - ( UnitNormal[iDim] * ( 2 * ProjVelocity_j - sR - sM) + dPI_dU[iDim+1] ) / RHO; + dSm_dU[nVar-1] = - dPI_dU[nVar-1] / RHO; + + + /*--- Computing d/dU_R (pStar) ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + dpStar_dU[iVar] = Density_j * (sL - ProjVelocity_i) * dSm_dU[iVar]; + + + /*--- Computing d/dU_R (rhoStar) ---*/ + + drhoStar_dU[0] = Omega * ( sR + IntermediateState[0] * dSm_dU[0] ); + for (iDim = 0; iDim < nDim; iDim++) + drhoStar_dU[iDim+1] = Omega * ( - UnitNormal[iDim] + IntermediateState[0] * dSm_dU[iDim+1] ); + drhoStar_dU[nVar-1] = Omega * IntermediateState[0] * dSm_dU[nVar-1]; + + + /*--- Computing d/dU_R (EStar) ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); + + dEStar_dU[0] += Omega * ProjVelocity_j * ( Enthalpy_j - dPI_dU[0] ); + for (iDim = 0; iDim < nDim; iDim++) + dEStar_dU[iDim+1] += Omega * ( - UnitNormal[iDim] * Enthalpy_j - ProjVelocity_j * dPI_dU[iDim+1] ); + dEStar_dU[nVar-1] += Omega * ( sR - ProjVelocity_j - ProjVelocity_j * dPI_dU[nVar-1] ); + + + + /*--- Jacobian First Row ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_j[0][iVar] = sM * drhoStar_dU[iVar] + IntermediateState[0] * dSm_dU[iVar]; + + /*--- Jacobian Middle Rows ---*/ + + for (jDim = 0; jDim < nDim; jDim++) { + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_j[jDim+1][iVar] = ( OmegaSM + 1 ) * ( UnitNormal[jDim] * dpStar_dU[iVar] + IntermediateState[jDim+1] * dSm_dU[iVar] ); + + val_Jacobian_j[jDim+1][0] += OmegaSM * Velocity_j[jDim] * ProjVelocity_j; + + val_Jacobian_j[jDim+1][jDim+1] += OmegaSM * (sR - ProjVelocity_j); + + for (iDim = 0; iDim < nDim; iDim++) + val_Jacobian_j[jDim+1][iDim+1] -= OmegaSM * Velocity_j[jDim] * UnitNormal[iDim]; + + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_j[jDim+1][iVar] -= OmegaSM * dPI_dU[iVar] * UnitNormal[jDim]; + } + + /*--- Jacobian Last Row ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_j[nVar-1][iVar] = sM * ( dEStar_dU[iVar] + dpStar_dU[iVar] ) + ( EStar + pStar ) * dSm_dU[iVar]; + + } + } + + + /*--- Jacobians of the inviscid flux, scale = k because val_residual ~ 0.5*(fc_i+fc_j)*Normal ---*/ + + Area *= kappa; + + for (iVar = 0; iVar < nVar; iVar++) { + for (jVar = 0; jVar < nVar; jVar++) { + val_Jacobian_i[iVar][jVar] *= Area; + val_Jacobian_j[iVar][jVar] *= Area; + } + } + +} + +CUpwGeneralHLLC_Flow::CUpwGeneralHLLC_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + kappa = config->GetRoe_Kappa(); + /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ + dynamic_grid = config->GetDynamic_Grid(); + + Gamma = config->GetGamma(); + + IntermediateState = new su2double [nVar]; + dSm_dU = new su2double [nVar]; + dPI_dU = new su2double [nVar]; + drhoStar_dU = new su2double [nVar]; + dpStar_dU = new su2double [nVar]; + dEStar_dU = new su2double [nVar]; + + Velocity_i = new su2double [nDim]; + Velocity_j = new su2double [nDim]; + RoeVelocity = new su2double [nDim]; + +} + +CUpwGeneralHLLC_Flow::~CUpwGeneralHLLC_Flow(void) { + + delete [] IntermediateState; + delete [] dSm_dU; + delete [] dPI_dU; + delete [] drhoStar_dU; + delete [] dpStar_dU; + delete [] dEStar_dU; + + delete [] Velocity_i; + delete [] Velocity_j; + delete [] RoeVelocity; + +} + +void CUpwGeneralHLLC_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { + + /*--- Face area (norm or the normal vector) ---*/ + + Area = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + Area += Normal[iDim] * Normal[iDim]; + + Area = sqrt(Area); + + /*-- Unit Normal ---*/ + + for (iDim = 0; iDim < nDim; iDim++) + UnitNormal[iDim] = Normal[iDim] / Area; + + /*-- Fluid velocity at node i,j ---*/ + + for (iDim = 0; iDim < nDim; iDim++) { + Velocity_i[iDim] = V_i[iDim+1]; + Velocity_j[iDim] = V_j[iDim+1]; + } + + /*--- Primitive variables at point i ---*/ + + Pressure_i = V_i[nDim+1]; + Density_i = V_i[nDim+2]; + Enthalpy_i = V_i[nDim+3]; + + /*--- Primitive variables at point j ---*/ + + Pressure_j = V_j[nDim+1]; + Density_j = V_j[nDim+2]; + Enthalpy_j = V_j[nDim+3]; + + + sq_vel_i = 0.0; + sq_vel_j = 0.0; + + for (iDim = 0; iDim < nDim; iDim++) { + sq_vel_i += Velocity_i[iDim] * Velocity_i[iDim]; + sq_vel_j += Velocity_j[iDim] * Velocity_j[iDim]; + } + + Energy_i = Enthalpy_i - Pressure_i / Density_i; + StaticEnthalpy_i = Enthalpy_i - 0.5 * sq_vel_i; + StaticEnergy_i = Energy_i - 0.5 * sq_vel_i; + + Kappa_i = S_i[1] / Density_i; + Chi_i = S_i[0] - Kappa_i * StaticEnergy_i; + SoundSpeed_i = sqrt(Chi_i + StaticEnthalpy_i * Kappa_i); + + + Energy_j = Enthalpy_j - Pressure_j / Density_j; + StaticEnthalpy_j = Enthalpy_j - 0.5 * sq_vel_j; + StaticEnergy_j = Energy_j - 0.5 * sq_vel_j; + + Kappa_j = S_j[1] / Density_j; + Chi_j = S_j[0] - Kappa_j * StaticEnergy_j; + SoundSpeed_j = sqrt(Chi_j + StaticEnthalpy_j * Kappa_j); + + /*--- Projected velocities ---*/ + + ProjVelocity_i = 0.0; + ProjVelocity_j = 0.0; + + for (iDim = 0; iDim < nDim; iDim++) { + ProjVelocity_i += Velocity_i[iDim] * UnitNormal[iDim]; + ProjVelocity_j += Velocity_j[iDim] * UnitNormal[iDim]; + } + + + /*--- Projected Grid Velocity ---*/ + + ProjInterfaceVel = 0; + + if (dynamic_grid) { + + for (iDim = 0; iDim < nDim; iDim++) + ProjInterfaceVel += 0.5 * ( GridVel_i[iDim] + GridVel_j[iDim] )*UnitNormal[iDim]; + + SoundSpeed_i -= ProjInterfaceVel; + SoundSpeed_j += ProjInterfaceVel; + + ProjVelocity_i -= ProjInterfaceVel; + ProjVelocity_j -= ProjInterfaceVel; + } + + /*--- Roe's averaging ---*/ + + Rrho = ( sqrt(Density_i) + sqrt(Density_j) ); + + sq_velRoe = 0.0; + RoeProjVelocity = - ProjInterfaceVel; + + for (iDim = 0; iDim < nDim; iDim++) { + RoeVelocity[iDim] = ( Velocity_i[iDim] * sqrt(Density_i) + Velocity_j[iDim] * sqrt(Density_j) ) / Rrho; + sq_velRoe += RoeVelocity[iDim] * RoeVelocity[iDim]; + RoeProjVelocity += RoeVelocity[iDim] * UnitNormal[iDim]; + } + + /*--- Mean Roe variables iPoint and jPoint ---*/ + + RoeKappa = 0.5 * ( Kappa_i + Kappa_j ); + RoeChi = 0.5 * ( Chi_i + Chi_j ); + RoeDensity = sqrt( Density_i * Density_j ); + RoeEnthalpy = ( sqrt(Density_j) * Enthalpy_j + sqrt(Density_i) * Enthalpy_i) / Rrho; + + VinokurMontagne(); + + /*--- Roe-averaged speed of sound ---*/ + + //RoeSoundSpeed2 = RoeChi + RoeKappa * ( RoeEnthalpy - 0.5 * sq_velRoe ); + RoeSoundSpeed = sqrt( RoeChi + RoeKappa * ( RoeEnthalpy - 0.5 * sq_velRoe ) ) - ProjInterfaceVel; + + /*--- Speed of sound at L and R ---*/ + + sL = min( RoeProjVelocity - RoeSoundSpeed, ProjVelocity_i - SoundSpeed_i ); + sR = max( RoeProjVelocity + RoeSoundSpeed, ProjVelocity_j + SoundSpeed_j ); + + /*--- speed of contact surface ---*/ + + RHO = Density_j * (sR - ProjVelocity_j) - Density_i * (sL - ProjVelocity_i); + sM = ( Pressure_i - Pressure_j - Density_i * ProjVelocity_i * ( sL - ProjVelocity_i ) + Density_j * ProjVelocity_j * ( sR - ProjVelocity_j ) ) / RHO; + + /*--- Pressure at right and left (Pressure_j=Pressure_i) side of contact surface ---*/ + + pStar = Density_j * ( ProjVelocity_j - sR ) * ( ProjVelocity_j - sM ) + Pressure_j; + + + if (sM > 0.0) { + + if (sL > 0.0) { + + /*--- Compute Left Flux ---*/ + + val_residual[0] = Density_i * ProjVelocity_i; + for (iDim = 0; iDim < nDim; iDim++) + val_residual[iDim+1] = Density_i * Velocity_i[iDim] * ProjVelocity_i + Pressure_i * UnitNormal[iDim]; + val_residual[nVar-1] = Enthalpy_i * Density_i * ProjVelocity_i; + } + else { + + /*--- Compute Flux Left Star from Left Star State ---*/ + + rhoSL = ( sL - ProjVelocity_i ) / ( sL - sM ); + + IntermediateState[0] = rhoSL * Density_i; + for (iDim = 0; iDim < nDim; iDim++) + IntermediateState[iDim+1] = rhoSL * ( Density_i * Velocity_i[iDim] + ( pStar - Pressure_i ) / ( sL - ProjVelocity_i ) * UnitNormal[iDim] ) ; + IntermediateState[nVar-1] = rhoSL * ( Density_i * Energy_i - ( Pressure_i * ProjVelocity_i - pStar * sM) / ( sL - ProjVelocity_i ) ); + + + val_residual[0] = sM * IntermediateState[0]; + for (iDim = 0; iDim < nDim; iDim++) + val_residual[iDim+1] = sM * IntermediateState[iDim+1] + pStar * UnitNormal[iDim]; + val_residual[nVar-1] = sM * ( IntermediateState[nVar-1] + pStar ) + pStar * ProjInterfaceVel; + } + } + else { + + if (sR < 0.0) { + + /*--- Compute Right Flux ---*/ + + val_residual[0] = Density_j * ProjVelocity_j; + for (iDim = 0; iDim < nDim; iDim++) + val_residual[iDim+1] = Density_j * Velocity_j[iDim] * ProjVelocity_j + Pressure_j * UnitNormal[iDim]; + val_residual[nVar-1] = Enthalpy_j * Density_j * ProjVelocity_j; + } + else { + + /*--- Compute Flux Right Star from Right Star State ---*/ + + rhoSR = ( sR - ProjVelocity_j ) / ( sR - sM ); + + IntermediateState[0] = rhoSR * Density_j; + for (iDim = 0; iDim < nDim; iDim++) + IntermediateState[iDim+1] = rhoSR * ( Density_j * Velocity_j[iDim] + ( pStar - Pressure_j ) / ( sR - ProjVelocity_j ) * UnitNormal[iDim] ) ; + IntermediateState[nVar-1] = rhoSR * ( Density_j * Energy_j - ( Pressure_j * ProjVelocity_j - pStar * sM ) / ( sR - ProjVelocity_j ) ); + + + val_residual[0] = sM * IntermediateState[0]; + for (iDim = 0; iDim < nDim; iDim++) + val_residual[iDim+1] = sM * IntermediateState[iDim+1] + pStar * UnitNormal[iDim]; + val_residual[nVar-1] = sM * (IntermediateState[nVar-1] + pStar ) + pStar * ProjInterfaceVel; + } + } + + for (iVar = 0; iVar < nVar; iVar++) + val_residual[iVar] *= Area; + + + /*--- Return early if the Jacobians do not need to be computed. ---*/ + + if (!implicit) return; + + if (sM > 0.0) { + + if (sL > 0.0) { + + /*--- Compute Jacobian based on Left State ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + for (jVar = 0; jVar < nVar; jVar++) + val_Jacobian_j[iVar][jVar] = 0; + + + GetInviscidProjJac(Velocity_i, &Enthalpy_i, &Chi_i, &Kappa_i, UnitNormal, 1.0, val_Jacobian_i); + + } + else { + /*--- Compute Jacobian based on Left Star State ---*/ + + EStar = IntermediateState[nVar-1]; + Omega = 1/(sL-sM); + OmegaSM = Omega * sM; + + + /*--------- Left Jacobian ---------*/ + + + /*--- Computing pressure derivatives d/dU_L (PI) ---*/ + + dPI_dU[0] = Chi_i - 0.5 * Kappa_i * sq_vel_i; + for (iDim = 0; iDim < nDim; iDim++) + dPI_dU[iDim+1] = - Kappa_i * Velocity_i[iDim]; + dPI_dU[nVar-1] = Kappa_i; + + + /*--- Computing d/dU_L (Sm) ---*/ + + dSm_dU[0] = ( - ProjVelocity_i * ProjVelocity_i + sM * sL + dPI_dU[0] ) / RHO; + for (iDim = 0; iDim < nDim; iDim++) + dSm_dU[iDim+1] = ( UnitNormal[iDim] * ( 2 * ProjVelocity_i - sL - sM ) + dPI_dU[iDim+1] ) / RHO; + dSm_dU[nVar-1] = dPI_dU[nVar-1] / RHO; + + + /*--- Computing d/dU_L (rhoStar) ---*/ + + drhoStar_dU[0] = Omega * ( sL + IntermediateState[0] * dSm_dU[0] ); + for (iDim = 0; iDim < nDim; iDim++) + drhoStar_dU[iDim+1] = Omega * ( - UnitNormal[iDim] + IntermediateState[0] * dSm_dU[iDim+1] ); + drhoStar_dU[nVar-1] = Omega * IntermediateState[0] * dSm_dU[nVar-1]; + + + /*--- Computing d/dU_L (pStar) ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + dpStar_dU[iVar] = Density_i * (sR - ProjVelocity_j) * dSm_dU[iVar]; + + + /*--- Computing d/dU_L (EStar) ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); + + dEStar_dU[0] += Omega * ProjVelocity_i * ( Enthalpy_i - dPI_dU[0] ); + for (iDim = 0; iDim < nDim; iDim++) + dEStar_dU[iDim+1] += Omega * ( - UnitNormal[iDim] * Enthalpy_i - ProjVelocity_i * dPI_dU[iDim+1] ); + dEStar_dU[nVar-1] += Omega * ( sL - ProjVelocity_i - ProjVelocity_i * dPI_dU[nVar-1] ); + + + + /*--- Jacobian First Row ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_i[0][iVar] = sM * drhoStar_dU[iVar] + IntermediateState[0] * dSm_dU[iVar]; + + /*--- Jacobian Middle Rows ---*/ + + for (jDim = 0; jDim < nDim; jDim++) { + + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_i[jDim+1][iVar] = ( OmegaSM + 1 ) * ( UnitNormal[jDim] * dpStar_dU[iVar] + IntermediateState[jDim+1] * dSm_dU[iVar] ); + + val_Jacobian_i[jDim+1][0] += OmegaSM * Velocity_i[jDim] * ProjVelocity_i; + + val_Jacobian_i[jDim+1][jDim+1] += OmegaSM * (sL - ProjVelocity_i); + + for (iDim = 0; iDim < nDim; iDim++) + val_Jacobian_i[jDim+1][iDim+1] -= OmegaSM * Velocity_i[jDim] * UnitNormal[iDim]; + + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_i[jDim+1][iVar] -= OmegaSM * dPI_dU[iVar] * UnitNormal[jDim]; + } + + /*--- Jacobian Last Row ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_i[nVar-1][iVar] = sM * ( dEStar_dU[iVar] + dpStar_dU[iVar] ) + ( EStar + pStar ) * dSm_dU[iVar]; + + + /*--------- Right Jacobian ---------*/ + + + /*--- Computing pressure derivatives d/dU_R (PI) ---*/ + + dPI_dU[0] = Chi_j - 0.5 * Kappa_j * sq_vel_j; + for (iDim = 0; iDim < nDim; iDim++) + dPI_dU[iDim+1] = - Kappa_j * Velocity_j[iDim]; + dPI_dU[nVar-1] = Kappa_j; + + + /*--- Computing d/dU_R (Sm) ---*/ + + dSm_dU[0] = ( ProjVelocity_j * ProjVelocity_j - sM * sR - dPI_dU[0] ) / RHO; + for (iDim = 0; iDim < nDim; iDim++) + dSm_dU[iDim+1] = - ( UnitNormal[iDim] * ( 2 * ProjVelocity_j - sR - sM) + dPI_dU[iDim+1] ) / RHO; + dSm_dU[nVar-1] = - dPI_dU[nVar-1] / RHO; + + + /*--- Computing d/dU_R (pStar) ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + dpStar_dU[iVar] = Density_j * (sL - ProjVelocity_i) * dSm_dU[iVar]; + + + /*--- Computing d/dU_R (EStar) ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); + + + + /*--- Jacobian First Row ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_j[0][iVar] = IntermediateState[0] * ( OmegaSM + 1 ) * dSm_dU[iVar]; + + /*--- Jacobian Middle Rows ---*/ + + for (iDim = 0; iDim < nDim; iDim++) { + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_j[iDim+1][iVar] = ( OmegaSM + 1 ) * ( IntermediateState[iDim+1] * dSm_dU[iVar] + UnitNormal[iDim] * dpStar_dU[iVar] ); + } + + /*--- Jacobian Last Row ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_j[nVar-1][iVar] = sM * (dEStar_dU[iVar] + dpStar_dU[iVar]) + (EStar + pStar) * dSm_dU[iVar]; + } + } + else { + if (sR < 0.0) { + + /*--- Compute Jacobian based on Right State ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + for (jVar = 0; jVar < nVar; jVar++) + val_Jacobian_i[iVar][jVar] = 0; + + GetInviscidProjJac(Velocity_j, &Enthalpy_j, &Chi_j, &Kappa_j, UnitNormal, 1.0, val_Jacobian_j); + + } + else { + /*--- Compute Jacobian based on Right Star State ---*/ + + EStar = IntermediateState[nVar-1]; + Omega = 1/(sR-sM); + OmegaSM = Omega * sM; + + + /*--------- Left Jacobian ---------*/ + + + /*--- Computing pressure derivatives d/dU_L (PI) ---*/ + + dPI_dU[0] = Chi_i - 0.5 * Kappa_i * sq_vel_i; + for (iDim = 0; iDim < nDim; iDim++) + dPI_dU[iDim+1] = - Kappa_i * Velocity_i[iDim]; + dPI_dU[nVar-1] = Kappa_i; + + + /*--- Computing d/dU_L (Sm) ---*/ + + dSm_dU[0] = ( - ProjVelocity_i * ProjVelocity_i + sM * sL + dPI_dU[0] ) / RHO; + for (iDim = 0; iDim < nDim; iDim++) + dSm_dU[iDim+1] = ( UnitNormal[iDim] * ( 2 * ProjVelocity_i - sL - sM ) + dPI_dU[iDim+1] ) / RHO; + dSm_dU[nVar-1] = dPI_dU[nVar-1] / RHO; + + + /*--- Computing d/dU_L (pStar) ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + dpStar_dU[iVar] = Density_i * (sR - ProjVelocity_j) * dSm_dU[iVar]; + + + /*--- Computing d/dU_L (EStar) ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); + + + + /*--- Jacobian First Row ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_i[0][iVar] = IntermediateState[0] * ( OmegaSM + 1 ) * dSm_dU[iVar]; + + /*--- Jacobian Middle Rows ---*/ + + for (iDim = 0; iDim < nDim; iDim++) { + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_i[iDim+1][iVar] = (OmegaSM + 1) * ( IntermediateState[iDim+1] * dSm_dU[iVar] + UnitNormal[iDim] * dpStar_dU[iVar] ); + } + + /*--- Jacobian Last Row ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_i[nVar-1][iVar] = sM * (dEStar_dU[iVar] + dpStar_dU[iVar]) + (EStar + pStar) * dSm_dU[iVar]; + + + + /*--------- Right Jacobian ---------*/ + + + /*--- Computing pressure derivatives d/dU_R (PI) ---*/ + + dPI_dU[0] = Chi_j - 0.5 * Kappa_j * sq_vel_j; + for (iDim = 0; iDim < nDim; iDim++) + dPI_dU[iDim+1] = - Kappa_j * Velocity_j[iDim]; + dPI_dU[nVar-1] = Kappa_j; + + + /*--- Computing d/dU_R (Sm) ---*/ + + dSm_dU[0] = - ( - ProjVelocity_j * ProjVelocity_j + sM * sR + dPI_dU[0] ) / RHO; + for (iDim = 0; iDim < nDim; iDim++) + dSm_dU[iDim+1] = - ( UnitNormal[iDim] * ( 2 * ProjVelocity_j - sR - sM) + dPI_dU[iDim+1] ) / RHO; + dSm_dU[nVar-1] = - dPI_dU[nVar-1] / RHO; + + + /*--- Computing d/dU_R (pStar) ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + dpStar_dU[iVar] = Density_j * (sL - ProjVelocity_i) * dSm_dU[iVar]; + + + /*--- Computing d/dU_R (rhoStar) ---*/ + + drhoStar_dU[0] = Omega * ( sR + IntermediateState[0] * dSm_dU[0] ); + for (iDim = 0; iDim < nDim; iDim++) + drhoStar_dU[iDim+1] = Omega * ( - UnitNormal[iDim] + IntermediateState[0] * dSm_dU[iDim+1] ); + drhoStar_dU[nVar-1] = Omega * IntermediateState[0] * dSm_dU[nVar-1]; + + + /*--- Computing d/dU_R (EStar) ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); + + dEStar_dU[0] += Omega * ProjVelocity_j * ( Enthalpy_j - dPI_dU[0] ); + for (iDim = 0; iDim < nDim; iDim++) + dEStar_dU[iDim+1] += Omega * ( - UnitNormal[iDim] * Enthalpy_j - ProjVelocity_j * dPI_dU[iDim+1] ); + dEStar_dU[nVar-1] += Omega * ( sR - ProjVelocity_j - ProjVelocity_j * dPI_dU[nVar-1] ); + + + + /*--- Jacobian First Row ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_j[0][iVar] = sM * drhoStar_dU[iVar] + IntermediateState[0] * dSm_dU[iVar]; + + /*--- Jacobian Middle Rows ---*/ + + for (jDim = 0; jDim < nDim; jDim++) { + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_j[jDim+1][iVar] = ( OmegaSM + 1 ) * ( UnitNormal[jDim] * dpStar_dU[iVar] + IntermediateState[jDim+1] * dSm_dU[iVar] ); + + val_Jacobian_j[jDim+1][0] += OmegaSM * Velocity_j[jDim] * ProjVelocity_j; + + val_Jacobian_j[jDim+1][jDim+1] += OmegaSM * (sR - ProjVelocity_j); + + for (iDim = 0; iDim < nDim; iDim++) + val_Jacobian_j[jDim+1][iDim+1] -= OmegaSM * Velocity_j[jDim] * UnitNormal[iDim]; + + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_j[jDim+1][iVar] -= OmegaSM * dPI_dU[iVar] * UnitNormal[jDim]; + } + + /*--- Jacobian Last Row ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + val_Jacobian_j[nVar-1][iVar] = sM * ( dEStar_dU[iVar] + dpStar_dU[iVar] ) + ( EStar + pStar ) * dSm_dU[iVar]; + } + } + + + /*--- Jacobians of the inviscid flux, scale = kappa because val_residual ~ 0.5*(fc_i+fc_j)*Normal ---*/ + + Area *= kappa; + + for (iVar = 0; iVar < nVar; iVar++) { + for (jVar = 0; jVar < nVar; jVar++) { + val_Jacobian_i[iVar][jVar] *= Area; + val_Jacobian_j[iVar][jVar] *= Area; + } + } + +} + +void CUpwGeneralHLLC_Flow::VinokurMontagne() { + + su2double delta_rhoStaticEnergy, delta_rho, delta_p, err_P, s, D; + + delta_rho = Density_j - Density_i; + delta_p = Pressure_j - Pressure_i; + + RoeKappaStaticEnthalpy = 0.5 * ( StaticEnthalpy_i * Kappa_i + StaticEnthalpy_j * Kappa_j ); + + s = RoeChi + RoeKappaStaticEnthalpy; + + D = s*s * delta_rho * delta_rho + delta_p * delta_p; + + delta_rhoStaticEnergy = Density_j * StaticEnergy_j - Density_i * StaticEnergy_i; + + err_P = delta_p - RoeChi * delta_rho - RoeKappa * delta_rhoStaticEnergy; + + if (abs((D - delta_p*err_P)/Density_i) > 1e-3 && abs(delta_rho/Density_i) > 1e-3 && s/Density_i > 1e-3) { + + RoeKappa = ( D * RoeKappa ) / ( D - delta_p * err_P ); + RoeChi = ( D * RoeChi+ s*s * delta_rho * err_P ) / ( D - delta_p * err_P ); + + } +} diff --git a/SU2_CFD/src/numerics/flow/convection/roe.cpp b/SU2_CFD/src/numerics/flow/convection/roe.cpp new file mode 100644 index 000000000000..433c1dbecf16 --- /dev/null +++ b/SU2_CFD/src/numerics/flow/convection/roe.cpp @@ -0,0 +1,990 @@ +/*! + * \file roe.cpp + * \brief Implementations of Roe-type schemes. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../../include/numerics/flow/convection/roe.hpp" + +CUpwRoeBase_Flow::CUpwRoeBase_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, + bool val_low_dissipation) : CNumerics(val_nDim, val_nVar, config) { + + implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ + dynamic_grid = config->GetDynamic_Grid(); + kappa = config->GetRoe_Kappa(); // 1 is unstable + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + + roe_low_dissipation = val_low_dissipation; + + Diff_U = new su2double [nVar]; + Velocity_i = new su2double [nDim]; + Velocity_j = new su2double [nDim]; + RoeVelocity = new su2double [nDim]; + ProjFlux_i = new su2double [nVar]; + ProjFlux_j = new su2double [nVar]; + Conservatives_i = new su2double [nVar]; + Conservatives_j = new su2double [nVar]; + Lambda = new su2double [nVar]; + P_Tensor = new su2double* [nVar]; + invP_Tensor = new su2double* [nVar]; + for (unsigned short iVar = 0; iVar < nVar; iVar++) { + P_Tensor[iVar] = new su2double [nVar]; + invP_Tensor[iVar] = new su2double [nVar]; + } +} + +CUpwRoeBase_Flow::~CUpwRoeBase_Flow(void) { + + delete [] Diff_U; + delete [] Velocity_i; + delete [] Velocity_j; + delete [] RoeVelocity; + delete [] ProjFlux_i; + delete [] ProjFlux_j; + delete [] Conservatives_i; + delete [] Conservatives_j; + delete [] Lambda; + for (unsigned short iVar = 0; iVar < nVar; iVar++) { + delete [] P_Tensor[iVar]; + delete [] invP_Tensor[iVar]; + } + delete [] P_Tensor; + delete [] invP_Tensor; + +} + +void CUpwRoeBase_Flow::FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { +/*--- + CUpwRoeBase_Flow::ComputeResidual initializes the residual (flux) and its Jacobians with the standard Roe averaging + fc_{1/2} = kappa*(fc_i+fc_j)*Normal. It then calls this method, which derived classes specialize, to account for + the dissipation part. +---*/ +} + +void CUpwRoeBase_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { + + unsigned short iVar, jVar, iDim; + su2double ProjGridVel = 0.0, Energy_i, Energy_j; + + AD::StartPreacc(); + AD::SetPreaccIn(V_i, nDim+4); AD::SetPreaccIn(V_j, nDim+4); AD::SetPreaccIn(Normal, nDim); + if (dynamic_grid) { + AD::SetPreaccIn(GridVel_i, nDim); AD::SetPreaccIn(GridVel_j, nDim); + } + if (roe_low_dissipation){ + AD::SetPreaccIn(Sensor_i); AD::SetPreaccIn(Sensor_j); + AD::SetPreaccIn(Dissipation_i); AD::SetPreaccIn(Dissipation_j); + } + + /*--- Face area (norm or the normal vector) and unit normal ---*/ + + 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; + + /*--- Primitive variables at point i ---*/ + + for (iDim = 0; iDim < nDim; iDim++) + Velocity_i[iDim] = V_i[iDim+1]; + Pressure_i = V_i[nDim+1]; + Density_i = V_i[nDim+2]; + Enthalpy_i = V_i[nDim+3]; + Energy_i = Enthalpy_i - Pressure_i/Density_i; + + /*--- Primitive variables at point j ---*/ + + for (iDim = 0; iDim < nDim; iDim++) + Velocity_j[iDim] = V_j[iDim+1]; + Pressure_j = V_j[nDim+1]; + Density_j = V_j[nDim+2]; + Enthalpy_j = V_j[nDim+3]; + Energy_j = Enthalpy_j - Pressure_j/Density_j; + + /*--- Compute variables that are common to the derived schemes ---*/ + + /*--- Roe-averaged variables at interface between i & j ---*/ + + su2double R = sqrt(fabs(Density_j/Density_i)); + RoeDensity = R*Density_i; + su2double sq_vel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + RoeVelocity[iDim] = (R*Velocity_j[iDim]+Velocity_i[iDim])/(R+1); + sq_vel += RoeVelocity[iDim]*RoeVelocity[iDim]; + } + RoeEnthalpy = (R*Enthalpy_j+Enthalpy_i)/(R+1); + RoeSoundSpeed2 = (Gamma-1)*(RoeEnthalpy-0.5*sq_vel); + + /*--- Negative RoeSoundSpeed^2, the jump variables is too large, clear fluxes and exit. ---*/ + + if (RoeSoundSpeed2 <= 0.0) { + for (iVar = 0; iVar < nVar; iVar++) { + val_residual[iVar] = 0.0; + if (implicit){ + for (jVar = 0; jVar < nVar; jVar++) { + val_Jacobian_i[iVar][jVar] = 0.0; + val_Jacobian_j[iVar][jVar] = 0.0; + } + } + } + AD::SetPreaccOut(val_residual, nVar); + AD::EndPreacc(); + return; + } + + RoeSoundSpeed = sqrt(RoeSoundSpeed2); + + /*--- P tensor ---*/ + + GetPMatrix(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, P_Tensor); + + /*--- Projected velocity adjusted for mesh motion ---*/ + + ProjVelocity = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + ProjVelocity += RoeVelocity[iDim]*UnitNormal[iDim]; + + if (dynamic_grid) { + for (iDim = 0; iDim < nDim; iDim++) + ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*UnitNormal[iDim]; + ProjVelocity -= ProjGridVel; + } + + /*--- Flow eigenvalues ---*/ + + for (iDim = 0; iDim < nDim; iDim++) + Lambda[iDim] = ProjVelocity; + + Lambda[nVar-2] = ProjVelocity + RoeSoundSpeed; + Lambda[nVar-1] = ProjVelocity - RoeSoundSpeed; + + /*--- Apply Mavriplis' entropy correction to eigenvalues ---*/ + + su2double MaxLambda = fabs(ProjVelocity) + RoeSoundSpeed; + + for (iVar = 0; iVar < nVar; iVar++) + Lambda[iVar] = max(fabs(Lambda[iVar]), config->GetEntropyFix_Coeff()*MaxLambda); + + /*--- Reconstruct conservative variables ---*/ + + Conservatives_i[0] = Density_i; + Conservatives_j[0] = Density_j; + + for (iDim = 0; iDim < nDim; iDim++) { + Conservatives_i[iDim+1] = Density_i*Velocity_i[iDim]; + Conservatives_j[iDim+1] = Density_j*Velocity_j[iDim]; + } + Conservatives_i[nDim+1] = Density_i*Energy_i; + Conservatives_j[nDim+1] = Density_j*Energy_j; + + /*--- Compute left and right fluxes ---*/ + + GetInviscidProjFlux(&Density_i, Velocity_i, &Pressure_i, &Enthalpy_i, Normal, ProjFlux_i); + GetInviscidProjFlux(&Density_j, Velocity_j, &Pressure_j, &Enthalpy_j, Normal, ProjFlux_j); + + /*--- Initialize residual (flux) and Jacobians ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + val_residual[iVar] = kappa*(ProjFlux_i[iVar]+ProjFlux_j[iVar]); + + if (implicit) { + GetInviscidProjJac(Velocity_i, &Energy_i, Normal, kappa, val_Jacobian_i); + GetInviscidProjJac(Velocity_j, &Energy_j, Normal, kappa, val_Jacobian_j); + } + + /*--- Finalize in children class ---*/ + + FinalizeResidual(val_residual, val_Jacobian_i, val_Jacobian_j, config); + + /*--- Correct for grid motion ---*/ + + if (dynamic_grid) { + for (iVar = 0; iVar < nVar; iVar++) { + val_residual[iVar] -= ProjGridVel*Area * 0.5*(Conservatives_i[iVar]+Conservatives_j[iVar]); + + if (implicit) { + val_Jacobian_i[iVar][iVar] -= 0.5*ProjGridVel*Area; + val_Jacobian_j[iVar][iVar] -= 0.5*ProjGridVel*Area; + } + } + } + + AD::SetPreaccOut(val_residual, nVar); + AD::EndPreacc(); + +} + +CUpwRoe_Flow::CUpwRoe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, + bool val_low_dissipation) : CUpwRoeBase_Flow(val_nDim, val_nVar, config, val_low_dissipation) {} + +void CUpwRoe_Flow::FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, + su2double **val_Jacobian_j, CConfig *config) { + + unsigned short iVar, jVar, kVar; + + /*--- Compute inverse P tensor ---*/ + GetPMatrix_inv(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, invP_Tensor); + + /*--- Diference between conservative variables at jPoint and iPoint ---*/ + for (iVar = 0; iVar < nVar; iVar++) + Diff_U[iVar] = Conservatives_j[iVar]-Conservatives_i[iVar]; + + /*--- Low dissipation formulation ---*/ + if (roe_low_dissipation) + SetRoe_Dissipation(Dissipation_i, Dissipation_j, Sensor_i, Sensor_j, Dissipation_ij, config); + else + Dissipation_ij = 1.0; + + /*--- Standard Roe "dissipation" ---*/ + + for (iVar = 0; iVar < nVar; iVar++) { + for (jVar = 0; jVar < nVar; jVar++) { + /*--- Compute |Proj_ModJac_Tensor| = P x |Lambda| x inverse P ---*/ + su2double Proj_ModJac_Tensor_ij = 0.0; + for (kVar = 0; kVar < nVar; kVar++) + Proj_ModJac_Tensor_ij += P_Tensor[iVar][kVar]*Lambda[kVar]*invP_Tensor[kVar][jVar]; + + /*--- Update residual and Jacobians ---*/ + val_residual[iVar] -= (1.0-kappa)*Proj_ModJac_Tensor_ij*Diff_U[jVar]*Area*Dissipation_ij; + + if(implicit){ + val_Jacobian_i[iVar][jVar] += (1.0-kappa)*Proj_ModJac_Tensor_ij*Area; + val_Jacobian_j[iVar][jVar] -= (1.0-kappa)*Proj_ModJac_Tensor_ij*Area; + } + } + } + +} + +CUpwL2Roe_Flow::CUpwL2Roe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : + CUpwRoeBase_Flow(val_nDim, val_nVar, config, false) {} + +void CUpwL2Roe_Flow::FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, + su2double **val_Jacobian_j, CConfig *config) { + + /*--- L2Roe: a low dissipation version of Roe's approximate Riemann solver for low Mach numbers. IJNMF 2015 ---*/ + + unsigned short iVar, jVar, kVar, iDim; + + /*--- Clamped Mach number ---*/ + + su2double M_i = 0.0, M_j = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + M_i += Velocity_i[iDim]*Velocity_i[iDim]; + M_j += Velocity_j[iDim]*Velocity_j[iDim]; + } + M_i = sqrt(M_i / fabs(Pressure_i*Gamma/Density_i)); + M_j = sqrt(M_j / fabs(Pressure_j*Gamma/Density_j)); + + su2double zeta = max(0.05,min(max(M_i,M_j),1.0)); + + /*--- Compute wave amplitudes (characteristics) ---*/ + + su2double proj_delta_vel = 0.0, delta_vel[3]; + for (iDim = 0; iDim < nDim; iDim++) { + delta_vel[iDim] = Velocity_j[iDim] - Velocity_i[iDim]; + proj_delta_vel += delta_vel[iDim]*UnitNormal[iDim]; + } + proj_delta_vel *= zeta; + su2double delta_p = Pressure_j - Pressure_i; + su2double delta_rho = Density_j - Density_i; + + su2double delta_wave[5] = {0.0, 0.0, 0.0, 0.0, 0.0}; + if (nDim == 2) { + delta_wave[0] = delta_rho - delta_p/RoeSoundSpeed2; + delta_wave[1] = (UnitNormal[1]*delta_vel[0]-UnitNormal[0]*delta_vel[1])*zeta; + delta_wave[2] = proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); + delta_wave[3] = -proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); + } else { + delta_wave[0] = delta_rho - delta_p/RoeSoundSpeed2; + delta_wave[1] = (UnitNormal[0]*delta_vel[2]-UnitNormal[2]*delta_vel[0])*zeta; + delta_wave[2] = (UnitNormal[1]*delta_vel[0]-UnitNormal[0]*delta_vel[1])*zeta; + delta_wave[3] = proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); + delta_wave[4] = -proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); + } + + /*--- Update residual ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + for (kVar = 0; kVar < nVar; kVar++) + val_residual[iVar] -= (1.0-kappa)*Lambda[kVar]*delta_wave[kVar]*P_Tensor[iVar][kVar]*Area; + + if (!implicit) return; + + /*--- If implicit use the Jacobians of the standard Roe scheme as an approximation ---*/ + + GetPMatrix_inv(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, invP_Tensor); + + for (iVar = 0; iVar < nVar; iVar++) { + for (jVar = 0; jVar < nVar; jVar++) { + /*--- Compute |Proj_ModJac_Tensor| = P x |Lambda| x inverse P ---*/ + su2double Proj_ModJac_Tensor_ij = 0.0; + for (kVar = 0; kVar < nVar; kVar++) + Proj_ModJac_Tensor_ij += P_Tensor[iVar][kVar]*Lambda[kVar]*invP_Tensor[kVar][jVar]; + + val_Jacobian_i[iVar][jVar] += (1.0-kappa)*Proj_ModJac_Tensor_ij*Area; + val_Jacobian_j[iVar][jVar] -= (1.0-kappa)*Proj_ModJac_Tensor_ij*Area; + } + } + +} + +CUpwLMRoe_Flow::CUpwLMRoe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : + CUpwRoeBase_Flow(val_nDim, val_nVar, config, false) {} + +void CUpwLMRoe_Flow::FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, + su2double **val_Jacobian_j, CConfig *config) { + + /*--- Rieper, A low-Mach number fix for Roe's approximate Riemman Solver, JCP 2011 ---*/ + + unsigned short iVar, jVar, kVar, iDim; + + /*--- Clamped Mach number ---*/ + + su2double M_i = 0.0, M_j = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + M_i += Velocity_i[iDim]*Velocity_i[iDim]; + M_j += Velocity_j[iDim]*Velocity_j[iDim]; + } + M_i = sqrt(M_i / fabs(Pressure_i*Gamma/Density_i)); + M_j = sqrt(M_j / fabs(Pressure_j*Gamma/Density_j)); + + su2double zeta = max(0.05,min(max(M_i,M_j),1.0)); + + /*--- Compute wave amplitudes (characteristics) ---*/ + + su2double proj_delta_vel = 0.0, delta_vel[3]; + for (iDim = 0; iDim < nDim; iDim++) { + delta_vel[iDim] = Velocity_j[iDim] - Velocity_i[iDim]; + proj_delta_vel += delta_vel[iDim]*UnitNormal[iDim]; + } + proj_delta_vel *= zeta; + su2double delta_p = Pressure_j - Pressure_i; + su2double delta_rho = Density_j - Density_i; + + su2double delta_wave[5] = {0.0, 0.0, 0.0, 0.0, 0.0}; + if (nDim == 2) { + delta_wave[0] = delta_rho - delta_p/RoeSoundSpeed2; + delta_wave[1] = (UnitNormal[1]*delta_vel[0]-UnitNormal[0]*delta_vel[1]); + delta_wave[2] = proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); + delta_wave[3] = -proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); + } else { + delta_wave[0] = delta_rho - delta_p/RoeSoundSpeed2; + delta_wave[1] = (UnitNormal[0]*delta_vel[2]-UnitNormal[2]*delta_vel[0]); + delta_wave[2] = (UnitNormal[1]*delta_vel[0]-UnitNormal[0]*delta_vel[1]); + delta_wave[3] = proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); + delta_wave[4] = -proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); + } + + /*--- Update residual ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + for (kVar = 0; kVar < nVar; kVar++) + val_residual[iVar] -= (1.0-kappa)*Lambda[kVar]*delta_wave[kVar]*P_Tensor[iVar][kVar]*Area; + + if (!implicit) return; + + /*--- If implicit use the Jacobians of the standard Roe scheme as an approximation ---*/ + + GetPMatrix_inv(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, invP_Tensor); + + for (iVar = 0; iVar < nVar; iVar++) { + for (jVar = 0; jVar < nVar; jVar++) { + /*--- Compute |Proj_ModJac_Tensor| = P x |Lambda| x inverse P ---*/ + su2double Proj_ModJac_Tensor_ij = 0.0; + for (kVar = 0; kVar < nVar; kVar++) + Proj_ModJac_Tensor_ij += P_Tensor[iVar][kVar]*Lambda[kVar]*invP_Tensor[kVar][jVar]; + + val_Jacobian_i[iVar][jVar] += (1.0-kappa)*Proj_ModJac_Tensor_ij*Area; + val_Jacobian_j[iVar][jVar] -= (1.0-kappa)*Proj_ModJac_Tensor_ij*Area; + } + } + +} + +CUpwTurkel_Flow::CUpwTurkel_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ + dynamic_grid = config->GetDynamic_Grid(); + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + + Beta_min = config->GetminTurkelBeta(); + Beta_max = config->GetmaxTurkelBeta(); + + Diff_U = new su2double [nVar]; + Velocity_i = new su2double [nDim]; + Velocity_j = new su2double [nDim]; + RoeVelocity = new su2double [nDim]; + ProjFlux_i = new su2double [nVar]; + ProjFlux_j = new su2double [nVar]; + Lambda = new su2double [nVar]; + Epsilon = new su2double [nVar]; + absPeJac = new su2double* [nVar]; + invRinvPe = new su2double* [nVar]; + R_Tensor = new su2double* [nVar]; + Matrix = new su2double* [nVar]; + Art_Visc = new su2double* [nVar]; + for (iVar = 0; iVar < nVar; iVar++) { + absPeJac[iVar] = new su2double [nVar]; + invRinvPe[iVar] = new su2double [nVar]; + Matrix[iVar] = new su2double [nVar]; + Art_Visc[iVar] = new su2double [nVar]; + R_Tensor[iVar] = new su2double [nVar]; + } +} + +CUpwTurkel_Flow::~CUpwTurkel_Flow(void) { + + delete [] Diff_U; + delete [] Velocity_i; + delete [] Velocity_j; + delete [] RoeVelocity; + delete [] ProjFlux_i; + delete [] ProjFlux_j; + delete [] Lambda; + delete [] Epsilon; + for (iVar = 0; iVar < nVar; iVar++) { + delete [] absPeJac[iVar]; + delete [] invRinvPe[iVar]; + delete [] Matrix[iVar]; + delete [] Art_Visc[iVar]; + delete [] R_Tensor[iVar]; + } + delete [] Matrix; + delete [] Art_Visc; + delete [] absPeJac; + delete [] invRinvPe; + delete [] R_Tensor; + +} + +void CUpwTurkel_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { + + su2double U_i[5] = {0.0,0.0,0.0,0.0,0.0}, U_j[5] = {0.0,0.0,0.0,0.0,0.0}; + + /*--- Face area (norm or the normal vector) ---*/ + + Area = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + Area += Normal[iDim]*Normal[iDim]; + Area = sqrt(Area); + + /*-- Unit Normal ---*/ + + for (iDim = 0; iDim < nDim; iDim++) + UnitNormal[iDim] = Normal[iDim]/Area; + + /*--- Primitive variables at point i ---*/ + + for (iDim = 0; iDim < nDim; iDim++) + Velocity_i[iDim] = V_i[iDim+1]; + Pressure_i = V_i[nDim+1]; + Density_i = V_i[nDim+2]; + Enthalpy_i = V_i[nDim+3]; + Energy_i = Enthalpy_i - Pressure_i/Density_i; + SoundSpeed_i = sqrt(fabs(Pressure_i*Gamma/Density_i)); + + /*--- Primitive variables at point j ---*/ + + for (iDim = 0; iDim < nDim; iDim++) + Velocity_j[iDim] = V_j[iDim+1]; + Pressure_j = V_j[nDim+1]; + Density_j = V_j[nDim+2]; + Enthalpy_j = V_j[nDim+3]; + Energy_j = Enthalpy_j - Pressure_j/Density_j; + SoundSpeed_j = sqrt(fabs(Pressure_j*Gamma/Density_j)); + + /*--- Recompute conservative variables ---*/ + + U_i[0] = Density_i; U_j[0] = Density_j; + for (iDim = 0; iDim < nDim; iDim++) { + U_i[iDim+1] = Density_i*Velocity_i[iDim]; U_j[iDim+1] = Density_j*Velocity_j[iDim]; + } + U_i[nDim+1] = Density_i*Energy_i; U_j[nDim+1] = Density_j*Energy_j; + + /*--- Roe-averaged variables at interface between i & j ---*/ + + R = sqrt(fabs(Density_j/Density_i)); + RoeDensity = R*Density_i; + sq_vel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + RoeVelocity[iDim] = (R*Velocity_j[iDim]+Velocity_i[iDim])/(R+1); + sq_vel += RoeVelocity[iDim]*RoeVelocity[iDim]; + } + RoeEnthalpy = (R*Enthalpy_j+Enthalpy_i)/(R+1); + RoeSoundSpeed = sqrt(fabs((Gamma-1)*(RoeEnthalpy-0.5*sq_vel))); + RoePressure = RoeDensity/Gamma*RoeSoundSpeed*RoeSoundSpeed; + + /*--- Compute ProjFlux_i ---*/ + GetInviscidProjFlux(&Density_i, Velocity_i, &Pressure_i, &Enthalpy_i, Normal, ProjFlux_i); + + /*--- Compute ProjFlux_j ---*/ + GetInviscidProjFlux(&Density_j, Velocity_j, &Pressure_j, &Enthalpy_j, Normal, ProjFlux_j); + + ProjVelocity = 0.0; ProjVelocity_i = 0.0; ProjVelocity_j = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + ProjVelocity += RoeVelocity[iDim]*UnitNormal[iDim]; + ProjVelocity_i += Velocity_i[iDim]*UnitNormal[iDim]; + ProjVelocity_j += Velocity_j[iDim]*UnitNormal[iDim]; + } + + /*--- Projected velocity adjustment due to mesh motion ---*/ + if (dynamic_grid) { + su2double ProjGridVel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*UnitNormal[iDim]; + } + ProjVelocity -= ProjGridVel; + ProjVelocity_i -= ProjGridVel; + ProjVelocity_j -= ProjGridVel; + } + + /*--- First few flow eigenvalues of A.Normal with the normal---*/ + for (iDim = 0; iDim < nDim; iDim++) + Lambda[iDim] = ProjVelocity; + + local_Mach = sqrt(sq_vel)/RoeSoundSpeed; + Beta = max(Beta_min, min(local_Mach, Beta_max)); + Beta2 = Beta*Beta; + + one_m_Betasqr = 1.0 - Beta2; // 1-Beta*Beta + one_p_Betasqr = 1.0 + Beta2; // 1+Beta*Beta + sqr_one_m_Betasqr_Lam1 = pow((one_m_Betasqr*Lambda[0]),2); // [(1-Beta^2)*Lambda[0]]^2 + sqr_two_Beta_c_Area = pow(2.0*Beta*RoeSoundSpeed*Area,2); // [2*Beta*c*Area]^2 + + /*--- The rest of the flow eigenvalues of preconditioned matrix---*/ + Lambda[nVar-2] = 0.5 * ( one_p_Betasqr*Lambda[0] + sqrt( sqr_one_m_Betasqr_Lam1 + sqr_two_Beta_c_Area)); + Lambda[nVar-1] = 0.5 * ( one_p_Betasqr*Lambda[0] - sqrt( sqr_one_m_Betasqr_Lam1 + sqr_two_Beta_c_Area)); + + s_hat = 1.0/Area * (Lambda[nVar-1] - Lambda[0]*Beta2); + r_hat = 1.0/Area * (Lambda[nVar-2] - Lambda[0]*Beta2); + t_hat = 0.5/Area * (Lambda[nVar-1] - Lambda[nVar-2]); + rhoB2a2 = RoeDensity*Beta2*RoeSoundSpeed*RoeSoundSpeed; + + /*--- Diference variables iPoint and jPoint and absolute value of the eigen values---*/ + for (iVar = 0; iVar < nVar; iVar++) { + Diff_U[iVar] = U_j[iVar]-U_i[iVar]; + Lambda[iVar] = fabs(Lambda[iVar]); + } + + /*--- Compute the absolute Preconditioned Jacobian in entropic Variables (do it with the Unitary Normal) ---*/ + GetPrecondJacobian(Beta2, r_hat, s_hat, t_hat, rhoB2a2, Lambda, UnitNormal, absPeJac); + + /*--- Compute the matrix from entropic variables to conserved variables ---*/ + GetinvRinvPe(Beta2, RoeEnthalpy, RoeSoundSpeed, RoeDensity, RoeVelocity, invRinvPe); + + /*--- Compute the matrix from entropic variables to conserved variables ---*/ + GetRMatrix(RoePressure, RoeSoundSpeed, RoeDensity, RoeVelocity, R_Tensor); + + if (implicit) { + /*--- Jacobians of the inviscid flux, scaled by + 0.5 because val_residual ~ 0.5*(fc_i+fc_j)*Normal ---*/ + GetInviscidProjJac(Velocity_i, &Energy_i, Normal, 0.5, val_Jacobian_i); + GetInviscidProjJac(Velocity_j, &Energy_j, Normal, 0.5, val_Jacobian_j); + } + + for (iVar = 0; iVar < nVar; iVar ++) { + for (jVar = 0; jVar < nVar; jVar ++) { + Matrix[iVar][jVar] = 0.0; + for (kVar = 0; kVar < nVar; kVar++) + Matrix[iVar][jVar] += absPeJac[iVar][kVar]*R_Tensor[kVar][jVar]; + } + } + + for (iVar = 0; iVar < nVar; iVar ++) { + for (jVar = 0; jVar < nVar; jVar ++) { + Art_Visc[iVar][jVar] = 0.0; + for (kVar = 0; kVar < nVar; kVar++) + Art_Visc[iVar][jVar] += invRinvPe[iVar][kVar]*Matrix[kVar][jVar]; + } + } + + /*--- Roe's Flux approximation ---*/ + for (iVar = 0; iVar < nVar; iVar++) { + val_residual[iVar] = 0.5*(ProjFlux_i[iVar]+ProjFlux_j[iVar]); + for (jVar = 0; jVar < nVar; jVar++) { + val_residual[iVar] -= 0.5*Art_Visc[iVar][jVar]*Diff_U[jVar]; + if (implicit) { + val_Jacobian_i[iVar][jVar] += 0.5*Art_Visc[iVar][jVar]; + val_Jacobian_j[iVar][jVar] -= 0.5*Art_Visc[iVar][jVar]; + } + } + } + + /*--- Contributions due to mesh motion---*/ + if (dynamic_grid) { + ProjVelocity = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + ProjVelocity += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*UnitNormal[iDim]; + for (iVar = 0; iVar < nVar; iVar++) { + val_residual[iVar] -= ProjVelocity * 0.5*(U_i[iVar]+U_j[iVar]); + /*--- Implicit terms ---*/ + if (implicit) { + val_Jacobian_i[iVar][iVar] -= 0.5*ProjVelocity; + val_Jacobian_j[iVar][iVar] -= 0.5*ProjVelocity; + } + } + } + +} + +CUpwGeneralRoe_Flow::CUpwGeneralRoe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ + dynamic_grid = config->GetDynamic_Grid(); + kappa = config->GetRoe_Kappa(); // 1 is unstable + + + Diff_U = new su2double [nVar]; + Velocity_i = new su2double [nDim]; + Velocity_j = new su2double [nDim]; + RoeVelocity = new su2double [nDim]; + delta_vel = new su2double [nDim]; + delta_wave = new su2double [nVar]; + ProjFlux_i = new su2double [nVar]; + ProjFlux_j = new su2double [nVar]; + Lambda = new su2double [nVar]; + Epsilon = new su2double [nVar]; + P_Tensor = new su2double* [nVar]; + invP_Tensor = new su2double* [nVar]; + + for (iVar = 0; iVar < nVar; iVar++) { + P_Tensor[iVar] = new su2double [nVar]; + invP_Tensor[iVar] = new su2double [nVar]; + } +} + +CUpwGeneralRoe_Flow::~CUpwGeneralRoe_Flow(void) { + + delete [] Diff_U; + delete [] Velocity_i; + delete [] Velocity_j; + delete [] RoeVelocity; + delete [] delta_vel; + delete [] delta_wave; + delete [] ProjFlux_i; + delete [] ProjFlux_j; + delete [] Lambda; + delete [] Epsilon; + for (iVar = 0; iVar < nVar; iVar++) { + delete [] P_Tensor[iVar]; + delete [] invP_Tensor[iVar]; + } + delete [] P_Tensor; + delete [] invP_Tensor; + +} + +void CUpwGeneralRoe_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { + + AD::StartPreacc(); + AD::SetPreaccIn(V_i, nDim+4); AD::SetPreaccIn(V_j, nDim+4); AD::SetPreaccIn(Normal, nDim); + AD::SetPreaccIn(S_i, 2); AD::SetPreaccIn(S_j, 2); + if (dynamic_grid) { + AD::SetPreaccIn(GridVel_i, nDim); AD::SetPreaccIn(GridVel_j, nDim); + } + su2double U_i[5] = {0.0,0.0,0.0,0.0,0.0}, U_j[5] = {0.0,0.0,0.0,0.0,0.0}; + + /*--- Face area (norm or the normal vector) ---*/ + + Area = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + Area += Normal[iDim]*Normal[iDim]; + Area = sqrt(Area); + + /*-- Unit Normal ---*/ + + for (iDim = 0; iDim < nDim; iDim++) + UnitNormal[iDim] = Normal[iDim]/Area; + + /*--- Primitive variables at point i ---*/ + + Velocity2_i = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + Velocity_i[iDim] = V_i[iDim+1]; + Velocity2_i += Velocity_i[iDim]*Velocity_i[iDim]; + } + + Pressure_i = V_i[nDim+1]; + Density_i = V_i[nDim+2]; + Enthalpy_i = V_i[nDim+3]; + Energy_i = Enthalpy_i - Pressure_i/Density_i; + StaticEnthalpy_i = Enthalpy_i - 0.5*Velocity2_i; + StaticEnergy_i = StaticEnthalpy_i - Pressure_i/Density_i; + + Kappa_i = S_i[1]/Density_i; + Chi_i = S_i[0] - Kappa_i*StaticEnergy_i; + SoundSpeed_i = sqrt(Chi_i + StaticEnthalpy_i*Kappa_i); + + /*--- Primitive variables at point j ---*/ + + + Velocity2_j = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + Velocity_j[iDim] = V_j[iDim+1]; + Velocity2_j += Velocity_j[iDim]*Velocity_j[iDim]; + } + + Pressure_j = V_j[nDim+1]; + Density_j = V_j[nDim+2]; + Enthalpy_j = V_j[nDim+3]; + Energy_j = Enthalpy_j - Pressure_j/Density_j; + + StaticEnthalpy_j = Enthalpy_j - 0.5*Velocity2_j; + StaticEnergy_j = StaticEnthalpy_j - Pressure_j/Density_j; + + Kappa_j = S_j[1]/Density_j; + Chi_j = S_j[0] - Kappa_j*StaticEnergy_j; + SoundSpeed_j = sqrt(Chi_j + StaticEnthalpy_j*Kappa_j); + + /*--- Recompute conservative variables ---*/ + + U_i[0] = Density_i; U_j[0] = Density_j; + for (iDim = 0; iDim < nDim; iDim++) { + U_i[iDim+1] = Density_i*Velocity_i[iDim]; U_j[iDim+1] = Density_j*Velocity_j[iDim]; + } + U_i[nDim+1] = Density_i*Energy_i; U_j[nDim+1] = Density_j*Energy_j; + +// /*--- Roe-averaged variables at interface between i & j ---*/ + + ComputeRoeAverage(); + + if (RoeSoundSpeed2 <= 0.0) { + for (iVar = 0; iVar < nVar; iVar++) { + val_residual[iVar] = 0.0; + for (jVar = 0; jVar < nVar; jVar++) { + val_Jacobian_i[iVar][iVar] = 0.0; + val_Jacobian_j[iVar][iVar] = 0.0; + } + } + return; + } + + RoeSoundSpeed = sqrt(RoeSoundSpeed2); + + /*--- Compute ProjFlux_i ---*/ + GetInviscidProjFlux(&Density_i, Velocity_i, &Pressure_i, &Enthalpy_i, Normal, ProjFlux_i); + + /*--- Compute ProjFlux_j ---*/ + GetInviscidProjFlux(&Density_j, Velocity_j, &Pressure_j, &Enthalpy_j, Normal, ProjFlux_j); + + /*--- Compute P and Lambda (do it with the Normal) ---*/ + + GetPMatrix(&RoeDensity, RoeVelocity, &RoeSoundSpeed, &RoeEnthalpy, &RoeChi, &RoeKappa, UnitNormal, P_Tensor); + + ProjVelocity = 0.0; ProjVelocity_i = 0.0; ProjVelocity_j = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + ProjVelocity += RoeVelocity[iDim]*UnitNormal[iDim]; + ProjVelocity_i += Velocity_i[iDim]*UnitNormal[iDim]; + ProjVelocity_j += Velocity_j[iDim]*UnitNormal[iDim]; + } + + /*--- Projected velocity adjustment due to mesh motion ---*/ + if (dynamic_grid) { + su2double ProjGridVel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*UnitNormal[iDim]; + } + ProjVelocity -= ProjGridVel; + ProjVelocity_i -= ProjGridVel; + ProjVelocity_j -= ProjGridVel; + } + + /*--- Flow eigenvalues and entropy correctors ---*/ + for (iDim = 0; iDim < nDim; iDim++) + Lambda[iDim] = ProjVelocity; + + Lambda[nVar-2] = ProjVelocity + RoeSoundSpeed; + Lambda[nVar-1] = ProjVelocity - RoeSoundSpeed; + + /*--- Compute absolute value with Mavriplis' entropy correction ---*/ + + MaxLambda = fabs(ProjVelocity) + RoeSoundSpeed; + Delta = config->GetEntropyFix_Coeff(); + + for (iVar = 0; iVar < nVar; iVar++) { + Lambda[iVar] = max(fabs(Lambda[iVar]), Delta*MaxLambda); + } + +// /*--- Harten and Hyman (1983) entropy correction ---*/ +// for (iDim = 0; iDim < nDim; iDim++) +// Epsilon[iDim] = 4.0*max(0.0, max(Lambda[iDim]-ProjVelocity_i, ProjVelocity_j-Lambda[iDim])); +// +// Epsilon[nVar-2] = 4.0*max(0.0, max(Lambda[nVar-2]-(ProjVelocity_i+SoundSpeed_i),(ProjVelocity_j+SoundSpeed_j)-Lambda[nVar-2])); +// Epsilon[nVar-1] = 4.0*max(0.0, max(Lambda[nVar-1]-(ProjVelocity_i-SoundSpeed_i),(ProjVelocity_j-SoundSpeed_j)-Lambda[nVar-1])); +// +// for (iVar = 0; iVar < nVar; iVar++) +// if ( fabs(Lambda[iVar]) < Epsilon[iVar] ) +// Lambda[iVar] = (Lambda[iVar]*Lambda[iVar] + Epsilon[iVar]*Epsilon[iVar])/(2.0*Epsilon[iVar]); +// else +// Lambda[iVar] = fabs(Lambda[iVar]); + +// for (iVar = 0; iVar < nVar; iVar++) +// Lambda[iVar] = fabs(Lambda[iVar]); + + if (!implicit) { + + /*--- Compute wave amplitudes (characteristics) ---*/ + proj_delta_vel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + delta_vel[iDim] = Velocity_j[iDim] - Velocity_i[iDim]; + proj_delta_vel += delta_vel[iDim]*Normal[iDim]; + } + delta_p = Pressure_j - Pressure_i; + delta_rho = Density_j - Density_i; + proj_delta_vel = proj_delta_vel/Area; + + if (nDim == 2) { + delta_wave[0] = delta_rho - delta_p/(RoeSoundSpeed*RoeSoundSpeed); + delta_wave[1] = UnitNormal[1]*delta_vel[0]-UnitNormal[0]*delta_vel[1]; + delta_wave[2] = proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); + delta_wave[3] = -proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); + } else { + delta_wave[0] = delta_rho - delta_p/(RoeSoundSpeed*RoeSoundSpeed); + delta_wave[1] = UnitNormal[0]*delta_vel[2]-UnitNormal[2]*delta_vel[0]; + delta_wave[2] = UnitNormal[1]*delta_vel[0]-UnitNormal[0]*delta_vel[1]; + delta_wave[3] = proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); + delta_wave[4] = -proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); + } + + /*--- Roe's Flux approximation ---*/ + for (iVar = 0; iVar < nVar; iVar++) { + val_residual[iVar] = 0.5*(ProjFlux_i[iVar]+ProjFlux_j[iVar]); + for (jVar = 0; jVar < nVar; jVar++) + val_residual[iVar] -= 0.5*Lambda[jVar]*delta_wave[jVar]*P_Tensor[iVar][jVar]*Area; + } + + /*--- Flux contribution due to grid motion ---*/ + if (dynamic_grid) { + ProjVelocity = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + ProjVelocity += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; + for (iVar = 0; iVar < nVar; iVar++) { + val_residual[iVar] -= ProjVelocity * 0.5*(U_i[iVar]+U_j[iVar]); + } + } + } + else { + + /*--- Compute inverse P ---*/ + + GetPMatrix_inv(invP_Tensor, &RoeDensity, RoeVelocity, &RoeSoundSpeed, &RoeChi , &RoeKappa, UnitNormal); + + /*--- Jacobians of the inviscid flux, scaled by + kappa because val_resconv ~ kappa*(fc_i+fc_j)*Normal ---*/ + + GetInviscidProjJac(Velocity_i, &Enthalpy_i, &Chi_i, &Kappa_i, Normal, kappa, val_Jacobian_i); + + GetInviscidProjJac(Velocity_j, &Enthalpy_j, &Chi_j, &Kappa_j, Normal, kappa, val_Jacobian_j); + + + /*--- Diference variables iPoint and jPoint ---*/ + for (iVar = 0; iVar < nVar; iVar++) + Diff_U[iVar] = U_j[iVar]-U_i[iVar]; + + /*--- Roe's Flux approximation ---*/ + for (iVar = 0; iVar < nVar; iVar++) { + val_residual[iVar] = kappa*(ProjFlux_i[iVar]+ProjFlux_j[iVar]); + for (jVar = 0; jVar < nVar; jVar++) { + Proj_ModJac_Tensor_ij = 0.0; + + /*--- Compute |Proj_ModJac_Tensor| = P x |Lambda| x inverse P ---*/ + + for (kVar = 0; kVar < nVar; kVar++) + Proj_ModJac_Tensor_ij += P_Tensor[iVar][kVar]*Lambda[kVar]*invP_Tensor[kVar][jVar]; + + val_residual[iVar] -= (1.0-kappa)*Proj_ModJac_Tensor_ij*Diff_U[jVar]*Area; + val_Jacobian_i[iVar][jVar] += (1.0-kappa)*Proj_ModJac_Tensor_ij*Area; + val_Jacobian_j[iVar][jVar] -= (1.0-kappa)*Proj_ModJac_Tensor_ij*Area; + } + } + + /*--- Jacobian contributions due to grid motion ---*/ + if (dynamic_grid) { + ProjVelocity = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + ProjVelocity += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; + for (iVar = 0; iVar < nVar; iVar++) { + val_residual[iVar] -= ProjVelocity * 0.5*(U_i[iVar]+U_j[iVar]); + /*--- Implicit terms ---*/ + val_Jacobian_i[iVar][iVar] -= 0.5*ProjVelocity; + val_Jacobian_j[iVar][iVar] -= 0.5*ProjVelocity; + } + } + + } + + AD::SetPreaccOut(val_residual, nVar); + AD::EndPreacc(); +} + +void CUpwGeneralRoe_Flow::ComputeRoeAverage() { + + //su2double delta_rhoStaticEnergy, err_P, s, D; + // su2double tol = 10-6; + + R = sqrt(fabs(Density_j/Density_i)); + RoeDensity = R*Density_i; + sq_vel = 0; for (iDim = 0; iDim < nDim; iDim++) { + RoeVelocity[iDim] = (R*Velocity_j[iDim]+Velocity_i[iDim])/(R+1); + sq_vel += RoeVelocity[iDim]*RoeVelocity[iDim]; + } + + RoeEnthalpy = (R*Enthalpy_j+Enthalpy_i)/(R+1); + delta_rho = Density_j - Density_i; + delta_p = Pressure_j - Pressure_i; + RoeKappa = 0.5*(Kappa_i + Kappa_j); + RoeKappa = (Kappa_i + Kappa_j + 4*RoeKappa)/6; + RoeChi = 0.5*(Chi_i + Chi_j); + RoeChi = (Chi_i + Chi_j + 4*RoeChi)/6; + + +// RoeKappaStaticEnthalpy = 0.5*(StaticEnthalpy_i*Kappa_i + StaticEnthalpy_j*Kappa_j); +// RoeKappaStaticEnthalpy = (StaticEnthalpy_i*Kappa_i + StaticEnthalpy_j*Kappa_j + 4*RoeKappaStaticEnthalpy)/6; +// s = RoeChi + RoeKappaStaticEnthalpy; +// D = s*s*delta_rho*delta_rho + delta_p*delta_p; +// delta_rhoStaticEnergy = Density_j*StaticEnergy_j - Density_i*StaticEnergy_i; +// err_P = delta_p - RoeChi*delta_rho - RoeKappa*delta_rhoStaticEnergy; +// +// +// if (abs((D - delta_p*err_P)/Density_i)>1e-3 && abs(delta_rho/Density_i)>1e-3 && s/Density_i > 1e-3) { +// +// RoeKappa = (D*RoeKappa)/(D - delta_p*err_P); +// RoeChi = (D*RoeChi+ s*s*delta_rho*err_P)/(D - delta_p*err_P); +// +// } + + RoeSoundSpeed2 = RoeChi + RoeKappa*(RoeEnthalpy-0.5*sq_vel); + +} diff --git a/SU2_CFD/src/numerics/flow/convection_centered/CCentBase_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_centered/CCentBase_Flow.cpp deleted file mode 100644 index a5b512a63d10..000000000000 --- a/SU2_CFD/src/numerics/flow/convection_centered/CCentBase_Flow.cpp +++ /dev/null @@ -1,207 +0,0 @@ -/*! - * \file CCentBase_Flow.cpp - * \brief Implementation of numerics class CCentBase_Flow. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../../include/numerics/flow/convection_centered/CCentBase_Flow.hpp" - -CCentBase_Flow::CCentBase_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : - CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ - dynamic_grid = config->GetDynamic_Grid(); - fix_factor = config->GetCent_Jac_Fix_Factor(); - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - /*--- Allocate required structures ---*/ - Diff_U = new su2double [nVar]; - Diff_Lapl = new su2double [nVar]; - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; - MeanVelocity = new su2double [nDim]; - ProjFlux = new su2double [nVar]; -} - -CCentBase_Flow::~CCentBase_Flow(void) { - delete [] Diff_U; - delete [] Diff_Lapl; - delete [] Velocity_i; - delete [] Velocity_j; - delete [] MeanVelocity; - delete [] ProjFlux; -} - -void CCentBase_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, - CConfig *config) { - - su2double U_i[5] = {0.0,0.0,0.0,0.0,0.0}, U_j[5] = {0.0,0.0,0.0,0.0,0.0}; - - bool preacc = SetPreaccInVars(); - - if (preacc) { - AD::SetPreaccIn(Normal, nDim); - AD::SetPreaccIn(V_i, nDim+5); AD::SetPreaccIn(V_j, nDim+5); - AD::SetPreaccIn(Lambda_i); AD::SetPreaccIn(Lambda_j); - if (dynamic_grid) { - AD::SetPreaccIn(GridVel_i, nDim); AD::SetPreaccIn(GridVel_j, nDim); - } - } - - /*--- Pressure, density, enthalpy, energy, and velocity at points i and j ---*/ - - Pressure_i = V_i[nDim+1]; Pressure_j = V_j[nDim+1]; - Density_i = V_i[nDim+2]; Density_j = V_j[nDim+2]; - Enthalpy_i = V_i[nDim+3]; Enthalpy_j = V_j[nDim+3]; - SoundSpeed_i = V_i[nDim+4]; SoundSpeed_j = V_j[nDim+4]; - Energy_i = Enthalpy_i - Pressure_i/Density_i; Energy_j = Enthalpy_j - Pressure_j/Density_j; - - sq_vel_i = 0.0; sq_vel_j = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = V_i[iDim+1]; - Velocity_j[iDim] = V_j[iDim+1]; - sq_vel_i += 0.5*Velocity_i[iDim]*Velocity_i[iDim]; - sq_vel_j += 0.5*Velocity_j[iDim]*Velocity_j[iDim]; - } - - /*--- Recompute conservative variables ---*/ - - U_i[0] = Density_i; U_j[0] = Density_j; - for (iDim = 0; iDim < nDim; iDim++) { - U_i[iDim+1] = Density_i*Velocity_i[iDim]; U_j[iDim+1] = Density_j*Velocity_j[iDim]; - } - U_i[nDim+1] = Density_i*Energy_i; U_j[nDim+1] = Density_j*Energy_j; - - /*--- Compute mean values of the variables ---*/ - - MeanDensity = 0.5*(Density_i+Density_j); - MeanPressure = 0.5*(Pressure_i+Pressure_j); - MeanEnthalpy = 0.5*(Enthalpy_i+Enthalpy_j); - for (iDim = 0; iDim < nDim; iDim++) - MeanVelocity[iDim] = 0.5*(Velocity_i[iDim]+Velocity_j[iDim]); - MeanEnergy = 0.5*(Energy_i+Energy_j); - - /*--- Get projected flux tensor ---*/ - - GetInviscidProjFlux(&MeanDensity, MeanVelocity, &MeanPressure, &MeanEnthalpy, Normal, ProjFlux); - - /*--- Residual of the inviscid flux ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_residual[iVar] = ProjFlux[iVar]; - - /*--- Jacobians of the inviscid flux, scale = 0.5 because val_residual ~ 0.5*(fc_i+fc_j)*Normal ---*/ - - if (implicit) { - GetInviscidProjJac(MeanVelocity, &MeanEnergy, Normal, 0.5, val_Jacobian_i); - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_j[iVar][jVar] = val_Jacobian_i[iVar][jVar]; - } - - /*--- Adjustment due to grid motion ---*/ - - if (dynamic_grid) { - ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] -= ProjGridVel * 0.5*(U_i[iVar] + U_j[iVar]); - if (implicit) { - val_Jacobian_i[iVar][iVar] -= 0.5*ProjGridVel; - val_Jacobian_j[iVar][iVar] -= 0.5*ProjGridVel; - } - } - } - - /*--- Compute the local spectral radius and the stretching factor ---*/ - - ProjVelocity_i = 0.0; ProjVelocity_j = 0.0; Area = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - ProjVelocity_i += Velocity_i[iDim]*Normal[iDim]; - ProjVelocity_j += Velocity_j[iDim]*Normal[iDim]; - Area += Normal[iDim]*Normal[iDim]; - } - Area = sqrt(Area); - - /*--- Adjustment due to mesh motion ---*/ - - if (dynamic_grid) { - ProjVelocity_i -= ProjGridVel; - ProjVelocity_j -= ProjGridVel; - } - - /*--- Dissipation term ---*/ - - Local_Lambda_i = (fabs(ProjVelocity_i)+SoundSpeed_i*Area); - Local_Lambda_j = (fabs(ProjVelocity_j)+SoundSpeed_j*Area); - MeanLambda = 0.5*(Local_Lambda_i+Local_Lambda_j); - - Phi_i = pow(Lambda_i/(4.0*MeanLambda), Param_p); - Phi_j = pow(Lambda_j/(4.0*MeanLambda), Param_p); - StretchingFactor = 4.0*Phi_i*Phi_j/(Phi_i+Phi_j); - - /*--- Compute differences btw. conservative variables, with a correction for enthalpy ---*/ - - for (iVar = 0; iVar < nVar-1; iVar++) { - Diff_U[iVar] = U_i[iVar]-U_j[iVar]; - } - Diff_U[nVar-1] = Density_i*Enthalpy_i-Density_j*Enthalpy_j; - - DissipationTerm(val_residual, val_Jacobian_i, val_Jacobian_j); - - if (preacc) { - AD::SetPreaccOut(val_residual, nVar); - AD::EndPreacc(); - } -} - -void CCentBase_Flow::ScalarDissipationJacobian(su2double **val_Jacobian_i, su2double **val_Jacobian_j) { - - /*--- n-1 diagonal entries ---*/ - - for (iVar = 0; iVar < (nVar-1); iVar++) { - val_Jacobian_i[iVar][iVar] += fix_factor*cte_0; - val_Jacobian_j[iVar][iVar] -= fix_factor*cte_1; - } - - /*--- Last row of Jacobian_i ---*/ - - val_Jacobian_i[nVar-1][0] += fix_factor*cte_0*Gamma_Minus_One*sq_vel_i; - for (iDim = 0; iDim < nDim; iDim++) - val_Jacobian_i[nVar-1][iDim+1] -= fix_factor*cte_0*Gamma_Minus_One*Velocity_i[iDim]; - val_Jacobian_i[nVar-1][nVar-1] += fix_factor*cte_0*Gamma; - - /*--- Last row of Jacobian_j ---*/ - - val_Jacobian_j[nVar-1][0] -= fix_factor*cte_1*Gamma_Minus_One*sq_vel_j; - for (iDim = 0; iDim < nDim; iDim++) - val_Jacobian_j[nVar-1][iDim+1] += fix_factor*cte_1*Gamma_Minus_One*Velocity_j[iDim]; - val_Jacobian_j[nVar-1][nVar-1] -= fix_factor*cte_1*Gamma; - -} diff --git a/SU2_CFD/src/numerics/flow/convection_centered/CCentJSTInc_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_centered/CCentJSTInc_Flow.cpp deleted file mode 100644 index cb1c9ca662af..000000000000 --- a/SU2_CFD/src/numerics/flow/convection_centered/CCentJSTInc_Flow.cpp +++ /dev/null @@ -1,241 +0,0 @@ -/*! - * \file CCentJSTInc_Flow.cpp - * \brief Implementation of numerics class CCentJSTInc_Flow. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../../include/numerics/flow/convection_centered/CCentJSTInc_Flow.hpp" - -CCentJSTInc_Flow::CCentJSTInc_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - variable_density = (config->GetKind_DensityModel() == VARIABLE); - energy = config->GetEnergy_Equation(); - /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ - dynamic_grid = config->GetDynamic_Grid(); - - /*--- Artifical dissipation part ---*/ - - Param_p = 0.3; - Param_Kappa_2 = config->GetKappa_2nd_Flow(); - Param_Kappa_4 = config->GetKappa_4th_Flow(); - - /*--- Allocate some structures ---*/ - - Diff_V = new su2double [nVar]; - Diff_Lapl = new su2double [nVar]; - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; - MeanVelocity = new su2double [nDim]; - ProjFlux = new su2double [nVar]; - Precon = new su2double*[nVar]; - - for (iVar = 0; iVar < nVar; iVar++) - Precon[iVar] = new su2double[nVar]; - -} - -CCentJSTInc_Flow::~CCentJSTInc_Flow(void) { - - delete [] Diff_V; - delete [] Diff_Lapl; - delete [] Velocity_i; - delete [] Velocity_j; - delete [] MeanVelocity; - delete [] ProjFlux; - - for (iVar = 0; iVar < nVar; iVar++) - delete [] Precon[iVar]; - delete [] Precon; - -} - -void CCentJSTInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - su2double U_i[5] = {0.0,0.0,0.0,0.0,0.0}, U_j[5] = {0.0,0.0,0.0,0.0,0.0}; - su2double ProjGridVel = 0.0; - - /*--- Primitive variables at point i and j ---*/ - - Pressure_i = V_i[0]; Pressure_j = V_j[0]; - Temperature_i = V_i[nDim+1]; Temperature_j = V_j[nDim+1]; - DensityInc_i = V_i[nDim+2]; DensityInc_j = V_j[nDim+2]; - BetaInc2_i = V_i[nDim+3]; BetaInc2_j = V_j[nDim+3]; - Cp_i = V_i[nDim+7]; Cp_j = V_j[nDim+7]; - Enthalpy_i = Cp_i*Temperature_i; Enthalpy_j = Cp_j*Temperature_j; - - Area = 0.0; - sq_vel_i = 0.0; sq_vel_j = 0.0; ProjVelocity_i = 0.0; ProjVelocity_j = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = V_i[iDim+1]; - Velocity_j[iDim] = V_j[iDim+1]; - MeanVelocity[iDim] = 0.5*(Velocity_i[iDim]+Velocity_j[iDim]); - sq_vel_i += 0.5*Velocity_i[iDim]*Velocity_i[iDim]; - sq_vel_j += 0.5*Velocity_j[iDim]*Velocity_j[iDim]; - ProjVelocity_i += Velocity_i[iDim]*Normal[iDim]; - ProjVelocity_j += Velocity_j[iDim]*Normal[iDim]; - Area += Normal[iDim]*Normal[iDim]; - } - Area = sqrt(Area); - - /*--- Compute mean values of the variables ---*/ - - MeanDensity = 0.5*(DensityInc_i + DensityInc_j); - MeanPressure = 0.5*(Pressure_i + Pressure_j); - MeanBetaInc2 = 0.5*(BetaInc2_i + BetaInc2_j); - MeanEnthalpy = 0.5*(Enthalpy_i + Enthalpy_j); - MeanCp = 0.5*(Cp_i + Cp_j); - MeanTemperature = 0.5*(Temperature_i + Temperature_j); - - /*--- We need the derivative of the equation of state to build the - preconditioning matrix. For now, the only option is the ideal gas - law, but in the future, dRhodT should be in the fluid model. ---*/ - - MeandRhodT = 0.0; - if (variable_density) { - MeandRhodT = -MeanDensity/MeanTemperature; - } - - /*--- Get projected flux tensor ---*/ - - GetInviscidIncProjFlux(&MeanDensity, MeanVelocity, &MeanPressure, &MeanBetaInc2, &MeanEnthalpy, Normal, ProjFlux); - - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] = ProjFlux[iVar]; - } - - /*--- Jacobians of the inviscid flux ---*/ - - if (implicit) { - GetInviscidIncProjJac(&MeanDensity, MeanVelocity, &MeanBetaInc2, &MeanCp, &MeanTemperature, &MeandRhodT, Normal, 0.5, val_Jacobian_i); - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - val_Jacobian_j[iVar][jVar] = val_Jacobian_i[iVar][jVar]; - } - } - } - - /*--- Corrections due to grid motion ---*/ - if (dynamic_grid) { - - /*--- Recompute conservative variables ---*/ - - U_i[0] = DensityInc_i; U_j[0] = DensityInc_j; - for (iDim = 0; iDim < nDim; iDim++) { - U_i[iDim+1] = DensityInc_i*Velocity_i[iDim]; U_j[iDim+1] = DensityInc_j*Velocity_j[iDim]; - } - U_i[nDim+1] = DensityInc_i*Enthalpy_i; U_j[nDim+1] = DensityInc_j*Enthalpy_j; - - su2double ProjVelocity = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjVelocity += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - - /*--- Residual contributions ---*/ - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] -= ProjVelocity * 0.5*(U_i[iVar]+U_j[iVar]); - - /*--- Jacobian contributions ---*/ - /*--- Implicit terms ---*/ - if (implicit) { - for (iDim = 0; iDim < nDim; iDim++){ - val_Jacobian_i[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_i; - val_Jacobian_j[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_j; - } - val_Jacobian_i[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_i*Cp_i; - val_Jacobian_j[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_j*Cp_j; - } - } - } - - /*--- Computes differences between Laplacians and conservative variables ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - Diff_Lapl[iVar] = Und_Lapl_i[iVar]-Und_Lapl_j[iVar]; - Diff_V[iVar] = V_i[iVar]-V_j[iVar]; - } - - /*--- Build the preconditioning matrix using mean values ---*/ - - GetPreconditioner(&MeanDensity, MeanVelocity, &MeanBetaInc2, &MeanCp, &MeanTemperature, &MeandRhodT, Precon); - - /*--- Compute the local spectral radius of the preconditioned system - and the stretching factor. ---*/ - - /*--- Projected velocity adjustment due to mesh motion ---*/ - - if (dynamic_grid) { - ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - } - ProjVelocity_i -= ProjGridVel; - ProjVelocity_j -= ProjGridVel; - } - - SoundSpeed_i = sqrt(BetaInc2_i*Area*Area); - SoundSpeed_j = sqrt(BetaInc2_j*Area*Area); - - Local_Lambda_i = fabs(ProjVelocity_i)+SoundSpeed_i; - Local_Lambda_j = fabs(ProjVelocity_j)+SoundSpeed_j; - - MeanLambda = 0.5*(Local_Lambda_i+Local_Lambda_j); - - Phi_i = pow(Lambda_i/(4.0*MeanLambda), Param_p); - Phi_j = pow(Lambda_j/(4.0*MeanLambda), Param_p); - - StretchingFactor = 4.0*Phi_i*Phi_j/(Phi_i+Phi_j); - - sc2 = 3.0*(su2double(Neighbor_i)+su2double(Neighbor_j))/(su2double(Neighbor_i)*su2double(Neighbor_j)); - sc4 = sc2*sc2/4.0; - - Epsilon_2 = Param_Kappa_2*0.5*(Sensor_i+Sensor_j)*sc2; - Epsilon_4 = max(0.0, Param_Kappa_4-Epsilon_2)*sc4; - - /*--- Compute viscous part of the residual ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - val_residual[iVar] += Precon[iVar][jVar]*(Epsilon_2*Diff_V[jVar] - Epsilon_4*Diff_Lapl[jVar])*StretchingFactor*MeanLambda; - if (implicit) { - val_Jacobian_i[iVar][jVar] += Precon[iVar][jVar]*(Epsilon_2 + Epsilon_4*su2double(Neighbor_i+1))*StretchingFactor*MeanLambda; - val_Jacobian_j[iVar][jVar] -= Precon[iVar][jVar]*(Epsilon_2 + Epsilon_4*su2double(Neighbor_j+1))*StretchingFactor*MeanLambda; - } - } - } - - /*--- Remove energy contributions if not solving the energy equation. ---*/ - - if (!energy) { - val_residual[nDim+1] = 0.0; - if (implicit) { - for (iVar = 0; iVar < nVar; iVar++) { - val_Jacobian_i[iVar][nDim+1] = 0.0; - val_Jacobian_j[iVar][nDim+1] = 0.0; - - val_Jacobian_i[nDim+1][iVar] = 0.0; - val_Jacobian_j[nDim+1][iVar] = 0.0; - } - } - } -} diff --git a/SU2_CFD/src/numerics/flow/convection_centered/CCentJST_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_centered/CCentJST_Flow.cpp deleted file mode 100644 index 8c4c908422ab..000000000000 --- a/SU2_CFD/src/numerics/flow/convection_centered/CCentJST_Flow.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/*! - * \file CCentJST_Flow.cpp - * \brief Implementation of numerics class CCentJST_Flow. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../../include/numerics/flow/convection_centered/CCentJST_Flow.hpp" - -CCentJST_Flow::CCentJST_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : - CCentBase_Flow(val_nDim, val_nVar, config) { - - /*--- Artifical dissipation parameters ---*/ - Param_p = 0.3; - Param_Kappa_2 = config->GetKappa_2nd_Flow(); - Param_Kappa_4 = config->GetKappa_4th_Flow(); - -} - -CCentJST_Flow::~CCentJST_Flow(void) { - -} - -void CCentJST_Flow::DissipationTerm(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j) { - - /*--- Compute differences btw. Laplacians ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - Diff_Lapl[iVar] = Und_Lapl_i[iVar]-Und_Lapl_j[iVar]; - } - - /*--- Compute dissipation coefficients ---*/ - - sc2 = 3.0*(su2double(Neighbor_i)+su2double(Neighbor_j))/(su2double(Neighbor_i)*su2double(Neighbor_j)); - sc4 = sc2*sc2/4.0; - - Epsilon_2 = Param_Kappa_2*0.5*(Sensor_i+Sensor_j)*sc2; - Epsilon_4 = max(0.0, Param_Kappa_4-Epsilon_2)*sc4; - - /*--- Compute viscous part of the residual ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_residual[iVar] += (Epsilon_2*Diff_U[iVar] - Epsilon_4*Diff_Lapl[iVar])*StretchingFactor*MeanLambda; - - /*--- Jacobian computation ---*/ - - if (implicit) { - - cte_0 = (Epsilon_2 + Epsilon_4*su2double(Neighbor_i+1))*StretchingFactor*MeanLambda; - cte_1 = (Epsilon_2 + Epsilon_4*su2double(Neighbor_j+1))*StretchingFactor*MeanLambda; - - ScalarDissipationJacobian(val_Jacobian_i, val_Jacobian_j); - } -} - -bool CCentJST_Flow::SetPreaccInVars(void) { - AD::StartPreacc(); - AD::SetPreaccIn(Sensor_i); AD::SetPreaccIn(Und_Lapl_i, nVar); - AD::SetPreaccIn(Sensor_j); AD::SetPreaccIn(Und_Lapl_j, nVar); - return true; -} diff --git a/SU2_CFD/src/numerics/flow/convection_centered/CCentJST_KE_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_centered/CCentJST_KE_Flow.cpp deleted file mode 100644 index 745169b95f33..000000000000 --- a/SU2_CFD/src/numerics/flow/convection_centered/CCentJST_KE_Flow.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/*! - * \file CCentJST_KE_Flow.cpp - * \brief Implementation of numerics class CCentJST_KE_Flow. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../../include/numerics/flow/convection_centered/CCentJST_KE_Flow.hpp" - -CCentJST_KE_Flow::CCentJST_KE_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : - CCentBase_Flow(val_nDim, val_nVar, config) { - - /*--- Artifical dissipation parameters ---*/ - Param_p = 0.3; - Param_Kappa_2 = config->GetKappa_2nd_Flow(); - -} - -CCentJST_KE_Flow::~CCentJST_KE_Flow(void) { - -} - -void CCentJST_KE_Flow::DissipationTerm(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j) { - - /*--- Compute dissipation coefficient ---*/ - - sc2 = 3.0*(su2double(Neighbor_i)+su2double(Neighbor_j))/(su2double(Neighbor_i)*su2double(Neighbor_j)); - Epsilon_2 = Param_Kappa_2*0.5*(Sensor_i+Sensor_j)*sc2; - - /*--- Compute viscous part of the residual ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_residual[iVar] += Epsilon_2*(Diff_U[iVar])*StretchingFactor*MeanLambda; - - /*--- Jacobian computation ---*/ - - if (implicit) { - - cte_0 = Epsilon_2*StretchingFactor*MeanLambda; - cte_1 = cte_0; - - ScalarDissipationJacobian(val_Jacobian_i, val_Jacobian_j); - } -} - -bool CCentJST_KE_Flow::SetPreaccInVars(void) { - AD::StartPreacc(); - AD::SetPreaccIn(Sensor_i); AD::SetPreaccIn(Sensor_j); - return true; -} diff --git a/SU2_CFD/src/numerics/flow/convection_centered/CCentLaxInc_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_centered/CCentLaxInc_Flow.cpp deleted file mode 100644 index a3bdafebb94f..000000000000 --- a/SU2_CFD/src/numerics/flow/convection_centered/CCentLaxInc_Flow.cpp +++ /dev/null @@ -1,234 +0,0 @@ -/*! - * \file CCentLaxInc_Flow.cpp - * \brief Implementation of numerics class CCentLaxInc_Flow. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../../include/numerics/flow/convection_centered/CCentLaxInc_Flow.hpp" - -CCentLaxInc_Flow::CCentLaxInc_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - variable_density = (config->GetKind_DensityModel() == VARIABLE); - /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ - dynamic_grid = config->GetDynamic_Grid(); - energy = config->GetEnergy_Equation(); - - /*--- Artificial dissipation part ---*/ - - Param_p = 0.3; - Param_Kappa_0 = config->GetKappa_1st_Flow(); - - /*--- Allocate some structures ---*/ - - Diff_V = new su2double[nVar]; - Velocity_i = new su2double[nDim]; - Velocity_j = new su2double[nDim]; - MeanVelocity = new su2double[nDim]; - ProjFlux = new su2double[nVar]; - Precon = new su2double*[nVar]; - - for (iVar = 0; iVar < nVar; iVar++) - Precon[iVar] = new su2double[nVar]; - -} - -CCentLaxInc_Flow::~CCentLaxInc_Flow(void) { - - delete [] Diff_V; - delete [] Velocity_i; - delete [] Velocity_j; - delete [] MeanVelocity; - delete [] ProjFlux; - - for (iVar = 0; iVar < nVar; iVar++) - delete [] Precon[iVar]; - delete [] Precon; - -} - -void CCentLaxInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - su2double U_i[5] = {0.0,0.0,0.0,0.0,0.0}, U_j[5] = {0.0,0.0,0.0,0.0,0.0}; - su2double ProjGridVel = 0.0, ProjVelocity = 0.0; - - /*--- Primitive variables at point i and j ---*/ - - Pressure_i = V_i[0]; Pressure_j = V_j[0]; - Temperature_i = V_i[nDim+1]; Temperature_j = V_j[nDim+1]; - DensityInc_i = V_i[nDim+2]; DensityInc_j = V_j[nDim+2]; - BetaInc2_i = V_i[nDim+3]; BetaInc2_j = V_j[nDim+3]; - Cp_i = V_i[nDim+7]; Cp_j = V_j[nDim+7]; - Enthalpy_i = Cp_i*Temperature_i; Enthalpy_j = Cp_j*Temperature_j; - - Area = 0.0; - sq_vel_i = 0.0; sq_vel_j = 0.0; ProjVelocity_i = 0.0; ProjVelocity_j = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = V_i[iDim+1]; - Velocity_j[iDim] = V_j[iDim+1]; - MeanVelocity[iDim] = 0.5*(Velocity_i[iDim]+Velocity_j[iDim]); - sq_vel_i += 0.5*Velocity_i[iDim]*Velocity_i[iDim]; - sq_vel_j += 0.5*Velocity_j[iDim]*Velocity_j[iDim]; - ProjVelocity_i += Velocity_i[iDim]*Normal[iDim]; - ProjVelocity_j += Velocity_j[iDim]*Normal[iDim]; - Area += Normal[iDim]*Normal[iDim]; - } - Area = sqrt(Area); - - /*--- Compute mean values of the variables ---*/ - - MeanDensity = 0.5*(DensityInc_i + DensityInc_j); - MeanPressure = 0.5*(Pressure_i + Pressure_j); - MeanBetaInc2 = 0.5*(BetaInc2_i + BetaInc2_j); - MeanEnthalpy = 0.5*(Enthalpy_i + Enthalpy_j); - MeanCp = 0.5*(Cp_i + Cp_j); - MeanTemperature = 0.5*(Temperature_i + Temperature_j); - - /*--- We need the derivative of the equation of state to build the - preconditioning matrix. For now, the only option is the ideal gas - law, but in the future, dRhodT should be in the fluid model. ---*/ - - MeandRhodT = 0.0; - if (variable_density) { - MeandRhodT = -MeanDensity/MeanTemperature; - } - - /*--- Get projected flux tensor ---*/ - - GetInviscidIncProjFlux(&MeanDensity, MeanVelocity, &MeanPressure, &MeanBetaInc2, &MeanEnthalpy, Normal, ProjFlux); - - /*--- Compute inviscid residual ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] = ProjFlux[iVar]; - } - - /*--- Jacobians of the inviscid flux ---*/ - - if (implicit) { - GetInviscidIncProjJac(&MeanDensity, MeanVelocity, &MeanBetaInc2, &MeanCp, &MeanTemperature, &MeandRhodT, Normal, 0.5, val_Jacobian_i); - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - val_Jacobian_j[iVar][jVar] = val_Jacobian_i[iVar][jVar]; - } - } - } - - /*--- Corrections due to grid motion ---*/ - if (dynamic_grid) { - - /*--- Recompute conservative variables ---*/ - - U_i[0] = DensityInc_i; U_j[0] = DensityInc_j; - for (iDim = 0; iDim < nDim; iDim++) { - U_i[iDim+1] = DensityInc_i*Velocity_i[iDim]; U_j[iDim+1] = DensityInc_j*Velocity_j[iDim]; - } - U_i[nDim+1] = DensityInc_i*Enthalpy_i; U_j[nDim+1] = DensityInc_j*Enthalpy_j; - - for (iDim = 0; iDim < nDim; iDim++) - ProjVelocity += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - - /*--- Residual contributions ---*/ - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] -= ProjVelocity * 0.5*(U_i[iVar]+U_j[iVar]); - - /*--- Jacobian contributions ---*/ - /*--- Implicit terms ---*/ - if (implicit) { - for (iDim = 0; iDim < nDim; iDim++){ - val_Jacobian_i[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_i; - val_Jacobian_j[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_j; - } - val_Jacobian_i[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_i*Cp_i; - val_Jacobian_j[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_j*Cp_j; - } - } - } - - /*--- Computes differences btw. conservative variables ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - Diff_V[iVar] = V_i[iVar]-V_j[iVar]; - - /*--- Build the preconditioning matrix using mean values ---*/ - - GetPreconditioner(&MeanDensity, MeanVelocity, &MeanBetaInc2, &MeanCp, &MeanTemperature, &MeandRhodT, Precon); - - /*--- Compute the local espectral radius of the preconditioned system - and the stretching factor. ---*/ - - SoundSpeed_i = sqrt(BetaInc2_i*Area*Area); - SoundSpeed_j = sqrt(BetaInc2_j*Area*Area); - - /*--- Projected velocity adjustment due to mesh motion ---*/ - - if (dynamic_grid) { - ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - } - ProjVelocity_i -= ProjGridVel; - ProjVelocity_j -= ProjGridVel; - } - - Local_Lambda_i = fabs(ProjVelocity_i)+SoundSpeed_i; - Local_Lambda_j = fabs(ProjVelocity_j)+SoundSpeed_j; - - MeanLambda = 0.5*(Local_Lambda_i+Local_Lambda_j); - - Phi_i = pow(Lambda_i/(4.0*MeanLambda), Param_p); - Phi_j = pow(Lambda_j/(4.0*MeanLambda), Param_p); - - StretchingFactor = 4.0*Phi_i*Phi_j/(Phi_i+Phi_j); - - sc0 = 3.0*(su2double(Neighbor_i)+su2double(Neighbor_j))/(su2double(Neighbor_i)*su2double(Neighbor_j)); - Epsilon_0 = Param_Kappa_0*sc0*su2double(nDim)/3.0; - - /*--- Compute viscous part of the residual ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - val_residual[iVar] += Precon[iVar][jVar]*Epsilon_0*Diff_V[jVar]*StretchingFactor*MeanLambda; - if (implicit) { - val_Jacobian_i[iVar][jVar] += Precon[iVar][jVar]*Epsilon_0*StretchingFactor*MeanLambda; - val_Jacobian_j[iVar][jVar] -= Precon[iVar][jVar]*Epsilon_0*StretchingFactor*MeanLambda; - } - } - } - - /*--- Remove energy contributions if we aren't solving the energy equation. ---*/ - - if (!energy) { - val_residual[nDim+1] = 0.0; - if (implicit) { - for (iVar = 0; iVar < nVar; iVar++) { - val_Jacobian_i[iVar][nDim+1] = 0.0; - val_Jacobian_j[iVar][nDim+1] = 0.0; - - val_Jacobian_i[nDim+1][iVar] = 0.0; - val_Jacobian_j[nDim+1][iVar] = 0.0; - } - } - } -} diff --git a/SU2_CFD/src/numerics/flow/convection_centered/CCentLax_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_centered/CCentLax_Flow.cpp deleted file mode 100644 index a2bc16c55e06..000000000000 --- a/SU2_CFD/src/numerics/flow/convection_centered/CCentLax_Flow.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/*! - * \file CCentLax_Flow.cpp - * \brief Implementation of numerics class CCentLax_Flow. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../../include/numerics/flow/convection_centered/CCentLax_Flow.hpp" - -CCentLax_Flow::CCentLax_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : - CCentBase_Flow(val_nDim, val_nVar, config) { - - /*--- Artifical dissipation parameters ---*/ - Param_p = 0.3; - Param_Kappa_0 = config->GetKappa_1st_Flow(); - -} - -CCentLax_Flow::~CCentLax_Flow(void) { - -} - -void CCentLax_Flow::DissipationTerm(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j) { - - /*--- Compute dissipation coefficient ---*/ - - sc0 = 3.0*(su2double(Neighbor_i)+su2double(Neighbor_j))/(su2double(Neighbor_i)*su2double(Neighbor_j)); - Epsilon_0 = Param_Kappa_0*sc0*su2double(nDim)/3.0; - - /*--- Compute viscous part of the residual ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_residual[iVar] += Epsilon_0*Diff_U[iVar]*StretchingFactor*MeanLambda; - - /*--- Jacobian computation ---*/ - - if (implicit) { - - cte_0 = Epsilon_0*StretchingFactor*MeanLambda; - cte_1 = cte_0; - - ScalarDissipationJacobian(val_Jacobian_i, val_Jacobian_j); - } -} - -bool CCentLax_Flow::SetPreaccInVars(void) { - AD::StartPreacc(); - return true; -} diff --git a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwAUSMPLUSUP2_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwAUSMPLUSUP2_Flow.cpp deleted file mode 100644 index c422a8f642cf..000000000000 --- a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwAUSMPLUSUP2_Flow.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/*! - * \file CUpwAUSMPLUSUP2_Flow.cpp - * \brief Implementation of numerics class CUpwAUSMPLUSUP2_Flow. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../../include/numerics/flow/convection_upwind/CUpwAUSMPLUSUP2_Flow.hpp" - -CUpwAUSMPLUSUP2_Flow::CUpwAUSMPLUSUP2_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : - CUpwAUSMPLUS_SLAU_Base_Flow(val_nDim, val_nVar, config) { - - 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) { - -} - -void CUpwAUSMPLUSUP2_Flow::ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure) { - - /*--- Projected velocities and squared magnitude ---*/ - - su2double ProjVelocity_i = 0.0, ProjVelocity_j = 0.0, sq_vel = 0.0; - - for (unsigned short iDim = 0; iDim < nDim; iDim++) { - ProjVelocity_i += Velocity_i[iDim]*UnitNormal[iDim]; - ProjVelocity_j += Velocity_j[iDim]*UnitNormal[iDim]; - - sq_vel += 0.5*(Velocity_i[iDim]*Velocity_i[iDim] + Velocity_j[iDim]*Velocity_j[iDim]); - } - - /*--- Compute interface speed of sound (aF) ---*/ - - su2double astarL = sqrt(2.0*(Gamma-1.0)/(Gamma+1.0)*Enthalpy_i); - su2double astarR = sqrt(2.0*(Gamma-1.0)/(Gamma+1.0)*Enthalpy_j); - - su2double ahatL = astarL*astarL/max(astarL, ProjVelocity_i); - su2double ahatR = astarR*astarR/max(astarR,-ProjVelocity_j); - - su2double aF = min(ahatL,ahatR); - - /*--- Left and right pressure functions and Mach numbers ---*/ - - su2double mLP, pLP, mRM, pRM; - - su2double mL = ProjVelocity_i/aF; - su2double mR = ProjVelocity_j/aF; - - su2double MFsq = 0.5*(mL*mL+mR*mR); - su2double param1 = max(MFsq, Minf*Minf); - su2double Mrefsq = min(1.0, param1); - - su2double fa = 2.0*sqrt(Mrefsq)-Mrefsq; - - su2double alpha = 3.0/16.0*(-4.0+5.0*fa*fa); - su2double beta = 1.0/8.0; - - if (fabs(mL) <= 1.0) { - su2double p1 = 0.25*(mL+1.0)*(mL+1.0); - su2double p2 = (mL*mL-1.0)*(mL*mL-1.0); - - mLP = p1 + beta*p2; - pLP = p1*(2.0-mL) + alpha*mL*p2; - } - else { - mLP = 0.5*(mL+fabs(mL)); - pLP = mLP/mL; - } - - if (fabs(mR) <= 1.0) { - su2double p1 = 0.25*(mR-1.0)*(mR-1.0); - su2double p2 = (mR*mR-1.0)*(mR*mR-1.0); - - mRM = -p1 - beta*p2; - pRM = p1*(2.0+mR) - alpha*mR*p2; - } - else { - mRM = 0.5*(mR-fabs(mR)); - pRM = mRM/mR; - } - - /*--- Mass flux with pressure diffusion term ---*/ - - su2double rhoF = 0.5*(Density_i+Density_j); - su2double Mp = -(Kp/fa)*max((1.0-sigma*MFsq),0.0)*(Pressure_j-Pressure_i)/(rhoF*aF*aF); - - su2double mF = mLP + mRM + Mp; - mdot = aF * (max(mF,0.0)*Density_i + min(mF,0.0)*Density_j); - - /*--- Modified pressure flux ---*/ - - pressure = 0.5*(Pressure_j+Pressure_i) + 0.5*(pLP-pRM)*(Pressure_i-Pressure_j) + sqrt(sq_vel)*(pLP+pRM-1.0)*rhoF*aF; - -} diff --git a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwAUSMPLUSUP_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwAUSMPLUSUP_Flow.cpp deleted file mode 100644 index 11f14140659e..000000000000 --- a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwAUSMPLUSUP_Flow.cpp +++ /dev/null @@ -1,258 +0,0 @@ -/*! - * \file CUpwAUSMPLUSUP_Flow.cpp - * \brief Implementation of numerics class CUpwAUSMPLUSUP_Flow. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../../include/numerics/flow/convection_upwind/CUpwAUSMPLUSUP_Flow.hpp" - -CUpwAUSMPLUSUP_Flow::CUpwAUSMPLUSUP_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : - CUpwAUSMPLUS_SLAU_Base_Flow(val_nDim, val_nVar, config) { - - HasAnalyticalDerivatives = true; - Minf = config->GetMach(); - 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) { - -} - -void CUpwAUSMPLUSUP_Flow::ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure) { - - /*--- Projected velocities ---*/ - - su2double ProjVelocity_i = 0.0, ProjVelocity_j = 0.0; - - for (unsigned short iDim = 0; iDim < nDim; iDim++) { - ProjVelocity_i += Velocity_i[iDim]*UnitNormal[iDim]; - ProjVelocity_j += Velocity_j[iDim]*UnitNormal[iDim]; - } - - /*--- Compute interface speed of sound (aF) ---*/ - - su2double astarL = sqrt(2.0*(Gamma-1.0)/(Gamma+1.0)*Enthalpy_i); - su2double astarR = sqrt(2.0*(Gamma-1.0)/(Gamma+1.0)*Enthalpy_j); - - su2double ahatL = astarL*astarL/max(astarL, ProjVelocity_i); - su2double ahatR = astarR*astarR/max(astarR,-ProjVelocity_j); - - su2double aF = min(ahatL,ahatR); - - /*--- Left and right pressures and Mach numbers ---*/ - - su2double mLP, betaLP, mRM, betaRM; - - su2double mL = ProjVelocity_i/aF; - su2double mR = ProjVelocity_j/aF; - - su2double MFsq = 0.5*(mL*mL+mR*mR); - su2double param1 = max(MFsq, Minf*Minf); - su2double Mrefsq = min(1.0, param1); - - su2double fa = 2.0*sqrt(Mrefsq)-Mrefsq; - - su2double alpha = 3.0/16.0*(-4.0+5.0*fa*fa); - su2double beta = 1.0/8.0; - - if (fabs(mL) <= 1.0) { - su2double p1 = 0.25*(mL+1.0)*(mL+1.0); - su2double p2 = (mL*mL-1.0)*(mL*mL-1.0); - - mLP = p1 + beta*p2; - betaLP = p1*(2.0-mL) + alpha*mL*p2; - } - else { - mLP = 0.5*(mL+fabs(mL)); - betaLP = mLP/mL; - } - - if (fabs(mR) <= 1.0) { - su2double p1 = 0.25*(mR-1.0)*(mR-1.0); - su2double p2 = (mR*mR-1.0)*(mR*mR-1.0); - - mRM = -p1 - beta*p2; - betaRM = p1*(2.0+mR) - alpha*mR*p2; - } - else { - mRM = 0.5*(mR-fabs(mR)); - betaRM = mRM/mR; - } - - /*--- Pressure and velocity diffusion terms ---*/ - - su2double rhoF = 0.5*(Density_i+Density_j); - su2double Mp = -(Kp/fa)*max((1.0-sigma*MFsq),0.0)*(Pressure_j-Pressure_i)/(rhoF*aF*aF); - - su2double Pu = -Ku*fa*betaLP*betaRM*2.0*rhoF*aF*(ProjVelocity_j-ProjVelocity_i); - - /*--- Finally the fluxes ---*/ - - su2double mF = mLP + mRM + Mp; - mdot = aF * (max(mF,0.0)*Density_i + min(mF,0.0)*Density_j); - - pressure = betaLP*Pressure_i + betaRM*Pressure_j + Pu; - - if (!implicit || !UseAccurateJacobian) return; - - /*--- Analytical differentiation of the face mass flux and - pressure (in reverse mode, "?_b" denotes dmot_d?). ---*/ - - /*--- limited mean Mach number (used in division...) ---*/ - su2double MF = max(numeric_limits::epsilon(),sqrt(MFsq)); - - for (int outVar=0; outVar<2; ++outVar) { - - su2double aF_b = 0.0, mF_b = 0.0, MF_b = 0.0, rhoF_b = 0.0, fa_b = 0.0, alpha_b = 0.0, - rho_i_b = 0.0, rho_j_b = 0.0, p_i_b = 0.0, p_j_b = 0.0, Vn_i_b = 0.0, Vn_j_b = 0.0, - mR_b = 0.0, mL_b = 0.0, betaLP_b = 0.0, betaRM_b = 0.0, tmp = 0.0; - - if (outVar==0) { - /*--- mdot = ... ---*/ - if (mF > 0.0) { - aF_b += mF*Density_i; - mF_b += aF*Density_i; - rho_i_b += mF*aF; - } - else { - aF_b += mF*Density_j; - mF_b += aF*Density_j; - rho_j_b += mF*aF; - } - - /*--- Mp = ... ---*/ - if (sigma*MFsq < 1.0) { - rhoF_b -= Mp/rhoF * mF_b; - fa_b -= Mp/fa * mF_b; - aF_b -= 2.0*Mp/aF * mF_b; - MF_b += 2.0*sigma*MF*(Kp/fa)*(Pressure_j-Pressure_i)/(rhoF*aF*aF) * mF_b; - tmp = -(Kp/fa)*(1.0-sigma*MFsq)/(rhoF*aF*aF); - p_i_b -= tmp * mF_b; - p_j_b += tmp * mF_b; - } - - /*--- rhoF = ... ---*/ - rho_i_b += 0.5*rhoF_b; rho_j_b += 0.5*rhoF_b; - - /*--- mRM = ... ---*/ - if (fabs(mR) < 1.0) mR_b += (1.0-mR)*(0.5+4.0*beta*mR*(mR+1.0)) * mF_b; - else if (mR <=-1.0) mR_b += mF_b; - - /*--- mLP = ... ---*/ - if (fabs(mL) < 1.0) mL_b += (1.0+mL)*(0.5+4.0*beta*mL*(mL-1.0)) * mF_b; - else if (mL >= 1.0) mL_b += mF_b; - } - else { - /*--- pressure = ... ---*/ - p_i_b += betaLP; betaLP_b += Pressure_i; - p_j_b += betaRM; betaRM_b += Pressure_j; - - /*--- Pu = ... ---*/ - rhoF_b += Pu/rhoF; - fa_b += Pu/fa; - aF_b += Pu/aF; - tmp = -Ku*fa*2.0*rhoF*aF*(ProjVelocity_j-ProjVelocity_i); - betaLP_b += tmp*betaRM; - betaRM_b += tmp*betaLP; - tmp = -Ku*fa*betaLP*betaRM*2.0*rhoF*aF; - Vn_i_b -= tmp; - Vn_j_b += tmp; - - /*--- rhoF = ... ---*/ - rho_i_b += 0.5*rhoF_b; rho_j_b += 0.5*rhoF_b; - - /*--- betaRM = ... ---*/ - if (fabs(mR) < 1.0) { - tmp = mR*mR-1.0; - mR_b += tmp*(0.75-alpha*(5.0*tmp+4.0)) * betaRM_b; - alpha_b -= mR*tmp*tmp * betaRM_b; - } - - /*--- betaLP = ... ---*/ - if (fabs(mL) < 1.0) { - tmp = mL*mL-1.0; - mL_b -= tmp*(0.75-alpha*(5.0*tmp+4.0)) * betaLP_b; - alpha_b += mL*tmp*tmp * betaLP_b; - } - - /*--- alpha = ... ---*/ - fa_b += 1.875*fa * alpha_b; - } - - /*--- steps shared by both ---*/ - /*--- fa = ... ---*/ - su2double Mref_b = 2.0*(1.0-sqrt(Mrefsq)) * fa_b; - - /*--- Mrefsq = ... ---*/ - if (MF < 1.0 && MF > Minf) MF_b += Mref_b; - - /*--- MFsq = ... ---*/ - mL_b += 0.5*mL/MF * MF_b; mR_b += 0.5*mR/MF * MF_b; - - /*--- mL/R = ... ---*/ - Vn_i_b += mL_b/aF; Vn_j_b += mR_b/aF; - aF_b -= (mL*mL_b+mR*mR_b)/aF; - - /*--- aF,ahat,astar = f(H_i,H_j) ---*/ - su2double astar_b = aF_b, H_i_b, H_j_b; - - if (ahatL < ahatR) { - if (astarL <= ProjVelocity_i) { - tmp = astarL/ProjVelocity_i; - astar_b *= 2.0*tmp; - Vn_i_b -= tmp*tmp * aF_b; - } - H_i_b = sqrt(0.5*(Gamma-1.0)/((Gamma+1.0)*Enthalpy_i)) * astar_b; - H_j_b = 0.0; - } - else { - if (astarR <= -ProjVelocity_j) { - tmp = -astarR/ProjVelocity_j; - astar_b *= 2.0*tmp; - Vn_j_b += tmp*tmp * aF_b; - } - H_j_b = sqrt(0.5*(Gamma-1.0)/((Gamma+1.0)*Enthalpy_j)) * astar_b; - H_i_b = 0.0; - } - - /*--- store derivatives ---*/ - su2double *target_i = (outVar==0 ? dmdot_dVi : dpres_dVi), - *target_j = (outVar==0 ? dmdot_dVj : dpres_dVj); - target_i[5] = target_j[5] = 0.0; - - /*--- ProjVelocity = ... ---*/ - for (unsigned short iDim = 0; iDim < nDim; ++iDim) { - target_i[iDim] = UnitNormal[iDim] * Vn_i_b; - target_j[iDim] = UnitNormal[iDim] * Vn_j_b; - } - target_i[ nDim ] = p_i_b; target_j[ nDim ] = p_j_b; - target_i[nDim+1] = rho_i_b; target_j[nDim+1] = rho_j_b; - target_i[nDim+2] = H_i_b; target_j[nDim+2] = H_j_b; - } -} diff --git a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwAUSMPLUS_SLAU_Base_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwAUSMPLUS_SLAU_Base_Flow.cpp deleted file mode 100644 index ed15245c8927..000000000000 --- a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwAUSMPLUS_SLAU_Base_Flow.cpp +++ /dev/null @@ -1,384 +0,0 @@ -/*! - * \file CUpwAUSMPLUS_SLAU_Base_Flow.cpp - * \brief Implementation of numerics class CUpwAUSMPLUS_SLAU_Base_Flow. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../../include/numerics/flow/convection_upwind/CUpwAUSMPLUS_SLAU_Base_Flow.hpp" - -CUpwAUSMPLUS_SLAU_Base_Flow::CUpwAUSMPLUS_SLAU_Base_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : - CNumerics(val_nDim, val_nVar, config) { - - if (config->GetDynamic_Grid() && (SU2_MPI::GetRank() == MASTER_NODE)) - cout << "WARNING: Grid velocities are NOT yet considered in AUSM-type schemes." << endl; - - implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - UseAccurateJacobian = config->GetUse_Accurate_Jacobians(); - HasAnalyticalDerivatives = false; - FinDiffStep = 1e-4; - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; - psi_i = new su2double [nVar]; - psi_j = new su2double [nVar]; - - RoeVelocity = new su2double [nDim]; - Lambda = new su2double [nVar]; - Epsilon = new su2double [nVar]; - P_Tensor = new su2double* [nVar]; - invP_Tensor = new su2double* [nVar]; - for (unsigned short iVar = 0; iVar < nVar; iVar++) { - P_Tensor[iVar] = new su2double [nVar]; - invP_Tensor[iVar] = new su2double [nVar]; - } -} - -CUpwAUSMPLUS_SLAU_Base_Flow::~CUpwAUSMPLUS_SLAU_Base_Flow(void) { - - delete [] Velocity_i; - delete [] Velocity_j; - delete [] psi_i; - delete [] psi_j; - - delete [] RoeVelocity; - delete [] Lambda; - delete [] Epsilon; - for (unsigned short iVar = 0; iVar < nVar; iVar++) { - delete [] P_Tensor[iVar]; - delete [] invP_Tensor[iVar]; - } - delete [] P_Tensor; - delete [] invP_Tensor; - -} - -void CUpwAUSMPLUS_SLAU_Base_Flow::ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure) -{ - /*--- For schemes that fit in the general form of AUSM+up and SLAU schemes you can inherit from this class - and implement only the specifics, which should be the face mass flux (per unit area) and the face pressure. - For implicit solution methods this class can either approximate the flux Jacobians (using those of the Roe - scheme) or compute accurate ones. This is done either numerically, differentiating "mdot" and "pressure" - using 1st order finite differences, or analytically if you use this function to set the values of - "dmdot_dVi/j", "dpres_dVi/j" and set "HasAnalyticalDerivatives" to true in the ctor of the derived class. - For accurate numerical differentiation "mdot" and "pressure" can be functions of, at most, the velocities, - pressures, densities, and enthalpies at nodes i/j. This is also the order expected for the partial derivatives - of "mdot" and "pressure" in "d?_dVi/j" (in case they are known analytically, see the AUSM+up implementation). - ---*/ -} - -void CUpwAUSMPLUS_SLAU_Base_Flow::ApproximateJacobian(su2double **val_Jacobian_i, su2double **val_Jacobian_j) { - - unsigned short iDim, iVar, jVar, kVar; - su2double R, RoeDensity, RoeEnthalpy, RoeSoundSpeed, ProjVelocity, sq_vel, Energy_i, Energy_j; - - Energy_i = Enthalpy_i - Pressure_i/Density_i; - Energy_j = Enthalpy_j - Pressure_j/Density_j; - - /*--- Mean Roe variables iPoint and jPoint ---*/ - - R = sqrt(fabs(Density_j/Density_i)); - RoeDensity = R*Density_i; - ProjVelocity = 0.0; - sq_vel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - RoeVelocity[iDim] = (R*Velocity_j[iDim]+Velocity_i[iDim])/(R+1); - ProjVelocity += RoeVelocity[iDim]*UnitNormal[iDim]; - sq_vel += RoeVelocity[iDim]*RoeVelocity[iDim]; - } - RoeEnthalpy = (R*Enthalpy_j+Enthalpy_i)/(R+1); - RoeSoundSpeed = sqrt(fabs((Gamma-1)*(RoeEnthalpy-0.5*sq_vel))); - - /*--- Compute P and Lambda (do it with the Normal) ---*/ - - GetPMatrix(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, P_Tensor); - - /*--- Flow eigenvalues and Entropy correctors ---*/ - - for (iDim = 0; iDim < nDim; iDim++) - Lambda[iDim] = ProjVelocity; - Lambda[nVar-2] = ProjVelocity + RoeSoundSpeed; - Lambda[nVar-1] = ProjVelocity - RoeSoundSpeed; - - /*--- Compute inverse P ---*/ - GetPMatrix_inv(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, invP_Tensor); - - /*--- Jacobians of the inviscid flux, scale = 0.5 because val_residual ~ 0.5*(fc_i+fc_j)*Normal ---*/ - GetInviscidProjJac(Velocity_i, &Energy_i, Normal, 0.5, val_Jacobian_i); - GetInviscidProjJac(Velocity_j, &Energy_j, Normal, 0.5, val_Jacobian_j); - - /*--- Roe's Flux approximation ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - su2double Proj_ModJac_Tensor_ij = 0.0; - /*--- Compute |Proj_ModJac_Tensor| = P x |Lambda| x inverse P ---*/ - for (kVar = 0; kVar < nVar; kVar++) - Proj_ModJac_Tensor_ij += P_Tensor[iVar][kVar]*fabs(Lambda[kVar])*invP_Tensor[kVar][jVar]; - val_Jacobian_i[iVar][jVar] += 0.5*Proj_ModJac_Tensor_ij*Area; - val_Jacobian_j[iVar][jVar] -= 0.5*Proj_ModJac_Tensor_ij*Area; - } - } - -} - -void CUpwAUSMPLUS_SLAU_Base_Flow::AccurateJacobian(CConfig *config, su2double **val_Jacobian_i, su2double **val_Jacobian_j) { - - /*--- Compute Jacobians using a mixed (numerical/analytical) formulation ---*/ - - unsigned short iDim, iVar, jVar; - - /*--- If not computed analytically, numerically differentiate the fluxes wrt primitives ---*/ - - if (!HasAnalyticalDerivatives) { - - /*--- Create arrays of pointers to the primitive variables so - we can loop through and perturb them in a general way. ---*/ - - su2double *primitives_i[6], *primitives_j[6]; - - for (iDim = 0; iDim < nDim; ++iDim) { - primitives_i[iDim] = &Velocity_i[iDim]; - primitives_j[iDim] = &Velocity_j[iDim]; - } - primitives_i[ nDim ] = &Pressure_i; primitives_j[ nDim ] = &Pressure_j; - primitives_i[nDim+1] = &Density_i; primitives_j[nDim+1] = &Density_j; - primitives_i[nDim+2] = &Enthalpy_i; primitives_j[nDim+2] = &Enthalpy_j; - - /*--- Initialize the gradient arrays with the negative of the quantity, - then for forward finite differences we add to it and divide. ---*/ - - for (iVar = 0; iVar < 6; ++iVar) { - dmdot_dVi[iVar] = -MassFlux; dpres_dVi[iVar] = -Pressure; - dmdot_dVj[iVar] = -MassFlux; dpres_dVj[iVar] = -Pressure; - } - - for (iVar = 0; iVar < nDim+3; ++iVar) { - /*--- Perturb side i ---*/ - su2double epsilon = FinDiffStep * max(1.0, fabs(*primitives_i[iVar])); - *primitives_i[iVar] += epsilon; - ComputeMassAndPressureFluxes(config, MassFlux, Pressure); - dmdot_dVi[iVar] += MassFlux; dpres_dVi[iVar] += Pressure; - dmdot_dVi[iVar] /= epsilon; dpres_dVi[iVar] /= epsilon; - *primitives_i[iVar] -= epsilon; - - /*--- Perturb side j ---*/ - epsilon = FinDiffStep * max(1.0, fabs(*primitives_j[iVar])); - *primitives_j[iVar] += epsilon; - ComputeMassAndPressureFluxes(config, MassFlux, Pressure); - dmdot_dVj[iVar] += MassFlux; dpres_dVj[iVar] += Pressure; - dmdot_dVj[iVar] /= epsilon; dpres_dVj[iVar] /= epsilon; - *primitives_j[iVar] -= epsilon; - } - } - - /*--- Differentiation of fluxes wrt conservatives assuming ideal gas ---*/ - - su2double dmdot_dUi[5], dmdot_dUj[5], dpres_dUi[5], dpres_dUj[5]; - su2double sq_veli = 0.0, sq_velj = 0.0, dHi_drhoi = 0.0, dHj_drhoj = 0.0; - su2double oneOnRhoi = 1.0/Density_i, oneOnRhoj = 1.0/Density_j; - - for (jVar = 0; jVar < nVar; ++jVar) { - - /*--- Partial derivatives of the primitives wrt conservative "jVar" ---*/ - su2double dVi_dUi[6] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; - su2double dVj_dUj[6] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; - - if (jVar == 0) { // Density - for (iDim = 0; iDim < nDim; ++iDim) { - // -u,v,w / rho - dVi_dUi[iDim] = -Velocity_i[iDim] * oneOnRhoi; - dVj_dUj[iDim] = -Velocity_j[iDim] * oneOnRhoj; - // ||V||^2 - sq_veli += Velocity_i[iDim] * Velocity_i[iDim]; - sq_velj += Velocity_j[iDim] * Velocity_j[iDim]; - } - dVi_dUi[nDim] = 0.5*Gamma_Minus_One*sq_veli; - dVj_dUj[nDim] = 0.5*Gamma_Minus_One*sq_velj; - - dVi_dUi[nDim+1] = dVj_dUj[nDim+1] = 1.0; - - dHi_drhoi = 0.5*(Gamma-2.0)*sq_veli - Gamma*Pressure_i/((Gamma-1.0)*Density_i); - dHj_drhoj = 0.5*(Gamma-2.0)*sq_velj - Gamma*Pressure_j/((Gamma-1.0)*Density_j); - dVi_dUi[nDim+2] = dHi_drhoi * oneOnRhoi; - dVj_dUj[nDim+2] = dHj_drhoj * oneOnRhoj; - } - else if (jVar == nVar-1) { // rho*Energy - dVi_dUi[nDim] = dVj_dUj[nDim] = Gamma_Minus_One; - dVi_dUi[nDim+2] = Gamma * oneOnRhoi; - dVj_dUj[nDim+2] = Gamma * oneOnRhoj; - } - else { // Momentum - dVi_dUi[jVar-1] = oneOnRhoi; - dVj_dUj[jVar-1] = oneOnRhoj; - - dVi_dUi[nDim] = -Gamma_Minus_One*Velocity_i[jVar-1]; - dVj_dUj[nDim] = -Gamma_Minus_One*Velocity_j[jVar-1]; - - dVi_dUi[nDim+2] = dVi_dUi[nDim] * oneOnRhoi; - dVj_dUj[nDim+2] = dVj_dUj[nDim] * oneOnRhoj; - } - - /*--- Dot product to complete chain rule ---*/ - dmdot_dUi[jVar] = 0.0; dpres_dUi[jVar] = 0.0; - dmdot_dUj[jVar] = 0.0; dpres_dUj[jVar] = 0.0; - for (iVar = 0; iVar < 6; ++iVar) { - dmdot_dUi[jVar] += dmdot_dVi[iVar]*dVi_dUi[iVar]; - dpres_dUi[jVar] += dpres_dVi[iVar]*dVi_dUi[iVar]; - dmdot_dUj[jVar] += dmdot_dVj[iVar]*dVj_dUj[iVar]; - dpres_dUj[jVar] += dpres_dVj[iVar]*dVj_dUj[iVar]; - } - } - - /*--- Assemble final Jacobians (assuming phi = |mdot|) ---*/ - - su2double mdot_hat, psi_hat[5]; - - if (MassFlux > 0.0) { - mdot_hat = Area*MassFlux*oneOnRhoi; - for (iVar = 0; iVar < nVar; ++iVar) psi_hat[iVar] = Area*psi_i[iVar]; - } - else { - mdot_hat = Area*MassFlux*oneOnRhoj; - for (iVar = 0; iVar < nVar; ++iVar) psi_hat[iVar] = Area*psi_j[iVar]; - } - - /*--- Contribution from the mass flux derivatives ---*/ - for (iVar = 0; iVar < nVar; ++iVar) { - for (jVar = 0; jVar < nVar; ++jVar) { - val_Jacobian_i[iVar][jVar] = psi_hat[iVar] * dmdot_dUi[jVar]; - val_Jacobian_j[iVar][jVar] = psi_hat[iVar] * dmdot_dUj[jVar]; - } - } - - /*--- Contribution from the pressure derivatives ---*/ - for (iDim = 0; iDim < nDim; ++iDim) { - for (jVar = 0; jVar < nVar; ++jVar) { - val_Jacobian_i[iDim+1][jVar] += Normal[iDim] * dpres_dUi[jVar]; - val_Jacobian_j[iDim+1][jVar] += Normal[iDim] * dpres_dUj[jVar]; - } - } - - /*--- Contributions from the derivatives of PSI wrt the conservatives ---*/ - if (MassFlux > 0.0) { - /*--- Velocity terms ---*/ - for (iDim = 0; iDim < nDim; ++iDim) { - val_Jacobian_i[iDim+1][0] -= mdot_hat*Velocity_i[iDim]; - val_Jacobian_i[iDim+1][iDim+1] += mdot_hat; - val_Jacobian_i[nVar-1][iDim+1] -= mdot_hat*Gamma_Minus_One*Velocity_i[iDim]; - } - /*--- Energy terms ---*/ - val_Jacobian_i[nVar-1][0] += mdot_hat*dHi_drhoi; - val_Jacobian_i[nVar-1][nVar-1] += mdot_hat*Gamma; - } - else { - /*--- Velocity terms ---*/ - for (iDim = 0; iDim < nDim; ++iDim) { - val_Jacobian_j[iDim+1][0] -= mdot_hat*Velocity_j[iDim]; - val_Jacobian_j[iDim+1][iDim+1] += mdot_hat; - val_Jacobian_j[nVar-1][iDim+1] -= mdot_hat*Gamma_Minus_One*Velocity_j[iDim]; - } - /*--- Energy terms ---*/ - val_Jacobian_j[nVar-1][0] += mdot_hat*dHj_drhoj; - val_Jacobian_j[nVar-1][nVar-1] += mdot_hat*Gamma; - } - -} - -void CUpwAUSMPLUS_SLAU_Base_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - unsigned short iDim, iVar; - - /*--- Space to start preaccumulation ---*/ - - AD::StartPreacc(); - AD::SetPreaccIn(Normal, nDim); - AD::SetPreaccIn(V_i, nDim+4); - AD::SetPreaccIn(V_j, nDim+4); - - /*--- Variables for the general form and primitives for mass flux and pressure calculation. ---*/ - /*--- F_{1/2} = ||A|| ( 0.5 * mdot * (psi_i+psi_j) - 0.5 * |mdot| * (psi_i-psi_j) + N * pf ) ---*/ - - psi_i[0] = 1.0; psi_j[0] = 1.0; - - for (iDim = 0; iDim < nDim; iDim++) { - /*--- Velocities ---*/ - Velocity_i[iDim] = psi_i[iDim+1] = V_i[iDim+1]; - Velocity_j[iDim] = psi_j[iDim+1] = V_j[iDim+1]; - } - - /*--- Pressure and Density ---*/ - Pressure_i = V_i[nDim+1]; Pressure_j = V_j[nDim+1]; - Density_i = V_i[nDim+2]; Density_j = V_j[nDim+2]; - - /*--- Enthalpy ---*/ - Enthalpy_i = psi_i[nVar-1] = V_i[nDim+3]; - Enthalpy_j = psi_j[nVar-1] = V_j[nDim+3]; - - /*--- Face area (norm or the normal vector) ---*/ - - Area = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - Area += Normal[iDim]*Normal[iDim]; - Area = sqrt(Area); - - /*-- Unit Normal ---*/ - for (iDim = 0; iDim < nDim; iDim++) - UnitNormal[iDim] = Normal[iDim]/Area; - - /*--- Mass and pressure fluxes defined by derived classes ---*/ - - ComputeMassAndPressureFluxes(config, MassFlux, Pressure); - DissFlux = fabs(MassFlux); - - val_residual[0] = MassFlux; - - for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = 0.5*MassFlux*(psi_i[iDim+1]+psi_j[iDim+1]) + - 0.5*DissFlux*(psi_i[iDim+1]-psi_j[iDim+1]) + - UnitNormal[iDim]*Pressure; - - val_residual[nVar-1] = 0.5*MassFlux*(psi_i[nVar-1]+psi_j[nVar-1]) + - 0.5*DissFlux*(psi_i[nVar-1]-psi_j[nVar-1]); - - for (iVar = 0; iVar < nVar; iVar++) val_residual[iVar] *= Area; - - /*--- Space to end preaccumulation ---*/ - - AD::SetPreaccOut(val_residual, nVar); - AD::EndPreacc(); - - /*--- If required, compute Jacobians, either approximately (Roe) or numerically ---*/ - - if (!implicit) return; - - if (UseAccurateJacobian) - AccurateJacobian(config, val_Jacobian_i, val_Jacobian_j); - else - ApproximateJacobian(val_Jacobian_i, val_Jacobian_j); - -} - diff --git a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwAUSM_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwAUSM_Flow.cpp deleted file mode 100644 index 53b01072a13f..000000000000 --- a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwAUSM_Flow.cpp +++ /dev/null @@ -1,208 +0,0 @@ -/*! - * \file CUpwAUSM_Flow.cpp - * \brief Implementation of numerics class CUpwAUSM_Flow. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../../include/numerics/flow/convection_upwind/CUpwAUSM_Flow.hpp" - -CUpwAUSM_Flow::CUpwAUSM_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - if (config->GetDynamic_Grid() && (SU2_MPI::GetRank() == MASTER_NODE)) - cout << "WARNING: Grid velocities are NOT yet considered in AUSM-type schemes." << endl; - - implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - Diff_U = new su2double [nVar]; - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; - RoeVelocity = new su2double [nDim]; - delta_vel = new su2double [nDim]; - delta_wave = new su2double [nVar]; - ProjFlux_i = new su2double [nVar]; - ProjFlux_j = new su2double [nVar]; - Lambda = new su2double [nVar]; - Epsilon = new su2double [nVar]; - P_Tensor = new su2double* [nVar]; - invP_Tensor = new su2double* [nVar]; - for (iVar = 0; iVar < nVar; iVar++) { - P_Tensor[iVar] = new su2double [nVar]; - invP_Tensor[iVar] = new su2double [nVar]; - } -} - -CUpwAUSM_Flow::~CUpwAUSM_Flow(void) { - - delete [] Diff_U; - delete [] Velocity_i; - delete [] Velocity_j; - delete [] RoeVelocity; - delete [] delta_vel; - delete [] delta_wave; - delete [] ProjFlux_i; - delete [] ProjFlux_j; - delete [] Lambda; - delete [] Epsilon; - for (iVar = 0; iVar < nVar; iVar++) { - delete [] P_Tensor[iVar]; - delete [] invP_Tensor[iVar]; - } - delete [] P_Tensor; - delete [] invP_Tensor; - -} - -void CUpwAUSM_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - AD::StartPreacc(); - AD::SetPreaccIn(Normal, nDim); - AD::SetPreaccIn(V_i, nDim+4); - AD::SetPreaccIn(V_j, nDim+4); - - /*--- Face area (norm or the normal vector) ---*/ - Area = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - Area += Normal[iDim]*Normal[iDim]; - Area = sqrt(Area); - - /*-- Unit Normal ---*/ - for (iDim = 0; iDim < nDim; iDim++) - UnitNormal[iDim] = Normal[iDim]/Area; - - /*--- Primitive variables at point i ---*/ - sq_vel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = V_i[iDim+1]; - sq_vel += Velocity_i[iDim]*Velocity_i[iDim]; - } - Pressure_i = V_i[nDim+1]; - Density_i = V_i[nDim+2]; - Enthalpy_i = V_i[nDim+3]; - Energy_i = Enthalpy_i - Pressure_i/Density_i; - SoundSpeed_i = sqrt(fabs(Gamma*Gamma_Minus_One*(Energy_i-0.5*sq_vel))); - - /*--- Primitive variables at point j ---*/ - sq_vel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_j[iDim] = V_j[iDim+1]; - sq_vel += Velocity_j[iDim]*Velocity_j[iDim]; - } - Pressure_j = V_j[nDim+1]; - Density_j = V_j[nDim+2]; - Enthalpy_j = V_j[nDim+3]; - Energy_j = Enthalpy_j - Pressure_j/Density_j; - SoundSpeed_j = sqrt(fabs(Gamma*Gamma_Minus_One*(Energy_j-0.5*sq_vel))); - - /*--- Projected velocities ---*/ - ProjVelocity_i = 0.0; ProjVelocity_j = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - ProjVelocity_i += Velocity_i[iDim]*UnitNormal[iDim]; - ProjVelocity_j += Velocity_j[iDim]*UnitNormal[iDim]; - } - - mL = ProjVelocity_i/SoundSpeed_i; - mR = ProjVelocity_j/SoundSpeed_j; - - if (fabs(mL) <= 1.0) mLP = 0.25*(mL+1.0)*(mL+1.0); - else mLP = 0.5*(mL+fabs(mL)); - - if (fabs(mR) <= 1.0) mRM = -0.25*(mR-1.0)*(mR-1.0); - else mRM = 0.5*(mR-fabs(mR)); - - mF = mLP + mRM; - - if (fabs(mL) <= 1.0) pLP = 0.25*Pressure_i*(mL+1.0)*(mL+1.0)*(2.0-mL); - else pLP = 0.5*Pressure_i*(mL+fabs(mL))/mL; - - if (fabs(mR) <= 1.0) pRM = 0.25*Pressure_j*(mR-1.0)*(mR-1.0)*(2.0+mR); - else pRM = 0.5*Pressure_j*(mR-fabs(mR))/mR; - - pF = pLP + pRM; - Phi = fabs(mF); - - val_residual[0] = 0.5*(mF*((Density_i*SoundSpeed_i)+(Density_j*SoundSpeed_j))-Phi*((Density_j*SoundSpeed_j)-(Density_i*SoundSpeed_i))); - for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = 0.5*(mF*((Density_i*SoundSpeed_i*Velocity_i[iDim])+(Density_j*SoundSpeed_j*Velocity_j[iDim])) - -Phi*((Density_j*SoundSpeed_j*Velocity_j[iDim])-(Density_i*SoundSpeed_i*Velocity_i[iDim])))+UnitNormal[iDim]*pF; - val_residual[nVar-1] = 0.5*(mF*((Density_i*SoundSpeed_i*Enthalpy_i)+(Density_j*SoundSpeed_j*Enthalpy_j))-Phi*((Density_j*SoundSpeed_j*Enthalpy_j)-(Density_i*SoundSpeed_i*Enthalpy_i))); - - for (iVar = 0; iVar < nVar; iVar++) - val_residual[iVar] *= Area; - - AD::SetPreaccOut(val_residual, nVar); - AD::EndPreacc(); - - /*--- Roe's Jacobian for AUSM (this must be fixed) ---*/ - if (implicit) { - - /*--- Mean Roe variables iPoint and jPoint ---*/ - R = sqrt(fabs(Density_j/Density_i)); - RoeDensity = R*Density_i; - sq_vel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - RoeVelocity[iDim] = (R*Velocity_j[iDim]+Velocity_i[iDim])/(R+1); - sq_vel += RoeVelocity[iDim]*RoeVelocity[iDim]; - } - RoeEnthalpy = (R*Enthalpy_j+Enthalpy_i)/(R+1); - RoeSoundSpeed = sqrt(fabs((Gamma-1)*(RoeEnthalpy-0.5*sq_vel))); - - /*--- Compute P and Lambda (do it with the Normal) ---*/ - GetPMatrix(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, P_Tensor); - - ProjVelocity = 0.0; ProjVelocity_i = 0.0; ProjVelocity_j = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - ProjVelocity += RoeVelocity[iDim]*UnitNormal[iDim]; - ProjVelocity_i += Velocity_i[iDim]*UnitNormal[iDim]; - ProjVelocity_j += Velocity_j[iDim]*UnitNormal[iDim]; - } - - /*--- Flow eigenvalues and Entropy correctors ---*/ - for (iDim = 0; iDim < nDim; iDim++) - Lambda[iDim] = ProjVelocity; - Lambda[nVar-2] = ProjVelocity + RoeSoundSpeed; - Lambda[nVar-1] = ProjVelocity - RoeSoundSpeed; - - /*--- Compute inverse P ---*/ - GetPMatrix_inv(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, invP_Tensor); - - /*--- Jacobias of the inviscid flux, scale = 0.5 because val_residual ~ 0.5*(fc_i+fc_j)*Normal ---*/ - GetInviscidProjJac(Velocity_i, &Energy_i, Normal, 0.5, val_Jacobian_i); - GetInviscidProjJac(Velocity_j, &Energy_j, Normal, 0.5, val_Jacobian_j); - - /*--- Roe's Flux approximation ---*/ - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - Proj_ModJac_Tensor_ij = 0.0; - /*--- Compute |Proj_ModJac_Tensor| = P x |Lambda| x inverse P ---*/ - for (kVar = 0; kVar < nVar; kVar++) - Proj_ModJac_Tensor_ij += P_Tensor[iVar][kVar]*fabs(Lambda[kVar])*invP_Tensor[kVar][jVar]; - val_Jacobian_i[iVar][jVar] += 0.5*Proj_ModJac_Tensor_ij*Area; - val_Jacobian_j[iVar][jVar] -= 0.5*Proj_ModJac_Tensor_ij*Area; - } - } - } -} diff --git a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwGeneralHLLC_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwGeneralHLLC_Flow.cpp deleted file mode 100644 index c57b4f599e20..000000000000 --- a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwGeneralHLLC_Flow.cpp +++ /dev/null @@ -1,593 +0,0 @@ -/*! - * \file CUpwGeneralHLLC_Flow.cpp - * \brief Implementation of numerics class CUpwGeneralHLLC_Flow. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../../include/numerics/flow/convection_upwind/CUpwGeneralHLLC_Flow.hpp" - -CUpwGeneralHLLC_Flow::CUpwGeneralHLLC_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - kappa = config->GetRoe_Kappa(); - /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ - dynamic_grid = config->GetDynamic_Grid(); - - Gamma = config->GetGamma(); - - IntermediateState = new su2double [nVar]; - dSm_dU = new su2double [nVar]; - dPI_dU = new su2double [nVar]; - drhoStar_dU = new su2double [nVar]; - dpStar_dU = new su2double [nVar]; - dEStar_dU = new su2double [nVar]; - - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; - RoeVelocity = new su2double [nDim]; - -} - -CUpwGeneralHLLC_Flow::~CUpwGeneralHLLC_Flow(void) { - - delete [] IntermediateState; - delete [] dSm_dU; - delete [] dPI_dU; - delete [] drhoStar_dU; - delete [] dpStar_dU; - delete [] dEStar_dU; - - delete [] Velocity_i; - delete [] Velocity_j; - delete [] RoeVelocity; - -} - -void CUpwGeneralHLLC_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - /*--- Face area (norm or the normal vector) ---*/ - - Area = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - Area += Normal[iDim] * Normal[iDim]; - - Area = sqrt(Area); - - /*-- Unit Normal ---*/ - - for (iDim = 0; iDim < nDim; iDim++) - UnitNormal[iDim] = Normal[iDim] / Area; - - /*-- Fluid velocity at node i,j ---*/ - - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = V_i[iDim+1]; - Velocity_j[iDim] = V_j[iDim+1]; - } - - /*--- Primitive variables at point i ---*/ - - Pressure_i = V_i[nDim+1]; - Density_i = V_i[nDim+2]; - Enthalpy_i = V_i[nDim+3]; - - /*--- Primitive variables at point j ---*/ - - Pressure_j = V_j[nDim+1]; - Density_j = V_j[nDim+2]; - Enthalpy_j = V_j[nDim+3]; - - - sq_vel_i = 0.0; - sq_vel_j = 0.0; - - for (iDim = 0; iDim < nDim; iDim++) { - sq_vel_i += Velocity_i[iDim] * Velocity_i[iDim]; - sq_vel_j += Velocity_j[iDim] * Velocity_j[iDim]; - } - - Energy_i = Enthalpy_i - Pressure_i / Density_i; - StaticEnthalpy_i = Enthalpy_i - 0.5 * sq_vel_i; - StaticEnergy_i = Energy_i - 0.5 * sq_vel_i; - - Kappa_i = S_i[1] / Density_i; - Chi_i = S_i[0] - Kappa_i * StaticEnergy_i; - SoundSpeed_i = sqrt(Chi_i + StaticEnthalpy_i * Kappa_i); - - - Energy_j = Enthalpy_j - Pressure_j / Density_j; - StaticEnthalpy_j = Enthalpy_j - 0.5 * sq_vel_j; - StaticEnergy_j = Energy_j - 0.5 * sq_vel_j; - - Kappa_j = S_j[1] / Density_j; - Chi_j = S_j[0] - Kappa_j * StaticEnergy_j; - SoundSpeed_j = sqrt(Chi_j + StaticEnthalpy_j * Kappa_j); - - /*--- Projected velocities ---*/ - - ProjVelocity_i = 0.0; - ProjVelocity_j = 0.0; - - for (iDim = 0; iDim < nDim; iDim++) { - ProjVelocity_i += Velocity_i[iDim] * UnitNormal[iDim]; - ProjVelocity_j += Velocity_j[iDim] * UnitNormal[iDim]; - } - - - /*--- Projected Grid Velocity ---*/ - - ProjInterfaceVel = 0; - - if (dynamic_grid) { - - for (iDim = 0; iDim < nDim; iDim++) - ProjInterfaceVel += 0.5 * ( GridVel_i[iDim] + GridVel_j[iDim] )*UnitNormal[iDim]; - - SoundSpeed_i -= ProjInterfaceVel; - SoundSpeed_j += ProjInterfaceVel; - - ProjVelocity_i -= ProjInterfaceVel; - ProjVelocity_j -= ProjInterfaceVel; - } - - /*--- Roe's averaging ---*/ - - Rrho = ( sqrt(Density_i) + sqrt(Density_j) ); - - sq_velRoe = 0.0; - RoeProjVelocity = - ProjInterfaceVel; - - for (iDim = 0; iDim < nDim; iDim++) { - RoeVelocity[iDim] = ( Velocity_i[iDim] * sqrt(Density_i) + Velocity_j[iDim] * sqrt(Density_j) ) / Rrho; - sq_velRoe += RoeVelocity[iDim] * RoeVelocity[iDim]; - RoeProjVelocity += RoeVelocity[iDim] * UnitNormal[iDim]; - } - - /*--- Mean Roe variables iPoint and jPoint ---*/ - - RoeKappa = 0.5 * ( Kappa_i + Kappa_j ); - RoeChi = 0.5 * ( Chi_i + Chi_j ); - RoeDensity = sqrt( Density_i * Density_j ); - RoeEnthalpy = ( sqrt(Density_j) * Enthalpy_j + sqrt(Density_i) * Enthalpy_i) / Rrho; - - VinokurMontagne(); - - /*--- Roe-averaged speed of sound ---*/ - - //RoeSoundSpeed2 = RoeChi + RoeKappa * ( RoeEnthalpy - 0.5 * sq_velRoe ); - RoeSoundSpeed = sqrt( RoeChi + RoeKappa * ( RoeEnthalpy - 0.5 * sq_velRoe ) ) - ProjInterfaceVel; - - /*--- Speed of sound at L and R ---*/ - - sL = min( RoeProjVelocity - RoeSoundSpeed, ProjVelocity_i - SoundSpeed_i ); - sR = max( RoeProjVelocity + RoeSoundSpeed, ProjVelocity_j + SoundSpeed_j ); - - /*--- speed of contact surface ---*/ - - RHO = Density_j * (sR - ProjVelocity_j) - Density_i * (sL - ProjVelocity_i); - sM = ( Pressure_i - Pressure_j - Density_i * ProjVelocity_i * ( sL - ProjVelocity_i ) + Density_j * ProjVelocity_j * ( sR - ProjVelocity_j ) ) / RHO; - - /*--- Pressure at right and left (Pressure_j=Pressure_i) side of contact surface ---*/ - - pStar = Density_j * ( ProjVelocity_j - sR ) * ( ProjVelocity_j - sM ) + Pressure_j; - - -if (sM > 0.0) { - - if (sL > 0.0) { - - /*--- Compute Left Flux ---*/ - - val_residual[0] = Density_i * ProjVelocity_i; - for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = Density_i * Velocity_i[iDim] * ProjVelocity_i + Pressure_i * UnitNormal[iDim]; - val_residual[nVar-1] = Enthalpy_i * Density_i * ProjVelocity_i; - } - else { - - /*--- Compute Flux Left Star from Left Star State ---*/ - - rhoSL = ( sL - ProjVelocity_i ) / ( sL - sM ); - - IntermediateState[0] = rhoSL * Density_i; - for (iDim = 0; iDim < nDim; iDim++) - IntermediateState[iDim+1] = rhoSL * ( Density_i * Velocity_i[iDim] + ( pStar - Pressure_i ) / ( sL - ProjVelocity_i ) * UnitNormal[iDim] ) ; - IntermediateState[nVar-1] = rhoSL * ( Density_i * Energy_i - ( Pressure_i * ProjVelocity_i - pStar * sM) / ( sL - ProjVelocity_i ) ); - - - val_residual[0] = sM * IntermediateState[0]; - for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = sM * IntermediateState[iDim+1] + pStar * UnitNormal[iDim]; - val_residual[nVar-1] = sM * ( IntermediateState[nVar-1] + pStar ) + pStar * ProjInterfaceVel; - } - } - else { - - if (sR < 0.0) { - - /*--- Compute Right Flux ---*/ - - val_residual[0] = Density_j * ProjVelocity_j; - for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = Density_j * Velocity_j[iDim] * ProjVelocity_j + Pressure_j * UnitNormal[iDim]; - val_residual[nVar-1] = Enthalpy_j * Density_j * ProjVelocity_j; - } - else { - - /*--- Compute Flux Right Star from Right Star State ---*/ - - rhoSR = ( sR - ProjVelocity_j ) / ( sR - sM ); - - IntermediateState[0] = rhoSR * Density_j; - for (iDim = 0; iDim < nDim; iDim++) - IntermediateState[iDim+1] = rhoSR * ( Density_j * Velocity_j[iDim] + ( pStar - Pressure_j ) / ( sR - ProjVelocity_j ) * UnitNormal[iDim] ) ; - IntermediateState[nVar-1] = rhoSR * ( Density_j * Energy_j - ( Pressure_j * ProjVelocity_j - pStar * sM ) / ( sR - ProjVelocity_j ) ); - - - val_residual[0] = sM * IntermediateState[0]; - for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = sM * IntermediateState[iDim+1] + pStar * UnitNormal[iDim]; - val_residual[nVar-1] = sM * (IntermediateState[nVar-1] + pStar ) + pStar * ProjInterfaceVel; - } - } - - for (iVar = 0; iVar < nVar; iVar++) - val_residual[iVar] *= Area; - - - if (implicit) { - - if (sM > 0.0) { - - if (sL > 0.0) { - - /*--- Compute Jacobian based on Left State ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_j[iVar][jVar] = 0; - - - GetInviscidProjJac(Velocity_i, &Enthalpy_i, &Chi_i, &Kappa_i, UnitNormal, 1.0, val_Jacobian_i); - - } - else { - /*--- Compute Jacobian based on Left Star State ---*/ - - EStar = IntermediateState[nVar-1]; - Omega = 1/(sL-sM); - OmegaSM = Omega * sM; - - - /*--------- Left Jacobian ---------*/ - - - /*--- Computing pressure derivatives d/dU_L (PI) ---*/ - - dPI_dU[0] = Chi_i - 0.5 * Kappa_i * sq_vel_i; - for (iDim = 0; iDim < nDim; iDim++) - dPI_dU[iDim+1] = - Kappa_i * Velocity_i[iDim]; - dPI_dU[nVar-1] = Kappa_i; - - - /*--- Computing d/dU_L (Sm) ---*/ - - dSm_dU[0] = ( - ProjVelocity_i * ProjVelocity_i + sM * sL + dPI_dU[0] ) / RHO; - for (iDim = 0; iDim < nDim; iDim++) - dSm_dU[iDim+1] = ( UnitNormal[iDim] * ( 2 * ProjVelocity_i - sL - sM ) + dPI_dU[iDim+1] ) / RHO; - dSm_dU[nVar-1] = dPI_dU[nVar-1] / RHO; - - - /*--- Computing d/dU_L (rhoStar) ---*/ - - drhoStar_dU[0] = Omega * ( sL + IntermediateState[0] * dSm_dU[0] ); - for (iDim = 0; iDim < nDim; iDim++) - drhoStar_dU[iDim+1] = Omega * ( - UnitNormal[iDim] + IntermediateState[0] * dSm_dU[iDim+1] ); - drhoStar_dU[nVar-1] = Omega * IntermediateState[0] * dSm_dU[nVar-1]; - - - /*--- Computing d/dU_L (pStar) ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - dpStar_dU[iVar] = Density_i * (sR - ProjVelocity_j) * dSm_dU[iVar]; - - - /*--- Computing d/dU_L (EStar) ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); - - dEStar_dU[0] += Omega * ProjVelocity_i * ( Enthalpy_i - dPI_dU[0] ); - for (iDim = 0; iDim < nDim; iDim++) - dEStar_dU[iDim+1] += Omega * ( - UnitNormal[iDim] * Enthalpy_i - ProjVelocity_i * dPI_dU[iDim+1] ); - dEStar_dU[nVar-1] += Omega * ( sL - ProjVelocity_i - ProjVelocity_i * dPI_dU[nVar-1] ); - - - - /*--- Jacobian First Row ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[0][iVar] = sM * drhoStar_dU[iVar] + IntermediateState[0] * dSm_dU[iVar]; - - /*--- Jacobian Middle Rows ---*/ - - for (jDim = 0; jDim < nDim; jDim++) { - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[jDim+1][iVar] = ( OmegaSM + 1 ) * ( UnitNormal[jDim] * dpStar_dU[iVar] + IntermediateState[jDim+1] * dSm_dU[iVar] ); - - val_Jacobian_i[jDim+1][0] += OmegaSM * Velocity_i[jDim] * ProjVelocity_i; - - val_Jacobian_i[jDim+1][jDim+1] += OmegaSM * (sL - ProjVelocity_i); - - for (iDim = 0; iDim < nDim; iDim++) - val_Jacobian_i[jDim+1][iDim+1] -= OmegaSM * Velocity_i[jDim] * UnitNormal[iDim]; - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[jDim+1][iVar] -= OmegaSM * dPI_dU[iVar] * UnitNormal[jDim]; - } - - /*--- Jacobian Last Row ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[nVar-1][iVar] = sM * ( dEStar_dU[iVar] + dpStar_dU[iVar] ) + ( EStar + pStar ) * dSm_dU[iVar]; - - - - - /*--------- Right Jacobian ---------*/ - - - /*--- Computing pressure derivatives d/dU_R (PI) ---*/ - - dPI_dU[0] = Chi_j - 0.5 * Kappa_j * sq_vel_j; - for (iDim = 0; iDim < nDim; iDim++) - dPI_dU[iDim+1] = - Kappa_j * Velocity_j[iDim]; - dPI_dU[nVar-1] = Kappa_j; - - - /*--- Computing d/dU_R (Sm) ---*/ - - dSm_dU[0] = ( ProjVelocity_j * ProjVelocity_j - sM * sR - dPI_dU[0] ) / RHO; - for (iDim = 0; iDim < nDim; iDim++) - dSm_dU[iDim+1] = - ( UnitNormal[iDim] * ( 2 * ProjVelocity_j - sR - sM) + dPI_dU[iDim+1] ) / RHO; - dSm_dU[nVar-1] = - dPI_dU[nVar-1] / RHO; - - - /*--- Computing d/dU_R (pStar) ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - dpStar_dU[iVar] = Density_j * (sL - ProjVelocity_i) * dSm_dU[iVar]; - - - /*--- Computing d/dU_R (EStar) ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); - - - - /*--- Jacobian First Row ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[0][iVar] = IntermediateState[0] * ( OmegaSM + 1 ) * dSm_dU[iVar]; - - /*--- Jacobian Middle Rows ---*/ - - for (iDim = 0; iDim < nDim; iDim++) { - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[iDim+1][iVar] = ( OmegaSM + 1 ) * ( IntermediateState[iDim+1] * dSm_dU[iVar] + UnitNormal[iDim] * dpStar_dU[iVar] ); - } - - /*--- Jacobian Last Row ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[nVar-1][iVar] = sM * (dEStar_dU[iVar] + dpStar_dU[iVar]) + (EStar + pStar) * dSm_dU[iVar]; - } - } - else { - if (sR < 0.0) { - - /*--- Compute Jacobian based on Right State ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_i[iVar][jVar] = 0; - - GetInviscidProjJac(Velocity_j, &Enthalpy_j, &Chi_j, &Kappa_j, UnitNormal, 1.0, val_Jacobian_j); - - } - else { - /*--- Compute Jacobian based on Right Star State ---*/ - - EStar = IntermediateState[nVar-1]; - Omega = 1/(sR-sM); - OmegaSM = Omega * sM; - - - /*--------- Left Jacobian ---------*/ - - - /*--- Computing pressure derivatives d/dU_L (PI) ---*/ - - dPI_dU[0] = Chi_i - 0.5 * Kappa_i * sq_vel_i; - for (iDim = 0; iDim < nDim; iDim++) - dPI_dU[iDim+1] = - Kappa_i * Velocity_i[iDim]; - dPI_dU[nVar-1] = Kappa_i; - - - /*--- Computing d/dU_L (Sm) ---*/ - - dSm_dU[0] = ( - ProjVelocity_i * ProjVelocity_i + sM * sL + dPI_dU[0] ) / RHO; - for (iDim = 0; iDim < nDim; iDim++) - dSm_dU[iDim+1] = ( UnitNormal[iDim] * ( 2 * ProjVelocity_i - sL - sM ) + dPI_dU[iDim+1] ) / RHO; - dSm_dU[nVar-1] = dPI_dU[nVar-1] / RHO; - - - /*--- Computing d/dU_L (pStar) ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - dpStar_dU[iVar] = Density_i * (sR - ProjVelocity_j) * dSm_dU[iVar]; - - - /*--- Computing d/dU_L (EStar) ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); - - - - /*--- Jacobian First Row ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[0][iVar] = IntermediateState[0] * ( OmegaSM + 1 ) * dSm_dU[iVar]; - - /*--- Jacobian Middle Rows ---*/ - - for (iDim = 0; iDim < nDim; iDim++) { - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[iDim+1][iVar] = (OmegaSM + 1) * ( IntermediateState[iDim+1] * dSm_dU[iVar] + UnitNormal[iDim] * dpStar_dU[iVar] ); - } - - /*--- Jacobian Last Row ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[nVar-1][iVar] = sM * (dEStar_dU[iVar] + dpStar_dU[iVar]) + (EStar + pStar) * dSm_dU[iVar]; - - - - /*--------- Right Jacobian ---------*/ - - - /*--- Computing pressure derivatives d/dU_R (PI) ---*/ - - dPI_dU[0] = Chi_j - 0.5 * Kappa_j * sq_vel_j; - for (iDim = 0; iDim < nDim; iDim++) - dPI_dU[iDim+1] = - Kappa_j * Velocity_j[iDim]; - dPI_dU[nVar-1] = Kappa_j; - - - /*--- Computing d/dU_R (Sm) ---*/ - - dSm_dU[0] = - ( - ProjVelocity_j * ProjVelocity_j + sM * sR + dPI_dU[0] ) / RHO; - for (iDim = 0; iDim < nDim; iDim++) - dSm_dU[iDim+1] = - ( UnitNormal[iDim] * ( 2 * ProjVelocity_j - sR - sM) + dPI_dU[iDim+1] ) / RHO; - dSm_dU[nVar-1] = - dPI_dU[nVar-1] / RHO; - - - /*--- Computing d/dU_R (pStar) ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - dpStar_dU[iVar] = Density_j * (sL - ProjVelocity_i) * dSm_dU[iVar]; - - - /*--- Computing d/dU_R (rhoStar) ---*/ - - drhoStar_dU[0] = Omega * ( sR + IntermediateState[0] * dSm_dU[0] ); - for (iDim = 0; iDim < nDim; iDim++) - drhoStar_dU[iDim+1] = Omega * ( - UnitNormal[iDim] + IntermediateState[0] * dSm_dU[iDim+1] ); - drhoStar_dU[nVar-1] = Omega * IntermediateState[0] * dSm_dU[nVar-1]; - - - /*--- Computing d/dU_R (EStar) ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); - - dEStar_dU[0] += Omega * ProjVelocity_j * ( Enthalpy_j - dPI_dU[0] ); - for (iDim = 0; iDim < nDim; iDim++) - dEStar_dU[iDim+1] += Omega * ( - UnitNormal[iDim] * Enthalpy_j - ProjVelocity_j * dPI_dU[iDim+1] ); - dEStar_dU[nVar-1] += Omega * ( sR - ProjVelocity_j - ProjVelocity_j * dPI_dU[nVar-1] ); - - - - /*--- Jacobian First Row ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[0][iVar] = sM * drhoStar_dU[iVar] + IntermediateState[0] * dSm_dU[iVar]; - - /*--- Jacobian Middle Rows ---*/ - - for (jDim = 0; jDim < nDim; jDim++) { - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[jDim+1][iVar] = ( OmegaSM + 1 ) * ( UnitNormal[jDim] * dpStar_dU[iVar] + IntermediateState[jDim+1] * dSm_dU[iVar] ); - - val_Jacobian_j[jDim+1][0] += OmegaSM * Velocity_j[jDim] * ProjVelocity_j; - - val_Jacobian_j[jDim+1][jDim+1] += OmegaSM * (sR - ProjVelocity_j); - - for (iDim = 0; iDim < nDim; iDim++) - val_Jacobian_j[jDim+1][iDim+1] -= OmegaSM * Velocity_j[jDim] * UnitNormal[iDim]; - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[jDim+1][iVar] -= OmegaSM * dPI_dU[iVar] * UnitNormal[jDim]; - } - - /*--- Jacobian Last Row ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[nVar-1][iVar] = sM * ( dEStar_dU[iVar] + dpStar_dU[iVar] ) + ( EStar + pStar ) * dSm_dU[iVar]; - } - } - - - /*--- Jacobians of the inviscid flux, scale = kappa because val_residual ~ 0.5*(fc_i+fc_j)*Normal ---*/ - - Area *= kappa; - - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - val_Jacobian_i[iVar][jVar] *= Area; - val_Jacobian_j[iVar][jVar] *= Area; - } - } - - } - -} - -void CUpwGeneralHLLC_Flow::VinokurMontagne() { - - su2double delta_rhoStaticEnergy, delta_rho, delta_p, err_P, s, D; - - delta_rho = Density_j - Density_i; - delta_p = Pressure_j - Pressure_i; - - RoeKappaStaticEnthalpy = 0.5 * ( StaticEnthalpy_i * Kappa_i + StaticEnthalpy_j * Kappa_j ); - - s = RoeChi + RoeKappaStaticEnthalpy; - - D = s*s * delta_rho * delta_rho + delta_p * delta_p; - - delta_rhoStaticEnergy = Density_j * StaticEnergy_j - Density_i * StaticEnergy_i; - - err_P = delta_p - RoeChi * delta_rho - RoeKappa * delta_rhoStaticEnergy; - - if (abs((D - delta_p*err_P)/Density_i) > 1e-3 && abs(delta_rho/Density_i) > 1e-3 && s/Density_i > 1e-3) { - - RoeKappa = ( D * RoeKappa ) / ( D - delta_p * err_P ); - RoeChi = ( D * RoeChi+ s*s * delta_rho * err_P ) / ( D - delta_p * err_P ); - - } -} diff --git a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwGeneralRoe_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwGeneralRoe_Flow.cpp deleted file mode 100644 index d132e73baebc..000000000000 --- a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwGeneralRoe_Flow.cpp +++ /dev/null @@ -1,360 +0,0 @@ -/*! - * \file CUpwGeneralRoe_Flow.cpp - * \brief Implementation of numerics class CUpwGeneralRoe_Flow. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../../include/numerics/flow/convection_upwind/CUpwGeneralRoe_Flow.hpp" - -CUpwGeneralRoe_Flow::CUpwGeneralRoe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ - dynamic_grid = config->GetDynamic_Grid(); - kappa = config->GetRoe_Kappa(); // 1 is unstable - - - Diff_U = new su2double [nVar]; - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; - RoeVelocity = new su2double [nDim]; - delta_vel = new su2double [nDim]; - delta_wave = new su2double [nVar]; - ProjFlux_i = new su2double [nVar]; - ProjFlux_j = new su2double [nVar]; - Lambda = new su2double [nVar]; - Epsilon = new su2double [nVar]; - P_Tensor = new su2double* [nVar]; - invP_Tensor = new su2double* [nVar]; - - for (iVar = 0; iVar < nVar; iVar++) { - P_Tensor[iVar] = new su2double [nVar]; - invP_Tensor[iVar] = new su2double [nVar]; - } -} - -CUpwGeneralRoe_Flow::~CUpwGeneralRoe_Flow(void) { - - delete [] Diff_U; - delete [] Velocity_i; - delete [] Velocity_j; - delete [] RoeVelocity; - delete [] delta_vel; - delete [] delta_wave; - delete [] ProjFlux_i; - delete [] ProjFlux_j; - delete [] Lambda; - delete [] Epsilon; - for (iVar = 0; iVar < nVar; iVar++) { - delete [] P_Tensor[iVar]; - delete [] invP_Tensor[iVar]; - } - delete [] P_Tensor; - delete [] invP_Tensor; - -} - -void CUpwGeneralRoe_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - AD::StartPreacc(); - AD::SetPreaccIn(V_i, nDim+4); AD::SetPreaccIn(V_j, nDim+4); AD::SetPreaccIn(Normal, nDim); - AD::SetPreaccIn(S_i, 2); AD::SetPreaccIn(S_j, 2); - if (dynamic_grid) { - AD::SetPreaccIn(GridVel_i, nDim); AD::SetPreaccIn(GridVel_j, nDim); - } - su2double U_i[5] = {0.0,0.0,0.0,0.0,0.0}, U_j[5] = {0.0,0.0,0.0,0.0,0.0}; - - /*--- Face area (norm or the normal vector) ---*/ - - Area = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - Area += Normal[iDim]*Normal[iDim]; - Area = sqrt(Area); - - /*-- Unit Normal ---*/ - - for (iDim = 0; iDim < nDim; iDim++) - UnitNormal[iDim] = Normal[iDim]/Area; - - /*--- Primitive variables at point i ---*/ - - Velocity2_i = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = V_i[iDim+1]; - Velocity2_i += Velocity_i[iDim]*Velocity_i[iDim]; - } - - Pressure_i = V_i[nDim+1]; - Density_i = V_i[nDim+2]; - Enthalpy_i = V_i[nDim+3]; - Energy_i = Enthalpy_i - Pressure_i/Density_i; - StaticEnthalpy_i = Enthalpy_i - 0.5*Velocity2_i; - StaticEnergy_i = StaticEnthalpy_i - Pressure_i/Density_i; - - Kappa_i = S_i[1]/Density_i; - Chi_i = S_i[0] - Kappa_i*StaticEnergy_i; - SoundSpeed_i = sqrt(Chi_i + StaticEnthalpy_i*Kappa_i); - - /*--- Primitive variables at point j ---*/ - - - Velocity2_j = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_j[iDim] = V_j[iDim+1]; - Velocity2_j += Velocity_j[iDim]*Velocity_j[iDim]; - } - - Pressure_j = V_j[nDim+1]; - Density_j = V_j[nDim+2]; - Enthalpy_j = V_j[nDim+3]; - Energy_j = Enthalpy_j - Pressure_j/Density_j; - - StaticEnthalpy_j = Enthalpy_j - 0.5*Velocity2_j; - StaticEnergy_j = StaticEnthalpy_j - Pressure_j/Density_j; - - Kappa_j = S_j[1]/Density_j; - Chi_j = S_j[0] - Kappa_j*StaticEnergy_j; - SoundSpeed_j = sqrt(Chi_j + StaticEnthalpy_j*Kappa_j); - - /*--- Recompute conservative variables ---*/ - - U_i[0] = Density_i; U_j[0] = Density_j; - for (iDim = 0; iDim < nDim; iDim++) { - U_i[iDim+1] = Density_i*Velocity_i[iDim]; U_j[iDim+1] = Density_j*Velocity_j[iDim]; - } - U_i[nDim+1] = Density_i*Energy_i; U_j[nDim+1] = Density_j*Energy_j; - -// /*--- Roe-averaged variables at interface between i & j ---*/ - - ComputeRoeAverage(); - - if (RoeSoundSpeed2 <= 0.0) { - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] = 0.0; - for (jVar = 0; jVar < nVar; jVar++) { - val_Jacobian_i[iVar][iVar] = 0.0; - val_Jacobian_j[iVar][iVar] = 0.0; - } - } - return; - } - - RoeSoundSpeed = sqrt(RoeSoundSpeed2); - - /*--- Compute ProjFlux_i ---*/ - GetInviscidProjFlux(&Density_i, Velocity_i, &Pressure_i, &Enthalpy_i, Normal, ProjFlux_i); - - /*--- Compute ProjFlux_j ---*/ - GetInviscidProjFlux(&Density_j, Velocity_j, &Pressure_j, &Enthalpy_j, Normal, ProjFlux_j); - - /*--- Compute P and Lambda (do it with the Normal) ---*/ - - GetPMatrix(&RoeDensity, RoeVelocity, &RoeSoundSpeed, &RoeEnthalpy, &RoeChi, &RoeKappa, UnitNormal, P_Tensor); - - ProjVelocity = 0.0; ProjVelocity_i = 0.0; ProjVelocity_j = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - ProjVelocity += RoeVelocity[iDim]*UnitNormal[iDim]; - ProjVelocity_i += Velocity_i[iDim]*UnitNormal[iDim]; - ProjVelocity_j += Velocity_j[iDim]*UnitNormal[iDim]; - } - - /*--- Projected velocity adjustment due to mesh motion ---*/ - if (dynamic_grid) { - su2double ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*UnitNormal[iDim]; - } - ProjVelocity -= ProjGridVel; - ProjVelocity_i -= ProjGridVel; - ProjVelocity_j -= ProjGridVel; - } - - /*--- Flow eigenvalues and entropy correctors ---*/ - for (iDim = 0; iDim < nDim; iDim++) - Lambda[iDim] = ProjVelocity; - - Lambda[nVar-2] = ProjVelocity + RoeSoundSpeed; - Lambda[nVar-1] = ProjVelocity - RoeSoundSpeed; - - /*--- Compute absolute value with Mavriplis' entropy correction ---*/ - - MaxLambda = fabs(ProjVelocity) + RoeSoundSpeed; - Delta = config->GetEntropyFix_Coeff(); - - for (iVar = 0; iVar < nVar; iVar++) { - Lambda[iVar] = max(fabs(Lambda[iVar]), Delta*MaxLambda); - } - -// /*--- Harten and Hyman (1983) entropy correction ---*/ -// for (iDim = 0; iDim < nDim; iDim++) -// Epsilon[iDim] = 4.0*max(0.0, max(Lambda[iDim]-ProjVelocity_i, ProjVelocity_j-Lambda[iDim])); -// -// Epsilon[nVar-2] = 4.0*max(0.0, max(Lambda[nVar-2]-(ProjVelocity_i+SoundSpeed_i),(ProjVelocity_j+SoundSpeed_j)-Lambda[nVar-2])); -// Epsilon[nVar-1] = 4.0*max(0.0, max(Lambda[nVar-1]-(ProjVelocity_i-SoundSpeed_i),(ProjVelocity_j-SoundSpeed_j)-Lambda[nVar-1])); -// -// for (iVar = 0; iVar < nVar; iVar++) -// if ( fabs(Lambda[iVar]) < Epsilon[iVar] ) -// Lambda[iVar] = (Lambda[iVar]*Lambda[iVar] + Epsilon[iVar]*Epsilon[iVar])/(2.0*Epsilon[iVar]); -// else -// Lambda[iVar] = fabs(Lambda[iVar]); - -// for (iVar = 0; iVar < nVar; iVar++) -// Lambda[iVar] = fabs(Lambda[iVar]); - - if (!implicit) { - - /*--- Compute wave amplitudes (characteristics) ---*/ - proj_delta_vel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - delta_vel[iDim] = Velocity_j[iDim] - Velocity_i[iDim]; - proj_delta_vel += delta_vel[iDim]*Normal[iDim]; - } - delta_p = Pressure_j - Pressure_i; - delta_rho = Density_j - Density_i; - proj_delta_vel = proj_delta_vel/Area; - - if (nDim == 2) { - delta_wave[0] = delta_rho - delta_p/(RoeSoundSpeed*RoeSoundSpeed); - delta_wave[1] = UnitNormal[1]*delta_vel[0]-UnitNormal[0]*delta_vel[1]; - delta_wave[2] = proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); - delta_wave[3] = -proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); - } else { - delta_wave[0] = delta_rho - delta_p/(RoeSoundSpeed*RoeSoundSpeed); - delta_wave[1] = UnitNormal[0]*delta_vel[2]-UnitNormal[2]*delta_vel[0]; - delta_wave[2] = UnitNormal[1]*delta_vel[0]-UnitNormal[0]*delta_vel[1]; - delta_wave[3] = proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); - delta_wave[4] = -proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); - } - - /*--- Roe's Flux approximation ---*/ - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] = 0.5*(ProjFlux_i[iVar]+ProjFlux_j[iVar]); - for (jVar = 0; jVar < nVar; jVar++) - val_residual[iVar] -= 0.5*Lambda[jVar]*delta_wave[jVar]*P_Tensor[iVar][jVar]*Area; - } - - /*--- Flux contribution due to grid motion ---*/ - if (dynamic_grid) { - ProjVelocity = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjVelocity += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] -= ProjVelocity * 0.5*(U_i[iVar]+U_j[iVar]); - } - } - } - else { - - /*--- Compute inverse P ---*/ - - GetPMatrix_inv(invP_Tensor, &RoeDensity, RoeVelocity, &RoeSoundSpeed, &RoeChi , &RoeKappa, UnitNormal); - - /*--- Jacobians of the inviscid flux, scaled by - kappa because val_resconv ~ kappa*(fc_i+fc_j)*Normal ---*/ - - GetInviscidProjJac(Velocity_i, &Enthalpy_i, &Chi_i, &Kappa_i, Normal, kappa, val_Jacobian_i); - - GetInviscidProjJac(Velocity_j, &Enthalpy_j, &Chi_j, &Kappa_j, Normal, kappa, val_Jacobian_j); - - - /*--- Diference variables iPoint and jPoint ---*/ - for (iVar = 0; iVar < nVar; iVar++) - Diff_U[iVar] = U_j[iVar]-U_i[iVar]; - - /*--- Roe's Flux approximation ---*/ - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] = kappa*(ProjFlux_i[iVar]+ProjFlux_j[iVar]); - for (jVar = 0; jVar < nVar; jVar++) { - Proj_ModJac_Tensor_ij = 0.0; - - /*--- Compute |Proj_ModJac_Tensor| = P x |Lambda| x inverse P ---*/ - - for (kVar = 0; kVar < nVar; kVar++) - Proj_ModJac_Tensor_ij += P_Tensor[iVar][kVar]*Lambda[kVar]*invP_Tensor[kVar][jVar]; - - val_residual[iVar] -= (1.0-kappa)*Proj_ModJac_Tensor_ij*Diff_U[jVar]*Area; - val_Jacobian_i[iVar][jVar] += (1.0-kappa)*Proj_ModJac_Tensor_ij*Area; - val_Jacobian_j[iVar][jVar] -= (1.0-kappa)*Proj_ModJac_Tensor_ij*Area; - } - } - - /*--- Jacobian contributions due to grid motion ---*/ - if (dynamic_grid) { - ProjVelocity = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjVelocity += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] -= ProjVelocity * 0.5*(U_i[iVar]+U_j[iVar]); - /*--- Implicit terms ---*/ - val_Jacobian_i[iVar][iVar] -= 0.5*ProjVelocity; - val_Jacobian_j[iVar][iVar] -= 0.5*ProjVelocity; - } - } - - } - - AD::SetPreaccOut(val_residual, nVar); - AD::EndPreacc(); -} - - -void CUpwGeneralRoe_Flow::ComputeRoeAverage() { - - //su2double delta_rhoStaticEnergy, err_P, s, D; - // su2double tol = 10-6; - - R = sqrt(fabs(Density_j/Density_i)); - RoeDensity = R*Density_i; - sq_vel = 0; for (iDim = 0; iDim < nDim; iDim++) { - RoeVelocity[iDim] = (R*Velocity_j[iDim]+Velocity_i[iDim])/(R+1); - sq_vel += RoeVelocity[iDim]*RoeVelocity[iDim]; - } - - RoeEnthalpy = (R*Enthalpy_j+Enthalpy_i)/(R+1); - delta_rho = Density_j - Density_i; - delta_p = Pressure_j - Pressure_i; - RoeKappa = 0.5*(Kappa_i + Kappa_j); - RoeKappa = (Kappa_i + Kappa_j + 4*RoeKappa)/6; - RoeChi = 0.5*(Chi_i + Chi_j); - RoeChi = (Chi_i + Chi_j + 4*RoeChi)/6; - - -// RoeKappaStaticEnthalpy = 0.5*(StaticEnthalpy_i*Kappa_i + StaticEnthalpy_j*Kappa_j); -// RoeKappaStaticEnthalpy = (StaticEnthalpy_i*Kappa_i + StaticEnthalpy_j*Kappa_j + 4*RoeKappaStaticEnthalpy)/6; -// s = RoeChi + RoeKappaStaticEnthalpy; -// D = s*s*delta_rho*delta_rho + delta_p*delta_p; -// delta_rhoStaticEnergy = Density_j*StaticEnergy_j - Density_i*StaticEnergy_i; -// err_P = delta_p - RoeChi*delta_rho - RoeKappa*delta_rhoStaticEnergy; -// -// -// if (abs((D - delta_p*err_P)/Density_i)>1e-3 && abs(delta_rho/Density_i)>1e-3 && s/Density_i > 1e-3) { -// -// RoeKappa = (D*RoeKappa)/(D - delta_p*err_P); -// RoeChi = (D*RoeChi+ s*s*delta_rho*err_P)/(D - delta_p*err_P); -// -// } - - RoeSoundSpeed2 = RoeChi + RoeKappa*(RoeEnthalpy-0.5*sq_vel); - -} diff --git a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwHLLC_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwHLLC_Flow.cpp deleted file mode 100644 index d29af2fdbaee..000000000000 --- a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwHLLC_Flow.cpp +++ /dev/null @@ -1,539 +0,0 @@ -/*! - * \file CUpwHLLC_Flow.cpp - * \brief Implementation of numerics class CUpwHLLC_Flow. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../../include/numerics/flow/convection_upwind/CUpwHLLC_Flow.hpp" - -CUpwHLLC_Flow::CUpwHLLC_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - kappa = config->GetRoe_Kappa(); - /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ - dynamic_grid = config->GetDynamic_Grid(); - - Gamma = config->GetGamma(); - - Gamma_Minus_One = Gamma - 1.0; - - IntermediateState = new su2double [nVar]; - dSm_dU = new su2double [nVar]; - dPI_dU = new su2double [nVar]; - drhoStar_dU = new su2double [nVar]; - dpStar_dU = new su2double [nVar]; - dEStar_dU = new su2double [nVar]; - - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; - RoeVelocity = new su2double [nDim]; - -} - -CUpwHLLC_Flow::~CUpwHLLC_Flow(void) { - - delete [] IntermediateState; - delete [] dSm_dU; - delete [] dPI_dU; - delete [] drhoStar_dU; - delete [] dpStar_dU; - delete [] dEStar_dU; - - delete [] Velocity_i; - delete [] Velocity_j; - delete [] RoeVelocity; - -} - -void CUpwHLLC_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - /*--- Face area (norm or the normal vector) ---*/ - - Area = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - Area += Normal[iDim] * Normal[iDim]; - - Area = sqrt(Area); - - /*-- Unit Normal ---*/ - - for (iDim = 0; iDim < nDim; iDim++) - UnitNormal[iDim] = Normal[iDim] / Area; - - /*-- Fluid velocity at node i,j ---*/ - - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = V_i[iDim+1]; - Velocity_j[iDim] = V_j[iDim+1]; - } - - /*--- Primitive variables at point i ---*/ - - Pressure_i = V_i[nDim+1]; - Density_i = V_i[nDim+2]; - Enthalpy_i = V_i[nDim+3]; - - /*--- Primitive variables at point j ---*/ - - Pressure_j = V_j[nDim+1]; - Density_j = V_j[nDim+2]; - Enthalpy_j = V_j[nDim+3]; - - - sq_vel_i = 0.0; - sq_vel_j = 0.0; - - for (iDim = 0; iDim < nDim; iDim++) { - sq_vel_i += Velocity_i[iDim] * Velocity_i[iDim]; - sq_vel_j += Velocity_j[iDim] * Velocity_j[iDim]; - } - - Energy_i = Enthalpy_i - Pressure_i / Density_i; - Energy_j = Enthalpy_j - Pressure_j / Density_j; - - SoundSpeed_i = sqrt( (Enthalpy_i - 0.5 * sq_vel_i) * Gamma_Minus_One ); - SoundSpeed_j = sqrt( (Enthalpy_j - 0.5 * sq_vel_j) * Gamma_Minus_One ); - - /*--- Projected velocities ---*/ - - ProjVelocity_i = 0; - ProjVelocity_j = 0; - - for (iDim = 0; iDim < nDim; iDim++) { - ProjVelocity_i += Velocity_i[iDim] * UnitNormal[iDim]; - ProjVelocity_j += Velocity_j[iDim] * UnitNormal[iDim]; - } - - /*--- Projected Grid Velocity ---*/ - - ProjInterfaceVel = 0; - - if (dynamic_grid) { - - for (iDim = 0; iDim < nDim; iDim++) - ProjInterfaceVel += 0.5 * ( GridVel_i[iDim] + GridVel_j[iDim] )*UnitNormal[iDim]; - - SoundSpeed_i -= ProjInterfaceVel; - SoundSpeed_j += ProjInterfaceVel; - - ProjVelocity_i -= ProjInterfaceVel; - ProjVelocity_j -= ProjInterfaceVel; - } - - /*--- Roe's averaging ---*/ - - Rrho = ( sqrt(Density_i) + sqrt(Density_j) ); - - sq_velRoe = 0.0; - RoeProjVelocity = - ProjInterfaceVel; - - for (iDim = 0; iDim < nDim; iDim++) { - RoeVelocity[iDim] = ( Velocity_i[iDim] * sqrt(Density_i) + Velocity_j[iDim] * sqrt(Density_j) ) / Rrho; - sq_velRoe += RoeVelocity[iDim] * RoeVelocity[iDim]; - RoeProjVelocity += RoeVelocity[iDim] * UnitNormal[iDim]; - } - - /*--- Mean Roe variables iPoint and jPoint ---*/ - - RoeDensity = sqrt( Density_i * Density_j ); - RoeEnthalpy = ( sqrt(Density_j) * Enthalpy_j + sqrt(Density_i) * Enthalpy_i) / Rrho; - - /*--- Roe-averaged speed of sound ---*/ - - //RoeSoundSpeed2 = Gamma_Minus_One * ( RoeEnthalpy - 0.5 * sq_velRoe ); - RoeSoundSpeed = sqrt( Gamma_Minus_One * ( RoeEnthalpy - 0.5 * sq_velRoe ) ) - ProjInterfaceVel; - - - /*--- Speed of sound at L and R ---*/ - - sL = min( RoeProjVelocity - RoeSoundSpeed, ProjVelocity_i - SoundSpeed_i); - sR = max( RoeProjVelocity + RoeSoundSpeed, ProjVelocity_j + SoundSpeed_j); - - /*--- speed of contact surface ---*/ - - RHO = Density_j * (sR - ProjVelocity_j) - Density_i * (sL - ProjVelocity_i); - sM = ( Pressure_i - Pressure_j - Density_i * ProjVelocity_i * ( sL - ProjVelocity_i ) + Density_j * ProjVelocity_j * ( sR - ProjVelocity_j ) ) / RHO; - - /*--- Pressure at right and left (Pressure_j=Pressure_i) side of contact surface ---*/ - - pStar = Density_j * ( ProjVelocity_j - sR ) * ( ProjVelocity_j - sM ) + Pressure_j; - - -if (sM > 0.0) { - - if (sL > 0.0) { - - /*--- Compute Left Flux ---*/ - - val_residual[0] = Density_i * ProjVelocity_i; - for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = Density_i * Velocity_i[iDim] * ProjVelocity_i + Pressure_i * UnitNormal[iDim]; - val_residual[nVar-1] = Enthalpy_i * Density_i * ProjVelocity_i; - } - else { - - /*--- Compute Flux Left Star from Left Star State ---*/ - - rhoSL = ( sL - ProjVelocity_i ) / ( sL - sM ); - - IntermediateState[0] = rhoSL * Density_i; - for (iDim = 0; iDim < nDim; iDim++) - IntermediateState[iDim+1] = rhoSL * ( Density_i * Velocity_i[iDim] + ( pStar - Pressure_i ) / ( sL - ProjVelocity_i ) * UnitNormal[iDim] ) ; - IntermediateState[nVar-1] = rhoSL * ( Density_i * Energy_i - ( Pressure_i * ProjVelocity_i - pStar * sM) / ( sL - ProjVelocity_i ) ); - - - val_residual[0] = sM * IntermediateState[0]; - for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = sM * IntermediateState[iDim+1] + pStar * UnitNormal[iDim]; - val_residual[nVar-1] = sM * ( IntermediateState[nVar-1] + pStar ) + pStar * ProjInterfaceVel; - } - } - else { - - if (sR < 0.0) { - - /*--- Compute Right Flux ---*/ - - val_residual[0] = Density_j * ProjVelocity_j; - for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = Density_j * Velocity_j[iDim] * ProjVelocity_j + Pressure_j * UnitNormal[iDim]; - val_residual[nVar-1] = Enthalpy_j * Density_j * ProjVelocity_j; - } - else { - - /*--- Compute Flux Right Star from Right Star State ---*/ - - rhoSR = ( sR - ProjVelocity_j ) / ( sR - sM ); - - IntermediateState[0] = rhoSR * Density_j; - for (iDim = 0; iDim < nDim; iDim++) - IntermediateState[iDim+1] = rhoSR * ( Density_j * Velocity_j[iDim] + ( pStar - Pressure_j ) / ( sR - ProjVelocity_j ) * UnitNormal[iDim] ) ; - IntermediateState[nVar-1] = rhoSR * ( Density_j * Energy_j - ( Pressure_j * ProjVelocity_j - pStar * sM ) / ( sR - ProjVelocity_j ) ); - - - val_residual[0] = sM * IntermediateState[0]; - for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = sM * IntermediateState[iDim+1] + pStar * UnitNormal[iDim]; - val_residual[nVar-1] = sM * (IntermediateState[nVar-1] + pStar ) + pStar * ProjInterfaceVel; - } - } - - - for (iVar = 0; iVar < nVar; iVar++) - val_residual[iVar] *= Area; - - - if (implicit) { - - if (sM > 0.0) { - - if (sL > 0.0) { - - /*--- Compute Jacobian based on Left State ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_j[iVar][jVar] = 0; - - GetInviscidProjJac(Velocity_i, &Energy_i, UnitNormal, 1.0, val_Jacobian_i); - - } - else { - /*--- Compute Jacobian based on Left Star State ---*/ - - EStar = IntermediateState[nVar-1]; - Omega = 1/(sL-sM); - OmegaSM = Omega * sM; - - - /*--------- Left Jacobian ---------*/ - - - /*--- Computing pressure derivatives d/dU_L (PI) ---*/ - - dPI_dU[0] = 0.5 * Gamma_Minus_One * sq_vel_i; - for (iDim = 0; iDim < nDim; iDim++) - dPI_dU[iDim+1] = - Gamma_Minus_One * Velocity_i[iDim]; - dPI_dU[nVar-1] = Gamma_Minus_One; - - - /*--- Computing d/dU_L (Sm) ---*/ - - dSm_dU[0] = ( - ProjVelocity_i * ProjVelocity_i + sM * sL + dPI_dU[0] ) / RHO; - for (iDim = 0; iDim < nDim; iDim++) - dSm_dU[iDim+1] = ( UnitNormal[iDim] * ( 2 * ProjVelocity_i - sL - sM ) + dPI_dU[iDim+1] ) / RHO; - dSm_dU[nVar-1] = dPI_dU[nVar-1] / RHO; - - - /*--- Computing d/dU_L (rhoStar) ---*/ - - drhoStar_dU[0] = Omega * ( sL + IntermediateState[0] * dSm_dU[0] ); - for (iDim = 0; iDim < nDim; iDim++) - drhoStar_dU[iDim+1] = Omega * ( - UnitNormal[iDim] + IntermediateState[0] * dSm_dU[iDim+1] ); - drhoStar_dU[nVar-1] = Omega * IntermediateState[0] * dSm_dU[nVar-1]; - - - /*--- Computing d/dU_L (pStar) ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - dpStar_dU[iVar] = Density_i * (sR - ProjVelocity_j) * dSm_dU[iVar]; - - - /*--- Computing d/dU_L (EStar) ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); - - dEStar_dU[0] += Omega * ProjVelocity_i * ( Enthalpy_i - dPI_dU[0] ); - for (iDim = 0; iDim < nDim; iDim++) - dEStar_dU[iDim+1] += Omega * ( - UnitNormal[iDim] * Enthalpy_i - ProjVelocity_i * dPI_dU[iDim+1] ); - dEStar_dU[nVar-1] += Omega * ( sL - ProjVelocity_i - ProjVelocity_i * dPI_dU[nVar-1] ); - - - - /*--- Jacobian First Row ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[0][iVar] = sM * drhoStar_dU[iVar] + IntermediateState[0] * dSm_dU[iVar]; - - /*--- Jacobian Middle Rows ---*/ - - for (jDim = 0; jDim < nDim; jDim++) { - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[jDim+1][iVar] = ( OmegaSM + 1 ) * ( UnitNormal[jDim] * dpStar_dU[iVar] + IntermediateState[jDim+1] * dSm_dU[iVar] ); - - val_Jacobian_i[jDim+1][0] += OmegaSM * Velocity_i[jDim] * ProjVelocity_i; - - val_Jacobian_i[jDim+1][jDim+1] += OmegaSM * (sL - ProjVelocity_i); - - for (iDim = 0; iDim < nDim; iDim++) - val_Jacobian_i[jDim+1][iDim+1] -= OmegaSM * Velocity_i[jDim] * UnitNormal[iDim]; - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[jDim+1][iVar] -= OmegaSM * dPI_dU[iVar] * UnitNormal[jDim]; - } - - /*--- Jacobian Last Row ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[nVar-1][iVar] = sM * ( dEStar_dU[iVar] + dpStar_dU[iVar] ) + ( EStar + pStar ) * dSm_dU[iVar]; - - - - - /*--------- Right Jacobian ---------*/ - - - /*--- Computing d/dU_R (Sm) ---*/ - - dSm_dU[0] = ( ProjVelocity_j * ProjVelocity_j - sM * sR - 0.5 * Gamma_Minus_One * sq_vel_j ) / RHO; - for (iDim = 0; iDim < nDim; iDim++) - dSm_dU[iDim+1] = - ( UnitNormal[iDim] * ( 2 * ProjVelocity_j - sR - sM) - Gamma_Minus_One * Velocity_j[iDim] ) / RHO; - dSm_dU[nVar-1] = - Gamma_Minus_One / RHO; - - - /*--- Computing d/dU_R (pStar) ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - dpStar_dU[iVar] = Density_j * (sL - ProjVelocity_i) * dSm_dU[iVar]; - - - /*--- Computing d/dU_R (EStar) ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); - - - - /*--- Jacobian First Row ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[0][iVar] = IntermediateState[0] * ( OmegaSM + 1 ) * dSm_dU[iVar]; - - /*--- Jacobian Middle Rows ---*/ - - for (iDim = 0; iDim < nDim; iDim++) { - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[iDim+1][iVar] = ( OmegaSM + 1 ) * ( IntermediateState[iDim+1] * dSm_dU[iVar] + UnitNormal[iDim] * dpStar_dU[iVar] ); - } - - /*--- Jacobian Last Row ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[nVar-1][iVar] = sM * (dEStar_dU[iVar] + dpStar_dU[iVar]) + (EStar + pStar) * dSm_dU[iVar]; - } - } - else { - if (sR < 0.0) { - - /*--- Compute Jacobian based on Right State ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_i[iVar][jVar] = 0; - - GetInviscidProjJac(Velocity_j, &Energy_j, UnitNormal, 1.0, val_Jacobian_j); - - } - else { - /*--- Compute Jacobian based on Right Star State ---*/ - - EStar = IntermediateState[nVar-1]; - Omega = 1/(sR-sM); - OmegaSM = Omega * sM; - - - /*--------- Left Jacobian ---------*/ - - - /*--- Computing d/dU_L (Sm) ---*/ - - dSm_dU[0] = ( - ProjVelocity_i * ProjVelocity_i + sM * sL + 0.5 * Gamma_Minus_One * sq_vel_i ) / RHO; - for (iDim = 0; iDim < nDim; iDim++) - dSm_dU[iDim+1] = ( UnitNormal[iDim] * ( 2 * ProjVelocity_i - sL - sM ) - Gamma_Minus_One * Velocity_i[iDim] ) / RHO; - dSm_dU[nVar-1] = Gamma_Minus_One / RHO; - - - /*--- Computing d/dU_L (pStar) ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - dpStar_dU[iVar] = Density_i * (sR - ProjVelocity_j) * dSm_dU[iVar]; - - - /*--- Computing d/dU_L (EStar) ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); - - - - /*--- Jacobian First Row ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[0][iVar] = IntermediateState[0] * ( OmegaSM + 1 ) * dSm_dU[iVar]; - - /*--- Jacobian Middle Rows ---*/ - - for (iDim = 0; iDim < nDim; iDim++) { - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[iDim+1][iVar] = (OmegaSM + 1) * ( IntermediateState[iDim+1] * dSm_dU[iVar] + UnitNormal[iDim] * dpStar_dU[iVar] ); - } - - /*--- Jacobian Last Row ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[nVar-1][iVar] = sM * (dEStar_dU[iVar] + dpStar_dU[iVar]) + (EStar + pStar) * dSm_dU[iVar]; - - - - /*--------- Right Jacobian ---------*/ - - - /*--- Computing pressure derivatives d/dU_R (PI) ---*/ - - dPI_dU[0] = 0.5 * Gamma_Minus_One * sq_vel_j; - for (iDim = 0; iDim < nDim; iDim++) - dPI_dU[iDim+1] = - Gamma_Minus_One * Velocity_j[iDim]; - dPI_dU[nVar-1] = Gamma_Minus_One; - - - - /*--- Computing d/dU_R (Sm) ---*/ - - dSm_dU[0] = - ( - ProjVelocity_j * ProjVelocity_j + sM * sR + dPI_dU[0] ) / RHO; - for (iDim = 0; iDim < nDim; iDim++) - dSm_dU[iDim+1] = - ( UnitNormal[iDim] * ( 2 * ProjVelocity_j - sR - sM) + dPI_dU[iDim+1] ) / RHO; - dSm_dU[nVar-1] = - dPI_dU[nVar-1] / RHO; - - - /*--- Computing d/dU_R (pStar) ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - dpStar_dU[iVar] = Density_j * (sL - ProjVelocity_i) * dSm_dU[iVar]; - - - /*--- Computing d/dU_R (rhoStar) ---*/ - - drhoStar_dU[0] = Omega * ( sR + IntermediateState[0] * dSm_dU[0] ); - for (iDim = 0; iDim < nDim; iDim++) - drhoStar_dU[iDim+1] = Omega * ( - UnitNormal[iDim] + IntermediateState[0] * dSm_dU[iDim+1] ); - drhoStar_dU[nVar-1] = Omega * IntermediateState[0] * dSm_dU[nVar-1]; - - - /*--- Computing d/dU_R (EStar) ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); - - dEStar_dU[0] += Omega * ProjVelocity_j * ( Enthalpy_j - dPI_dU[0] ); - for (iDim = 0; iDim < nDim; iDim++) - dEStar_dU[iDim+1] += Omega * ( - UnitNormal[iDim] * Enthalpy_j - ProjVelocity_j * dPI_dU[iDim+1] ); - dEStar_dU[nVar-1] += Omega * ( sR - ProjVelocity_j - ProjVelocity_j * dPI_dU[nVar-1] ); - - - - /*--- Jacobian First Row ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[0][iVar] = sM * drhoStar_dU[iVar] + IntermediateState[0] * dSm_dU[iVar]; - - /*--- Jacobian Middle Rows ---*/ - - for (jDim = 0; jDim < nDim; jDim++) { - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[jDim+1][iVar] = ( OmegaSM + 1 ) * ( UnitNormal[jDim] * dpStar_dU[iVar] + IntermediateState[jDim+1] * dSm_dU[iVar] ); - - val_Jacobian_j[jDim+1][0] += OmegaSM * Velocity_j[jDim] * ProjVelocity_j; - - val_Jacobian_j[jDim+1][jDim+1] += OmegaSM * (sR - ProjVelocity_j); - - for (iDim = 0; iDim < nDim; iDim++) - val_Jacobian_j[jDim+1][iDim+1] -= OmegaSM * Velocity_j[jDim] * UnitNormal[iDim]; - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[jDim+1][iVar] -= OmegaSM * dPI_dU[iVar] * UnitNormal[jDim]; - } - - /*--- Jacobian Last Row ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[nVar-1][iVar] = sM * ( dEStar_dU[iVar] + dpStar_dU[iVar] ) + ( EStar + pStar ) * dSm_dU[iVar]; - - } - } - - - /*--- Jacobians of the inviscid flux, scale = k because val_residual ~ 0.5*(fc_i+fc_j)*Normal ---*/ - - Area *= kappa; - - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - val_Jacobian_i[iVar][jVar] *= Area; - val_Jacobian_j[iVar][jVar] *= Area; - } - } -} - -} diff --git a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwL2Roe_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwL2Roe_Flow.cpp deleted file mode 100644 index e1473e9a26e5..000000000000 --- a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwL2Roe_Flow.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/*! - * \file CUpwL2Roe_Flow.cpp - * \brief Implementation of numerics class CUpwL2Roe_Flow. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../../include/numerics/flow/convection_upwind/CUpwL2Roe_Flow.hpp" - -CUpwL2Roe_Flow::CUpwL2Roe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : - CUpwRoeBase_Flow(val_nDim, val_nVar, config, false) {} - -CUpwL2Roe_Flow::~CUpwL2Roe_Flow() {} - -void CUpwL2Roe_Flow::FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, - su2double **val_Jacobian_j, CConfig *config) { - - /*--- L2Roe: a low dissipation version of Roe's approximate Riemann solver for low Mach numbers. IJNMF 2015 ---*/ - - unsigned short iVar, jVar, kVar, iDim; - - /*--- Clamped Mach number ---*/ - - su2double M_i = 0.0, M_j = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - M_i += Velocity_i[iDim]*Velocity_i[iDim]; - M_j += Velocity_j[iDim]*Velocity_j[iDim]; - } - M_i = sqrt(M_i / fabs(Pressure_i*Gamma/Density_i)); - M_j = sqrt(M_j / fabs(Pressure_j*Gamma/Density_j)); - - su2double zeta = max(0.05,min(max(M_i,M_j),1.0)); - - /*--- Compute wave amplitudes (characteristics) ---*/ - - su2double proj_delta_vel = 0.0, delta_vel[3]; - for (iDim = 0; iDim < nDim; iDim++) { - delta_vel[iDim] = Velocity_j[iDim] - Velocity_i[iDim]; - proj_delta_vel += delta_vel[iDim]*UnitNormal[iDim]; - } - proj_delta_vel *= zeta; - su2double delta_p = Pressure_j - Pressure_i; - su2double delta_rho = Density_j - Density_i; - - su2double delta_wave[5] = {0.0, 0.0, 0.0, 0.0, 0.0}; - if (nDim == 2) { - delta_wave[0] = delta_rho - delta_p/RoeSoundSpeed2; - delta_wave[1] = (UnitNormal[1]*delta_vel[0]-UnitNormal[0]*delta_vel[1])*zeta; - delta_wave[2] = proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); - delta_wave[3] = -proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); - } else { - delta_wave[0] = delta_rho - delta_p/RoeSoundSpeed2; - delta_wave[1] = (UnitNormal[0]*delta_vel[2]-UnitNormal[2]*delta_vel[0])*zeta; - delta_wave[2] = (UnitNormal[1]*delta_vel[0]-UnitNormal[0]*delta_vel[1])*zeta; - delta_wave[3] = proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); - delta_wave[4] = -proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); - } - - /*--- Update residual ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - for (kVar = 0; kVar < nVar; kVar++) - val_residual[iVar] -= (1.0-kappa)*Lambda[kVar]*delta_wave[kVar]*P_Tensor[iVar][kVar]*Area; - - if (!implicit) return; - - /*--- If implicit use the Jacobians of the standard Roe scheme as an approximation ---*/ - - GetPMatrix_inv(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, invP_Tensor); - - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - /*--- Compute |Proj_ModJac_Tensor| = P x |Lambda| x inverse P ---*/ - su2double Proj_ModJac_Tensor_ij = 0.0; - for (kVar = 0; kVar < nVar; kVar++) - Proj_ModJac_Tensor_ij += P_Tensor[iVar][kVar]*Lambda[kVar]*invP_Tensor[kVar][jVar]; - - val_Jacobian_i[iVar][jVar] += (1.0-kappa)*Proj_ModJac_Tensor_ij*Area; - val_Jacobian_j[iVar][jVar] -= (1.0-kappa)*Proj_ModJac_Tensor_ij*Area; - } - } - -} diff --git a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwLMRoe_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwLMRoe_Flow.cpp deleted file mode 100644 index d47d245bf20d..000000000000 --- a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwLMRoe_Flow.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/*! - * \file CUpwLMRoe_Flow.cpp - * \brief Implementation of numerics class CUpwLMRoe_Flow. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../../include/numerics/flow/convection_upwind/CUpwLMRoe_Flow.hpp" - -CUpwLMRoe_Flow::CUpwLMRoe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : - CUpwRoeBase_Flow(val_nDim, val_nVar, config, false) {} - -CUpwLMRoe_Flow::~CUpwLMRoe_Flow() {} - -void CUpwLMRoe_Flow::FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, - su2double **val_Jacobian_j, CConfig *config) { - - /*--- Rieper, A low-Mach number fix for Roe's approximate Riemman Solver, JCP 2011 ---*/ - - unsigned short iVar, jVar, kVar, iDim; - - /*--- Clamped Mach number ---*/ - - su2double M_i = 0.0, M_j = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - M_i += Velocity_i[iDim]*Velocity_i[iDim]; - M_j += Velocity_j[iDim]*Velocity_j[iDim]; - } - M_i = sqrt(M_i / fabs(Pressure_i*Gamma/Density_i)); - M_j = sqrt(M_j / fabs(Pressure_j*Gamma/Density_j)); - - su2double zeta = max(0.05,min(max(M_i,M_j),1.0)); - - /*--- Compute wave amplitudes (characteristics) ---*/ - - su2double proj_delta_vel = 0.0, delta_vel[3]; - for (iDim = 0; iDim < nDim; iDim++) { - delta_vel[iDim] = Velocity_j[iDim] - Velocity_i[iDim]; - proj_delta_vel += delta_vel[iDim]*UnitNormal[iDim]; - } - proj_delta_vel *= zeta; - su2double delta_p = Pressure_j - Pressure_i; - su2double delta_rho = Density_j - Density_i; - - su2double delta_wave[5] = {0.0, 0.0, 0.0, 0.0, 0.0}; - if (nDim == 2) { - delta_wave[0] = delta_rho - delta_p/RoeSoundSpeed2; - delta_wave[1] = (UnitNormal[1]*delta_vel[0]-UnitNormal[0]*delta_vel[1]); - delta_wave[2] = proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); - delta_wave[3] = -proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); - } else { - delta_wave[0] = delta_rho - delta_p/RoeSoundSpeed2; - delta_wave[1] = (UnitNormal[0]*delta_vel[2]-UnitNormal[2]*delta_vel[0]); - delta_wave[2] = (UnitNormal[1]*delta_vel[0]-UnitNormal[0]*delta_vel[1]); - delta_wave[3] = proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); - delta_wave[4] = -proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); - } - - /*--- Update residual ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - for (kVar = 0; kVar < nVar; kVar++) - val_residual[iVar] -= (1.0-kappa)*Lambda[kVar]*delta_wave[kVar]*P_Tensor[iVar][kVar]*Area; - - if (!implicit) return; - - /*--- If implicit use the Jacobians of the standard Roe scheme as an approximation ---*/ - - GetPMatrix_inv(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, invP_Tensor); - - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - /*--- Compute |Proj_ModJac_Tensor| = P x |Lambda| x inverse P ---*/ - su2double Proj_ModJac_Tensor_ij = 0.0; - for (kVar = 0; kVar < nVar; kVar++) - Proj_ModJac_Tensor_ij += P_Tensor[iVar][kVar]*Lambda[kVar]*invP_Tensor[kVar][jVar]; - - val_Jacobian_i[iVar][jVar] += (1.0-kappa)*Proj_ModJac_Tensor_ij*Area; - val_Jacobian_j[iVar][jVar] -= (1.0-kappa)*Proj_ModJac_Tensor_ij*Area; - } - } - -} diff --git a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwRoeBase_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwRoeBase_Flow.cpp deleted file mode 100644 index 7b5cc491e2c1..000000000000 --- a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwRoeBase_Flow.cpp +++ /dev/null @@ -1,242 +0,0 @@ -/*! - * \file CUpwRoeBase_Flow.cpp - * \brief Implementation of numerics class CUpwRoeBase_Flow. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../../include/numerics/flow/convection_upwind/CUpwRoeBase_Flow.hpp" - -CUpwRoeBase_Flow::CUpwRoeBase_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, - bool val_low_dissipation) : CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ - dynamic_grid = config->GetDynamic_Grid(); - kappa = config->GetRoe_Kappa(); // 1 is unstable - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - roe_low_dissipation = val_low_dissipation; - - Diff_U = new su2double [nVar]; - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; - RoeVelocity = new su2double [nDim]; - ProjFlux_i = new su2double [nVar]; - ProjFlux_j = new su2double [nVar]; - Conservatives_i = new su2double [nVar]; - Conservatives_j = new su2double [nVar]; - Lambda = new su2double [nVar]; - P_Tensor = new su2double* [nVar]; - invP_Tensor = new su2double* [nVar]; - for (unsigned short iVar = 0; iVar < nVar; iVar++) { - P_Tensor[iVar] = new su2double [nVar]; - invP_Tensor[iVar] = new su2double [nVar]; - } -} - -CUpwRoeBase_Flow::~CUpwRoeBase_Flow(void) { - - delete [] Diff_U; - delete [] Velocity_i; - delete [] Velocity_j; - delete [] RoeVelocity; - delete [] ProjFlux_i; - delete [] ProjFlux_j; - delete [] Conservatives_i; - delete [] Conservatives_j; - delete [] Lambda; - for (unsigned short iVar = 0; iVar < nVar; iVar++) { - delete [] P_Tensor[iVar]; - delete [] invP_Tensor[iVar]; - } - delete [] P_Tensor; - delete [] invP_Tensor; - -} - -void CUpwRoeBase_Flow::FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { -/*--- - CUpwRoeBase_Flow::ComputeResidual initializes the residual (flux) and its Jacobians with the standard Roe averaging - fc_{1/2} = kappa*(fc_i+fc_j)*Normal. It then calls this method, which derived classes specialize, to account for - the dissipation part. ----*/ -} - -void CUpwRoeBase_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - unsigned short iVar, jVar, iDim; - su2double ProjGridVel = 0.0, Energy_i, Energy_j; - - AD::StartPreacc(); - AD::SetPreaccIn(V_i, nDim+4); AD::SetPreaccIn(V_j, nDim+4); AD::SetPreaccIn(Normal, nDim); - if (dynamic_grid) { - AD::SetPreaccIn(GridVel_i, nDim); AD::SetPreaccIn(GridVel_j, nDim); - } - if (roe_low_dissipation){ - AD::SetPreaccIn(Sensor_i); AD::SetPreaccIn(Sensor_j); - AD::SetPreaccIn(Dissipation_i); AD::SetPreaccIn(Dissipation_j); - } - - /*--- Face area (norm or the normal vector) and unit normal ---*/ - - 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; - - /*--- Primitive variables at point i ---*/ - - for (iDim = 0; iDim < nDim; iDim++) - Velocity_i[iDim] = V_i[iDim+1]; - Pressure_i = V_i[nDim+1]; - Density_i = V_i[nDim+2]; - Enthalpy_i = V_i[nDim+3]; - Energy_i = Enthalpy_i - Pressure_i/Density_i; - - /*--- Primitive variables at point j ---*/ - - for (iDim = 0; iDim < nDim; iDim++) - Velocity_j[iDim] = V_j[iDim+1]; - Pressure_j = V_j[nDim+1]; - Density_j = V_j[nDim+2]; - Enthalpy_j = V_j[nDim+3]; - Energy_j = Enthalpy_j - Pressure_j/Density_j; - - /*--- Compute variables that are common to the derived schemes ---*/ - - /*--- Roe-averaged variables at interface between i & j ---*/ - - su2double R = sqrt(fabs(Density_j/Density_i)); - RoeDensity = R*Density_i; - su2double sq_vel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - RoeVelocity[iDim] = (R*Velocity_j[iDim]+Velocity_i[iDim])/(R+1); - sq_vel += RoeVelocity[iDim]*RoeVelocity[iDim]; - } - RoeEnthalpy = (R*Enthalpy_j+Enthalpy_i)/(R+1); - RoeSoundSpeed2 = (Gamma-1)*(RoeEnthalpy-0.5*sq_vel); - - /*--- Negative RoeSoundSpeed^2, the jump variables is too large, clear fluxes and exit. ---*/ - - if (RoeSoundSpeed2 <= 0.0) { - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] = 0.0; - if (implicit){ - for (jVar = 0; jVar < nVar; jVar++) { - val_Jacobian_i[iVar][jVar] = 0.0; - val_Jacobian_j[iVar][jVar] = 0.0; - } - } - } - AD::SetPreaccOut(val_residual, nVar); - AD::EndPreacc(); - return; - } - - RoeSoundSpeed = sqrt(RoeSoundSpeed2); - - /*--- P tensor ---*/ - - GetPMatrix(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, P_Tensor); - - /*--- Projected velocity adjusted for mesh motion ---*/ - - ProjVelocity = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjVelocity += RoeVelocity[iDim]*UnitNormal[iDim]; - - if (dynamic_grid) { - for (iDim = 0; iDim < nDim; iDim++) - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*UnitNormal[iDim]; - ProjVelocity -= ProjGridVel; - } - - /*--- Flow eigenvalues ---*/ - - for (iDim = 0; iDim < nDim; iDim++) - Lambda[iDim] = ProjVelocity; - - Lambda[nVar-2] = ProjVelocity + RoeSoundSpeed; - Lambda[nVar-1] = ProjVelocity - RoeSoundSpeed; - - /*--- Apply Mavriplis' entropy correction to eigenvalues ---*/ - - su2double MaxLambda = fabs(ProjVelocity) + RoeSoundSpeed; - - for (iVar = 0; iVar < nVar; iVar++) - Lambda[iVar] = max(fabs(Lambda[iVar]), config->GetEntropyFix_Coeff()*MaxLambda); - - /*--- Reconstruct conservative variables ---*/ - - Conservatives_i[0] = Density_i; - Conservatives_j[0] = Density_j; - - for (iDim = 0; iDim < nDim; iDim++) { - Conservatives_i[iDim+1] = Density_i*Velocity_i[iDim]; - Conservatives_j[iDim+1] = Density_j*Velocity_j[iDim]; - } - Conservatives_i[nDim+1] = Density_i*Energy_i; - Conservatives_j[nDim+1] = Density_j*Energy_j; - - /*--- Compute left and right fluxes ---*/ - - GetInviscidProjFlux(&Density_i, Velocity_i, &Pressure_i, &Enthalpy_i, Normal, ProjFlux_i); - GetInviscidProjFlux(&Density_j, Velocity_j, &Pressure_j, &Enthalpy_j, Normal, ProjFlux_j); - - /*--- Initialize residual (flux) and Jacobians ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_residual[iVar] = kappa*(ProjFlux_i[iVar]+ProjFlux_j[iVar]); - - if (implicit) { - GetInviscidProjJac(Velocity_i, &Energy_i, Normal, kappa, val_Jacobian_i); - GetInviscidProjJac(Velocity_j, &Energy_j, Normal, kappa, val_Jacobian_j); - } - - /*--- Finalize in children class ---*/ - - FinalizeResidual(val_residual, val_Jacobian_i, val_Jacobian_j, config); - - /*--- Correct for grid motion ---*/ - - if (dynamic_grid) { - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] -= ProjGridVel*Area * 0.5*(Conservatives_i[iVar]+Conservatives_j[iVar]); - - if (implicit) { - val_Jacobian_i[iVar][iVar] -= 0.5*ProjGridVel*Area; - val_Jacobian_j[iVar][iVar] -= 0.5*ProjGridVel*Area; - } - } - } - - AD::SetPreaccOut(val_residual, nVar); - AD::EndPreacc(); - -} diff --git a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwRoe_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwRoe_Flow.cpp deleted file mode 100644 index 66bb00a75450..000000000000 --- a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwRoe_Flow.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/*! - * \file CUpwRoe_Flow.cpp - * \brief Implementation of numerics class CUpwRoe_Flow. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../../include/numerics/flow/convection_upwind/CUpwRoe_Flow.hpp" - -CUpwRoe_Flow::CUpwRoe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, - bool val_low_dissipation) : CUpwRoeBase_Flow(val_nDim, val_nVar, config, val_low_dissipation) {} - -CUpwRoe_Flow::~CUpwRoe_Flow() {} - -void CUpwRoe_Flow::FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, - su2double **val_Jacobian_j, CConfig *config) { - - unsigned short iVar, jVar, kVar; - - /*--- Compute inverse P tensor ---*/ - GetPMatrix_inv(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, invP_Tensor); - - /*--- Diference between conservative variables at jPoint and iPoint ---*/ - for (iVar = 0; iVar < nVar; iVar++) - Diff_U[iVar] = Conservatives_j[iVar]-Conservatives_i[iVar]; - - /*--- Low dissipation formulation ---*/ - if (roe_low_dissipation) - SetRoe_Dissipation(Dissipation_i, Dissipation_j, Sensor_i, Sensor_j, Dissipation_ij, config); - else - Dissipation_ij = 1.0; - - /*--- Standard Roe "dissipation" ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - /*--- Compute |Proj_ModJac_Tensor| = P x |Lambda| x inverse P ---*/ - su2double Proj_ModJac_Tensor_ij = 0.0; - for (kVar = 0; kVar < nVar; kVar++) - Proj_ModJac_Tensor_ij += P_Tensor[iVar][kVar]*Lambda[kVar]*invP_Tensor[kVar][jVar]; - - /*--- Update residual and Jacobians ---*/ - val_residual[iVar] -= (1.0-kappa)*Proj_ModJac_Tensor_ij*Diff_U[jVar]*Area*Dissipation_ij; - - if(implicit){ - val_Jacobian_i[iVar][jVar] += (1.0-kappa)*Proj_ModJac_Tensor_ij*Area; - val_Jacobian_j[iVar][jVar] -= (1.0-kappa)*Proj_ModJac_Tensor_ij*Area; - } - } - } - -} diff --git a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwSLAU_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwSLAU_Flow.cpp deleted file mode 100644 index 8f5db9396a9b..000000000000 --- a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwSLAU_Flow.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/*! - * \file CUpwSLAU_Flow.cpp - * \brief Implementation of numerics class CUpwSLAU_Flow. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../../include/numerics/flow/convection_upwind/CUpwSLAU_Flow.hpp" - -CUpwSLAU_Flow::CUpwSLAU_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, bool val_low_dissipation) : - CUpwAUSMPLUS_SLAU_Base_Flow(val_nDim, val_nVar, config) { - - slau_low_diss = val_low_dissipation; - slau2 = false; -} - -CUpwSLAU_Flow::~CUpwSLAU_Flow(void) { - -} - -void CUpwSLAU_Flow::ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure) { - - /*--- Project velocities and speed of sound ---*/ - - su2double ProjVelocity_i = 0.0, ProjVelocity_j = 0.0, sq_veli = 0.0, sq_velj = 0.0; - - for (unsigned short iDim = 0; iDim < nDim; iDim++) { - ProjVelocity_i += Velocity_i[iDim]*UnitNormal[iDim]; - ProjVelocity_j += Velocity_j[iDim]*UnitNormal[iDim]; - - sq_veli += Velocity_i[iDim]*Velocity_i[iDim]; - sq_velj += Velocity_j[iDim]*Velocity_j[iDim]; - } - - su2double Energy_i = Enthalpy_i - Pressure_i/Density_i; - SoundSpeed_i = sqrt(fabs(Gamma*Gamma_Minus_One*(Energy_i-0.5*sq_veli))); - - su2double Energy_j = Enthalpy_j - Pressure_j/Density_j; - SoundSpeed_j = sqrt(fabs(Gamma*Gamma_Minus_One*(Energy_j-0.5*sq_velj))); - - /*--- Compute interface speed of sound (aF), and left/right Mach number ---*/ - - su2double aF = 0.5 * (SoundSpeed_i + SoundSpeed_j); - su2double mL = ProjVelocity_i/aF; - su2double mR = ProjVelocity_j/aF; - - /*--- Smooth function of the local Mach number---*/ - - su2double Mach_tilde = min(1.0, (1.0/aF) * sqrt(0.5*(sq_veli+sq_velj))); - su2double Chi = pow((1.0 - Mach_tilde),2.0); - su2double f_rho = -max(min(mL,0.0),-1.0) * min(max(mR,0.0),1.0); - - /*--- Mean normal velocity with density weighting ---*/ - - su2double Vn_Mag = (Density_i*fabs(ProjVelocity_i) + Density_j*fabs(ProjVelocity_j)) / (Density_i + Density_j); - su2double Vn_MagL= (1.0 - f_rho)*Vn_Mag + f_rho*fabs(ProjVelocity_i); - su2double Vn_MagR= (1.0 - f_rho)*Vn_Mag + f_rho*fabs(ProjVelocity_j); - - /*--- Mass flux function ---*/ - - mdot = 0.5 * (Density_i*(ProjVelocity_i+Vn_MagL) + Density_j*(ProjVelocity_j-Vn_MagR) - (Chi/aF)*(Pressure_j-Pressure_i)); - - /*--- Pressure function ---*/ - - su2double BetaL, BetaR, Dissipation_ij; - - if (fabs(mL) < 1.0) BetaL = 0.25*(2.0-mL)*pow((mL+1.0),2.0); - else if (mL >= 0) BetaL = 1.0; - else BetaL = 0.0; - - if (fabs(mR) < 1.0) BetaR = 0.25*(2.0+mR)*pow((mR-1.0),2.0); - else if (mR >= 0) BetaR = 0.0; - else BetaR = 1.0; - - if (slau_low_diss) - SetRoe_Dissipation(Dissipation_i, Dissipation_j, Sensor_i, Sensor_j, Dissipation_ij, config); - else - Dissipation_ij = 1.0; - - pressure = 0.5*(Pressure_i+Pressure_j) + 0.5*(BetaL-BetaR)*(Pressure_i-Pressure_j); - - if (!slau2) pressure += Dissipation_ij*(1.0-Chi)*(BetaL+BetaR-1.0)*0.5*(Pressure_i+Pressure_j); - else pressure += Dissipation_ij*sqrt(0.5*(sq_veli+sq_velj))*(BetaL+BetaR-1.0)*aF*0.5*(Density_i+Density_j); - -} - - -CUpwSLAU2_Flow::CUpwSLAU2_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, bool val_low_dissipation) : - CUpwSLAU_Flow(val_nDim, val_nVar, config, val_low_dissipation) { - - /*--- The difference between SLAU and SLAU2 is minimal, so we derive from SLAU and set this flag - so that the ComputeMassAndPressureFluxes function modifies the pressure according to SLAU2. - This is safe since this constructor is guaranteed to execute after SLAU's one. ---*/ - slau2 = true; -} - -CUpwSLAU2_Flow::~CUpwSLAU2_Flow(void) { - -} diff --git a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwTurkel_Flow.cpp b/SU2_CFD/src/numerics/flow/convection_upwind/CUpwTurkel_Flow.cpp deleted file mode 100644 index 331ba4e68ca6..000000000000 --- a/SU2_CFD/src/numerics/flow/convection_upwind/CUpwTurkel_Flow.cpp +++ /dev/null @@ -1,257 +0,0 @@ -/*! - * \file CUpwTurkel_Flow.cpp - * \brief Implementation of numerics class CUpwTurkel_Flow. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../../include/numerics/flow/convection_upwind/CUpwTurkel_Flow.hpp" - -CUpwTurkel_Flow::CUpwTurkel_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ - dynamic_grid = config->GetDynamic_Grid(); - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - Beta_min = config->GetminTurkelBeta(); - Beta_max = config->GetmaxTurkelBeta(); - - Diff_U = new su2double [nVar]; - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; - RoeVelocity = new su2double [nDim]; - ProjFlux_i = new su2double [nVar]; - ProjFlux_j = new su2double [nVar]; - Lambda = new su2double [nVar]; - Epsilon = new su2double [nVar]; - absPeJac = new su2double* [nVar]; - invRinvPe = new su2double* [nVar]; - R_Tensor = new su2double* [nVar]; - Matrix = new su2double* [nVar]; - Art_Visc = new su2double* [nVar]; - for (iVar = 0; iVar < nVar; iVar++) { - absPeJac[iVar] = new su2double [nVar]; - invRinvPe[iVar] = new su2double [nVar]; - Matrix[iVar] = new su2double [nVar]; - Art_Visc[iVar] = new su2double [nVar]; - R_Tensor[iVar] = new su2double [nVar]; - } -} - -CUpwTurkel_Flow::~CUpwTurkel_Flow(void) { - - delete [] Diff_U; - delete [] Velocity_i; - delete [] Velocity_j; - delete [] RoeVelocity; - delete [] ProjFlux_i; - delete [] ProjFlux_j; - delete [] Lambda; - delete [] Epsilon; - for (iVar = 0; iVar < nVar; iVar++) { - delete [] absPeJac[iVar]; - delete [] invRinvPe[iVar]; - delete [] Matrix[iVar]; - delete [] Art_Visc[iVar]; - delete [] R_Tensor[iVar]; - } - delete [] Matrix; - delete [] Art_Visc; - delete [] absPeJac; - delete [] invRinvPe; - delete [] R_Tensor; - -} - -void CUpwTurkel_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - su2double U_i[5] = {0.0,0.0,0.0,0.0,0.0}, U_j[5] = {0.0,0.0,0.0,0.0,0.0}; - - /*--- Face area (norm or the normal vector) ---*/ - - Area = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - Area += Normal[iDim]*Normal[iDim]; - Area = sqrt(Area); - - /*-- Unit Normal ---*/ - - for (iDim = 0; iDim < nDim; iDim++) - UnitNormal[iDim] = Normal[iDim]/Area; - - /*--- Primitive variables at point i ---*/ - - for (iDim = 0; iDim < nDim; iDim++) - Velocity_i[iDim] = V_i[iDim+1]; - Pressure_i = V_i[nDim+1]; - Density_i = V_i[nDim+2]; - Enthalpy_i = V_i[nDim+3]; - Energy_i = Enthalpy_i - Pressure_i/Density_i; - SoundSpeed_i = sqrt(fabs(Pressure_i*Gamma/Density_i)); - - /*--- Primitive variables at point j ---*/ - - for (iDim = 0; iDim < nDim; iDim++) - Velocity_j[iDim] = V_j[iDim+1]; - Pressure_j = V_j[nDim+1]; - Density_j = V_j[nDim+2]; - Enthalpy_j = V_j[nDim+3]; - Energy_j = Enthalpy_j - Pressure_j/Density_j; - SoundSpeed_j = sqrt(fabs(Pressure_j*Gamma/Density_j)); - - /*--- Recompute conservative variables ---*/ - - U_i[0] = Density_i; U_j[0] = Density_j; - for (iDim = 0; iDim < nDim; iDim++) { - U_i[iDim+1] = Density_i*Velocity_i[iDim]; U_j[iDim+1] = Density_j*Velocity_j[iDim]; - } - U_i[nDim+1] = Density_i*Energy_i; U_j[nDim+1] = Density_j*Energy_j; - - /*--- Roe-averaged variables at interface between i & j ---*/ - - R = sqrt(fabs(Density_j/Density_i)); - RoeDensity = R*Density_i; - sq_vel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - RoeVelocity[iDim] = (R*Velocity_j[iDim]+Velocity_i[iDim])/(R+1); - sq_vel += RoeVelocity[iDim]*RoeVelocity[iDim]; - } - RoeEnthalpy = (R*Enthalpy_j+Enthalpy_i)/(R+1); - RoeSoundSpeed = sqrt(fabs((Gamma-1)*(RoeEnthalpy-0.5*sq_vel))); - RoePressure = RoeDensity/Gamma*RoeSoundSpeed*RoeSoundSpeed; - - /*--- Compute ProjFlux_i ---*/ - GetInviscidProjFlux(&Density_i, Velocity_i, &Pressure_i, &Enthalpy_i, Normal, ProjFlux_i); - - /*--- Compute ProjFlux_j ---*/ - GetInviscidProjFlux(&Density_j, Velocity_j, &Pressure_j, &Enthalpy_j, Normal, ProjFlux_j); - - ProjVelocity = 0.0; ProjVelocity_i = 0.0; ProjVelocity_j = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - ProjVelocity += RoeVelocity[iDim]*UnitNormal[iDim]; - ProjVelocity_i += Velocity_i[iDim]*UnitNormal[iDim]; - ProjVelocity_j += Velocity_j[iDim]*UnitNormal[iDim]; - } - - /*--- Projected velocity adjustment due to mesh motion ---*/ - if (dynamic_grid) { - su2double ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*UnitNormal[iDim]; - } - ProjVelocity -= ProjGridVel; - ProjVelocity_i -= ProjGridVel; - ProjVelocity_j -= ProjGridVel; - } - - /*--- First few flow eigenvalues of A.Normal with the normal---*/ - for (iDim = 0; iDim < nDim; iDim++) - Lambda[iDim] = ProjVelocity; - - local_Mach = sqrt(sq_vel)/RoeSoundSpeed; - Beta = max(Beta_min, min(local_Mach, Beta_max)); - Beta2 = Beta*Beta; - - one_m_Betasqr = 1.0 - Beta2; // 1-Beta*Beta - one_p_Betasqr = 1.0 + Beta2; // 1+Beta*Beta - sqr_one_m_Betasqr_Lam1 = pow((one_m_Betasqr*Lambda[0]),2); // [(1-Beta^2)*Lambda[0]]^2 - sqr_two_Beta_c_Area = pow(2.0*Beta*RoeSoundSpeed*Area,2); // [2*Beta*c*Area]^2 - - /*--- The rest of the flow eigenvalues of preconditioned matrix---*/ - Lambda[nVar-2] = 0.5 * ( one_p_Betasqr*Lambda[0] + sqrt( sqr_one_m_Betasqr_Lam1 + sqr_two_Beta_c_Area)); - Lambda[nVar-1] = 0.5 * ( one_p_Betasqr*Lambda[0] - sqrt( sqr_one_m_Betasqr_Lam1 + sqr_two_Beta_c_Area)); - - s_hat = 1.0/Area * (Lambda[nVar-1] - Lambda[0]*Beta2); - r_hat = 1.0/Area * (Lambda[nVar-2] - Lambda[0]*Beta2); - t_hat = 0.5/Area * (Lambda[nVar-1] - Lambda[nVar-2]); - rhoB2a2 = RoeDensity*Beta2*RoeSoundSpeed*RoeSoundSpeed; - - /*--- Diference variables iPoint and jPoint and absolute value of the eigen values---*/ - for (iVar = 0; iVar < nVar; iVar++) { - Diff_U[iVar] = U_j[iVar]-U_i[iVar]; - Lambda[iVar] = fabs(Lambda[iVar]); - } - - /*--- Compute the absolute Preconditioned Jacobian in entropic Variables (do it with the Unitary Normal) ---*/ - GetPrecondJacobian(Beta2, r_hat, s_hat, t_hat, rhoB2a2, Lambda, UnitNormal, absPeJac); - - /*--- Compute the matrix from entropic variables to conserved variables ---*/ - GetinvRinvPe(Beta2, RoeEnthalpy, RoeSoundSpeed, RoeDensity, RoeVelocity, invRinvPe); - - /*--- Compute the matrix from entropic variables to conserved variables ---*/ - GetRMatrix(RoePressure, RoeSoundSpeed, RoeDensity, RoeVelocity, R_Tensor); - - if (implicit) { - /*--- Jacobians of the inviscid flux, scaled by - 0.5 because val_residual ~ 0.5*(fc_i+fc_j)*Normal ---*/ - GetInviscidProjJac(Velocity_i, &Energy_i, Normal, 0.5, val_Jacobian_i); - GetInviscidProjJac(Velocity_j, &Energy_j, Normal, 0.5, val_Jacobian_j); - } - - for (iVar = 0; iVar < nVar; iVar ++) { - for (jVar = 0; jVar < nVar; jVar ++) { - Matrix[iVar][jVar] = 0.0; - for (kVar = 0; kVar < nVar; kVar++) - Matrix[iVar][jVar] += absPeJac[iVar][kVar]*R_Tensor[kVar][jVar]; - } - } - - for (iVar = 0; iVar < nVar; iVar ++) { - for (jVar = 0; jVar < nVar; jVar ++) { - Art_Visc[iVar][jVar] = 0.0; - for (kVar = 0; kVar < nVar; kVar++) - Art_Visc[iVar][jVar] += invRinvPe[iVar][kVar]*Matrix[kVar][jVar]; - } - } - - /*--- Roe's Flux approximation ---*/ - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] = 0.5*(ProjFlux_i[iVar]+ProjFlux_j[iVar]); - for (jVar = 0; jVar < nVar; jVar++) { - val_residual[iVar] -= 0.5*Art_Visc[iVar][jVar]*Diff_U[jVar]; - if (implicit) { - val_Jacobian_i[iVar][jVar] += 0.5*Art_Visc[iVar][jVar]; - val_Jacobian_j[iVar][jVar] -= 0.5*Art_Visc[iVar][jVar]; - } - } - } - - /*--- Contributions due to mesh motion---*/ - if (dynamic_grid) { - ProjVelocity = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjVelocity += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*UnitNormal[iDim]; - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] -= ProjVelocity * 0.5*(U_i[iVar]+U_j[iVar]); - /*--- Implicit terms ---*/ - if (implicit) { - val_Jacobian_i[iVar][iVar] -= 0.5*ProjVelocity; - val_Jacobian_j[iVar][iVar] -= 0.5*ProjVelocity; - } - } - } - -} diff --git a/SU2_CFD/src/numerics/flow/diffusion/CAvgGradInc_Flow.cpp b/SU2_CFD/src/numerics/flow/diffusion/CAvgGradInc_Flow.cpp deleted file mode 100644 index 32227b9403c2..000000000000 --- a/SU2_CFD/src/numerics/flow/diffusion/CAvgGradInc_Flow.cpp +++ /dev/null @@ -1,274 +0,0 @@ -/*! - * \file CAvgGradInc_Flow.cpp - * \brief Implementation of numerics class CAvgGradInc_Flow. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../../include/numerics/flow/diffusion/CAvgGradInc_Flow.hpp" - -CAvgGradInc_Flow::CAvgGradInc_Flow(unsigned short val_nDim, - unsigned short val_nVar, - bool val_correct_grad, CConfig *config) - : CAvgGrad_Base(val_nDim, val_nVar, val_nDim+3, val_correct_grad, config) { - - energy = config->GetEnergy_Equation(); - -} - -CAvgGradInc_Flow::~CAvgGradInc_Flow(void) { -} - -void CAvgGradInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - AD::StartPreacc(); - AD::SetPreaccIn(V_i, nDim+9); AD::SetPreaccIn(V_j, nDim+9); - AD::SetPreaccIn(Coord_i, nDim); AD::SetPreaccIn(Coord_j, nDim); - AD::SetPreaccIn(PrimVar_Grad_i, nVar, nDim); - AD::SetPreaccIn(PrimVar_Grad_j, nVar, nDim); - AD::SetPreaccIn(turb_ke_i); AD::SetPreaccIn(turb_ke_j); - AD::SetPreaccIn(Normal, nDim); - - unsigned short iVar, jVar, iDim; - - /*--- Normalized normal vector ---*/ - - 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; - - for (iVar = 0; iVar < nPrimVar; iVar++) { - PrimVar_i[iVar] = V_i[iVar]; - PrimVar_j[iVar] = V_j[iVar]; - Mean_PrimVar[iVar] = 0.5*(PrimVar_i[iVar]+PrimVar_j[iVar]); - } - - /*--- Compute vector going from iPoint to jPoint ---*/ - - dist_ij_2 = 0.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]; - } - - /*--- Density and transport properties ---*/ - - Laminar_Viscosity_i = V_i[nDim+4]; Laminar_Viscosity_j = V_j[nDim+4]; - Eddy_Viscosity_i = V_i[nDim+5]; Eddy_Viscosity_j = V_j[nDim+5]; - Thermal_Conductivity_i = V_i[nDim+6]; Thermal_Conductivity_j = V_j[nDim+6]; - - /*--- Mean transport properties ---*/ - - Mean_Laminar_Viscosity = 0.5*(Laminar_Viscosity_i + Laminar_Viscosity_j); - Mean_Eddy_Viscosity = 0.5*(Eddy_Viscosity_i + Eddy_Viscosity_j); - Mean_turb_ke = 0.5*(turb_ke_i + turb_ke_j); - Mean_Thermal_Conductivity = 0.5*(Thermal_Conductivity_i + Thermal_Conductivity_j); - - /*--- Mean gradient approximation ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - for (iDim = 0; iDim < nDim; iDim++) - Mean_GradPrimVar[iVar][iDim] = 0.5*(PrimVar_Grad_i[iVar][iDim] + PrimVar_Grad_j[iVar][iDim]); - - /*--- Projection of the mean gradient in the direction of the edge ---*/ - - if (correct_gradient && dist_ij_2 != 0.0) { - CorrectGradient(Mean_GradPrimVar, PrimVar_i, PrimVar_j, Edge_Vector, - dist_ij_2, nVar); - } - - /*--- Get projected flux tensor ---*/ - SetStressTensor(Mean_PrimVar, Mean_GradPrimVar, Mean_turb_ke, - Mean_Laminar_Viscosity, Mean_Eddy_Viscosity); - GetViscousIncProjFlux(Mean_GradPrimVar, Normal, Mean_Thermal_Conductivity); - - /*--- Update viscous residual ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] = Proj_Flux_Tensor[iVar]; - } - - /*--- Implicit part ---*/ - - if (implicit) { - - if (dist_ij_2 == 0.0) { - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - val_Jacobian_i[iVar][jVar] = 0.0; - val_Jacobian_j[iVar][jVar] = 0.0; - } - } - } else { - - const su2double dist_ij = sqrt(dist_ij_2); - SetIncTauJacobian(Mean_Laminar_Viscosity, Mean_Eddy_Viscosity, - dist_ij, UnitNormal); - GetViscousIncProjJacs(Area, val_Jacobian_i, val_Jacobian_j); - - /*--- Include the temperature equation Jacobian. ---*/ - su2double proj_vector_ij = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - proj_vector_ij += (Coord_j[iDim]-Coord_i[iDim])*Normal[iDim]; - } - proj_vector_ij = proj_vector_ij/dist_ij_2; - val_Jacobian_i[nDim+1][nDim+1] = -Mean_Thermal_Conductivity*proj_vector_ij; - val_Jacobian_j[nDim+1][nDim+1] = Mean_Thermal_Conductivity*proj_vector_ij; - } - - } - - if (!energy) { - val_residual[nDim+1] = 0.0; - if (implicit) { - for (iVar = 0; iVar < nVar; iVar++) { - val_Jacobian_i[iVar][nDim+1] = 0.0; - val_Jacobian_j[iVar][nDim+1] = 0.0; - - val_Jacobian_i[nDim+1][iVar] = 0.0; - val_Jacobian_j[nDim+1][iVar] = 0.0; - } - } - } - - AD::SetPreaccOut(val_residual, nVar); - AD::EndPreacc(); - -} - -void CAvgGradInc_Flow::GetViscousIncProjFlux(const su2double* const *val_gradprimvar, - const su2double *val_normal, - su2double val_thermal_conductivity) { - - /*--- Gradient of primitive variables -> [Pressure vel_x vel_y vel_z Temperature] ---*/ - - if (nDim == 2) { - Flux_Tensor[0][0] = 0.0; - Flux_Tensor[1][0] = tau[0][0]; - Flux_Tensor[2][0] = tau[0][1]; - Flux_Tensor[3][0] = val_thermal_conductivity*val_gradprimvar[nDim+1][0]; - - Flux_Tensor[0][1] = 0.0; - Flux_Tensor[1][1] = tau[1][0]; - Flux_Tensor[2][1] = tau[1][1]; - Flux_Tensor[3][1] = val_thermal_conductivity*val_gradprimvar[nDim+1][1]; - - } else { - - Flux_Tensor[0][0] = 0.0; - Flux_Tensor[1][0] = tau[0][0]; - Flux_Tensor[2][0] = tau[0][1]; - Flux_Tensor[3][0] = tau[0][2]; - Flux_Tensor[4][0] = val_thermal_conductivity*val_gradprimvar[nDim+1][0]; - - Flux_Tensor[0][1] = 0.0; - Flux_Tensor[1][1] = tau[1][0]; - Flux_Tensor[2][1] = tau[1][1]; - Flux_Tensor[3][1] = tau[1][2]; - Flux_Tensor[4][1] = val_thermal_conductivity*val_gradprimvar[nDim+1][1]; - - Flux_Tensor[0][2] = 0.0; - Flux_Tensor[1][2] = tau[2][0]; - Flux_Tensor[2][2] = tau[2][1]; - Flux_Tensor[3][2] = tau[2][2]; - Flux_Tensor[4][2] = val_thermal_conductivity*val_gradprimvar[nDim+1][2]; - - } - - for (unsigned short iVar = 0; iVar < nVar; iVar++) { - Proj_Flux_Tensor[iVar] = 0.0; - for (unsigned short iDim = 0; iDim < nDim; iDim++) - Proj_Flux_Tensor[iVar] += Flux_Tensor[iVar][iDim] * val_normal[iDim]; - } - -} - -void CAvgGradInc_Flow::GetViscousIncProjJacs(su2double val_dS, - su2double **val_Proj_Jac_Tensor_i, - su2double **val_Proj_Jac_Tensor_j) { - - if (nDim == 2) { - - val_Proj_Jac_Tensor_i[0][0] = 0.0; - val_Proj_Jac_Tensor_i[0][1] = 0.0; - val_Proj_Jac_Tensor_i[0][2] = 0.0; - val_Proj_Jac_Tensor_i[0][3] = 0.0; - - val_Proj_Jac_Tensor_i[1][0] = val_dS*tau_jacobian_i[0][0]; - val_Proj_Jac_Tensor_i[1][1] = val_dS*tau_jacobian_i[0][1]; - val_Proj_Jac_Tensor_i[1][2] = val_dS*tau_jacobian_i[0][2]; - val_Proj_Jac_Tensor_i[1][3] = val_dS*tau_jacobian_i[0][3]; - - val_Proj_Jac_Tensor_i[2][0] = val_dS*tau_jacobian_i[1][0]; - val_Proj_Jac_Tensor_i[2][1] = val_dS*tau_jacobian_i[1][1]; - val_Proj_Jac_Tensor_i[2][2] = val_dS*tau_jacobian_i[1][2]; - val_Proj_Jac_Tensor_i[2][3] = val_dS*tau_jacobian_i[1][3]; - - val_Proj_Jac_Tensor_i[3][0] = 0.0; - val_Proj_Jac_Tensor_i[3][1] = 0.0; - val_Proj_Jac_Tensor_i[3][2] = 0.0; - val_Proj_Jac_Tensor_i[3][3] = 0.0; - - } else { - - val_Proj_Jac_Tensor_i[0][0] = 0.0; - val_Proj_Jac_Tensor_i[0][1] = 0.0; - val_Proj_Jac_Tensor_i[0][2] = 0.0; - val_Proj_Jac_Tensor_i[0][3] = 0.0; - val_Proj_Jac_Tensor_i[0][4] = 0.0; - - val_Proj_Jac_Tensor_i[1][0] = val_dS*tau_jacobian_i[0][0]; - val_Proj_Jac_Tensor_i[1][1] = val_dS*tau_jacobian_i[0][1]; - val_Proj_Jac_Tensor_i[1][2] = val_dS*tau_jacobian_i[0][2]; - val_Proj_Jac_Tensor_i[1][3] = val_dS*tau_jacobian_i[0][3]; - val_Proj_Jac_Tensor_i[1][4] = val_dS*tau_jacobian_i[0][4]; - - val_Proj_Jac_Tensor_i[2][0] = val_dS*tau_jacobian_i[1][0]; - val_Proj_Jac_Tensor_i[2][1] = val_dS*tau_jacobian_i[1][1]; - val_Proj_Jac_Tensor_i[2][2] = val_dS*tau_jacobian_i[1][2]; - val_Proj_Jac_Tensor_i[2][3] = val_dS*tau_jacobian_i[1][3]; - val_Proj_Jac_Tensor_i[2][4] = val_dS*tau_jacobian_i[1][4]; - - val_Proj_Jac_Tensor_i[3][0] = val_dS*tau_jacobian_i[2][0]; - val_Proj_Jac_Tensor_i[3][1] = val_dS*tau_jacobian_i[2][1]; - val_Proj_Jac_Tensor_i[3][2] = val_dS*tau_jacobian_i[2][2]; - val_Proj_Jac_Tensor_i[3][3] = val_dS*tau_jacobian_i[2][3]; - val_Proj_Jac_Tensor_i[3][4] = val_dS*tau_jacobian_i[2][4]; - - val_Proj_Jac_Tensor_i[4][0] = 0.0; - val_Proj_Jac_Tensor_i[4][1] = 0.0; - val_Proj_Jac_Tensor_i[4][2] = 0.0; - val_Proj_Jac_Tensor_i[4][3] = 0.0; - val_Proj_Jac_Tensor_i[4][4] = 0.0; - - } - - for (unsigned short iVar = 0; iVar < nVar; iVar++) - for (unsigned short jVar = 0; jVar < nVar; jVar++) - val_Proj_Jac_Tensor_j[iVar][jVar] = -val_Proj_Jac_Tensor_i[iVar][jVar]; - -} diff --git a/SU2_CFD/src/numerics/flow/diffusion/CAvgGrad_Base.cpp b/SU2_CFD/src/numerics/flow/diffusion/CAvgGrad_Base.cpp deleted file mode 100644 index b15a0990f5d1..000000000000 --- a/SU2_CFD/src/numerics/flow/diffusion/CAvgGrad_Base.cpp +++ /dev/null @@ -1,560 +0,0 @@ -/*! - * \file CAvgGrad_Base.cpp - * \brief Implementation of numerics class CAvgGrad_Base. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../../include/numerics/flow/diffusion/CAvgGrad_Base.hpp" - -CAvgGrad_Base::CAvgGrad_Base(unsigned short val_nDim, - unsigned short val_nVar, - unsigned short val_nPrimVar, - bool val_correct_grad, - CConfig *config) - : CNumerics(val_nDim, val_nVar, config), - nPrimVar(val_nPrimVar), - correct_gradient(val_correct_grad) { - - unsigned short iVar, iDim; - - implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - - TauWall_i = 0; TauWall_j = 0; - - PrimVar_i = new su2double [nPrimVar]; - PrimVar_j = new su2double [nPrimVar]; - Mean_PrimVar = new su2double [nPrimVar]; - - Mean_GradPrimVar = new su2double* [nPrimVar]; - for (iVar = 0; iVar < nPrimVar; iVar++) - Mean_GradPrimVar[iVar] = new su2double [nDim]; - - Edge_Vector = new su2double[nDim]; - - if (correct_gradient) { - Proj_Mean_GradPrimVar_Edge = new su2double[val_nPrimVar]; - } else { - Proj_Mean_GradPrimVar_Edge = NULL; - } - - tau_jacobian_i = new su2double* [nDim]; - for (iDim = 0; iDim < nDim; iDim++) { - tau_jacobian_i[iDim] = new su2double [nVar]; - } - heat_flux_vector = new su2double[nDim]; - heat_flux_jac_i = new su2double[nVar]; - -} - -CAvgGrad_Base::~CAvgGrad_Base() { - - delete [] PrimVar_i; - delete [] PrimVar_j; - delete [] Mean_PrimVar; - for (unsigned short iVar = 0; iVar < nPrimVar; iVar++) - delete [] Mean_GradPrimVar[iVar]; - delete [] Mean_GradPrimVar; - - if (tau_jacobian_i != NULL) { - for (unsigned short iDim = 0; iDim < nDim; iDim++) { - delete [] tau_jacobian_i[iDim]; - } - delete [] tau_jacobian_i; - } - if (heat_flux_vector != NULL) { - delete [] heat_flux_vector; - } - if (heat_flux_jac_i != NULL) { - delete [] heat_flux_jac_i; - } - - delete [] Edge_Vector; - if (Proj_Mean_GradPrimVar_Edge != NULL) - delete [] Proj_Mean_GradPrimVar_Edge; -} - -void CAvgGrad_Base::CorrectGradient(su2double** GradPrimVar, - const su2double* val_PrimVar_i, - const su2double* val_PrimVar_j, - const su2double* val_edge_vector, - const su2double val_dist_ij_2, - const unsigned short val_nPrimVar) { - for (unsigned short iVar = 0; iVar < val_nPrimVar; iVar++) { - Proj_Mean_GradPrimVar_Edge[iVar] = 0.0; - for (unsigned short iDim = 0; iDim < nDim; iDim++) { - Proj_Mean_GradPrimVar_Edge[iVar] += GradPrimVar[iVar][iDim]*val_edge_vector[iDim]; - } - for (unsigned short iDim = 0; iDim < nDim; iDim++) { - GradPrimVar[iVar][iDim] -= (Proj_Mean_GradPrimVar_Edge[iVar] - - (val_PrimVar_j[iVar]-val_PrimVar_i[iVar]))*val_edge_vector[iDim] / val_dist_ij_2; - } - } -} - -void CAvgGrad_Base::SetStressTensor(const su2double *val_primvar, - const su2double* const *val_gradprimvar, - const su2double val_turb_ke, - const su2double val_laminar_viscosity, - const su2double val_eddy_viscosity) { - - unsigned short iDim, jDim; - const su2double Density = val_primvar[nDim+2]; - const su2double total_viscosity = val_laminar_viscosity + val_eddy_viscosity; - - su2double div_vel = 0.0; - for (iDim = 0 ; iDim < nDim; iDim++) - div_vel += val_gradprimvar[iDim+1][iDim]; - - /* --- If UQ methodology is used, calculate tau using the perturbed reynolds stress tensor --- */ - - if (using_uq){ - for (iDim = 0 ; iDim < nDim; iDim++) - for (jDim = 0 ; jDim < nDim; jDim++) - tau[iDim][jDim] = val_laminar_viscosity*( val_gradprimvar[jDim+1][iDim] + val_gradprimvar[iDim+1][jDim] ) - - TWO3*val_laminar_viscosity*div_vel*delta[iDim][jDim] - Density * MeanPerturbedRSM[iDim][jDim]; - - } else { - - 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]; - } -} - -void CAvgGrad_Base::AddQCR(const su2double* const *val_gradprimvar) { - - su2double den_aux, c_cr1= 0.3, O_ik, O_jk; - unsigned short iDim, jDim, kDim; - - /*--- Denominator Antisymmetric normalized rotation tensor ---*/ - - den_aux = 0.0; - for (iDim = 0 ; iDim < nDim; iDim++) - for (jDim = 0 ; jDim < nDim; jDim++) - den_aux += val_gradprimvar[iDim+1][jDim] * val_gradprimvar[iDim+1][jDim]; - den_aux = sqrt(max(den_aux,1E-10)); - - /*--- Adding the QCR contribution ---*/ - - for (iDim = 0 ; iDim < nDim; iDim++){ - for (jDim = 0 ; jDim < nDim; jDim++){ - for (kDim = 0 ; kDim < nDim; kDim++){ - O_ik = (val_gradprimvar[iDim+1][kDim] - val_gradprimvar[kDim+1][iDim])/ den_aux; - O_jk = (val_gradprimvar[jDim+1][kDim] - val_gradprimvar[kDim+1][jDim])/ den_aux; - tau[iDim][jDim] -= c_cr1 * ((O_ik * tau[jDim][kDim]) + (O_jk * tau[iDim][kDim])); - } - } - } -} - -void CAvgGrad_Base::AddTauWall(const su2double *val_normal, - const su2double val_tau_wall) { - - unsigned short iDim, jDim; - su2double TauNormal, TauElem[3], TauTangent[3], WallShearStress, Area, UnitNormal[3]; - - Area = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - Area += val_normal[iDim]*val_normal[iDim]; - Area = sqrt(Area); - - for (iDim = 0; iDim < nDim; iDim++) - UnitNormal[iDim] = val_normal[iDim]/Area; - - /*--- First, compute wall shear stress as the magnitude of the wall-tangential - component of the shear stress tensor---*/ - - for (iDim = 0; iDim < nDim; iDim++) { - TauElem[iDim] = 0.0; - for (jDim = 0; jDim < nDim; jDim++) - TauElem[iDim] += tau[iDim][jDim]*UnitNormal[jDim]; - } - - TauNormal = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - TauNormal += TauElem[iDim] * UnitNormal[iDim]; - - for (iDim = 0; iDim < nDim; iDim++) - TauTangent[iDim] = TauElem[iDim] - TauNormal * UnitNormal[iDim]; - - WallShearStress = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - WallShearStress += TauTangent[iDim]*TauTangent[iDim]; - WallShearStress = sqrt(WallShearStress); - - /*--- Scale the stress tensor by the ratio of the wall shear stress - to the computed representation of the shear stress ---*/ - - for (iDim = 0 ; iDim < nDim; iDim++) - for (jDim = 0 ; jDim < nDim; jDim++) - tau[iDim][jDim] = tau[iDim][jDim]*(val_tau_wall/WallShearStress); -} - -void CAvgGrad_Base::GetMeanRateOfStrainMatrix(su2double **S_ij) const -{ - /* --- Calculate the rate of strain tensor, using mean velocity gradients --- */ - - if (nDim == 3){ - S_ij[0][0] = Mean_GradPrimVar[1][0]; - S_ij[1][1] = Mean_GradPrimVar[2][1]; - S_ij[2][2] = Mean_GradPrimVar[3][2]; - S_ij[0][1] = 0.5 * (Mean_GradPrimVar[1][1] + Mean_GradPrimVar[2][0]); - S_ij[0][2] = 0.5 * (Mean_GradPrimVar[1][2] + Mean_GradPrimVar[3][0]); - S_ij[1][2] = 0.5 * (Mean_GradPrimVar[2][2] + Mean_GradPrimVar[3][1]); - S_ij[1][0] = S_ij[0][1]; - S_ij[2][1] = S_ij[1][2]; - S_ij[2][0] = S_ij[0][2]; - } - else { - S_ij[0][0] = Mean_GradPrimVar[1][0]; - S_ij[1][1] = Mean_GradPrimVar[2][1]; - S_ij[2][2] = 0.0; - S_ij[0][1] = 0.5 * (Mean_GradPrimVar[1][1] + Mean_GradPrimVar[2][0]); - S_ij[0][2] = 0.0; - S_ij[1][2] = 0.0; - S_ij[1][0] = S_ij[0][1]; - S_ij[2][1] = S_ij[1][2]; - S_ij[2][0] = S_ij[0][2]; - - } -} - -void CAvgGrad_Base::SetReynoldsStressMatrix(su2double turb_ke){ - unsigned short iDim, jDim; - su2double **S_ij = new su2double* [3]; - su2double muT = Mean_Eddy_Viscosity; - su2double divVel = 0; - su2double density; - su2double TWO3 = 2.0/3.0; - density = Mean_PrimVar[nDim+2]; - - for (iDim = 0; iDim < 3; iDim++){ - S_ij[iDim] = new su2double [3]; - } - - - GetMeanRateOfStrainMatrix(S_ij); - - /* --- Using rate of strain matrix, calculate Reynolds stress tensor --- */ - - for (iDim = 0; iDim < 3; iDim++){ - divVel += S_ij[iDim][iDim]; - } - - for (iDim = 0; iDim < 3; iDim++){ - for (jDim = 0; jDim < 3; jDim++){ - MeanReynoldsStress[iDim][jDim] = TWO3 * turb_ke * delta3[iDim][jDim] - - muT / density * (2 * S_ij[iDim][jDim] - TWO3 * divVel * delta3[iDim][jDim]); - } - } - - for (iDim = 0; iDim < 3; iDim++) - delete [] S_ij[iDim]; - delete [] S_ij; -} - -void CAvgGrad_Base::SetPerturbedRSM(su2double turb_ke, CConfig *config){ - - unsigned short iDim,jDim; - - /* --- Calculate anisotropic part of Reynolds Stress tensor --- */ - - for (iDim = 0; iDim< 3; iDim++){ - for (jDim = 0; jDim < 3; jDim++){ - A_ij[iDim][jDim] = .5 * MeanReynoldsStress[iDim][jDim] / turb_ke - delta3[iDim][jDim] / 3.0; - Eig_Vec[iDim][jDim] = A_ij[iDim][jDim]; - } - } - - /* --- Get ordered eigenvectors and eigenvalues of A_ij --- */ - - EigenDecomposition(A_ij, Eig_Vec, Eig_Val, 3); - - /* compute convex combination coefficients */ - su2double c1c = Eig_Val[2] - Eig_Val[1]; - su2double c2c = 2.0 * (Eig_Val[1] - Eig_Val[0]); - su2double c3c = 3.0 * Eig_Val[0] + 1.0; - - /* define barycentric traingle corner points */ - Corners[0][0] = 1.0; - Corners[0][1] = 0.0; - Corners[1][0] = 0.0; - Corners[1][1] = 0.0; - Corners[2][0] = 0.5; - Corners[2][1] = 0.866025; - - /* define barycentric coordinates */ - Barycentric_Coord[0] = Corners[0][0] * c1c + Corners[1][0] * c2c + Corners[2][0] * c3c; - Barycentric_Coord[1] = Corners[0][1] * c1c + Corners[1][1] * c2c + Corners[2][1] * c3c; - - if (Eig_Val_Comp == 1) { - /* 1C turbulence */ - New_Coord[0] = Corners[0][0]; - New_Coord[1] = Corners[0][1]; - } - else if (Eig_Val_Comp== 2) { - /* 2C turbulence */ - New_Coord[0] = Corners[1][0]; - New_Coord[1] = Corners[1][1]; - } - else if (Eig_Val_Comp == 3) { - /* 3C turbulence */ - New_Coord[0] = Corners[2][0]; - New_Coord[1] = Corners[2][1]; - } - else { - /* 2C turbulence */ - New_Coord[0] = Corners[1][0]; - New_Coord[1] = Corners[1][1]; - } - - /* calculate perturbed barycentric coordinates */ - Barycentric_Coord[0] = Barycentric_Coord[0] + (uq_delta_b) * (New_Coord[0] - Barycentric_Coord[0]); - Barycentric_Coord[1] = Barycentric_Coord[1] + (uq_delta_b) * (New_Coord[1] - Barycentric_Coord[1]); - - /* rebuild c1c,c2c,c3c based on perturbed barycentric coordinates */ - c3c = Barycentric_Coord[1] / Corners[2][1]; - c1c = Barycentric_Coord[0] - Corners[2][0] * c3c; - c2c = 1 - c1c - c3c; - - /* build new anisotropy eigenvalues */ - Eig_Val[0] = (c3c - 1) / 3.0; - Eig_Val[1] = 0.5 *c2c + Eig_Val[0]; - Eig_Val[2] = c1c + Eig_Val[1]; - - /* permute eigenvectors if required */ - if (uq_permute) { - for (iDim=0; iDim<3; iDim++) { - for (jDim=0; jDim<3; jDim++) { - New_Eig_Vec[iDim][jDim] = Eig_Vec[2-iDim][jDim]; - } - } - } - - else { - for (iDim=0; iDim<3; iDim++) { - for (jDim=0; jDim<3; jDim++) { - New_Eig_Vec[iDim][jDim] = Eig_Vec[iDim][jDim]; - } - } - } - - EigenRecomposition(newA_ij, New_Eig_Vec, Eig_Val, 3); - - /* compute perturbed Reynolds stress matrix; use under-relaxation factor (uq_urlx)*/ - for (iDim = 0; iDim< 3; iDim++){ - for (jDim = 0; jDim < 3; jDim++){ - MeanPerturbedRSM[iDim][jDim] = 2.0 * turb_ke * (newA_ij[iDim][jDim] + 1.0/3.0 * delta3[iDim][jDim]); - MeanPerturbedRSM[iDim][jDim] = MeanReynoldsStress[iDim][jDim] + - uq_urlx*(MeanPerturbedRSM[iDim][jDim] - MeanReynoldsStress[iDim][jDim]); - } - } - -} - - -void CAvgGrad_Base::SetTauJacobian(const su2double *val_Mean_PrimVar, - const su2double val_laminar_viscosity, - const su2double val_eddy_viscosity, - const su2double val_dist_ij, - const su2double *val_normal) { - - /*--- QCR and wall functions are **not** accounted for here ---*/ - - const su2double Density = val_Mean_PrimVar[nDim+2]; - const su2double total_viscosity = val_laminar_viscosity + val_eddy_viscosity; - const su2double xi = total_viscosity/(Density*val_dist_ij); - - for (unsigned short iDim = 0; iDim < nDim; iDim++) { - for (unsigned short jDim = 0; jDim < nDim; jDim++) { - // Jacobian w.r.t. momentum - tau_jacobian_i[iDim][jDim+1] = -xi*(delta[iDim][jDim] + val_normal[iDim]*val_normal[jDim]/3.0); - } - // Jacobian w.r.t. density - tau_jacobian_i[iDim][0] = 0; - for (unsigned short jDim = 0; jDim < nDim; jDim++) { - tau_jacobian_i[iDim][0] -= tau_jacobian_i[iDim][jDim+1]*val_Mean_PrimVar[jDim+1]; - } - // Jacobian w.r.t. energy - tau_jacobian_i[iDim][nDim+1] = 0; - } -} - -void CAvgGrad_Base::SetIncTauJacobian(const su2double val_laminar_viscosity, - const su2double val_eddy_viscosity, - const su2double val_dist_ij, - const su2double *val_normal) { - - const su2double total_viscosity = val_laminar_viscosity + val_eddy_viscosity; - const su2double xi = total_viscosity/val_dist_ij; - - for (unsigned short iDim = 0; iDim < nDim; iDim++) { - tau_jacobian_i[iDim][0] = 0; - for (unsigned short jDim = 0; jDim < nDim; jDim++) { - tau_jacobian_i[iDim][jDim+1] = -xi*(delta[iDim][jDim] + val_normal[iDim]*val_normal[jDim]/3.0); - } - tau_jacobian_i[iDim][nDim+1] = 0; - } -} - -void CAvgGrad_Base::GetViscousProjFlux(const su2double *val_primvar, - const su2double *val_normal) { - - /*--- Primitive variables -> [Temp vel_x vel_y vel_z Pressure] ---*/ - - if (nDim == 2) { - Flux_Tensor[0][0] = 0.0; - Flux_Tensor[1][0] = tau[0][0]; - Flux_Tensor[2][0] = tau[0][1]; - Flux_Tensor[3][0] = tau[0][0]*val_primvar[1] + tau[0][1]*val_primvar[2]+ - heat_flux_vector[0]; - Flux_Tensor[0][1] = 0.0; - Flux_Tensor[1][1] = tau[1][0]; - Flux_Tensor[2][1] = tau[1][1]; - Flux_Tensor[3][1] = tau[1][0]*val_primvar[1] + tau[1][1]*val_primvar[2]+ - heat_flux_vector[1]; - } else { - Flux_Tensor[0][0] = 0.0; - Flux_Tensor[1][0] = tau[0][0]; - Flux_Tensor[2][0] = tau[0][1]; - Flux_Tensor[3][0] = tau[0][2]; - Flux_Tensor[4][0] = tau[0][0]*val_primvar[1] + tau[0][1]*val_primvar[2] + tau[0][2]*val_primvar[3] + - heat_flux_vector[0]; - Flux_Tensor[0][1] = 0.0; - Flux_Tensor[1][1] = tau[1][0]; - Flux_Tensor[2][1] = tau[1][1]; - Flux_Tensor[3][1] = tau[1][2]; - Flux_Tensor[4][1] = tau[1][0]*val_primvar[1] + tau[1][1]*val_primvar[2] + tau[1][2]*val_primvar[3] + - heat_flux_vector[1]; - Flux_Tensor[0][2] = 0.0; - Flux_Tensor[1][2] = tau[2][0]; - Flux_Tensor[2][2] = tau[2][1]; - Flux_Tensor[3][2] = tau[2][2]; - Flux_Tensor[4][2] = tau[2][0]*val_primvar[1] + tau[2][1]*val_primvar[2] + tau[2][2]*val_primvar[3] + - heat_flux_vector[2]; - } - - for (unsigned short iVar = 0; iVar < nVar; iVar++) { - Proj_Flux_Tensor[iVar] = 0.0; - for (unsigned short iDim = 0; iDim < nDim; iDim++) - Proj_Flux_Tensor[iVar] += Flux_Tensor[iVar][iDim] * val_normal[iDim]; - } - -} - -void CAvgGrad_Base::GetViscousProjJacs(const su2double *val_Mean_PrimVar, - const su2double val_dS, - const su2double *val_Proj_Visc_Flux, - su2double **val_Proj_Jac_Tensor_i, - su2double **val_Proj_Jac_Tensor_j) { - - const su2double Density = val_Mean_PrimVar[nDim+2]; - const su2double factor = 0.5/Density; - - if (nDim == 2) { - - val_Proj_Jac_Tensor_i[0][0] = 0.0; - val_Proj_Jac_Tensor_i[0][1] = 0.0; - val_Proj_Jac_Tensor_i[0][2] = 0.0; - val_Proj_Jac_Tensor_i[0][3] = 0.0; - val_Proj_Jac_Tensor_i[1][0] = val_dS*tau_jacobian_i[0][0]; - val_Proj_Jac_Tensor_i[1][1] = val_dS*tau_jacobian_i[0][1]; - val_Proj_Jac_Tensor_i[1][2] = val_dS*tau_jacobian_i[0][2]; - val_Proj_Jac_Tensor_i[1][3] = val_dS*tau_jacobian_i[0][3]; - val_Proj_Jac_Tensor_i[2][0] = val_dS*tau_jacobian_i[1][0]; - val_Proj_Jac_Tensor_i[2][1] = val_dS*tau_jacobian_i[1][1]; - val_Proj_Jac_Tensor_i[2][2] = val_dS*tau_jacobian_i[1][2]; - val_Proj_Jac_Tensor_i[2][3] = val_dS*tau_jacobian_i[1][3]; - const su2double contraction = tau_jacobian_i[0][0]*val_Mean_PrimVar[1] + - tau_jacobian_i[1][0]*val_Mean_PrimVar[2]; - val_Proj_Jac_Tensor_i[3][0] = val_dS*(contraction - heat_flux_jac_i[0]); - val_Proj_Jac_Tensor_i[3][1] = -val_dS*(tau_jacobian_i[0][0] + heat_flux_jac_i[1]); - val_Proj_Jac_Tensor_i[3][2] = -val_dS*(tau_jacobian_i[1][0] + heat_flux_jac_i[2]); - val_Proj_Jac_Tensor_i[3][3] = -val_dS*heat_flux_jac_i[3]; - - for (unsigned short iVar = 0; iVar < nVar; iVar++) - for (unsigned short jVar = 0; jVar < nVar; jVar++) - val_Proj_Jac_Tensor_j[iVar][jVar] = -val_Proj_Jac_Tensor_i[iVar][jVar]; - - const su2double proj_viscousflux_vel= val_Proj_Visc_Flux[1]*val_Mean_PrimVar[1] + - val_Proj_Visc_Flux[2]*val_Mean_PrimVar[2]; - val_Proj_Jac_Tensor_i[3][0] -= factor*proj_viscousflux_vel; - val_Proj_Jac_Tensor_j[3][0] -= factor*proj_viscousflux_vel; - val_Proj_Jac_Tensor_i[3][1] += factor*val_Proj_Visc_Flux[1]; - val_Proj_Jac_Tensor_j[3][1] += factor*val_Proj_Visc_Flux[1]; - val_Proj_Jac_Tensor_i[3][2] += factor*val_Proj_Visc_Flux[2]; - val_Proj_Jac_Tensor_j[3][2] += factor*val_Proj_Visc_Flux[2]; - - - } else { - - val_Proj_Jac_Tensor_i[0][0] = 0.0; - val_Proj_Jac_Tensor_i[0][1] = 0.0; - val_Proj_Jac_Tensor_i[0][2] = 0.0; - val_Proj_Jac_Tensor_i[0][3] = 0.0; - val_Proj_Jac_Tensor_i[0][4] = 0.0; - val_Proj_Jac_Tensor_i[1][0] = val_dS*tau_jacobian_i[0][0]; - val_Proj_Jac_Tensor_i[1][1] = val_dS*tau_jacobian_i[0][1]; - val_Proj_Jac_Tensor_i[1][2] = val_dS*tau_jacobian_i[0][2]; - val_Proj_Jac_Tensor_i[1][3] = val_dS*tau_jacobian_i[0][3]; - val_Proj_Jac_Tensor_i[1][4] = val_dS*tau_jacobian_i[0][4]; - val_Proj_Jac_Tensor_i[2][0] = val_dS*tau_jacobian_i[1][0]; - val_Proj_Jac_Tensor_i[2][1] = val_dS*tau_jacobian_i[1][1]; - val_Proj_Jac_Tensor_i[2][2] = val_dS*tau_jacobian_i[1][2]; - val_Proj_Jac_Tensor_i[2][3] = val_dS*tau_jacobian_i[1][3]; - val_Proj_Jac_Tensor_i[2][4] = val_dS*tau_jacobian_i[1][4]; - val_Proj_Jac_Tensor_i[3][0] = val_dS*tau_jacobian_i[2][0]; - val_Proj_Jac_Tensor_i[3][1] = val_dS*tau_jacobian_i[2][1]; - val_Proj_Jac_Tensor_i[3][2] = val_dS*tau_jacobian_i[2][2]; - val_Proj_Jac_Tensor_i[3][3] = val_dS*tau_jacobian_i[2][3]; - val_Proj_Jac_Tensor_i[3][4] = val_dS*tau_jacobian_i[2][4]; - const su2double contraction = tau_jacobian_i[0][0]*val_Mean_PrimVar[1] + - tau_jacobian_i[1][0]*val_Mean_PrimVar[2] + - tau_jacobian_i[2][0]*val_Mean_PrimVar[3]; - val_Proj_Jac_Tensor_i[4][0] = val_dS*(contraction - heat_flux_jac_i[0]); - val_Proj_Jac_Tensor_i[4][1] = -val_dS*(tau_jacobian_i[0][0] + heat_flux_jac_i[1]); - val_Proj_Jac_Tensor_i[4][2] = -val_dS*(tau_jacobian_i[1][0] + heat_flux_jac_i[2]); - val_Proj_Jac_Tensor_i[4][3] = -val_dS*(tau_jacobian_i[2][0] + heat_flux_jac_i[3]); - val_Proj_Jac_Tensor_i[4][4] = -val_dS*heat_flux_jac_i[4]; - - for (unsigned short iVar = 0; iVar < nVar; iVar++) - for (unsigned short jVar = 0; jVar < nVar; jVar++) - val_Proj_Jac_Tensor_j[iVar][jVar] = -val_Proj_Jac_Tensor_i[iVar][jVar]; - - const su2double proj_viscousflux_vel= val_Proj_Visc_Flux[1]*val_Mean_PrimVar[1] + - val_Proj_Visc_Flux[2]*val_Mean_PrimVar[2] + - val_Proj_Visc_Flux[3]*val_Mean_PrimVar[3]; - val_Proj_Jac_Tensor_i[4][0] -= factor*proj_viscousflux_vel; - val_Proj_Jac_Tensor_j[4][0] -= factor*proj_viscousflux_vel; - val_Proj_Jac_Tensor_i[4][1] += factor*val_Proj_Visc_Flux[1]; - val_Proj_Jac_Tensor_j[4][1] += factor*val_Proj_Visc_Flux[1]; - val_Proj_Jac_Tensor_i[4][2] += factor*val_Proj_Visc_Flux[2]; - val_Proj_Jac_Tensor_j[4][2] += factor*val_Proj_Visc_Flux[2]; - val_Proj_Jac_Tensor_i[4][3] += factor*val_Proj_Visc_Flux[3]; - val_Proj_Jac_Tensor_j[4][3] += factor*val_Proj_Visc_Flux[3]; - - } - -} diff --git a/SU2_CFD/src/numerics/flow/diffusion/CAvgGrad_Flow.cpp b/SU2_CFD/src/numerics/flow/diffusion/CAvgGrad_Flow.cpp deleted file mode 100644 index 8f3698c57d2a..000000000000 --- a/SU2_CFD/src/numerics/flow/diffusion/CAvgGrad_Flow.cpp +++ /dev/null @@ -1,223 +0,0 @@ -/*! - * \file CAvgGrad_Flow.cpp - * \brief Implementation of numerics class CAvgGrad_Flow. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../../include/numerics/flow/diffusion/CAvgGrad_Flow.hpp" - -CAvgGrad_Flow::CAvgGrad_Flow(unsigned short val_nDim, - unsigned short val_nVar, - bool val_correct_grad, - CConfig *config) - : CAvgGrad_Base(val_nDim, val_nVar, val_nDim+3, val_correct_grad, config) { - -} - -CAvgGrad_Flow::~CAvgGrad_Flow(void) { - -} - -void CAvgGrad_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - AD::StartPreacc(); - AD::SetPreaccIn(V_i, nDim+9); AD::SetPreaccIn(V_j, nDim+9); - AD::SetPreaccIn(Coord_i, nDim); AD::SetPreaccIn(Coord_j, nDim); - AD::SetPreaccIn(PrimVar_Grad_i, nDim+1, nDim); - AD::SetPreaccIn(PrimVar_Grad_j, nDim+1, nDim); - AD::SetPreaccIn(turb_ke_i); AD::SetPreaccIn(turb_ke_j); - AD::SetPreaccIn(Normal, nDim); - - unsigned short iVar, jVar, iDim; - - /*--- Normalized normal vector ---*/ - - 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; - - for (iVar = 0; iVar < nPrimVar; iVar++) { - PrimVar_i[iVar] = V_i[iVar]; - PrimVar_j[iVar] = V_j[iVar]; - Mean_PrimVar[iVar] = 0.5*(PrimVar_i[iVar]+PrimVar_j[iVar]); - } - - - /*--- Compute vector going from iPoint to jPoint ---*/ - - dist_ij_2 = 0.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]; - } - - /*--- Laminar and Eddy viscosity ---*/ - - Laminar_Viscosity_i = V_i[nDim+5]; Laminar_Viscosity_j = V_j[nDim+5]; - Eddy_Viscosity_i = V_i[nDim+6]; Eddy_Viscosity_j = V_j[nDim+6]; - - /*--- Mean Viscosities and turbulent kinetic energy---*/ - - Mean_Laminar_Viscosity = 0.5*(Laminar_Viscosity_i + Laminar_Viscosity_j); - Mean_Eddy_Viscosity = 0.5*(Eddy_Viscosity_i + Eddy_Viscosity_j); - Mean_turb_ke = 0.5*(turb_ke_i + turb_ke_j); - - /*--- Mean gradient approximation ---*/ - - for (iVar = 0; iVar < nDim+1; iVar++) { - for (iDim = 0; iDim < nDim; iDim++) { - Mean_GradPrimVar[iVar][iDim] = 0.5*(PrimVar_Grad_i[iVar][iDim] + PrimVar_Grad_j[iVar][iDim]); - } - } - - /*--- Projection of the mean gradient in the direction of the edge ---*/ - - if (correct_gradient && dist_ij_2 != 0.0) { - CorrectGradient(Mean_GradPrimVar, PrimVar_i, PrimVar_j, Edge_Vector, - dist_ij_2, nDim+1); - } - - /*--- Wall shear stress values (wall functions) ---*/ - - if (TauWall_i > 0.0 && TauWall_j > 0.0) Mean_TauWall = 0.5*(TauWall_i + TauWall_j); - else if (TauWall_i > 0.0) Mean_TauWall = TauWall_i; - else if (TauWall_j > 0.0) Mean_TauWall = TauWall_j; - else Mean_TauWall = -1.0; - - /* --- If using UQ methodology, set Reynolds Stress tensor and perform perturbation--- */ - - if (using_uq){ - SetReynoldsStressMatrix(Mean_turb_ke); - SetPerturbedRSM(Mean_turb_ke, config); - } - - /*--- Get projected flux tensor ---*/ - - SetStressTensor(Mean_PrimVar, Mean_GradPrimVar, Mean_turb_ke, - Mean_Laminar_Viscosity, Mean_Eddy_Viscosity); - if (config->GetQCR()) AddQCR(Mean_GradPrimVar); - if (Mean_TauWall > 0) AddTauWall(Normal, Mean_TauWall); - - SetHeatFluxVector(Mean_GradPrimVar, Mean_Laminar_Viscosity, - Mean_Eddy_Viscosity); - - GetViscousProjFlux(Mean_PrimVar, Normal); - - /*--- Update viscous residual ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_residual[iVar] = Proj_Flux_Tensor[iVar]; - - /*--- Compute the implicit part ---*/ - - if (implicit) { - - if (dist_ij_2 == 0.0) { - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - val_Jacobian_i[iVar][jVar] = 0.0; - val_Jacobian_j[iVar][jVar] = 0.0; - } - } - } else { - const su2double dist_ij = sqrt(dist_ij_2); - SetTauJacobian(Mean_PrimVar, Mean_Laminar_Viscosity, Mean_Eddy_Viscosity, - dist_ij, UnitNormal); - SetHeatFluxJacobian(Mean_PrimVar, Mean_Laminar_Viscosity, - Mean_Eddy_Viscosity, dist_ij, UnitNormal); - GetViscousProjJacs(Mean_PrimVar, Area, Proj_Flux_Tensor, - val_Jacobian_i, val_Jacobian_j); - } - - } - - AD::SetPreaccOut(val_residual, nVar); - AD::EndPreacc(); - -} - - - -void CAvgGrad_Flow::SetHeatFluxVector(const su2double* const *val_gradprimvar, - const su2double val_laminar_viscosity, - const su2double val_eddy_viscosity) { - - const su2double Cp = (Gamma / Gamma_Minus_One) * Gas_Constant; - const su2double heat_flux_factor = Cp * (val_laminar_viscosity/Prandtl_Lam + val_eddy_viscosity/Prandtl_Turb); - - /*--- Gradient of primitive variables -> [Temp vel_x vel_y vel_z Pressure] ---*/ - - for (unsigned short iDim = 0; iDim < nDim; iDim++) { - heat_flux_vector[iDim] = heat_flux_factor*val_gradprimvar[0][iDim]; - } -} - -void CAvgGrad_Flow::SetHeatFluxJacobian(const su2double *val_Mean_PrimVar, - const su2double val_laminar_viscosity, - const su2double val_eddy_viscosity, - const su2double val_dist_ij, - const su2double *val_normal) { - su2double sqvel = 0.0; - - for (unsigned short iDim = 0; iDim < nDim; iDim++) { - sqvel += val_Mean_PrimVar[iDim+1]*val_Mean_PrimVar[iDim+1]; - } - - const su2double Density = val_Mean_PrimVar[nDim+2]; - const su2double Pressure = val_Mean_PrimVar[nDim+1]; - const su2double phi = Gamma_Minus_One/Density; - - /*--- R times partial derivatives of temp. ---*/ - - const su2double R_dTdu0 = -Pressure/(Density*Density) + 0.5*sqvel*phi; - const su2double R_dTdu1 = -phi*val_Mean_PrimVar[1]; - const su2double R_dTdu2 = -phi*val_Mean_PrimVar[2]; - - const su2double heat_flux_factor = val_laminar_viscosity/Prandtl_Lam + val_eddy_viscosity/Prandtl_Turb; - const su2double cpoR = Gamma/Gamma_Minus_One; // cp over R - const su2double conductivity_over_Rd = cpoR*heat_flux_factor/val_dist_ij; - - heat_flux_jac_i[0] = conductivity_over_Rd * R_dTdu0; - heat_flux_jac_i[1] = conductivity_over_Rd * R_dTdu1; - heat_flux_jac_i[2] = conductivity_over_Rd * R_dTdu2; - - if (nDim == 2) { - - const su2double R_dTdu3 = phi; - heat_flux_jac_i[3] = conductivity_over_Rd * R_dTdu3; - - } else { - - const su2double R_dTdu3 = -phi*val_Mean_PrimVar[3]; - const su2double R_dTdu4 = phi; - heat_flux_jac_i[3] = conductivity_over_Rd * R_dTdu3; - heat_flux_jac_i[4] = conductivity_over_Rd * R_dTdu4; - - } -} - diff --git a/SU2_CFD/src/numerics/flow/diffusion/CGeneralAvgGrad_Flow.cpp b/SU2_CFD/src/numerics/flow/diffusion/CGeneralAvgGrad_Flow.cpp deleted file mode 100644 index 99cecc196d5b..000000000000 --- a/SU2_CFD/src/numerics/flow/diffusion/CGeneralAvgGrad_Flow.cpp +++ /dev/null @@ -1,232 +0,0 @@ -/*! - * \file CGeneralAvgGrad_Flow.cpp - * \brief Implementation of numerics class CGeneralAvgGrad_Flow. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../../include/numerics/flow/diffusion/CGeneralAvgGrad_Flow.hpp" - -CGeneralAvgGrad_Flow::CGeneralAvgGrad_Flow(unsigned short val_nDim, - unsigned short val_nVar, - bool val_correct_grad, - CConfig *config) - : CAvgGrad_Base(val_nDim, val_nVar, val_nDim+4, val_correct_grad, config) { - - Mean_SecVar = new su2double [2]; - -} - -CGeneralAvgGrad_Flow::~CGeneralAvgGrad_Flow(void) { - - delete [] Mean_SecVar; - -} - -void CGeneralAvgGrad_Flow::SetHeatFluxVector(const su2double* const *val_gradprimvar, - const su2double val_laminar_viscosity, - const su2double val_eddy_viscosity, - const su2double val_thermal_conductivity, - const su2double val_heat_capacity_cp) { - - const su2double heat_flux_factor = val_thermal_conductivity + val_heat_capacity_cp*val_eddy_viscosity/Prandtl_Turb; - - /*--- Gradient of primitive variables -> [Temp vel_x vel_y vel_z Pressure] ---*/ - for (unsigned short iDim = 0; iDim < nDim; iDim++) { - heat_flux_vector[iDim] = heat_flux_factor*val_gradprimvar[0][iDim]; - } -} - -void CGeneralAvgGrad_Flow::SetHeatFluxJacobian(const su2double *val_Mean_PrimVar, - const su2double *val_Mean_SecVar, - const su2double val_eddy_viscosity, - const su2double val_thermal_conductivity, - const su2double val_heat_capacity_cp, - const su2double val_dist_ij) { - /* Viscous flux Jacobians for arbitrary equations of state */ - - //order of val_mean_primitives: T, vx, vy, vz, P, rho, ht - //order of secondary:dTdrho_e, dTde_rho - - su2double sqvel = 0.0; - for (unsigned short iDim = 0; iDim < nDim; iDim++) { - sqvel += val_Mean_PrimVar[iDim+1]*val_Mean_PrimVar[iDim+1]; - } - - su2double rho = val_Mean_PrimVar[nDim+2]; - su2double P= val_Mean_PrimVar[nDim+1]; - su2double h= val_Mean_PrimVar[nDim+3]; - su2double dTdrho_e= val_Mean_SecVar[0]; - su2double dTde_rho= val_Mean_SecVar[1]; - - su2double dTdu0= dTdrho_e + dTde_rho*(-(h-P/rho) + sqvel)*(1/rho); - su2double dTdu1= dTde_rho*(-val_Mean_PrimVar[1])*(1/rho); - su2double dTdu2= dTde_rho*(-val_Mean_PrimVar[2])*(1/rho); - - su2double total_conductivity = val_thermal_conductivity + val_heat_capacity_cp*val_eddy_viscosity/Prandtl_Turb; - su2double factor2 = total_conductivity/val_dist_ij; - - heat_flux_jac_i[0] = factor2*dTdu0; - heat_flux_jac_i[1] = factor2*dTdu1; - heat_flux_jac_i[2] = factor2*dTdu2; - - if (nDim == 2) { - - su2double dTdu3= dTde_rho*(1/rho); - heat_flux_jac_i[3] = factor2*dTdu3; - - } else { - - su2double dTdu3= dTde_rho*(-val_Mean_PrimVar[3])*(1/rho); - su2double dTdu4= dTde_rho*(1/rho); - heat_flux_jac_i[3] = factor2*dTdu3; - heat_flux_jac_i[4] = factor2*dTdu4; - - } - -} - -void CGeneralAvgGrad_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - AD::StartPreacc(); - AD::SetPreaccIn(V_i, nDim+9); AD::SetPreaccIn(V_j, nDim+9); - AD::SetPreaccIn(Coord_i, nDim); AD::SetPreaccIn(Coord_j, nDim); - AD::SetPreaccIn(S_i, 4); AD::SetPreaccIn(S_j, 4); - AD::SetPreaccIn(PrimVar_Grad_i, nDim+1, nDim); - AD::SetPreaccIn(PrimVar_Grad_j, nDim+1, nDim); - AD::SetPreaccIn(turb_ke_i); AD::SetPreaccIn(turb_ke_j); - AD::SetPreaccIn(Normal, nDim); - - unsigned short iVar, jVar, iDim; - - /*--- Normalized normal vector ---*/ - - 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; - - /*--- Mean primitive variables ---*/ - - for (iVar = 0; iVar < nPrimVar; iVar++) { - PrimVar_i[iVar] = V_i[iVar]; - PrimVar_j[iVar] = V_j[iVar]; - Mean_PrimVar[iVar] = 0.5*(PrimVar_i[iVar]+PrimVar_j[iVar]); - } - - /*--- Compute vector going from iPoint to jPoint ---*/ - - dist_ij_2 = 0.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]; - } - - /*--- Laminar and Eddy viscosity ---*/ - - Laminar_Viscosity_i = V_i[nDim+5]; Laminar_Viscosity_j = V_j[nDim+5]; - Eddy_Viscosity_i = V_i[nDim+6]; Eddy_Viscosity_j = V_j[nDim+6]; - Thermal_Conductivity_i = V_i[nDim+7]; Thermal_Conductivity_j = V_j[nDim+7]; - Cp_i = V_i[nDim+8]; Cp_j = V_j[nDim+8]; - - /*--- Mean secondary variables ---*/ - - for (iVar = 0; iVar < 2; iVar++) { - Mean_SecVar[iVar] = 0.5*(S_i[iVar+2]+S_j[iVar+2]); - } - - /*--- Mean Viscosities and turbulent kinetic energy---*/ - - Mean_Laminar_Viscosity = 0.5*(Laminar_Viscosity_i + Laminar_Viscosity_j); - Mean_Eddy_Viscosity = 0.5*(Eddy_Viscosity_i + Eddy_Viscosity_j); - Mean_turb_ke = 0.5*(turb_ke_i + turb_ke_j); - Mean_Thermal_Conductivity = 0.5*(Thermal_Conductivity_i + Thermal_Conductivity_j); - Mean_Cp = 0.5*(Cp_i + Cp_j); - - /*--- Mean gradient approximation ---*/ - - for (iVar = 0; iVar < nDim+1; iVar++) { - for (iDim = 0; iDim < nDim; iDim++) { - Mean_GradPrimVar[iVar][iDim] = 0.5*(PrimVar_Grad_i[iVar][iDim] + PrimVar_Grad_j[iVar][iDim]); - } - } - - /*--- Projection of the mean gradient in the direction of the edge ---*/ - - if (correct_gradient && dist_ij_2 != 0.0) { - CorrectGradient(Mean_GradPrimVar, PrimVar_i, PrimVar_j, Edge_Vector, - dist_ij_2, nDim+1); - } - - /* --- If using UQ methodology, set Reynolds Stress tensor and perform perturbation--- */ - - if (using_uq){ - SetReynoldsStressMatrix(Mean_turb_ke); - SetPerturbedRSM(Mean_turb_ke, config); - } - - /*--- Get projected flux tensor ---*/ - - SetStressTensor(Mean_PrimVar, Mean_GradPrimVar, Mean_turb_ke, - Mean_Laminar_Viscosity, Mean_Eddy_Viscosity); - - SetHeatFluxVector(Mean_GradPrimVar, Mean_Laminar_Viscosity, - Mean_Eddy_Viscosity, Mean_Thermal_Conductivity, Mean_Cp); - - GetViscousProjFlux(Mean_PrimVar, Normal); - - /*--- Update viscous residual ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_residual[iVar] = Proj_Flux_Tensor[iVar]; - - /*--- Compute the implicit part ---*/ - - if (implicit) { - - if (dist_ij_2 == 0.0) { - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - val_Jacobian_i[iVar][jVar] = 0.0; - val_Jacobian_j[iVar][jVar] = 0.0; - } - } - } else { - const su2double dist_ij = sqrt(dist_ij_2); - SetTauJacobian(Mean_PrimVar, Mean_Laminar_Viscosity, Mean_Eddy_Viscosity, - dist_ij, UnitNormal); - SetHeatFluxJacobian(Mean_PrimVar, Mean_SecVar, Mean_Eddy_Viscosity, - Mean_Thermal_Conductivity, Mean_Cp, dist_ij); - GetViscousProjJacs(Mean_PrimVar, Area, Proj_Flux_Tensor, - val_Jacobian_i, val_Jacobian_j); - } - - } - - AD::SetPreaccOut(val_residual, nVar); - AD::EndPreacc(); - -} diff --git a/SU2_CFD/src/numerics/flow/flow_diffusion.cpp b/SU2_CFD/src/numerics/flow/flow_diffusion.cpp new file mode 100644 index 000000000000..c5c2c5892e8d --- /dev/null +++ b/SU2_CFD/src/numerics/flow/flow_diffusion.cpp @@ -0,0 +1,1186 @@ +/*! + * \file flow_diffusion.cpp + * \brief Implementation of numerics classes for discretization + * of viscous fluxes in fluid flow problems. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../include/numerics/flow/flow_diffusion.hpp" + +CAvgGrad_Base::CAvgGrad_Base(unsigned short val_nDim, + unsigned short val_nVar, + unsigned short val_nPrimVar, + bool val_correct_grad, + CConfig *config) + : CNumerics(val_nDim, val_nVar, config), + nPrimVar(val_nPrimVar), + correct_gradient(val_correct_grad) { + + unsigned short iVar, iDim; + + implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + + TauWall_i = 0; TauWall_j = 0; + + PrimVar_i = new su2double [nPrimVar]; + PrimVar_j = new su2double [nPrimVar]; + Mean_PrimVar = new su2double [nPrimVar]; + + Mean_GradPrimVar = new su2double* [nPrimVar]; + for (iVar = 0; iVar < nPrimVar; iVar++) + Mean_GradPrimVar[iVar] = new su2double [nDim]; + + Edge_Vector = new su2double[nDim]; + + if (correct_gradient) { + Proj_Mean_GradPrimVar_Edge = new su2double[val_nPrimVar]; + } else { + Proj_Mean_GradPrimVar_Edge = NULL; + } + + tau_jacobian_i = new su2double* [nDim]; + for (iDim = 0; iDim < nDim; iDim++) { + tau_jacobian_i[iDim] = new su2double [nVar]; + } + heat_flux_vector = new su2double[nDim]; + heat_flux_jac_i = new su2double[nVar]; + +} + +CAvgGrad_Base::~CAvgGrad_Base() { + + delete [] PrimVar_i; + delete [] PrimVar_j; + delete [] Mean_PrimVar; + for (unsigned short iVar = 0; iVar < nPrimVar; iVar++) + delete [] Mean_GradPrimVar[iVar]; + delete [] Mean_GradPrimVar; + + if (tau_jacobian_i != NULL) { + for (unsigned short iDim = 0; iDim < nDim; iDim++) { + delete [] tau_jacobian_i[iDim]; + } + delete [] tau_jacobian_i; + } + if (heat_flux_vector != NULL) { + delete [] heat_flux_vector; + } + if (heat_flux_jac_i != NULL) { + delete [] heat_flux_jac_i; + } + + delete [] Edge_Vector; + if (Proj_Mean_GradPrimVar_Edge != NULL) + delete [] Proj_Mean_GradPrimVar_Edge; +} + +void CAvgGrad_Base::CorrectGradient(su2double** GradPrimVar, + const su2double* val_PrimVar_i, + const su2double* val_PrimVar_j, + const su2double* val_edge_vector, + const su2double val_dist_ij_2, + const unsigned short val_nPrimVar) { + for (unsigned short iVar = 0; iVar < val_nPrimVar; iVar++) { + Proj_Mean_GradPrimVar_Edge[iVar] = 0.0; + for (unsigned short iDim = 0; iDim < nDim; iDim++) { + Proj_Mean_GradPrimVar_Edge[iVar] += GradPrimVar[iVar][iDim]*val_edge_vector[iDim]; + } + for (unsigned short iDim = 0; iDim < nDim; iDim++) { + GradPrimVar[iVar][iDim] -= (Proj_Mean_GradPrimVar_Edge[iVar] - + (val_PrimVar_j[iVar]-val_PrimVar_i[iVar]))*val_edge_vector[iDim] / val_dist_ij_2; + } + } +} + +void CAvgGrad_Base::SetStressTensor(const su2double *val_primvar, + const su2double* const *val_gradprimvar, + const su2double val_turb_ke, + const su2double val_laminar_viscosity, + const su2double val_eddy_viscosity) { + + unsigned short iDim, jDim; + const su2double Density = val_primvar[nDim+2]; + const su2double total_viscosity = val_laminar_viscosity + val_eddy_viscosity; + + su2double div_vel = 0.0; + for (iDim = 0 ; iDim < nDim; iDim++) + div_vel += val_gradprimvar[iDim+1][iDim]; + + /* --- If UQ methodology is used, calculate tau using the perturbed reynolds stress tensor --- */ + + if (using_uq){ + for (iDim = 0 ; iDim < nDim; iDim++) + for (jDim = 0 ; jDim < nDim; jDim++) + tau[iDim][jDim] = val_laminar_viscosity*( val_gradprimvar[jDim+1][iDim] + val_gradprimvar[iDim+1][jDim] ) + - TWO3*val_laminar_viscosity*div_vel*delta[iDim][jDim] - Density * MeanPerturbedRSM[iDim][jDim]; + + } else { + + 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]; + } +} + +void CAvgGrad_Base::AddQCR(const su2double* const *val_gradprimvar) { + + su2double den_aux, c_cr1= 0.3, O_ik, O_jk; + unsigned short iDim, jDim, kDim; + + /*--- Denominator Antisymmetric normalized rotation tensor ---*/ + + den_aux = 0.0; + for (iDim = 0 ; iDim < nDim; iDim++) + for (jDim = 0 ; jDim < nDim; jDim++) + den_aux += val_gradprimvar[iDim+1][jDim] * val_gradprimvar[iDim+1][jDim]; + den_aux = sqrt(max(den_aux,1E-10)); + + /*--- Adding the QCR contribution ---*/ + + for (iDim = 0 ; iDim < nDim; iDim++){ + for (jDim = 0 ; jDim < nDim; jDim++){ + for (kDim = 0 ; kDim < nDim; kDim++){ + O_ik = (val_gradprimvar[iDim+1][kDim] - val_gradprimvar[kDim+1][iDim])/ den_aux; + O_jk = (val_gradprimvar[jDim+1][kDim] - val_gradprimvar[kDim+1][jDim])/ den_aux; + tau[iDim][jDim] -= c_cr1 * ((O_ik * tau[jDim][kDim]) + (O_jk * tau[iDim][kDim])); + } + } + } +} + +void CAvgGrad_Base::AddTauWall(const su2double *val_normal, + const su2double val_tau_wall) { + + unsigned short iDim, jDim; + su2double TauNormal, TauElem[3], TauTangent[3], WallShearStress, Area, UnitNormal[3]; + + Area = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + Area += val_normal[iDim]*val_normal[iDim]; + Area = sqrt(Area); + + for (iDim = 0; iDim < nDim; iDim++) + UnitNormal[iDim] = val_normal[iDim]/Area; + + /*--- First, compute wall shear stress as the magnitude of the wall-tangential + component of the shear stress tensor---*/ + + for (iDim = 0; iDim < nDim; iDim++) { + TauElem[iDim] = 0.0; + for (jDim = 0; jDim < nDim; jDim++) + TauElem[iDim] += tau[iDim][jDim]*UnitNormal[jDim]; + } + + TauNormal = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + TauNormal += TauElem[iDim] * UnitNormal[iDim]; + + for (iDim = 0; iDim < nDim; iDim++) + TauTangent[iDim] = TauElem[iDim] - TauNormal * UnitNormal[iDim]; + + WallShearStress = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + WallShearStress += TauTangent[iDim]*TauTangent[iDim]; + WallShearStress = sqrt(WallShearStress); + + /*--- Scale the stress tensor by the ratio of the wall shear stress + to the computed representation of the shear stress ---*/ + + for (iDim = 0 ; iDim < nDim; iDim++) + for (jDim = 0 ; jDim < nDim; jDim++) + tau[iDim][jDim] = tau[iDim][jDim]*(val_tau_wall/WallShearStress); +} + +void CAvgGrad_Base::GetMeanRateOfStrainMatrix(su2double **S_ij) const +{ + /* --- Calculate the rate of strain tensor, using mean velocity gradients --- */ + + if (nDim == 3){ + S_ij[0][0] = Mean_GradPrimVar[1][0]; + S_ij[1][1] = Mean_GradPrimVar[2][1]; + S_ij[2][2] = Mean_GradPrimVar[3][2]; + S_ij[0][1] = 0.5 * (Mean_GradPrimVar[1][1] + Mean_GradPrimVar[2][0]); + S_ij[0][2] = 0.5 * (Mean_GradPrimVar[1][2] + Mean_GradPrimVar[3][0]); + S_ij[1][2] = 0.5 * (Mean_GradPrimVar[2][2] + Mean_GradPrimVar[3][1]); + S_ij[1][0] = S_ij[0][1]; + S_ij[2][1] = S_ij[1][2]; + S_ij[2][0] = S_ij[0][2]; + } + else { + S_ij[0][0] = Mean_GradPrimVar[1][0]; + S_ij[1][1] = Mean_GradPrimVar[2][1]; + S_ij[2][2] = 0.0; + S_ij[0][1] = 0.5 * (Mean_GradPrimVar[1][1] + Mean_GradPrimVar[2][0]); + S_ij[0][2] = 0.0; + S_ij[1][2] = 0.0; + S_ij[1][0] = S_ij[0][1]; + S_ij[2][1] = S_ij[1][2]; + S_ij[2][0] = S_ij[0][2]; + + } +} + +void CAvgGrad_Base::SetReynoldsStressMatrix(su2double turb_ke){ + + unsigned short iDim, jDim; + su2double **S_ij = new su2double* [3]; + su2double muT = Mean_Eddy_Viscosity; + su2double divVel = 0; + su2double density; + su2double TWO3 = 2.0/3.0; + density = Mean_PrimVar[nDim+2]; + + for (iDim = 0; iDim < 3; iDim++){ + S_ij[iDim] = new su2double [3]; + } + + GetMeanRateOfStrainMatrix(S_ij); + + /* --- Using rate of strain matrix, calculate Reynolds stress tensor --- */ + + for (iDim = 0; iDim < 3; iDim++){ + divVel += S_ij[iDim][iDim]; + } + + for (iDim = 0; iDim < 3; iDim++){ + for (jDim = 0; jDim < 3; jDim++){ + MeanReynoldsStress[iDim][jDim] = TWO3 * turb_ke * delta3[iDim][jDim] + - muT / density * (2 * S_ij[iDim][jDim] - TWO3 * divVel * delta3[iDim][jDim]); + } + } + + for (iDim = 0; iDim < 3; iDim++) + delete [] S_ij[iDim]; + delete [] S_ij; +} + +void CAvgGrad_Base::SetPerturbedRSM(su2double turb_ke, CConfig *config){ + + unsigned short iDim,jDim; + + /* --- Calculate anisotropic part of Reynolds Stress tensor --- */ + + for (iDim = 0; iDim< 3; iDim++){ + for (jDim = 0; jDim < 3; jDim++){ + A_ij[iDim][jDim] = .5 * MeanReynoldsStress[iDim][jDim] / turb_ke - delta3[iDim][jDim] / 3.0; + Eig_Vec[iDim][jDim] = A_ij[iDim][jDim]; + } + } + + /* --- Get ordered eigenvectors and eigenvalues of A_ij --- */ + + EigenDecomposition(A_ij, Eig_Vec, Eig_Val, 3); + + /* compute convex combination coefficients */ + su2double c1c = Eig_Val[2] - Eig_Val[1]; + su2double c2c = 2.0 * (Eig_Val[1] - Eig_Val[0]); + su2double c3c = 3.0 * Eig_Val[0] + 1.0; + + /* define barycentric traingle corner points */ + Corners[0][0] = 1.0; + Corners[0][1] = 0.0; + Corners[1][0] = 0.0; + Corners[1][1] = 0.0; + Corners[2][0] = 0.5; + Corners[2][1] = 0.866025; + + /* define barycentric coordinates */ + Barycentric_Coord[0] = Corners[0][0] * c1c + Corners[1][0] * c2c + Corners[2][0] * c3c; + Barycentric_Coord[1] = Corners[0][1] * c1c + Corners[1][1] * c2c + Corners[2][1] * c3c; + + if (Eig_Val_Comp == 1) { + /* 1C turbulence */ + New_Coord[0] = Corners[0][0]; + New_Coord[1] = Corners[0][1]; + } + else if (Eig_Val_Comp== 2) { + /* 2C turbulence */ + New_Coord[0] = Corners[1][0]; + New_Coord[1] = Corners[1][1]; + } + else if (Eig_Val_Comp == 3) { + /* 3C turbulence */ + New_Coord[0] = Corners[2][0]; + New_Coord[1] = Corners[2][1]; + } + else { + /* 2C turbulence */ + New_Coord[0] = Corners[1][0]; + New_Coord[1] = Corners[1][1]; + } + + /* calculate perturbed barycentric coordinates */ + Barycentric_Coord[0] = Barycentric_Coord[0] + (uq_delta_b) * (New_Coord[0] - Barycentric_Coord[0]); + Barycentric_Coord[1] = Barycentric_Coord[1] + (uq_delta_b) * (New_Coord[1] - Barycentric_Coord[1]); + + /* rebuild c1c,c2c,c3c based on perturbed barycentric coordinates */ + c3c = Barycentric_Coord[1] / Corners[2][1]; + c1c = Barycentric_Coord[0] - Corners[2][0] * c3c; + c2c = 1 - c1c - c3c; + + /* build new anisotropy eigenvalues */ + Eig_Val[0] = (c3c - 1) / 3.0; + Eig_Val[1] = 0.5 *c2c + Eig_Val[0]; + Eig_Val[2] = c1c + Eig_Val[1]; + + /* permute eigenvectors if required */ + if (uq_permute) { + for (iDim=0; iDim<3; iDim++) { + for (jDim=0; jDim<3; jDim++) { + New_Eig_Vec[iDim][jDim] = Eig_Vec[2-iDim][jDim]; + } + } + } + + else { + for (iDim=0; iDim<3; iDim++) { + for (jDim=0; jDim<3; jDim++) { + New_Eig_Vec[iDim][jDim] = Eig_Vec[iDim][jDim]; + } + } + } + + EigenRecomposition(newA_ij, New_Eig_Vec, Eig_Val, 3); + + /* compute perturbed Reynolds stress matrix; use under-relaxation factor (uq_urlx)*/ + for (iDim = 0; iDim< 3; iDim++){ + for (jDim = 0; jDim < 3; jDim++){ + MeanPerturbedRSM[iDim][jDim] = 2.0 * turb_ke * (newA_ij[iDim][jDim] + 1.0/3.0 * delta3[iDim][jDim]); + MeanPerturbedRSM[iDim][jDim] = MeanReynoldsStress[iDim][jDim] + + uq_urlx*(MeanPerturbedRSM[iDim][jDim] - MeanReynoldsStress[iDim][jDim]); + } + } + +} + + +void CAvgGrad_Base::SetTauJacobian(const su2double *val_Mean_PrimVar, + const su2double val_laminar_viscosity, + const su2double val_eddy_viscosity, + const su2double val_dist_ij, + const su2double *val_normal) { + + /*--- QCR and wall functions are **not** accounted for here ---*/ + + const su2double Density = val_Mean_PrimVar[nDim+2]; + const su2double total_viscosity = val_laminar_viscosity + val_eddy_viscosity; + const su2double xi = total_viscosity/(Density*val_dist_ij); + + for (unsigned short iDim = 0; iDim < nDim; iDim++) { + for (unsigned short jDim = 0; jDim < nDim; jDim++) { + // Jacobian w.r.t. momentum + tau_jacobian_i[iDim][jDim+1] = -xi*(delta[iDim][jDim] + val_normal[iDim]*val_normal[jDim]/3.0); + } + // Jacobian w.r.t. density + tau_jacobian_i[iDim][0] = 0; + for (unsigned short jDim = 0; jDim < nDim; jDim++) { + tau_jacobian_i[iDim][0] -= tau_jacobian_i[iDim][jDim+1]*val_Mean_PrimVar[jDim+1]; + } + // Jacobian w.r.t. energy + tau_jacobian_i[iDim][nDim+1] = 0; + } +} + +void CAvgGrad_Base::SetIncTauJacobian(const su2double val_laminar_viscosity, + const su2double val_eddy_viscosity, + const su2double val_dist_ij, + const su2double *val_normal) { + + const su2double total_viscosity = val_laminar_viscosity + val_eddy_viscosity; + const su2double xi = total_viscosity/val_dist_ij; + + for (unsigned short iDim = 0; iDim < nDim; iDim++) { + tau_jacobian_i[iDim][0] = 0; + for (unsigned short jDim = 0; jDim < nDim; jDim++) { + tau_jacobian_i[iDim][jDim+1] = -xi*(delta[iDim][jDim] + val_normal[iDim]*val_normal[jDim]/3.0); + } + tau_jacobian_i[iDim][nDim+1] = 0; + } +} + +void CAvgGrad_Base::GetViscousProjFlux(const su2double *val_primvar, + const su2double *val_normal) { + + /*--- Primitive variables -> [Temp vel_x vel_y vel_z Pressure] ---*/ + + if (nDim == 2) { + Flux_Tensor[0][0] = 0.0; + Flux_Tensor[1][0] = tau[0][0]; + Flux_Tensor[2][0] = tau[0][1]; + Flux_Tensor[3][0] = tau[0][0]*val_primvar[1] + tau[0][1]*val_primvar[2]+ + heat_flux_vector[0]; + Flux_Tensor[0][1] = 0.0; + Flux_Tensor[1][1] = tau[1][0]; + Flux_Tensor[2][1] = tau[1][1]; + Flux_Tensor[3][1] = tau[1][0]*val_primvar[1] + tau[1][1]*val_primvar[2]+ + heat_flux_vector[1]; + } else { + Flux_Tensor[0][0] = 0.0; + Flux_Tensor[1][0] = tau[0][0]; + Flux_Tensor[2][0] = tau[0][1]; + Flux_Tensor[3][0] = tau[0][2]; + Flux_Tensor[4][0] = tau[0][0]*val_primvar[1] + tau[0][1]*val_primvar[2] + tau[0][2]*val_primvar[3] + + heat_flux_vector[0]; + Flux_Tensor[0][1] = 0.0; + Flux_Tensor[1][1] = tau[1][0]; + Flux_Tensor[2][1] = tau[1][1]; + Flux_Tensor[3][1] = tau[1][2]; + Flux_Tensor[4][1] = tau[1][0]*val_primvar[1] + tau[1][1]*val_primvar[2] + tau[1][2]*val_primvar[3] + + heat_flux_vector[1]; + Flux_Tensor[0][2] = 0.0; + Flux_Tensor[1][2] = tau[2][0]; + Flux_Tensor[2][2] = tau[2][1]; + Flux_Tensor[3][2] = tau[2][2]; + Flux_Tensor[4][2] = tau[2][0]*val_primvar[1] + tau[2][1]*val_primvar[2] + tau[2][2]*val_primvar[3] + + heat_flux_vector[2]; + } + + for (unsigned short iVar = 0; iVar < nVar; iVar++) { + Proj_Flux_Tensor[iVar] = 0.0; + for (unsigned short iDim = 0; iDim < nDim; iDim++) + Proj_Flux_Tensor[iVar] += Flux_Tensor[iVar][iDim] * val_normal[iDim]; + } + +} + +void CAvgGrad_Base::GetViscousProjJacs(const su2double *val_Mean_PrimVar, + const su2double val_dS, + const su2double *val_Proj_Visc_Flux, + su2double **val_Proj_Jac_Tensor_i, + su2double **val_Proj_Jac_Tensor_j) { + + const su2double Density = val_Mean_PrimVar[nDim+2]; + const su2double factor = 0.5/Density; + + if (nDim == 2) { + + val_Proj_Jac_Tensor_i[0][0] = 0.0; + val_Proj_Jac_Tensor_i[0][1] = 0.0; + val_Proj_Jac_Tensor_i[0][2] = 0.0; + val_Proj_Jac_Tensor_i[0][3] = 0.0; + val_Proj_Jac_Tensor_i[1][0] = val_dS*tau_jacobian_i[0][0]; + val_Proj_Jac_Tensor_i[1][1] = val_dS*tau_jacobian_i[0][1]; + val_Proj_Jac_Tensor_i[1][2] = val_dS*tau_jacobian_i[0][2]; + val_Proj_Jac_Tensor_i[1][3] = val_dS*tau_jacobian_i[0][3]; + val_Proj_Jac_Tensor_i[2][0] = val_dS*tau_jacobian_i[1][0]; + val_Proj_Jac_Tensor_i[2][1] = val_dS*tau_jacobian_i[1][1]; + val_Proj_Jac_Tensor_i[2][2] = val_dS*tau_jacobian_i[1][2]; + val_Proj_Jac_Tensor_i[2][3] = val_dS*tau_jacobian_i[1][3]; + const su2double contraction = tau_jacobian_i[0][0]*val_Mean_PrimVar[1] + + tau_jacobian_i[1][0]*val_Mean_PrimVar[2]; + val_Proj_Jac_Tensor_i[3][0] = val_dS*(contraction - heat_flux_jac_i[0]); + val_Proj_Jac_Tensor_i[3][1] = -val_dS*(tau_jacobian_i[0][0] + heat_flux_jac_i[1]); + val_Proj_Jac_Tensor_i[3][2] = -val_dS*(tau_jacobian_i[1][0] + heat_flux_jac_i[2]); + val_Proj_Jac_Tensor_i[3][3] = -val_dS*heat_flux_jac_i[3]; + + for (unsigned short iVar = 0; iVar < nVar; iVar++) + for (unsigned short jVar = 0; jVar < nVar; jVar++) + val_Proj_Jac_Tensor_j[iVar][jVar] = -val_Proj_Jac_Tensor_i[iVar][jVar]; + + const su2double proj_viscousflux_vel= val_Proj_Visc_Flux[1]*val_Mean_PrimVar[1] + + val_Proj_Visc_Flux[2]*val_Mean_PrimVar[2]; + val_Proj_Jac_Tensor_i[3][0] -= factor*proj_viscousflux_vel; + val_Proj_Jac_Tensor_j[3][0] -= factor*proj_viscousflux_vel; + val_Proj_Jac_Tensor_i[3][1] += factor*val_Proj_Visc_Flux[1]; + val_Proj_Jac_Tensor_j[3][1] += factor*val_Proj_Visc_Flux[1]; + val_Proj_Jac_Tensor_i[3][2] += factor*val_Proj_Visc_Flux[2]; + val_Proj_Jac_Tensor_j[3][2] += factor*val_Proj_Visc_Flux[2]; + + + } else { + + val_Proj_Jac_Tensor_i[0][0] = 0.0; + val_Proj_Jac_Tensor_i[0][1] = 0.0; + val_Proj_Jac_Tensor_i[0][2] = 0.0; + val_Proj_Jac_Tensor_i[0][3] = 0.0; + val_Proj_Jac_Tensor_i[0][4] = 0.0; + val_Proj_Jac_Tensor_i[1][0] = val_dS*tau_jacobian_i[0][0]; + val_Proj_Jac_Tensor_i[1][1] = val_dS*tau_jacobian_i[0][1]; + val_Proj_Jac_Tensor_i[1][2] = val_dS*tau_jacobian_i[0][2]; + val_Proj_Jac_Tensor_i[1][3] = val_dS*tau_jacobian_i[0][3]; + val_Proj_Jac_Tensor_i[1][4] = val_dS*tau_jacobian_i[0][4]; + val_Proj_Jac_Tensor_i[2][0] = val_dS*tau_jacobian_i[1][0]; + val_Proj_Jac_Tensor_i[2][1] = val_dS*tau_jacobian_i[1][1]; + val_Proj_Jac_Tensor_i[2][2] = val_dS*tau_jacobian_i[1][2]; + val_Proj_Jac_Tensor_i[2][3] = val_dS*tau_jacobian_i[1][3]; + val_Proj_Jac_Tensor_i[2][4] = val_dS*tau_jacobian_i[1][4]; + val_Proj_Jac_Tensor_i[3][0] = val_dS*tau_jacobian_i[2][0]; + val_Proj_Jac_Tensor_i[3][1] = val_dS*tau_jacobian_i[2][1]; + val_Proj_Jac_Tensor_i[3][2] = val_dS*tau_jacobian_i[2][2]; + val_Proj_Jac_Tensor_i[3][3] = val_dS*tau_jacobian_i[2][3]; + val_Proj_Jac_Tensor_i[3][4] = val_dS*tau_jacobian_i[2][4]; + const su2double contraction = tau_jacobian_i[0][0]*val_Mean_PrimVar[1] + + tau_jacobian_i[1][0]*val_Mean_PrimVar[2] + + tau_jacobian_i[2][0]*val_Mean_PrimVar[3]; + val_Proj_Jac_Tensor_i[4][0] = val_dS*(contraction - heat_flux_jac_i[0]); + val_Proj_Jac_Tensor_i[4][1] = -val_dS*(tau_jacobian_i[0][0] + heat_flux_jac_i[1]); + val_Proj_Jac_Tensor_i[4][2] = -val_dS*(tau_jacobian_i[1][0] + heat_flux_jac_i[2]); + val_Proj_Jac_Tensor_i[4][3] = -val_dS*(tau_jacobian_i[2][0] + heat_flux_jac_i[3]); + val_Proj_Jac_Tensor_i[4][4] = -val_dS*heat_flux_jac_i[4]; + + for (unsigned short iVar = 0; iVar < nVar; iVar++) + for (unsigned short jVar = 0; jVar < nVar; jVar++) + val_Proj_Jac_Tensor_j[iVar][jVar] = -val_Proj_Jac_Tensor_i[iVar][jVar]; + + const su2double proj_viscousflux_vel= val_Proj_Visc_Flux[1]*val_Mean_PrimVar[1] + + val_Proj_Visc_Flux[2]*val_Mean_PrimVar[2] + + val_Proj_Visc_Flux[3]*val_Mean_PrimVar[3]; + val_Proj_Jac_Tensor_i[4][0] -= factor*proj_viscousflux_vel; + val_Proj_Jac_Tensor_j[4][0] -= factor*proj_viscousflux_vel; + val_Proj_Jac_Tensor_i[4][1] += factor*val_Proj_Visc_Flux[1]; + val_Proj_Jac_Tensor_j[4][1] += factor*val_Proj_Visc_Flux[1]; + val_Proj_Jac_Tensor_i[4][2] += factor*val_Proj_Visc_Flux[2]; + val_Proj_Jac_Tensor_j[4][2] += factor*val_Proj_Visc_Flux[2]; + val_Proj_Jac_Tensor_i[4][3] += factor*val_Proj_Visc_Flux[3]; + val_Proj_Jac_Tensor_j[4][3] += factor*val_Proj_Visc_Flux[3]; + + } + +} + +CAvgGrad_Flow::CAvgGrad_Flow(unsigned short val_nDim, + unsigned short val_nVar, + bool val_correct_grad, + CConfig *config) + : CAvgGrad_Base(val_nDim, val_nVar, val_nDim+3, val_correct_grad, config) { } + +void CAvgGrad_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, + su2double **val_Jacobian_j, CConfig *config) { + + AD::StartPreacc(); + AD::SetPreaccIn(V_i, nDim+9); AD::SetPreaccIn(V_j, nDim+9); + AD::SetPreaccIn(Coord_i, nDim); AD::SetPreaccIn(Coord_j, nDim); + AD::SetPreaccIn(PrimVar_Grad_i, nDim+1, nDim); + AD::SetPreaccIn(PrimVar_Grad_j, nDim+1, nDim); + AD::SetPreaccIn(turb_ke_i); AD::SetPreaccIn(turb_ke_j); + AD::SetPreaccIn(Normal, nDim); + + unsigned short iVar, jVar, iDim; + + /*--- Normalized normal vector ---*/ + + 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; + + for (iVar = 0; iVar < nPrimVar; iVar++) { + PrimVar_i[iVar] = V_i[iVar]; + PrimVar_j[iVar] = V_j[iVar]; + Mean_PrimVar[iVar] = 0.5*(PrimVar_i[iVar]+PrimVar_j[iVar]); + } + + + /*--- Compute vector going from iPoint to jPoint ---*/ + + dist_ij_2 = 0.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]; + } + + /*--- Laminar and Eddy viscosity ---*/ + + Laminar_Viscosity_i = V_i[nDim+5]; Laminar_Viscosity_j = V_j[nDim+5]; + Eddy_Viscosity_i = V_i[nDim+6]; Eddy_Viscosity_j = V_j[nDim+6]; + + /*--- Mean Viscosities and turbulent kinetic energy---*/ + + Mean_Laminar_Viscosity = 0.5*(Laminar_Viscosity_i + Laminar_Viscosity_j); + Mean_Eddy_Viscosity = 0.5*(Eddy_Viscosity_i + Eddy_Viscosity_j); + Mean_turb_ke = 0.5*(turb_ke_i + turb_ke_j); + + /*--- Mean gradient approximation ---*/ + + for (iVar = 0; iVar < nDim+1; iVar++) { + for (iDim = 0; iDim < nDim; iDim++) { + Mean_GradPrimVar[iVar][iDim] = 0.5*(PrimVar_Grad_i[iVar][iDim] + PrimVar_Grad_j[iVar][iDim]); + } + } + + /*--- Projection of the mean gradient in the direction of the edge ---*/ + + if (correct_gradient && dist_ij_2 != 0.0) { + CorrectGradient(Mean_GradPrimVar, PrimVar_i, PrimVar_j, Edge_Vector, + dist_ij_2, nDim+1); + } + + /*--- Wall shear stress values (wall functions) ---*/ + + if (TauWall_i > 0.0 && TauWall_j > 0.0) Mean_TauWall = 0.5*(TauWall_i + TauWall_j); + else if (TauWall_i > 0.0) Mean_TauWall = TauWall_i; + else if (TauWall_j > 0.0) Mean_TauWall = TauWall_j; + else Mean_TauWall = -1.0; + + /* --- If using UQ methodology, set Reynolds Stress tensor and perform perturbation--- */ + + if (using_uq){ + SetReynoldsStressMatrix(Mean_turb_ke); + SetPerturbedRSM(Mean_turb_ke, config); + } + + /*--- Get projected flux tensor ---*/ + + SetStressTensor(Mean_PrimVar, Mean_GradPrimVar, Mean_turb_ke, + Mean_Laminar_Viscosity, Mean_Eddy_Viscosity); + if (config->GetQCR()) AddQCR(Mean_GradPrimVar); + if (Mean_TauWall > 0) AddTauWall(Normal, Mean_TauWall); + + SetHeatFluxVector(Mean_GradPrimVar, Mean_Laminar_Viscosity, + Mean_Eddy_Viscosity); + + GetViscousProjFlux(Mean_PrimVar, Normal); + + /*--- Update viscous residual ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + val_residual[iVar] = Proj_Flux_Tensor[iVar]; + + /*--- Compute the implicit part ---*/ + + if (implicit) { + + if (dist_ij_2 == 0.0) { + for (iVar = 0; iVar < nVar; iVar++) { + for (jVar = 0; jVar < nVar; jVar++) { + val_Jacobian_i[iVar][jVar] = 0.0; + val_Jacobian_j[iVar][jVar] = 0.0; + } + } + } else { + const su2double dist_ij = sqrt(dist_ij_2); + SetTauJacobian(Mean_PrimVar, Mean_Laminar_Viscosity, Mean_Eddy_Viscosity, + dist_ij, UnitNormal); + SetHeatFluxJacobian(Mean_PrimVar, Mean_Laminar_Viscosity, + Mean_Eddy_Viscosity, dist_ij, UnitNormal); + GetViscousProjJacs(Mean_PrimVar, Area, Proj_Flux_Tensor, + val_Jacobian_i, val_Jacobian_j); + } + + } + + AD::SetPreaccOut(val_residual, nVar); + AD::EndPreacc(); + +} + +void CAvgGrad_Flow::SetHeatFluxVector(const su2double* const *val_gradprimvar, + const su2double val_laminar_viscosity, + const su2double val_eddy_viscosity) { + + const su2double Cp = (Gamma / Gamma_Minus_One) * Gas_Constant; + const su2double heat_flux_factor = Cp * (val_laminar_viscosity/Prandtl_Lam + val_eddy_viscosity/Prandtl_Turb); + + /*--- Gradient of primitive variables -> [Temp vel_x vel_y vel_z Pressure] ---*/ + + for (unsigned short iDim = 0; iDim < nDim; iDim++) { + heat_flux_vector[iDim] = heat_flux_factor*val_gradprimvar[0][iDim]; + } +} + +void CAvgGrad_Flow::SetHeatFluxJacobian(const su2double *val_Mean_PrimVar, + const su2double val_laminar_viscosity, + const su2double val_eddy_viscosity, + const su2double val_dist_ij, + const su2double *val_normal) { + su2double sqvel = 0.0; + + for (unsigned short iDim = 0; iDim < nDim; iDim++) { + sqvel += val_Mean_PrimVar[iDim+1]*val_Mean_PrimVar[iDim+1]; + } + + const su2double Density = val_Mean_PrimVar[nDim+2]; + const su2double Pressure = val_Mean_PrimVar[nDim+1]; + const su2double phi = Gamma_Minus_One/Density; + + /*--- R times partial derivatives of temp. ---*/ + + const su2double R_dTdu0 = -Pressure/(Density*Density) + 0.5*sqvel*phi; + const su2double R_dTdu1 = -phi*val_Mean_PrimVar[1]; + const su2double R_dTdu2 = -phi*val_Mean_PrimVar[2]; + + const su2double heat_flux_factor = val_laminar_viscosity/Prandtl_Lam + val_eddy_viscosity/Prandtl_Turb; + const su2double cpoR = Gamma/Gamma_Minus_One; // cp over R + const su2double conductivity_over_Rd = cpoR*heat_flux_factor/val_dist_ij; + + heat_flux_jac_i[0] = conductivity_over_Rd * R_dTdu0; + heat_flux_jac_i[1] = conductivity_over_Rd * R_dTdu1; + heat_flux_jac_i[2] = conductivity_over_Rd * R_dTdu2; + + if (nDim == 2) { + + const su2double R_dTdu3 = phi; + heat_flux_jac_i[3] = conductivity_over_Rd * R_dTdu3; + + } else { + + const su2double R_dTdu3 = -phi*val_Mean_PrimVar[3]; + const su2double R_dTdu4 = phi; + heat_flux_jac_i[3] = conductivity_over_Rd * R_dTdu3; + heat_flux_jac_i[4] = conductivity_over_Rd * R_dTdu4; + + } +} + +CAvgGradInc_Flow::CAvgGradInc_Flow(unsigned short val_nDim, + unsigned short val_nVar, + bool val_correct_grad, CConfig *config) + : CAvgGrad_Base(val_nDim, val_nVar, val_nDim+3, val_correct_grad, config) { + + energy = config->GetEnergy_Equation(); + +} + +void CAvgGradInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, + su2double **val_Jacobian_j, CConfig *config) { + + AD::StartPreacc(); + AD::SetPreaccIn(V_i, nDim+9); AD::SetPreaccIn(V_j, nDim+9); + AD::SetPreaccIn(Coord_i, nDim); AD::SetPreaccIn(Coord_j, nDim); + AD::SetPreaccIn(PrimVar_Grad_i, nVar, nDim); + AD::SetPreaccIn(PrimVar_Grad_j, nVar, nDim); + AD::SetPreaccIn(turb_ke_i); AD::SetPreaccIn(turb_ke_j); + AD::SetPreaccIn(Normal, nDim); + + unsigned short iVar, jVar, iDim; + + /*--- Normalized normal vector ---*/ + + 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; + + for (iVar = 0; iVar < nPrimVar; iVar++) { + PrimVar_i[iVar] = V_i[iVar]; + PrimVar_j[iVar] = V_j[iVar]; + Mean_PrimVar[iVar] = 0.5*(PrimVar_i[iVar]+PrimVar_j[iVar]); + } + + /*--- Compute vector going from iPoint to jPoint ---*/ + + dist_ij_2 = 0.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]; + } + + /*--- Density and transport properties ---*/ + + Laminar_Viscosity_i = V_i[nDim+4]; Laminar_Viscosity_j = V_j[nDim+4]; + Eddy_Viscosity_i = V_i[nDim+5]; Eddy_Viscosity_j = V_j[nDim+5]; + Thermal_Conductivity_i = V_i[nDim+6]; Thermal_Conductivity_j = V_j[nDim+6]; + + /*--- Mean transport properties ---*/ + + Mean_Laminar_Viscosity = 0.5*(Laminar_Viscosity_i + Laminar_Viscosity_j); + Mean_Eddy_Viscosity = 0.5*(Eddy_Viscosity_i + Eddy_Viscosity_j); + Mean_turb_ke = 0.5*(turb_ke_i + turb_ke_j); + Mean_Thermal_Conductivity = 0.5*(Thermal_Conductivity_i + Thermal_Conductivity_j); + + /*--- Mean gradient approximation ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + for (iDim = 0; iDim < nDim; iDim++) + Mean_GradPrimVar[iVar][iDim] = 0.5*(PrimVar_Grad_i[iVar][iDim] + PrimVar_Grad_j[iVar][iDim]); + + /*--- Projection of the mean gradient in the direction of the edge ---*/ + + if (correct_gradient && dist_ij_2 != 0.0) { + CorrectGradient(Mean_GradPrimVar, PrimVar_i, PrimVar_j, Edge_Vector, + dist_ij_2, nVar); + } + + /*--- Get projected flux tensor ---*/ + SetStressTensor(Mean_PrimVar, Mean_GradPrimVar, Mean_turb_ke, + Mean_Laminar_Viscosity, Mean_Eddy_Viscosity); + GetViscousIncProjFlux(Mean_GradPrimVar, Normal, Mean_Thermal_Conductivity); + + /*--- Update viscous residual ---*/ + + for (iVar = 0; iVar < nVar; iVar++) { + val_residual[iVar] = Proj_Flux_Tensor[iVar]; + } + + /*--- Implicit part ---*/ + + if (implicit) { + + if (dist_ij_2 == 0.0) { + for (iVar = 0; iVar < nVar; iVar++) { + for (jVar = 0; jVar < nVar; jVar++) { + val_Jacobian_i[iVar][jVar] = 0.0; + val_Jacobian_j[iVar][jVar] = 0.0; + } + } + } else { + + const su2double dist_ij = sqrt(dist_ij_2); + SetIncTauJacobian(Mean_Laminar_Viscosity, Mean_Eddy_Viscosity, + dist_ij, UnitNormal); + GetViscousIncProjJacs(Area, val_Jacobian_i, val_Jacobian_j); + + /*--- Include the temperature equation Jacobian. ---*/ + su2double proj_vector_ij = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + proj_vector_ij += (Coord_j[iDim]-Coord_i[iDim])*Normal[iDim]; + } + proj_vector_ij = proj_vector_ij/dist_ij_2; + val_Jacobian_i[nDim+1][nDim+1] = -Mean_Thermal_Conductivity*proj_vector_ij; + val_Jacobian_j[nDim+1][nDim+1] = Mean_Thermal_Conductivity*proj_vector_ij; + } + + } + + if (!energy) { + val_residual[nDim+1] = 0.0; + if (implicit) { + for (iVar = 0; iVar < nVar; iVar++) { + val_Jacobian_i[iVar][nDim+1] = 0.0; + val_Jacobian_j[iVar][nDim+1] = 0.0; + + val_Jacobian_i[nDim+1][iVar] = 0.0; + val_Jacobian_j[nDim+1][iVar] = 0.0; + } + } + } + + AD::SetPreaccOut(val_residual, nVar); + AD::EndPreacc(); + +} + +void CAvgGradInc_Flow::GetViscousIncProjFlux(const su2double* const *val_gradprimvar, + const su2double *val_normal, + su2double val_thermal_conductivity) { + + /*--- Gradient of primitive variables -> [Pressure vel_x vel_y vel_z Temperature] ---*/ + + if (nDim == 2) { + Flux_Tensor[0][0] = 0.0; + Flux_Tensor[1][0] = tau[0][0]; + Flux_Tensor[2][0] = tau[0][1]; + Flux_Tensor[3][0] = val_thermal_conductivity*val_gradprimvar[nDim+1][0]; + + Flux_Tensor[0][1] = 0.0; + Flux_Tensor[1][1] = tau[1][0]; + Flux_Tensor[2][1] = tau[1][1]; + Flux_Tensor[3][1] = val_thermal_conductivity*val_gradprimvar[nDim+1][1]; + + } else { + + Flux_Tensor[0][0] = 0.0; + Flux_Tensor[1][0] = tau[0][0]; + Flux_Tensor[2][0] = tau[0][1]; + Flux_Tensor[3][0] = tau[0][2]; + Flux_Tensor[4][0] = val_thermal_conductivity*val_gradprimvar[nDim+1][0]; + + Flux_Tensor[0][1] = 0.0; + Flux_Tensor[1][1] = tau[1][0]; + Flux_Tensor[2][1] = tau[1][1]; + Flux_Tensor[3][1] = tau[1][2]; + Flux_Tensor[4][1] = val_thermal_conductivity*val_gradprimvar[nDim+1][1]; + + Flux_Tensor[0][2] = 0.0; + Flux_Tensor[1][2] = tau[2][0]; + Flux_Tensor[2][2] = tau[2][1]; + Flux_Tensor[3][2] = tau[2][2]; + Flux_Tensor[4][2] = val_thermal_conductivity*val_gradprimvar[nDim+1][2]; + + } + + for (unsigned short iVar = 0; iVar < nVar; iVar++) { + Proj_Flux_Tensor[iVar] = 0.0; + for (unsigned short iDim = 0; iDim < nDim; iDim++) + Proj_Flux_Tensor[iVar] += Flux_Tensor[iVar][iDim] * val_normal[iDim]; + } + +} + +void CAvgGradInc_Flow::GetViscousIncProjJacs(su2double val_dS, + su2double **val_Proj_Jac_Tensor_i, + su2double **val_Proj_Jac_Tensor_j) { + if (nDim == 2) { + + val_Proj_Jac_Tensor_i[0][0] = 0.0; + val_Proj_Jac_Tensor_i[0][1] = 0.0; + val_Proj_Jac_Tensor_i[0][2] = 0.0; + val_Proj_Jac_Tensor_i[0][3] = 0.0; + + val_Proj_Jac_Tensor_i[1][0] = val_dS*tau_jacobian_i[0][0]; + val_Proj_Jac_Tensor_i[1][1] = val_dS*tau_jacobian_i[0][1]; + val_Proj_Jac_Tensor_i[1][2] = val_dS*tau_jacobian_i[0][2]; + val_Proj_Jac_Tensor_i[1][3] = val_dS*tau_jacobian_i[0][3]; + + val_Proj_Jac_Tensor_i[2][0] = val_dS*tau_jacobian_i[1][0]; + val_Proj_Jac_Tensor_i[2][1] = val_dS*tau_jacobian_i[1][1]; + val_Proj_Jac_Tensor_i[2][2] = val_dS*tau_jacobian_i[1][2]; + val_Proj_Jac_Tensor_i[2][3] = val_dS*tau_jacobian_i[1][3]; + + val_Proj_Jac_Tensor_i[3][0] = 0.0; + val_Proj_Jac_Tensor_i[3][1] = 0.0; + val_Proj_Jac_Tensor_i[3][2] = 0.0; + val_Proj_Jac_Tensor_i[3][3] = 0.0; + + } else { + + val_Proj_Jac_Tensor_i[0][0] = 0.0; + val_Proj_Jac_Tensor_i[0][1] = 0.0; + val_Proj_Jac_Tensor_i[0][2] = 0.0; + val_Proj_Jac_Tensor_i[0][3] = 0.0; + val_Proj_Jac_Tensor_i[0][4] = 0.0; + + val_Proj_Jac_Tensor_i[1][0] = val_dS*tau_jacobian_i[0][0]; + val_Proj_Jac_Tensor_i[1][1] = val_dS*tau_jacobian_i[0][1]; + val_Proj_Jac_Tensor_i[1][2] = val_dS*tau_jacobian_i[0][2]; + val_Proj_Jac_Tensor_i[1][3] = val_dS*tau_jacobian_i[0][3]; + val_Proj_Jac_Tensor_i[1][4] = val_dS*tau_jacobian_i[0][4]; + + val_Proj_Jac_Tensor_i[2][0] = val_dS*tau_jacobian_i[1][0]; + val_Proj_Jac_Tensor_i[2][1] = val_dS*tau_jacobian_i[1][1]; + val_Proj_Jac_Tensor_i[2][2] = val_dS*tau_jacobian_i[1][2]; + val_Proj_Jac_Tensor_i[2][3] = val_dS*tau_jacobian_i[1][3]; + val_Proj_Jac_Tensor_i[2][4] = val_dS*tau_jacobian_i[1][4]; + + val_Proj_Jac_Tensor_i[3][0] = val_dS*tau_jacobian_i[2][0]; + val_Proj_Jac_Tensor_i[3][1] = val_dS*tau_jacobian_i[2][1]; + val_Proj_Jac_Tensor_i[3][2] = val_dS*tau_jacobian_i[2][2]; + val_Proj_Jac_Tensor_i[3][3] = val_dS*tau_jacobian_i[2][3]; + val_Proj_Jac_Tensor_i[3][4] = val_dS*tau_jacobian_i[2][4]; + + val_Proj_Jac_Tensor_i[4][0] = 0.0; + val_Proj_Jac_Tensor_i[4][1] = 0.0; + val_Proj_Jac_Tensor_i[4][2] = 0.0; + val_Proj_Jac_Tensor_i[4][3] = 0.0; + val_Proj_Jac_Tensor_i[4][4] = 0.0; + + } + + for (unsigned short iVar = 0; iVar < nVar; iVar++) + for (unsigned short jVar = 0; jVar < nVar; jVar++) + val_Proj_Jac_Tensor_j[iVar][jVar] = -val_Proj_Jac_Tensor_i[iVar][jVar]; + +} + +CGeneralAvgGrad_Flow::CGeneralAvgGrad_Flow(unsigned short val_nDim, + unsigned short val_nVar, + bool val_correct_grad, + CConfig *config) + : CAvgGrad_Base(val_nDim, val_nVar, val_nDim+4, val_correct_grad, config) { } + +void CGeneralAvgGrad_Flow::SetHeatFluxVector(const su2double* const *val_gradprimvar, + const su2double val_laminar_viscosity, + const su2double val_eddy_viscosity, + const su2double val_thermal_conductivity, + const su2double val_heat_capacity_cp) { + + const su2double heat_flux_factor = val_thermal_conductivity + val_heat_capacity_cp*val_eddy_viscosity/Prandtl_Turb; + + /*--- Gradient of primitive variables -> [Temp vel_x vel_y vel_z Pressure] ---*/ + for (unsigned short iDim = 0; iDim < nDim; iDim++) { + heat_flux_vector[iDim] = heat_flux_factor*val_gradprimvar[0][iDim]; + } +} + +void CGeneralAvgGrad_Flow::SetHeatFluxJacobian(const su2double *val_Mean_PrimVar, + const su2double *val_Mean_SecVar, + const su2double val_eddy_viscosity, + const su2double val_thermal_conductivity, + const su2double val_heat_capacity_cp, + const su2double val_dist_ij) { + /* Viscous flux Jacobians for arbitrary equations of state */ + + //order of val_mean_primitives: T, vx, vy, vz, P, rho, ht + //order of secondary:dTdrho_e, dTde_rho + + su2double sqvel = 0.0; + for (unsigned short iDim = 0; iDim < nDim; iDim++) { + sqvel += val_Mean_PrimVar[iDim+1]*val_Mean_PrimVar[iDim+1]; + } + + su2double rho = val_Mean_PrimVar[nDim+2]; + su2double P= val_Mean_PrimVar[nDim+1]; + su2double h= val_Mean_PrimVar[nDim+3]; + su2double dTdrho_e= val_Mean_SecVar[0]; + su2double dTde_rho= val_Mean_SecVar[1]; + + su2double dTdu0= dTdrho_e + dTde_rho*(-(h-P/rho) + sqvel)*(1/rho); + su2double dTdu1= dTde_rho*(-val_Mean_PrimVar[1])*(1/rho); + su2double dTdu2= dTde_rho*(-val_Mean_PrimVar[2])*(1/rho); + + su2double total_conductivity = val_thermal_conductivity + val_heat_capacity_cp*val_eddy_viscosity/Prandtl_Turb; + su2double factor2 = total_conductivity/val_dist_ij; + + heat_flux_jac_i[0] = factor2*dTdu0; + heat_flux_jac_i[1] = factor2*dTdu1; + heat_flux_jac_i[2] = factor2*dTdu2; + + if (nDim == 2) { + + su2double dTdu3= dTde_rho*(1/rho); + heat_flux_jac_i[3] = factor2*dTdu3; + + } else { + + su2double dTdu3= dTde_rho*(-val_Mean_PrimVar[3])*(1/rho); + su2double dTdu4= dTde_rho*(1/rho); + heat_flux_jac_i[3] = factor2*dTdu3; + heat_flux_jac_i[4] = factor2*dTdu4; + + } + +} + +void CGeneralAvgGrad_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, + su2double **val_Jacobian_j, CConfig *config) { + + AD::StartPreacc(); + AD::SetPreaccIn(V_i, nDim+9); AD::SetPreaccIn(V_j, nDim+9); + AD::SetPreaccIn(Coord_i, nDim); AD::SetPreaccIn(Coord_j, nDim); + AD::SetPreaccIn(S_i, 4); AD::SetPreaccIn(S_j, 4); + AD::SetPreaccIn(PrimVar_Grad_i, nDim+1, nDim); + AD::SetPreaccIn(PrimVar_Grad_j, nDim+1, nDim); + AD::SetPreaccIn(turb_ke_i); AD::SetPreaccIn(turb_ke_j); + AD::SetPreaccIn(Normal, nDim); + + unsigned short iVar, jVar, iDim; + + /*--- Normalized normal vector ---*/ + + 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; + + /*--- Mean primitive variables ---*/ + + for (iVar = 0; iVar < nPrimVar; iVar++) { + PrimVar_i[iVar] = V_i[iVar]; + PrimVar_j[iVar] = V_j[iVar]; + Mean_PrimVar[iVar] = 0.5*(PrimVar_i[iVar]+PrimVar_j[iVar]); + } + + /*--- Compute vector going from iPoint to jPoint ---*/ + + dist_ij_2 = 0.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]; + } + + /*--- Laminar and Eddy viscosity ---*/ + + Laminar_Viscosity_i = V_i[nDim+5]; Laminar_Viscosity_j = V_j[nDim+5]; + Eddy_Viscosity_i = V_i[nDim+6]; Eddy_Viscosity_j = V_j[nDim+6]; + Thermal_Conductivity_i = V_i[nDim+7]; Thermal_Conductivity_j = V_j[nDim+7]; + Cp_i = V_i[nDim+8]; Cp_j = V_j[nDim+8]; + + /*--- Mean secondary variables ---*/ + + for (iVar = 0; iVar < 2; iVar++) { + Mean_SecVar[iVar] = 0.5*(S_i[iVar+2]+S_j[iVar+2]); + } + + /*--- Mean Viscosities and turbulent kinetic energy---*/ + + Mean_Laminar_Viscosity = 0.5*(Laminar_Viscosity_i + Laminar_Viscosity_j); + Mean_Eddy_Viscosity = 0.5*(Eddy_Viscosity_i + Eddy_Viscosity_j); + Mean_turb_ke = 0.5*(turb_ke_i + turb_ke_j); + Mean_Thermal_Conductivity = 0.5*(Thermal_Conductivity_i + Thermal_Conductivity_j); + Mean_Cp = 0.5*(Cp_i + Cp_j); + + /*--- Mean gradient approximation ---*/ + + for (iVar = 0; iVar < nDim+1; iVar++) { + for (iDim = 0; iDim < nDim; iDim++) { + Mean_GradPrimVar[iVar][iDim] = 0.5*(PrimVar_Grad_i[iVar][iDim] + PrimVar_Grad_j[iVar][iDim]); + } + } + + /*--- Projection of the mean gradient in the direction of the edge ---*/ + + if (correct_gradient && dist_ij_2 != 0.0) { + CorrectGradient(Mean_GradPrimVar, PrimVar_i, PrimVar_j, Edge_Vector, + dist_ij_2, nDim+1); + } + + /* --- If using UQ methodology, set Reynolds Stress tensor and perform perturbation--- */ + + if (using_uq){ + SetReynoldsStressMatrix(Mean_turb_ke); + SetPerturbedRSM(Mean_turb_ke, config); + } + + /*--- Get projected flux tensor ---*/ + + SetStressTensor(Mean_PrimVar, Mean_GradPrimVar, Mean_turb_ke, + Mean_Laminar_Viscosity, Mean_Eddy_Viscosity); + + SetHeatFluxVector(Mean_GradPrimVar, Mean_Laminar_Viscosity, + Mean_Eddy_Viscosity, Mean_Thermal_Conductivity, Mean_Cp); + + GetViscousProjFlux(Mean_PrimVar, Normal); + + /*--- Update viscous residual ---*/ + + for (iVar = 0; iVar < nVar; iVar++) + val_residual[iVar] = Proj_Flux_Tensor[iVar]; + + /*--- Compute the implicit part ---*/ + + if (implicit) { + + if (dist_ij_2 == 0.0) { + for (iVar = 0; iVar < nVar; iVar++) { + for (jVar = 0; jVar < nVar; jVar++) { + val_Jacobian_i[iVar][jVar] = 0.0; + val_Jacobian_j[iVar][jVar] = 0.0; + } + } + } else { + const su2double dist_ij = sqrt(dist_ij_2); + SetTauJacobian(Mean_PrimVar, Mean_Laminar_Viscosity, Mean_Eddy_Viscosity, + dist_ij, UnitNormal); + SetHeatFluxJacobian(Mean_PrimVar, Mean_SecVar, Mean_Eddy_Viscosity, + Mean_Thermal_Conductivity, Mean_Cp, dist_ij); + GetViscousProjJacs(Mean_PrimVar, Area, Proj_Flux_Tensor, + val_Jacobian_i, val_Jacobian_j); + } + + } + + AD::SetPreaccOut(val_residual, nVar); + AD::EndPreacc(); + +} diff --git a/SU2_CFD/src/numerics/flow/flow_sources.cpp b/SU2_CFD/src/numerics/flow/flow_sources.cpp new file mode 100644 index 000000000000..a3443e45f24b --- /dev/null +++ b/SU2_CFD/src/numerics/flow/flow_sources.cpp @@ -0,0 +1,541 @@ +/*! + * \file flow_sources.cpp + * \brief Implementation of numerics classes for integration + * of source terms in fluid flow problems. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../include/numerics/flow/flow_sources.hpp" + +CSourceAxisymmetric_Flow::CSourceAxisymmetric_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : + CNumerics(val_nDim, val_nVar, config) { + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + +} + +void CSourceAxisymmetric_Flow::ComputeResidual(su2double *val_residual, su2double **Jacobian_i, CConfig *config) { + + su2double yinv, Pressure_i, Enthalpy_i, Velocity_i, sq_vel; + unsigned short iDim, iVar, jVar; + + bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + + if (Coord_i[1] > EPS) { + + yinv = 1.0/Coord_i[1]; + + sq_vel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + Velocity_i = U_i[iDim+1] / U_i[0]; + sq_vel += Velocity_i *Velocity_i; + } + + Pressure_i = (Gamma-1.0)*U_i[0]*(U_i[nDim+1]/U_i[0]-0.5*sq_vel); + Enthalpy_i = (U_i[nDim+1] + Pressure_i) / U_i[0]; + + val_residual[0] = yinv*Volume*U_i[2]; + val_residual[1] = yinv*Volume*U_i[1]*U_i[2]/U_i[0]; + val_residual[2] = yinv*Volume*(U_i[2]*U_i[2]/U_i[0]); + val_residual[3] = yinv*Volume*Enthalpy_i*U_i[2]; + + if (implicit) { + Jacobian_i[0][0] = 0.0; + Jacobian_i[0][1] = 0.0; + Jacobian_i[0][2] = 1.0; + Jacobian_i[0][3] = 0.0; + + Jacobian_i[1][0] = -U_i[1]*U_i[2]/(U_i[0]*U_i[0]); + Jacobian_i[1][1] = U_i[2]/U_i[0]; + Jacobian_i[1][2] = U_i[1]/U_i[0]; + Jacobian_i[1][3] = 0.0; + + Jacobian_i[2][0] = -U_i[2]*U_i[2]/(U_i[0]*U_i[0]); + Jacobian_i[2][1] = 0.0; + Jacobian_i[2][2] = 2*U_i[2]/U_i[0]; + Jacobian_i[2][3] = 0.0; + + Jacobian_i[3][0] = -Gamma*U_i[2]*U_i[3]/(U_i[0]*U_i[0]) + (Gamma-1)*U_i[2]*(U_i[1]*U_i[1]+U_i[2]*U_i[2])/(U_i[0]*U_i[0]*U_i[0]); + Jacobian_i[3][1] = -(Gamma-1)*U_i[2]*U_i[1]/(U_i[0]*U_i[0]); + Jacobian_i[3][2] = Gamma*U_i[3]/U_i[0] - 1/2*(Gamma-1)*( (U_i[1]*U_i[1]+U_i[2]*U_i[2])/(U_i[0]*U_i[0]) + 2*U_i[2]*U_i[2]/(U_i[0]*U_i[0]) ); + Jacobian_i[3][3] = Gamma*U_i[2]/U_i[0]; + + for (iVar=0; iVar < nVar; iVar++) + for (jVar=0; jVar < nVar; jVar++) + Jacobian_i[iVar][jVar] *= yinv*Volume; + + } + + } + + else { + + for (iVar=0; iVar < nVar; iVar++) + val_residual[iVar] = 0.0; + + if (implicit) { + for (iVar=0; iVar < nVar; iVar++) { + for (jVar=0; jVar < nVar; jVar++) + Jacobian_i[iVar][jVar] = 0.0; + } + } + + } + +} + +CSourceIncAxisymmetric_Flow::CSourceIncAxisymmetric_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : + CNumerics(val_nDim, val_nVar, config) { + + implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + energy = config->GetEnergy_Equation(); + viscous = config->GetViscous(); + +} + +void CSourceIncAxisymmetric_Flow::ComputeResidual(su2double *val_residual, su2double **Jacobian_i, CConfig *config) { + + su2double yinv, Velocity_i[3]; + unsigned short iDim, jDim, iVar, jVar; + + if (Coord_i[1] > EPS) { + + yinv = 1.0/Coord_i[1]; + + /*--- Set primitive variables at points iPoint. ---*/ + + Pressure_i = V_i[0]; + Temp_i = V_i[nDim+1]; + DensityInc_i = V_i[nDim+2]; + BetaInc2_i = V_i[nDim+3]; + Cp_i = V_i[nDim+7]; + Enthalpy_i = Cp_i*Temp_i; + + for (iDim = 0; iDim < nDim; iDim++) + Velocity_i[iDim] = V_i[iDim+1]; + + /*--- Inviscid component of the source term. ---*/ + + val_residual[0] = yinv*Volume*DensityInc_i*Velocity_i[1]; + val_residual[1] = yinv*Volume*DensityInc_i*Velocity_i[0]*Velocity_i[1]; + val_residual[2] = yinv*Volume*DensityInc_i*Velocity_i[1]*Velocity_i[1]; + val_residual[3] = yinv*Volume*DensityInc_i*Enthalpy_i*Velocity_i[1]; + + if (implicit) { + + Jacobian_i[0][0] = 0.0; + Jacobian_i[0][1] = 0.0; + Jacobian_i[0][2] = 1.0; + Jacobian_i[0][3] = 0.0; + + Jacobian_i[1][0] = 0.0; + Jacobian_i[1][1] = Velocity_i[1]; + Jacobian_i[1][2] = Velocity_i[0]; + Jacobian_i[1][3] = 0.0; + + Jacobian_i[2][0] = 0.0; + Jacobian_i[2][1] = 0.0; + Jacobian_i[2][2] = 2.0*Velocity_i[1]; + Jacobian_i[2][3] = 0.0; + + Jacobian_i[3][0] = 0.0; + Jacobian_i[3][1] = 0.0; + Jacobian_i[3][2] = Enthalpy_i; + Jacobian_i[3][3] = Cp_i*Velocity_i[1]; + + for (iVar=0; iVar < nVar; iVar++) + for (jVar=0; jVar < nVar; jVar++) + Jacobian_i[iVar][jVar] *= yinv*Volume*DensityInc_i; + + } + + /*--- Add the viscous terms if necessary. ---*/ + + if (viscous) { + + Laminar_Viscosity_i = V_i[nDim+4]; + Eddy_Viscosity_i = V_i[nDim+5]; + Thermal_Conductivity_i = V_i[nDim+6]; + + su2double total_viscosity, div_vel; + + total_viscosity = (Laminar_Viscosity_i + Eddy_Viscosity_i); + + /*--- The full stress tensor is needed for variable density ---*/ + + div_vel = 0.0; + for (iDim = 0 ; iDim < nDim; iDim++) + div_vel += PrimVar_Grad_i[iDim+1][iDim]; + + for (iDim = 0 ; iDim < nDim; iDim++) + for (jDim = 0 ; jDim < nDim; jDim++) + tau[iDim][jDim] = (total_viscosity*(PrimVar_Grad_i[jDim+1][iDim] + + PrimVar_Grad_i[iDim+1][jDim] ) + -TWO3*total_viscosity*div_vel*delta[iDim][jDim]); + + /*--- Viscous terms. ---*/ + + val_residual[0] -= 0.0; + val_residual[1] -= Volume*(yinv*tau[0][1] - TWO3*AuxVar_Grad_i[0]); + val_residual[2] -= Volume*(yinv*2.0*total_viscosity*PrimVar_Grad_i[2][1] - + yinv*yinv*2.0*total_viscosity*Velocity_i[1] - + TWO3*AuxVar_Grad_i[1]); + val_residual[3] -= Volume*yinv*Thermal_Conductivity_i*PrimVar_Grad_i[nDim+1][1]; + + } + + } else { + + for (iVar=0; iVar < nVar; iVar++) + val_residual[iVar] = 0.0; + + if (implicit) { + for (iVar=0; iVar < nVar; iVar++) { + for (jVar=0; jVar < nVar; jVar++) + Jacobian_i[iVar][jVar] = 0.0; + } + } + + } + + if (!energy) { + val_residual[nDim+1] = 0.0; + if (implicit) { + for (iVar = 0; iVar < nVar; iVar++) { + Jacobian_i[iVar][nDim+1] = 0.0; + Jacobian_i[nDim+1][iVar] = 0.0; + } + } + } +} + +CSourceBodyForce::CSourceBodyForce(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : + CNumerics(val_nDim, val_nVar, config) { + + /*--- Store the pointer to the constant body force vector. ---*/ + + for (unsigned short iDim = 0; iDim < nDim; iDim++) + Body_Force_Vector[iDim] = config->GetBody_Force_Vector()[iDim]; + +} + +void CSourceBodyForce::ComputeResidual(su2double *val_residual, CConfig *config) { + + unsigned short iDim; + su2double Force_Ref = config->GetForce_Ref(); + + /*--- Zero the continuity contribution ---*/ + + val_residual[0] = 0.0; + + /*--- Momentum contribution ---*/ + + for (iDim = 0; iDim < nDim; iDim++) + val_residual[iDim+1] = -Volume * U_i[0] * Body_Force_Vector[iDim] / Force_Ref; + + /*--- Energy contribution ---*/ + + val_residual[nDim+1] = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + val_residual[nDim+1] += -Volume * U_i[iDim+1] * Body_Force_Vector[iDim] / Force_Ref; + +} + +CSourceIncBodyForce::CSourceIncBodyForce(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + /*--- Store the pointer to the constant body force vector. ---*/ + + for (unsigned short iDim = 0; iDim < nDim; iDim++) + Body_Force_Vector[iDim] = config->GetBody_Force_Vector()[iDim]; + +} + +void CSourceIncBodyForce::ComputeResidual(su2double *val_residual, CConfig *config) { + + unsigned short iDim; + su2double DensityInc_0 = 0.0; + su2double Force_Ref = config->GetForce_Ref(); + bool variable_density = (config->GetKind_DensityModel() == VARIABLE); + + /*--- Check for variable density. If we have a variable density + problem, we should subtract out the hydrostatic pressure component. ---*/ + + if (variable_density) DensityInc_0 = config->GetDensity_FreeStreamND(); + + /*--- Zero the continuity contribution ---*/ + + val_residual[0] = 0.0; + + /*--- Momentum contribution. Note that this form assumes we have + subtracted the operating density * gravity, i.e., removed the + hydrostatic pressure component (important for pressure BCs). ---*/ + + for (iDim = 0; iDim < nDim; iDim++) + val_residual[iDim+1] = -Volume * (DensityInc_i - DensityInc_0) * Body_Force_Vector[iDim] / Force_Ref; + + /*--- Zero the temperature contribution ---*/ + + val_residual[nDim+1] = 0.0; + +} + + +CSourceBoussinesq::CSourceBoussinesq(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + /*--- Store the pointer to the constant body force vector. ---*/ + + for (unsigned short iDim = 0; iDim < nDim; iDim++) + Gravity_Vector[iDim] = 0.0; + + /*--- Gravity is downward in y-dir for 2D and downward z-dir for 3D. ---*/ + + Gravity_Vector[nDim-1] = -STANDARD_GRAVITY; + +} + +void CSourceBoussinesq::ComputeResidual(su2double *val_residual, CConfig *config) { + + unsigned short iDim; + su2double Force_Ref = config->GetForce_Ref(); + su2double T0 = config->GetTemperature_FreeStreamND(); + su2double Beta = config->GetThermal_Expansion_CoeffND(); + + /*--- Zero the continuity contribution ---*/ + + val_residual[0] = 0.0; + + /*--- Momentum contribution. Note that this form assumes we have + subtracted the operating density * gravity, i.e., removed the + hydrostatic pressure component (important for pressure BCs). ---*/ + + for (iDim = 0; iDim < nDim; iDim++) + val_residual[iDim+1] = Volume * DensityInc_i * ( Beta * (U_i[nDim+1] - T0)) * Gravity_Vector[iDim] / Force_Ref; + + /*--- Zero the energy contribution ---*/ + + val_residual[nDim+1] = 0.0; + +} + +CSourceGravity::CSourceGravity(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : + CNumerics(val_nDim, val_nVar, config) { } + +void CSourceGravity::ComputeResidual(su2double *val_residual, CConfig *config) { + unsigned short iVar; + + for (iVar = 0; iVar < nVar; iVar++) + val_residual[iVar] = 0.0; + + /*--- Evaluate the source term ---*/ + val_residual[nDim] = Volume * U_i[0] * STANDARD_GRAVITY; + +} + +CSourceRotatingFrame_Flow::CSourceRotatingFrame_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + +} + +void CSourceRotatingFrame_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config) { + + unsigned short iDim, iVar, jVar; + su2double Omega[3] = {0,0,0}, Momentum[3] = {0,0,0}; + + bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + + /*--- Retrieve the angular velocity vector from config. ---*/ + + for (iDim = 0; iDim < 3; iDim++){ + Omega[iDim] = config->GetRotation_Rate(iDim)/config->GetOmega_Ref(); + } + + /*--- Get the momentum vector at the current node. ---*/ + + for (iDim = 0; iDim < nDim; iDim++) + Momentum[iDim] = U_i[iDim+1]; + + /*--- Calculate rotating frame source term as ( Omega X Rho-U ) ---*/ + + if (nDim == 2) { + val_residual[0] = 0.0; + val_residual[1] = (Omega[1]*Momentum[2] - Omega[2]*Momentum[1])*Volume; + val_residual[2] = (Omega[2]*Momentum[0] - Omega[0]*Momentum[2])*Volume; + val_residual[3] = 0.0; + } else { + val_residual[0] = 0.0; + val_residual[1] = (Omega[1]*Momentum[2] - Omega[2]*Momentum[1])*Volume; + val_residual[2] = (Omega[2]*Momentum[0] - Omega[0]*Momentum[2])*Volume; + val_residual[3] = (Omega[0]*Momentum[1] - Omega[1]*Momentum[0])*Volume; + val_residual[4] = 0.0; + } + + /*--- Calculate the source term Jacobian ---*/ + + if (implicit) { + for (iVar = 0; iVar < nVar; iVar++) + for (jVar = 0; jVar < nVar; jVar++) + val_Jacobian_i[iVar][jVar] = 0.0; + if (nDim == 2) { + val_Jacobian_i[1][2] = -Omega[2]*Volume; + val_Jacobian_i[2][1] = Omega[2]*Volume; + } else { + val_Jacobian_i[1][2] = -Omega[2]*Volume; + val_Jacobian_i[1][3] = Omega[1]*Volume; + val_Jacobian_i[2][1] = Omega[2]*Volume; + val_Jacobian_i[2][3] = -Omega[0]*Volume; + val_Jacobian_i[3][1] = -Omega[1]*Volume; + val_Jacobian_i[3][2] = Omega[0]*Volume; + } + } + +} + +CSourceIncRotatingFrame_Flow::CSourceIncRotatingFrame_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + + /*--- Retrieve the angular velocity vector from config. ---*/ + for (unsigned short iDim = 0; iDim < 3; iDim++) + Omega[iDim] = config->GetRotation_Rate(iDim)/config->GetOmega_Ref(); + +} + +void CSourceIncRotatingFrame_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config) { + + unsigned short iDim, iVar, jVar; + su2double Momentum[3] = {0,0,0}, + Velocity_i[3] = {0,0,0}; + + /*--- Primitive variables plus momentum at the node (point i) ---*/ + + DensityInc_i = V_i[nDim+2]; + + for (iDim = 0; iDim < nDim; iDim++) { + Velocity_i[iDim] = V_i[iDim+1]; + Momentum[iDim] = DensityInc_i*Velocity_i[iDim]; + } + + /*--- Calculate rotating frame source term residual as ( Omega X Rho-U ) ---*/ + + if (nDim == 2) { + val_residual[0] = 0.0; + val_residual[1] = (Omega[1]*Momentum[2] - Omega[2]*Momentum[1])*Volume; + val_residual[2] = (Omega[2]*Momentum[0] - Omega[0]*Momentum[2])*Volume; + val_residual[3] = 0.0; + } else { + val_residual[0] = 0.0; + val_residual[1] = (Omega[1]*Momentum[2] - Omega[2]*Momentum[1])*Volume; + val_residual[2] = (Omega[2]*Momentum[0] - Omega[0]*Momentum[2])*Volume; + val_residual[3] = (Omega[0]*Momentum[1] - Omega[1]*Momentum[0])*Volume; + val_residual[4] = 0.0; + } + + /*--- Calculate the source term Jacobian ---*/ + + if (implicit) { + for (iVar = 0; iVar < nVar; iVar++) + for (jVar = 0; jVar < nVar; jVar++) + val_Jacobian_i[iVar][jVar] = 0.0; + if (nDim == 2) { + val_Jacobian_i[1][2] = -DensityInc_i*Omega[2]*Volume; + val_Jacobian_i[2][1] = DensityInc_i*Omega[2]*Volume; + } else { + val_Jacobian_i[1][2] = -DensityInc_i*Omega[2]*Volume; + val_Jacobian_i[1][3] = DensityInc_i*Omega[1]*Volume; + val_Jacobian_i[2][1] = DensityInc_i*Omega[2]*Volume; + val_Jacobian_i[2][3] = -DensityInc_i*Omega[0]*Volume; + val_Jacobian_i[3][1] = -DensityInc_i*Omega[1]*Volume; + val_Jacobian_i[3][2] = DensityInc_i*Omega[0]*Volume; + } + } + +} + +CSourceWindGust::CSourceWindGust(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : + CNumerics(val_nDim, val_nVar, config) { } + +void CSourceWindGust::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config) { + + su2double u_gust, v_gust, du_gust_dx, du_gust_dy, du_gust_dt, dv_gust_dx, dv_gust_dy, dv_gust_dt, smx, smy, se, rho, u, v, p; + unsigned short GustDir = config->GetGust_Dir(); //Gust direction + + u_gust = WindGust_i[0]; + v_gust = WindGust_i[1]; + + if (GustDir == X_DIR) { + du_gust_dx = WindGustDer_i[0]; + du_gust_dy = WindGustDer_i[1]; + du_gust_dt = WindGustDer_i[2]; + dv_gust_dx = 0.0; + dv_gust_dy = 0.0; + dv_gust_dt = 0.0; + } else { + du_gust_dx = 0.0; + du_gust_dy = 0.0; + du_gust_dt = 0.0; + dv_gust_dx = WindGustDer_i[0]; + dv_gust_dy = WindGustDer_i[1]; + dv_gust_dt = WindGustDer_i[2]; + + } + + /*--- Primitive variables at point i ---*/ + u = V_i[1]; + v = V_i[2]; + p = V_i[nDim+1]; + rho = V_i[nDim+2]; + + /*--- Source terms ---*/ + smx = rho*(du_gust_dt + (u+u_gust)*du_gust_dx + (v+v_gust)*du_gust_dy); + smy = rho*(dv_gust_dt + (u+u_gust)*dv_gust_dx + (v+v_gust)*dv_gust_dy); + se = u*smx + v*smy + p*(du_gust_dx + dv_gust_dy); + + if (nDim == 2) { + val_residual[0] = 0.0; + val_residual[1] = smx*Volume; + val_residual[2] = smy*Volume; + val_residual[3] = se*Volume; + } else { + SU2_MPI::Error("You should only be in the gust source term in two dimensions", CURRENT_FUNCTION); + } + + /*--- For now the source term Jacobian is just set to zero ---*/ + + unsigned short iVar, jVar; + bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + + /*--- Calculate the source term Jacobian ---*/ + + if (implicit) { + for (iVar = 0; iVar < nVar; iVar++) + for (jVar = 0; jVar < nVar; jVar++) + val_Jacobian_i[iVar][jVar] = 0.0; + } +} diff --git a/SU2_CFD/src/numerics/flow/sources/CSourceAxisymmetric_Flow.cpp b/SU2_CFD/src/numerics/flow/sources/CSourceAxisymmetric_Flow.cpp deleted file mode 100644 index 5db5e70935da..000000000000 --- a/SU2_CFD/src/numerics/flow/sources/CSourceAxisymmetric_Flow.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/*! - * \file CSourceAxisymmetric_Flow.cpp - * \brief Implementation of numerics class CSourceAxisymmetric_Flow. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../../include/numerics/flow/sources/CSourceAxisymmetric_Flow.hpp" - -CSourceAxisymmetric_Flow::CSourceAxisymmetric_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - -} - -CSourceAxisymmetric_Flow::~CSourceAxisymmetric_Flow(void) { } - -void CSourceAxisymmetric_Flow::ComputeResidual(su2double *val_residual, su2double **Jacobian_i, CConfig *config) { - - su2double yinv, Pressure_i, Enthalpy_i, Velocity_i, sq_vel; - unsigned short iDim, iVar, jVar; - - bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - - if (Coord_i[1] > EPS) { - - yinv = 1.0/Coord_i[1]; - - sq_vel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i = U_i[iDim+1] / U_i[0]; - sq_vel += Velocity_i *Velocity_i; - } - - Pressure_i = (Gamma-1.0)*U_i[0]*(U_i[nDim+1]/U_i[0]-0.5*sq_vel); - Enthalpy_i = (U_i[nDim+1] + Pressure_i) / U_i[0]; - - val_residual[0] = yinv*Volume*U_i[2]; - val_residual[1] = yinv*Volume*U_i[1]*U_i[2]/U_i[0]; - val_residual[2] = yinv*Volume*(U_i[2]*U_i[2]/U_i[0]); - val_residual[3] = yinv*Volume*Enthalpy_i*U_i[2]; - - if (implicit) { - Jacobian_i[0][0] = 0.0; - Jacobian_i[0][1] = 0.0; - Jacobian_i[0][2] = 1.0; - Jacobian_i[0][3] = 0.0; - - Jacobian_i[1][0] = -U_i[1]*U_i[2]/(U_i[0]*U_i[0]); - Jacobian_i[1][1] = U_i[2]/U_i[0]; - Jacobian_i[1][2] = U_i[1]/U_i[0]; - Jacobian_i[1][3] = 0.0; - - Jacobian_i[2][0] = -U_i[2]*U_i[2]/(U_i[0]*U_i[0]); - Jacobian_i[2][1] = 0.0; - Jacobian_i[2][2] = 2*U_i[2]/U_i[0]; - Jacobian_i[2][3] = 0.0; - - Jacobian_i[3][0] = -Gamma*U_i[2]*U_i[3]/(U_i[0]*U_i[0]) + (Gamma-1)*U_i[2]*(U_i[1]*U_i[1]+U_i[2]*U_i[2])/(U_i[0]*U_i[0]*U_i[0]); - Jacobian_i[3][1] = -(Gamma-1)*U_i[2]*U_i[1]/(U_i[0]*U_i[0]); - Jacobian_i[3][2] = Gamma*U_i[3]/U_i[0] - 1/2*(Gamma-1)*( (U_i[1]*U_i[1]+U_i[2]*U_i[2])/(U_i[0]*U_i[0]) + 2*U_i[2]*U_i[2]/(U_i[0]*U_i[0]) ); - Jacobian_i[3][3] = Gamma*U_i[2]/U_i[0]; - - for (iVar=0; iVar < nVar; iVar++) - for (jVar=0; jVar < nVar; jVar++) - Jacobian_i[iVar][jVar] *= yinv*Volume; - - } - - } - - else { - - for (iVar=0; iVar < nVar; iVar++) - val_residual[iVar] = 0.0; - - if (implicit) { - for (iVar=0; iVar < nVar; iVar++) { - for (jVar=0; jVar < nVar; jVar++) - Jacobian_i[iVar][jVar] = 0.0; - } - } - - } - -} diff --git a/SU2_CFD/src/numerics/flow/sources/CSourceBodyForce.cpp b/SU2_CFD/src/numerics/flow/sources/CSourceBodyForce.cpp deleted file mode 100644 index 4cf55b06632a..000000000000 --- a/SU2_CFD/src/numerics/flow/sources/CSourceBodyForce.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/*! - * \file CSourceBodyForce.cpp - * \brief Implementation of numerics class CSourceBodyForce. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../../include/numerics/flow/sources/CSourceBodyForce.hpp" - -CSourceBodyForce::CSourceBodyForce(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - /*--- Store the pointer to the constant body force vector. ---*/ - - Body_Force_Vector = new su2double[nDim]; - for (unsigned short iDim = 0; iDim < nDim; iDim++) - Body_Force_Vector[iDim] = config->GetBody_Force_Vector()[iDim]; - -} - -CSourceBodyForce::~CSourceBodyForce(void) { - - if (Body_Force_Vector != NULL) delete [] Body_Force_Vector; - -} - -void CSourceBodyForce::ComputeResidual(su2double *val_residual, CConfig *config) { - - unsigned short iDim; - su2double Force_Ref = config->GetForce_Ref(); - - /*--- Zero the continuity contribution ---*/ - - val_residual[0] = 0.0; - - /*--- Momentum contribution ---*/ - - for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = -Volume * U_i[0] * Body_Force_Vector[iDim] / Force_Ref; - - /*--- Energy contribution ---*/ - - val_residual[nDim+1] = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - val_residual[nDim+1] += -Volume * U_i[iDim+1] * Body_Force_Vector[iDim] / Force_Ref; - -} diff --git a/SU2_CFD/src/numerics/flow/sources/CSourceBoussinesq.cpp b/SU2_CFD/src/numerics/flow/sources/CSourceBoussinesq.cpp deleted file mode 100644 index d62b0e17d285..000000000000 --- a/SU2_CFD/src/numerics/flow/sources/CSourceBoussinesq.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/*! - * \file CSourceBoussinesq.cpp - * \brief Implementation of numerics class CSourceBoussinesq. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../../include/numerics/flow/sources/CSourceBoussinesq.hpp" - -CSourceBoussinesq::CSourceBoussinesq(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - /*--- Store the pointer to the constant body force vector. ---*/ - - Gravity_Vector = new su2double[nDim]; - for (unsigned short iDim = 0; iDim < nDim; iDim++) - Gravity_Vector[iDim] = 0.0; - - /*--- Gravity is downward in y-dir for 2D and downward z-dir for 3D. ---*/ - - Gravity_Vector[nDim-1] = -STANDARD_GRAVITY; - -} - -CSourceBoussinesq::~CSourceBoussinesq(void) { - - if (Gravity_Vector != NULL) delete [] Gravity_Vector; - -} - -void CSourceBoussinesq::ComputeResidual(su2double *val_residual, CConfig *config) { - - unsigned short iDim; - su2double Force_Ref = config->GetForce_Ref(); - su2double T0 = config->GetTemperature_FreeStreamND(); - su2double Beta = config->GetThermal_Expansion_CoeffND(); - - /*--- Zero the continuity contribution ---*/ - - val_residual[0] = 0.0; - - /*--- Momentum contribution. Note that this form assumes we have - subtracted the operating density * gravity, i.e., removed the - hydrostatic pressure component (important for pressure BCs). ---*/ - - for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = Volume * DensityInc_i * ( Beta * (U_i[nDim+1] - T0)) * Gravity_Vector[iDim] / Force_Ref; - - /*--- Zero the energy contribution ---*/ - - val_residual[nDim+1] = 0.0; - -} diff --git a/SU2_CFD/src/numerics/flow/sources/CSourceGravity.cpp b/SU2_CFD/src/numerics/flow/sources/CSourceGravity.cpp deleted file mode 100644 index 58d26d6b97ef..000000000000 --- a/SU2_CFD/src/numerics/flow/sources/CSourceGravity.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/*! - * \file CSourceGravity.cpp - * \brief Implementation of numerics class CSourceGravity. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../../include/numerics/flow/sources/CSourceGravity.hpp" - -CSourceGravity::CSourceGravity(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - -} - -CSourceGravity::~CSourceGravity(void) { } - -void CSourceGravity::ComputeResidual(su2double *val_residual, CConfig *config) { - unsigned short iVar; - - for (iVar = 0; iVar < nVar; iVar++) - val_residual[iVar] = 0.0; - - /*--- Evaluate the source term ---*/ - val_residual[nDim] = Volume * U_i[0] * STANDARD_GRAVITY; - -} diff --git a/SU2_CFD/src/numerics/flow/sources/CSourceIncAxisymmetric_Flow.cpp b/SU2_CFD/src/numerics/flow/sources/CSourceIncAxisymmetric_Flow.cpp deleted file mode 100644 index f6e9c1e52fca..000000000000 --- a/SU2_CFD/src/numerics/flow/sources/CSourceIncAxisymmetric_Flow.cpp +++ /dev/null @@ -1,154 +0,0 @@ -/*! - * \file CSourceIncAxisymmetric_Flow.cpp - * \brief Implementation of numerics class CSourceIncAxisymmetric_Flow. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../../include/numerics/flow/sources/CSourceIncAxisymmetric_Flow.hpp" - -CSourceIncAxisymmetric_Flow::CSourceIncAxisymmetric_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - energy = config->GetEnergy_Equation(); - viscous = config->GetViscous(); - -} - -CSourceIncAxisymmetric_Flow::~CSourceIncAxisymmetric_Flow(void) { } - -void CSourceIncAxisymmetric_Flow::ComputeResidual(su2double *val_residual, su2double **Jacobian_i, CConfig *config) { - - su2double yinv, Velocity_i[3]; - unsigned short iDim, jDim, iVar, jVar; - - if (Coord_i[1] > EPS) { - - yinv = 1.0/Coord_i[1]; - - /*--- Set primitive variables at points iPoint. ---*/ - - Pressure_i = V_i[0]; - Temp_i = V_i[nDim+1]; - DensityInc_i = V_i[nDim+2]; - BetaInc2_i = V_i[nDim+3]; - Cp_i = V_i[nDim+7]; - Enthalpy_i = Cp_i*Temp_i; - - for (iDim = 0; iDim < nDim; iDim++) - Velocity_i[iDim] = V_i[iDim+1]; - - /*--- Inviscid component of the source term. ---*/ - - val_residual[0] = yinv*Volume*DensityInc_i*Velocity_i[1]; - val_residual[1] = yinv*Volume*DensityInc_i*Velocity_i[0]*Velocity_i[1]; - val_residual[2] = yinv*Volume*DensityInc_i*Velocity_i[1]*Velocity_i[1]; - val_residual[3] = yinv*Volume*DensityInc_i*Enthalpy_i*Velocity_i[1]; - - if (implicit) { - - Jacobian_i[0][0] = 0.0; - Jacobian_i[0][1] = 0.0; - Jacobian_i[0][2] = 1.0; - Jacobian_i[0][3] = 0.0; - - Jacobian_i[1][0] = 0.0; - Jacobian_i[1][1] = Velocity_i[1]; - Jacobian_i[1][2] = Velocity_i[0]; - Jacobian_i[1][3] = 0.0; - - Jacobian_i[2][0] = 0.0; - Jacobian_i[2][1] = 0.0; - Jacobian_i[2][2] = 2.0*Velocity_i[1]; - Jacobian_i[2][3] = 0.0; - - Jacobian_i[3][0] = 0.0; - Jacobian_i[3][1] = 0.0; - Jacobian_i[3][2] = Enthalpy_i; - Jacobian_i[3][3] = Cp_i*Velocity_i[1]; - - for (iVar=0; iVar < nVar; iVar++) - for (jVar=0; jVar < nVar; jVar++) - Jacobian_i[iVar][jVar] *= yinv*Volume*DensityInc_i; - - } - - /*--- Add the viscous terms if necessary. ---*/ - - if (viscous) { - - Laminar_Viscosity_i = V_i[nDim+4]; - Eddy_Viscosity_i = V_i[nDim+5]; - Thermal_Conductivity_i = V_i[nDim+6]; - - su2double total_viscosity, div_vel; - - total_viscosity = (Laminar_Viscosity_i + Eddy_Viscosity_i); - - /*--- The full stress tensor is needed for variable density ---*/ - - div_vel = 0.0; - for (iDim = 0 ; iDim < nDim; iDim++) - div_vel += PrimVar_Grad_i[iDim+1][iDim]; - - for (iDim = 0 ; iDim < nDim; iDim++) - for (jDim = 0 ; jDim < nDim; jDim++) - tau[iDim][jDim] = (total_viscosity*(PrimVar_Grad_i[jDim+1][iDim] + - PrimVar_Grad_i[iDim+1][jDim] ) - -TWO3*total_viscosity*div_vel*delta[iDim][jDim]); - - /*--- Viscous terms. ---*/ - - val_residual[0] -= 0.0; - val_residual[1] -= Volume*(yinv*tau[0][1] - TWO3*AuxVar_Grad_i[0]); - val_residual[2] -= Volume*(yinv*2.0*total_viscosity*PrimVar_Grad_i[2][1] - - yinv*yinv*2.0*total_viscosity*Velocity_i[1] - - TWO3*AuxVar_Grad_i[1]); - val_residual[3] -= Volume*yinv*Thermal_Conductivity_i*PrimVar_Grad_i[nDim+1][1]; - - } - - } else { - - for (iVar=0; iVar < nVar; iVar++) - val_residual[iVar] = 0.0; - - if (implicit) { - for (iVar=0; iVar < nVar; iVar++) { - for (jVar=0; jVar < nVar; jVar++) - Jacobian_i[iVar][jVar] = 0.0; - } - } - - } - - if (!energy) { - val_residual[nDim+1] = 0.0; - if (implicit) { - for (iVar = 0; iVar < nVar; iVar++) { - Jacobian_i[iVar][nDim+1] = 0.0; - Jacobian_i[nDim+1][iVar] = 0.0; - } - } - } -} diff --git a/SU2_CFD/src/numerics/flow/sources/CSourceIncBodyForce.cpp b/SU2_CFD/src/numerics/flow/sources/CSourceIncBodyForce.cpp deleted file mode 100644 index 223764c3d22d..000000000000 --- a/SU2_CFD/src/numerics/flow/sources/CSourceIncBodyForce.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/*! - * \file CSourceIncBodyForce.cpp - * \brief Implementation of numerics class CSourceIncBodyForce. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../../include/numerics/flow/sources/CSourceIncBodyForce.hpp" - -CSourceIncBodyForce::CSourceIncBodyForce(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - /*--- Store the pointer to the constant body force vector. ---*/ - - Body_Force_Vector = new su2double[nDim]; - for (unsigned short iDim = 0; iDim < nDim; iDim++) - Body_Force_Vector[iDim] = config->GetBody_Force_Vector()[iDim]; - -} - -CSourceIncBodyForce::~CSourceIncBodyForce(void) { - - if (Body_Force_Vector != NULL) delete [] Body_Force_Vector; - -} - -void CSourceIncBodyForce::ComputeResidual(su2double *val_residual, CConfig *config) { - - unsigned short iDim; - su2double DensityInc_0 = 0.0; - su2double Force_Ref = config->GetForce_Ref(); - bool variable_density = (config->GetKind_DensityModel() == VARIABLE); - - /*--- Check for variable density. If we have a variable density - problem, we should subtract out the hydrostatic pressure component. ---*/ - - if (variable_density) DensityInc_0 = config->GetDensity_FreeStreamND(); - - /*--- Zero the continuity contribution ---*/ - - val_residual[0] = 0.0; - - /*--- Momentum contribution. Note that this form assumes we have - subtracted the operating density * gravity, i.e., removed the - hydrostatic pressure component (important for pressure BCs). ---*/ - - for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = -Volume * (DensityInc_i - DensityInc_0) * Body_Force_Vector[iDim] / Force_Ref; - - /*--- Zero the temperature contribution ---*/ - - val_residual[nDim+1] = 0.0; - -} diff --git a/SU2_CFD/src/numerics/flow/sources/CSourceIncRotatingFrame_Flow.cpp b/SU2_CFD/src/numerics/flow/sources/CSourceIncRotatingFrame_Flow.cpp deleted file mode 100644 index e59cb0eb29ab..000000000000 --- a/SU2_CFD/src/numerics/flow/sources/CSourceIncRotatingFrame_Flow.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/*! - * \file CSourceIncRotatingFrame_Flow.cpp - * \brief Implementation of numerics class CSourceIncRotatingFrame_Flow. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../../include/numerics/flow/sources/CSourceIncRotatingFrame_Flow.hpp" - -CSourceIncRotatingFrame_Flow::CSourceIncRotatingFrame_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - /*--- Retrieve the angular velocity vector from config. ---*/ - for (unsigned short iDim = 0; iDim < 3; iDim++) - Omega[iDim] = config->GetRotation_Rate(iDim)/config->GetOmega_Ref(); - -} - -CSourceIncRotatingFrame_Flow::~CSourceIncRotatingFrame_Flow(void) { } - -void CSourceIncRotatingFrame_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config) { - - unsigned short iDim, iVar, jVar; - su2double Momentum[3] = {0,0,0}, - Velocity_i[3] = {0,0,0}; - - /*--- Primitive variables plus momentum at the node (point i) ---*/ - - DensityInc_i = V_i[nDim+2]; - - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = V_i[iDim+1]; - Momentum[iDim] = DensityInc_i*Velocity_i[iDim]; - } - - /*--- Calculate rotating frame source term residual as ( Omega X Rho-U ) ---*/ - - if (nDim == 2) { - val_residual[0] = 0.0; - val_residual[1] = (Omega[1]*Momentum[2] - Omega[2]*Momentum[1])*Volume; - val_residual[2] = (Omega[2]*Momentum[0] - Omega[0]*Momentum[2])*Volume; - val_residual[3] = 0.0; - } else { - val_residual[0] = 0.0; - val_residual[1] = (Omega[1]*Momentum[2] - Omega[2]*Momentum[1])*Volume; - val_residual[2] = (Omega[2]*Momentum[0] - Omega[0]*Momentum[2])*Volume; - val_residual[3] = (Omega[0]*Momentum[1] - Omega[1]*Momentum[0])*Volume; - val_residual[4] = 0.0; - } - - /*--- Calculate the source term Jacobian ---*/ - - if (implicit) { - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_i[iVar][jVar] = 0.0; - if (nDim == 2) { - val_Jacobian_i[1][2] = -DensityInc_i*Omega[2]*Volume; - val_Jacobian_i[2][1] = DensityInc_i*Omega[2]*Volume; - } else { - val_Jacobian_i[1][2] = -DensityInc_i*Omega[2]*Volume; - val_Jacobian_i[1][3] = DensityInc_i*Omega[1]*Volume; - val_Jacobian_i[2][1] = DensityInc_i*Omega[2]*Volume; - val_Jacobian_i[2][3] = -DensityInc_i*Omega[0]*Volume; - val_Jacobian_i[3][1] = -DensityInc_i*Omega[1]*Volume; - val_Jacobian_i[3][2] = DensityInc_i*Omega[0]*Volume; - } - } - -} diff --git a/SU2_CFD/src/numerics/flow/sources/CSourceRotatingFrame_Flow.cpp b/SU2_CFD/src/numerics/flow/sources/CSourceRotatingFrame_Flow.cpp deleted file mode 100644 index d63aaea8fa13..000000000000 --- a/SU2_CFD/src/numerics/flow/sources/CSourceRotatingFrame_Flow.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/*! - * \file CSourceRotatingFrame_Flow.cpp - * \brief Implementation of numerics class CSourceRotatingFrame_Flow. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../../include/numerics/flow/sources/CSourceRotatingFrame_Flow.hpp" - -CSourceRotatingFrame_Flow::CSourceRotatingFrame_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - -} - -CSourceRotatingFrame_Flow::~CSourceRotatingFrame_Flow(void) { } - -void CSourceRotatingFrame_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config) { - - unsigned short iDim, iVar, jVar; - su2double Omega[3] = {0,0,0}, Momentum[3] = {0,0,0}; - - bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - - /*--- Retrieve the angular velocity vector from config. ---*/ - - for (iDim = 0; iDim < 3; iDim++){ - Omega[iDim] = config->GetRotation_Rate(iDim)/config->GetOmega_Ref(); - } - - /*--- Get the momentum vector at the current node. ---*/ - - for (iDim = 0; iDim < nDim; iDim++) - Momentum[iDim] = U_i[iDim+1]; - - /*--- Calculate rotating frame source term as ( Omega X Rho-U ) ---*/ - - if (nDim == 2) { - val_residual[0] = 0.0; - val_residual[1] = (Omega[1]*Momentum[2] - Omega[2]*Momentum[1])*Volume; - val_residual[2] = (Omega[2]*Momentum[0] - Omega[0]*Momentum[2])*Volume; - val_residual[3] = 0.0; - } else { - val_residual[0] = 0.0; - val_residual[1] = (Omega[1]*Momentum[2] - Omega[2]*Momentum[1])*Volume; - val_residual[2] = (Omega[2]*Momentum[0] - Omega[0]*Momentum[2])*Volume; - val_residual[3] = (Omega[0]*Momentum[1] - Omega[1]*Momentum[0])*Volume; - val_residual[4] = 0.0; - } - - /*--- Calculate the source term Jacobian ---*/ - - if (implicit) { - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_i[iVar][jVar] = 0.0; - if (nDim == 2) { - val_Jacobian_i[1][2] = -Omega[2]*Volume; - val_Jacobian_i[2][1] = Omega[2]*Volume; - } else { - val_Jacobian_i[1][2] = -Omega[2]*Volume; - val_Jacobian_i[1][3] = Omega[1]*Volume; - val_Jacobian_i[2][1] = Omega[2]*Volume; - val_Jacobian_i[2][3] = -Omega[0]*Volume; - val_Jacobian_i[3][1] = -Omega[1]*Volume; - val_Jacobian_i[3][2] = Omega[0]*Volume; - } - } - -} diff --git a/SU2_CFD/src/numerics/flow/sources/CSourceWindGust.cpp b/SU2_CFD/src/numerics/flow/sources/CSourceWindGust.cpp deleted file mode 100644 index c8d8f360033c..000000000000 --- a/SU2_CFD/src/numerics/flow/sources/CSourceWindGust.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/*! - * \file CSourceWindGust.cpp - * \brief Implementation of numerics class CSourceWindGust. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../../include/numerics/flow/sources/CSourceWindGust.hpp" - -CSourceWindGust::CSourceWindGust(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - -} - -CSourceWindGust::~CSourceWindGust(void) { } - -void CSourceWindGust::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config) { - - su2double u_gust, v_gust, du_gust_dx, du_gust_dy, du_gust_dt, dv_gust_dx, dv_gust_dy, dv_gust_dt, smx, smy, se, rho, u, v, p; - unsigned short GustDir = config->GetGust_Dir(); //Gust direction - - u_gust = WindGust_i[0]; - v_gust = WindGust_i[1]; - - if (GustDir == X_DIR) { - du_gust_dx = WindGustDer_i[0]; - du_gust_dy = WindGustDer_i[1]; - du_gust_dt = WindGustDer_i[2]; - dv_gust_dx = 0.0; - dv_gust_dy = 0.0; - dv_gust_dt = 0.0; - } else { - du_gust_dx = 0.0; - du_gust_dy = 0.0; - du_gust_dt = 0.0; - dv_gust_dx = WindGustDer_i[0]; - dv_gust_dy = WindGustDer_i[1]; - dv_gust_dt = WindGustDer_i[2]; - - } - - /*--- Primitive variables at point i ---*/ - u = V_i[1]; - v = V_i[2]; - p = V_i[nDim+1]; - rho = V_i[nDim+2]; - - /*--- Source terms ---*/ - smx = rho*(du_gust_dt + (u+u_gust)*du_gust_dx + (v+v_gust)*du_gust_dy); - smy = rho*(dv_gust_dt + (u+u_gust)*dv_gust_dx + (v+v_gust)*dv_gust_dy); - se = u*smx + v*smy + p*(du_gust_dx + dv_gust_dy); - - if (nDim == 2) { - val_residual[0] = 0.0; - val_residual[1] = smx*Volume; - val_residual[2] = smy*Volume; - val_residual[3] = se*Volume; - } else { - SU2_MPI::Error("You should only be in the gust source term in two dimensions", CURRENT_FUNCTION); - } - - /*--- For now the source term Jacobian is just set to zero ---*/ - - unsigned short iVar, jVar; - bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - - /*--- Calculate the source term Jacobian ---*/ - - if (implicit) { - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_i[iVar][jVar] = 0.0; - } -} diff --git a/SU2_CFD/src/numerics/heat.cpp b/SU2_CFD/src/numerics/heat.cpp new file mode 100644 index 000000000000..c35c8f609c79 --- /dev/null +++ b/SU2_CFD/src/numerics/heat.cpp @@ -0,0 +1,322 @@ +/*! + * \file heat.cpp + * \brief Implementation of numerics classes for heat transfer. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../include/numerics/heat.hpp" + +CCentSca_Heat::CCentSca_Heat(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : + CNumerics(val_nDim, val_nVar, config) { + + implicit = (config->GetKind_TimeIntScheme_Turb() == EULER_IMPLICIT); + /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ + dynamic_grid = config->GetDynamic_Grid(); + + MeanVelocity = new su2double [nDim]; + + Laminar_Viscosity_i = config->GetViscosity_FreeStreamND(); + Laminar_Viscosity_j = config->GetViscosity_FreeStreamND(); + + Param_Kappa_4 = config->GetKappa_4th_Heat(); + Diff_Lapl = new su2double [nVar]; +} + +CCentSca_Heat::~CCentSca_Heat(void) { + + delete [] MeanVelocity; + delete [] Diff_Lapl; + +} + +void CCentSca_Heat::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, + su2double **val_Jacobian_j, CConfig *config) { + + AD::StartPreacc(); + AD::SetPreaccIn(V_i, nDim+3); AD::SetPreaccIn(V_j, nDim+3); + AD::SetPreaccIn(Temp_i); AD::SetPreaccIn(Temp_j); + AD::SetPreaccIn(Und_Lapl_i, nVar); AD::SetPreaccIn(Und_Lapl_j, nVar); + AD::SetPreaccIn(Normal, nDim); + if (dynamic_grid) { + AD::SetPreaccIn(GridVel_i, nDim); AD::SetPreaccIn(GridVel_j, nDim); + } + + /*--- Primitive variables at point i and j ---*/ + + Pressure_i = V_i[0]; Pressure_j = V_j[0]; + DensityInc_i = V_i[nDim+2]; DensityInc_j = V_j[nDim+2]; + BetaInc2_i = V_i[nDim+3]; BetaInc2_j = V_j[nDim+3]; + + /*--- Projected velocities at the current edge ---*/ + + ProjVelocity = 0.0; ProjVelocity_i = 0.0; ProjVelocity_j = 0.0; Area = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + ProjVelocity_i += V_i[iDim+1]*Normal[iDim]; + ProjVelocity_j += V_j[iDim+1]*Normal[iDim]; + Area += Normal[iDim]*Normal[iDim]; + } + Area = sqrt(Area); + + /*--- Computing the second order centered scheme part ---*/ + + ProjVelocity = 0.5*(ProjVelocity_i+ProjVelocity_j); + + val_residual[0] = 0.5*(Temp_i + Temp_j)*ProjVelocity; + + if (implicit) { + val_Jacobian_i[0][0] = 0.5*ProjVelocity; + val_Jacobian_j[0][0] = 0.5*ProjVelocity; + } + + /*--- Adding artificial dissipation to stabilize the centered scheme ---*/ + + Diff_Lapl[0] = Und_Lapl_i[0]-Und_Lapl_j[0]; + + SoundSpeed_i = sqrt(ProjVelocity_i*ProjVelocity_i + (BetaInc2_i/DensityInc_i)*Area*Area); + SoundSpeed_j = sqrt(ProjVelocity_j*ProjVelocity_j + (BetaInc2_j/DensityInc_j)*Area*Area); + + Local_Lambda_i = fabs(ProjVelocity_i)+SoundSpeed_i; + Local_Lambda_j = fabs(ProjVelocity_j)+SoundSpeed_j; + MeanLambda = 0.5*(Local_Lambda_i+Local_Lambda_j); + + val_residual[0] += -Param_Kappa_4*Diff_Lapl[0]*MeanLambda; + + if (implicit) { + cte_0 = Param_Kappa_4*su2double(Neighbor_i+1)*MeanLambda; + cte_1 = Param_Kappa_4*su2double(Neighbor_j+1)*MeanLambda; + + val_Jacobian_i[0][0] += cte_0; + val_Jacobian_j[0][0] -= cte_1; + } + + AD::SetPreaccOut(val_residual[0]); + AD::EndPreacc(); + +} + +CUpwSca_Heat::CUpwSca_Heat(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : + CNumerics(val_nDim, val_nVar, config) { + + implicit = (config->GetKind_TimeIntScheme_Turb() == EULER_IMPLICIT); + /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ + dynamic_grid = config->GetDynamic_Grid(); + + Velocity_i = new su2double [nDim]; + Velocity_j = new su2double [nDim]; + + Laminar_Viscosity_i = config->GetViscosity_FreeStreamND(); + Laminar_Viscosity_j = config->GetViscosity_FreeStreamND(); +} + +CUpwSca_Heat::~CUpwSca_Heat(void) { + + delete [] Velocity_i; + delete [] Velocity_j; + +} + +void CUpwSca_Heat::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, + su2double **val_Jacobian_j, CConfig *config) { + + q_ij = 0.0; + + AD::StartPreacc(); + AD::SetPreaccIn(V_i, nDim+1); AD::SetPreaccIn(V_j, nDim+1); + AD::SetPreaccIn(Temp_i); AD::SetPreaccIn(Temp_j); + AD::SetPreaccIn(Normal, nDim); + if (dynamic_grid) { + AD::SetPreaccIn(GridVel_i, nDim); AD::SetPreaccIn(GridVel_j, nDim); + } + + for (iDim = 0; iDim < nDim; iDim++) { + Velocity_i[iDim] = V_i[iDim+1]; + Velocity_j[iDim] = V_j[iDim+1]; + q_ij += 0.5*(Velocity_i[iDim]+Velocity_j[iDim])*Normal[iDim]; + } + + a0 = 0.5*(q_ij+fabs(q_ij)); + a1 = 0.5*(q_ij-fabs(q_ij)); + val_residual[0] = a0*Temp_i+a1*Temp_j; + + if (implicit) { + val_Jacobian_i[0][0] = a0; + val_Jacobian_j[0][0] = a1; + } + + AD::SetPreaccOut(val_residual[0]); + AD::EndPreacc(); + +} + +CAvgGrad_Heat::CAvgGrad_Heat(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : + CNumerics(val_nDim, val_nVar, config) { + + implicit = (config->GetKind_TimeIntScheme_Heat() == EULER_IMPLICIT); + + Edge_Vector = new su2double [nDim]; + Proj_Mean_GradHeatVar_Normal = new su2double [nVar]; + Proj_Mean_GradHeatVar_Corrected = new su2double [nVar]; + Mean_GradHeatVar = new su2double* [nVar]; + for (iVar = 0; iVar < nVar; iVar++) + Mean_GradHeatVar[iVar] = new su2double [nDim]; + +} + +CAvgGrad_Heat::~CAvgGrad_Heat(void) { + + delete [] Edge_Vector; + delete [] Proj_Mean_GradHeatVar_Normal; + delete [] Proj_Mean_GradHeatVar_Corrected; + for (iVar = 0; iVar < nVar; iVar++) + delete [] Mean_GradHeatVar[iVar]; + delete [] Mean_GradHeatVar; + +} + +void CAvgGrad_Heat::ComputeResidual(su2double *val_residual, su2double **Jacobian_i, + su2double **Jacobian_j, CConfig *config) { + + AD::StartPreacc(); + AD::SetPreaccIn(Coord_i, nDim); AD::SetPreaccIn(Coord_j, nDim); + AD::SetPreaccIn(Normal, nDim); + AD::SetPreaccIn(Temp_i); AD::SetPreaccIn(Temp_j); + AD::SetPreaccIn(ConsVar_Grad_i[0],nDim); AD::SetPreaccIn(ConsVar_Grad_j[0],nDim); + AD::SetPreaccIn(Thermal_Diffusivity_i); AD::SetPreaccIn(Thermal_Conductivity_j); + + Thermal_Diffusivity_Mean = 0.5*(Thermal_Diffusivity_i + Thermal_Diffusivity_j); + + /*--- Compute vector going from iPoint to jPoint ---*/ + + 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; + + /*--- Mean gradient approximation. Projection of the mean gradient in the direction of the edge ---*/ + for (iVar = 0; iVar < nVar; iVar++) { + Proj_Mean_GradHeatVar_Normal[iVar] = 0.0; + Proj_Mean_GradHeatVar_Corrected[iVar] = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + Mean_GradHeatVar[iVar][iDim] = 0.5*(ConsVar_Grad_i[iVar][iDim] + ConsVar_Grad_j[iVar][iDim]); + Proj_Mean_GradHeatVar_Normal[iVar] += Mean_GradHeatVar[iVar][iDim]*Normal[iDim]; + } + Proj_Mean_GradHeatVar_Corrected[iVar] = Proj_Mean_GradHeatVar_Normal[iVar]; + } + + val_residual[0] = Thermal_Diffusivity_Mean*Proj_Mean_GradHeatVar_Corrected[0]; + + /*--- For Jacobians -> Use of TSL approx. to compute derivatives of the gradients ---*/ + if (implicit) { + Jacobian_i[0][0] = -Thermal_Diffusivity_Mean*proj_vector_ij; + Jacobian_j[0][0] = Thermal_Diffusivity_Mean*proj_vector_ij; + } + + AD::SetPreaccOut(val_residual, nVar); + AD::EndPreacc(); + +} + +CAvgGradCorrected_Heat::CAvgGradCorrected_Heat(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : + CNumerics(val_nDim, val_nVar, config) { + + implicit = (config->GetKind_TimeIntScheme_Heat() == EULER_IMPLICIT); + + Edge_Vector = new su2double [nDim]; + Proj_Mean_GradHeatVar_Edge = new su2double [nVar]; + Proj_Mean_GradHeatVar_Kappa = new su2double [nVar]; + Proj_Mean_GradHeatVar_Corrected = new su2double [nVar]; + Mean_GradHeatVar = new su2double* [nVar]; + for (iVar = 0; iVar < nVar; iVar++) + Mean_GradHeatVar[iVar] = new su2double [nDim]; + +} + +CAvgGradCorrected_Heat::~CAvgGradCorrected_Heat(void) { + + delete [] Edge_Vector; + delete [] Proj_Mean_GradHeatVar_Edge; + delete [] Proj_Mean_GradHeatVar_Kappa; + delete [] Proj_Mean_GradHeatVar_Corrected; + for (iVar = 0; iVar < nVar; iVar++) + delete [] Mean_GradHeatVar[iVar]; + delete [] Mean_GradHeatVar; + +} + +void CAvgGradCorrected_Heat::ComputeResidual(su2double *val_residual, su2double **Jacobian_i, + su2double **Jacobian_j, CConfig *config) { + + AD::StartPreacc(); + AD::SetPreaccIn(Coord_i, nDim); AD::SetPreaccIn(Coord_j, nDim); + AD::SetPreaccIn(Normal, nDim); + AD::SetPreaccIn(Temp_i); AD::SetPreaccIn(Temp_j); + AD::SetPreaccIn(ConsVar_Grad_i[0],nDim); AD::SetPreaccIn(ConsVar_Grad_j[0],nDim); + AD::SetPreaccIn(Thermal_Diffusivity_i); AD::SetPreaccIn(Thermal_Diffusivity_j); + + Thermal_Diffusivity_Mean = 0.5*(Thermal_Diffusivity_i + Thermal_Diffusivity_j); + + /*--- Compute vector going from iPoint to jPoint ---*/ + + 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; + + /*--- Mean gradient approximation. Projection of the mean gradient + in the direction of the edge ---*/ + + for (iVar = 0; iVar < nVar; iVar++) { + Proj_Mean_GradHeatVar_Edge[iVar] = 0.0; + Proj_Mean_GradHeatVar_Kappa[iVar] = 0.0; + + for (iDim = 0; iDim < nDim; iDim++) { + Mean_GradHeatVar[iVar][iDim] = 0.5*(ConsVar_Grad_i[iVar][iDim] + ConsVar_Grad_j[iVar][iDim]); + Proj_Mean_GradHeatVar_Kappa[iVar] += Mean_GradHeatVar[iVar][iDim]*Normal[iDim]; + Proj_Mean_GradHeatVar_Edge[iVar] += Mean_GradHeatVar[iVar][iDim]*Edge_Vector[iDim]; + } + Proj_Mean_GradHeatVar_Corrected[iVar] = Proj_Mean_GradHeatVar_Kappa[iVar]; + Proj_Mean_GradHeatVar_Corrected[iVar] -= Proj_Mean_GradHeatVar_Edge[iVar]*proj_vector_ij - + (Temp_j-Temp_i)*proj_vector_ij; + } + + val_residual[0] = Thermal_Diffusivity_Mean*Proj_Mean_GradHeatVar_Corrected[0]; + + /*--- For Jacobians -> Use of TSL approx. to compute derivatives of the gradients ---*/ + + if (implicit) { + Jacobian_i[0][0] = -Thermal_Diffusivity_Mean*proj_vector_ij; + Jacobian_j[0][0] = Thermal_Diffusivity_Mean*proj_vector_ij; + } + + AD::SetPreaccOut(val_residual, nVar); + AD::EndPreacc(); +} diff --git a/SU2_CFD/src/numerics/heat/CAvgGradCorrected_Heat.cpp b/SU2_CFD/src/numerics/heat/CAvgGradCorrected_Heat.cpp deleted file mode 100644 index 5e6446ea9815..000000000000 --- a/SU2_CFD/src/numerics/heat/CAvgGradCorrected_Heat.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/*! - * \file CAvgGradCorrected_Heat.cpp - * \brief Implementation of numerics class CAvgGradCorrected_Heat. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../include/numerics/heat/CAvgGradCorrected_Heat.hpp" - -CAvgGradCorrected_Heat::CAvgGradCorrected_Heat(unsigned short val_nDim, unsigned short val_nVar, - CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_Heat() == EULER_IMPLICIT); - - Edge_Vector = new su2double [nDim]; - Proj_Mean_GradHeatVar_Edge = new su2double [nVar]; - Proj_Mean_GradHeatVar_Kappa = new su2double [nVar]; - Proj_Mean_GradHeatVar_Corrected = new su2double [nVar]; - Mean_GradHeatVar = new su2double* [nVar]; - for (iVar = 0; iVar < nVar; iVar++) - Mean_GradHeatVar[iVar] = new su2double [nDim]; - -} - -CAvgGradCorrected_Heat::~CAvgGradCorrected_Heat(void) { - - delete [] Edge_Vector; - delete [] Proj_Mean_GradHeatVar_Edge; - delete [] Proj_Mean_GradHeatVar_Kappa; - delete [] Proj_Mean_GradHeatVar_Corrected; - for (iVar = 0; iVar < nVar; iVar++) - delete [] Mean_GradHeatVar[iVar]; - delete [] Mean_GradHeatVar; - -} - -void CAvgGradCorrected_Heat::ComputeResidual(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config) { - - AD::StartPreacc(); - AD::SetPreaccIn(Coord_i, nDim); AD::SetPreaccIn(Coord_j, nDim); - AD::SetPreaccIn(Normal, nDim); - AD::SetPreaccIn(Temp_i); AD::SetPreaccIn(Temp_j); - AD::SetPreaccIn(ConsVar_Grad_i[0],nDim); AD::SetPreaccIn(ConsVar_Grad_j[0],nDim); - AD::SetPreaccIn(Thermal_Diffusivity_i); AD::SetPreaccIn(Thermal_Diffusivity_j); - - Thermal_Diffusivity_Mean = 0.5*(Thermal_Diffusivity_i + Thermal_Diffusivity_j); - - /*--- Compute vector going from iPoint to jPoint ---*/ - - 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; - - /*--- Mean gradient approximation. Projection of the mean gradient - in the direction of the edge ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - Proj_Mean_GradHeatVar_Edge[iVar] = 0.0; - Proj_Mean_GradHeatVar_Kappa[iVar] = 0.0; - - for (iDim = 0; iDim < nDim; iDim++) { - Mean_GradHeatVar[iVar][iDim] = 0.5*(ConsVar_Grad_i[iVar][iDim] + ConsVar_Grad_j[iVar][iDim]); - Proj_Mean_GradHeatVar_Kappa[iVar] += Mean_GradHeatVar[iVar][iDim]*Normal[iDim]; - Proj_Mean_GradHeatVar_Edge[iVar] += Mean_GradHeatVar[iVar][iDim]*Edge_Vector[iDim]; - } - Proj_Mean_GradHeatVar_Corrected[iVar] = Proj_Mean_GradHeatVar_Kappa[iVar]; - Proj_Mean_GradHeatVar_Corrected[iVar] -= Proj_Mean_GradHeatVar_Edge[iVar]*proj_vector_ij - - (Temp_j-Temp_i)*proj_vector_ij; - } - - val_residual[0] = Thermal_Diffusivity_Mean*Proj_Mean_GradHeatVar_Corrected[0]; - - /*--- For Jacobians -> Use of TSL approx. to compute derivatives of the gradients ---*/ - - if (implicit) { - Jacobian_i[0][0] = -Thermal_Diffusivity_Mean*proj_vector_ij; - Jacobian_j[0][0] = Thermal_Diffusivity_Mean*proj_vector_ij; - } - - AD::SetPreaccOut(val_residual, nVar); - AD::EndPreacc(); -} diff --git a/SU2_CFD/src/numerics/heat/CAvgGrad_Heat.cpp b/SU2_CFD/src/numerics/heat/CAvgGrad_Heat.cpp deleted file mode 100644 index 75c06279fc3a..000000000000 --- a/SU2_CFD/src/numerics/heat/CAvgGrad_Heat.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/*! - * \file CAvgGrad_Heat.cpp - * \brief Implementation of numerics class CAvgGrad_Heat. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../include/numerics/heat/CAvgGrad_Heat.hpp" - -CAvgGrad_Heat::CAvgGrad_Heat(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_Heat() == EULER_IMPLICIT); - - Edge_Vector = new su2double [nDim]; - Proj_Mean_GradHeatVar_Normal = new su2double [nVar]; - Proj_Mean_GradHeatVar_Corrected = new su2double [nVar]; - Mean_GradHeatVar = new su2double* [nVar]; - for (iVar = 0; iVar < nVar; iVar++) - Mean_GradHeatVar[iVar] = new su2double [nDim]; - -} - -CAvgGrad_Heat::~CAvgGrad_Heat(void) { - - delete [] Edge_Vector; - delete [] Proj_Mean_GradHeatVar_Normal; - delete [] Proj_Mean_GradHeatVar_Corrected; - for (iVar = 0; iVar < nVar; iVar++) - delete [] Mean_GradHeatVar[iVar]; - delete [] Mean_GradHeatVar; - -} - -void CAvgGrad_Heat::ComputeResidual(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config) { - - AD::StartPreacc(); - AD::SetPreaccIn(Coord_i, nDim); AD::SetPreaccIn(Coord_j, nDim); - AD::SetPreaccIn(Normal, nDim); - AD::SetPreaccIn(Temp_i); AD::SetPreaccIn(Temp_j); - AD::SetPreaccIn(ConsVar_Grad_i[0],nDim); AD::SetPreaccIn(ConsVar_Grad_j[0],nDim); - AD::SetPreaccIn(Thermal_Diffusivity_i); AD::SetPreaccIn(Thermal_Conductivity_j); - - Thermal_Diffusivity_Mean = 0.5*(Thermal_Diffusivity_i + Thermal_Diffusivity_j); - - /*--- Compute vector going from iPoint to jPoint ---*/ - - 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; - - /*--- Mean gradient approximation. Projection of the mean gradient in the direction of the edge ---*/ - for (iVar = 0; iVar < nVar; iVar++) { - Proj_Mean_GradHeatVar_Normal[iVar] = 0.0; - Proj_Mean_GradHeatVar_Corrected[iVar] = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Mean_GradHeatVar[iVar][iDim] = 0.5*(ConsVar_Grad_i[iVar][iDim] + ConsVar_Grad_j[iVar][iDim]); - Proj_Mean_GradHeatVar_Normal[iVar] += Mean_GradHeatVar[iVar][iDim]*Normal[iDim]; - } - Proj_Mean_GradHeatVar_Corrected[iVar] = Proj_Mean_GradHeatVar_Normal[iVar]; - } - - val_residual[0] = Thermal_Diffusivity_Mean*Proj_Mean_GradHeatVar_Corrected[0]; - - /*--- For Jacobians -> Use of TSL approx. to compute derivatives of the gradients ---*/ - if (implicit) { - Jacobian_i[0][0] = -Thermal_Diffusivity_Mean*proj_vector_ij; - Jacobian_j[0][0] = Thermal_Diffusivity_Mean*proj_vector_ij; - } - - AD::SetPreaccOut(val_residual, nVar); - AD::EndPreacc(); - -} - diff --git a/SU2_CFD/src/numerics/heat/CCentSca_Heat.cpp b/SU2_CFD/src/numerics/heat/CCentSca_Heat.cpp deleted file mode 100644 index f04075b47d05..000000000000 --- a/SU2_CFD/src/numerics/heat/CCentSca_Heat.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/*! - * \file CCentSca_Heat.cpp - * \brief Implementation of numerics class CCentSca_Heat. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../include/numerics/heat/CCentSca_Heat.hpp" - -CCentSca_Heat::CCentSca_Heat(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_Turb() == EULER_IMPLICIT); - /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ - dynamic_grid = config->GetDynamic_Grid(); - - MeanVelocity = new su2double [nDim]; - - Laminar_Viscosity_i = config->GetViscosity_FreeStreamND(); - Laminar_Viscosity_j = config->GetViscosity_FreeStreamND(); - - Param_Kappa_4 = config->GetKappa_4th_Heat(); - Diff_Lapl = new su2double [nVar]; -} - -CCentSca_Heat::~CCentSca_Heat(void) { - - delete [] MeanVelocity; - delete [] Diff_Lapl; - -} - -void CCentSca_Heat::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - AD::StartPreacc(); - AD::SetPreaccIn(V_i, nDim+3); AD::SetPreaccIn(V_j, nDim+3); - AD::SetPreaccIn(Temp_i); AD::SetPreaccIn(Temp_j); - AD::SetPreaccIn(Und_Lapl_i, nVar); AD::SetPreaccIn(Und_Lapl_j, nVar); - AD::SetPreaccIn(Normal, nDim); - if (dynamic_grid) { - AD::SetPreaccIn(GridVel_i, nDim); AD::SetPreaccIn(GridVel_j, nDim); - } - - /*--- Primitive variables at point i and j ---*/ - - Pressure_i = V_i[0]; Pressure_j = V_j[0]; - DensityInc_i = V_i[nDim+2]; DensityInc_j = V_j[nDim+2]; - BetaInc2_i = V_i[nDim+3]; BetaInc2_j = V_j[nDim+3]; - - /*--- Projected velocities at the current edge ---*/ - - ProjVelocity = 0.0; ProjVelocity_i = 0.0; ProjVelocity_j = 0.0; Area = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - ProjVelocity_i += V_i[iDim+1]*Normal[iDim]; - ProjVelocity_j += V_j[iDim+1]*Normal[iDim]; - Area += Normal[iDim]*Normal[iDim]; - } - Area = sqrt(Area); - - /*--- Computing the second order centered scheme part ---*/ - - ProjVelocity = 0.5*(ProjVelocity_i+ProjVelocity_j); - - val_residual[0] = 0.5*(Temp_i + Temp_j)*ProjVelocity; - - if (implicit) { - val_Jacobian_i[0][0] = 0.5*ProjVelocity; - val_Jacobian_j[0][0] = 0.5*ProjVelocity; - } - - /*--- Adding artificial dissipation to stabilize the centered scheme ---*/ - - Diff_Lapl[0] = Und_Lapl_i[0]-Und_Lapl_j[0]; - - SoundSpeed_i = sqrt(ProjVelocity_i*ProjVelocity_i + (BetaInc2_i/DensityInc_i)*Area*Area); - SoundSpeed_j = sqrt(ProjVelocity_j*ProjVelocity_j + (BetaInc2_j/DensityInc_j)*Area*Area); - - Local_Lambda_i = fabs(ProjVelocity_i)+SoundSpeed_i; - Local_Lambda_j = fabs(ProjVelocity_j)+SoundSpeed_j; - MeanLambda = 0.5*(Local_Lambda_i+Local_Lambda_j); - - val_residual[0] += -Param_Kappa_4*Diff_Lapl[0]*MeanLambda; - - if (implicit) { - cte_0 = Param_Kappa_4*su2double(Neighbor_i+1)*MeanLambda; - cte_1 = Param_Kappa_4*su2double(Neighbor_j+1)*MeanLambda; - - val_Jacobian_i[0][0] += cte_0; - val_Jacobian_j[0][0] -= cte_1; - } - - AD::SetPreaccOut(val_residual[0]); - AD::EndPreacc(); - -} diff --git a/SU2_CFD/src/numerics/heat/CUpwSca_Heat.cpp b/SU2_CFD/src/numerics/heat/CUpwSca_Heat.cpp deleted file mode 100644 index ff2057724e84..000000000000 --- a/SU2_CFD/src/numerics/heat/CUpwSca_Heat.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/*! - * \file CUpwSca_Heat.cpp - * \brief Implementation of numerics class CUpwSca_Heat. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../include/numerics/heat/CUpwSca_Heat.hpp" - -CUpwSca_Heat::CUpwSca_Heat(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_Turb() == EULER_IMPLICIT); - /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ - dynamic_grid = config->GetDynamic_Grid(); - - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; - - Laminar_Viscosity_i = config->GetViscosity_FreeStreamND(); - Laminar_Viscosity_j = config->GetViscosity_FreeStreamND(); -} - -CUpwSca_Heat::~CUpwSca_Heat(void) { - - delete [] Velocity_i; - delete [] Velocity_j; - -} - -void CUpwSca_Heat::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - q_ij = 0.0; - - AD::StartPreacc(); - AD::SetPreaccIn(V_i, nDim+1); AD::SetPreaccIn(V_j, nDim+1); - AD::SetPreaccIn(Temp_i); AD::SetPreaccIn(Temp_j); - AD::SetPreaccIn(Normal, nDim); - if (dynamic_grid) { - AD::SetPreaccIn(GridVel_i, nDim); AD::SetPreaccIn(GridVel_j, nDim); - } - - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = V_i[iDim+1]; - Velocity_j[iDim] = V_j[iDim+1]; - q_ij += 0.5*(Velocity_i[iDim]+Velocity_j[iDim])*Normal[iDim]; - } - - a0 = 0.5*(q_ij+fabs(q_ij)); - a1 = 0.5*(q_ij-fabs(q_ij)); - val_residual[0] = a0*Temp_i+a1*Temp_j; - - if (implicit) { - val_Jacobian_i[0][0] = a0; - val_Jacobian_j[0][0] = a1; - } - - AD::SetPreaccOut(val_residual[0]); - AD::EndPreacc(); - -} diff --git a/SU2_CFD/src/numerics/template.cpp b/SU2_CFD/src/numerics/template.cpp new file mode 100644 index 000000000000..53077ffe9545 --- /dev/null +++ b/SU2_CFD/src/numerics/template.cpp @@ -0,0 +1,70 @@ +/*! + * \file template.cpp + * \brief Empty implementation of numerics templates, see .hpp file. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../include/numerics/template.hpp" + +CConvective_Template::CConvective_Template(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : + CNumerics(val_nDim, val_nVar, config) { + +} + +CConvective_Template::~CConvective_Template(void) { + +} + +void CConvective_Template::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, + su2double **val_Jacobian_j, CConfig *config) { + +} + +CViscous_Template::CViscous_Template(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : + CNumerics(val_nDim, val_nVar, config) { + +} + +CViscous_Template::~CViscous_Template(void) { + +} + +void CViscous_Template::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, + su2double **val_Jacobian_j, CConfig *config) { + +} + + +CSource_Template::CSource_Template(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : + CNumerics(val_nDim, val_nVar, config) { + +} + +CSource_Template::~CSource_Template(void) { + +} + +void CSource_Template::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config) { + +} diff --git a/SU2_CFD/src/numerics/template/CConvective_Template.cpp b/SU2_CFD/src/numerics/template/CConvective_Template.cpp deleted file mode 100644 index 969c316a0f8b..000000000000 --- a/SU2_CFD/src/numerics/template/CConvective_Template.cpp +++ /dev/null @@ -1,216 +0,0 @@ -/*! - * \file CConvective_Template.cpp - * \brief Implementation of numerics class CConvective_Template. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../include/numerics/template/CConvective_Template.hpp" - -CConvective_Template::CConvective_Template(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - - implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - Diff_U = new su2double [nVar]; - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; - RoeVelocity = new su2double [nDim]; - delta_vel = new su2double [nDim]; - delta_wave = new su2double [nVar]; - ProjFlux_i = new su2double [nVar]; - ProjFlux_j = new su2double [nVar]; - Lambda = new su2double [nVar]; - Epsilon = new su2double [nVar]; - P_Tensor = new su2double* [nVar]; - invP_Tensor = new su2double* [nVar]; - for (iVar = 0; iVar < nVar; iVar++) { - P_Tensor[iVar] = new su2double [nVar]; - invP_Tensor[iVar] = new su2double [nVar]; - } -} - -CConvective_Template::~CConvective_Template(void) { - unsigned short iVar; - - delete [] Diff_U; - delete [] Velocity_i; - delete [] Velocity_j; - delete [] RoeVelocity; - delete [] delta_vel; - delete [] delta_wave; - delete [] ProjFlux_i; - delete [] ProjFlux_j; - delete [] Lambda; - delete [] Epsilon; - for (iVar = 0; iVar < nVar; iVar++) { - delete [] P_Tensor[iVar]; - delete [] invP_Tensor[iVar]; - } - delete [] P_Tensor; - delete [] invP_Tensor; -} - -void CConvective_Template::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - Area = 0; - for (iDim = 0; iDim < nDim; iDim++) - /*!< \brief Normal: Normal vector, it norm is the area of the face. */ - Area += Normal[iDim]*Normal[iDim]; - Area = sqrt(Area); /*! Area of the face*/ - - for (iDim = 0; iDim < nDim; iDim++) - UnitNormal[iDim] = Normal[iDim]/Area; /* ! Unit Normal*/ - - /*--- Point i, Needs to recompute SoundSpeed / Pressure / Enthalpy in case of 2nd order reconstruction ---*/ - Density_i = U_i[0]; - sq_vel = 0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = U_i[iDim+1] / Density_i; - sq_vel += Velocity_i[iDim]*Velocity_i[iDim]; - } - Energy_i = U_i[nDim+1] / Density_i; - SoundSpeed_i = sqrt(Gamma*Gamma_Minus_One*(Energy_i-0.5*sq_vel)); - Pressure_i = (SoundSpeed_i * SoundSpeed_i * Density_i) / Gamma; - Enthalpy_i = (U_i[nDim+1] + Pressure_i) / Density_i; - - /*--- Point j, Needs to recompute SoundSpeed / Pressure / Enthalpy in case of 2nd order reconstruction ---*/ - Density_j = U_j[0]; - sq_vel = 0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_j[iDim] = U_j[iDim+1] / Density_j; - sq_vel += Velocity_j[iDim]*Velocity_j[iDim]; - } - Energy_j = U_j[nDim+1] / Density_j; - SoundSpeed_j = sqrt(Gamma*Gamma_Minus_One*(Energy_j-0.5*sq_vel)); - Pressure_j = (SoundSpeed_j * SoundSpeed_j * Density_j) / Gamma; - Enthalpy_j = (U_j[nDim+1] + Pressure_j) / Density_j; - - /*--- Mean Roe variables iPoint and jPoint ---*/ - R = sqrt(Density_j/Density_i); - RoeDensity = R*Density_i; - sq_vel = 0; - for (iDim = 0; iDim < nDim; iDim++) { - RoeVelocity[iDim] = (R*Velocity_j[iDim]+Velocity_i[iDim])/(R+1); - sq_vel += RoeVelocity[iDim]*RoeVelocity[iDim]; - } - RoeEnthalpy = (R*Enthalpy_j+Enthalpy_i)/(R+1); - RoeSoundSpeed = sqrt((Gamma-1)*(RoeEnthalpy-0.5*sq_vel)); - - /*--- Compute ProjFlux_i ---*/ - GetInviscidProjFlux(&Density_i, Velocity_i, &Pressure_i, &Enthalpy_i, Normal, ProjFlux_i); - - /*--- Compute ProjFlux_j ---*/ - GetInviscidProjFlux(&Density_j, Velocity_j, &Pressure_j, &Enthalpy_j, Normal, ProjFlux_j); - - /*--- Compute P and Lambda (do it with the Normal) ---*/ - GetPMatrix(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, P_Tensor); - - ProjVelocity = 0.0; ProjVelocity_i = 0.0; ProjVelocity_j = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - ProjVelocity += RoeVelocity[iDim]*UnitNormal[iDim]; - ProjVelocity_i += Velocity_i[iDim]*UnitNormal[iDim]; - ProjVelocity_j += Velocity_j[iDim]*UnitNormal[iDim]; - } - - /*--- Flow eigenvalues and Entropy correctors ---*/ - for (iDim = 0; iDim < nDim; iDim++) { - Lambda[iDim] = ProjVelocity; - Epsilon[iDim] = 4.0*max(0.0, max(Lambda[iDim]-ProjVelocity_i, ProjVelocity_j-Lambda[iDim])); - } - Lambda[nVar-2] = ProjVelocity + RoeSoundSpeed; - Epsilon[nVar-2] = 4.0*max(0.0, max(Lambda[nVar-2]-(ProjVelocity_i+SoundSpeed_i),(ProjVelocity_j+SoundSpeed_j)-Lambda[nVar-2])); - Lambda[nVar-1] = ProjVelocity - RoeSoundSpeed; - Epsilon[nVar-1] = 4.0*max(0.0, max(Lambda[nVar-1]-(ProjVelocity_i-SoundSpeed_i),(ProjVelocity_j-SoundSpeed_j)-Lambda[nVar-1])); - - /*--- Entropy correction ---*/ - for (iVar = 0; iVar < nVar; iVar++) - if ( fabs(Lambda[iVar]) < Epsilon[iVar] ) - Lambda[iVar] = (Lambda[iVar]*Lambda[iVar] + Epsilon[iVar]*Epsilon[iVar])/(2.0*Epsilon[iVar]); - else - Lambda[iVar] = fabs(Lambda[iVar]); - - - if (!implicit) { - /*--- Compute wave amplitudes (characteristics) ---*/ - proj_delta_vel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - delta_vel[iDim] = Velocity_j[iDim] - Velocity_i[iDim]; - proj_delta_vel += delta_vel[iDim]*Normal[iDim]; - } - delta_p = Pressure_j - Pressure_i; - delta_rho = Density_j - Density_i; - proj_delta_vel = proj_delta_vel/Area; - - if (nDim == 3) { - delta_wave[0] = delta_rho - delta_p/(RoeSoundSpeed*RoeSoundSpeed); - delta_wave[1] = UnitNormal[0]*delta_vel[2]-UnitNormal[2]*delta_vel[0]; - delta_wave[2] = UnitNormal[1]*delta_vel[0]-UnitNormal[0]*delta_vel[1]; - delta_wave[3] = proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); - delta_wave[4] = -proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); - } - else { - delta_wave[0] = delta_rho - delta_p/(RoeSoundSpeed*RoeSoundSpeed); - delta_wave[1] = UnitNormal[1]*delta_vel[0]-UnitNormal[0]*delta_vel[1]; - delta_wave[2] = proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); - delta_wave[3] = -proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); - } - - /*--- Roe's Flux approximation ---*/ - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] = 0.5*(ProjFlux_i[iVar]+ProjFlux_j[iVar]); - for (jVar = 0; jVar < nVar; jVar++) - val_residual[iVar] -= 0.5*Lambda[jVar]*delta_wave[jVar]*P_Tensor[iVar][jVar]*Area; - } - } - else { - - /*--- Compute inverse P ---*/ - GetPMatrix_inv(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, invP_Tensor); - - /*--- Jacobias of the inviscid flux, scale = 0.5 because val_resconv ~ 0.5*(fc_i+fc_j)*Normal ---*/ - GetInviscidProjJac(Velocity_i, &Energy_i, Normal, 0.5, val_Jacobian_i); - GetInviscidProjJac(Velocity_j, &Energy_j, Normal, 0.5, val_Jacobian_j); - - /*--- Diference variables iPoint and jPoint ---*/ - for (iVar = 0; iVar < nVar; iVar++) - Diff_U[iVar] = U_j[iVar]-U_i[iVar]; - - /*--- Roe's Flux approximation ---*/ - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] = 0.5*(ProjFlux_i[iVar]+ProjFlux_j[iVar]); - for (jVar = 0; jVar < nVar; jVar++) { - Proj_ModJac_Tensor_ij = 0.0; - /*--- Compute |Proj_ModJac_Tensor| = P x |Lambda| x inverse P ---*/ - for (kVar = 0; kVar < nVar; kVar++) - Proj_ModJac_Tensor_ij += P_Tensor[iVar][kVar]*Lambda[kVar]*invP_Tensor[kVar][jVar]; - val_residual[iVar] -= 0.5*Proj_ModJac_Tensor_ij*Diff_U[jVar]*Area; - val_Jacobian_i[iVar][jVar] += 0.5*Proj_ModJac_Tensor_ij*Area; - val_Jacobian_j[iVar][jVar] -= 0.5*Proj_ModJac_Tensor_ij*Area; - } - } - } -} diff --git a/SU2_CFD/src/numerics/template/CSource_Template.cpp b/SU2_CFD/src/numerics/template/CSource_Template.cpp deleted file mode 100644 index d4847888c3a3..000000000000 --- a/SU2_CFD/src/numerics/template/CSource_Template.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/*! - * \file CSource_Template.cpp - * \brief Implementation of numerics class CSource_Template. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../include/numerics/template/CSource_Template.hpp" - -CSource_Template::CSource_Template(unsigned short val_nDim, unsigned short val_nVar, - CConfig *config) : CNumerics(val_nDim, val_nVar, config) {} - -CSource_Template::~CSource_Template(void) { - -} - -void CSource_Template::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config) {} diff --git a/SU2_CFD/src/numerics/template/CViscous_Template.cpp b/SU2_CFD/src/numerics/template/CViscous_Template.cpp deleted file mode 100644 index afdec7585921..000000000000 --- a/SU2_CFD/src/numerics/template/CViscous_Template.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/*! - * \file CViscous_Template.cpp - * \brief Implementation of numerics class CViscous_Template. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../include/numerics/template/CViscous_Template.hpp" - -CViscous_Template::CViscous_Template(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { } - -CViscous_Template::~CViscous_Template(void) { } - -void CViscous_Template::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { } - diff --git a/SU2_CFD/src/numerics/transition/CSourcePieceWise_TransLM.cpp b/SU2_CFD/src/numerics/transition.cpp similarity index 60% rename from SU2_CFD/src/numerics/transition/CSourcePieceWise_TransLM.cpp rename to SU2_CFD/src/numerics/transition.cpp index 45652e2c7fdf..4accc7b2b94d 100644 --- a/SU2_CFD/src/numerics/transition/CSourcePieceWise_TransLM.cpp +++ b/SU2_CFD/src/numerics/transition.cpp @@ -1,6 +1,6 @@ /*! - * \file CSourcePieceWise_TransLM.cpp - * \brief Implementation of numerics class CSourcePieceWise_TransLM. + * \file transition.cpp + * \brief Implementation of numerics classes for transition problems. * \author F. Palacios, T. Economon * \version 7.0.0 "Blackbird" * @@ -25,7 +25,288 @@ * License along with SU2. If not, see . */ -#include "../../../include/numerics/transition/CSourcePieceWise_TransLM.hpp" +#include "../../include/numerics/transition.hpp" + +CUpwLin_TransLM::CUpwLin_TransLM(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + implicit = (config->GetKind_TimeIntScheme_Turb() == EULER_IMPLICIT); + incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + + Velocity_i = new su2double [nDim]; + Velocity_j = new su2double [nDim]; + +} + +CUpwLin_TransLM::~CUpwLin_TransLM(void) { + delete [] Velocity_i; + delete [] Velocity_j; +} + +void CUpwLin_TransLM::ComputeResidual (su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { + + + Density_i = U_i[0]; + Density_j = U_j[0]; + + q_ij = 0; + for (iDim = 0; iDim < nDim; iDim++) { + Velocity_i[iDim] = U_i[iDim+1]/Density_i; + Velocity_j[iDim] = U_j[iDim+1]/Density_j; + q_ij += 0.5*(Velocity_i[iDim]+Velocity_j[iDim])*Normal[iDim]; + } + + a0 = 0.5*(q_ij+fabs(q_ij)); + a1 = 0.5*(q_ij-fabs(q_ij)); + val_residual[0] = a0*TransVar_i[0]+a1*TransVar_j[0]; + val_residual[1] = a0*TransVar_i[1]+a1*TransVar_j[1]; + // cout << "Velicity x: " << Velocity_i[0] << ", " << Velocity_j[0] << endl; + // cout << "Velicity y: " << Velocity_i[1] << ", " << Velocity_j[1] << endl; + // cout << "val_resid: " << val_residual[0] << ", " << val_residual[1] << endl; + + + if (implicit) { + val_Jacobian_i[0][0] = a0; + val_Jacobian_i[1][1] = a0; + } +} + +CUpwSca_TransLM::CUpwSca_TransLM(unsigned short val_nDim, unsigned short val_nVar, + CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + implicit = (config->GetKind_TimeIntScheme_Turb() == EULER_IMPLICIT); + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + + Velocity_i = new su2double [nDim]; + Velocity_j = new su2double [nDim]; +} + +CUpwSca_TransLM::~CUpwSca_TransLM(void) { + delete [] Velocity_i; + delete [] Velocity_j; +} + +void CUpwSca_TransLM::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { + + q_ij = 0; + for (iDim = 0; iDim < nDim; iDim++) { + q_ij += 0.5*(U_i[iDim]+U_j[iDim])*Normal[iDim]; + } + + a0 = 0.5*(q_ij+fabs(q_ij)); + a1 = 0.5*(q_ij-fabs(q_ij)); + val_residual[0] = a0*TransVar_i[0]+a1*TransVar_j[0]; + val_residual[1] = a0*TransVar_i[1]+a1*TransVar_j[1]; + + if (implicit) { + val_Jacobian_i[0][0] = a0; + val_Jacobian_j[0][0] = a1; + val_Jacobian_i[1][1] = a0; + val_Jacobian_j[1][1] = a1; + + /*--- Zero out off-diagonal terms just in case ---*/ + val_Jacobian_i[0][1] = 0; + val_Jacobian_j[0][1] = 0; + val_Jacobian_i[1][0] = 0; + val_Jacobian_j[1][0] = 0; + } + +} + +CAvgGrad_TransLM::CAvgGrad_TransLM(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + unsigned short iVar; + + implicit = (config->GetKind_TimeIntScheme_Turb() == EULER_IMPLICIT); + incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + + sigma = 2./3.; + + Edge_Vector = new su2double [nDim]; + Proj_Mean_GradTransVar_Kappa = new su2double [nVar]; + Proj_Mean_GradTransVar_Edge = new su2double [nVar]; + Mean_GradTransVar = new su2double* [nVar]; + for (iVar = 0; iVar < nVar; iVar++) + Mean_GradTransVar[iVar] = new su2double [nDim]; +} + +CAvgGrad_TransLM::~CAvgGrad_TransLM(void) { + + unsigned short iVar; + + delete [] Edge_Vector; + delete [] Proj_Mean_GradTransVar_Kappa; + delete [] Proj_Mean_GradTransVar_Edge; + for (iVar = 0; iVar < nVar; iVar++) + delete [] Mean_GradTransVar[iVar]; + delete [] Mean_GradTransVar; +} + +void CAvgGrad_TransLM::ComputeResidual(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config) { + /*--- This section is commented out on 04/11/2016 + after review of the static scan ---*/ + // su2double *Density_Grad_i = new su2double[nDim]; + // su2double *Density_Grad_j = new su2double[nDim]; + // su2double *Conservative_Grad_i = new su2double[nDim]; + // su2double *Conservative_Grad_j = new su2double[nDim]; + // su2double *Primitive_Grad_i = new su2double[nDim]; + // su2double *Primitive_Grad_j = new su2double[nDim]; + // + // /*--- Intermediate values for combining viscosities ---*/ + // su2double Inter_Viscosity_i, Inter_Viscosity_j, REth_Viscosity_i, REth_Viscosity_j, Inter_Viscosity_Mean, REth_Viscosity_Mean; + // + // /*--- Model constants---*/ + // su2double sigmaf = 1.0; + // su2double sigma_thetat = 2.0; + // + // /*--- Get density ---*/ + // Density_i = U_i[0]; + // Density_j = U_j[0]; + // + // /*--- Construct combinations of viscosity ---*/ + // Inter_Viscosity_i = (Laminar_Viscosity_i+Eddy_Viscosity_i/sigmaf); + // Inter_Viscosity_j = (Laminar_Viscosity_j+Eddy_Viscosity_j/sigmaf); + // Inter_Viscosity_Mean = 0.5*(Inter_Viscosity_i+Inter_Viscosity_j); + // REth_Viscosity_i = sigma_thetat*(Laminar_Viscosity_i+Eddy_Viscosity_i); + // REth_Viscosity_j = sigma_thetat*(Laminar_Viscosity_j+Eddy_Viscosity_j); + // REth_Viscosity_Mean = 0.5*(REth_Viscosity_i+REth_Viscosity_j); + // + ///*--- Compute vector going from iPoint to jPoint ---*/ + //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]; + //} + //proj_vector_ij = proj_vector_ij/dist_ij_2; // to normalize vectors + // + ///*--- Mean gradient approximation ---*/ + //for (iVar = 0; iVar < nVar; iVar++) { + // Proj_Mean_GradTransVar_Kappa[iVar] = 0.0; + // // Proj_Mean_GradTransVar_Edge[iVar] = 0.0; + // for (iDim = 0; iDim < nDim; iDim++) { + // + // /* -- Compute primitive grad using chain rule -- */ + // Density_Grad_i[iDim] = ConsVar_Grad_i[0][iDim]; + // Density_Grad_j[iDim] = ConsVar_Grad_j[0][iDim]; + // Conservative_Grad_i[iDim] = TransVar_Grad_i[iVar][iDim]; + // Conservative_Grad_j[iDim] = TransVar_Grad_j[iVar][iDim]; + // Primitive_Grad_i[iDim] = 1./Density_i*(Conservative_Grad_i[iDim]-TransVar_i[iVar]*Density_Grad_i[iDim]); + // Primitive_Grad_j[iDim] = 1./Density_j*(Conservative_Grad_j[iDim]-TransVar_j[iVar]*Density_Grad_j[iDim]); + // + // /*--- Compute the average primitive gradient and project it in the normal direction ---*/ + // Mean_GradTransVar[iVar][iDim] = 0.5*(Primitive_Grad_i[iDim] + Primitive_Grad_j[iDim]); + // Proj_Mean_GradTransVar_Kappa[iVar] += Mean_GradTransVar[iVar][iDim]*Normal[iDim]; + // } + //} + // + //val_residual[0] = Inter_Viscosity_Mean*Proj_Mean_GradTransVar_Kappa[0]; + //val_residual[1] = REth_Viscosity_Mean*Proj_Mean_GradTransVar_Kappa[1]; + // + ///*--- For Jacobians -> Use of TSL approx. to compute derivatives of the gradients ---*/ + //if (implicit) { + // Jacobian_i[0][0] = (0.5*Proj_Mean_GradTransVar_Kappa[0]-Inter_Viscosity_Mean*proj_vector_ij); + // Jacobian_j[0][0] = (0.5*Proj_Mean_GradTransVar_Kappa[0]+Inter_Viscosity_Mean*proj_vector_ij); + // Jacobian_i[1][1] = (0.5*Proj_Mean_GradTransVar_Kappa[1]-REth_Viscosity_Mean*proj_vector_ij); + // Jacobian_j[1][1] = (0.5*Proj_Mean_GradTransVar_Kappa[1]+REth_Viscosity_Mean*proj_vector_ij); + //} + // + // /*--- Free locally allocated memory. For efficiency, these arrays + // should really be allocated/deallocated in the constructor/destructor. ---*/ + // delete [] Density_Grad_i; + // delete [] Density_Grad_j; + // delete [] Conservative_Grad_i; + // delete [] Conservative_Grad_j; + // delete [] Primitive_Grad_i; + // delete [] Primitive_Grad_j; + // +} + +CAvgGradCorrected_TransLM::CAvgGradCorrected_TransLM(unsigned short val_nDim, unsigned short val_nVar, + CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + unsigned short iVar; + + implicit = (config->GetKind_TimeIntScheme_Turb() == EULER_IMPLICIT); + incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + + sigma = 2./3.; + + Edge_Vector = new su2double [nDim]; + Proj_Mean_GradTurbVar_Kappa = new su2double [nVar]; + Proj_Mean_GradTurbVar_Edge = new su2double [nVar]; + Proj_Mean_GradTurbVar_Corrected = new su2double [nVar]; + Mean_GradTurbVar = new su2double* [nVar]; + for (iVar = 0; iVar < nVar; iVar++) + Mean_GradTurbVar[iVar] = new su2double [nDim]; +} + +CAvgGradCorrected_TransLM::~CAvgGradCorrected_TransLM(void) { + + unsigned short iVar; + + delete [] Edge_Vector; + delete [] Proj_Mean_GradTurbVar_Kappa; + delete [] Proj_Mean_GradTurbVar_Edge; + delete [] Proj_Mean_GradTurbVar_Corrected; + for (iVar = 0; iVar < nVar; iVar++) + delete [] Mean_GradTurbVar[iVar]; + delete [] Mean_GradTurbVar; +} + +void CAvgGradCorrected_TransLM::ComputeResidual(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config) { + + // switch (config->GetKind_Turb_Model()) { + // case SA : + // /*--- Compute mean effective viscosity ---*/ + // nu_i = Laminar_Viscosity_i/U_i[0]; + // nu_j = Laminar_Viscosity_j/U_j[0]; + // nu_e = 0.5*(nu_i+nu_j+TurbVar_i[0]+TurbVar_j[0]); + // + // /*--- Compute vector going from iPoint to jPoint ---*/ + // 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]; + // } + // proj_vector_ij = proj_vector_ij/dist_ij_2; + // + // /*--- Mean gradient approximation. Projection of the mean gradient + // in the direction of the edge ---*/ + // for (iVar = 0; iVar < nVar; iVar++) { + // Proj_Mean_GradTurbVar_Kappa[iVar] = 0.0; + // Proj_Mean_GradTurbVar_Edge[iVar] = 0.0; + // for (iDim = 0; iDim < nDim; iDim++) { + // Mean_GradTurbVar[iVar][iDim] = 0.5*(TurbVar_Grad_i[iVar][iDim] + TurbVar_Grad_j[iVar][iDim]); + // Proj_Mean_GradTurbVar_Kappa[iVar] += Mean_GradTurbVar[iVar][iDim]*Normal[iDim]; + // Proj_Mean_GradTurbVar_Edge[iVar] += Mean_GradTurbVar[iVar][iDim]*Edge_Vector[iDim]; + // } + // Proj_Mean_GradTurbVar_Corrected[iVar] = Proj_Mean_GradTurbVar_Kappa[iVar]; + // Proj_Mean_GradTurbVar_Corrected[iVar] -= Proj_Mean_GradTurbVar_Edge[iVar]*proj_vector_ij - + // (TurbVar_j[iVar]-TurbVar_i[iVar])*proj_vector_ij; + // } + // + // val_residual[0] = nu_e*Proj_Mean_GradTurbVar_Corrected[0]/sigma; + // + // /*--- For Jacobians -> Use of TSL approx. to compute derivatives of the gradients ---*/ + // if (implicit) { + // Jacobian_i[0][0] = (0.5*Proj_Mean_GradTurbVar_Corrected[0]-nu_e*proj_vector_ij)/sigma; + // Jacobian_j[0][0] = (0.5*Proj_Mean_GradTurbVar_Corrected[0]+nu_e*proj_vector_ij)/sigma; + // } + // break; + // + // } +} CSourcePieceWise_TransLM::CSourcePieceWise_TransLM(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { diff --git a/SU2_CFD/src/numerics/transition/CAvgGradCorrected_TransLM.cpp b/SU2_CFD/src/numerics/transition/CAvgGradCorrected_TransLM.cpp deleted file mode 100644 index 195e9d407ee2..000000000000 --- a/SU2_CFD/src/numerics/transition/CAvgGradCorrected_TransLM.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/*! - * \file CAvgGradCorrected_TransLM.cpp - * \brief Implementation of numerics class CAvgGradCorrected_TransLM. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../include/numerics/transition/CAvgGradCorrected_TransLM.hpp" - -CAvgGradCorrected_TransLM::CAvgGradCorrected_TransLM(unsigned short val_nDim, unsigned short val_nVar, - CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - unsigned short iVar; - - implicit = (config->GetKind_TimeIntScheme_Turb() == EULER_IMPLICIT); - incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - sigma = 2./3.; - - Edge_Vector = new su2double [nDim]; - Proj_Mean_GradTurbVar_Kappa = new su2double [nVar]; - Proj_Mean_GradTurbVar_Edge = new su2double [nVar]; - Proj_Mean_GradTurbVar_Corrected = new su2double [nVar]; - Mean_GradTurbVar = new su2double* [nVar]; - for (iVar = 0; iVar < nVar; iVar++) - Mean_GradTurbVar[iVar] = new su2double [nDim]; -} - -CAvgGradCorrected_TransLM::~CAvgGradCorrected_TransLM(void) { - - unsigned short iVar; - - delete [] Edge_Vector; - delete [] Proj_Mean_GradTurbVar_Kappa; - delete [] Proj_Mean_GradTurbVar_Edge; - delete [] Proj_Mean_GradTurbVar_Corrected; - for (iVar = 0; iVar < nVar; iVar++) - delete [] Mean_GradTurbVar[iVar]; - delete [] Mean_GradTurbVar; -} - -void CAvgGradCorrected_TransLM::ComputeResidual(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config) { - - // switch (config->GetKind_Turb_Model()) { - // case SA : - // /*--- Compute mean effective viscosity ---*/ - // nu_i = Laminar_Viscosity_i/U_i[0]; - // nu_j = Laminar_Viscosity_j/U_j[0]; - // nu_e = 0.5*(nu_i+nu_j+TurbVar_i[0]+TurbVar_j[0]); - // - // /*--- Compute vector going from iPoint to jPoint ---*/ - // 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]; - // } - // proj_vector_ij = proj_vector_ij/dist_ij_2; - // - // /*--- Mean gradient approximation. Projection of the mean gradient - // in the direction of the edge ---*/ - // for (iVar = 0; iVar < nVar; iVar++) { - // Proj_Mean_GradTurbVar_Kappa[iVar] = 0.0; - // Proj_Mean_GradTurbVar_Edge[iVar] = 0.0; - // for (iDim = 0; iDim < nDim; iDim++) { - // Mean_GradTurbVar[iVar][iDim] = 0.5*(TurbVar_Grad_i[iVar][iDim] + TurbVar_Grad_j[iVar][iDim]); - // Proj_Mean_GradTurbVar_Kappa[iVar] += Mean_GradTurbVar[iVar][iDim]*Normal[iDim]; - // Proj_Mean_GradTurbVar_Edge[iVar] += Mean_GradTurbVar[iVar][iDim]*Edge_Vector[iDim]; - // } - // Proj_Mean_GradTurbVar_Corrected[iVar] = Proj_Mean_GradTurbVar_Kappa[iVar]; - // Proj_Mean_GradTurbVar_Corrected[iVar] -= Proj_Mean_GradTurbVar_Edge[iVar]*proj_vector_ij - - // (TurbVar_j[iVar]-TurbVar_i[iVar])*proj_vector_ij; - // } - // - // val_residual[0] = nu_e*Proj_Mean_GradTurbVar_Corrected[0]/sigma; - // - // /*--- For Jacobians -> Use of TSL approx. to compute derivatives of the gradients ---*/ - // if (implicit) { - // Jacobian_i[0][0] = (0.5*Proj_Mean_GradTurbVar_Corrected[0]-nu_e*proj_vector_ij)/sigma; - // Jacobian_j[0][0] = (0.5*Proj_Mean_GradTurbVar_Corrected[0]+nu_e*proj_vector_ij)/sigma; - // } - // break; - // - // } -} diff --git a/SU2_CFD/src/numerics/transition/CAvgGrad_TransLM.cpp b/SU2_CFD/src/numerics/transition/CAvgGrad_TransLM.cpp deleted file mode 100644 index 40c840ffe05e..000000000000 --- a/SU2_CFD/src/numerics/transition/CAvgGrad_TransLM.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/*! - * \file CAvgGrad_TransLM.cpp - * \brief Implementation of numerics class CAvgGrad_TransLM. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../include/numerics/transition/CAvgGrad_TransLM.hpp" - -CAvgGrad_TransLM::CAvgGrad_TransLM(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - unsigned short iVar; - - implicit = (config->GetKind_TimeIntScheme_Turb() == EULER_IMPLICIT); - incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - sigma = 2./3.; - - Edge_Vector = new su2double [nDim]; - Proj_Mean_GradTransVar_Kappa = new su2double [nVar]; - Proj_Mean_GradTransVar_Edge = new su2double [nVar]; - Mean_GradTransVar = new su2double* [nVar]; - for (iVar = 0; iVar < nVar; iVar++) - Mean_GradTransVar[iVar] = new su2double [nDim]; -} - -CAvgGrad_TransLM::~CAvgGrad_TransLM(void) { - - unsigned short iVar; - - delete [] Edge_Vector; - delete [] Proj_Mean_GradTransVar_Kappa; - delete [] Proj_Mean_GradTransVar_Edge; - for (iVar = 0; iVar < nVar; iVar++) - delete [] Mean_GradTransVar[iVar]; - delete [] Mean_GradTransVar; -} - -void CAvgGrad_TransLM::ComputeResidual(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config) { - /*--- This section is commented out on 04/11/2016 - after review of the static scan ---*/ - // su2double *Density_Grad_i = new su2double[nDim]; - // su2double *Density_Grad_j = new su2double[nDim]; - // su2double *Conservative_Grad_i = new su2double[nDim]; - // su2double *Conservative_Grad_j = new su2double[nDim]; - // su2double *Primitive_Grad_i = new su2double[nDim]; - // su2double *Primitive_Grad_j = new su2double[nDim]; - // - // /*--- Intermediate values for combining viscosities ---*/ - // su2double Inter_Viscosity_i, Inter_Viscosity_j, REth_Viscosity_i, REth_Viscosity_j, Inter_Viscosity_Mean, REth_Viscosity_Mean; - // - // /*--- Model constants---*/ - // su2double sigmaf = 1.0; - // su2double sigma_thetat = 2.0; - // - // /*--- Get density ---*/ - // Density_i = U_i[0]; - // Density_j = U_j[0]; - // - // /*--- Construct combinations of viscosity ---*/ - // Inter_Viscosity_i = (Laminar_Viscosity_i+Eddy_Viscosity_i/sigmaf); - // Inter_Viscosity_j = (Laminar_Viscosity_j+Eddy_Viscosity_j/sigmaf); - // Inter_Viscosity_Mean = 0.5*(Inter_Viscosity_i+Inter_Viscosity_j); - // REth_Viscosity_i = sigma_thetat*(Laminar_Viscosity_i+Eddy_Viscosity_i); - // REth_Viscosity_j = sigma_thetat*(Laminar_Viscosity_j+Eddy_Viscosity_j); - // REth_Viscosity_Mean = 0.5*(REth_Viscosity_i+REth_Viscosity_j); - // - ///*--- Compute vector going from iPoint to jPoint ---*/ - //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]; - //} - //proj_vector_ij = proj_vector_ij/dist_ij_2; // to normalize vectors - // - ///*--- Mean gradient approximation ---*/ - //for (iVar = 0; iVar < nVar; iVar++) { - // Proj_Mean_GradTransVar_Kappa[iVar] = 0.0; - // // Proj_Mean_GradTransVar_Edge[iVar] = 0.0; - // for (iDim = 0; iDim < nDim; iDim++) { - // - // /* -- Compute primitive grad using chain rule -- */ - // Density_Grad_i[iDim] = ConsVar_Grad_i[0][iDim]; - // Density_Grad_j[iDim] = ConsVar_Grad_j[0][iDim]; - // Conservative_Grad_i[iDim] = TransVar_Grad_i[iVar][iDim]; - // Conservative_Grad_j[iDim] = TransVar_Grad_j[iVar][iDim]; - // Primitive_Grad_i[iDim] = 1./Density_i*(Conservative_Grad_i[iDim]-TransVar_i[iVar]*Density_Grad_i[iDim]); - // Primitive_Grad_j[iDim] = 1./Density_j*(Conservative_Grad_j[iDim]-TransVar_j[iVar]*Density_Grad_j[iDim]); - // - // /*--- Compute the average primitive gradient and project it in the normal direction ---*/ - // Mean_GradTransVar[iVar][iDim] = 0.5*(Primitive_Grad_i[iDim] + Primitive_Grad_j[iDim]); - // Proj_Mean_GradTransVar_Kappa[iVar] += Mean_GradTransVar[iVar][iDim]*Normal[iDim]; - // } - //} - // - //val_residual[0] = Inter_Viscosity_Mean*Proj_Mean_GradTransVar_Kappa[0]; - //val_residual[1] = REth_Viscosity_Mean*Proj_Mean_GradTransVar_Kappa[1]; - // - ///*--- For Jacobians -> Use of TSL approx. to compute derivatives of the gradients ---*/ - //if (implicit) { - // Jacobian_i[0][0] = (0.5*Proj_Mean_GradTransVar_Kappa[0]-Inter_Viscosity_Mean*proj_vector_ij); - // Jacobian_j[0][0] = (0.5*Proj_Mean_GradTransVar_Kappa[0]+Inter_Viscosity_Mean*proj_vector_ij); - // Jacobian_i[1][1] = (0.5*Proj_Mean_GradTransVar_Kappa[1]-REth_Viscosity_Mean*proj_vector_ij); - // Jacobian_j[1][1] = (0.5*Proj_Mean_GradTransVar_Kappa[1]+REth_Viscosity_Mean*proj_vector_ij); - //} - // - // /*--- Free locally allocated memory. For efficiency, these arrays - // should really be allocated/deallocated in the constructor/destructor. ---*/ - // delete [] Density_Grad_i; - // delete [] Density_Grad_j; - // delete [] Conservative_Grad_i; - // delete [] Conservative_Grad_j; - // delete [] Primitive_Grad_i; - // delete [] Primitive_Grad_j; - // -} diff --git a/SU2_CFD/src/numerics/transition/CUpwLin_TransLM.cpp b/SU2_CFD/src/numerics/transition/CUpwLin_TransLM.cpp deleted file mode 100644 index e2320ee3ecc3..000000000000 --- a/SU2_CFD/src/numerics/transition/CUpwLin_TransLM.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/*! - * \file CUpwLin_TransLM.cpp - * \brief Implementation of numerics class CUpwLin_TransLM. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../include/numerics/transition/CUpwLin_TransLM.hpp" - -CUpwLin_TransLM::CUpwLin_TransLM(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_Turb() == EULER_IMPLICIT); - incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; - -} - -CUpwLin_TransLM::~CUpwLin_TransLM(void) { - delete [] Velocity_i; - delete [] Velocity_j; -} - -void CUpwLin_TransLM::ComputeResidual (su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - - Density_i = U_i[0]; - Density_j = U_j[0]; - - q_ij = 0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = U_i[iDim+1]/Density_i; - Velocity_j[iDim] = U_j[iDim+1]/Density_j; - q_ij += 0.5*(Velocity_i[iDim]+Velocity_j[iDim])*Normal[iDim]; - } - - a0 = 0.5*(q_ij+fabs(q_ij)); - a1 = 0.5*(q_ij-fabs(q_ij)); - val_residual[0] = a0*TransVar_i[0]+a1*TransVar_j[0]; - val_residual[1] = a0*TransVar_i[1]+a1*TransVar_j[1]; - // cout << "Velicity x: " << Velocity_i[0] << ", " << Velocity_j[0] << endl; - // cout << "Velicity y: " << Velocity_i[1] << ", " << Velocity_j[1] << endl; - // cout << "val_resid: " << val_residual[0] << ", " << val_residual[1] << endl; - - - if (implicit) { - val_Jacobian_i[0][0] = a0; - val_Jacobian_i[1][1] = a0; - } -} diff --git a/SU2_CFD/src/numerics/transition/CUpwSca_TransLM.cpp b/SU2_CFD/src/numerics/transition/CUpwSca_TransLM.cpp deleted file mode 100644 index d258a17cffa4..000000000000 --- a/SU2_CFD/src/numerics/transition/CUpwSca_TransLM.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/*! - * \file CUpwSca_TransLM.cpp - * \brief Implementation of numerics class CUpwSca_TransLM. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../include/numerics/transition/CUpwSca_TransLM.hpp" - -CUpwSca_TransLM::CUpwSca_TransLM(unsigned short val_nDim, unsigned short val_nVar, - CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_Turb() == EULER_IMPLICIT); - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; -} - -CUpwSca_TransLM::~CUpwSca_TransLM(void) { - delete [] Velocity_i; - delete [] Velocity_j; -} - -void CUpwSca_TransLM::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - q_ij = 0; - for (iDim = 0; iDim < nDim; iDim++) { - q_ij += 0.5*(U_i[iDim]+U_j[iDim])*Normal[iDim]; - } - - a0 = 0.5*(q_ij+fabs(q_ij)); - a1 = 0.5*(q_ij-fabs(q_ij)); - val_residual[0] = a0*TransVar_i[0]+a1*TransVar_j[0]; - val_residual[1] = a0*TransVar_i[1]+a1*TransVar_j[1]; - - if (implicit) { - val_Jacobian_i[0][0] = a0; - val_Jacobian_j[0][0] = a1; - val_Jacobian_i[1][1] = a0; - val_Jacobian_j[1][1] = a1; - - /*--- Zero out off-diagonal terms just in case ---*/ - val_Jacobian_i[0][1] = 0; - val_Jacobian_j[0][1] = 0; - val_Jacobian_i[1][0] = 0; - val_Jacobian_j[1][0] = 0; - } - -} diff --git a/SU2_CFD/src/numerics/turbulent/CAvgGrad_Scalar.cpp b/SU2_CFD/src/numerics/turbulent/CAvgGrad_Scalar.cpp deleted file mode 100644 index d2dec6f5d65d..000000000000 --- a/SU2_CFD/src/numerics/turbulent/CAvgGrad_Scalar.cpp +++ /dev/null @@ -1,126 +0,0 @@ -/*! - * \file CAvgGrad_Scalar.cpp - * \brief Implementation of numerics class CAvgGrad_Scalar. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../include/numerics/turbulent/CAvgGrad_Scalar.hpp" - -CAvgGrad_Scalar::CAvgGrad_Scalar(unsigned short val_nDim, - unsigned short val_nVar, - bool correct_grad, - CConfig *config) - : CNumerics(val_nDim, val_nVar, config), correct_gradient(correct_grad) { - - implicit = (config->GetKind_TimeIntScheme_Turb() == EULER_IMPLICIT); - incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); - - Edge_Vector = new su2double [nDim]; - Proj_Mean_GradTurbVar_Normal = new su2double [nVar]; - Proj_Mean_GradTurbVar_Edge = new su2double [nVar]; - Proj_Mean_GradTurbVar = new su2double [nVar]; - Mean_GradTurbVar = new su2double* [nVar]; - for (iVar = 0; iVar < nVar; iVar++) - Mean_GradTurbVar[iVar] = new su2double [nDim]; - -} - -CAvgGrad_Scalar::~CAvgGrad_Scalar(void) { - - delete [] Edge_Vector; - delete [] Proj_Mean_GradTurbVar_Normal; - delete [] Proj_Mean_GradTurbVar_Edge; - delete [] Proj_Mean_GradTurbVar; - for (iVar = 0; iVar < nVar; iVar++) - delete [] Mean_GradTurbVar[iVar]; - delete [] Mean_GradTurbVar; - -} - -void CAvgGrad_Scalar::ComputeResidual(su2double *val_residual, - su2double **Jacobian_i, - su2double **Jacobian_j, - CConfig *config) { - - AD::StartPreacc(); - AD::SetPreaccIn(Coord_i, nDim); AD::SetPreaccIn(Coord_j, nDim); - AD::SetPreaccIn(Normal, nDim); - AD::SetPreaccIn(TurbVar_Grad_i, nVar, nDim); - AD::SetPreaccIn(TurbVar_Grad_j, nVar, nDim); - if (correct_gradient) { - AD::SetPreaccIn(TurbVar_i, nVar); AD::SetPreaccIn(TurbVar_j ,nVar); - } - ExtraADPreaccIn(); - - if (incompressible) { - AD::SetPreaccIn(V_i, nDim+6); AD::SetPreaccIn(V_j, nDim+6); - - Density_i = V_i[nDim+2]; Density_j = V_j[nDim+2]; - Laminar_Viscosity_i = V_i[nDim+4]; Laminar_Viscosity_j = V_j[nDim+4]; - Eddy_Viscosity_i = V_i[nDim+5]; Eddy_Viscosity_j = V_j[nDim+5]; - } - else { - AD::SetPreaccIn(V_i, nDim+7); AD::SetPreaccIn(V_j, nDim+7); - - Density_i = V_i[nDim+2]; Density_j = V_j[nDim+2]; - Laminar_Viscosity_i = V_i[nDim+5]; Laminar_Viscosity_j = V_j[nDim+5]; - Eddy_Viscosity_i = V_i[nDim+6]; Eddy_Viscosity_j = V_j[nDim+6]; - } - - /*--- Compute vector going from iPoint to jPoint ---*/ - - 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; - - /*--- Mean gradient approximation ---*/ - for (iVar = 0; iVar < nVar; iVar++) { - Proj_Mean_GradTurbVar_Normal[iVar] = 0.0; - Proj_Mean_GradTurbVar_Edge[iVar] = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Mean_GradTurbVar[iVar][iDim] = 0.5*(TurbVar_Grad_i[iVar][iDim] + - TurbVar_Grad_j[iVar][iDim]); - Proj_Mean_GradTurbVar_Normal[iVar] += Mean_GradTurbVar[iVar][iDim] * - Normal[iDim]; - if (correct_gradient) - Proj_Mean_GradTurbVar_Edge[iVar] += Mean_GradTurbVar[iVar][iDim]*Edge_Vector[iDim]; - } - Proj_Mean_GradTurbVar[iVar] = Proj_Mean_GradTurbVar_Normal[iVar]; - if (correct_gradient) { - Proj_Mean_GradTurbVar[iVar] -= Proj_Mean_GradTurbVar_Edge[iVar]*proj_vector_ij - - (TurbVar_j[iVar]-TurbVar_i[iVar])*proj_vector_ij; - } - } - - FinishResidualCalc(val_residual, Jacobian_i, Jacobian_j, config); - - AD::SetPreaccOut(val_residual, nVar); - AD::EndPreacc(); - -} diff --git a/SU2_CFD/src/numerics/turbulent/CAvgGrad_TurbSA.cpp b/SU2_CFD/src/numerics/turbulent/CAvgGrad_TurbSA.cpp deleted file mode 100644 index c2867468a915..000000000000 --- a/SU2_CFD/src/numerics/turbulent/CAvgGrad_TurbSA.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/*! - * \file CAvgGrad_TurbSA.cpp - * \brief Implementation of numerics class CAvgGrad_TurbSA. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../include/numerics/turbulent/CAvgGrad_TurbSA.hpp" - -CAvgGrad_TurbSA::CAvgGrad_TurbSA(unsigned short val_nDim, - unsigned short val_nVar, bool correct_grad, - CConfig *config) - : CAvgGrad_Scalar(val_nDim, val_nVar, correct_grad, config), sigma(2./3.) { -} - -CAvgGrad_TurbSA::~CAvgGrad_TurbSA(void) { -} - -void CAvgGrad_TurbSA::ExtraADPreaccIn() { -} - -void CAvgGrad_TurbSA::FinishResidualCalc(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config) { - - /*--- Compute mean effective viscosity ---*/ - - nu_i = Laminar_Viscosity_i/Density_i; - nu_j = Laminar_Viscosity_j/Density_j; - nu_e = 0.5*(nu_i+nu_j+TurbVar_i[0]+TurbVar_j[0]); - - val_residual[0] = nu_e*Proj_Mean_GradTurbVar[0]/sigma; - - /*--- For Jacobians -> Use of TSL approx. to compute derivatives of the gradients ---*/ - - if (implicit) { - Jacobian_i[0][0] = (0.5*Proj_Mean_GradTurbVar[0]-nu_e*proj_vector_ij)/sigma; - Jacobian_j[0][0] = (0.5*Proj_Mean_GradTurbVar[0]+nu_e*proj_vector_ij)/sigma; - } - -} diff --git a/SU2_CFD/src/numerics/turbulent/CAvgGrad_TurbSA_Neg.cpp b/SU2_CFD/src/numerics/turbulent/CAvgGrad_TurbSA_Neg.cpp deleted file mode 100644 index 708bed5d2afa..000000000000 --- a/SU2_CFD/src/numerics/turbulent/CAvgGrad_TurbSA_Neg.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/*! - * \file CAvgGrad_TurbSA_Neg.cpp - * \brief Implementation of numerics class CAvgGrad_TurbSA_Neg. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../include/numerics/turbulent/CAvgGrad_TurbSA_Neg.hpp" - -CAvgGrad_TurbSA_Neg::CAvgGrad_TurbSA_Neg(unsigned short val_nDim, - unsigned short val_nVar, - bool correct_grad, - CConfig *config) - : CAvgGrad_Scalar(val_nDim, val_nVar, correct_grad, config), - sigma(2./3.), cn1(16.0), fn(0.0) { -} - -CAvgGrad_TurbSA_Neg::~CAvgGrad_TurbSA_Neg(void) { -} - -void CAvgGrad_TurbSA_Neg::ExtraADPreaccIn() { -} - -void CAvgGrad_TurbSA_Neg::FinishResidualCalc(su2double *val_residual, - su2double **Jacobian_i, - su2double **Jacobian_j, - CConfig *config) { - - /*--- Compute mean effective viscosity ---*/ - - nu_i = Laminar_Viscosity_i/Density_i; - nu_j = Laminar_Viscosity_j/Density_j; - - nu_ij = 0.5*(nu_i+nu_j); - nu_tilde_ij = 0.5*(TurbVar_i[0]+TurbVar_j[0]); - - Xi = nu_tilde_ij/nu_ij; - - if (nu_tilde_ij > 0.0) { - nu_e = nu_ij + nu_tilde_ij; - } - else { - fn = (cn1 + Xi*Xi*Xi)/(cn1 - Xi*Xi*Xi); - nu_e = nu_ij + fn*nu_tilde_ij; - } - - val_residual[0] = nu_e*Proj_Mean_GradTurbVar_Normal[0]/sigma; - - /*--- For Jacobians -> Use of TSL approx. to compute derivatives of the gradients ---*/ - - if (implicit) { - Jacobian_i[0][0] = (0.5*Proj_Mean_GradTurbVar[0]-nu_e*proj_vector_ij)/sigma; - Jacobian_j[0][0] = (0.5*Proj_Mean_GradTurbVar[0]+nu_e*proj_vector_ij)/sigma; - } - -} diff --git a/SU2_CFD/src/numerics/turbulent/CAvgGrad_TurbSST.cpp b/SU2_CFD/src/numerics/turbulent/CAvgGrad_TurbSST.cpp deleted file mode 100644 index b29974db2930..000000000000 --- a/SU2_CFD/src/numerics/turbulent/CAvgGrad_TurbSST.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/*! - * \file CAvgGrad_TurbSST.cpp - * \brief Implementation of numerics class CAvgGrad_TurbSST. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../include/numerics/turbulent/CAvgGrad_TurbSST.hpp" - -CAvgGrad_TurbSST::CAvgGrad_TurbSST(unsigned short val_nDim, - unsigned short val_nVar, - const su2double *constants, - bool correct_grad, - CConfig *config) - : CAvgGrad_Scalar(val_nDim, val_nVar, correct_grad, config) { - - sigma_k1 = constants[0]; - sigma_om1 = constants[2]; - sigma_k2 = constants[1]; - sigma_om2 = constants[3]; - - F1_i = 0.0; F1_j = 0.0; - diff_kine = 0.0; - diff_omega = 0.0; - -} - -CAvgGrad_TurbSST::~CAvgGrad_TurbSST(void) { -} - -void CAvgGrad_TurbSST::ExtraADPreaccIn() { - AD::SetPreaccIn(F1_i); AD::SetPreaccIn(F1_j); -} - -void CAvgGrad_TurbSST::FinishResidualCalc(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config) { - - su2double sigma_kine_i, sigma_kine_j, sigma_omega_i, sigma_omega_j; - su2double diff_i_kine, diff_i_omega, diff_j_kine, diff_j_omega; - - /*--- Compute the blended constant for the viscous terms ---*/ - sigma_kine_i = F1_i*sigma_k1 + (1.0 - F1_i)*sigma_k2; - sigma_kine_j = F1_j*sigma_k1 + (1.0 - F1_j)*sigma_k2; - sigma_omega_i = F1_i*sigma_om1 + (1.0 - F1_i)*sigma_om2; - sigma_omega_j = F1_j*sigma_om1 + (1.0 - F1_j)*sigma_om2; - - /*--- Compute mean effective viscosity ---*/ - diff_i_kine = Laminar_Viscosity_i + sigma_kine_i*Eddy_Viscosity_i; - diff_j_kine = Laminar_Viscosity_j + sigma_kine_j*Eddy_Viscosity_j; - diff_i_omega = Laminar_Viscosity_i + sigma_omega_i*Eddy_Viscosity_i; - diff_j_omega = Laminar_Viscosity_j + sigma_omega_j*Eddy_Viscosity_j; - - diff_kine = 0.5*(diff_i_kine + diff_j_kine); // Could instead use weighted average! - diff_omega = 0.5*(diff_i_omega + diff_j_omega); - - val_residual[0] = diff_kine*Proj_Mean_GradTurbVar[0]; - val_residual[1] = diff_omega*Proj_Mean_GradTurbVar[1]; - - /*--- For Jacobians -> Use of TSL approx. to compute derivatives of the gradients ---*/ - if (implicit) { - Jacobian_i[0][0] = -diff_kine*proj_vector_ij/Density_i; Jacobian_i[0][1] = 0.0; - Jacobian_i[1][0] = 0.0; Jacobian_i[1][1] = -diff_omega*proj_vector_ij/Density_i; - - Jacobian_j[0][0] = diff_kine*proj_vector_ij/Density_j; Jacobian_j[0][1] = 0.0; - Jacobian_j[1][0] = 0.0; Jacobian_j[1][1] = diff_omega*proj_vector_ij/Density_j; - } - -} diff --git a/SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSA.cpp b/SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSA.cpp deleted file mode 100644 index 476e00129f69..000000000000 --- a/SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSA.cpp +++ /dev/null @@ -1,202 +0,0 @@ -/*! - * \file CSourcePieceWise_TurbSA.cpp - * \brief Implementation of numerics class CSourcePieceWise_TurbSA. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../include/numerics/turbulent/CSourcePieceWise_TurbSA.hpp" - -CSourcePieceWise_TurbSA::CSourcePieceWise_TurbSA(unsigned short val_nDim, unsigned short val_nVar, - CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); - rotating_frame = config->GetRotating_Frame(); - transition = (config->GetKind_Trans_Model() == BC); - - /*--- Spalart-Allmaras closure constants ---*/ - - cv1_3 = pow(7.1, 3.0); - k2 = pow(0.41, 2.0); - cb1 = 0.1355; - cw2 = 0.3; - ct3 = 1.2; - ct4 = 0.5; - cw3_6 = pow(2.0, 6.0); - sigma = 2./3.; - cb2 = 0.622; - cb2_sigma = cb2/sigma; - cw1 = cb1/k2+(1.0+cb2)/sigma; - -} - -CSourcePieceWise_TurbSA::~CSourcePieceWise_TurbSA(void) { } - -void CSourcePieceWise_TurbSA::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - -// AD::StartPreacc(); -// AD::SetPreaccIn(V_i, nDim+6); -// AD::SetPreaccIn(Vorticity_i, nDim); -// AD::SetPreaccIn(StrainMag_i); -// AD::SetPreaccIn(TurbVar_i[0]); -// AD::SetPreaccIn(TurbVar_Grad_i[0], nDim); -// AD::SetPreaccIn(Volume); AD::SetPreaccIn(dist_i); - -// BC Transition Model variables - su2double vmag, rey, re_theta, re_theta_t, re_v; - su2double tu , nu_cr, nu_t, nu_BC, chi_1, chi_2, term1, term2, term_exponential; - - if (incompressible) { - Density_i = V_i[nDim+2]; - Laminar_Viscosity_i = V_i[nDim+4]; - } - else { - Density_i = V_i[nDim+2]; - Laminar_Viscosity_i = V_i[nDim+5]; - } - - val_residual[0] = 0.0; - Production = 0.0; - Destruction = 0.0; - CrossProduction = 0.0; - val_Jacobian_i[0][0] = 0.0; - - gamma_BC = 0.0; - vmag = 0.0; - tu = config->GetTurbulenceIntensity_FreeStream(); - rey = config->GetReynolds(); - - if (nDim==2) { - vmag = sqrt(V_i[1]*V_i[1]+V_i[2]*V_i[2]); - } - else if (nDim==3) { - vmag = sqrt(V_i[1]*V_i[1]+V_i[2]*V_i[2]+V_i[3]*V_i[3]); - } - - /*--- Evaluate Omega ---*/ - - Omega = sqrt(Vorticity_i[0]*Vorticity_i[0] + Vorticity_i[1]*Vorticity_i[1] + Vorticity_i[2]*Vorticity_i[2]); - - /*--- Rotational correction term ---*/ - - if (rotating_frame) { Omega += 2.0*min(0.0, StrainMag_i-Omega); } - - if (dist_i > 1e-10) { - - /*--- Production term ---*/ - - dist_i_2 = dist_i*dist_i; - nu = Laminar_Viscosity_i/Density_i; - Ji = TurbVar_i[0]/nu; - Ji_2 = Ji*Ji; - Ji_3 = Ji_2*Ji; - fv1 = Ji_3/(Ji_3+cv1_3); - fv2 = 1.0 - Ji/(1.0+Ji*fv1); - ft2 = ct3*exp(-ct4*Ji_2); - S = Omega; - inv_k2_d2 = 1.0/(k2*dist_i_2); - - Shat = S + TurbVar_i[0]*fv2*inv_k2_d2; - Shat = max(Shat, 1.0e-10); - inv_Shat = 1.0/Shat; - -// Original SA model -// Production = cb1*(1.0-ft2)*Shat*TurbVar_i[0]*Volume; - - if (transition) { - -// BC model constants - chi_1 = 0.002; - chi_2 = 5.0; - - nu_t = (TurbVar_i[0]*fv1); //S-A variable - nu_cr = chi_2/rey; - nu_BC = (nu_t)/(vmag*dist_i); - - re_v = ((Density_i*pow(dist_i,2.))/(Laminar_Viscosity_i))*Omega; - re_theta = re_v/2.193; - re_theta_t = (803.73 * pow((tu + 0.6067),-1.027)); //MENTER correlation - //re_theta_t = 163.0 + exp(6.91-tu); //ABU-GHANNAM & SHAW correlation - - term1 = sqrt(max(re_theta-re_theta_t,0.)/(chi_1*re_theta_t)); - term2 = sqrt(max(nu_BC-nu_cr,0.)/(nu_cr)); - term_exponential = (term1 + term2); - gamma_BC = 1.0 - exp(-term_exponential); - - Production = gamma_BC*cb1*Shat*TurbVar_i[0]*Volume; - } - else { - Production = cb1*Shat*TurbVar_i[0]*Volume; - } - - /*--- Destruction term ---*/ - - r = min(TurbVar_i[0]*inv_Shat*inv_k2_d2,10.0); - g = r + cw2*(pow(r,6.0)-r); - g_6 = pow(g,6.0); - glim = pow((1.0+cw3_6)/(g_6+cw3_6),1.0/6.0); - fw = g*glim; - -// Original SA model -// Destruction = (cw1*fw-cb1*ft2/k2)*TurbVar_i[0]*TurbVar_i[0]/dist_i_2*Volume; - - Destruction = cw1*fw*TurbVar_i[0]*TurbVar_i[0]/dist_i_2*Volume; - - /*--- Diffusion term ---*/ - - norm2_Grad = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - norm2_Grad += TurbVar_Grad_i[0][iDim]*TurbVar_Grad_i[0][iDim]; - - CrossProduction = cb2_sigma*norm2_Grad*Volume; - - val_residual[0] = Production - Destruction + CrossProduction; - - /*--- Implicit part, production term ---*/ - - dfv1 = 3.0*Ji_2*cv1_3/(nu*pow(Ji_3+cv1_3,2.)); - dfv2 = -(1/nu-Ji_2*dfv1)/pow(1.+Ji*fv1,2.); - if ( Shat <= 1.0e-10 ) dShat = 0.0; - else dShat = (fv2+TurbVar_i[0]*dfv2)*inv_k2_d2; - - if (transition) { - val_Jacobian_i[0][0] += gamma_BC*cb1*(TurbVar_i[0]*dShat+Shat)*Volume; - } - else { - val_Jacobian_i[0][0] += cb1*(TurbVar_i[0]*dShat+Shat)*Volume; - } - - /*--- Implicit part, destruction term ---*/ - - dr = (Shat-TurbVar_i[0]*dShat)*inv_Shat*inv_Shat*inv_k2_d2; - if (r == 10.0) dr = 0.0; - dg = dr*(1.+cw2*(6.0*pow(r,5.0)-1.0)); - dfw = dg*glim*(1.-g_6/(g_6+cw3_6)); - val_Jacobian_i[0][0] -= cw1*(dfw*TurbVar_i[0] + 2.0*fw)*TurbVar_i[0]/dist_i_2*Volume; - - } - -// AD::SetPreaccOut(val_residual[0]); -// AD::EndPreacc(); - -} diff --git a/SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSA_COMP.cpp b/SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSA_COMP.cpp deleted file mode 100644 index 206121aa4f30..000000000000 --- a/SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSA_COMP.cpp +++ /dev/null @@ -1,166 +0,0 @@ -/*! - * \file CSourcePieceWise_TurbSA_COMP.cpp - * \brief Implementation of numerics class CSourcePieceWise_TurbSA_COMP. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../include/numerics/turbulent/CSourcePieceWise_TurbSA_COMP.hpp" - -CSourcePieceWise_TurbSA_COMP::CSourcePieceWise_TurbSA_COMP(unsigned short val_nDim, unsigned short val_nVar, - CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); - rotating_frame = config->GetRotating_Frame(); - - /*--- Spalart-Allmaras closure constants ---*/ - - cv1_3 = pow(7.1, 3.0); - k2 = pow(0.41, 2.0); - cb1 = 0.1355; - cw2 = 0.3; - ct3 = 1.2; - ct4 = 0.5; - cw3_6 = pow(2.0, 6.0); - sigma = 2./3.; - cb2 = 0.622; - cb2_sigma = cb2/sigma; - cw1 = cb1/k2+(1.0+cb2)/sigma; - c5 = 3.5; - -} - -CSourcePieceWise_TurbSA_COMP::~CSourcePieceWise_TurbSA_COMP(void) { } - -void CSourcePieceWise_TurbSA_COMP::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - // AD::StartPreacc(); - // AD::SetPreaccIn(V_i, nDim+6); - // AD::SetPreaccIn(Vorticity_i, nDim); - // AD::SetPreaccIn(StrainMag_i); - // AD::SetPreaccIn(TurbVar_i[0]); - // AD::SetPreaccIn(TurbVar_Grad_i[0], nDim); - // AD::SetPreaccIn(Volume); AD::SetPreaccIn(dist_i); - - if (incompressible) { - Density_i = V_i[nDim+2]; - Laminar_Viscosity_i = V_i[nDim+4]; - } - else { - Density_i = V_i[nDim+2]; - Laminar_Viscosity_i = V_i[nDim+5]; - } - - val_residual[0] = 0.0; - Production = 0.0; - Destruction = 0.0; - CrossProduction = 0.0; - val_Jacobian_i[0][0] = 0.0; - - /*--- Evaluate Omega ---*/ - - Omega = sqrt(Vorticity_i[0]*Vorticity_i[0] + Vorticity_i[1]*Vorticity_i[1] + Vorticity_i[2]*Vorticity_i[2]); - - /*--- Rotational correction term ---*/ - - if (rotating_frame) { Omega += 2.0*min(0.0, StrainMag_i-Omega); } - - if (dist_i > 1e-10) { - - /*--- Production term ---*/ - - dist_i_2 = dist_i*dist_i; - nu = Laminar_Viscosity_i/Density_i; - Ji = TurbVar_i[0]/nu; - Ji_2 = Ji*Ji; - Ji_3 = Ji_2*Ji; - fv1 = Ji_3/(Ji_3+cv1_3); - fv2 = 1.0 - Ji/(1.0+Ji*fv1); - ft2 = ct3*exp(-ct4*Ji_2); - S = Omega; - inv_k2_d2 = 1.0/(k2*dist_i_2); - - Shat = S + TurbVar_i[0]*fv2*inv_k2_d2; - Shat = max(Shat, 1.0e-10); - inv_Shat = 1.0/Shat; - - /*--- Production term ---*/; - - Production = cb1*Shat*TurbVar_i[0]*Volume; - - /*--- Destruction term ---*/ - - r = min(TurbVar_i[0]*inv_Shat*inv_k2_d2,10.0); - g = r + cw2*(pow(r,6.0)-r); - g_6 = pow(g,6.0); - glim = pow((1.0+cw3_6)/(g_6+cw3_6),1.0/6.0); - fw = g*glim; - - Destruction = cw1*fw*TurbVar_i[0]*TurbVar_i[0]/dist_i_2*Volume; - - /*--- Diffusion term ---*/ - - norm2_Grad = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - norm2_Grad += TurbVar_Grad_i[0][iDim]*TurbVar_Grad_i[0][iDim]; - - CrossProduction = cb2_sigma*norm2_Grad*Volume; - - val_residual[0] = Production - Destruction + CrossProduction; - - /*--- Compressibility Correction term ---*/ - Pressure_i = V_i[nDim+1]; - SoundSpeed_i = sqrt(Pressure_i*Gamma/Density_i); - aux_cc=0; - for(iDim=0;iDim. - */ - -#include "../../../include/numerics/turbulent/CSourcePieceWise_TurbSA_E.hpp" - -CSourcePieceWise_TurbSA_E::CSourcePieceWise_TurbSA_E(unsigned short val_nDim, unsigned short val_nVar, - CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); - rotating_frame = config->GetRotating_Frame(); - - /*--- Spalart-Allmaras closure constants ---*/ - - cv1_3 = pow(7.1, 3.0); - k2 = pow(0.41, 2.0); - cb1 = 0.1355; - cw2 = 0.3; - ct3 = 1.2; - ct4 = 0.5; - cw3_6 = pow(2.0, 6.0); - sigma = 2./3.; - cb2 = 0.622; - cb2_sigma = cb2/sigma; - cw1 = cb1/k2+(1.0+cb2)/sigma; - -} - -CSourcePieceWise_TurbSA_E::~CSourcePieceWise_TurbSA_E(void) { } - -void CSourcePieceWise_TurbSA_E::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - // AD::StartPreacc(); - // AD::SetPreaccIn(V_i, nDim+6); - // AD::SetPreaccIn(Vorticity_i, nDim); - // AD::SetPreaccIn(StrainMag_i); - // AD::SetPreaccIn(TurbVar_i[0]); - // AD::SetPreaccIn(TurbVar_Grad_i[0], nDim); - // AD::SetPreaccIn(Volume); AD::SetPreaccIn(dist_i); - - if (incompressible) { - Density_i = V_i[nDim+2]; - Laminar_Viscosity_i = V_i[nDim+4]; - } - else { - Density_i = V_i[nDim+2]; - Laminar_Viscosity_i = V_i[nDim+5]; - } - - val_residual[0] = 0.0; - Production = 0.0; - Destruction = 0.0; - CrossProduction = 0.0; - val_Jacobian_i[0][0] = 0.0; - - - /* - From NASA Turbulence model site. http://turbmodels.larc.nasa.gov/spalart.html - This form was developed primarily to improve the near-wall numerical behavior of the model (i.e., the goal was to improve the convergence behavior). The reference is: - Edwards, J. R. and Chandra, S. "Comparison of Eddy Viscosity-Transport Turbulence Models for Three-Dimensional, Shock-Separated Flowfields," AIAA Journal, Vol. 34, No. 4, 1996, pp. 756-763. - In this modificaton Omega is replaced by Strain Rate - */ - - /*--- Evaluate Omega, here Omega is the Strain Rate ---*/ - - Sbar = 0.0; - for(iDim=0;iDim 1e-10) { - - /*--- Production term ---*/ - - dist_i_2 = dist_i*dist_i; - nu = Laminar_Viscosity_i/Density_i; - Ji = TurbVar_i[0]/nu; - Ji_2 = Ji*Ji; - Ji_3 = Ji_2*Ji; - fv1 = Ji_3/(Ji_3+cv1_3); - fv2 = 1.0 - Ji/(1.0+Ji*fv1); - ft2 = ct3*exp(-ct4*Ji_2); - S = Omega; - inv_k2_d2 = 1.0/(k2*dist_i_2); - - //Shat = S + TurbVar_i[0]*fv2*inv_k2_d2; - Shat = max(S*((1.0/max(Ji,1.0e-16))+fv1),1.0e-16); - - Shat = max(Shat, 1.0e-10); - inv_Shat = 1.0/Shat; - - /*--- Production term ---*/; - - Production = cb1*Shat*TurbVar_i[0]*Volume; - - /*--- Destruction term ---*/ - - r = min(TurbVar_i[0]*inv_Shat*inv_k2_d2,10.0); - r=tanh(r)/tanh(1.0); - - g = r + cw2*(pow(r,6.0)-r); - g_6 = pow(g,6.0); - glim = pow((1.0+cw3_6)/(g_6+cw3_6),1.0/6.0); - fw = g*glim; - - Destruction = cw1*fw*TurbVar_i[0]*TurbVar_i[0]/dist_i_2*Volume; - - /*--- Diffusion term ---*/ - - norm2_Grad = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - norm2_Grad += TurbVar_Grad_i[0][iDim]*TurbVar_Grad_i[0][iDim]; - - CrossProduction = cb2_sigma*norm2_Grad*Volume; - - val_residual[0] = Production - Destruction + CrossProduction; - - /*--- Implicit part, production term ---*/ - - dfv1 = 3.0*Ji_2*cv1_3/(nu*pow(Ji_3+cv1_3,2.)); - dfv2 = -(1/nu-Ji_2*dfv1)/pow(1.+Ji*fv1,2.); - - if ( Shat <= 1.0e-10 ) dShat = 0.0; - else dShat = -S*pow(Ji,-2.0)/nu + S*dfv1; - val_Jacobian_i[0][0] += cb1*(TurbVar_i[0]*dShat+Shat)*Volume; - - /*--- Implicit part, destruction term ---*/ - - dr = (Shat-TurbVar_i[0]*dShat)*inv_Shat*inv_Shat*inv_k2_d2; - dr=(1-pow(tanh(r),2.0))*(dr)/tanh(1.0); - dg = dr*(1.+cw2*(6.0*pow(r,5.0)-1.0)); - dfw = dg*glim*(1.-g_6/(g_6+cw3_6)); - val_Jacobian_i[0][0] -= cw1*(dfw*TurbVar_i[0] + 2.0*fw)*TurbVar_i[0]/dist_i_2*Volume; - - } - - // AD::SetPreaccOut(val_residual[0]); - // AD::EndPreacc(); - -} diff --git a/SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSA_E_COMP.cpp b/SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSA_E_COMP.cpp deleted file mode 100644 index b217afde8140..000000000000 --- a/SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSA_E_COMP.cpp +++ /dev/null @@ -1,183 +0,0 @@ -/*! - * \file CSourcePieceWise_TurbSA_E_COMP.cpp - * \brief Implementation of numerics class CSourcePieceWise_TurbSA_E_COMP. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../include/numerics/turbulent/CSourcePieceWise_TurbSA_E_COMP.hpp" - -CSourcePieceWise_TurbSA_E_COMP::CSourcePieceWise_TurbSA_E_COMP(unsigned short val_nDim, unsigned short val_nVar, - CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); - rotating_frame = config->GetRotating_Frame(); - - /*--- Spalart-Allmaras closure constants ---*/ - - cv1_3 = pow(7.1, 3.0); - k2 = pow(0.41, 2.0); - cb1 = 0.1355; - cw2 = 0.3; - ct3 = 1.2; - ct4 = 0.5; - cw3_6 = pow(2.0, 6.0); - sigma = 2./3.; - cb2 = 0.622; - cb2_sigma = cb2/sigma; - cw1 = cb1/k2+(1.0+cb2)/sigma; - -} - -CSourcePieceWise_TurbSA_E_COMP::~CSourcePieceWise_TurbSA_E_COMP(void) { } - -void CSourcePieceWise_TurbSA_E_COMP::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - // AD::StartPreacc(); - // AD::SetPreaccIn(V_i, nDim+6); - // AD::SetPreaccIn(Vorticity_i, nDim); - // AD::SetPreaccIn(StrainMag_i); - // AD::SetPreaccIn(TurbVar_i[0]); - // AD::SetPreaccIn(TurbVar_Grad_i[0], nDim); - // AD::SetPreaccIn(Volume); AD::SetPreaccIn(dist_i); - - if (incompressible) { - Density_i = V_i[nDim+2]; - Laminar_Viscosity_i = V_i[nDim+4]; - } - else { - Density_i = V_i[nDim+2]; - Laminar_Viscosity_i = V_i[nDim+5]; - } - - val_residual[0] = 0.0; - Production = 0.0; - Destruction = 0.0; - CrossProduction = 0.0; - val_Jacobian_i[0][0] = 0.0; - - /* - From NASA Turbulence model site. http://turbmodels.larc.nasa.gov/spalart.html - This form was developed primarily to improve the near-wall numerical behavior of the model (i.e., the goal was to improve the convergence behavior). The reference is: - Edwards, J. R. and Chandra, S. "Comparison of Eddy Viscosity-Transport Turbulence Models for Three-Dimensional, Shock-Separated Flowfields," AIAA Journal, Vol. 34, No. 4, 1996, pp. 756-763. - In this modificaton Omega is replaced by Strain Rate - */ - - /*--- Evaluate Omega, here Omega is the Strain Rate ---*/ - - Sbar = 0.0; - for(iDim=0;iDim 1e-10) { - - /*--- Production term ---*/ - - dist_i_2 = dist_i*dist_i; - nu = Laminar_Viscosity_i/Density_i; - Ji = TurbVar_i[0]/nu; - Ji_2 = Ji*Ji; - Ji_3 = Ji_2*Ji; - fv1 = Ji_3/(Ji_3+cv1_3); - fv2 = 1.0 - Ji/(1.0+Ji*fv1); - ft2 = ct3*exp(-ct4*Ji_2); - S = Omega; - inv_k2_d2 = 1.0/(k2*dist_i_2); - - Shat = max(S*((1.0/max(Ji,1.0e-16))+fv1),1.0e-16); - - Shat = max(Shat, 1.0e-10); - inv_Shat = 1.0/Shat; - - /*--- Production term ---*/; - - Production = cb1*Shat*TurbVar_i[0]*Volume; - - /*--- Destruction term ---*/ - - r = min(TurbVar_i[0]*inv_Shat*inv_k2_d2,10.0); - r=tanh(r)/tanh(1.0); - - g = r + cw2*(pow(r,6.0)-r); - g_6 = pow(g,6.0); - glim = pow((1.0+cw3_6)/(g_6+cw3_6),1.0/6.0); - fw = g*glim; - - Destruction = cw1*fw*TurbVar_i[0]*TurbVar_i[0]/dist_i_2*Volume; - - /*--- Diffusion term ---*/ - - norm2_Grad = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - norm2_Grad += TurbVar_Grad_i[0][iDim]*TurbVar_Grad_i[0][iDim]; - - CrossProduction = cb2_sigma*norm2_Grad*Volume; - - val_residual[0] = Production - Destruction + CrossProduction; - - /*--- Compressibility Correction term ---*/ - Pressure_i = V_i[nDim+1]; - SoundSpeed_i = sqrt(Pressure_i*Gamma/Density_i); - aux_cc=0; - for(iDim=0;iDim. - */ - -#include "../../../include/numerics/turbulent/CSourcePieceWise_TurbSA_Neg.hpp" - -CSourcePieceWise_TurbSA_Neg::CSourcePieceWise_TurbSA_Neg(unsigned short val_nDim, unsigned short val_nVar, - CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); - rotating_frame = config->GetRotating_Frame(); - - /*--- Negative Spalart-Allmaras closure constants ---*/ - - cv1_3 = pow(7.1, 3.0); - k2 = pow(0.41, 2.0); - cb1 = 0.1355; - cw2 = 0.3; - ct3 = 1.2; - ct4 = 0.5; - cw3_6 = pow(2.0, 6.0); - sigma = 2./3.; - cb2 = 0.622; - cb2_sigma = cb2/sigma; - cw1 = cb1/k2+(1.0+cb2)/sigma; - -} - -CSourcePieceWise_TurbSA_Neg::~CSourcePieceWise_TurbSA_Neg(void) { - -} - -void CSourcePieceWise_TurbSA_Neg::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - -// AD::StartPreacc(); -// AD::SetPreaccIn(V_i, nDim+6); -// AD::SetPreaccIn(Vorticity_i, nDim); -// AD::SetPreaccIn(StrainMag_i); -// AD::SetPreaccIn(TurbVar_i[0]); -// AD::SetPreaccIn(TurbVar_Grad_i[0], nDim); -// AD::SetPreaccIn(Volume); AD::SetPreaccIn(dist_i); - - if (incompressible) { - Density_i = V_i[nDim+2]; - Laminar_Viscosity_i = V_i[nDim+4]; - } - else { - Density_i = V_i[nDim+2]; - Laminar_Viscosity_i = V_i[nDim+5]; - } - - val_residual[0] = 0.0; - Production = 0.0; - Destruction = 0.0; - CrossProduction = 0.0; - val_Jacobian_i[0][0] = 0.0; - - /*--- Evaluate Omega ---*/ - - Omega = sqrt(Vorticity_i[0]*Vorticity_i[0] + Vorticity_i[1]*Vorticity_i[1] + Vorticity_i[2]*Vorticity_i[2]); - - /*--- Rotational correction term ---*/ - - if (rotating_frame) { Omega += 2.0*min(0.0, StrainMag_i-Omega); } - - if (dist_i > 1e-10) { - - if (TurbVar_i[0] > 0.0) { - - /*--- Production term ---*/ - - dist_i_2 = dist_i*dist_i; - nu = Laminar_Viscosity_i/Density_i; - Ji = TurbVar_i[0]/nu; - Ji_2 = Ji*Ji; - Ji_3 = Ji_2*Ji; - fv1 = Ji_3/(Ji_3+cv1_3); - fv2 = 1.0 - Ji/(1.0+Ji*fv1); - ft2 = ct3*exp(-ct4*Ji_2); - S = Omega; - inv_k2_d2 = 1.0/(k2*dist_i_2); - - Shat = S + TurbVar_i[0]*fv2*inv_k2_d2; - Shat = max(Shat, 1.0e-10); - inv_Shat = 1.0/Shat; - - /*--- Production term ---*/; - - // Original SA model - // Production = cb1*(1.0-ft2)*Shat*TurbVar_i[0]*Volume; - - Production = cb1*Shat*TurbVar_i[0]*Volume; - - /*--- Destruction term ---*/ - - r = min(TurbVar_i[0]*inv_Shat*inv_k2_d2,10.0); - g = r + cw2*(pow(r,6.0)-r); - g_6 = pow(g,6.0); - glim = pow((1.0+cw3_6)/(g_6+cw3_6),1.0/6.0); - fw = g*glim; - - Destruction = cw1*fw*TurbVar_i[0]*TurbVar_i[0]/dist_i_2*Volume; - - /*--- Diffusion term ---*/ - - norm2_Grad = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - norm2_Grad += TurbVar_Grad_i[0][iDim]*TurbVar_Grad_i[0][iDim]; - - CrossProduction = cb2_sigma*norm2_Grad*Volume; - - val_residual[0] = Production - Destruction + CrossProduction; - - /*--- Implicit part, production term ---*/ - - dfv1 = 3.0*Ji_2*cv1_3/(nu*pow(Ji_3+cv1_3,2.)); - dfv2 = -(1/nu-Ji_2*dfv1)/pow(1.+Ji*fv1,2.); - if ( Shat <= 1.0e-10 ) dShat = 0.0; - else dShat = (fv2+TurbVar_i[0]*dfv2)*inv_k2_d2; - val_Jacobian_i[0][0] += cb1*(TurbVar_i[0]*dShat+Shat)*Volume; - - /*--- Implicit part, destruction term ---*/ - - dr = (Shat-TurbVar_i[0]*dShat)*inv_Shat*inv_Shat*inv_k2_d2; - if (r == 10.0) dr = 0.0; - dg = dr*(1.+cw2*(6.0*pow(r,5.0)-1.0)); - dfw = dg*glim*(1.-g_6/(g_6+cw3_6)); - val_Jacobian_i[0][0] -= cw1*(dfw*TurbVar_i[0] + 2.0*fw)*TurbVar_i[0]/dist_i_2*Volume; - - } - - else { - - /*--- Production term ---*/ - - dist_i_2 = dist_i*dist_i; - - /*--- Production term ---*/; - - Production = cb1*(1.0-ct3)*Omega*TurbVar_i[0]*Volume; - - /*--- Destruction term ---*/ - - Destruction = cw1*TurbVar_i[0]*TurbVar_i[0]/dist_i_2*Volume; - - /*--- Diffusion term ---*/ - - norm2_Grad = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - norm2_Grad += TurbVar_Grad_i[0][iDim]*TurbVar_Grad_i[0][iDim]; - - CrossProduction = cb2_sigma*norm2_Grad*Volume; - - val_residual[0] = Production + Destruction + CrossProduction; - - /*--- Implicit part, production term ---*/ - - val_Jacobian_i[0][0] += cb1*(1.0-ct3)*Omega*Volume; - - /*--- Implicit part, destruction term ---*/ - - val_Jacobian_i[0][0] += 2.0*cw1*TurbVar_i[0]/dist_i_2*Volume; - - } - - } - -// AD::SetPreaccOut(val_residual, nVar); -// AD::EndPreacc(); -} diff --git a/SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSST.cpp b/SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSST.cpp deleted file mode 100644 index ab83d43330ed..000000000000 --- a/SU2_CFD/src/numerics/turbulent/CSourcePieceWise_TurbSST.cpp +++ /dev/null @@ -1,371 +0,0 @@ -/*! - * \file CSourcePieceWise_TurbSST.cpp - * \brief Implementation of numerics class CSourcePieceWise_TurbSST. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../include/numerics/turbulent/CSourcePieceWise_TurbSST.hpp" - -CSourcePieceWise_TurbSST::CSourcePieceWise_TurbSST(unsigned short val_nDim, unsigned short val_nVar, const su2double *constants, - su2double val_kine_Inf, su2double val_omega_Inf, CConfig *config) - : CNumerics(val_nDim, val_nVar, config) { - - incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); - sustaining_terms = (config->GetKind_Turb_Model() == SST_SUST); - - /*--- Closure constants ---*/ - beta_star = constants[6]; - sigma_omega_1 = constants[2]; - sigma_omega_2 = constants[3]; - beta_1 = constants[4]; - beta_2 = constants[5]; - alfa_1 = constants[8]; - alfa_2 = constants[9]; - a1 = constants[7]; - - /*--- Set the ambient values of k and omega to the free stream values. ---*/ - kAmb = val_kine_Inf; - omegaAmb = val_omega_Inf; -} - -CSourcePieceWise_TurbSST::~CSourcePieceWise_TurbSST(void) { } - -void CSourcePieceWise_TurbSST::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - AD::StartPreacc(); - AD::SetPreaccIn(StrainMag_i); - AD::SetPreaccIn(TurbVar_i, nVar); - AD::SetPreaccIn(TurbVar_Grad_i, nVar, nDim); - AD::SetPreaccIn(Volume); AD::SetPreaccIn(dist_i); - AD::SetPreaccIn(F1_i); AD::SetPreaccIn(F2_i); AD::SetPreaccIn(CDkw_i); - AD::SetPreaccIn(PrimVar_Grad_i, nDim+1, nDim); - - unsigned short iDim; - su2double alfa_blended, beta_blended; - su2double diverg, pk, pw, zeta; - - if (incompressible) { - AD::SetPreaccIn(V_i, nDim+6); - - Density_i = V_i[nDim+2]; - Laminar_Viscosity_i = V_i[nDim+4]; - Eddy_Viscosity_i = V_i[nDim+5]; - } - else { - AD::SetPreaccIn(V_i, nDim+7); - - Density_i = V_i[nDim+2]; - Laminar_Viscosity_i = V_i[nDim+5]; - Eddy_Viscosity_i = V_i[nDim+6]; - } - - val_residual[0] = 0.0; val_residual[1] = 0.0; - val_Jacobian_i[0][0] = 0.0; val_Jacobian_i[0][1] = 0.0; - val_Jacobian_i[1][0] = 0.0; val_Jacobian_i[1][1] = 0.0; - - /*--- Computation of blended constants for the source terms---*/ - - alfa_blended = F1_i*alfa_1 + (1.0 - F1_i)*alfa_2; - beta_blended = F1_i*beta_1 + (1.0 - F1_i)*beta_2; - - if (dist_i > 1e-10) { - - /*--- Production ---*/ - - diverg = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - diverg += PrimVar_Grad_i[iDim+1][iDim]; - - /* if using UQ methodolgy, calculate production using perturbed Reynolds stress matrix */ - - if (using_uq){ - SetReynoldsStressMatrix(TurbVar_i[0]); - SetPerturbedRSM(TurbVar_i[0], config); - SetPerturbedStrainMag(TurbVar_i[0]); - pk = Eddy_Viscosity_i*PerturbedStrainMag*PerturbedStrainMag - - 2.0/3.0*Density_i*TurbVar_i[0]*diverg; - } - else { - pk = Eddy_Viscosity_i*StrainMag_i*StrainMag_i - 2.0/3.0*Density_i*TurbVar_i[0]*diverg; - } - - - pk = min(pk,20.0*beta_star*Density_i*TurbVar_i[1]*TurbVar_i[0]); - pk = max(pk,0.0); - - zeta = max(TurbVar_i[1], StrainMag_i*F2_i/a1); - - /* if using UQ methodolgy, calculate production using perturbed Reynolds stress matrix */ - - if (using_uq){ - pw = PerturbedStrainMag * PerturbedStrainMag - 2.0/3.0*zeta*diverg; - } - else { - pw = StrainMag_i*StrainMag_i - 2.0/3.0*zeta*diverg; - } - pw = alfa_blended*Density_i*max(pw,0.0); - - /*--- Sustaining terms, if desired. Note that if the production terms are - larger equal than the sustaining terms, the original formulation is - obtained again. This is in contrast to the version in literature - where the sustaining terms are simply added. This latter approach could - lead to problems for very big values of the free-stream turbulence - intensity. ---*/ - - if ( sustaining_terms ) { - const su2double sust_k = beta_star*Density_i*kAmb*omegaAmb; - const su2double sust_w = beta_blended*Density_i*omegaAmb*omegaAmb; - - pk = max(pk, sust_k); - pw = max(pw, sust_w); - } - - /*--- Add the production terms to the residuals. ---*/ - - val_residual[0] += pk*Volume; - val_residual[1] += pw*Volume; - - /*--- Dissipation ---*/ - - val_residual[0] -= beta_star*Density_i*TurbVar_i[1]*TurbVar_i[0]*Volume; - val_residual[1] -= beta_blended*Density_i*TurbVar_i[1]*TurbVar_i[1]*Volume; - - /*--- Cross diffusion ---*/ - - val_residual[1] += (1.0 - F1_i)*CDkw_i*Volume; - - /*--- Implicit part ---*/ - - val_Jacobian_i[0][0] = -beta_star*TurbVar_i[1]*Volume; - val_Jacobian_i[0][1] = -beta_star*TurbVar_i[0]*Volume; - val_Jacobian_i[1][0] = 0.0; - val_Jacobian_i[1][1] = -2.0*beta_blended*TurbVar_i[1]*Volume; - } - - AD::SetPreaccOut(val_residual, nVar); - AD::EndPreacc(); - -} - -void CSourcePieceWise_TurbSST::GetMeanRateOfStrainMatrix(su2double **S_ij) -{ - /* --- Calculate the rate of strain tensor, using mean velocity gradients --- */ - - if (nDim == 3){ - S_ij[0][0] = PrimVar_Grad_i[1][0]; - S_ij[1][1] = PrimVar_Grad_i[2][1]; - S_ij[2][2] = PrimVar_Grad_i[3][2]; - S_ij[0][1] = 0.5 * (PrimVar_Grad_i[1][1] + PrimVar_Grad_i[2][0]); - S_ij[0][2] = 0.5 * (PrimVar_Grad_i[1][2] + PrimVar_Grad_i[3][0]); - S_ij[1][2] = 0.5 * (PrimVar_Grad_i[2][2] + PrimVar_Grad_i[3][1]); - S_ij[1][0] = S_ij[0][1]; - S_ij[2][1] = S_ij[1][2]; - S_ij[2][0] = S_ij[0][2]; - } - else { - S_ij[0][0] = PrimVar_Grad_i[1][0]; - S_ij[1][1] = PrimVar_Grad_i[2][1]; - S_ij[2][2] = 0.0; - S_ij[0][1] = 0.5 * (PrimVar_Grad_i[1][1] + PrimVar_Grad_i[2][0]); - S_ij[0][2] = 0.0; - S_ij[1][2] = 0.0; - S_ij[1][0] = S_ij[0][1]; - S_ij[2][1] = S_ij[1][2]; - S_ij[2][0] = S_ij[0][2]; - - } -} - -void CSourcePieceWise_TurbSST::SetReynoldsStressMatrix(su2double turb_ke){ - unsigned short iDim, jDim; - su2double **S_ij = new su2double* [3]; - su2double divVel = 0; - su2double TWO3 = 2.0/3.0; - - - - for (iDim = 0; iDim < 3; iDim++){ - S_ij[iDim] = new su2double [3]; - } - - GetMeanRateOfStrainMatrix(S_ij); - - /* --- Using rate of strain matrix, calculate Reynolds stress tensor --- */ - - for (iDim = 0; iDim < 3; iDim++){ - divVel += S_ij[iDim][iDim]; - } - - for (iDim = 0; iDim < 3; iDim++){ - for (jDim = 0; jDim < 3; jDim++){ - MeanReynoldsStress[iDim][jDim] = TWO3 * turb_ke * delta3[iDim][jDim] - - Eddy_Viscosity_i / Density_i * (2 * S_ij[iDim][jDim] - TWO3 * divVel * delta3[iDim][jDim]); - } - } - - for (iDim = 0; iDim < 3; iDim++) - delete [] S_ij[iDim]; - delete [] S_ij; -} - -void CSourcePieceWise_TurbSST::SetPerturbedRSM(su2double turb_ke, CConfig *config){ - - unsigned short iDim,jDim; - - /* --- Calculate anisotropic part of Reynolds Stress tensor --- */ - - for (iDim = 0; iDim< 3; iDim++){ - for (jDim = 0; jDim < 3; jDim++){ - A_ij[iDim][jDim] = .5 * MeanReynoldsStress[iDim][jDim] / turb_ke - delta3[iDim][jDim] / 3.0; - Eig_Vec[iDim][jDim] = A_ij[iDim][jDim]; - } - } - - /* --- Get ordered eigenvectors and eigenvalues of A_ij --- */ - - EigenDecomposition(A_ij, Eig_Vec, Eig_Val, 3); - - /* compute convex combination coefficients */ - su2double c1c = Eig_Val[2] - Eig_Val[1]; - su2double c2c = 2.0 * (Eig_Val[1] - Eig_Val[0]); - su2double c3c = 3.0 * Eig_Val[0] + 1.0; - - /* define barycentric traingle corner points */ - Corners[0][0] = 1.0; - Corners[0][1] = 0.0; - Corners[1][0] = 0.0; - Corners[1][1] = 0.0; - Corners[2][0] = 0.5; - Corners[2][1] = 0.866025; - - /* define barycentric coordinates */ - Barycentric_Coord[0] = Corners[0][0] * c1c + Corners[1][0] * c2c + Corners[2][0] * c3c; - Barycentric_Coord[1] = Corners[0][1] * c1c + Corners[1][1] * c2c + Corners[2][1] * c3c; - - if (Eig_Val_Comp == 1) { - /* 1C turbulence */ - New_Coord[0] = Corners[0][0]; - New_Coord[1] = Corners[0][1]; - } - else if (Eig_Val_Comp == 2) { - /* 2C turbulence */ - New_Coord[0] = Corners[1][0]; - New_Coord[1] = Corners[1][1]; - } - else if (Eig_Val_Comp == 3) { - /* 3C turbulence */ - New_Coord[0] = Corners[2][0]; - New_Coord[1] = Corners[2][1]; - } - else { - /* 2C turbulence */ - New_Coord[0] = Corners[1][0]; - New_Coord[1] = Corners[1][1]; - } - /* calculate perturbed barycentric coordinates */ - - Barycentric_Coord[0] = Barycentric_Coord[0] + (uq_delta_b) * (New_Coord[0] - Barycentric_Coord[0]); - Barycentric_Coord[1] = Barycentric_Coord[1] + (uq_delta_b) * (New_Coord[1] - Barycentric_Coord[1]); - - /* rebuild c1c,c2c,c3c based on new barycentric coordinates */ - c3c = Barycentric_Coord[1] / Corners[2][1]; - c1c = Barycentric_Coord[0] - Corners[2][0] * c3c; - c2c = 1 - c1c - c3c; - - /* build new anisotropy eigenvalues */ - Eig_Val[0] = (c3c - 1) / 3.0; - Eig_Val[1] = 0.5 *c2c + Eig_Val[0]; - Eig_Val[2] = c1c + Eig_Val[1]; - - /* permute eigenvectors if required */ - if (uq_permute) { - for (iDim=0; iDim<3; iDim++) { - for (jDim=0; jDim<3; jDim++) { - New_Eig_Vec[iDim][jDim] = Eig_Vec[2-iDim][jDim]; - } - } - } - - else { - for (iDim=0; iDim<3; iDim++) { - for (jDim=0; jDim<3; jDim++) { - New_Eig_Vec[iDim][jDim] = Eig_Vec[iDim][jDim]; - } - } - } - - EigenRecomposition(newA_ij, New_Eig_Vec, Eig_Val, 3); - - /* compute perturbed Reynolds stress matrix; use under-relaxation factor (urlx)*/ - for (iDim = 0; iDim< 3; iDim++){ - for (jDim = 0; jDim < 3; jDim++){ - MeanPerturbedRSM[iDim][jDim] = 2.0 * turb_ke * (newA_ij[iDim][jDim] + 1.0/3.0 * delta3[iDim][jDim]); - MeanPerturbedRSM[iDim][jDim] = MeanReynoldsStress[iDim][jDim] + - uq_urlx*(MeanPerturbedRSM[iDim][jDim] - MeanReynoldsStress[iDim][jDim]); - } - } - -} - -void CSourcePieceWise_TurbSST::SetPerturbedStrainMag(su2double turb_ke){ - unsigned short iDim, jDim; - PerturbedStrainMag = 0; - su2double **StrainRate = new su2double* [nDim]; - for (iDim= 0; iDim< nDim; iDim++){ - StrainRate[iDim] = new su2double [nDim]; - } - - /* compute perturbed strain rate tensor */ - - for (iDim = 0; iDim < nDim; iDim++){ - for (jDim =0; jDim < nDim; jDim++){ - StrainRate[iDim][jDim] = MeanPerturbedRSM[iDim][jDim] - - TWO3 * turb_ke * delta[iDim][jDim]; - StrainRate[iDim][jDim] = - StrainRate[iDim][jDim] * Density_i / (2 * Eddy_Viscosity_i); - } - } - - /*--- Add diagonal part ---*/ - - for (iDim = 0; iDim < nDim; iDim++) { - PerturbedStrainMag += pow(StrainRate[iDim][iDim], 2.0); - } - - /*--- Add off diagonals ---*/ - - PerturbedStrainMag += 2.0*pow(StrainRate[1][0], 2.0); - - if (nDim == 3) { - PerturbedStrainMag += 2.0*pow(StrainRate[0][2], 2.0); - PerturbedStrainMag += 2.0*pow(StrainRate[1][2], 2.0); - } - - PerturbedStrainMag = sqrt(2.0*PerturbedStrainMag); - - for (iDim= 0; iDim< nDim; iDim++){ - delete [] StrainRate[iDim]; - } - - delete [] StrainRate; -} diff --git a/SU2_CFD/src/numerics/turbulent/CUpwSca_TurbSA.cpp b/SU2_CFD/src/numerics/turbulent/CUpwSca_TurbSA.cpp deleted file mode 100644 index 1df3b98b98de..000000000000 --- a/SU2_CFD/src/numerics/turbulent/CUpwSca_TurbSA.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/*! - * \file CUpwSca_TurbSA.cpp - * \brief Implementation of numerics class CUpwSca_TurbSA. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../include/numerics/turbulent/CUpwSca_TurbSA.hpp" - -CUpwSca_TurbSA::CUpwSca_TurbSA(unsigned short val_nDim, - unsigned short val_nVar, - CConfig *config) - : CUpwScalar(val_nDim, val_nVar, config) { -} - -CUpwSca_TurbSA::~CUpwSca_TurbSA(void) { -} - -void CUpwSca_TurbSA::ExtraADPreaccIn() { - AD::SetPreaccIn(V_i, nDim+1); AD::SetPreaccIn(V_j, nDim+1); -} - -void CUpwSca_TurbSA::FinishResidualCalc(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - val_residual[0] = a0*TurbVar_i[0]+a1*TurbVar_j[0]; - - if (implicit) { - val_Jacobian_i[0][0] = a0; - val_Jacobian_j[0][0] = a1; - } -} diff --git a/SU2_CFD/src/numerics/turbulent/CUpwSca_TurbSST.cpp b/SU2_CFD/src/numerics/turbulent/CUpwSca_TurbSST.cpp deleted file mode 100644 index 2efb07416803..000000000000 --- a/SU2_CFD/src/numerics/turbulent/CUpwSca_TurbSST.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/*! - * \file CUpwSca_TurbSST.cpp - * \brief Implementation of numerics class CUpwSca_TurbSST. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../include/numerics/turbulent/CUpwSca_TurbSST.hpp" - -CUpwSca_TurbSST::CUpwSca_TurbSST(unsigned short val_nDim, - unsigned short val_nVar, - CConfig *config) - : CUpwScalar(val_nDim, val_nVar, config) { -} - -CUpwSca_TurbSST::~CUpwSca_TurbSST(void) { -} - -void CUpwSca_TurbSST::ExtraADPreaccIn() { - - AD::SetPreaccIn(V_i, nDim+3); - AD::SetPreaccIn(V_j, nDim+3); - -} - -void CUpwSca_TurbSST::FinishResidualCalc(su2double *val_residual, - su2double **val_Jacobian_i, - su2double **val_Jacobian_j, - CConfig *config) { - - val_residual[0] = a0*Density_i*TurbVar_i[0]+a1*Density_j*TurbVar_j[0]; - val_residual[1] = a0*Density_i*TurbVar_i[1]+a1*Density_j*TurbVar_j[1]; - - if (implicit) { - val_Jacobian_i[0][0] = a0; val_Jacobian_i[0][1] = 0.0; - val_Jacobian_i[1][0] = 0.0; val_Jacobian_i[1][1] = a0; - - val_Jacobian_j[0][0] = a1; val_Jacobian_j[0][1] = 0.0; - val_Jacobian_j[1][0] = 0.0; val_Jacobian_j[1][1] = a1; - } -} diff --git a/SU2_CFD/src/numerics/turbulent/CUpwScalar.cpp b/SU2_CFD/src/numerics/turbulent/turb_convection.cpp similarity index 50% rename from SU2_CFD/src/numerics/turbulent/CUpwScalar.cpp rename to SU2_CFD/src/numerics/turbulent/turb_convection.cpp index 784b95938dc3..6b69d5bdcbee 100644 --- a/SU2_CFD/src/numerics/turbulent/CUpwScalar.cpp +++ b/SU2_CFD/src/numerics/turbulent/turb_convection.cpp @@ -1,6 +1,7 @@ /*! - * \file CUpwScalar.cpp - * \brief Implementation of numerics class CUpwScalar. + * \file turb_convection.cpp + * \brief Implementation of numerics classes to compute convective + * fluxes in turbulence problems. * \author F. Palacios, T. Economon * \version 7.0.0 "Blackbird" * @@ -25,14 +26,14 @@ * License along with SU2. If not, see . */ -#include "../../../include/numerics/turbulent/CUpwScalar.hpp" +#include "../../../include/numerics/turbulent/turb_convection.hpp" CUpwScalar::CUpwScalar(unsigned short val_nDim, - unsigned short val_nVar, - CConfig *config) - : CNumerics(val_nDim, val_nVar, config) { + unsigned short val_nVar, + CConfig *config) : + CNumerics(val_nDim, val_nVar, config) { - implicit = (config->GetKind_TimeIntScheme_Turb() == EULER_IMPLICIT); + implicit = (config->GetKind_TimeIntScheme_Turb() == EULER_IMPLICIT); incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ dynamic_grid = config->GetDynamic_Grid(); @@ -50,9 +51,9 @@ CUpwScalar::~CUpwScalar(void) { } void CUpwScalar::ComputeResidual(su2double *val_residual, - su2double **val_Jacobian_i, - su2double **val_Jacobian_j, - CConfig *config) { + su2double **val_Jacobian_i, + su2double **val_Jacobian_j, + CConfig *config) { AD::StartPreacc(); AD::SetPreaccIn(Normal, nDim); @@ -92,3 +93,59 @@ void CUpwScalar::ComputeResidual(su2double *val_residual, AD::EndPreacc(); } + +CUpwSca_TurbSA::CUpwSca_TurbSA(unsigned short val_nDim, + unsigned short val_nVar, + CConfig *config) + : CUpwScalar(val_nDim, val_nVar, config) { +} + +CUpwSca_TurbSA::~CUpwSca_TurbSA(void) { +} + +void CUpwSca_TurbSA::ExtraADPreaccIn() { + AD::SetPreaccIn(V_i, nDim+1); AD::SetPreaccIn(V_j, nDim+1); +} + +void CUpwSca_TurbSA::FinishResidualCalc(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { + + val_residual[0] = a0*TurbVar_i[0]+a1*TurbVar_j[0]; + + if (implicit) { + val_Jacobian_i[0][0] = a0; + val_Jacobian_j[0][0] = a1; + } +} + +CUpwSca_TurbSST::CUpwSca_TurbSST(unsigned short val_nDim, + unsigned short val_nVar, + CConfig *config) + : CUpwScalar(val_nDim, val_nVar, config) { +} + +CUpwSca_TurbSST::~CUpwSca_TurbSST(void) { +} + +void CUpwSca_TurbSST::ExtraADPreaccIn() { + + AD::SetPreaccIn(V_i, nDim+3); + AD::SetPreaccIn(V_j, nDim+3); + +} + +void CUpwSca_TurbSST::FinishResidualCalc(su2double *val_residual, + su2double **val_Jacobian_i, + su2double **val_Jacobian_j, + CConfig *config) { + + val_residual[0] = a0*Density_i*TurbVar_i[0]+a1*Density_j*TurbVar_j[0]; + val_residual[1] = a0*Density_i*TurbVar_i[1]+a1*Density_j*TurbVar_j[1]; + + if (implicit) { + val_Jacobian_i[0][0] = a0; val_Jacobian_i[0][1] = 0.0; + val_Jacobian_i[1][0] = 0.0; val_Jacobian_i[1][1] = a0; + + val_Jacobian_j[0][0] = a1; val_Jacobian_j[0][1] = 0.0; + val_Jacobian_j[1][0] = 0.0; val_Jacobian_j[1][1] = a1; + } +} diff --git a/SU2_CFD/src/numerics/turbulent/turb_diffusion.cpp b/SU2_CFD/src/numerics/turbulent/turb_diffusion.cpp new file mode 100644 index 000000000000..5c6bb8fe952e --- /dev/null +++ b/SU2_CFD/src/numerics/turbulent/turb_diffusion.cpp @@ -0,0 +1,266 @@ +/*! + * \file turb_diffusion.cpp + * \brief Implementation of numerics classes to compute viscous + * fluxes in turbulence problems. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../include/numerics/turbulent/turb_diffusion.hpp" + +CAvgGrad_Scalar::CAvgGrad_Scalar(unsigned short val_nDim, + unsigned short val_nVar, + bool correct_grad, + CConfig *config) + : CNumerics(val_nDim, val_nVar, config), correct_gradient(correct_grad) { + + implicit = (config->GetKind_TimeIntScheme_Turb() == EULER_IMPLICIT); + incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); + + Edge_Vector = new su2double [nDim]; + Proj_Mean_GradTurbVar_Normal = new su2double [nVar]; + Proj_Mean_GradTurbVar_Edge = new su2double [nVar]; + Proj_Mean_GradTurbVar = new su2double [nVar]; + Mean_GradTurbVar = new su2double* [nVar]; + for (iVar = 0; iVar < nVar; iVar++) + Mean_GradTurbVar[iVar] = new su2double [nDim]; + +} + +CAvgGrad_Scalar::~CAvgGrad_Scalar(void) { + + delete [] Edge_Vector; + delete [] Proj_Mean_GradTurbVar_Normal; + delete [] Proj_Mean_GradTurbVar_Edge; + delete [] Proj_Mean_GradTurbVar; + for (iVar = 0; iVar < nVar; iVar++) + delete [] Mean_GradTurbVar[iVar]; + delete [] Mean_GradTurbVar; + +} + +void CAvgGrad_Scalar::ComputeResidual(su2double *val_residual, + su2double **Jacobian_i, + su2double **Jacobian_j, + CConfig *config) { + + AD::StartPreacc(); + AD::SetPreaccIn(Coord_i, nDim); AD::SetPreaccIn(Coord_j, nDim); + AD::SetPreaccIn(Normal, nDim); + AD::SetPreaccIn(TurbVar_Grad_i, nVar, nDim); + AD::SetPreaccIn(TurbVar_Grad_j, nVar, nDim); + if (correct_gradient) { + AD::SetPreaccIn(TurbVar_i, nVar); AD::SetPreaccIn(TurbVar_j ,nVar); + } + ExtraADPreaccIn(); + + if (incompressible) { + AD::SetPreaccIn(V_i, nDim+6); AD::SetPreaccIn(V_j, nDim+6); + + Density_i = V_i[nDim+2]; Density_j = V_j[nDim+2]; + Laminar_Viscosity_i = V_i[nDim+4]; Laminar_Viscosity_j = V_j[nDim+4]; + Eddy_Viscosity_i = V_i[nDim+5]; Eddy_Viscosity_j = V_j[nDim+5]; + } + else { + AD::SetPreaccIn(V_i, nDim+7); AD::SetPreaccIn(V_j, nDim+7); + + Density_i = V_i[nDim+2]; Density_j = V_j[nDim+2]; + Laminar_Viscosity_i = V_i[nDim+5]; Laminar_Viscosity_j = V_j[nDim+5]; + Eddy_Viscosity_i = V_i[nDim+6]; Eddy_Viscosity_j = V_j[nDim+6]; + } + + /*--- Compute vector going from iPoint to jPoint ---*/ + + 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; + + /*--- Mean gradient approximation ---*/ + for (iVar = 0; iVar < nVar; iVar++) { + Proj_Mean_GradTurbVar_Normal[iVar] = 0.0; + Proj_Mean_GradTurbVar_Edge[iVar] = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + Mean_GradTurbVar[iVar][iDim] = 0.5*(TurbVar_Grad_i[iVar][iDim] + + TurbVar_Grad_j[iVar][iDim]); + Proj_Mean_GradTurbVar_Normal[iVar] += Mean_GradTurbVar[iVar][iDim] * + Normal[iDim]; + if (correct_gradient) + Proj_Mean_GradTurbVar_Edge[iVar] += Mean_GradTurbVar[iVar][iDim]*Edge_Vector[iDim]; + } + Proj_Mean_GradTurbVar[iVar] = Proj_Mean_GradTurbVar_Normal[iVar]; + if (correct_gradient) { + Proj_Mean_GradTurbVar[iVar] -= Proj_Mean_GradTurbVar_Edge[iVar]*proj_vector_ij - + (TurbVar_j[iVar]-TurbVar_i[iVar])*proj_vector_ij; + } + } + + FinishResidualCalc(val_residual, Jacobian_i, Jacobian_j, config); + + AD::SetPreaccOut(val_residual, nVar); + AD::EndPreacc(); + +} + +CAvgGrad_TurbSA::CAvgGrad_TurbSA(unsigned short val_nDim, + unsigned short val_nVar, bool correct_grad, + CConfig *config) + : CAvgGrad_Scalar(val_nDim, val_nVar, correct_grad, config), sigma(2./3.) { +} + +CAvgGrad_TurbSA::~CAvgGrad_TurbSA(void) { +} + +void CAvgGrad_TurbSA::ExtraADPreaccIn() { +} + +void CAvgGrad_TurbSA::FinishResidualCalc(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config) { + + /*--- Compute mean effective viscosity ---*/ + + nu_i = Laminar_Viscosity_i/Density_i; + nu_j = Laminar_Viscosity_j/Density_j; + nu_e = 0.5*(nu_i+nu_j+TurbVar_i[0]+TurbVar_j[0]); + + val_residual[0] = nu_e*Proj_Mean_GradTurbVar[0]/sigma; + + /*--- For Jacobians -> Use of TSL approx. to compute derivatives of the gradients ---*/ + + if (implicit) { + Jacobian_i[0][0] = (0.5*Proj_Mean_GradTurbVar[0]-nu_e*proj_vector_ij)/sigma; + Jacobian_j[0][0] = (0.5*Proj_Mean_GradTurbVar[0]+nu_e*proj_vector_ij)/sigma; + } + +} + + +CAvgGrad_TurbSA_Neg::CAvgGrad_TurbSA_Neg(unsigned short val_nDim, + unsigned short val_nVar, + bool correct_grad, + CConfig *config) + : CAvgGrad_Scalar(val_nDim, val_nVar, correct_grad, config), + sigma(2./3.), cn1(16.0), fn(0.0) { +} + +CAvgGrad_TurbSA_Neg::~CAvgGrad_TurbSA_Neg(void) { +} + +void CAvgGrad_TurbSA_Neg::ExtraADPreaccIn() { +} + +void CAvgGrad_TurbSA_Neg::FinishResidualCalc(su2double *val_residual, + su2double **Jacobian_i, + su2double **Jacobian_j, + CConfig *config) { + + /*--- Compute mean effective viscosity ---*/ + + nu_i = Laminar_Viscosity_i/Density_i; + nu_j = Laminar_Viscosity_j/Density_j; + + nu_ij = 0.5*(nu_i+nu_j); + nu_tilde_ij = 0.5*(TurbVar_i[0]+TurbVar_j[0]); + + Xi = nu_tilde_ij/nu_ij; + + if (nu_tilde_ij > 0.0) { + nu_e = nu_ij + nu_tilde_ij; + } + else { + fn = (cn1 + Xi*Xi*Xi)/(cn1 - Xi*Xi*Xi); + nu_e = nu_ij + fn*nu_tilde_ij; + } + + val_residual[0] = nu_e*Proj_Mean_GradTurbVar_Normal[0]/sigma; + + /*--- For Jacobians -> Use of TSL approx. to compute derivatives of the gradients ---*/ + + if (implicit) { + Jacobian_i[0][0] = (0.5*Proj_Mean_GradTurbVar[0]-nu_e*proj_vector_ij)/sigma; + Jacobian_j[0][0] = (0.5*Proj_Mean_GradTurbVar[0]+nu_e*proj_vector_ij)/sigma; + } + +} + +CAvgGrad_TurbSST::CAvgGrad_TurbSST(unsigned short val_nDim, + unsigned short val_nVar, + const su2double *constants, + bool correct_grad, + CConfig *config) + : CAvgGrad_Scalar(val_nDim, val_nVar, correct_grad, config) { + + sigma_k1 = constants[0]; + sigma_om1 = constants[2]; + sigma_k2 = constants[1]; + sigma_om2 = constants[3]; + + F1_i = 0.0; F1_j = 0.0; + diff_kine = 0.0; + diff_omega = 0.0; + +} + +CAvgGrad_TurbSST::~CAvgGrad_TurbSST(void) { +} + +void CAvgGrad_TurbSST::ExtraADPreaccIn() { + AD::SetPreaccIn(F1_i); AD::SetPreaccIn(F1_j); +} + +void CAvgGrad_TurbSST::FinishResidualCalc(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config) { + + su2double sigma_kine_i, sigma_kine_j, sigma_omega_i, sigma_omega_j; + su2double diff_i_kine, diff_i_omega, diff_j_kine, diff_j_omega; + + /*--- Compute the blended constant for the viscous terms ---*/ + sigma_kine_i = F1_i*sigma_k1 + (1.0 - F1_i)*sigma_k2; + sigma_kine_j = F1_j*sigma_k1 + (1.0 - F1_j)*sigma_k2; + sigma_omega_i = F1_i*sigma_om1 + (1.0 - F1_i)*sigma_om2; + sigma_omega_j = F1_j*sigma_om1 + (1.0 - F1_j)*sigma_om2; + + /*--- Compute mean effective viscosity ---*/ + diff_i_kine = Laminar_Viscosity_i + sigma_kine_i*Eddy_Viscosity_i; + diff_j_kine = Laminar_Viscosity_j + sigma_kine_j*Eddy_Viscosity_j; + diff_i_omega = Laminar_Viscosity_i + sigma_omega_i*Eddy_Viscosity_i; + diff_j_omega = Laminar_Viscosity_j + sigma_omega_j*Eddy_Viscosity_j; + + diff_kine = 0.5*(diff_i_kine + diff_j_kine); + diff_omega = 0.5*(diff_i_omega + diff_j_omega); + + val_residual[0] = diff_kine*Proj_Mean_GradTurbVar[0]; + val_residual[1] = diff_omega*Proj_Mean_GradTurbVar[1]; + + /*--- For Jacobians -> Use of TSL approx. to compute derivatives of the gradients ---*/ + if (implicit) { + Jacobian_i[0][0] = -diff_kine*proj_vector_ij/Density_i; Jacobian_i[0][1] = 0.0; + Jacobian_i[1][0] = 0.0; Jacobian_i[1][1] = -diff_omega*proj_vector_ij/Density_i; + + Jacobian_j[0][0] = diff_kine*proj_vector_ij/Density_j; Jacobian_j[0][1] = 0.0; + Jacobian_j[1][0] = 0.0; Jacobian_j[1][1] = diff_omega*proj_vector_ij/Density_j; + } + +} diff --git a/SU2_CFD/src/numerics/turbulent/turb_sources.cpp b/SU2_CFD/src/numerics/turbulent/turb_sources.cpp new file mode 100644 index 000000000000..75ca147f8ad5 --- /dev/null +++ b/SU2_CFD/src/numerics/turbulent/turb_sources.cpp @@ -0,0 +1,1152 @@ +/*! + * \file turb_sources.cpp + * \brief Implementation of numerics classes for integration of + * turbulence source-terms. + * \author F. Palacios, T. Economon + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../include/numerics/turbulent/turb_sources.hpp" + +CSourcePieceWise_TurbSA::CSourcePieceWise_TurbSA(unsigned short val_nDim, unsigned short val_nVar, + CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); + rotating_frame = config->GetRotating_Frame(); + transition = (config->GetKind_Trans_Model() == BC); + + /*--- Spalart-Allmaras closure constants ---*/ + + cv1_3 = pow(7.1, 3.0); + k2 = pow(0.41, 2.0); + cb1 = 0.1355; + cw2 = 0.3; + ct3 = 1.2; + ct4 = 0.5; + cw3_6 = pow(2.0, 6.0); + sigma = 2./3.; + cb2 = 0.622; + cb2_sigma = cb2/sigma; + cw1 = cb1/k2+(1.0+cb2)/sigma; + +} + +CSourcePieceWise_TurbSA::~CSourcePieceWise_TurbSA(void) { } + +void CSourcePieceWise_TurbSA::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, + su2double **val_Jacobian_j, CConfig *config) { + +// AD::StartPreacc(); +// AD::SetPreaccIn(V_i, nDim+6); +// AD::SetPreaccIn(Vorticity_i, nDim); +// AD::SetPreaccIn(StrainMag_i); +// AD::SetPreaccIn(TurbVar_i[0]); +// AD::SetPreaccIn(TurbVar_Grad_i[0], nDim); +// AD::SetPreaccIn(Volume); AD::SetPreaccIn(dist_i); + +// BC Transition Model variables + su2double vmag, rey, re_theta, re_theta_t, re_v; + su2double tu , nu_cr, nu_t, nu_BC, chi_1, chi_2, term1, term2, term_exponential; + + if (incompressible) { + Density_i = V_i[nDim+2]; + Laminar_Viscosity_i = V_i[nDim+4]; + } + else { + Density_i = V_i[nDim+2]; + Laminar_Viscosity_i = V_i[nDim+5]; + } + + val_residual[0] = 0.0; + Production = 0.0; + Destruction = 0.0; + CrossProduction = 0.0; + val_Jacobian_i[0][0] = 0.0; + + gamma_BC = 0.0; + vmag = 0.0; + tu = config->GetTurbulenceIntensity_FreeStream(); + rey = config->GetReynolds(); + + if (nDim==2) { + vmag = sqrt(V_i[1]*V_i[1]+V_i[2]*V_i[2]); + } + else if (nDim==3) { + vmag = sqrt(V_i[1]*V_i[1]+V_i[2]*V_i[2]+V_i[3]*V_i[3]); + } + + /*--- Evaluate Omega ---*/ + + Omega = sqrt(Vorticity_i[0]*Vorticity_i[0] + Vorticity_i[1]*Vorticity_i[1] + Vorticity_i[2]*Vorticity_i[2]); + + /*--- Rotational correction term ---*/ + + if (rotating_frame) { Omega += 2.0*min(0.0, StrainMag_i-Omega); } + + if (dist_i > 1e-10) { + + /*--- Production term ---*/ + + dist_i_2 = dist_i*dist_i; + nu = Laminar_Viscosity_i/Density_i; + Ji = TurbVar_i[0]/nu; + Ji_2 = Ji*Ji; + Ji_3 = Ji_2*Ji; + fv1 = Ji_3/(Ji_3+cv1_3); + fv2 = 1.0 - Ji/(1.0+Ji*fv1); + ft2 = ct3*exp(-ct4*Ji_2); + S = Omega; + inv_k2_d2 = 1.0/(k2*dist_i_2); + + Shat = S + TurbVar_i[0]*fv2*inv_k2_d2; + Shat = max(Shat, 1.0e-10); + inv_Shat = 1.0/Shat; + +// Original SA model +// Production = cb1*(1.0-ft2)*Shat*TurbVar_i[0]*Volume; + + if (transition) { + +// BC model constants + chi_1 = 0.002; + chi_2 = 5.0; + + nu_t = (TurbVar_i[0]*fv1); //S-A variable + nu_cr = chi_2/rey; + nu_BC = (nu_t)/(vmag*dist_i); + + re_v = ((Density_i*pow(dist_i,2.))/(Laminar_Viscosity_i))*Omega; + re_theta = re_v/2.193; + re_theta_t = (803.73 * pow((tu + 0.6067),-1.027)); //MENTER correlation + //re_theta_t = 163.0 + exp(6.91-tu); //ABU-GHANNAM & SHAW correlation + + term1 = sqrt(max(re_theta-re_theta_t,0.)/(chi_1*re_theta_t)); + term2 = sqrt(max(nu_BC-nu_cr,0.)/(nu_cr)); + term_exponential = (term1 + term2); + gamma_BC = 1.0 - exp(-term_exponential); + + Production = gamma_BC*cb1*Shat*TurbVar_i[0]*Volume; + } + else { + Production = cb1*Shat*TurbVar_i[0]*Volume; + } + + /*--- Destruction term ---*/ + + r = min(TurbVar_i[0]*inv_Shat*inv_k2_d2,10.0); + g = r + cw2*(pow(r,6.0)-r); + g_6 = pow(g,6.0); + glim = pow((1.0+cw3_6)/(g_6+cw3_6),1.0/6.0); + fw = g*glim; + +// Original SA model +// Destruction = (cw1*fw-cb1*ft2/k2)*TurbVar_i[0]*TurbVar_i[0]/dist_i_2*Volume; + + Destruction = cw1*fw*TurbVar_i[0]*TurbVar_i[0]/dist_i_2*Volume; + + /*--- Diffusion term ---*/ + + norm2_Grad = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + norm2_Grad += TurbVar_Grad_i[0][iDim]*TurbVar_Grad_i[0][iDim]; + + CrossProduction = cb2_sigma*norm2_Grad*Volume; + + val_residual[0] = Production - Destruction + CrossProduction; + + /*--- Implicit part, production term ---*/ + + dfv1 = 3.0*Ji_2*cv1_3/(nu*pow(Ji_3+cv1_3,2.)); + dfv2 = -(1/nu-Ji_2*dfv1)/pow(1.+Ji*fv1,2.); + if ( Shat <= 1.0e-10 ) dShat = 0.0; + else dShat = (fv2+TurbVar_i[0]*dfv2)*inv_k2_d2; + + if (transition) { + val_Jacobian_i[0][0] += gamma_BC*cb1*(TurbVar_i[0]*dShat+Shat)*Volume; + } + else { + val_Jacobian_i[0][0] += cb1*(TurbVar_i[0]*dShat+Shat)*Volume; + } + + /*--- Implicit part, destruction term ---*/ + + dr = (Shat-TurbVar_i[0]*dShat)*inv_Shat*inv_Shat*inv_k2_d2; + if (r == 10.0) dr = 0.0; + dg = dr*(1.+cw2*(6.0*pow(r,5.0)-1.0)); + dfw = dg*glim*(1.-g_6/(g_6+cw3_6)); + val_Jacobian_i[0][0] -= cw1*(dfw*TurbVar_i[0] + 2.0*fw)*TurbVar_i[0]/dist_i_2*Volume; + + } + +// AD::SetPreaccOut(val_residual[0]); +// AD::EndPreacc(); + +} + +CSourcePieceWise_TurbSA_COMP::CSourcePieceWise_TurbSA_COMP(unsigned short val_nDim, unsigned short val_nVar, + CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); + rotating_frame = config->GetRotating_Frame(); + + /*--- Spalart-Allmaras closure constants ---*/ + + cv1_3 = pow(7.1, 3.0); + k2 = pow(0.41, 2.0); + cb1 = 0.1355; + cw2 = 0.3; + ct3 = 1.2; + ct4 = 0.5; + cw3_6 = pow(2.0, 6.0); + sigma = 2./3.; + cb2 = 0.622; + cb2_sigma = cb2/sigma; + cw1 = cb1/k2+(1.0+cb2)/sigma; + c5 = 3.5; + +} + +CSourcePieceWise_TurbSA_COMP::~CSourcePieceWise_TurbSA_COMP(void) { } + +void CSourcePieceWise_TurbSA_COMP::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, + su2double **val_Jacobian_j, CConfig *config) { + + // AD::StartPreacc(); + // AD::SetPreaccIn(V_i, nDim+6); + // AD::SetPreaccIn(Vorticity_i, nDim); + // AD::SetPreaccIn(StrainMag_i); + // AD::SetPreaccIn(TurbVar_i[0]); + // AD::SetPreaccIn(TurbVar_Grad_i[0], nDim); + // AD::SetPreaccIn(Volume); AD::SetPreaccIn(dist_i); + + if (incompressible) { + Density_i = V_i[nDim+2]; + Laminar_Viscosity_i = V_i[nDim+4]; + } + else { + Density_i = V_i[nDim+2]; + Laminar_Viscosity_i = V_i[nDim+5]; + } + + val_residual[0] = 0.0; + Production = 0.0; + Destruction = 0.0; + CrossProduction = 0.0; + val_Jacobian_i[0][0] = 0.0; + + /*--- Evaluate Omega ---*/ + + Omega = sqrt(Vorticity_i[0]*Vorticity_i[0] + Vorticity_i[1]*Vorticity_i[1] + Vorticity_i[2]*Vorticity_i[2]); + + /*--- Rotational correction term ---*/ + + if (rotating_frame) { Omega += 2.0*min(0.0, StrainMag_i-Omega); } + + if (dist_i > 1e-10) { + + /*--- Production term ---*/ + + dist_i_2 = dist_i*dist_i; + nu = Laminar_Viscosity_i/Density_i; + Ji = TurbVar_i[0]/nu; + Ji_2 = Ji*Ji; + Ji_3 = Ji_2*Ji; + fv1 = Ji_3/(Ji_3+cv1_3); + fv2 = 1.0 - Ji/(1.0+Ji*fv1); + ft2 = ct3*exp(-ct4*Ji_2); + S = Omega; + inv_k2_d2 = 1.0/(k2*dist_i_2); + + Shat = S + TurbVar_i[0]*fv2*inv_k2_d2; + Shat = max(Shat, 1.0e-10); + inv_Shat = 1.0/Shat; + + /*--- Production term ---*/; + + Production = cb1*Shat*TurbVar_i[0]*Volume; + + /*--- Destruction term ---*/ + + r = min(TurbVar_i[0]*inv_Shat*inv_k2_d2,10.0); + g = r + cw2*(pow(r,6.0)-r); + g_6 = pow(g,6.0); + glim = pow((1.0+cw3_6)/(g_6+cw3_6),1.0/6.0); + fw = g*glim; + + Destruction = cw1*fw*TurbVar_i[0]*TurbVar_i[0]/dist_i_2*Volume; + + /*--- Diffusion term ---*/ + + norm2_Grad = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + norm2_Grad += TurbVar_Grad_i[0][iDim]*TurbVar_Grad_i[0][iDim]; + + CrossProduction = cb2_sigma*norm2_Grad*Volume; + + val_residual[0] = Production - Destruction + CrossProduction; + + /*--- Compressibility Correction term ---*/ + Pressure_i = V_i[nDim+1]; + SoundSpeed_i = sqrt(Pressure_i*Gamma/Density_i); + aux_cc=0; + for(iDim=0;iDimGetKind_Regime() == INCOMPRESSIBLE); + rotating_frame = config->GetRotating_Frame(); + + /*--- Spalart-Allmaras closure constants ---*/ + + cv1_3 = pow(7.1, 3.0); + k2 = pow(0.41, 2.0); + cb1 = 0.1355; + cw2 = 0.3; + ct3 = 1.2; + ct4 = 0.5; + cw3_6 = pow(2.0, 6.0); + sigma = 2./3.; + cb2 = 0.622; + cb2_sigma = cb2/sigma; + cw1 = cb1/k2+(1.0+cb2)/sigma; + +} + +CSourcePieceWise_TurbSA_E::~CSourcePieceWise_TurbSA_E(void) { } + +void CSourcePieceWise_TurbSA_E::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, + su2double **val_Jacobian_j, CConfig *config) { + + // AD::StartPreacc(); + // AD::SetPreaccIn(V_i, nDim+6); + // AD::SetPreaccIn(Vorticity_i, nDim); + // AD::SetPreaccIn(StrainMag_i); + // AD::SetPreaccIn(TurbVar_i[0]); + // AD::SetPreaccIn(TurbVar_Grad_i[0], nDim); + // AD::SetPreaccIn(Volume); AD::SetPreaccIn(dist_i); + + if (incompressible) { + Density_i = V_i[nDim+2]; + Laminar_Viscosity_i = V_i[nDim+4]; + } + else { + Density_i = V_i[nDim+2]; + Laminar_Viscosity_i = V_i[nDim+5]; + } + + val_residual[0] = 0.0; + Production = 0.0; + Destruction = 0.0; + CrossProduction = 0.0; + val_Jacobian_i[0][0] = 0.0; + + /* + From NASA Turbulence model site. http://turbmodels.larc.nasa.gov/spalart.html + This form was developed primarily to improve the near-wall numerical behavior of the model (i.e., the goal was to improve the convergence behavior). The reference is: + Edwards, J. R. and Chandra, S. "Comparison of Eddy Viscosity-Transport Turbulence Models for Three-Dimensional, Shock-Separated Flowfields," AIAA Journal, Vol. 34, No. 4, 1996, pp. 756-763. + In this modificaton Omega is replaced by Strain Rate + */ + + /*--- Evaluate Omega, here Omega is the Strain Rate ---*/ + + Sbar = 0.0; + for(iDim=0;iDim 1e-10) { + + /*--- Production term ---*/ + + dist_i_2 = dist_i*dist_i; + nu = Laminar_Viscosity_i/Density_i; + Ji = TurbVar_i[0]/nu; + Ji_2 = Ji*Ji; + Ji_3 = Ji_2*Ji; + fv1 = Ji_3/(Ji_3+cv1_3); + fv2 = 1.0 - Ji/(1.0+Ji*fv1); + ft2 = ct3*exp(-ct4*Ji_2); + S = Omega; + inv_k2_d2 = 1.0/(k2*dist_i_2); + + //Shat = S + TurbVar_i[0]*fv2*inv_k2_d2; + Shat = max(S*((1.0/max(Ji,1.0e-16))+fv1),1.0e-16); + + Shat = max(Shat, 1.0e-10); + inv_Shat = 1.0/Shat; + + /*--- Production term ---*/; + + Production = cb1*Shat*TurbVar_i[0]*Volume; + + /*--- Destruction term ---*/ + + r = min(TurbVar_i[0]*inv_Shat*inv_k2_d2,10.0); + r=tanh(r)/tanh(1.0); + + g = r + cw2*(pow(r,6.0)-r); + g_6 = pow(g,6.0); + glim = pow((1.0+cw3_6)/(g_6+cw3_6),1.0/6.0); + fw = g*glim; + + Destruction = cw1*fw*TurbVar_i[0]*TurbVar_i[0]/dist_i_2*Volume; + + /*--- Diffusion term ---*/ + + norm2_Grad = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + norm2_Grad += TurbVar_Grad_i[0][iDim]*TurbVar_Grad_i[0][iDim]; + + CrossProduction = cb2_sigma*norm2_Grad*Volume; + + val_residual[0] = Production - Destruction + CrossProduction; + + /*--- Implicit part, production term ---*/ + + dfv1 = 3.0*Ji_2*cv1_3/(nu*pow(Ji_3+cv1_3,2.)); + dfv2 = -(1/nu-Ji_2*dfv1)/pow(1.+Ji*fv1,2.); + + if ( Shat <= 1.0e-10 ) dShat = 0.0; + else dShat = -S*pow(Ji,-2.0)/nu + S*dfv1; + val_Jacobian_i[0][0] += cb1*(TurbVar_i[0]*dShat+Shat)*Volume; + + /*--- Implicit part, destruction term ---*/ + + dr = (Shat-TurbVar_i[0]*dShat)*inv_Shat*inv_Shat*inv_k2_d2; + dr=(1-pow(tanh(r),2.0))*(dr)/tanh(1.0); + dg = dr*(1.+cw2*(6.0*pow(r,5.0)-1.0)); + dfw = dg*glim*(1.-g_6/(g_6+cw3_6)); + val_Jacobian_i[0][0] -= cw1*(dfw*TurbVar_i[0] + 2.0*fw)*TurbVar_i[0]/dist_i_2*Volume; + + } + + // AD::SetPreaccOut(val_residual[0]); + // AD::EndPreacc(); + +} + +CSourcePieceWise_TurbSA_E_COMP::CSourcePieceWise_TurbSA_E_COMP(unsigned short val_nDim, unsigned short val_nVar, + CConfig *config) : CNumerics(val_nDim, val_nVar, config) { + + incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); + rotating_frame = config->GetRotating_Frame(); + + /*--- Spalart-Allmaras closure constants ---*/ + + cv1_3 = pow(7.1, 3.0); + k2 = pow(0.41, 2.0); + cb1 = 0.1355; + cw2 = 0.3; + ct3 = 1.2; + ct4 = 0.5; + cw3_6 = pow(2.0, 6.0); + sigma = 2./3.; + cb2 = 0.622; + cb2_sigma = cb2/sigma; + cw1 = cb1/k2+(1.0+cb2)/sigma; + +} + +CSourcePieceWise_TurbSA_E_COMP::~CSourcePieceWise_TurbSA_E_COMP(void) { } + +void CSourcePieceWise_TurbSA_E_COMP::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, + su2double **val_Jacobian_j, CConfig *config) { + + // AD::StartPreacc(); + // AD::SetPreaccIn(V_i, nDim+6); + // AD::SetPreaccIn(Vorticity_i, nDim); + // AD::SetPreaccIn(StrainMag_i); + // AD::SetPreaccIn(TurbVar_i[0]); + // AD::SetPreaccIn(TurbVar_Grad_i[0], nDim); + // AD::SetPreaccIn(Volume); AD::SetPreaccIn(dist_i); + + if (incompressible) { + Density_i = V_i[nDim+2]; + Laminar_Viscosity_i = V_i[nDim+4]; + } + else { + Density_i = V_i[nDim+2]; + Laminar_Viscosity_i = V_i[nDim+5]; + } + + val_residual[0] = 0.0; + Production = 0.0; + Destruction = 0.0; + CrossProduction = 0.0; + val_Jacobian_i[0][0] = 0.0; + + /* + From NASA Turbulence model site. http://turbmodels.larc.nasa.gov/spalart.html + This form was developed primarily to improve the near-wall numerical behavior of the model (i.e., the goal was to improve the convergence behavior). The reference is: + Edwards, J. R. and Chandra, S. "Comparison of Eddy Viscosity-Transport Turbulence Models for Three-Dimensional, Shock-Separated Flowfields," AIAA Journal, Vol. 34, No. 4, 1996, pp. 756-763. + In this modificaton Omega is replaced by Strain Rate + */ + + /*--- Evaluate Omega, here Omega is the Strain Rate ---*/ + + Sbar = 0.0; + for(iDim=0;iDim 1e-10) { + + /*--- Production term ---*/ + + dist_i_2 = dist_i*dist_i; + nu = Laminar_Viscosity_i/Density_i; + Ji = TurbVar_i[0]/nu; + Ji_2 = Ji*Ji; + Ji_3 = Ji_2*Ji; + fv1 = Ji_3/(Ji_3+cv1_3); + fv2 = 1.0 - Ji/(1.0+Ji*fv1); + ft2 = ct3*exp(-ct4*Ji_2); + S = Omega; + inv_k2_d2 = 1.0/(k2*dist_i_2); + + Shat = max(S*((1.0/max(Ji,1.0e-16))+fv1),1.0e-16); + + Shat = max(Shat, 1.0e-10); + inv_Shat = 1.0/Shat; + + /*--- Production term ---*/; + + Production = cb1*Shat*TurbVar_i[0]*Volume; + + /*--- Destruction term ---*/ + + r = min(TurbVar_i[0]*inv_Shat*inv_k2_d2,10.0); + r=tanh(r)/tanh(1.0); + + g = r + cw2*(pow(r,6.0)-r); + g_6 = pow(g,6.0); + glim = pow((1.0+cw3_6)/(g_6+cw3_6),1.0/6.0); + fw = g*glim; + + Destruction = cw1*fw*TurbVar_i[0]*TurbVar_i[0]/dist_i_2*Volume; + + /*--- Diffusion term ---*/ + + norm2_Grad = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + norm2_Grad += TurbVar_Grad_i[0][iDim]*TurbVar_Grad_i[0][iDim]; + + CrossProduction = cb2_sigma*norm2_Grad*Volume; + + val_residual[0] = Production - Destruction + CrossProduction; + + /*--- Compressibility Correction term ---*/ + Pressure_i = V_i[nDim+1]; + SoundSpeed_i = sqrt(Pressure_i*Gamma/Density_i); + aux_cc=0; + for(iDim=0;iDimGetKind_Regime() == INCOMPRESSIBLE); + rotating_frame = config->GetRotating_Frame(); + + /*--- Negative Spalart-Allmaras closure constants ---*/ + + cv1_3 = pow(7.1, 3.0); + k2 = pow(0.41, 2.0); + cb1 = 0.1355; + cw2 = 0.3; + ct3 = 1.2; + ct4 = 0.5; + cw3_6 = pow(2.0, 6.0); + sigma = 2./3.; + cb2 = 0.622; + cb2_sigma = cb2/sigma; + cw1 = cb1/k2+(1.0+cb2)/sigma; + +} + +CSourcePieceWise_TurbSA_Neg::~CSourcePieceWise_TurbSA_Neg(void) { + +} + +void CSourcePieceWise_TurbSA_Neg::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, + su2double **val_Jacobian_j, CConfig *config) { + +// AD::StartPreacc(); +// AD::SetPreaccIn(V_i, nDim+6); +// AD::SetPreaccIn(Vorticity_i, nDim); +// AD::SetPreaccIn(StrainMag_i); +// AD::SetPreaccIn(TurbVar_i[0]); +// AD::SetPreaccIn(TurbVar_Grad_i[0], nDim); +// AD::SetPreaccIn(Volume); AD::SetPreaccIn(dist_i); + + if (incompressible) { + Density_i = V_i[nDim+2]; + Laminar_Viscosity_i = V_i[nDim+4]; + } + else { + Density_i = V_i[nDim+2]; + Laminar_Viscosity_i = V_i[nDim+5]; + } + + val_residual[0] = 0.0; + Production = 0.0; + Destruction = 0.0; + CrossProduction = 0.0; + val_Jacobian_i[0][0] = 0.0; + + /*--- Evaluate Omega ---*/ + + Omega = sqrt(Vorticity_i[0]*Vorticity_i[0] + Vorticity_i[1]*Vorticity_i[1] + Vorticity_i[2]*Vorticity_i[2]); + + /*--- Rotational correction term ---*/ + + if (rotating_frame) { Omega += 2.0*min(0.0, StrainMag_i-Omega); } + + if (dist_i > 1e-10) { + + if (TurbVar_i[0] > 0.0) { + + /*--- Production term ---*/ + + dist_i_2 = dist_i*dist_i; + nu = Laminar_Viscosity_i/Density_i; + Ji = TurbVar_i[0]/nu; + Ji_2 = Ji*Ji; + Ji_3 = Ji_2*Ji; + fv1 = Ji_3/(Ji_3+cv1_3); + fv2 = 1.0 - Ji/(1.0+Ji*fv1); + ft2 = ct3*exp(-ct4*Ji_2); + S = Omega; + inv_k2_d2 = 1.0/(k2*dist_i_2); + + Shat = S + TurbVar_i[0]*fv2*inv_k2_d2; + Shat = max(Shat, 1.0e-10); + inv_Shat = 1.0/Shat; + + /*--- Production term ---*/; + + // Original SA model + // Production = cb1*(1.0-ft2)*Shat*TurbVar_i[0]*Volume; + + Production = cb1*Shat*TurbVar_i[0]*Volume; + + /*--- Destruction term ---*/ + + r = min(TurbVar_i[0]*inv_Shat*inv_k2_d2,10.0); + g = r + cw2*(pow(r,6.0)-r); + g_6 = pow(g,6.0); + glim = pow((1.0+cw3_6)/(g_6+cw3_6),1.0/6.0); + fw = g*glim; + + Destruction = cw1*fw*TurbVar_i[0]*TurbVar_i[0]/dist_i_2*Volume; + + /*--- Diffusion term ---*/ + + norm2_Grad = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + norm2_Grad += TurbVar_Grad_i[0][iDim]*TurbVar_Grad_i[0][iDim]; + + CrossProduction = cb2_sigma*norm2_Grad*Volume; + + val_residual[0] = Production - Destruction + CrossProduction; + + /*--- Implicit part, production term ---*/ + + dfv1 = 3.0*Ji_2*cv1_3/(nu*pow(Ji_3+cv1_3,2.)); + dfv2 = -(1/nu-Ji_2*dfv1)/pow(1.+Ji*fv1,2.); + if ( Shat <= 1.0e-10 ) dShat = 0.0; + else dShat = (fv2+TurbVar_i[0]*dfv2)*inv_k2_d2; + val_Jacobian_i[0][0] += cb1*(TurbVar_i[0]*dShat+Shat)*Volume; + + /*--- Implicit part, destruction term ---*/ + + dr = (Shat-TurbVar_i[0]*dShat)*inv_Shat*inv_Shat*inv_k2_d2; + if (r == 10.0) dr = 0.0; + dg = dr*(1.+cw2*(6.0*pow(r,5.0)-1.0)); + dfw = dg*glim*(1.-g_6/(g_6+cw3_6)); + val_Jacobian_i[0][0] -= cw1*(dfw*TurbVar_i[0] + 2.0*fw)*TurbVar_i[0]/dist_i_2*Volume; + + } + + else { + + /*--- Production term ---*/ + + dist_i_2 = dist_i*dist_i; + + /*--- Production term ---*/; + + Production = cb1*(1.0-ct3)*Omega*TurbVar_i[0]*Volume; + + /*--- Destruction term ---*/ + + Destruction = cw1*TurbVar_i[0]*TurbVar_i[0]/dist_i_2*Volume; + + /*--- Diffusion term ---*/ + + norm2_Grad = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + norm2_Grad += TurbVar_Grad_i[0][iDim]*TurbVar_Grad_i[0][iDim]; + + CrossProduction = cb2_sigma*norm2_Grad*Volume; + + val_residual[0] = Production + Destruction + CrossProduction; + + /*--- Implicit part, production term ---*/ + + val_Jacobian_i[0][0] += cb1*(1.0-ct3)*Omega*Volume; + + /*--- Implicit part, destruction term ---*/ + + val_Jacobian_i[0][0] += 2.0*cw1*TurbVar_i[0]/dist_i_2*Volume; + + } + + } + +// AD::SetPreaccOut(val_residual, nVar); +// AD::EndPreacc(); +} + +CSourcePieceWise_TurbSST::CSourcePieceWise_TurbSST(unsigned short val_nDim, unsigned short val_nVar, const su2double *constants, + su2double val_kine_Inf, su2double val_omega_Inf, CConfig *config) + : CNumerics(val_nDim, val_nVar, config) { + + incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); + sustaining_terms = (config->GetKind_Turb_Model() == SST_SUST); + + /*--- Closure constants ---*/ + beta_star = constants[6]; + sigma_omega_1 = constants[2]; + sigma_omega_2 = constants[3]; + beta_1 = constants[4]; + beta_2 = constants[5]; + alfa_1 = constants[8]; + alfa_2 = constants[9]; + a1 = constants[7]; + + /*--- Set the ambient values of k and omega to the free stream values. ---*/ + kAmb = val_kine_Inf; + omegaAmb = val_omega_Inf; +} + +CSourcePieceWise_TurbSST::~CSourcePieceWise_TurbSST(void) { } + +void CSourcePieceWise_TurbSST::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, + su2double **val_Jacobian_j, CConfig *config) { + + AD::StartPreacc(); + AD::SetPreaccIn(StrainMag_i); + AD::SetPreaccIn(TurbVar_i, nVar); + AD::SetPreaccIn(TurbVar_Grad_i, nVar, nDim); + AD::SetPreaccIn(Volume); AD::SetPreaccIn(dist_i); + AD::SetPreaccIn(F1_i); AD::SetPreaccIn(F2_i); AD::SetPreaccIn(CDkw_i); + AD::SetPreaccIn(PrimVar_Grad_i, nDim+1, nDim); + + unsigned short iDim; + su2double alfa_blended, beta_blended; + su2double diverg, pk, pw, zeta; + + if (incompressible) { + AD::SetPreaccIn(V_i, nDim+6); + + Density_i = V_i[nDim+2]; + Laminar_Viscosity_i = V_i[nDim+4]; + Eddy_Viscosity_i = V_i[nDim+5]; + } + else { + AD::SetPreaccIn(V_i, nDim+7); + + Density_i = V_i[nDim+2]; + Laminar_Viscosity_i = V_i[nDim+5]; + Eddy_Viscosity_i = V_i[nDim+6]; + } + + val_residual[0] = 0.0; val_residual[1] = 0.0; + val_Jacobian_i[0][0] = 0.0; val_Jacobian_i[0][1] = 0.0; + val_Jacobian_i[1][0] = 0.0; val_Jacobian_i[1][1] = 0.0; + + /*--- Computation of blended constants for the source terms---*/ + + alfa_blended = F1_i*alfa_1 + (1.0 - F1_i)*alfa_2; + beta_blended = F1_i*beta_1 + (1.0 - F1_i)*beta_2; + + if (dist_i > 1e-10) { + + /*--- Production ---*/ + + diverg = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + diverg += PrimVar_Grad_i[iDim+1][iDim]; + + /* if using UQ methodolgy, calculate production using perturbed Reynolds stress matrix */ + + if (using_uq){ + SetReynoldsStressMatrix(TurbVar_i[0]); + SetPerturbedRSM(TurbVar_i[0], config); + SetPerturbedStrainMag(TurbVar_i[0]); + pk = Eddy_Viscosity_i*PerturbedStrainMag*PerturbedStrainMag + - 2.0/3.0*Density_i*TurbVar_i[0]*diverg; + } + else { + pk = Eddy_Viscosity_i*StrainMag_i*StrainMag_i - 2.0/3.0*Density_i*TurbVar_i[0]*diverg; + } + + + pk = min(pk,20.0*beta_star*Density_i*TurbVar_i[1]*TurbVar_i[0]); + pk = max(pk,0.0); + + zeta = max(TurbVar_i[1], StrainMag_i*F2_i/a1); + + /* if using UQ methodolgy, calculate production using perturbed Reynolds stress matrix */ + + if (using_uq){ + pw = PerturbedStrainMag * PerturbedStrainMag - 2.0/3.0*zeta*diverg; + } + else { + pw = StrainMag_i*StrainMag_i - 2.0/3.0*zeta*diverg; + } + pw = alfa_blended*Density_i*max(pw,0.0); + + /*--- Sustaining terms, if desired. Note that if the production terms are + larger equal than the sustaining terms, the original formulation is + obtained again. This is in contrast to the version in literature + where the sustaining terms are simply added. This latter approach could + lead to problems for very big values of the free-stream turbulence + intensity. ---*/ + + if ( sustaining_terms ) { + const su2double sust_k = beta_star*Density_i*kAmb*omegaAmb; + const su2double sust_w = beta_blended*Density_i*omegaAmb*omegaAmb; + + pk = max(pk, sust_k); + pw = max(pw, sust_w); + } + + /*--- Add the production terms to the residuals. ---*/ + + val_residual[0] += pk*Volume; + val_residual[1] += pw*Volume; + + /*--- Dissipation ---*/ + + val_residual[0] -= beta_star*Density_i*TurbVar_i[1]*TurbVar_i[0]*Volume; + val_residual[1] -= beta_blended*Density_i*TurbVar_i[1]*TurbVar_i[1]*Volume; + + /*--- Cross diffusion ---*/ + + val_residual[1] += (1.0 - F1_i)*CDkw_i*Volume; + + /*--- Implicit part ---*/ + + val_Jacobian_i[0][0] = -beta_star*TurbVar_i[1]*Volume; + val_Jacobian_i[0][1] = -beta_star*TurbVar_i[0]*Volume; + val_Jacobian_i[1][0] = 0.0; + val_Jacobian_i[1][1] = -2.0*beta_blended*TurbVar_i[1]*Volume; + } + + AD::SetPreaccOut(val_residual, nVar); + AD::EndPreacc(); + +} + +void CSourcePieceWise_TurbSST::GetMeanRateOfStrainMatrix(su2double **S_ij) +{ + /* --- Calculate the rate of strain tensor, using mean velocity gradients --- */ + + if (nDim == 3){ + S_ij[0][0] = PrimVar_Grad_i[1][0]; + S_ij[1][1] = PrimVar_Grad_i[2][1]; + S_ij[2][2] = PrimVar_Grad_i[3][2]; + S_ij[0][1] = 0.5 * (PrimVar_Grad_i[1][1] + PrimVar_Grad_i[2][0]); + S_ij[0][2] = 0.5 * (PrimVar_Grad_i[1][2] + PrimVar_Grad_i[3][0]); + S_ij[1][2] = 0.5 * (PrimVar_Grad_i[2][2] + PrimVar_Grad_i[3][1]); + S_ij[1][0] = S_ij[0][1]; + S_ij[2][1] = S_ij[1][2]; + S_ij[2][0] = S_ij[0][2]; + } + else { + S_ij[0][0] = PrimVar_Grad_i[1][0]; + S_ij[1][1] = PrimVar_Grad_i[2][1]; + S_ij[2][2] = 0.0; + S_ij[0][1] = 0.5 * (PrimVar_Grad_i[1][1] + PrimVar_Grad_i[2][0]); + S_ij[0][2] = 0.0; + S_ij[1][2] = 0.0; + S_ij[1][0] = S_ij[0][1]; + S_ij[2][1] = S_ij[1][2]; + S_ij[2][0] = S_ij[0][2]; + + } +} + +void CSourcePieceWise_TurbSST::SetReynoldsStressMatrix(su2double turb_ke){ + unsigned short iDim, jDim; + su2double **S_ij = new su2double* [3]; + su2double divVel = 0; + su2double TWO3 = 2.0/3.0; + + + + for (iDim = 0; iDim < 3; iDim++){ + S_ij[iDim] = new su2double [3]; + } + + GetMeanRateOfStrainMatrix(S_ij); + + /* --- Using rate of strain matrix, calculate Reynolds stress tensor --- */ + + for (iDim = 0; iDim < 3; iDim++){ + divVel += S_ij[iDim][iDim]; + } + + for (iDim = 0; iDim < 3; iDim++){ + for (jDim = 0; jDim < 3; jDim++){ + MeanReynoldsStress[iDim][jDim] = TWO3 * turb_ke * delta3[iDim][jDim] + - Eddy_Viscosity_i / Density_i * (2 * S_ij[iDim][jDim] - TWO3 * divVel * delta3[iDim][jDim]); + } + } + + for (iDim = 0; iDim < 3; iDim++) + delete [] S_ij[iDim]; + delete [] S_ij; +} + +void CSourcePieceWise_TurbSST::SetPerturbedRSM(su2double turb_ke, CConfig *config){ + + unsigned short iDim,jDim; + + /* --- Calculate anisotropic part of Reynolds Stress tensor --- */ + + for (iDim = 0; iDim< 3; iDim++){ + for (jDim = 0; jDim < 3; jDim++){ + A_ij[iDim][jDim] = .5 * MeanReynoldsStress[iDim][jDim] / turb_ke - delta3[iDim][jDim] / 3.0; + Eig_Vec[iDim][jDim] = A_ij[iDim][jDim]; + } + } + + /* --- Get ordered eigenvectors and eigenvalues of A_ij --- */ + + EigenDecomposition(A_ij, Eig_Vec, Eig_Val, 3); + + /* compute convex combination coefficients */ + su2double c1c = Eig_Val[2] - Eig_Val[1]; + su2double c2c = 2.0 * (Eig_Val[1] - Eig_Val[0]); + su2double c3c = 3.0 * Eig_Val[0] + 1.0; + + /* define barycentric traingle corner points */ + Corners[0][0] = 1.0; + Corners[0][1] = 0.0; + Corners[1][0] = 0.0; + Corners[1][1] = 0.0; + Corners[2][0] = 0.5; + Corners[2][1] = 0.866025; + + /* define barycentric coordinates */ + Barycentric_Coord[0] = Corners[0][0] * c1c + Corners[1][0] * c2c + Corners[2][0] * c3c; + Barycentric_Coord[1] = Corners[0][1] * c1c + Corners[1][1] * c2c + Corners[2][1] * c3c; + + if (Eig_Val_Comp == 1) { + /* 1C turbulence */ + New_Coord[0] = Corners[0][0]; + New_Coord[1] = Corners[0][1]; + } + else if (Eig_Val_Comp == 2) { + /* 2C turbulence */ + New_Coord[0] = Corners[1][0]; + New_Coord[1] = Corners[1][1]; + } + else if (Eig_Val_Comp == 3) { + /* 3C turbulence */ + New_Coord[0] = Corners[2][0]; + New_Coord[1] = Corners[2][1]; + } + else { + /* 2C turbulence */ + New_Coord[0] = Corners[1][0]; + New_Coord[1] = Corners[1][1]; + } + /* calculate perturbed barycentric coordinates */ + + Barycentric_Coord[0] = Barycentric_Coord[0] + (uq_delta_b) * (New_Coord[0] - Barycentric_Coord[0]); + Barycentric_Coord[1] = Barycentric_Coord[1] + (uq_delta_b) * (New_Coord[1] - Barycentric_Coord[1]); + + /* rebuild c1c,c2c,c3c based on new barycentric coordinates */ + c3c = Barycentric_Coord[1] / Corners[2][1]; + c1c = Barycentric_Coord[0] - Corners[2][0] * c3c; + c2c = 1 - c1c - c3c; + + /* build new anisotropy eigenvalues */ + Eig_Val[0] = (c3c - 1) / 3.0; + Eig_Val[1] = 0.5 *c2c + Eig_Val[0]; + Eig_Val[2] = c1c + Eig_Val[1]; + + /* permute eigenvectors if required */ + if (uq_permute) { + for (iDim=0; iDim<3; iDim++) { + for (jDim=0; jDim<3; jDim++) { + New_Eig_Vec[iDim][jDim] = Eig_Vec[2-iDim][jDim]; + } + } + } + + else { + for (iDim=0; iDim<3; iDim++) { + for (jDim=0; jDim<3; jDim++) { + New_Eig_Vec[iDim][jDim] = Eig_Vec[iDim][jDim]; + } + } + } + + EigenRecomposition(newA_ij, New_Eig_Vec, Eig_Val, 3); + + /* compute perturbed Reynolds stress matrix; use under-relaxation factor (urlx)*/ + for (iDim = 0; iDim< 3; iDim++){ + for (jDim = 0; jDim < 3; jDim++){ + MeanPerturbedRSM[iDim][jDim] = 2.0 * turb_ke * (newA_ij[iDim][jDim] + 1.0/3.0 * delta3[iDim][jDim]); + MeanPerturbedRSM[iDim][jDim] = MeanReynoldsStress[iDim][jDim] + + uq_urlx*(MeanPerturbedRSM[iDim][jDim] - MeanReynoldsStress[iDim][jDim]); + } + } + +} + +void CSourcePieceWise_TurbSST::SetPerturbedStrainMag(su2double turb_ke){ + unsigned short iDim, jDim; + PerturbedStrainMag = 0; + su2double **StrainRate = new su2double* [nDim]; + for (iDim= 0; iDim< nDim; iDim++){ + StrainRate[iDim] = new su2double [nDim]; + } + + /* compute perturbed strain rate tensor */ + + for (iDim = 0; iDim < nDim; iDim++){ + for (jDim =0; jDim < nDim; jDim++){ + StrainRate[iDim][jDim] = MeanPerturbedRSM[iDim][jDim] + - TWO3 * turb_ke * delta[iDim][jDim]; + StrainRate[iDim][jDim] = - StrainRate[iDim][jDim] * Density_i / (2 * Eddy_Viscosity_i); + } + } + + /*--- Add diagonal part ---*/ + + for (iDim = 0; iDim < nDim; iDim++) { + PerturbedStrainMag += pow(StrainRate[iDim][iDim], 2.0); + } + + /*--- Add off diagonals ---*/ + + PerturbedStrainMag += 2.0*pow(StrainRate[1][0], 2.0); + + if (nDim == 3) { + PerturbedStrainMag += 2.0*pow(StrainRate[0][2], 2.0); + PerturbedStrainMag += 2.0*pow(StrainRate[1][2], 2.0); + } + + PerturbedStrainMag = sqrt(2.0*PerturbedStrainMag); + + for (iDim= 0; iDim< nDim; iDim++){ + delete [] StrainRate[iDim]; + } + + delete [] StrainRate; +} diff --git a/SU2_CFD/src/output/COutput.cpp b/SU2_CFD/src/output/COutput.cpp index a04c98c3da31..f6ff5d4c9054 100644 --- a/SU2_CFD/src/output/COutput.cpp +++ b/SU2_CFD/src/output/COutput.cpp @@ -1637,7 +1637,7 @@ void COutput::Postprocess_HistoryData(CConfig *config){ void COutput::Postprocess_HistoryFields(CConfig *config){ map Average; - map AverageGroupName = CCreateMap("BGS_RES", "bgs")("RMS_RES","rms")("MAX_RES", "max"); + map AverageGroupName = {{"BGS_RES", "bgs"},{"RMS_RES","rms"},{"MAX_RES", "max"}}; for (unsigned short iField = 0; iField < historyOutput_List.size(); iField++){ const string &fieldIdentifier = historyOutput_List[iField]; From 118bb2217458019b3f6348d4e43f38b6e6c377bd Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Mon, 27 Jan 2020 16:37:57 +0000 Subject: [PATCH 019/118] update build systems --- SU2_CFD/obj/Makefile.am | 40 ++++++++------- SU2_CFD/src/meson.build | 105 +++++++++------------------------------- 2 files changed, 45 insertions(+), 100 deletions(-) diff --git a/SU2_CFD/obj/Makefile.am b/SU2_CFD/obj/Makefile.am index d5b16380a082..f0df1d234a73 100644 --- a/SU2_CFD/obj/Makefile.am +++ b/SU2_CFD/obj/Makefile.am @@ -63,23 +63,29 @@ libSU2Core_sources = ../src/definition_structure.cpp \ ../src/drivers/CDriver.cpp \ ../src/drivers/CDummyDriver.cpp \ ../src/iteration_structure.cpp \ - ../src/numerics_adjoint_mean.cpp \ - ../src/numerics_adjoint_turbulent.cpp \ - ../src/numerics_direct_heat.cpp \ - ../src/numerics_direct_mean.cpp \ - ../src/numerics_direct_mean_inc.cpp \ - ../src/numerics_direct_transition.cpp \ - ../src/numerics_direct_turbulent.cpp \ - ../src/numerics/elasticity/CFEAElasticity.cpp \ - ../src/numerics/elasticity/CFEALinearElasticity.cpp \ - ../src/numerics/elasticity/CFEAMeshElasticity.cpp \ - ../src/numerics/elasticity/CFEANonlinearElasticity.cpp \ - ../src/numerics/elasticity/CFEM_NeoHookean_Comp.cpp \ - ../src/numerics/elasticity/CFEM_Knowles_NearInc.cpp \ - ../src/numerics/elasticity/CFEM_IdealDE.cpp \ - ../src/numerics/elasticity/CFEM_DielectricElastomer.cpp \ - ../src/numerics_structure.cpp \ - ../src/numerics_template.cpp \ + ../src/numerics/CNumerics.cpp \ + ../src/numerics/template.hpp \ + ../src/numerics/transition.hpp \ + ../src/numerics/heat.hpp \ + ../src/numerics/flow/convection/roe.hpp \ + ../src/numerics/flow/convection/fds.hpp \ + ../src/numerics/flow/convection/fvs.hpp \ + ../src/numerics/flow/convection/cusp.hpp \ + ../src/numerics/flow/convection/hllc.hpp \ + ../src/numerics/flow/convection/ausm_slau.hpp \ + ../src/numerics/flow/convection/centered.hpp \ + ../src/numerics/flow/flow_diffusion.hpp \ + ../src/numerics/flow/flow_sources.hpp \ + ../src/numerics/continuous_adjoint/adj_convection.hpp \ + ../src/numerics/continuous_adjoint/adj_diffusion.hpp \ + ../src/numerics/continuous_adjoint/adj_sources.hpp \ + ../src/numerics/turbulent/turb_convection.hpp \ + ../src/numerics/turbulent/turb_diffusion.hpp \ + ../src/numerics/turbulent/turb_sources.hpp \ + ../src/numerics/elasticity/CFEAElasticity.hpp \ + ../src/numerics/elasticity/CFEALinearElasticity.hpp \ + ../src/numerics/elasticity/CFEANonlinearElasticity.hpp \ + ../src/numerics/elasticity/nonlinear_models.hpp \ ../src/output/filewriter/CCSVFileWriter.cpp \ ../src/output/filewriter/CSTLFileWriter.cpp \ ../src/output/filewriter/CFEMDataSorter.cpp \ diff --git a/SU2_CFD/src/meson.build b/SU2_CFD/src/meson.build index 8056f6799a32..5823d642af52 100644 --- a/SU2_CFD/src/meson.build +++ b/SU2_CFD/src/meson.build @@ -94,89 +94,28 @@ su2_cfd_src += files(['solvers/CAdjEulerSolver.cpp', 'solvers/CTurbSSTSolver.cpp']) su2_cfd_src += files(['numerics/CNumerics.cpp', - 'numerics/template/CSource_Template.cpp', - 'numerics/template/CConvective_Template.cpp', - 'numerics/template/CViscous_Template.cpp', - 'numerics/transition/CAvgGradCorrected_TransLM.cpp', - 'numerics/transition/CUpwLin_TransLM.cpp', - 'numerics/transition/CAvgGrad_TransLM.cpp', - 'numerics/transition/CUpwSca_TransLM.cpp', - 'numerics/transition/CSourcePieceWise_TransLM.cpp', - 'numerics/heat/CCentSca_Heat.cpp', - 'numerics/heat/CUpwSca_Heat.cpp', - 'numerics/heat/CAvgGradCorrected_Heat.cpp', - 'numerics/heat/CAvgGrad_Heat.cpp', - 'numerics/flow/diffusion/CAvgGradInc_Flow.cpp', - 'numerics/flow/diffusion/CAvgGrad_Base.cpp', - 'numerics/flow/diffusion/CAvgGrad_Flow.cpp', - 'numerics/flow/diffusion/CGeneralAvgGrad_Flow.cpp', - 'numerics/flow/convection_upwind/CUpwCUSP_Flow.cpp', - 'numerics/flow/convection_upwind/CUpwMSW_Flow.cpp', - 'numerics/flow/convection_upwind/CUpwAUSMPLUS_SLAU_Base_Flow.cpp', - 'numerics/flow/convection_upwind/CUpwTurkel_Flow.cpp', - 'numerics/flow/convection_upwind/CUpwL2Roe_Flow.cpp', - 'numerics/flow/convection_upwind/CUpwFDSInc_Flow.cpp', - 'numerics/flow/convection_upwind/CUpwHLLC_Flow.cpp', - 'numerics/flow/convection_upwind/CUpwSLAU_Flow.cpp', - 'numerics/flow/convection_upwind/CUpwGeneralRoe_Flow.cpp', - 'numerics/flow/convection_upwind/CUpwAUSMPLUSUP_Flow.cpp', - 'numerics/flow/convection_upwind/CUpwGeneralHLLC_Flow.cpp', - 'numerics/flow/convection_upwind/CUpwRoe_Flow.cpp', - 'numerics/flow/convection_upwind/CUpwAUSMPLUSUP2_Flow.cpp', - 'numerics/flow/convection_upwind/CUpwRoeBase_Flow.cpp', - 'numerics/flow/convection_upwind/CUpwAUSM_Flow.cpp', - 'numerics/flow/convection_upwind/CUpwLMRoe_Flow.cpp', - 'numerics/flow/sources/CSourceWindGust.cpp', - 'numerics/flow/sources/CSourceRotatingFrame_Flow.cpp', - 'numerics/flow/sources/CSourceIncAxisymmetric_Flow.cpp', - 'numerics/flow/sources/CSourceIncBodyForce.cpp', - 'numerics/flow/sources/CSourceIncRotatingFrame_Flow.cpp', - 'numerics/flow/sources/CSourceGravity.cpp', - 'numerics/flow/sources/CSourceBodyForce.cpp', - 'numerics/flow/sources/CSourceAxisymmetric_Flow.cpp', - 'numerics/flow/sources/CSourceBoussinesq.cpp', - 'numerics/flow/convection_centered/CCentBase_Flow.cpp', - 'numerics/flow/convection_centered/CCentJSTInc_Flow.cpp', - 'numerics/flow/convection_centered/CCentJST_KE_Flow.cpp', - 'numerics/flow/convection_centered/CCentJST_Flow.cpp', - 'numerics/flow/convection_centered/CCentLaxInc_Flow.cpp', - 'numerics/flow/convection_centered/CCentLax_Flow.cpp', - 'numerics/elasticity/CFEAMeshElasticity.cpp', - 'numerics/elasticity/CFEM_DielectricElastomer.cpp', - 'numerics/elasticity/CFEALinearElasticity.cpp', - 'numerics/elasticity/CFEAElasticity.cpp', - 'numerics/elasticity/CFEANonlinearElasticity.cpp', - 'numerics/elasticity/CFEM_NeoHookean_Comp.cpp', - 'numerics/elasticity/CFEM_Knowles_NearInc.cpp', - 'numerics/elasticity/CFEM_IdealDE.cpp', - 'numerics/continuous_adjoint/CAvgGradCorrected_AdjFlow.cpp', - 'numerics/continuous_adjoint/CSourceRotatingFrame_AdjFlow.cpp', - 'numerics/continuous_adjoint/CUpwSca_AdjTurb.cpp', - 'numerics/continuous_adjoint/CAvgGradCorrected_AdjTurb.cpp', - 'numerics/continuous_adjoint/CSourceConservative_AdjFlow.cpp', - 'numerics/continuous_adjoint/CSourceAxisymmetric_AdjFlow.cpp', - 'numerics/continuous_adjoint/CSourceConservative_AdjTurb.cpp', - 'numerics/continuous_adjoint/CAvgGrad_AdjFlow.cpp', - 'numerics/continuous_adjoint/CUpwRoe_AdjFlow.cpp', - 'numerics/continuous_adjoint/CSourcePieceWise_AdjTurb.cpp', - 'numerics/continuous_adjoint/CCentLax_AdjFlow.cpp', - 'numerics/continuous_adjoint/CSourceViscous_AdjFlow.cpp', - 'numerics/continuous_adjoint/CAvgGrad_AdjTurb.cpp', - 'numerics/continuous_adjoint/CUpwLin_AdjTurb.cpp', - 'numerics/continuous_adjoint/CCentJST_AdjFlow.cpp', - 'numerics/turbulent/CUpwSca_TurbSST.cpp', - 'numerics/turbulent/CSourcePieceWise_TurbSA_E.cpp', - 'numerics/turbulent/CSourcePieceWise_TurbSA.cpp', - 'numerics/turbulent/CSourcePieceWise_TurbSA_Neg.cpp', - 'numerics/turbulent/CAvgGrad_TurbSA.cpp', - 'numerics/turbulent/CSourcePieceWise_TurbSA_E_COMP.cpp', - 'numerics/turbulent/CUpwScalar.cpp', - 'numerics/turbulent/CAvgGrad_TurbSA_Neg.cpp', - 'numerics/turbulent/CSourcePieceWise_TurbSST.cpp', - 'numerics/turbulent/CSourcePieceWise_TurbSA_COMP.cpp', - 'numerics/turbulent/CUpwSca_TurbSA.cpp', - 'numerics/turbulent/CAvgGrad_Scalar.cpp', - 'numerics/turbulent/CAvgGrad_TurbSST.cpp']) + 'numerics/template.hpp', + 'numerics/transition.hpp', + 'numerics/heat.hpp', + 'numerics/flow/convection/roe.hpp', + 'numerics/flow/convection/fds.hpp', + 'numerics/flow/convection/fvs.hpp', + 'numerics/flow/convection/cusp.hpp', + 'numerics/flow/convection/hllc.hpp', + 'numerics/flow/convection/ausm_slau.hpp', + 'numerics/flow/convection/centered.hpp', + 'numerics/flow/flow_diffusion.hpp', + 'numerics/flow/flow_sources.hpp', + 'numerics/continuous_adjoint/adj_convection.hpp', + 'numerics/continuous_adjoint/adj_diffusion.hpp', + 'numerics/continuous_adjoint/adj_sources.hpp', + 'numerics/turbulent/turb_convection.hpp', + 'numerics/turbulent/turb_diffusion.hpp', + 'numerics/turbulent/turb_sources.hpp', + 'numerics/elasticity/CFEAElasticity.hpp', + 'numerics/elasticity/CFEALinearElasticity.hpp', + 'numerics/elasticity/CFEANonlinearElasticity.hpp', + 'numerics/elasticity/nonlinear_models.hpp']) su2_cfd_src += files(['interfaces/CInterface.cpp', 'interfaces/cfd/CConservativeVarsInterface.cpp', From fa5b9c5f1b1d0e3e1af02f500f7ef02290613a8c Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Mon, 27 Jan 2020 16:51:34 +0000 Subject: [PATCH 020/118] fix build again --- SU2_CFD/obj/Makefile.am | 46 ++++++++++++++++++++--------------------- SU2_CFD/src/meson.build | 44 +++++++++++++++++++-------------------- 2 files changed, 45 insertions(+), 45 deletions(-) diff --git a/SU2_CFD/obj/Makefile.am b/SU2_CFD/obj/Makefile.am index f0df1d234a73..fcab6c236934 100644 --- a/SU2_CFD/obj/Makefile.am +++ b/SU2_CFD/obj/Makefile.am @@ -64,28 +64,28 @@ libSU2Core_sources = ../src/definition_structure.cpp \ ../src/drivers/CDummyDriver.cpp \ ../src/iteration_structure.cpp \ ../src/numerics/CNumerics.cpp \ - ../src/numerics/template.hpp \ - ../src/numerics/transition.hpp \ - ../src/numerics/heat.hpp \ - ../src/numerics/flow/convection/roe.hpp \ - ../src/numerics/flow/convection/fds.hpp \ - ../src/numerics/flow/convection/fvs.hpp \ - ../src/numerics/flow/convection/cusp.hpp \ - ../src/numerics/flow/convection/hllc.hpp \ - ../src/numerics/flow/convection/ausm_slau.hpp \ - ../src/numerics/flow/convection/centered.hpp \ - ../src/numerics/flow/flow_diffusion.hpp \ - ../src/numerics/flow/flow_sources.hpp \ - ../src/numerics/continuous_adjoint/adj_convection.hpp \ - ../src/numerics/continuous_adjoint/adj_diffusion.hpp \ - ../src/numerics/continuous_adjoint/adj_sources.hpp \ - ../src/numerics/turbulent/turb_convection.hpp \ - ../src/numerics/turbulent/turb_diffusion.hpp \ - ../src/numerics/turbulent/turb_sources.hpp \ - ../src/numerics/elasticity/CFEAElasticity.hpp \ - ../src/numerics/elasticity/CFEALinearElasticity.hpp \ - ../src/numerics/elasticity/CFEANonlinearElasticity.hpp \ - ../src/numerics/elasticity/nonlinear_models.hpp \ + ../src/numerics/template.cpp \ + ../src/numerics/transition.cpp \ + ../src/numerics/heat.cpp \ + ../src/numerics/flow/convection/roe.cpp \ + ../src/numerics/flow/convection/fds.cpp \ + ../src/numerics/flow/convection/fvs.cpp \ + ../src/numerics/flow/convection/cusp.cpp \ + ../src/numerics/flow/convection/hllc.cpp \ + ../src/numerics/flow/convection/ausm_slau.cpp \ + ../src/numerics/flow/convection/centered.cpp \ + ../src/numerics/flow/flow_diffusion.cpp \ + ../src/numerics/flow/flow_sources.cpp \ + ../src/numerics/continuous_adjoint/adj_convection.cpp \ + ../src/numerics/continuous_adjoint/adj_diffusion.cpp \ + ../src/numerics/continuous_adjoint/adj_sources.cpp \ + ../src/numerics/turbulent/turb_convection.cpp \ + ../src/numerics/turbulent/turb_diffusion.cpp \ + ../src/numerics/turbulent/turb_sources.cpp \ + ../src/numerics/elasticity/CFEAElasticity.cpp \ + ../src/numerics/elasticity/CFEALinearElasticity.cpp \ + ../src/numerics/elasticity/CFEANonlinearElasticity.cpp \ + ../src/numerics/elasticity/nonlinear_models.cpp \ ../src/output/filewriter/CCSVFileWriter.cpp \ ../src/output/filewriter/CSTLFileWriter.cpp \ ../src/output/filewriter/CFEMDataSorter.cpp \ @@ -179,7 +179,7 @@ libSU2Core_sources = ../src/definition_structure.cpp \ ../src/variables/CEulerVariable.cpp su2_cfd_sources = \ - ../include/SU2_CFD.hpp \ + ../include/SU2_CFD.cpp \ ../src/SU2_CFD.cpp libSU2Core_cxx_flags = -fPIC -std=c++11 diff --git a/SU2_CFD/src/meson.build b/SU2_CFD/src/meson.build index 5823d642af52..f436995b9051 100644 --- a/SU2_CFD/src/meson.build +++ b/SU2_CFD/src/meson.build @@ -94,28 +94,28 @@ su2_cfd_src += files(['solvers/CAdjEulerSolver.cpp', 'solvers/CTurbSSTSolver.cpp']) su2_cfd_src += files(['numerics/CNumerics.cpp', - 'numerics/template.hpp', - 'numerics/transition.hpp', - 'numerics/heat.hpp', - 'numerics/flow/convection/roe.hpp', - 'numerics/flow/convection/fds.hpp', - 'numerics/flow/convection/fvs.hpp', - 'numerics/flow/convection/cusp.hpp', - 'numerics/flow/convection/hllc.hpp', - 'numerics/flow/convection/ausm_slau.hpp', - 'numerics/flow/convection/centered.hpp', - 'numerics/flow/flow_diffusion.hpp', - 'numerics/flow/flow_sources.hpp', - 'numerics/continuous_adjoint/adj_convection.hpp', - 'numerics/continuous_adjoint/adj_diffusion.hpp', - 'numerics/continuous_adjoint/adj_sources.hpp', - 'numerics/turbulent/turb_convection.hpp', - 'numerics/turbulent/turb_diffusion.hpp', - 'numerics/turbulent/turb_sources.hpp', - 'numerics/elasticity/CFEAElasticity.hpp', - 'numerics/elasticity/CFEALinearElasticity.hpp', - 'numerics/elasticity/CFEANonlinearElasticity.hpp', - 'numerics/elasticity/nonlinear_models.hpp']) + 'numerics/template.cpp', + 'numerics/transition.cpp', + 'numerics/heat.cpp', + 'numerics/flow/convection/roe.cpp', + 'numerics/flow/convection/fds.cpp', + 'numerics/flow/convection/fvs.cpp', + 'numerics/flow/convection/cusp.cpp', + 'numerics/flow/convection/hllc.cpp', + 'numerics/flow/convection/ausm_slau.cpp', + 'numerics/flow/convection/centered.cpp', + 'numerics/flow/flow_diffusion.cpp', + 'numerics/flow/flow_sources.cpp', + 'numerics/continuous_adjoint/adj_convection.cpp', + 'numerics/continuous_adjoint/adj_diffusion.cpp', + 'numerics/continuous_adjoint/adj_sources.cpp', + 'numerics/turbulent/turb_convection.cpp', + 'numerics/turbulent/turb_diffusion.cpp', + 'numerics/turbulent/turb_sources.cpp', + 'numerics/elasticity/CFEAElasticity.cpp', + 'numerics/elasticity/CFEALinearElasticity.cpp', + 'numerics/elasticity/CFEANonlinearElasticity.cpp', + 'numerics/elasticity/nonlinear_models.cpp']) su2_cfd_src += files(['interfaces/CInterface.cpp', 'interfaces/cfd/CConservativeVarsInterface.cpp', From 048f9d2fbf875d410c4cac6b5eff9c555c79ad26 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Mon, 27 Jan 2020 23:12:29 +0000 Subject: [PATCH 021/118] work around a segfault during parallel allocation of numerics --- SU2_CFD/include/numerics/turbulent/turb_diffusion.hpp | 4 ++-- SU2_CFD/src/drivers/CDriver.cpp | 5 ++++- SU2_CFD/src/numerics/CNumerics.cpp | 4 ---- SU2_CFD/src/solvers/CEulerSolver.cpp | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/SU2_CFD/include/numerics/turbulent/turb_diffusion.hpp b/SU2_CFD/include/numerics/turbulent/turb_diffusion.hpp index 3a482bab8e0a..9ad7111d15d0 100644 --- a/SU2_CFD/include/numerics/turbulent/turb_diffusion.hpp +++ b/SU2_CFD/include/numerics/turbulent/turb_diffusion.hpp @@ -84,7 +84,7 @@ class CAvgGrad_Scalar : public CNumerics { * \param[in] config - Definition of the particular problem. */ CAvgGrad_Scalar(unsigned short val_nDim, unsigned short val_nVar, - bool correct_gradient, CConfig *config); + bool correct_gradient, CConfig *config); /*! * \brief Destructor of the class. @@ -127,7 +127,7 @@ class CAvgGrad_TurbSA : public CAvgGrad_Scalar { * \param[in] config - Definition of the particular problem. */ void FinishResidualCalc(su2double *val_residual, su2double **Jacobian_i, - su2double **Jacobian_j, CConfig *config); + su2double **Jacobian_j, CConfig *config); public: diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index 295722a27fc4..687cae778cb4 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -2081,6 +2081,9 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol SU2_OMP_PARALLEL { + /// TODO: we are segfaulting when allocating in parallel... + SU2_OMP_CRITICAL + { const int thread = omp_get_thread_num(); const int offset = thread * MAX_TERMS; @@ -2822,7 +2825,7 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol if (config->GetDeform_Mesh()) numerics[MESH_0][MESH_SOL][fea_term] = new CFEAMeshElasticity(nDim, nDim, geometry[MESH_0]->GetnElem(), config); - } // end SU2_OMP_PARALLEL + }} // end SU2_OMP_PARALLEL } diff --git a/SU2_CFD/src/numerics/CNumerics.cpp b/SU2_CFD/src/numerics/CNumerics.cpp index 49f89282fb46..97ec33b7448d 100644 --- a/SU2_CFD/src/numerics/CNumerics.cpp +++ b/SU2_CFD/src/numerics/CNumerics.cpp @@ -178,10 +178,6 @@ CNumerics::~CNumerics(void) { if (UnitNormal!= NULL) delete [] UnitNormal; if (UnitNormald!= NULL) delete [] UnitNormald; -// if (U_n!= NULL) delete [] U_n; -// if (U_nM1!= NULL) delete [] U_nM1; -// if (U_nP1!= NULL) delete [] U_nP1; - // visc if (Proj_Flux_Tensor!= NULL) delete [] Proj_Flux_Tensor; diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index bcf59fb1713b..8df8f7877fa9 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -748,7 +748,7 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short nodes = new CEulerVariable(Density_Inf, Velocity_Inf, Energy_Inf, nPoint, nDim, nVar, config); SetBaseClassPointerToNodes(); -#ifndef HAVE_OMP +#ifdef HAVE_OMP /*--- Get the edge coloring. ---*/ const auto& coloring = geometry->GetEdgeColoring(); From 4a0716e9bff997b1f2cb265bec85d8ecccd7fcf2 Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Tue, 28 Jan 2020 09:39:18 +0000 Subject: [PATCH 022/118] compressible centered schemes working in parallel --- Common/include/linear_algebra/CSysMatrix.hpp | 2 +- SU2_CFD/include/numerics/CNumerics.hpp | 12 +++++ .../numerics/flow/convection/centered.hpp | 20 ++++--- .../src/numerics/flow/convection/centered.cpp | 52 +++++++++++-------- SU2_CFD/src/solvers/CEulerSolver.cpp | 16 +++--- 5 files changed, 63 insertions(+), 39 deletions(-) diff --git a/Common/include/linear_algebra/CSysMatrix.hpp b/Common/include/linear_algebra/CSysMatrix.hpp index b96a62ce8b08..fc74609bed4b 100644 --- a/Common/include/linear_algebra/CSysMatrix.hpp +++ b/Common/include/linear_algebra/CSysMatrix.hpp @@ -550,7 +550,7 @@ class CSysMatrix { */ template inline void UpdateBlocks(unsigned long iEdge, unsigned long iPoint, unsigned long jPoint, - OtherType **block_i, OtherType **block_j) { + const OtherType* const* block_i, const OtherType* const* block_j) { ScalarType *bii = &matrix[dia_ptr[iPoint]*nVar*nEqn]; ScalarType *bjj = &matrix[dia_ptr[jPoint]*nVar*nEqn]; diff --git a/SU2_CFD/include/numerics/CNumerics.hpp b/SU2_CFD/include/numerics/CNumerics.hpp index ea9e6a3529dd..473e52adb1d0 100644 --- a/SU2_CFD/include/numerics/CNumerics.hpp +++ b/SU2_CFD/include/numerics/CNumerics.hpp @@ -1019,6 +1019,18 @@ class CNumerics { inline virtual void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { } + /*! + * \overload For numerics classes that store the residual/flux and Jacobians internally. + * \param[out] residual - Pointer to the total residual. + * \param[out] jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[in] config - Definition of the particular problem. + */ + inline virtual void ComputeResidual(const su2double* &residual, + const su2double* const* &jacobian_i, + const su2double* const* &jacobian_j, + CConfig *config) { } + /*! * \overload * \param[out] val_residual_i - Pointer to the total residual at point i. diff --git a/SU2_CFD/include/numerics/flow/convection/centered.hpp b/SU2_CFD/include/numerics/flow/convection/centered.hpp index 55e6c4a22c3e..6a2ea10173b1 100644 --- a/SU2_CFD/include/numerics/flow/convection/centered.hpp +++ b/SU2_CFD/include/numerics/flow/convection/centered.hpp @@ -44,20 +44,24 @@ class CCentBase_Flow : public CNumerics { bool implicit; /*!< \brief Implicit calculation (compute Jacobians). */ su2double fix_factor; /*!< \brief Fix factor for dissipation Jacobians (more diagonal dominance). */ - su2double *Velocity_i, *Velocity_j, *MeanVelocity; /*!< \brief Velocity at nodes i and j and mean. */ + su2double Velocity_i[3], Velocity_j[3]; /*!< \brief Velocity at nodes i and j. */ + su2double MeanVelocity[3]; /*!< \brief Mean velocity. */ su2double ProjVelocity_i, ProjVelocity_j; /*!< \brief Velocities in the face normal direction. */ su2double sq_vel_i, sq_vel_j; /*!< \brief Squared norm of the velocity vectors. */ su2double Energy_i, Energy_j, MeanEnergy; /*!< \brief Energy at nodes i and j and mean. */ su2double MeanDensity, MeanPressure, MeanEnthalpy; /*!< \brief Mean density, pressure, and enthalpy. */ - su2double *ProjFlux; /*!< \brief Projected inviscid flux. */ + su2double *ProjFlux = nullptr; /*!< \brief "The" flux. */ - su2double *Diff_U, *Diff_Lapl; /*!< \brief Differences of conservatives and undiv. Laplacians. */ + su2double *Diff_U = nullptr, *Diff_Lapl = nullptr; /*!< \brief Differences of conservatives and undiv. Laplacians. */ su2double Local_Lambda_i, Local_Lambda_j, MeanLambda; /*!< \brief Local eingenvalues. */ su2double Param_p, Phi_i, Phi_j, StretchingFactor; /*!< \brief Streching parameters. */ su2double cte_0, cte_1; /*!< \brief Constants for the scalar dissipation Jacobian. */ su2double ProjGridVel; /*!< \brief Projected grid velocity. */ + su2double** Jacobian_i = nullptr; /*!< \brief The Jacobian w.r.t. point i after computation. */ + su2double** Jacobian_j = nullptr; /*!< \brief The Jacobian w.r.t. point j after computation. */ + /*! * \brief Hook method for derived classes to define preaccumulated variables, optional to implement. * \return true if any variable was set as preacc. input, in which case the residual will be output. @@ -95,13 +99,13 @@ class CCentBase_Flow : public CNumerics { /*! * \brief Compute the flow residual using a centered method with artificial dissipation. - * \param[out] val_residual - Pointer to the convective flux contribution to the residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \param[out] residual - Pointer to the convective flux contribution to the residual. + * \param[out] jacobian_i - Jacobian of the numerical method at node i (implicit computation). + * \param[out] jacobian_j - Jacobian of the numerical method at node j (implicit computation). * \param[in] config - Definition of the particular problem. */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - + void ComputeResidual(const su2double* &residual, const su2double* const* &jacobian_i, + const su2double* const* &jacobian_j, CConfig *config) final; }; /*! diff --git a/SU2_CFD/src/numerics/flow/convection/centered.cpp b/SU2_CFD/src/numerics/flow/convection/centered.cpp index 8273a4d53842..629c204cc89f 100644 --- a/SU2_CFD/src/numerics/flow/convection/centered.cpp +++ b/SU2_CFD/src/numerics/flow/convection/centered.cpp @@ -41,23 +41,31 @@ CCentBase_Flow::CCentBase_Flow(unsigned short val_nDim, unsigned short val_nVar, /*--- Allocate required structures ---*/ Diff_U = new su2double [nVar]; Diff_Lapl = new su2double [nVar]; - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; - MeanVelocity = new su2double [nDim]; ProjFlux = new su2double [nVar]; + Jacobian_i = new su2double* [nVar]; + Jacobian_j = new su2double* [nVar]; + for (iVar = 0; iVar < nVar; iVar++) { + Jacobian_i[iVar] = new su2double [nVar]; + Jacobian_j[iVar] = new su2double [nVar]; + } } CCentBase_Flow::~CCentBase_Flow(void) { delete [] Diff_U; delete [] Diff_Lapl; - delete [] Velocity_i; - delete [] Velocity_j; - delete [] MeanVelocity; delete [] ProjFlux; + for (iVar = 0; iVar < nVar; iVar++) { + delete [] Jacobian_i[iVar]; + delete [] Jacobian_j[iVar]; + } + delete [] Jacobian_i; + delete [] Jacobian_j; } -void CCentBase_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, - CConfig *config) { +void CCentBase_Flow::ComputeResidual(const su2double* &residual, + const su2double* const* &jacobian_i, + const su2double* const* &jacobian_j, + CConfig *config) { su2double U_i[5] = {0.0,0.0,0.0,0.0,0.0}, U_j[5] = {0.0,0.0,0.0,0.0,0.0}; @@ -105,22 +113,17 @@ void CCentBase_Flow::ComputeResidual(su2double *val_residual, su2double **val_Ja MeanVelocity[iDim] = 0.5*(Velocity_i[iDim]+Velocity_j[iDim]); MeanEnergy = 0.5*(Energy_i+Energy_j); - /*--- Get projected flux tensor ---*/ - - GetInviscidProjFlux(&MeanDensity, MeanVelocity, &MeanPressure, &MeanEnthalpy, Normal, ProjFlux); - /*--- Residual of the inviscid flux ---*/ - for (iVar = 0; iVar < nVar; iVar++) - val_residual[iVar] = ProjFlux[iVar]; + GetInviscidProjFlux(&MeanDensity, MeanVelocity, &MeanPressure, &MeanEnthalpy, Normal, ProjFlux); - /*--- Jacobians of the inviscid flux, scale = 0.5 because val_residual ~ 0.5*(fc_i+fc_j)*Normal ---*/ + /*--- Jacobians of the inviscid flux, scale = 0.5 because ProjFlux ~ 0.5*(fc_i+fc_j)*Normal ---*/ if (implicit) { - GetInviscidProjJac(MeanVelocity, &MeanEnergy, Normal, 0.5, val_Jacobian_i); + GetInviscidProjJac(MeanVelocity, &MeanEnergy, Normal, 0.5, Jacobian_i); for (iVar = 0; iVar < nVar; iVar++) for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_j[iVar][jVar] = val_Jacobian_i[iVar][jVar]; + Jacobian_j[iVar][jVar] = Jacobian_i[iVar][jVar]; } /*--- Adjustment due to grid motion ---*/ @@ -131,10 +134,10 @@ void CCentBase_Flow::ComputeResidual(su2double *val_residual, su2double **val_Ja ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] -= ProjGridVel * 0.5*(U_i[iVar] + U_j[iVar]); + ProjFlux[iVar] -= ProjGridVel * 0.5*(U_i[iVar] + U_j[iVar]); if (implicit) { - val_Jacobian_i[iVar][iVar] -= 0.5*ProjGridVel; - val_Jacobian_j[iVar][iVar] -= 0.5*ProjGridVel; + Jacobian_i[iVar][iVar] -= 0.5*ProjGridVel; + Jacobian_j[iVar][iVar] -= 0.5*ProjGridVel; } } } @@ -173,12 +176,17 @@ void CCentBase_Flow::ComputeResidual(su2double *val_residual, su2double **val_Ja } Diff_U[nVar-1] = Density_i*Enthalpy_i-Density_j*Enthalpy_j; - DissipationTerm(val_residual, val_Jacobian_i, val_Jacobian_j); + DissipationTerm(ProjFlux, Jacobian_i, Jacobian_j); if (preacc) { - AD::SetPreaccOut(val_residual, nVar); + AD::SetPreaccOut(ProjFlux, nVar); AD::EndPreacc(); } + + residual = ProjFlux; + jacobian_i = Jacobian_i; + jacobian_j = Jacobian_j; + } void CCentBase_Flow::ScalarDissipationJacobian(su2double **val_Jacobian_i, su2double **val_Jacobian_j) { diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 8df8f7877fa9..2d64ce56b6f0 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -3326,16 +3326,19 @@ void CEulerSolver::Centered_Residual(CGeometry *geometry, CSolver **solver_conta /*--- Compute residuals, and Jacobians ---*/ - numerics->ComputeResidual(Res_Conv, Jacobian_i, Jacobian_j, config); + const su2double* flux; + const su2double* const* jacobian_i; + const su2double* const* jacobian_j; + numerics->ComputeResidual(flux, jacobian_i, jacobian_j, config); /*--- Update convective and artificial dissipation residuals ---*/ - LinSysRes.AddBlock(iPoint, Res_Conv); - LinSysRes.SubtractBlock(jPoint, Res_Conv); + LinSysRes.AddBlock(iPoint, flux); + LinSysRes.SubtractBlock(jPoint, flux); /*--- Set implicit computation ---*/ if (implicit) { - Jacobian.UpdateBlocks(iEdge, iPoint, jPoint, Jacobian_i, Jacobian_j); + Jacobian.UpdateBlocks(iEdge, iPoint, jPoint, jacobian_i, jacobian_j); } } } // end color loop @@ -3597,11 +3600,8 @@ void CEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_contain /*--- 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); } } From aa4ce5f829375d93da8f74e08c0cfe1b1c587bd2 Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Tue, 28 Jan 2020 14:52:54 +0000 Subject: [PATCH 023/118] thread-safe compressible upwind residual loop --- SU2_CFD/include/solvers/CEulerSolver.hpp | 44 ++- SU2_CFD/include/variables/CVariable.hpp | 2 +- SU2_CFD/src/solvers/CEulerSolver.cpp | 402 +++++++++++------------ SU2_CFD/src/solvers/CNSSolver.cpp | 12 - 4 files changed, 216 insertions(+), 244 deletions(-) diff --git a/SU2_CFD/include/solvers/CEulerSolver.hpp b/SU2_CFD/include/solvers/CEulerSolver.hpp index 2d03cfd9c673..e51190d9c12b 100644 --- a/SU2_CFD/include/solvers/CEulerSolver.hpp +++ b/SU2_CFD/include/solvers/CEulerSolver.hpp @@ -39,6 +39,9 @@ */ class CEulerSolver : public CSolver { protected: + enum : size_t {MAXNDIM = 3}; /*!< \brief Max number of space dimensions, used in some static arrays. */ + enum : size_t {MAXNVAR = 12}; /*!< \brief Max number of variables, used in some static arrays. */ + enum : size_t {OMP_MAX_SIZE = 512}; /*!< \brief Max chunk size for light point loops. */ enum : size_t {OMP_MIN_SIZE = 128}; /*!< \brief Min chunk size for edge loops (max is color group size). */ @@ -253,14 +256,6 @@ class CEulerSolver : public CSolver { su2double Gamma; /*!< \brief Fluid's Gamma constant (ratio of specific heats). */ su2double Gamma_Minus_One; /*!< \brief Fluids's Gamma - 1.0 . */ - su2double *Primitive, /*!< \brief Auxiliary nPrimVar vector. */ - *Primitive_i, /*!< \brief Auxiliary nPrimVar vector for storing the primitive at point i. */ - *Primitive_j; /*!< \brief Auxiliary nPrimVar vector for storing the primitive at point j. */ - - su2double *Secondary, /*!< \brief Auxiliary nPrimVar vector. */ - *Secondary_i, /*!< \brief Auxiliary nPrimVar vector for storing the primitive at point i. */ - *Secondary_j; /*!< \brief Auxiliary nPrimVar vector for storing the primitive at point j. */ - su2double AoA_Prev, /*!< \brief Old value of the angle of attack (monitored). */ AoA_inc; bool Start_AoA_FD, /*!< \brief Boolean for start of finite differencing for FixedCL mode */ @@ -467,11 +462,34 @@ class CEulerSolver : public CSolver { unsigned short iMesh) final; /*! - * \brief Compute the extrapolated quantities, for MUSCL upwind 2nd reconstruction, - * in a more thermodynamic consistent way - * \param[in] config - Definition of the particular problem. - */ - void ComputeConsExtrapolation(CConfig *config); + * \brief Recompute the extrapolated quantities, after MUSCL reconstruction, + * in a more thermodynamically consistent way. + * \note This method is static to improve the chances of it being used in a + * thread-safe manner. + * \param[in,out] fluidModel - The fluid model. + * \param[in] nDim - Number of physical dimensions. + * \param[in,out] primitive - Primitive variables. + * \param[out] secondary - Secondary variables. + */ + static void ComputeConsistentExtrapolation(CFluidModel *fluidModel, + unsigned short nDim, + su2double *primitive, + su2double *secondary); + + /*! + * \brief Apply low Mach number correction to the primitives at two points, + * usually connected by an edge. + * \note This method is static to improve the chances of it being used in a + * thread-safe manner. + * \param[in,out] fluidModel - The fluid model. + * \param[in] nDim - Number of physical dimensions. + * \param[in,out] primitive_i - Primitive variables at point i. + * \param[in,out] primitive_j - Primitive variables at point j. + */ + static void LowMachPrimitiveCorrection(CFluidModel *fluidModel, + unsigned short nDim, + su2double *primitive_i, + su2double *primitive_j); /*! * \brief Source term integration. diff --git a/SU2_CFD/include/variables/CVariable.hpp b/SU2_CFD/include/variables/CVariable.hpp index 7a65f6401214..e08179e595f7 100644 --- a/SU2_CFD/include/variables/CVariable.hpp +++ b/SU2_CFD/include/variables/CVariable.hpp @@ -197,7 +197,7 @@ class CVariable { } else { Non_Physical_Counter(iPoint)++; if (Non_Physical_Counter(iPoint) > 20) { - Non_Physical(iPoint) = val_value; + Non_Physical(iPoint) = false; } } } diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 2d64ce56b6f0..6d9349b1c18f 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -85,7 +85,6 @@ CEulerSolver::CEulerSolver(void) : CSolver() { /*--- Numerical methods array initialization ---*/ LowMach_Precontioner = NULL; - Primitive = NULL; Primitive_i = NULL; Primitive_j = NULL; CharacPrimVar = NULL; DonorPrimVar = NULL; DonorGlobalIndex = NULL; @@ -96,8 +95,6 @@ CEulerSolver::CEulerSolver(void) : CSolver() { Smatrix = NULL; Cvector = NULL; - Secondary = NULL; Secondary_i = NULL; Secondary_j = NULL; - /*--- Fixed CL mode initialization ---*/ Start_AoA_FD = false; @@ -269,15 +266,12 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short iPoint_UndLapl = NULL; jPoint_UndLapl = NULL; LowMach_Precontioner = NULL; - Primitive = NULL; Primitive_i = NULL; Primitive_j = NULL; CharacPrimVar = NULL; DonorPrimVar = NULL; DonorGlobalIndex = NULL; ActDisk_DeltaP = NULL; ActDisk_DeltaT = NULL; Smatrix = NULL; Cvector = NULL; - Secondary=NULL; Secondary_i=NULL; Secondary_j=NULL; - /*--- Fixed CL mode initialization ---*/ Start_AoA_FD = false; @@ -404,18 +398,6 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short Vector_i = new su2double[nDim]; for (iDim = 0; iDim < nDim; iDim++) Vector_i[iDim] = 0.0; Vector_j = new su2double[nDim]; for (iDim = 0; iDim < nDim; iDim++) Vector_j[iDim] = 0.0; - /*--- Define some auxiliary vectors related to the primitive solution ---*/ - - Primitive = new su2double[nPrimVar]; for (iVar = 0; iVar < nPrimVar; iVar++) Primitive[iVar] = 0.0; - Primitive_i = new su2double[nPrimVar]; for (iVar = 0; iVar < nPrimVar; iVar++) Primitive_i[iVar] = 0.0; - Primitive_j = new su2double[nPrimVar]; for (iVar = 0; iVar < nPrimVar; iVar++) Primitive_j[iVar] = 0.0; - - /*--- Define some auxiliary vectors related to the Secondary solution ---*/ - - Secondary = new su2double[nSecondaryVar]; for (iVar = 0; iVar < nSecondaryVar; iVar++) Secondary[iVar] = 0.0; - Secondary_i = new su2double[nSecondaryVar]; for (iVar = 0; iVar < nSecondaryVar; iVar++) Secondary_i[iVar] = 0.0; - Secondary_j = new su2double[nSecondaryVar]; for (iVar = 0; iVar < nSecondaryVar; iVar++) Secondary_j[iVar] = 0.0; - /*--- Define some auxiliary vectors related to the undivided lapalacian ---*/ if (config->GetKind_ConvNumScheme_Flow() == SPACE_CENTERED) { @@ -957,14 +939,6 @@ CEulerSolver::~CEulerSolver(void) { delete [] Exhaust_Pressure; delete [] Exhaust_Temperature; - delete [] Primitive; - delete [] Primitive_i; - delete [] Primitive_j; - - delete [] Secondary; - delete [] Secondary_i; - delete [] Secondary_j; - if (LowMach_Precontioner != NULL) { for (iVar = 0; iVar < nVar; iVar ++) delete [] LowMach_Precontioner[iVar]; @@ -3349,83 +3323,126 @@ void CEulerSolver::Centered_Residual(CGeometry *geometry, CSolver **solver_conta void CEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics_container, CConfig *config, unsigned short iMesh) { - CNumerics* numerics = numerics_container[CONV_TERM]; + assert(nDim <= MAXNDIM && nPrimVar <= MAXNVAR && nSecondaryVar <= MAXNVAR && + "Oops! The CEulerSolver static array sizes are not large enough."); - 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, Sensor_i, Sensor_j, Dissipation_i, Dissipation_j, *Coord_i, *Coord_j; + const auto InnerIter = config->GetInnerIter(); + const bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + const bool ideal_gas = (config->GetKind_FluidModel() == STANDARD_AIR) || + (config->GetKind_FluidModel() == IDEAL_GAS); - su2double z, velocity2_i, velocity2_j, mach_i, mach_j, vel_i_corr[3], vel_j_corr[3]; + const bool roe_turkel = (config->GetKind_Upwind_Flow() == TURKEL); + const bool low_mach_corr = config->Low_Mach_Correction(); + const auto kind_dissipation = config->GetKind_RoeLowDiss(); - unsigned long iEdge, iPoint, jPoint, counter_local = 0, counter_global = 0; - unsigned short iDim, iVar; + const bool muscl = (config->GetMUSCL_Flow() && (iMesh == MESH_0)); + const bool limiter = (config->GetKind_SlopeLimit_Flow() != NO_LIMITER) && + (InnerIter <= config->GetLimiterIter()); + const bool van_albada = (config->GetKind_SlopeLimit_Flow() == VAN_ALBADA_EDGE); - bool neg_density_i = false, neg_density_j = false, neg_pressure_i = false, neg_pressure_j = false, neg_sound_speed = false; + /*--- Non-physical counter. ---*/ + unsigned long counter_local = 0; - unsigned long InnerIter = config->GetInnerIter(); - bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - bool muscl = (config->GetMUSCL_Flow() && (iMesh == MESH_0)); - bool limiter = (config->GetKind_SlopeLimit_Flow() != NO_LIMITER) && (InnerIter <= config->GetLimiterIter()); - bool roe_turkel = (config->GetKind_Upwind_Flow() == TURKEL); - bool ideal_gas = (config->GetKind_FluidModel() == STANDARD_AIR || config->GetKind_FluidModel() == IDEAL_GAS ); - bool van_albada = config->GetKind_SlopeLimit_Flow() == VAN_ALBADA_EDGE; - bool low_mach_corr = config->Low_Mach_Correction(); - unsigned short kind_dissipation = config->GetKind_RoeLowDiss(); + /*--- Start OpenMP parallel section. ---*/ + + SU2_OMP_PARALLEL_(reduction(+:counter_local)) + { + /*--- Pick one numerics object per thread. ---*/ + CNumerics* numerics = numerics_container[CONV_TERM + omp_get_thread_num()*MAX_TERMS]; /*--- Loop over all the edges ---*/ - for (iEdge = 0; iEdge < geometry->GetnEdge(); iEdge++) { +#ifdef HAVE_OMP + /*--- Chunk size is at least OMP_MIN_SIZE and a multiple of the color group size. ---*/ + auto chunkSize = roundUpDiv(OMP_MIN_SIZE, ColorGroupSize)*ColorGroupSize; + + /*--- Loop over edge colors. ---*/ + for (auto color : EdgeColoring) + { + SU2_OMP_FOR_DYN(chunkSize) + for(auto k = 0ul; k < color.size; ++k) { + + auto iEdge = color.indices[k]; +#else + /*--- Natural coloring. ---*/ + { + for (auto iEdge = 0ul; iEdge < geometry->GetnEdge(); iEdge++) { +#endif + unsigned short iDim, iVar; /*--- Points in edge and normal vectors ---*/ - iPoint = geometry->edge[iEdge]->GetNode(0); jPoint = geometry->edge[iEdge]->GetNode(1); + auto iPoint = geometry->edge[iEdge]->GetNode(0); + auto jPoint = geometry->edge[iEdge]->GetNode(1); + numerics->SetNormal(geometry->edge[iEdge]->GetNormal()); + auto Coord_i = geometry->node[iPoint]->GetCoord(); + auto Coord_j = geometry->node[jPoint]->GetCoord(); + /*--- Roe Turkel preconditioning ---*/ if (roe_turkel) { - sqvel = 0.0; + su2double sqvel = 0.0; for (iDim = 0; iDim < nDim; iDim ++) - sqvel += config->GetVelocity_FreeStream()[iDim]*config->GetVelocity_FreeStream()[iDim]; + sqvel += pow(config->GetVelocity_FreeStream()[iDim], 2); numerics->SetVelocity2_Inf(sqvel); } /*--- Grid movement ---*/ - if (dynamic_grid) - numerics->SetGridVel(geometry->node[iPoint]->GetGridVel(), geometry->node[jPoint]->GetGridVel()); + if (dynamic_grid) { + numerics->SetGridVel(geometry->node[iPoint]->GetGridVel(), + geometry->node[jPoint]->GetGridVel()); + } - /*--- Get primitive variables ---*/ + /*--- Get primitive and secondary variables ---*/ - V_i = nodes->GetPrimitive(iPoint); V_j = nodes->GetPrimitive(jPoint); - S_i = nodes->GetSecondary(iPoint); S_j = nodes->GetSecondary(jPoint); + auto V_i = nodes->GetPrimitive(iPoint); auto V_j = nodes->GetPrimitive(jPoint); + auto S_i = nodes->GetSecondary(iPoint); auto S_j = nodes->GetSecondary(jPoint); - /*--- High order reconstruction using MUSCL strategy ---*/ + /*--- Set them with or without high order reconstruction using MUSCL strategy. ---*/ - if (muscl) { + if (!muscl) { - 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)); - } + numerics->SetPrimitive(V_i, V_j); + numerics->SetSecondary(S_i, S_j); - Gradient_i = nodes->GetGradient_Reconstruction(iPoint); - Gradient_j = nodes->GetGradient_Reconstruction(jPoint); + } + else { + /*--- Reconstruction ---*/ + + /*--- Static arrays of primitives and secondaries (thread safety). ---*/ + + su2double Primitive_i[MAXNVAR] = {0.0}, Primitive_j[MAXNVAR] = {0.0}; + su2double Secondary_i[MAXNVAR] = {0.0}, Secondary_j[MAXNVAR] = {0.0}; - if (limiter) { - Limiter_i = nodes->GetLimiter_Primitive(iPoint); - Limiter_j = nodes->GetLimiter_Primitive(jPoint); + su2double Vector_ij[MAXNDIM] = {0.0}; + for (iDim = 0; iDim < nDim; iDim++) { + Vector_ij[iDim] = 0.5*(Coord_j[iDim] - Coord_i[iDim]); } + auto Gradient_i = nodes->GetGradient_Reconstruction(iPoint); + auto Gradient_j = nodes->GetGradient_Reconstruction(jPoint); + for (iVar = 0; iVar < nPrimVarGrad; iVar++) { - Project_Grad_i = 0.0; Project_Grad_j = 0.0; + + su2double Project_Grad_i = 0.0; + su2double Project_Grad_j = 0.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]; + Project_Grad_i += Vector_ij[iDim]*Gradient_i[iVar][iDim]; + Project_Grad_j -= Vector_ij[iDim]*Gradient_j[iVar][iDim]; } + if (limiter) { - if (van_albada){ - Limiter_i[iVar] = (V_j[iVar]-V_i[iVar])*(2.0*Project_Grad_i + V_j[iVar]-V_i[iVar])/(4*Project_Grad_i*Project_Grad_i+(V_j[iVar]-V_i[iVar])*(V_j[iVar]-V_i[iVar])+EPS); - Limiter_j[iVar] = (V_j[iVar]-V_i[iVar])*(-2.0*Project_Grad_j + V_j[iVar]-V_i[iVar])/(4*Project_Grad_j*Project_Grad_j+(V_j[iVar]-V_i[iVar])*(V_j[iVar]-V_i[iVar])+EPS); + auto Limiter_i = nodes->GetLimiter_Primitive(iPoint); + auto Limiter_j = nodes->GetLimiter_Primitive(jPoint); + + if (van_albada) { + su2double V_ij = V_j[iVar] - V_i[iVar]; + Limiter_i[iVar] = V_ij*( 2.0*Project_Grad_i + V_ij) / (4*pow(Project_Grad_i, 2) + pow(V_ij, 2) + EPS); + Limiter_j[iVar] = V_ij*(-2.0*Project_Grad_j + V_ij) / (4*pow(Project_Grad_j, 2) + pow(V_ij, 2) + EPS); } Primitive_i[iVar] = V_i[iVar] + Limiter_i[iVar]*Project_Grad_i; Primitive_j[iVar] = V_j[iVar] + Limiter_j[iVar]*Project_Grad_j; @@ -3434,212 +3451,166 @@ void CEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_contain Primitive_i[iVar] = V_i[iVar] + Project_Grad_i; Primitive_j[iVar] = V_j[iVar] + Project_Grad_j; } + } - /*--- Recompute the extrapolated quantities in a - thermodynamic consistent way ---*/ + /*--- Recompute the reconstructed quantities in a thermodynamically consistent way. ---*/ - if (!ideal_gas || low_mach_corr) { ComputeConsExtrapolation(config); } + if (!ideal_gas || low_mach_corr) { + ComputeConsistentExtrapolation(GetFluidModel(), nDim, Primitive_i, Secondary_i); + ComputeConsistentExtrapolation(GetFluidModel(), nDim, Primitive_j, Secondary_j); + } - /*--- Low-Mach number correction ---*/ + /*--- Low-Mach number correction. ---*/ if (low_mach_corr) { - - velocity2_i = 0.0; - velocity2_j = 0.0; - - for (iDim = 0; iDim < nDim; iDim++) { - velocity2_i += Primitive_i[iDim+1]*Primitive_i[iDim+1]; - velocity2_j += Primitive_j[iDim+1]*Primitive_j[iDim+1]; - } - mach_i = sqrt(velocity2_i)/Primitive_i[nDim+4]; - mach_j = sqrt(velocity2_j)/Primitive_j[nDim+4]; - - z = min(max(mach_i,mach_j),1.0); - velocity2_i = 0.0; - velocity2_j = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - vel_i_corr[iDim] = ( Primitive_i[iDim+1] + Primitive_j[iDim+1] )/2.0 \ - + z * ( Primitive_i[iDim+1] - Primitive_j[iDim+1] )/2.0; - vel_j_corr[iDim] = ( Primitive_i[iDim+1] + Primitive_j[iDim+1] )/2.0 \ - + z * ( Primitive_j[iDim+1] - Primitive_i[iDim+1] )/2.0; - - velocity2_j += vel_j_corr[iDim]*vel_j_corr[iDim]; - velocity2_i += vel_i_corr[iDim]*vel_i_corr[iDim]; - - Primitive_i[iDim+1] = vel_i_corr[iDim]; - Primitive_j[iDim+1] = vel_j_corr[iDim]; - } - - GetFluidModel()->SetEnergy_Prho(Primitive_i[nDim+1],Primitive_i[nDim+2]); - Primitive_i[nDim+3]= GetFluidModel()->GetStaticEnergy() + Primitive_i[nDim+1]/Primitive_i[nDim+2] + 0.5*velocity2_i; - - GetFluidModel()->SetEnergy_Prho(Primitive_j[nDim+1],Primitive_j[nDim+2]); - Primitive_j[nDim+3]= GetFluidModel()->GetStaticEnergy() + Primitive_j[nDim+1]/Primitive_j[nDim+2] + 0.5*velocity2_j; - + LowMachPrimitiveCorrection(GetFluidModel(), nDim, Primitive_i, Primitive_j); } - /*--- 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. If non-physical, use the - cell-averaged state. ---*/ + /*--- Check for non-physical solutions after reconstruction. If found, use the + cell-average value of the solution. This is a locally 1st order approximation, + which is typically only active during the start-up of a calculation. ---*/ - neg_pressure_i = (Primitive_i[nDim+1] < 0.0); neg_pressure_j = (Primitive_j[nDim+1] < 0.0); - neg_density_i = (Primitive_i[nDim+2] < 0.0); neg_density_j = (Primitive_j[nDim+2] < 0.0); + bool neg_pres_or_rho_i = (Primitive_i[nDim+1] < 0.0) || (Primitive_i[nDim+2] < 0.0); + bool neg_pres_or_rho_j = (Primitive_j[nDim+1] < 0.0) || (Primitive_j[nDim+2] < 0.0); - R = sqrt(fabs(Primitive_j[nDim+2]/Primitive_i[nDim+2])); - sq_vel = 0.0; + su2double R = sqrt(fabs(Primitive_j[nDim+2]/Primitive_i[nDim+2])); + su2double sq_vel = 0.0; for (iDim = 0; iDim < nDim; iDim++) { - RoeVelocity[iDim] = (R*Primitive_j[iDim+1]+Primitive_i[iDim+1])/(R+1); - sq_vel += RoeVelocity[iDim]*RoeVelocity[iDim]; - } - 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]; - } - 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]; - 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]; - nodes->SetNon_Physical(jPoint, true); - Secondary_j[0] = S_j[0]; Secondary_j[1] = S_j[1]; + su2double RoeVelocity = (R*Primitive_j[iDim+1]+Primitive_i[iDim+1])/(R+1); + sq_vel += pow(RoeVelocity, 2); } + su2double RoeEnthalpy = (R*Primitive_j[nDim+3]+Primitive_i[nDim+3])/(R+1); - if (!neg_sound_speed && !neg_density_i && !neg_pressure_i) - nodes->SetNon_Physical(iPoint, false); - - if (!neg_sound_speed && !neg_density_j && !neg_pressure_j) - nodes->SetNon_Physical(jPoint, false); + bool neg_sound_speed = ((Gamma-1)*(RoeEnthalpy-0.5*sq_vel) < 0.0); - /* Lastly, check for existing first-order points still active - from previous iterations. */ + bool bad_i = neg_sound_speed || neg_pres_or_rho_i; + bool bad_j = neg_sound_speed || neg_pres_or_rho_j; - if (nodes->GetNon_Physical(iPoint)) { - counter_local++; - for (iVar = 0; iVar < nPrimVar; iVar++) - Primitive_i[iVar] = V_i[iVar]; - } - if (nodes->GetNon_Physical(jPoint)) { - counter_local++; - for (iVar = 0; iVar < nPrimVar; iVar++) - Primitive_j[iVar] = V_j[iVar]; - } + nodes->SetNon_Physical(iPoint, bad_i); + nodes->SetNon_Physical(jPoint, bad_j); - numerics->SetPrimitive(Primitive_i, Primitive_j); - numerics->SetSecondary(Secondary_i, Secondary_j); + /*--- Get updated state, in case the point recovered after the set. ---*/ + bad_i = nodes->GetNon_Physical(iPoint); + bad_j = nodes->GetNon_Physical(jPoint); - } - else { + counter_local += bad_i+bad_j; - /*--- Set conservative variables without reconstruction ---*/ - - numerics->SetPrimitive(V_i, V_j); - numerics->SetSecondary(S_i, S_j); + numerics->SetPrimitive(bad_i? V_i : Primitive_i, bad_j? V_j : Primitive_j); + numerics->SetSecondary(bad_i? S_i : Secondary_i, bad_j? S_j : Secondary_j); } /*--- Roe Low Dissipation Scheme ---*/ - if (kind_dissipation != NO_ROELOWDISS){ + if (kind_dissipation != NO_ROELOWDISS) { - Dissipation_i = nodes->GetRoe_Dissipation(iPoint); - Dissipation_j = nodes->GetRoe_Dissipation(jPoint); - numerics->SetDissipation(Dissipation_i, Dissipation_j); + numerics->SetDissipation(nodes->GetRoe_Dissipation(iPoint), + nodes->GetRoe_Dissipation(jPoint)); if (kind_dissipation == FD_DUCROS || kind_dissipation == NTS_DUCROS){ - Sensor_i = nodes->GetSensor(iPoint); - Sensor_j = nodes->GetSensor(jPoint); - numerics->SetSensor(Sensor_i, Sensor_j); + numerics->SetSensor(nodes->GetSensor(iPoint), + nodes->GetSensor(jPoint)); } if (kind_dissipation == NTS || kind_dissipation == NTS_DUCROS){ - Coord_i = geometry->node[iPoint]->GetCoord(); - Coord_j = geometry->node[jPoint]->GetCoord(); numerics->SetCoord(Coord_i, Coord_j); } } /*--- Compute the residual ---*/ - numerics->ComputeResidual(Res_Conv, Jacobian_i, Jacobian_j, config); + const su2double* flux; + const su2double* const* jacobian_i; + const su2double* const* jacobian_j; + numerics->ComputeResidual(flux, jacobian_i, jacobian_j, config); /*--- Update residual value ---*/ - LinSysRes.AddBlock(iPoint, Res_Conv); - LinSysRes.SubtractBlock(jPoint, Res_Conv); + LinSysRes.AddBlock(iPoint, flux); + LinSysRes.SubtractBlock(jPoint, flux); /*--- Set implicit Jacobians ---*/ if (implicit) { - Jacobian.UpdateBlocks(iEdge, iPoint, jPoint, Jacobian_i, Jacobian_j); + Jacobian.UpdateBlocks(iEdge, iPoint, jPoint, jacobian_i, jacobian_j); } /*--- Set the final value of the Roe dissipation coefficient ---*/ - if (kind_dissipation != NO_ROELOWDISS){ + if (kind_dissipation != NO_ROELOWDISS) { nodes->SetRoe_Dissipation(iPoint,numerics->GetDissipation()); nodes->SetRoe_Dissipation(jPoint,numerics->GetDissipation()); } - } + } // end color loop + } // end SU2_OMP_PARALLEL - /*--- Warning message about non-physical reconstructions ---*/ + /*--- Warning message about non-physical reconstructions. ---*/ if (config->GetComm_Level() == COMM_FULL) { - SU2_MPI::Reduce(&counter_local, &counter_global, 1, MPI_UNSIGNED_LONG, MPI_SUM, MASTER_NODE, MPI_COMM_WORLD); - - if (iMesh == MESH_0) config->SetNonphysical_Reconstr(counter_global); + if (iMesh == MESH_0) { + unsigned long counter_global = 0; + SU2_MPI::Reduce(&counter_local, &counter_global, 1, MPI_UNSIGNED_LONG, MPI_SUM, MASTER_NODE, MPI_COMM_WORLD); + config->SetNonphysical_Reconstr(counter_global); + } } } -void CEulerSolver::ComputeConsExtrapolation(CConfig *config) { +void CEulerSolver::ComputeConsistentExtrapolation(CFluidModel *fluidModel, unsigned short nDim, + su2double *primitive, su2double *secondary) { + + su2double density = primitive[nDim+2]; + su2double pressure = primitive[nDim+1]; + + su2double velocity2 = 0.0; + for (unsigned short iDim = 0; iDim < nDim; iDim++) + velocity2 += pow(primitive[iDim+1], 2); + + fluidModel->SetTDState_Prho(pressure, density); + + primitive[0] = fluidModel->GetTemperature(); + primitive[nDim+3] = fluidModel->GetStaticEnergy() + primitive[nDim+1]/primitive[nDim+2] + 0.5*velocity2; + primitive[nDim+4] = fluidModel->GetSoundSpeed(); + secondary[0] = fluidModel->GetdPdrho_e(); + secondary[1] = fluidModel->GetdPde_rho(); + +} +void CEulerSolver::LowMachPrimitiveCorrection(CFluidModel *fluidModel, unsigned short nDim, + su2double *primitive_i, su2double *primitive_j) { unsigned short iDim; - su2double density_i = Primitive_i[nDim+2]; - su2double pressure_i = Primitive_i[nDim+1]; su2double velocity2_i = 0.0; + su2double velocity2_j = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { - velocity2_i += Primitive_i[iDim+1]*Primitive_i[iDim+1]; + velocity2_i += pow(primitive_i[iDim+1], 2); + velocity2_j += pow(primitive_j[iDim+1], 2); } + su2double mach_i = sqrt(velocity2_i)/primitive_i[nDim+4]; + su2double mach_j = sqrt(velocity2_j)/primitive_j[nDim+4]; - GetFluidModel()->SetTDState_Prho(pressure_i, density_i); - - Primitive_i[0]= GetFluidModel()->GetTemperature(); - Primitive_i[nDim+3]= GetFluidModel()->GetStaticEnergy() + Primitive_i[nDim+1]/Primitive_i[nDim+2] + 0.5*velocity2_i; - Primitive_i[nDim+4]= GetFluidModel()->GetSoundSpeed(); - Secondary_i[0]=GetFluidModel()->GetdPdrho_e(); - Secondary_i[1]=GetFluidModel()->GetdPde_rho(); + su2double z = min(max(mach_i,mach_j),1.0); + velocity2_i = 0.0; + velocity2_j = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + su2double vel_i_corr = ( primitive_i[iDim+1] + primitive_j[iDim+1] )/2.0 + + z * ( primitive_i[iDim+1] - primitive_j[iDim+1] )/2.0; + su2double vel_j_corr = ( primitive_i[iDim+1] + primitive_j[iDim+1] )/2.0 + + z * ( primitive_j[iDim+1] - primitive_i[iDim+1] )/2.0; + velocity2_i += pow(vel_i_corr, 2); + velocity2_j += pow(vel_j_corr, 2); - su2double density_j = Primitive_j[nDim+2]; - su2double pressure_j = Primitive_j[nDim+1]; - su2double velocity2_j = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - velocity2_j += Primitive_j[iDim+1]*Primitive_j[iDim+1]; + primitive_i[iDim+1] = vel_i_corr; + primitive_j[iDim+1] = vel_j_corr; } - GetFluidModel()->SetTDState_Prho(pressure_j, density_j); + fluidModel->SetEnergy_Prho(primitive_i[nDim+1], primitive_i[nDim+2]); + primitive_i[nDim+3]= fluidModel->GetStaticEnergy() + primitive_i[nDim+1]/primitive_i[nDim+2] + 0.5*velocity2_i; - Primitive_j[0]= GetFluidModel()->GetTemperature(); - Primitive_j[nDim+3]= GetFluidModel()->GetStaticEnergy() + Primitive_j[nDim+1]/Primitive_j[nDim+2] + 0.5*velocity2_j; - Primitive_j[nDim+4]=GetFluidModel()->GetSoundSpeed(); - Secondary_j[0]=GetFluidModel()->GetdPdrho_e(); - Secondary_j[1]=GetFluidModel()->GetdPde_rho(); + fluidModel->SetEnergy_Prho(primitive_j[nDim+1], primitive_j[nDim+2]); + primitive_j[nDim+3]= fluidModel->GetStaticEnergy() + primitive_j[nDim+1]/primitive_j[nDim+2] + 0.5*velocity2_j; } @@ -10975,10 +10946,11 @@ void CEulerSolver::BC_Fluid_Interface(CGeometry *geometry, CSolver **solver_cont bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); bool viscous = config->GetViscous(); - su2double *Normal = new su2double[nDim]; - su2double *PrimVar_i = new su2double[nPrimVar]; - su2double *PrimVar_j = new su2double[nPrimVar]; - su2double *tmp_residual = new su2double[nVar]; + su2double Normal[MAXNDIM] = {0.0}; + su2double PrimVar_i[MAXNVAR] = {0.0}; + su2double PrimVar_j[MAXNVAR] = {0.0}; + su2double tmp_residual[MAXNVAR] = {0.0}; + su2double Secondary_j[MAXNVAR] = {0.0}; su2double weight; su2double P_static, rho_static; @@ -11019,7 +10991,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 = nodes->GetSecondary(iPoint); + auto Secondary_i = nodes->GetSecondary(iPoint); P_static = PrimVar_j[nDim+1]; rho_static = PrimVar_j[nDim+2]; @@ -11118,12 +11090,6 @@ void CEulerSolver::BC_Fluid_Interface(CGeometry *geometry, CSolver **solver_cont } } - /*--- Free locally allocated memory ---*/ - - delete [] tmp_residual; - delete [] Normal; - delete [] PrimVar_i; - delete [] PrimVar_j; } void CEulerSolver::BC_Interface_Boundary(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, diff --git a/SU2_CFD/src/solvers/CNSSolver.cpp b/SU2_CFD/src/solvers/CNSSolver.cpp index bb931461a94b..68cf03ee79ef 100644 --- a/SU2_CFD/src/solvers/CNSSolver.cpp +++ b/SU2_CFD/src/solvers/CNSSolver.cpp @@ -264,18 +264,6 @@ CNSSolver::CNSSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) Vector_i = new su2double[nDim]; for (iDim = 0; iDim < nDim; iDim++) Vector_i[iDim] = 0.0; Vector_j = new su2double[nDim]; for (iDim = 0; iDim < nDim; iDim++) Vector_j[iDim] = 0.0; - /*--- Define some auxiliary vectors related to the primitive solution ---*/ - - Primitive = new su2double[nPrimVar]; for (iVar = 0; iVar < nPrimVar; iVar++) Primitive[iVar] = 0.0; - Primitive_i = new su2double[nPrimVar]; for (iVar = 0; iVar < nPrimVar; iVar++) Primitive_i[iVar] = 0.0; - Primitive_j = new su2double[nPrimVar]; for (iVar = 0; iVar < nPrimVar; iVar++) Primitive_j[iVar] = 0.0; - - /*--- Define some auxiliary vectors related to the Secondary solution ---*/ - - Secondary = new su2double[nSecondaryVar]; for (iVar = 0; iVar < nSecondaryVar; iVar++) Secondary[iVar] = 0.0; - Secondary_i = new su2double[nSecondaryVar]; for (iVar = 0; iVar < nSecondaryVar; iVar++) Secondary_i[iVar] = 0.0; - Secondary_j = new su2double[nSecondaryVar]; for (iVar = 0; iVar < nSecondaryVar; iVar++) Secondary_j[iVar] = 0.0; - /*--- Define some auxiliar vector related with the undivided lapalacian computation ---*/ if (config->GetKind_ConvNumScheme_Flow() == SPACE_CENTERED) { From 0e3a8dcff4f01c06a7b2fc78281138c73a0fdbdd Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Tue, 28 Jan 2020 14:58:21 +0000 Subject: [PATCH 024/118] delete some unused variables --- SU2_CFD/include/solvers/CEulerSolver.hpp | 8 +---- SU2_CFD/src/solvers/CEulerSolver.cpp | 40 ++++++++++++------------ SU2_CFD/src/solvers/CNSSolver.cpp | 4 +-- 3 files changed, 23 insertions(+), 29 deletions(-) diff --git a/SU2_CFD/include/solvers/CEulerSolver.hpp b/SU2_CFD/include/solvers/CEulerSolver.hpp index e51190d9c12b..482a038132f7 100644 --- a/SU2_CFD/include/solvers/CEulerSolver.hpp +++ b/SU2_CFD/include/solvers/CEulerSolver.hpp @@ -243,13 +243,7 @@ class CEulerSolver : public CSolver { *Surface_HF_Visc, /*!< \brief Total (integrated) heat flux for each monitored surface. */ *Surface_MaxHF_Visc; /*!< \brief Maximum heat flux for each monitored surface. */ - su2double - *SecondaryVar_i, /*!< \brief Auxiliary vector for storing the solution at point i. */ - *SecondaryVar_j; /*!< \brief Auxiliary vector for storing the solution at point j. */ - su2double - *PrimVar_i, /*!< \brief Auxiliary vector for storing the solution at point i. */ - *PrimVar_j; /*!< \brief Auxiliary vector for storing the solution at point j. */ - su2double **LowMach_Precontioner; /*!< \brief Auxiliary vector for storing the inverse of Roe-turkel preconditioner. */ + su2double **LowMach_Preconditioner; /*!< \brief Auxiliary vector for storing the inverse of Roe-turkel preconditioner. */ bool space_centered, /*!< \brief True if space centered scheeme used. */ euler_implicit, /*!< \brief True if euler implicit scheme used. */ least_squares; /*!< \brief True if computing gradients by least squares. */ diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 6d9349b1c18f..60b1fe5f4793 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -84,7 +84,7 @@ CEulerSolver::CEulerSolver(void) : CSolver() { /*--- Numerical methods array initialization ---*/ - LowMach_Precontioner = NULL; + LowMach_Preconditioner = NULL; CharacPrimVar = NULL; DonorPrimVar = NULL; DonorGlobalIndex = NULL; @@ -265,7 +265,7 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short iPoint_UndLapl = NULL; jPoint_UndLapl = NULL; - LowMach_Precontioner = NULL; + LowMach_Preconditioner = NULL; CharacPrimVar = NULL; DonorPrimVar = NULL; DonorGlobalIndex = NULL; ActDisk_DeltaP = NULL; ActDisk_DeltaT = NULL; @@ -408,9 +408,9 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short /*--- Define some auxiliary vectors related to low-speed preconditioning ---*/ if (roe_turkel || low_mach_prec) { - LowMach_Precontioner = new su2double* [nVar]; + LowMach_Preconditioner = new su2double* [nVar]; for (iVar = 0; iVar < nVar; iVar ++) - LowMach_Precontioner[iVar] = new su2double[nVar]; + LowMach_Preconditioner[iVar] = new su2double[nVar]; } /*--- Initialize the solution and right hand side vectors for storing @@ -939,10 +939,10 @@ CEulerSolver::~CEulerSolver(void) { delete [] Exhaust_Pressure; delete [] Exhaust_Temperature; - if (LowMach_Precontioner != NULL) { + if (LowMach_Preconditioner != NULL) { for (iVar = 0; iVar < nVar; iVar ++) - delete [] LowMach_Precontioner[iVar]; - delete [] LowMach_Precontioner; + delete [] LowMach_Preconditioner[iVar]; + delete [] LowMach_Preconditioner; } if (CPressure != NULL) { @@ -5119,8 +5119,8 @@ void CEulerSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver SetPreconditioner(config, iPoint); for (iVar = 0; iVar < nVar; iVar ++ ) for (jVar = 0; jVar < nVar; jVar ++ ) - LowMach_Precontioner[iVar][jVar] = Delta*LowMach_Precontioner[iVar][jVar]; - Jacobian.AddBlock(iPoint, iPoint, LowMach_Precontioner); + LowMach_Preconditioner[iVar][jVar] = Delta*LowMach_Preconditioner[iVar][jVar]; + Jacobian.AddBlock(iPoint, iPoint, LowMach_Preconditioner); } else { Jacobian.AddVal2Diag(iPoint, Delta); @@ -5309,30 +5309,30 @@ void CEulerSolver::SetPreconditioner(CConfig *config, unsigned long 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; - LowMach_Precontioner[0][nVar-1] = 1.0; + LowMach_Preconditioner[0][0] = 0.5*sq_vel; + LowMach_Preconditioner[0][nVar-1] = 1.0; for (iDim = 0; iDim < nDim; iDim ++) - LowMach_Precontioner[0][1+iDim] = -1.0*U_i[iDim+1]/rho; + LowMach_Preconditioner[0][1+iDim] = -1.0*U_i[iDim+1]/rho; for (iDim = 0; iDim < nDim; iDim ++) { - LowMach_Precontioner[iDim+1][0] = 0.5*sq_vel*U_i[iDim+1]/rho; - LowMach_Precontioner[iDim+1][nVar-1] = U_i[iDim+1]/rho; + LowMach_Preconditioner[iDim+1][0] = 0.5*sq_vel*U_i[iDim+1]/rho; + LowMach_Preconditioner[iDim+1][nVar-1] = U_i[iDim+1]/rho; for (jDim = 0; jDim < nDim; jDim ++) { - LowMach_Precontioner[iDim+1][1+jDim] = -1.0*U_i[jDim+1]/rho*U_i[iDim+1]/rho; + LowMach_Preconditioner[iDim+1][1+jDim] = -1.0*U_i[jDim+1]/rho*U_i[iDim+1]/rho; } } - LowMach_Precontioner[nVar-1][0] = 0.5*sq_vel*enthalpy; - LowMach_Precontioner[nVar-1][nVar-1] = enthalpy; + LowMach_Preconditioner[nVar-1][0] = 0.5*sq_vel*enthalpy; + LowMach_Preconditioner[nVar-1][nVar-1] = enthalpy; for (iDim = 0; iDim < nDim; iDim ++) - LowMach_Precontioner[nVar-1][1+iDim] = -1.0*U_i[iDim+1]/rho*enthalpy; + LowMach_Preconditioner[nVar-1][1+iDim] = -1.0*U_i[iDim+1]/rho*enthalpy; for (iVar = 0; iVar < nVar; iVar ++ ) { for (jVar = 0; jVar < nVar; jVar ++ ) { - LowMach_Precontioner[iVar][jVar] = (parameter - 1.0) * ((Gamma-1.0)/(soundspeed*soundspeed))*LowMach_Precontioner[iVar][jVar]; + LowMach_Preconditioner[iVar][jVar] = (parameter - 1.0) * ((Gamma-1.0)/(soundspeed*soundspeed))*LowMach_Preconditioner[iVar][jVar]; if (iVar == jVar) - LowMach_Precontioner[iVar][iVar] += 1.0; + LowMach_Preconditioner[iVar][iVar] += 1.0; } } diff --git a/SU2_CFD/src/solvers/CNSSolver.cpp b/SU2_CFD/src/solvers/CNSSolver.cpp index 68cf03ee79ef..6ab878f31de7 100644 --- a/SU2_CFD/src/solvers/CNSSolver.cpp +++ b/SU2_CFD/src/solvers/CNSSolver.cpp @@ -274,9 +274,9 @@ CNSSolver::CNSSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) /*--- Define some auxiliary vectors related to low-speed preconditioning ---*/ if (roe_turkel || low_mach_prec) { - LowMach_Precontioner = new su2double* [nVar]; + LowMach_Preconditioner = new su2double* [nVar]; for (iVar = 0; iVar < nVar; iVar ++) - LowMach_Precontioner[iVar] = new su2double[nVar]; + LowMach_Preconditioner[iVar] = new su2double[nVar]; } /*--- Initialize the solution and right hand side vectors for storing From 5534707ecada03072bb25836d1df08ca9c416869 Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Tue, 28 Jan 2020 15:30:48 +0000 Subject: [PATCH 025/118] thread-safe AUSM family --- SU2_CFD/include/numerics/CNumerics.hpp | 6 +- .../numerics/flow/convection/ausm_slau.hpp | 49 +++++---- .../numerics/flow/convection/centered.hpp | 21 ++-- .../numerics/flow/convection/ausm_slau.cpp | 99 +++++++++++-------- .../src/numerics/flow/convection/centered.cpp | 6 +- 5 files changed, 107 insertions(+), 74 deletions(-) diff --git a/SU2_CFD/include/numerics/CNumerics.hpp b/SU2_CFD/include/numerics/CNumerics.hpp index 473e52adb1d0..ab4a426fb8fa 100644 --- a/SU2_CFD/include/numerics/CNumerics.hpp +++ b/SU2_CFD/include/numerics/CNumerics.hpp @@ -47,14 +47,16 @@ class CFluidModel; */ class CNumerics { protected: + enum : size_t {MAXNDIM = 3}; /*!< \brief Max number of space dimensions, used in some static arrays. */ + unsigned short nDim, nVar; /*!< \brief Number of dimensions and variables. */ su2double Gamma; /*!< \brief Fluid's Gamma constant (ratio of specific heats). */ su2double Gamma_Minus_One; /*!< \brief Fluids's Gamma - 1.0 . */ su2double Minf; /*!< \brief Free stream Mach number . */ su2double Gas_Constant; /*!< \brief Gas constant. */ su2double *Vector; /*!< \brief Auxiliary vector. */ - su2double Prandtl_Lam; /*!< \brief Laminar Prandtl's number. */ - su2double Prandtl_Turb; /*!< \brief Turbulent Prandtl's number. */ + su2double Prandtl_Lam; /*!< \brief Laminar Prandtl's number. */ + su2double Prandtl_Turb; /*!< \brief Turbulent Prandtl's number. */ su2double **Flux_Tensor, /*!< \brief Flux tensor (used for viscous and inviscid purposes. */ *Proj_Flux_Tensor; /*!< \brief Flux tensor projected in a direction. */ diff --git a/SU2_CFD/include/numerics/flow/convection/ausm_slau.hpp b/SU2_CFD/include/numerics/flow/convection/ausm_slau.hpp index 2cafcff57ca4..b9e5576a0a61 100644 --- a/SU2_CFD/include/numerics/flow/convection/ausm_slau.hpp +++ b/SU2_CFD/include/numerics/flow/convection/ausm_slau.hpp @@ -34,7 +34,7 @@ * \class CUpwAUSMPLUS_SLAU_Base_Flow * \brief Base class for AUSM+up(2) and SLAU(2) convective schemes. * \ingroup ConvDiscr - * \author Amit Sachdeva + * \author Amit Sachdeva, P. Gomes */ class CUpwAUSMPLUS_SLAU_Base_Flow : public CNumerics { protected: @@ -44,12 +44,17 @@ class CUpwAUSMPLUS_SLAU_Base_Flow : public CNumerics { su2double FinDiffStep; su2double MassFlux, DissFlux, Pressure; - su2double *Velocity_i, *Velocity_j; - su2double *psi_i, *psi_j; + su2double Velocity_i[MAXNDIM] = {0.0}, Velocity_j[MAXNDIM] = {0.0}; + su2double *psi_i = nullptr, *psi_j = nullptr; su2double dmdot_dVi[6], dmdot_dVj[6], dpres_dVi[6], dpres_dVj[6]; /*--- Roe variables (for approximate Jacobian) ---*/ - su2double *Lambda, *Epsilon, *RoeVelocity, **P_Tensor, **invP_Tensor; + su2double *Lambda = nullptr, *Epsilon = nullptr, RoeVelocity[MAXNDIM] = {0.0}; + su2double **P_Tensor = nullptr, **invP_Tensor = nullptr; + + su2double* Flux = nullptr; /*!< \brief The flux accross the face. */ + su2double** Jacobian_i = nullptr; /*!< \brief The Jacobian w.r.t. point i after computation. */ + su2double** Jacobian_j = nullptr; /*!< \brief The Jacobian w.r.t. point j after computation. */ /*! * \brief Compute the mass flux and pressure based on Primitives_i/j, derived classes must implement this method. @@ -60,6 +65,7 @@ class CUpwAUSMPLUS_SLAU_Base_Flow : public CNumerics { */ virtual void ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure) = 0; +private: /*! * \brief Compute the flux Jacobians of the Roe scheme to use as an approximation. * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). @@ -96,16 +102,17 @@ class CUpwAUSMPLUS_SLAU_Base_Flow : public CNumerics { * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). * \param[in] config - Definition of the particular problem. */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + void ComputeResidual(const su2double* &residual, const su2double* const* &jacobian_i, + const su2double* const* &jacobian_j, CConfig *config) final; }; /*! * \class CUpwAUSMPLUSUP_Flow * \brief Class for solving an approximate Riemann AUSM+ -up. * \ingroup ConvDiscr - * \author Amit Sachdeva + * \author Amit Sachdeva, P. Gomes */ -class CUpwAUSMPLUSUP_Flow : public CUpwAUSMPLUS_SLAU_Base_Flow { +class CUpwAUSMPLUSUP_Flow final : public CUpwAUSMPLUS_SLAU_Base_Flow { private: su2double Kp, Ku, sigma; @@ -115,7 +122,7 @@ class CUpwAUSMPLUSUP_Flow : public CUpwAUSMPLUS_SLAU_Base_Flow { * \param[out] mdot - The mass flux. * \param[out] pressure - The pressure at the control volume face. */ - void ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure); + void ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure) override; public: @@ -133,9 +140,9 @@ class CUpwAUSMPLUSUP_Flow : public CUpwAUSMPLUS_SLAU_Base_Flow { * \class CUpwAUSMPLUSUP2_Flow * \brief Class for solving an approximate Riemann AUSM+ -up. * \ingroup ConvDiscr - * \author Amit Sachdeva + * \author Amit Sachdeva, P. Gomes */ -class CUpwAUSMPLUSUP2_Flow : public CUpwAUSMPLUS_SLAU_Base_Flow { +class CUpwAUSMPLUSUP2_Flow final : public CUpwAUSMPLUS_SLAU_Base_Flow { private: su2double Kp, sigma; @@ -145,7 +152,7 @@ class CUpwAUSMPLUSUP2_Flow : public CUpwAUSMPLUS_SLAU_Base_Flow { * \param[out] mdot - The mass flux. * \param[out] pressure - The pressure at the control volume face. */ - void ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure); + void ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure) override; public: @@ -163,7 +170,7 @@ class CUpwAUSMPLUSUP2_Flow : public CUpwAUSMPLUS_SLAU_Base_Flow { * \class CUpwSLAU_Flow * \brief Class for solving the Low-Dissipation AUSM. * \ingroup ConvDiscr - * \author E. Molina + * \author E. Molina, P. Gomes */ class CUpwSLAU_Flow : public CUpwAUSMPLUS_SLAU_Base_Flow { protected: @@ -176,7 +183,7 @@ class CUpwSLAU_Flow : public CUpwAUSMPLUS_SLAU_Base_Flow { * \param[out] mdot - The mass flux. * \param[out] pressure - The pressure at the control volume face. */ - void ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure); + void ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure) final; public: @@ -194,9 +201,9 @@ class CUpwSLAU_Flow : public CUpwAUSMPLUS_SLAU_Base_Flow { * \class CUpwSLAU2_Flow * \brief Class for solving the Simple Low-Dissipation AUSM 2. * \ingroup ConvDiscr - * \author E. Molina + * \author E. Molina, P. Gomes */ -class CUpwSLAU2_Flow : public CUpwSLAU_Flow { +class CUpwSLAU2_Flow final : public CUpwSLAU_Flow { public: /*! * \brief Constructor of the class. @@ -214,13 +221,13 @@ class CUpwSLAU2_Flow : public CUpwSLAU_Flow { * \ingroup ConvDiscr * \author F. Palacios */ -class CUpwAUSM_Flow : public CNumerics { +class CUpwAUSM_Flow final : public CNumerics { private: bool implicit; su2double *Diff_U; - su2double *Velocity_i, *Velocity_j, *RoeVelocity; + su2double Velocity_i[MAXNDIM], Velocity_j[MAXNDIM], RoeVelocity[MAXNDIM]; su2double *ProjFlux_i, *ProjFlux_j; - su2double *delta_wave, *delta_vel; + su2double *delta_wave, delta_vel[MAXNDIM]; su2double *Lambda, *Epsilon; su2double **P_Tensor, **invP_Tensor; su2double sq_vel, Proj_ModJac_Tensor_ij, Density_i, Energy_i, SoundSpeed_i, Pressure_i, Enthalpy_i, @@ -229,6 +236,9 @@ class CUpwAUSM_Flow : public CNumerics { unsigned short iDim, iVar, jVar, kVar; su2double mL, mR, mLP, mRM, mF, pLP, pRM, pF, Phi; + su2double* Flux; /*!< \brief The flux accross the face. */ + su2double** Jacobian_i; /*!< \brief The Jacobian w.r.t. point i after computation. */ + su2double** Jacobian_j; /*!< \brief The Jacobian w.r.t. point j after computation. */ public: /*! @@ -251,5 +261,6 @@ class CUpwAUSM_Flow : public CNumerics { * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). * \param[in] config - Definition of the particular problem. */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + void ComputeResidual(const su2double* &residual, const su2double* const* &jacobian_i, + const su2double* const* &jacobian_j, CConfig *config) override; }; diff --git a/SU2_CFD/include/numerics/flow/convection/centered.hpp b/SU2_CFD/include/numerics/flow/convection/centered.hpp index 6a2ea10173b1..a61997082845 100644 --- a/SU2_CFD/include/numerics/flow/convection/centered.hpp +++ b/SU2_CFD/include/numerics/flow/convection/centered.hpp @@ -44,8 +44,9 @@ class CCentBase_Flow : public CNumerics { bool implicit; /*!< \brief Implicit calculation (compute Jacobians). */ su2double fix_factor; /*!< \brief Fix factor for dissipation Jacobians (more diagonal dominance). */ - su2double Velocity_i[3], Velocity_j[3]; /*!< \brief Velocity at nodes i and j. */ - su2double MeanVelocity[3]; /*!< \brief Mean velocity. */ + su2double Velocity_i[MAXNDIM] = {0.0}; /*!< \brief Velocity at node i. */ + su2double Velocity_j[MAXNDIM] = {0.0}; /*!< \brief Velocity at node j. */ + su2double MeanVelocity[MAXNDIM] = {0.0}; /*!< \brief Mean velocity. */ su2double ProjVelocity_i, ProjVelocity_j; /*!< \brief Velocities in the face normal direction. */ su2double sq_vel_i, sq_vel_j; /*!< \brief Squared norm of the velocity vectors. */ su2double Energy_i, Energy_j, MeanEnergy; /*!< \brief Energy at nodes i and j and mean. */ @@ -114,7 +115,7 @@ class CCentBase_Flow : public CNumerics { * \ingroup ConvDiscr * \author F. Palacios */ -class CCentLax_Flow : public CCentBase_Flow { +class CCentLax_Flow final : public CCentBase_Flow { private: su2double Param_Kappa_0; /*!< \brief Artificial dissipation parameter. */ su2double sc0; /*!< \brief Streching parameter. */ @@ -126,13 +127,13 @@ class CCentLax_Flow : public CCentBase_Flow { * \param[in,out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). * \param[in,out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). */ - void DissipationTerm(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j); + void DissipationTerm(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j) override; /*! * \brief Set input variables for AD preaccumulation. * \return true, as we will define inputs. */ - bool SetPreaccInVars(void); + bool SetPreaccInVars(void) override; public: /*! @@ -151,7 +152,7 @@ class CCentLax_Flow : public CCentBase_Flow { * \ingroup ConvDiscr * \author F. Palacios */ -class CCentJST_KE_Flow : public CCentBase_Flow { +class CCentJST_KE_Flow final : public CCentBase_Flow { private: su2double Param_Kappa_2; /*!< \brief Artificial dissipation parameter. */ @@ -164,7 +165,7 @@ class CCentJST_KE_Flow : public CCentBase_Flow { * \param[in,out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). * \param[in,out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). */ - void DissipationTerm(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j); + void DissipationTerm(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j) override; /*! * \brief Set input variables for AD preaccumulation. @@ -189,7 +190,7 @@ class CCentJST_KE_Flow : public CCentBase_Flow { * \ingroup ConvDiscr * \author F. Palacios */ -class CCentJST_Flow : public CCentBase_Flow { +class CCentJST_Flow final : public CCentBase_Flow { private: su2double Param_Kappa_2, Param_Kappa_4; /*!< \brief Artificial dissipation parameters. */ @@ -202,13 +203,13 @@ class CCentJST_Flow : public CCentBase_Flow { * \param[in,out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). * \param[in,out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). */ - void DissipationTerm(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j); + void DissipationTerm(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j) override; /*! * \brief Set input variables for AD preaccumulation. * \return true, as we will define inputs. */ - bool SetPreaccInVars(void); + bool SetPreaccInVars(void) override; public: /*! diff --git a/SU2_CFD/src/numerics/flow/convection/ausm_slau.cpp b/SU2_CFD/src/numerics/flow/convection/ausm_slau.cpp index ac1e4ac97e54..cab137b00c61 100644 --- a/SU2_CFD/src/numerics/flow/convection/ausm_slau.cpp +++ b/SU2_CFD/src/numerics/flow/convection/ausm_slau.cpp @@ -41,38 +41,42 @@ CUpwAUSMPLUS_SLAU_Base_Flow::CUpwAUSMPLUS_SLAU_Base_Flow(unsigned short val_nDim Gamma = config->GetGamma(); Gamma_Minus_One = Gamma - 1.0; - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; psi_i = new su2double [nVar]; psi_j = new su2double [nVar]; - RoeVelocity = new su2double [nDim]; + Flux = new su2double [nVar]; Lambda = new su2double [nVar]; Epsilon = new su2double [nVar]; P_Tensor = new su2double* [nVar]; invP_Tensor = new su2double* [nVar]; + Jacobian_i = new su2double* [nVar]; + Jacobian_j = new su2double* [nVar]; for (unsigned short iVar = 0; iVar < nVar; iVar++) { P_Tensor[iVar] = new su2double [nVar]; invP_Tensor[iVar] = new su2double [nVar]; + Jacobian_i[iVar] = new su2double [nVar]; + Jacobian_j[iVar] = new su2double [nVar]; } } CUpwAUSMPLUS_SLAU_Base_Flow::~CUpwAUSMPLUS_SLAU_Base_Flow(void) { - delete [] Velocity_i; - delete [] Velocity_j; delete [] psi_i; delete [] psi_j; - delete [] RoeVelocity; + delete [] Flux; delete [] Lambda; delete [] Epsilon; for (unsigned short iVar = 0; iVar < nVar; iVar++) { delete [] P_Tensor[iVar]; delete [] invP_Tensor[iVar]; + delete [] Jacobian_i[iVar]; + delete [] Jacobian_j[iVar]; } delete [] P_Tensor; delete [] invP_Tensor; + delete [] Jacobian_i; + delete [] Jacobian_j; } @@ -308,8 +312,10 @@ void CUpwAUSMPLUS_SLAU_Base_Flow::AccurateJacobian(CConfig *config, su2double ** } -void CUpwAUSMPLUS_SLAU_Base_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - +void CUpwAUSMPLUS_SLAU_Base_Flow::ComputeResidual(const su2double* &residual, + const su2double* const* &jacobian_i, + const su2double* const* &jacobian_j, + CConfig *config) { unsigned short iDim, iVar; /*--- Space to start preaccumulation ---*/ @@ -354,32 +360,36 @@ void CUpwAUSMPLUS_SLAU_Base_Flow::ComputeResidual(su2double *val_residual, su2do ComputeMassAndPressureFluxes(config, MassFlux, Pressure); DissFlux = fabs(MassFlux); - val_residual[0] = MassFlux; + Flux[0] = MassFlux; for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = 0.5*MassFlux*(psi_i[iDim+1]+psi_j[iDim+1]) + - 0.5*DissFlux*(psi_i[iDim+1]-psi_j[iDim+1]) + - UnitNormal[iDim]*Pressure; + Flux[iDim+1] = 0.5*MassFlux*(psi_i[iDim+1]+psi_j[iDim+1]) + + 0.5*DissFlux*(psi_i[iDim+1]-psi_j[iDim+1]) + + UnitNormal[iDim]*Pressure; - val_residual[nVar-1] = 0.5*MassFlux*(psi_i[nVar-1]+psi_j[nVar-1]) + - 0.5*DissFlux*(psi_i[nVar-1]-psi_j[nVar-1]); + Flux[nVar-1] = 0.5*MassFlux*(psi_i[nVar-1]+psi_j[nVar-1]) + + 0.5*DissFlux*(psi_i[nVar-1]-psi_j[nVar-1]); - for (iVar = 0; iVar < nVar; iVar++) val_residual[iVar] *= Area; + for (iVar = 0; iVar < nVar; iVar++) Flux[iVar] *= Area; /*--- Space to end preaccumulation ---*/ - AD::SetPreaccOut(val_residual, nVar); + AD::SetPreaccOut(Flux, nVar); AD::EndPreacc(); + residual = Flux; + /*--- If required, compute Jacobians, either approximately (Roe) or numerically ---*/ if (!implicit) return; if (UseAccurateJacobian) - AccurateJacobian(config, val_Jacobian_i, val_Jacobian_j); + AccurateJacobian(config, Jacobian_i, Jacobian_j); else - ApproximateJacobian(val_Jacobian_i, val_Jacobian_j); + ApproximateJacobian(Jacobian_i, Jacobian_j); + jacobian_i = Jacobian_i; + jacobian_j = Jacobian_j; } CUpwAUSMPLUSUP_Flow::CUpwAUSMPLUSUP_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : @@ -788,11 +798,8 @@ CUpwAUSM_Flow::CUpwAUSM_Flow(unsigned short val_nDim, unsigned short val_nVar, C Gamma = config->GetGamma(); Gamma_Minus_One = Gamma - 1.0; + Flux = new su2double [nVar]; Diff_U = new su2double [nVar]; - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; - RoeVelocity = new su2double [nDim]; - delta_vel = new su2double [nDim]; delta_wave = new su2double [nVar]; ProjFlux_i = new su2double [nVar]; ProjFlux_j = new su2double [nVar]; @@ -800,35 +807,42 @@ CUpwAUSM_Flow::CUpwAUSM_Flow(unsigned short val_nDim, unsigned short val_nVar, C Epsilon = new su2double [nVar]; P_Tensor = new su2double* [nVar]; invP_Tensor = new su2double* [nVar]; - for (iVar = 0; iVar < nVar; iVar++) { + Jacobian_i = new su2double* [nVar]; + Jacobian_j = new su2double* [nVar]; + for (unsigned short iVar = 0; iVar < nVar; iVar++) { P_Tensor[iVar] = new su2double [nVar]; invP_Tensor[iVar] = new su2double [nVar]; + Jacobian_i[iVar] = new su2double [nVar]; + Jacobian_j[iVar] = new su2double [nVar]; } } CUpwAUSM_Flow::~CUpwAUSM_Flow(void) { + delete [] Flux; delete [] Diff_U; - delete [] Velocity_i; - delete [] Velocity_j; - delete [] RoeVelocity; - delete [] delta_vel; delete [] delta_wave; delete [] ProjFlux_i; delete [] ProjFlux_j; delete [] Lambda; delete [] Epsilon; - for (iVar = 0; iVar < nVar; iVar++) { + for (unsigned short iVar = 0; iVar < nVar; iVar++) { delete [] P_Tensor[iVar]; delete [] invP_Tensor[iVar]; + delete [] Jacobian_i[iVar]; + delete [] Jacobian_j[iVar]; } delete [] P_Tensor; delete [] invP_Tensor; + delete [] Jacobian_i; + delete [] Jacobian_j; } -void CUpwAUSM_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - +void CUpwAUSM_Flow::ComputeResidual(const su2double* &residual, + const su2double* const* &jacobian_i, + const su2double* const* &jacobian_j, + CConfig *config) { AD::StartPreacc(); AD::SetPreaccIn(Normal, nDim); AD::SetPreaccIn(V_i, nDim+4); @@ -895,18 +909,20 @@ void CUpwAUSM_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jac pF = pLP + pRM; Phi = fabs(mF); - val_residual[0] = 0.5*(mF*((Density_i*SoundSpeed_i)+(Density_j*SoundSpeed_j))-Phi*((Density_j*SoundSpeed_j)-(Density_i*SoundSpeed_i))); + Flux[0] = 0.5*(mF*((Density_i*SoundSpeed_i)+(Density_j*SoundSpeed_j))-Phi*((Density_j*SoundSpeed_j)-(Density_i*SoundSpeed_i))); for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = 0.5*(mF*((Density_i*SoundSpeed_i*Velocity_i[iDim])+(Density_j*SoundSpeed_j*Velocity_j[iDim])) - -Phi*((Density_j*SoundSpeed_j*Velocity_j[iDim])-(Density_i*SoundSpeed_i*Velocity_i[iDim])))+UnitNormal[iDim]*pF; - val_residual[nVar-1] = 0.5*(mF*((Density_i*SoundSpeed_i*Enthalpy_i)+(Density_j*SoundSpeed_j*Enthalpy_j))-Phi*((Density_j*SoundSpeed_j*Enthalpy_j)-(Density_i*SoundSpeed_i*Enthalpy_i))); + Flux[iDim+1] = 0.5*(mF*((Density_i*SoundSpeed_i*Velocity_i[iDim])+(Density_j*SoundSpeed_j*Velocity_j[iDim])) + -Phi*((Density_j*SoundSpeed_j*Velocity_j[iDim])-(Density_i*SoundSpeed_i*Velocity_i[iDim])))+UnitNormal[iDim]*pF; + Flux[nVar-1] = 0.5*(mF*((Density_i*SoundSpeed_i*Enthalpy_i)+(Density_j*SoundSpeed_j*Enthalpy_j))-Phi*((Density_j*SoundSpeed_j*Enthalpy_j)-(Density_i*SoundSpeed_i*Enthalpy_i))); for (iVar = 0; iVar < nVar; iVar++) - val_residual[iVar] *= Area; + Flux[iVar] *= Area; - AD::SetPreaccOut(val_residual, nVar); + AD::SetPreaccOut(Flux, nVar); AD::EndPreacc(); + residual = Flux; + /*--- Roe's Jacobian for AUSM (this must be fixed) ---*/ if (implicit) { @@ -941,8 +957,8 @@ void CUpwAUSM_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jac GetPMatrix_inv(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, invP_Tensor); /*--- Jacobias of the inviscid flux, scale = 0.5 because val_residual ~ 0.5*(fc_i+fc_j)*Normal ---*/ - GetInviscidProjJac(Velocity_i, &Energy_i, Normal, 0.5, val_Jacobian_i); - GetInviscidProjJac(Velocity_j, &Energy_j, Normal, 0.5, val_Jacobian_j); + GetInviscidProjJac(Velocity_i, &Energy_i, Normal, 0.5, Jacobian_i); + GetInviscidProjJac(Velocity_j, &Energy_j, Normal, 0.5, Jacobian_j); /*--- Roe's Flux approximation ---*/ for (iVar = 0; iVar < nVar; iVar++) { @@ -951,9 +967,12 @@ void CUpwAUSM_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jac /*--- Compute |Proj_ModJac_Tensor| = P x |Lambda| x inverse P ---*/ for (kVar = 0; kVar < nVar; kVar++) Proj_ModJac_Tensor_ij += P_Tensor[iVar][kVar]*fabs(Lambda[kVar])*invP_Tensor[kVar][jVar]; - val_Jacobian_i[iVar][jVar] += 0.5*Proj_ModJac_Tensor_ij*Area; - val_Jacobian_j[iVar][jVar] -= 0.5*Proj_ModJac_Tensor_ij*Area; + Jacobian_i[iVar][jVar] += 0.5*Proj_ModJac_Tensor_ij*Area; + Jacobian_j[iVar][jVar] -= 0.5*Proj_ModJac_Tensor_ij*Area; } } + + jacobian_i = Jacobian_i; + jacobian_j = Jacobian_j; } } diff --git a/SU2_CFD/src/numerics/flow/convection/centered.cpp b/SU2_CFD/src/numerics/flow/convection/centered.cpp index 629c204cc89f..2f50d3b59f59 100644 --- a/SU2_CFD/src/numerics/flow/convection/centered.cpp +++ b/SU2_CFD/src/numerics/flow/convection/centered.cpp @@ -67,7 +67,7 @@ void CCentBase_Flow::ComputeResidual(const su2double* &residual, const su2double* const* &jacobian_j, CConfig *config) { - su2double U_i[5] = {0.0,0.0,0.0,0.0,0.0}, U_j[5] = {0.0,0.0,0.0,0.0,0.0}; + su2double U_i[5] = {0.0}, U_j[5] = {0.0}; bool preacc = SetPreaccInVars(); @@ -381,7 +381,7 @@ CCentLaxInc_Flow::~CCentLaxInc_Flow(void) { void CCentLaxInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - su2double U_i[5] = {0.0,0.0,0.0,0.0,0.0}, U_j[5] = {0.0,0.0,0.0,0.0,0.0}; + su2double U_i[5] = {0.0}, U_j[5] = {0.0}; su2double ProjGridVel = 0.0, ProjVelocity = 0.0; /*--- Primitive variables at point i and j ---*/ @@ -591,7 +591,7 @@ CCentJSTInc_Flow::~CCentJSTInc_Flow(void) { void CCentJSTInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - su2double U_i[5] = {0.0,0.0,0.0,0.0,0.0}, U_j[5] = {0.0,0.0,0.0,0.0,0.0}; + su2double U_i[5] = {0.0}, U_j[5] = {0.0}; su2double ProjGridVel = 0.0; /*--- Primitive variables at point i and j ---*/ From c0713190ef872d6a4968f80ac451eddc03424b5d Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Tue, 28 Jan 2020 15:36:06 +0000 Subject: [PATCH 026/118] thread safe CUSP --- .../include/numerics/flow/convection/cusp.hpp | 11 ++-- SU2_CFD/src/numerics/flow/convection/cusp.cpp | 56 ++++++++++++------- 2 files changed, 43 insertions(+), 24 deletions(-) diff --git a/SU2_CFD/include/numerics/flow/convection/cusp.hpp b/SU2_CFD/include/numerics/flow/convection/cusp.hpp index 82eff71a5453..7c8a6f48b0e8 100644 --- a/SU2_CFD/include/numerics/flow/convection/cusp.hpp +++ b/SU2_CFD/include/numerics/flow/convection/cusp.hpp @@ -35,12 +35,15 @@ * \ingroup ConvDiscr * \author F. Palacios */ -class CUpwCUSP_Flow : public CNumerics { +class CUpwCUSP_Flow final : public CNumerics { private: - su2double *Velocity_i, *Velocity_j, *ProjFlux_i, *ProjFlux_j; + su2double Velocity_i[MAXNDIM], Velocity_j[MAXNDIM], *ProjFlux_i, *ProjFlux_j; bool implicit; + su2double* Flux; /*!< \brief The flux accross the face. */ + su2double** Jacobian_i; /*!< \brief The Jacobian w.r.t. point i after computation. */ + su2double** Jacobian_j; /*!< \brief The Jacobian w.r.t. point j after computation. */ public: /*! @@ -63,6 +66,6 @@ class CUpwCUSP_Flow : public CNumerics { * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). * \param[in] config - Definition of the particular problem. */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, - CConfig *config); + void ComputeResidual(const su2double* &residual, const su2double* const* &jacobian_i, + const su2double* const* &jacobian_j, CConfig *config) override; }; diff --git a/SU2_CFD/src/numerics/flow/convection/cusp.cpp b/SU2_CFD/src/numerics/flow/convection/cusp.cpp index 28372cf570db..b27d1dda6fa0 100644 --- a/SU2_CFD/src/numerics/flow/convection/cusp.cpp +++ b/SU2_CFD/src/numerics/flow/convection/cusp.cpp @@ -38,24 +38,35 @@ CUpwCUSP_Flow::CUpwCUSP_Flow(unsigned short val_nDim, unsigned short val_nVar, C cout << "WARNING: Grid velocities are NOT yet considered by the CUSP scheme." << endl; /*--- Allocate some structures ---*/ - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; + Flux = new su2double [nVar]; ProjFlux_i = new su2double [nVar]; ProjFlux_j = new su2double [nVar]; + Jacobian_i = new su2double* [nVar]; + Jacobian_j = new su2double* [nVar]; + for (unsigned short iVar = 0; iVar < nVar; iVar++) { + Jacobian_i[iVar] = new su2double [nVar]; + Jacobian_j[iVar] = new su2double [nVar]; + } } CUpwCUSP_Flow::~CUpwCUSP_Flow(void) { - delete [] Velocity_i; - delete [] Velocity_j; + delete [] Flux; delete [] ProjFlux_i; delete [] ProjFlux_j; + for (unsigned short iVar = 0; iVar < nVar; iVar++) { + delete [] Jacobian_i[iVar]; + delete [] Jacobian_j[iVar]; + } + delete [] Jacobian_i; + delete [] Jacobian_j; } -void CUpwCUSP_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, - CConfig *config) { - +void CUpwCUSP_Flow::ComputeResidual(const su2double* &residual, + const su2double* const* &jacobian_i, + const su2double* const* &jacobian_j, + CConfig *config) { unsigned short iDim, iVar; - su2double Diff_U[5] = {0.0,0.0,0.0,0.0,0.0}; + su2double Diff_U[5] = {0.0}; AD::SetPreaccIn(Normal, nDim); AD::SetPreaccIn(V_i, nDim+4); @@ -134,7 +145,7 @@ void CUpwCUSP_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jac /*--- Compute the residual ---*/ for (iVar = 0; iVar < nVar; iVar++) - val_residual[iVar] = 0.5*((1.0+Beta)*ProjFlux_i[iVar] + (1.0-Beta)*ProjFlux_j[iVar] + Nu_c*Diff_U[iVar])*Area; + Flux[iVar] = 0.5*((1.0+Beta)*ProjFlux_i[iVar] + (1.0-Beta)*ProjFlux_j[iVar] + Nu_c*Diff_U[iVar])*Area; /*--- Jacobian computation ---*/ @@ -142,8 +153,8 @@ void CUpwCUSP_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jac /*--- Flux average and difference contributions ---*/ - GetInviscidProjJac(Velocity_i, &Energy_i, Normal, 0.5*(1.0+Beta), val_Jacobian_i); - GetInviscidProjJac(Velocity_j, &Energy_j, Normal, 0.5*(1.0-Beta), val_Jacobian_j); + GetInviscidProjJac(Velocity_i, &Energy_i, Normal, 0.5*(1.0+Beta), Jacobian_i); + GetInviscidProjJac(Velocity_j, &Energy_j, Normal, 0.5*(1.0-Beta), Jacobian_j); /*--- Solution difference (scalar dissipation) contribution ---*/ @@ -152,24 +163,29 @@ void CUpwCUSP_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jac /*--- n-1 diagonal entries ---*/ for (iVar = 0; iVar < (nVar-1); iVar++) { - val_Jacobian_i[iVar][iVar] += cte_0; - val_Jacobian_j[iVar][iVar] -= cte_0; + Jacobian_i[iVar][iVar] += cte_0; + Jacobian_j[iVar][iVar] -= cte_0; } /*--- Last rows ---*/ - val_Jacobian_i[nVar-1][0] += cte_0*Gamma_Minus_One*0.5*sq_vel_i; + Jacobian_i[nVar-1][0] += cte_0*Gamma_Minus_One*0.5*sq_vel_i; for (iDim = 0; iDim < nDim; iDim++) - val_Jacobian_i[nVar-1][iDim+1] -= cte_0*Gamma_Minus_One*Velocity_i[iDim]; - val_Jacobian_i[nVar-1][nVar-1] += cte_0*Gamma; + Jacobian_i[nVar-1][iDim+1] -= cte_0*Gamma_Minus_One*Velocity_i[iDim]; + Jacobian_i[nVar-1][nVar-1] += cte_0*Gamma; - val_Jacobian_j[nVar-1][0] -= cte_0*Gamma_Minus_One*0.5*sq_vel_j; + Jacobian_j[nVar-1][0] -= cte_0*Gamma_Minus_One*0.5*sq_vel_j; for (iDim = 0; iDim < nDim; iDim++) - val_Jacobian_j[nVar-1][iDim+1] += cte_0*Gamma_Minus_One*Velocity_j[iDim]; - val_Jacobian_j[nVar-1][nVar-1] -= cte_0*Gamma; + Jacobian_j[nVar-1][iDim+1] += cte_0*Gamma_Minus_One*Velocity_j[iDim]; + Jacobian_j[nVar-1][nVar-1] -= cte_0*Gamma; } - AD::SetPreaccOut(val_residual, nVar); + AD::SetPreaccOut(Flux, nVar); AD::EndPreacc(); + + residual = Flux; + jacobian_i = Jacobian_i; + jacobian_j = Jacobian_j; + } From 91303e9f967ee9863af6572d087a3e4a2e237b62 Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Tue, 28 Jan 2020 15:42:41 +0000 Subject: [PATCH 027/118] thread safe MSW --- .../include/numerics/flow/convection/fvs.hpp | 8 ++- SU2_CFD/src/numerics/flow/convection/fvs.cpp | 55 +++++++++++-------- 2 files changed, 39 insertions(+), 24 deletions(-) diff --git a/SU2_CFD/include/numerics/flow/convection/fvs.hpp b/SU2_CFD/include/numerics/flow/convection/fvs.hpp index 57b4a078008f..5d96448bd82c 100644 --- a/SU2_CFD/include/numerics/flow/convection/fvs.hpp +++ b/SU2_CFD/include/numerics/flow/convection/fvs.hpp @@ -36,7 +36,7 @@ * \ingroup ConvDiscr * \author S. Copeland */ -class CUpwMSW_Flow : public CNumerics { +class CUpwMSW_Flow final : public CNumerics { private: bool implicit; su2double *Diff_U; @@ -48,6 +48,9 @@ class CUpwMSW_Flow : public CNumerics { su2double **P_Tensor, **invP_Tensor; unsigned short nPrimVar, nVar, nDim; + su2double** Jacobian_i; /*!< \brief The Jacobian w.r.t. point i after computation. */ + su2double** Jacobian_j; /*!< \brief The Jacobian w.r.t. point j after computation. */ + public: /*! @@ -70,6 +73,7 @@ class CUpwMSW_Flow : public CNumerics { * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). * \param[in] config - Definition of the particular problem. */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + void ComputeResidual(const su2double* &residual, const su2double* const* &jacobian_i, + const su2double* const* &jacobian_j, CConfig *config) override; }; diff --git a/SU2_CFD/src/numerics/flow/convection/fvs.cpp b/SU2_CFD/src/numerics/flow/convection/fvs.cpp index 2639c482c66b..b3a2e66d9359 100644 --- a/SU2_CFD/src/numerics/flow/convection/fvs.cpp +++ b/SU2_CFD/src/numerics/flow/convection/fvs.cpp @@ -42,8 +42,8 @@ CUpwMSW_Flow::CUpwMSW_Flow(unsigned short val_nDim, unsigned short val_nVar, CCo Lambda_i = new su2double [nVar]; Lambda_j = new su2double [nVar]; - u_i = new su2double [nDim]; - u_j = new su2double [nDim]; + u_i = new su2double [nDim]; + u_j = new su2double [nDim]; ust_i = new su2double [nDim]; ust_j = new su2double [nDim]; Vst_i = new su2double [nPrimVar]; @@ -54,11 +54,15 @@ CUpwMSW_Flow::CUpwMSW_Flow(unsigned short val_nDim, unsigned short val_nVar, CCo Velst_i = new su2double [nDim]; Velst_j = new su2double [nDim]; - P_Tensor = new su2double* [nVar]; - invP_Tensor = new su2double* [nVar]; + P_Tensor = new su2double* [nVar]; + invP_Tensor= new su2double* [nVar]; + Jacobian_i = new su2double* [nVar]; + Jacobian_j = new su2double* [nVar]; for (unsigned short iVar = 0; iVar < nVar; iVar++) { - P_Tensor[iVar] = new su2double [nVar]; + P_Tensor[iVar] = new su2double [nVar]; invP_Tensor[iVar] = new su2double [nVar]; + Jacobian_i[iVar] = new su2double [nVar]; + Jacobian_j[iVar] = new su2double [nVar]; } } @@ -85,15 +89,20 @@ CUpwMSW_Flow::~CUpwMSW_Flow(void) { for (unsigned short iVar = 0; iVar < nVar; iVar++) { delete [] P_Tensor[iVar]; delete [] invP_Tensor[iVar]; + delete [] Jacobian_i[iVar]; + delete [] Jacobian_j[iVar]; } delete [] P_Tensor; delete [] invP_Tensor; + delete [] Jacobian_i; + delete [] Jacobian_j; } -void CUpwMSW_Flow::ComputeResidual(su2double *val_residual, - su2double **val_Jacobian_i, - su2double **val_Jacobian_j, CConfig *config) { +void CUpwMSW_Flow::ComputeResidual(const su2double* &residual, + const su2double* const* &jacobian_i, + const su2double* const* &jacobian_j, + CConfig *config) { unsigned short iDim, iVar, jVar, kVar; su2double P_i, P_j; @@ -124,8 +133,8 @@ void CUpwMSW_Flow::ComputeResidual(su2double *val_residual, if (implicit) { for (iVar = 0; iVar < nVar; iVar++) { for (jVar = 0; jVar < nVar; jVar++) { - val_Jacobian_i[iVar][jVar] = 0.0; - val_Jacobian_j[iVar][jVar] = 0.0; + Jacobian_i[iVar][jVar] = 0.0; + Jacobian_j[iVar][jVar] = 0.0; } } } @@ -179,11 +188,11 @@ void CUpwMSW_Flow::ComputeResidual(su2double *val_residual, /*--- Flow eigenvalues at i (Lambda+) ---*/ for (iDim = 0; iDim < nDim; iDim++) { - Lambda_i[iDim] = 0.5*(ProjVelst_i + fabs(ProjVelst_i)); + Lambda_i[iDim] = 0.5*(ProjVelst_i + fabs(ProjVelst_i)); } - Lambda_i[nDim] = 0.5*( ProjVelst_i + Vst_i[nDim+4] + fabs(ProjVelst_i + Vst_i[nDim+4]) ); - Lambda_i[nDim+1] = 0.5*( ProjVelst_i - Vst_i[nDim+4] + fabs(ProjVelst_i - Vst_i[nDim+4]) ); + Lambda_i[nDim] = 0.5*( ProjVelst_i + Vst_i[nDim+4] + fabs(ProjVelst_i + Vst_i[nDim+4]) ); + Lambda_i[nDim+1] = 0.5*( ProjVelst_i - Vst_i[nDim+4] + fabs(ProjVelst_i - Vst_i[nDim+4]) ); /*--- Compute projected P, invP, and Lambda ---*/ @@ -202,19 +211,17 @@ void CUpwMSW_Flow::ComputeResidual(su2double *val_residual, Proj_ModJac_Tensor_i += P_Tensor[iVar][kVar]*Lambda_i[kVar]*invP_Tensor[kVar][jVar]; Fc_i[iVar] += Proj_ModJac_Tensor_i*U_i[jVar]*Area; if (implicit) - val_Jacobian_i[iVar][jVar] += Proj_ModJac_Tensor_i*Area; + Jacobian_i[iVar][jVar] += Proj_ModJac_Tensor_i*Area; } } /*--- Flow eigenvalues at j (Lambda-) ---*/ for (iDim = 0; iDim < nDim; iDim++) { - Lambda_j[iDim] = 0.5*(ProjVelst_j - fabs(ProjVelst_j)); + Lambda_j[iDim] = 0.5*(ProjVelst_j - fabs(ProjVelst_j)); } - Lambda_j[nDim] = 0.5*( ProjVelst_j + Vst_j[nDim+4] - - fabs(ProjVelst_j + Vst_j[nDim+4]) ); - Lambda_j[nDim+1] = 0.5*( ProjVelst_j - Vst_j[nDim+4] - - fabs(ProjVelst_j - Vst_j[nDim+4]) ); + Lambda_j[nDim] = 0.5*( ProjVelst_j + Vst_j[nDim+4] - fabs(ProjVelst_j + Vst_j[nDim+4]) ); + Lambda_j[nDim+1] = 0.5*( ProjVelst_j - Vst_j[nDim+4] - fabs(ProjVelst_j - Vst_j[nDim+4]) ); /*--- Compute projected P, invP, and Lambda ---*/ @@ -231,14 +238,18 @@ void CUpwMSW_Flow::ComputeResidual(su2double *val_residual, Proj_ModJac_Tensor_j += P_Tensor[iVar][kVar]*Lambda_j[kVar]*invP_Tensor[kVar][jVar]; Fc_j[iVar] += Proj_ModJac_Tensor_j*U_j[jVar]*Area; if (implicit) - val_Jacobian_j[iVar][jVar] += Proj_ModJac_Tensor_j*Area; + Jacobian_j[iVar][jVar] += Proj_ModJac_Tensor_j*Area; } } - /*--- Flux splitting ---*/ + /*--- Flux splitting, use the i flux as final output. ---*/ for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] = Fc_i[iVar]+Fc_j[iVar]; + Fc_i[iVar] += Fc_j[iVar]; } + residual = Fc_i; + + jacobian_i = Jacobian_i; + jacobian_j = Jacobian_j; } From b159d1d84b4a8443e22f4d4d8bf9abd67dd4a49a Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Tue, 28 Jan 2020 15:50:06 +0000 Subject: [PATCH 028/118] thread safe HLLC --- .../include/numerics/flow/convection/hllc.hpp | 19 +- SU2_CFD/src/numerics/flow/convection/hllc.cpp | 208 +++++++++++------- 2 files changed, 139 insertions(+), 88 deletions(-) diff --git a/SU2_CFD/include/numerics/flow/convection/hllc.hpp b/SU2_CFD/include/numerics/flow/convection/hllc.hpp index 79422a5d0db6..4c15ba2fa3a1 100644 --- a/SU2_CFD/include/numerics/flow/convection/hllc.hpp +++ b/SU2_CFD/include/numerics/flow/convection/hllc.hpp @@ -36,7 +36,7 @@ * \author G. Gori, Politecnico di Milano * \version 7.0.0 "Blackbird" */ -class CUpwHLLC_Flow : public CNumerics { +class CUpwHLLC_Flow final : public CNumerics { private: bool implicit, dynamic_grid; unsigned short iDim, jDim, iVar, jVar; @@ -54,8 +54,11 @@ class CUpwHLLC_Flow : public CNumerics { su2double Omega, RHO, OmegaSM; su2double *dSm_dU, *dPI_dU, *drhoStar_dU, *dpStar_dU, *dEStar_dU; -public: + su2double* Flux; /*!< \brief The flux accross the face. */ + su2double** Jacobian_i; /*!< \brief The Jacobian w.r.t. point i after computation. */ + su2double** Jacobian_j; /*!< \brief The Jacobian w.r.t. point j after computation. */ +public: /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. @@ -76,7 +79,8 @@ class CUpwHLLC_Flow : public CNumerics { * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). * \param[in] config - Definition of the particular problem. */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + void ComputeResidual(const su2double* &residual, const su2double* const* &jacobian_i, + const su2double* const* &jacobian_j, CConfig *config) override; }; @@ -87,7 +91,7 @@ class CUpwHLLC_Flow : public CNumerics { * \author G. Gori, Politecnico di Milano * \version 7.0.0 "Blackbird" */ -class CUpwGeneralHLLC_Flow : public CNumerics { +class CUpwGeneralHLLC_Flow final : public CNumerics { private: bool implicit, dynamic_grid; unsigned short iDim, jDim, iVar, jVar; @@ -106,9 +110,11 @@ class CUpwGeneralHLLC_Flow : public CNumerics { su2double Omega, RHO, OmegaSM; su2double *dSm_dU, *dPI_dU, *drhoStar_dU, *dpStar_dU, *dEStar_dU; + su2double* Flux; /*!< \brief The flux accross the face. */ + su2double** Jacobian_i; /*!< \brief The Jacobian w.r.t. point i after computation. */ + su2double** Jacobian_j; /*!< \brief The Jacobian w.r.t. point j after computation. */ public: - /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. @@ -129,7 +135,8 @@ class CUpwGeneralHLLC_Flow : public CNumerics { * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). * \param[in] config - Definition of the particular problem. */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + void ComputeResidual(const su2double* &residual, const su2double* const* &jacobian_i, + const su2double* const* &jacobian_j, CConfig *config) override; /*! * \brief Compute the Average quantities for a general fluid flux between two nodes i and j. diff --git a/SU2_CFD/src/numerics/flow/convection/hllc.cpp b/SU2_CFD/src/numerics/flow/convection/hllc.cpp index ddf682d72471..96d2d743abed 100644 --- a/SU2_CFD/src/numerics/flow/convection/hllc.cpp +++ b/SU2_CFD/src/numerics/flow/convection/hllc.cpp @@ -49,6 +49,13 @@ CUpwHLLC_Flow::CUpwHLLC_Flow(unsigned short val_nDim, unsigned short val_nVar, C Velocity_j = new su2double [nDim]; RoeVelocity = new su2double [nDim]; + Flux = new su2double [nVar]; + Jacobian_i = new su2double* [nVar]; + Jacobian_j = new su2double* [nVar]; + for (unsigned short iVar = 0; iVar < nVar; iVar++) { + Jacobian_i[iVar] = new su2double [nVar]; + Jacobian_j[iVar] = new su2double [nVar]; + } } CUpwHLLC_Flow::~CUpwHLLC_Flow(void) { @@ -64,9 +71,20 @@ CUpwHLLC_Flow::~CUpwHLLC_Flow(void) { delete [] Velocity_j; delete [] RoeVelocity; + for (unsigned short iVar = 0; iVar < nVar; iVar++) { + delete [] Jacobian_i[iVar]; + delete [] Jacobian_j[iVar]; + } + delete [] Flux; + delete [] Jacobian_i; + delete [] Jacobian_j; + } -void CUpwHLLC_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { +void CUpwHLLC_Flow::ComputeResidual(const su2double* &residual, + const su2double* const* &jacobian_i, + const su2double* const* &jacobian_j, + CConfig *config) { /*--- Face area (norm or the normal vector) ---*/ @@ -186,10 +204,10 @@ void CUpwHLLC_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jac /*--- Compute Left Flux ---*/ - val_residual[0] = Density_i * ProjVelocity_i; + Flux[0] = Density_i * ProjVelocity_i; for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = Density_i * Velocity_i[iDim] * ProjVelocity_i + Pressure_i * UnitNormal[iDim]; - val_residual[nVar-1] = Enthalpy_i * Density_i * ProjVelocity_i; + Flux[iDim+1] = Density_i * Velocity_i[iDim] * ProjVelocity_i + Pressure_i * UnitNormal[iDim]; + Flux[nVar-1] = Enthalpy_i * Density_i * ProjVelocity_i; } else { @@ -204,10 +222,10 @@ void CUpwHLLC_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jac IntermediateState[nVar-1] = rhoSL * ( Density_i * Energy_i - ( Pressure_i * ProjVelocity_i - pStar * sM) / ( sL - ProjVelocity_i ) ); - val_residual[0] = sM * IntermediateState[0]; + Flux[0] = sM * IntermediateState[0]; for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = sM * IntermediateState[iDim+1] + pStar * UnitNormal[iDim]; - val_residual[nVar-1] = sM * ( IntermediateState[nVar-1] + pStar ) + pStar * ProjInterfaceVel; + Flux[iDim+1] = sM * IntermediateState[iDim+1] + pStar * UnitNormal[iDim]; + Flux[nVar-1] = sM * ( IntermediateState[nVar-1] + pStar ) + pStar * ProjInterfaceVel; } } else { @@ -216,10 +234,10 @@ void CUpwHLLC_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jac /*--- Compute Right Flux ---*/ - val_residual[0] = Density_j * ProjVelocity_j; + Flux[0] = Density_j * ProjVelocity_j; for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = Density_j * Velocity_j[iDim] * ProjVelocity_j + Pressure_j * UnitNormal[iDim]; - val_residual[nVar-1] = Enthalpy_j * Density_j * ProjVelocity_j; + Flux[iDim+1] = Density_j * Velocity_j[iDim] * ProjVelocity_j + Pressure_j * UnitNormal[iDim]; + Flux[nVar-1] = Enthalpy_j * Density_j * ProjVelocity_j; } else { @@ -233,17 +251,18 @@ void CUpwHLLC_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jac IntermediateState[nVar-1] = rhoSR * ( Density_j * Energy_j - ( Pressure_j * ProjVelocity_j - pStar * sM ) / ( sR - ProjVelocity_j ) ); - val_residual[0] = sM * IntermediateState[0]; + Flux[0] = sM * IntermediateState[0]; for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = sM * IntermediateState[iDim+1] + pStar * UnitNormal[iDim]; - val_residual[nVar-1] = sM * (IntermediateState[nVar-1] + pStar ) + pStar * ProjInterfaceVel; + Flux[iDim+1] = sM * IntermediateState[iDim+1] + pStar * UnitNormal[iDim]; + Flux[nVar-1] = sM * (IntermediateState[nVar-1] + pStar ) + pStar * ProjInterfaceVel; } } for (iVar = 0; iVar < nVar; iVar++) - val_residual[iVar] *= Area; + Flux[iVar] *= Area; + residual = Flux; /*--- Return early if the Jacobians do not need to be computed. ---*/ @@ -257,9 +276,9 @@ void CUpwHLLC_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jac for (iVar = 0; iVar < nVar; iVar++) for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_j[iVar][jVar] = 0; + Jacobian_j[iVar][jVar] = 0; - GetInviscidProjJac(Velocity_i, &Energy_i, UnitNormal, 1.0, val_Jacobian_i); + GetInviscidProjJac(Velocity_i, &Energy_i, UnitNormal, 1.0, Jacobian_i); } else { @@ -318,29 +337,29 @@ void CUpwHLLC_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jac /*--- Jacobian First Row ---*/ for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[0][iVar] = sM * drhoStar_dU[iVar] + IntermediateState[0] * dSm_dU[iVar]; + Jacobian_i[0][iVar] = sM * drhoStar_dU[iVar] + IntermediateState[0] * dSm_dU[iVar]; /*--- Jacobian Middle Rows ---*/ for (jDim = 0; jDim < nDim; jDim++) { for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[jDim+1][iVar] = ( OmegaSM + 1 ) * ( UnitNormal[jDim] * dpStar_dU[iVar] + IntermediateState[jDim+1] * dSm_dU[iVar] ); + Jacobian_i[jDim+1][iVar] = ( OmegaSM + 1 ) * ( UnitNormal[jDim] * dpStar_dU[iVar] + IntermediateState[jDim+1] * dSm_dU[iVar] ); - val_Jacobian_i[jDim+1][0] += OmegaSM * Velocity_i[jDim] * ProjVelocity_i; + Jacobian_i[jDim+1][0] += OmegaSM * Velocity_i[jDim] * ProjVelocity_i; - val_Jacobian_i[jDim+1][jDim+1] += OmegaSM * (sL - ProjVelocity_i); + Jacobian_i[jDim+1][jDim+1] += OmegaSM * (sL - ProjVelocity_i); for (iDim = 0; iDim < nDim; iDim++) - val_Jacobian_i[jDim+1][iDim+1] -= OmegaSM * Velocity_i[jDim] * UnitNormal[iDim]; + Jacobian_i[jDim+1][iDim+1] -= OmegaSM * Velocity_i[jDim] * UnitNormal[iDim]; for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[jDim+1][iVar] -= OmegaSM * dPI_dU[iVar] * UnitNormal[jDim]; + Jacobian_i[jDim+1][iVar] -= OmegaSM * dPI_dU[iVar] * UnitNormal[jDim]; } /*--- Jacobian Last Row ---*/ for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[nVar-1][iVar] = sM * ( dEStar_dU[iVar] + dpStar_dU[iVar] ) + ( EStar + pStar ) * dSm_dU[iVar]; + Jacobian_i[nVar-1][iVar] = sM * ( dEStar_dU[iVar] + dpStar_dU[iVar] ) + ( EStar + pStar ) * dSm_dU[iVar]; /*--------- Right Jacobian ---------*/ @@ -370,19 +389,19 @@ void CUpwHLLC_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jac /*--- Jacobian First Row ---*/ for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[0][iVar] = IntermediateState[0] * ( OmegaSM + 1 ) * dSm_dU[iVar]; + Jacobian_j[0][iVar] = IntermediateState[0] * ( OmegaSM + 1 ) * dSm_dU[iVar]; /*--- Jacobian Middle Rows ---*/ for (iDim = 0; iDim < nDim; iDim++) { for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[iDim+1][iVar] = ( OmegaSM + 1 ) * ( IntermediateState[iDim+1] * dSm_dU[iVar] + UnitNormal[iDim] * dpStar_dU[iVar] ); + Jacobian_j[iDim+1][iVar] = ( OmegaSM + 1 ) * ( IntermediateState[iDim+1] * dSm_dU[iVar] + UnitNormal[iDim] * dpStar_dU[iVar] ); } /*--- Jacobian Last Row ---*/ for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[nVar-1][iVar] = sM * (dEStar_dU[iVar] + dpStar_dU[iVar]) + (EStar + pStar) * dSm_dU[iVar]; + Jacobian_j[nVar-1][iVar] = sM * (dEStar_dU[iVar] + dpStar_dU[iVar]) + (EStar + pStar) * dSm_dU[iVar]; } } else { @@ -392,9 +411,9 @@ void CUpwHLLC_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jac for (iVar = 0; iVar < nVar; iVar++) for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_i[iVar][jVar] = 0; + Jacobian_i[iVar][jVar] = 0; - GetInviscidProjJac(Velocity_j, &Energy_j, UnitNormal, 1.0, val_Jacobian_j); + GetInviscidProjJac(Velocity_j, &Energy_j, UnitNormal, 1.0, Jacobian_j); } else { @@ -432,19 +451,19 @@ void CUpwHLLC_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jac /*--- Jacobian First Row ---*/ for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[0][iVar] = IntermediateState[0] * ( OmegaSM + 1 ) * dSm_dU[iVar]; + Jacobian_i[0][iVar] = IntermediateState[0] * ( OmegaSM + 1 ) * dSm_dU[iVar]; /*--- Jacobian Middle Rows ---*/ for (iDim = 0; iDim < nDim; iDim++) { for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[iDim+1][iVar] = (OmegaSM + 1) * ( IntermediateState[iDim+1] * dSm_dU[iVar] + UnitNormal[iDim] * dpStar_dU[iVar] ); + Jacobian_i[iDim+1][iVar] = (OmegaSM + 1) * ( IntermediateState[iDim+1] * dSm_dU[iVar] + UnitNormal[iDim] * dpStar_dU[iVar] ); } /*--- Jacobian Last Row ---*/ for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[nVar-1][iVar] = sM * (dEStar_dU[iVar] + dpStar_dU[iVar]) + (EStar + pStar) * dSm_dU[iVar]; + Jacobian_i[nVar-1][iVar] = sM * (dEStar_dU[iVar] + dpStar_dU[iVar]) + (EStar + pStar) * dSm_dU[iVar]; @@ -497,45 +516,48 @@ void CUpwHLLC_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jac /*--- Jacobian First Row ---*/ for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[0][iVar] = sM * drhoStar_dU[iVar] + IntermediateState[0] * dSm_dU[iVar]; + Jacobian_j[0][iVar] = sM * drhoStar_dU[iVar] + IntermediateState[0] * dSm_dU[iVar]; /*--- Jacobian Middle Rows ---*/ for (jDim = 0; jDim < nDim; jDim++) { for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[jDim+1][iVar] = ( OmegaSM + 1 ) * ( UnitNormal[jDim] * dpStar_dU[iVar] + IntermediateState[jDim+1] * dSm_dU[iVar] ); + Jacobian_j[jDim+1][iVar] = ( OmegaSM + 1 ) * ( UnitNormal[jDim] * dpStar_dU[iVar] + IntermediateState[jDim+1] * dSm_dU[iVar] ); - val_Jacobian_j[jDim+1][0] += OmegaSM * Velocity_j[jDim] * ProjVelocity_j; + Jacobian_j[jDim+1][0] += OmegaSM * Velocity_j[jDim] * ProjVelocity_j; - val_Jacobian_j[jDim+1][jDim+1] += OmegaSM * (sR - ProjVelocity_j); + Jacobian_j[jDim+1][jDim+1] += OmegaSM * (sR - ProjVelocity_j); for (iDim = 0; iDim < nDim; iDim++) - val_Jacobian_j[jDim+1][iDim+1] -= OmegaSM * Velocity_j[jDim] * UnitNormal[iDim]; + Jacobian_j[jDim+1][iDim+1] -= OmegaSM * Velocity_j[jDim] * UnitNormal[iDim]; for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[jDim+1][iVar] -= OmegaSM * dPI_dU[iVar] * UnitNormal[jDim]; + Jacobian_j[jDim+1][iVar] -= OmegaSM * dPI_dU[iVar] * UnitNormal[jDim]; } /*--- Jacobian Last Row ---*/ for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[nVar-1][iVar] = sM * ( dEStar_dU[iVar] + dpStar_dU[iVar] ) + ( EStar + pStar ) * dSm_dU[iVar]; + Jacobian_j[nVar-1][iVar] = sM * ( dEStar_dU[iVar] + dpStar_dU[iVar] ) + ( EStar + pStar ) * dSm_dU[iVar]; } } - /*--- Jacobians of the inviscid flux, scale = k because val_residual ~ 0.5*(fc_i+fc_j)*Normal ---*/ + /*--- Jacobians of the inviscid flux, scale = k because Flux ~ 0.5*(fc_i+fc_j)*Normal ---*/ Area *= kappa; for (iVar = 0; iVar < nVar; iVar++) { for (jVar = 0; jVar < nVar; jVar++) { - val_Jacobian_i[iVar][jVar] *= Area; - val_Jacobian_j[iVar][jVar] *= Area; + Jacobian_i[iVar][jVar] *= Area; + Jacobian_j[iVar][jVar] *= Area; } } + jacobian_i = Jacobian_i; + jacobian_j = Jacobian_j; + } CUpwGeneralHLLC_Flow::CUpwGeneralHLLC_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { @@ -558,6 +580,13 @@ CUpwGeneralHLLC_Flow::CUpwGeneralHLLC_Flow(unsigned short val_nDim, unsigned sho Velocity_j = new su2double [nDim]; RoeVelocity = new su2double [nDim]; + Flux = new su2double [nVar]; + Jacobian_i = new su2double* [nVar]; + Jacobian_j = new su2double* [nVar]; + for (unsigned short iVar = 0; iVar < nVar; iVar++) { + Jacobian_i[iVar] = new su2double [nVar]; + Jacobian_j[iVar] = new su2double [nVar]; + } } CUpwGeneralHLLC_Flow::~CUpwGeneralHLLC_Flow(void) { @@ -573,9 +602,20 @@ CUpwGeneralHLLC_Flow::~CUpwGeneralHLLC_Flow(void) { delete [] Velocity_j; delete [] RoeVelocity; + for (unsigned short iVar = 0; iVar < nVar; iVar++) { + delete [] Jacobian_i[iVar]; + delete [] Jacobian_j[iVar]; + } + delete [] Flux; + delete [] Jacobian_i; + delete [] Jacobian_j; + } -void CUpwGeneralHLLC_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { +void CUpwGeneralHLLC_Flow::ComputeResidual(const su2double* &residual, + const su2double* const* &jacobian_i, + const su2double* const* &jacobian_j, + CConfig *config) { /*--- Face area (norm or the normal vector) ---*/ @@ -710,10 +750,10 @@ void CUpwGeneralHLLC_Flow::ComputeResidual(su2double *val_residual, su2double ** /*--- Compute Left Flux ---*/ - val_residual[0] = Density_i * ProjVelocity_i; + Flux[0] = Density_i * ProjVelocity_i; for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = Density_i * Velocity_i[iDim] * ProjVelocity_i + Pressure_i * UnitNormal[iDim]; - val_residual[nVar-1] = Enthalpy_i * Density_i * ProjVelocity_i; + Flux[iDim+1] = Density_i * Velocity_i[iDim] * ProjVelocity_i + Pressure_i * UnitNormal[iDim]; + Flux[nVar-1] = Enthalpy_i * Density_i * ProjVelocity_i; } else { @@ -727,10 +767,10 @@ void CUpwGeneralHLLC_Flow::ComputeResidual(su2double *val_residual, su2double ** IntermediateState[nVar-1] = rhoSL * ( Density_i * Energy_i - ( Pressure_i * ProjVelocity_i - pStar * sM) / ( sL - ProjVelocity_i ) ); - val_residual[0] = sM * IntermediateState[0]; + Flux[0] = sM * IntermediateState[0]; for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = sM * IntermediateState[iDim+1] + pStar * UnitNormal[iDim]; - val_residual[nVar-1] = sM * ( IntermediateState[nVar-1] + pStar ) + pStar * ProjInterfaceVel; + Flux[iDim+1] = sM * IntermediateState[iDim+1] + pStar * UnitNormal[iDim]; + Flux[nVar-1] = sM * ( IntermediateState[nVar-1] + pStar ) + pStar * ProjInterfaceVel; } } else { @@ -739,10 +779,10 @@ void CUpwGeneralHLLC_Flow::ComputeResidual(su2double *val_residual, su2double ** /*--- Compute Right Flux ---*/ - val_residual[0] = Density_j * ProjVelocity_j; + Flux[0] = Density_j * ProjVelocity_j; for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = Density_j * Velocity_j[iDim] * ProjVelocity_j + Pressure_j * UnitNormal[iDim]; - val_residual[nVar-1] = Enthalpy_j * Density_j * ProjVelocity_j; + Flux[iDim+1] = Density_j * Velocity_j[iDim] * ProjVelocity_j + Pressure_j * UnitNormal[iDim]; + Flux[nVar-1] = Enthalpy_j * Density_j * ProjVelocity_j; } else { @@ -756,16 +796,17 @@ void CUpwGeneralHLLC_Flow::ComputeResidual(su2double *val_residual, su2double ** IntermediateState[nVar-1] = rhoSR * ( Density_j * Energy_j - ( Pressure_j * ProjVelocity_j - pStar * sM ) / ( sR - ProjVelocity_j ) ); - val_residual[0] = sM * IntermediateState[0]; + Flux[0] = sM * IntermediateState[0]; for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = sM * IntermediateState[iDim+1] + pStar * UnitNormal[iDim]; - val_residual[nVar-1] = sM * (IntermediateState[nVar-1] + pStar ) + pStar * ProjInterfaceVel; + Flux[iDim+1] = sM * IntermediateState[iDim+1] + pStar * UnitNormal[iDim]; + Flux[nVar-1] = sM * (IntermediateState[nVar-1] + pStar ) + pStar * ProjInterfaceVel; } } for (iVar = 0; iVar < nVar; iVar++) - val_residual[iVar] *= Area; + Flux[iVar] *= Area; + residual = Flux; /*--- Return early if the Jacobians do not need to be computed. ---*/ @@ -779,10 +820,10 @@ void CUpwGeneralHLLC_Flow::ComputeResidual(su2double *val_residual, su2double ** for (iVar = 0; iVar < nVar; iVar++) for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_j[iVar][jVar] = 0; + Jacobian_j[iVar][jVar] = 0; - GetInviscidProjJac(Velocity_i, &Enthalpy_i, &Chi_i, &Kappa_i, UnitNormal, 1.0, val_Jacobian_i); + GetInviscidProjJac(Velocity_i, &Enthalpy_i, &Chi_i, &Kappa_i, UnitNormal, 1.0, Jacobian_i); } else { @@ -841,30 +882,30 @@ void CUpwGeneralHLLC_Flow::ComputeResidual(su2double *val_residual, su2double ** /*--- Jacobian First Row ---*/ for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[0][iVar] = sM * drhoStar_dU[iVar] + IntermediateState[0] * dSm_dU[iVar]; + Jacobian_i[0][iVar] = sM * drhoStar_dU[iVar] + IntermediateState[0] * dSm_dU[iVar]; /*--- Jacobian Middle Rows ---*/ for (jDim = 0; jDim < nDim; jDim++) { for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[jDim+1][iVar] = ( OmegaSM + 1 ) * ( UnitNormal[jDim] * dpStar_dU[iVar] + IntermediateState[jDim+1] * dSm_dU[iVar] ); + Jacobian_i[jDim+1][iVar] = ( OmegaSM + 1 ) * ( UnitNormal[jDim] * dpStar_dU[iVar] + IntermediateState[jDim+1] * dSm_dU[iVar] ); - val_Jacobian_i[jDim+1][0] += OmegaSM * Velocity_i[jDim] * ProjVelocity_i; + Jacobian_i[jDim+1][0] += OmegaSM * Velocity_i[jDim] * ProjVelocity_i; - val_Jacobian_i[jDim+1][jDim+1] += OmegaSM * (sL - ProjVelocity_i); + Jacobian_i[jDim+1][jDim+1] += OmegaSM * (sL - ProjVelocity_i); for (iDim = 0; iDim < nDim; iDim++) - val_Jacobian_i[jDim+1][iDim+1] -= OmegaSM * Velocity_i[jDim] * UnitNormal[iDim]; + Jacobian_i[jDim+1][iDim+1] -= OmegaSM * Velocity_i[jDim] * UnitNormal[iDim]; for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[jDim+1][iVar] -= OmegaSM * dPI_dU[iVar] * UnitNormal[jDim]; + Jacobian_i[jDim+1][iVar] -= OmegaSM * dPI_dU[iVar] * UnitNormal[jDim]; } /*--- Jacobian Last Row ---*/ for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[nVar-1][iVar] = sM * ( dEStar_dU[iVar] + dpStar_dU[iVar] ) + ( EStar + pStar ) * dSm_dU[iVar]; + Jacobian_i[nVar-1][iVar] = sM * ( dEStar_dU[iVar] + dpStar_dU[iVar] ) + ( EStar + pStar ) * dSm_dU[iVar]; /*--------- Right Jacobian ---------*/ @@ -902,19 +943,19 @@ void CUpwGeneralHLLC_Flow::ComputeResidual(su2double *val_residual, su2double ** /*--- Jacobian First Row ---*/ for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[0][iVar] = IntermediateState[0] * ( OmegaSM + 1 ) * dSm_dU[iVar]; + Jacobian_j[0][iVar] = IntermediateState[0] * ( OmegaSM + 1 ) * dSm_dU[iVar]; /*--- Jacobian Middle Rows ---*/ for (iDim = 0; iDim < nDim; iDim++) { for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[iDim+1][iVar] = ( OmegaSM + 1 ) * ( IntermediateState[iDim+1] * dSm_dU[iVar] + UnitNormal[iDim] * dpStar_dU[iVar] ); + Jacobian_j[iDim+1][iVar] = ( OmegaSM + 1 ) * ( IntermediateState[iDim+1] * dSm_dU[iVar] + UnitNormal[iDim] * dpStar_dU[iVar] ); } /*--- Jacobian Last Row ---*/ for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[nVar-1][iVar] = sM * (dEStar_dU[iVar] + dpStar_dU[iVar]) + (EStar + pStar) * dSm_dU[iVar]; + Jacobian_j[nVar-1][iVar] = sM * (dEStar_dU[iVar] + dpStar_dU[iVar]) + (EStar + pStar) * dSm_dU[iVar]; } } else { @@ -924,9 +965,9 @@ void CUpwGeneralHLLC_Flow::ComputeResidual(su2double *val_residual, su2double ** for (iVar = 0; iVar < nVar; iVar++) for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_i[iVar][jVar] = 0; + Jacobian_i[iVar][jVar] = 0; - GetInviscidProjJac(Velocity_j, &Enthalpy_j, &Chi_j, &Kappa_j, UnitNormal, 1.0, val_Jacobian_j); + GetInviscidProjJac(Velocity_j, &Enthalpy_j, &Chi_j, &Kappa_j, UnitNormal, 1.0, Jacobian_j); } else { @@ -972,19 +1013,19 @@ void CUpwGeneralHLLC_Flow::ComputeResidual(su2double *val_residual, su2double ** /*--- Jacobian First Row ---*/ for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[0][iVar] = IntermediateState[0] * ( OmegaSM + 1 ) * dSm_dU[iVar]; + Jacobian_i[0][iVar] = IntermediateState[0] * ( OmegaSM + 1 ) * dSm_dU[iVar]; /*--- Jacobian Middle Rows ---*/ for (iDim = 0; iDim < nDim; iDim++) { for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[iDim+1][iVar] = (OmegaSM + 1) * ( IntermediateState[iDim+1] * dSm_dU[iVar] + UnitNormal[iDim] * dpStar_dU[iVar] ); + Jacobian_i[iDim+1][iVar] = (OmegaSM + 1) * ( IntermediateState[iDim+1] * dSm_dU[iVar] + UnitNormal[iDim] * dpStar_dU[iVar] ); } /*--- Jacobian Last Row ---*/ for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[nVar-1][iVar] = sM * (dEStar_dU[iVar] + dpStar_dU[iVar]) + (EStar + pStar) * dSm_dU[iVar]; + Jacobian_i[nVar-1][iVar] = sM * (dEStar_dU[iVar] + dpStar_dU[iVar]) + (EStar + pStar) * dSm_dU[iVar]; @@ -1036,44 +1077,47 @@ void CUpwGeneralHLLC_Flow::ComputeResidual(su2double *val_residual, su2double ** /*--- Jacobian First Row ---*/ for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[0][iVar] = sM * drhoStar_dU[iVar] + IntermediateState[0] * dSm_dU[iVar]; + Jacobian_j[0][iVar] = sM * drhoStar_dU[iVar] + IntermediateState[0] * dSm_dU[iVar]; /*--- Jacobian Middle Rows ---*/ for (jDim = 0; jDim < nDim; jDim++) { for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[jDim+1][iVar] = ( OmegaSM + 1 ) * ( UnitNormal[jDim] * dpStar_dU[iVar] + IntermediateState[jDim+1] * dSm_dU[iVar] ); + Jacobian_j[jDim+1][iVar] = ( OmegaSM + 1 ) * ( UnitNormal[jDim] * dpStar_dU[iVar] + IntermediateState[jDim+1] * dSm_dU[iVar] ); - val_Jacobian_j[jDim+1][0] += OmegaSM * Velocity_j[jDim] * ProjVelocity_j; + Jacobian_j[jDim+1][0] += OmegaSM * Velocity_j[jDim] * ProjVelocity_j; - val_Jacobian_j[jDim+1][jDim+1] += OmegaSM * (sR - ProjVelocity_j); + Jacobian_j[jDim+1][jDim+1] += OmegaSM * (sR - ProjVelocity_j); for (iDim = 0; iDim < nDim; iDim++) - val_Jacobian_j[jDim+1][iDim+1] -= OmegaSM * Velocity_j[jDim] * UnitNormal[iDim]; + Jacobian_j[jDim+1][iDim+1] -= OmegaSM * Velocity_j[jDim] * UnitNormal[iDim]; for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[jDim+1][iVar] -= OmegaSM * dPI_dU[iVar] * UnitNormal[jDim]; + Jacobian_j[jDim+1][iVar] -= OmegaSM * dPI_dU[iVar] * UnitNormal[jDim]; } /*--- Jacobian Last Row ---*/ for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[nVar-1][iVar] = sM * ( dEStar_dU[iVar] + dpStar_dU[iVar] ) + ( EStar + pStar ) * dSm_dU[iVar]; + Jacobian_j[nVar-1][iVar] = sM * ( dEStar_dU[iVar] + dpStar_dU[iVar] ) + ( EStar + pStar ) * dSm_dU[iVar]; } } - /*--- Jacobians of the inviscid flux, scale = kappa because val_residual ~ 0.5*(fc_i+fc_j)*Normal ---*/ + /*--- Jacobians of the inviscid flux, scale = kappa because Flux ~ 0.5*(fc_i+fc_j)*Normal ---*/ Area *= kappa; for (iVar = 0; iVar < nVar; iVar++) { for (jVar = 0; jVar < nVar; jVar++) { - val_Jacobian_i[iVar][jVar] *= Area; - val_Jacobian_j[iVar][jVar] *= Area; + Jacobian_i[iVar][jVar] *= Area; + Jacobian_j[iVar][jVar] *= Area; } } + jacobian_i = Jacobian_i; + jacobian_j = Jacobian_j; + } void CUpwGeneralHLLC_Flow::VinokurMontagne() { From 2dca913b2ee0b8a0b09bf8afff08c996d253d64d Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Tue, 28 Jan 2020 16:38:32 +0000 Subject: [PATCH 029/118] thread safe Roe family --- .../include/numerics/flow/convection/roe.hpp | 58 +++--- SU2_CFD/src/numerics/flow/convection/roe.cpp | 169 +++++++++++------- 2 files changed, 146 insertions(+), 81 deletions(-) diff --git a/SU2_CFD/include/numerics/flow/convection/roe.hpp b/SU2_CFD/include/numerics/flow/convection/roe.hpp index e8ef64ebbb6b..3e0bf4099de4 100644 --- a/SU2_CFD/include/numerics/flow/convection/roe.hpp +++ b/SU2_CFD/include/numerics/flow/convection/roe.hpp @@ -34,14 +34,21 @@ * \class CUpwRoeBase_Flow * \brief Intermediate base class for Roe schemes on ideal gas. * \ingroup ConvDiscr - * \author A. Bueno, F. Palacios + * \author A. Bueno, F. Palacios, P. Gomes */ class CUpwRoeBase_Flow : public CNumerics { protected: bool implicit, dynamic_grid, roe_low_dissipation; - su2double *Velocity_i, *Velocity_j, *ProjFlux_i, *ProjFlux_j, *Conservatives_i, *Conservatives_j; - su2double *Diff_U, *Lambda, **P_Tensor, **invP_Tensor; - su2double *RoeVelocity, RoeDensity, RoeEnthalpy, RoeSoundSpeed, ProjVelocity, RoeSoundSpeed2, kappa; + su2double Velocity_i[MAXNDIM] = {0.0}, Velocity_j[MAXNDIM] = {0.0}, RoeVelocity[MAXNDIM] = {0.0}; + su2double *Diff_U = nullptr, *Lambda = nullptr; + su2double *ProjFlux_i = nullptr, *Conservatives_i = nullptr; + su2double *ProjFlux_j = nullptr, *Conservatives_j = nullptr; + su2double **P_Tensor = nullptr, **invP_Tensor = nullptr; + su2double RoeDensity, RoeEnthalpy, RoeSoundSpeed, ProjVelocity, RoeSoundSpeed2, kappa; + + su2double* Flux = nullptr; /*!< \brief The flux accross the face. */ + su2double** Jacobian_i = nullptr; /*!< \brief The Jacobian w.r.t. point i after computation. */ + su2double** Jacobian_j = nullptr; /*!< \brief The Jacobian w.r.t. point j after computation. */ /*! * \brief Derived classes must specialize this method to add the specifics of the scheme they implement (e.g. low-Mach precond.). @@ -74,7 +81,8 @@ class CUpwRoeBase_Flow : public CNumerics { * \param[out] val_Jacobian_j - Flux Jacobian wrt node j conservatives (implicit computation). * \param[in] config - Definition of the particular problem. */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + void ComputeResidual(const su2double* &residual, const su2double* const* &jacobian_i, + const su2double* const* &jacobian_j, CConfig *config) final; }; @@ -82,9 +90,9 @@ class CUpwRoeBase_Flow : public CNumerics { * \class CUpwRoe_Flow * \brief Class for solving an approximate Riemann solver of Roe for the flow equations. * \ingroup ConvDiscr - * \author A. Bueno, F. Palacios + * \author A. Bueno, F. Palacios, P. Gomes */ -class CUpwRoe_Flow : public CUpwRoeBase_Flow { +class CUpwRoe_Flow final : public CUpwRoeBase_Flow { private: /*! * \brief Add standard Roe dissipation to the flux. @@ -93,7 +101,7 @@ class CUpwRoe_Flow : public CUpwRoeBase_Flow { * \param[out] val_Jacobian_j - Flux Jacobian wrt node j conservatives (implicit computation). * \param[in] config - Definition of the particular problem. */ - void FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + void FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) override; public: /*! @@ -111,10 +119,10 @@ class CUpwRoe_Flow : public CUpwRoeBase_Flow { * \class CUpwL2Roe_Flow * \brief Class for solving an approximate Riemann solver of L2Roe for the flow equations. * \ingroup ConvDiscr - * \author E. Molina, A. Bueno, F. Palacios + * \author E. Molina, A. Bueno, F. Palacios, P. Gomes * \version 7.0.0 "Blackbird" */ -class CUpwL2Roe_Flow : public CUpwRoeBase_Flow { +class CUpwL2Roe_Flow final : public CUpwRoeBase_Flow { private: /*! * \brief Add L^2 Roe dissipation to the flux (low-Mach scheme). @@ -123,7 +131,7 @@ class CUpwL2Roe_Flow : public CUpwRoeBase_Flow { * \param[out] val_Jacobian_j - Flux Jacobian wrt node j conservatives (implicit computation). * \param[in] config - Definition of the particular problem. */ - void FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + void FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) override; public: /*! @@ -140,10 +148,10 @@ class CUpwL2Roe_Flow : public CUpwRoeBase_Flow { * \class CUpwLMRoe_Flow * \brief Class for solving an approximate Riemann solver of LMRoe for the flow equations. * \ingroup ConvDiscr - * \author E. Molina, A. Bueno, F. Palacios + * \author E. Molina, A. Bueno, F. Palacios, P. Gomes * \version 7.0.0 "Blackbird" */ -class CUpwLMRoe_Flow : public CUpwRoeBase_Flow { +class CUpwLMRoe_Flow final : public CUpwRoeBase_Flow { private: /*! * \brief Add LMRoe dissipation to the flux (low-Mach scheme). @@ -152,7 +160,7 @@ class CUpwLMRoe_Flow : public CUpwRoeBase_Flow { * \param[out] val_Jacobian_j - Flux Jacobian wrt node j conservatives (implicit computation). * \param[in] config - Definition of the particular problem. */ - void FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + void FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) override; public: /*! @@ -171,7 +179,7 @@ class CUpwLMRoe_Flow : public CUpwRoeBase_Flow { * \ingroup ConvDiscr * \author A. K. Lonkar */ -class CUpwTurkel_Flow : public CNumerics { +class CUpwTurkel_Flow final : public CNumerics { private: bool implicit, dynamic_grid; su2double *Diff_U; @@ -188,6 +196,10 @@ class CUpwTurkel_Flow : public CNumerics { su2double Beta2, one_m_Betasqr, one_p_Betasqr, sqr_two_Beta_c_Area; su2double local_Mach; + su2double* Flux = nullptr; /*!< \brief The flux accross the face. */ + su2double** Jacobian_i = nullptr; /*!< \brief The Jacobian w.r.t. point i after computation. */ + su2double** Jacobian_j = nullptr; /*!< \brief The Jacobian w.r.t. point j after computation. */ + public: /*! * \brief Constructor of the class. @@ -209,7 +221,8 @@ class CUpwTurkel_Flow : public CNumerics { * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). * \param[in] config - Definition of the particular problem. */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + void ComputeResidual(const su2double* &residual, const su2double* const* &jacobian_i, + const su2double* const* &jacobian_j, CConfig *config) override; }; @@ -219,7 +232,7 @@ class CUpwTurkel_Flow : public CNumerics { * \ingroup ConvDiscr * \author S.Vitale, G.Gori, M.Pini */ -class CUpwGeneralRoe_Flow : public CNumerics { +class CUpwGeneralRoe_Flow final : public CNumerics { private: bool implicit, dynamic_grid; @@ -236,12 +249,14 @@ class CUpwGeneralRoe_Flow : public CNumerics { ProjVelocity, ProjVelocity_i, ProjVelocity_j, proj_delta_vel, delta_p, delta_rho, kappa; unsigned short iDim, iVar, jVar, kVar; - su2double StaticEnthalpy_i, StaticEnergy_i, StaticEnthalpy_j, StaticEnergy_j, Kappa_i, Kappa_j, Chi_i, Chi_j, Velocity2_i, Velocity2_j; su2double RoeKappa, RoeChi; -public: + su2double* Flux = nullptr; /*!< \brief The flux accross the face. */ + su2double** Jacobian_i = nullptr; /*!< \brief The Jacobian w.r.t. point i after computation. */ + su2double** Jacobian_j = nullptr; /*!< \brief The Jacobian w.r.t. point j after computation. */ +public: /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. @@ -262,12 +277,13 @@ class CUpwGeneralRoe_Flow : public CNumerics { * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). * \param[in] config - Definition of the particular problem. */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + void ComputeResidual(const su2double* &residual, const su2double* const* &jacobian_i, + const su2double* const* &jacobian_j, CConfig *config) override; /*! * \brief Compute the Average for a general fluid flux between two nodes i and j. * Using the approach of Vinokur and Montagne' */ - void ComputeRoeAverage(); + }; diff --git a/SU2_CFD/src/numerics/flow/convection/roe.cpp b/SU2_CFD/src/numerics/flow/convection/roe.cpp index 433c1dbecf16..87dad4eca98c 100644 --- a/SU2_CFD/src/numerics/flow/convection/roe.cpp +++ b/SU2_CFD/src/numerics/flow/convection/roe.cpp @@ -40,10 +40,8 @@ CUpwRoeBase_Flow::CUpwRoeBase_Flow(unsigned short val_nDim, unsigned short val_n roe_low_dissipation = val_low_dissipation; + Flux = new su2double [nVar]; Diff_U = new su2double [nVar]; - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; - RoeVelocity = new su2double [nDim]; ProjFlux_i = new su2double [nVar]; ProjFlux_j = new su2double [nVar]; Conservatives_i = new su2double [nVar]; @@ -51,18 +49,20 @@ CUpwRoeBase_Flow::CUpwRoeBase_Flow(unsigned short val_nDim, unsigned short val_n Lambda = new su2double [nVar]; P_Tensor = new su2double* [nVar]; invP_Tensor = new su2double* [nVar]; + Jacobian_i = new su2double* [nVar]; + Jacobian_j = new su2double* [nVar]; for (unsigned short iVar = 0; iVar < nVar; iVar++) { P_Tensor[iVar] = new su2double [nVar]; invP_Tensor[iVar] = new su2double [nVar]; + Jacobian_i[iVar] = new su2double [nVar]; + Jacobian_j[iVar] = new su2double [nVar]; } } CUpwRoeBase_Flow::~CUpwRoeBase_Flow(void) { + delete [] Flux; delete [] Diff_U; - delete [] Velocity_i; - delete [] Velocity_j; - delete [] RoeVelocity; delete [] ProjFlux_i; delete [] ProjFlux_j; delete [] Conservatives_i; @@ -71,9 +71,13 @@ CUpwRoeBase_Flow::~CUpwRoeBase_Flow(void) { for (unsigned short iVar = 0; iVar < nVar; iVar++) { delete [] P_Tensor[iVar]; delete [] invP_Tensor[iVar]; + delete [] Jacobian_i[iVar]; + delete [] Jacobian_j[iVar]; } delete [] P_Tensor; delete [] invP_Tensor; + delete [] Jacobian_i; + delete [] Jacobian_j; } @@ -85,8 +89,10 @@ void CUpwRoeBase_Flow::FinalizeResidual(su2double *val_residual, su2double **val ---*/ } -void CUpwRoeBase_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - +void CUpwRoeBase_Flow::ComputeResidual(const su2double* &residual, + const su2double* const* &jacobian_i, + const su2double* const* &jacobian_j, + CConfig *config) { unsigned short iVar, jVar, iDim; su2double ProjGridVel = 0.0, Energy_i, Energy_j; @@ -146,16 +152,19 @@ void CUpwRoeBase_Flow::ComputeResidual(su2double *val_residual, su2double **val_ if (RoeSoundSpeed2 <= 0.0) { for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] = 0.0; + Flux[iVar] = 0.0; if (implicit){ for (jVar = 0; jVar < nVar; jVar++) { - val_Jacobian_i[iVar][jVar] = 0.0; - val_Jacobian_j[iVar][jVar] = 0.0; + Jacobian_i[iVar][jVar] = 0.0; + Jacobian_j[iVar][jVar] = 0.0; } } } - AD::SetPreaccOut(val_residual, nVar); + AD::SetPreaccOut(Flux, nVar); AD::EndPreacc(); + residual = Flux; + jacobian_i = Jacobian_i; + jacobian_j = Jacobian_j; return; } @@ -212,33 +221,37 @@ void CUpwRoeBase_Flow::ComputeResidual(su2double *val_residual, su2double **val_ /*--- Initialize residual (flux) and Jacobians ---*/ for (iVar = 0; iVar < nVar; iVar++) - val_residual[iVar] = kappa*(ProjFlux_i[iVar]+ProjFlux_j[iVar]); + Flux[iVar] = kappa*(ProjFlux_i[iVar]+ProjFlux_j[iVar]); if (implicit) { - GetInviscidProjJac(Velocity_i, &Energy_i, Normal, kappa, val_Jacobian_i); - GetInviscidProjJac(Velocity_j, &Energy_j, Normal, kappa, val_Jacobian_j); + GetInviscidProjJac(Velocity_i, &Energy_i, Normal, kappa, Jacobian_i); + GetInviscidProjJac(Velocity_j, &Energy_j, Normal, kappa, Jacobian_j); } /*--- Finalize in children class ---*/ - FinalizeResidual(val_residual, val_Jacobian_i, val_Jacobian_j, config); + FinalizeResidual(Flux, Jacobian_i, Jacobian_j, config); /*--- Correct for grid motion ---*/ if (dynamic_grid) { for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] -= ProjGridVel*Area * 0.5*(Conservatives_i[iVar]+Conservatives_j[iVar]); + Flux[iVar] -= ProjGridVel*Area * 0.5*(Conservatives_i[iVar]+Conservatives_j[iVar]); if (implicit) { - val_Jacobian_i[iVar][iVar] -= 0.5*ProjGridVel*Area; - val_Jacobian_j[iVar][iVar] -= 0.5*ProjGridVel*Area; + Jacobian_i[iVar][iVar] -= 0.5*ProjGridVel*Area; + Jacobian_j[iVar][iVar] -= 0.5*ProjGridVel*Area; } } } - AD::SetPreaccOut(val_residual, nVar); + AD::SetPreaccOut(Flux, nVar); AD::EndPreacc(); + residual = Flux; + jacobian_i = Jacobian_i; + jacobian_j = Jacobian_j; + } CUpwRoe_Flow::CUpwRoe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, @@ -441,6 +454,7 @@ CUpwTurkel_Flow::CUpwTurkel_Flow(unsigned short val_nDim, unsigned short val_nVa Beta_min = config->GetminTurkelBeta(); Beta_max = config->GetmaxTurkelBeta(); + Flux = new su2double [nVar]; Diff_U = new su2double [nVar]; Velocity_i = new su2double [nDim]; Velocity_j = new su2double [nDim]; @@ -454,17 +468,22 @@ CUpwTurkel_Flow::CUpwTurkel_Flow(unsigned short val_nDim, unsigned short val_nVa R_Tensor = new su2double* [nVar]; Matrix = new su2double* [nVar]; Art_Visc = new su2double* [nVar]; + Jacobian_i = new su2double* [nVar]; + Jacobian_j = new su2double* [nVar]; for (iVar = 0; iVar < nVar; iVar++) { absPeJac[iVar] = new su2double [nVar]; invRinvPe[iVar] = new su2double [nVar]; Matrix[iVar] = new su2double [nVar]; Art_Visc[iVar] = new su2double [nVar]; R_Tensor[iVar] = new su2double [nVar]; + Jacobian_i[iVar] = new su2double [nVar]; + Jacobian_j[iVar] = new su2double [nVar]; } } CUpwTurkel_Flow::~CUpwTurkel_Flow(void) { + delete [] Flux; delete [] Diff_U; delete [] Velocity_i; delete [] Velocity_j; @@ -479,18 +498,25 @@ CUpwTurkel_Flow::~CUpwTurkel_Flow(void) { delete [] Matrix[iVar]; delete [] Art_Visc[iVar]; delete [] R_Tensor[iVar]; + delete [] Jacobian_i[iVar]; + delete [] Jacobian_j[iVar]; } delete [] Matrix; delete [] Art_Visc; delete [] absPeJac; delete [] invRinvPe; delete [] R_Tensor; + delete [] Jacobian_i; + delete [] Jacobian_j; } -void CUpwTurkel_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { +void CUpwTurkel_Flow::ComputeResidual(const su2double* &residual, + const su2double* const* &jacobian_i, + const su2double* const* &jacobian_j, + CConfig *config) { - su2double U_i[5] = {0.0,0.0,0.0,0.0,0.0}, U_j[5] = {0.0,0.0,0.0,0.0,0.0}; + su2double U_i[5] = {0.0}, U_j[5] = {0.0}; /*--- Face area (norm or the normal vector) ---*/ @@ -574,7 +600,7 @@ void CUpwTurkel_Flow::ComputeResidual(su2double *val_residual, su2double **val_J Lambda[iDim] = ProjVelocity; local_Mach = sqrt(sq_vel)/RoeSoundSpeed; - Beta = max(Beta_min, min(local_Mach, Beta_max)); + Beta = max(Beta_min, min(local_Mach, Beta_max)); Beta2 = Beta*Beta; one_m_Betasqr = 1.0 - Beta2; // 1-Beta*Beta @@ -608,9 +634,9 @@ void CUpwTurkel_Flow::ComputeResidual(su2double *val_residual, su2double **val_J if (implicit) { /*--- Jacobians of the inviscid flux, scaled by - 0.5 because val_residual ~ 0.5*(fc_i+fc_j)*Normal ---*/ - GetInviscidProjJac(Velocity_i, &Energy_i, Normal, 0.5, val_Jacobian_i); - GetInviscidProjJac(Velocity_j, &Energy_j, Normal, 0.5, val_Jacobian_j); + 0.5 because Flux ~ 0.5*(fc_i+fc_j)*Normal ---*/ + GetInviscidProjJac(Velocity_i, &Energy_i, Normal, 0.5, Jacobian_i); + GetInviscidProjJac(Velocity_j, &Energy_j, Normal, 0.5, Jacobian_j); } for (iVar = 0; iVar < nVar; iVar ++) { @@ -631,12 +657,12 @@ void CUpwTurkel_Flow::ComputeResidual(su2double *val_residual, su2double **val_J /*--- Roe's Flux approximation ---*/ for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] = 0.5*(ProjFlux_i[iVar]+ProjFlux_j[iVar]); + Flux[iVar] = 0.5*(ProjFlux_i[iVar]+ProjFlux_j[iVar]); for (jVar = 0; jVar < nVar; jVar++) { - val_residual[iVar] -= 0.5*Art_Visc[iVar][jVar]*Diff_U[jVar]; + Flux[iVar] -= 0.5*Art_Visc[iVar][jVar]*Diff_U[jVar]; if (implicit) { - val_Jacobian_i[iVar][jVar] += 0.5*Art_Visc[iVar][jVar]; - val_Jacobian_j[iVar][jVar] -= 0.5*Art_Visc[iVar][jVar]; + Jacobian_i[iVar][jVar] += 0.5*Art_Visc[iVar][jVar]; + Jacobian_j[iVar][jVar] -= 0.5*Art_Visc[iVar][jVar]; } } } @@ -647,15 +673,19 @@ void CUpwTurkel_Flow::ComputeResidual(su2double *val_residual, su2double **val_J for (iDim = 0; iDim < nDim; iDim++) ProjVelocity += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*UnitNormal[iDim]; for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] -= ProjVelocity * 0.5*(U_i[iVar]+U_j[iVar]); + Flux[iVar] -= ProjVelocity * 0.5*(U_i[iVar]+U_j[iVar]); /*--- Implicit terms ---*/ if (implicit) { - val_Jacobian_i[iVar][iVar] -= 0.5*ProjVelocity; - val_Jacobian_j[iVar][iVar] -= 0.5*ProjVelocity; + Jacobian_i[iVar][iVar] -= 0.5*ProjVelocity; + Jacobian_j[iVar][iVar] -= 0.5*ProjVelocity; } } } + residual = Flux; + jacobian_i = Jacobian_i; + jacobian_j = Jacobian_j; + } CUpwGeneralRoe_Flow::CUpwGeneralRoe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { @@ -666,6 +696,7 @@ CUpwGeneralRoe_Flow::CUpwGeneralRoe_Flow(unsigned short val_nDim, unsigned short kappa = config->GetRoe_Kappa(); // 1 is unstable + Flux = new su2double [nVar]; Diff_U = new su2double [nVar]; Velocity_i = new su2double [nDim]; Velocity_j = new su2double [nDim]; @@ -678,15 +709,19 @@ CUpwGeneralRoe_Flow::CUpwGeneralRoe_Flow(unsigned short val_nDim, unsigned short Epsilon = new su2double [nVar]; P_Tensor = new su2double* [nVar]; invP_Tensor = new su2double* [nVar]; - + Jacobian_i = new su2double* [nVar]; + Jacobian_j = new su2double* [nVar]; for (iVar = 0; iVar < nVar; iVar++) { P_Tensor[iVar] = new su2double [nVar]; invP_Tensor[iVar] = new su2double [nVar]; + Jacobian_i[iVar] = new su2double [nVar]; + Jacobian_j[iVar] = new su2double [nVar]; } } CUpwGeneralRoe_Flow::~CUpwGeneralRoe_Flow(void) { + delete [] Flux; delete [] Diff_U; delete [] Velocity_i; delete [] Velocity_j; @@ -700,14 +735,20 @@ CUpwGeneralRoe_Flow::~CUpwGeneralRoe_Flow(void) { for (iVar = 0; iVar < nVar; iVar++) { delete [] P_Tensor[iVar]; delete [] invP_Tensor[iVar]; + delete [] Jacobian_i[iVar]; + delete [] Jacobian_j[iVar]; } delete [] P_Tensor; delete [] invP_Tensor; + delete [] Jacobian_i; + delete [] Jacobian_j; } -void CUpwGeneralRoe_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - +void CUpwGeneralRoe_Flow::ComputeResidual(const su2double* &residual, + const su2double* const* &jacobian_i, + const su2double* const* &jacobian_j, + CConfig *config) { AD::StartPreacc(); AD::SetPreaccIn(V_i, nDim+4); AD::SetPreaccIn(V_j, nDim+4); AD::SetPreaccIn(Normal, nDim); AD::SetPreaccIn(S_i, 2); AD::SetPreaccIn(S_j, 2); @@ -749,7 +790,6 @@ void CUpwGeneralRoe_Flow::ComputeResidual(su2double *val_residual, su2double **v /*--- Primitive variables at point j ---*/ - Velocity2_j = 0.0; for (iDim = 0; iDim < nDim; iDim++) { Velocity_j[iDim] = V_j[iDim+1]; @@ -776,22 +816,27 @@ void CUpwGeneralRoe_Flow::ComputeResidual(su2double *val_residual, su2double **v } U_i[nDim+1] = Density_i*Energy_i; U_j[nDim+1] = Density_j*Energy_j; -// /*--- Roe-averaged variables at interface between i & j ---*/ + /*--- Roe-averaged variables at interface between i & j ---*/ - ComputeRoeAverage(); + ComputeRoeAverage(); - if (RoeSoundSpeed2 <= 0.0) { + if (RoeSoundSpeed2 <= 0.0) { for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] = 0.0; + Flux[iVar] = 0.0; for (jVar = 0; jVar < nVar; jVar++) { - val_Jacobian_i[iVar][iVar] = 0.0; - val_Jacobian_j[iVar][iVar] = 0.0; + Jacobian_i[iVar][iVar] = 0.0; + Jacobian_j[iVar][iVar] = 0.0; } } - return; - } + AD::SetPreaccOut(Flux, nVar); + AD::EndPreacc(); + residual = Flux; + jacobian_i = Jacobian_i; + jacobian_j = Jacobian_j; + return; + } - RoeSoundSpeed = sqrt(RoeSoundSpeed2); + RoeSoundSpeed = sqrt(RoeSoundSpeed2); /*--- Compute ProjFlux_i ---*/ GetInviscidProjFlux(&Density_i, Velocity_i, &Pressure_i, &Enthalpy_i, Normal, ProjFlux_i); @@ -880,9 +925,9 @@ void CUpwGeneralRoe_Flow::ComputeResidual(su2double *val_residual, su2double **v /*--- Roe's Flux approximation ---*/ for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] = 0.5*(ProjFlux_i[iVar]+ProjFlux_j[iVar]); + Flux[iVar] = 0.5*(ProjFlux_i[iVar]+ProjFlux_j[iVar]); for (jVar = 0; jVar < nVar; jVar++) - val_residual[iVar] -= 0.5*Lambda[jVar]*delta_wave[jVar]*P_Tensor[iVar][jVar]*Area; + Flux[iVar] -= 0.5*Lambda[jVar]*delta_wave[jVar]*P_Tensor[iVar][jVar]*Area; } /*--- Flux contribution due to grid motion ---*/ @@ -891,7 +936,7 @@ void CUpwGeneralRoe_Flow::ComputeResidual(su2double *val_residual, su2double **v for (iDim = 0; iDim < nDim; iDim++) ProjVelocity += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] -= ProjVelocity * 0.5*(U_i[iVar]+U_j[iVar]); + Flux[iVar] -= ProjVelocity * 0.5*(U_i[iVar]+U_j[iVar]); } } } @@ -904,9 +949,9 @@ void CUpwGeneralRoe_Flow::ComputeResidual(su2double *val_residual, su2double **v /*--- Jacobians of the inviscid flux, scaled by kappa because val_resconv ~ kappa*(fc_i+fc_j)*Normal ---*/ - GetInviscidProjJac(Velocity_i, &Enthalpy_i, &Chi_i, &Kappa_i, Normal, kappa, val_Jacobian_i); + GetInviscidProjJac(Velocity_i, &Enthalpy_i, &Chi_i, &Kappa_i, Normal, kappa, Jacobian_i); - GetInviscidProjJac(Velocity_j, &Enthalpy_j, &Chi_j, &Kappa_j, Normal, kappa, val_Jacobian_j); + GetInviscidProjJac(Velocity_j, &Enthalpy_j, &Chi_j, &Kappa_j, Normal, kappa, Jacobian_j); /*--- Diference variables iPoint and jPoint ---*/ @@ -915,7 +960,7 @@ void CUpwGeneralRoe_Flow::ComputeResidual(su2double *val_residual, su2double **v /*--- Roe's Flux approximation ---*/ for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] = kappa*(ProjFlux_i[iVar]+ProjFlux_j[iVar]); + Flux[iVar] = kappa*(ProjFlux_i[iVar]+ProjFlux_j[iVar]); for (jVar = 0; jVar < nVar; jVar++) { Proj_ModJac_Tensor_ij = 0.0; @@ -924,9 +969,9 @@ void CUpwGeneralRoe_Flow::ComputeResidual(su2double *val_residual, su2double **v for (kVar = 0; kVar < nVar; kVar++) Proj_ModJac_Tensor_ij += P_Tensor[iVar][kVar]*Lambda[kVar]*invP_Tensor[kVar][jVar]; - val_residual[iVar] -= (1.0-kappa)*Proj_ModJac_Tensor_ij*Diff_U[jVar]*Area; - val_Jacobian_i[iVar][jVar] += (1.0-kappa)*Proj_ModJac_Tensor_ij*Area; - val_Jacobian_j[iVar][jVar] -= (1.0-kappa)*Proj_ModJac_Tensor_ij*Area; + Flux[iVar] -= (1.0-kappa)*Proj_ModJac_Tensor_ij*Diff_U[jVar]*Area; + Jacobian_i[iVar][jVar] += (1.0-kappa)*Proj_ModJac_Tensor_ij*Area; + Jacobian_j[iVar][jVar] -= (1.0-kappa)*Proj_ModJac_Tensor_ij*Area; } } @@ -936,17 +981,22 @@ void CUpwGeneralRoe_Flow::ComputeResidual(su2double *val_residual, su2double **v for (iDim = 0; iDim < nDim; iDim++) ProjVelocity += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] -= ProjVelocity * 0.5*(U_i[iVar]+U_j[iVar]); + Flux[iVar] -= ProjVelocity * 0.5*(U_i[iVar]+U_j[iVar]); /*--- Implicit terms ---*/ - val_Jacobian_i[iVar][iVar] -= 0.5*ProjVelocity; - val_Jacobian_j[iVar][iVar] -= 0.5*ProjVelocity; + Jacobian_i[iVar][iVar] -= 0.5*ProjVelocity; + Jacobian_j[iVar][iVar] -= 0.5*ProjVelocity; } } } - AD::SetPreaccOut(val_residual, nVar); + AD::SetPreaccOut(Flux, nVar); AD::EndPreacc(); + + residual = Flux; + jacobian_i = Jacobian_i; + jacobian_j = Jacobian_j; + } void CUpwGeneralRoe_Flow::ComputeRoeAverage() { @@ -969,7 +1019,6 @@ void CUpwGeneralRoe_Flow::ComputeRoeAverage() { RoeChi = 0.5*(Chi_i + Chi_j); RoeChi = (Chi_i + Chi_j + 4*RoeChi)/6; - // RoeKappaStaticEnthalpy = 0.5*(StaticEnthalpy_i*Kappa_i + StaticEnthalpy_j*Kappa_j); // RoeKappaStaticEnthalpy = (StaticEnthalpy_i*Kappa_i + StaticEnthalpy_j*Kappa_j + 4*RoeKappaStaticEnthalpy)/6; // s = RoeChi + RoeKappaStaticEnthalpy; From ce5447c1f80ca0af6f35813df05582e724835b7e Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Tue, 28 Jan 2020 17:23:50 +0000 Subject: [PATCH 030/118] fix variable lifetime issues --- SU2_CFD/src/solvers/CEulerSolver.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 60b1fe5f4793..4fe8e423ccba 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -3242,7 +3242,7 @@ void CEulerSolver::Centered_Residual(CGeometry *geometry, CSolver **solver_conta CConfig *config, unsigned short iMesh, unsigned short iRKStep) { const bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - const bool jst_scheme = ((config->GetKind_Centered_Flow() == JST) && (iMesh == MESH_0)); + const bool jst_scheme = (config->GetKind_Centered_Flow() == JST) && (iMesh == MESH_0); /*--- Start OpenMP parallel section. ---*/ @@ -3350,6 +3350,10 @@ void CEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_contain /*--- Pick one numerics object per thread. ---*/ CNumerics* numerics = numerics_container[CONV_TERM + omp_get_thread_num()*MAX_TERMS]; + /*--- Static arrays of MUSCL-reconstructed primitives and secondaries (thread safety). ---*/ + su2double Primitive_i[MAXNVAR] = {0.0}, Primitive_j[MAXNVAR] = {0.0}; + su2double Secondary_i[MAXNVAR] = {0.0}, Secondary_j[MAXNVAR] = {0.0}; + /*--- Loop over all the edges ---*/ #ifdef HAVE_OMP @@ -3412,11 +3416,6 @@ void CEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_contain else { /*--- Reconstruction ---*/ - /*--- Static arrays of primitives and secondaries (thread safety). ---*/ - - su2double Primitive_i[MAXNVAR] = {0.0}, Primitive_j[MAXNVAR] = {0.0}; - su2double Secondary_i[MAXNVAR] = {0.0}, Secondary_j[MAXNVAR] = {0.0}; - su2double Vector_ij[MAXNDIM] = {0.0}; for (iDim = 0; iDim < nDim; iDim++) { Vector_ij[iDim] = 0.5*(Coord_j[iDim] - Coord_i[iDim]); From 9a30827e481162d781ec852d8e7f7ffd15af98cd Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Tue, 28 Jan 2020 17:43:12 +0000 Subject: [PATCH 031/118] change the signature of Source_Residual to pass another index of numerics --- SU2_CFD/include/solvers/CAdjEulerSolver.hpp | 9 +- SU2_CFD/include/solvers/CAdjNSSolver.hpp | 11 +- SU2_CFD/include/solvers/CAdjTurbSolver.hpp | 9 +- SU2_CFD/include/solvers/CEulerSolver.hpp | 9 +- SU2_CFD/include/solvers/CHeatSolverFVM.hpp | 9 +- SU2_CFD/include/solvers/CIncEulerSolver.hpp | 9 +- SU2_CFD/include/solvers/CSolver.hpp | 5 +- SU2_CFD/include/solvers/CTemplateSolver.hpp | 9 +- SU2_CFD/include/solvers/CTransLMSolver.hpp | 9 +- SU2_CFD/include/solvers/CTurbSASolver.hpp | 11 +- SU2_CFD/include/solvers/CTurbSSTSolver.hpp | 11 +- SU2_CFD/src/integration_structure.cpp | 108 ++++++++++---------- SU2_CFD/src/solvers/CAdjEulerSolver.cpp | 6 +- SU2_CFD/src/solvers/CAdjNSSolver.cpp | 9 +- SU2_CFD/src/solvers/CAdjTurbSolver.cpp | 7 +- SU2_CFD/src/solvers/CEulerSolver.cpp | 26 +++-- SU2_CFD/src/solvers/CHeatSolverFVM.cpp | 3 +- SU2_CFD/src/solvers/CIncEulerSolver.cpp | 5 +- SU2_CFD/src/solvers/CTemplateSolver.cpp | 4 +- SU2_CFD/src/solvers/CTransLMSolver.cpp | 7 +- SU2_CFD/src/solvers/CTurbSASolver.cpp | 7 +- SU2_CFD/src/solvers/CTurbSSTSolver.cpp | 5 +- 22 files changed, 154 insertions(+), 134 deletions(-) diff --git a/SU2_CFD/include/solvers/CAdjEulerSolver.hpp b/SU2_CFD/include/solvers/CAdjEulerSolver.hpp index 083fbf2df828..53787ac7323a 100644 --- a/SU2_CFD/include/solvers/CAdjEulerSolver.hpp +++ b/SU2_CFD/include/solvers/CAdjEulerSolver.hpp @@ -199,16 +199,15 @@ class CAdjEulerSolver : public CSolver { * \brief Source term integration. * \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] numerics_container - Description of the numerical method. * \param[in] config - Definition of the particular problem. * \param[in] iMesh - Index of the mesh in multigrid computations. */ void Source_Residual(CGeometry *geometry, CSolver **solver_container, - CNumerics *numerics, - CNumerics *second_numerics, - CConfig *config, unsigned short iMesh) override; + CNumerics **numerics_container, + CConfig *config, + unsigned short iMesh) override; /*! * \brief Source term integration. diff --git a/SU2_CFD/include/solvers/CAdjNSSolver.hpp b/SU2_CFD/include/solvers/CAdjNSSolver.hpp index 489e7c130fd9..2abf49f71452 100644 --- a/SU2_CFD/include/solvers/CAdjNSSolver.hpp +++ b/SU2_CFD/include/solvers/CAdjNSSolver.hpp @@ -152,15 +152,14 @@ class CAdjNSSolver final : public CAdjEulerSolver { * \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] numerics_container - Description of the numerical method. * \param[in] config - Definition of the particular problem. * \param[in] iMesh - Index of the mesh in multigrid computations. */ void Source_Residual(CGeometry *geometry, CSolver **solver_container, - CNumerics *numerics, - CNumerics *second_numerics, - CConfig *config, unsigned short iMesh) override; + CNumerics **numerics_container, + CConfig *config, + unsigned short iMesh) override; -}; \ No newline at end of file +}; diff --git a/SU2_CFD/include/solvers/CAdjTurbSolver.hpp b/SU2_CFD/include/solvers/CAdjTurbSolver.hpp index f0be052e191a..48a85fb6afc2 100644 --- a/SU2_CFD/include/solvers/CAdjTurbSolver.hpp +++ b/SU2_CFD/include/solvers/CAdjTurbSolver.hpp @@ -169,16 +169,15 @@ class CAdjTurbSolver final : public CSolver { * \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] numerics_container - Description of the numerical method. * \param[in] config - Definition of the particular problem. * \param[in] iMesh - Index of the mesh in multigrid computations. */ void Source_Residual(CGeometry *geometry, CSolver **solver_container, - CNumerics *numerics, - CNumerics *second_numerics, - CConfig *config, unsigned short iMesh) override; + CNumerics **numerics_container, + CConfig *config, + unsigned short iMesh) override; /*! * \brief Update the solution using an implicit solver. diff --git a/SU2_CFD/include/solvers/CEulerSolver.hpp b/SU2_CFD/include/solvers/CEulerSolver.hpp index 482a038132f7..c0e5c77b3245 100644 --- a/SU2_CFD/include/solvers/CEulerSolver.hpp +++ b/SU2_CFD/include/solvers/CEulerSolver.hpp @@ -489,16 +489,15 @@ class CEulerSolver : public CSolver { * \brief Source term integration. * \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] numerics_container - Description of the numerical method. * \param[in] config - Definition of the particular problem. * \param[in] iMesh - Index of the mesh in multigrid computations. */ void Source_Residual(CGeometry *geometry, CSolver **solver_container, - CNumerics *numerics, - CNumerics *second_numerics, - CConfig *config, unsigned short iMesh) override; + CNumerics **numerics_container, + CConfig *config, + unsigned short iMesh) override; /*! * \brief Source term integration. diff --git a/SU2_CFD/include/solvers/CHeatSolverFVM.hpp b/SU2_CFD/include/solvers/CHeatSolverFVM.hpp index 3dc5653ff90a..0d7df2235d2e 100644 --- a/SU2_CFD/include/solvers/CHeatSolverFVM.hpp +++ b/SU2_CFD/include/solvers/CHeatSolverFVM.hpp @@ -116,16 +116,15 @@ class CHeatSolverFVM final : public CSolver { * \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] numerics_container - Description of the numerical method. * \param[in] config - Definition of the particular problem. * \param[in] iMesh - Index of the mesh in multigrid computations. */ void Source_Residual(CGeometry *geometry, CSolver **solver_container, - CNumerics *numerics, - CNumerics *second_numerics, - CConfig *config, unsigned short iMesh) override; + CNumerics **numerics_container, + CConfig *config, + unsigned short iMesh) override; /*! * \brief Compute the undivided laplacian for the solution. diff --git a/SU2_CFD/include/solvers/CIncEulerSolver.hpp b/SU2_CFD/include/solvers/CIncEulerSolver.hpp index 5c523cb5eeba..b434a50d0339 100644 --- a/SU2_CFD/include/solvers/CIncEulerSolver.hpp +++ b/SU2_CFD/include/solvers/CIncEulerSolver.hpp @@ -358,16 +358,15 @@ class CIncEulerSolver : public CSolver { * \brief Source term integration. * \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] numerics_container - Description of the numerical method. * \param[in] config - Definition of the particular problem. * \param[in] iMesh - Index of the mesh in multigrid computations. */ void Source_Residual(CGeometry *geometry, CSolver **solver_container, - CNumerics *numerics, - CNumerics *second_numerics, - CConfig *config, unsigned short iMesh) final; + CNumerics **numerics_container, + CConfig *config, + unsigned short iMesh) final; /*! * \brief Source term integration. diff --git a/SU2_CFD/include/solvers/CSolver.hpp b/SU2_CFD/include/solvers/CSolver.hpp index 5f4ed97cae92..05014bb78ce0 100644 --- a/SU2_CFD/include/solvers/CSolver.hpp +++ b/SU2_CFD/include/solvers/CSolver.hpp @@ -1723,15 +1723,14 @@ class CSolver { * \brief A virtual member. * \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] numerics_container - 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. */ inline virtual void Source_Residual(CGeometry *geometry, CSolver **solver_container, - CNumerics *numerics, - CNumerics *second_numerics, + CNumerics **numerics_container, CConfig *config, unsigned short iMesh) { } diff --git a/SU2_CFD/include/solvers/CTemplateSolver.hpp b/SU2_CFD/include/solvers/CTemplateSolver.hpp index 6e6a6a53a102..611d3ac54145 100644 --- a/SU2_CFD/include/solvers/CTemplateSolver.hpp +++ b/SU2_CFD/include/solvers/CTemplateSolver.hpp @@ -130,16 +130,15 @@ class CTemplateSolver final : public CSolver { * \brief Source term integration. * \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] numerics_container - Description of the numerical method. * \param[in] config - Definition of the particular problem. * \param[in] iMesh - Index of the mesh in multigrid computations. */ void Source_Residual(CGeometry *geometry, CSolver **solver_container, - CNumerics *numerics, - CNumerics *second_numerics, - CConfig *config, unsigned short iMesh) override; + CNumerics **numerics_container, + CConfig *config, + unsigned short iMesh) override; /*! * \brief Source term integration. diff --git a/SU2_CFD/include/solvers/CTransLMSolver.hpp b/SU2_CFD/include/solvers/CTransLMSolver.hpp index 4e76354fcc93..6099ca4573a7 100644 --- a/SU2_CFD/include/solvers/CTransLMSolver.hpp +++ b/SU2_CFD/include/solvers/CTransLMSolver.hpp @@ -122,16 +122,15 @@ class CTransLMSolver final : public CTurbSolver { * \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] numerics_container - Description of the numerical method. * \param[in] config - Definition of the particular problem. * \param[in] iMesh - Index of the mesh in multigrid computations. */ void Source_Residual(CGeometry *geometry, CSolver **solver_container, - CNumerics *numerics, - CNumerics *second_numerics, - CConfig *config, unsigned short iMesh) override; + CNumerics **numerics_container, + CConfig *config, + unsigned short iMesh) override; /*! * \brief Source term computation. diff --git a/SU2_CFD/include/solvers/CTurbSASolver.hpp b/SU2_CFD/include/solvers/CTurbSASolver.hpp index 9b16dd487ecb..dfb5f1d6b670 100644 --- a/SU2_CFD/include/solvers/CTurbSASolver.hpp +++ b/SU2_CFD/include/solvers/CTurbSASolver.hpp @@ -93,16 +93,15 @@ class CTurbSASolver final : public CTurbSolver { * \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] numerics_container - Description of the numerical method. * \param[in] config - Definition of the particular problem. * \param[in] iMesh - Index of the mesh in multigrid computations. */ void Source_Residual(CGeometry *geometry, CSolver **solver_container, - CNumerics *numerics, - CNumerics *second_numerics, - CConfig *config, unsigned short iMesh) override; + CNumerics **numerics_container, + CConfig *config, + unsigned short iMesh) override; /*! * \brief Source term computation. @@ -431,4 +430,4 @@ class CTurbSASolver final : public CTurbSolver { CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) override; -}; \ No newline at end of file +}; diff --git a/SU2_CFD/include/solvers/CTurbSSTSolver.hpp b/SU2_CFD/include/solvers/CTurbSSTSolver.hpp index 0dc6391acd15..843f4b98a057 100644 --- a/SU2_CFD/include/solvers/CTurbSSTSolver.hpp +++ b/SU2_CFD/include/solvers/CTurbSSTSolver.hpp @@ -95,16 +95,15 @@ class CTurbSSTSolver final : public CTurbSolver { * \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] numerics_container - Description of the numerical method. * \param[in] config - Definition of the particular problem. * \param[in] iMesh - Index of the mesh in multigrid computations. */ void Source_Residual(CGeometry *geometry, CSolver **solver_container, - CNumerics *numerics, - CNumerics *second_numerics, - CConfig *config, unsigned short iMesh) override; + CNumerics **numerics_container, + CConfig *config, + unsigned short iMesh) override; /*! * \brief Source term computation. @@ -309,4 +308,4 @@ class CTurbSSTSolver final : public CTurbSolver { */ inline su2double GetOmega_Inf(void) const override { return omega_Inf; } -}; \ No newline at end of file +}; diff --git a/SU2_CFD/src/integration_structure.cpp b/SU2_CFD/src/integration_structure.cpp index 0cd4f726e752..f0aa3b49af3c 100644 --- a/SU2_CFD/src/integration_structure.cpp +++ b/SU2_CFD/src/integration_structure.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -54,13 +54,13 @@ void CIntegration::Space_Integration(CGeometry *geometry, unsigned short iRKStep, unsigned short RunTime_EqSystem) { unsigned short iMarker, KindBC; - + unsigned short MainSolver = config->GetContainerPosition(RunTime_EqSystem); bool dual_time = ((config->GetTime_Marching() == DT_STEPPING_1ST) || (config->GetTime_Marching() == DT_STEPPING_2ND)); /*--- Compute inviscid residuals ---*/ - + switch (config->GetKind_ConvNumScheme()) { case SPACE_CENTERED: solver_container[MainSolver]->Centered_Residual(geometry, solver_container, numerics, config, iMesh, iRKStep); @@ -72,20 +72,20 @@ void CIntegration::Space_Integration(CGeometry *geometry, solver_container[MainSolver]->Convective_Residual(geometry, solver_container, numerics[CONV_TERM], config, iMesh, iRKStep); break; } - + /*--- Compute viscous residuals ---*/ - + solver_container[MainSolver]->Viscous_Residual(geometry, solver_container, numerics[VISC_TERM], config, iMesh, iRKStep); - + /*--- Compute source term residuals ---*/ - solver_container[MainSolver]->Source_Residual(geometry, solver_container, numerics[SOURCE_FIRST_TERM], numerics[SOURCE_SECOND_TERM], config, iMesh); - + solver_container[MainSolver]->Source_Residual(geometry, solver_container, numerics, config, iMesh); + /*--- Add viscous and convective residuals, and compute the Dual Time Source term ---*/ - + if (dual_time) solver_container[MainSolver]->SetResidual_DualTime(geometry, solver_container, config, iRKStep, iMesh, RunTime_EqSystem); - + /*--- Boundary conditions that depend on other boundaries (they require MPI sincronization)---*/ solver_container[MainSolver]->BC_Fluid_Interface(geometry, solver_container, numerics[CONV_BOUND_TERM], numerics[VISC_BOUND_TERM], config); @@ -99,7 +99,7 @@ void CIntegration::Space_Integration(CGeometry *geometry, } /*--- Weak boundary conditions ---*/ - + for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { KindBC = config->GetMarker_All_KindBC(iMarker); switch (KindBC) { @@ -155,9 +155,9 @@ void CIntegration::Space_Integration(CGeometry *geometry, break; } } - + /*--- Strong boundary conditions (Navier-Stokes and Dirichlet type BCs) ---*/ - + for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) switch (config->GetMarker_All_KindBC(iMarker)) { case ISOTHERMAL: @@ -169,7 +169,7 @@ void CIntegration::Space_Integration(CGeometry *geometry, case CUSTOM_BOUNDARY: solver_container[MainSolver]->BC_Custom(geometry, solver_container, numerics[CONV_BOUND_TERM], numerics[VISC_BOUND_TERM], config, iMarker); break; - case CHT_WALL_INTERFACE: + case CHT_WALL_INTERFACE: if ((MainSolver == HEAT_SOL) || (MainSolver == FLOW_SOL && ((config->GetKind_Regime() == COMPRESSIBLE) || config->GetEnergy_Equation()))) { solver_container[MainSolver]->BC_ConjugateHeat_Interface(geometry, solver_container, numerics[CONV_BOUND_TERM], config, iMarker); } @@ -178,16 +178,16 @@ void CIntegration::Space_Integration(CGeometry *geometry, } break; } - + /*--- Complete residuals for periodic boundary conditions. We loop over the periodic BCs in matching pairs so that, in the event that there are adjacent periodic markers, the repeated points will have their residuals accumulated corectly during the communications. ---*/ - + if (config->GetnMarker_Periodic() > 0) { solver_container[MainSolver]->BC_Periodic(geometry, solver_container, numerics[CONV_BOUND_TERM], config); } - + } void CIntegration::Space_Integration_FEM(CGeometry *geometry, @@ -273,24 +273,24 @@ void CIntegration::Space_Integration_FEM(CGeometry *geometry, void CIntegration::Adjoint_Setup(CGeometry ****geometry, CSolver *****solver_container, CConfig **config, unsigned short RunTime_EqSystem, unsigned long Iteration, unsigned short iZone) { - + unsigned short iMGLevel; - + if ( ( (RunTime_EqSystem == RUNTIME_ADJFLOW_SYS) && (Iteration == 0) ) ) { for (iMGLevel = 0; iMGLevel <= config[iZone]->GetnMGLevels(); iMGLevel++) { - + /*--- Set the time step in all the MG levels ---*/ - + solver_container[iZone][INST_0][iMGLevel][FLOW_SOL]->SetTime_Step(geometry[iZone][INST_0][iMGLevel], solver_container[iZone][INST_0][iMGLevel], config[iZone], iMGLevel, Iteration); - + /*--- Set the force coefficients ---*/ solver_container[iZone][INST_0][iMGLevel][FLOW_SOL]->SetTotal_CD(solver_container[iZone][INST_0][MESH_0][FLOW_SOL]->GetTotal_CD()); solver_container[iZone][INST_0][iMGLevel][FLOW_SOL]->SetTotal_CL(solver_container[iZone][INST_0][MESH_0][FLOW_SOL]->GetTotal_CL()); solver_container[iZone][INST_0][iMGLevel][FLOW_SOL]->SetTotal_CT(solver_container[iZone][INST_0][MESH_0][FLOW_SOL]->GetTotal_CT()); solver_container[iZone][INST_0][iMGLevel][FLOW_SOL]->SetTotal_CQ(solver_container[iZone][INST_0][MESH_0][FLOW_SOL]->GetTotal_CQ()); - + /*--- Restrict solution and gradients to the coarse levels ---*/ - + 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]); @@ -298,17 +298,17 @@ void CIntegration::Adjoint_Setup(CGeometry ****geometry, CSolver *****solver_con // 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]); } - + } } - + } void CIntegration::Time_Integration(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iRKStep, unsigned short RunTime_EqSystem) { unsigned short MainSolver = config->GetContainerPosition(RunTime_EqSystem); unsigned short KindSolver = config->GetKind_Solver(); - + /*--- Perform the time integration ---*/ /*--- Fluid time integration schemes ---*/ @@ -331,7 +331,7 @@ void CIntegration::Time_Integration(CGeometry *geometry, CSolver **solver_contai } /*--- Structural time integration schemes ---*/ - + } else if (KindSolver == FEM_ELASTICITY) { @@ -432,74 +432,74 @@ void CIntegration::SetDualTime_Solver(CGeometry *geometry, CSolver *solver, CCon solver->ResetCFLAdapt(); 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)); - + geometry->node[iPoint]->SetVolume_nM1(); geometry->node[iPoint]->SetVolume_n(); - + /*--- Store old coordinates in case there is grid movement ---*/ - + if (config->GetGrid_Movement()) { geometry->node[iPoint]->SetCoord_n1(); geometry->node[iPoint]->SetCoord_n(); } } - + /*--- Store old aeroelastic solutions ---*/ if (config->GetGrid_Movement() && config->GetAeroelastic_Simulation() && (iMesh == MESH_0)) { config->SetAeroelastic_n1(); config->SetAeroelastic_n(); - + /*--- Also communicate plunge and pitch to the master node. Needed for output in case of parallel run ---*/ - + #ifdef HAVE_MPI su2double plunge, pitch, *plunge_all = NULL, *pitch_all = NULL; unsigned short iMarker, iMarker_Monitoring; unsigned long iProcessor, owner, *owner_all = NULL; - + string Marker_Tag, Monitoring_Tag; int nProcessor = size; /*--- Only if master node allocate memory ---*/ - + if (rank == MASTER_NODE) { plunge_all = new su2double[nProcessor]; pitch_all = new su2double[nProcessor]; owner_all = new unsigned long[nProcessor]; } - + /*--- Find marker and give it's plunge and pitch coordinate to the master node ---*/ - + for (iMarker_Monitoring = 0; iMarker_Monitoring < config->GetnMarker_Monitoring(); iMarker_Monitoring++) { - + for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { - + Monitoring_Tag = config->GetMarker_Monitoring_TagBound(iMarker_Monitoring); Marker_Tag = config->GetMarker_All_TagBound(iMarker); if (Marker_Tag == Monitoring_Tag) { owner = 1; break; } else { owner = 0; } - + } plunge = config->GetAeroelastic_plunge(iMarker_Monitoring); pitch = config->GetAeroelastic_pitch(iMarker_Monitoring); - + /*--- Gather the data on the master node. ---*/ - + SU2_MPI::Gather(&plunge, 1, MPI_DOUBLE, plunge_all, 1, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); SU2_MPI::Gather(&pitch, 1, MPI_DOUBLE, pitch_all, 1, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); SU2_MPI::Gather(&owner, 1, MPI_UNSIGNED_LONG, owner_all, 1, MPI_UNSIGNED_LONG, MASTER_NODE, MPI_COMM_WORLD); - + /*--- Set plunge and pitch on the master node ---*/ - + if (rank == MASTER_NODE) { for (iProcessor = 0; iProcessor < (unsigned long)nProcessor; iProcessor++) { if (owner_all[iProcessor] == 1) { @@ -509,9 +509,9 @@ void CIntegration::SetDualTime_Solver(CGeometry *geometry, CSolver *solver, CCon } } } - + } - + if (rank == MASTER_NODE) { delete [] plunge_all; delete [] pitch_all; @@ -519,7 +519,7 @@ void CIntegration::SetDualTime_Solver(CGeometry *geometry, CSolver *solver, CCon } #endif } - + } void CIntegration::SetStructural_Solver(CGeometry *geometry, CSolver *solver, CConfig *config, unsigned short iMesh) { @@ -545,9 +545,9 @@ void CIntegration::SetStructural_Solver(CGeometry *geometry, CSolver *solver, CC void CIntegration::SetFEM_StructuralSolver(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh) { bool fsi = config->GetFSI_Simulation(); - + /*--- Update the solution according to the integration scheme used ---*/ - + switch (config->GetKind_TimeIntScheme_FEA()) { case (CD_EXPLICIT): break; diff --git a/SU2_CFD/src/solvers/CAdjEulerSolver.cpp b/SU2_CFD/src/solvers/CAdjEulerSolver.cpp index 5f52e00b70cc..e733952c92b2 100644 --- a/SU2_CFD/src/solvers/CAdjEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CAdjEulerSolver.cpp @@ -1915,8 +1915,10 @@ void CAdjEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_cont } -void CAdjEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, CNumerics *second_numerics, - CConfig *config, unsigned short iMesh) { +void CAdjEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_container, + CNumerics **numerics_container, CConfig *config, unsigned short iMesh) { + + CNumerics* numerics = numerics_container[SOURCE_FIRST_TERM]; unsigned short iVar; unsigned long iPoint; diff --git a/SU2_CFD/src/solvers/CAdjNSSolver.cpp b/SU2_CFD/src/solvers/CAdjNSSolver.cpp index ec4ffd182bd4..f9c4c5502a0c 100644 --- a/SU2_CFD/src/solvers/CAdjNSSolver.cpp +++ b/SU2_CFD/src/solvers/CAdjNSSolver.cpp @@ -463,8 +463,11 @@ void CAdjNSSolver::Viscous_Residual(CGeometry *geometry, CSolver **solver_contai } -void CAdjNSSolver::Source_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, CNumerics *second_numerics, - CConfig *config, unsigned short iMesh) { +void CAdjNSSolver::Source_Residual(CGeometry *geometry, CSolver **solver_container, + CNumerics **numerics_container, CConfig *config, unsigned short iMesh) { + + CNumerics* numerics = numerics_container[SOURCE_FIRST_TERM]; + CNumerics* second_numerics = numerics_container[SOURCE_SECOND_TERM]; unsigned long iPoint, jPoint, iEdge; @@ -1908,4 +1911,4 @@ void CAdjNSSolver::BC_Isothermal_Wall(CGeometry *geometry, CSolver **solver_cont delete [] GradPhi[iDim]; delete [] GradPhi; delete [] dPoRho2; -} \ No newline at end of file +} diff --git a/SU2_CFD/src/solvers/CAdjTurbSolver.cpp b/SU2_CFD/src/solvers/CAdjTurbSolver.cpp index c409af03f69e..00f2343891a7 100644 --- a/SU2_CFD/src/solvers/CAdjTurbSolver.cpp +++ b/SU2_CFD/src/solvers/CAdjTurbSolver.cpp @@ -389,7 +389,12 @@ void CAdjTurbSolver::Viscous_Residual(CGeometry *geometry, CSolver **solver_cont } -void CAdjTurbSolver::Source_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, CNumerics *second_numerics, CConfig *config, unsigned short iMesh) { +void CAdjTurbSolver::Source_Residual(CGeometry *geometry, CSolver **solver_container, + CNumerics **numerics_container, CConfig *config, unsigned short iMesh) { + + CNumerics* numerics = numerics_container[SOURCE_FIRST_TERM]; + //CNumerics* second_numerics = numerics_container[SOURCE_SECOND_TERM]; + unsigned long iPoint; su2double *U_i, **GradPrimVar_i, *TurbVar_i; su2double **TurbVar_Grad_i, *TurbPsi_i, **PsiVar_Grad_i; // Gradients diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 4fe8e423ccba..80e5defa9481 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -3613,18 +3613,26 @@ void CEulerSolver::LowMachPrimitiveCorrection(CFluidModel *fluidModel, unsigned } -void CEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, CNumerics *second_numerics, - CConfig *config, unsigned short iMesh) { +void CEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_container, + CNumerics **numerics_container, CConfig *config, unsigned short iMesh) { + + CNumerics* numerics = numerics_container[SOURCE_FIRST_TERM]; + + const bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + const bool rotating_frame = config->GetRotating_Frame(); + const bool axisymmetric = config->GetAxisymmetric(); + const bool gravity = (config->GetGravityForce() == YES); + const bool harmonic_balance = (config->GetTime_Marching() == HARMONIC_BALANCE); + const bool windgust = config->GetWind_Gust(); + const bool body_force = config->GetBody_Force(); + +// /*--- Start OpenMP parallel section. ---*/ +// +// SU2_OMP_PARALLEL_(reduction(+:counter_local)) +// { unsigned short iVar; unsigned long iPoint; - bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - bool rotating_frame = config->GetRotating_Frame(); - bool axisymmetric = config->GetAxisymmetric(); - bool gravity = (config->GetGravityForce() == YES); - bool harmonic_balance = (config->GetTime_Marching() == HARMONIC_BALANCE); - bool windgust = config->GetWind_Gust(); - bool body_force = config->GetBody_Force(); /*--- Initialize the source residual to zero ---*/ diff --git a/SU2_CFD/src/solvers/CHeatSolverFVM.cpp b/SU2_CFD/src/solvers/CHeatSolverFVM.cpp index fd9c23ed64ef..de738528e81b 100644 --- a/SU2_CFD/src/solvers/CHeatSolverFVM.cpp +++ b/SU2_CFD/src/solvers/CHeatSolverFVM.cpp @@ -721,7 +721,8 @@ void CHeatSolverFVM::Viscous_Residual(CGeometry *geometry, CSolver **solver_cont } } -void CHeatSolverFVM::Source_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, CNumerics *second_numerics, CConfig *config, unsigned short iMesh) { } +void CHeatSolverFVM::Source_Residual(CGeometry *geometry, CSolver **solver_container, + CNumerics **numerics_container, CConfig *config, unsigned short iMesh) { } void CHeatSolverFVM::Set_Heatflux_Areas(CGeometry *geometry, CConfig *config) { diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index 8658c0f3fc80..f7a2a77661fe 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -2028,7 +2028,10 @@ void CIncEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_cont } -void CIncEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, CNumerics *second_numerics, CConfig *config, unsigned short iMesh) { +void CIncEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_container, + CNumerics **numerics_container, CConfig *config, unsigned short iMesh) { + + CNumerics* numerics = numerics_container[SOURCE_FIRST_TERM]; unsigned short iVar; unsigned long iPoint; diff --git a/SU2_CFD/src/solvers/CTemplateSolver.cpp b/SU2_CFD/src/solvers/CTemplateSolver.cpp index 28b995fa8371..5d6aceaf5a5f 100644 --- a/SU2_CFD/src/solvers/CTemplateSolver.cpp +++ b/SU2_CFD/src/solvers/CTemplateSolver.cpp @@ -44,8 +44,8 @@ void CTemplateSolver::Centered_Residual(CGeometry *geometry, CSolver **solver_co void CTemplateSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics_container, CConfig *config, unsigned short iMesh) { } -void CTemplateSolver::Source_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, CNumerics *second_numerics, - CConfig *config, unsigned short iMesh) { } +void CTemplateSolver::Source_Residual(CGeometry *geometry, CSolver **solver_container, + CNumerics **numerics_container, CConfig *config, unsigned short iMesh) { } void CTemplateSolver::Source_Template(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, CConfig *config, unsigned short iMesh) { } diff --git a/SU2_CFD/src/solvers/CTransLMSolver.cpp b/SU2_CFD/src/solvers/CTransLMSolver.cpp index c807859d5f2c..4fdd1bbca056 100644 --- a/SU2_CFD/src/solvers/CTransLMSolver.cpp +++ b/SU2_CFD/src/solvers/CTransLMSolver.cpp @@ -351,8 +351,11 @@ void CTransLMSolver::Viscous_Residual(CGeometry *geometry, CSolver **solver_cont } } -void CTransLMSolver::Source_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, CNumerics *second_numerics, - CConfig *config, unsigned short iMesh) { +void CTransLMSolver::Source_Residual(CGeometry *geometry, CSolver **solver_container, + CNumerics **numerics_container, CConfig *config, unsigned short iMesh) { + + CNumerics* numerics = numerics_container[SOURCE_FIRST_TERM]; + unsigned long iPoint; su2double gamma_sep = 0.0; diff --git a/SU2_CFD/src/solvers/CTurbSASolver.cpp b/SU2_CFD/src/solvers/CTurbSASolver.cpp index d296ccf7d419..88d133e08a3d 100644 --- a/SU2_CFD/src/solvers/CTurbSASolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSASolver.cpp @@ -376,8 +376,11 @@ void CTurbSASolver::Postprocessing(CGeometry *geometry, CSolver **solver_contain } -void CTurbSASolver::Source_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, CNumerics *second_numerics, - CConfig *config, unsigned short iMesh) { +void CTurbSASolver::Source_Residual(CGeometry *geometry, CSolver **solver_container, + CNumerics **numerics_container, CConfig *config, unsigned short iMesh) { + + CNumerics* numerics = numerics_container[SOURCE_FIRST_TERM]; + unsigned long iPoint; bool harmonic_balance = (config->GetTime_Marching() == HARMONIC_BALANCE); diff --git a/SU2_CFD/src/solvers/CTurbSSTSolver.cpp b/SU2_CFD/src/solvers/CTurbSSTSolver.cpp index c30873da000a..4680e813a8b0 100644 --- a/SU2_CFD/src/solvers/CTurbSSTSolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSSTSolver.cpp @@ -381,7 +381,10 @@ void CTurbSSTSolver::Postprocessing(CGeometry *geometry, CSolver **solver_contai } -void CTurbSSTSolver::Source_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, CNumerics *second_numerics, CConfig *config, unsigned short iMesh) { +void CTurbSSTSolver::Source_Residual(CGeometry *geometry, CSolver **solver_container, + CNumerics **numerics_container, CConfig *config, unsigned short iMesh) { + + CNumerics* numerics = numerics_container[SOURCE_FIRST_TERM]; unsigned long iPoint; From 8444c6b3795efd9301464b2d69aa0fe2f3f1abbc Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Tue, 28 Jan 2020 19:40:24 +0000 Subject: [PATCH 032/118] fix calls to CNumerics::ComputeResidual in BC contexts --- Common/include/linear_algebra/CSysMatrix.hpp | 6 +- SU2_CFD/src/solvers/CEulerSolver.cpp | 168 ++++++++++++------- 2 files changed, 113 insertions(+), 61 deletions(-) diff --git a/Common/include/linear_algebra/CSysMatrix.hpp b/Common/include/linear_algebra/CSysMatrix.hpp index fc74609bed4b..8e6ec422047f 100644 --- a/Common/include/linear_algebra/CSysMatrix.hpp +++ b/Common/include/linear_algebra/CSysMatrix.hpp @@ -440,7 +440,7 @@ class CSysMatrix { * \param[in] val_block - Block to set to A(i, j). */ template - inline void SetBlock(unsigned long block_i, unsigned long block_j, OtherType **val_block) { + inline void SetBlock(unsigned long block_i, unsigned long block_j, const OtherType* const* val_block) { unsigned long iVar, jVar, index; @@ -503,7 +503,7 @@ class CSysMatrix { * \param[in] val_block - Block to add to A(i, j). */ template - inline void AddBlock(unsigned long block_i, unsigned long block_j, OtherType **val_block) { + inline void AddBlock(unsigned long block_i, unsigned long block_j, const OtherType* const* val_block) { unsigned long iVar, jVar, index; @@ -524,7 +524,7 @@ class CSysMatrix { * \param[in] val_block - Block to subtract to A(i, j). */ template - inline void SubtractBlock(unsigned long block_i, unsigned long block_j, OtherType **val_block) { + inline void SubtractBlock(unsigned long block_i, unsigned long block_j, const OtherType* const* val_block) { unsigned long iVar, jVar, index; diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 80e5defa9481..14c22df0e2b2 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -7458,14 +7458,17 @@ void CEulerSolver::BC_Sym_Plane(CGeometry *geometry, nodes->GetSecondary(iPoint)); /*--- Compute the residual using an upwind scheme. ---*/ - conv_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); + const su2double* flux; + const su2double* const* jacobian_i; + const su2double* const* jacobian_j; + conv_numerics->ComputeResidual(flux, jacobian_i, jacobian_j, config); /*--- Update residual value ---*/ - LinSysRes.AddBlock(iPoint, Residual); + LinSysRes.AddBlock(iPoint, flux); /*--- Jacobian contribution for implicit integration. ---*/ if (implicit) { - Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + Jacobian.AddBlock(iPoint, iPoint, jacobian_i); } if (viscous) { @@ -7783,16 +7786,19 @@ void CEulerSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_container, /*--- Compute the convective residual using an upwind scheme ---*/ - conv_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); + const su2double* flux; + const su2double* const* jacobian_i; + const su2double* const* jacobian_j; + conv_numerics->ComputeResidual(flux, jacobian_i, jacobian_j, config); /*--- Update residual value ---*/ - LinSysRes.AddBlock(iPoint, Residual); + LinSysRes.AddBlock(iPoint, flux); /*--- Convective Jacobian contribution for implicit integration ---*/ if (implicit) - Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + Jacobian.AddBlock(iPoint, iPoint, jacobian_i); /*--- Viscous residual contribution ---*/ @@ -7846,7 +7852,9 @@ void CEulerSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_container, } void CEulerSolver::BC_Riemann(CGeometry *geometry, CSolver **solver_container, - CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { + CNumerics *conv_numerics, CNumerics *visc_numerics, + CConfig *config, unsigned short val_marker) { + unsigned short iDim, iVar, jVar, kVar; unsigned long iVertex, iPoint, Point_Normal; su2double P_Total, T_Total, P_static, T_static, Rho_static, *Mach, *Flow_Dir, Area, UnitNormal[3]; @@ -8348,7 +8356,9 @@ void CEulerSolver::BC_Riemann(CGeometry *geometry, CSolver **solver_container, void CEulerSolver::BC_TurboRiemann(CGeometry *geometry, CSolver **solver_container, - CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { + CNumerics *conv_numerics, CNumerics *visc_numerics, + CConfig *config, unsigned short val_marker) { + unsigned short iDim, iVar, jVar, kVar, iSpan; unsigned long iPoint, Point_Normal, oldVertex, iVertex; su2double P_Total, T_Total, *Flow_Dir; @@ -9005,8 +9015,9 @@ void CEulerSolver::PreprocessBC_Giles(CGeometry *geometry, CConfig *config, CNum } -void CEulerSolver::BC_Giles(CGeometry *geometry, CSolver **solver_container, - CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { +void CEulerSolver::BC_Giles(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, + CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { + unsigned short iDim, iVar, jVar, iSpan; unsigned long iPoint, Point_Normal, oldVertex, k, kend, kend_max, iVertex; su2double *UnitNormal, *turboVelocity, *turboNormal; @@ -9640,14 +9651,17 @@ void CEulerSolver::BC_Giles(CGeometry *geometry, CSolver **solver_container, /*--- Compute the residual using an upwind scheme ---*/ - conv_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); + const su2double* flux; + const su2double* const* jacobian_i; + const su2double* const* jacobian_j; + conv_numerics->ComputeResidual(flux, jacobian_i, jacobian_j, config); /*--- Update residual value ---*/ - LinSysRes.AddBlock(iPoint, Residual); + LinSysRes.AddBlock(iPoint, flux); /*--- Jacobian contribution for implicit integration ---*/ if (implicit) - Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + Jacobian.AddBlock(iPoint, iPoint, jacobian_i); /*--- Viscous contribution ---*/ @@ -9746,7 +9760,8 @@ void CEulerSolver::BC_Giles(CGeometry *geometry, CSolver **solver_container, } void CEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, - CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { + CNumerics *conv_numerics, CNumerics *visc_numerics, + CConfig *config, unsigned short val_marker) { unsigned short iDim; unsigned long iVertex, iPoint; su2double P_Total, T_Total, Velocity[3], Velocity2, H_Total, Temperature, Riemann, @@ -9980,16 +9995,19 @@ void CEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, /*--- Compute the residual using an upwind scheme ---*/ - conv_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); + const su2double* flux; + const su2double* const* jacobian_i; + const su2double* const* jacobian_j; + conv_numerics->ComputeResidual(flux, jacobian_i, jacobian_j, config); /*--- Update residual value ---*/ - LinSysRes.AddBlock(iPoint, Residual); + LinSysRes.AddBlock(iPoint, flux); /*--- Jacobian contribution for implicit integration ---*/ if (implicit) - Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + Jacobian.AddBlock(iPoint, iPoint, jacobian_i); // /*--- Viscous contribution, commented out because serious convergence problems ---*/ // @@ -10041,7 +10059,8 @@ void CEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, } void CEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, - CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { + CNumerics *conv_numerics, CNumerics *visc_numerics, + CConfig *config, unsigned short val_marker) { unsigned short iVar, iDim; unsigned long iVertex, iPoint; su2double Pressure, P_Exit, Velocity[3], @@ -10155,15 +10174,16 @@ void CEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, conv_numerics->SetGridVel(geometry->node[iPoint]->GetGridVel(), geometry->node[iPoint]->GetGridVel()); /*--- Compute the residual using an upwind scheme ---*/ - conv_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); + const su2double* flux; + const su2double* const* jacobian_i; + const su2double* const* jacobian_j; + conv_numerics->ComputeResidual(flux, jacobian_i, jacobian_j, config); - /*--- Update residual value ---*/ - LinSysRes.AddBlock(iPoint, Residual); + /*--- Add Residuals and Jacobians ---*/ - /*--- Jacobian contribution for implicit integration ---*/ - if (implicit) { - Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); - } + LinSysRes.AddBlock(iPoint, flux); + if (implicit) + Jacobian.AddBlock(iPoint, iPoint, jacobian_i); // /*--- Viscous contribution, commented out because serious convergence problems ---*/ // @@ -10213,7 +10233,8 @@ void CEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, } void CEulerSolver::BC_Supersonic_Inlet(CGeometry *geometry, CSolver **solver_container, - CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { + CNumerics *conv_numerics, CNumerics *visc_numerics, + CConfig *config, unsigned short val_marker) { unsigned short iDim; unsigned long iVertex, iPoint; su2double *V_inlet, *V_domain; @@ -10297,13 +10318,16 @@ void CEulerSolver::BC_Supersonic_Inlet(CGeometry *geometry, CSolver **solver_con /*--- Compute the residual using an upwind scheme ---*/ - conv_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); - LinSysRes.AddBlock(iPoint, Residual); + const su2double* flux; + const su2double* const* jacobian_i; + const su2double* const* jacobian_j; + conv_numerics->ComputeResidual(flux, jacobian_i, jacobian_j, config); + LinSysRes.AddBlock(iPoint, flux); /*--- Jacobian contribution for implicit integration ---*/ if (implicit) - Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + Jacobian.AddBlock(iPoint, iPoint, jacobian_i); // /*--- Viscous contribution, commented out because serious convergence problems ---*/ // @@ -10355,7 +10379,8 @@ void CEulerSolver::BC_Supersonic_Inlet(CGeometry *geometry, CSolver **solver_con } void CEulerSolver::BC_Supersonic_Outlet(CGeometry *geometry, CSolver **solver_container, - CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { + CNumerics *conv_numerics, CNumerics *visc_numerics, + CConfig *config, unsigned short val_marker) { unsigned short iDim; unsigned long iVertex, iPoint; su2double *V_outlet, *V_domain; @@ -10415,13 +10440,16 @@ void CEulerSolver::BC_Supersonic_Outlet(CGeometry *geometry, CSolver **solver_co /*--- Compute the residual using an upwind scheme ---*/ - conv_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); - LinSysRes.AddBlock(iPoint, Residual); + const su2double* flux; + const su2double* const* jacobian_i; + const su2double* const* jacobian_j; + conv_numerics->ComputeResidual(flux, jacobian_i, jacobian_j, config); + LinSysRes.AddBlock(iPoint, flux); /*--- Jacobian contribution for implicit integration ---*/ if (implicit) - Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + Jacobian.AddBlock(iPoint, iPoint, jacobian_i); // /*--- Viscous contribution, commented out because serious convergence problems ---*/ // @@ -10636,13 +10664,16 @@ void CEulerSolver::BC_Engine_Inflow(CGeometry *geometry, CSolver **solver_contai /*--- Compute the residual using an upwind scheme ---*/ - conv_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); - LinSysRes.AddBlock(iPoint, Residual); + const su2double* flux; + const su2double* const* jacobian_i; + const su2double* const* jacobian_j; + conv_numerics->ComputeResidual(flux, jacobian_i, jacobian_j, config); + LinSysRes.AddBlock(iPoint, flux); /*--- Jacobian contribution for implicit integration ---*/ if (implicit) - Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + Jacobian.AddBlock(iPoint, iPoint, jacobian_i); // /*--- Viscous contribution, commented out because serious convergence problems ---*/ // @@ -10889,13 +10920,16 @@ void CEulerSolver::BC_Engine_Exhaust(CGeometry *geometry, CSolver **solver_conta /*--- Compute the residual using an upwind scheme ---*/ - conv_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); - LinSysRes.AddBlock(iPoint, Residual); + const su2double* flux; + const su2double* const* jacobian_i; + const su2double* const* jacobian_j; + conv_numerics->ComputeResidual(flux, jacobian_i, jacobian_j, config); + LinSysRes.AddBlock(iPoint, flux); /*--- Jacobian contribution for implicit integration ---*/ if (implicit) - Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + Jacobian.AddBlock(iPoint, iPoint, jacobian_i); // /*--- Viscous contribution, commented out because serious convergence problems ---*/ // @@ -10944,11 +10978,11 @@ 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) { +void CEulerSolver::BC_Fluid_Interface(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, + CNumerics *visc_numerics, CConfig *config) { unsigned long iVertex, jVertex, iPoint, Point_Normal = 0; - unsigned short iDim, iVar, iMarker, nDonorVertex; + unsigned short iDim, iVar, jVar, iMarker, nDonorVertex; bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); bool viscous = config->GetViscous(); @@ -10975,12 +11009,15 @@ void CEulerSolver::BC_Fluid_Interface(CGeometry *geometry, CSolver **solver_cont /*--- Initialize Residual, this will serve to accumulate the average ---*/ - for (iVar = 0; iVar < nVar; iVar++) + for (iVar = 0; iVar < nVar; iVar++) { Residual[iVar] = 0.0; + for (jVar = 0; jVar < nVar; jVar++) + Jacobian_i[iVar][jVar] = 0.0; + } /*--- Loop over the nDonorVertexes and compute the averaged flux ---*/ - for (jVertex = 0; jVertex < nDonorVertex; jVertex++){ + for (jVertex = 0; jVertex < nDonorVertex; jVertex++) { Point_Normal = geometry->vertex[iMarker][iVertex]->GetNormal_Neighbor(); @@ -11023,18 +11060,24 @@ void CEulerSolver::BC_Fluid_Interface(CGeometry *geometry, CSolver **solver_cont /*--- Compute the convective residual using an upwind scheme ---*/ - conv_numerics->ComputeResidual(tmp_residual, Jacobian_i, Jacobian_j, config); + const su2double* flux; + const su2double* const* jacobian_i; + const su2double* const* jacobian_j; + conv_numerics->ComputeResidual(flux, jacobian_i, jacobian_j, config); /*--- Accumulate the residuals to compute the average ---*/ - for (iVar = 0; iVar < nVar; iVar++) - Residual[iVar] += weight*tmp_residual[iVar]; - + for (iVar = 0; iVar < nVar; iVar++) { + Residual[iVar] += weight*flux[iVar]; + for (jVar = 0; jVar < nVar; jVar++) + Jacobian_i[iVar][jVar] += weight*jacobian_i[iVar][jVar]; + } } /*--- Add Residuals and Jacobians ---*/ LinSysRes.AddBlock(iPoint, Residual); + if (implicit) Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); @@ -11141,12 +11184,15 @@ void CEulerSolver::BC_Interface_Boundary(CGeometry *geometry, CSolver **solver_c /*--- Compute the convective residual using an upwind scheme ---*/ - numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); + const su2double* flux; + const su2double* const* jacobian_i; + const su2double* const* jacobian_j; + numerics->ComputeResidual(flux, jacobian_i, jacobian_j, config); /*--- Add Residuals and Jacobians ---*/ - LinSysRes.AddBlock(iPoint, Residual); - if (implicit) Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + LinSysRes.AddBlock(iPoint, flux); + if (implicit) Jacobian.AddBlock(iPoint, iPoint, jacobian_i); } @@ -11202,12 +11248,15 @@ void CEulerSolver::BC_NearField_Boundary(CGeometry *geometry, CSolver **solver_c /*--- Compute the convective residual using an upwind scheme ---*/ - numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); + const su2double* flux; + const su2double* const* jacobian_i; + const su2double* const* jacobian_j; + numerics->ComputeResidual(flux, jacobian_i, jacobian_j, config); /*--- Add Residuals and Jacobians ---*/ - LinSysRes.AddBlock(iPoint, Residual); - if (implicit) Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + LinSysRes.AddBlock(iPoint, flux); + if (implicit) Jacobian.AddBlock(iPoint, iPoint, jacobian_i); } @@ -11330,7 +11379,7 @@ void CEulerSolver::BC_ActDisk(CGeometry *geometry, CSolver **solver_container, C P_static = V_outlet[nDim+1] / (Target_Press_Jump/PressureAdj); T_static = V_outlet[0] / (Target_Temp_Jump/TemperatureAdj); } - else { P_static = V_outlet[nDim+1] - Target_Press_Jump; T_static = V_outlet[0] - Target_Temp_Jump; } + else { P_static = V_outlet[nDim+1] - Target_Press_Jump; T_static = V_outlet[0] - Target_Temp_Jump; } } else { V_outlet = nodes->GetPrimitive(iPoint); @@ -11579,15 +11628,18 @@ void CEulerSolver::BC_ActDisk(CGeometry *geometry, CSolver **solver_container, C /*--- Compute the residual using an upwind scheme ---*/ - conv_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); + const su2double* flux; + const su2double* const* jacobian_i; + const su2double* const* jacobian_j; + conv_numerics->ComputeResidual(flux, jacobian_i, jacobian_j, config); /*--- Update residual value ---*/ - LinSysRes.AddBlock(iPoint, Residual); + LinSysRes.AddBlock(iPoint, flux); /*--- Jacobian contribution for implicit integration ---*/ - if (implicit) Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + if (implicit) Jacobian.AddBlock(iPoint, iPoint, jacobian_i); // /*--- Viscous contribution, commented out because serious convergence problems ---*/ // From d3d338c8e43a618da5209cffb8a6aa5a1e1636b9 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Tue, 28 Jan 2020 23:39:19 +0000 Subject: [PATCH 033/118] make the improved compilation mechanism more readable --- Common/include/option_structure.hpp | 4121 ++++------------- Common/include/option_structure.inl | 2148 +++++++++ Common/include/toolboxes/printing_toolbox.hpp | 98 +- Common/src/config_structure.cpp | 1309 +++--- 4 files changed, 3795 insertions(+), 3881 deletions(-) create mode 100644 Common/include/option_structure.inl diff --git a/Common/include/option_structure.hpp b/Common/include/option_structure.hpp index 30c217f8e41a..4929aa648bad 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -40,55 +40,26 @@ using namespace std; /*! - * \class CCreateMap - * \brief creates a map from a list by overloading operator() - * \tparam T - the key type in the map - * \tparam U - the mapped value type in the map - * \author Boost.Assign and anonymous person on stackoverflow - * - * We need this to create static const maps that map strings to enum - * types. The implementation is based on the Boost.Assign library. This - * particular version is taken from - * http://stackoverflow.com/questions/138600/initializing-a-static-stdmapint-int-in-c + * \class CEmptyMap + * \brief */ template -class CCreateMap { -private: - std::map m_map; -public: - CCreateMap(const T& key, const U& val) { - m_map[key] = val; - } - CCreateMap& operator()(const T& key, const U& val) { - m_map[key] = val; - return *this; - } - operator std::map() { - return m_map; - } +struct CEmptyMap { + CEmptyMap(initializer_list >) {} }; -/*! - * \brief utility function for converting strings to uppercase - * \param[in, out] str - string we want to convert - */ -inline void StringToUpperCase(string & str) { - std::transform(str.begin(), str.end(), str.begin(), ::toupper); -} - -/*! - * \brief utility function for converting strings to uppercase - * \param[in] str - string we want a copy of converted to uppercase - * \returns a copy of str in uppercase - */ -inline string StringToUpperCase(const string & str) { - string upp_str(str); - std::transform(upp_str.begin(), upp_str.end(), upp_str.begin(), ::toupper); - return upp_str; -} +#ifdef ENABLE_MAPS +template +using MapType = map; +#define MakePair(a,b) {a,b}, +#else +template +using MapType = CEmptyMap; +#define MakePair(a,b) +#endif /*! - * \brief different software components of SU2 + * \brief Different software components of SU2 */ enum SU2_COMPONENT { SU2_CFD = 1, /*!< \brief Running the SU2_CFD software. */ @@ -174,11 +145,10 @@ enum AVERAGE_TYPE { AVERAGE_AREA = 1, /*!< \brief Area-weighted average. */ AVERAGE_MASSFLUX = 2 /*!< \brief Mass-flux weighted average. */ }; -#ifdef ENABLE_MAPS -static const map Average_Map = CCreateMap -("AREA", AVERAGE_AREA) -("MASSFLUX", AVERAGE_MASSFLUX); -#endif +static const MapType Average_Map = { + MakePair("AREA", AVERAGE_AREA) + MakePair("MASSFLUX", AVERAGE_MASSFLUX) +}; /*! * \brief different solver types for the CFD component @@ -203,7 +173,7 @@ enum ENUM_SOLVER { DISC_ADJ_NAVIER_STOKES = 17, /*!< \brief Definition of the discrete adjoint Navier-Stokes' solver. */ DISC_ADJ_INC_EULER = 18, /*!< \brief Definition of the discrete adjoint incompressible Euler solver. */ DISC_ADJ_INC_RANS = 19, /*!< \brief Definition of the discrete adjoint imcompressible Reynolds-averaged Navier-Stokes' (RANS) solver. */ - DISC_ADJ_INC_NAVIER_STOKES = 20, /*!< \brief Definition of the doscrete adjoint imcompressible Navier-Stokes'. */ + DISC_ADJ_INC_NAVIER_STOKES = 20, /*!< \brief Definition of the discrete adjoint imcompressible Navier-Stokes'. */ DISC_ADJ_HEAT = 21, /*!< \brief Definition of the discrete adjoint heat solver. */ DISC_ADJ_FEM_EULER = 22, /*!< \brief Definition of the discrete adjoint FEM Euler solver. */ DISC_ADJ_FEM_RANS = 23, /*!< \brief Definition of the discrete adjoint FEM Reynolds-averaged Navier-Stokes' (RANS) solver. */ @@ -215,40 +185,38 @@ enum ENUM_SOLVER { FEM_LES = 29, /*!< \brief Definition of the finite element Large Eddy Simulation Navier-Stokes' (LES) solver. */ MULTIPHYSICS = 30 }; -/* BEGIN_CONFIG_ENUMS */ -#ifdef ENABLE_MAPS -static const map Solver_Map = CCreateMap -("NONE", NO_SOLVER) -("EULER", EULER) -("NAVIER_STOKES", NAVIER_STOKES) -("RANS", RANS) -("INC_EULER", INC_EULER) -("INC_NAVIER_STOKES", INC_NAVIER_STOKES) -("INC_RANS", INC_RANS) -("FEM_EULER", FEM_EULER) -("FEM_NAVIER_STOKES", FEM_NAVIER_STOKES) -("FEM_RANS", FEM_RANS) -("FEM_LES", FEM_LES) -("ADJ_EULER", ADJ_EULER) -("ADJ_NAVIER_STOKES", ADJ_NAVIER_STOKES) -("ADJ_RANS", ADJ_RANS ) -("HEAT_EQUATION_FVM", HEAT_EQUATION_FVM) -("ELASTICITY", FEM_ELASTICITY) -("DISC_ADJ_EULER", DISC_ADJ_EULER) -("DISC_ADJ_RANS", DISC_ADJ_RANS) -("DISC_ADJ_NAVIERSTOKES", DISC_ADJ_NAVIER_STOKES) -("DISC_ADJ_INC_EULER", DISC_ADJ_INC_EULER) -("DISC_ADJ_INC_RANS", DISC_ADJ_INC_RANS) -("DISC_ADJ_INC_NAVIERSTOKES", DISC_ADJ_INC_NAVIER_STOKES) -("DISC_ADJ_HEAT_EQUATION_FVM", DISC_ADJ_HEAT) -("DISC_ADJ_FEM_EULER", DISC_ADJ_FEM_EULER) -("DISC_ADJ_FEM_RANS", DISC_ADJ_FEM_RANS) -("DISC_ADJ_FEM_NS", DISC_ADJ_FEM_NS) -("DISC_ADJ_FEM", DISC_ADJ_FEM) -("FLUID_STRUCTURE_INTERACTION", FLUID_STRUCTURE_INTERACTION) -("TEMPLATE_SOLVER", TEMPLATE_SOLVER) -("MULTIPHYSICS", MULTIPHYSICS); -#endif +static const MapType Solver_Map = { + MakePair("NONE", NO_SOLVER) + MakePair("EULER", EULER) + MakePair("NAVIER_STOKES", NAVIER_STOKES) + MakePair("RANS", RANS) + MakePair("INC_EULER", INC_EULER) + MakePair("INC_NAVIER_STOKES", INC_NAVIER_STOKES) + MakePair("INC_RANS", INC_RANS) + MakePair("FEM_EULER", FEM_EULER) + MakePair("FEM_NAVIER_STOKES", FEM_NAVIER_STOKES) + MakePair("FEM_RANS", FEM_RANS) + MakePair("FEM_LES", FEM_LES) + MakePair("ADJ_EULER", ADJ_EULER) + MakePair("ADJ_NAVIER_STOKES", ADJ_NAVIER_STOKES) + MakePair("ADJ_RANS", ADJ_RANS ) + MakePair("HEAT_EQUATION_FVM", HEAT_EQUATION_FVM) + MakePair("ELASTICITY", FEM_ELASTICITY) + MakePair("DISC_ADJ_EULER", DISC_ADJ_EULER) + MakePair("DISC_ADJ_RANS", DISC_ADJ_RANS) + MakePair("DISC_ADJ_NAVIERSTOKES", DISC_ADJ_NAVIER_STOKES) + MakePair("DISC_ADJ_INC_EULER", DISC_ADJ_INC_EULER) + MakePair("DISC_ADJ_INC_RANS", DISC_ADJ_INC_RANS) + MakePair("DISC_ADJ_INC_NAVIERSTOKES", DISC_ADJ_INC_NAVIER_STOKES) + MakePair("DISC_ADJ_HEAT_EQUATION_FVM", DISC_ADJ_HEAT) + MakePair("DISC_ADJ_FEM_EULER", DISC_ADJ_FEM_EULER) + MakePair("DISC_ADJ_FEM_RANS", DISC_ADJ_FEM_RANS) + MakePair("DISC_ADJ_FEM_NS", DISC_ADJ_FEM_NS) + MakePair("DISC_ADJ_FEM", DISC_ADJ_FEM) + MakePair("FLUID_STRUCTURE_INTERACTION", FLUID_STRUCTURE_INTERACTION) + MakePair("TEMPLATE_SOLVER", TEMPLATE_SOLVER) + MakePair("MULTIPHYSICS", MULTIPHYSICS) +}; /*! * \brief different solver types for the multizone environment component @@ -257,12 +225,10 @@ enum ENUM_MULTIZONE { MZ_BLOCK_GAUSS_SEIDEL = 0, /*!< \brief Definition of a Block-Gauss-Seidel multizone solver. */ MZ_BLOCK_JACOBI = 1 /*!< \brief Definition of a Block-Jacobi solver. */ }; -/* BEGIN_CONFIG_ENUMS */ -#ifdef ENABLE_MAPS -static const map Multizone_Map = CCreateMap -("BLOCK_GAUSS_SEIDEL", MZ_BLOCK_GAUSS_SEIDEL) -("BLOCK_JACOBI", MZ_BLOCK_JACOBI); -#endif +static const MapType Multizone_Map = { + MakePair("BLOCK_GAUSS_SEIDEL", MZ_BLOCK_GAUSS_SEIDEL) + MakePair("BLOCK_JACOBI", MZ_BLOCK_JACOBI) +}; /*! * \brief types of fluid solvers @@ -273,86 +239,80 @@ enum ENUM_FSI_FLUID_PROBLEM { NAVIER_STOKES_FFSI = 2, /*!< \brief NS equations for the FSI problem */ RANS_FFSI = 3 /*!< \brief RANS equations for the FSI problem */ }; -#ifdef ENABLE_MAPS -static const map FSI_Fluid_Solver_Map = CCreateMap -("NONE", NO_SOLVER_FFSI) -("EULER", EULER_FFSI) -("NAVIER_STOKES", NAVIER_STOKES_FFSI) -("RANS", RANS_FFSI); -#endif +static const MapType FSI_Fluid_Solver_Map = { + MakePair("NONE", NO_SOLVER_FFSI) + MakePair("EULER", EULER_FFSI) + MakePair("NAVIER_STOKES", NAVIER_STOKES_FFSI) + MakePair("RANS", RANS_FFSI) +}; /*! * \brief types of structural solvers */ enum ENUM_FSI_STRUC_PROBLEM { - NO_SOLVER_SFSI = 0, /*!< \brief Definition of no solver. */ - FEM_ELASTICITY_SFSI = 9, /*!< \brief Nonlinear elasticity equations for the FSI problem */ + NO_SOLVER_SFSI = 0, /*!< \brief Definition of no solver. */ + FEM_ELASTICITY_SFSI = 9, /*!< \brief Nonlinear elasticity equations for the FSI problem */ +}; +static const MapType FSI_Struc_Solver_Map = { + MakePair("NONE", NO_SOLVER_SFSI) + MakePair("ELASTICITY", FEM_ELASTICITY_SFSI) }; -#ifdef ENABLE_MAPS -static const map FSI_Struc_Solver_Map = CCreateMap -("NONE", NO_SOLVER_SFSI) -("ELASTICITY", FEM_ELASTICITY_SFSI); -#endif /*! * \brief Material geometric conditions */ enum ENUM_STRUCT_SOLVER { - SMALL_DEFORMATIONS = 0, /*!< \brief Definition of linear elastic material. */ - LARGE_DEFORMATIONS = 1, /*!< \brief Definition of Neo-Hookean material. */ + SMALL_DEFORMATIONS = 0, /*!< \brief Definition of linear elastic material. */ + LARGE_DEFORMATIONS = 1, /*!< \brief Definition of Neo-Hookean material. */ +}; +static const MapType Struct_Map = { + MakePair("SMALL_DEFORMATIONS", SMALL_DEFORMATIONS) + MakePair("LARGE_DEFORMATIONS", LARGE_DEFORMATIONS) }; -#ifdef ENABLE_MAPS -static const map Struct_Map = CCreateMap -("SMALL_DEFORMATIONS", SMALL_DEFORMATIONS) -("LARGE_DEFORMATIONS", LARGE_DEFORMATIONS); -#endif /*! * \brief Material model */ enum ENUM_MATERIAL_MODEL { - LINEAR_ELASTIC = 0, /*!< \brief Definition of linear elastic material. */ - NEO_HOOKEAN = 1, /*!< \brief Definition of Neo-Hookean material. */ - KNOWLES = 2, /*!< \brief Definition of Knowles stored-energy potential */ - IDEAL_DE = 3 /*!< \brief Definition of ideal Dielectric Elastomer */ + LINEAR_ELASTIC = 0, /*!< \brief Definition of linear elastic material. */ + NEO_HOOKEAN = 1, /*!< \brief Definition of Neo-Hookean material. */ + KNOWLES = 2, /*!< \brief Definition of Knowles stored-energy potential */ + IDEAL_DE = 3 /*!< \brief Definition of ideal Dielectric Elastomer */ +}; +static const MapType Material_Map = { + MakePair("LINEAR_ELASTIC", LINEAR_ELASTIC) + MakePair("NEO_HOOKEAN", NEO_HOOKEAN) + MakePair("KNOWLES", KNOWLES) + MakePair("IDEAL_DE", IDEAL_DE) }; -#ifdef ENABLE_MAPS -static const map Material_Map = CCreateMap -("LINEAR_ELASTIC", LINEAR_ELASTIC) -("NEO_HOOKEAN", NEO_HOOKEAN) -("KNOWLES", KNOWLES) -("IDEAL_DE", IDEAL_DE); -#endif /*! * \brief Material compressibility */ enum ENUM_MAT_COMPRESS { - COMPRESSIBLE_MAT = 0, /*!< \brief Definition of compressible material. */ + COMPRESSIBLE_MAT = 0, /*!< \brief Definition of compressible material. */ NEARLY_INCOMPRESSIBLE_MAT = 1, /*!< \brief Definition of nearly incompressible material. */ }; -#ifdef ENABLE_MAPS -static const map MatComp_Map = CCreateMap -("COMPRESSIBLE", COMPRESSIBLE_MAT) -("NEARLY_INCOMPRESSIBLE", NEARLY_INCOMPRESSIBLE_MAT); -#endif +static const MapType MatComp_Map = { + MakePair("COMPRESSIBLE", COMPRESSIBLE_MAT) + MakePair("NEARLY_INCOMPRESSIBLE", NEARLY_INCOMPRESSIBLE_MAT) +}; /*! * \brief types of interpolators */ enum ENUM_INTERPOLATOR { - NEAREST_NEIGHBOR = 0, /*!< \brief Nearest Neigbhor interpolation */ - ISOPARAMETRIC = 1, /*!< \brief Isoparametric interpolation, use CONSERVATIVE_INTERPOLATION=YES for conservative interpolation (S.A. Brown 1997).*/ - WEIGHTED_AVERAGE = 3, /*!< \brief Sliding Mesh Approach E. Rinaldi 2015 */ - RADIAL_BASIS_FUNCTION= 4, /*!< \brief Radial basis function interpolation. */ + NEAREST_NEIGHBOR = 0, /*!< \brief Nearest Neigbhor interpolation */ + ISOPARAMETRIC = 1, /*!< \brief Isoparametric interpolation, use CONSERVATIVE_INTERPOLATION=YES for conservative interpolation (S.A. Brown 1997).*/ + WEIGHTED_AVERAGE = 3, /*!< \brief Sliding Mesh Approach E. Rinaldi 2015 */ + RADIAL_BASIS_FUNCTION = 4, /*!< \brief Radial basis function interpolation. */ +}; +static const MapType Interpolator_Map = { + MakePair("NEAREST_NEIGHBOR", NEAREST_NEIGHBOR) + MakePair("ISOPARAMETRIC", ISOPARAMETRIC) + MakePair("WEIGHTED_AVERAGE", WEIGHTED_AVERAGE) + MakePair("RADIAL_BASIS_FUNCTION", RADIAL_BASIS_FUNCTION) }; -#ifdef ENABLE_MAPS -static const map Interpolator_Map = CCreateMap -("NEAREST_NEIGHBOR", NEAREST_NEIGHBOR) -("ISOPARAMETRIC", ISOPARAMETRIC) -("WEIGHTED_AVERAGE", WEIGHTED_AVERAGE) -("RADIAL_BASIS_FUNCTION", RADIAL_BASIS_FUNCTION); -#endif /*! * \brief types of radial basis functions @@ -364,14 +324,13 @@ enum ENUM_RADIALBASIS { THIN_PLATE_SPLINE = 3, /*!< \brief Thin plate spline. */ MULTI_QUADRIC = 4, /*!< \brief Multi quartic biharmonic spline. */ }; -#ifdef ENABLE_MAPS -static const map RadialBasisFunction_Map = CCreateMap -("WENDLAND_C2", WENDLAND_C2) -("INV_MULTI_QUADRIC", INV_MULTI_QUADRIC) -("GAUSSIAN", GAUSSIAN) -("THIN_PLATE_SPLINE", THIN_PLATE_SPLINE) -("MULTI_QUADRIC", MULTI_QUADRIC); -#endif +static const MapType RadialBasisFunction_Map = { + MakePair("WENDLAND_C2", WENDLAND_C2) + MakePair("INV_MULTI_QUADRIC", INV_MULTI_QUADRIC) + MakePair("GAUSSIAN", GAUSSIAN) + MakePair("THIN_PLATE_SPLINE", THIN_PLATE_SPLINE) + MakePair("MULTI_QUADRIC", MULTI_QUADRIC) +}; /*! * \brief types of (coupling) transfers between distinct physical zones @@ -413,15 +372,14 @@ enum ENUM_KIND_NONDIM { INITIAL_VALUES = 4, /*!< \brief Non-dimensional incompressible simulation based on intial values for external flow. */ REFERENCE_VALUES = 5 /*!< \brief Non-dimensional incompressible simulation based on custom reference values. */ }; -#ifdef ENABLE_MAPS -static const map NonDim_Map = CCreateMap -("DIMENSIONAL", DIMENSIONAL) -("FREESTREAM_PRESS_EQ_ONE", FREESTREAM_PRESS_EQ_ONE) -("FREESTREAM_VEL_EQ_MACH", FREESTREAM_VEL_EQ_MACH) -("FREESTREAM_VEL_EQ_ONE", FREESTREAM_VEL_EQ_ONE) -("INITIAL_VALUES", INITIAL_VALUES) -("REFERENCE_VALUES", REFERENCE_VALUES); -#endif +static const MapType NonDim_Map = { + MakePair("DIMENSIONAL", DIMENSIONAL) + MakePair("FREESTREAM_PRESS_EQ_ONE", FREESTREAM_PRESS_EQ_ONE) + MakePair("FREESTREAM_VEL_EQ_MACH", FREESTREAM_VEL_EQ_MACH) + MakePair("FREESTREAM_VEL_EQ_ONE", FREESTREAM_VEL_EQ_ONE) + MakePair("INITIAL_VALUES", INITIAL_VALUES) + MakePair("REFERENCE_VALUES", REFERENCE_VALUES) +}; /*! * \brief different system of measurements @@ -430,11 +388,10 @@ enum ENUM_MEASUREMENTS { SI = 0, /*!< \brief Definition of compressible solver. */ US = 1 /*!< \brief Definition of incompressible solver. */ }; -#ifdef ENABLE_MAPS -static const map Measurements_Map = CCreateMap -("SI", SI) -("US", US); -#endif +static const MapType Measurements_Map = { + MakePair("SI", SI) + MakePair("US", US) +}; /*! * \brief different types of systems @@ -485,7 +442,6 @@ const int MAT_KNOWLES = 4; /*!< \brief Position of the Knowles material model. const int MESH_SOL = 8; /*!< \brief Position of the mesh solver. */ const int ADJMESH_SOL = 9; /*!< \brief Position of the adjoint of the mesh solver. */ - /*! * \brief types of finite elements (in 2D or 3D) */ @@ -506,12 +462,11 @@ enum ENUM_MATH_PROBLEM { CONTINUOUS_ADJOINT = 1, /*!< \brief Continuous adjoint problem */ DISCRETE_ADJOINT = 2 /*!< \brief AD-based discrete adjoint problem. */ }; -#ifdef ENABLE_MAPS -static const map Math_Problem_Map = CCreateMap -("DIRECT", DIRECT) -("CONTINUOUS_ADJOINT", CONTINUOUS_ADJOINT) -("DISCRETE_ADJOINT", DISCRETE_ADJOINT); -#endif +static const MapType Math_Problem_Map = { + MakePair("DIRECT", DIRECT) + MakePair("CONTINUOUS_ADJOINT", CONTINUOUS_ADJOINT) + MakePair("DISCRETE_ADJOINT", DISCRETE_ADJOINT) +}; /*! * \brief types of spatial discretizations @@ -519,16 +474,15 @@ static const map Math_Problem_Map = CCreateMap Space_Map = CCreateMap -("NONE", NO_CONVECTIVE) -("SPACE_CENTERED", SPACE_CENTERED) -("SPACE_UPWIND", SPACE_UPWIND) -("FINITE_ELEMENT", FINITE_ELEMENT); -#endif +static const MapType Space_Map = { + MakePair("NONE", NO_CONVECTIVE) + MakePair("SPACE_CENTERED", SPACE_CENTERED) + MakePair("SPACE_UPWIND", SPACE_UPWIND) + MakePair("FINITE_ELEMENT", FINITE_ELEMENT) +}; /*! * \brief types of fluid model @@ -542,16 +496,15 @@ enum ENUM_FLUIDMODEL { INC_IDEAL_GAS = 5, /*!< \brief Incompressible ideal gas model. */ INC_IDEAL_GAS_POLY = 6 /*!< \brief Inc. ideal gas, polynomial gas model. */ }; -#ifdef ENABLE_MAPS -static const map FluidModel_Map = CCreateMap -("STANDARD_AIR", STANDARD_AIR) -("IDEAL_GAS", IDEAL_GAS) -("VW_GAS", VW_GAS) -("PR_GAS", PR_GAS) -("CONSTANT_DENSITY", CONSTANT_DENSITY) -("INC_IDEAL_GAS", INC_IDEAL_GAS) -("INC_IDEAL_GAS_POLY", INC_IDEAL_GAS_POLY); -#endif +static const MapType FluidModel_Map = { + MakePair("STANDARD_AIR", STANDARD_AIR) + MakePair("IDEAL_GAS", IDEAL_GAS) + MakePair("VW_GAS", VW_GAS) + MakePair("PR_GAS", PR_GAS) + MakePair("CONSTANT_DENSITY", CONSTANT_DENSITY) + MakePair("INC_IDEAL_GAS", INC_IDEAL_GAS) + MakePair("INC_IDEAL_GAS_POLY", INC_IDEAL_GAS_POLY) +}; /*! * \brief types of density models @@ -561,12 +514,11 @@ enum ENUM_DENSITYMODEL { BOUSSINESQ = 1, /*!< \brief BoussinesQ density model. */ VARIABLE = 2 /*!< \brief Variable density model. */ }; -#ifdef ENABLE_MAPS -static const map DensityModel_Map = CCreateMap -("CONSTANT", CONSTANT) -("BOUSSINESQ", BOUSSINESQ) -("VARIABLE", VARIABLE); -#endif +static const MapType DensityModel_Map = { + MakePair("CONSTANT", CONSTANT) + MakePair("BOUSSINESQ", BOUSSINESQ) + MakePair("VARIABLE", VARIABLE) +}; /*! * \brief types of initialization option @@ -575,11 +527,10 @@ enum ENUM_INIT_OPTION { REYNOLDS = 0, /*!< \brief Reynold's number initalization. */ TD_CONDITIONS = 1 /*!< \brief Total conditions initalization. */ }; -#ifdef ENABLE_MAPS -static const map InitOption_Map = CCreateMap -("REYNOLDS", REYNOLDS) -("TD_CONDITIONS", TD_CONDITIONS); -#endif +static const MapType InitOption_Map = { + MakePair("REYNOLDS", REYNOLDS) + MakePair("TD_CONDITIONS", TD_CONDITIONS) +}; /*! * \brief types of initialization option @@ -588,11 +539,10 @@ enum ENUM_FREESTREAM_OPTION { TEMPERATURE_FS = 0, /*!< \brief Temperature initialization. */ DENSITY_FS = 1 /*!< \brief Density initalization. */ }; -#ifdef ENABLE_MAPS -static const map FreeStreamOption_Map = CCreateMap -("TEMPERATURE_FS", TEMPERATURE_FS) -("DENSITY_FS", DENSITY_FS); -#endif +static const MapType FreeStreamOption_Map = { + MakePair("TEMPERATURE_FS", TEMPERATURE_FS) + MakePair("DENSITY_FS", DENSITY_FS) +}; /*! * \brief types of viscosity model @@ -602,12 +552,11 @@ enum ENUM_VISCOSITYMODEL { SUTHERLAND = 1, /*!< \brief Sutherlands Law viscosity. */ POLYNOMIAL_VISCOSITY = 2 /*!< \brief Polynomial viscosity. */ }; -#ifdef ENABLE_MAPS -static const map ViscosityModel_Map = CCreateMap -("CONSTANT_VISCOSITY", CONSTANT_VISCOSITY) -("SUTHERLAND", SUTHERLAND) -("POLYNOMIAL_VISCOSITY", POLYNOMIAL_VISCOSITY); -#endif +static const MapType ViscosityModel_Map = { + MakePair("CONSTANT_VISCOSITY", CONSTANT_VISCOSITY) + MakePair("SUTHERLAND", SUTHERLAND) + MakePair("POLYNOMIAL_VISCOSITY", POLYNOMIAL_VISCOSITY) +}; /*! * \brief types of thermal conductivity model @@ -617,12 +566,11 @@ enum ENUM_CONDUCTIVITYMODEL { CONSTANT_PRANDTL = 1, /*!< \brief Constant Prandtl number. */ POLYNOMIAL_CONDUCTIVITY = 2 /*!< \brief Polynomial thermal conductivity. */ }; -#ifdef ENABLE_MAPS -static const map ConductivityModel_Map = CCreateMap -("CONSTANT_CONDUCTIVITY", CONSTANT_CONDUCTIVITY) -("CONSTANT_PRANDTL", CONSTANT_PRANDTL) -("POLYNOMIAL_CONDUCTIVITY", POLYNOMIAL_CONDUCTIVITY); -#endif +static const MapType ConductivityModel_Map = { + MakePair("CONSTANT_CONDUCTIVITY", CONSTANT_CONDUCTIVITY) + MakePair("CONSTANT_PRANDTL", CONSTANT_PRANDTL) + MakePair("POLYNOMIAL_CONDUCTIVITY", POLYNOMIAL_CONDUCTIVITY) +}; /*! * \brief types of turbulent thermal conductivity model @@ -631,11 +579,10 @@ enum ENUM_CONDUCTIVITYMODEL_TURB { NO_CONDUCTIVITY_TURB = 0, /*!< \brief No turbulent contribution to the effective thermal conductivity for RANS. */ CONSTANT_PRANDTL_TURB = 1 /*!< \brief Include contribution to effective conductivity using constant turbulent Prandtl number for RANS. */ }; -#ifdef ENABLE_MAPS -static const map TurbConductivityModel_Map = CCreateMap -("NONE", NO_CONDUCTIVITY_TURB) -("CONSTANT_PRANDTL_TURB", CONSTANT_PRANDTL_TURB); -#endif +static const MapType TurbConductivityModel_Map = { + MakePair("NONE", NO_CONDUCTIVITY_TURB) + MakePair("CONSTANT_PRANDTL_TURB", CONSTANT_PRANDTL_TURB) +}; /*! * \brief types of unsteady mesh motion @@ -649,38 +596,36 @@ enum ENUM_GRIDMOVEMENT { GUST = 12, /*!< \brief Simulation on a static mesh with a gust. */ MOVING_HTP = 13, /*!< \brief Simulation with moving HTP (rotation). */ }; -#ifdef ENABLE_MAPS -static const map GridMovement_Map = CCreateMap -("NONE", NO_MOVEMENT) -("RIGID_MOTION", RIGID_MOTION) -("ROTATING_FRAME", ROTATING_FRAME) -("ELASTICITY", ELASTICITY) -("MOVING_HTP", MOVING_HTP) -("STEADY_TRANSLATION", STEADY_TRANSLATION) -("GUST", GUST); -#endif +static const MapType GridMovement_Map = { + MakePair("NONE", NO_MOVEMENT) + MakePair("RIGID_MOTION", RIGID_MOTION) + MakePair("ROTATING_FRAME", ROTATING_FRAME) + MakePair("ELASTICITY", ELASTICITY) + MakePair("MOVING_HTP", MOVING_HTP) + MakePair("STEADY_TRANSLATION", STEADY_TRANSLATION) + MakePair("GUST", GUST) +}; enum ENUM_SURFACEMOVEMENT { DEFORMING = 1, /*!< \brief Simulation with deformation. */ MOVING_WALL = 2, /*!< \brief Simulation with moving wall. */ AEROELASTIC = 3, /*!< \brief Simulation with aeroelastic motion. */ AEROELASTIC_RIGID_MOTION = 4, /*!< \brief Simulation with rotation and aeroelastic motion. */ - FLUID_STRUCTURE = 5, /*!< \brief Fluid structure deformation. */ + FLUID_STRUCTURE = 5, /*!< \brief Fluid structure deformation. */ EXTERNAL = 6, /*!< \brief Simulation with external motion. */ EXTERNAL_ROTATION = 7, /*!< \brief Simulation with external rotation motion. */ FLUID_STRUCTURE_STATIC = 8 /*!< \brief Fluid structure deformation with no grid velocity. */ }; -#ifdef ENABLE_MAPS -static const map SurfaceMovement_Map = CCreateMap -("DEFORMING", DEFORMING) -("MOVING_WALL", MOVING_WALL) -("AEROELASTIC_RIGID_MOTION", AEROELASTIC_RIGID_MOTION) -("AEROELASTIC", AEROELASTIC) -("FLUID_STRUCTURE_STATIC", FLUID_STRUCTURE_STATIC) -("FLUID_STRUCTURE", FLUID_STRUCTURE) -("EXTERNAL", EXTERNAL) -("EXTERNAL_ROTATION", EXTERNAL_ROTATION); -#endif +static const MapType SurfaceMovement_Map = { + MakePair("DEFORMING", DEFORMING) + MakePair("MOVING_WALL", MOVING_WALL) + MakePair("AEROELASTIC_RIGID_MOTION", AEROELASTIC_RIGID_MOTION) + MakePair("AEROELASTIC", AEROELASTIC) + MakePair("FLUID_STRUCTURE_STATIC", FLUID_STRUCTURE_STATIC) + MakePair("FLUID_STRUCTURE", FLUID_STRUCTURE) + MakePair("EXTERNAL", EXTERNAL) + MakePair("EXTERNAL_ROTATION", EXTERNAL_ROTATION) +}; /*! * \brief type of wind gusts @@ -693,15 +638,14 @@ enum ENUM_GUST_TYPE { VORTEX = 4, /*!< \brief A gust made from vortices */ EOG = 5 /*!< \brief An extreme operating gust */ }; -#ifdef ENABLE_MAPS -static const map Gust_Type_Map = CCreateMap -("NONE", NO_GUST) -("TOP_HAT", TOP_HAT) -("SINE", SINE) -("ONE_M_COSINE", ONE_M_COSINE) -("VORTEX", VORTEX) -("EOG", EOG); -#endif +static const MapType Gust_Type_Map = { + MakePair("NONE", NO_GUST) + MakePair("TOP_HAT", TOP_HAT) + MakePair("SINE", SINE) + MakePair("ONE_M_COSINE", ONE_M_COSINE) + MakePair("VORTEX", VORTEX) + MakePair("EOG", EOG) +}; /*! * \brief type of wind direction @@ -710,11 +654,10 @@ enum ENUM_GUST_DIR { X_DIR = 0, /*!< \brief Gust direction-X. */ Y_DIR = 1 /*!< \brief Gust direction-Y. */ }; -#ifdef ENABLE_MAPS -static const map Gust_Dir_Map = CCreateMap -("X_DIR", X_DIR) -("Y_DIR", Y_DIR); -#endif +static const MapType Gust_Dir_Map = { + MakePair("X_DIR", X_DIR) + MakePair("Y_DIR", Y_DIR) +}; // If you add to ENUM_CENTERED, you must also add the option to ENUM_CONVECTIVE /*! @@ -726,13 +669,12 @@ enum ENUM_CENTERED { LAX = 2, /*!< \brief Lax-Friedrich centered numerical method. */ JST_KE = 4 /*!< \brief Kinetic Energy preserving Jameson-Smith-Turkel centered numerical method. */ }; -#ifdef ENABLE_MAPS -static const map Centered_Map = CCreateMap -("NONE", NO_CENTERED) -("JST", JST) -("JST_KE", JST_KE) -("LAX-FRIEDRICH", LAX); -#endif +static const MapType Centered_Map = { + MakePair("NONE", NO_CENTERED) + MakePair("JST", JST) + MakePair("JST_KE", JST_KE) + MakePair("LAX-FRIEDRICH", LAX) +}; // If you add to ENUM_UPWIND, you must also add the option to ENUM_CONVECTIVE @@ -759,27 +701,26 @@ enum ENUM_UPWIND { AUSMPLUSUP = 16, /*!< \brief AUSM+ -up numerical method (All Speed) */ AUSMPLUSUP2 = 17 /*!< \brief AUSM+ -up2 numerical method (All Speed) */ }; -#ifdef ENABLE_MAPS -static const map Upwind_Map = CCreateMap -("NONE", NO_UPWIND) -("ROE", ROE) -("TURKEL_PREC", TURKEL) -("AUSM", AUSM) -("AUSMPLUSUP", AUSMPLUSUP) -("AUSMPLUSUP2", AUSMPLUSUP2) -("SLAU", SLAU) -("HLLC", HLLC) -("SW", SW) -("MSW", MSW) -("CUSP", CUSP) -("SCALAR_UPWIND", SCALAR_UPWIND) -("CONVECTIVE_TEMPLATE", CONVECTIVE_TEMPLATE) -("L2ROE", L2ROE) -("LMROE", LMROE) -("SLAU2", SLAU2) -("FDS", FDS) -("LAX-FRIEDRICH", LAX_FRIEDRICH); -#endif +static const MapType Upwind_Map = { + MakePair("NONE", NO_UPWIND) + MakePair("ROE", ROE) + MakePair("TURKEL_PREC", TURKEL) + MakePair("AUSM", AUSM) + MakePair("AUSMPLUSUP", AUSMPLUSUP) + MakePair("AUSMPLUSUP2", AUSMPLUSUP2) + MakePair("SLAU", SLAU) + MakePair("HLLC", HLLC) + MakePair("SW", SW) + MakePair("MSW", MSW) + MakePair("CUSP", CUSP) + MakePair("SCALAR_UPWIND", SCALAR_UPWIND) + MakePair("CONVECTIVE_TEMPLATE", CONVECTIVE_TEMPLATE) + MakePair("L2ROE", L2ROE) + MakePair("LMROE", LMROE) + MakePair("SLAU2", SLAU2) + MakePair("FDS", FDS) + MakePair("LAX-FRIEDRICH", LAX_FRIEDRICH) +}; /*! * \brief types of FEM spatial discretizations @@ -788,24 +729,22 @@ enum ENUM_FEM { NO_FEM = 0, /*!< \brief No finite element scheme is used. */ DG = 1 /*!< \brief Discontinuous Galerkin numerical method. */ }; -#ifdef ENABLE_MAPS -static const map FEM_Map = CCreateMap -("NONE", NO_FEM) -("DG", DG); -#endif +static const MapType FEM_Map = { + MakePair("NONE", NO_FEM) + MakePair("DG", DG) +}; /*! * \brief types of shock capturing method in Discontinuous Galerkin numerical method. */ enum ENUM_SHOCK_CAPTURING_DG { - NO_SHOCK_CAPTURING = 0, /*!< \brief Shock capturing is not used. */ - PERSSON = 1 /*!< \brief Per-Olof Persson's sub-cell shock capturing method. */ + NO_SHOCK_CAPTURING = 0, /*!< \brief Shock capturing is not used. */ + PERSSON = 1 /*!< \brief Per-Olof Persson's sub-cell shock capturing method. */ +}; +static const MapType ShockCapturingDG_Map = { + MakePair("NONE", NO_SHOCK_CAPTURING) + MakePair("PERSSON", PERSSON) }; -#ifdef ENABLE_MAPS -static const map ShockCapturingDG_Map = CCreateMap -("NONE", NO_SHOCK_CAPTURING) -("PERSSON", PERSSON); -#endif /*! * \brief types of matrix coloring to compute a sparse Jacobian matrix. @@ -814,34 +753,32 @@ enum ENUM_MATRIX_COLORING { GREEDY_COLORING = 0, /*!< \brief Greedy type of algorithm for the coloring. */ NATURAL_COLORING = 1 /*!< \brief One color for every DOF, very slow. Only to be used for debugging. */ }; -#ifdef ENABLE_MAPS -static const map MatrixColoring_Map = CCreateMap -("GREEDY_COLORING", GREEDY_COLORING) -("NATURAL_COLORING", NATURAL_COLORING); -#endif +static const MapType MatrixColoring_Map = { + MakePair("GREEDY_COLORING", GREEDY_COLORING) + MakePair("NATURAL_COLORING", NATURAL_COLORING) +}; /*! * \brief types of slope limiters */ enum ENUM_LIMITER { NO_LIMITER = 0, /*!< \brief No limiter. */ - VENKATAKRISHNAN = 1, /*!< \brief Slope limiter using Venkatakrisnan method (stencil formulation). */ - VENKATAKRISHNAN_WANG = 2, /*!< \brief Slope limiter using Venkatakrisnan method, eps based on solution (stencil formulation). */ + VENKATAKRISHNAN = 1, /*!< \brief Slope limiter using Venkatakrisnan method (stencil formulation). */ + VENKATAKRISHNAN_WANG = 2, /*!< \brief Slope limiter using Venkatakrisnan method, eps based on solution (stencil formulation). */ BARTH_JESPERSEN = 3, /*!< \brief Slope limiter using Barth-Jespersen method (stencil formulation). */ VAN_ALBADA_EDGE = 4, /*!< \brief Slope limiter using Van Albada method (edge formulation). */ SHARP_EDGES = 5, /*!< \brief Slope limiter using sharp edges. */ WALL_DISTANCE = 6 /*!< \brief Slope limiter using wall distance. */ }; -#ifdef ENABLE_MAPS -static const map Limiter_Map = CCreateMap -("NONE", NO_LIMITER) -("VENKATAKRISHNAN", VENKATAKRISHNAN) -("VENKATAKRISHNAN_WANG", VENKATAKRISHNAN_WANG) -("BARTH_JESPERSEN", BARTH_JESPERSEN) -("VAN_ALBADA_EDGE", VAN_ALBADA_EDGE) -("SHARP_EDGES", SHARP_EDGES) -("WALL_DISTANCE", WALL_DISTANCE); -#endif +static const MapType Limiter_Map = { + MakePair("NONE", NO_LIMITER) + MakePair("VENKATAKRISHNAN", VENKATAKRISHNAN) + MakePair("VENKATAKRISHNAN_WANG", VENKATAKRISHNAN_WANG) + MakePair("BARTH_JESPERSEN", BARTH_JESPERSEN) + MakePair("VAN_ALBADA_EDGE", VAN_ALBADA_EDGE) + MakePair("SHARP_EDGES", SHARP_EDGES) + MakePair("WALL_DISTANCE", WALL_DISTANCE) +}; /*! * \brief types of turbulent models @@ -856,32 +793,30 @@ enum ENUM_TURB_MODEL { SST = 6, /*!< \brief Kind of Turbulence model (Menter SST). */ SST_SUST = 7 /*!< \brief Kind of Turbulence model (Menter SST with sustaining terms for free-stream preservation). */ }; -#ifdef ENABLE_MAPS -static const map Turb_Model_Map = CCreateMap -("NONE", NO_TURB_MODEL) -("SA", SA) -("SA_NEG", SA_NEG) -("SA_E", SA_E) -("SA_COMP", SA_COMP) -("SA_E_COMP", SA_E_COMP) -("SST", SST) -("SST_SUST", SST_SUST); -#endif +static const MapType Turb_Model_Map = { + MakePair("NONE", NO_TURB_MODEL) + MakePair("SA", SA) + MakePair("SA_NEG", SA_NEG) + MakePair("SA_E", SA_E) + MakePair("SA_COMP", SA_COMP) + MakePair("SA_E_COMP", SA_E_COMP) + MakePair("SST", SST) + MakePair("SST_SUST", SST_SUST) +}; /*! * \brief types of transition models */ enum ENUM_TRANS_MODEL { NO_TRANS_MODEL = 0, /*!< \brief No transition model. */ - LM = 1, /*!< \brief Kind of transition model (Langtry-Menter (LM) for SST and Spalart-Allmaras). */ - BC = 2 /*!< \brief Kind of transition model (BAS-CAKMAKCIOGLU (BC) for Spalart-Allmaras). */ + LM = 1, /*!< \brief Kind of transition model (Langtry-Menter (LM) for SST and Spalart-Allmaras). */ + BC = 2 /*!< \brief Kind of transition model (BAS-CAKMAKCIOGLU (BC) for Spalart-Allmaras). */ +}; +static const MapType Trans_Model_Map = { + MakePair("NONE", NO_TRANS_MODEL) + MakePair("LM", LM) + MakePair("BC", BC) }; -#ifdef ENABLE_MAPS -static const map Trans_Model_Map = CCreateMap -("NONE", NO_TRANS_MODEL) -("LM", LM) -("BC", BC); //BAS-CAKMAKCIOGLU -#endif /*! * \brief types of subgrid scale models @@ -893,33 +828,30 @@ enum ENUM_SGS_MODEL { WALE = 3, /*!< \brief Wall-Adapting Local Eddy-viscosity SGS model. */ VREMAN = 4 /*!< \brief Vreman SGS model. */ }; -#ifdef ENABLE_MAPS -static const map SGS_Model_Map = CCreateMap -("NONE", NO_SGS_MODEL) -("IMPLICIT_LES", IMPLICIT_LES) -("SMAGORINSKY", SMAGORINSKY) -("WALE", WALE) -("VREMAN", VREMAN); -#endif +static const MapType SGS_Model_Map = { + MakePair("NONE", NO_SGS_MODEL) + MakePair("IMPLICIT_LES", IMPLICIT_LES) + MakePair("SMAGORINSKY", SMAGORINSKY) + MakePair("WALE", WALE) + MakePair("VREMAN", VREMAN) +}; /*! * \brief types of window (weight) functions for cost functional */ enum WINDOW_FUNCTION { - SQUARE = 0, /*!< \brief No weight function (order 1)*/ - HANN = 1, /*!< \brief Hann-type weight function (order 3) */ - HANN_SQUARE = 2, /*!< \brief Hann-squared type weight function (order 5)*/ - BUMP = 3, /*!< \brief bump type weight function (exponential order of convergence) */ + SQUARE = 0, /*!< \brief No weight function (order 1)*/ + HANN = 1, /*!< \brief Hann-type weight function (order 3) */ + HANN_SQUARE = 2, /*!< \brief Hann-squared type weight function (order 5)*/ + BUMP = 3, /*!< \brief bump type weight function (exponential order of convergence) */ +}; +static const MapType Window_Map = { + MakePair("SQUARE", SQUARE) + MakePair("HANN", HANN) + MakePair("HANN_SQUARE", HANN_SQUARE) + MakePair("BUMP", BUMP) }; - -#ifdef ENABLE_MAPS -static const map Window_Map = CCreateMap -("SQUARE", SQUARE) -("HANN", HANN) -("HANN_SQUARE", HANN_SQUARE) -("BUMP", BUMP); -#endif /*! * \brief types of hybrid RANS/LES models @@ -931,14 +863,13 @@ enum ENUM_HYBRIDRANSLES { SA_ZDES = 3, /*!< \brief Kind of Hybrid RANS/LES (SA - Delayed DES (DDES) with Vorticity based SGS like Zonal DES). */ SA_EDDES = 4 /*!< \brief Kind of Hybrid RANS/LES (SA - Delayed DES (DDES) with Shear Layer Adapted SGS: Enhanced DDES). */ }; -#ifdef ENABLE_MAPS -static const map HybridRANSLES_Map = CCreateMap -("NONE", NO_HYBRIDRANSLES) -("SA_DES", SA_DES) -("SA_DDES", SA_DDES) -("SA_ZDES", SA_ZDES) -("SA_EDDES", SA_EDDES); -#endif +static const MapType HybridRANSLES_Map = { + MakePair("NONE", NO_HYBRIDRANSLES) + MakePair("SA_DES", SA_DES) + MakePair("SA_DDES", SA_DDES) + MakePair("SA_ZDES", SA_ZDES) + MakePair("SA_EDDES", SA_EDDES) +}; /*! * \brief types of Roe Low Dissipation Schemes @@ -950,14 +881,13 @@ enum ENUM_ROELOWDISS { NTS_DUCROS = 3, /*!< \brief Numerical Blending of Travin and Shur + Ducros' Shock Sensor. */ FD_DUCROS = 4 /*!< \brief Numerical Blending based on DDES's F_d function + Ducros' Shock Sensor */ }; -#ifdef ENABLE_MAPS -static const map RoeLowDiss_Map = CCreateMap -("NONE", NO_ROELOWDISS) -("FD", FD) -("NTS", NTS) -("NTS_DUCROS", NTS_DUCROS) -("FD_DUCROS", FD_DUCROS); -#endif +static const MapType RoeLowDiss_Map = { + MakePair("NONE", NO_ROELOWDISS) + MakePair("FD", FD) + MakePair("NTS", NTS) + MakePair("NTS_DUCROS", NTS_DUCROS) + MakePair("FD_DUCROS", FD_DUCROS) +}; /*! * \brief types of wall functions. @@ -971,35 +901,33 @@ enum ENUM_WALL_FUNCTIONS { NONEQUILIBRIUM_WALL_MODEL = 5, /*!< \brief Non-equilibrium wall model for LES. */ LOGARITHMIC_WALL_MODEL = 6 /*!< \brief Logarithmic law-of-the-wall model for LES. */ }; -#ifdef ENABLE_MAPS -static const map Wall_Functions_Map = CCreateMap -("NO_WALL_FUNCTION", NO_WALL_FUNCTION) -("STANDARD_WALL_FUNCTION", STANDARD_WALL_FUNCTION) -("ADAPTIVE_WALL_FUNCTION", ADAPTIVE_WALL_FUNCTION) -("SCALABLE_WALL_FUNCTION", SCALABLE_WALL_FUNCTION) -("EQUILIBRIUM_WALL_MODEL", EQUILIBRIUM_WALL_MODEL) -("NONEQUILIBRIUM_WALL_MODEL", NONEQUILIBRIUM_WALL_MODEL) -("LOGARITHMIC_WALL_MODEL", LOGARITHMIC_WALL_MODEL); -#endif +static const MapType Wall_Functions_Map = { + MakePair("NO_WALL_FUNCTION", NO_WALL_FUNCTION) + MakePair("STANDARD_WALL_FUNCTION", STANDARD_WALL_FUNCTION) + MakePair("ADAPTIVE_WALL_FUNCTION", ADAPTIVE_WALL_FUNCTION) + MakePair("SCALABLE_WALL_FUNCTION", SCALABLE_WALL_FUNCTION) + MakePair("EQUILIBRIUM_WALL_MODEL", EQUILIBRIUM_WALL_MODEL) + MakePair("NONEQUILIBRIUM_WALL_MODEL", NONEQUILIBRIUM_WALL_MODEL) + MakePair("LOGARITHMIC_WALL_MODEL", LOGARITHMIC_WALL_MODEL) +}; /*! * \brief type of time integration schemes */ enum ENUM_TIME_INT { - RUNGE_KUTTA_EXPLICIT = 1, /*!< \brief Explicit Runge-Kutta time integration definition. */ - EULER_EXPLICIT = 2, /*!< \brief Explicit Euler time integration definition. */ - EULER_IMPLICIT = 3, /*!< \brief Implicit Euler time integration definition. */ - CLASSICAL_RK4_EXPLICIT = 4, /*!< \brief Classical RK4 time integration definition. */ - ADER_DG = 5 /*!< \brief ADER-DG time integration definition. */ + RUNGE_KUTTA_EXPLICIT = 1, /*!< \brief Explicit Runge-Kutta time integration definition. */ + EULER_EXPLICIT = 2, /*!< \brief Explicit Euler time integration definition. */ + EULER_IMPLICIT = 3, /*!< \brief Implicit Euler time integration definition. */ + CLASSICAL_RK4_EXPLICIT = 4, /*!< \brief Classical RK4 time integration definition. */ + ADER_DG = 5 /*!< \brief ADER-DG time integration definition. */ +}; +static const MapType Time_Int_Map = { + MakePair("RUNGE-KUTTA_EXPLICIT", RUNGE_KUTTA_EXPLICIT) + MakePair("EULER_EXPLICIT", EULER_EXPLICIT) + MakePair("EULER_IMPLICIT", EULER_IMPLICIT) + MakePair("CLASSICAL_RK4_EXPLICIT", CLASSICAL_RK4_EXPLICIT) + MakePair("ADER_DG", ADER_DG) }; -#ifdef ENABLE_MAPS -static const map Time_Int_Map = CCreateMap -("RUNGE-KUTTA_EXPLICIT", RUNGE_KUTTA_EXPLICIT) -("EULER_EXPLICIT", EULER_EXPLICIT) -("EULER_IMPLICIT", EULER_IMPLICIT) -("CLASSICAL_RK4_EXPLICIT", CLASSICAL_RK4_EXPLICIT) -("ADER_DG", ADER_DG); -#endif /*! * \brief type of predictor for the ADER-DG time integration scheme. @@ -1008,11 +936,10 @@ enum ENUM_ADER_PREDICTOR { ADER_ALIASED_PREDICTOR = 1, /*!< \brief Aliased predictor, easiest to do. */ ADER_NON_ALIASED_PREDICTOR = 2 /*!< \brief Non-aliased predictor. Consistent, but more difficult. */ }; -#ifdef ENABLE_MAPS -static const map Ader_Predictor_Map = CCreateMap -("ADER_ALIASED_PREDICTOR", ADER_ALIASED_PREDICTOR) -("ADER_NON_ALIASED_PREDICTOR", ADER_NON_ALIASED_PREDICTOR); -#endif +static const MapType Ader_Predictor_Map = { + MakePair("ADER_ALIASED_PREDICTOR", ADER_ALIASED_PREDICTOR) + MakePair("ADER_NON_ALIASED_PREDICTOR", ADER_NON_ALIASED_PREDICTOR) +}; /*! * \brief type of heat timestep calculation @@ -1023,13 +950,12 @@ enum ENUM_HEAT_TIMESTEP { VISCOUS = 3, /*!< \brief Local time stepping based on viscous spectral radius.*/ BYFLOW = 4, /*!< \brief Unsing the mean solvers time step. */ }; -#ifdef ENABLE_MAPS -static const map Heat_TimeStep_Map = CCreateMap -("LOCAL", MINIMUM) -("CONVECTIVE", CONVECTIVE) -("VISCOUS", VISCOUS) -("BYFLOW", BYFLOW); -#endif +static const MapType Heat_TimeStep_Map = { + MakePair("LOCAL", MINIMUM) + MakePair("CONVECTIVE", CONVECTIVE) + MakePair("VISCOUS", VISCOUS) + MakePair("BYFLOW", BYFLOW) +}; /*! * \brief type of time integration schemes @@ -1039,133 +965,126 @@ enum ENUM_TIME_INT_FEA { NEWMARK_IMPLICIT = 2, /*!< \brief Implicit Newmark integration definition. */ GENERALIZED_ALPHA = 3 /*!< \brief Support for implementing another implicit method. */ }; -#ifdef ENABLE_MAPS -static const map Time_Int_Map_FEA = CCreateMap -("CD_EXPLICIT", CD_EXPLICIT) -("NEWMARK_IMPLICIT", NEWMARK_IMPLICIT) -("GENERALIZED_ALPHA", GENERALIZED_ALPHA); -#endif +static const MapType Time_Int_Map_FEA = { + MakePair("CD_EXPLICIT", CD_EXPLICIT) + MakePair("NEWMARK_IMPLICIT", NEWMARK_IMPLICIT) + MakePair("GENERALIZED_ALPHA", GENERALIZED_ALPHA) +}; /*! * \brief type of time integration schemes */ enum ENUM_SPACE_ITE_FEA { - NEWTON_RAPHSON = 1, /*!< \brief Full Newton-Rapshon method. */ + NEWTON_RAPHSON = 1, /*!< \brief Full Newton-Rapshon method. */ MODIFIED_NEWTON_RAPHSON = 2 /*!< \brief Modified Newton-Raphson method. */ }; -#ifdef ENABLE_MAPS -static const map Space_Ite_Map_FEA = CCreateMap -("NEWTON_RAPHSON", NEWTON_RAPHSON) -("MODIFIED_NEWTON_RAPHSON", MODIFIED_NEWTON_RAPHSON); -#endif +static const MapType Space_Ite_Map_FEA = { + MakePair("NEWTON_RAPHSON", NEWTON_RAPHSON) + MakePair("MODIFIED_NEWTON_RAPHSON", MODIFIED_NEWTON_RAPHSON) +}; /*! * \brief types of schemes to compute the flow gradient */ enum ENUM_FLOW_GRADIENT { - NO_GRADIENT = 0, /*!< \brief No gradient method. Only possible for reconstruction gradient, in which case, the option chosen for NUM_METHOD_GRAD is used. */ - GREEN_GAUSS = 1, /*!< \brief Gradient computation using Green-Gauss theorem. */ - LEAST_SQUARES = 2, /*!< \brief Gradient computation using unweighted least squares. */ - WEIGHTED_LEAST_SQUARES = 3 /*!< \brief Gradients computation using inverse-distance weighted least squares. */ + NO_GRADIENT = 0, /*!< \brief No gradient method. Only possible for reconstruction gradient, in which case, the option chosen for NUM_METHOD_GRAD is used. */ + GREEN_GAUSS = 1, /*!< \brief Gradient computation using Green-Gauss theorem. */ + LEAST_SQUARES = 2, /*!< \brief Gradient computation using unweighted least squares. */ + WEIGHTED_LEAST_SQUARES = 3 /*!< \brief Gradients computation using inverse-distance weighted least squares. */ +}; +static const MapType Gradient_Map = { + MakePair("NONE", NO_GRADIENT) + MakePair("GREEN_GAUSS", GREEN_GAUSS) + MakePair("LEAST_SQUARES", LEAST_SQUARES) + MakePair("WEIGHTED_LEAST_SQUARES", WEIGHTED_LEAST_SQUARES) }; -#ifdef ENABLE_MAPS -static const map Gradient_Map = CCreateMap -("NONE", NO_GRADIENT) -("GREEN_GAUSS", GREEN_GAUSS) -("LEAST_SQUARES", LEAST_SQUARES) -("WEIGHTED_LEAST_SQUARES", WEIGHTED_LEAST_SQUARES); -#endif /*! * \brief types of action to take on a geometry structure */ enum GEOMETRY_ACTION { - ALLOCATE = 0, /*!< \brief Allocate geometry structure. */ - UPDATE = 1 /*!< \brief Update geometry structure (grid moving, adaptation, etc.). */ + ALLOCATE = 0, /*!< \brief Allocate geometry structure. */ + UPDATE = 1 /*!< \brief Update geometry structure (grid moving, adaptation, etc.). */ }; /*! * \brief types of action to perform when doing the geometry evaluation */ enum GEOMETRY_MODE { - FUNCTION = 0, /*!< \brief Geometrical analysis. */ - GRADIENT = 1 /*!< \brief Geometrical analysis and gradient using finite differences. */ + FUNCTION = 0, /*!< \brief Geometrical analysis. */ + GRADIENT = 1 /*!< \brief Geometrical analysis and gradient using finite differences. */ +}; +static const MapType GeometryMode_Map = { + MakePair("FUNCTION", FUNCTION) + MakePair("GRADIENT", GRADIENT) }; -#ifdef ENABLE_MAPS -static const map GeometryMode_Map = CCreateMap -("FUNCTION", FUNCTION) -("GRADIENT", GRADIENT); -#endif /*! * \brief types of boundary conditions */ enum BC_TYPE { - EULER_WALL = 1, /*!< \brief Boundary Euler wall definition. */ - FAR_FIELD = 2, /*!< \brief Boundary far-field definition. */ - SYMMETRY_PLANE = 3, /*!< \brief Boundary symmetry plane definition. */ - INLET_FLOW = 4, /*!< \brief Boundary inlet flow definition. */ - OUTLET_FLOW = 5, /*!< \brief Boundary outlet flow definition. */ - PERIODIC_BOUNDARY = 6, /*!< \brief Periodic boundary definition. */ - NEARFIELD_BOUNDARY = 7, /*!< \brief Near-Field boundary definition. */ - ELECTRODE_BOUNDARY = 8, /*!< \brief Electrode boundary definition. */ - DIELEC_BOUNDARY = 9, /*!< \brief Dipoisson boundary definition. */ - CUSTOM_BOUNDARY = 10, /*!< \brief custom boundary definition. */ - INTERFACE_BOUNDARY = 11, /*!< \brief Domain interface boundary definition. */ - DIRICHLET = 12, /*!< \brief Boundary Euler wall definition. */ - NEUMANN = 13, /*!< \brief Boundary Neumann definition. */ - DISPLACEMENT_BOUNDARY = 14, /*!< \brief Boundary displacement definition. */ - LOAD_BOUNDARY = 15, /*!< \brief Boundary Load definition. */ - FLOWLOAD_BOUNDARY = 16, /*!< \brief Boundary Load definition. */ - SUPERSONIC_INLET = 19, /*!< \brief Boundary supersonic inlet definition. */ - SUPERSONIC_OUTLET = 20, /*!< \brief Boundary supersonic inlet definition. */ - ENGINE_INFLOW = 21, /*!< \brief Boundary nacelle inflow. */ - ENGINE_EXHAUST = 22, /*!< \brief Boundary nacelle exhaust. */ - RIEMANN_BOUNDARY= 24, /*!< \brief Riemann Boundary definition. */ - ISOTHERMAL = 25, /*!< \brief No slip isothermal wall boundary condition. */ - HEAT_FLUX = 26, /*!< \brief No slip constant heat flux wall boundary condition. */ - ACTDISK_INLET = 32, /*!< \brief Actuator disk inlet boundary definition. */ - ACTDISK_OUTLET = 33, /*!< \brief Actuator disk outlet boundary definition. */ - CLAMPED_BOUNDARY = 34, /*!< \brief Clamped Boundary definition. */ - LOAD_DIR_BOUNDARY = 35, /*!< \brief Boundary Load definition. */ - LOAD_SINE_BOUNDARY = 36, /*!< \brief Sine-waveBoundary Load definition. */ - GILES_BOUNDARY= 37, /*!< \brief Giles Boundary definition. */ - INTERNAL_BOUNDARY= 38, /*!< \brief Internal Boundary definition. */ - FLUID_INTERFACE = 39, /*!< \brief Domain interface definition. */ - DISP_DIR_BOUNDARY = 40, /*!< \brief Boundary displacement definition. */ - DAMPER_BOUNDARY = 41, /*!< \brief Damper. */ - CHT_WALL_INTERFACE = 50, /*!< \brief Domain interface definition. */ - SEND_RECEIVE = 99, /*!< \brief Boundary send-receive definition. */ -}; - - -/*! - * \brief different regime modes + EULER_WALL = 1, /*!< \brief Boundary Euler wall definition. */ + FAR_FIELD = 2, /*!< \brief Boundary far-field definition. */ + SYMMETRY_PLANE = 3, /*!< \brief Boundary symmetry plane definition. */ + INLET_FLOW = 4, /*!< \brief Boundary inlet flow definition. */ + OUTLET_FLOW = 5, /*!< \brief Boundary outlet flow definition. */ + PERIODIC_BOUNDARY = 6, /*!< \brief Periodic boundary definition. */ + NEARFIELD_BOUNDARY = 7, /*!< \brief Near-Field boundary definition. */ + ELECTRODE_BOUNDARY = 8, /*!< \brief Electrode boundary definition. */ + DIELEC_BOUNDARY = 9, /*!< \brief Dipoisson boundary definition. */ + CUSTOM_BOUNDARY = 10, /*!< \brief custom boundary definition. */ + INTERFACE_BOUNDARY = 11, /*!< \brief Domain interface boundary definition. */ + DIRICHLET = 12, /*!< \brief Boundary Euler wall definition. */ + NEUMANN = 13, /*!< \brief Boundary Neumann definition. */ + DISPLACEMENT_BOUNDARY = 14, /*!< \brief Boundary displacement definition. */ + LOAD_BOUNDARY = 15, /*!< \brief Boundary Load definition. */ + FLOWLOAD_BOUNDARY = 16, /*!< \brief Boundary Load definition. */ + SUPERSONIC_INLET = 19, /*!< \brief Boundary supersonic inlet definition. */ + SUPERSONIC_OUTLET = 20, /*!< \brief Boundary supersonic inlet definition. */ + ENGINE_INFLOW = 21, /*!< \brief Boundary nacelle inflow. */ + ENGINE_EXHAUST = 22, /*!< \brief Boundary nacelle exhaust. */ + RIEMANN_BOUNDARY= 24, /*!< \brief Riemann Boundary definition. */ + ISOTHERMAL = 25, /*!< \brief No slip isothermal wall boundary condition. */ + HEAT_FLUX = 26, /*!< \brief No slip constant heat flux wall boundary condition. */ + ACTDISK_INLET = 32, /*!< \brief Actuator disk inlet boundary definition. */ + ACTDISK_OUTLET = 33, /*!< \brief Actuator disk outlet boundary definition. */ + CLAMPED_BOUNDARY = 34, /*!< \brief Clamped Boundary definition. */ + LOAD_DIR_BOUNDARY = 35, /*!< \brief Boundary Load definition. */ + LOAD_SINE_BOUNDARY = 36, /*!< \brief Sine-waveBoundary Load definition. */ + GILES_BOUNDARY= 37, /*!< \brief Giles Boundary definition. */ + INTERNAL_BOUNDARY= 38, /*!< \brief Internal Boundary definition. */ + FLUID_INTERFACE = 39, /*!< \brief Domain interface definition. */ + DISP_DIR_BOUNDARY = 40, /*!< \brief Boundary displacement definition. */ + DAMPER_BOUNDARY = 41, /*!< \brief Damper. */ + CHT_WALL_INTERFACE = 50, /*!< \brief Domain interface definition. */ + SEND_RECEIVE = 99, /*!< \brief Boundary send-receive definition. */ +}; + +/*! + * \brief Different regime modes */ enum ENUM_2DFORM { - PLANE_STRESS = 0, /*!< \brief Definition of plane stress solver. */ - PLANE_STRAIN = 1 /*!< \brief Definition of plane strain solver. */ + PLANE_STRESS = 0, /*!< \brief Definition of plane stress solver. */ + PLANE_STRAIN = 1 /*!< \brief Definition of plane strain solver. */ +}; +static const MapType ElasForm_2D = { + MakePair("PLANE_STRESS", PLANE_STRESS) + MakePair("PLANE_STRAIN", PLANE_STRAIN) }; -#ifdef ENABLE_MAPS -static const map ElasForm_2D = CCreateMap -("PLANE_STRESS", PLANE_STRESS) -("PLANE_STRAIN", PLANE_STRAIN); -#endif /*! * \brief Kinds of relaxation for FSI problem */ enum ENUM_AITKEN { - NO_RELAXATION = 0, /*!< \brief No relaxation in the strongly coupled approach. */ - FIXED_PARAMETER = 1, /*!< \brief Relaxation with a fixed parameter. */ - AITKEN_DYNAMIC = 2 /*!< \brief Relaxation using Aitken's dynamic parameter. */ + NO_RELAXATION = 0, /*!< \brief No relaxation in the strongly coupled approach. */ + FIXED_PARAMETER = 1, /*!< \brief Relaxation with a fixed parameter. */ + AITKEN_DYNAMIC = 2 /*!< \brief Relaxation using Aitken's dynamic parameter. */ +}; +static const MapType AitkenForm_Map = { + MakePair("NONE", NO_RELAXATION) + MakePair("FIXED_PARAMETER", FIXED_PARAMETER) + MakePair("AITKEN_DYNAMIC", AITKEN_DYNAMIC) }; -#ifdef ENABLE_MAPS -static const map AitkenForm_Map = CCreateMap -("NONE", NO_RELAXATION) -("FIXED_PARAMETER", FIXED_PARAMETER) -("AITKEN_DYNAMIC", AITKEN_DYNAMIC); -#endif /*! * \brief types of dynamic transfer methods @@ -1178,36 +1097,34 @@ enum ENUM_DYN_TRANSFER_METHOD { SIGMOID_10 = 5, /*!< \brief The load is transferred using a sigmoid with parameter 10 */ SIGMOID_20 = 6 /*!< \brief The load is transferred using a sigmoid with parameter 20 */ }; -#ifdef ENABLE_MAPS -static const map Dyn_Transfer_Method_Map = CCreateMap -("INSTANTANEOUS", INSTANTANEOUS) -("RAMP", POL_ORDER_1) -("CUBIC", POL_ORDER_3) -("QUINTIC", POL_ORDER_5) -("SIGMOID_10", SIGMOID_10) -("SIGMOID_20", SIGMOID_20); -#endif +static const MapType Dyn_Transfer_Method_Map = { + MakePair("INSTANTANEOUS", INSTANTANEOUS) + MakePair("RAMP", POL_ORDER_1) + MakePair("CUBIC", POL_ORDER_3) + MakePair("QUINTIC", POL_ORDER_5) + MakePair("SIGMOID_10", SIGMOID_10) + MakePair("SIGMOID_20", SIGMOID_20) +}; /*! - * \brief Kinds of Design Variables for FEA problems + * \brief Kinds of Design Variables for FEA problems */ enum ENUM_DVFEA { NODV_FEA = 0, /*!< \brief No design variable for FEA problems. */ - YOUNG_MODULUS = 1, /*!< \brief Young modulus (E) as design variable. */ - POISSON_RATIO = 2, /*!< \brief Poisson ratio (Nu) as design variable. */ + YOUNG_MODULUS = 1, /*!< \brief Young modulus (E) as design variable. */ + POISSON_RATIO = 2, /*!< \brief Poisson ratio (Nu) as design variable. */ DENSITY_VAL = 3, /*!< \brief Density (Rho) as design variable. */ DEAD_WEIGHT = 4, /*!< \brief Dead Weight (Rho_DL) as design variable. */ ELECTRIC_FIELD = 5 /*!< \brief Electric field (E) as design variable. */ }; -#ifdef ENABLE_MAPS -static const map DVFEA_Map = CCreateMap -("NONE", NODV_FEA) -("YOUNG_MODULUS", YOUNG_MODULUS) -("POISSON_RATIO", POISSON_RATIO) -("DENSITY", DENSITY_VAL) -("DEAD_WEIGHT", DEAD_WEIGHT) -("ELECTRIC_FIELD", ELECTRIC_FIELD); -#endif +static const MapType DVFEA_Map = { + MakePair("NONE", NODV_FEA) + MakePair("YOUNG_MODULUS", YOUNG_MODULUS) + MakePair("POISSON_RATIO", POISSON_RATIO) + MakePair("DENSITY", DENSITY_VAL) + MakePair("DEAD_WEIGHT", DEAD_WEIGHT) + MakePair("ELECTRIC_FIELD", ELECTRIC_FIELD) +}; /*! * \brief Kinds of coupling methods at CHT interfaces. @@ -1220,19 +1137,18 @@ enum ENUM_CHT_COUPLING { DIRECT_TEMPERATURE_ROBIN_HEATFLUX = 2, AVERAGED_TEMPERATURE_ROBIN_HEATFLUX = 3 }; -#ifdef ENABLE_MAPS -static const map CHT_Coupling_Map = CCreateMap -("DIRECT_TEMPERATURE_NEUMANN_HEATFLUX", DIRECT_TEMPERATURE_NEUMANN_HEATFLUX) -("AVERAGED_TEMPERATURE_NEUMANN_HEATFLUX", AVERAGED_TEMPERATURE_NEUMANN_HEATFLUX) -("DIRECT_TEMPERATURE_ROBIN_HEATFLUX", DIRECT_TEMPERATURE_ROBIN_HEATFLUX) -("AVERAGED_TEMPERATURE_ROBIN_HEATFLUX", AVERAGED_TEMPERATURE_ROBIN_HEATFLUX); -#endif +static const MapType CHT_Coupling_Map = { + MakePair("DIRECT_TEMPERATURE_NEUMANN_HEATFLUX", DIRECT_TEMPERATURE_NEUMANN_HEATFLUX) + MakePair("AVERAGED_TEMPERATURE_NEUMANN_HEATFLUX", AVERAGED_TEMPERATURE_NEUMANN_HEATFLUX) + MakePair("DIRECT_TEMPERATURE_ROBIN_HEATFLUX", DIRECT_TEMPERATURE_ROBIN_HEATFLUX) + MakePair("AVERAGED_TEMPERATURE_ROBIN_HEATFLUX", AVERAGED_TEMPERATURE_ROBIN_HEATFLUX) +}; /*! * \brief types Riemann boundary treatments */ enum RIEMANN_TYPE { - TOTAL_CONDITIONS_PT = 1, /*!< \brief User specifies total pressure, total temperature, and flow direction. */ + TOTAL_CONDITIONS_PT = 1, /*!< \brief User specifies total pressure, total temperature, and flow direction. */ DENSITY_VELOCITY = 2, /*!< \brief User specifies density and velocity, and flow direction. */ STATIC_PRESSURE = 3, /*!< \brief User specifies static pressure. */ TOTAL_SUPERSONIC_INFLOW = 4, /*!< \brief User specifies total pressure, total temperature and Velocity components. */ @@ -1247,43 +1163,39 @@ enum RIEMANN_TYPE { MIXING_IN_1D = 13, MIXING_OUT_1D =14 }; - -#ifdef ENABLE_MAPS -static const map Riemann_Map = CCreateMap -("TOTAL_CONDITIONS_PT", TOTAL_CONDITIONS_PT) -("DENSITY_VELOCITY", DENSITY_VELOCITY) -("STATIC_PRESSURE", STATIC_PRESSURE) -("TOTAL_SUPERSONIC_INFLOW", TOTAL_SUPERSONIC_INFLOW) -("STATIC_SUPERSONIC_INFLOW_PT", STATIC_SUPERSONIC_INFLOW_PT) -("STATIC_SUPERSONIC_INFLOW_PD", STATIC_SUPERSONIC_INFLOW_PD) -("MIXING_IN", MIXING_IN) -("MIXING_OUT", MIXING_OUT) -("MIXING_IN_1D", MIXING_IN_1D) -("MIXING_OUT_1D", MIXING_OUT_1D) -("SUPERSONIC_OUTFLOW", SUPERSONIC_OUTFLOW) -("RADIAL_EQUILIBRIUM", RADIAL_EQUILIBRIUM) -("TOTAL_CONDITIONS_PT_1D", TOTAL_CONDITIONS_PT_1D) -("STATIC_PRESSURE_1D", STATIC_PRESSURE_1D); -#endif - - -#ifdef ENABLE_MAPS -static const map Giles_Map = CCreateMap -("TOTAL_CONDITIONS_PT", TOTAL_CONDITIONS_PT) -("DENSITY_VELOCITY", DENSITY_VELOCITY) -("STATIC_PRESSURE", STATIC_PRESSURE) -("TOTAL_SUPERSONIC_INFLOW", TOTAL_SUPERSONIC_INFLOW) -("STATIC_SUPERSONIC_INFLOW_PT", STATIC_SUPERSONIC_INFLOW_PT) -("STATIC_SUPERSONIC_INFLOW_PD", STATIC_SUPERSONIC_INFLOW_PD) -("MIXING_IN", MIXING_IN) -("MIXING_OUT", MIXING_OUT) -("MIXING_IN_1D", MIXING_IN_1D) -("MIXING_OUT_1D", MIXING_OUT_1D) -("SUPERSONIC_OUTFLOW", SUPERSONIC_OUTFLOW) -("RADIAL_EQUILIBRIUM", RADIAL_EQUILIBRIUM) -("TOTAL_CONDITIONS_PT_1D", TOTAL_CONDITIONS_PT_1D) -("STATIC_PRESSURE_1D", STATIC_PRESSURE_1D); -#endif +static const MapType Riemann_Map = { + MakePair("TOTAL_CONDITIONS_PT", TOTAL_CONDITIONS_PT) + MakePair("DENSITY_VELOCITY", DENSITY_VELOCITY) + MakePair("STATIC_PRESSURE", STATIC_PRESSURE) + MakePair("TOTAL_SUPERSONIC_INFLOW", TOTAL_SUPERSONIC_INFLOW) + MakePair("STATIC_SUPERSONIC_INFLOW_PT", STATIC_SUPERSONIC_INFLOW_PT) + MakePair("STATIC_SUPERSONIC_INFLOW_PD", STATIC_SUPERSONIC_INFLOW_PD) + MakePair("MIXING_IN", MIXING_IN) + MakePair("MIXING_OUT", MIXING_OUT) + MakePair("MIXING_IN_1D", MIXING_IN_1D) + MakePair("MIXING_OUT_1D", MIXING_OUT_1D) + MakePair("SUPERSONIC_OUTFLOW", SUPERSONIC_OUTFLOW) + MakePair("RADIAL_EQUILIBRIUM", RADIAL_EQUILIBRIUM) + MakePair("TOTAL_CONDITIONS_PT_1D", TOTAL_CONDITIONS_PT_1D) + MakePair("STATIC_PRESSURE_1D", STATIC_PRESSURE_1D) +}; + +static const MapType Giles_Map = { + MakePair("TOTAL_CONDITIONS_PT", TOTAL_CONDITIONS_PT) + MakePair("DENSITY_VELOCITY", DENSITY_VELOCITY) + MakePair("STATIC_PRESSURE", STATIC_PRESSURE) + MakePair("TOTAL_SUPERSONIC_INFLOW", TOTAL_SUPERSONIC_INFLOW) + MakePair("STATIC_SUPERSONIC_INFLOW_PT", STATIC_SUPERSONIC_INFLOW_PT) + MakePair("STATIC_SUPERSONIC_INFLOW_PD", STATIC_SUPERSONIC_INFLOW_PD) + MakePair("MIXING_IN", MIXING_IN) + MakePair("MIXING_OUT", MIXING_OUT) + MakePair("MIXING_IN_1D", MIXING_IN_1D) + MakePair("MIXING_OUT_1D", MIXING_OUT_1D) + MakePair("SUPERSONIC_OUTFLOW", SUPERSONIC_OUTFLOW) + MakePair("RADIAL_EQUILIBRIUM", RADIAL_EQUILIBRIUM) + MakePair("TOTAL_CONDITIONS_PT_1D", TOTAL_CONDITIONS_PT_1D) + MakePair("STATIC_PRESSURE_1D", STATIC_PRESSURE_1D) +}; /*! * \brief types of mixing process for averaging quantities at the boundaries. @@ -1294,60 +1206,56 @@ enum AVERAGEPROCESS_TYPE { MIXEDOUT = 3, /*!< \brief an mixed-out average is computed at the boundary of interest. */ MASSFLUX = 4 /*!< \brief a mass flow average is computed at the boundary of interest. */ }; -#ifdef ENABLE_MAPS -static const map AverageProcess_Map = CCreateMap -("ALGEBRAIC", ALGEBRAIC) -("AREA", AREA) -("MIXEDOUT", MIXEDOUT) -("MASSFLUX", MASSFLUX); -#endif +static const MapType AverageProcess_Map = { + MakePair("ALGEBRAIC", ALGEBRAIC) + MakePair("AREA", AREA) + MakePair("MIXEDOUT", MIXEDOUT) + MakePair("MASSFLUX", MASSFLUX) +}; /*! * \brief types of mixing process for averaging quantities at the boundaries. */ enum MIXINGPLANE_INTERFACE_TYPE { - MATCHING = 1, /*!< \brief an algebraic average is computed at the boundary of interest. */ + MATCHING = 1, /*!< \brief an algebraic average is computed at the boundary of interest. */ NEAREST_SPAN = 2, /*!< \brief an area average is computed at the boundary of interest. */ - LINEAR_INTERPOLATION = 3 /*!< \brief an mixed-out average is computed at the boundary of interest. */ + LINEAR_INTERPOLATION = 3 /*!< \brief an mixed-out average is computed at the boundary of interest. */ +}; +static const MapType MixingPlaneInterface_Map = { + MakePair("MATCHING", MATCHING) + MakePair("NEAREST_SPAN", NEAREST_SPAN) + MakePair("LINEAR_INTERPOLATION", LINEAR_INTERPOLATION) }; -#ifdef ENABLE_MAPS -static const map MixingPlaneInterface_Map = CCreateMap -("MATCHING", MATCHING) -("NEAREST_SPAN", NEAREST_SPAN) -("LINEAR_INTERPOLATION", LINEAR_INTERPOLATION); -#endif /*! * \brief this option allow to compute the span-wise section in different ways. */ enum SPANWISE_TYPE { - AUTOMATIC = 1, /*!< \brief number of span-wise section are computed automatically */ - EQUISPACED = 2 /*!< \brief number of span-wise section are specified from the user */ + AUTOMATIC = 1, /*!< \brief number of span-wise section are computed automatically */ + EQUISPACED = 2 /*!< \brief number of span-wise section are specified from the user */ +}; +static const MapType SpanWise_Map = { + MakePair("AUTOMATIC", AUTOMATIC) + MakePair("EQUISPACED", EQUISPACED) }; -#ifdef ENABLE_MAPS -static const map SpanWise_Map = CCreateMap -("AUTOMATIC", AUTOMATIC) -("EQUISPACED", EQUISPACED); -#endif /*! * \brief types of mixing process for averaging quantities at the boundaries. */ enum TURBOMACHINERY_TYPE { - AXIAL = 1, /*!< \brief axial turbomachinery. */ + AXIAL = 1, /*!< \brief axial turbomachinery. */ CENTRIFUGAL = 2, /*!< \brief centrifugal turbomachinery. */ - CENTRIPETAL = 3, /*!< \brief centripetal turbomachinery. */ + CENTRIPETAL = 3, /*!< \brief centripetal turbomachinery. */ CENTRIPETAL_AXIAL = 4, /*!< \brief mixed flow turbine. */ - AXIAL_CENTRIFUGAL = 5 /*!< \brief mixed flow turbine. */ + AXIAL_CENTRIFUGAL = 5 /*!< \brief mixed flow turbine. */ +}; +static const MapType TurboMachinery_Map = { + MakePair("AXIAL", AXIAL) + MakePair("CENTRIFUGAL", CENTRIFUGAL) + MakePair("CENTRIPETAL", CENTRIPETAL) + MakePair("CENTRIPETAL_AXIAL", CENTRIPETAL_AXIAL) + MakePair("AXIAL_CENTRIFUGAL", AXIAL_CENTRIFUGAL) }; -#ifdef ENABLE_MAPS -static const map TurboMachinery_Map = CCreateMap -("AXIAL", AXIAL) -("CENTRIFUGAL", CENTRIFUGAL) -("CENTRIPETAL", CENTRIPETAL) -("CENTRIPETAL_AXIAL", CENTRIPETAL_AXIAL) -("AXIAL_CENTRIFUGAL", AXIAL_CENTRIFUGAL); -#endif /*! * \brief types of Turbomachinery performance flag. @@ -1367,14 +1275,13 @@ enum INLET_TYPE { VELOCITY_INLET = 4, /*!< \brief Velocity inlet for an incompressible flow. */ PRESSURE_INLET = 5 /*!< \brief Total pressure inlet for an incompressible flow. */ }; -#ifdef ENABLE_MAPS -static const map Inlet_Map = CCreateMap -("TOTAL_CONDITIONS", TOTAL_CONDITIONS) -("MASS_FLOW", MASS_FLOW) -("INPUT_FILE", INPUT_FILE) -("VELOCITY_INLET", VELOCITY_INLET) -("PRESSURE_INLET", PRESSURE_INLET); -#endif +static const MapType Inlet_Map = { + MakePair("TOTAL_CONDITIONS", TOTAL_CONDITIONS) + MakePair("MASS_FLOW", MASS_FLOW) + MakePair("INPUT_FILE", INPUT_FILE) + MakePair("VELOCITY_INLET", VELOCITY_INLET) + MakePair("PRESSURE_INLET", PRESSURE_INLET) +}; /*! * \brief types outlet boundary treatments @@ -1383,86 +1290,83 @@ enum OUTLET_TYPE { PRESSURE_OUTLET = 1, /*!< \brief Gauge pressure outlet for incompressible flow */ MASS_FLOW_OUTLET = 2, /*!< \brief Mass flow outlet for incompressible flow. */ }; -#ifdef ENABLE_MAPS -static const map Outlet_Map = CCreateMap -("PRESSURE_OUTLET", PRESSURE_OUTLET) -("MASS_FLOW_OUTLET", MASS_FLOW_OUTLET); -#endif +static const MapType Outlet_Map = { + MakePair("PRESSURE_OUTLET", PRESSURE_OUTLET) + MakePair("MASS_FLOW_OUTLET", MASS_FLOW_OUTLET) +}; /*! * \brief types engine inflow boundary treatments */ enum ENGINE_INFLOW_TYPE { - FAN_FACE_MACH = 1, /*!< \brief User specifies fan face mach number. */ - FAN_FACE_MDOT = 2, /*!< \brief User specifies Static pressure. */ - FAN_FACE_PRESSURE = 3 /*!< \brief User specifies Static pressure. */ + FAN_FACE_MACH = 1, /*!< \brief User specifies fan face mach number. */ + FAN_FACE_MDOT = 2, /*!< \brief User specifies Static pressure. */ + FAN_FACE_PRESSURE = 3 /*!< \brief User specifies Static pressure. */ +}; +static const MapType Engine_Inflow_Map = { + MakePair("FAN_FACE_MACH", FAN_FACE_MACH) + MakePair("FAN_FACE_MDOT", FAN_FACE_MDOT) + MakePair("FAN_FACE_PRESSURE", FAN_FACE_PRESSURE) }; -#ifdef ENABLE_MAPS -static const map Engine_Inflow_Map = CCreateMap -("FAN_FACE_MACH", FAN_FACE_MACH) -("FAN_FACE_MDOT", FAN_FACE_MDOT) -("FAN_FACE_PRESSURE", FAN_FACE_PRESSURE); -#endif /*! * \brief types actuator disk boundary treatments */ enum ACTDISK_TYPE { - VARIABLES_JUMP = 1, /*!< \brief User specifies the variables jump. */ + VARIABLES_JUMP = 1, /*!< \brief User specifies the variables jump. */ BC_THRUST = 2, /*!< \brief User specifies the BC thrust. */ NET_THRUST = 3, /*!< \brief User specifies the Net thrust. */ DRAG_MINUS_THRUST = 4, /*!< \brief User specifies the D-T. */ MASSFLOW = 5, /*!< \brief User specifies the massflow. */ POWER = 6 /*!< \brief User specifies the power. */ }; -#ifdef ENABLE_MAPS -static const map ActDisk_Map = CCreateMap -("VARIABLES_JUMP", VARIABLES_JUMP) -("BC_THRUST", BC_THRUST) -("NET_THRUST", NET_THRUST) -("DRAG_MINUS_THRUST", DRAG_MINUS_THRUST) -("MASSFLOW", MASSFLOW) -("POWER", POWER); -#endif +static const MapType ActDisk_Map = { + MakePair("VARIABLES_JUMP", VARIABLES_JUMP) + MakePair("BC_THRUST", BC_THRUST) + MakePair("NET_THRUST", NET_THRUST) + MakePair("DRAG_MINUS_THRUST", DRAG_MINUS_THRUST) + MakePair("MASSFLOW", MASSFLOW) + MakePair("POWER", POWER) +}; /*! * \brief types of geometric entities based on VTK nomenclature */ enum GEO_TYPE { - VERTEX = 1, /*!< \brief VTK nomenclature for defining a vertex element. */ - LINE = 3, /*!< \brief VTK nomenclature for defining a line element. */ - TRIANGLE = 5, /*!< \brief VTK nomenclature for defining a triangle element. */ + VERTEX = 1, /*!< \brief VTK nomenclature for defining a vertex element. */ + LINE = 3, /*!< \brief VTK nomenclature for defining a line element. */ + TRIANGLE = 5, /*!< \brief VTK nomenclature for defining a triangle element. */ QUADRILATERAL = 9, /*!< \brief VTK nomenclature for defining a quadrilateral element. */ TETRAHEDRON = 10, /*!< \brief VTK nomenclature for defining a tetrahedron element. */ HEXAHEDRON = 12, /*!< \brief VTK nomenclature for defining a hexahedron element. */ - PRISM = 13, /*!< \brief VTK nomenclature for defining a prism element. */ - PYRAMID = 14 /*!< \brief VTK nomenclature for defining a pyramid element. */ + PRISM = 13, /*!< \brief VTK nomenclature for defining a prism element. */ + PYRAMID = 14 /*!< \brief VTK nomenclature for defining a pyramid element. */ }; /*! * \brief types of objective functions */ enum ENUM_OBJECTIVE { - DRAG_COEFFICIENT = 1, /*!< \brief Drag objective function definition. */ - LIFT_COEFFICIENT = 2, /*!< \brief Lift objective function definition. */ + DRAG_COEFFICIENT = 1, /*!< \brief Drag objective function definition. */ + LIFT_COEFFICIENT = 2, /*!< \brief Lift objective function definition. */ SIDEFORCE_COEFFICIENT = 3, /*!< \brief Side force objective function definition. */ - EFFICIENCY = 4, /*!< \brief Efficiency objective function definition. */ + EFFICIENCY = 4, /*!< \brief Efficiency objective function definition. */ INVERSE_DESIGN_PRESSURE = 5, /*!< \brief Pressure objective function definition (inverse design). */ INVERSE_DESIGN_HEATFLUX = 6, /*!< \brief Heat flux objective function definition (inverse design). */ TOTAL_HEATFLUX = 7, /*!< \brief Total heat flux. */ MAXIMUM_HEATFLUX = 8, /*!< \brief Maximum heat flux. */ TOTAL_AVG_TEMPERATURE = 70, /*!< \brief Total averaged temperature. */ - MOMENT_X_COEFFICIENT = 9, /*!< \brief Pitching moment objective function definition. */ + MOMENT_X_COEFFICIENT = 9, /*!< \brief Pitching moment objective function definition. */ MOMENT_Y_COEFFICIENT = 10, /*!< \brief Rolling moment objective function definition. */ MOMENT_Z_COEFFICIENT = 11, /*!< \brief Yawing objective function definition. */ - EQUIVALENT_AREA = 12, /*!< \brief Equivalent area objective function definition. */ - NEARFIELD_PRESSURE = 13, /*!< \brief NearField Pressure objective function definition. */ - FORCE_X_COEFFICIENT = 14, /*!< \brief X-direction force objective function definition. */ - FORCE_Y_COEFFICIENT = 15, /*!< \brief Y-direction force objective function definition. */ - FORCE_Z_COEFFICIENT = 16, /*!< \brief Z-direction force objective function definition. */ - THRUST_COEFFICIENT = 17, /*!< \brief Thrust objective function definition. */ - TORQUE_COEFFICIENT = 18, /*!< \brief Torque objective function definition. */ - FIGURE_OF_MERIT = 19, /*!< \brief Rotor Figure of Merit objective function definition. */ + EQUIVALENT_AREA = 12, /*!< \brief Equivalent area objective function definition. */ + NEARFIELD_PRESSURE = 13, /*!< \brief NearField Pressure objective function definition. */ + FORCE_X_COEFFICIENT = 14, /*!< \brief X-direction force objective function definition. */ + FORCE_Y_COEFFICIENT = 15, /*!< \brief Y-direction force objective function definition. */ + FORCE_Z_COEFFICIENT = 16, /*!< \brief Z-direction force objective function definition. */ + THRUST_COEFFICIENT = 17, /*!< \brief Thrust objective function definition. */ + TORQUE_COEFFICIENT = 18, /*!< \brief Torque objective function definition. */ + FIGURE_OF_MERIT = 19, /*!< \brief Rotor Figure of Merit objective function definition. */ BUFFET_SENSOR = 20, /*!< \brief Sensor for detecting separation. */ SURFACE_TOTAL_PRESSURE = 28, /*!< \brief Total Pressure objective function definition. */ SURFACE_STATIC_PRESSURE = 29, /*!< \brief Static Pressure objective function definition. */ @@ -1472,8 +1376,8 @@ enum ENUM_OBJECTIVE { SURFACE_SECONDARY = 53, /*!< \brief Secondary flow strength objective function definition. */ SURFACE_MOM_DISTORTION = 54, /*!< \brief Momentum distortion objective function definition. */ SURFACE_SECOND_OVER_UNIFORM = 55, /*!< \brief Secondary over uniformity (relative secondary strength) objective function definition. */ - SURFACE_PRESSURE_DROP = 56, /*!< \brief Pressure drop objective function definition. */ - CUSTOM_OBJFUNC = 31, /*!< \brief Custom objective function definition. */ + SURFACE_PRESSURE_DROP = 56, /*!< \brief Pressure drop objective function definition. */ + CUSTOM_OBJFUNC = 31, /*!< \brief Custom objective function definition. */ TOTAL_PRESSURE_LOSS = 39, KINETIC_ENERGY_LOSS = 40, TOTAL_EFFICIENCY = 41, @@ -1486,63 +1390,62 @@ enum ENUM_OBJECTIVE { MASS_FLOW_OUT = 48, PRESSURE_RATIO = 49, ENTROPY_GENERATION = 50, - REFERENCE_GEOMETRY=60, /*!< \brief Norm of displacements with respect to target geometry. */ - REFERENCE_NODE=61, /*!< \brief Objective function defined as the difference of a particular node respect to a reference position. */ - VOLUME_FRACTION=62, /*!< \brief Volume average physical density, for material-based topology optimization applications. */ - TOPOL_DISCRETENESS=63, /*!< \brief Measure of the discreteness of the current topology. */ - TOPOL_COMPLIANCE=64 /*!< \brief Measure of the discreteness of the current topology. */ + REFERENCE_GEOMETRY = 60, /*!< \brief Norm of displacements with respect to target geometry. */ + REFERENCE_NODE = 61, /*!< \brief Objective function defined as the difference of a particular node respect to a reference position. */ + VOLUME_FRACTION = 62, /*!< \brief Volume average physical density, for material-based topology optimization applications. */ + TOPOL_DISCRETENESS = 63, /*!< \brief Measure of the discreteness of the current topology. */ + TOPOL_COMPLIANCE = 64 /*!< \brief Measure of the discreteness of the current topology. */ +}; +static const MapType Objective_Map = { + MakePair("DRAG", DRAG_COEFFICIENT) + MakePair("LIFT", LIFT_COEFFICIENT) + MakePair("SIDEFORCE", SIDEFORCE_COEFFICIENT) + MakePair("EFFICIENCY", EFFICIENCY) + MakePair("INVERSE_DESIGN_PRESSURE", INVERSE_DESIGN_PRESSURE) + MakePair("INVERSE_DESIGN_HEATFLUX", INVERSE_DESIGN_HEATFLUX) + MakePair("MOMENT_X", MOMENT_X_COEFFICIENT) + MakePair("MOMENT_Y", MOMENT_Y_COEFFICIENT) + MakePair("MOMENT_Z", MOMENT_Z_COEFFICIENT) + MakePair("EQUIVALENT_AREA", EQUIVALENT_AREA) + MakePair("NEARFIELD_PRESSURE", NEARFIELD_PRESSURE) + MakePair("FORCE_X", FORCE_X_COEFFICIENT) + MakePair("FORCE_Y", FORCE_Y_COEFFICIENT) + MakePair("FORCE_Z", FORCE_Z_COEFFICIENT) + MakePair("THRUST", THRUST_COEFFICIENT) + MakePair("TORQUE", TORQUE_COEFFICIENT) + MakePair("TOTAL_HEATFLUX", TOTAL_HEATFLUX) + MakePair("MAXIMUM_HEATFLUX", MAXIMUM_HEATFLUX) + MakePair("TOTAL_AVG_TEMPERATURE", TOTAL_AVG_TEMPERATURE) + MakePair("FIGURE_OF_MERIT", FIGURE_OF_MERIT) + MakePair("BUFFET", BUFFET_SENSOR) + MakePair("SURFACE_TOTAL_PRESSURE", SURFACE_TOTAL_PRESSURE) + MakePair("SURFACE_STATIC_PRESSURE", SURFACE_STATIC_PRESSURE) + MakePair("SURFACE_MASSFLOW", SURFACE_MASSFLOW) + MakePair("SURFACE_MACH", SURFACE_MACH) + MakePair("SURFACE_UNIFORMITY", SURFACE_UNIFORMITY) + MakePair("SURFACE_SECONDARY", SURFACE_SECONDARY) + MakePair("SURFACE_MOM_DISTORTION", SURFACE_MOM_DISTORTION) + MakePair("SURFACE_SECOND_OVER_UNIFORM", SURFACE_SECOND_OVER_UNIFORM) + MakePair("SURFACE_PRESSURE_DROP", SURFACE_PRESSURE_DROP) + MakePair("CUSTOM_OBJFUNC", CUSTOM_OBJFUNC) + MakePair("TOTAL_EFFICIENCY", TOTAL_EFFICIENCY) + MakePair("TOTAL_STATIC_EFFICIENCY", TOTAL_STATIC_EFFICIENCY) + MakePair("TOTAL_PRESSURE_LOSS", TOTAL_PRESSURE_LOSS) + MakePair("EULERIAN_WORK", EULERIAN_WORK) + MakePair("TOTAL_ENTHALPY_IN", TOTAL_ENTHALPY_IN) + MakePair("FLOW_ANGLE_IN", FLOW_ANGLE_IN) + MakePair("FLOW_ANGLE_OUT", FLOW_ANGLE_OUT) + MakePair("MASS_FLOW_IN", MASS_FLOW_IN) + MakePair("MASS_FLOW_OUT", MASS_FLOW_OUT) + MakePair("PRESSURE_RATIO", PRESSURE_RATIO) + MakePair("ENTROPY_GENERATION", ENTROPY_GENERATION) + MakePair("KINETIC_ENERGY_LOSS", KINETIC_ENERGY_LOSS) + MakePair("REFERENCE_GEOMETRY", REFERENCE_GEOMETRY) + MakePair("REFERENCE_NODE", REFERENCE_NODE) + MakePair("VOLUME_FRACTION", VOLUME_FRACTION) + MakePair("TOPOL_DISCRETENESS", TOPOL_DISCRETENESS) + MakePair("TOPOL_COMPLIANCE", TOPOL_COMPLIANCE) }; -#ifdef ENABLE_MAPS -static const map Objective_Map = CCreateMap -("DRAG", DRAG_COEFFICIENT) -("LIFT", LIFT_COEFFICIENT) -("SIDEFORCE", SIDEFORCE_COEFFICIENT) -("EFFICIENCY", EFFICIENCY) -("INVERSE_DESIGN_PRESSURE", INVERSE_DESIGN_PRESSURE) -("INVERSE_DESIGN_HEATFLUX", INVERSE_DESIGN_HEATFLUX) -("MOMENT_X", MOMENT_X_COEFFICIENT) -("MOMENT_Y", MOMENT_Y_COEFFICIENT) -("MOMENT_Z", MOMENT_Z_COEFFICIENT) -("EQUIVALENT_AREA", EQUIVALENT_AREA) -("NEARFIELD_PRESSURE", NEARFIELD_PRESSURE) -("FORCE_X", FORCE_X_COEFFICIENT) -("FORCE_Y", FORCE_Y_COEFFICIENT) -("FORCE_Z", FORCE_Z_COEFFICIENT) -("THRUST", THRUST_COEFFICIENT) -("TORQUE", TORQUE_COEFFICIENT) -("TOTAL_HEATFLUX", TOTAL_HEATFLUX) -("MAXIMUM_HEATFLUX", MAXIMUM_HEATFLUX) -("TOTAL_AVG_TEMPERATURE", TOTAL_AVG_TEMPERATURE) -("FIGURE_OF_MERIT", FIGURE_OF_MERIT) -("BUFFET", BUFFET_SENSOR) -("SURFACE_TOTAL_PRESSURE", SURFACE_TOTAL_PRESSURE) -("SURFACE_STATIC_PRESSURE", SURFACE_STATIC_PRESSURE) -("SURFACE_MASSFLOW", SURFACE_MASSFLOW) -("SURFACE_MACH", SURFACE_MACH) -("SURFACE_UNIFORMITY", SURFACE_UNIFORMITY) -("SURFACE_SECONDARY", SURFACE_SECONDARY) -("SURFACE_MOM_DISTORTION", SURFACE_MOM_DISTORTION) -("SURFACE_SECOND_OVER_UNIFORM", SURFACE_SECOND_OVER_UNIFORM) -("SURFACE_PRESSURE_DROP", SURFACE_PRESSURE_DROP) -("CUSTOM_OBJFUNC", CUSTOM_OBJFUNC) -("TOTAL_EFFICIENCY", TOTAL_EFFICIENCY) -("TOTAL_STATIC_EFFICIENCY", TOTAL_STATIC_EFFICIENCY) -("TOTAL_PRESSURE_LOSS", TOTAL_PRESSURE_LOSS) -("EULERIAN_WORK", EULERIAN_WORK) -("TOTAL_ENTHALPY_IN", TOTAL_ENTHALPY_IN) -("FLOW_ANGLE_IN", FLOW_ANGLE_IN) -("FLOW_ANGLE_OUT", FLOW_ANGLE_OUT) -("MASS_FLOW_IN", MASS_FLOW_IN) -("MASS_FLOW_OUT", MASS_FLOW_OUT) -("PRESSURE_RATIO", PRESSURE_RATIO) -("ENTROPY_GENERATION", ENTROPY_GENERATION) -("KINETIC_ENERGY_LOSS", KINETIC_ENERGY_LOSS) -("REFERENCE_GEOMETRY", REFERENCE_GEOMETRY) -("REFERENCE_NODE", REFERENCE_NODE) -("VOLUME_FRACTION", VOLUME_FRACTION) -("TOPOL_DISCRETENESS", TOPOL_DISCRETENESS) -("TOPOL_COMPLIANCE", TOPOL_COMPLIANCE); -#endif /*! * \brief types of residual criteria equations @@ -1551,11 +1454,10 @@ enum ENUM_RESIDUAL { RHO_RESIDUAL = 1, /*!< \brief Rho equation residual criteria equation. */ RHO_ENERGY_RESIDUAL = 2 /*!< \brief RhoE equation residual criteria equation. */ }; -#ifdef ENABLE_MAPS -static const map Residual_Map = CCreateMap -("RHO", RHO_RESIDUAL) -("RHO_ENERGY", RHO_ENERGY_RESIDUAL); -#endif +static const MapType Residual_Map = { + MakePair("RHO", RHO_RESIDUAL) + MakePair("RHO_ENERGY", RHO_ENERGY_RESIDUAL) +}; /*! * \brief types of residual criteria for structural problems @@ -1564,63 +1466,60 @@ enum ENUM_RESFEM { RESFEM_RELATIVE = 1, /*!< \brief Relative criteria: Res/Res0. */ RESFEM_ABSOLUTE = 2 /*!< \brief Absolute criteria: abs(Res). */ }; -#ifdef ENABLE_MAPS -static const map ResFem_Map = CCreateMap -("RELATIVE", RESFEM_RELATIVE) -("ABSOLUTE", RESFEM_ABSOLUTE); -#endif +static const MapType ResFem_Map = { + MakePair("RELATIVE", RESFEM_RELATIVE) + MakePair("ABSOLUTE", RESFEM_ABSOLUTE) +}; /*! * \brief types of sensitivities to compute */ enum ENUM_SENS { - SENS_GEOMETRY = 1, /*!< \brief Geometrical sensitivity. */ - SENS_MACH = 2, /*!< \brief Mach number sensitivity. */ - SENS_AOA = 3, /*!< \brief Angle of attack sensitivity. */ - SENS_AOS = 4 /*!< \brief Angle of Sideslip sensitivity. */ + SENS_GEOMETRY = 1, /*!< \brief Geometrical sensitivity. */ + SENS_MACH = 2, /*!< \brief Mach number sensitivity. */ + SENS_AOA = 3, /*!< \brief Angle of attack sensitivity. */ + SENS_AOS = 4 /*!< \brief Angle of Sideslip sensitivity. */ +}; +static const MapType Sens_Map = { + MakePair("SENS_GEOMETRY", SENS_GEOMETRY) + MakePair("SENS_MACH", SENS_MACH) + MakePair("SENS_AOA", SENS_AOA) + MakePair("SENS_AOS", SENS_AOS) }; -#ifdef ENABLE_MAPS -static const map Sens_Map = CCreateMap -("SENS_GEOMETRY", SENS_GEOMETRY) -("SENS_MACH", SENS_MACH) -("SENS_AOA", SENS_AOA) -("SENS_AOS", SENS_AOS); -#endif /*! * \brief types of grid adaptation/refinement */ enum ENUM_ADAPT { NO_ADAPT = 0, /*!< \brief No grid adaptation. */ - FULL = 1, /*!< \brief Do a complete grid refinement of all the computational grids. */ - FULL_FLOW = 2, /*!< \brief Do a complete grid refinement of the flow grid. */ - FULL_ADJOINT = 3, /*!< \brief Do a complete grid refinement of the adjoint grid. */ - GRAD_FLOW = 5, /*!< \brief Do a gradient based grid adaptation of the flow grid. */ - GRAD_ADJOINT = 6, /*!< \brief Do a gradient based grid adaptation of the adjoint grid. */ - GRAD_FLOW_ADJ = 7, /*!< \brief Do a gradient based grid adaptation of the flow and adjoint grid. */ - COMPUTABLE = 9, /*!< \brief Apply a computable error grid adaptation. */ - REMAINING = 10, /*!< \brief Apply a remaining error grid adaptation. */ - WAKE = 12, /*!< \brief Do a grid refinement on the wake. */ - SMOOTHING = 14, /*!< \brief Do a grid smoothing of the geometry. */ + FULL = 1, /*!< \brief Do a complete grid refinement of all the computational grids. */ + FULL_FLOW = 2, /*!< \brief Do a complete grid refinement of the flow grid. */ + FULL_ADJOINT = 3, /*!< \brief Do a complete grid refinement of the adjoint grid. */ + GRAD_FLOW = 5, /*!< \brief Do a gradient based grid adaptation of the flow grid. */ + GRAD_ADJOINT = 6, /*!< \brief Do a gradient based grid adaptation of the adjoint grid. */ + GRAD_FLOW_ADJ = 7, /*!< \brief Do a gradient based grid adaptation of the flow and adjoint grid. */ + COMPUTABLE = 9, /*!< \brief Apply a computable error grid adaptation. */ + REMAINING = 10, /*!< \brief Apply a remaining error grid adaptation. */ + WAKE = 12, /*!< \brief Do a grid refinement on the wake. */ + SMOOTHING = 14, /*!< \brief Do a grid smoothing of the geometry. */ SUPERSONIC_SHOCK = 15, /*!< \brief Do a grid smoothing. */ - PERIODIC = 17 /*!< \brief Add the periodic halo cells. */ + PERIODIC = 17 /*!< \brief Add the periodic halo cells. */ +}; +static const MapType Adapt_Map = { + MakePair("NONE", NO_ADAPT) + MakePair("FULL", FULL) + MakePair("FULL_FLOW", FULL_FLOW) + MakePair("FULL_ADJOINT", FULL_ADJOINT) + MakePair("GRAD_FLOW", GRAD_FLOW) + MakePair("GRAD_ADJOINT", GRAD_ADJOINT) + MakePair("GRAD_FLOW_ADJ", GRAD_FLOW_ADJ) + MakePair("COMPUTABLE", COMPUTABLE) + MakePair("REMAINING", REMAINING) + MakePair("WAKE", WAKE) + MakePair("SMOOTHING", SMOOTHING) + MakePair("SUPERSONIC_SHOCK", SUPERSONIC_SHOCK) + MakePair("PERIODIC", PERIODIC) }; -#ifdef ENABLE_MAPS -static const map Adapt_Map = CCreateMap -("NONE", NO_ADAPT) -("FULL", FULL) -("FULL_FLOW", FULL_FLOW) -("FULL_ADJOINT", FULL_ADJOINT) -("GRAD_FLOW", GRAD_FLOW) -("GRAD_ADJOINT", GRAD_ADJOINT) -("GRAD_FLOW_ADJ", GRAD_FLOW_ADJ) -("COMPUTABLE", COMPUTABLE) -("REMAINING", REMAINING) -("WAKE", WAKE) -("SMOOTHING", SMOOTHING) -("SUPERSONIC_SHOCK", SUPERSONIC_SHOCK) -("PERIODIC", PERIODIC); -#endif /*! * \brief types of input file formats @@ -1631,13 +1530,12 @@ enum ENUM_INPUT { RECTANGLE = 3, /*!< \brief 2D rectangular mesh with N x M points of size Lx x Ly. */ BOX = 4 /*!< \brief 3D box mesh with N x M x L points of size Lx x Ly x Lz. */ }; -#ifdef ENABLE_MAPS -static const map Input_Map = CCreateMap -("SU2", SU2) -("CGNS", CGNS_GRID) -("RECTANGLE", RECTANGLE) -("BOX", BOX); -#endif +static const MapType Input_Map = { + MakePair("SU2", SU2) + MakePair("CGNS", CGNS_GRID) + MakePair("RECTANGLE", RECTANGLE) + MakePair("BOX", BOX) +}; /*! * \brief type of solution output file formats @@ -1660,38 +1558,35 @@ enum ENUM_OUTPUT { STL = 15, /*!< \brief STL ASCII format for surface solution output. */ STL_BINARY = 16 /*!< \brief STL binary format for surface solution output. Not implemented yet. */ }; - -#ifdef ENABLE_MAPS -static const map Output_Map = CCreateMap -("TECPLOT_ASCII", TECPLOT) -("TECPLOT", TECPLOT_BINARY) -("SURFACE_TECPLOT_ASCII", SURFACE_TECPLOT) -("SURFACE_TECPLOT", SURFACE_TECPLOT_BINARY) -("CSV", CSV) -("SURFACE_CSV", SURFACE_CSV) -("PARAVIEW_ASCII", PARAVIEW) -("PARAVIEW", PARAVIEW_BINARY) -("SURFACE_PARAVIEW_ASCII", SURFACE_PARAVIEW) -("SURFACE_PARAVIEW", SURFACE_PARAVIEW_BINARY) -("RESTART_ASCII", RESTART_ASCII) -("RESTART", RESTART_BINARY) -("CGNS", CGNS) -("STL", STL) -("STL_BINARY", STL_BINARY); -#endif +static const MapType Output_Map = { + MakePair("TECPLOT_ASCII", TECPLOT) + MakePair("TECPLOT", TECPLOT_BINARY) + MakePair("SURFACE_TECPLOT_ASCII", SURFACE_TECPLOT) + MakePair("SURFACE_TECPLOT", SURFACE_TECPLOT_BINARY) + MakePair("CSV", CSV) + MakePair("SURFACE_CSV", SURFACE_CSV) + MakePair("PARAVIEW_ASCII", PARAVIEW) + MakePair("PARAVIEW", PARAVIEW_BINARY) + MakePair("SURFACE_PARAVIEW_ASCII", SURFACE_PARAVIEW) + MakePair("SURFACE_PARAVIEW", SURFACE_PARAVIEW_BINARY) + MakePair("RESTART_ASCII", RESTART_ASCII) + MakePair("RESTART", RESTART_BINARY) + MakePair("CGNS", CGNS) + MakePair("STL", STL) + MakePair("STL_BINARY", STL_BINARY) +}; /*! * \brief type of solution output file formats */ enum ENUM_TAB_OUTPUT { - TAB_CSV = 1, /*!< \brief Comma-separated values format for the solution output. */ - TAB_TECPLOT = 2 /*!< \brief Tecplot format for the solution output. */ + TAB_CSV = 1, /*!< \brief Comma-separated values format for the solution output. */ + TAB_TECPLOT = 2 /*!< \brief Tecplot format for the solution output. */ +}; +static const MapType TabOutput_Map = { + MakePair("CSV", TAB_CSV) + MakePair("TECPLOT", TAB_TECPLOT) }; -#ifdef ENABLE_MAPS -static const map TabOutput_Map = CCreateMap -("CSV", TAB_CSV) -("TECPLOT", TAB_TECPLOT); -#endif /*! * \brief type of volume sensitivity file formats (inout to SU2_DOT) @@ -1700,11 +1595,10 @@ enum ENUM_SENSITIVITY { SU2_NATIVE = 1, /*!< \brief SU2 native binary format for the volume sensitivity input. */ UNORDERED_ASCII = 2 /*!< \brief Unordered ASCII list (x,y,z,dJ/dx,dJ/dy/dJ/dz) format for the volume sensitivity input. */ }; -#ifdef ENABLE_MAPS -static const map Sensitivity_Map = CCreateMap -("SU2_NATIVE", SU2_NATIVE) -("UNORDERED_ASCII", UNORDERED_ASCII); -#endif +static const MapType Sensitivity_Map = { + MakePair("SU2_NATIVE", SU2_NATIVE) + MakePair("UNORDERED_ASCII", UNORDERED_ASCII) +}; /*! * \brief type of jump definition @@ -1713,26 +1607,24 @@ enum JUMP_DEFINITION { DIFFERENCE = 1, /*!< \brief Jump given by a difference in values. */ RATIO = 2 /*!< \brief Jump given by a ratio. */ }; -#ifdef ENABLE_MAPS -static const map Jump_Map = CCreateMap -("DIFFERENCE", DIFFERENCE) -("RATIO", RATIO); -#endif +static const MapType Jump_Map = { + MakePair("DIFFERENCE", DIFFERENCE) + MakePair("RATIO", RATIO) +}; /*! * \brief type of multigrid cycle */ enum MG_CYCLE { - V_CYCLE = 0, /*!< \brief V cycle. */ - W_CYCLE = 1, /*!< \brief W cycle. */ - FULLMG_CYCLE = 2 /*!< \brief FullMG cycle. */ + V_CYCLE = 0, /*!< \brief V cycle. */ + W_CYCLE = 1, /*!< \brief W cycle. */ + FULLMG_CYCLE = 2 /*!< \brief FullMG cycle. */ +}; +static const MapType MG_Cycle_Map = { + MakePair("V_CYCLE", V_CYCLE) + MakePair("W_CYCLE", W_CYCLE) + MakePair("FULLMG_CYCLE", FULLMG_CYCLE) }; -#ifdef ENABLE_MAPS -static const map MG_Cycle_Map = CCreateMap -("V_CYCLE", V_CYCLE) -("W_CYCLE", W_CYCLE) -("FULLMG_CYCLE", FULLMG_CYCLE); -#endif /*! * \brief type of solution output variables @@ -1742,167 +1634,155 @@ enum ENUM_OUTPUT_VARS { VEL_X = 2, /*!< \brief X-component of velocity. */ VEL_Y = 3, /*!< \brief Y-component of velocity. */ VEL_Z = 4, /*!< \brief Z-component of velocity. */ - PRESSURE = 5, /*!< \brief Static pressure. */ + PRESSURE = 5, /*!< \brief Static pressure. */ MACH = 6, /*!< \brief Mach number. */ TEMPERATURE = 7, /*!< \brief Temperature. */ LAM_VISC = 8, /*!< \brief Laminar viscosity. */ EDDY_VISC = 9 /*!< \brief Eddy viscosity. */ }; -#ifdef ENABLE_MAPS -static const map Output_Vars_Map = CCreateMap -("DENSITY", DENSITY) -("VEL_X", VEL_X) -("VEL_Y", VEL_Y) -("VEL_Z", VEL_Z) -("PRESSURE", PRESSURE) -("MACH", MACH) -("TEMPERATURE", TEMPERATURE) -("LAM_VISC", LAM_VISC) -("EDDY_VISC", EDDY_VISC); -#endif +static const MapType Output_Vars_Map = { + MakePair("DENSITY", DENSITY) + MakePair("VEL_X", VEL_X) + MakePair("VEL_Y", VEL_Y) + MakePair("VEL_Z", VEL_Z) + MakePair("PRESSURE", PRESSURE) + MakePair("MACH", MACH) + MakePair("TEMPERATURE", TEMPERATURE) + MakePair("LAM_VISC", LAM_VISC) + MakePair("EDDY_VISC", EDDY_VISC) +}; /*! * \brief types of design parameterizations */ enum ENUM_PARAM { - NO_DEFORMATION = 0, /*!< \brief No deformation. */ - - TRANSLATION = 1, /*!< \brief Surface movement as design variable. */ - ROTATION = 2, /*!< \brief Surface rotation as design variable. */ - SCALE = 3, /*!< \brief Surface rotation as design variable. */ - - FFD_SETTING = 10, /*!< \brief No surface deformation. */ - FFD_CONTROL_POINT = 11, /*!< \brief Free form deformation for 3D design (change a control point). */ - FFD_NACELLE = 12, /*!< \brief Free form deformation for 3D design (change a control point). */ - FFD_GULL = 13, /*!< \brief Free form deformation for 3D design (change a control point). */ - FFD_CAMBER = 14, /*!< \brief Free form deformation for 3D design (camber change). */ - FFD_TWIST = 15, /*!< \brief Free form deformation for 3D design (change the twist angle of a section). */ - FFD_THICKNESS = 16, /*!< \brief Free form deformation for 3D design (thickness change). */ - FFD_ROTATION = 18, /*!< \brief Free form deformation for 3D design (rotation around a line). */ - FFD_CONTROL_POINT_2D = 19, /*!< \brief Free form deformation for 2D design (change a control point). */ - FFD_CAMBER_2D = 20, /*!< \brief Free form deformation for 3D design (camber change). */ - FFD_THICKNESS_2D = 21, /*!< \brief Free form deformation for 3D design (thickness change). */ - FFD_TWIST_2D = 22, /*!< \brief Free form deformation for 3D design (camber change). */ - FFD_CONTROL_SURFACE = 23, /*!< \brief Free form deformation for 3D design (control surface). */ - FFD_ANGLE_OF_ATTACK = 24, /*!< \brief Angle of attack for FFD problem. */ - - HICKS_HENNE = 30, /*!< \brief Hicks-Henne bump function for airfoil deformation. */ - PARABOLIC = 31, /*!< \brief Parabolic airfoil definition as design variables. */ - NACA_4DIGITS = 32, /*!< \brief The four digits NACA airfoil family as design variables. */ - AIRFOIL = 33, /*!< \brief Airfoil definition as design variables. */ - CST = 34, /*!< \brief CST method with Kulfan parameters for airfoil deformation. */ - SURFACE_BUMP = 35, /*!< \brief Surfacebump function for flat surfaces deformation. */ - SURFACE_FILE = 36, /*!< \brief Nodal coordinates for surface set using a file (external parameterization). */ - - DV_EFIELD = 40, /*!< \brief Electric field in deformable membranes. */ + NO_DEFORMATION = 0, /*!< \brief No deformation. */ + TRANSLATION = 1, /*!< \brief Surface movement as design variable. */ + ROTATION = 2, /*!< \brief Surface rotation as design variable. */ + SCALE = 3, /*!< \brief Surface rotation as design variable. */ + FFD_SETTING = 10, /*!< \brief No surface deformation. */ + FFD_CONTROL_POINT = 11, /*!< \brief Free form deformation for 3D design (change a control point). */ + FFD_NACELLE = 12, /*!< \brief Free form deformation for 3D design (change a control point). */ + FFD_GULL = 13, /*!< \brief Free form deformation for 3D design (change a control point). */ + FFD_CAMBER = 14, /*!< \brief Free form deformation for 3D design (camber change). */ + FFD_TWIST = 15, /*!< \brief Free form deformation for 3D design (change the twist angle of a section). */ + FFD_THICKNESS = 16, /*!< \brief Free form deformation for 3D design (thickness change). */ + FFD_ROTATION = 18, /*!< \brief Free form deformation for 3D design (rotation around a line). */ + FFD_CONTROL_POINT_2D = 19, /*!< \brief Free form deformation for 2D design (change a control point). */ + FFD_CAMBER_2D = 20, /*!< \brief Free form deformation for 3D design (camber change). */ + FFD_THICKNESS_2D = 21, /*!< \brief Free form deformation for 3D design (thickness change). */ + FFD_TWIST_2D = 22, /*!< \brief Free form deformation for 3D design (camber change). */ + FFD_CONTROL_SURFACE = 23, /*!< \brief Free form deformation for 3D design (control surface). */ + FFD_ANGLE_OF_ATTACK = 24, /*!< \brief Angle of attack for FFD problem. */ + HICKS_HENNE = 30, /*!< \brief Hicks-Henne bump function for airfoil deformation. */ + PARABOLIC = 31, /*!< \brief Parabolic airfoil definition as design variables. */ + NACA_4DIGITS = 32, /*!< \brief The four digits NACA airfoil family as design variables. */ + AIRFOIL = 33, /*!< \brief Airfoil definition as design variables. */ + CST = 34, /*!< \brief CST method with Kulfan parameters for airfoil deformation. */ + SURFACE_BUMP = 35, /*!< \brief Surfacebump function for flat surfaces deformation. */ + SURFACE_FILE = 36, /*!< \brief Nodal coordinates for surface set using a file (external parameterization). */ + DV_EFIELD = 40, /*!< \brief Electric field in deformable membranes. */ DV_YOUNG = 41, DV_POISSON = 42, DV_RHO = 43, DV_RHO_DL = 44, - - TRANSLATE_GRID = 50, /*!< \brief Translate the volume grid. */ - ROTATE_GRID = 51, /*!< \brief Rotate the volume grid */ - SCALE_GRID = 52, /*!< \brief Scale the volume grid. */ - - ANGLE_OF_ATTACK = 101 /*!< \brief Angle of attack for airfoils. */ -}; -#ifdef ENABLE_MAPS -static const map Param_Map = CCreateMap -("FFD_SETTING", FFD_SETTING) -("FFD_CONTROL_POINT_2D", FFD_CONTROL_POINT_2D) -("FFD_TWIST_2D", FFD_TWIST_2D) -("FFD_ANGLE_OF_ATTACK", FFD_ANGLE_OF_ATTACK) -("FFD_CAMBER_2D", FFD_CAMBER_2D) -("FFD_THICKNESS_2D", FFD_THICKNESS_2D) -("HICKS_HENNE", HICKS_HENNE) -("SURFACE_BUMP", SURFACE_BUMP) -("ANGLE_OF_ATTACK", ANGLE_OF_ATTACK) -("NACA_4DIGITS", NACA_4DIGITS) -("TRANSLATION", TRANSLATION) -("ROTATION", ROTATION) -("SCALE", SCALE) -("FFD_CONTROL_POINT", FFD_CONTROL_POINT) -("FFD_ROTATION", FFD_ROTATION) -("FFD_CONTROL_SURFACE", FFD_CONTROL_SURFACE) -("FFD_NACELLE", FFD_NACELLE) -("FFD_GULL", FFD_GULL) -("FFD_TWIST", FFD_TWIST) -("FFD_CAMBER", FFD_CAMBER) -("FFD_THICKNESS", FFD_THICKNESS) -("PARABOLIC", PARABOLIC) -("AIRFOIL", AIRFOIL) -("SURFACE_FILE", SURFACE_FILE) -("NO_DEFORMATION", NO_DEFORMATION) -("CST", CST) -("ELECTRIC_FIELD", DV_EFIELD) -("YOUNG_MODULUS", DV_YOUNG) -("POISSON_RATIO", DV_POISSON) -("STRUCTURAL_DENSITY", DV_RHO) -("DEAD_WEIGHT", DV_RHO_DL) -("TRANSLATE_GRID", TRANSLATE_GRID) -("ROTATE_GRID", ROTATE_GRID) -("SCALE_GRID", SCALE_GRID) -#endif -; - -/*! - * \brief types of FFD Blending function + TRANSLATE_GRID = 50, /*!< \brief Translate the volume grid. */ + ROTATE_GRID = 51, /*!< \brief Rotate the volume grid */ + SCALE_GRID = 52, /*!< \brief Scale the volume grid. */ + ANGLE_OF_ATTACK = 101 /*!< \brief Angle of attack for airfoils. */ +}; +static const MapType Param_Map = { + MakePair("FFD_SETTING", FFD_SETTING) + MakePair("FFD_CONTROL_POINT_2D", FFD_CONTROL_POINT_2D) + MakePair("FFD_TWIST_2D", FFD_TWIST_2D) + MakePair("FFD_ANGLE_OF_ATTACK", FFD_ANGLE_OF_ATTACK) + MakePair("FFD_CAMBER_2D", FFD_CAMBER_2D) + MakePair("FFD_THICKNESS_2D", FFD_THICKNESS_2D) + MakePair("HICKS_HENNE", HICKS_HENNE) + MakePair("SURFACE_BUMP", SURFACE_BUMP) + MakePair("ANGLE_OF_ATTACK", ANGLE_OF_ATTACK) + MakePair("NACA_4DIGITS", NACA_4DIGITS) + MakePair("TRANSLATION", TRANSLATION) + MakePair("ROTATION", ROTATION) + MakePair("SCALE", SCALE) + MakePair("FFD_CONTROL_POINT", FFD_CONTROL_POINT) + MakePair("FFD_ROTATION", FFD_ROTATION) + MakePair("FFD_CONTROL_SURFACE", FFD_CONTROL_SURFACE) + MakePair("FFD_NACELLE", FFD_NACELLE) + MakePair("FFD_GULL", FFD_GULL) + MakePair("FFD_TWIST", FFD_TWIST) + MakePair("FFD_CAMBER", FFD_CAMBER) + MakePair("FFD_THICKNESS", FFD_THICKNESS) + MakePair("PARABOLIC", PARABOLIC) + MakePair("AIRFOIL", AIRFOIL) + MakePair("SURFACE_FILE", SURFACE_FILE) + MakePair("NO_DEFORMATION", NO_DEFORMATION) + MakePair("CST", CST) + MakePair("ELECTRIC_FIELD", DV_EFIELD) + MakePair("YOUNG_MODULUS", DV_YOUNG) + MakePair("POISSON_RATIO", DV_POISSON) + MakePair("STRUCTURAL_DENSITY", DV_RHO) + MakePair("DEAD_WEIGHT", DV_RHO_DL) + MakePair("TRANSLATE_GRID", TRANSLATE_GRID) + MakePair("ROTATE_GRID", ROTATE_GRID) + MakePair("SCALE_GRID", SCALE_GRID) +}; + +/*! + * \brief Types of FFD Blending function */ enum ENUM_FFD_BLENDING{ BSPLINE_UNIFORM = 0, /*!< \brief BSpline blending */ BEZIER = 1, /*!< \brief Bezier blending */ }; -#ifdef ENABLE_MAPS -static const map Blending_Map = CCreateMap -("BSPLINE_UNIFORM", BSPLINE_UNIFORM) -("BEZIER", BEZIER); -#endif +static const MapType Blending_Map = { + MakePair("BSPLINE_UNIFORM", BSPLINE_UNIFORM) + MakePair("BEZIER", BEZIER) +}; /*! - * \brief types of solvers for solving linear systems + * \brief Types of solvers for solving linear systems */ enum ENUM_LINEAR_SOLVER { - STEEPEST_DESCENT = 1, /*!< \brief Steepest descent method for point inversion algoritm (Free-Form). */ - NEWTON = 2, /*!< \brief Newton method for point inversion algorithm (Free-Form). */ - QUASI_NEWTON = 3, /*!< \brief Quasi Newton method for point inversion algorithm (Free-Form). */ - CONJUGATE_GRADIENT = 4, /*!< \brief Preconditionated conjugate gradient method for grid deformation. */ - FGMRES = 5, /*!< \brief Flexible Generalized Minimal Residual method. */ - BCGSTAB = 6, /*!< \brief BCGSTAB - Biconjugate Gradient Stabilized Method (main solver). */ - RESTARTED_FGMRES = 7, /*!< \brief Flexible Generalized Minimal Residual method with restart. */ - SMOOTHER = 8, /*!< \brief Iterative smoother. */ - PASTIX_LDLT = 9, /*!< \brief PaStiX LDLT (complete) factorization. */ - PASTIX_LU = 10, /*!< \brief PaStiX LU (complete) factorization. */ + STEEPEST_DESCENT = 1, /*!< \brief Steepest descent method for point inversion algoritm (Free-Form). */ + NEWTON = 2, /*!< \brief Newton method for point inversion algorithm (Free-Form). */ + QUASI_NEWTON = 3, /*!< \brief Quasi Newton method for point inversion algorithm (Free-Form). */ + CONJUGATE_GRADIENT = 4, /*!< \brief Preconditionated conjugate gradient method for grid deformation. */ + FGMRES = 5, /*!< \brief Flexible Generalized Minimal Residual method. */ + BCGSTAB = 6, /*!< \brief BCGSTAB - Biconjugate Gradient Stabilized Method (main solver). */ + RESTARTED_FGMRES = 7, /*!< \brief Flexible Generalized Minimal Residual method with restart. */ + SMOOTHER = 8, /*!< \brief Iterative smoother. */ + PASTIX_LDLT = 9, /*!< \brief PaStiX LDLT (complete) factorization. */ + PASTIX_LU = 10, /*!< \brief PaStiX LU (complete) factorization. */ +}; +static const MapType Linear_Solver_Map = { + MakePair("STEEPEST_DESCENT", STEEPEST_DESCENT) + MakePair("NEWTON", NEWTON) + MakePair("QUASI_NEWTON", QUASI_NEWTON) + MakePair("CONJUGATE_GRADIENT", CONJUGATE_GRADIENT) + MakePair("BCGSTAB", BCGSTAB) + MakePair("FGMRES", FGMRES) + MakePair("RESTARTED_FGMRES", RESTARTED_FGMRES) + MakePair("SMOOTHER", SMOOTHER) + MakePair("PASTIX_LDLT", PASTIX_LDLT) + MakePair("PASTIX_LU", PASTIX_LU) }; -#ifdef ENABLE_MAPS -static const map Linear_Solver_Map = CCreateMap -("STEEPEST_DESCENT", STEEPEST_DESCENT) -("NEWTON", NEWTON) -("QUASI_NEWTON", QUASI_NEWTON) -("CONJUGATE_GRADIENT", CONJUGATE_GRADIENT) -("BCGSTAB", BCGSTAB) -("FGMRES", FGMRES) -("RESTARTED_FGMRES", RESTARTED_FGMRES) -("SMOOTHER", SMOOTHER) -("PASTIX_LDLT", PASTIX_LDLT) -("PASTIX_LU", PASTIX_LU); -#endif /*! * \brief types surface continuity at the intersection with the FFD */ enum ENUM_FFD_CONTINUITY { - DERIVATIVE_NONE = 0, /*!< \brief No derivative continuity. */ - DERIVATIVE_1ST = 1, /*!< \brief First derivative continuity. */ - DERIVATIVE_2ND = 2, /*!< \brief Second derivative continuity. */ - USER_INPUT = 3 /*!< \brief User input. */ + DERIVATIVE_NONE = 0, /*!< \brief No derivative continuity. */ + DERIVATIVE_1ST = 1, /*!< \brief First derivative continuity. */ + DERIVATIVE_2ND = 2, /*!< \brief Second derivative continuity. */ + USER_INPUT = 3 /*!< \brief User input. */ +}; +static const MapType Continuity_Map = { + MakePair("NO_DERIVATIVE", DERIVATIVE_NONE) + MakePair("1ST_DERIVATIVE", DERIVATIVE_1ST) + MakePair("2ND_DERIVATIVE", DERIVATIVE_2ND) + MakePair("USER_INPUT", USER_INPUT) }; -#ifdef ENABLE_MAPS -static const map Continuity_Map = CCreateMap -("NO_DERIVATIVE", DERIVATIVE_NONE) -("1ST_DERIVATIVE", DERIVATIVE_1ST) -("2ND_DERIVATIVE", DERIVATIVE_2ND) -("USER_INPUT", USER_INPUT); -#endif /*! * \brief types of coordinates systems for the FFD @@ -1913,51 +1793,48 @@ enum ENUM_FFD_COORD_SYSTEM { SPHERICAL = 2, /*!< \brief Spherical coordinate system. */ POLAR = 3 /*!< \brief Polar coordinate system. */ }; -#ifdef ENABLE_MAPS -static const map CoordSystem_Map = CCreateMap -("CARTESIAN", CARTESIAN) -("CYLINDRICAL", CYLINDRICAL) -("SPHERICAL", SPHERICAL) -("POLAR", POLAR); -#endif +static const MapType CoordSystem_Map = { + MakePair("CARTESIAN", CARTESIAN) + MakePair("CYLINDRICAL", CYLINDRICAL) + MakePair("SPHERICAL", SPHERICAL) + MakePair("POLAR", POLAR) +}; /*! * \brief types of sensitivity smoothing */ enum ENUM_SENS_SMOOTHING { NO_SMOOTH = 0, /*!< \brief No smoothing. */ - SOBOLEV = 1, /*!< \brief Sobolev gradient smoothing. */ - BIGRID = 2 /*!< \brief Bi-grid technique smoothing. */ + SOBOLEV = 1, /*!< \brief Sobolev gradient smoothing. */ + BIGRID = 2 /*!< \brief Bi-grid technique smoothing. */ +}; +static const MapType Sens_Smoothing_Map = { + MakePair("NONE", NO_SMOOTH) + MakePair("SOBOLEV", SOBOLEV) + MakePair("BIGRID", BIGRID) }; -#ifdef ENABLE_MAPS -static const map Sens_Smoothing_Map = CCreateMap -("NONE", NO_SMOOTH) -("SOBOLEV", SOBOLEV) -("BIGRID", BIGRID); -#endif /*! * \brief types of preconditioners for the linear solver */ enum ENUM_LINEAR_SOLVER_PREC { - JACOBI = 1, /*!< \brief Jacobi preconditioner. */ - LU_SGS = 2, /*!< \brief LU SGS preconditioner. */ + JACOBI = 1, /*!< \brief Jacobi preconditioner. */ + LU_SGS = 2, /*!< \brief LU SGS preconditioner. */ LINELET = 3, /*!< \brief Line implicit preconditioner. */ ILU = 4, /*!< \brief ILU(k) preconditioner. */ PASTIX_ILU= 5, /*!< \brief PaStiX ILU(k) preconditioner. */ PASTIX_LU_P= 6, /*!< \brief PaStiX LU as preconditioner. */ PASTIX_LDLT_P= 7, /*!< \brief PaStiX LDLT as preconditioner. */ }; -#ifdef ENABLE_MAPS -static const map Linear_Solver_Prec_Map = CCreateMap -("JACOBI", JACOBI) -("LU_SGS", LU_SGS) -("LINELET", LINELET) -("ILU", ILU) -("PASTIX_ILU", PASTIX_ILU) -("PASTIX_LU", PASTIX_LU_P) -("PASTIX_LDLT", PASTIX_LDLT_P); -#endif +static const MapType Linear_Solver_Prec_Map = { + MakePair("JACOBI", JACOBI) + MakePair("LU_SGS", LU_SGS) + MakePair("LINELET", LINELET) + MakePair("ILU", ILU) + MakePair("PASTIX_ILU", PASTIX_ILU) + MakePair("PASTIX_LU", PASTIX_LU_P) + MakePair("PASTIX_LDLT", PASTIX_LDLT_P) +}; /*! * \brief types of analytic definitions for various geometries @@ -1966,17 +1843,16 @@ enum ENUM_GEO_ANALYTIC { NO_GEO_ANALYTIC = 0, /*!< \brief No analytic definition of the geometry. */ NACA0012_AIRFOIL = 1, /*!< \brief Use the analytical definition of the NACA0012 for doing the grid adaptation. */ NACA4412_AIRFOIL = 2, /*!< \brief Use the analytical definition of the NACA4412 for doing the grid adaptation. */ - CYLINDER = 3, /*!< \brief Use the analytical definition of a cylinder for doing the grid adaptation. */ + CYLINDER = 3, /*!< \brief Use the analytical definition of a cylinder for doing the grid adaptation. */ BIPARABOLIC = 4 /*!< \brief Use the analytical definition of a biparabolic airfoil for doing the grid adaptation. */ }; -#ifdef ENABLE_MAPS -static const map Geo_Analytic_Map = CCreateMap -("NONE", NO_GEO_ANALYTIC) -("NACA0012_AIRFOIL", NACA0012_AIRFOIL) -("NACA4412_AIRFOIL", NACA4412_AIRFOIL) -("CYLINDER", CYLINDER) -("BIPARABOLIC", BIPARABOLIC); -#endif +static const MapType Geo_Analytic_Map = { + MakePair("NONE", NO_GEO_ANALYTIC) + MakePair("NACA0012_AIRFOIL", NACA0012_AIRFOIL) + MakePair("NACA4412_AIRFOIL", NACA4412_AIRFOIL) + MakePair("CYLINDER", CYLINDER) + MakePair("BIPARABOLIC", BIPARABOLIC) +}; /*! * \brief types of axis orientation @@ -1987,62 +1863,58 @@ enum ENUM_GEO_DESCRIPTION { FUSELAGE = 2, /*!< \brief Fuselage analysis. */ NACELLE = 3 /*!< \brief Nacelle analysis. */ }; -#ifdef ENABLE_MAPS -static const map Geo_Description_Map = CCreateMap -("AIRFOIL", TWOD_AIRFOIL) -("WING", WING) -("FUSELAGE", FUSELAGE) -("NACELLE", NACELLE); -#endif +static const MapType Geo_Description_Map = { + MakePair("AIRFOIL", TWOD_AIRFOIL) + MakePair("WING", WING) + MakePair("FUSELAGE", FUSELAGE) + MakePair("NACELLE", NACELLE) +}; /*! * \brief types of schemes for unsteady computations */ enum ENUM_UNSTEADY { STEADY = 0, /*!< \brief A steady computation. */ - TIME_STEPPING = 1, /*!< \brief Use a time stepping strategy for unsteady computations. */ + TIME_STEPPING = 1, /*!< \brief Use a time stepping strategy for unsteady computations. */ DT_STEPPING_1ST = 2, /*!< \brief Use a dual time stepping strategy for unsteady computations (1st order). */ DT_STEPPING_2ND = 3, /*!< \brief Use a dual time stepping strategy for unsteady computations (2nd order). */ ROTATIONAL_FRAME = 4, /*!< \brief Use a rotational source term. */ HARMONIC_BALANCE = 5 /*!< \brief Use a harmonic balance source term. */ }; -#ifdef ENABLE_MAPS -static const map TimeMarching_Map = CCreateMap -("NO", STEADY) -("TIME_STEPPING", TIME_STEPPING) -("DUAL_TIME_STEPPING-1ST_ORDER", DT_STEPPING_1ST) -("DUAL_TIME_STEPPING-2ND_ORDER", DT_STEPPING_2ND) -("HARMONIC_BALANCE", HARMONIC_BALANCE) -("ROTATIONAL_FRAME", ROTATIONAL_FRAME); -#endif +static const MapType TimeMarching_Map = { + MakePair("NO", STEADY) + MakePair("TIME_STEPPING", TIME_STEPPING) + MakePair("DUAL_TIME_STEPPING-1ST_ORDER", DT_STEPPING_1ST) + MakePair("DUAL_TIME_STEPPING-2ND_ORDER", DT_STEPPING_2ND) + MakePair("HARMONIC_BALANCE", HARMONIC_BALANCE) + MakePair("ROTATIONAL_FRAME", ROTATIONAL_FRAME) +}; /*! * \brief types of criteria to determine when the solution is converged */ enum ENUM_CONVERGE_CRIT { - CAUCHY = 1, /*!< \brief Cauchy criteria to establish the convergence of the code. */ - RESIDUAL = 2 /*!< \brief Residual criteria to establish the convergence of the code. */ + CAUCHY = 1, /*!< \brief Cauchy criteria to establish the convergence of the code. */ + RESIDUAL = 2 /*!< \brief Residual criteria to establish the convergence of the code. */ +}; +static const MapType Converge_Crit_Map = { + MakePair("CAUCHY", CAUCHY) + MakePair("RESIDUAL", RESIDUAL) }; -#ifdef ENABLE_MAPS -static const map Converge_Crit_Map = CCreateMap -("CAUCHY", CAUCHY) -("RESIDUAL", RESIDUAL); -#endif /*! * \brief types of element stiffnesses imposed for FEA mesh deformation */ enum ENUM_DEFORM_STIFFNESS { - CONSTANT_STIFFNESS = 0, /*!< \brief Impose a constant stiffness for each element (steel). */ - INVERSE_VOLUME = 1, /*!< \brief Impose a stiffness for each element that is inversely proportional to cell volume. */ - SOLID_WALL_DISTANCE = 2 /*!< \brief Impose a stiffness for each element that is proportional to the distance from the solid surface. */ + CONSTANT_STIFFNESS = 0, /*!< \brief Impose a constant stiffness for each element (steel). */ + INVERSE_VOLUME = 1, /*!< \brief Impose a stiffness for each element that is inversely proportional to cell volume. */ + SOLID_WALL_DISTANCE = 2 /*!< \brief Impose a stiffness for each element that is proportional to the distance from the solid surface. */ +}; +static const MapType Deform_Stiffness_Map = { + MakePair("CONSTANT_STIFFNESS", CONSTANT_STIFFNESS) + MakePair("INVERSE_VOLUME", INVERSE_VOLUME) + MakePair("WALL_DISTANCE", SOLID_WALL_DISTANCE) }; -#ifdef ENABLE_MAPS -static const map Deform_Stiffness_Map = CCreateMap -("CONSTANT_STIFFNESS", CONSTANT_STIFFNESS) -("INVERSE_VOLUME", INVERSE_VOLUME) -("WALL_DISTANCE", SOLID_WALL_DISTANCE); -#endif /*! * \brief The direct differentation variables. @@ -2065,25 +1937,24 @@ enum ENUM_DIRECTDIFF_VAR { D_RHO_DL = 14, /*!< \brief Derivative w.r.t. the density for dead loads */ D_EFIELD = 15 /*!< \brief Derivative w.r.t. the electric field */ }; -#ifdef ENABLE_MAPS -static const map DirectDiff_Var_Map = CCreateMap -("NONE", NO_DERIVATIVE) -("MACH", D_MACH) -("AOA", D_AOA) -("PRESSURE", D_PRESSURE) -("TEMPERATURE", D_TEMPERATURE) -("DENSITY", D_DENSITY) -("TURB2LAM", D_TURB2LAM) -("SIDESLIP", D_SIDESLIP) -("VISCOSITY", D_VISCOSITY) -("REYNOLDS", D_REYNOLDS) -("DESIGN_VARIABLES", D_DESIGN) -("YOUNG_MODULUS", D_YOUNG) -("POISSON_RATIO", D_POISSON) -("STRUCTURAL_DENSITY", D_RHO) -("STRUCTURAL_DEAD_LOAD", D_RHO_DL) -("ELECTRIC_FIELD", D_EFIELD); -#endif +static const MapType DirectDiff_Var_Map = { + MakePair("NONE", NO_DERIVATIVE) + MakePair("MACH", D_MACH) + MakePair("AOA", D_AOA) + MakePair("PRESSURE", D_PRESSURE) + MakePair("TEMPERATURE", D_TEMPERATURE) + MakePair("DENSITY", D_DENSITY) + MakePair("TURB2LAM", D_TURB2LAM) + MakePair("SIDESLIP", D_SIDESLIP) + MakePair("VISCOSITY", D_VISCOSITY) + MakePair("REYNOLDS", D_REYNOLDS) + MakePair("DESIGN_VARIABLES", D_DESIGN) + MakePair("YOUNG_MODULUS", D_YOUNG) + MakePair("POISSON_RATIO", D_POISSON) + MakePair("STRUCTURAL_DENSITY", D_RHO) + MakePair("STRUCTURAL_DEAD_LOAD", D_RHO_DL) + MakePair("ELECTRIC_FIELD", D_EFIELD) +}; enum ENUM_RECORDING { @@ -2102,27 +1973,25 @@ enum ENUM_RECORDING { * \brief types of schemes for dynamic structural computations */ enum ENUM_DYNAMIC { - STATIC = 0, /*!< \brief A static structural computation. */ - DYNAMIC = 1 /*!< \brief Use a time stepping strategy for dynamic computations. */ + STATIC = 0, /*!< \brief A static structural computation. */ + DYNAMIC = 1 /*!< \brief Use a time stepping strategy for dynamic computations. */ +}; +static const MapType Dynamic_Map = { + MakePair("NO", STATIC) + MakePair("YES", DYNAMIC) }; -#ifdef ENABLE_MAPS -static const map Dynamic_Map = CCreateMap -("NO", STATIC) -("YES", DYNAMIC); -#endif /*! * \brief types of input file formats */ enum ENUM_INPUT_REF { - SU2_REF = 1, /*!< \brief SU2 input format (from a restart). */ - CUSTOM_REF = 2 /*!< \brief CGNS input format for the computational grid. */ + SU2_REF = 1, /*!< \brief SU2 input format (from a restart). */ + CUSTOM_REF = 2 /*!< \brief CGNS input format for the computational grid. */ +}; +static const MapType Input_Ref_Map = { + MakePair("SU2", SU2_REF) + MakePair("CUSTOM", CUSTOM_REF) }; -#ifdef ENABLE_MAPS -static const map Input_Ref_Map = CCreateMap -("SU2", SU2_REF) -("CUSTOM", CUSTOM_REF); -#endif /*! * \brief Vertex-based quantities exchanged during periodic marker communications. @@ -2192,12 +2061,11 @@ enum COMM_LEVEL { COMM_MINIMAL = 1, /*!< \brief Perform only the minimal set of MPI communications for correctness. Disables many console and output comms. */ COMM_FULL = 2 /*!< \brief Perform all MPI communications. */ }; -#ifdef ENABLE_MAPS -static const map Comm_Map = CCreateMap -("NONE", COMM_NONE) -("MINIMAL", COMM_MINIMAL) -("FULL", COMM_FULL); -#endif +static const MapType Comm_Map = { + MakePair("NONE", COMM_NONE) + MakePair("MINIMAL", COMM_MINIMAL) + MakePair("FULL", COMM_FULL) +}; /* * \brief types of filter kernels, initially intended for structural topology optimization applications @@ -2209,14 +2077,13 @@ enum ENUM_FILTER_KERNEL { DILATE_MORPH_FILTER = 3, /*!< \brief Continuous version of the dilate morphology operator [Sigmund 2007]. */ ERODE_MORPH_FILTER = 4, /*!< \brief Continuous version of the erode morphology operator [Sigmund 2007].*/ }; -#ifdef ENABLE_MAPS -static const map Filter_Kernel_Map = CCreateMap -("CONSTANT", CONSTANT_WEIGHT_FILTER) -("CONICAL" , CONICAL_WEIGHT_FILTER) -("GAUSSIAN", GAUSSIAN_WEIGHT_FILTER) -("DILATE" , DILATE_MORPH_FILTER) -("ERODE" , ERODE_MORPH_FILTER); -#endif +static const MapType Filter_Kernel_Map = { + MakePair("CONSTANT", CONSTANT_WEIGHT_FILTER) + MakePair("CONICAL" , CONICAL_WEIGHT_FILTER) + MakePair("GAUSSIAN", GAUSSIAN_WEIGHT_FILTER) + MakePair("DILATE" , DILATE_MORPH_FILTER) + MakePair("ERODE" , ERODE_MORPH_FILTER) +}; /*! * \brief types of projection function, initially intended for structural topology optimization applications @@ -2226,12 +2093,11 @@ enum ENUM_PROJECTION_FUNCTION { HEAVISIDE_UP = 1, /*!< \brief Project values towards 1. */ HEAVISIDE_DOWN = 2, /*!< \brief Project values towards 0. */ }; -#ifdef ENABLE_MAPS -static const map Projection_Function_Map = CCreateMap -("NO_PROJECTION" , NO_PROJECTION) -("HEAVISIDE_UP" , HEAVISIDE_UP) -("HEAVISIDE_DOWN", HEAVISIDE_DOWN); -#endif +static const MapType Projection_Function_Map = { + MakePair("NO_PROJECTION" , NO_PROJECTION) + MakePair("HEAVISIDE_UP" , HEAVISIDE_UP) + MakePair("HEAVISIDE_DOWN", HEAVISIDE_DOWN) +}; /*! * \brief the different validation solution @@ -2251,23 +2117,23 @@ enum ENUM_VERIFICATION_SOLUTIONS { MMS_INC_NS = 66, /*!< \brief Manufactured solution of the laminar incompressible Navier Stokes equations. */ USER_DEFINED_SOLUTION = 99, /*!< \brief User defined solution. */ }; -#ifdef ENABLE_MAPS -static const map Verification_Solution_Map = CCreateMap -("NO_VERIFICATION_SOLUTION", NO_VERIFICATION_SOLUTION) -("INVISCID_VORTEX", INVISCID_VORTEX) -("RINGLEB", RINGLEB) -("NS_UNIT_QUAD", NS_UNIT_QUAD) -("TAYLOR_GREEN_VORTEX", TAYLOR_GREEN_VORTEX) -("INC_TAYLOR_GREEN_VORTEX", INC_TAYLOR_GREEN_VORTEX) -("MMS_NS_UNIT_QUAD", MMS_NS_UNIT_QUAD) -("MMS_NS_UNIT_QUAD_WALL_BC", MMS_NS_UNIT_QUAD_WALL_BC) -("MMS_NS_TWO_HALF_CIRCLES", MMS_NS_TWO_HALF_CIRCLES) -("MMS_NS_TWO_HALF_SPHERES", MMS_NS_TWO_HALF_SPHERES) -("MMS_INC_EULER", MMS_INC_EULER) -("MMS_INC_NS", MMS_INC_NS) -("USER_DEFINED_SOLUTION", USER_DEFINED_SOLUTION); -#endif - +static const MapType Verification_Solution_Map = { + MakePair("NO_VERIFICATION_SOLUTION", NO_VERIFICATION_SOLUTION) + MakePair("INVISCID_VORTEX", INVISCID_VORTEX) + MakePair("RINGLEB", RINGLEB) + MakePair("NS_UNIT_QUAD", NS_UNIT_QUAD) + MakePair("TAYLOR_GREEN_VORTEX", TAYLOR_GREEN_VORTEX) + MakePair("INC_TAYLOR_GREEN_VORTEX", INC_TAYLOR_GREEN_VORTEX) + MakePair("MMS_NS_UNIT_QUAD", MMS_NS_UNIT_QUAD) + MakePair("MMS_NS_UNIT_QUAD_WALL_BC", MMS_NS_UNIT_QUAD_WALL_BC) + MakePair("MMS_NS_TWO_HALF_CIRCLES", MMS_NS_TWO_HALF_CIRCLES) + MakePair("MMS_NS_TWO_HALF_SPHERES", MMS_NS_TWO_HALF_SPHERES) + MakePair("MMS_INC_EULER", MMS_INC_EULER) + MakePair("MMS_INC_NS", MMS_INC_NS) + MakePair("USER_DEFINED_SOLUTION", USER_DEFINED_SOLUTION) +}; + +#undef MakePair /* END_CONFIG_ENUMS */ class COptionBase { @@ -2304,2126 +2170,5 @@ class COptionBase { inline COptionBase::~COptionBase() {} #ifdef ENABLE_MAPS - -template -class COptionEnum : public COptionBase { - - map m; - unsigned short & field; // Reference to the feildname - Tenum def; // Default value - string name; // identifier for the option - -public: - COptionEnum(string option_field_name, const map m, unsigned short & option_field, Tenum default_value) : field(option_field) { - this->m = m; - this->def = default_value; - this->name = option_field_name; - } - - ~COptionEnum() {}; - string SetValue(vector option_value) { - COptionBase::SetValue(option_value); - // Check if there is more than one string - string out = optionCheckMultipleValues(option_value, "enum", this->name); - if (out.compare("") != 0) { - return out; - } - - // Check to see if the enum value is in the map - if (this->m.find(option_value[0]) == m.end()) { - string str; - str.append(this->name); - str.append(": invalid option value "); - str.append(option_value[0]); - str.append(". Check current SU2 options in config_template.cfg."); - return str; - } - // If it is there, set the option value - Tenum val = this->m[option_value[0]]; - this->field = val; - return ""; - } - - void SetDefault() { - this->field = this->def; - } -}; - -class COptionDouble : public COptionBase { - su2double & field; // Reference to the fieldname - su2double def; // Default value - string name; // identifier for the option - -public: - COptionDouble(string option_field_name, su2double & option_field, su2double default_value) : field(option_field) { - this->def = default_value; - this->name = option_field_name; - } - - ~COptionDouble() {}; - string SetValue(vector option_value) { - COptionBase::SetValue(option_value); - // check if there is more than one value - string out = optionCheckMultipleValues(option_value, "su2double", this->name); - if (out.compare("") != 0) { - return out; - } - istringstream is(option_value[0]); - su2double val; - if (is >> val) { - this->field = val; - return ""; - } - return badValue(option_value, "su2double", this->name); - } - void SetDefault() { - this->field = this->def; - } -}; - -class COptionString : public COptionBase { - string & field; // Reference to the fieldname - string def; // Default value - string name; // identifier for the option - -public: - COptionString(string option_field_name, string & option_field, string default_value) : field(option_field) { - this->def = default_value; - this->name = option_field_name; - } - - ~COptionString() {}; - string SetValue(vector option_value) { - COptionBase::SetValue(option_value); - // check if there is more than one value - string out = optionCheckMultipleValues(option_value, "su2double", this->name); - if (out.compare("") != 0) { - return out; - } - this->field.assign(option_value[0]); - return ""; - } - void SetDefault() { - this->field = this->def; - } -}; - -class COptionInt : public COptionBase { - int & field; // Reference to the feildname - int def; // Default value - string name; // identifier for the option - -public: - COptionInt(string option_field_name, int & option_field, int default_value) : field(option_field) { - this->def = default_value; - this->name = option_field_name; - } - - ~COptionInt() {}; - string SetValue(vector option_value) { - COptionBase::SetValue(option_value); - string out = optionCheckMultipleValues(option_value, "int", this->name); - if (out.compare("") != 0) { - return out; - } - istringstream is(option_value[0]); - int val; - if (is >> val) { - this->field = val; - return ""; - } - return badValue(option_value, "int", this->name); - } - void SetDefault() { - this->field = this->def; - } -}; - -class COptionULong : public COptionBase { - unsigned long & field; // Reference to the feildname - unsigned long def; // Default value - string name; // identifier for the option - -public: - COptionULong(string option_field_name, unsigned long & option_field, unsigned long default_value) : field(option_field) { - this->def = default_value; - this->name = option_field_name; - } - - ~COptionULong() {}; - string SetValue(vector option_value) { - COptionBase::SetValue(option_value); - string out = optionCheckMultipleValues(option_value, "unsigned long", this->name); - if (out.compare("") != 0) { - return out; - } - istringstream is(option_value[0]); - unsigned long val; - if (is >> val) { - this->field = val; - return ""; - } - return badValue(option_value, "unsigned long", this->name); - } - void SetDefault() { - this->field = this->def; - } -}; - -class COptionUShort : public COptionBase { - unsigned short & field; // Reference to the feildname - unsigned short def; // Default value - string name; // identifier for the option - -public: - COptionUShort(string option_field_name, unsigned short & option_field, unsigned short default_value) : field(option_field) { - this->def = default_value; - this->name = option_field_name; - } - - ~COptionUShort() {}; - string SetValue(vector option_value) { - COptionBase::SetValue(option_value); - string out = optionCheckMultipleValues(option_value, "unsigned short", this->name); - if (out.compare("") != 0) { - return out; - } - istringstream is(option_value[0]); - unsigned short val; - if (is >> val) { - this->field = val; - return ""; - } - return badValue(option_value, "unsigned short", this->name); - } - void SetDefault() { - this->field = this->def; - } -}; - -class COptionLong : public COptionBase { - long & field; // Reference to the feildname - long def; // Default value - string name; // identifier for the option - -public: - COptionLong(string option_field_name, long & option_field, long default_value) : field(option_field) { - this->def = default_value; - this->name = option_field_name; - } - - ~COptionLong() {}; - string SetValue(vector option_value) { - COptionBase::SetValue(option_value); - string out = optionCheckMultipleValues(option_value, "long", this->name); - if (out.compare("") != 0) { - return out; - } - istringstream is(option_value[0]); - long val; - if (is >> val) { - this->field = val; - return ""; - } - return badValue(option_value, "long", this->name); - } - void SetDefault() { - this->field = this->def; - } -}; - -class COptionBool : public COptionBase { - bool & field; // Reference to the feildname - bool def; // Default value - string name; // identifier for the option - -public: - COptionBool(string option_field_name, bool & option_field, bool default_value) : field(option_field) { - this->def = default_value; - this->name = option_field_name; - } - - ~COptionBool() {}; - string SetValue(vector option_value) { - COptionBase::SetValue(option_value); - // check if there is more than one value - string out = optionCheckMultipleValues(option_value, "bool", this->name); - if (out.compare("") != 0) { - return out; - } - if (option_value[0].compare("YES") == 0) { - this->field = true; - return ""; - } - if (option_value[0].compare("NO") == 0) { - this->field = false; - return ""; - } - return badValue(option_value, "bool", this->name); - } - void SetDefault() { - this->field = this->def; - } -}; - -template -class COptionEnumList : public COptionBase { - - map m; - unsigned short * & field; // Reference to the feildname - string name; // identifier for the option - unsigned short & size; - -public: - COptionEnumList(string option_field_name, const map m, unsigned short * & option_field, unsigned short & list_size) : field(option_field) , size(list_size) { - this->m = m; - this->name = option_field_name; - } - - ~COptionEnumList() {}; - string SetValue(vector option_value) { - COptionBase::SetValue(option_value); - if (option_value.size() == 1 && option_value[0].compare("NONE") == 0) { - this->size = 0; - return ""; - } - // size is the length of the option list - this->size = option_value.size(); - unsigned short * enums = new unsigned short[size]; - for (int i = 0; i < this->size; i++) { - // Check to see if the enum value is in the map - if (this->m.find(option_value[i]) == m.end()) { - string str; - str.append(this->name); - str.append(": invalid option value "); - str.append(option_value[i]); - str.append(". Check current SU2 options in config_template.cfg."); - return str; - } - // If it is there, set the option value - enums[i] = this->m[option_value[i]]; - } - this->field = enums; - return ""; - } - - void SetDefault() { - // No default to set - size = 0; - } -}; - -class COptionDoubleArray : public COptionBase { - su2double * & field; // Reference to the feildname - string name; // identifier for the option - const int size; - su2double * def; - su2double * vals; - su2double * default_value; - -public: - COptionDoubleArray(string option_field_name, const int list_size, su2double * & option_field, su2double * default_value) : field(option_field), size(list_size) { - this->name = option_field_name; - this->default_value = default_value; - def = NULL; - vals = NULL; - } - - ~COptionDoubleArray() { - if(def != NULL) delete [] def; - if(vals != NULL) delete [] vals; - }; - string SetValue(vector option_value) { - COptionBase::SetValue(option_value); - // Check that the size is correct - if (option_value.size() != (unsigned long)this->size) { - string newstring; - newstring.append(this->name); - newstring.append(": wrong number of arguments: "); - stringstream ss; - ss << this->size; - newstring.append(ss.str()); - newstring.append(" expected, "); - stringstream ss2; - ss2 << option_value.size(); - newstring.append(ss2.str()); - newstring.append(" found"); - return newstring; - } - vals = new su2double[this->size]; - for (int i = 0; i < this->size; i++) { - istringstream is(option_value[i]); - su2double val; - if (!(is >> val)) { - delete [] vals; - return badValue(option_value, "su2double array", this->name); - } - vals[i] = val; - } - this->field = vals; - return ""; - } - - void SetDefault() { - def = new su2double [size]; - for (int i = 0; i < size; i++) { - def[i] = default_value[i]; - } - this->field = def; - } -}; - -class COptionDoubleList : public COptionBase { - su2double * & field; // Reference to the feildname - string name; // identifier for the option - unsigned short & size; - -public: - COptionDoubleList(string option_field_name, unsigned short & list_size, su2double * & option_field) : field(option_field), size(list_size) { - this->name = option_field_name; - } - - ~COptionDoubleList() {}; - string SetValue(vector option_value) { - COptionBase::SetValue(option_value); - // The size is the length of option_value - unsigned short option_size = option_value.size(); - if (option_size == 1 && option_value[0].compare("NONE") == 0) { - // No options - this->size = 0; - return ""; - } - - this->size = option_size; - - // Parse all of the options - su2double * vals = new su2double[option_size]; - for (unsigned long i = 0; i < option_size; i++) { - istringstream is(option_value[i]); - su2double val; - if (!(is >> val)) { - delete [] vals; - return badValue(option_value, "su2double list", this->name); - } - vals[i] = val; - } - this->field = vals; - return ""; - } - - void SetDefault() { - this->size = 0; // There is no default value for list - } -}; - -class COptionShortList : public COptionBase { - short * & field; // Reference to the feildname - string name; // identifier for the option - unsigned short & size; - -public: - COptionShortList(string option_field_name, unsigned short & list_size, short * & option_field) : field(option_field), size(list_size) { - this->name = option_field_name; - } - - ~COptionShortList() {}; - string SetValue(vector option_value) { - COptionBase::SetValue(option_value); - // The size is the length of option_value - unsigned short option_size = option_value.size(); - if (option_size == 1 && option_value[0].compare("NONE") == 0) { - // No options - this->size = 0; - return ""; - } - this->size = option_size; - - // Parse all of the options - short * vals = new short[option_size]; - for (unsigned long i = 0; i < option_size; i++) { - istringstream is(option_value[i]); - unsigned short val; - if (!(is >> val)) { - delete [] vals; - return badValue(option_value, "short", this->name); - } - vals[i] = val; - } - this->field = vals; - return ""; - } - - void SetDefault() { - this->size = 0; // There is no default value for list - } -}; - -class COptionUShortList : public COptionBase { - unsigned short * & field; // Reference to the feildname - string name; // identifier for the option - unsigned short & size; - -public: - COptionUShortList(string option_field_name, unsigned short & list_size, unsigned short * & option_field) : field(option_field), size(list_size) { - this->name = option_field_name; - } - - ~COptionUShortList() {}; - string SetValue(vector option_value) { - COptionBase::SetValue(option_value); - // The size is the length of option_value - unsigned short option_size = option_value.size(); - if (option_size == 1 && option_value[0].compare("NONE") == 0) { - // No options - this->size = 0; - return ""; - } - this->size = option_size; - - // Parse all of the options - unsigned short * vals = new unsigned short[option_size]; - for (unsigned long i = 0; i < option_size; i++) { - istringstream is(option_value[i]); - unsigned short val; - if (!(is >> val)) { - delete [] vals; - return badValue(option_value, "unsigned short", this->name); - } - vals[i] = val; - } - this->field = vals; - return ""; - } - - void SetDefault() { - this->size = 0; // There is no default value for list - } -}; - -class COptionStringList : public COptionBase { - string * & field; // Reference to the feildname - string name; // identifier for the option - unsigned short & size; - -public: - COptionStringList(string option_field_name, unsigned short & list_size, string * & option_field) : field(option_field), size(list_size) { - this->name = option_field_name; - } - - ~COptionStringList() {}; - string SetValue(vector option_value) { - COptionBase::SetValue(option_value); - // The size is the length of option_value - unsigned short option_size = option_value.size(); - if (option_size == 1 && option_value[0].compare("NONE") == 0) { - this->size = 0; - return ""; - } - this->size = option_size; - - // Parse all of the options - string * vals = new string[option_size]; - for (unsigned long i = 0; i < option_size; i++) { - vals[i].assign(option_value[i]); - } - this->field = vals; - return ""; - } - - void SetDefault() { - this->size = 0; // There is no default value for list - } -}; - -class COptionConvect : public COptionBase { - string name; // identifier for the option - unsigned short & space; - unsigned short & centered; - unsigned short & upwind; - -public: - COptionConvect(string option_field_name, unsigned short & space_field, unsigned short & centered_field, unsigned short & upwind_field) - : name(option_field_name), space(space_field), centered(centered_field), upwind(upwind_field) { } - - string SetValue(vector option_value) { - COptionBase::SetValue(option_value); - - string out = optionCheckMultipleValues(option_value, "unsigned short", this->name); - if (out.compare("") != 0) { - return out; - } - - if (Centered_Map.count(option_value[0])) { - this->space = Space_Map.find("SPACE_CENTERED")->second; - this->centered = Centered_Map.find(option_value[0])->second; - this->upwind = NO_UPWIND; - return ""; - } - if (Upwind_Map.count(option_value[0])) { - this->space = Space_Map.find("SPACE_UPWIND")->second; - this->upwind = Upwind_Map.find(option_value[0])->second; - this->centered = NO_CENTERED; - return ""; - } - // Make them defined in case something weird happens - SetDefault(); - return badValue(option_value, "convect", this->name); - - } - - void SetDefault() { - this->centered = NO_CENTERED; - this->upwind = NO_UPWIND; - this->space = NO_CONVECTIVE; - } -}; - -class COptionFEMConvect : public COptionBase{ - string name; // identifier for the option - unsigned short & space; - unsigned short & fem; - -public: - COptionFEMConvect(string option_field_name, unsigned short & space_field, unsigned short & fem_field) : space(space_field), fem(fem_field) { - this->name = option_field_name; - } - - ~COptionFEMConvect() {}; - string SetValue(vector option_value) { - COptionBase::SetValue(option_value); - - string out = optionCheckMultipleValues(option_value, "unsigned short", this->name); - if (out.compare("") != 0) { - return out; - } - - if (FEM_Map.count(option_value[0])) { - this->space = Space_Map.find("FINITE_ELEMENT")->second; - this->fem = FEM_Map.find(option_value[0])->second; - return ""; - } - - // Make them defined in case something weird happens - this->fem = NO_FEM; - return badValue(option_value, "convect", this->name); - - } - - void SetDefault() { - this->fem = NO_FEM; - } -}; - -class COptionMathProblem : public COptionBase { - string name; // identifier for the option - bool & cont_adjoint; - bool cont_adjoint_def; - bool & disc_adjoint; - bool disc_adjoint_def; - bool & restart; - bool restart_def; - -public: - COptionMathProblem(string option_field_name, bool & cont_adjoint_field, bool cont_adjoint_default, bool & disc_adjoint_field, bool disc_adjoint_default, bool & restart_field, bool restart_default) : cont_adjoint(cont_adjoint_field), disc_adjoint(disc_adjoint_field), restart(restart_field) { - this->name = option_field_name; - this->cont_adjoint_def = cont_adjoint_default; - this->disc_adjoint_def = disc_adjoint_default; - this->restart_def = restart_default; - } - - ~COptionMathProblem() {}; - string SetValue(vector option_value) { - COptionBase::SetValue(option_value); - string out = optionCheckMultipleValues(option_value, "unsigned short", this->name); - if (out.compare("") != 0) { - return out; - } - if (option_value[0] == "ADJOINT") { - return badValue(option_value, "math problem (try CONTINUOUS_ADJOINT)", this->name); - } - if (Math_Problem_Map.find(option_value[0]) == Math_Problem_Map.end()) { - return badValue(option_value, "math problem", this->name); - } - if (option_value[0] == "DIRECT") { - this->cont_adjoint = false; - this->disc_adjoint = false; - this->restart = false; - return ""; - } - if (option_value[0] == "CONTINUOUS_ADJOINT") { - this->cont_adjoint= true; - this->disc_adjoint = false; - this->restart= true; - return ""; - } - if (option_value[0] == "DISCRETE_ADJOINT") { - this->disc_adjoint = true; - this->cont_adjoint= false; - this->restart = true; - return ""; - } - return "option in math problem map not considered in constructor"; - } - - void SetDefault() { - this->cont_adjoint = this->cont_adjoint_def; - this->disc_adjoint = this->disc_adjoint_def; - this->restart = this->restart_def; - } - -}; - -class COptionDVParam : public COptionBase { - string name; // identifier for the option - unsigned short & nDV; - su2double ** & paramDV; - string * & FFDTag; - unsigned short* & design_variable; - -public: - COptionDVParam(string option_field_name, unsigned short & nDV_field, su2double** & paramDV_field, string* & FFDTag_field, unsigned short * & design_variable_field) : nDV(nDV_field), paramDV(paramDV_field), FFDTag(FFDTag_field), design_variable(design_variable_field) { - this->name = option_field_name; - } - - ~COptionDVParam() {}; - - string SetValue(vector option_value) { - COptionBase::SetValue(option_value); - if ((option_value.size() == 1) && (option_value[0].compare("NONE") == 0)) { - this->nDV = 0; - return ""; - } - - // Cannot have ; at the beginning or the end - if (option_value[0].compare(";") == 0) { - string newstring; - newstring.append(this->name); - newstring.append(": may not have beginning semicolon"); - return newstring; - } - if (option_value[option_value.size()-1].compare(";") == 0) { - string newstring; - newstring.append(this->name); - newstring.append(": may not have ending semicolon"); - return newstring; - } - - - // use the ";" token to determine the number of design variables - // This works because semicolon is not one of the delimiters in tokenize string - this->nDV = 0; - //unsigned int num_semi = 0; - for (unsigned int i = 0; i < static_cast(option_value.size()); i++) { - if (option_value[i].compare(";") == 0) { - this->nDV++; - // num_semi++; - } - } - - // One more design variable than semicolon - this->nDV++; - - if ( (this->nDV > 0) && (this->design_variable == NULL) ) { - string newstring; - newstring.append(this->name); - newstring.append(": Design_Variable array has not been allocated. Check that DV_KIND appears before DV_PARAM in configuration file."); - return newstring; - } - - this->paramDV = new su2double*[this->nDV]; - for (unsigned short iDV = 0; iDV < this->nDV; iDV++) { - this->paramDV[iDV] = new su2double[MAX_PARAMETERS]; - } - - this->FFDTag = new string[this->nDV]; - - vector nParamDV(nDV, 0); - unsigned short totalnParamDV = 0; - stringstream ss; - unsigned int i = 0; - - for (unsigned short iDV = 0; iDV < this->nDV; iDV++) { - switch (this->design_variable[iDV]) { - case NO_DEFORMATION: nParamDV[iDV] = 0; break; - case FFD_SETTING: nParamDV[iDV] = 0; break; - case FFD_CONTROL_POINT_2D: nParamDV[iDV] = 5; break; - case FFD_CAMBER_2D: nParamDV[iDV] = 2; break; - case FFD_THICKNESS_2D: nParamDV[iDV] = 2; break; - case FFD_TWIST_2D: nParamDV[iDV] = 3; break; - case HICKS_HENNE: nParamDV[iDV] = 2; break; - case SURFACE_BUMP: nParamDV[iDV] = 3; break; - case CST: nParamDV[iDV] = 3; break; - case ANGLE_OF_ATTACK: nParamDV[iDV] = 1; break; - case SCALE: nParamDV[iDV] = 0; break; - case TRANSLATION: nParamDV[iDV] = 3; break; - case ROTATION: nParamDV[iDV] = 6; break; - case NACA_4DIGITS: nParamDV[iDV] = 3; break; - case PARABOLIC: nParamDV[iDV] = 2; break; - case AIRFOIL: nParamDV[iDV] = 2; break; - case FFD_CONTROL_POINT: nParamDV[iDV] = 7; break; - case FFD_NACELLE: nParamDV[iDV] = 6; break; - case FFD_GULL: nParamDV[iDV] = 2; break; - case FFD_TWIST: nParamDV[iDV] = 8; break; - case FFD_ROTATION: nParamDV[iDV] = 7; break; - case FFD_CONTROL_SURFACE: nParamDV[iDV] = 7; break; - case FFD_CAMBER: nParamDV[iDV] = 3; break; - case FFD_THICKNESS: nParamDV[iDV] = 3; break; - case FFD_ANGLE_OF_ATTACK: nParamDV[iDV] = 2; break; - case SURFACE_FILE: nParamDV[iDV] = 0; break; - case DV_EFIELD: nParamDV[iDV] = 2; break; - case DV_YOUNG: nParamDV[iDV] = 0; break; - case DV_POISSON: nParamDV[iDV] = 0; break; - case DV_RHO: nParamDV[iDV] = 0; break; - case DV_RHO_DL: nParamDV[iDV] = 0; break; - case SCALE_GRID: nParamDV[iDV] = 0; break; - case TRANSLATE_GRID: nParamDV[iDV] = 3; break; - case ROTATE_GRID: nParamDV[iDV] = 6; break; - default : { - string newstring; - newstring.append(this->name); - newstring.append(": undefined design variable type found in configuration file."); - return newstring; - } - } - totalnParamDV += nParamDV[iDV]; - } - - if (totalnParamDV > option_value.size()){ - SU2_MPI::Error("Wrong number of arguments for DV_PARAM!", CURRENT_FUNCTION); - } - - for (unsigned short iDV = 0; iDV < this->nDV; iDV++) { - for (unsigned short iParamDV = 0; iParamDV < nParamDV[iDV]; iParamDV++) { - - ss << option_value[i] << " "; - - if ((iParamDV == 0) && - ((this->design_variable[iDV] == NO_DEFORMATION) || - (this->design_variable[iDV] == FFD_SETTING) || - (this->design_variable[iDV] == FFD_ANGLE_OF_ATTACK)|| - (this->design_variable[iDV] == FFD_CONTROL_POINT_2D) || - (this->design_variable[iDV] == FFD_CAMBER_2D) || - (this->design_variable[iDV] == FFD_TWIST_2D) || - (this->design_variable[iDV] == FFD_THICKNESS_2D) || - (this->design_variable[iDV] == FFD_CONTROL_POINT) || - (this->design_variable[iDV] == FFD_NACELLE) || - (this->design_variable[iDV] == FFD_GULL) || - (this->design_variable[iDV] == FFD_TWIST) || - (this->design_variable[iDV] == FFD_ROTATION) || - (this->design_variable[iDV] == FFD_CONTROL_SURFACE) || - (this->design_variable[iDV] == FFD_CAMBER) || - (this->design_variable[iDV] == FFD_THICKNESS))) { - ss >> this->FFDTag[iDV]; - this->paramDV[iDV][iParamDV] = 0; - } - else - ss >> this->paramDV[iDV][iParamDV]; - - i++; - } - if (iDV < (this->nDV-1)) { - if (option_value[i].compare(";") != 0) { - string newstring; - newstring.append(this->name); - newstring.append(": a design variable in the configuration file has the wrong number of parameters"); - return newstring; - } - i++; - } - } - - // Need to return something... - return ""; - } - - void SetDefault() { - this->nDV = 0; - this->paramDV = NULL; - this->FFDTag = NULL; - // Don't mess with the Design_Variable because it's an input, not modified - } -}; - -class COptionDVValue : public COptionBase { - string name; // identifier for the option - unsigned short* & nDV_Value; - su2double ** & valueDV; - unsigned short & nDV; - su2double ** & paramDV; - unsigned short* & design_variable; - -public: - COptionDVValue(string option_field_name, unsigned short* & nDVValue_field, su2double** & valueDV_field, unsigned short & nDV_field, su2double** & paramDV_field, unsigned short * & design_variable_field) : nDV_Value(nDVValue_field), valueDV(valueDV_field), nDV(nDV_field), paramDV(paramDV_field), design_variable(design_variable_field) { - this->name = option_field_name; - } - - ~COptionDVValue() {}; - - string SetValue(vector option_value) { - COptionBase::SetValue(option_value); - if ((option_value.size() == 1) && (option_value[0].compare("NONE") == 0)) { - this->nDV_Value = NULL; - return ""; - } - - if ( (this->nDV > 0) && (this->design_variable == NULL) ) { - string newstring; - newstring.append(this->name); - newstring.append(": Design_Variable array has not been allocated. Check that DV_KIND appears before DV_VALUE in configuration file."); - return newstring; - } - if ( (this->nDV > 0) && (this->paramDV == NULL) ) { - string newstring; - newstring.append(this->name); - newstring.append(": Design_Parameter array has not been allocated. Check that DV_PARAM appears before DV_VALUE in configuration file."); - return newstring; - } - - this->valueDV = new su2double*[this->nDV]; - this->nDV_Value = new unsigned short[this->nDV]; - - for (unsigned short iDV = 0; iDV < this->nDV; iDV++) { - this->valueDV[iDV] = new su2double[3]; - } - - unsigned short nValueDV = 0; - unsigned short totalnValueDV = 0; - stringstream ss; - unsigned int i = 0; - for (unsigned short iDV = 0; iDV < this->nDV; iDV++) { - switch (this->design_variable[iDV]) { - case FFD_CONTROL_POINT: - if((this->paramDV[iDV][4] == 0) && - (this->paramDV[iDV][5] == 0) && - (this->paramDV[iDV][6] == 0)) { - nValueDV = 3; - } else { - nValueDV = 1; - } - break; - case FFD_CONTROL_POINT_2D: - if((this->paramDV[iDV][3] == 0) && - (this->paramDV[iDV][4] == 0)) { - nValueDV = 2; - } else { - nValueDV = 1; - } - break; - default : - nValueDV = 1; - } - - this->nDV_Value[iDV] = nValueDV; - - totalnValueDV += nValueDV; - - for (unsigned short iValueDV = 0; iValueDV < nValueDV; iValueDV++) { - - if (i >= option_value.size()) { - string newstring; - newstring.append(this->name); - newstring.append(": DV_VALUE does not contain enough entries to match DV_KIND or DV_PARAM."); - return newstring; - } - - ss << option_value[i] << " "; - - ss >> this->valueDV[iDV][iValueDV]; - - i++; - } - } - - if (i != totalnValueDV) { - string newstring; - newstring.append(this->name); - newstring.append(": a design variable in the configuration file has the wrong number of values"); - return newstring; - } - - // Need to return something... - return ""; - } - - void SetDefault() { - this->nDV_Value = 0; - this->valueDV = NULL; - // Don't mess with the Design_Variable because it's an input, not modified - } -}; - -class COptionFFDDef : public COptionBase { - string name; - unsigned short & nFFD; - su2double ** & CoordFFD; - string * & FFDTag; - -public: - COptionFFDDef(string option_field_name, unsigned short & nFFD_field, su2double** & coordFFD_field, string* & FFDTag_field) : nFFD(nFFD_field), CoordFFD(coordFFD_field), FFDTag(FFDTag_field) { - this->name = option_field_name; - } - - ~COptionFFDDef() {}; - - string SetValue(vector option_value) { - COptionBase::SetValue(option_value); - if ((option_value.size() == 1) && (option_value[0].compare("NONE") == 0)) { - this->nFFD = 0; - return ""; - } - - // Cannot have ; at the beginning or the end - if (option_value[0].compare(";") == 0) { - string newstring; - newstring.append(this->name); - newstring.append(": may not have beginning semicolon"); - return newstring; - } - if (option_value[option_value.size()-1].compare(";") == 0) { - string newstring; - newstring.append(this->name); - newstring.append(": may not have ending semicolon"); - return newstring; - } - - - // use the ";" token to determine the number of design variables - // This works because semicolon is not one of the delimiters in tokenize string - this->nFFD = 0; - for (unsigned int i = 0; i < static_cast(option_value.size()); i++) { - if (option_value[i].compare(";") == 0) { - this->nFFD++; - } - } - - // One more design variable than semicolon - this->nFFD++; - - this->CoordFFD = new su2double*[this->nFFD]; - for (unsigned short iFFD = 0; iFFD < this->nFFD; iFFD++) { - this->CoordFFD[iFFD] = new su2double[25]; - } - - this->FFDTag = new string[this->nFFD]; - - unsigned short nCoordFFD = 0; - stringstream ss; - unsigned int i = 0; - - for (unsigned short iFFD = 0; iFFD < this->nFFD; iFFD++) { - - nCoordFFD = 25; - - for (unsigned short iCoordFFD = 0; iCoordFFD < nCoordFFD; iCoordFFD++) { - - ss << option_value[i] << " "; - - if (iCoordFFD == 0) ss >> this->FFDTag[iFFD]; - else ss >> this->CoordFFD[iFFD][iCoordFFD-1]; - - i++; - } - - if (iFFD < (this->nFFD-1)) { - if (option_value[i].compare(";") != 0) { - string newstring; - newstring.append(this->name); - newstring.append(": a FFD box in the configuration file has the wrong number of parameters"); - return newstring; - } - i++; - } - - } - - // Need to return something... - return ""; - } - - void SetDefault() { - this->nFFD = 0; - this->CoordFFD = NULL; - this->FFDTag = NULL; - } - -}; - -class COptionFFDDegree : public COptionBase { - string name; - unsigned short & nFFD; - unsigned short ** & DegreeFFD; - -public: - COptionFFDDegree(string option_field_name, unsigned short & nFFD_field, unsigned short** & degreeFFD_field) : nFFD(nFFD_field), DegreeFFD(degreeFFD_field) { - this->name = option_field_name; - } - - ~COptionFFDDegree() {}; - - string SetValue(vector option_value) { - COptionBase::SetValue(option_value); - if ((option_value.size() == 1) && (option_value[0].compare("NONE") == 0)) { - this->nFFD = 0; - return ""; - } - - // Cannot have ; at the beginning or the end - if (option_value[0].compare(";") == 0) { - string newstring; - newstring.append(this->name); - newstring.append(": may not have beginning semicolon"); - return newstring; - } - if (option_value[option_value.size()-1].compare(";") == 0) { - string newstring; - newstring.append(this->name); - newstring.append(": may not have ending semicolon"); - return newstring; - } - - - // use the ";" token to determine the number of design variables - // This works because semicolon is not one of the delimiters in tokenize string - this->nFFD = 0; - for (unsigned int i = 0; i < static_cast(option_value.size()); i++) { - if (option_value[i].compare(";") == 0) { - this->nFFD++; - } - } - - // One more design variable than semicolon - this->nFFD++; - - this->DegreeFFD = new unsigned short*[this->nFFD]; - for (unsigned short iFFD = 0; iFFD < this->nFFD; iFFD++) { - this->DegreeFFD[iFFD] = new unsigned short[3]; - } - - unsigned short nDegreeFFD = 0; - stringstream ss; - unsigned int i = 0; - - for (unsigned short iFFD = 0; iFFD < this->nFFD; iFFD++) { - - nDegreeFFD = 3; - - for (unsigned short iDegreeFFD = 0; iDegreeFFD < nDegreeFFD; iDegreeFFD++) { - ss << option_value[i] << " "; - ss >> this->DegreeFFD[iFFD][iDegreeFFD]; - i++; - } - - if (iFFD < (this->nFFD-1)) { - if (option_value[i].compare(";") != 0) { - string newstring; - newstring.append(this->name); - newstring.append(": a FFD degree in the configuration file has the wrong number of parameters"); - return newstring; - } - i++; - } - - } - - // Need to return something... - return ""; - } - - void SetDefault() { - this->nFFD = 0; - this->DegreeFFD = NULL; - } - -}; - -// Class where the option is represented by (String, su2double, string, su2double, ...) -class COptionStringDoubleList : public COptionBase { - string name; // identifier for the option - unsigned short & size; // how many strings are there (same as number of su2doubles) - - string * & s_f; // Reference to the string fields - su2double* & d_f; // reference to the su2double fields - -public: - COptionStringDoubleList(string option_field_name, unsigned short & list_size, string * & string_field, su2double* & double_field) : size(list_size), s_f(string_field), d_f(double_field) { - this->name = option_field_name; - } - - ~COptionStringDoubleList() {}; - string SetValue(vector option_value) { - COptionBase::SetValue(option_value); - // There must be an even number of entries (same number of strings and doubles - unsigned short totalVals = option_value.size(); - if ((totalVals % 2) != 0) { - if ((totalVals == 1) && (option_value[0].compare("NONE") == 0)) { - // It's okay to say its NONE - this->size = 0; - return ""; - } - string newstring; - newstring.append(this->name); - newstring.append(": must have an even number of entries"); - return newstring; - } - unsigned short nVals = totalVals / 2; - this->size = nVals; - this->s_f = new string[nVals]; - this->d_f = new su2double[nVals]; - - for (unsigned long i = 0; i < nVals; i++) { - this->s_f[i].assign(option_value[2*i]); // 2 because have su2double and string - istringstream is(option_value[2*i + 1]); - su2double val; - if (!(is >> val)) { - return badValue(option_value, "string su2double", this->name); - } - this->d_f[i] = val; - } - // Need to return something... - return ""; - } - - void SetDefault() { - this->size = 0; // There is no default value for list - } -}; - -class COptionInlet : public COptionBase { - string name; // identifier for the option - unsigned short & size; - string * & marker; - su2double * & ttotal; - su2double * & ptotal; - su2double ** & flowdir; - -public: - COptionInlet(string option_field_name, unsigned short & nMarker_Inlet, string* & Marker_Inlet, su2double* & Ttotal, su2double* & Ptotal, su2double** & FlowDir) : size(nMarker_Inlet), marker(Marker_Inlet), ttotal(Ttotal), ptotal(Ptotal), flowdir(FlowDir) { - this->name = option_field_name; - } - - ~COptionInlet() {}; - string SetValue(vector option_value) { - COptionBase::SetValue(option_value); - unsigned short totalVals = option_value.size(); - if ((totalVals == 1) && (option_value[0].compare("NONE") == 0)) { - this->size = 0; - this->marker = NULL; - this->ttotal = NULL; - this->ptotal = NULL; - this->flowdir = NULL; - return ""; - } - - if (totalVals % 6 != 0) { - string newstring; - newstring.append(this->name); - newstring.append(": must have a number of entries divisible by 6"); - this->size = 0; - this->marker = NULL; - this->ttotal = NULL; - this->ptotal = NULL; - this->flowdir = NULL; - return newstring; - } - - unsigned short nVals = totalVals / 6; - this->size = nVals; - this->marker = new string[nVals]; - this->ttotal = new su2double[nVals]; - this->ptotal = new su2double[nVals]; - this->flowdir = new su2double*[nVals]; - for (unsigned long i = 0; i < nVals; i++) { - this->flowdir[i] = new su2double[3]; - } - - for (unsigned long i = 0; i < nVals; i++) { - this->marker[i].assign(option_value[6*i]); - istringstream ss_1st(option_value[6*i + 1]); - if (!(ss_1st >> this->ttotal[i])) { - return badValue(option_value, "inlet", this->name); - } - istringstream ss_2nd(option_value[6*i + 2]); - if (!(ss_2nd >> this->ptotal[i])) { - return badValue(option_value, "inlet", this->name); - } - istringstream ss_3rd(option_value[6*i + 3]); - if (!(ss_3rd >> this->flowdir[i][0])) { - return badValue(option_value, "inlet", this->name); - } - istringstream ss_4th(option_value[6*i + 4]); - if (!(ss_4th >> this->flowdir[i][1])) { - return badValue(option_value, "inlet", this->name); - } - istringstream ss_5th(option_value[6*i + 5]); - if (!(ss_5th >> this->flowdir[i][2])) { - return badValue(option_value, "inlet", this->name); - } - } - - return ""; - } - - void SetDefault() { - this->marker = NULL; - this->ttotal = NULL; - this->ptotal = NULL; - this->flowdir = NULL; - this->size = 0; // There is no default value for list - } -}; - -template -class COptionRiemann : public COptionBase { - -protected: - map m; - string name; // identifier for the option - unsigned short & size; - string * & marker; - unsigned short* & field; // Reference to the field name - su2double * & var1; - su2double * & var2; - su2double ** & flowdir; - -public: - COptionRiemann(string option_field_name, unsigned short & nMarker_Riemann, string* & Marker_Riemann, unsigned short* & option_field, const map m, su2double* & var1, su2double* & var2, su2double** & FlowDir) : size(nMarker_Riemann), - marker(Marker_Riemann), field(option_field), var1(var1), var2(var2), flowdir(FlowDir) { - this->name = option_field_name; - this->m = m; - } - ~COptionRiemann() {}; - - string SetValue(vector option_value) { - COptionBase::SetValue(option_value); - unsigned short totalVals = option_value.size(); - if ((totalVals == 1) && (option_value[0].compare("NONE") == 0)) { - this->size = 0; - this->marker = NULL; - this->field = 0; - this->var1 = NULL; - this->var2 = NULL; - this->flowdir = NULL; - return ""; - } - - if (totalVals % 7 != 0) { - string newstring; - newstring.append(this->name); - newstring.append(": must have a number of entries divisible by 7"); - this->size = 0; - this->marker = NULL; - this->var1 = NULL; - this->var2 = NULL; - this->flowdir = NULL; - this->field = NULL; - return newstring; - } - - unsigned short nVals = totalVals / 7; - this->size = nVals; - this->marker = new string[nVals]; - this->var1 = new su2double[nVals]; - this->var2 = new su2double[nVals]; - this->flowdir = new su2double*[nVals]; - this->field = new unsigned short[nVals]; - - for (unsigned long i = 0; i < nVals; i++) { - this->flowdir[i] = new su2double[3]; - } - - for (unsigned long i = 0; i < nVals; i++) { - this->marker[i].assign(option_value[7*i]); - // Check to see if the enum value is in the map - if (this->m.find(option_value[7*i + 1]) == m.end()) { - string str; - str.append(this->name); - str.append(": invalid option value "); - str.append(option_value[0]); - str.append(". Check current SU2 options in config_template.cfg."); - return str; - } - Tenum val = this->m[option_value[7*i + 1]]; - this->field[i] = val; - - istringstream ss_1st(option_value[7*i + 2]); - if (!(ss_1st >> this->var1[i])) { - return badValue(option_value, "Riemann", this->name); - } - istringstream ss_2nd(option_value[7*i + 3]); - if (!(ss_2nd >> this->var2[i])) { - return badValue(option_value, "Riemann", this->name); - } - istringstream ss_3rd(option_value[7*i + 4]); - if (!(ss_3rd >> this->flowdir[i][0])) { - return badValue(option_value, "Riemann", this->name); - } - istringstream ss_4th(option_value[7*i + 5]); - if (!(ss_4th >> this->flowdir[i][1])) { - return badValue(option_value, "Riemann", this->name); - } - istringstream ss_5th(option_value[7*i + 6]); - if (!(ss_5th >> this->flowdir[i][2])) { - return badValue(option_value, "Riemann", this->name); - } - } - - return ""; - } - - void SetDefault() { - this->marker = NULL; - this->var1 = NULL; - this->var2 = NULL; - this->flowdir = NULL; - this->size = 0; // There is no default value for list - } -}; - -template -class COptionGiles : public COptionBase{ - - map m; - unsigned short & size; - string * & marker; - unsigned short* & field; // Reference to the fieldname - string name; // identifier for the option - su2double * & var1; - su2double * & var2; - su2double ** & flowdir; - su2double * & relfac1; - su2double * & relfac2; - -public: - COptionGiles(string option_field_name, unsigned short & nMarker_Giles, string* & Marker_Giles, unsigned short* & option_field, const map m, su2double* & var1, su2double* & var2, su2double** & FlowDir, su2double* & relfac1, su2double* & relfac2) : size(nMarker_Giles), - marker(Marker_Giles), field(option_field), var1(var1), var2(var2), flowdir(FlowDir), relfac1(relfac1), relfac2(relfac2) { - this->name = option_field_name; - this->m = m; - } - ~COptionGiles() {}; - - string SetValue(vector option_value) { - COptionBase::SetValue(option_value); - unsigned long totalVals = option_value.size(); - if ((totalVals == 1) && (option_value[0].compare("NONE") == 0)) { - this->size = 0; - this->marker = NULL; - this->field = 0; - this->var1 = NULL; - this->var2 = NULL; - this->flowdir = NULL; - this->relfac1 = NULL; - this->relfac2 = NULL; - return ""; - } - - if (totalVals % 9 != 0) { - string newstring; - newstring.append(this->name); - newstring.append(": must have a number of entries divisible by 9"); - this->size = 0; - this->marker = NULL; - this->var1 = NULL; - this->var2 = NULL; - this->flowdir = NULL; - this->field = NULL; - this->relfac1 = NULL; - this->relfac2 = NULL; - return newstring; - } - - unsigned long nVals = totalVals / 9; - this->size = nVals; - this->marker = new string[nVals]; - this->var1 = new su2double[nVals]; - this->var2 = new su2double[nVals]; - this->flowdir = new su2double*[nVals]; - this->field = new unsigned short[nVals]; - this->relfac1 = new su2double[nVals]; - this->relfac2 = new su2double[nVals]; - - for (unsigned int i = 0; i < nVals; i++) { - this->flowdir[i] = new su2double[3]; - } - - for (unsigned int i = 0; i < nVals; i++) { - this->marker[i].assign(option_value[9*i]); - // Check to see if the enum value is in the map - if (this->m.find(option_value[9*i + 1]) == m.end()) { - string str; - str.append(this->name); - str.append(": invalid option value "); - str.append(option_value[0]); - str.append(". Check current SU2 options in config_template.cfg."); - return str; - } - Tenum val = this->m[option_value[9*i + 1]]; - this->field[i] = val; - - istringstream ss_1st(option_value[9*i + 2]); - if (!(ss_1st >> this->var1[i])) { - return badValue(option_value, "Giles BC", this->name); - } - istringstream ss_2nd(option_value[9*i + 3]); - if (!(ss_2nd >> this->var2[i])) { - return badValue(option_value, "Giles BC", this->name); - } - istringstream ss_3rd(option_value[9*i + 4]); - if (!(ss_3rd >> this->flowdir[i][0])) { - return badValue(option_value, "Giles BC", this->name); - } - istringstream ss_4th(option_value[9*i + 5]); - if (!(ss_4th >> this->flowdir[i][1])) { - return badValue(option_value, "Giles BC", this->name); - } - istringstream ss_5th(option_value[9*i + 6]); - if (!(ss_5th >> this->flowdir[i][2])) { - return badValue(option_value, "Giles BC", this->name); - } - istringstream ss_6th(option_value[9*i + 7]); - if (!(ss_6th >> this->relfac1[i])) { - return badValue(option_value, "Giles BC", this->name); - } - istringstream ss_7th(option_value[9*i + 8]); - if (!(ss_7th >> this->relfac2[i])) { - return badValue(option_value, "Giles BC", this->name); - } - } - - return ""; - } - - void SetDefault() { - this->marker = NULL; - this->var1 = NULL; - this->var2 = NULL; - this->relfac1 = NULL; - this->relfac2 = NULL; - this->flowdir = NULL; - this->size = 0; // There is no default value for list - } -}; - -//Inlet condition where the input direction is assumed -class COptionExhaust : public COptionBase { - string name; // identifier for the option - unsigned short & size; - string * & marker; - su2double * & ttotal; - su2double * & ptotal; - -public: - COptionExhaust(string option_field_name, unsigned short & nMarker_Exhaust, string* & Marker_Exhaust, su2double* & Ttotal, su2double* & Ptotal) : size(nMarker_Exhaust), marker(Marker_Exhaust), ttotal(Ttotal), ptotal(Ptotal) { - this->name = option_field_name; - } - - ~COptionExhaust() {}; - - string SetValue(vector option_value) { - COptionBase::SetValue(option_value); - unsigned short totalVals = option_value.size(); - if ((totalVals == 1) && (option_value[0].compare("NONE") == 0)) { - this->size = 0; - this->marker = NULL; - this->ttotal = NULL; - this->ptotal = NULL; - return ""; - } - - if (totalVals % 3 != 0) { - string newstring; - newstring.append(this->name); - newstring.append(": must have a number of entries divisible by 3"); - this->size = 0; - this->marker = NULL; - this->ttotal = NULL; - this->ptotal = NULL; - return newstring; - } - - unsigned short nVals = totalVals / 3; - this->size = nVals; - this->marker = new string[nVals]; - this->ttotal = new su2double[nVals]; - this->ptotal = new su2double[nVals]; - - for (unsigned long i = 0; i < nVals; i++) { - this->marker[i].assign(option_value[3*i]); - istringstream ss_1st(option_value[3*i + 1]); - if (!(ss_1st >> this->ttotal[i])) - return badValue(option_value, "exhaust fixed", this->name); - istringstream ss_2nd(option_value[3*i + 2]); - if (!(ss_2nd >> this->ptotal[i])) - return badValue(option_value, "exhaust fixed", this->name); - } - - return ""; - } - - void SetDefault() { - this->marker = NULL; - this->ttotal = NULL; - this->ptotal = NULL; - this->size = 0; // There is no default value for list - } - -}; - -class COptionPeriodic : public COptionBase { - string name; // identifier for the option - unsigned short & size; - string * & marker_bound; - string * & marker_donor; - su2double ** & rot_center; - su2double ** & rot_angles; - su2double ** & translation; - -public: - COptionPeriodic(const string option_field_name, unsigned short & nMarker_PerBound, - string* & Marker_PerBound, string* & Marker_PerDonor, - su2double** & RotCenter, su2double** & RotAngles, su2double** & Translation) : size(nMarker_PerBound), marker_bound(Marker_PerBound), marker_donor(Marker_PerDonor), rot_center(RotCenter), rot_angles(RotAngles), translation(Translation) { - this->name = option_field_name; - } - - ~COptionPeriodic() {}; - string SetValue(vector option_value) { - COptionBase::SetValue(option_value); - const int mod_num = 11; - - unsigned short totalVals = option_value.size(); - if ((totalVals == 1) && (option_value[0].compare("NONE") == 0)) { - this->size = 0; - this->marker_bound = NULL; - this->marker_donor = NULL; - this->rot_center = NULL; - this->rot_angles = NULL; - this->translation = NULL; - return ""; - } - - if (totalVals % mod_num != 0) { - string newstring; - newstring.append(this->name); - newstring.append(": must have a number of entries divisible by 11"); - this->size = 0; - this->marker_bound = NULL; - this->marker_donor = NULL; - this->rot_center = NULL; - this->rot_angles = NULL; - this->translation = NULL; - return newstring; - } - - unsigned short nVals = 2 * (totalVals / mod_num); // To account for periodic and donor - this->size = nVals; - this->marker_bound = new string[nVals]; - this->marker_donor = new string[nVals]; - this->rot_center = new su2double*[nVals]; - this->rot_angles = new su2double*[nVals]; - this->translation = new su2double*[nVals]; - for (unsigned long i = 0; i < nVals; i++) { - this->rot_center[i] = new su2double[3]; - this->rot_angles[i] = new su2double[3]; - this->translation[i] = new su2double[3]; - } - - su2double deg2rad = PI_NUMBER/180.0; - - for (unsigned long i = 0; i < (nVals/2); i++) { - this->marker_bound[i].assign(option_value[mod_num*i]); - this->marker_donor[i].assign(option_value[mod_num*i+1]); - istringstream ss_1st(option_value[mod_num*i + 2]); - if (!(ss_1st >> this->rot_center[i][0])) { - return badValue(option_value, "periodic", this->name); - } - istringstream ss_2nd(option_value[mod_num*i + 3]); - if (!(ss_2nd >> this->rot_center[i][1])) { - return badValue(option_value, "periodic", this->name); - } - istringstream ss_3rd(option_value[mod_num*i + 4]); - if (!(ss_3rd >> this->rot_center[i][2])) { - return badValue(option_value, "periodic", this->name); - } - istringstream ss_4th(option_value[mod_num*i + 5]); - if (!(ss_4th >> this->rot_angles[i][0])) { - return badValue(option_value, "periodic", this->name); - } - istringstream ss_5th(option_value[mod_num*i + 6]); - if (!(ss_5th >> this->rot_angles[i][1])) { - return badValue(option_value, "periodic", this->name); - } - istringstream ss_6th(option_value[mod_num*i + 7]); - if (!(ss_6th >> this->rot_angles[i][2])) { - return badValue(option_value, "periodic", this->name); - } - istringstream ss_7th(option_value[mod_num*i + 8]); - if (!(ss_7th >> this->translation[i][0])) { - return badValue(option_value, "periodic", this->name); - } - istringstream ss_8th(option_value[mod_num*i + 9]); - if (!(ss_8th >> this->translation[i][1])) { - return badValue(option_value, "periodic", this->name); - } - istringstream ss_9th(option_value[mod_num*i + 10]); - if (!(ss_9th >> this->translation[i][2])) { - return badValue(option_value, "periodic", this->name); - } - this->rot_angles[i][0] *= deg2rad; - this->rot_angles[i][1] *= deg2rad; - this->rot_angles[i][2] *= deg2rad; - } - - for (unsigned long i = (nVals/2); i < nVals; i++) { - this->marker_bound[i].assign(option_value[mod_num*(i-nVals/2)+1]); - this->marker_donor[i].assign(option_value[mod_num*(i-nVals/2)]); - istringstream ss_1st(option_value[mod_num*(i-nVals/2) + 2]); - if (!(ss_1st >> this->rot_center[i][0])) { - return badValue(option_value, "periodic", this->name); - } - istringstream ss_2nd(option_value[mod_num*(i-nVals/2) + 3]); - if (!(ss_2nd >> this->rot_center[i][1])) { - return badValue(option_value, "periodic", this->name); - } - istringstream ss_3rd(option_value[mod_num*(i-nVals/2) + 4]); - if (!(ss_3rd >> this->rot_center[i][2])) { - return badValue(option_value, "periodic", this->name); - } - istringstream ss_4th(option_value[mod_num*(i-nVals/2) + 5]); - if (!(ss_4th >> this->rot_angles[i][0])) { - return badValue(option_value, "periodic", this->name); - } - istringstream ss_5th(option_value[mod_num*(i-nVals/2) + 6]); - if (!(ss_5th >> this->rot_angles[i][1])) { - return badValue(option_value, "periodic", this->name); - } - istringstream ss_6th(option_value[mod_num*(i-nVals/2) + 7]); - if (!(ss_6th >> this->rot_angles[i][2])) { - return badValue(option_value, "periodic", this->name); - } - istringstream ss_7th(option_value[mod_num*(i-nVals/2) + 8]); - if (!(ss_7th >> this->translation[i][0])) { - return badValue(option_value, "periodic", this->name); - } - istringstream ss_8th(option_value[mod_num*(i-nVals/2) + 9]); - if (!(ss_8th >> this->translation[i][1])) { - return badValue(option_value, "periodic", this->name); - } - istringstream ss_9th(option_value[mod_num*(i-nVals/2) + 10]); - if (!(ss_9th >> this->translation[i][2])) { - return badValue(option_value, "periodic", this->name); - } - /*--- Mirror the rotational angles and translation vector (rotational - center does not need to move) ---*/ - this->rot_center[i][0] *= 1.0; - this->rot_center[i][1] *= 1.0; - this->rot_center[i][2] *= 1.0; - this->rot_angles[i][0] *= -deg2rad; - this->rot_angles[i][1] *= -deg2rad; - this->rot_angles[i][2] *= -deg2rad; - this->translation[i][0] *= -1.0; - this->translation[i][1] *= -1.0; - this->translation[i][2] *= -1.0; - } - - return ""; - } - - void SetDefault() { - this->size = 0; - this->marker_bound = NULL; - this->marker_donor = NULL; - this->rot_center = NULL; - this->rot_angles = NULL; - this->translation = NULL; - } -}; - -class COptionTurboPerformance : public COptionBase { - string name; // identifier for the option - unsigned short & size; - string * & marker_turboIn; - string * & marker_turboOut; - -public: - COptionTurboPerformance(const string option_field_name, unsigned short & nMarker_TurboPerf, - string* & Marker_TurboBoundIn, string* & Marker_TurboBoundOut) : size(nMarker_TurboPerf), marker_turboIn(Marker_TurboBoundIn), marker_turboOut(Marker_TurboBoundOut){ - this->name = option_field_name; - } - - ~COptionTurboPerformance() {}; - string SetValue(vector option_value) { - COptionBase::SetValue(option_value); - const int mod_num = 2; - - unsigned long totalVals = option_value.size(); - if ((totalVals == 1) && (option_value[0].compare("NONE") == 0)) { - this->size = 0; - this->marker_turboIn= NULL; - this->marker_turboOut = NULL; - return ""; - } - - if (totalVals % mod_num != 0) { - string newstring; - newstring.append(this->name); - newstring.append(": must have a number of entries divisible by 2"); - this->size = 0; - this->marker_turboIn= NULL; - this->marker_turboOut = NULL;; - return newstring; - } - - unsigned long nVals = totalVals / mod_num; - this->size = nVals; - this->marker_turboIn = new string[nVals]; - this->marker_turboOut = new string[nVals]; - for (unsigned long i = 0; i < nVals; i++) { - this->marker_turboIn[i].assign(option_value[mod_num*i]); - this->marker_turboOut[i].assign(option_value[mod_num*i+1]); - } - - - return ""; - } - - void SetDefault() { - this->size = 0; - this->marker_turboIn= NULL; - this->marker_turboOut = NULL; - } -}; - -class COptionPython : public COptionBase { - string name; -public: - COptionPython(const string name) { - this->name = name; - } - ~COptionPython() {}; - // No checking happens with python options - string SetValue(vector option_value) { - COptionBase::SetValue(option_value); - return ""; - } - // No defaults with python options - void SetDefault() { - return; - }; -}; - -class COptionActDisk : public COptionBase { - string name; // identifier for the option - unsigned short & inlet_size; - unsigned short & outlet_size; - string * & marker_inlet; - string * & marker_outlet; - su2double ** & press_jump; - su2double ** & temp_jump; - su2double ** & omega; - -public: - COptionActDisk(const string name, - unsigned short & nMarker_ActDiskInlet, unsigned short & nMarker_ActDiskOutlet, string * & Marker_ActDiskInlet, string * & Marker_ActDiskOutlet, - su2double ** & ActDisk_PressJump, su2double ** & ActDisk_TempJump, su2double ** & ActDisk_Omega) : - inlet_size(nMarker_ActDiskInlet), outlet_size(nMarker_ActDiskOutlet), marker_inlet(Marker_ActDiskInlet), marker_outlet(Marker_ActDiskOutlet), - press_jump(ActDisk_PressJump), temp_jump(ActDisk_TempJump), omega(ActDisk_Omega) { - this->name = name; - } - - ~COptionActDisk() {}; - string SetValue(vector option_value) { - COptionBase::SetValue(option_value); - const int mod_num = 8; - unsigned short totalVals = option_value.size(); - if ((totalVals == 1) && (option_value[0].compare("NONE") == 0)) { - this->SetDefault(); - return ""; - } - - if (totalVals % mod_num != 0) { - string newstring; - newstring.append(this->name); - newstring.append(": must have a number of entries divisible by 8"); - this->SetDefault(); - return newstring; - } - - unsigned short nVals = totalVals / mod_num; - this->inlet_size = nVals; - this->outlet_size = nVals; - this->marker_inlet = new string[this->inlet_size]; - this->marker_outlet = new string[this->outlet_size]; - - this->press_jump = new su2double*[this->inlet_size]; - this->temp_jump = new su2double*[this->inlet_size]; - this->omega = new su2double*[this->inlet_size]; - for (int i = 0; i < this->inlet_size; i++) { - this->press_jump[i] = new su2double[2]; - this->temp_jump[i] = new su2double[2]; - this->omega[i] = new su2double[2]; - } - - string tname = "actuator disk"; - - for (int i = 0; i < this->inlet_size; i++) { - this->marker_inlet[i].assign(option_value[mod_num*i]); - this->marker_outlet[i].assign(option_value[mod_num*i+1]); - istringstream ss_1st(option_value[mod_num*i + 2]); - if (!(ss_1st >> this->press_jump[i][0])) { - return badValue(option_value, tname, this->name); - } - istringstream ss_2nd(option_value[mod_num*i + 3]); - if (!(ss_2nd >> this->temp_jump[i][0])) { - return badValue(option_value, tname, this->name); - } - istringstream ss_3rd(option_value[mod_num*i + 4]); - if (!(ss_3rd >> this->omega[i][0])) { - return badValue(option_value, tname, this->name); - } - istringstream ss_4th(option_value[mod_num*i + 5]); - if (!(ss_4th >> this->press_jump[i][1])) { - return badValue(option_value, tname, this->name); - } - istringstream ss_5th(option_value[mod_num*i + 6]); - if (!(ss_5th >> this->temp_jump[i][1])) { - return badValue(option_value, tname, this->name); - } - istringstream ss_6th(option_value[mod_num*i + 7]); - if (!(ss_6th >> this->omega[i][1])) { - return badValue(option_value, tname, this->name); - } - } - return ""; - } - void SetDefault() { - this->inlet_size = 0; - this->outlet_size = 0; - this->marker_inlet = NULL; - this->marker_outlet = NULL; - this->press_jump = NULL; - this->temp_jump = NULL; - this->omega = NULL; - } -}; - -class COptionWallFunction : public COptionBase { - string name; // identifier for the option - unsigned short &nMarkers; - string* &markers; - unsigned short* &walltype; - unsigned short** &intInfo; - su2double** &doubleInfo; - -public: - COptionWallFunction(const string name, unsigned short &nMarker_WF, - string* &Marker_WF, unsigned short* &type_WF, - unsigned short** &intInfo_WF, su2double** &doubleInfo_WF) : - nMarkers(nMarker_WF), markers(Marker_WF), walltype(type_WF), - intInfo(intInfo_WF), doubleInfo(doubleInfo_WF) { - this->name = name; - } - - ~COptionWallFunction(){} - - string SetValue(vector option_value) { - COptionBase::SetValue(option_value); - /*--- First check if NONE is specified. ---*/ - unsigned short totalSize = option_value.size(); - if ((totalSize == 1) && (option_value[0].compare("NONE") == 0)) { - this->SetDefault(); - return ""; - } - - /*--- Determine the number of markers, for which a wall - function treatment has been specified. ---*/ - unsigned short counter = 0, nVals = 0; - while (counter < totalSize ) { - - /* Update the counter for the number of markers specified - and store the current index for possible error messages. */ - ++nVals; - const unsigned short indMarker = counter; - - /* Check if a wall function type has been specified for this marker. - If not, create an error message and return. */ - ++counter; - const unsigned short indWallType = counter; - unsigned short typeWF = NO_WALL_FUNCTION; - bool validWF = true; - if (counter == totalSize) validWF = false; - else { - map::const_iterator it; - it = Wall_Functions_Map.find(option_value[counter]); - if(it == Wall_Functions_Map.end()) validWF = false; - else typeWF = it->second; - } - - if (!validWF ) { - string newstring; - newstring.append(this->name); - newstring.append(": Invalid wall function type, "); - newstring.append(option_value[counter]); - newstring.append(", encountered for marker "); - newstring.append(option_value[indMarker]); - return newstring; - } - - /* Update the counter, as the wall function type is valid. */ - ++counter; - - /*--- For some wall function types some additional info - must be specified. Hence the counter must be updated - accordingly. ---*/ - switch( typeWF ) { - case EQUILIBRIUM_WALL_MODEL: counter += 3; break; - case NONEQUILIBRIUM_WALL_MODEL: counter += 2; break; - case LOGARITHMIC_WALL_MODEL: counter += 3; break; - default: break; - } - - /* In case the counter is larger than totalSize, the data for - this wall function type has not been specified correctly. */ - if (counter > totalSize) { - string newstring; - newstring.append(this->name); - newstring.append(", marker "); - newstring.append(option_value[indMarker]); - newstring.append(", wall function type "); - newstring.append(option_value[indWallType]); - newstring.append(": Additional information is missing."); - return newstring; - } - } - - /* Allocate the memory to store the data for the wall function markers. */ - this->nMarkers = nVals; - this->markers = new string[nVals]; - this->walltype = new unsigned short[nVals]; - this->intInfo = new unsigned short*[nVals]; - this->doubleInfo = new su2double*[nVals]; - - for (unsigned short i=0; iintInfo[i] = NULL; - this->doubleInfo[i] = NULL; - } - - /*--- Loop over the wall markers and store the info in the - appropriate arrays. ---*/ - counter = 0; - for (unsigned short i=0; imarkers[i].assign(option_value[counter++]); - - /* Determine the wall function type. As their validaties have - already been tested, there is no need to do so again. */ - map::const_iterator it; - it = Wall_Functions_Map.find(option_value[counter++]); - - this->walltype[i] = it->second; - - /*--- For some wall function types, some additional info - is needed, which is extracted from option_value. ---*/ - switch( this->walltype[i] ) { - - case EQUILIBRIUM_WALL_MODEL: { - - /* LES equilibrium wall model. The exchange distance, stretching - factor and number of points in the wall model must be specified. */ - this->intInfo[i] = new unsigned short[1]; - this->doubleInfo[i] = new su2double[2]; - - istringstream ss_1st(option_value[counter++]); - if (!(ss_1st >> this->doubleInfo[i][0])) { - return badValue(option_value, "su2double", this->name); - } - - istringstream ss_2nd(option_value[counter++]); - if (!(ss_2nd >> this->doubleInfo[i][1])) { - return badValue(option_value, "su2double", this->name); - } - - istringstream ss_3rd(option_value[counter++]); - if (!(ss_3rd >> this->intInfo[i][0])) { - return badValue(option_value, "unsigned short", this->name); - } - - break; - } - - case NONEQUILIBRIUM_WALL_MODEL: { - - /* LES non-equilibrium model. The RANS turbulence model and - the exchange distance need to be specified. */ - this->intInfo[i] = new unsigned short[1]; - this->doubleInfo[i] = new su2double[1]; - - /* Check for a valid RANS turbulence model. */ - map::const_iterator iit; - iit = Turb_Model_Map.find(option_value[counter++]); - if(iit == Turb_Model_Map.end()) { - string newstring; - newstring.append(this->name); - newstring.append(", marker "); - newstring.append(this->markers[i]); - newstring.append(", wall function type "); - newstring.append(option_value[counter-2]); - newstring.append(": Invalid RANS turbulence model, "); - newstring.append(option_value[counter-1]); - newstring.append(", specified"); - return newstring; - } - - this->intInfo[i][0] = iit->second; - - /* Extract the exchange distance. */ - istringstream ss_1st(option_value[counter++]); - if (!(ss_1st >> this->doubleInfo[i][0])) { - return badValue(option_value, "su2double", this->name); - } - - break; - } - case LOGARITHMIC_WALL_MODEL: { - - /* LES Logarithmic law-of-the-wall model. The exchange distance, stretching - factor and number of points in the wall model must be specified. */ - this->intInfo[i] = new unsigned short[1]; - this->doubleInfo[i] = new su2double[2]; - - istringstream ss_1st(option_value[counter++]); - if (!(ss_1st >> this->doubleInfo[i][0])) { - return badValue(option_value, "su2double", this->name); - } - - istringstream ss_2nd(option_value[counter++]); - if (!(ss_2nd >> this->doubleInfo[i][1])) { - return badValue(option_value, "su2double", this->name); - } - - istringstream ss_3rd(option_value[counter++]); - if (!(ss_3rd >> this->intInfo[i][0])) { - return badValue(option_value, "unsigned short", this->name); - } - - break; - } - - default: // Just to avoid a compiler warning. - break; - } - } - - // Need to return something... - return ""; - } - - void SetDefault() { - this->nMarkers = 0; - this->markers = NULL; - this->walltype = NULL; - this->intInfo = NULL; - this->doubleInfo = NULL; - } -}; - +#include "option_structure.inl" #endif diff --git a/Common/include/option_structure.inl b/Common/include/option_structure.inl new file mode 100644 index 000000000000..34918a495562 --- /dev/null +++ b/Common/include/option_structure.inl @@ -0,0 +1,2148 @@ +/*! + * \file option_structure.inl + * \brief Template derived classes from COption, defined here as we + * only include them where needed to reduce compilation time. + * \author J. Hicken, B. Tracey + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +template +class COptionEnum : public COptionBase { + + map m; + unsigned short & field; // Reference to the feildname + Tenum def; // Default value + string name; // identifier for the option + +public: + COptionEnum(string option_field_name, const map m, unsigned short & option_field, Tenum default_value) : field(option_field) { + this->m = m; + this->def = default_value; + this->name = option_field_name; + } + + ~COptionEnum() {}; + string SetValue(vector option_value) { + COptionBase::SetValue(option_value); + // Check if there is more than one string + string out = optionCheckMultipleValues(option_value, "enum", this->name); + if (out.compare("") != 0) { + return out; + } + + // Check to see if the enum value is in the map + if (this->m.find(option_value[0]) == m.end()) { + string str; + str.append(this->name); + str.append(": invalid option value "); + str.append(option_value[0]); + str.append(". Check current SU2 options in config_template.cfg."); + return str; + } + // If it is there, set the option value + Tenum val = this->m[option_value[0]]; + this->field = val; + return ""; + } + + void SetDefault() { + this->field = this->def; + } +}; + +class COptionDouble : public COptionBase { + su2double & field; // Reference to the fieldname + su2double def; // Default value + string name; // identifier for the option + +public: + COptionDouble(string option_field_name, su2double & option_field, su2double default_value) : field(option_field) { + this->def = default_value; + this->name = option_field_name; + } + + ~COptionDouble() {}; + string SetValue(vector option_value) { + COptionBase::SetValue(option_value); + // check if there is more than one value + string out = optionCheckMultipleValues(option_value, "su2double", this->name); + if (out.compare("") != 0) { + return out; + } + istringstream is(option_value[0]); + su2double val; + if (is >> val) { + this->field = val; + return ""; + } + return badValue(option_value, "su2double", this->name); + } + void SetDefault() { + this->field = this->def; + } +}; + +class COptionString : public COptionBase { + string & field; // Reference to the fieldname + string def; // Default value + string name; // identifier for the option + +public: + COptionString(string option_field_name, string & option_field, string default_value) : field(option_field) { + this->def = default_value; + this->name = option_field_name; + } + + ~COptionString() {}; + string SetValue(vector option_value) { + COptionBase::SetValue(option_value); + // check if there is more than one value + string out = optionCheckMultipleValues(option_value, "su2double", this->name); + if (out.compare("") != 0) { + return out; + } + this->field.assign(option_value[0]); + return ""; + } + void SetDefault() { + this->field = this->def; + } +}; + +class COptionInt : public COptionBase { + int & field; // Reference to the feildname + int def; // Default value + string name; // identifier for the option + +public: + COptionInt(string option_field_name, int & option_field, int default_value) : field(option_field) { + this->def = default_value; + this->name = option_field_name; + } + + ~COptionInt() {}; + string SetValue(vector option_value) { + COptionBase::SetValue(option_value); + string out = optionCheckMultipleValues(option_value, "int", this->name); + if (out.compare("") != 0) { + return out; + } + istringstream is(option_value[0]); + int val; + if (is >> val) { + this->field = val; + return ""; + } + return badValue(option_value, "int", this->name); + } + void SetDefault() { + this->field = this->def; + } +}; + +class COptionULong : public COptionBase { + unsigned long & field; // Reference to the feildname + unsigned long def; // Default value + string name; // identifier for the option + +public: + COptionULong(string option_field_name, unsigned long & option_field, unsigned long default_value) : field(option_field) { + this->def = default_value; + this->name = option_field_name; + } + + ~COptionULong() {}; + string SetValue(vector option_value) { + COptionBase::SetValue(option_value); + string out = optionCheckMultipleValues(option_value, "unsigned long", this->name); + if (out.compare("") != 0) { + return out; + } + istringstream is(option_value[0]); + unsigned long val; + if (is >> val) { + this->field = val; + return ""; + } + return badValue(option_value, "unsigned long", this->name); + } + void SetDefault() { + this->field = this->def; + } +}; + +class COptionUShort : public COptionBase { + unsigned short & field; // Reference to the feildname + unsigned short def; // Default value + string name; // identifier for the option + +public: + COptionUShort(string option_field_name, unsigned short & option_field, unsigned short default_value) : field(option_field) { + this->def = default_value; + this->name = option_field_name; + } + + ~COptionUShort() {}; + string SetValue(vector option_value) { + COptionBase::SetValue(option_value); + string out = optionCheckMultipleValues(option_value, "unsigned short", this->name); + if (out.compare("") != 0) { + return out; + } + istringstream is(option_value[0]); + unsigned short val; + if (is >> val) { + this->field = val; + return ""; + } + return badValue(option_value, "unsigned short", this->name); + } + void SetDefault() { + this->field = this->def; + } +}; + +class COptionLong : public COptionBase { + long & field; // Reference to the feildname + long def; // Default value + string name; // identifier for the option + +public: + COptionLong(string option_field_name, long & option_field, long default_value) : field(option_field) { + this->def = default_value; + this->name = option_field_name; + } + + ~COptionLong() {}; + string SetValue(vector option_value) { + COptionBase::SetValue(option_value); + string out = optionCheckMultipleValues(option_value, "long", this->name); + if (out.compare("") != 0) { + return out; + } + istringstream is(option_value[0]); + long val; + if (is >> val) { + this->field = val; + return ""; + } + return badValue(option_value, "long", this->name); + } + void SetDefault() { + this->field = this->def; + } +}; + +class COptionBool : public COptionBase { + bool & field; // Reference to the feildname + bool def; // Default value + string name; // identifier for the option + +public: + COptionBool(string option_field_name, bool & option_field, bool default_value) : field(option_field) { + this->def = default_value; + this->name = option_field_name; + } + + ~COptionBool() {}; + string SetValue(vector option_value) { + COptionBase::SetValue(option_value); + // check if there is more than one value + string out = optionCheckMultipleValues(option_value, "bool", this->name); + if (out.compare("") != 0) { + return out; + } + if (option_value[0].compare("YES") == 0) { + this->field = true; + return ""; + } + if (option_value[0].compare("NO") == 0) { + this->field = false; + return ""; + } + return badValue(option_value, "bool", this->name); + } + void SetDefault() { + this->field = this->def; + } +}; + +template +class COptionEnumList : public COptionBase { + + map m; + unsigned short * & field; // Reference to the feildname + string name; // identifier for the option + unsigned short & size; + +public: + COptionEnumList(string option_field_name, const map m, unsigned short * & option_field, unsigned short & list_size) : field(option_field) , size(list_size) { + this->m = m; + this->name = option_field_name; + } + + ~COptionEnumList() {}; + string SetValue(vector option_value) { + COptionBase::SetValue(option_value); + if (option_value.size() == 1 && option_value[0].compare("NONE") == 0) { + this->size = 0; + return ""; + } + // size is the length of the option list + this->size = option_value.size(); + unsigned short * enums = new unsigned short[size]; + for (int i = 0; i < this->size; i++) { + // Check to see if the enum value is in the map + if (this->m.find(option_value[i]) == m.end()) { + string str; + str.append(this->name); + str.append(": invalid option value "); + str.append(option_value[i]); + str.append(". Check current SU2 options in config_template.cfg."); + return str; + } + // If it is there, set the option value + enums[i] = this->m[option_value[i]]; + } + this->field = enums; + return ""; + } + + void SetDefault() { + // No default to set + size = 0; + } +}; + +class COptionDoubleArray : public COptionBase { + su2double * & field; // Reference to the feildname + string name; // identifier for the option + const int size; + su2double * def; + su2double * vals; + su2double * default_value; + +public: + COptionDoubleArray(string option_field_name, const int list_size, su2double * & option_field, su2double * default_value) : field(option_field), size(list_size) { + this->name = option_field_name; + this->default_value = default_value; + def = NULL; + vals = NULL; + } + + ~COptionDoubleArray() { + if(def != NULL) delete [] def; + if(vals != NULL) delete [] vals; + }; + string SetValue(vector option_value) { + COptionBase::SetValue(option_value); + // Check that the size is correct + if (option_value.size() != (unsigned long)this->size) { + string newstring; + newstring.append(this->name); + newstring.append(": wrong number of arguments: "); + stringstream ss; + ss << this->size; + newstring.append(ss.str()); + newstring.append(" expected, "); + stringstream ss2; + ss2 << option_value.size(); + newstring.append(ss2.str()); + newstring.append(" found"); + return newstring; + } + vals = new su2double[this->size]; + for (int i = 0; i < this->size; i++) { + istringstream is(option_value[i]); + su2double val; + if (!(is >> val)) { + delete [] vals; + return badValue(option_value, "su2double array", this->name); + } + vals[i] = val; + } + this->field = vals; + return ""; + } + + void SetDefault() { + def = new su2double [size]; + for (int i = 0; i < size; i++) { + def[i] = default_value[i]; + } + this->field = def; + } +}; + +class COptionDoubleList : public COptionBase { + su2double * & field; // Reference to the feildname + string name; // identifier for the option + unsigned short & size; + +public: + COptionDoubleList(string option_field_name, unsigned short & list_size, su2double * & option_field) : field(option_field), size(list_size) { + this->name = option_field_name; + } + + ~COptionDoubleList() {}; + string SetValue(vector option_value) { + COptionBase::SetValue(option_value); + // The size is the length of option_value + unsigned short option_size = option_value.size(); + if (option_size == 1 && option_value[0].compare("NONE") == 0) { + // No options + this->size = 0; + return ""; + } + + this->size = option_size; + + // Parse all of the options + su2double * vals = new su2double[option_size]; + for (unsigned long i = 0; i < option_size; i++) { + istringstream is(option_value[i]); + su2double val; + if (!(is >> val)) { + delete [] vals; + return badValue(option_value, "su2double list", this->name); + } + vals[i] = val; + } + this->field = vals; + return ""; + } + + void SetDefault() { + this->size = 0; // There is no default value for list + } +}; + +class COptionShortList : public COptionBase { + short * & field; // Reference to the feildname + string name; // identifier for the option + unsigned short & size; + +public: + COptionShortList(string option_field_name, unsigned short & list_size, short * & option_field) : field(option_field), size(list_size) { + this->name = option_field_name; + } + + ~COptionShortList() {}; + string SetValue(vector option_value) { + COptionBase::SetValue(option_value); + // The size is the length of option_value + unsigned short option_size = option_value.size(); + if (option_size == 1 && option_value[0].compare("NONE") == 0) { + // No options + this->size = 0; + return ""; + } + this->size = option_size; + + // Parse all of the options + short * vals = new short[option_size]; + for (unsigned long i = 0; i < option_size; i++) { + istringstream is(option_value[i]); + unsigned short val; + if (!(is >> val)) { + delete [] vals; + return badValue(option_value, "short", this->name); + } + vals[i] = val; + } + this->field = vals; + return ""; + } + + void SetDefault() { + this->size = 0; // There is no default value for list + } +}; + +class COptionUShortList : public COptionBase { + unsigned short * & field; // Reference to the feildname + string name; // identifier for the option + unsigned short & size; + +public: + COptionUShortList(string option_field_name, unsigned short & list_size, unsigned short * & option_field) : field(option_field), size(list_size) { + this->name = option_field_name; + } + + ~COptionUShortList() {}; + string SetValue(vector option_value) { + COptionBase::SetValue(option_value); + // The size is the length of option_value + unsigned short option_size = option_value.size(); + if (option_size == 1 && option_value[0].compare("NONE") == 0) { + // No options + this->size = 0; + return ""; + } + this->size = option_size; + + // Parse all of the options + unsigned short * vals = new unsigned short[option_size]; + for (unsigned long i = 0; i < option_size; i++) { + istringstream is(option_value[i]); + unsigned short val; + if (!(is >> val)) { + delete [] vals; + return badValue(option_value, "unsigned short", this->name); + } + vals[i] = val; + } + this->field = vals; + return ""; + } + + void SetDefault() { + this->size = 0; // There is no default value for list + } +}; + +class COptionStringList : public COptionBase { + string * & field; // Reference to the feildname + string name; // identifier for the option + unsigned short & size; + +public: + COptionStringList(string option_field_name, unsigned short & list_size, string * & option_field) : field(option_field), size(list_size) { + this->name = option_field_name; + } + + ~COptionStringList() {}; + string SetValue(vector option_value) { + COptionBase::SetValue(option_value); + // The size is the length of option_value + unsigned short option_size = option_value.size(); + if (option_size == 1 && option_value[0].compare("NONE") == 0) { + this->size = 0; + return ""; + } + this->size = option_size; + + // Parse all of the options + string * vals = new string[option_size]; + for (unsigned long i = 0; i < option_size; i++) { + vals[i].assign(option_value[i]); + } + this->field = vals; + return ""; + } + + void SetDefault() { + this->size = 0; // There is no default value for list + } +}; + +class COptionConvect : public COptionBase { + string name; // identifier for the option + unsigned short & space; + unsigned short & centered; + unsigned short & upwind; + +public: + COptionConvect(string option_field_name, unsigned short & space_field, unsigned short & centered_field, unsigned short & upwind_field) + : name(option_field_name), space(space_field), centered(centered_field), upwind(upwind_field) { } + + string SetValue(vector option_value) { + COptionBase::SetValue(option_value); + + string out = optionCheckMultipleValues(option_value, "unsigned short", this->name); + if (out.compare("") != 0) { + return out; + } + + if (Centered_Map.count(option_value[0])) { + this->space = Space_Map.find("SPACE_CENTERED")->second; + this->centered = Centered_Map.find(option_value[0])->second; + this->upwind = NO_UPWIND; + return ""; + } + if (Upwind_Map.count(option_value[0])) { + this->space = Space_Map.find("SPACE_UPWIND")->second; + this->upwind = Upwind_Map.find(option_value[0])->second; + this->centered = NO_CENTERED; + return ""; + } + // Make them defined in case something weird happens + SetDefault(); + return badValue(option_value, "convect", this->name); + + } + + void SetDefault() { + this->centered = NO_CENTERED; + this->upwind = NO_UPWIND; + this->space = NO_CONVECTIVE; + } +}; + +class COptionFEMConvect : public COptionBase{ + string name; // identifier for the option + unsigned short & space; + unsigned short & fem; + +public: + COptionFEMConvect(string option_field_name, unsigned short & space_field, unsigned short & fem_field) : space(space_field), fem(fem_field) { + this->name = option_field_name; + } + + ~COptionFEMConvect() {}; + string SetValue(vector option_value) { + COptionBase::SetValue(option_value); + + string out = optionCheckMultipleValues(option_value, "unsigned short", this->name); + if (out.compare("") != 0) { + return out; + } + + if (FEM_Map.count(option_value[0])) { + this->space = Space_Map.find("FINITE_ELEMENT")->second; + this->fem = FEM_Map.find(option_value[0])->second; + return ""; + } + + // Make them defined in case something weird happens + this->fem = NO_FEM; + return badValue(option_value, "convect", this->name); + + } + + void SetDefault() { + this->fem = NO_FEM; + } +}; + +class COptionMathProblem : public COptionBase { + string name; // identifier for the option + bool & cont_adjoint; + bool cont_adjoint_def; + bool & disc_adjoint; + bool disc_adjoint_def; + bool & restart; + bool restart_def; + +public: + COptionMathProblem(string option_field_name, bool & cont_adjoint_field, bool cont_adjoint_default, bool & disc_adjoint_field, bool disc_adjoint_default, bool & restart_field, bool restart_default) : cont_adjoint(cont_adjoint_field), disc_adjoint(disc_adjoint_field), restart(restart_field) { + this->name = option_field_name; + this->cont_adjoint_def = cont_adjoint_default; + this->disc_adjoint_def = disc_adjoint_default; + this->restart_def = restart_default; + } + + ~COptionMathProblem() {}; + string SetValue(vector option_value) { + COptionBase::SetValue(option_value); + string out = optionCheckMultipleValues(option_value, "unsigned short", this->name); + if (out.compare("") != 0) { + return out; + } + if (option_value[0] == "ADJOINT") { + return badValue(option_value, "math problem (try CONTINUOUS_ADJOINT)", this->name); + } + if (Math_Problem_Map.find(option_value[0]) == Math_Problem_Map.end()) { + return badValue(option_value, "math problem", this->name); + } + if (option_value[0] == "DIRECT") { + this->cont_adjoint = false; + this->disc_adjoint = false; + this->restart = false; + return ""; + } + if (option_value[0] == "CONTINUOUS_ADJOINT") { + this->cont_adjoint= true; + this->disc_adjoint = false; + this->restart= true; + return ""; + } + if (option_value[0] == "DISCRETE_ADJOINT") { + this->disc_adjoint = true; + this->cont_adjoint= false; + this->restart = true; + return ""; + } + return "option in math problem map not considered in constructor"; + } + + void SetDefault() { + this->cont_adjoint = this->cont_adjoint_def; + this->disc_adjoint = this->disc_adjoint_def; + this->restart = this->restart_def; + } + +}; + +class COptionDVParam : public COptionBase { + string name; // identifier for the option + unsigned short & nDV; + su2double ** & paramDV; + string * & FFDTag; + unsigned short* & design_variable; + +public: + COptionDVParam(string option_field_name, unsigned short & nDV_field, su2double** & paramDV_field, string* & FFDTag_field, unsigned short * & design_variable_field) : nDV(nDV_field), paramDV(paramDV_field), FFDTag(FFDTag_field), design_variable(design_variable_field) { + this->name = option_field_name; + } + + ~COptionDVParam() {}; + + string SetValue(vector option_value) { + COptionBase::SetValue(option_value); + if ((option_value.size() == 1) && (option_value[0].compare("NONE") == 0)) { + this->nDV = 0; + return ""; + } + + // Cannot have ; at the beginning or the end + if (option_value[0].compare(";") == 0) { + string newstring; + newstring.append(this->name); + newstring.append(": may not have beginning semicolon"); + return newstring; + } + if (option_value[option_value.size()-1].compare(";") == 0) { + string newstring; + newstring.append(this->name); + newstring.append(": may not have ending semicolon"); + return newstring; + } + + + // use the ";" token to determine the number of design variables + // This works because semicolon is not one of the delimiters in tokenize string + this->nDV = 0; + //unsigned int num_semi = 0; + for (unsigned int i = 0; i < static_cast(option_value.size()); i++) { + if (option_value[i].compare(";") == 0) { + this->nDV++; + // num_semi++; + } + } + + // One more design variable than semicolon + this->nDV++; + + if ( (this->nDV > 0) && (this->design_variable == NULL) ) { + string newstring; + newstring.append(this->name); + newstring.append(": Design_Variable array has not been allocated. Check that DV_KIND appears before DV_PARAM in configuration file."); + return newstring; + } + + this->paramDV = new su2double*[this->nDV]; + for (unsigned short iDV = 0; iDV < this->nDV; iDV++) { + this->paramDV[iDV] = new su2double[MAX_PARAMETERS]; + } + + this->FFDTag = new string[this->nDV]; + + vector nParamDV(nDV, 0); + unsigned short totalnParamDV = 0; + stringstream ss; + unsigned int i = 0; + + for (unsigned short iDV = 0; iDV < this->nDV; iDV++) { + switch (this->design_variable[iDV]) { + case NO_DEFORMATION: nParamDV[iDV] = 0; break; + case FFD_SETTING: nParamDV[iDV] = 0; break; + case FFD_CONTROL_POINT_2D: nParamDV[iDV] = 5; break; + case FFD_CAMBER_2D: nParamDV[iDV] = 2; break; + case FFD_THICKNESS_2D: nParamDV[iDV] = 2; break; + case FFD_TWIST_2D: nParamDV[iDV] = 3; break; + case HICKS_HENNE: nParamDV[iDV] = 2; break; + case SURFACE_BUMP: nParamDV[iDV] = 3; break; + case CST: nParamDV[iDV] = 3; break; + case ANGLE_OF_ATTACK: nParamDV[iDV] = 1; break; + case SCALE: nParamDV[iDV] = 0; break; + case TRANSLATION: nParamDV[iDV] = 3; break; + case ROTATION: nParamDV[iDV] = 6; break; + case NACA_4DIGITS: nParamDV[iDV] = 3; break; + case PARABOLIC: nParamDV[iDV] = 2; break; + case AIRFOIL: nParamDV[iDV] = 2; break; + case FFD_CONTROL_POINT: nParamDV[iDV] = 7; break; + case FFD_NACELLE: nParamDV[iDV] = 6; break; + case FFD_GULL: nParamDV[iDV] = 2; break; + case FFD_TWIST: nParamDV[iDV] = 8; break; + case FFD_ROTATION: nParamDV[iDV] = 7; break; + case FFD_CONTROL_SURFACE: nParamDV[iDV] = 7; break; + case FFD_CAMBER: nParamDV[iDV] = 3; break; + case FFD_THICKNESS: nParamDV[iDV] = 3; break; + case FFD_ANGLE_OF_ATTACK: nParamDV[iDV] = 2; break; + case SURFACE_FILE: nParamDV[iDV] = 0; break; + case DV_EFIELD: nParamDV[iDV] = 2; break; + case DV_YOUNG: nParamDV[iDV] = 0; break; + case DV_POISSON: nParamDV[iDV] = 0; break; + case DV_RHO: nParamDV[iDV] = 0; break; + case DV_RHO_DL: nParamDV[iDV] = 0; break; + case SCALE_GRID: nParamDV[iDV] = 0; break; + case TRANSLATE_GRID: nParamDV[iDV] = 3; break; + case ROTATE_GRID: nParamDV[iDV] = 6; break; + default : { + string newstring; + newstring.append(this->name); + newstring.append(": undefined design variable type found in configuration file."); + return newstring; + } + } + totalnParamDV += nParamDV[iDV]; + } + + if (totalnParamDV > option_value.size()){ + SU2_MPI::Error("Wrong number of arguments for DV_PARAM!", CURRENT_FUNCTION); + } + + for (unsigned short iDV = 0; iDV < this->nDV; iDV++) { + for (unsigned short iParamDV = 0; iParamDV < nParamDV[iDV]; iParamDV++) { + + ss << option_value[i] << " "; + + if ((iParamDV == 0) && + ((this->design_variable[iDV] == NO_DEFORMATION) || + (this->design_variable[iDV] == FFD_SETTING) || + (this->design_variable[iDV] == FFD_ANGLE_OF_ATTACK)|| + (this->design_variable[iDV] == FFD_CONTROL_POINT_2D) || + (this->design_variable[iDV] == FFD_CAMBER_2D) || + (this->design_variable[iDV] == FFD_TWIST_2D) || + (this->design_variable[iDV] == FFD_THICKNESS_2D) || + (this->design_variable[iDV] == FFD_CONTROL_POINT) || + (this->design_variable[iDV] == FFD_NACELLE) || + (this->design_variable[iDV] == FFD_GULL) || + (this->design_variable[iDV] == FFD_TWIST) || + (this->design_variable[iDV] == FFD_ROTATION) || + (this->design_variable[iDV] == FFD_CONTROL_SURFACE) || + (this->design_variable[iDV] == FFD_CAMBER) || + (this->design_variable[iDV] == FFD_THICKNESS))) { + ss >> this->FFDTag[iDV]; + this->paramDV[iDV][iParamDV] = 0; + } + else + ss >> this->paramDV[iDV][iParamDV]; + + i++; + } + if (iDV < (this->nDV-1)) { + if (option_value[i].compare(";") != 0) { + string newstring; + newstring.append(this->name); + newstring.append(": a design variable in the configuration file has the wrong number of parameters"); + return newstring; + } + i++; + } + } + + // Need to return something... + return ""; + } + + void SetDefault() { + this->nDV = 0; + this->paramDV = NULL; + this->FFDTag = NULL; + // Don't mess with the Design_Variable because it's an input, not modified + } +}; + +class COptionDVValue : public COptionBase { + string name; // identifier for the option + unsigned short* & nDV_Value; + su2double ** & valueDV; + unsigned short & nDV; + su2double ** & paramDV; + unsigned short* & design_variable; + +public: + COptionDVValue(string option_field_name, unsigned short* & nDVValue_field, su2double** & valueDV_field, unsigned short & nDV_field, su2double** & paramDV_field, unsigned short * & design_variable_field) : nDV_Value(nDVValue_field), valueDV(valueDV_field), nDV(nDV_field), paramDV(paramDV_field), design_variable(design_variable_field) { + this->name = option_field_name; + } + + ~COptionDVValue() {}; + + string SetValue(vector option_value) { + COptionBase::SetValue(option_value); + if ((option_value.size() == 1) && (option_value[0].compare("NONE") == 0)) { + this->nDV_Value = NULL; + return ""; + } + + if ( (this->nDV > 0) && (this->design_variable == NULL) ) { + string newstring; + newstring.append(this->name); + newstring.append(": Design_Variable array has not been allocated. Check that DV_KIND appears before DV_VALUE in configuration file."); + return newstring; + } + if ( (this->nDV > 0) && (this->paramDV == NULL) ) { + string newstring; + newstring.append(this->name); + newstring.append(": Design_Parameter array has not been allocated. Check that DV_PARAM appears before DV_VALUE in configuration file."); + return newstring; + } + + this->valueDV = new su2double*[this->nDV]; + this->nDV_Value = new unsigned short[this->nDV]; + + for (unsigned short iDV = 0; iDV < this->nDV; iDV++) { + this->valueDV[iDV] = new su2double[3]; + } + + unsigned short nValueDV = 0; + unsigned short totalnValueDV = 0; + stringstream ss; + unsigned int i = 0; + for (unsigned short iDV = 0; iDV < this->nDV; iDV++) { + switch (this->design_variable[iDV]) { + case FFD_CONTROL_POINT: + if((this->paramDV[iDV][4] == 0) && + (this->paramDV[iDV][5] == 0) && + (this->paramDV[iDV][6] == 0)) { + nValueDV = 3; + } else { + nValueDV = 1; + } + break; + case FFD_CONTROL_POINT_2D: + if((this->paramDV[iDV][3] == 0) && + (this->paramDV[iDV][4] == 0)) { + nValueDV = 2; + } else { + nValueDV = 1; + } + break; + default : + nValueDV = 1; + } + + this->nDV_Value[iDV] = nValueDV; + + totalnValueDV += nValueDV; + + for (unsigned short iValueDV = 0; iValueDV < nValueDV; iValueDV++) { + + if (i >= option_value.size()) { + string newstring; + newstring.append(this->name); + newstring.append(": DV_VALUE does not contain enough entries to match DV_KIND or DV_PARAM."); + return newstring; + } + + ss << option_value[i] << " "; + + ss >> this->valueDV[iDV][iValueDV]; + + i++; + } + } + + if (i != totalnValueDV) { + string newstring; + newstring.append(this->name); + newstring.append(": a design variable in the configuration file has the wrong number of values"); + return newstring; + } + + // Need to return something... + return ""; + } + + void SetDefault() { + this->nDV_Value = 0; + this->valueDV = NULL; + // Don't mess with the Design_Variable because it's an input, not modified + } +}; + +class COptionFFDDef : public COptionBase { + string name; + unsigned short & nFFD; + su2double ** & CoordFFD; + string * & FFDTag; + +public: + COptionFFDDef(string option_field_name, unsigned short & nFFD_field, su2double** & coordFFD_field, string* & FFDTag_field) : nFFD(nFFD_field), CoordFFD(coordFFD_field), FFDTag(FFDTag_field) { + this->name = option_field_name; + } + + ~COptionFFDDef() {}; + + string SetValue(vector option_value) { + COptionBase::SetValue(option_value); + if ((option_value.size() == 1) && (option_value[0].compare("NONE") == 0)) { + this->nFFD = 0; + return ""; + } + + // Cannot have ; at the beginning or the end + if (option_value[0].compare(";") == 0) { + string newstring; + newstring.append(this->name); + newstring.append(": may not have beginning semicolon"); + return newstring; + } + if (option_value[option_value.size()-1].compare(";") == 0) { + string newstring; + newstring.append(this->name); + newstring.append(": may not have ending semicolon"); + return newstring; + } + + + // use the ";" token to determine the number of design variables + // This works because semicolon is not one of the delimiters in tokenize string + this->nFFD = 0; + for (unsigned int i = 0; i < static_cast(option_value.size()); i++) { + if (option_value[i].compare(";") == 0) { + this->nFFD++; + } + } + + // One more design variable than semicolon + this->nFFD++; + + this->CoordFFD = new su2double*[this->nFFD]; + for (unsigned short iFFD = 0; iFFD < this->nFFD; iFFD++) { + this->CoordFFD[iFFD] = new su2double[25]; + } + + this->FFDTag = new string[this->nFFD]; + + unsigned short nCoordFFD = 0; + stringstream ss; + unsigned int i = 0; + + for (unsigned short iFFD = 0; iFFD < this->nFFD; iFFD++) { + + nCoordFFD = 25; + + for (unsigned short iCoordFFD = 0; iCoordFFD < nCoordFFD; iCoordFFD++) { + + ss << option_value[i] << " "; + + if (iCoordFFD == 0) ss >> this->FFDTag[iFFD]; + else ss >> this->CoordFFD[iFFD][iCoordFFD-1]; + + i++; + } + + if (iFFD < (this->nFFD-1)) { + if (option_value[i].compare(";") != 0) { + string newstring; + newstring.append(this->name); + newstring.append(": a FFD box in the configuration file has the wrong number of parameters"); + return newstring; + } + i++; + } + + } + + // Need to return something... + return ""; + } + + void SetDefault() { + this->nFFD = 0; + this->CoordFFD = NULL; + this->FFDTag = NULL; + } + +}; + +class COptionFFDDegree : public COptionBase { + string name; + unsigned short & nFFD; + unsigned short ** & DegreeFFD; + +public: + COptionFFDDegree(string option_field_name, unsigned short & nFFD_field, unsigned short** & degreeFFD_field) : nFFD(nFFD_field), DegreeFFD(degreeFFD_field) { + this->name = option_field_name; + } + + ~COptionFFDDegree() {}; + + string SetValue(vector option_value) { + COptionBase::SetValue(option_value); + if ((option_value.size() == 1) && (option_value[0].compare("NONE") == 0)) { + this->nFFD = 0; + return ""; + } + + // Cannot have ; at the beginning or the end + if (option_value[0].compare(";") == 0) { + string newstring; + newstring.append(this->name); + newstring.append(": may not have beginning semicolon"); + return newstring; + } + if (option_value[option_value.size()-1].compare(";") == 0) { + string newstring; + newstring.append(this->name); + newstring.append(": may not have ending semicolon"); + return newstring; + } + + + // use the ";" token to determine the number of design variables + // This works because semicolon is not one of the delimiters in tokenize string + this->nFFD = 0; + for (unsigned int i = 0; i < static_cast(option_value.size()); i++) { + if (option_value[i].compare(";") == 0) { + this->nFFD++; + } + } + + // One more design variable than semicolon + this->nFFD++; + + this->DegreeFFD = new unsigned short*[this->nFFD]; + for (unsigned short iFFD = 0; iFFD < this->nFFD; iFFD++) { + this->DegreeFFD[iFFD] = new unsigned short[3]; + } + + unsigned short nDegreeFFD = 0; + stringstream ss; + unsigned int i = 0; + + for (unsigned short iFFD = 0; iFFD < this->nFFD; iFFD++) { + + nDegreeFFD = 3; + + for (unsigned short iDegreeFFD = 0; iDegreeFFD < nDegreeFFD; iDegreeFFD++) { + ss << option_value[i] << " "; + ss >> this->DegreeFFD[iFFD][iDegreeFFD]; + i++; + } + + if (iFFD < (this->nFFD-1)) { + if (option_value[i].compare(";") != 0) { + string newstring; + newstring.append(this->name); + newstring.append(": a FFD degree in the configuration file has the wrong number of parameters"); + return newstring; + } + i++; + } + + } + + // Need to return something... + return ""; + } + + void SetDefault() { + this->nFFD = 0; + this->DegreeFFD = NULL; + } + +}; + +// Class where the option is represented by (String, su2double, string, su2double, ...) +class COptionStringDoubleList : public COptionBase { + string name; // identifier for the option + unsigned short & size; // how many strings are there (same as number of su2doubles) + + string * & s_f; // Reference to the string fields + su2double* & d_f; // reference to the su2double fields + +public: + COptionStringDoubleList(string option_field_name, unsigned short & list_size, string * & string_field, su2double* & double_field) : size(list_size), s_f(string_field), d_f(double_field) { + this->name = option_field_name; + } + + ~COptionStringDoubleList() {}; + string SetValue(vector option_value) { + COptionBase::SetValue(option_value); + // There must be an even number of entries (same number of strings and doubles + unsigned short totalVals = option_value.size(); + if ((totalVals % 2) != 0) { + if ((totalVals == 1) && (option_value[0].compare("NONE") == 0)) { + // It's okay to say its NONE + this->size = 0; + return ""; + } + string newstring; + newstring.append(this->name); + newstring.append(": must have an even number of entries"); + return newstring; + } + unsigned short nVals = totalVals / 2; + this->size = nVals; + this->s_f = new string[nVals]; + this->d_f = new su2double[nVals]; + + for (unsigned long i = 0; i < nVals; i++) { + this->s_f[i].assign(option_value[2*i]); // 2 because have su2double and string + istringstream is(option_value[2*i + 1]); + su2double val; + if (!(is >> val)) { + return badValue(option_value, "string su2double", this->name); + } + this->d_f[i] = val; + } + // Need to return something... + return ""; + } + + void SetDefault() { + this->size = 0; // There is no default value for list + } +}; + +class COptionInlet : public COptionBase { + string name; // identifier for the option + unsigned short & size; + string * & marker; + su2double * & ttotal; + su2double * & ptotal; + su2double ** & flowdir; + +public: + COptionInlet(string option_field_name, unsigned short & nMarker_Inlet, string* & Marker_Inlet, su2double* & Ttotal, su2double* & Ptotal, su2double** & FlowDir) : size(nMarker_Inlet), marker(Marker_Inlet), ttotal(Ttotal), ptotal(Ptotal), flowdir(FlowDir) { + this->name = option_field_name; + } + + ~COptionInlet() {}; + string SetValue(vector option_value) { + COptionBase::SetValue(option_value); + unsigned short totalVals = option_value.size(); + if ((totalVals == 1) && (option_value[0].compare("NONE") == 0)) { + this->size = 0; + this->marker = NULL; + this->ttotal = NULL; + this->ptotal = NULL; + this->flowdir = NULL; + return ""; + } + + if (totalVals % 6 != 0) { + string newstring; + newstring.append(this->name); + newstring.append(": must have a number of entries divisible by 6"); + this->size = 0; + this->marker = NULL; + this->ttotal = NULL; + this->ptotal = NULL; + this->flowdir = NULL; + return newstring; + } + + unsigned short nVals = totalVals / 6; + this->size = nVals; + this->marker = new string[nVals]; + this->ttotal = new su2double[nVals]; + this->ptotal = new su2double[nVals]; + this->flowdir = new su2double*[nVals]; + for (unsigned long i = 0; i < nVals; i++) { + this->flowdir[i] = new su2double[3]; + } + + for (unsigned long i = 0; i < nVals; i++) { + this->marker[i].assign(option_value[6*i]); + istringstream ss_1st(option_value[6*i + 1]); + if (!(ss_1st >> this->ttotal[i])) { + return badValue(option_value, "inlet", this->name); + } + istringstream ss_2nd(option_value[6*i + 2]); + if (!(ss_2nd >> this->ptotal[i])) { + return badValue(option_value, "inlet", this->name); + } + istringstream ss_3rd(option_value[6*i + 3]); + if (!(ss_3rd >> this->flowdir[i][0])) { + return badValue(option_value, "inlet", this->name); + } + istringstream ss_4th(option_value[6*i + 4]); + if (!(ss_4th >> this->flowdir[i][1])) { + return badValue(option_value, "inlet", this->name); + } + istringstream ss_5th(option_value[6*i + 5]); + if (!(ss_5th >> this->flowdir[i][2])) { + return badValue(option_value, "inlet", this->name); + } + } + + return ""; + } + + void SetDefault() { + this->marker = NULL; + this->ttotal = NULL; + this->ptotal = NULL; + this->flowdir = NULL; + this->size = 0; // There is no default value for list + } +}; + +template +class COptionRiemann : public COptionBase { + +protected: + map m; + string name; // identifier for the option + unsigned short & size; + string * & marker; + unsigned short* & field; // Reference to the field name + su2double * & var1; + su2double * & var2; + su2double ** & flowdir; + +public: + COptionRiemann(string option_field_name, unsigned short & nMarker_Riemann, string* & Marker_Riemann, unsigned short* & option_field, const map m, su2double* & var1, su2double* & var2, su2double** & FlowDir) : size(nMarker_Riemann), + marker(Marker_Riemann), field(option_field), var1(var1), var2(var2), flowdir(FlowDir) { + this->name = option_field_name; + this->m = m; + } + ~COptionRiemann() {}; + + string SetValue(vector option_value) { + COptionBase::SetValue(option_value); + unsigned short totalVals = option_value.size(); + if ((totalVals == 1) && (option_value[0].compare("NONE") == 0)) { + this->size = 0; + this->marker = NULL; + this->field = 0; + this->var1 = NULL; + this->var2 = NULL; + this->flowdir = NULL; + return ""; + } + + if (totalVals % 7 != 0) { + string newstring; + newstring.append(this->name); + newstring.append(": must have a number of entries divisible by 7"); + this->size = 0; + this->marker = NULL; + this->var1 = NULL; + this->var2 = NULL; + this->flowdir = NULL; + this->field = NULL; + return newstring; + } + + unsigned short nVals = totalVals / 7; + this->size = nVals; + this->marker = new string[nVals]; + this->var1 = new su2double[nVals]; + this->var2 = new su2double[nVals]; + this->flowdir = new su2double*[nVals]; + this->field = new unsigned short[nVals]; + + for (unsigned long i = 0; i < nVals; i++) { + this->flowdir[i] = new su2double[3]; + } + + for (unsigned long i = 0; i < nVals; i++) { + this->marker[i].assign(option_value[7*i]); + // Check to see if the enum value is in the map + if (this->m.find(option_value[7*i + 1]) == m.end()) { + string str; + str.append(this->name); + str.append(": invalid option value "); + str.append(option_value[0]); + str.append(". Check current SU2 options in config_template.cfg."); + return str; + } + Tenum val = this->m[option_value[7*i + 1]]; + this->field[i] = val; + + istringstream ss_1st(option_value[7*i + 2]); + if (!(ss_1st >> this->var1[i])) { + return badValue(option_value, "Riemann", this->name); + } + istringstream ss_2nd(option_value[7*i + 3]); + if (!(ss_2nd >> this->var2[i])) { + return badValue(option_value, "Riemann", this->name); + } + istringstream ss_3rd(option_value[7*i + 4]); + if (!(ss_3rd >> this->flowdir[i][0])) { + return badValue(option_value, "Riemann", this->name); + } + istringstream ss_4th(option_value[7*i + 5]); + if (!(ss_4th >> this->flowdir[i][1])) { + return badValue(option_value, "Riemann", this->name); + } + istringstream ss_5th(option_value[7*i + 6]); + if (!(ss_5th >> this->flowdir[i][2])) { + return badValue(option_value, "Riemann", this->name); + } + } + + return ""; + } + + void SetDefault() { + this->marker = NULL; + this->var1 = NULL; + this->var2 = NULL; + this->flowdir = NULL; + this->size = 0; // There is no default value for list + } +}; + +template +class COptionGiles : public COptionBase{ + + map m; + unsigned short & size; + string * & marker; + unsigned short* & field; // Reference to the fieldname + string name; // identifier for the option + su2double * & var1; + su2double * & var2; + su2double ** & flowdir; + su2double * & relfac1; + su2double * & relfac2; + +public: + COptionGiles(string option_field_name, unsigned short & nMarker_Giles, string* & Marker_Giles, unsigned short* & option_field, const map m, su2double* & var1, su2double* & var2, su2double** & FlowDir, su2double* & relfac1, su2double* & relfac2) : size(nMarker_Giles), + marker(Marker_Giles), field(option_field), var1(var1), var2(var2), flowdir(FlowDir), relfac1(relfac1), relfac2(relfac2) { + this->name = option_field_name; + this->m = m; + } + ~COptionGiles() {}; + + string SetValue(vector option_value) { + COptionBase::SetValue(option_value); + unsigned long totalVals = option_value.size(); + if ((totalVals == 1) && (option_value[0].compare("NONE") == 0)) { + this->size = 0; + this->marker = NULL; + this->field = 0; + this->var1 = NULL; + this->var2 = NULL; + this->flowdir = NULL; + this->relfac1 = NULL; + this->relfac2 = NULL; + return ""; + } + + if (totalVals % 9 != 0) { + string newstring; + newstring.append(this->name); + newstring.append(": must have a number of entries divisible by 9"); + this->size = 0; + this->marker = NULL; + this->var1 = NULL; + this->var2 = NULL; + this->flowdir = NULL; + this->field = NULL; + this->relfac1 = NULL; + this->relfac2 = NULL; + return newstring; + } + + unsigned long nVals = totalVals / 9; + this->size = nVals; + this->marker = new string[nVals]; + this->var1 = new su2double[nVals]; + this->var2 = new su2double[nVals]; + this->flowdir = new su2double*[nVals]; + this->field = new unsigned short[nVals]; + this->relfac1 = new su2double[nVals]; + this->relfac2 = new su2double[nVals]; + + for (unsigned int i = 0; i < nVals; i++) { + this->flowdir[i] = new su2double[3]; + } + + for (unsigned int i = 0; i < nVals; i++) { + this->marker[i].assign(option_value[9*i]); + // Check to see if the enum value is in the map + if (this->m.find(option_value[9*i + 1]) == m.end()) { + string str; + str.append(this->name); + str.append(": invalid option value "); + str.append(option_value[0]); + str.append(". Check current SU2 options in config_template.cfg."); + return str; + } + Tenum val = this->m[option_value[9*i + 1]]; + this->field[i] = val; + + istringstream ss_1st(option_value[9*i + 2]); + if (!(ss_1st >> this->var1[i])) { + return badValue(option_value, "Giles BC", this->name); + } + istringstream ss_2nd(option_value[9*i + 3]); + if (!(ss_2nd >> this->var2[i])) { + return badValue(option_value, "Giles BC", this->name); + } + istringstream ss_3rd(option_value[9*i + 4]); + if (!(ss_3rd >> this->flowdir[i][0])) { + return badValue(option_value, "Giles BC", this->name); + } + istringstream ss_4th(option_value[9*i + 5]); + if (!(ss_4th >> this->flowdir[i][1])) { + return badValue(option_value, "Giles BC", this->name); + } + istringstream ss_5th(option_value[9*i + 6]); + if (!(ss_5th >> this->flowdir[i][2])) { + return badValue(option_value, "Giles BC", this->name); + } + istringstream ss_6th(option_value[9*i + 7]); + if (!(ss_6th >> this->relfac1[i])) { + return badValue(option_value, "Giles BC", this->name); + } + istringstream ss_7th(option_value[9*i + 8]); + if (!(ss_7th >> this->relfac2[i])) { + return badValue(option_value, "Giles BC", this->name); + } + } + + return ""; + } + + void SetDefault() { + this->marker = NULL; + this->var1 = NULL; + this->var2 = NULL; + this->relfac1 = NULL; + this->relfac2 = NULL; + this->flowdir = NULL; + this->size = 0; // There is no default value for list + } +}; + +//Inlet condition where the input direction is assumed +class COptionExhaust : public COptionBase { + string name; // identifier for the option + unsigned short & size; + string * & marker; + su2double * & ttotal; + su2double * & ptotal; + +public: + COptionExhaust(string option_field_name, unsigned short & nMarker_Exhaust, string* & Marker_Exhaust, su2double* & Ttotal, su2double* & Ptotal) : size(nMarker_Exhaust), marker(Marker_Exhaust), ttotal(Ttotal), ptotal(Ptotal) { + this->name = option_field_name; + } + + ~COptionExhaust() {}; + + string SetValue(vector option_value) { + COptionBase::SetValue(option_value); + unsigned short totalVals = option_value.size(); + if ((totalVals == 1) && (option_value[0].compare("NONE") == 0)) { + this->size = 0; + this->marker = NULL; + this->ttotal = NULL; + this->ptotal = NULL; + return ""; + } + + if (totalVals % 3 != 0) { + string newstring; + newstring.append(this->name); + newstring.append(": must have a number of entries divisible by 3"); + this->size = 0; + this->marker = NULL; + this->ttotal = NULL; + this->ptotal = NULL; + return newstring; + } + + unsigned short nVals = totalVals / 3; + this->size = nVals; + this->marker = new string[nVals]; + this->ttotal = new su2double[nVals]; + this->ptotal = new su2double[nVals]; + + for (unsigned long i = 0; i < nVals; i++) { + this->marker[i].assign(option_value[3*i]); + istringstream ss_1st(option_value[3*i + 1]); + if (!(ss_1st >> this->ttotal[i])) + return badValue(option_value, "exhaust fixed", this->name); + istringstream ss_2nd(option_value[3*i + 2]); + if (!(ss_2nd >> this->ptotal[i])) + return badValue(option_value, "exhaust fixed", this->name); + } + + return ""; + } + + void SetDefault() { + this->marker = NULL; + this->ttotal = NULL; + this->ptotal = NULL; + this->size = 0; // There is no default value for list + } + +}; + +class COptionPeriodic : public COptionBase { + string name; // identifier for the option + unsigned short & size; + string * & marker_bound; + string * & marker_donor; + su2double ** & rot_center; + su2double ** & rot_angles; + su2double ** & translation; + +public: + COptionPeriodic(const string option_field_name, unsigned short & nMarker_PerBound, + string* & Marker_PerBound, string* & Marker_PerDonor, + su2double** & RotCenter, su2double** & RotAngles, su2double** & Translation) : size(nMarker_PerBound), marker_bound(Marker_PerBound), marker_donor(Marker_PerDonor), rot_center(RotCenter), rot_angles(RotAngles), translation(Translation) { + this->name = option_field_name; + } + + ~COptionPeriodic() {}; + string SetValue(vector option_value) { + COptionBase::SetValue(option_value); + const int mod_num = 11; + + unsigned short totalVals = option_value.size(); + if ((totalVals == 1) && (option_value[0].compare("NONE") == 0)) { + this->size = 0; + this->marker_bound = NULL; + this->marker_donor = NULL; + this->rot_center = NULL; + this->rot_angles = NULL; + this->translation = NULL; + return ""; + } + + if (totalVals % mod_num != 0) { + string newstring; + newstring.append(this->name); + newstring.append(": must have a number of entries divisible by 11"); + this->size = 0; + this->marker_bound = NULL; + this->marker_donor = NULL; + this->rot_center = NULL; + this->rot_angles = NULL; + this->translation = NULL; + return newstring; + } + + unsigned short nVals = 2 * (totalVals / mod_num); // To account for periodic and donor + this->size = nVals; + this->marker_bound = new string[nVals]; + this->marker_donor = new string[nVals]; + this->rot_center = new su2double*[nVals]; + this->rot_angles = new su2double*[nVals]; + this->translation = new su2double*[nVals]; + for (unsigned long i = 0; i < nVals; i++) { + this->rot_center[i] = new su2double[3]; + this->rot_angles[i] = new su2double[3]; + this->translation[i] = new su2double[3]; + } + + su2double deg2rad = PI_NUMBER/180.0; + + for (unsigned long i = 0; i < (nVals/2); i++) { + this->marker_bound[i].assign(option_value[mod_num*i]); + this->marker_donor[i].assign(option_value[mod_num*i+1]); + istringstream ss_1st(option_value[mod_num*i + 2]); + if (!(ss_1st >> this->rot_center[i][0])) { + return badValue(option_value, "periodic", this->name); + } + istringstream ss_2nd(option_value[mod_num*i + 3]); + if (!(ss_2nd >> this->rot_center[i][1])) { + return badValue(option_value, "periodic", this->name); + } + istringstream ss_3rd(option_value[mod_num*i + 4]); + if (!(ss_3rd >> this->rot_center[i][2])) { + return badValue(option_value, "periodic", this->name); + } + istringstream ss_4th(option_value[mod_num*i + 5]); + if (!(ss_4th >> this->rot_angles[i][0])) { + return badValue(option_value, "periodic", this->name); + } + istringstream ss_5th(option_value[mod_num*i + 6]); + if (!(ss_5th >> this->rot_angles[i][1])) { + return badValue(option_value, "periodic", this->name); + } + istringstream ss_6th(option_value[mod_num*i + 7]); + if (!(ss_6th >> this->rot_angles[i][2])) { + return badValue(option_value, "periodic", this->name); + } + istringstream ss_7th(option_value[mod_num*i + 8]); + if (!(ss_7th >> this->translation[i][0])) { + return badValue(option_value, "periodic", this->name); + } + istringstream ss_8th(option_value[mod_num*i + 9]); + if (!(ss_8th >> this->translation[i][1])) { + return badValue(option_value, "periodic", this->name); + } + istringstream ss_9th(option_value[mod_num*i + 10]); + if (!(ss_9th >> this->translation[i][2])) { + return badValue(option_value, "periodic", this->name); + } + this->rot_angles[i][0] *= deg2rad; + this->rot_angles[i][1] *= deg2rad; + this->rot_angles[i][2] *= deg2rad; + } + + for (unsigned long i = (nVals/2); i < nVals; i++) { + this->marker_bound[i].assign(option_value[mod_num*(i-nVals/2)+1]); + this->marker_donor[i].assign(option_value[mod_num*(i-nVals/2)]); + istringstream ss_1st(option_value[mod_num*(i-nVals/2) + 2]); + if (!(ss_1st >> this->rot_center[i][0])) { + return badValue(option_value, "periodic", this->name); + } + istringstream ss_2nd(option_value[mod_num*(i-nVals/2) + 3]); + if (!(ss_2nd >> this->rot_center[i][1])) { + return badValue(option_value, "periodic", this->name); + } + istringstream ss_3rd(option_value[mod_num*(i-nVals/2) + 4]); + if (!(ss_3rd >> this->rot_center[i][2])) { + return badValue(option_value, "periodic", this->name); + } + istringstream ss_4th(option_value[mod_num*(i-nVals/2) + 5]); + if (!(ss_4th >> this->rot_angles[i][0])) { + return badValue(option_value, "periodic", this->name); + } + istringstream ss_5th(option_value[mod_num*(i-nVals/2) + 6]); + if (!(ss_5th >> this->rot_angles[i][1])) { + return badValue(option_value, "periodic", this->name); + } + istringstream ss_6th(option_value[mod_num*(i-nVals/2) + 7]); + if (!(ss_6th >> this->rot_angles[i][2])) { + return badValue(option_value, "periodic", this->name); + } + istringstream ss_7th(option_value[mod_num*(i-nVals/2) + 8]); + if (!(ss_7th >> this->translation[i][0])) { + return badValue(option_value, "periodic", this->name); + } + istringstream ss_8th(option_value[mod_num*(i-nVals/2) + 9]); + if (!(ss_8th >> this->translation[i][1])) { + return badValue(option_value, "periodic", this->name); + } + istringstream ss_9th(option_value[mod_num*(i-nVals/2) + 10]); + if (!(ss_9th >> this->translation[i][2])) { + return badValue(option_value, "periodic", this->name); + } + /*--- Mirror the rotational angles and translation vector (rotational + center does not need to move) ---*/ + this->rot_center[i][0] *= 1.0; + this->rot_center[i][1] *= 1.0; + this->rot_center[i][2] *= 1.0; + this->rot_angles[i][0] *= -deg2rad; + this->rot_angles[i][1] *= -deg2rad; + this->rot_angles[i][2] *= -deg2rad; + this->translation[i][0] *= -1.0; + this->translation[i][1] *= -1.0; + this->translation[i][2] *= -1.0; + } + + return ""; + } + + void SetDefault() { + this->size = 0; + this->marker_bound = NULL; + this->marker_donor = NULL; + this->rot_center = NULL; + this->rot_angles = NULL; + this->translation = NULL; + } +}; + +class COptionTurboPerformance : public COptionBase { + string name; // identifier for the option + unsigned short & size; + string * & marker_turboIn; + string * & marker_turboOut; + +public: + COptionTurboPerformance(const string option_field_name, unsigned short & nMarker_TurboPerf, + string* & Marker_TurboBoundIn, string* & Marker_TurboBoundOut) : size(nMarker_TurboPerf), marker_turboIn(Marker_TurboBoundIn), marker_turboOut(Marker_TurboBoundOut){ + this->name = option_field_name; + } + + ~COptionTurboPerformance() {}; + string SetValue(vector option_value) { + COptionBase::SetValue(option_value); + const int mod_num = 2; + + unsigned long totalVals = option_value.size(); + if ((totalVals == 1) && (option_value[0].compare("NONE") == 0)) { + this->size = 0; + this->marker_turboIn= NULL; + this->marker_turboOut = NULL; + return ""; + } + + if (totalVals % mod_num != 0) { + string newstring; + newstring.append(this->name); + newstring.append(": must have a number of entries divisible by 2"); + this->size = 0; + this->marker_turboIn= NULL; + this->marker_turboOut = NULL;; + return newstring; + } + + unsigned long nVals = totalVals / mod_num; + this->size = nVals; + this->marker_turboIn = new string[nVals]; + this->marker_turboOut = new string[nVals]; + for (unsigned long i = 0; i < nVals; i++) { + this->marker_turboIn[i].assign(option_value[mod_num*i]); + this->marker_turboOut[i].assign(option_value[mod_num*i+1]); + } + + + return ""; + } + + void SetDefault() { + this->size = 0; + this->marker_turboIn= NULL; + this->marker_turboOut = NULL; + } +}; + +class COptionPython : public COptionBase { + string name; +public: + COptionPython(const string name) { + this->name = name; + } + ~COptionPython() {}; + // No checking happens with python options + string SetValue(vector option_value) { + COptionBase::SetValue(option_value); + return ""; + } + // No defaults with python options + void SetDefault() { + return; + }; +}; + +class COptionActDisk : public COptionBase { + string name; // identifier for the option + unsigned short & inlet_size; + unsigned short & outlet_size; + string * & marker_inlet; + string * & marker_outlet; + su2double ** & press_jump; + su2double ** & temp_jump; + su2double ** & omega; + +public: + COptionActDisk(const string name, + unsigned short & nMarker_ActDiskInlet, unsigned short & nMarker_ActDiskOutlet, string * & Marker_ActDiskInlet, string * & Marker_ActDiskOutlet, + su2double ** & ActDisk_PressJump, su2double ** & ActDisk_TempJump, su2double ** & ActDisk_Omega) : + inlet_size(nMarker_ActDiskInlet), outlet_size(nMarker_ActDiskOutlet), marker_inlet(Marker_ActDiskInlet), marker_outlet(Marker_ActDiskOutlet), + press_jump(ActDisk_PressJump), temp_jump(ActDisk_TempJump), omega(ActDisk_Omega) { + this->name = name; + } + + ~COptionActDisk() {}; + string SetValue(vector option_value) { + COptionBase::SetValue(option_value); + const int mod_num = 8; + unsigned short totalVals = option_value.size(); + if ((totalVals == 1) && (option_value[0].compare("NONE") == 0)) { + this->SetDefault(); + return ""; + } + + if (totalVals % mod_num != 0) { + string newstring; + newstring.append(this->name); + newstring.append(": must have a number of entries divisible by 8"); + this->SetDefault(); + return newstring; + } + + unsigned short nVals = totalVals / mod_num; + this->inlet_size = nVals; + this->outlet_size = nVals; + this->marker_inlet = new string[this->inlet_size]; + this->marker_outlet = new string[this->outlet_size]; + + this->press_jump = new su2double*[this->inlet_size]; + this->temp_jump = new su2double*[this->inlet_size]; + this->omega = new su2double*[this->inlet_size]; + for (int i = 0; i < this->inlet_size; i++) { + this->press_jump[i] = new su2double[2]; + this->temp_jump[i] = new su2double[2]; + this->omega[i] = new su2double[2]; + } + + string tname = "actuator disk"; + + for (int i = 0; i < this->inlet_size; i++) { + this->marker_inlet[i].assign(option_value[mod_num*i]); + this->marker_outlet[i].assign(option_value[mod_num*i+1]); + istringstream ss_1st(option_value[mod_num*i + 2]); + if (!(ss_1st >> this->press_jump[i][0])) { + return badValue(option_value, tname, this->name); + } + istringstream ss_2nd(option_value[mod_num*i + 3]); + if (!(ss_2nd >> this->temp_jump[i][0])) { + return badValue(option_value, tname, this->name); + } + istringstream ss_3rd(option_value[mod_num*i + 4]); + if (!(ss_3rd >> this->omega[i][0])) { + return badValue(option_value, tname, this->name); + } + istringstream ss_4th(option_value[mod_num*i + 5]); + if (!(ss_4th >> this->press_jump[i][1])) { + return badValue(option_value, tname, this->name); + } + istringstream ss_5th(option_value[mod_num*i + 6]); + if (!(ss_5th >> this->temp_jump[i][1])) { + return badValue(option_value, tname, this->name); + } + istringstream ss_6th(option_value[mod_num*i + 7]); + if (!(ss_6th >> this->omega[i][1])) { + return badValue(option_value, tname, this->name); + } + } + return ""; + } + void SetDefault() { + this->inlet_size = 0; + this->outlet_size = 0; + this->marker_inlet = NULL; + this->marker_outlet = NULL; + this->press_jump = NULL; + this->temp_jump = NULL; + this->omega = NULL; + } +}; + +class COptionWallFunction : public COptionBase { + string name; // identifier for the option + unsigned short &nMarkers; + string* &markers; + unsigned short* &walltype; + unsigned short** &intInfo; + su2double** &doubleInfo; + +public: + COptionWallFunction(const string name, unsigned short &nMarker_WF, + string* &Marker_WF, unsigned short* &type_WF, + unsigned short** &intInfo_WF, su2double** &doubleInfo_WF) : + nMarkers(nMarker_WF), markers(Marker_WF), walltype(type_WF), + intInfo(intInfo_WF), doubleInfo(doubleInfo_WF) { + this->name = name; + } + + ~COptionWallFunction(){} + + string SetValue(vector option_value) { + COptionBase::SetValue(option_value); + /*--- First check if NONE is specified. ---*/ + unsigned short totalSize = option_value.size(); + if ((totalSize == 1) && (option_value[0].compare("NONE") == 0)) { + this->SetDefault(); + return ""; + } + + /*--- Determine the number of markers, for which a wall + function treatment has been specified. ---*/ + unsigned short counter = 0, nVals = 0; + while (counter < totalSize ) { + + /* Update the counter for the number of markers specified + and store the current index for possible error messages. */ + ++nVals; + const unsigned short indMarker = counter; + + /* Check if a wall function type has been specified for this marker. + If not, create an error message and return. */ + ++counter; + const unsigned short indWallType = counter; + unsigned short typeWF = NO_WALL_FUNCTION; + bool validWF = true; + if (counter == totalSize) validWF = false; + else { + map::const_iterator it; + it = Wall_Functions_Map.find(option_value[counter]); + if(it == Wall_Functions_Map.end()) validWF = false; + else typeWF = it->second; + } + + if (!validWF ) { + string newstring; + newstring.append(this->name); + newstring.append(": Invalid wall function type, "); + newstring.append(option_value[counter]); + newstring.append(", encountered for marker "); + newstring.append(option_value[indMarker]); + return newstring; + } + + /* Update the counter, as the wall function type is valid. */ + ++counter; + + /*--- For some wall function types some additional info + must be specified. Hence the counter must be updated + accordingly. ---*/ + switch( typeWF ) { + case EQUILIBRIUM_WALL_MODEL: counter += 3; break; + case NONEQUILIBRIUM_WALL_MODEL: counter += 2; break; + case LOGARITHMIC_WALL_MODEL: counter += 3; break; + default: break; + } + + /* In case the counter is larger than totalSize, the data for + this wall function type has not been specified correctly. */ + if (counter > totalSize) { + string newstring; + newstring.append(this->name); + newstring.append(", marker "); + newstring.append(option_value[indMarker]); + newstring.append(", wall function type "); + newstring.append(option_value[indWallType]); + newstring.append(": Additional information is missing."); + return newstring; + } + } + + /* Allocate the memory to store the data for the wall function markers. */ + this->nMarkers = nVals; + this->markers = new string[nVals]; + this->walltype = new unsigned short[nVals]; + this->intInfo = new unsigned short*[nVals]; + this->doubleInfo = new su2double*[nVals]; + + for (unsigned short i=0; iintInfo[i] = NULL; + this->doubleInfo[i] = NULL; + } + + /*--- Loop over the wall markers and store the info in the + appropriate arrays. ---*/ + counter = 0; + for (unsigned short i=0; imarkers[i].assign(option_value[counter++]); + + /* Determine the wall function type. As their validaties have + already been tested, there is no need to do so again. */ + map::const_iterator it; + it = Wall_Functions_Map.find(option_value[counter++]); + + this->walltype[i] = it->second; + + /*--- For some wall function types, some additional info + is needed, which is extracted from option_value. ---*/ + switch( this->walltype[i] ) { + + case EQUILIBRIUM_WALL_MODEL: { + + /* LES equilibrium wall model. The exchange distance, stretching + factor and number of points in the wall model must be specified. */ + this->intInfo[i] = new unsigned short[1]; + this->doubleInfo[i] = new su2double[2]; + + istringstream ss_1st(option_value[counter++]); + if (!(ss_1st >> this->doubleInfo[i][0])) { + return badValue(option_value, "su2double", this->name); + } + + istringstream ss_2nd(option_value[counter++]); + if (!(ss_2nd >> this->doubleInfo[i][1])) { + return badValue(option_value, "su2double", this->name); + } + + istringstream ss_3rd(option_value[counter++]); + if (!(ss_3rd >> this->intInfo[i][0])) { + return badValue(option_value, "unsigned short", this->name); + } + + break; + } + + case NONEQUILIBRIUM_WALL_MODEL: { + + /* LES non-equilibrium model. The RANS turbulence model and + the exchange distance need to be specified. */ + this->intInfo[i] = new unsigned short[1]; + this->doubleInfo[i] = new su2double[1]; + + /* Check for a valid RANS turbulence model. */ + map::const_iterator iit; + iit = Turb_Model_Map.find(option_value[counter++]); + if(iit == Turb_Model_Map.end()) { + string newstring; + newstring.append(this->name); + newstring.append(", marker "); + newstring.append(this->markers[i]); + newstring.append(", wall function type "); + newstring.append(option_value[counter-2]); + newstring.append(": Invalid RANS turbulence model, "); + newstring.append(option_value[counter-1]); + newstring.append(", specified"); + return newstring; + } + + this->intInfo[i][0] = iit->second; + + /* Extract the exchange distance. */ + istringstream ss_1st(option_value[counter++]); + if (!(ss_1st >> this->doubleInfo[i][0])) { + return badValue(option_value, "su2double", this->name); + } + + break; + } + case LOGARITHMIC_WALL_MODEL: { + + /* LES Logarithmic law-of-the-wall model. The exchange distance, stretching + factor and number of points in the wall model must be specified. */ + this->intInfo[i] = new unsigned short[1]; + this->doubleInfo[i] = new su2double[2]; + + istringstream ss_1st(option_value[counter++]); + if (!(ss_1st >> this->doubleInfo[i][0])) { + return badValue(option_value, "su2double", this->name); + } + + istringstream ss_2nd(option_value[counter++]); + if (!(ss_2nd >> this->doubleInfo[i][1])) { + return badValue(option_value, "su2double", this->name); + } + + istringstream ss_3rd(option_value[counter++]); + if (!(ss_3rd >> this->intInfo[i][0])) { + return badValue(option_value, "unsigned short", this->name); + } + + break; + } + + default: // Just to avoid a compiler warning. + break; + } + } + + // Need to return something... + return ""; + } + + void SetDefault() { + this->nMarkers = 0; + this->markers = NULL; + this->walltype = NULL; + this->intInfo = NULL; + this->doubleInfo = NULL; + } +}; diff --git a/Common/include/toolboxes/printing_toolbox.hpp b/Common/include/toolboxes/printing_toolbox.hpp index c4df080db1ad..28ef1bef3fe9 100644 --- a/Common/include/toolboxes/printing_toolbox.hpp +++ b/Common/include/toolboxes/printing_toolbox.hpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -31,28 +31,29 @@ #include #include #include +#include #include "../datatype_structure.hpp" -namespace PrintingToolbox { +namespace PrintingToolbox { /*! * \class CTablePrinter - * \brief Class for writing output in a table. - * + * \brief Class for writing output in a table. + * * For example the output - * + * * +-------------------------------------------+ * | MG Level| Presmooth|PostSmooth|CorrectSmo| * +-------------------------------------------+ * | 0| 1| 0| 0| - * | 1| 1| 0| 0| + * | 1| 1| 0| 0| * | 2| 1| 0| 0| * | 3| 1| 0| 0| * +-------------------------------------------+ - * - * - * can be generated with the code - * + * + * + * can be generated with the code + * * CTablePrinter MGTable(&std::cout); * MGTable.AddColumn("MG Level", 10); * MGTable.AddColumn("Presmooth", 10); @@ -63,15 +64,15 @@ namespace PrintingToolbox { * MGTable << iLevel << MG_PreSmooth[iLevel] << MG_PostSmooth[iLevel] << MG_CorrecSmooth[iLevel]; * } * MGTable.PrintFooter(); - * - * + * + * * \author T. Albring */ class CTablePrinter{ public: CTablePrinter(std::ostream * output, const std::string & separator = "|"); ~CTablePrinter(); - + enum alignment { CENTER, LEFT, @@ -83,7 +84,7 @@ class CTablePrinter{ * \return Number of columns. */ int GetNumColumns() const; - + /*! * \brief Get total width of the table. * \return Total width of the table. @@ -95,54 +96,54 @@ class CTablePrinter{ * \param[in] separator - The separation character. */ void SetSeparator(const std::string & separator); - + /*! * \brief Set the separator between columns (inner decoration) * \param[in] separator - The separation character. */ void SetInnerSeparator(const std::string & inner_separator); - + /*! * \brief Set the alignment of the table entries (CENTER only works for the header at the moment). * \param[in] align_ - The alignment (CENTER, LEFT, RIGHT). */ void SetAlign(int align_); - + /*! * \brief Set whether to print the line at the bottom of the table. * \param[in] print - If TRUE, the bottom line is printed. */ void SetPrintHeaderBottomLine(bool print); - + /*! * \brief Set whether to print the line at the top of the table. * \param[in] print - If TRUE, the top line is printed. */ void SetPrintHeaderTopLine(bool print); - - + + /*! * \brief Add a column to the table by specifiying the header name and the width. * \param[in] header_name - The name printed in the header. * \param[in] column_width - The width of the column. */ void AddColumn(const std::string & header_name, int column_width); - + /*! * \brief Print the header. */ void PrintHeader(); - + /*! * \brief Print the footer. */ void PrintFooter(); - + /*! * \brief Set the floating point precision. */ void SetPrecision(int precision); - + template CTablePrinter& operator<<(T input){ int indent = 0; @@ -155,13 +156,13 @@ class CTablePrinter{ if(align_ == LEFT) *out_stream_ << std::left; else if (align_ == RIGHT || align_ == CENTER) - *out_stream_ << std::right; + *out_stream_ << std::right; /*--- Print the current column value to the stream --- */ *out_stream_ << std::setw(column_widths_.at(j_) - indent) << std::setprecision(precision_) << input; - /*--- Reset the column counter and if it is the last column, + /*--- Reset the column counter and if it is the last column, * add also a line break ---*/ if (j_ == GetNumColumns()-1){ *out_stream_ << std::setw(indent+1+(int)separator_.size()) << separator_ + "\n"; @@ -176,7 +177,7 @@ class CTablePrinter{ } private: - + /*! * \brief Print a horizontal line. */ @@ -188,8 +189,8 @@ class CTablePrinter{ std::string separator_; /*< \brief Column separator char. */ std::string inner_separator_; /*< \brief Inner column separator char. */ - int precision_; /*< \brief Floating point precision */ - + int precision_; /*< \brief Floating point precision */ + int i_; /*< \brief Index of the current row. */ int j_; /*< \brief Index of the current column. */ @@ -210,7 +211,7 @@ inline void PrintScreenFixed(std::ostream &stream, su2double val, unsigned short inline void PrintScreenScientific(std::ostream &stream, su2double val, unsigned short field_width) { stream.precision(4); stream.setf(std::ios::scientific, std::ios::floatfield); stream.width(field_width); stream << std::right << val; - stream.unsetf(std::ios::scientific); + stream.unsetf(std::ios::scientific); } inline void PrintScreenInteger(std::ostream &stream, unsigned long val, unsigned short field_width){ @@ -246,32 +247,51 @@ inline su2double stod(const std::string s){ } inline std::string to_string(const su2double number){ - + std::stringstream ss; - + ss << number; - + return ss.str(); - + } const static char* ws = " \t\n\r\f\v"; // trim from end of string (right) inline std::string& rtrim(std::string& s, const char* t = ws){ - s.erase(s.find_last_not_of(t) + 1); - return s; + s.erase(s.find_last_not_of(t) + 1); + return s; } // trim from beginning of string (left) inline std::string& ltrim(std::string& s, const char* t = ws){ - s.erase(0, s.find_first_not_of(t)); - return s; + s.erase(0, s.find_first_not_of(t)); + return s; } // trim from both ends of string (right then left) inline std::string& trim(std::string& s, const char* t = ws){ - return ltrim(rtrim(s, t), t); + return ltrim(rtrim(s, t), t); +} + +/*! + * \brief utility function for converting strings to uppercase + * \param[in,out] str - string we want to convert + */ +inline void StringToUpperCase(std::string & str) { + std::transform(str.begin(), str.end(), str.begin(), ::toupper); +} + +/*! + * \brief utility function for converting strings to uppercase + * \param[in] str - string we want a copy of converted to uppercase + * \return a copy of str in uppercase + */ +inline std::string StringToUpperCase(const std::string & str) { + std::string upp_str(str); + std::transform(upp_str.begin(), upp_str.end(), upp_str.begin(), ::toupper); + return upp_str; } } diff --git a/Common/src/config_structure.cpp b/Common/src/config_structure.cpp index eec541d01b8e..2d3b4c718afb 100644 --- a/Common/src/config_structure.cpp +++ b/Common/src/config_structure.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -31,6 +31,11 @@ #include "../include/fem_gauss_jacobi_quadrature.hpp" #include "../include/fem_geometry_structure.hpp" +#include "../include/ad_structure.hpp" +#include "../include/toolboxes/printing_toolbox.hpp" + +using namespace PrintingToolbox; + #ifdef PROFILE #ifdef HAVE_MKL #include "mkl.h" @@ -52,18 +57,16 @@ vector GEMM_Profile_MaxTime; /*!< \brief Maximum time spent for thi //#pragma omp threadprivate(Profile_Function_tp, Profile_Time_tp, Profile_ID_tp, Profile_Map_tp) -#include "../include/ad_structure.hpp" -#include "../include/toolboxes/printing_toolbox.hpp" CConfig::CConfig(char case_filename[MAX_STRING_SIZE], unsigned short val_software, bool verb_high) { - + base_config = true; - - /*--- Store MPI rank and size ---*/ - + + /*--- Store MPI rank and size ---*/ + rank = SU2_MPI::GetRank(); size = SU2_MPI::GetSize(); - + iZone = 0; nZone = 1; @@ -78,13 +81,13 @@ CConfig::CConfig(char case_filename[MAX_STRING_SIZE], unsigned short val_softwar /*--- Parsing the config file ---*/ SetConfig_Parsing(case_filename); - + /*--- Set the default values for all of the options that weren't set ---*/ - + SetDefault(); - + /*--- Set number of zone ---*/ - + SetnZone(); /*--- Configuration file postprocessing ---*/ @@ -103,19 +106,19 @@ CConfig::CConfig(char case_filename[MAX_STRING_SIZE], unsigned short val_softwar } CConfig::CConfig(CConfig* config, char case_filename[MAX_STRING_SIZE], unsigned short val_software, unsigned short val_iZone, unsigned short val_nZone, bool verb_high) { - + unsigned short val_nDim; - + base_config = false; - - /*--- Store MPI rank and size ---*/ - + + /*--- Store MPI rank and size ---*/ + rank = SU2_MPI::GetRank(); size = SU2_MPI::GetSize(); iZone = val_iZone; nZone = val_nZone; - + /*--- Initialize pointers to Null---*/ SetPointersNull(); @@ -127,17 +130,17 @@ CConfig::CConfig(CConfig* config, char case_filename[MAX_STRING_SIZE], unsigned /*--- Parsing the config file ---*/ SetConfig_Parsing(case_filename); - + /*--- Set default options from base config ---*/ - + SetDefaultFromConfig(config); - + /*--- Set the default values for all of the options that weren't set ---*/ - + SetDefault(); - + /*--- Get the dimension --- */ - + val_nDim = GetnDim(Mesh_FileName, Mesh_FileFormat); /*--- Configuration file postprocessing ---*/ @@ -154,21 +157,21 @@ CConfig::CConfig(CConfig* config, char case_filename[MAX_STRING_SIZE], unsigned SetOutput(val_software, val_iZone); Multizone_Problem = config->GetMultizone_Problem(); - + } CConfig::CConfig(char case_filename[MAX_STRING_SIZE], unsigned short val_software) { base_config = true; - + nZone = 1; iZone = 0; - /*--- Store MPI rank and size ---*/ + /*--- Store MPI rank and size ---*/ rank = SU2_MPI::GetRank(); size = SU2_MPI::GetSize(); - + /*--- Initialize pointers to Null---*/ SetPointersNull(); @@ -180,13 +183,13 @@ CConfig::CConfig(char case_filename[MAX_STRING_SIZE], unsigned short val_softwar /*--- Parsing the config file ---*/ SetConfig_Parsing(case_filename); - + /*--- Set the default values for all of the options that weren't set ---*/ - + SetDefault(); - + /*--- Set number of zones --- */ - + SetnZone(); /*--- Configuration file postprocessing ---*/ @@ -198,7 +201,7 @@ CConfig::CConfig(char case_filename[MAX_STRING_SIZE], unsigned short val_softwar SetMarkers(val_software); /*--- Print the header --- */ - + SetHeader(val_software); } @@ -206,12 +209,12 @@ CConfig::CConfig(char case_filename[MAX_STRING_SIZE], unsigned short val_softwar CConfig::CConfig(char case_filename[MAX_STRING_SIZE], CConfig *config) { base_config = true; - - /*--- Store MPI rank and size ---*/ - + + /*--- Store MPI rank and size ---*/ + rank = SU2_MPI::GetRank(); size = SU2_MPI::GetSize(); - + bool runtime_file = false; /*--- Initialize pointers to Null---*/ @@ -225,9 +228,9 @@ CConfig::CConfig(char case_filename[MAX_STRING_SIZE], CConfig *config) { /*--- Parsing the config file ---*/ runtime_file = SetRunTime_Parsing(case_filename); - + /*--- Set the default values for all of the options that weren't set ---*/ - + SetDefault(); /*--- Update original config file ---*/ @@ -254,15 +257,15 @@ void CConfig::addDoubleOption(const string name, su2double & option_field, su2do // Check if the key is already in the map. If this fails, it is coder error // and not user error, so throw. assert(option_map.find(name) == option_map.end()); - + // Add this option to the list of all the options all_options.insert(pair(name, true)); - + // Create the parser for a su2double option with a reference to the option_field and the desired // default value. This will take the string in the config file, convert it to a su2double, and // place that su2double in the memory location specified by the reference. COptionBase* val = new COptionDouble(name, option_field, default_value); - + // Create an association between the option name ("CFL") and the parser generated above. // During configuration, the parsing script will get the option name, and use this map // to find how to parse that option. @@ -334,12 +337,12 @@ void CConfig::addEnumListOption(const string name, unsigned short & input_size, } void CConfig::addDoubleArrayOption(const string name, const int size, su2double * & option_field, su2double * default_value) { - + // su2double * def = new su2double [size]; // for (int i = 0; i < size; i++) { // def[i] = default_value[i]; // } - + assert(option_map.find(name) == option_map.end()); all_options.insert(pair(name, true)); COptionBase* val = new COptionDoubleArray(name, size, option_field, default_value); @@ -552,74 +555,74 @@ unsigned short CConfig::GetnZone(string val_mesh_filename, unsigned short val_fo mesh_file.close(); break; - + } - + case CGNS_GRID: { - + #ifdef HAVE_CGNS - + /*--- Local variables which are needed when calling the CGNS mid-level API. ---*/ - + int fn, nbases = 0, nzones = 0, file_type; int cell_dim = 0, phys_dim = 0; char basename[CGNS_STRING_SIZE]; - + /*--- Check whether the supplied file is truly a CGNS file. ---*/ - + if ( cg_is_cgns(val_mesh_filename.c_str(), &file_type) != CG_OK ) { SU2_MPI::Error(val_mesh_filename + string(" was not found or is not a properly formatted CGNS file.\n") + string("Note that SU2 expects unstructured CGNS files in ADF data format."), CURRENT_FUNCTION); } - + /*--- Open the CGNS file for reading. The value of fn returned is the specific index number for this file and will be repeatedly used in the function calls. ---*/ - + if (cg_open(val_mesh_filename.c_str(), CG_MODE_READ, &fn)) cg_error_exit(); - + /*--- Get the number of databases. This is the highest node in the CGNS heirarchy. ---*/ - + if (cg_nbases(fn, &nbases)) cg_error_exit(); - + /*--- Check if there is more than one database. Throw an error if there is because this reader can currently only handle one database. ---*/ - + if ( nbases > 1 ) { SU2_MPI::Error("CGNS reader currently incapable of handling more than 1 database." , CURRENT_FUNCTION); } - + /*--- Read the databases. Note that the indexing starts at 1. ---*/ - + for ( int i = 1; i <= nbases; i++ ) { - + if (cg_base_read(fn, i, basename, &cell_dim, &phys_dim)) cg_error_exit(); - + /*--- Get the number of zones for this base. ---*/ - + if (cg_nzones(fn, i, &nzones)) cg_error_exit(); - + } /*--- Close the CGNS file. ---*/ if ( cg_close(fn) ) cg_error_exit(); - + /*--- Set the number of zones as read from the CGNS file ---*/ - + nZone = nzones; - + #else SU2_MPI::Error(string(" SU2 built without CGNS support. \n") + string(" To use CGNS, build SU2 accordingly."), CURRENT_FUNCTION); #endif - + break; } case RECTANGLE: { @@ -633,7 +636,7 @@ unsigned short CConfig::GetnZone(string val_mesh_filename, unsigned short val_fo } return (unsigned short) nZone; - + } unsigned short CConfig::GetnDim(string val_mesh_filename, unsigned short val_format) { @@ -723,13 +726,13 @@ unsigned short CConfig::GetnDim(string val_mesh_filename, unsigned short val_for /*--- Set the problem dimension as read from the CGNS file ---*/ nDim = cell_dim; - + #else SU2_MPI::Error(string(" SU2 built without CGNS support. \n") + string(" To use CGNS, build SU2 accordingly."), CURRENT_FUNCTION); #endif - + break; } case RECTANGLE: { @@ -749,7 +752,7 @@ unsigned short CConfig::GetnDim(string val_mesh_filename, unsigned short val_for } void CConfig::SetPointersNull(void) { - + Marker_CfgFile_GeoEval = NULL; Marker_All_GeoEval = NULL; Marker_CfgFile_Monitoring = NULL; Marker_All_Monitoring = NULL; Marker_CfgFile_Designing = NULL; Marker_All_Designing = NULL; @@ -770,7 +773,7 @@ void CConfig::SetPointersNull(void) { Marker_CfgFile_MixingPlaneInterface = NULL; Marker_All_MixingPlaneInterface = NULL; Marker_CfgFile_PyCustom = NULL; Marker_All_PyCustom = NULL; - + Marker_DV = NULL; Marker_Moving = NULL; Marker_Monitoring = NULL; Marker_Designing = NULL; Marker_GeoEval = NULL; Marker_Plotting = NULL; Marker_Analyze = NULL; Marker_PyCustom = NULL; Marker_WallFunctions = NULL; @@ -779,7 +782,7 @@ void CConfig::SetPointersNull(void) { Kind_WallFunctions = NULL; IntInfo_WallFunctions = NULL; DoubleInfo_WallFunctions = NULL; - + Config_Filenames = NULL; /*--- Marker Pointers ---*/ @@ -800,37 +803,37 @@ void CConfig::SetPointersNull(void) { Marker_ZoneInterface = NULL; Marker_All_ZoneInterface= NULL; Marker_Riemann = NULL; Marker_Fluid_InterfaceBound = NULL; Marker_CHTInterface = NULL; Marker_Damper = NULL; - + /*--- Boundary Condition settings ---*/ Isothermal_Temperature = NULL; Heat_Flux = NULL; Displ_Value = NULL; Load_Value = NULL; FlowLoad_Value = NULL; Damper_Constant = NULL; - + /*--- Inlet Outlet Boundary Condition settings ---*/ Inlet_Ttotal = NULL; Inlet_Ptotal = NULL; Inlet_FlowDir = NULL; Inlet_Temperature = NULL; Inlet_Pressure = NULL; Inlet_Velocity = NULL; Outlet_Pressure = NULL; - + /*--- Engine Boundary Condition settings ---*/ - + Inflow_Pressure = NULL; Inflow_MassFlow = NULL; Inflow_ReverseMassFlow = NULL; Inflow_TotalPressure = NULL; Inflow_Temperature = NULL; Inflow_TotalTemperature = NULL; Inflow_RamDrag = NULL; Inflow_Force = NULL; Inflow_Power = NULL; Inflow_Mach = NULL; - + Exhaust_Pressure = NULL; Exhaust_Temperature = NULL; Exhaust_MassFlow = NULL; Exhaust_TotalPressure = NULL; Exhaust_TotalTemperature = NULL; Exhaust_GrossThrust = NULL; Exhaust_Force = NULL; Exhaust_Power = NULL; Exhaust_Temperature_Target = NULL; Exhaust_Pressure_Target = NULL; - + Engine_Mach = NULL; Engine_Force = NULL; Engine_Power = NULL; Engine_NetThrust = NULL; Engine_GrossThrust = NULL; Engine_Area = NULL; EngineInflow_Target = NULL; - + Exhaust_Temperature_Target = NULL; Exhaust_Temperature = NULL; Exhaust_Pressure_Target = NULL; Inlet_Ttotal = NULL; Inlet_Ptotal = NULL; Inlet_FlowDir = NULL; Inlet_Temperature = NULL; Inlet_Pressure = NULL; @@ -849,7 +852,7 @@ void CConfig::SetPointersNull(void) { Electric_Constant = NULL; /*--- Actuator Disk Boundary Condition settings ---*/ - + ActDiskInlet_Pressure = NULL; ActDiskInlet_TotalPressure = NULL; ActDiskInlet_Temperature = NULL; ActDiskInlet_TotalTemperature = NULL; ActDiskInlet_MassFlow = NULL; ActDiskInlet_RamDrag = NULL; ActDiskInlet_Force = NULL; ActDiskInlet_Power = NULL; @@ -858,7 +861,7 @@ void CConfig::SetPointersNull(void) { ActDiskOutlet_TotalPressure = NULL; ActDiskOutlet_GrossThrust = NULL; ActDiskOutlet_Force = NULL; ActDiskOutlet_Power = NULL; ActDiskOutlet_Temperature = NULL; ActDiskOutlet_TotalTemperature = NULL; ActDiskOutlet_MassFlow = NULL; - + ActDisk_DeltaPress = NULL; ActDisk_DeltaTemp = NULL; ActDisk_TotalPressRatio = NULL; ActDisk_TotalTempRatio = NULL; ActDisk_StaticPressRatio = NULL; ActDisk_StaticTempRatio = NULL; ActDisk_NetThrust = NULL; ActDisk_GrossThrust = NULL; @@ -875,7 +878,7 @@ void CConfig::SetPointersNull(void) { Surface_IDC_Mach = NULL; Surface_IDR = NULL; ActDisk_Mach = NULL; ActDisk_Force = NULL; ActDisk_BCThrust = NULL; ActDisk_BCThrust_Old = NULL; - + /*--- Miscellaneous/unsorted ---*/ Aeroelastic_plunge = NULL; @@ -885,16 +888,16 @@ void CConfig::SetPointersNull(void) { Inc_Velocity_Init = NULL; RefOriginMoment = NULL; - CFL_AdaptParam = NULL; + CFL_AdaptParam = NULL; CFL = NULL; HTP_Axis = NULL; PlaneTag = NULL; - Kappa_Flow = NULL; + Kappa_Flow = NULL; Kappa_AdjFlow = NULL; Kappa_Heat = NULL; Stations_Bounds = NULL; - ParamDV = NULL; - DV_Value = NULL; + ParamDV = NULL; + DV_Value = NULL; Design_Variable = NULL; Hold_GridFixed_Coord = NULL; @@ -911,46 +914,46 @@ void CConfig::SetPointersNull(void) { Kind_Inc_Inlet = NULL; Kind_Inc_Outlet = NULL; - + Kind_ObjFunc = NULL; Weight_ObjFunc = NULL; /*--- Moving mesh pointers ---*/ - + nKind_SurfaceMovement = 0; Kind_SurfaceMovement = NULL; LocationStations = NULL; - Motion_Origin = NULL; - Translation_Rate = NULL; - Rotation_Rate = NULL; - Pitching_Omega = NULL; - Pitching_Ampl = NULL; - Pitching_Phase = NULL; - Plunging_Omega = NULL; - Plunging_Ampl = NULL; - MarkerMotion_Origin = NULL; - MarkerTranslation_Rate = NULL; - MarkerRotation_Rate = NULL; - MarkerPitching_Omega = NULL; - MarkerPitching_Ampl = NULL; - MarkerPitching_Phase = NULL; - MarkerPlunging_Omega = NULL; - MarkerPlunging_Ampl = NULL; + Motion_Origin = NULL; + Translation_Rate = NULL; + Rotation_Rate = NULL; + Pitching_Omega = NULL; + Pitching_Ampl = NULL; + Pitching_Phase = NULL; + Plunging_Omega = NULL; + Plunging_Ampl = NULL; + MarkerMotion_Origin = NULL; + MarkerTranslation_Rate = NULL; + MarkerRotation_Rate = NULL; + MarkerPitching_Omega = NULL; + MarkerPitching_Ampl = NULL; + MarkerPitching_Phase = NULL; + MarkerPlunging_Omega = NULL; + MarkerPlunging_Ampl = NULL; RefOriginMoment_X = NULL; RefOriginMoment_Y = NULL; RefOriginMoment_Z = NULL; MoveMotion_Origin = NULL; /*--- Periodic BC pointers. ---*/ - + Periodic_Translate = NULL; Periodic_Rotation = NULL; Periodic_Center = NULL; Periodic_Translation= NULL; Periodic_RotAngles = NULL; Periodic_RotCenter = NULL; /* Harmonic Balance Frequency pointer */ - + Omega_HB = NULL; - + /*--- Initialize some default arrays to NULL. ---*/ - + default_vel_inf = NULL; default_ffd_axis = NULL; default_eng_cyl = NULL; @@ -975,14 +978,14 @@ void CConfig::SetPointersNull(void) { default_sineload_coeff = NULL; default_nacelle_location = NULL; default_wrt_freq = NULL; - + default_cp_polycoeffs = NULL; default_mu_polycoeffs = NULL; default_kt_polycoeffs = NULL; CpPolyCoefficientsND = NULL; MuPolyCoefficientsND = NULL; KtPolyCoefficientsND = NULL; - + Riemann_FlowDir = NULL; Giles_FlowDir = NULL; CoordFFDBox = NULL; @@ -990,7 +993,7 @@ void CConfig::SetPointersNull(void) { FFDTag = NULL; nDV_Value = NULL; TagFFDBox = NULL; - + Kind_Data_Riemann = NULL; Riemann_Var1 = NULL; Riemann_Var2 = NULL; @@ -1021,19 +1024,19 @@ void CConfig::SetPointersNull(void) { top_optim_kernels = NULL; top_optim_kernel_params = NULL; top_optim_filter_radius = NULL; - + ScreenOutput = NULL; HistoryOutput = NULL; VolumeOutput = NULL; VolumeOutputFiles = NULL; /*--- Variable initialization ---*/ - + TimeIter = 0; InnerIter = 0; nIntCoeffs = 0; OuterIter = 0; - + AoA_Offset = 0; AoS_Offset = 0; @@ -1043,30 +1046,30 @@ void CConfig::SetPointersNull(void) { Aeroelastic_Simulation = false; nSpanMaxAllZones = 1; - + Restart_Bandwidth_Agg = 0.0; - + Mesh_Box_Size = NULL; - + } void CConfig::SetRunTime_Options(void) { - + /* DESCRIPTION: Number of external iterations */ - + addUnsignedLongOption("TIME_ITER", nTimeIter, 999999); - + /* DESCRIPTION: CFL Number */ - + addDoubleOption("CFL_NUMBER", CFLFineGrid, 10); } void CConfig::SetConfig_Options() { - + /*--- Allocate some default arrays needed for lists of doubles. ---*/ - + default_vel_inf = new su2double[3]; default_ffd_axis = new su2double[3]; default_eng_cyl = new su2double[7]; @@ -1091,12 +1094,12 @@ void CConfig::SetConfig_Options() { default_sineload_coeff = new su2double[3]; default_nacelle_location = new su2double[5]; default_wrt_freq = new su2double[3]; - + /*--- All temperature polynomial fits for the fluid models currently assume a quartic form (5 coefficients). For example, Cp(T) = b0 + b1*T + b2*T^2 + b3*T^3 + b4*T^4. By default, all coeffs are set to zero and will be properly non-dim. in the solver. ---*/ - + nPolyCoeffs = 5; default_cp_polycoeffs = new su2double[nPolyCoeffs]; default_mu_polycoeffs = new su2double[nPolyCoeffs]; @@ -1126,7 +1129,7 @@ void CConfig::SetConfig_Options() { /*!\brief SOLVER \n DESCRIPTION: Type of solver \n Options: see \link Solver_Map \endlink \n DEFAULT: NO_SOLVER \ingroup Config*/ addEnumOption("SOLVER", Kind_Solver, Solver_Map, NO_SOLVER); - /*!\brief MULTIZONE \n DESCRIPTION: Enable multizone mode \ingroup Config*/ + /*!\brief MULTIZONE \n DESCRIPTION: Enable multizone mode \ingroup Config*/ addBoolOption("MULTIZONE", Multizone_Problem, NO); /*!\brief PHYSICAL_PROBLEM \n DESCRIPTION: Physical governing equations \n Options: see \link Solver_Map \endlink \n DEFAULT: NO_SOLVER \ingroup Config*/ addEnumOption("MULTIZONE_SOLVER", Kind_MZSolver, Multizone_Map, MZ_BLOCK_GAUSS_SEIDEL); @@ -1155,7 +1158,7 @@ void CConfig::SetConfig_Options() { addBoolOption("WEAKLY_COUPLED_HEAT_EQUATION", Weakly_Coupled_Heat, NO); addBoolOption("ADJ_FSI", FSI_Problem, NO); - + /*\brief AXISYMMETRIC \n DESCRIPTION: Axisymmetric simulation \n DEFAULT: false \ingroup Config */ addBoolOption("AXISYMMETRIC", Axisymmetric, false); /* DESCRIPTION: Add the gravity force */ @@ -1194,7 +1197,7 @@ void CConfig::SetConfig_Options() { addDoubleOption("THERMAL_EXPANSION_COEFF", Thermal_Expansion_Coeff, 0.00347); /*!\brief MOLECULAR_WEIGHT \n DESCRIPTION: Molecular weight for an incompressible ideal gas (28.96 g/mol (air) default) \ingroup Config*/ addDoubleOption("MOLECULAR_WEIGHT", Molecular_Weight, 28.96); - + /*--- Options related to VAN der WAALS MODEL and PENG ROBINSON ---*/ /* DESCRIPTION: Critical Temperature, default value for AIR */ @@ -1237,9 +1240,9 @@ void CConfig::SetConfig_Options() { /* DESCRIPTION: default value for AIR */ addDoubleOption("KT_CONSTANT", Kt_Constant , 0.0257); - + /*--- Options related to temperature polynomial coefficients for fluid models. ---*/ - + /* DESCRIPTION: Definition of the temperature polynomial coefficients for specific heat Cp. */ addDoubleArrayOption("CP_POLYCOEFFS", nPolyCoeffs, CpPolyCoefficients, default_cp_polycoeffs); /* DESCRIPTION: Definition of the temperature polynomial coefficients for specific heat Cp. */ @@ -1299,7 +1302,7 @@ void CConfig::SetConfig_Options() { addDoubleOption("INC_INLET_DAMPING", Inc_Inlet_Damping, 0.1); /*!\brief INC_OUTLET_DAMPING \n DESCRIPTION: Damping factor applied to the iterative updates to the pressure at a mass flow outlet in incompressible flow (0.1 by default). \ingroup Config*/ addDoubleOption("INC_OUTLET_DAMPING", Inc_Outlet_Damping, 0.1); - + /*!\brief FREESTREAM_TEMPERATURE_VE\n DESCRIPTION: Free-stream vibrational-electronic temperature (288.15 K by default) \ingroup Config*/ addDoubleOption("FREESTREAM_TEMPERATURE_VE", Temperature_ve_FreeStream, 288.15); default_vel_inf[0] = 1.0; default_vel_inf[1] = 0.0; default_vel_inf[2] = 0.0; @@ -1609,7 +1612,7 @@ void CConfig::SetConfig_Options() { addEnumOption("ENGINE_INFLOW_TYPE", Kind_Engine_Inflow, Engine_Inflow_Map, FAN_FACE_MACH); /* DESCRIPTION: Evaluate a problem with engines */ addBoolOption("ENGINE", Engine, false); - + /* DESCRIPTION: Compute buffet sensor */ addBoolOption("BUFFET_MONITORING", Buffet_Monitoring, false); /* DESCRIPTION: Sharpness coefficient for the buffet sensor */ @@ -1738,10 +1741,10 @@ void CConfig::SetConfig_Options() { addEnumOption("FSI_DISCADJ_LIN_SOLVER_STRUC", Kind_DiscAdj_Linear_Solver_FSI_Struc, Linear_Solver_Map, CONJUGATE_GRADIENT); /* DESCRIPTION: Preconditioner for the discrete adjoint Krylov linear solvers */ addEnumOption("FSI_DISCADJ_LIN_PREC_STRUC", Kind_DiscAdj_Linear_Prec_FSI_Struc, Linear_Solver_Prec_Map, JACOBI); - + /*!\par CONFIG_CATEGORY: Convergence\ingroup Config*/ /*--- Options related to convergence ---*/ - + /*!\brief CONV_CRITERIA * \n DESCRIPTION: Convergence criteria \n OPTIONS: see \link Converge_Crit_Map \endlink \n DEFAULT: RESIDUAL \ingroup Config*/ addEnumOption("CONV_CRITERIA", ConvCriteria, Converge_Crit_Map, RESIDUAL); @@ -1855,7 +1858,7 @@ void CConfig::SetConfig_Options() { /*!\brief CONV_NUM_METHOD_TURB * \n DESCRIPTION: Convective numerical method \ingroup Config*/ addConvectOption("CONV_NUM_METHOD_TURB", Kind_ConvNumScheme_Turb, Kind_Centered_Turb, Kind_Upwind_Turb); - + /*!\brief MUSCL_FLOW \n DESCRIPTION: Check if the MUSCL scheme should be used \ingroup Config*/ addBoolOption("MUSCL_ADJTURB", MUSCL_AdjTurb, false); /*!\brief SLOPE_LIMITER_ADJTURB @@ -1958,18 +1961,18 @@ void CConfig::SetConfig_Options() { addStringOption("MESH_FILENAME", Mesh_FileName, string("mesh.su2")); /*!\brief MESH_OUT_FILENAME \n DESCRIPTION: Mesh output file name. Used when converting, scaling, or deforming a mesh. \n DEFAULT: mesh_out.su2 \ingroup Config*/ addStringOption("MESH_OUT_FILENAME", Mesh_Out_FileName, string("mesh_out.su2")); - + /* DESCRIPTION: List of the number of grid points in the RECTANGLE or BOX grid in the x,y,z directions. (default: (33,33,33) ). */ addShortListOption("MESH_BOX_SIZE", nMesh_Box_Size, Mesh_Box_Size); - + /* DESCRIPTION: List of the length of the RECTANGLE or BOX grid in the x,y,z directions. (default: (1.0,1.0,1.0) ). */ array default_mesh_box_length = {{1.0, 1.0, 1.0}}; addDoubleArrayOption("MESH_BOX_LENGTH", 3, Mesh_Box_Length, default_mesh_box_length.data()); - + /* DESCRIPTION: List of the offset from 0.0 of the RECTANGLE or BOX grid in the x,y,z directions. (default: (0.0,0.0,0.0) ). */ array default_mesh_box_offset = {{0.0, 0.0, 0.0}}; addDoubleArrayOption("MESH_BOX_OFFSET", 3, Mesh_Box_Offset, default_mesh_box_offset.data()); - + /* DESCRIPTION: Determine if the mesh file supports multizone. \n DEFAULT: true (temporarily) */ addBoolOption("MULTIZONE_MESH", Multizone_Mesh, true); /* DESCRIPTION: Determine if we need to allocate memory to store the multizone residual. \n DEFAULT: true (temporarily) */ @@ -2079,17 +2082,17 @@ void CConfig::SetConfig_Options() { addStringListOption("MARKER_MOVING", nMarker_Moving, Marker_Moving); /* DESCRIPTION: Mach number (non-dimensional, based on the mesh velocity and freestream vals.) */ addDoubleOption("MACH_MOTION", Mach_Motion, 0.0); - default_vel_inf[0] = 0.0; default_vel_inf[1] = 0.0; default_vel_inf[2] = 0.0; + default_vel_inf[0] = 0.0; default_vel_inf[1] = 0.0; default_vel_inf[2] = 0.0; /* DESCRIPTION: Coordinates of the rigid motion origin */ addDoubleArrayOption("MOTION_ORIGIN", 3, Motion_Origin, default_vel_inf); /* DESCRIPTION: Translational velocity vector (m/s) in the x, y, & z directions (RIGID_MOTION only) */ - addDoubleArrayOption("TRANSLATION_RATE", 3, Translation_Rate, default_vel_inf); + addDoubleArrayOption("TRANSLATION_RATE", 3, Translation_Rate, default_vel_inf); /* DESCRIPTION: Angular velocity vector (rad/s) about x, y, & z axes (RIGID_MOTION only) */ addDoubleArrayOption("ROTATION_RATE", 3, Rotation_Rate, default_vel_inf); /* DESCRIPTION: Pitching angular freq. (rad/s) about x, y, & z axes (RIGID_MOTION only) */ addDoubleArrayOption("PITCHING_OMEGA", 3, Pitching_Omega, default_vel_inf); /* DESCRIPTION: Pitching amplitude (degrees) about x, y, & z axes (RIGID_MOTION only) */ - addDoubleArrayOption("PITCHING_AMPL", 3, Pitching_Ampl, default_vel_inf); + addDoubleArrayOption("PITCHING_AMPL", 3, Pitching_Ampl, default_vel_inf); /* DESCRIPTION: Pitching phase offset (degrees) about x, y, & z axes (RIGID_MOTION only) */ addDoubleArrayOption("PITCHING_PHASE", 3, Pitching_Phase, default_vel_inf); /* DESCRIPTION: Plunging angular freq. (rad/s) in x, y, & z directions (RIGID_MOTION only) */ @@ -2099,13 +2102,13 @@ void CConfig::SetConfig_Options() { /* DESCRIPTION: Coordinates of the rigid motion origin */ addDoubleListOption("SURFACE_MOTION_ORIGIN", nMarkerMotion_Origin, MarkerMotion_Origin); /* DESCRIPTION: Translational velocity vector (m/s) in the x, y, & z directions (DEFORMING only) */ - addDoubleListOption("SURFACE_TRANSLATION_RATE", nMarkerTranslation, MarkerTranslation_Rate); + addDoubleListOption("SURFACE_TRANSLATION_RATE", nMarkerTranslation, MarkerTranslation_Rate); /* DESCRIPTION: Angular velocity vector (rad/s) about x, y, & z axes (DEFORMING only) */ addDoubleListOption("SURFACE_ROTATION_RATE", nMarkerRotation_Rate, MarkerRotation_Rate); /* DESCRIPTION: Pitching angular freq. (rad/s) about x, y, & z axes (DEFORMING only) */ addDoubleListOption("SURFACE_PITCHING_OMEGA", nMarkerPitching_Omega, MarkerPitching_Omega); /* DESCRIPTION: Pitching amplitude (degrees) about x, y, & z axes (DEFORMING only) */ - addDoubleListOption("SURFACE_PITCHING_AMPL", nMarkerPitching_Ampl, MarkerPitching_Ampl); + addDoubleListOption("SURFACE_PITCHING_AMPL", nMarkerPitching_Ampl, MarkerPitching_Ampl); /* DESCRIPTION: Pitching phase offset (degrees) about x, y, & z axes (DEFORMING only) */ addDoubleListOption("SURFACE_PITCHING_PHASE", nMarkerPitching_Phase, MarkerPitching_Phase); /* DESCRIPTION: Plunging angular freq. (rad/s) in x, y, & z directions (DEFORMING only) */ @@ -2147,9 +2150,9 @@ void CConfig::SetConfig_Options() { addDoubleOption("RADIUS_GYRATION_SQUARED", RadiusGyrationSquared, 3.48); /* DESCRIPTION: Solve the aeroelastic equations every given number of internal iterations. */ addUnsignedShortOption("AEROELASTIC_ITER", AeroelasticIter, 3); - + /*!\par CONFIG_CATEGORY: Optimization Problem*/ - + /* DESCRIPTION: Scale the line search in the optimizer */ addDoubleOption("OPT_RELAX_FACTOR", Opt_RelaxFactor, 1.0); @@ -2500,17 +2503,17 @@ void CConfig::SetConfig_Options() { * Sets Kind_Interpolation \ingroup Config */ addEnumOption("KIND_INTERPOLATION", Kind_Interpolation, Interpolator_Map, NEAREST_NEIGHBOR); - + /*!\par KIND_INTERPOLATION \n * DESCRIPTION: Type of radial basis function to use for radial basis function interpolation. \n OPTIONS: see \link RadialBasis_Map \endlink * Sets Kind_RadialBasis \ingroup Config */ addEnumOption("KIND_RADIAL_BASIS_FUNCTION", Kind_RadialBasisFunction, RadialBasisFunction_Map, WENDLAND_C2); - + /* DESCRIPTION: Use polynomial term in radial basis function interpolation. * Options: NO, YES \ingroup Config */ addBoolOption("RADIAL_BASIS_FUNCTION_POLYNOMIAL_TERM", RadialBasisFunction_PolynomialOption, true); - + /* DESCRIPTION: Radius for radial basis function */ addDoubleOption("RADIAL_BASIS_FUNCTION_PARAMETER", RadialBasisFunction_Parameter, 1); @@ -2568,16 +2571,16 @@ void CConfig::SetConfig_Options() { /*--- options related to the FFD problem ---*/ /*!\par CONFIG_CATEGORY:FFD point inversion \ingroup Config*/ - + /* DESCRIPTION: Fix I plane */ addShortListOption("FFD_FIX_I", nFFD_Fix_IDir, FFD_Fix_IDir); - + /* DESCRIPTION: Fix J plane */ addShortListOption("FFD_FIX_J", nFFD_Fix_JDir, FFD_Fix_JDir); - + /* DESCRIPTION: Fix K plane */ addShortListOption("FFD_FIX_K", nFFD_Fix_KDir, FFD_Fix_KDir); - + /* DESCRIPTION: FFD symmetry plane (j=0) */ addBoolOption("FFD_SYMMETRY_PLANE", FFD_Symmetry_Plane, false); @@ -2596,10 +2599,10 @@ void CConfig::SetConfig_Options() { /* DESCRIPTION: Definition of the FFD boxes */ addFFDDefOption("FFD_DEFINITION", nFFDBox, CoordFFDBox, TagFFDBox); - + /* DESCRIPTION: Definition of the FFD boxes */ addFFDDegreeOption("FFD_DEGREE", nFFDBox, DegreeFFDBox); - + /* DESCRIPTION: Surface continuity at the intersection with the FFD */ addEnumOption("FFD_CONTINUITY", FFD_Continuity, Continuity_Map, DERIVATIVE_2ND); @@ -2636,10 +2639,10 @@ void CConfig::SetConfig_Options() { /* DESCRIPTION: Maximum number of iterations */ addPythonOption("OPT_ITERATIONS"); - + /* DESCRIPTION: Requested accuracy */ addPythonOption("OPT_ACCURACY"); - + /*!\brief OPT_COMBINE_OBJECTIVE * \n DESCRIPTION: Flag specifying whether to internally combine a multi-objective function or treat separately */ addPythonOption("OPT_COMBINE_OBJECTIVE"); @@ -2670,10 +2673,10 @@ void CConfig::SetConfig_Options() { /* DESCRIPTION: Optimization gradient factor */ addPythonOption("OPT_GRADIENT_FACTOR"); - + /* DESCRIPTION: Upper bound for the optimizer */ addPythonOption("OPT_BOUND_UPPER"); - + /* DESCRIPTION: Lower bound for the optimizer */ addPythonOption("OPT_BOUND_LOWER"); @@ -2682,10 +2685,10 @@ void CConfig::SetConfig_Options() { /* DESCRIPTION: Activate ParMETIS mode for testing */ addBoolOption("PARMETIS", ParMETIS, false); - + /*--- options that are used in the Hybrid RANS/LES Simulations ---*/ /*!\par CONFIG_CATEGORY:Hybrid_RANSLES Options\ingroup Config*/ - + /* DESCRIPTION: Writing surface solution file frequency for dual time */ addUnsignedLongOption("WRT_SURF_FREQ_DUALTIME", Wrt_Surf_Freq_DualTime, 1); @@ -2700,43 +2703,43 @@ void CConfig::SetConfig_Options() { /* DESCRIPTION: Specify Hybrid RANS/LES model */ addEnumOption("HYBRID_RANSLES", Kind_HybridRANSLES, HybridRANSLES_Map, NO_HYBRIDRANSLES); - + /* DESCRIPTION: Roe with low dissipation for unsteady flows */ addEnumOption("ROE_LOW_DISSIPATION", Kind_RoeLowDiss, RoeLowDiss_Map, NO_ROELOWDISS); /* DESCRIPTION: Activate SA Quadratic Constitutive Relation, 2000 version */ addBoolOption("SA_QCR", QCR, false); - + /* DESCRIPTION: Compute Average for unsteady simulations */ addBoolOption("COMPUTE_AVERAGE", Compute_Average, false); - + /* DESCRIPTION: Multipoint design Mach number*/ addPythonOption("MULTIPOINT_MACH_NUMBER"); - + /* DESCRIPTION: Multipoint design Weight */ addPythonOption("MULTIPOINT_WEIGHT"); - + /* DESCRIPTION: Multipoint design Angle of Attack */ addPythonOption("MULTIPOINT_AOA"); - + /* DESCRIPTION: Multipoint design Sideslip angle */ addPythonOption("MULTIPOINT_SIDESLIP_ANGLE"); - + /* DESCRIPTION: Multipoint design target CL*/ addPythonOption("MULTIPOINT_TARGET_CL"); - + /* DESCRIPTION: Multipoint design Reynolds number */ addPythonOption("MULTIPOINT_REYNOLDS_NUMBER"); - + /* DESCRIPTION: Multipoint design freestream temperature */ addPythonOption("MULTIPOINT_FREESTREAM_TEMPERATURE"); - + /* DESCRIPTION: Multipoint design freestream pressure */ addPythonOption("MULTIPOINT_FREESTREAM_PRESSURE"); - + /* 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"); @@ -2749,25 +2752,25 @@ void CConfig::SetConfig_Options() { addStringListOption("HISTORY_OUTPUT", nHistoryOutput, HistoryOutput); /* DESCRIPTION: Type of output printed to the volume solution file */ addStringListOption("VOLUME_OUTPUT", nVolumeOutput, VolumeOutput); - + /* DESCRIPTION: History writing frequency (INNER_ITER) */ addUnsignedLongOption("HISTORY_WRT_FREQ_INNER", HistoryWrtFreq[2], 1); /* DESCRIPTION: History writing frequency (OUTER_ITER) */ - addUnsignedLongOption("HISTORY_WRT_FREQ_OUTER", HistoryWrtFreq[1], 1); + addUnsignedLongOption("HISTORY_WRT_FREQ_OUTER", HistoryWrtFreq[1], 1); /* DESCRIPTION: History writing frequency (TIME_ITER) */ addUnsignedLongOption("HISTORY_WRT_FREQ_TIME", HistoryWrtFreq[0], 1); - + /* DESCRIPTION: Screen writing frequency (INNER_ITER) */ addUnsignedLongOption("SCREEN_WRT_FREQ_INNER", ScreenWrtFreq[2], 1); /* DESCRIPTION: Screen writing frequency (OUTER_ITER) */ - addUnsignedLongOption("SCREEN_WRT_FREQ_OUTER", ScreenWrtFreq[1], 1); + addUnsignedLongOption("SCREEN_WRT_FREQ_OUTER", ScreenWrtFreq[1], 1); /* DESCRIPTION: Screen writing frequency (TIME_ITER) */ addUnsignedLongOption("SCREEN_WRT_FREQ_TIME", ScreenWrtFreq[0], 1); /* DESCRIPTION: Volume solution writing frequency */ addUnsignedLongOption("OUTPUT_WRT_FREQ", VolumeWrtFreq, 250); - /* DESCRIPTION: Volume solution files */ + /* DESCRIPTION: Volume solution files */ addEnumListOption("OUTPUT_FILES", nVolumeOutputFiles, VolumeOutputFiles, Output_Map); - + /* DESCRIPTION: Using Uncertainty Quantification with SST Turbulence Model */ addBoolOption("USING_UQ", using_uq, false); @@ -2800,9 +2803,9 @@ void CConfig::SetConfig_Parsing(char case_filename[MAX_STRING_SIZE]) { string text_line, option_name; ifstream case_file; vector option_value; - + /*--- Read the configuration file ---*/ - + case_file.open(case_filename, ios::in); if (case_file.fail()) { @@ -2817,18 +2820,18 @@ void CConfig::SetConfig_Parsing(char case_filename[MAX_STRING_SIZE]) { map included_options; /*--- Parse the configuration file and set the options ---*/ - + while (getline (case_file, text_line)) { - + if (err_count >= max_err_count) { errorString.append("too many errors. Stopping parse"); cout << errorString << endl; throw(1); } - + if (TokenizeString(text_line, option_name, option_value)) { - + /*--- See if it's a python option ---*/ if (option_map.find(option_name) == option_map.end()) { @@ -2857,7 +2860,7 @@ void CConfig::SetConfig_Parsing(char case_filename[MAX_STRING_SIZE]) { } /*--- Option exists, check if the option has already been in the config file ---*/ - + if (included_options.find(option_name) != included_options.end()) { string newString; newString.append(option_name); @@ -2870,12 +2873,12 @@ void CConfig::SetConfig_Parsing(char case_filename[MAX_STRING_SIZE]) { /*--- New found option. Add it to the map, and delete from all options ---*/ - + included_options.insert(pair(option_name, true)); all_options.erase(option_name); /*--- Set the value and check error ---*/ - + string out = option_map[option_name]->SetValue(option_value); if (out.compare("") != 0) { errorString.append(out); @@ -2886,36 +2889,34 @@ void CConfig::SetConfig_Parsing(char case_filename[MAX_STRING_SIZE]) { } /*--- See if there were any errors parsing the config file ---*/ - + if (errorString.size() != 0) { SU2_MPI::Error(errorString, CURRENT_FUNCTION); } case_file.close(); - + } void CConfig::SetDefaultFromConfig(CConfig *config){ - - map noInheritance = CCreateMap - ("SCREEN_OUTPUT", true) - ("HISTORY_OUTPUT", true); - + + map noInheritance = {{"SCREEN_OUTPUT", true},{"HISTORY_OUTPUT", true}}; + map::iterator iter = all_options.begin(), curr_iter; - + while (iter != all_options.end()){ - curr_iter = iter++; + curr_iter = iter++; if (config->option_map[curr_iter->first]->GetValue().size() > 0 && !noInheritance[curr_iter->first]){ option_map[curr_iter->first]->SetValue(config->option_map[curr_iter->first]->GetValue()); - all_options.erase(curr_iter); + all_options.erase(curr_iter); } } } void CConfig::SetDefault(){ - + /*--- Set the default values for all of the options that weren't set ---*/ - + for (map::iterator iter = all_options.begin(); iter != all_options.end(); ++iter) { if (option_map[iter->first]->GetValue().size() == 0) option_map[iter->first]->SetDefault(); @@ -2926,37 +2927,37 @@ bool CConfig::SetRunTime_Parsing(char case_filename[MAX_STRING_SIZE]) { string text_line, option_name; ifstream case_file; vector option_value; - + /*--- Read the configuration file ---*/ - + case_file.open(case_filename, ios::in); - + if (case_file.fail()) { return false; } - + string errorString; - + int err_count = 0; // How many errors have we found in the config file int max_err_count = 30; // Maximum number of errors to print before stopping - + map included_options; - + /*--- Parse the configuration file and set the options ---*/ - + while (getline (case_file, text_line)) { - + if (err_count >= max_err_count) { errorString.append("too many errors. Stopping parse"); - + cout << errorString << endl; throw(1); } - + if (TokenizeString(text_line, option_name, option_value)) { - + if (option_map.find(option_name) == option_map.end()) { - + /*--- See if it's a python option ---*/ - + string newString; newString.append(option_name); newString.append(": invalid option name"); @@ -2965,9 +2966,9 @@ bool CConfig::SetRunTime_Parsing(char case_filename[MAX_STRING_SIZE]) { err_count++; continue; } - + /*--- Option exists, check if the option has already been in the config file ---*/ - + if (included_options.find(option_name) != included_options.end()) { string newString; newString.append(option_name); @@ -2977,40 +2978,40 @@ bool CConfig::SetRunTime_Parsing(char case_filename[MAX_STRING_SIZE]) { err_count++; continue; } - + /*--- New found option. Add it to the map, and delete from all options ---*/ - + included_options.insert(pair(option_name, true)); all_options.erase(option_name); - + /*--- Set the value and check error ---*/ - + string out = option_map[option_name]->SetValue(option_value); if (out.compare("") != 0) { errorString.append(out); errorString.append("\n"); err_count++; } - + } } - + /*--- Set the default values for all of the options that weren't set ---*/ - + for (map::iterator iter = all_options.begin(); iter != all_options.end(); ++iter) { option_map[iter->first]->SetDefault(); } - + /*--- See if there were any errors parsing the runtime file ---*/ - + if (errorString.size() != 0) { SU2_MPI::Error(errorString, CURRENT_FUNCTION); } - + case_file.close(); - + return true; - + } void CConfig::SetHeader(unsigned short val_software){ @@ -3031,7 +3032,7 @@ void CConfig::SetHeader(unsigned short val_software){ case SU2_GEO: cout << "| |___/\\___//___| Suite (Geometry Definition Code) |" << endl; break; case SU2_SOL: cout << "| |___/\\___//___| Suite (Solution Exporting Code) |" << endl; break; } - + cout << "| |" << endl; //cout << "| Local date and time: " << dt << " |" << endl; cout <<"-------------------------------------------------------------------------" << endl; @@ -3056,58 +3057,58 @@ void CConfig::SetHeader(unsigned short val_software){ cout << "| License along with SU2. If not, see . |" << endl; cout <<"-------------------------------------------------------------------------" << endl; } - + } void CConfig::SetnZone(){ - + /*--- Just as a clarification --- */ - + if (Multizone_Problem == NO && Kind_Solver != MULTIPHYSICS){ nZone = 1; } - + if (Kind_Solver == MULTIPHYSICS){ Multizone_Problem = YES; if (nConfig_Files == 0){ SU2_MPI::Error("CONFIG_LIST must be provided if PHYSICAL_PROBLEM=MULTIPHYSICS", CURRENT_FUNCTION); } } - + if (Multizone_Problem == YES){ - + /*--- Some basic multizone checks ---*/ - + if (nMarker_ZoneInterface % 2 != 0){ SU2_MPI::Error("Number of markers in MARKER_ZONE_INTERFACE must be a multiple of 2", CURRENT_FUNCTION); } - + SinglezoneDriver = NO; - + if (Multizone_Mesh){ - + /*--- Get the number of zones from the mesh file --- */ - + nZone = GetnZone(Mesh_FileName, Mesh_FileFormat); - + /*--- If config list is set, make sure number matches number of zones in mesh file --- */ - + if (nConfig_Files != 0 && (nZone != nConfig_Files)){ SU2_MPI::Error("Number of CONFIG_LIST must match number of zones in mesh file.", CURRENT_FUNCTION); } } else { - + /*--- Number of zones is determined from the number of config files provided --- */ - + if (nConfig_Files == 0){ SU2_MPI::Error("If MULTIZONE_MESH is set to YES, you must provide a list of config files using CONFIG_LIST option", CURRENT_FUNCTION); } nZone = nConfig_Files; - + } - + /*--- Check if subconfig files exist --- */ - + if (nConfig_Files != 0){ for (unsigned short iConfig = 0; iConfig < nConfig_Files; iConfig++){ ifstream f(Config_Filenames[iConfig].c_str()); @@ -3116,20 +3117,20 @@ void CConfig::SetnZone(){ } } } - + } - + /*--- Temporary fix until Multizone Disc. Adj. solver is ready ---- */ - + if (Kind_Solver == FLUID_STRUCTURE_INTERACTION){ - + nZone = GetnZone(Mesh_FileName, Mesh_FileFormat); - - } + + } } void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_izone, unsigned short val_nDim) { - + unsigned short iCFL, iMarker; bool ideal_gas = ((Kind_FluidModel == STANDARD_AIR) || (Kind_FluidModel == IDEAL_GAS) || @@ -3137,11 +3138,11 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ (Kind_FluidModel == INC_IDEAL_GAS_POLY) || (Kind_FluidModel == CONSTANT_DENSITY)); bool standard_air = ((Kind_FluidModel == STANDARD_AIR)); - + if (nZone > 1){ Multizone_Problem = YES; } - + /*--- Set the default output files ---*/ if (!OptionIsSet("OUTPUT_FILES")){ nVolumeOutputFiles = 3; @@ -3193,7 +3194,7 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ for (iMarker = 0; iMarker < nMarker_WallFunctions; iMarker++) { if (Kind_WallFunctions[iMarker] != NO_WALL_FUNCTION) Wall_Functions = true; - + if ((Kind_WallFunctions[iMarker] == ADAPTIVE_WALL_FUNCTION) || (Kind_WallFunctions[iMarker] == SCALABLE_WALL_FUNCTION) || (Kind_WallFunctions[iMarker] == NONEQUILIBRIUM_WALL_MODEL)) @@ -3201,9 +3202,9 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ } } - + /*--- Fixed CM mode requires a static movement of the grid ---*/ - + if (Fixed_CM_Mode) { Kind_GridMovement = MOVING_HTP; } @@ -3241,7 +3242,7 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ if (Fixed_CL_Mode) { SU2_MPI::Error(string("Fixed CL mode not implemented for the incompressible solver. \n"), CURRENT_FUNCTION); } - + } /*--- By default, in 2D we should use TWOD_AIRFOIL (independenly from the input file) ---*/ @@ -3249,18 +3250,18 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ if (val_nDim == 2) Geo_Description = TWOD_AIRFOIL; /*--- Store the SU2 module that we are executing. ---*/ - + Kind_SU2 = val_software; /*--- Set limiter for no MUSCL reconstructions ---*/ - + if ((!MUSCL_Flow) || (Kind_ConvNumScheme_Flow == SPACE_CENTERED)) Kind_SlopeLimit_Flow = NO_LIMITER; if ((!MUSCL_Turb) || (Kind_ConvNumScheme_Turb == SPACE_CENTERED)) Kind_SlopeLimit_Turb = NO_LIMITER; if ((!MUSCL_AdjFlow) || (Kind_ConvNumScheme_AdjFlow == SPACE_CENTERED)) Kind_SlopeLimit_AdjFlow = NO_LIMITER; if ((!MUSCL_AdjTurb) || (Kind_ConvNumScheme_AdjTurb == SPACE_CENTERED)) Kind_SlopeLimit_AdjTurb = NO_LIMITER; /*--- Set the default for thrust in ActDisk ---*/ - + if ((Kind_ActDisk == NET_THRUST) || (Kind_ActDisk == BC_THRUST) || (Kind_ActDisk == DRAG_MINUS_THRUST) || (Kind_ActDisk == MASSFLOW) || (Kind_ActDisk == POWER)) @@ -3320,7 +3321,7 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ } /*-- Correct for case where Weight_ObjFunc has not been provided or has length < kind_objfunc---*/ - + if (nObjW1) { SU2_MPI::Error(string("The option OBJECTIVE_WEIGHT must either have the same length as OBJECTIVE_FUNCTION,\n") + @@ -3333,7 +3334,7 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ /*--- One final check for multi-objective with the set of objectives that are not counted per-surface. We will disable multi-objective here. ---*/ - + if (nObj > 1) { unsigned short Obj_0 = Kind_ObjFunc[0]; for (unsigned short iObj=1; iObj 1 && (GetSurface_Movement(FLUID_STRUCTURE) || GetSurface_Movement(FLUID_STRUCTURE_STATIC))){ - SU2_MPI::Error("FSI in combination with moving surfaces is currently not supported.", CURRENT_FUNCTION); + SU2_MPI::Error("FSI in combination with moving surfaces is currently not supported.", CURRENT_FUNCTION); } if (nKind_SurfaceMovement != nMarker_Moving && !(GetSurface_Movement(FLUID_STRUCTURE) || GetSurface_Movement(FLUID_STRUCTURE_STATIC))){ @@ -3554,23 +3555,23 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ if (Time_Domain && Time_Step <= 0.0 && Unst_CFL == 0.0){ SU2_MPI::Error("Invalid value for TIME_STEP.", CURRENT_FUNCTION); } - + if (TimeMarching == TIME_STEPPING){ nIter = 1; nInnerIter = 1; } - + if (!Time_Domain){ nTimeIter = 1; Time_Step = 0; - + ScreenWrtFreq[0] = 1; HistoryWrtFreq[0] = 1; - + if (TimeMarching != HARMONIC_BALANCE) TimeMarching = STEADY; - } - + } + if (Time_Domain){ Delta_UnstTime = Time_Step; Delta_DynTime = Time_Step; @@ -3579,7 +3580,7 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ VolumeWrtFreq = 1; } } - + if (!Multizone_Problem){ ScreenWrtFreq[1] = 0; HistoryWrtFreq[1] = 0; @@ -3591,8 +3592,8 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ } } } - - + + if ((Multizone_Problem || Time_Domain) && OptionIsSet("ITER")){ SU2_MPI::Error("ITER must not be used when running multizone and/or unsteady problems.\n" "Use TIME_ITER, OUTER_ITER or INNER_ITER to specify number of time iterations,\n" @@ -3602,19 +3603,19 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ /*--- If we're solving a purely steady problem with no prescribed grid movement (both rotating frame and moving walls can be steady), make sure that there is no grid motion ---*/ - + if (GetGrid_Movement()){ if ((Kind_SU2 == SU2_CFD || Kind_SU2 == SU2_SOL) && (TimeMarching == STEADY && !Time_Domain)){ - + if((Kind_GridMovement != ROTATING_FRAME) && (Kind_GridMovement != STEADY_TRANSLATION) && (Kind_GridMovement != NONE)){ - SU2_MPI::Error("Unsupported kind of grid movement for steady state problems.", CURRENT_FUNCTION); + SU2_MPI::Error("Unsupported kind of grid movement for steady state problems.", CURRENT_FUNCTION); } for (iMarker = 0; iMarker < nMarker_Moving; iMarker++){ if (Kind_SurfaceMovement[iMarker] != MOVING_WALL){ - SU2_MPI::Error("Unsupported kind of surface movement for steady state problems.", CURRENT_FUNCTION); + SU2_MPI::Error("Unsupported kind of surface movement for steady state problems.", CURRENT_FUNCTION); } } } @@ -3628,21 +3629,21 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ /*--- If it is not specified, set the mesh motion mach number equal to the freestream value. ---*/ - + if (GetGrid_Movement() && Mach_Motion == 0.0) Mach_Motion = Mach; - + /*--- Set the boolean flag if we are in a rotating frame (source term). ---*/ - + if (Kind_GridMovement == ROTATING_FRAME) Rotating_Frame = true; else Rotating_Frame = false; - + /*--- In case the grid movement parameters have not been declared in the config file, set them equal to zero for safety. Also check to make sure that for each option, a value has been declared for each moving marker. ---*/ - + if (nMarker_Moving > 0){ unsigned short iDim; if (nMarkerMotion_Origin == 0){ @@ -3741,7 +3742,7 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ if (nMarkerPitching_Phase/3 != nMarker_Moving){ SU2_MPI::Error("Number of SURFACE_PITCHING_PHASE must be three times the number of MARKER_MOVING, (x,y,z) per marker.", CURRENT_FUNCTION); } - + if (nMoveMotion_Origin == 0){ nMoveMotion_Origin = nMarker_Moving; MoveMotion_Origin = new unsigned short[nMoveMotion_Origin]; @@ -3753,7 +3754,7 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ SU2_MPI::Error("Number of MOVE_MOTION_ORIGIN must match number of MARKER_MOVING.", CURRENT_FUNCTION); } } - + /*-- Setting Harmonic Balance period from the config file */ if (TimeMarching == HARMONIC_BALANCE) { @@ -3772,7 +3773,7 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ } } } - + /*--- Force number of span-wise section to 1 if 2D case ---*/ if(val_nDim ==2){ nSpanWiseSections_User=1; @@ -3802,7 +3803,7 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ if(abs(FinalRotation_Rate_Z) > 0.0){ Rotation_Rate[2] = RampRotatingFrame_Coeff[0]; } - + } if(RampOutletPressure && !DiscreteAdjoint){ @@ -3827,88 +3828,88 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ /*--- Use the various rigid-motion input frequencies to determine the period to be used with harmonic balance cases. There are THREE types of motion to consider, namely: rotation, pitching, and plunging. The largest period of motion is the one to be used for harmonic balance calculations. ---*/ - + /*if (Unsteady_Simulation == HARMONIC_BALANCE) { if (!(GetGrid_Movement())) { // No grid movement - Time period from config file // HarmonicBalance_Period = GetHarmonicBalance_Period(); } - + else { unsigned short N_MOTION_TYPES = 3; su2double *periods; periods = new su2double[N_MOTION_TYPES]; - + //--- rotation: ---// - + su2double Omega_mag_rot = sqrt(pow(Rotation_Rate_X[ZONE_0],2)+pow(Rotation_Rate_Y[ZONE_0],2)+pow(Rotation_Rate_Z[ZONE_0],2)); if (Omega_mag_rot > 0) periods[0] = 2*PI_NUMBER/Omega_mag_rot; else periods[0] = 0.0; - + //--- pitching: ---// - + su2double Omega_mag_pitch = sqrt(pow(Pitching_Omega_X[ZONE_0],2)+pow(Pitching_Omega_Y[ZONE_0],2)+pow(Pitching_Omega_Z[ZONE_0],2)); if (Omega_mag_pitch > 0) periods[1] = 2*PI_NUMBER/Omega_mag_pitch; else periods[1] = 0.0; - + //--- plunging: ---// - + su2double Omega_mag_plunge = sqrt(pow(Plunging_Omega_X[ZONE_0],2)+pow(Plunging_Omega_Y[ZONE_0],2)+pow(Plunging_Omega_Z[ZONE_0],2)); if (Omega_mag_plunge > 0) periods[2] = 2*PI_NUMBER/Omega_mag_plunge; else periods[2] = 0.0; - + //--- determine which period is largest ---// - + unsigned short iVar; HarmonicBalance_Period = 0.0; for (iVar = 0; iVar < N_MOTION_TYPES; iVar++) { if (periods[iVar] > HarmonicBalance_Period) HarmonicBalance_Period = periods[iVar]; } - + delete periods; } - + }*/ - - - + + + /*--- Initialize the RefOriginMoment Pointer ---*/ - + RefOriginMoment = NULL; RefOriginMoment = new su2double[3]; RefOriginMoment[0] = 0.0; RefOriginMoment[1] = 0.0; RefOriginMoment[2] = 0.0; - + /*--- In case the moment origin coordinates have not been declared in the config file, set them equal to zero for safety. Also check to make sure that for each marker, a value has been declared for the moment origin. Unless only one value was specified, then set this value for all the markers being monitored. ---*/ - - + + if ((nRefOriginMoment_X != nRefOriginMoment_Y) || (nRefOriginMoment_X != nRefOriginMoment_Z) ) { SU2_MPI::Error("ERROR: Length of REF_ORIGIN_MOMENT_X, REF_ORIGIN_MOMENT_Y and REF_ORIGIN_MOMENT_Z must be the same!!", CURRENT_FUNCTION); } - + if (RefOriginMoment_X == NULL) { RefOriginMoment_X = new su2double[nMarker_Monitoring]; for (iMarker = 0; iMarker < nMarker_Monitoring; iMarker++ ) RefOriginMoment_X[iMarker] = 0.0; } else { if (nRefOriginMoment_X == 1) { - + su2double aux_RefOriginMoment_X = RefOriginMoment_X[0]; delete [] RefOriginMoment_X; RefOriginMoment_X = new su2double[nMarker_Monitoring]; nRefOriginMoment_X = nMarker_Monitoring; - + for (iMarker = 0; iMarker < nMarker_Monitoring; iMarker++ ) RefOriginMoment_X[iMarker] = aux_RefOriginMoment_X; } @@ -3916,19 +3917,19 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ SU2_MPI::Error("ERROR: Length of REF_ORIGIN_MOMENT_X must match number of Monitoring Markers!!", CURRENT_FUNCTION); } } - + if (RefOriginMoment_Y == NULL) { RefOriginMoment_Y = new su2double[nMarker_Monitoring]; for (iMarker = 0; iMarker < nMarker_Monitoring; iMarker++ ) RefOriginMoment_Y[iMarker] = 0.0; } else { if (nRefOriginMoment_Y == 1) { - + su2double aux_RefOriginMoment_Y = RefOriginMoment_Y[0]; delete [] RefOriginMoment_Y; RefOriginMoment_Y = new su2double[nMarker_Monitoring]; nRefOriginMoment_Y = nMarker_Monitoring; - + for (iMarker = 0; iMarker < nMarker_Monitoring; iMarker++ ) RefOriginMoment_Y[iMarker] = aux_RefOriginMoment_Y; } @@ -3936,19 +3937,19 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ SU2_MPI::Error("ERROR: Length of REF_ORIGIN_MOMENT_Y must match number of Monitoring Markers!!", CURRENT_FUNCTION); } } - + if (RefOriginMoment_Z == NULL) { RefOriginMoment_Z = new su2double[nMarker_Monitoring]; for (iMarker = 0; iMarker < nMarker_Monitoring; iMarker++ ) RefOriginMoment_Z[iMarker] = 0.0; } else { if (nRefOriginMoment_Z == 1) { - + su2double aux_RefOriginMoment_Z = RefOriginMoment_Z[0]; delete [] RefOriginMoment_Z; RefOriginMoment_Z = new su2double[nMarker_Monitoring]; nRefOriginMoment_Z = nMarker_Monitoring; - + for (iMarker = 0; iMarker < nMarker_Monitoring; iMarker++ ) RefOriginMoment_Z[iMarker] = aux_RefOriginMoment_Z; } @@ -3956,15 +3957,15 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ SU2_MPI::Error("ERROR: Length of REF_ORIGIN_MOMENT_Z must match number of Monitoring Markers!!", CURRENT_FUNCTION); } } - + /*--- Set the boolean flag if we are carrying out an aeroelastic simulation. ---*/ - + if (GetGrid_Movement() && (GetSurface_Movement(AEROELASTIC) || GetSurface_Movement(AEROELASTIC_RIGID_MOTION))) Aeroelastic_Simulation = true; else Aeroelastic_Simulation = false; - + /*--- Initializing the size for the solutions of the Aeroelastic problem. ---*/ - - + + if (GetGrid_Movement() && Aeroelastic_Simulation) { Aeroelastic_np1.resize(nMarker_Monitoring); Aeroelastic_n.resize(nMarker_Monitoring); @@ -3985,9 +3986,9 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ } } } - + /*--- Allocate memory for the plunge and pitch and initialized them to zero ---*/ - + if (GetGrid_Movement() && Aeroelastic_Simulation) { Aeroelastic_pitch = new su2double[nMarker_Monitoring]; Aeroelastic_plunge = new su2double[nMarker_Monitoring]; @@ -3999,15 +4000,15 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ FinestMesh = MESH_0; if (MGCycle == FULLMG_CYCLE) FinestMesh = nMGLevels; - + if ((Kind_Solver == NAVIER_STOKES) && (Kind_Turb_Model != NONE)) Kind_Solver = RANS; - + if ((Kind_Solver == INC_NAVIER_STOKES) && (Kind_Turb_Model != NONE)) Kind_Solver = INC_RANS; - + if (Kind_Solver == EULER || Kind_Solver == INC_EULER || Kind_Solver == FEM_EULER) @@ -4019,25 +4020,25 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ Kappa_4th_AdjFlow = Kappa_AdjFlow[1]; Kappa_2nd_Heat = Kappa_Heat[0]; Kappa_4th_Heat = Kappa_Heat[1]; - + /*--- Make the MG_PreSmooth, MG_PostSmooth, and MG_CorrecSmooth arrays consistent with nMGLevels ---*/ - + unsigned short * tmp_smooth = new unsigned short[nMGLevels+1]; - + if ((nMG_PreSmooth != nMGLevels+1) && (nMG_PreSmooth != 0)) { if (nMG_PreSmooth > nMGLevels+1) { - + /*--- Truncate by removing unnecessary elements at the end ---*/ - + for (unsigned int i = 0; i <= nMGLevels; i++) tmp_smooth[i] = MG_PreSmooth[i]; delete [] MG_PreSmooth; MG_PreSmooth=NULL; } else { - + /*--- Add additional elements equal to last element ---*/ - + for (unsigned int i = 0; i < nMG_PreSmooth; i++) tmp_smooth[i] = MG_PreSmooth[i]; for (unsigned int i = nMG_PreSmooth; i <= nMGLevels; i++) @@ -4045,7 +4046,7 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ delete [] MG_PreSmooth; MG_PreSmooth=NULL; } - + nMG_PreSmooth = nMGLevels+1; MG_PreSmooth = new unsigned short[nMG_PreSmooth]; for (unsigned int i = 0; i < nMG_PreSmooth; i++) @@ -4058,20 +4059,20 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ for (unsigned int i = 0; i < nMG_PreSmooth; i++) MG_PreSmooth[i] = i+1; } - + if ((nMG_PostSmooth != nMGLevels+1) && (nMG_PostSmooth != 0)) { if (nMG_PostSmooth > nMGLevels+1) { - + /*--- Truncate by removing unnecessary elements at the end ---*/ - + for (unsigned int i = 0; i <= nMGLevels; i++) tmp_smooth[i] = MG_PostSmooth[i]; delete [] MG_PostSmooth; MG_PostSmooth=NULL; } else { - + /*--- Add additional elements equal to last element ---*/ - + for (unsigned int i = 0; i < nMG_PostSmooth; i++) tmp_smooth[i] = MG_PostSmooth[i]; for (unsigned int i = nMG_PostSmooth; i <= nMGLevels; i++) @@ -4079,14 +4080,14 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ delete [] MG_PostSmooth; MG_PostSmooth=NULL; } - + nMG_PostSmooth = nMGLevels+1; MG_PostSmooth = new unsigned short[nMG_PostSmooth]; for (unsigned int i = 0; i < nMG_PostSmooth; i++) MG_PostSmooth[i] = tmp_smooth[i]; - + } - + if ((nMGLevels != 0) && (nMG_PostSmooth == 0)) { delete [] MG_PostSmooth; nMG_PostSmooth = nMGLevels+1; @@ -4094,20 +4095,20 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ for (unsigned int i = 0; i < nMG_PostSmooth; i++) MG_PostSmooth[i] = 0; } - + if ((nMG_CorrecSmooth != nMGLevels+1) && (nMG_CorrecSmooth != 0)) { if (nMG_CorrecSmooth > nMGLevels+1) { - + /*--- Truncate by removing unnecessary elements at the end ---*/ - + for (unsigned int i = 0; i <= nMGLevels; i++) tmp_smooth[i] = MG_CorrecSmooth[i]; delete [] MG_CorrecSmooth; MG_CorrecSmooth = NULL; } else { - + /*--- Add additional elements equal to last element ---*/ - + for (unsigned int i = 0; i < nMG_CorrecSmooth; i++) tmp_smooth[i] = MG_CorrecSmooth[i]; for (unsigned int i = nMG_CorrecSmooth; i <= nMGLevels; i++) @@ -4120,7 +4121,7 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ for (unsigned int i = 0; i < nMG_CorrecSmooth; i++) MG_CorrecSmooth[i] = tmp_smooth[i]; } - + if ((nMGLevels != 0) && (nMG_CorrecSmooth == 0)) { delete [] MG_CorrecSmooth; nMG_CorrecSmooth = nMGLevels+1; @@ -4128,30 +4129,30 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ for (unsigned int i = 0; i < nMG_CorrecSmooth; i++) MG_CorrecSmooth[i] = 0; } - + /*--- Override MG Smooth parameters ---*/ - + if (nMG_PreSmooth != 0) MG_PreSmooth[MESH_0] = 1; if (nMG_PostSmooth != 0) { MG_PostSmooth[MESH_0] = 0; MG_PostSmooth[nMGLevels] = 0; } if (nMG_CorrecSmooth != 0) MG_CorrecSmooth[nMGLevels] = 0; - + if (Restart) MGCycle = V_CYCLE; - + if (ContinuousAdjoint) { if (Kind_Solver == EULER) Kind_Solver = ADJ_EULER; if (Kind_Solver == NAVIER_STOKES) Kind_Solver = ADJ_NAVIER_STOKES; if (Kind_Solver == RANS) Kind_Solver = ADJ_RANS; } - + nCFL = nMGLevels+1; CFL = new su2double[nCFL]; CFL[0] = CFLFineGrid; - + /*--- Evaluate when the Cl should be evaluated ---*/ - + Iter_Fixed_CM = SU2_TYPE::Int(nInnerIter / (su2double(Update_iH)+1)); Iter_Fixed_NetThrust = SU2_TYPE::Int(nInnerIter / (su2double(Update_BCThrust)+1)); @@ -4172,16 +4173,16 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ Kappa_Flow[0] = Kappa_AdjFlow[0]; Kappa_Flow[1] = Kappa_AdjFlow[1]; } - - if (Update_AoA_Iter_Limit == 0 && Fixed_CL_Mode) { - SU2_MPI::Error("ERROR: Please specify non-zero UPDATE_AOA_ITER_LIMIT.", CURRENT_FUNCTION); + + if (Update_AoA_Iter_Limit == 0 && Fixed_CL_Mode) { + SU2_MPI::Error("ERROR: Please specify non-zero UPDATE_AOA_ITER_LIMIT.", CURRENT_FUNCTION); } if (Iter_Fixed_CM == 0) { Iter_Fixed_CM = nInnerIter+1; Update_iH = 0; } if (Iter_Fixed_NetThrust == 0) { Iter_Fixed_NetThrust = nInnerIter+1; Update_BCThrust = 0; } for (iCFL = 1; iCFL < nCFL; iCFL++) CFL[iCFL] = CFL[iCFL-1]; - + if (nRKStep == 0) { nRKStep = 1; RK_Alpha_Step = new su2double[1]; RK_Alpha_Step[0] = 1.0; @@ -4262,7 +4263,7 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ nIntCoeffs = 2; Int_Coeffs = new su2double[2]; Int_Coeffs[0] = 0.25; Int_Coeffs[1] = 0.5; } - + if (nElasticityMod == 0) { nElasticityMod = 1; ElasticityMod = new su2double[1]; ElasticityMod[0] = 2E11; @@ -4302,9 +4303,9 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ if ((Kind_SU2 == SU2_CFD) && (Kind_Solver == NO_SOLVER)) { SU2_MPI::Error("PHYSICAL_PROBLEM must be set in the configuration file", CURRENT_FUNCTION); } - + /*--- Set a flag for viscous simulations ---*/ - + Viscous = (( Kind_Solver == NAVIER_STOKES ) || ( Kind_Solver == ADJ_NAVIER_STOKES ) || ( Kind_Solver == RANS ) || @@ -4333,27 +4334,27 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ /*--- Length based parameter for slope limiters uses a default value of 0.1m ---*/ - + RefElemLength = 1.0; if (SystemMeasurements == US) RefElemLength /= 0.3048; /*--- Re-scale the length based parameters. The US system uses feet, but SU2 assumes that the grid is in inches ---*/ - + if ((SystemMeasurements == US) && (Kind_SU2 == SU2_CFD)) { - + for (iMarker = 0; iMarker < nMarker_Monitoring; iMarker++) { RefOriginMoment_X[iMarker] = RefOriginMoment_X[iMarker]/12.0; RefOriginMoment_Y[iMarker] = RefOriginMoment_Y[iMarker]/12.0; RefOriginMoment_Z[iMarker] = RefOriginMoment_Z[iMarker]/12.0; } - + for (iMarker = 0; iMarker < nMarker_Moving; iMarker++){ for (unsigned short iDim = 0; iDim < 3; iDim++){ MarkerMotion_Origin[3*iMarker+iDim] /= 12.0; } } - + RefLength = RefLength/12.0; if ((val_nDim == 2) && (!Axisymmetric)) RefArea = RefArea/12.0; @@ -4365,7 +4366,7 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ EA_IntLimit[0] = EA_IntLimit[0]/12.0; EA_IntLimit[1] = EA_IntLimit[1]/12.0; EA_IntLimit[2] = EA_IntLimit[2]/12.0; - + if (Geo_Description != NACELLE) { for (unsigned short iSections = 0; iSections < nLocationStations; iSections++) { LocationStations[iSections] = LocationStations[iSections]/12.0; @@ -4373,7 +4374,7 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ Stations_Bounds[0] = Stations_Bounds[0]/12.0; Stations_Bounds[1] = Stations_Bounds[1]/12.0; } - + SubsonicEngine_Cyl[0] = SubsonicEngine_Cyl[0]/12.0; SubsonicEngine_Cyl[1] = SubsonicEngine_Cyl[1]/12.0; SubsonicEngine_Cyl[2] = SubsonicEngine_Cyl[2]/12.0; @@ -4381,16 +4382,16 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ SubsonicEngine_Cyl[4] = SubsonicEngine_Cyl[4]/12.0; SubsonicEngine_Cyl[5] = SubsonicEngine_Cyl[5]/12.0; SubsonicEngine_Cyl[6] = SubsonicEngine_Cyl[6]/12.0; - + } if ((Kind_Turb_Model != SA) && (Kind_Trans_Model == BC)){ SU2_MPI::Error("BC transition model currently only available in combination with SA turbulence model!", CURRENT_FUNCTION); } - + /*--- Check for constant lift mode. Initialize the update flag for the AoA with each iteration to false ---*/ - + if (Fixed_CL_Mode) Update_AoA = false; if (Fixed_CM_Mode) Update_HTPIncidence = false; @@ -4539,15 +4540,15 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ } } } - + /*--- Check the coefficients for the polynomial models. ---*/ - + if (Kind_Solver != INC_EULER && Kind_Solver != INC_NAVIER_STOKES && Kind_Solver != INC_RANS) { if ((Kind_ViscosityModel == POLYNOMIAL_VISCOSITY) || (Kind_ConductivityModel == POLYNOMIAL_CONDUCTIVITY) || (Kind_FluidModel == INC_IDEAL_GAS_POLY)) { SU2_MPI::Error("POLYNOMIAL_VISCOSITY and POLYNOMIAL_CONDUCTIVITY are for incompressible only currently.", CURRENT_FUNCTION); } } - + if ((Kind_Solver == INC_EULER || Kind_Solver == INC_NAVIER_STOKES || Kind_Solver == INC_RANS) && (Kind_FluidModel == INC_IDEAL_GAS_POLY)) { su2double sum = 0.0; for (unsigned short iVar = 0; iVar < nPolyCoeffs; iVar++) { @@ -4556,7 +4557,7 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ if ((nPolyCoeffs < 1) || (sum == 0.0)) SU2_MPI::Error(string("CP_POLYCOEFFS not set for fluid model INC_IDEAL_GAS_POLY. \n"), CURRENT_FUNCTION); } - + if (((Kind_Solver == INC_EULER || Kind_Solver == INC_NAVIER_STOKES || Kind_Solver == INC_RANS)) && (Kind_ViscosityModel == POLYNOMIAL_VISCOSITY)) { su2double sum = 0.0; for (unsigned short iVar = 0; iVar < nPolyCoeffs; iVar++) { @@ -4565,7 +4566,7 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ if ((nPolyCoeffs < 1) || (sum == 0.0)) SU2_MPI::Error(string("MU_POLYCOEFFS not set for viscosity model POLYNOMIAL_VISCOSITY. \n"), CURRENT_FUNCTION); } - + if ((Kind_Solver == INC_EULER || Kind_Solver == INC_NAVIER_STOKES || Kind_Solver == INC_RANS) && (Kind_ConductivityModel == POLYNOMIAL_CONDUCTIVITY)) { su2double sum = 0.0; for (unsigned short iVar = 0; iVar < nPolyCoeffs; iVar++) { @@ -4588,9 +4589,9 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ SU2_MPI::Error("Incompressible non-dim. scheme invalid.\n Must use INITIAL_VALUES, REFERENCE_VALUES, or DIMENSIONAL.", CURRENT_FUNCTION); } } - + /*--- Check that the incompressible inlets are correctly specified. ---*/ - + if ((Kind_Solver == INC_EULER || Kind_Solver == INC_NAVIER_STOKES || Kind_Solver == INC_RANS) && (nMarker_Inlet != 0)) { if (nMarker_Inlet != nInc_Inlet) { SU2_MPI::Error("Inlet types for incompressible problem improperly specified.\n Use INC_INLET_TYPE= VELOCITY_INLET or PRESSURE_INLET.\n Must list a type for each inlet marker, including duplicates, e.g.,\n INC_INLET_TYPE= VELOCITY_INLET VELOCITY_INLET PRESSURE_INLET", CURRENT_FUNCTION); @@ -4601,9 +4602,9 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ } } } - + /*--- Check that the incompressible inlets are correctly specified. ---*/ - + if ((Kind_Solver == INC_EULER || Kind_Solver == INC_NAVIER_STOKES || Kind_Solver == INC_RANS) && (nMarker_Outlet != 0)) { if (nMarker_Outlet != nInc_Outlet) { SU2_MPI::Error("Outlet types for incompressible problem improperly specified.\n Use INC_OUTLET_TYPE= PRESSURE_OUTLET or MASS_FLOW_OUTLET.\n Must list a type for each inlet marker, including duplicates, e.g.,\n INC_OUTLET_TYPE= PRESSURE_OUTLET PRESSURE_OUTLET MASS_FLOW_OUTLET", CURRENT_FUNCTION); @@ -4629,15 +4630,15 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ SU2_MPI::Error("Must list two markers for the pressure drop objective function.\n Expected format: MARKER_ANALYZE= (outlet_name, inlet_name).", CURRENT_FUNCTION); } } - + /*--- Handle default options for topology optimization ---*/ - + if (topology_optimization && top_optim_nKernel==0) { top_optim_nKernel = 1; top_optim_kernels = new unsigned short [1]; top_optim_kernels[0] = CONICAL_WEIGHT_FILTER; } - + if (top_optim_nKernel != 0) { /*--- Set default value of kernel parameters ---*/ if (top_optim_nKernelParams == 0) { @@ -4677,60 +4678,60 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ SU2_MPI::Error("Different number of topology filter kernels and respective radii.", CURRENT_FUNCTION); } } - + /*--- If we are executing SU2_DOT in surface file mode, then force the projected surface sensitivity file to be written. ---*/ - + Wrt_Projected_Sensitivity = false; if ((Kind_SU2 == SU2_DOT) && (Design_Variable[0] == SURFACE_FILE)) { Wrt_Projected_Sensitivity = true; } /*--- Delay the output until exit for minimal communication mode. ---*/ - + if (Comm_Level != COMM_FULL) { - + /*--- Disable the use of Comm_Level = NONE until we have properly implemented it. ---*/ - + if (Comm_Level == COMM_NONE) SU2_MPI::Error("COMM_LEVEL = NONE not yet implemented.", CURRENT_FUNCTION); Wrt_Sol_Freq = nTimeIter+1; Wrt_Sol_Freq_DualTime = nTimeIter+1; - + /*--- Write only the restart. ---*/ - + Wrt_Slice = false; Wrt_Vol_Sol = false; Wrt_Srf_Sol = false; Wrt_Csv_Sol = false; } - + /*--- Check the conductivity model. Deactivate the turbulent component if we are not running RANS. ---*/ - + if ((Kind_Solver != RANS) && (Kind_Solver != ADJ_RANS) && - (Kind_Solver != DISC_ADJ_RANS) && + (Kind_Solver != DISC_ADJ_RANS) && (Kind_Solver != INC_RANS) && (Kind_Solver != DISC_ADJ_INC_RANS)){ Kind_ConductivityModel_Turb = NO_CONDUCTIVITY_TURB; } - + /*--- Check for running SU2_MSH for periodic preprocessing, and throw an error to report that this is no longer necessary. ---*/ - + if ((Kind_SU2 == SU2_MSH) && (Kind_Adaptation == PERIODIC)) { SU2_MPI::Error(string("For SU2 v7.0.0 and later, preprocessing of periodic grids by SU2_MSH\n") + string("is no longer necessary. Please use the original mesh file (prior to SU2_MSH)\n") + string("with the same MARKER_PERIODIC definition in the configuration file.") , CURRENT_FUNCTION); } - + /* Set a default for the size of the RECTANGLE / BOX grid sizes. */ - + if (nMesh_Box_Size == 0) { nMesh_Box_Size = 3; Mesh_Box_Size = new short [nMesh_Box_Size]; @@ -4741,7 +4742,7 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ SU2_MPI::Error(string("MESH_BOX_SIZE specified without 3 values.\n"), CURRENT_FUNCTION); } - + if (DiscreteAdjoint) { #if !defined CODI_REVERSE_TYPE if (Kind_SU2 == SU2_CFD) { @@ -4760,7 +4761,7 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ if (GetKind_GridMovement() != RIGID_MOTION && GetKind_GridMovement() != NO_MOVEMENT) { - SU2_MPI::Error(string("Dynamic mesh movement currently only supported for the discrete adjoint solver for\n") + + SU2_MPI::Error(string("Dynamic mesh movement currently only supported for the discrete adjoint solver for\n") + string("GRID_MOVEMENT = RIGID_MOTION."), CURRENT_FUNCTION); } @@ -4777,7 +4778,7 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ } } - + /*--- Note that this is deliberatly done at the end of this routine! ---*/ switch(Kind_Solver) { case EULER: @@ -4804,7 +4805,7 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ case FEM_RANS : Kind_Solver = DISC_ADJ_FEM_RANS; break; - case FEM_NAVIER_STOKES : + case FEM_NAVIER_STOKES : Kind_Solver = DISC_ADJ_FEM_NS; break; case FEM_ELASTICITY: @@ -4820,24 +4821,24 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ RampOutletPressure = false; RampRotatingFrame = false; } - + /* 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)) { @@ -4849,11 +4850,11 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ ReconstructionGradientRequired = false; Kind_Gradient_Method_Recon = Kind_Gradient_Method; } - + } - + /* 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) || @@ -4861,16 +4862,16 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ (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); } - + /* 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) || @@ -4888,13 +4889,13 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ 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) { @@ -4913,14 +4914,14 @@ void CConfig::SetMarkers(unsigned short val_software) { iMarker_Turbomachinery, iMarker_MixingPlaneInterface; int size = SINGLE_NODE; - + #ifdef HAVE_MPI if (val_software != SU2_MSH) SU2_MPI::Comm_size(MPI_COMM_WORLD, &size); #endif /*--- Compute the total number of markers in the config file ---*/ - + nMarker_CfgFile = nMarker_Euler + nMarker_FarField + nMarker_SymWall + nMarker_PerBound + nMarker_NearFieldBound + nMarker_Fluid_InterfaceBound + nMarker_CHTInterface + nMarker_Inlet + nMarker_Riemann + @@ -4930,17 +4931,17 @@ void CConfig::SetMarkers(unsigned short val_software) { nMarker_FlowLoad + nMarker_Custom + nMarker_Damper + nMarker_Fluid_Load + nMarker_Clamped + nMarker_Load_Sine + nMarker_Load_Dir + nMarker_Disp_Dir + nMarker_ActDiskInlet + nMarker_ActDiskOutlet + nMarker_ZoneInterface; - + /*--- Add the possible send/receive domains ---*/ nMarker_Max = nMarker_CfgFile + OVERHEAD*size; - + /*--- Basic dimensionalization of the markers (worst scenario) ---*/ nMarker_All = nMarker_Max; /*--- Allocate the memory (markers in each domain) ---*/ - + Marker_All_TagBound = new string[nMarker_All]; // Store the tag that correspond with each marker. Marker_All_SendRecv = new short[nMarker_All]; // +#domain (send), -#domain (receive). Marker_All_KindBC = new unsigned short[nMarker_All]; // Store the kind of boundary condition. @@ -5107,7 +5108,7 @@ void CConfig::SetMarkers(unsigned short val_software) { ActDisk_GrossThrust = new su2double[nMarker_ActDiskInlet]; ActDisk_Area = new su2double[nMarker_ActDiskInlet]; ActDisk_ReverseMassFlow = new su2double[nMarker_ActDiskInlet]; - + for (iMarker_ActDiskInlet = 0; iMarker_ActDiskInlet < nMarker_ActDiskInlet; iMarker_ActDiskInlet++) { ActDisk_DeltaPress[iMarker_ActDiskInlet] = 0.0; ActDisk_DeltaTemp[iMarker_ActDiskInlet] = 0.0; @@ -5126,8 +5127,8 @@ void CConfig::SetMarkers(unsigned short val_software) { ActDisk_Area[iMarker_ActDiskInlet] = 0.0; ActDisk_ReverseMassFlow[iMarker_ActDiskInlet] = 0.0; } - - + + ActDiskInlet_MassFlow = new su2double[nMarker_ActDiskInlet]; ActDiskInlet_Temperature = new su2double[nMarker_ActDiskInlet]; ActDiskInlet_TotalTemperature = new su2double[nMarker_ActDiskInlet]; @@ -5136,7 +5137,7 @@ void CConfig::SetMarkers(unsigned short val_software) { ActDiskInlet_RamDrag = new su2double[nMarker_ActDiskInlet]; ActDiskInlet_Force = new su2double[nMarker_ActDiskInlet]; ActDiskInlet_Power = new su2double[nMarker_ActDiskInlet]; - + for (iMarker_ActDiskInlet = 0; iMarker_ActDiskInlet < nMarker_ActDiskInlet; iMarker_ActDiskInlet++) { Marker_CfgFile_TagBound[iMarker_CfgFile] = Marker_ActDiskInlet[iMarker_ActDiskInlet]; Marker_CfgFile_KindBC[iMarker_CfgFile] = ACTDISK_INLET; @@ -5150,7 +5151,7 @@ void CConfig::SetMarkers(unsigned short val_software) { ActDiskInlet_Power[iMarker_ActDiskInlet] = 0.0; iMarker_CfgFile++; } - + ActDiskOutlet_MassFlow = new su2double[nMarker_ActDiskOutlet]; ActDiskOutlet_Temperature = new su2double[nMarker_ActDiskOutlet]; ActDiskOutlet_TotalTemperature = new su2double[nMarker_ActDiskOutlet]; @@ -5159,7 +5160,7 @@ void CConfig::SetMarkers(unsigned short val_software) { ActDiskOutlet_GrossThrust = new su2double[nMarker_ActDiskOutlet]; ActDiskOutlet_Force = new su2double[nMarker_ActDiskOutlet]; ActDiskOutlet_Power = new su2double[nMarker_ActDiskOutlet]; - + for (iMarker_ActDiskOutlet = 0; iMarker_ActDiskOutlet < nMarker_ActDiskOutlet; iMarker_ActDiskOutlet++) { Marker_CfgFile_TagBound[iMarker_CfgFile] = Marker_ActDiskOutlet[iMarker_ActDiskOutlet]; Marker_CfgFile_KindBC[iMarker_CfgFile] = ACTDISK_OUTLET; @@ -5182,13 +5183,13 @@ void CConfig::SetMarkers(unsigned short val_software) { Outlet_Density[iMarker_Outlet] = 0.0; Outlet_Area[iMarker_Outlet] = 0.0; } - + for (iMarker_NearFieldBound = 0; iMarker_NearFieldBound < nMarker_NearFieldBound; iMarker_NearFieldBound++) { Marker_CfgFile_TagBound[iMarker_CfgFile] = Marker_NearFieldBound[iMarker_NearFieldBound]; Marker_CfgFile_KindBC[iMarker_CfgFile] = NEARFIELD_BOUNDARY; iMarker_CfgFile++; } - + for (iMarker_Fluid_InterfaceBound = 0; iMarker_Fluid_InterfaceBound < nMarker_Fluid_InterfaceBound; iMarker_Fluid_InterfaceBound++) { Marker_CfgFile_TagBound[iMarker_CfgFile] = Marker_Fluid_InterfaceBound[iMarker_Fluid_InterfaceBound]; Marker_CfgFile_KindBC[iMarker_CfgFile] = FLUID_INTERFACE; @@ -5225,7 +5226,7 @@ void CConfig::SetMarkers(unsigned short val_software) { Engine_NetThrust = new su2double[nMarker_EngineInflow]; Engine_GrossThrust = new su2double[nMarker_EngineInflow]; Engine_Area = new su2double[nMarker_EngineInflow]; - + for (iMarker_EngineInflow = 0; iMarker_EngineInflow < nMarker_EngineInflow; iMarker_EngineInflow++) { Engine_Power[iMarker_EngineInflow] = 0.0; Engine_Mach[iMarker_EngineInflow] = 0.0; @@ -5234,7 +5235,7 @@ void CConfig::SetMarkers(unsigned short val_software) { Engine_GrossThrust[iMarker_EngineInflow] = 0.0; Engine_Area[iMarker_EngineInflow] = 0.0; } - + Inflow_Mach = new su2double[nMarker_EngineInflow]; Inflow_Pressure = new su2double[nMarker_EngineInflow]; Inflow_MassFlow = new su2double[nMarker_EngineInflow]; @@ -5245,7 +5246,7 @@ void CConfig::SetMarkers(unsigned short val_software) { Inflow_RamDrag = new su2double[nMarker_EngineInflow]; Inflow_Force = new su2double[nMarker_EngineInflow]; Inflow_Power = new su2double[nMarker_EngineInflow]; - + for (iMarker_EngineInflow = 0; iMarker_EngineInflow < nMarker_EngineInflow; iMarker_EngineInflow++) { Marker_CfgFile_TagBound[iMarker_CfgFile] = Marker_EngineInflow[iMarker_EngineInflow]; Marker_CfgFile_KindBC[iMarker_CfgFile] = ENGINE_INFLOW; @@ -5261,7 +5262,7 @@ void CConfig::SetMarkers(unsigned short val_software) { Inflow_Power[iMarker_EngineInflow] = 0.0; iMarker_CfgFile++; } - + Exhaust_Pressure = new su2double[nMarker_EngineExhaust]; Exhaust_Temperature = new su2double[nMarker_EngineExhaust]; Exhaust_MassFlow = new su2double[nMarker_EngineExhaust]; @@ -5270,7 +5271,7 @@ void CConfig::SetMarkers(unsigned short val_software) { Exhaust_GrossThrust = new su2double[nMarker_EngineExhaust]; Exhaust_Force = new su2double[nMarker_EngineExhaust]; Exhaust_Power = new su2double[nMarker_EngineExhaust]; - + for (iMarker_EngineExhaust = 0; iMarker_EngineExhaust < nMarker_EngineExhaust; iMarker_EngineExhaust++) { Marker_CfgFile_TagBound[iMarker_CfgFile] = Marker_EngineExhaust[iMarker_EngineExhaust]; Marker_CfgFile_KindBC[iMarker_CfgFile] = ENGINE_EXHAUST; @@ -5284,19 +5285,19 @@ void CConfig::SetMarkers(unsigned short val_software) { Exhaust_Power[iMarker_EngineExhaust] = 0.0; iMarker_CfgFile++; } - + for (iMarker_Supersonic_Inlet = 0; iMarker_Supersonic_Inlet < nMarker_Supersonic_Inlet; iMarker_Supersonic_Inlet++) { Marker_CfgFile_TagBound[iMarker_CfgFile] = Marker_Supersonic_Inlet[iMarker_Supersonic_Inlet]; Marker_CfgFile_KindBC[iMarker_CfgFile] = SUPERSONIC_INLET; iMarker_CfgFile++; } - + for (iMarker_Supersonic_Outlet = 0; iMarker_Supersonic_Outlet < nMarker_Supersonic_Outlet; iMarker_Supersonic_Outlet++) { Marker_CfgFile_TagBound[iMarker_CfgFile] = Marker_Supersonic_Outlet[iMarker_Supersonic_Outlet]; Marker_CfgFile_KindBC[iMarker_CfgFile] = SUPERSONIC_OUTLET; iMarker_CfgFile++; } - + for (iMarker_Internal = 0; iMarker_Internal < nMarker_Internal; iMarker_Internal++) { Marker_CfgFile_TagBound[iMarker_CfgFile] = Marker_Internal[iMarker_Internal]; Marker_CfgFile_KindBC[iMarker_CfgFile] = INTERNAL_BOUNDARY; @@ -5407,7 +5408,7 @@ void CConfig::SetMarkers(unsigned short val_software) { if (Marker_CfgFile_TagBound[iMarker_CfgFile] == Marker_Plotting[iMarker_Plotting]) Marker_CfgFile_Plotting[iMarker_CfgFile] = YES; } - + for (iMarker_CfgFile = 0; iMarker_CfgFile < nMarker_CfgFile; iMarker_CfgFile++) { Marker_CfgFile_Analyze[iMarker_CfgFile] = NO; for (iMarker_Analyze = 0; iMarker_Analyze < nMarker_Analyze; iMarker_Analyze++) @@ -5523,9 +5524,9 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { iMarker_ZoneInterface, iMarker_PyCustom, iMarker_Load_Dir, iMarker_Disp_Dir, iMarker_Load_Sine, iMarker_Clamped, iMarker_Moving, iMarker_Supersonic_Inlet, iMarker_Supersonic_Outlet, iMarker_ActDiskInlet, iMarker_ActDiskOutlet, iMarker_MixingPlaneInterface; - + bool fea = ((Kind_Solver == FEM_ELASTICITY) || (Kind_Solver == DISC_ADJ_FEM)); - + cout << endl <<"----------------- Physical Case Definition ( Zone " << iZone << " ) -------------------" << endl; if (val_software == SU2_CFD) { if (FSI_Problem) { @@ -5569,8 +5570,8 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { } if (using_uq){ cout << "Perturbing Reynold's Stress Matrix towards "<< eig_val_comp << " component turbulence"<< endl; - if (uq_permute) cout << "Permuting eigenvectors" << endl; - } + if (uq_permute) cout << "Permuting eigenvectors" << endl; + } break; case FEM_LES: if (Kind_Regime == COMPRESSIBLE) cout << "Compressible LES equations." << endl; @@ -5657,7 +5658,7 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { if (ContinuousAdjoint) cout << "Read flow solution from: " << Solution_FileName << "." << endl; - + if (!fea){ if (Kind_Regime == COMPRESSIBLE) { if (Ref_NonDim == DIMENSIONAL) { cout << "Dimensional simulation." << endl; } @@ -5669,7 +5670,7 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { else if (Ref_Inc_NonDim == INITIAL_VALUES) { cout << "Non-Dimensional simulation using intialization values." << endl; } else if (Ref_Inc_NonDim == REFERENCE_VALUES) { cout << "Non-Dimensional simulation using user-specified reference values." << endl; } } - + if (RefArea == 0.0) cout << "The reference area will be computed using y(2D) or z(3D) projection." << endl; else { cout << "The reference area is " << RefArea; if (SystemMeasurements == US) cout << " ft^2." << endl; else cout << " m^2." << endl; @@ -5687,7 +5688,7 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { if ((nRefOriginMoment_X > 1) || (nRefOriginMoment_Y > 1) || (nRefOriginMoment_Z > 1)) { cout << "Surface(s) where the force coefficients are evaluated and \n"; cout << "their reference origin for moment computation: \n"; - + for (iMarker_Monitoring = 0; iMarker_Monitoring < nMarker_Monitoring; iMarker_Monitoring++) { cout << " - " << Marker_Monitoring[iMarker_Monitoring] << " (" << RefOriginMoment_X[iMarker_Monitoring] <<", "< value <-> param):" << endl; - + switch (Design_Variable[iDV]) { case FFD_CONTROL_POINT_2D: cout << "FFD 2D (control point) <-> "; break; case FFD_CAMBER_2D: cout << "FFD 2D (camber) <-> "; break; @@ -5873,7 +5874,7 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { case FFD_THICKNESS: cout << "FFD (thickness) -> "; break; case FFD_ANGLE_OF_ATTACK: cout << "FFD (angle of attack) <-> "; break; } - + for (iMarker_DV = 0; iMarker_DV < nMarker_DV; iMarker_DV++) { cout << Marker_DV[iMarker_DV]; if (iMarker_DV < nMarker_DV-1) cout << ", "; @@ -5935,46 +5936,46 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { if (iParamDV < nParamDV-1) cout << ", "; else cout <<" )"<< endl; - + } } - + else if (Design_Variable[iDV] == NO_DEFORMATION) { cout << "No deformation of the numerical grid. Just output .su2 file." << endl; } - + else if (Design_Variable[iDV] == SCALE_GRID) { nParamDV = 0; cout << "Scaling of the volume grid by a constant factor." << endl; } - + else if (Design_Variable[iDV] == TRANSLATE_GRID) { nParamDV = 3; cout << "Rigid translation of the volume grid." << endl; } - + else if (Design_Variable[iDV] == ROTATE_GRID) { nParamDV = 6; cout << "Rigid rotation of the volume grid." << endl; } else if (Design_Variable[iDV] == FFD_SETTING) { - + cout << "Setting the FFD box structure." << endl; cout << "FFD boxes definition (FFD tag <-> degree <-> coord):" << endl; - + for (unsigned short iFFDBox = 0; iFFDBox < nFFDBox; iFFDBox++) { - + cout << TagFFDBox[iFFDBox] << " <-> "; - + for (unsigned short iDegreeFFD = 0; iDegreeFFD < 3; iDegreeFFD++) { if (iDegreeFFD == 0) cout << "( "; cout << DegreeFFDBox[iFFDBox][iDegreeFFD]; if (iDegreeFFD < 2) cout << ", "; else cout <<" )"; } - + cout << " <-> "; for (unsigned short iCoordFFD = 0; iCoordFFD < 24; iCoordFFD++) { @@ -5983,11 +5984,11 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { if (iCoordFFD < 23) cout << ", "; else cout <<" )"<< endl; } - + } - + } - + else cout << endl; } @@ -6091,7 +6092,7 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { if (Kind_Upwind_Flow == FDS) cout << "Flux difference splitting (FDS) upwind scheme for the flow inviscid terms."<< endl; if (Kind_Upwind_Flow == AUSMPLUSUP) cout << "AUSM+-up solver for the flow inviscid terms."<< endl; if (Kind_Upwind_Flow == AUSMPLUSUP2) cout << "AUSM+-up2 solver for the flow inviscid terms."<< endl; - + if (Kind_Solver == EULER || Kind_Solver == DISC_ADJ_EULER || Kind_Solver == NAVIER_STOKES || Kind_Solver == DISC_ADJ_NAVIER_STOKES || Kind_Solver == RANS || Kind_Solver == DISC_ADJ_RANS) { @@ -6103,7 +6104,7 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { case FD_DUCROS: cout << "Roe with DDES's FD low-dissipation function + Ducros shock sensor."<< endl; break; } } - + if (MUSCL_Flow) { cout << "Second order integration in space, with slope limiter." << endl; switch (Kind_SlopeLimit_Flow) { @@ -6128,7 +6129,7 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { else { cout << "First order integration in space." << endl; } - + } } @@ -6216,7 +6217,7 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { cout << "First order integration." << endl; } } - + cout << "The reference sharp edge distance is: " << AdjSharp_LimiterCoeff*RefElemLength*Venkat_LimiterCoeff <<". "<< endl; } @@ -6263,7 +6264,7 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { if ((Kind_Solver == NAVIER_STOKES) || (Kind_Solver == RANS) || (Kind_Solver == INC_NAVIER_STOKES) || (Kind_Solver == INC_RANS) || - (Kind_Solver == DISC_ADJ_INC_NAVIER_STOKES) || (Kind_Solver == DISC_ADJ_INC_RANS) || + (Kind_Solver == DISC_ADJ_INC_NAVIER_STOKES) || (Kind_Solver == DISC_ADJ_INC_RANS) || (Kind_Solver == DISC_ADJ_NAVIER_STOKES) || (Kind_Solver == DISC_ADJ_RANS)) { cout << "Average of gradients with correction (viscous flow terms)." << endl; } @@ -6283,7 +6284,7 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { if(Kind_Solver != FEM_EULER && Kind_Solver != FEM_NAVIER_STOKES && Kind_Solver != FEM_RANS && Kind_Solver != FEM_LES && - Kind_Solver != DISC_ADJ_FEM_EULER && Kind_Solver != DISC_ADJ_FEM_NS && + 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) { @@ -6523,7 +6524,7 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { } if (nMGLevels !=0) { - + if (nStartUpIter != 0) cout << "A total of " << nStartUpIter << " start up iterations on the fine grid."<< endl; if (MGCycle == V_CYCLE) cout << "V Multigrid Cycle, with " << nMGLevels << " multigrid levels."<< endl; if (MGCycle == W_CYCLE) cout << "W Multigrid Cycle, with " << nMGLevels << " multigrid levels."<< endl; @@ -6541,7 +6542,7 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { if (nMGLevels !=0) { PrintingToolbox::CTablePrinter MGTable(&std::cout); - + MGTable.AddColumn("MG Level", 10); MGTable.AddColumn("Presmooth", 10); MGTable.AddColumn("PostSmooth", 10); @@ -6559,7 +6560,7 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { cout.width(6); cout << CFL[0]; cout << endl; } - + } if ((Kind_Solver == RANS) || (Kind_Solver == DISC_ADJ_RANS) || @@ -6577,8 +6578,8 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { cout << "Maximum number of solver outer iterations: " << nOuterIter <<"."<< endl; if (Time_Domain) cout << "Maximum number of physical time-steps: " << nTimeIter <<"."<< endl; - - cout << "Begin convergence monitoring at iteration " << StartConv_Iter << "." << endl; + + cout << "Begin convergence monitoring at iteration " << StartConv_Iter << "." << endl; cout << "Residual minimum value: 1e" << MinLogResidual << "." << endl; cout << "Cauchy series min. value: " << Cauchy_Eps << "." << endl; cout << "Number of Cauchy elements: " << Cauchy_Elems << "." << endl; @@ -6635,17 +6636,17 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { cout << "Writing solution files every " << VolumeWrtFreq <<" iterations."<< endl; cout << "Writing the convergence history file every " << HistoryWrtFreq[2] <<" inner iterations."<< endl; if (Multizone_Problem){ - cout << "Writing the convergence history file every " << HistoryWrtFreq[1] <<" outer iterations."<< endl; + cout << "Writing the convergence history file every " << HistoryWrtFreq[1] <<" outer iterations."<< endl; } if (Time_Domain) { - cout << "Writing the convergence history file every " << HistoryWrtFreq[0] <<" time iterations."<< endl; + cout << "Writing the convergence history file every " << HistoryWrtFreq[0] <<" time iterations."<< endl; } cout << "Writing the screen convergence history every " << ScreenWrtFreq[2] <<" inner iterations."<< endl; if (Multizone_Problem){ - cout << "Writing the screen convergence history every " << ScreenWrtFreq[1] <<" outer iterations."<< endl; + cout << "Writing the screen convergence history every " << ScreenWrtFreq[1] <<" outer iterations."<< endl; } if (Time_Domain) { - cout << "Writing the screen convergence history every " << ScreenWrtFreq[0] <<" time iterations."<< endl; + cout << "Writing the screen convergence history every " << ScreenWrtFreq[0] <<" time iterations."<< endl; } switch (Tab_FileFormat) { @@ -6657,13 +6658,13 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { cout << "Forces breakdown file name: " << Breakdown_FileName << "." << endl; - + if (!ContinuousAdjoint && !DiscreteAdjoint) { cout << "Surface file name: " << SurfCoeff_FileName << "." << endl; cout << "Volume file name: " << Volume_FileName << "." << endl; cout << "Restart file name: " << Restart_FileName << "." << endl; } - + if (ContinuousAdjoint || DiscreteAdjoint) { cout << "Adjoint solution file name: " << Solution_AdjFileName << "." << endl; cout << "Restart adjoint file name: " << Restart_AdjFileName << "." << endl; @@ -6728,10 +6729,10 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { PrintingToolbox::CTablePrinter BoundaryTable(&std::cout); BoundaryTable.AddColumn("Marker Type", 35); BoundaryTable.AddColumn("Marker Name", 35); - + BoundaryTable.PrintHeader(); - - if (nMarker_Euler != 0) { + + if (nMarker_Euler != 0) { BoundaryTable << "Euler wall"; for (iMarker_Euler = 0; iMarker_Euler < nMarker_Euler; iMarker_Euler++) { BoundaryTable << Marker_Euler[iMarker_Euler]; @@ -6739,7 +6740,7 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { } BoundaryTable.PrintFooter(); } - + if (nMarker_FarField != 0) { BoundaryTable << "Far-field"; for (iMarker_FarField = 0; iMarker_FarField < nMarker_FarField; iMarker_FarField++) { @@ -6748,7 +6749,7 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { } BoundaryTable.PrintFooter(); } - + if (nMarker_SymWall != 0) { BoundaryTable << "Symmetry plane"; for (iMarker_SymWall = 0; iMarker_SymWall < nMarker_SymWall; iMarker_SymWall++) { @@ -6757,7 +6758,7 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { } BoundaryTable.PrintFooter(); } - + if (nMarker_PerBound != 0) { BoundaryTable << "Periodic boundary"; for (iMarker_PerBound = 0; iMarker_PerBound < nMarker_PerBound; iMarker_PerBound++) { @@ -6775,7 +6776,7 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { } BoundaryTable.PrintFooter(); } - + if (nMarker_Deform_Mesh != 0) { BoundaryTable << "Deformable mesh boundary"; for (iMarker_Deform_Mesh = 0; iMarker_Deform_Mesh < nMarker_Deform_Mesh; iMarker_Deform_Mesh++) { @@ -6793,7 +6794,7 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { } BoundaryTable.PrintFooter(); } - + if (nMarker_Fluid_InterfaceBound != 0) { BoundaryTable << "Fluid interface boundary"; for (iMarker_Fluid_InterfaceBound = 0; iMarker_Fluid_InterfaceBound < nMarker_Fluid_InterfaceBound; iMarker_Fluid_InterfaceBound++) { @@ -6802,7 +6803,7 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { } BoundaryTable.PrintFooter(); } - + if (nMarker_FlowLoad != 0) { BoundaryTable << "Flow load boundary"; for (iMarker_FlowLoad = 0; iMarker_FlowLoad < nMarker_FlowLoad; iMarker_FlowLoad++) { @@ -6811,7 +6812,7 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { } BoundaryTable.PrintFooter(); } - + if (nMarker_Internal != 0) { BoundaryTable << "Internal boundary"; for (iMarker_Internal = 0; iMarker_Internal < nMarker_Internal; iMarker_Internal++) { @@ -6820,7 +6821,7 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { } BoundaryTable.PrintFooter(); } - + if (nMarker_Inlet != 0) { BoundaryTable << "Inlet boundary"; for (iMarker_Inlet = 0; iMarker_Inlet < nMarker_Inlet; iMarker_Inlet++) { @@ -6828,8 +6829,8 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { if (iMarker_Inlet < nMarker_Inlet-1) BoundaryTable << " "; } BoundaryTable.PrintFooter(); - } - + } + if (nMarker_Riemann != 0) { BoundaryTable << "Riemann boundary"; for (iMarker_Riemann = 0; iMarker_Riemann < nMarker_Riemann; iMarker_Riemann++) { @@ -6837,8 +6838,8 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { if (iMarker_Riemann < nMarker_Riemann-1) BoundaryTable << " "; } BoundaryTable.PrintFooter(); - } - + } + if (nMarker_Giles != 0) { BoundaryTable << "Giles boundary"; for (iMarker_Giles = 0; iMarker_Giles < nMarker_Giles; iMarker_Giles++) { @@ -6846,8 +6847,8 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { if (iMarker_Giles < nMarker_Giles-1) BoundaryTable << " "; } BoundaryTable.PrintFooter(); - } - + } + if (nMarker_MixingPlaneInterface != 0) { BoundaryTable << "MixingPlane boundary"; for (iMarker_MixingPlaneInterface = 0; iMarker_MixingPlaneInterface < nMarker_MixingPlaneInterface; iMarker_MixingPlaneInterface++) { @@ -6855,8 +6856,8 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { if (iMarker_MixingPlaneInterface < nMarker_MixingPlaneInterface-1) BoundaryTable << " "; } BoundaryTable.PrintFooter(); - } - + } + if (nMarker_EngineInflow != 0) { BoundaryTable << "Engine inflow boundary"; for (iMarker_EngineInflow = 0; iMarker_EngineInflow < nMarker_EngineInflow; iMarker_EngineInflow++) { @@ -6864,8 +6865,8 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { if (iMarker_EngineInflow < nMarker_EngineInflow-1) BoundaryTable << " "; } BoundaryTable.PrintFooter(); - } - + } + if (nMarker_EngineExhaust != 0) { BoundaryTable << "Engine exhaust boundary"; for (iMarker_EngineExhaust = 0; iMarker_EngineExhaust < nMarker_EngineExhaust; iMarker_EngineExhaust++) { @@ -6873,8 +6874,8 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { if (iMarker_EngineExhaust < nMarker_EngineExhaust-1) BoundaryTable << " "; } BoundaryTable.PrintFooter(); - } - + } + if (nMarker_Supersonic_Inlet != 0) { BoundaryTable << "Supersonic inlet boundary"; for (iMarker_Supersonic_Inlet = 0; iMarker_Supersonic_Inlet < nMarker_Supersonic_Inlet; iMarker_Supersonic_Inlet++) { @@ -6882,8 +6883,8 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { if (iMarker_Supersonic_Inlet < nMarker_Supersonic_Inlet-1) BoundaryTable << " "; } BoundaryTable.PrintFooter(); - } - + } + if (nMarker_Supersonic_Outlet != 0) { BoundaryTable << "Supersonic outlet boundary"; for (iMarker_Supersonic_Outlet = 0; iMarker_Supersonic_Outlet < nMarker_Supersonic_Outlet; iMarker_Supersonic_Outlet++) { @@ -6891,8 +6892,8 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { if (iMarker_Supersonic_Outlet < nMarker_Supersonic_Outlet-1) BoundaryTable << " "; } BoundaryTable.PrintFooter(); - } - + } + if (nMarker_Outlet != 0) { BoundaryTable << "Outlet boundary"; for (iMarker_Outlet = 0; iMarker_Outlet < nMarker_Outlet; iMarker_Outlet++) { @@ -6900,8 +6901,8 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { if (iMarker_Outlet < nMarker_Outlet-1) BoundaryTable << " "; } BoundaryTable.PrintFooter(); - } - + } + if (nMarker_Isothermal != 0) { BoundaryTable << "Isothermal wall"; for (iMarker_Isothermal = 0; iMarker_Isothermal < nMarker_Isothermal; iMarker_Isothermal++) { @@ -6909,9 +6910,9 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { if (iMarker_Isothermal < nMarker_Isothermal-1) BoundaryTable << " "; } BoundaryTable.PrintFooter(); - } - - if (nMarker_HeatFlux != 0) { + } + + if (nMarker_HeatFlux != 0) { BoundaryTable << "Heat flux wall"; for (iMarker_HeatFlux = 0; iMarker_HeatFlux < nMarker_HeatFlux; iMarker_HeatFlux++) { BoundaryTable << Marker_HeatFlux[iMarker_HeatFlux]; @@ -6919,8 +6920,8 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { } BoundaryTable.PrintFooter(); } - - if (nMarker_Clamped != 0) { + + if (nMarker_Clamped != 0) { BoundaryTable << "Clamped boundary"; for (iMarker_Clamped = 0; iMarker_Clamped < nMarker_Clamped; iMarker_Clamped++) { BoundaryTable << Marker_Clamped[iMarker_Clamped]; @@ -6929,7 +6930,7 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { BoundaryTable.PrintFooter(); } - if (nMarker_Displacement != 0) { + if (nMarker_Displacement != 0) { BoundaryTable << "Displacement boundary"; for (iMarker_Displacement = 0; iMarker_Displacement < nMarker_Displacement; iMarker_Displacement++) { BoundaryTable << Marker_Displacement[iMarker_Displacement]; @@ -6938,7 +6939,7 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { BoundaryTable.PrintFooter(); } - if (nMarker_Load != 0) { + if (nMarker_Load != 0) { BoundaryTable << "Normal load boundary"; for (iMarker_Load = 0; iMarker_Load < nMarker_Load; iMarker_Load++) { BoundaryTable << Marker_Load[iMarker_Load]; @@ -6946,8 +6947,8 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { } BoundaryTable.PrintFooter(); } - - if (nMarker_Damper != 0) { + + if (nMarker_Damper != 0) { BoundaryTable << "Damper boundary"; for (iMarker_Damper = 0; iMarker_Damper < nMarker_Damper; iMarker_Damper++) { BoundaryTable << Marker_Damper[iMarker_Damper]; @@ -6955,8 +6956,8 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { } BoundaryTable.PrintFooter(); } - - if (nMarker_Load_Dir != 0) { + + if (nMarker_Load_Dir != 0) { BoundaryTable << "Load boundary"; for (iMarker_Load_Dir = 0; iMarker_Load_Dir < nMarker_Load_Dir; iMarker_Load_Dir++) { BoundaryTable << Marker_Load_Dir[iMarker_Load_Dir]; @@ -6964,8 +6965,8 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { } BoundaryTable.PrintFooter(); } - - if (nMarker_Disp_Dir != 0) { + + if (nMarker_Disp_Dir != 0) { BoundaryTable << "Disp boundary"; for (iMarker_Disp_Dir = 0; iMarker_Disp_Dir < nMarker_Disp_Dir; iMarker_Disp_Dir++) { BoundaryTable << Marker_Disp_Dir[iMarker_Disp_Dir]; @@ -6973,8 +6974,8 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { } BoundaryTable.PrintFooter(); } - - if (nMarker_Load_Sine != 0) { + + if (nMarker_Load_Sine != 0) { BoundaryTable << "Sine-Wave boundary"; for (iMarker_Load_Sine = 0; iMarker_Load_Sine < nMarker_Load_Sine; iMarker_Load_Sine++) { BoundaryTable << Marker_Load_Sine[iMarker_Load_Sine]; @@ -6982,8 +6983,8 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { } BoundaryTable.PrintFooter(); } - - if (nMarker_Custom != 0) { + + if (nMarker_Custom != 0) { BoundaryTable << "Custom boundary"; for (iMarker_Custom = 0; iMarker_Custom < nMarker_Custom; iMarker_Custom++) { BoundaryTable << Marker_Custom[iMarker_Custom]; @@ -6991,8 +6992,8 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { } BoundaryTable.PrintFooter(); } - - if (nMarker_ActDiskInlet != 0) { + + if (nMarker_ActDiskInlet != 0) { BoundaryTable << "Actuator disk (inlet) boundary"; for (iMarker_ActDiskInlet = 0; iMarker_ActDiskInlet < nMarker_ActDiskInlet; iMarker_ActDiskInlet++) { BoundaryTable << Marker_ActDiskInlet[iMarker_ActDiskInlet]; @@ -7000,8 +7001,8 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { } BoundaryTable.PrintFooter(); } - - if (nMarker_ActDiskOutlet != 0) { + + if (nMarker_ActDiskOutlet != 0) { BoundaryTable << "Actuator disk (outlet) boundary"; for (iMarker_ActDiskOutlet = 0; iMarker_ActDiskOutlet < nMarker_ActDiskOutlet; iMarker_ActDiskOutlet++) { BoundaryTable << Marker_ActDiskOutlet[iMarker_ActDiskOutlet]; @@ -7294,10 +7295,10 @@ unsigned short CConfig::GetMarker_CfgFile_PerBound(string val_marker) { return Marker_CfgFile_PerBound[iMarker_CfgFile]; } -int CConfig::GetMarker_ZoneInterface(string val_marker) { +int CConfig::GetMarker_ZoneInterface(string val_marker) { unsigned short iMarker_CfgFile; for (iMarker_CfgFile = 0; iMarker_CfgFile < nMarker_CfgFile; iMarker_CfgFile++) - + if (Marker_CfgFile_TagBound[iMarker_CfgFile] == val_marker) return Marker_CfgFile_ZoneInterface[iMarker_CfgFile]; return 0; @@ -7305,59 +7306,59 @@ int CConfig::GetMarker_ZoneInterface(string val_marker) { bool CConfig::GetSolid_Wall(unsigned short iMarker){ - + if (Marker_All_KindBC[iMarker] == HEAT_FLUX || Marker_All_KindBC[iMarker] == ISOTHERMAL || Marker_All_KindBC[iMarker] == CHT_WALL_INTERFACE || Marker_All_KindBC[iMarker] == EULER_WALL){ return true; } - + return false; } bool CConfig::GetViscous_Wall(unsigned short iMarker){ - + if (Marker_All_KindBC[iMarker] == HEAT_FLUX || Marker_All_KindBC[iMarker] == ISOTHERMAL || Marker_All_KindBC[iMarker] == CHT_WALL_INTERFACE){ return true; } - + return false; } void CConfig::SetSurface_Movement(unsigned short iMarker, unsigned short kind_movement){ - + unsigned short* new_surface_movement = new unsigned short[nMarker_Moving + 1]; string* new_marker_moving = new string[nMarker_Moving+1]; - + for (unsigned short iMarker_Moving = 0; iMarker_Moving < nMarker_Moving; iMarker_Moving++){ new_surface_movement[iMarker_Moving] = Kind_SurfaceMovement[iMarker_Moving]; new_marker_moving[iMarker_Moving] = Marker_Moving[iMarker_Moving]; } - + if (nKind_SurfaceMovement > 0){ delete [] Marker_Moving; delete [] Kind_SurfaceMovement; } - + Kind_SurfaceMovement = new_surface_movement; Marker_Moving = new_marker_moving; - + Kind_SurfaceMovement[nMarker_Moving] = kind_movement; Marker_Moving[nMarker_Moving] = Marker_All_TagBound[iMarker]; - + nMarker_Moving++; nKind_SurfaceMovement++; - + } CConfig::~CConfig(void) { - + unsigned long iDV, iMarker, iPeriodic, iFFD; /*--- Delete all of the option objects in the global option map ---*/ - + for(map::iterator itr = option_map.begin(); itr != option_map.end(); itr++) { delete itr->second; } @@ -7373,84 +7374,84 @@ CConfig::~CConfig(void) { if (Aeroelastic_pitch != NULL) delete[] Aeroelastic_pitch; if (Aeroelastic_plunge != NULL) delete[] Aeroelastic_plunge; - + /*--- Free memory for airfoil sections ---*/ if (LocationStations != NULL) delete [] LocationStations; /*--- motion origin: ---*/ - + if (MarkerMotion_Origin != NULL) delete [] MarkerMotion_Origin; - + if (MoveMotion_Origin != NULL) delete [] MoveMotion_Origin; /*--- translation: ---*/ - + if (MarkerTranslation_Rate != NULL) delete [] MarkerTranslation_Rate; /*--- rotation: ---*/ - + if (MarkerRotation_Rate != NULL) delete [] MarkerRotation_Rate; /*--- pitching: ---*/ - + if (MarkerPitching_Omega != NULL) delete [] MarkerPitching_Omega; /*--- pitching amplitude: ---*/ - + if (MarkerPitching_Ampl != NULL) delete [] MarkerPitching_Ampl; /*--- pitching phase: ---*/ - + if (MarkerPitching_Phase != NULL) delete [] MarkerPitching_Phase; /*--- plunging: ---*/ - + if (MarkerPlunging_Omega != NULL) delete [] MarkerPlunging_Omega; /*--- plunging amplitude: ---*/ if (MarkerPlunging_Ampl != NULL) delete [] MarkerPlunging_Ampl; /*--- reference origin for moments ---*/ - + if (RefOriginMoment != NULL) delete [] RefOriginMoment; if (RefOriginMoment_X != NULL) delete [] RefOriginMoment_X; if (RefOriginMoment_Y != NULL) delete [] RefOriginMoment_Y; if (RefOriginMoment_Z != NULL) delete [] RefOriginMoment_Z; /*--- Free memory for Harmonic Blance Frequency pointer ---*/ - + if (Omega_HB != NULL) delete [] Omega_HB; - + /*--- Marker pointers ---*/ - + if (Marker_CfgFile_GeoEval != NULL) delete[] Marker_CfgFile_GeoEval; if (Marker_All_GeoEval != NULL) delete[] Marker_All_GeoEval; - + if (Marker_CfgFile_TagBound != NULL) delete[] Marker_CfgFile_TagBound; if (Marker_All_TagBound != NULL) delete[] Marker_All_TagBound; - + if (Marker_CfgFile_KindBC != NULL) delete[] Marker_CfgFile_KindBC; if (Marker_All_KindBC != NULL) delete[] Marker_All_KindBC; - + if (Marker_CfgFile_Monitoring != NULL) delete[] Marker_CfgFile_Monitoring; if (Marker_All_Monitoring != NULL) delete[] Marker_All_Monitoring; - + if (Marker_CfgFile_Designing != NULL) delete[] Marker_CfgFile_Designing; if (Marker_All_Designing != NULL) delete[] Marker_All_Designing; - + if (Marker_CfgFile_Plotting != NULL) delete[] Marker_CfgFile_Plotting; if (Marker_All_Plotting != NULL) delete[] Marker_All_Plotting; - + if (Marker_CfgFile_Analyze != NULL) delete[] Marker_CfgFile_Analyze; if (Marker_All_Analyze != NULL) delete[] Marker_All_Analyze; if (Marker_CfgFile_ZoneInterface != NULL) delete[] Marker_CfgFile_ZoneInterface; if (Marker_All_ZoneInterface != NULL) delete[] Marker_All_ZoneInterface; - + if (Marker_CfgFile_DV != NULL) delete[] Marker_CfgFile_DV; if (Marker_All_DV != NULL) delete[] Marker_All_DV; - + if (Marker_CfgFile_Moving != NULL) delete[] Marker_CfgFile_Moving; if (Marker_All_Moving != NULL) delete[] Marker_All_Moving; @@ -7462,7 +7463,7 @@ CConfig::~CConfig(void) { if (Marker_CfgFile_PyCustom != NULL) delete[] Marker_CfgFile_PyCustom; if (Marker_All_PyCustom != NULL) delete[] Marker_All_PyCustom; - + if (Marker_CfgFile_PerBound != NULL) delete[] Marker_CfgFile_PerBound; if (Marker_All_PerBound != NULL) delete[] Marker_All_PerBound; @@ -7504,7 +7505,7 @@ CConfig::~CConfig(void) { if (DoubleInfo_WallFunctions != NULL) { for (iMarker = 0; iMarker < nMarker_WallFunctions; ++iMarker) { - if (DoubleInfo_WallFunctions[iMarker] != NULL) + if (DoubleInfo_WallFunctions[iMarker] != NULL) delete[] DoubleInfo_WallFunctions[iMarker]; } delete[] DoubleInfo_WallFunctions; @@ -7517,24 +7518,24 @@ CConfig::~CConfig(void) { for (iDV = 0; iDV < nDV; iDV++) delete[] DV_Value[iDV]; delete [] DV_Value; } - + if (ParamDV != NULL) { for (iDV = 0; iDV < nDV; iDV++) delete[] ParamDV[iDV]; delete [] ParamDV; } - + if (CoordFFDBox != NULL) { for (iFFD = 0; iFFD < nFFDBox; iFFD++) delete[] CoordFFDBox[iFFD]; delete [] CoordFFDBox; } - + if (DegreeFFDBox != NULL) { for (iFFD = 0; iFFD < nFFDBox; iFFD++) delete[] DegreeFFDBox[iFFD]; delete [] DegreeFFDBox; } - + if (Design_Variable != NULL) delete[] Design_Variable; - + if (Exhaust_Temperature_Target != NULL) delete[] Exhaust_Temperature_Target; if (Exhaust_Pressure_Target != NULL) delete[] Exhaust_Pressure_Target; if (Exhaust_Pressure != NULL) delete[] Exhaust_Pressure; @@ -7603,7 +7604,7 @@ CConfig::~CConfig(void) { if (ActDisk_GrossThrust != NULL) delete[] ActDisk_GrossThrust; if (ActDisk_Area != NULL) delete[] ActDisk_Area; if (ActDisk_ReverseMassFlow != NULL) delete[] ActDisk_ReverseMassFlow; - + if (Surface_MassFlow != NULL) delete[] Surface_MassFlow; if (Surface_Mach != NULL) delete[] Surface_Mach; if (Surface_Temperature != NULL) delete[] Surface_Temperature; @@ -7630,37 +7631,37 @@ CConfig::~CConfig(void) { delete [] Inlet_FlowDir[iMarker]; delete [] Inlet_FlowDir; } - + if (Inlet_Velocity != NULL) { for (iMarker = 0; iMarker < nMarker_Supersonic_Inlet; iMarker++) delete [] Inlet_Velocity[iMarker]; delete [] Inlet_Velocity; } - + if (Riemann_FlowDir != NULL) { for (iMarker = 0; iMarker < nMarker_Riemann; iMarker++) delete [] Riemann_FlowDir[iMarker]; delete [] Riemann_FlowDir; } - + if (Giles_FlowDir != NULL) { for (iMarker = 0; iMarker < nMarker_Giles; iMarker++) delete [] Giles_FlowDir[iMarker]; delete [] Giles_FlowDir; } - + if (Load_Sine_Dir != NULL) { for (iMarker = 0; iMarker < nMarker_Load_Sine; iMarker++) delete [] Load_Sine_Dir[iMarker]; delete [] Load_Sine_Dir; } - + if (Load_Dir != NULL) { for (iMarker = 0; iMarker < nMarker_Load_Dir; iMarker++) delete [] Load_Dir[iMarker]; delete [] Load_Dir; } - + if (Inlet_Temperature != NULL) delete[] Inlet_Temperature; if (Inlet_Pressure != NULL) delete[] Inlet_Pressure; if (Outlet_Pressure != NULL) delete[] Outlet_Pressure; @@ -7679,7 +7680,7 @@ CConfig::~CConfig(void) { if (FlowLoad_Value != NULL) delete[] FlowLoad_Value; /*--- related to periodic boundary conditions ---*/ - + for (iMarker = 0; iMarker < nMarker_PerBound; iMarker++) { if (Periodic_RotCenter != NULL) delete [] Periodic_RotCenter[iMarker]; if (Periodic_RotAngles != NULL) delete [] Periodic_RotAngles[iMarker]; @@ -7703,7 +7704,7 @@ CConfig::~CConfig(void) { if (CFL != NULL) delete[] CFL; /*--- String markers ---*/ - + if (Marker_Euler != NULL ) delete[] Marker_Euler; if (Marker_FarField != NULL ) delete[] Marker_FarField; if (Marker_Custom != NULL ) delete[] Marker_Custom; @@ -7732,7 +7733,7 @@ CConfig::~CConfig(void) { if (Marker_HeatFlux != NULL ) delete[] Marker_HeatFlux; if (Int_Coeffs != NULL) delete [] Int_Coeffs; - + if (ElasticityMod != NULL) delete [] ElasticityMod; if (PoissonRatio != NULL) delete [] PoissonRatio; if (MaterialDensity != NULL) delete [] MaterialDensity; @@ -7742,7 +7743,7 @@ CConfig::~CConfig(void) { if (Electric_Field_Dir != NULL) delete [] Electric_Field_Dir; /*--- Delete some arrays needed just for initializing options. ---*/ - + if (default_vel_inf != NULL) delete [] default_vel_inf; if (default_ffd_axis != NULL) delete [] default_ffd_axis; if (default_eng_cyl != NULL) delete [] default_eng_cyl; @@ -7767,7 +7768,7 @@ CConfig::~CConfig(void) { if (default_sineload_coeff!= NULL) delete [] default_sineload_coeff; if (default_nacelle_location != NULL) delete [] default_nacelle_location; if (default_wrt_freq != NULL) delete [] default_wrt_freq; - + if (default_cp_polycoeffs != NULL) delete [] default_cp_polycoeffs; if (default_mu_polycoeffs != NULL) delete [] default_mu_polycoeffs; if (default_kt_polycoeffs != NULL) delete [] default_kt_polycoeffs; @@ -7778,7 +7779,7 @@ CConfig::~CConfig(void) { if (FFDTag != NULL) delete [] FFDTag; if (nDV_Value != NULL) delete [] nDV_Value; if (TagFFDBox != NULL) delete [] TagFFDBox; - + if (Kind_Data_Riemann != NULL) delete [] Kind_Data_Riemann; if (Riemann_Var1 != NULL) delete [] Riemann_Var1; if (Riemann_Var2 != NULL) delete [] Riemann_Var2; @@ -7803,7 +7804,7 @@ CConfig::~CConfig(void) { if (top_optim_kernels != NULL) delete [] top_optim_kernels; if (top_optim_kernel_params != NULL) delete [] top_optim_kernel_params; if (top_optim_filter_radius != NULL) delete [] top_optim_filter_radius; - + if (ScreenOutput != NULL) delete [] ScreenOutput; if (HistoryOutput != NULL) delete [] HistoryOutput; if (VolumeOutput != NULL) delete [] VolumeOutput; @@ -7813,16 +7814,16 @@ CConfig::~CConfig(void) { } string CConfig::GetFilename(string filename, string ext, unsigned long Iter){ - + /*--- Remove any extension --- */ - + unsigned short lastindex = filename.find_last_of("."); filename = filename.substr(0, lastindex); - + /*--- Add the extension --- */ - + filename = filename + string(ext); - + /*--- Append the zone number if multizone problems ---*/ if (Multizone_Problem) filename = GetMultizone_FileName(filename, GetiZone(), ext); @@ -7834,7 +7835,7 @@ string CConfig::GetFilename(string filename, string ext, unsigned long Iter){ if (GetTime_Domain()){ filename = GetUnsteady_FileName(filename, (int)Iter, ext); } - + return filename; } @@ -7844,14 +7845,14 @@ string CConfig::GetUnsteady_FileName(string val_filename, int val_iter, string e char buffer[50]; /*--- Check that a positive value iteration is requested (for now). ---*/ - + if (val_iter < 0) { SU2_MPI::Error("Requesting a negative iteration number for the restart file!!", CURRENT_FUNCTION); } - + unsigned short lastindex = UnstFilename.find_last_of("."); UnstFilename = UnstFilename.substr(0, lastindex); - + /*--- Append iteration number for unsteady cases ---*/ if (Time_Domain) { @@ -7873,16 +7874,16 @@ string CConfig::GetMultizone_FileName(string val_filename, int val_iZone, string string multizone_filename = val_filename; char buffer[50]; - + unsigned short lastindex = multizone_filename.find_last_of("."); multizone_filename = multizone_filename.substr(0, lastindex); - + if (Multizone_Problem) { SPRINTF (buffer, "_%d", SU2_TYPE::Int(val_iZone)); multizone_filename.append(string(buffer)); } - - multizone_filename += ext; + + multizone_filename += ext; return multizone_filename; } @@ -8035,12 +8036,12 @@ void CConfig::SetGlobalParam(unsigned short val_solver, unsigned short val_system) { /*--- Set the simulation global time ---*/ - + Current_UnstTime = static_cast(TimeIter)*Delta_UnstTime; Current_UnstTimeND = static_cast(TimeIter)*Delta_UnstTimeND; /*--- Set the solver methods ---*/ - + switch (val_solver) { case EULER: case INC_EULER: if (val_system == RUNTIME_FLOW_SYS) { @@ -8357,51 +8358,51 @@ su2double CConfig::GetOutlet_Area(string val_marker) { unsigned short CConfig::GetMarker_CfgFile_ActDiskOutlet(string val_marker) { unsigned short iMarker_ActDisk, kMarker_All; - + /*--- Find the marker for this actuator disk inlet. ---*/ - + for (iMarker_ActDisk = 0; iMarker_ActDisk < nMarker_ActDiskInlet; iMarker_ActDisk++) if (Marker_ActDiskInlet[iMarker_ActDisk] == val_marker) break; - + /*--- Find and return global marker index for the actuator disk outlet. ---*/ - + for (kMarker_All = 0; kMarker_All < nMarker_CfgFile; kMarker_All++) if (Marker_ActDiskOutlet[iMarker_ActDisk] == Marker_CfgFile_TagBound[kMarker_All]) break; - + return kMarker_All; } unsigned short CConfig::GetMarker_CfgFile_EngineExhaust(string val_marker) { unsigned short iMarker_Engine, kMarker_All; - + /*--- Find the marker for this engine inflow. ---*/ - + for (iMarker_Engine = 0; iMarker_Engine < nMarker_EngineInflow; iMarker_Engine++) if (Marker_EngineInflow[iMarker_Engine] == val_marker) break; - + /*--- Find and return global marker index for the engine exhaust. ---*/ - + for (kMarker_All = 0; kMarker_All < nMarker_CfgFile; kMarker_All++) if (Marker_EngineExhaust[iMarker_Engine] == Marker_CfgFile_TagBound[kMarker_All]) break; - + return kMarker_All; } bool CConfig::GetVolumetric_Movement(){ bool volumetric_movement = false; - - if (GetSurface_Movement(AEROELASTIC) || + + if (GetSurface_Movement(AEROELASTIC) || GetSurface_Movement(DEFORMING) || GetSurface_Movement(AEROELASTIC_RIGID_MOTION)|| GetSurface_Movement(FLUID_STRUCTURE) || GetSurface_Movement(FLUID_STRUCTURE_STATIC) || - GetSurface_Movement(EXTERNAL) || + GetSurface_Movement(EXTERNAL) || GetSurface_Movement(EXTERNAL_ROTATION)){ volumetric_movement = true; } - - if (Kind_SU2 == SU2_DEF || - Kind_SU2 == SU2_DOT || + + if (Kind_SU2 == SU2_DEF || + Kind_SU2 == SU2_DOT || DirectDiff) { volumetric_movement = true;} return volumetric_movement; @@ -8757,7 +8758,7 @@ void CConfig::SetIncInlet_BC(su2double val_in) { else if (Kind_Inc_Inlet[0] == PRESSURE_INLET) Inlet_Ptotal[0] = val_in*Pressure_Ref; } - + } su2double CConfig::GetIncTemperature_BC() { @@ -8776,7 +8777,7 @@ void CConfig::SetIncTemperature_BC(su2double val_temperature) { if (nMarker_Inlet > 0) { Inlet_Ttotal[0] = val_temperature*Temperature_Ref; } - + } su2double CConfig::GetIncPressureOut_BC() { @@ -8858,8 +8859,8 @@ su2double* CConfig::GetWallFunction_DoubleInfo(string val_marker) { if(Marker_WallFunctions[iMarker] == val_marker) { doubleInfo = DoubleInfo_WallFunctions[iMarker]; break; - } - } + } + } return doubleInfo; } @@ -9697,9 +9698,9 @@ void CConfig::SetFreeStreamTurboNormal(su2double* turboNormal){ } void CConfig::SetMultizone(CConfig *driver_config, CConfig **config_container){ - + for (unsigned short iZone = 0; iZone < nZone; iZone++){ - + if (config_container[iZone]->GetTime_Domain() != GetTime_Domain()){ SU2_MPI::Error("Option TIME_DOMAIN must be the same in all zones.", CURRENT_FUNCTION); } @@ -9753,7 +9754,7 @@ void CConfig::SetMultizone(CConfig *driver_config, CConfig **config_container){ for (iZone = 0; iZone < nZone; iZone++){ switch (config_container[iZone]->GetKind_Solver()) { case EULER: case NAVIER_STOKES: case RANS: - case INC_EULER: case INC_NAVIER_STOKES: case INC_RANS: + case INC_EULER: case INC_NAVIER_STOKES: case INC_RANS: fluid_zone = true; break; case FEM_ELASTICITY: From efe60d9cf00cf11f0f7d69e209a3e1e676314b62 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Wed, 29 Jan 2020 00:32:12 +0000 Subject: [PATCH 034/118] fix blanks and tabs in config_structure.hpp --- Common/include/config_structure.hpp | 2719 +++++++++++++-------------- Common/include/option_structure.hpp | 158 +- 2 files changed, 1439 insertions(+), 1438 deletions(-) diff --git a/Common/include/config_structure.hpp b/Common/include/config_structure.hpp index 209ab4e83581..cbb5ab7d6ece 100644 --- a/Common/include/config_structure.hpp +++ b/Common/include/config_structure.hpp @@ -7,7 +7,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -82,15 +82,15 @@ class CConfig { su2double AdjointLimit; /*!< \brief Adjoint variable limit */ su2double* Obj_ChainRuleCoeff; /*!< \brief Array defining objective function for adjoint problem based on chain rule in terms of gradient w.r.t. density, velocity, pressure */ - string* ConvField; /*!< \brief Field used for convergence check.*/ + string* ConvField; /*!< \brief Field used for convergence check.*/ - string* WndConvField; /*!< \brief Function where to apply the windowed convergence criteria for the time average of the unsteady (single zone) flow problem. */ + string* WndConvField; /*!< \brief Function where to apply the windowed convergence criteria for the time average of the unsteady (single zone) flow problem. */ unsigned short nConvField; /*!< \brief Number of fields used to monitor convergence.*/ unsigned short nWndConvField; /*!< \brief Number of fields used to monitor time convergence.*/ unsigned short Wnd_Cauchy_Elems; /*!< \brief Number of elements to evaluate in the time iteration for convergence of the time average of the unsteady (single zone)´ flow problem. */ su2double Wnd_Cauchy_Eps; /*!< \brief Epsilon used for the convergence of the time average of the unsteady (single zone)´ flow problem. */ unsigned long Wnd_StartConv_Iter; /*!< \brief Start convergence criteria at this iteration after Start_Iter_Wnd. */ - bool Wnd_Cauchy_Crit; /*!< \brief True => Cauchy criterion is used for time average objective function in unsteady flows. */ + bool Wnd_Cauchy_Crit; /*!< \brief True => Cauchy criterion is used for time average objective function in unsteady flows. */ bool MG_AdjointFlow; /*!< \brief MG with the adjoint flow problem */ su2double* SubsonicEngine_Cyl; /*!< \brief Coordinates of the box subsonic region */ @@ -99,49 +99,49 @@ class CConfig { su2double *DistortionRack; su2double *PressureLimits, *DensityLimits, - *TemperatureLimits; /*!< \brief Limits for the primitive variables */ - bool ActDisk_DoubleSurface; /*!< \brief actuator disk double surface */ - bool Engine_HalfModel; /*!< \brief only half model is in the computational grid */ - bool ActDisk_SU2_DEF; /*!< \brief actuator disk double surface */ - unsigned short ConvCriteria; /*!< \brief Kind of convergence criteria. */ - unsigned short nFFD_Iter; /*!< \brief Iteration for the point inversion problem. */ + *TemperatureLimits; /*!< \brief Limits for the primitive variables */ + bool ActDisk_DoubleSurface; /*!< \brief actuator disk double surface */ + bool Engine_HalfModel; /*!< \brief only half model is in the computational grid */ + bool ActDisk_SU2_DEF; /*!< \brief actuator disk double surface */ + unsigned short ConvCriteria; /*!< \brief Kind of convergence criteria. */ + unsigned short nFFD_Iter; /*!< \brief Iteration for the point inversion problem. */ unsigned short FFD_Blending; /*!< \brief Kind of FFD Blending function. */ su2double* FFD_BSpline_Order; /*!< \brief BSpline order in i,j,k direction. */ - su2double FFD_Tol; /*!< \brief Tolerance in the point inversion problem. */ - su2double Opt_RelaxFactor; /*!< \brief Scale factor for the line search. */ + 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; 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. */ + EquivArea, /*!< \brief Flag to know if the code is going to compute and plot the equivalent area. */ Engine, /*!< \brief Flag to know if the code is going to compute a problem with engine. */ - InvDesign_Cp, /*!< \brief Flag to know if the code is going to compute and plot the inverse design. */ - InvDesign_HeatFlux, /*!< \brief Flag to know if the code is going to compute and plot the inverse design. */ + InvDesign_Cp, /*!< \brief Flag to know if the code is going to compute and plot the inverse design. */ + InvDesign_HeatFlux, /*!< \brief Flag to know if the code is going to compute and plot the inverse design. */ Wind_Gust, /*!< \brief Flag to know if there is a wind gust. */ Aeroelastic_Simulation, /*!< \brief Flag to know if there is an aeroelastic simulation. */ Weakly_Coupled_Heat, /*!< \brief Flag to know if a heat equation should be weakly coupled to the incompressible solver. */ - Rotating_Frame, /*!< \brief Flag to know if there is a rotating frame. */ - PoissonSolver, /*!< \brief Flag to know if we are solving poisson forces in plasma solver. */ - Low_Mach_Precon, /*!< \brief Flag to know if we are using a low Mach number preconditioner. */ - Low_Mach_Corr, /*!< \brief Flag to know if we are using a low Mach number correction. */ - GravityForce, /*!< \brief Flag to know if the gravity force is incuded in the formulation. */ - SmoothNumGrid, /*!< \brief Smooth the numerical grid. */ - AdaptBoundary, /*!< \brief Adapt the elements on the boundary. */ - SubsonicEngine, /*!< \brief Engine intake subsonic region. */ - Frozen_Visc_Cont, /*!< \brief Flag for cont. adjoint problem with/without frozen viscosity. */ - Frozen_Visc_Disc, /*!< \brief Flag for disc. adjoint problem with/without frozen viscosity. */ + Rotating_Frame, /*!< \brief Flag to know if there is a rotating frame. */ + PoissonSolver, /*!< \brief Flag to know if we are solving poisson forces in plasma solver. */ + Low_Mach_Precon, /*!< \brief Flag to know if we are using a low Mach number preconditioner. */ + Low_Mach_Corr, /*!< \brief Flag to know if we are using a low Mach number correction. */ + GravityForce, /*!< \brief Flag to know if the gravity force is incuded in the formulation. */ + SmoothNumGrid, /*!< \brief Smooth the numerical grid. */ + AdaptBoundary, /*!< \brief Adapt the elements on the boundary. */ + SubsonicEngine, /*!< \brief Engine intake subsonic region. */ + Frozen_Visc_Cont, /*!< \brief Flag for cont. adjoint problem with/without frozen viscosity. */ + Frozen_Visc_Disc, /*!< \brief Flag for disc. adjoint problem with/without frozen viscosity. */ Frozen_Limiter_Disc, /*!< \brief Flag for disc. adjoint problem with/without frozen limiter. */ Inconsistent_Disc, /*!< \brief Use an inconsistent (primal/dual) discrete adjoint formulation. */ - Sens_Remove_Sharp, /*!< \brief Flag for removing or not the sharp edges from the sensitivity computation. */ - Hold_GridFixed, /*!< \brief Flag hold fixed some part of the mesh during the deformation. */ + Sens_Remove_Sharp, /*!< \brief Flag for removing or not the sharp edges from the sensitivity computation. */ + Hold_GridFixed, /*!< \brief Flag hold fixed some part of the mesh during the deformation. */ Axisymmetric, /*!< \brief Flag for axisymmetric calculations */ Integrated_HeatFlux, /*!< \brief Flag for heat flux BC whether it deals with integrated values.*/ Buffet_Monitoring; /*!< \brief Flag for computing the buffet sensor.*/ su2double Buffet_k; /*!< \brief Sharpness coefficient for buffet sensor.*/ su2double Buffet_lambda; /*!< \brief Offset parameter for buffet sensor.*/ - su2double Damp_Engine_Inflow; /*!< \brief Damping factor for the engine inlet. */ + su2double Damp_Engine_Inflow; /*!< \brief Damping factor for the engine inlet. */ su2double Damp_Engine_Exhaust; /*!< \brief Damping factor for the engine exhaust. */ - su2double Damp_Res_Restric, /*!< \brief Damping factor for the residual restriction. */ + su2double Damp_Res_Restric, /*!< \brief Damping factor for the residual restriction. */ Damp_Correc_Prolong; /*!< \brief Damping factor for the correction prolongation. */ su2double Position_Plane; /*!< \brief Position of the Near-Field (y coordinate 2D, and z coordinate 3D). */ su2double WeightCd; /*!< \brief Weight of the drag coefficient. */ @@ -154,119 +154,118 @@ class CConfig { su2double CM_Target; /*!< \brief Fixed Cl mode Target CM. */ su2double *HTP_Min_XCoord, *HTP_Min_YCoord; /*!< \brief Identification of the HTP. */ - unsigned short TimeMarching; /*!< \brief Steady or unsteady (time stepping or dual time stepping) computation. */ + unsigned short TimeMarching; /*!< \brief Steady or unsteady (time stepping or dual time stepping) computation. */ unsigned short Dynamic_Analysis; /*!< \brief Static or dynamic structural analysis. */ - unsigned short nStartUpIter; /*!< \brief Start up iterations using the fine grid. */ + unsigned short nStartUpIter; /*!< \brief Start up iterations using the fine grid. */ su2double FixAzimuthalLine; /*!< \brief Fix an azimuthal line due to misalignments of the nearfield. */ - su2double **DV_Value; /*!< \brief Previous value of the design variable. */ + su2double **DV_Value; /*!< \brief Previous value of the design variable. */ su2double Venkat_LimiterCoeff; /*!< \brief Limiter coefficient */ - unsigned long LimiterIter; /*!< \brief Freeze the value of the limiter after a number of iterations */ + unsigned long LimiterIter; /*!< \brief Freeze the value of the limiter after a number of iterations */ su2double AdjSharp_LimiterCoeff; /*!< \brief Coefficient to identify the limit of a sharp edge. */ unsigned short SystemMeasurements; /*!< \brief System of measurements. */ - unsigned short Kind_Regime; /*!< \brief Kind of adjoint function. */ - unsigned short *Kind_ObjFunc; /*!< \brief Kind of objective function. */ - su2double *Weight_ObjFunc; /*!< \brief Weight applied to objective function. */ - unsigned short Kind_SensSmooth; /*!< \brief Kind of sensitivity smoothing technique. */ - unsigned short Continuous_Eqns; /*!< \brief Which equations to treat continuously (Hybrid adjoint)*/ - unsigned short Discrete_Eqns; /*!< \brief Which equations to treat discretely (Hybrid adjoint). */ - unsigned short *Design_Variable; /*!< \brief Kind of design variable. */ - unsigned short Kind_Adaptation; /*!< \brief Kind of numerical grid adaptation. */ - unsigned short nTimeInstances; /*!< \brief Number of periodic time instances for harmonic balance. */ - su2double HarmonicBalance_Period; /*!< \brief Period of oscillation to be used with harmonic balance computations. */ - su2double New_Elem_Adapt; /*!< \brief Elements to adapt in the numerical grid adaptation process. */ - su2double Delta_UnstTime, /*!< \brief Time step for unsteady computations. */ - Delta_UnstTimeND; /*!< \brief Time step for unsteady computations (non dimensional). */ - su2double Delta_DynTime, /*!< \brief Time step for dynamic structural computations. */ - Total_DynTime, /*!< \brief Total time for dynamic structural computations. */ - Current_DynTime; /*!< \brief Global time of the dynamic structural computations. */ - su2double Total_UnstTime, /*!< \brief Total time for unsteady computations. */ - Total_UnstTimeND; /*!< \brief Total time for unsteady computations (non dimensional). */ - su2double Current_UnstTime, /*!< \brief Global time of the unsteady simulation. */ - Current_UnstTimeND; /*!< \brief Global time of the unsteady simulation. */ - unsigned short nMarker_Euler, /*!< \brief Number of Euler wall markers. */ - nMarker_FarField, /*!< \brief Number of far-field markers. */ + unsigned short Kind_Regime; /*!< \brief Kind of adjoint function. */ + unsigned short *Kind_ObjFunc; /*!< \brief Kind of objective function. */ + su2double *Weight_ObjFunc; /*!< \brief Weight applied to objective function. */ + unsigned short Kind_SensSmooth; /*!< \brief Kind of sensitivity smoothing technique. */ + unsigned short Continuous_Eqns; /*!< \brief Which equations to treat continuously (Hybrid adjoint)*/ + unsigned short Discrete_Eqns; /*!< \brief Which equations to treat discretely (Hybrid adjoint). */ + unsigned short *Design_Variable; /*!< \brief Kind of design variable. */ + unsigned short Kind_Adaptation; /*!< \brief Kind of numerical grid adaptation. */ + unsigned short nTimeInstances; /*!< \brief Number of periodic time instances for harmonic balance. */ + su2double HarmonicBalance_Period; /*!< \brief Period of oscillation to be used with harmonic balance computations. */ + su2double New_Elem_Adapt; /*!< \brief Elements to adapt in the numerical grid adaptation process. */ + su2double Delta_UnstTime, /*!< \brief Time step for unsteady computations. */ + Delta_UnstTimeND; /*!< \brief Time step for unsteady computations (non dimensional). */ + su2double Delta_DynTime, /*!< \brief Time step for dynamic structural computations. */ + Total_DynTime, /*!< \brief Total time for dynamic structural computations. */ + Current_DynTime; /*!< \brief Global time of the dynamic structural computations. */ + su2double Total_UnstTime, /*!< \brief Total time for unsteady computations. */ + Total_UnstTimeND; /*!< \brief Total time for unsteady computations (non dimensional). */ + su2double Current_UnstTime, /*!< \brief Global time of the unsteady simulation. */ + Current_UnstTimeND; /*!< \brief Global time of the unsteady simulation. */ + unsigned short nMarker_Euler, /*!< \brief Number of Euler wall markers. */ + nMarker_FarField, /*!< \brief Number of far-field markers. */ nMarker_Custom, /*!< \brief Number of custom markers. */ - nMarker_SymWall, /*!< \brief Number of symmetry wall markers. */ - nMarker_PerBound, /*!< \brief Number of periodic boundary markers. */ - nMarker_MixingPlaneInterface, /*!< \brief Number of mixing plane interface boundary markers. */ - nMarker_Turbomachinery, /*!< \brief Number turbomachinery markers. */ - nMarker_TurboPerformance, /*!< \brief Number of turboperformance markers. */ - nSpanWiseSections_User, /*!< \brief Number of spanwise sections to compute 3D BC and Performance for turbomachinery */ + nMarker_SymWall, /*!< \brief Number of symmetry wall markers. */ + nMarker_PerBound, /*!< \brief Number of periodic boundary markers. */ + nMarker_MixingPlaneInterface, /*!< \brief Number of mixing plane interface boundary markers. */ + nMarker_Turbomachinery, /*!< \brief Number turbomachinery markers. */ + nMarker_TurboPerformance, /*!< \brief Number of turboperformance markers. */ + nSpanWiseSections_User, /*!< \brief Number of spanwise sections to compute 3D BC and Performance for turbomachinery */ nMarker_Shroud, /*!< \brief Number of shroud markers to set grid velocity to 0.*/ - nMarker_NearFieldBound, /*!< \brief Number of near field boundary markers. */ + nMarker_NearFieldBound, /*!< \brief Number of near field boundary markers. */ nMarker_ActDiskInlet, /*!< \brief Number of actuator disk inlet markers. */ nMarker_ActDiskOutlet, /*!< \brief Number of actuator disk outlet markers. */ - nMarker_Deform_Mesh, /*!< \brief Number of deformable markers at the boundary. */ - nMarker_Fluid_Load, /*!< \brief Number of markers in which the flow load is computed/employed. */ - nMarker_Fluid_InterfaceBound, /*!< \brief Number of fluid interface markers. */ + nMarker_Deform_Mesh, /*!< \brief Number of deformable markers at the boundary. */ + nMarker_Fluid_Load, /*!< \brief Number of markers in which the flow load is computed/employed. */ + nMarker_Fluid_InterfaceBound, /*!< \brief Number of fluid interface markers. */ nMarker_CHTInterface, /*!< \brief Number of conjugate heat transfer interface markers. */ - nMarker_Inlet, /*!< \brief Number of inlet flow markers. */ - nMarker_Riemann, /*!< \brief Number of Riemann flow markers. */ - nMarker_Giles, /*!< \brief Number of Giles flow markers. */ + nMarker_Inlet, /*!< \brief Number of inlet flow markers. */ + nMarker_Riemann, /*!< \brief Number of Riemann flow markers. */ + nMarker_Giles, /*!< \brief Number of Giles flow markers. */ nRelaxFactor_Giles, /*!< \brief Number of relaxation factors for Giles markers. */ - nMarker_Supersonic_Inlet, /*!< \brief Number of supersonic inlet flow markers. */ + nMarker_Supersonic_Inlet, /*!< \brief Number of supersonic inlet flow markers. */ nMarker_Supersonic_Outlet, /*!< \brief Number of supersonic outlet flow markers. */ - nMarker_Outlet, /*!< \brief Number of outlet flow markers. */ + nMarker_Outlet, /*!< \brief Number of outlet flow markers. */ nMarker_Isothermal, /*!< \brief Number of isothermal wall boundaries. */ nMarker_HeatFlux, /*!< \brief Number of constant heat flux wall boundaries. */ - nMarker_EngineExhaust, /*!< \brief Number of nacelle exhaust flow markers. */ - nMarker_EngineInflow, /*!< \brief Number of nacelle inflow flow markers. */ - nMarker_Clamped, /*!< \brief Number of clamped markers in the FEM. */ - nMarker_Displacement, /*!< \brief Number of displacement surface markers. */ - nMarker_Load, /*!< \brief Number of load surface markers. */ + nMarker_EngineExhaust, /*!< \brief Number of nacelle exhaust flow markers. */ + nMarker_EngineInflow, /*!< \brief Number of nacelle inflow flow markers. */ + nMarker_Clamped, /*!< \brief Number of clamped markers in the FEM. */ + nMarker_Displacement, /*!< \brief Number of displacement surface markers. */ + nMarker_Load, /*!< \brief Number of load surface markers. */ nMarker_Damper, /*!< \brief Number of damper surface markers. */ - nMarker_Load_Dir, /*!< \brief Number of load surface markers defined by magnitude and direction. */ + nMarker_Load_Dir, /*!< \brief Number of load surface markers defined by magnitude and direction. */ nMarker_Disp_Dir, /*!< \brief Number of load surface markers defined by magnitude and direction. */ - nMarker_Load_Sine, /*!< \brief Number of load surface markers defined by magnitude and direction. */ - nMarker_FlowLoad, /*!< \brief Number of load surface markers. */ - nMarker_Internal, /*!< \brief Number of internal flow markers. */ - nMarker_All, /*!< \brief Total number of markers using the grid information. */ - nMarker_Max, /*!< \brief Max number of number of markers using the grid information. */ - nMarker_CfgFile; /*!< \brief Total number of markers using the config file - (note that using parallel computation this number can be different - from nMarker_All). */ + nMarker_Load_Sine, /*!< \brief Number of load surface markers defined by magnitude and direction. */ + nMarker_FlowLoad, /*!< \brief Number of load surface markers. */ + nMarker_Internal, /*!< \brief Number of internal flow markers. */ + nMarker_All, /*!< \brief Total number of markers using the grid information. */ + nMarker_Max, /*!< \brief Max number of number of markers using the grid information. */ + nMarker_CfgFile; /*!< \brief Total number of markers using the config file (note that in + parallel computations this number can be different from nMarker_All). */ bool Inlet_From_File; /*!< \brief True if the inlet profile is to be loaded from a file. */ string Inlet_Filename; /*!< \brief Filename specifying an inlet profile. */ su2double Inlet_Matching_Tol; /*!< \brief Tolerance used when matching a point to a point from the inlet file. */ - string *Marker_Euler, /*!< \brief Euler wall markers. */ - *Marker_FarField, /*!< \brief Far field markers. */ + string *Marker_Euler, /*!< \brief Euler wall markers. */ + *Marker_FarField, /*!< \brief Far field markers. */ *Marker_Custom, - *Marker_SymWall, /*!< \brief Symmetry wall markers. */ - *Marker_PerBound, /*!< \brief Periodic boundary markers. */ - *Marker_PerDonor, /*!< \brief Rotationally periodic boundary donor markers. */ - *Marker_MixingPlaneInterface, /*!< \brief MixingPlane interface boundary markers. */ - *Marker_TurboBoundIn, /*!< \brief Turbomachinery performance boundary markers. */ - *Marker_TurboBoundOut, /*!< \brief Turbomachinery performance boundary donor markers. */ - *Marker_NearFieldBound, /*!< \brief Near Field boundaries markers. */ - *Marker_Deform_Mesh, /*!< \brief Deformable markers at the boundary. */ - *Marker_Fluid_Load, /*!< \brief Markers in which the flow load is computed/employed. */ - *Marker_Fluid_InterfaceBound, /*!< \brief Fluid interface markers. */ + *Marker_SymWall, /*!< \brief Symmetry wall markers. */ + *Marker_PerBound, /*!< \brief Periodic boundary markers. */ + *Marker_PerDonor, /*!< \brief Rotationally periodic boundary donor markers. */ + *Marker_MixingPlaneInterface, /*!< \brief MixingPlane interface boundary markers. */ + *Marker_TurboBoundIn, /*!< \brief Turbomachinery performance boundary markers. */ + *Marker_TurboBoundOut, /*!< \brief Turbomachinery performance boundary donor markers. */ + *Marker_NearFieldBound, /*!< \brief Near Field boundaries markers. */ + *Marker_Deform_Mesh, /*!< \brief Deformable markers at the boundary. */ + *Marker_Fluid_Load, /*!< \brief Markers in which the flow load is computed/employed. */ + *Marker_Fluid_InterfaceBound, /*!< \brief Fluid interface markers. */ *Marker_CHTInterface, /*!< \brief Conjugate heat transfer interface markers. */ *Marker_ActDiskInlet, /*!< \brief Actuator disk inlet markers. */ *Marker_ActDiskOutlet, /*!< \brief Actuator disk outlet markers. */ - *Marker_Inlet, /*!< \brief Inlet flow markers. */ - *Marker_Riemann, /*!< \brief Riemann markers. */ - *Marker_Giles, /*!< \brief Giles markers. */ + *Marker_Inlet, /*!< \brief Inlet flow markers. */ + *Marker_Riemann, /*!< \brief Riemann markers. */ + *Marker_Giles, /*!< \brief Giles markers. */ *Marker_Shroud, /*!< \brief Shroud markers. */ *Marker_Supersonic_Inlet, /*!< \brief Supersonic inlet flow markers. */ - *Marker_Supersonic_Outlet, /*!< \brief Supersonic outlet flow markers. */ - *Marker_Outlet, /*!< \brief Outlet flow markers. */ + *Marker_Supersonic_Outlet, /*!< \brief Supersonic outlet flow markers. */ + *Marker_Outlet, /*!< \brief Outlet flow markers. */ *Marker_Isothermal, /*!< \brief Isothermal wall markers. */ *Marker_HeatFlux, /*!< \brief Constant heat flux wall markers. */ - *Marker_EngineInflow, /*!< \brief Engine Inflow flow markers. */ - *Marker_EngineExhaust, /*!< \brief Engine Exhaust flow markers. */ - *Marker_Clamped, /*!< \brief Clamped markers. */ - *Marker_Displacement, /*!< \brief Displacement markers. */ - *Marker_Load, /*!< \brief Load markers. */ + *Marker_EngineInflow, /*!< \brief Engine Inflow flow markers. */ + *Marker_EngineExhaust, /*!< \brief Engine Exhaust flow markers. */ + *Marker_Clamped, /*!< \brief Clamped markers. */ + *Marker_Displacement, /*!< \brief Displacement markers. */ + *Marker_Load, /*!< \brief Load markers. */ *Marker_Damper, /*!< \brief Damper markers. */ - *Marker_Load_Dir, /*!< \brief Load markers defined in cartesian coordinates. */ + *Marker_Load_Dir, /*!< \brief Load markers defined in cartesian coordinates. */ *Marker_Disp_Dir, /*!< \brief Load markers defined in cartesian coordinates. */ *Marker_Load_Sine, /*!< \brief Sine-wave loaded markers defined in cartesian coordinates. */ - *Marker_FlowLoad, /*!< \brief Flow Load markers. */ - *Marker_Internal, /*!< \brief Internal flow markers. */ - *Marker_All_TagBound; /*!< \brief Global index for markers using grid information. */ + *Marker_FlowLoad, /*!< \brief Flow Load markers. */ + *Marker_Internal, /*!< \brief Internal flow markers. */ + *Marker_All_TagBound; /*!< \brief Global index for markers using grid information. */ su2double *Exhaust_Temperature_Target; /*!< \brief Specified total temperatures for nacelle boundaries. */ su2double *Exhaust_Pressure_Target; /*!< \brief Specified total pressures for nacelle boundaries. */ @@ -384,24 +383,24 @@ class CConfig { su2double **Periodic_Center; /*!< \brief Rotational center for each SEND_RECEIVE boundary. */ su2double **Periodic_Rotation; /*!< \brief Rotation angles for each SEND_RECEIVE boundary. */ su2double **Periodic_Translate; /*!< \brief Translation vector for each SEND_RECEIVE boundary. */ - string *Marker_CfgFile_TagBound; /*!< \brief Global index for markers using config file. */ - unsigned short *Marker_All_KindBC, /*!< \brief Global index for boundaries using grid information. */ - *Marker_CfgFile_KindBC; /*!< \brief Global index for boundaries using config file. */ - short *Marker_All_SendRecv; /*!< \brief Information about if the boundary is sended (+), received (-). */ - short *Marker_All_PerBound; /*!< \brief Global index for periodic bc using the grid information. */ - - unsigned long nExtIter; /*!< \brief Number of external iterations. */ - unsigned long ExtIter; /*!< \brief Current external iteration number. */ - unsigned long ExtIter_OffSet; /*!< \brief External iteration number offset. */ - unsigned long IntIter; /*!< \brief Current internal iteration number. */ - unsigned long OuterIter; /*!< \brief Current Outer iterations for multizone problems. */ - unsigned long InnerIter; /*!< \brief Current inner iterations for multizone problems. */ - unsigned long TimeIter; /*!< \brief Current time iterations for multizone problems. */ - unsigned long Unst_nIntIter; /*!< \brief Number of internal iterations (Dual time Method). */ - unsigned long Dyn_nIntIter; /*!< \brief Number of internal iterations (Newton-Raphson Method for nonlinear structural analysis). */ - long Unst_RestartIter; /*!< \brief Iteration number to restart an unsteady simulation (Dual time Method). */ - long Unst_AdjointIter; /*!< \brief Iteration number to begin the reverse time integration in the direct solver for the unsteady adjoint. */ - long Iter_Avg_Objective; /*!< \brief Iteration the number of time steps to be averaged, counting from the back */ + string *Marker_CfgFile_TagBound; /*!< \brief Global index for markers using config file. */ + unsigned short *Marker_All_KindBC, /*!< \brief Global index for boundaries using grid information. */ + *Marker_CfgFile_KindBC; /*!< \brief Global index for boundaries using config file. */ + short *Marker_All_SendRecv; /*!< \brief Information about if the boundary is sended (+), received (-). */ + short *Marker_All_PerBound; /*!< \brief Global index for periodic bc using the grid information. */ + + unsigned long nExtIter; /*!< \brief Number of external iterations. */ + unsigned long ExtIter; /*!< \brief Current external iteration number. */ + unsigned long ExtIter_OffSet; /*!< \brief External iteration number offset. */ + unsigned long IntIter; /*!< \brief Current internal iteration number. */ + unsigned long OuterIter; /*!< \brief Current Outer iterations for multizone problems. */ + unsigned long InnerIter; /*!< \brief Current inner iterations for multizone problems. */ + unsigned long TimeIter; /*!< \brief Current time iterations for multizone problems. */ + unsigned long Unst_nIntIter; /*!< \brief Number of internal iterations (Dual time Method). */ + unsigned long Dyn_nIntIter; /*!< \brief Number of internal iterations (Newton-Raphson Method for nonlinear structural analysis). */ + long Unst_RestartIter; /*!< \brief Iteration number to restart an unsteady simulation (Dual time Method). */ + long Unst_AdjointIter; /*!< \brief Iteration number to begin the reverse time integration in the direct solver for the unsteady adjoint. */ + long Iter_Avg_Objective; /*!< \brief Iteration the number of time steps to be averaged, counting from the back */ long Dyn_RestartIter; /*!< \brief Iteration number to restart a dynamic structural analysis. */ su2double PhysicalTime; /*!< \brief Physical time at the current iteration in the solver for unsteady problems. */ @@ -411,147 +410,147 @@ class CConfig { unsigned short nTimeIntegrationADER_DG; /*!< \brief Number of time integration points ADER-DG. */ su2double *TimeIntegrationADER_DG; /*!< \brief The location of the ADER-DG time integration points on the interval [-1,1]. */ su2double *WeightsIntegrationADER_DG; /*!< \brief The weights of the ADER-DG time integration points on the interval [-1,1]. */ - unsigned short nRKStep; /*!< \brief Number of steps of the explicit Runge-Kutta method. */ - su2double *RK_Alpha_Step; /*!< \brief Runge-Kutta beta coefficients. */ + unsigned short nRKStep; /*!< \brief Number of steps of the explicit Runge-Kutta method. */ + su2double *RK_Alpha_Step; /*!< \brief Runge-Kutta beta coefficients. */ - unsigned short nMGLevels; /*!< \brief Number of multigrid levels (coarse levels). */ - unsigned short nCFL; /*!< \brief Number of CFL, one for each multigrid level. */ + unsigned short nMGLevels; /*!< \brief Number of multigrid levels (coarse levels). */ + unsigned short nCFL; /*!< \brief Number of CFL, one for each multigrid level. */ su2double - CFLRedCoeff_Turb, /*!< \brief CFL reduction coefficient on the LevelSet problem. */ - CFLRedCoeff_AdjFlow, /*!< \brief CFL reduction coefficient for the adjoint problem. */ - CFLRedCoeff_AdjTurb, /*!< \brief CFL reduction coefficient for the adjoint turbulent problem. */ - CFLFineGrid, /*!< \brief CFL of the finest grid. */ - Max_DeltaTime, /*!< \brief Max delta time. */ - Unst_CFL; /*!< \brief Unsteady CFL number. */ - - bool ReorientElements; /*!< \brief Flag for enabling element reorientation. */ - bool AddIndNeighbor; /*!< \brief Include indirect neighbor in the agglomeration process. */ - unsigned short nDV, /*!< \brief Number of design variables. */ + CFLRedCoeff_Turb, /*!< \brief CFL reduction coefficient on the LevelSet problem. */ + CFLRedCoeff_AdjFlow, /*!< \brief CFL reduction coefficient for the adjoint problem. */ + CFLRedCoeff_AdjTurb, /*!< \brief CFL reduction coefficient for the adjoint turbulent problem. */ + CFLFineGrid, /*!< \brief CFL of the finest grid. */ + Max_DeltaTime, /*!< \brief Max delta time. */ + Unst_CFL; /*!< \brief Unsteady CFL number. */ + + bool ReorientElements; /*!< \brief Flag for enabling element reorientation. */ + bool AddIndNeighbor; /*!< \brief Include indirect neighbor in the agglomeration process. */ + unsigned short nDV, /*!< \brief Number of design variables. */ nObj, nObjW; /*! \brief Number of objective functions. */ - unsigned short* nDV_Value; /*!< \brief Number of values for each design variable (might be different than 1 if we allow arbitrary movement). */ - unsigned short nFFDBox; /*!< \brief Number of ffd boxes. */ + unsigned short* nDV_Value; /*!< \brief Number of values for each design variable (might be different than 1 if we allow arbitrary movement). */ + unsigned short nFFDBox; /*!< \brief Number of ffd boxes. */ unsigned short nTurboMachineryKind; /*!< \brief Number turbomachinery types specified. */ - unsigned short nParamDV; /*!< \brief Number of parameters of the design variable. */ + unsigned short nParamDV; /*!< \brief Number of parameters of the design variable. */ string DV_Filename; /*!< \brief Filename for providing surface positions from an external parameterization. */ string DV_Unordered_Sens_Filename; /*!< \brief Filename of volume sensitivities in an unordered ASCII format. */ string DV_Sens_Filename; /*!< \brief Filename of surface sensitivities written to an unordered ASCII format. */ unsigned short Sensitivity_FileFormat; /*!< \brief Format of the input volume sensitivity files (SU2_DOT). */ - su2double **ParamDV; /*!< \brief Parameters of the design variable. */ - su2double **CoordFFDBox; /*!< \brief Coordinates of the FFD boxes. */ - unsigned short **DegreeFFDBox; /*!< \brief Degree of the FFD boxes. */ - string *FFDTag; /*!< \brief Parameters of the design variable. */ - string *TagFFDBox; /*!< \brief Tag of the FFD box. */ - unsigned short GeometryMode; /*!< \brief Gemoetry mode (analysis or gradient computation). */ - unsigned short MGCycle; /*!< \brief Kind of multigrid cycle. */ - unsigned short FinestMesh; /*!< \brief Finest mesh for the full multigrid approach. */ + su2double **ParamDV; /*!< \brief Parameters of the design variable. */ + su2double **CoordFFDBox; /*!< \brief Coordinates of the FFD boxes. */ + unsigned short **DegreeFFDBox; /*!< \brief Degree of the FFD boxes. */ + string *FFDTag; /*!< \brief Parameters of the design variable. */ + string *TagFFDBox; /*!< \brief Tag of the FFD box. */ + unsigned short GeometryMode; /*!< \brief Gemoetry mode (analysis or gradient computation). */ + unsigned short MGCycle; /*!< \brief Kind of multigrid cycle. */ + unsigned short FinestMesh; /*!< \brief Finest mesh for the full multigrid approach. */ unsigned short nFFD_Fix_IDir, nFFD_Fix_JDir, nFFD_Fix_KDir; /*!< \brief Number of planes fixed in the FFD. */ unsigned short nMG_PreSmooth, /*!< \brief Number of MG pre-smooth parameters found in config file. */ nMG_PostSmooth, /*!< \brief Number of MG post-smooth parameters found in config file. */ nMG_CorrecSmooth; /*!< \brief Number of MG correct-smooth parameters found in config file. */ short *FFD_Fix_IDir, - *FFD_Fix_JDir, *FFD_Fix_KDir; /*!< \brief Exact sections. */ - unsigned short *MG_PreSmooth, /*!< \brief Multigrid Pre smoothing. */ - *MG_PostSmooth, /*!< \brief Multigrid Post smoothing. */ - *MG_CorrecSmooth; /*!< \brief Multigrid Jacobi implicit smoothing of the correction. */ + *FFD_Fix_JDir, *FFD_Fix_KDir; /*!< \brief Exact sections. */ + unsigned short *MG_PreSmooth, /*!< \brief Multigrid Pre smoothing. */ + *MG_PostSmooth, /*!< \brief Multigrid Post smoothing. */ + *MG_CorrecSmooth; /*!< \brief Multigrid Jacobi implicit smoothing of the correction. */ su2double *LocationStations; /*!< \brief Airfoil sections in wing slicing subroutine. */ su2double *NacelleLocation; /*!< \brief Definition of the nacelle location. */ unsigned short Kind_Solver, /*!< \brief Kind of solver Euler, NS, Continuous adjoint, etc. */ Kind_MZSolver, /*!< \brief Kind of multizone solver. */ - Kind_FluidModel, /*!< \brief Kind of the Fluid Model: Ideal or Van der Walls, ... . */ - Kind_ViscosityModel, /*!< \brief Kind of the Viscosity Model*/ - Kind_ConductivityModel, /*!< \brief Kind of the Thermal Conductivity Model*/ + Kind_FluidModel, /*!< \brief Kind of the Fluid Model: Ideal or Van der Walls, ... . */ + Kind_ViscosityModel, /*!< \brief Kind of the Viscosity Model*/ + Kind_ConductivityModel, /*!< \brief Kind of the Thermal Conductivity Model*/ Kind_ConductivityModel_Turb, /*!< \brief Kind of the Turbulent Thermal Conductivity Model*/ - Kind_FreeStreamOption, /*!< \brief Kind of free stream option to choose if initializing with density or temperature */ - Kind_InitOption, /*!< \brief Kind of Init option to choose if initializing with Reynolds number or with thermodynamic conditions */ - Kind_GasModel, /*!< \brief Kind of the Gas Model. */ - Kind_DensityModel, /*!< \brief Kind of the density model for incompressible flows. */ + Kind_FreeStreamOption, /*!< \brief Kind of free stream option to choose if initializing with density or temperature */ + Kind_InitOption, /*!< \brief Kind of Init option to choose if initializing with Reynolds number or with thermodynamic conditions */ + Kind_GasModel, /*!< \brief Kind of the Gas Model. */ + Kind_DensityModel, /*!< \brief Kind of the density model for incompressible flows. */ Kind_GridMovement, /*!< \brief Kind of the static mesh movement. */ *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_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. */ - Kind_Linear_Solver_FSI_Struc, /*!< \brief Numerical solver for the structural part in FSI problems. */ - Kind_Linear_Solver_Prec, /*!< \brief Preconditioner of the linear solver. */ + Kind_Linear_Solver, /*!< \brief Numerical solver for the implicit scheme. */ + Kind_Linear_Solver_FSI_Struc, /*!< \brief Numerical solver for the structural part in FSI problems. */ + Kind_Linear_Solver_Prec, /*!< \brief Preconditioner of the linear solver. */ Kind_Linear_Solver_Prec_FSI_Struc, /*!< \brief Preconditioner of the linear solver for the structural part in FSI problems. */ - Kind_AdjTurb_Linear_Solver, /*!< \brief Numerical solver for the turbulent adjoint implicit scheme. */ - Kind_AdjTurb_Linear_Prec, /*!< \brief Preconditioner of the turbulent adjoint linear solver. */ + Kind_AdjTurb_Linear_Solver, /*!< \brief Numerical solver for the turbulent adjoint implicit scheme. */ + Kind_AdjTurb_Linear_Prec, /*!< \brief Preconditioner of the turbulent adjoint linear solver. */ Kind_DiscAdj_Linear_Solver, /*!< \brief Linear solver for the discrete adjoint system. */ Kind_DiscAdj_Linear_Prec, /*!< \brief Preconditioner of the discrete adjoint linear solver. */ Kind_DiscAdj_Linear_Solver_FSI_Struc, /*!< \brief Linear solver for the discrete adjoint system in the structural side of FSI problems. */ Kind_DiscAdj_Linear_Prec_FSI_Struc, /*!< \brief Preconditioner of the discrete adjoint linear solver in the structural side of FSI problems. */ - Kind_SlopeLimit, /*!< \brief Global slope limiter. */ - Kind_SlopeLimit_Flow, /*!< \brief Slope limiter for flow equations.*/ - Kind_SlopeLimit_Turb, /*!< \brief Slope limiter for the turbulence equation.*/ - Kind_SlopeLimit_AdjTurb, /*!< \brief Slope limiter for the adjoint turbulent equation.*/ - Kind_SlopeLimit_AdjFlow, /*!< \brief Slope limiter for the adjoint equation.*/ - Kind_TimeNumScheme, /*!< \brief Global explicit or implicit time integration. */ - Kind_TimeIntScheme_Flow, /*!< \brief Time integration for the flow equations. */ + Kind_SlopeLimit, /*!< \brief Global slope limiter. */ + Kind_SlopeLimit_Flow, /*!< \brief Slope limiter for flow equations.*/ + Kind_SlopeLimit_Turb, /*!< \brief Slope limiter for the turbulence equation.*/ + Kind_SlopeLimit_AdjTurb, /*!< \brief Slope limiter for the adjoint turbulent equation.*/ + Kind_SlopeLimit_AdjFlow, /*!< \brief Slope limiter for the adjoint equation.*/ + Kind_TimeNumScheme, /*!< \brief Global explicit or implicit time integration. */ + Kind_TimeIntScheme_Flow, /*!< \brief Time integration for the flow equations. */ Kind_TimeIntScheme_FEM_Flow, /*!< \brief Time integration for the flow equations. */ Kind_ADER_Predictor, /*!< \brief Predictor step of the ADER-DG time integration scheme. */ - Kind_TimeIntScheme_AdjFlow, /*!< \brief Time integration for the adjoint flow equations. */ - Kind_TimeIntScheme_Turb, /*!< \brief Time integration for the turbulence model. */ - Kind_TimeIntScheme_AdjTurb, /*!< \brief Time integration for the adjoint turbulence model. */ - Kind_TimeIntScheme_Heat, /*!< \brief Time integration for the wave equations. */ + Kind_TimeIntScheme_AdjFlow, /*!< \brief Time integration for the adjoint flow equations. */ + Kind_TimeIntScheme_Turb, /*!< \brief Time integration for the turbulence model. */ + Kind_TimeIntScheme_AdjTurb, /*!< \brief Time integration for the adjoint turbulence model. */ + Kind_TimeIntScheme_Heat, /*!< \brief Time integration for the wave equations. */ Kind_TimeStep_Heat, /*!< \brief Time stepping method for the (fvm) heat equation. */ - Kind_TimeIntScheme_FEA, /*!< \brief Time integration for the FEA equations. */ - Kind_SpaceIteScheme_FEA, /*!< \brief Iterative scheme for nonlinear structural analysis. */ - Kind_ConvNumScheme, /*!< \brief Global definition of the convective term. */ - Kind_ConvNumScheme_Flow, /*!< \brief Centered or upwind scheme for the flow equations. */ + Kind_TimeIntScheme_FEA, /*!< \brief Time integration for the FEA equations. */ + Kind_SpaceIteScheme_FEA, /*!< \brief Iterative scheme for nonlinear structural analysis. */ + Kind_ConvNumScheme, /*!< \brief Global definition of the convective term. */ + Kind_ConvNumScheme_Flow, /*!< \brief Centered or upwind scheme for the flow equations. */ Kind_ConvNumScheme_FEM_Flow, /*!< \brief Finite element scheme for the flow equations. */ - Kind_ConvNumScheme_Heat, /*!< \brief Centered or upwind scheme for the flow equations. */ - Kind_ConvNumScheme_AdjFlow, /*!< \brief Centered or upwind scheme for the adjoint flow equations. */ - Kind_ConvNumScheme_Turb, /*!< \brief Centered or upwind scheme for the turbulence model. */ - Kind_ConvNumScheme_AdjTurb, /*!< \brief Centered or upwind scheme for the adjoint turbulence model. */ - Kind_ConvNumScheme_Template, /*!< \brief Centered or upwind scheme for the level set equation. */ - Kind_Centered, /*!< \brief Centered scheme. */ - Kind_Centered_Flow, /*!< \brief Centered scheme for the flow equations. */ - Kind_Centered_AdjFlow, /*!< \brief Centered scheme for the adjoint flow equations. */ - Kind_Centered_Turb, /*!< \brief Centered scheme for the turbulence model. */ - Kind_Centered_AdjTurb, /*!< \brief Centered scheme for the adjoint turbulence model. */ - Kind_Centered_Template, /*!< \brief Centered scheme for the template model. */ - Kind_Upwind, /*!< \brief Upwind scheme. */ - Kind_Upwind_Flow, /*!< \brief Upwind scheme for the flow equations. */ - Kind_Upwind_AdjFlow, /*!< \brief Upwind scheme for the adjoint flow equations. */ - Kind_Upwind_Turb, /*!< \brief Upwind scheme for the turbulence model. */ - Kind_Upwind_AdjTurb, /*!< \brief Upwind scheme for the adjoint turbulence model. */ - Kind_Upwind_Template, /*!< \brief Upwind scheme for the template model. */ + Kind_ConvNumScheme_Heat, /*!< \brief Centered or upwind scheme for the flow equations. */ + Kind_ConvNumScheme_AdjFlow, /*!< \brief Centered or upwind scheme for the adjoint flow equations. */ + Kind_ConvNumScheme_Turb, /*!< \brief Centered or upwind scheme for the turbulence model. */ + Kind_ConvNumScheme_AdjTurb, /*!< \brief Centered or upwind scheme for the adjoint turbulence model. */ + Kind_ConvNumScheme_Template, /*!< \brief Centered or upwind scheme for the level set equation. */ + Kind_Centered, /*!< \brief Centered scheme. */ + Kind_Centered_Flow, /*!< \brief Centered scheme for the flow equations. */ + Kind_Centered_AdjFlow, /*!< \brief Centered scheme for the adjoint flow equations. */ + Kind_Centered_Turb, /*!< \brief Centered scheme for the turbulence model. */ + Kind_Centered_AdjTurb, /*!< \brief Centered scheme for the adjoint turbulence model. */ + Kind_Centered_Template, /*!< \brief Centered scheme for the template model. */ + Kind_Upwind, /*!< \brief Upwind scheme. */ + Kind_Upwind_Flow, /*!< \brief Upwind scheme for the flow equations. */ + Kind_Upwind_AdjFlow, /*!< \brief Upwind scheme for the adjoint flow equations. */ + Kind_Upwind_Turb, /*!< \brief Upwind scheme for the turbulence model. */ + Kind_Upwind_AdjTurb, /*!< \brief Upwind scheme for the adjoint turbulence model. */ + Kind_Upwind_Template, /*!< \brief Upwind scheme for the template model. */ Kind_FEM, /*!< \brief Finite element scheme for the flow equations. */ Kind_FEM_Flow, /*!< \brief Finite element scheme for the flow equations. */ Kind_FEM_DG_Shock, /*!< \brief Shock capturing method for the FEM DG solver. */ Kind_Matrix_Coloring, /*!< \brief Type of matrix coloring for sparse Jacobian computation. */ - 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. */ - Kind_CHT_Coupling; /*!< \brief Kind of coupling method used at CHT interfaces. */ + 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. */ + Kind_CHT_Coupling; /*!< \brief Kind of coupling method used at CHT interfaces. */ 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 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.*/ - MUSCL_Turb, /*!< \brief MUSCL scheme for the turbulence equations.*/ - MUSCL_Heat, /*!< \brief MUSCL scheme for the (fvm) heat equation.*/ - MUSCL_AdjFlow, /*!< \brief MUSCL scheme for the adj flow equations.*/ - MUSCL_AdjTurb, /*!< \brief MUSCL scheme for the adj turbulence equations.*/ + bool MUSCL, /*!< \brief MUSCL scheme .*/ + MUSCL_Flow, /*!< \brief MUSCL scheme for the flow equations.*/ + MUSCL_Turb, /*!< \brief MUSCL scheme for the turbulence equations.*/ + MUSCL_Heat, /*!< \brief MUSCL scheme for the (fvm) heat equation.*/ + MUSCL_AdjFlow, /*!< \brief MUSCL scheme for the adj flow equations.*/ + MUSCL_AdjTurb, /*!< \brief MUSCL scheme for the adj turbulence equations.*/ Use_Accurate_Jacobians; /*!< \brief Use numerically computed Jacobians for AUSM+up(2) and SLAU(2). */ bool EulerPersson; /*!< \brief Boolean to determine whether this is an Euler simulation with Persson shock capturing. */ - bool FSI_Problem, /*!< \brief Boolean to determine whether the simulation is FSI or not. */ + bool FSI_Problem, /*!< \brief Boolean to determine whether the simulation is FSI or not. */ Multizone_Problem; /*!< \brief Boolean to determine whether we are solving a multizone problem. */ unsigned short nID_DV; /*!< \brief ID for the region of FEM when computed using direct differentiation. */ bool AD_Mode; /*!< \brief Algorithmic Differentiation support. */ bool AD_Preaccumulation; /*!< \brief Enable or disable preaccumulation in the AD mode. */ unsigned short - Kind_Material_Compress, /*!< \brief Determines if the material is compressible or incompressible (structural analysis). */ - Kind_Material, /*!< \brief Determines the material model to be used (structural analysis). */ - Kind_Struct_Solver, /*!< \brief Determines the geometric condition (small or large deformations) for structural analysis. */ - Kind_DV_FEA; /*!< \brief Kind of Design Variable for FEA problems.*/ + Kind_Material_Compress, /*!< \brief Determines if the material is compressible or incompressible (structural analysis). */ + Kind_Material, /*!< \brief Determines the material model to be used (structural analysis). */ + Kind_Struct_Solver, /*!< \brief Determines the geometric condition (small or large deformations) for structural analysis. */ + Kind_DV_FEA; /*!< \brief Kind of Design Variable for FEA problems.*/ unsigned short Kind_Turb_Model; /*!< \brief Turbulent model definition. */ unsigned short Kind_SGS_Model; /*!< \brief LES SGS model definition. */ @@ -576,13 +575,13 @@ class CConfig { unsigned long Linear_Solver_Restart_Frequency; /*!< \brief Restart frequency of the linear solver for the implicit formulation. */ unsigned long Linear_Solver_Prec_Threads; /*!< \brief Number of threads per rank for ILU and LU_SGS preconditioners. */ 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 SemiSpan; /*!< \brief Wing Semi span. */ + su2double Roe_Kappa; /*!< \brief Relaxation of the Roe scheme. */ 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. */ + su2double AdjTurb_Linear_Error; /*!< \brief Min error of the turbulent adjoint linear solver for the implicit formulation. */ su2double EntropyFix_Coeff; /*!< \brief Entropy fix coefficient. */ - unsigned short AdjTurb_Linear_Iter; /*!< \brief Min error of the turbulent adjoint linear solver for the implicit formulation. */ + unsigned short AdjTurb_Linear_Iter; /*!< \brief Min error of the turbulent adjoint linear solver for the implicit formulation. */ su2double *Stations_Bounds; /*!< \brief Airfoil section limit. */ unsigned short nLocationStations, /*!< \brief Number of section cuts to make when outputting mesh and cp . */ nWingStations; /*!< \brief Number of section cuts to make when calculating internal volume. */ @@ -590,20 +589,20 @@ class CConfig { *Kappa_AdjFlow, /*!< \brief Numerical dissipation coefficients for the adjoint flow equations. */ *Kappa_Heat; /*!< \brief Numerical dissipation coefficients for the (fvm) heat equation. */ su2double* FFD_Axis; /*!< \brief Numerical dissipation coefficients for the adjoint equations. */ - su2double Kappa_1st_AdjFlow, /*!< \brief JST 1st order dissipation coefficient for adjoint flow equations (coarse multigrid levels). */ - Kappa_2nd_AdjFlow, /*!< \brief JST 2nd order dissipation coefficient for adjoint flow equations. */ - Kappa_4th_AdjFlow, /*!< \brief JST 4th order dissipation coefficient for adjoint flow equations. */ - Kappa_1st_Flow, /*!< \brief JST 1st order dissipation coefficient for flow equations (coarse multigrid levels). */ - Kappa_2nd_Flow, /*!< \brief JST 2nd order dissipation coefficient for flow equations. */ - Kappa_4th_Flow, /*!< \brief JST 4th order dissipation coefficient for flow equations. */ + su2double Kappa_1st_AdjFlow, /*!< \brief JST 1st order dissipation coefficient for adjoint flow equations (coarse multigrid levels). */ + Kappa_2nd_AdjFlow, /*!< \brief JST 2nd order dissipation coefficient for adjoint flow equations. */ + Kappa_4th_AdjFlow, /*!< \brief JST 4th order dissipation coefficient for adjoint flow equations. */ + Kappa_1st_Flow, /*!< \brief JST 1st order dissipation coefficient for flow equations (coarse multigrid levels). */ + Kappa_2nd_Flow, /*!< \brief JST 2nd order dissipation coefficient for flow equations. */ + Kappa_4th_Flow, /*!< \brief JST 4th order dissipation coefficient for flow equations. */ Kappa_2nd_Heat, /*!< \brief 2nd order dissipation coefficient for heat equation. */ - Kappa_4th_Heat, /*!< \brief 4th order dissipation coefficient for heat equation. */ + Kappa_4th_Heat, /*!< \brief 4th order dissipation coefficient for heat equation. */ Cent_Jac_Fix_Factor; /*!< \brief Multiply the dissipation contribution to the Jacobian of central schemes by this factor to make the global matrix more diagonal dominant. */ su2double Geo_Waterline_Location; /*!< \brief Location of the waterline. */ - - su2double Min_Beta_RoeTurkel, /*!< \brief Minimum value of Beta for the Roe-Turkel low Mach preconditioner. */ - Max_Beta_RoeTurkel; /*!< \brief Maximum value of Beta for the Roe-Turkel low Mach preconditioner. */ + + su2double Min_Beta_RoeTurkel, /*!< \brief Minimum value of Beta for the Roe-Turkel low Mach preconditioner. */ + Max_Beta_RoeTurkel; /*!< \brief Maximum value of Beta for the Roe-Turkel low Mach preconditioner. */ unsigned long GridDef_Nonlinear_Iter; /*!< \brief Number of nonlinear increments for grid deformation. */ unsigned short Deform_Stiffness_Type; /*!< \brief Type of element stiffness imposed for FEA mesh deformation. */ bool Deform_Mesh; /*!< \brief Determines whether the mesh will be deformed. */ @@ -617,60 +616,60 @@ class CConfig { Deform_PoissonRatio; /*!< \brief Young's Modulus and poisson ratio for volume deformation stiffness model */ bool Visualize_Surface_Def; /*!< \brief Flag to visualize the surface deformacion in SU2_DEF. */ bool Visualize_Volume_Def; /*!< \brief Flag to visualize the volume deformation in SU2_DEF. */ - bool FFD_Symmetry_Plane; /*!< \brief FFD symmetry plane. */ + bool FFD_Symmetry_Plane; /*!< \brief FFD symmetry plane. */ - su2double Mach; /*!< \brief Mach number. */ - su2double Reynolds; /*!< \brief Reynolds number. */ - su2double Froude; /*!< \brief Froude number. */ + su2double Mach; /*!< \brief Mach number. */ + su2double Reynolds; /*!< \brief Reynolds number. */ + su2double Froude; /*!< \brief Froude number. */ su2double Length_Reynolds; /*!< \brief Reynolds length (dimensional). */ - su2double AoA, /*!< \brief Angle of attack (just external flow). */ + su2double AoA, /*!< \brief Angle of attack (just external flow). */ iH, AoS, AoA_Offset, - AoS_Offset, AoA_Sens; /*!< \brief Angle of sideSlip (just external flow). */ - bool Fixed_CL_Mode; /*!< \brief Activate fixed CL mode (external flow only). */ - bool Fixed_CM_Mode; /*!< \brief Activate fixed CL mode (external flow only). */ - bool Eval_dOF_dCX; /*!< \brief Activate fixed CL mode (external flow only). */ + AoS_Offset, AoA_Sens; /*!< \brief Angle of sideSlip (just external flow). */ + bool Fixed_CL_Mode; /*!< \brief Activate fixed CL mode (external flow only). */ + bool Fixed_CM_Mode; /*!< \brief Activate fixed CL mode (external flow only). */ + bool Eval_dOF_dCX; /*!< \brief Activate fixed CL mode (external flow only). */ bool Discard_InFiles; /*!< \brief Discard angle of attack in solution and geometry files. */ - su2double Target_CL; /*!< \brief Specify a target CL instead of AoA (external flow only). */ + su2double Target_CL; /*!< \brief Specify a target CL instead of AoA (external flow only). */ su2double Target_CM; /*!< \brief Specify a target CM instead of AoA (external flow only). */ su2double Total_CM; /*!< \brief Specify a Total CM instead of AoA (external flow only). */ su2double Total_CD; /*!< \brief Specify a target CD instead of AoA (external flow only). */ su2double dCL_dAlpha; /*!< \brief value of dCl/dAlpha. */ su2double dCM_diH; /*!< \brief value of dCM/dHi. */ - unsigned long Iter_Fixed_CM; /*!< \brief Iterations to re-evaluate the angle of attack (external flow only). */ - unsigned long Iter_Fixed_NetThrust; /*!< \brief Iterations to re-evaluate the angle of attack (external flow only). */ + unsigned long Iter_Fixed_CM; /*!< \brief Iterations to re-evaluate the angle of attack (external flow only). */ + unsigned long Iter_Fixed_NetThrust; /*!< \brief Iterations to re-evaluate the angle of attack (external flow only). */ unsigned long Iter_dCL_dAlpha; /*!< \brief Number of iterations to evaluate dCL_dAlpha. */ - unsigned long Update_Alpha; /*!< \brief Iterations to re-evaluate the angle of attack (external flow only). */ - unsigned long Update_iH; /*!< \brief Iterations to re-evaluate the angle of attack (external flow only). */ - unsigned long Update_BCThrust; /*!< \brief Iterations to re-evaluate the angle of attack (external flow only). */ + unsigned long Update_Alpha; /*!< \brief Iterations to re-evaluate the angle of attack (external flow only). */ + unsigned long Update_iH; /*!< \brief Iterations to re-evaluate the angle of attack (external flow only). */ + unsigned long Update_BCThrust; /*!< \brief Iterations to re-evaluate the angle of attack (external flow only). */ su2double dNetThrust_dBCThrust; /*!< \brief value of dNetThrust/dBCThrust. */ - bool Update_BCThrust_Bool; /*!< \brief Boolean flag for whether to update the AoA for fixed lift mode on a given iteration. */ - bool Update_AoA; /*!< \brief Boolean flag for whether to update the AoA for fixed lift mode on a given iteration. */ + bool Update_BCThrust_Bool; /*!< \brief Boolean flag for whether to update the AoA for fixed lift mode on a given iteration. */ + bool Update_AoA; /*!< \brief Boolean flag for whether to update the AoA for fixed lift mode on a given iteration. */ unsigned long Update_AoA_Iter_Limit; /*!< \brief Limit on number of iterations between AoA updates for fixed lift mode. */ - bool Finite_Difference_Mode; /*!< \brief Flag to run the finite difference mode in fixed Cl mode. */ - bool Update_HTPIncidence; /*!< \brief Boolean flag for whether to update the AoA for fixed lift mode on a given iteration. */ - su2double ChargeCoeff; /*!< \brief Charge coefficient (just for poisson problems). */ - unsigned short Cauchy_Func_Flow, /*!< \brief Function where to apply the convergence criteria in the flow problem. */ - Cauchy_Func_AdjFlow, /*!< \brief Function where to apply the convergence criteria in the adjoint problem. */ - Cauchy_Elems; /*!< \brief Number of elements to evaluate. */ + bool Finite_Difference_Mode; /*!< \brief Flag to run the finite difference mode in fixed Cl mode. */ + bool Update_HTPIncidence; /*!< \brief Boolean flag for whether to update the AoA for fixed lift mode on a given iteration. */ + su2double ChargeCoeff; /*!< \brief Charge coefficient (just for poisson problems). */ + unsigned short Cauchy_Func_Flow, /*!< \brief Function where to apply the convergence criteria in the flow problem. */ + Cauchy_Func_AdjFlow, /*!< \brief Function where to apply the convergence criteria in the adjoint problem. */ + Cauchy_Elems; /*!< \brief Number of elements to evaluate. */ unsigned short Residual_Func_Flow; /*!< \brief Equation to apply residual convergence to. */ unsigned short Res_FEM_CRIT; /*!< \brief Criteria to apply to the FEM convergence (absolute/relative). */ - unsigned long StartConv_Iter; /*!< \brief Start convergence criteria at iteration. */ - su2double Cauchy_Eps; /*!< \brief Epsilon used for the convergence. */ - unsigned long Wrt_Sol_Freq, /*!< \brief Writing solution frequency. */ - Wrt_Sol_Freq_DualTime, /*!< \brief Writing solution frequency for Dual Time. */ - Wrt_Con_Freq, /*!< \brief Writing convergence history frequency. */ - Wrt_Con_Freq_DualTime; /*!< \brief Writing convergence history frequency. */ - bool Wrt_Dynamic; /*!< \brief Write dynamic data adding header and prefix. */ - bool Restart, /*!< \brief Restart solution (for direct, adjoint, and linearized problems).*/ - Wrt_Binary_Restart, /*!< \brief Write binary SU2 native restart files.*/ - Read_Binary_Restart, /*!< \brief Read binary SU2 native restart files.*/ - Restart_Flow; /*!< \brief Restart flow solution for adjoint and linearized problems. */ + unsigned long StartConv_Iter; /*!< \brief Start convergence criteria at iteration. */ + su2double Cauchy_Eps; /*!< \brief Epsilon used for the convergence. */ + unsigned long Wrt_Sol_Freq, /*!< \brief Writing solution frequency. */ + Wrt_Sol_Freq_DualTime, /*!< \brief Writing solution frequency for Dual Time. */ + Wrt_Con_Freq, /*!< \brief Writing convergence history frequency. */ + Wrt_Con_Freq_DualTime; /*!< \brief Writing convergence history frequency. */ + bool Wrt_Dynamic; /*!< \brief Write dynamic data adding header and prefix. */ + bool Restart, /*!< \brief Restart solution (for direct, adjoint, and linearized problems).*/ + Wrt_Binary_Restart, /*!< \brief Write binary SU2 native restart files.*/ + Read_Binary_Restart, /*!< \brief Read binary SU2 native restart files.*/ + Restart_Flow; /*!< \brief Restart flow solution for adjoint and linearized problems. */ unsigned short nMarker_Monitoring, /*!< \brief Number of markers to monitor. */ - nMarker_Designing, /*!< \brief Number of markers for the objective function. */ - nMarker_GeoEval, /*!< \brief Number of markers for the objective function. */ + nMarker_Designing, /*!< \brief Number of markers for the objective function. */ + nMarker_GeoEval, /*!< \brief Number of markers for the objective function. */ nMarker_ZoneInterface, /*!< \brief Number of markers in the zone interface. */ - nMarker_Plotting, /*!< \brief Number of markers to plot. */ - nMarker_Analyze, /*!< \brief Number of markers to analyze. */ + nMarker_Plotting, /*!< \brief Number of markers to plot. */ + nMarker_Analyze, /*!< \brief Number of markers to analyze. */ nMarker_Moving, /*!< \brief Number of markers in motion (DEFORMING, MOVING_WALL, or FLUID_STRUCTURE). */ nMarker_PyCustom, /*!< \brief Number of markers that are customizable in Python. */ nMarker_DV, /*!< \brief Number of markers affected by the design variables. */ @@ -722,18 +721,18 @@ class CConfig { *Marker_CfgFile_PerBound; /*!< \brief Global index for periodic boundaries using the config information. */ string *PlaneTag; /*!< \brief Global index for the plane adaptation (upper, lower). */ su2double DualVol_Power; /*!< \brief Power for the dual volume in the grid adaptation sensor. */ - su2double *nBlades; /*!< \brief number of blades for turbomachinery computation. */ + su2double *nBlades; /*!< \brief number of blades for turbomachinery computation. */ unsigned short Analytical_Surface; /*!< \brief Information about the analytical definition of the surface for grid adaptation. */ - unsigned short Geo_Description; /*!< \brief Description of the geometry. */ - unsigned short Mesh_FileFormat; /*!< \brief Mesh input format. */ - unsigned short Tab_FileFormat; /*!< \brief Format of the output files. */ - unsigned short ActDisk_Jump; /*!< \brief Format of the output files. */ - unsigned long StartWindowIteration; /*!< \brief Starting Iteration for long time Windowing apporach . */ + unsigned short Geo_Description; /*!< \brief Description of the geometry. */ + unsigned short Mesh_FileFormat; /*!< \brief Mesh input format. */ + unsigned short Tab_FileFormat; /*!< \brief Format of the output files. */ + unsigned short ActDisk_Jump; /*!< \brief Format of the output files. */ + unsigned long StartWindowIteration; /*!< \brief Starting Iteration for long time Windowing apporach . */ bool CFL_Adapt; /*!< \brief Adaptive CFL number. */ - bool HB_Precondition; /*< \brief Flag to turn on harmonic balance source term preconditioning */ - su2double RefArea, /*!< \brief Reference area for coefficient computation. */ - RefElemLength, /*!< \brief Reference element length for computing the slope limiting epsilon. */ - RefSharpEdges, /*!< \brief Reference coefficient for detecting sharp edges. */ + bool HB_Precondition; /*!< \brief Flag to turn on harmonic balance source term preconditioning */ + su2double RefArea, /*!< \brief Reference area for coefficient computation. */ + RefElemLength, /*!< \brief Reference element length for computing the slope limiting epsilon. */ + RefSharpEdges, /*!< \brief Reference coefficient for detecting sharp edges. */ RefLength, /*!< \brief Reference length for moment computation. */ *RefOriginMoment, /*!< \brief Origin for moment computation. */ *RefOriginMoment_X, /*!< \brief X Origin for moment computation. */ @@ -743,7 +742,7 @@ class CConfig { *RelaxFactor_Giles, /*!< \brief Information about the under relaxation factor for Giles BC. */ *CFL, /*!< \brief CFL number. */ *HTP_Axis, /*!< \brief Location of the HTP axis. */ - DomainVolume; /*!< \brief Volume of the computational grid. */ + DomainVolume; /*!< \brief Volume of the computational grid. */ unsigned short nRefOriginMoment_X, /*!< \brief Number of X-coordinate moment computation origins. */ nRefOriginMoment_Y, /*!< \brief Number of Y-coordinate moment computation origins. */ @@ -752,25 +751,25 @@ class CConfig { short *Mesh_Box_Size; /*!< \brief Array containing the number of grid points in the x-, y-, and z-directions for the analytic RECTANGLE and BOX grid formats. */ su2double* Mesh_Box_Length; /*!< \brief Array containing the length in the x-, y-, and z-directions for the analytic RECTANGLE and BOX grid formats. */ su2double* Mesh_Box_Offset; /*!< \brief Array containing the offset from 0.0 in the x-, y-, and z-directions for the analytic RECTANGLE and BOX grid formats. */ - string Mesh_FileName, /*!< \brief Mesh input file. */ - Mesh_Out_FileName, /*!< \brief Mesh output file. */ - Solution_FileName, /*!< \brief Flow solution input file. */ - Solution_LinFileName, /*!< \brief Linearized flow solution input file. */ - Solution_AdjFileName, /*!< \brief Adjoint solution input file for drag functional. */ - Volume_FileName, /*!< \brief Flow variables output file. */ - Residual_FileName, /*!< \brief Residual variables output file. */ - Conv_FileName, /*!< \brief Convergence history output file. */ - Breakdown_FileName, /*!< \brief Breakdown output file. */ - Restart_FileName, /*!< \brief Restart file for flow variables. */ - Restart_AdjFileName, /*!< \brief Restart file for adjoint variables, drag functional. */ - Adj_FileName, /*!< \brief Output file with the adjoint variables. */ - ObjFunc_Grad_FileName, /*!< \brief Gradient of the objective function. */ + string Mesh_FileName, /*!< \brief Mesh input file. */ + Mesh_Out_FileName, /*!< \brief Mesh output file. */ + Solution_FileName, /*!< \brief Flow solution input file. */ + Solution_LinFileName, /*!< \brief Linearized flow solution input file. */ + Solution_AdjFileName, /*!< \brief Adjoint solution input file for drag functional. */ + Volume_FileName, /*!< \brief Flow variables output file. */ + Residual_FileName, /*!< \brief Residual variables output file. */ + Conv_FileName, /*!< \brief Convergence history output file. */ + Breakdown_FileName, /*!< \brief Breakdown output file. */ + Restart_FileName, /*!< \brief Restart file for flow variables. */ + Restart_AdjFileName, /*!< \brief Restart file for adjoint variables, drag functional. */ + Adj_FileName, /*!< \brief Output file with the adjoint variables. */ + ObjFunc_Grad_FileName, /*!< \brief Gradient of the objective function. */ ObjFunc_Value_FileName, /*!< \brief Objective function. */ - SurfCoeff_FileName, /*!< \brief Output file with the flow variables on the surface. */ - SurfAdjCoeff_FileName, /*!< \brief Output file with the adjoint variables on the surface. */ - New_SU2_FileName, /*!< \brief Output SU2 mesh file converted from CGNS format. */ - SurfSens_FileName, /*!< \brief Output file for the sensitivity on the surface (discrete adjoint). */ - VolSens_FileName; /*!< \brief Output file for the sensitivity in the volume (discrete adjoint). */ + SurfCoeff_FileName, /*!< \brief Output file with the flow variables on the surface. */ + SurfAdjCoeff_FileName, /*!< \brief Output file with the adjoint variables on the surface. */ + New_SU2_FileName, /*!< \brief Output SU2 mesh file converted from CGNS format. */ + SurfSens_FileName, /*!< \brief Output file for the sensitivity on the surface (discrete adjoint). */ + VolSens_FileName; /*!< \brief Output file for the sensitivity in the volume (discrete adjoint). */ bool Wrt_Output, /*!< \brief Write any output files */ Wrt_Vol_Sol, /*!< \brief Write a volume solution file */ @@ -793,9 +792,9 @@ class CConfig { Kind_Average; /*!< \brief Particular average for the marker analyze. */ unsigned short nPolyCoeffs; /*!< \brief Number of coefficients in temperature polynomial fits for fluid models. */ - su2double Gamma, /*!< \brief Ratio of specific heats of the gas. */ - Bulk_Modulus, /*!< \brief Value of the bulk modulus for incompressible flows. */ - Beta_Factor, /*!< \brief Value of the epsilon^2 multiplier for Beta for the incompressible preconditioner. */ + su2double Gamma, /*!< \brief Ratio of specific heats of the gas. */ + Bulk_Modulus, /*!< \brief Value of the bulk modulus for incompressible flows. */ + Beta_Factor, /*!< \brief Value of the epsilon^2 multiplier for Beta for the incompressible preconditioner. */ Gas_Constant, /*!< \brief Specific gas constant. */ Gas_ConstantND, /*!< \brief Non-dimensional specific gas constant. */ Molecular_Weight, /*!< \brief Molecular weight of an incompressible ideal gas (g/mol). */ @@ -817,10 +816,10 @@ class CConfig { Pressure_Critical, /*!< \brief Critical Pressure for real fluid model. */ Density_Critical, /*!< \brief Critical Density for real fluid model. */ Acentric_Factor, /*!< \brief Acentric Factor for real fluid model. */ - Mu_Constant, /*!< \brief Constant viscosity for ConstantViscosity model. */ - Mu_ConstantND, /*!< \brief Non-dimensional constant viscosity for ConstantViscosity model. */ - Kt_Constant, /*!< \brief Constant thermal conductivity for ConstantConductivity model. */ - Kt_ConstantND, /*!< \brief Non-dimensional constant thermal conductivity for ConstantConductivity model. */ + Mu_Constant, /*!< \brief Constant viscosity for ConstantViscosity model. */ + Mu_ConstantND, /*!< \brief Non-dimensional constant viscosity for ConstantViscosity model. */ + Kt_Constant, /*!< \brief Constant thermal conductivity for ConstantConductivity model. */ + Kt_ConstantND, /*!< \brief Non-dimensional constant thermal conductivity for ConstantConductivity model. */ Mu_Ref, /*!< \brief Reference viscosity for Sutherland model. */ Mu_RefND, /*!< \brief Non-dimensional reference viscosity for Sutherland model. */ Mu_Temperature_Ref, /*!< \brief Reference temperature for Sutherland model. */ @@ -880,21 +879,21 @@ class CConfig { Tke_FreeStreamND, /*!< \brief Farfield kinetic energy (external flow). */ Omega_FreeStreamND, /*!< \brief Specific dissipation (external flow). */ Omega_FreeStream; /*!< \brief Specific dissipation (external flow). */ - unsigned short nElectric_Constant; /*!< \brief Number of different electric constants. */ - su2double *Electric_Constant; /*!< \brief Dielectric constant modulus. */ - su2double Knowles_B, /*!< \brief Knowles material model constant B. */ - Knowles_N; /*!< \brief Knowles material model constant N. */ - bool DE_Effects; /*!< Application of DE effects to FE analysis */ - bool RefGeom; /*!< Read a reference geometry for optimization purposes. */ + unsigned short nElectric_Constant; /*!< \brief Number of different electric constants. */ + su2double *Electric_Constant; /*!< \brief Dielectric constant modulus. */ + su2double Knowles_B, /*!< \brief Knowles material model constant B. */ + Knowles_N; /*!< \brief Knowles material model constant N. */ + bool DE_Effects; /*!< Application of DE effects to FE analysis */ + bool RefGeom; /*!< Read a reference geometry for optimization purposes. */ unsigned long refNodeID; /*!< \brief Global ID for the reference node (optimization). */ - string RefGeom_FEMFileName; /*!< \brief File name for reference geometry. */ - unsigned short RefGeom_FileFormat; /*!< \brief Mesh input format. */ - unsigned short Kind_2DElasForm; /*!< \brief Kind of bidimensional elasticity solver. */ - unsigned short nIterFSI; /*!< \brief Number of maximum number of subiterations in a FSI problem. */ + string RefGeom_FEMFileName; /*!< \brief File name for reference geometry. */ + unsigned short RefGeom_FileFormat; /*!< \brief Mesh input format. */ + unsigned short Kind_2DElasForm; /*!< \brief Kind of bidimensional elasticity solver. */ + unsigned short nIterFSI; /*!< \brief Number of maximum number of subiterations in a FSI problem. */ unsigned short nIterFSI_Ramp; /*!< \brief Number of FSI subiterations during which a ramp is applied. */ unsigned short iInst; /*!< \brief Current instance value */ - su2double AitkenStatRelax; /*!< \brief Aitken's relaxation factor (if set as static) */ - su2double AitkenDynMaxInit; /*!< \brief Aitken's maximum dynamic relaxation factor for the first iteration */ + su2double AitkenStatRelax; /*!< \brief Aitken's relaxation factor (if set as static) */ + su2double AitkenDynMaxInit; /*!< \brief Aitken's maximum dynamic relaxation factor for the first iteration */ su2double AitkenDynMinInit; /*!< \brief Aitken's minimum dynamic relaxation factor for the first iteration */ bool RampAndRelease; /*!< \brief option for ramp load and release */ bool Sine_Load; /*!< \brief option for sine load */ @@ -903,32 +902,32 @@ class CConfig { 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. */ - + su2double *Motion_Origin, /*!< \brief Mesh motion origin. */ *Translation_Rate, /*!< \brief Translational velocity of the mesh. */ *Rotation_Rate, /*!< \brief Angular velocity of the mesh . */ *Pitching_Omega, /*!< \brief Angular frequency of the mesh pitching. */ - *Pitching_Ampl, /*!< \brief Pitching amplitude. */ - *Pitching_Phase, /*!< \brief Pitching phase offset. */ - *Plunging_Omega, /*!< \brief Angular frequency of the mesh plunging. */ + *Pitching_Ampl, /*!< \brief Pitching amplitude. */ + *Pitching_Phase, /*!< \brief Pitching phase offset. */ + *Plunging_Omega, /*!< \brief Angular frequency of the mesh plunging. */ *Plunging_Ampl; /*!< \brief Plunging amplitude. */ su2double *MarkerMotion_Origin, /*!< \brief Mesh motion origin of marker. */ *MarkerTranslation_Rate, /*!< \brief Translational velocity of marker. */ *MarkerRotation_Rate, /*!< \brief Angular velocity of marker. */ *MarkerPitching_Omega, /*!< \brief Angular frequency of marker. */ - *MarkerPitching_Ampl, /*!< \brief Pitching amplitude of marker. */ - *MarkerPitching_Phase, /*!< \brief Pitching phase offset of marker. */ - *MarkerPlunging_Omega, /*!< \brief Angular frequency of marker.. */ + *MarkerPitching_Ampl, /*!< \brief Pitching amplitude of marker. */ + *MarkerPitching_Phase, /*!< \brief Pitching phase offset of marker. */ + *MarkerPlunging_Omega, /*!< \brief Angular frequency of marker.. */ *MarkerPlunging_Ampl; /*!< \brief Plunging amplitude of marker. */ - + unsigned short nMarkerMotion_Origin, /*!< \brief Number of values provided for mesh motion origin of marker. */ nMarkerTranslation, /*!< \brief Number of values provided for translational velocity of marker. */ nMarkerRotation_Rate, /*!< \brief Number of values provided for angular velocity of marker. */ nMarkerPitching_Omega, /*!< \brief Number of values provided for angular frequency of marker. */ - nMarkerPitching_Ampl, /*!< \brief Number of values provided for pitching amplitude of marker. */ - nMarkerPitching_Phase, /*!< \brief Number of values provided for pitching phase offset of marker. */ - nMarkerPlunging_Omega, /*!< \brief Number of values provided for angular frequency of marker. */ + nMarkerPitching_Ampl, /*!< \brief Number of values provided for pitching amplitude of marker. */ + nMarkerPitching_Phase, /*!< \brief Number of values provided for pitching phase offset of marker. */ + nMarkerPlunging_Omega, /*!< \brief Number of values provided for angular frequency of marker. */ nMarkerPlunging_Ampl; /*!< \brief Number of values provided for plunging amplitude of marker. */ su2double *Omega_HB; /*!< \brief Frequency for Harmonic Balance Operator (in rad/s). */ unsigned short @@ -947,7 +946,7 @@ class CConfig { su2double *Aeroelastic_plunge, /*!< \brief Value of plunging coordinate at the end of an external iteration. */ *Aeroelastic_pitch; /*!< \brief Value of pitching coordinate at the end of an external iteration. */ unsigned short AeroelasticIter; /*!< \brief Solve the aeroelastic equations every given number of internal iterations. */ - unsigned short Gust_Type, /*!< \brief Type of Gust. */ + unsigned short Gust_Type, /*!< \brief Type of Gust. */ Gust_Dir; /*!< \brief Direction of the gust */ su2double Gust_WaveLength, /*!< \brief The gust wavelength. */ Gust_Periods, /*!< \brief Number of gust periods. */ @@ -958,35 +957,35 @@ class CConfig { bool ExtraOutput; /*!< \brief Check if extra output need. */ bool Wall_Functions; /*!< \brief Use wall functions with the turbulence model */ long ExtraHeatOutputZone; /*!< \brief Heat solver zone with extra screen output */ - bool DeadLoad; /*!< \brief Application of dead loads to the FE analysis */ + bool DeadLoad; /*!< \brief Application of dead loads to the FE analysis */ bool PseudoStatic; /*!< \brief Application of dead loads to the FE analysis */ - bool SteadyRestart; /*!< \brief Restart from a steady state for FSI problems. */ - su2double Newmark_beta, /*!< \brief Parameter alpha for Newmark method. */ - Newmark_gamma; /*!< \brief Parameter delta for Newmark method. */ + bool SteadyRestart; /*!< \brief Restart from a steady state for FSI problems. */ + su2double Newmark_beta, /*!< \brief Parameter alpha for Newmark method. */ + Newmark_gamma; /*!< \brief Parameter delta for Newmark method. */ unsigned short nIntCoeffs; /*!< \brief Number of integration coeffs for structural calculations. */ - su2double *Int_Coeffs; /*!< \brief Time integration coefficients for structural method. */ + su2double *Int_Coeffs; /*!< \brief Time integration coefficients for structural method. */ unsigned short nElasticityMod, /*!< \brief Number of different values for the elasticity modulus. */ nPoissonRatio, /*!< \brief Number of different values for the Poisson ratio modulus. */ nMaterialDensity; /*!< \brief Number of different values for the Material density. */ su2double *ElasticityMod, /*!< \brief Value of the elasticity moduli. */ *PoissonRatio, /*!< \brief Value of the Poisson ratios. */ *MaterialDensity; /*!< \brief Value of the Material densities. */ - unsigned short nElectric_Field, /*!< \brief Number of different values for the electric field in the membrane. */ - nDim_Electric_Field; /*!< \brief Dimensionality of the problem. */ + unsigned short nElectric_Field, /*!< \brief Number of different values for the electric field in the membrane. */ + nDim_Electric_Field; /*!< \brief Dimensionality of the problem. */ unsigned short nDim_RefNode; /*!< \brief Dimensionality of the vector . */ - su2double *Electric_Field_Mod, /*!< \brief Values of the modulus of the electric field. */ - *Electric_Field_Dir; /*!< \brief Direction of the electric field. */ + su2double *Electric_Field_Mod, /*!< \brief Values of the modulus of the electric field. */ + *Electric_Field_Dir; /*!< \brief Direction of the electric field. */ su2double *RefNode_Displacement; /*!< \brief Displacement of the reference node. */ - bool Ramp_Load; /*!< \brief Apply the load with linear increases. */ + bool Ramp_Load; /*!< \brief Apply the load with linear increases. */ unsigned short Dynamic_LoadTransfer; /*!< \brief Method for dynamic load transferring. */ - bool IncrementalLoad; /*!< \brief Apply the load in increments (for nonlinear structural analysis). */ + bool IncrementalLoad; /*!< \brief Apply the load in increments (for nonlinear structural analysis). */ unsigned long IncLoad_Nincrements; /*!< \brief Number of increments. */ su2double *IncLoad_Criteria; /*!< \brief Criteria for the application of incremental loading. */ - su2double Ramp_Time; /*!< \brief Time until the maximum load is applied. */ + su2double Ramp_Time; /*!< \brief Time until the maximum load is applied. */ bool Predictor, /*!< \brief Determines whether a predictor step is used. */ Relaxation; /*!< \brief Determines whether a relaxation step is used. */ unsigned short Pred_Order; /*!< \brief Order of the predictor for FSI applications. */ - unsigned short Kind_Interpolation; /*!< \brief type of interpolation to use for FSI applications. */ + unsigned short Kind_Interpolation; /*!< \brief type of interpolation to use for FSI applications. */ bool ConservativeInterpolation; /*!< \brief Conservative approach for non matching mesh interpolation. */ unsigned short Kind_RadialBasisFunction; /*!< \brief type of radial basis function to use for radial basis FSI. */ bool RadialBasisFunction_PolynomialOption; /*!< \brief Option of whether to include polynomial terms in Radial Basis Function Interpolation or not. */ @@ -1004,9 +1003,9 @@ class CConfig { unsigned short DirectDiff; /*!< \brief Direct Differentation 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. */ + 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_WindowFct ; /*!< \brief Type of window (weight) function for objective functional. */ + unsigned short Kind_WindowFct; /*!< \brief Type of window (weight) function for objective functional. */ unsigned short Kind_HybridRANSLES; /*!< \brief Kind of Hybrid RANS/LES. */ unsigned short Kind_RoeLowDiss; /*!< \brief Kind of Roe scheme with low dissipation for unsteady flows. */ bool QCR; /*!< \brief Spalart-Allmaras with Quadratic Constitutive Relation, 2000 version (SA-QCR2000) . */ @@ -1083,7 +1082,7 @@ class CConfig { bool Jacobian_Spatial_Discretization_Only; /*!< \brief Flag to know if only the exact Jacobian of the spatial discretization must be computed. */ bool Compute_Average; /*!< \brief Whether or not to compute averages for unsteady simulations in FV or DG solver. */ unsigned short Comm_Level; /*!< \brief Level of MPI communications to be performed. */ - unsigned short Kind_Verification_Solution; /*!< \brief Verification solution for accuracy assessment. */ + unsigned short Kind_Verification_Solution; /*!< \brief Verification solution for accuracy assessment. */ ofstream *ConvHistFile; /*!< \brief Store the pointer to each history file */ bool Time_Domain; /*!< \brief Determines if the multizone problem is solved in time-domain */ @@ -1100,7 +1099,7 @@ class CConfig { unsigned long VolumeWrtFreq; /*!< \brief Writing frequency for solution files. */ unsigned short* VolumeOutputFiles; /*!< \brief File formats to output */ unsigned short nVolumeOutputFiles; /*!< \brief Number of File formats to output */ - + bool Multizone_Mesh; /*!< \brief Determines if the mesh contains multiple zones. */ bool SinglezoneDriver; /*!< \brief Determines if the single-zone driver is used. (TEMPORARY) */ bool Wrt_ZoneConv; /*!< \brief Write the convergence history of each individual zone to screen. */ @@ -1112,7 +1111,7 @@ class CConfig { unsigned short nScreenOutput, /*!< \brief Number of screen output variables (max: 6). */ nHistoryOutput, nVolumeOutput; /*!< \brief Number of variables printed to the history file. */ bool Multizone_Residual; /*!< \brief Determines if memory should be allocated for the multizone residual. */ - + bool using_uq; /*!< \brief Using uncertainty quantification with SST model */ su2double uq_delta_b; /*!< \brief Parameter used to perturb eigenvalues of Reynolds Stress Matrix */ unsigned short eig_val_comp; /*!< \brief Parameter used to determine type of eigenvalue perturbation */ @@ -1130,24 +1129,24 @@ class CConfig { * \param config - Config object to use the default values from. */ void SetDefaultFromConfig(CConfig *config); - + /*! * \brief Set default values for all options not yet set. */ void SetDefault(); - + /*--- all_options is a map containing all of the options. This is used during config file parsing to track the options which have not been set (so the default values can be used). Without this map there would be no list of all the config file options. ---*/ - + map all_options; - + /*--- brief param is a map from the option name (config file string) to its decoder (the specific child class of COptionBase that turns the string into a value) ---*/ - + map option_map; - - + + // All of the addXxxOptions take in the name of the option, and a refernce to the field of that option // in the option structure. Depending on the specific type, it may take in a default value, and may // take in extra options. The addXxxOptions mostly follow the same pattern, so please see addDoubleOption @@ -1160,85 +1159,85 @@ class CConfig { // // List and Array options should also be able to be specified with the string "NONE" indicating that there // are no elements. This allows the option to be present in a config file but left blank. - + /*!< \brief addDoubleOption creates a config file parser for an option with the given name whose value can be represented by a su2double.*/ - + void addDoubleOption(const string name, su2double & option_field, su2double default_value); - + void addStringOption(const string name, string & option_field, string default_value); - + void addIntegerOption(const string name, int & option_field, int default_value); - + void addUnsignedLongOption(const string name, unsigned long & option_field, unsigned long default_value); - + void addUnsignedShortOption(const string name, unsigned short & option_field, unsigned short default_value); - + void addLongOption(const string name, long & option_field, long default_value); - + void addBoolOption(const string name, bool & option_field, bool default_value); - + // enum types work differently than all of the others because there are a small number of valid // string entries for the type. One must also provide a list of all the valid strings of that type. template void addEnumOption(const string name, unsigned short & option_field, const map & enum_map, Tenum default_value); - + // input_size is the number of options read in from the config file template void addEnumListOption(const string name, unsigned short & input_size, unsigned short * & option_field, const map & enum_map); - + void addDoubleArrayOption(const string name, const int size, su2double * & option_field, su2double * default_value); - + void addDoubleListOption(const string name, unsigned short & size, su2double * & option_field); - + void addShortListOption(const string name, unsigned short & size, short * & option_field); - + void addUShortListOption(const string name, unsigned short & size, unsigned short * & option_field); - + void addStringListOption(const string name, unsigned short & num_marker, string* & option_field); - + void addConvectOption(const string name, unsigned short & space_field, unsigned short & centered_field, unsigned short & upwind_field); void addConvectFEMOption(const string name, unsigned short & space_field, unsigned short & fem_field); - + void addMathProblemOption(const string name, bool & ContinuousAdjoint, const bool & ContinuousAdjoint_default, bool & DiscreteAdjoint, const bool & DiscreteAdjoint_default, bool & Restart_Flow, const bool & Restart_Flow_default); - + void addDVParamOption(const string name, unsigned short & nDV_field, su2double** & paramDV, string* & FFDTag, unsigned short* & design_variable); - + void addDVValueOption(const string name, unsigned short* & nDVValue_field, su2double** & valueDV, unsigned short & nDV_field, su2double** & paramDV, unsigned short* & design_variable); void addFFDDefOption(const string name, unsigned short & nFFD_field, su2double** & coordFFD, string* & FFDTag); - + void addFFDDegreeOption(const string name, unsigned short & nFFD_field, unsigned short** & degreeFFD); - + void addStringDoubleListOption(const string name, unsigned short & list_size, string * & string_field, su2double* & double_field); - + void addInletOption(const string name, unsigned short & nMarker_Inlet, string * & Marker_Inlet, su2double* & Ttotal, su2double* & Ptotal, su2double** & FlowDir); - + template void addRiemannOption(const string name, unsigned short & nMarker_Riemann, string * & Marker_Riemann, unsigned short* & option_field, const map & enum_map, su2double* & var1, su2double* & var2, su2double** & FlowDir); - + template void addGilesOption(const string name, unsigned short & nMarker_Giles, string * & Marker_Giles, unsigned short* & option_field, const map & enum_map, su2double* & var1, su2double* & var2, su2double** & FlowDir, su2double* & relaxfactor1, su2double* & relaxfactor2); - + void addExhaustOption(const string name, unsigned short & nMarker_Exhaust, string * & Marker_Exhaust, su2double* & Ttotal, su2double* & Ptotal); - + void addPeriodicOption(const string & name, unsigned short & nMarker_PerBound, string* & Marker_PerBound, string* & Marker_PerDonor, su2double** & RotCenter, su2double** & RotAngles, su2double** & Translation); - + void addTurboPerfOption(const string & name, unsigned short & nMarker_TurboPerf, string* & Marker_TurboBoundIn, string* & Marker_TurboBoundOut); - + void addActDiskOption(const string & name, unsigned short & nMarker_ActDiskInlet, unsigned short & nMarker_ActDiskOutlet, string* & Marker_ActDiskInlet, string* & Marker_ActDiskOutlet, su2double** & ActDisk_PressJump, su2double** & ActDisk_TempJump, su2double** & ActDisk_Omega); @@ -1246,46 +1245,46 @@ class CConfig { void addWallFunctionOption(const string &name, unsigned short &list_size, string* &string_field, unsigned short* &val_Kind_WF, unsigned short** &val_IntInfo_WF, su2double** &val_DoubleInfo_WF); - + void addPythonOption(const string name); - + public: - + /*! * \brief Tags for the different fields in a restart file. */ vector fields; - + /*! * \brief Constructor of the class which reads the input file. */ 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. */ CConfig(CConfig * config, char case_filename[MAX_STRING_SIZE], unsigned short val_software, unsigned short val_iZone, unsigned short val_nZone, bool verb_high); - + /*! * \brief Constructor of the class which reads the input file. */ CConfig(char case_filename[MAX_STRING_SIZE], unsigned short val_software); - + /*! * \brief Constructor of the class which reads the input file. */ CConfig(char case_filename[MAX_STRING_SIZE], CConfig *config); - + /*! * \brief Destructor of the class. */ ~CConfig(void); - - void SetnZone(); - - void SetnDim(); - - void SetHeader(unsigned short val_software); + + void SetnZone(); + + void SetnDim(); + + void SetHeader(unsigned short val_software); /*! * \brief Get the MPI communicator of SU2. @@ -1306,7 +1305,7 @@ class CConfig { * \return Total number of zones in the grid file. */ static unsigned short GetnZone(string val_mesh_filename, unsigned short val_format); - + /*! * \brief Gets the number of dimensions in the mesh file * \param[in] val_mesh_filename - Name of the file with the grid information. @@ -1314,12 +1313,12 @@ class CConfig { * \return Total number of domains in the grid file. */ static unsigned short GetnDim(string val_mesh_filename, unsigned short val_format); - + /*! * \brief Initializes pointers to null */ void SetPointersNull(void); - + /*! * \brief breaks an input line from the config file into a set of tokens * \param[in] str - the input line string @@ -1329,113 +1328,113 @@ class CConfig { */ bool TokenizeString(string & str, string & option_name, vector & option_value); - + /*! * \brief Get reference origin for moment computation. * \param[in] val_marker - the marker we are monitoring. * \return Reference origin (in cartesians coordinates) for moment computation. */ su2double *GetRefOriginMoment(unsigned short val_marker); - + /*! * \brief Get reference origin x-coordinate for moment computation. * \param[in] val_marker - the marker we are monitoring. * \return Reference origin x-coordinate (in cartesians coordinates) for moment computation. */ su2double GetRefOriginMoment_X(unsigned short val_marker); - + /*! * \brief Get reference origin y-coordinate for moment computation. * \param[in] val_marker - the marker we are monitoring. * \return Reference origin y-coordinate (in cartesians coordinates) for moment computation. */ su2double GetRefOriginMoment_Y(unsigned short val_marker); - + /*! * \brief Get reference origin z-coordinate for moment computation. * \param[in] val_marker - the marker we are monitoring. * \return Reference origin z-coordinate (in cartesians coordinates) for moment computation. */ su2double GetRefOriginMoment_Z(unsigned short val_marker); - + /*! * \brief Set reference origin x-coordinate for moment computation. * \param[in] val_marker - the marker we are monitoring. * \param[in] val_origin - New x-coordinate of the mesh motion origin. */ void SetRefOriginMoment_X(unsigned short val_marker, su2double val_origin); - + /*! * \brief Set reference origin y-coordinate for moment computation. * \param[in] val_marker - the marker we are monitoring. * \param[in] val_origin - New y-coordinate of the mesh motion origin. */ void SetRefOriginMoment_Y(unsigned short val_marker, su2double val_origin); - + /*! * \brief Set reference origin z-coordinate for moment computation. * \param[in] val_marker - the marker we are monitoring. * \param[in] val_origin - New z-coordinate of the mesh motion origin. */ void SetRefOriginMoment_Z(unsigned short val_marker, su2double val_origin); - + /*! * \brief Get index of the upper and lower horizontal plane. * \param[in] index - 0 means upper surface, and 1 means lower surface. * \return Index of the upper and lower surface. */ string GetPlaneTag(unsigned short index); - + /*! * \brief Get the integration limits for the equivalent area computation. * \param[in] index - 0 means x_min, and 1 means x_max. * \return Integration limits for the equivalent area computation. */ su2double GetEA_IntLimit(unsigned short index); - + /*! * \brief Get the integration limits for the equivalent area computation. * \param[in] index - 0 means x_min, and 1 means x_max. * \return Integration limits for the equivalent area computation. */ su2double GetEA_ScaleFactor(void); - + /*! * \brief Get the limit value for the adjoint variables. * \return Limit value for the adjoint variables. */ su2double GetAdjointLimit(void); - + /*! * \brief Get the coordinates where of the box where the grid is going to be deformed. * \return Coordinates where of the box where the grid is going to be deformed. */ su2double *GetHold_GridFixed_Coord(void); - + /*! * \brief Get the values of subsonic engine. * \return Values of subsonic engine. */ su2double *GetSubsonicEngine_Values(void); - + /*! * \brief Get the cycle of a subsonic engine. * \return Cyl of a subsonic engine. */ su2double *GetSubsonicEngine_Cyl(void); - + /*! * \brief Get the distortion rack. * \return Distortion rack. */ su2double *GetDistortionRack(void); - + /*! * \brief Get the power of the dual volume in the grid adaptation sensor. * \return Power of the dual volume in the grid adaptation sensor. */ su2double GetDualVol_Power(void); - + /*! * \brief Get Information about if there is an analytical definition of the surface for doing the * grid adaptation. @@ -1443,12 +1442,12 @@ class CConfig { * and it will use and interpolation. */ unsigned short GetAnalytical_Surface(void); - + /*! * \brief Get Description of the geometry to be analyzed */ unsigned short GetGeo_Description(void); - + /*! * \brief Creates a tecplot file to visualize the partition made by the DDC software. * \return TRUE if the partition is going to be plotted; otherwise FALSE. @@ -1460,92 +1459,92 @@ class CConfig { * \return Heat solver zone with extra screen output. */ long GetExtraHeatOutputZone(void); - + /*! * \brief Get the value of the Mach number (velocity divided by speed of sound). * \return Value of the Mach number. */ su2double GetMach(void); - + /*! * \brief Get the value of the Gamma of fluid (ratio of specific heats). * \return Value of the constant: Gamma */ su2double GetGamma(void); - + /*! * \brief Get the values of the CFL adaption parameters. * \return Value of CFL adaption parameter */ su2double GetCFL_AdaptParam(unsigned short val_index); - + /*! * \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 value of the CFL adaption flag. * \return TRUE if CFL adaption is active; otherwise FALSE. */ bool GetCFL_Adapt(void); - + /*! * \brief Get the values of the CFL adapation. * \return Value of CFL adapation */ su2double GetHTP_Axis(unsigned short val_index); - + /*! * \brief Get the value of the limits for the sections. * \return Value of the limits for the sections. */ su2double GetStations_Bounds(unsigned short val_var); - + /*! * \brief Get the value of the vector that connects the cartesian axis with a sherical or cylindrical one. * \return Coordinate of the Axis. */ su2double GetFFD_Axis(unsigned short val_var); - + /*! * \brief Get the value of the bulk modulus. * \return Value of the bulk modulus. */ su2double GetBulk_Modulus(void); - + /*! * \brief Get the epsilon^2 multiplier for Beta in the incompressible preconditioner. * \return Value of the epsilon^2 multiplier for Beta in the incompressible preconditioner. */ su2double GetBeta_Factor(void); - + /*! * \brief Get the value of specific gas constant. * \return Value of the constant: Gamma */ su2double GetGas_Constant(void); - + /*! * \brief Get the value of specific gas constant. * \return Value of the constant: Gamma */ su2double GetGas_ConstantND(void); - + /*! * \brief Get the value of the molecular weight for an incompressible ideal gas (g/mol). * \return Value of the molecular weight for an incompressible ideal gas (g/mol). */ su2double GetMolecular_Weight(void); - + /*! * \brief Get the value of specific heat at constant pressure. * \return Value of the constant: Cp */ su2double GetSpecific_Heat_Cp(void); - + /*! * \brief Get the non-dimensional value of specific heat at constant pressure. * \return Value of the non-dim. constant: Cp @@ -1557,7 +1556,7 @@ class CConfig { * \return Value of the constant: Cv */ su2double GetSpecific_Heat_Cv(void); - + /*! * \brief Get the non-dimensional value of specific heat at constant volume. * \return Value of the non-dim. constant: Cv @@ -1571,25 +1570,25 @@ class CConfig { * \return Value of the Blottner coefficient */ su2double GetBlottnerCoeff(unsigned short val_Species, unsigned short val_Coeff); - + /*! * \brief Get the p-norm for heat-flux objective functions (adjoint problem). * \return Value of the heat flux p-norm */ su2double GetPnormHeat(void); - + /*! * \brief Get the value of wall temperature. * \return Value of the constant: Temperature */ su2double GetWallTemperature(void); - + /*! * \brief Get the reference value for the specific gas constant. * \return Reference value for the specific gas constant. */ su2double GetGas_Constant_Ref(void); - + /*! * \brief Get the reference value for the heat flux. * \return Reference value for the heat flux. @@ -1601,19 +1600,19 @@ class CConfig { * \return Freestream temperature. */ su2double GetTemperature_FreeStream(void); - + /*! * \brief Get the value of the frestream temperature. * \return Freestream temperature. */ su2double GetEnergy_FreeStream(void); - + /*! * \brief Get the value of the frestream temperature. * \return Freestream temperature. */ su2double GetViscosity_FreeStream(void); - + /*! * \brief Get the value of the frestream temperature. * \return Freestream temperature. @@ -1625,31 +1624,31 @@ class CConfig { * \return Solid density. */ su2double GetDensity_Solid(void); - + /*! * \brief Get the value of the frestream temperature. * \return Freestream temperature. */ su2double GetModVel_FreeStream(void); - + /*! * \brief Get the value of the frestream temperature. * \return Freestream temperature. */ su2double GetModVel_FreeStreamND(void); - + /*! * \brief Get the value of the frestream vibrational-electronic temperature. * \return Freestream temperature ve. */ su2double GetTemperature_ve_FreeStream(void); - + /*! * \brief Get the value of the laminar Prandtl number. * \return Laminar Prandtl number. */ su2double GetPrandtl_Lam(void); - + /*! * \brief Get the value of the turbulent Prandtl number. * \return Turbulent Prandtl number. @@ -1673,104 +1672,104 @@ class CConfig { * \return Freestream temperature (solid). */ su2double GetTemperature_Initial_Solid(void); - + /*! * \brief Get the value of the reference length for non-dimensionalization. * This value should always be 1 internally, and is not user-specified. * \return Reference length for non-dimensionalization. */ su2double GetLength_Ref(void); - + /*! * \brief Get the value of the reference pressure for non-dimensionalization. * \return Reference pressure for non-dimensionalization. */ su2double GetPressure_Ref(void); - + /*! * \brief Get the value of the reference pressure for non-dimensionalization. * \return Reference pressure for non-dimensionalization. */ su2double GetEnergy_Ref(void); - + /*! * \brief Get the value of the reference temperature for non-dimensionalization. * \return Reference temperature for non-dimensionalization. */ su2double GetTemperature_Ref(void); - + /*! * \brief Get the value of the reference density for non-dimensionalization. * \return Reference density for non-dimensionalization. */ su2double GetDensity_Ref(void); - + /*! * \brief Get the value of the reference velocity for non-dimensionalization. * \return Reference velocity for non-dimensionalization. */ su2double GetVelocity_Ref(void); - + /*! * \brief Get the value of the reference time for non-dimensionalization. * \return Reference time for non-dimensionalization. */ su2double GetTime_Ref(void); - + /*! * \brief Get the value of the reference viscosity for non-dimensionalization. * \return Reference viscosity for non-dimensionalization. */ su2double GetViscosity_Ref(void); - + /*! * \brief Get the value of the reference viscosity for non-dimensionalization. * \return Reference viscosity for non-dimensionalization. */ su2double GetHighlite_Area(void); - + /*! * \brief Get the value of the reference viscosity for non-dimensionalization. * \return Reference viscosity for non-dimensionalization. */ su2double GetFan_Poly_Eff(void); - + /*! * \brief Get the value of the reference conductivity for non-dimensionalization. * \return Reference conductivity for non-dimensionalization. */ su2double GetConductivity_Ref(void); - + /*! * \brief Get the value of the reference angular velocity for non-dimensionalization. * \return Reference angular velocity for non-dimensionalization. */ su2double GetOmega_Ref(void); - + /*! * \brief Get the value of the reference force for non-dimensionalization. * \return Reference force for non-dimensionalization. */ su2double GetForce_Ref(void); - + /*! * \brief Get the value of the non-dimensionalized freestream pressure. * \return Non-dimensionalized freestream pressure. */ su2double GetPressure_FreeStream(void); - + /*! * \brief Get the value of the non-dimensionalized freestream pressure. * \return Non-dimensionalized freestream pressure. */ su2double GetPressure_FreeStreamND(void); - + /*! * \brief Get the value of the thermodynamic pressure. * \return Thermodynamic pressure. */ su2double GetPressure_Thermodynamic(void); - + /*! * \brief Get the value of the non-dimensionalized thermodynamic pressure. * \return Non-dimensionalized thermodynamic pressure. @@ -1782,127 +1781,127 @@ class CConfig { * \return Dimensionalized freestream velocity vector. */ su2double* GetVelocity_FreeStream(void); - + /*! * \brief Get the value of the non-dimensionalized freestream temperature. * \return Non-dimensionalized freestream temperature. */ su2double GetTemperature_FreeStreamND(void); - + /*! * \brief Get the value of the non-dimensionalized freestream density. * \return Non-dimensionalized freestream density. */ su2double GetDensity_FreeStreamND(void); - + /*! * \brief Get the vector of the non-dimensionalized freestream velocity. * \return Non-dimensionalized freestream velocity vector. */ su2double* GetVelocity_FreeStreamND(void); - + /*! * \brief Get the value of the non-dimensionalized freestream energy. * \return Non-dimensionalized freestream energy. */ su2double GetEnergy_FreeStreamND(void); - + /*! * \brief Get the value of the non-dimensionalized freestream viscosity. * \return Non-dimensionalized freestream viscosity. */ su2double GetViscosity_FreeStreamND(void); - + /*! * \brief Get the value of the non-dimensionalized freestream viscosity. * \return Non-dimensionalized freestream viscosity. */ su2double GetTke_FreeStreamND(void); - + /*! * \brief Get the value of the non-dimensionalized freestream viscosity. * \return Non-dimensionalized freestream viscosity. */ su2double GetOmega_FreeStreamND(void); - + /*! * \brief Get the value of the non-dimensionalized freestream viscosity. * \return Non-dimensionalized freestream viscosity. */ su2double GetTke_FreeStream(void); - + /*! * \brief Get the value of the non-dimensionalized freestream viscosity. * \return Non-dimensionalized freestream viscosity. */ su2double GetOmega_FreeStream(void); - + /*! * \brief Get the value of the non-dimensionalized freestream intermittency. * \return Non-dimensionalized freestream intermittency. */ su2double GetIntermittency_FreeStream(void); - + /*! * \brief Get the value of the non-dimensionalized freestream turbulence intensity. * \return Non-dimensionalized freestream intensity. */ su2double GetTurbulenceIntensity_FreeStream(void); - + /*! * \brief Get the value of the non-dimensionalized freestream turbulence intensity. * \return Non-dimensionalized freestream intensity. */ su2double GetNuFactor_FreeStream(void); - + /*! * \brief Get the value of the non-dimensionalized engine turbulence intensity. * \return Non-dimensionalized engine intensity. */ su2double GetNuFactor_Engine(void); - + /*! * \brief Get the value of the non-dimensionalized actuator disk turbulence intensity. * \return Non-dimensionalized actuator disk intensity. */ su2double GetSecondaryFlow_ActDisk(void); - + /*! * \brief Get the value of the non-dimensionalized actuator disk turbulence intensity. * \return Non-dimensionalized actuator disk intensity. */ su2double GetInitial_BCThrust(void); - + /*! * \brief Get the value of the non-dimensionalized actuator disk turbulence intensity. * \return Non-dimensionalized actuator disk intensity. */ void SetInitial_BCThrust(su2double val_bcthrust); - + /*! * \brief Get the value of the turbulent to laminar viscosity ratio. * \return Ratio of turbulent to laminar viscosity ratio. */ su2double GetTurb2LamViscRatio_FreeStream(void); - + /*! * \brief Get the vector of free stream mass fraction values. * \return Ratio of species mass to mixture mass. */ su2double* GetMassFrac_FreeStream(void); - + /*! * \brief Get the value of the Reynolds length. * \return Reynolds length. */ su2double GetLength_Reynolds(void); - + /*! * \brief Get the start up iterations using the fine grid, this works only for multigrid problems. * \return Start up iterations using the fine grid. */ unsigned short GetnStartUpIter(void); - + /*! * \brief Get the reference area for non dimensional coefficient computation. If the value from the * is 0 then, the code will compute the reference area using the projection of the shape into @@ -1910,13 +1909,13 @@ class CConfig { * \return Value of the reference area for coefficient computation. */ su2double GetRefArea(void); - + /*! * \brief Get the wave speed. * \return Value of the wave speed. */ su2double GetThermalDiffusivity(void); - + /*! * \brief Get the thermal expansion coefficient. * \return Value of the thermal expansion coefficient. @@ -1982,19 +1981,19 @@ class CConfig { * \return Value of the Young's modulus of elasticity. */ su2double GetElasticyMod(unsigned short id_val); - + /*! * \brief Decide whether to apply DE effects to the model. * \return TRUE if the DE effects are to be applied, FALSE otherwise. */ bool GetDE_Effects(void); - + /*! * \brief Decide whether to predict the DE effects for the next time step. * \return TRUE if the DE effects are to be applied, FALSE otherwise. */ bool GetDE_Predicted(void); - + /*! * \brief Get the number of different electric constants. * \return Value of the DE modulus. @@ -2066,19 +2065,19 @@ class CConfig { * \return Flag to 2D elasticity model. */ unsigned short GetElas2D_Formulation(void); - + /*! * \brief Decide whether it's necessary to read a reference geometry. * \return TRUE if it's necessary to read a reference geometry, FALSE otherwise. */ bool GetPrestretch(void); - + /*! * \brief Decide whether it's necessary to add the cross term for adjoint FSI. * \return TRUE if it's necessary to add the cross term, FALSE otherwise. */ bool Add_CrossTerm(void); - + /*! * \brief Set the boolean addCrossTerm to true or false. */ @@ -2095,83 +2094,83 @@ class CConfig { * \return Name of the file with the reference geometry of the structural problem. */ string GetPrestretch_FEMFileName(void); - + /*! * \brief Get the Poisson's ratio. * \return Value of the Poisson's ratio. */ su2double GetPoissonRatio(unsigned short id_val); - + /*! * \brief Get the Material Density. * \return Value of the Material Density. */ su2double GetMaterialDensity(unsigned short id_val); - + /*! * \brief Compressibility/incompressibility of the solids analysed using the structural solver. * \return Compressible or incompressible. */ unsigned short GetMaterialCompressibility(void); - + /*! * \brief Compressibility/incompressibility of the solids analysed using the structural solver. * \return Compressible or incompressible. */ unsigned short GetMaterialModel(void); - + /*! * \brief Geometric conditions for the structural solver. * \return Small or large deformation structural analysis. */ unsigned short GetGeometricConditions(void); - + /*! * \brief Get the reference length for computing moment (the default value is 1). * \return Reference length for moment computation. */ su2double GetRefLength(void); - + /*! * \brief Get the reference element length for computing the slope limiting epsilon. * \return Reference element length for slope limiting epsilon. */ su2double GetRefElemLength(void); - + /*! * \brief Get the reference coefficient for detecting sharp edges. * \return Reference coefficient for detecting sharp edges. */ su2double GetRefSharpEdges(void); - + /*! * \brief Get the volume of the whole domain using the fine grid, this value is common for all the grids * in the multigrid method. * \return Volume of the whole domain. */ su2double GetDomainVolume(void); - + /*! * \brief In case the RefArea is equal to 0 then, it is necessary to compute a reference area, * with this function we set the value of the reference area. * \param[in] val_area - Value of the reference area for non dimensional coefficient computation. */ void SetRefArea(su2double val_area); - + /*! * \brief In case the SemiSpan is equal to 0 then, it is necessary to compute the max y distance, * with this function we set the value of the semi span. * \param[in] val_semispan - Value of the semispan. */ void SetSemiSpan(su2double val_semispan); - + /*! * \brief Set the value of the domain volume computed on the finest grid. * \note This volume do not include the volume of the body that is being simulated. * \param[in] val_volume - Value of the domain volume computed on the finest grid. */ void SetDomainVolume(su2double val_volume); - + /*! * \brief Set the finest mesh in a multigrid strategy. * \note If we are using a Full Multigrid Strategy or a start up with finest grid, it is necessary @@ -2179,7 +2178,7 @@ class CConfig { * \param[in] val_finestmesh - Index of the finest grid. */ void SetFinestMesh(unsigned short val_finestmesh); - + /*! * \brief Set the kind of time integration scheme. * \note If we are solving different equations it will be necessary to change several @@ -2187,7 +2186,7 @@ class CConfig { * \param[in] val_kind_timeintscheme - Kind of time integration scheme. */ void SetKind_TimeIntScheme(unsigned short val_kind_timeintscheme); - + /*! * \brief Set the parameters of the convective numerical scheme. * \note The parameters will change because we are solving different kind of equations. @@ -2207,19 +2206,19 @@ class CConfig { * \return Value of the limiter coefficient. */ su2double GetVenkat_LimiterCoeff(void); - + /*! * \brief Freeze the value of the limiter after a number of iterations. * \return Number of iterations. */ unsigned long GetLimiterIter(void); - + /*! * \brief Get the value of sharp edge limiter. * \return Value of the sharp edge limiter coefficient. */ su2double GetAdjSharp_LimiterCoeff(void); - + /*! * \brief Get the Reynolds number. Dimensionless number that gives a measure of the ratio of inertial forces * to viscous forces and consequently quantifies the relative importance of these two types of forces @@ -2227,97 +2226,97 @@ class CConfig { * \return Value of the Reynolds number. */ su2double GetReynolds(void); - + /*! * \brief Get the Froude number for free surface problems. * \return Value of the Froude number. */ su2double GetFroude(void); - + /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ void SetFroude(su2double val_froude); - + /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ void SetMach(su2double val_mach); - + /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ void SetReynolds(su2double val_reynolds); - + /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ void SetLength_Ref(su2double val_length_ref); - + /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ void SetVelocity_Ref(su2double val_velocity_ref); - + /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ void SetPressure_Ref(su2double val_pressure_ref); - + /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ void SetDensity_Ref(su2double val_density_ref); - + /*! * \brief Set the reference temperature. * \return Value of the Froude number. */ void SetTemperature_Ref(su2double val_temperature_ref); - + /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ void SetTime_Ref(su2double val_time_ref); - + /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ void SetEnergy_Ref(su2double val_energy_ref); - + /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ void SetOmega_Ref(su2double val_omega_ref); - + /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ void SetForce_Ref(su2double val_force_ref); - + /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ void SetGas_Constant_Ref(su2double val_gas_constant_ref); - + /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ void SetGas_Constant(su2double val_gas_constant); - + /*! * \brief Set the value of the specific heat at constant pressure (incompressible fluids with energy equation). * \param[in] val_specific_heat_cp - specific heat at constant pressure. @@ -2353,31 +2352,31 @@ class CConfig { * \return Value of the Froude number. */ void SetViscosity_Ref(su2double val_viscosity_ref); - + /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ void SetConductivity_Ref(su2double val_conductivity_ref); - + /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ void SetPressure_FreeStreamND(su2double val_pressure_freestreamnd); - + /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ void SetPressure_FreeStream(su2double val_pressure_freestream); - + /*! * \brief Set the non-dimensionalized thermodynamic pressure for low Mach problems. * \return Value of the non-dimensionalized thermodynamic pressure. */ void SetPressure_ThermodynamicND(su2double val_pressure_thermodynamicnd); - + /*! * \brief Set the thermodynamic pressure for low Mach problems. * \return Value of the thermodynamic pressure. @@ -2389,49 +2388,49 @@ class CConfig { * \return Value of the Froude number. */ void SetDensity_FreeStreamND(su2double val_density_freestreamnd); - + /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ void SetDensity_FreeStream(su2double val_density_freestream); - + /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ void SetViscosity_FreeStream(su2double val_viscosity_freestream); - + /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ void SetModVel_FreeStream(su2double val_modvel_freestream); - + /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ void SetModVel_FreeStreamND(su2double val_modvel_freestreamnd); - + /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ void SetTemperature_FreeStream(su2double val_temperature_freestream); - + /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ void SetTemperature_FreeStreamND(su2double val_temperature_freestreamnd); - + /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ void SetGas_ConstantND(su2double val_gas_constantnd); - + /*! * \brief Set the free-stream velocity. * \param[in] val_velocity_freestream - Value of the free-stream velocity component. @@ -2444,43 +2443,43 @@ class CConfig { * \return Value of the Froude number. */ void SetVelocity_FreeStreamND(su2double val_velocity_freestreamnd, unsigned short val_dim); - + /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ void SetViscosity_FreeStreamND(su2double val_viscosity_freestreamnd); - + /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ void SetTke_FreeStreamND(su2double val_tke_freestreamnd); - + /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ void SetOmega_FreeStreamND(su2double val_omega_freestreamnd); - + /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ void SetTke_FreeStream(su2double val_tke_freestream); - + /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ void SetOmega_FreeStream(su2double val_omega_freestream); - + /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ void SetEnergy_FreeStreamND(su2double val_energy_freestreamnd); - + /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. @@ -2492,13 +2491,13 @@ class CConfig { * \return Value of the Froude number. */ void SetThermalDiffusivity_Solid(su2double val_thermal_diffusivity); - + /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ void SetTotal_UnstTimeND(su2double val_total_unsttimend); - + /*! * \brief Get the angle of attack of the body. This is the angle between a reference line on a lifting body * (often the chord line of an airfoil) and the vector representing the relative motion between the @@ -2506,109 +2505,109 @@ class CConfig { * \return Value of the angle of attack. */ su2double GetAoA(void); - + /*! * \brief Get the off set angle of attack of the body. The solution and the geometry * file are able to modifity the angle of attack in the config file * \return Value of the off set angle of attack. */ su2double GetAoA_Offset(void); - + /*! * \brief Get the off set sideslip angle of the body. The solution and the geometry * file are able to modifity the angle of attack in the config file * \return Value of the off set sideslip angle. */ su2double GetAoS_Offset(void); - + /*! * \brief Get the functional sensitivity with respect to changes in the angle of attack. * \return Value of the angle of attack. */ su2double GetAoA_Sens(void); - + /*! * \brief Set the angle of attack. * \param[in] val_AoA - Value of the angle of attack. */ void SetAoA(su2double val_AoA); - + /*! * \brief Set the off set angle of attack. * \param[in] val_AoA - Value of the angle of attack. */ void SetAoA_Offset(su2double val_AoA_offset); - + /*! * \brief Set the off set sideslip angle. * \param[in] val_AoA - Value of the off set sideslip angle. */ void SetAoS_Offset(su2double val_AoS_offset); - + /*! * \brief Set the angle of attack. * \param[in] val_AoA - Value of the angle of attack. */ void SetAoA_Sens(su2double val_AoA_sens); - + /*! * \brief Set the angle of attack. * \param[in] val_AoA - Value of the angle of attack. */ void SetAoS(su2double val_AoS); - + /*! * \brief Get the angle of sideslip of the body. It relates to the rotation of the aircraft centerline from * the relative wind. * \return Value of the angle of sideslip. */ su2double GetAoS(void); - + /*! * \brief Get the charge coefficient that is used in the poissonal potential simulation. * \return Value of the charge coefficient. */ su2double GetChargeCoeff(void); - + /*! * \brief Get the number of multigrid levels. * \return Number of multigrid levels (without including the original grid). */ unsigned short GetnMGLevels(void); - + /*! * \brief Set the number of multigrid levels. * \param[in] val_nMGLevels - Index of the mesh were the CFL is applied */ void SetMGLevels(unsigned short val_nMGLevels); - + /*! * \brief Get the index of the finest grid. * \return Index of the finest grid in a multigrid strategy, this is 0 unless we are performing a Full multigrid. */ unsigned short GetFinestMesh(void); - + /*! * \brief Get the kind of multigrid (V or W). * \note This variable is used in a recursive way to perform the different kind of cycles * \return 0 or 1 depending of we are dealing with a V or W cycle. */ unsigned short GetMGCycle(void); - + /*! * \brief Get the king of evaluation in the geometrical module. * \return 0 or 1 depending of we are dealing with a V or W cycle. */ unsigned short GetGeometryMode(void); - + /*! * \brief Get the Courant Friedrich Levi number for each grid. * \param[in] val_mesh - Index of the mesh were the CFL is applied. * \return CFL number for each grid. */ su2double GetCFL(unsigned short val_mesh); - + /*! * \brief Get the Courant Friedrich Levi number for each grid. * \param[in] val_mesh - Index of the mesh were the CFL is applied. @@ -2624,16 +2623,16 @@ class CConfig { /*! * \brief Get information about element reorientation - * \return TRUE means that elements can be reoriented if suspected unhealthy + * \return TRUE means that elements can be reoriented if suspected unhealthy */ bool GetReorientElements(void); - + /*! * \brief Get the Courant Friedrich Levi number for unsteady simulations. * \return CFL number for unsteady simulations. */ su2double GetMax_DeltaTime(void); - + /*! * \brief Get a parameter of the particular design variable. * \param[in] val_dv - Number of the design variable that we want to read. @@ -2641,7 +2640,7 @@ class CConfig { * \return Design variable parameter. */ su2double GetParamDV(unsigned short val_dv, unsigned short val_param); - + /*! * \brief Get the coordinates of the FFD corner points. * \param[in] val_ffd - Index of the FFD box. @@ -2649,7 +2648,7 @@ class CConfig { * \return Value of the coordinate. */ su2double GetCoordFFDBox(unsigned short val_ffd, unsigned short val_index); - + /*! * \brief Get the degree of the FFD corner points. * \param[in] val_ffd - Index of the FFD box. @@ -2657,63 +2656,63 @@ class CConfig { * \return Value of the degree in a particular direction. */ unsigned short GetDegreeFFDBox(unsigned short val_ffd, unsigned short val_index); - + /*! * \brief Get the FFD Tag of a particular design variable. * \param[in] val_dv - Number of the design variable that we want to read. * \return Name of the FFD box. */ string GetFFDTag(unsigned short val_dv); - + /*! * \brief Get the FFD Tag of a particular FFD box. * \param[in] val_ffd - Number of the FFD box that we want to read. * \return Name of the FFD box. */ string GetTagFFDBox(unsigned short val_ffd); - + /*! * \brief Get the number of design variables. * \return Number of the design variables. */ unsigned short GetnDV(void); - + /*! * \brief Get the number of design variables. * \return Number of the design variables. */ unsigned short GetnDV_Value(unsigned short iDV); - + /*! * \brief Get the number of FFD boxes. * \return Number of FFD boxes. */ unsigned short GetnFFDBox(void); - + /*! * \brief Get the required continuity level at the surface intersection with the FFD * \return Continuity level at the surface intersection. */ unsigned short GetFFD_Continuity(void); - + /*! * \brief Get the coordinate system that we are going to use to define the FFD * \return Coordinate system (cartesian, spherical, etc). */ unsigned short GetFFD_CoordSystem(void); - + /*! * \brief Get the kind of FFD Blending function. * \return Kind of FFD Blending function. */ unsigned short GetFFD_Blending(void); - + /*! * \brief Get the kind BSpline Order in i,j,k direction. * \return The kind BSpline Order in i,j,k direction. */ su2double* GetFFD_BSplineOrder(); - + /*! * \brief Get the number of Runge-Kutta steps. * \return Number of Runge-Kutta steps. @@ -2785,25 +2784,25 @@ class CConfig { * \return Number of symmetry boundary markers. */ unsigned short GetnMarker_SymWall(void); - + /*! * \brief Get the total number of boundary markers. * \return Total number of boundary markers. */ unsigned short GetnMarker_Max(void); - + /*! * \brief Get the total number of boundary markers. * \return Total number of boundary markers. */ unsigned short GetnMarker_EngineInflow(void); - + /*! * \brief Get the total number of boundary markers. * \return Total number of boundary markers. */ unsigned short GetnMarker_EngineExhaust(void); - + /*! * \brief Get the total number of boundary markers. * \return Total number of boundary markers. @@ -2820,43 +2819,43 @@ class CConfig { * \return Total number of markers in which the flow load is computed/employed. */ unsigned short GetnMarker_Fluid_Load(void); - + /*! * \brief Get the total number of boundary markers. * \return Total number of boundary markers. */ unsigned short GetnMarker_Fluid_InterfaceBound(void); - + /*! * \brief Get the total number of boundary markers. * \return Total number of boundary markers. */ unsigned short GetnMarker_ActDiskInlet(void); - + /*! * \brief Get the total number of boundary markers. * \return Total number of boundary markers. */ unsigned short GetnMarker_ActDiskOutlet(void); - + /*! * \brief Get the total number of boundary markers. * \return Total number of boundary markers. */ unsigned short GetnMarker_Outlet(void); - + /*! * \brief Get the total number of monitoring markers. * \return Total number of monitoring markers. */ unsigned short GetnMarker_Monitoring(void); - + /*! * \brief Get the total number of DV markers. * \return Total number of DV markers. */ unsigned short GetnMarker_DV(void); - + /*! * \brief Get the total number of moving markers. * \return Total number of moving markers. @@ -2868,7 +2867,7 @@ class CConfig { * \return Total number of Python customizable markers. */ unsigned short GetnMarker_PyCustom(void); - + /*! * \brief Get the total number of moving markers. * \return Total number of moving markers. @@ -2886,133 +2885,133 @@ class CConfig { * \return Total number of heat flux markers. */ unsigned short GetnMarker_HeatFlux(void); - + /*! * \brief Get the total number of objectives in kind_objective list * \return Total number of objectives in kind_objective list */ unsigned short GetnObj(void); - + /*! * \brief Stores the number of marker in the simulation. * \param[in] val_nmarker - Number of markers of the problem. */ void SetnMarker_All(unsigned short val_nmarker); - + /*! * \brief Get the number of internal iterations. * \return Number of internal iterations. */ unsigned long GetUnst_nIntIter(void); - + /*! * \brief Get the number of internal iterations for the Newton-Raphson Method in nonlinear structural applications. * \return Number of internal iterations. */ unsigned long GetDyn_nIntIter(void); - + /*! * \brief Get the starting direct iteration number for the unsteady adjoint (reverse time integration). * \return Starting direct iteration number for the unsteady adjoint. */ long GetUnst_AdjointIter(void); - + /*! * \brief Number of iterations to average (reverse time integration). * \return Starting direct iteration number for the unsteady adjoint. */ unsigned long GetIter_Avg_Objective(void); - + /*! * \brief Retrieves the number of periodic time instances for Harmonic Balance. * \return: Number of periodic time instances for Harmonic Balance. */ unsigned short GetnTimeInstances(void); - + /*! * \brief Retrieves the period of oscillations to be used with Harmonic Balance. * \return: Period for Harmonic Balance. */ su2double GetHarmonicBalance_Period(void); - + /*! * \brief Set the current external iteration number. * \param[in] val_iter - Current external iteration number. */ void SetExtIter_OffSet(unsigned long val_iter); - + /*! * \brief Set the current FSI iteration number. * \param[in] val_iter - Current FSI iteration number. */ void SetOuterIter(unsigned long val_iter); - + /*! * \brief Set the current FSI iteration number. * \param[in] val_iter - Current FSI iteration number. */ void SetInnerIter(unsigned long val_iter); - + /*! * \brief Set the current time iteration number. * \param[in] val_iter - Current FSI iteration number. */ void SetTimeIter(unsigned long val_iter); - + /*! * \brief Get the current time iteration number. * \param[in] val_iter - Current time iterationnumber. */ unsigned long GetTimeIter(); - + /*! * \brief Get the current internal iteration number. * \return Current external iteration. */ unsigned long GetExtIter_OffSet(void); - + /*! * \brief Get the current FSI iteration number. * \return Current FSI iteration. */ unsigned long GetOuterIter(void); - + /*! * \brief Get the current FSI iteration number. * \return Current FSI iteration. */ unsigned long GetInnerIter(void); - + /*! * \brief Set the current physical time. * \param[in] val_t - Current physical time. */ void SetPhysicalTime(su2double val_t); - + /*! * \brief Get the current physical time. * \return Current physical time. */ su2double GetPhysicalTime(void); - + /*! * \brief Get the frequency for writing the solution file. * \return It writes the solution file with this frequency. */ unsigned long GetWrt_Sol_Freq(void); - + /*! * \brief Get the frequency for writing the solution file in Dual Time. * \return It writes the solution file with this frequency. */ unsigned long GetWrt_Sol_Freq_DualTime(void); - + /*! * \brief Get the frequency for writing the convergence file. * \return It writes the convergence file with this frequency. */ unsigned long GetWrt_Con_Freq(void); - + /*! * \brief Set the frequency for writing the convergence file. * \return It writes the convergence file with this frequency. @@ -3024,10 +3023,10 @@ class CConfig { * \return It writes the convergence file with this frequency. */ unsigned long GetWrt_Con_Freq_DualTime(void); - + /*! * \brief Get information about writing unsteady headers and file extensions. - * \return TRUE means that unsteady solution files will be written. + * \return TRUE means that unsteady solution files will be written. */ bool GetWrt_Unsteady(void); @@ -3048,43 +3047,43 @@ class CConfig { * \return TRUE means that a surface solution file will be written. */ bool GetWrt_Srf_Sol(void); - + /*! * \brief Get information about writing a surface comma-separated values (CSV) solution file. * \return TRUE means that a surface comma-separated values (CSV) solution file will be written. */ bool GetWrt_Csv_Sol(void); - + /*! * \brief Get information about writing a binary coordinates file. * \return TRUE means that a binary coordinates file will be written. */ bool GetWrt_Crd_Sol(void); - + /*! * \brief Get information about writing residuals to volume solution file. * \return TRUE means that residuals will be written to the solution file. */ bool GetWrt_Residuals(void); - + /*! * \brief Get information about writing residuals to volume solution file. * \return TRUE means that residuals will be written to the solution file. */ bool GetWrt_Limiters(void); - + /*! * \brief Write solution at each surface. * \return TRUE means that the solution at each surface will be written. */ bool GetWrt_Surface(void); - + /*! * \brief Get information about writing residuals to volume solution file. * \return TRUE means that residuals will be written to the solution file. */ bool GetWrt_SharpEdges(void); - + /*! * \brief Get information about writing rind layers to the solution files. * \return TRUE means that rind layers will be written to the solution file. @@ -3102,7 +3101,7 @@ class CConfig { * \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. * \return TRUE means that the mesh quality metrics will be written to the visualization files. @@ -3120,26 +3119,26 @@ class CConfig { * \return TRUE means that projected sensitivities on surfaces in an ASCII file with rows as x, y, z, dJ/dx, dJ/dy, dJ/dz for each vertex will be written. */ bool GetWrt_Projected_Sensitivity(void); - + /*! * \brief Get information about the format for the input volume sensitvities. * \return Format of the input volume sensitivities. */ unsigned short GetSensitivity_Format(void); - + /*! * \brief Get information about writing sectional force files. * \return TRUE means that sectional force files will be written for specified markers. */ bool GetPlot_Section_Forces(void); - + /*! * \brief Get the alpha (convective) coefficients for the Runge-Kutta integration scheme. * \param[in] val_step - Index of the step. * \return Alpha coefficient for the Runge-Kutta integration scheme. */ su2double Get_Alpha_RKStep(unsigned short val_step); - + /*! * \brief Get the index of the surface defined in the geometry file. * \param[in] val_marker - Value of the marker in which we are interested. @@ -3147,7 +3146,7 @@ class CConfig { * has the marker val_marker. */ string GetMarker_All_TagBound(unsigned short val_marker); - + /*! * \brief Get the index of the surface defined in the geometry file. * \param[in] val_marker - Value of the marker in which we are interested. @@ -3155,7 +3154,7 @@ class CConfig { * has the marker val_marker. */ string GetMarker_ActDiskInlet_TagBound(unsigned short val_marker); - + /*! * \brief Get the index of the surface defined in the geometry file. * \param[in] val_marker - Value of the marker in which we are interested. @@ -3163,7 +3162,7 @@ class CConfig { * has the marker val_marker. */ string GetMarker_ActDiskOutlet_TagBound(unsigned short val_marker); - + /*! * \brief Get the index of the surface defined in the geometry file. * \param[in] val_marker - Value of the marker in which we are interested. @@ -3171,7 +3170,7 @@ class CConfig { * has the marker val_marker. */ string GetMarker_Outlet_TagBound(unsigned short val_marker); - + /*! * \brief Get the index of the surface defined in the geometry file. * \param[in] val_marker - Value of the marker in which we are interested. @@ -3179,7 +3178,7 @@ class CConfig { * has the marker val_marker. */ string GetMarker_EngineInflow_TagBound(unsigned short val_marker); - + /*! * \brief Get the index of the surface defined in the geometry file. * \param[in] val_marker - Value of the marker in which we are interested. @@ -3187,7 +3186,7 @@ class CConfig { * has the marker val_marker. */ string GetMarker_EngineExhaust_TagBound(unsigned short val_marker); - + /*! * \brief Get the name of the surface defined in the geometry file. * \param[in] val_marker - Value of the marker in which we are interested. @@ -3203,7 +3202,7 @@ class CConfig { * has the marker val_marker. */ string GetMarker_HeatFlux_TagBound(unsigned short val_marker); - + /*! * \brief Get the tag if the iMarker defined in the geometry file. * \param[in] val_tag - Value of the tag in which we are interested. @@ -3211,14 +3210,14 @@ class CConfig { * for the surface that has the tag. */ short GetMarker_All_TagBound(string val_tag); - + /*! * \brief Get the kind of boundary for each marker. * \param[in] val_marker - Index of the marker in which we are interested. * \return Kind of boundary for the marker val_marker. */ unsigned short GetMarker_All_KindBC(unsigned short val_marker); - + /*! * \brief Set the value of the boundary val_boundary (read from the config file) * for the marker val_marker. @@ -3226,7 +3225,7 @@ class CConfig { * \param[in] val_boundary - Kind of boundary read from config file. */ void SetMarker_All_KindBC(unsigned short val_marker, unsigned short val_boundary); - + /*! * \brief Set the value of the index val_index (read from the geometry file) for * the marker val_marker. @@ -3234,7 +3233,7 @@ class CConfig { * \param[in] val_index - Index of the surface read from geometry file. */ void SetMarker_All_TagBound(unsigned short val_marker, string val_index); - + /*! * \brief Set if a marker val_marker is going to be monitored val_monitoring * (read from the config file). @@ -3243,7 +3242,7 @@ class CConfig { * \param[in] val_monitoring - 0 or 1 depending if the the marker is going to be monitored. */ void SetMarker_All_Monitoring(unsigned short val_marker, unsigned short val_monitoring); - + /*! * \brief Set if a marker val_marker is going to be monitored val_monitoring * (read from the config file). @@ -3252,7 +3251,7 @@ class CConfig { * \param[in] val_monitoring - 0 or 1 depending if the the marker is going to be monitored. */ void SetMarker_All_GeoEval(unsigned short val_marker, unsigned short val_geoeval); - + /*! * \brief Set if a marker val_marker is going to be designed val_designing * (read from the config file). @@ -3261,7 +3260,7 @@ class CConfig { * \param[in] val_monitoring - 0 or 1 depending if the the marker is going to be designed. */ void SetMarker_All_Designing(unsigned short val_marker, unsigned short val_designing); - + /*! * \brief Set if a marker val_marker is going to be plot val_plotting * (read from the config file). @@ -3269,7 +3268,7 @@ class CConfig { * \param[in] val_plotting - 0 or 1 depending if the the marker is going to be plot. */ void SetMarker_All_Plotting(unsigned short val_marker, unsigned short val_plotting); - + /*! * \brief Set if a marker val_marker is going to be plot val_plotting * (read from the config file). @@ -3277,7 +3276,7 @@ class CConfig { * \param[in] val_plotting - 0 or 1 depending if the the marker is going to be plot. */ void SetMarker_All_Analyze(unsigned short val_marker, unsigned short val_analyze); - + /*! * \brief Set if a marker val_marker is part of the FSI interface val_plotting * (read from the config file). @@ -3285,7 +3284,7 @@ class CConfig { * \param[in] val_plotting - 0 or 1 depending if the the marker is part of the FSI interface. */ void SetMarker_All_ZoneInterface(unsigned short val_marker, unsigned short val_fsiinterface); - + /*! * \brief Set if a marker val_marker is part of the Turbomachinery (read from the config file). * \param[in] val_marker - Index of the marker in which we are interested. @@ -3306,7 +3305,7 @@ class CConfig { * \param[in] val_turboperf - 0 if not part of the MixingPlane interface or greater than 1 if it is part. */ void SetMarker_All_MixingPlaneInterface(unsigned short val_marker, unsigned short val_mixplan_interface); - + /*! * \brief Set if a marker val_marker is going to be affected by design variables val_moving * (read from the config file). @@ -3314,7 +3313,7 @@ class CConfig { * \param[in] val_DV - 0 or 1 depending if the the marker is affected by design variables. */ void SetMarker_All_DV(unsigned short val_marker, unsigned short val_DV); - + /*! * \brief Set if a marker val_marker is going to be moved val_moving * (read from the config file). @@ -3344,7 +3343,7 @@ class CConfig { * \param[in] val_PyCustom - 0 or 1 depending if the the marker is going to be customized in Python. */ void SetMarker_All_PyCustom(unsigned short val_marker, unsigned short val_PyCustom); - + /*! * \brief Set if a marker val_marker is going to be periodic val_perbound * (read from the config file). @@ -3352,7 +3351,7 @@ class CConfig { * \param[in] val_perbound - Index of the surface with the periodic boundary. */ void SetMarker_All_PerBound(unsigned short val_marker, short val_perbound); - + /*! * \brief Set if a marker val_marker is going to be sent or receive val_index * from another domain. @@ -3360,7 +3359,7 @@ class CConfig { * \param[in] val_index - Index of the surface read from geometry file. */ void SetMarker_All_SendRecv(unsigned short val_marker, short val_index); - + /*! * \brief Get the send-receive information for a marker val_marker. * \param[in] val_marker - 0 or 1 depending if the the marker is going to be moved. @@ -3368,91 +3367,91 @@ class CConfig { * the information is receive from that domain. */ short GetMarker_All_SendRecv(unsigned short val_marker); - + /*! * \brief Get an internal index that identify the periodic boundary conditions. * \param[in] val_marker - Value of the marker that correspond with the periodic boundary. * \return The internal index of the periodic boundary condition. */ short GetMarker_All_PerBound(unsigned short val_marker); - + /*! * \brief Get the monitoring information for a marker val_marker. * \param[in] val_marker - 0 or 1 depending if the the marker is going to be monitored. * \return 0 or 1 depending if the marker is going to be monitored. */ unsigned short GetMarker_All_Monitoring(unsigned short val_marker); - + /*! * \brief Get the monitoring information for a marker val_marker. * \param[in] val_marker - 0 or 1 depending if the the marker is going to be monitored. * \return 0 or 1 depending if the marker is going to be monitored. */ unsigned short GetMarker_All_GeoEval(unsigned short val_marker); - + /*! * \brief Get the design information for a marker val_marker. * \param[in] val_marker - 0 or 1 depending if the the marker is going to be monitored. * \return 0 or 1 depending if the marker is going to be monitored. */ unsigned short GetMarker_All_Designing(unsigned short val_marker); - + /*! * \brief Get the plotting information for a marker val_marker. * \param[in] val_marker - 0 or 1 depending if the the marker is going to be moved. * \return 0 or 1 depending if the marker is going to be plotted. */ unsigned short GetMarker_All_Plotting(unsigned short val_marker); - + /*! * \brief Get the plotting information for a marker val_marker. * \param[in] val_marker - 0 or 1 depending if the the marker is going to be moved. * \return 0 or 1 depending if the marker is going to be plotted. */ unsigned short GetMarker_All_Analyze(unsigned short val_marker); - + /*! * \brief Get the FSI interface information for a marker val_marker. * \param[in] val_marker - 0 or 1 depending if the the marker is going to be moved. * \return 0 or 1 depending if the marker is part of the FSI interface. */ unsigned short GetMarker_All_ZoneInterface(unsigned short val_marker); - - /*! - * \brief Get the MixingPlane interface information for a marker val_marker. - * \param[in] val_marker value of the marker on the grid. - * \return 0 if is not part of the MixingPlane Interface and greater than 1 if it is part. - */ - unsigned short GetMarker_All_MixingPlaneInterface(unsigned short val_marker); - - /*! - * \brief Get the Turbomachinery information for a marker val_marker. - * \param[in] val_marker value of the marker on the grid. - * \return 0 if is not part of the Turbomachinery and greater than 1 if it is part. - */ - unsigned short GetMarker_All_Turbomachinery(unsigned short val_marker); - - /*! - * \brief Get the Turbomachinery flag information for a marker val_marker. - * \param[in] val_marker value of the marker on the grid. - * \return 0 if is not part of the Turbomachinery, flag INFLOW or OUTFLOW if it is part. - */ - unsigned short GetMarker_All_TurbomachineryFlag(unsigned short val_marker); - - /*! + + /*! + * \brief Get the MixingPlane interface information for a marker val_marker. + * \param[in] val_marker value of the marker on the grid. + * \return 0 if is not part of the MixingPlane Interface and greater than 1 if it is part. + */ + unsigned short GetMarker_All_MixingPlaneInterface(unsigned short val_marker); + + /*! + * \brief Get the Turbomachinery information for a marker val_marker. + * \param[in] val_marker value of the marker on the grid. + * \return 0 if is not part of the Turbomachinery and greater than 1 if it is part. + */ + unsigned short GetMarker_All_Turbomachinery(unsigned short val_marker); + + /*! + * \brief Get the Turbomachinery flag information for a marker val_marker. + * \param[in] val_marker value of the marker on the grid. + * \return 0 if is not part of the Turbomachinery, flag INFLOW or OUTFLOW if it is part. + */ + unsigned short GetMarker_All_TurbomachineryFlag(unsigned short val_marker); + + /*! * \brief Get the number of FSI interface markers val_marker. * \param[in] void. * \return Number of markers belonging to the FSI interface. */ unsigned short GetMarker_n_ZoneInterface(void); - + /*! * \brief Get the DV information for a marker val_marker. * \param[in] val_marker - 0 or 1 depending if the the marker is going to be affected by design variables. * \return 0 or 1 depending if the marker is going to be affected by design variables. */ unsigned short GetMarker_All_DV(unsigned short val_marker); - + /*! * \brief Get the motion information for a marker val_marker. * \param[in] val_marker - 0 or 1 depending if the the marker is going to be moved. @@ -3480,134 +3479,134 @@ class CConfig { * \return 0 or 1 depending if the marker is going to be customized in Python. */ unsigned short GetMarker_All_PyCustom(unsigned short val_marker); - + /*! * \brief Get the airfoil sections in the slicing process. * \param[in] val_section - Index of the section. * \return Coordinate of the airfoil to slice. */ su2double GetLocationStations(unsigned short val_section); - + /*! * \brief Get the defintion of the nacelle location. * \param[in] val_index - Index of the section. * \return Coordinate of the nacelle location. */ su2double GetNacelleLocation(unsigned short val_index); - + /*! * \brief Get the number of pre-smoothings in a multigrid strategy. * \param[in] val_mesh - Index of the grid. * \return Number of smoothing iterations. */ unsigned short GetMG_PreSmooth(unsigned short val_mesh); - + /*! * \brief Get the number of post-smoothings in a multigrid strategy. * \param[in] val_mesh - Index of the grid. * \return Number of smoothing iterations. */ unsigned short GetMG_PostSmooth(unsigned short val_mesh); - + /*! * \brief Get the number of implicit Jacobi smoothings of the correction in a multigrid strategy. * \param[in] val_mesh - Index of the grid. * \return Number of implicit smoothing iterations. */ unsigned short GetMG_CorrecSmooth(unsigned short val_mesh); - + /*! * \brief plane of the FFD (I axis) that should be fixed. * \param[in] val_index - Index of the arrray with all the planes in the I direction that should be fixed. * \return Index of the plane that is going to be freeze. */ short GetFFD_Fix_IDir(unsigned short val_index); - + /*! * \brief plane of the FFD (J axis) that should be fixed. * \param[in] val_index - Index of the arrray with all the planes in the J direction that should be fixed. * \return Index of the plane that is going to be freeze. */ short GetFFD_Fix_JDir(unsigned short val_index); - + /*! * \brief plane of the FFD (K axis) that should be fixed. * \param[in] val_index - Index of the arrray with all the planes in the K direction that should be fixed. * \return Index of the plane that is going to be freeze. */ short GetFFD_Fix_KDir(unsigned short val_index); - + /*! * \brief Get the number of planes to fix in the I direction. * \return Number of planes to fix in the I direction. */ unsigned short GetnFFD_Fix_IDir(void); - + /*! * \brief Get the number of planes to fix in the J direction. * \return Number of planes to fix in the J direction. */ unsigned short GetnFFD_Fix_JDir(void); - + /*! * \brief Get the number of planes to fix in the K direction. * \return Number of planes to fix in the K direction. */ unsigned short GetnFFD_Fix_KDir(void); - + /*! * \brief Governing equations of the flow (it can be different from the run time equation). * \param[in] val_zone - Zone where the soler is applied. * \return Governing equation that we are solving. */ unsigned short GetKind_Solver(void); - + /*! * \brief Governing equations of the flow (it can be different from the run time equation). * \param[in] val_zone - Zone where the soler is applied. * \return Governing equation that we are solving. */ void SetKind_Solver(unsigned short val_solver); - + /*! * \brief Kind of Multizone Solver. * \return Governing equation that we are solving. */ unsigned short GetKind_MZSolver(void); - + /*! * \brief Governing equations of the flow (it can be different from the run time equation). * \param[in] val_zone - Zone where the soler is applied. * \return Governing equation that we are solving. */ unsigned short GetKind_Regime(void); - + /*! * \brief Governing equations of the flow (it can be different from the run time equation). * \param[in] val_zone - Zone where the soler is applied. * \return Governing equation that we are solving. */ unsigned short GetSystemMeasurements(void); - + /*! * \brief Gas model that we are using. * \return Gas model that we are using. */ unsigned short GetKind_GasModel(void); - + /*! * \brief Fluid model that we are using. * \return Fluid model that we are using. */ unsigned short GetKind_FluidModel(void); - + /*! * \brief Option to define the density model for incompressible flows. * \return Density model option */ unsigned short GetKind_DensityModel(void); - + /*! * \brief Flag for whether to solve the energy equation for incompressible flows. * \return Flag for energy equation @@ -3619,7 +3618,7 @@ class CConfig { * \return free stream option */ unsigned short GetKind_FreeStreamOption(void); - + /*! * \brief free stream option to initialize the solution * \return free stream option @@ -3630,37 +3629,37 @@ class CConfig { * \return Critical pressure. */ su2double GetPressure_Critical(void); - + /*! * \brief Get the value of the critical temperature. * \return Critical temperature. */ su2double GetTemperature_Critical(void); - + /*! * \brief Get the value of the critical pressure. * \return Critical pressure. */ su2double GetAcentric_Factor(void); - + /*! * \brief Get the value of the viscosity model. * \return Viscosity model. */ unsigned short GetKind_ViscosityModel(void); - + /*! * \brief Get the value of the thermal conductivity model. * \return Conductivity model. */ unsigned short GetKind_ConductivityModel(void); - + /*! * \brief Get the value of the turbulent thermal conductivity model. * \return Turbulent conductivity model. */ unsigned short GetKind_ConductivityModel_Turb(void); - + /*! * \brief Get the value of the constant viscosity. * \return Constant viscosity. @@ -3678,13 +3677,13 @@ class CConfig { * \return Thermal conductivity. */ su2double GetKt_Constant(void); - + /*! * \brief Get the value of the non-dimensional thermal conductivity. * \return Non-dimensional thermal conductivity. */ su2double GetKt_ConstantND(void); - + /*! * \brief Get the value of the reference viscosity for Sutherland model. * \return The reference viscosity. @@ -3696,7 +3695,7 @@ class CConfig { * \return The non-dimensional reference viscosity. */ su2double GetMu_RefND(void); - + /*! * \brief Get the value of the reference temperature for Sutherland model. * \return The reference temperature. @@ -3708,7 +3707,7 @@ class CConfig { * \return The non-dimensional reference temperature. */ su2double GetMu_Temperature_RefND(void); - + /*! * \brief Get the value of the reference S for Sutherland model. * \return The reference S. @@ -3720,13 +3719,13 @@ class CConfig { * \return The non-dimensional reference S. */ su2double GetMu_SND(void); - + /*! * \brief Get the number of coefficients in the temperature polynomial models. * \return The the number of coefficients in the temperature polynomial models. */ unsigned short GetnPolyCoeffs(void); - + /*! * \brief Get the temperature polynomial coefficient for specific heat Cp. * \param[in] val_index - Index of the array with all polynomial coefficients. @@ -3740,172 +3739,172 @@ class CConfig { * \return Temperature polynomial coefficient for specific heat Cp. */ su2double GetCp_PolyCoeffND(unsigned short val_index); - + /*! * \brief Get the temperature polynomial coefficient for viscosity. * \param[in] val_index - Index of the array with all polynomial coefficients. * \return Temperature polynomial coefficient for viscosity. */ su2double GetMu_PolyCoeff(unsigned short val_index); - + /*! * \brief Get the temperature polynomial coefficient for viscosity. * \param[in] val_index - Index of the array with all polynomial coefficients. * \return Non-dimensional temperature polynomial coefficient for viscosity. */ su2double GetMu_PolyCoeffND(unsigned short val_index); - + /*! * \brief Get the temperature polynomial coefficients for viscosity. * \return Non-dimensional temperature polynomial coefficients for viscosity. */ su2double* GetMu_PolyCoeffND(void); - + /*! * \brief Get the temperature polynomial coefficient for thermal conductivity. * \param[in] val_index - Index of the array with all polynomial coefficients. * \return Temperature polynomial coefficient for thermal conductivity. */ su2double GetKt_PolyCoeff(unsigned short val_index); - + /*! * \brief Get the temperature polynomial coefficient for thermal conductivity. * \param[in] val_index - Index of the array with all polynomial coefficients. * \return Non-dimensional temperature polynomial coefficient for thermal conductivity. */ su2double GetKt_PolyCoeffND(unsigned short val_index); - + /*! * \brief Get the temperature polynomial coefficients for thermal conductivity. * \return Non-dimensional temperature polynomial coefficients for thermal conductivity. */ su2double* GetKt_PolyCoeffND(void); - + /*! * \brief Set the value of the non-dimensional constant viscosity. */ void SetMu_ConstantND(su2double mu_const); - + /*! * \brief Set the value of the non-dimensional thermal conductivity. */ void SetKt_ConstantND(su2double kt_const); - + /*! * \brief Set the value of the non-dimensional reference viscosity for Sutherland model. */ void SetMu_RefND(su2double mu_ref); - + /*! * \brief Set the value of the non-dimensional reference temperature for Sutherland model. */ void SetMu_Temperature_RefND(su2double mu_Tref); - + /*! * \brief Set the value of the non-dimensional S for Sutherland model. */ void SetMu_SND(su2double mu_s); - + /*! * \brief Set the temperature polynomial coefficient for specific heat Cp. * \param[in] val_coeff - Temperature polynomial coefficient for specific heat Cp. * \param[in] val_index - Index of the array with all polynomial coefficients. */ void SetCp_PolyCoeffND(su2double val_coeff, unsigned short val_index); - + /*! * \brief Set the temperature polynomial coefficient for viscosity. * \param[in] val_coeff - Non-dimensional temperature polynomial coefficient for viscosity. * \param[in] val_index - Index of the array with all polynomial coefficients. */ void SetMu_PolyCoeffND(su2double val_coeff, unsigned short val_index); - + /*! * \brief Set the temperature polynomial coefficient for thermal conductivity. * \param[in] val_coeff - Non-dimensional temperature polynomial coefficient for thermal conductivity. * \param[in] val_index - Index of the array with all polynomial coefficients. */ void SetKt_PolyCoeffND(su2double val_coeff, unsigned short val_index); - + /*! * \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). */ unsigned short GetKind_Linear_Solver(void); - - + + /*! * \brief Get the kind of preconditioner for the implicit solver. * \return Numerical preconditioner for implicit formulation (solving the linear system). */ unsigned short GetKind_Linear_Solver_Prec(void); - + /*! * \brief Get the kind of solver for the implicit solver. * \return Numerical solver for implicit formulation (solving the linear system). */ unsigned short GetKind_Deform_Linear_Solver(void); - + /*! * \brief Set the kind of preconditioner for the implicit solver. * \return Numerical preconditioner for implicit formulation (solving the linear system). */ void SetKind_Deform_Linear_Solver_Prec(unsigned short val_kind_prec); - + /*! * \brief Set the kind of preconditioner for the implicit solver. * \return Numerical preconditioner for implicit formulation (solving the linear system). */ void SetKind_Linear_Solver_Prec(unsigned short val_kind_prec); - + /*! * \brief Get min error of the linear solver for the implicit formulation. * \return Min error of the linear solver for the implicit formulation. */ su2double GetLinear_Solver_Error(void); - + /*! * \brief Get min error of the linear solver for the implicit formulation. * \return Min error of the linear solver for the implicit formulation. */ su2double GetDeform_Linear_Solver_Error(void); - + /*! * \brief Get max number of iterations of the linear solver for the implicit formulation. * \return Max number of iterations of the linear solver for the implicit formulation. */ unsigned long GetLinear_Solver_Iter(void); - + /*! * \brief Get max number of iterations of the linear solver for the implicit formulation. * \return Max number of iterations of the linear solver for the implicit formulation. */ unsigned long GetDeform_Linear_Solver_Iter(void); - + /*! * \brief Get the ILU fill-in level for the linear solver. * \return Fill in level of the ILU preconditioner for the linear solver. @@ -3917,13 +3916,13 @@ class CConfig { * \return Restart frequency of the linear solver for the implicit formulation. */ unsigned long GetLinear_Solver_Restart_Frequency(void); - + /*! * \brief Get the relaxation factor for iterative linear smoothers. * \return Relaxation factor. */ 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. @@ -3935,79 +3934,79 @@ class CConfig { * \return relaxation coefficient of the CHT coupling. */ su2double GetRelaxation_Factor_CHT(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 GetRoe_Kappa(void); - + /*! * \brief Get the wing semi span. * \return value of the wing semi span. */ su2double GetSemiSpan(void); - + /*! * \brief Get the kind of solver for the implicit solver. * \return Numerical solver for implicit formulation (solving the linear system). */ unsigned short GetKind_AdjTurb_Linear_Solver(void); - + /*! * \brief Get the kind of preconditioner for the implicit solver. * \return Numerical preconditioner for implicit formulation (solving the linear system). */ unsigned short GetKind_AdjTurb_Linear_Prec(void); - + /*! * \brief Get the kind of solver for the implicit solver. * \return Numerical solver for implicit formulation (solving the linear system). */ unsigned short GetKind_DiscAdj_Linear_Solver(void); - + /*! * \brief Get the kind of preconditioner for the implicit solver. * \return Numerical preconditioner for implicit formulation (solving the linear system). */ unsigned short GetKind_DiscAdj_Linear_Prec(void); - + /*! * \brief Get the kind of preconditioner for the implicit solver. * \return Numerical preconditioner for implicit formulation (solving the linear system). */ unsigned short GetKind_Deform_Linear_Solver_Prec(void); - + /*! * \brief Set the kind of preconditioner for the implicit solver. * \return Numerical preconditioner for implicit formulation (solving the linear system). */ void SetKind_AdjTurb_Linear_Prec(unsigned short val_kind_prec); - + /*! * \brief Get min error of the linear solver for the implicit formulation. * \return Min error of the linear solver for the implicit formulation. */ su2double GetAdjTurb_Linear_Error(void); - + /*! * \brief Get the entropy fix. * \return Vaule of the entropy fix. */ su2double GetEntropyFix_Coeff(void); - + /*! * \brief Get max number of iterations of the linear solver for the implicit formulation. * \return Max number of iterations of the linear solver for the implicit formulation. */ unsigned short GetAdjTurb_Linear_Iter(void); - + /*! * \brief Get CFL reduction factor for adjoint turbulence model. * \return CFL reduction factor. */ su2double GetCFLRedCoeff_AdjTurb(void); - + /*! * \brief Get the number of nonlinear increments for mesh deformation. * \return Number of nonlinear increments for mesh deformation. @@ -4019,72 +4018,72 @@ class CConfig { * \return TRUE means that grid deformation is active. */ bool GetDeform_Mesh(void); - + /*! * \brief Get information about writing grid deformation residuals to the console. * \return TRUE means that grid deformation residuals will be written to the console. */ bool GetDeform_Output(void); - + /*! * \brief Get factor to multiply smallest volume for deform tolerance. * \return Factor to multiply smallest volume for deform tolerance. */ su2double GetDeform_Coeff(void); - + /*! * \brief Get limit for the volumetric deformation. * \return Distance to the surface to be deformed. */ su2double GetDeform_Limit(void); - + /*! * \brief Get Young's modulus for deformation (constant stiffness deformation) */ su2double GetDeform_ElasticityMod(void); - + /*! * \brief Get Poisson's ratio for deformation (constant stiffness deformation) * \ */ su2double GetDeform_PoissonRatio(void); - + /*! * \brief Get the type of stiffness to impose for FEA mesh deformation. * \return type of stiffness to impose for FEA mesh deformation. */ unsigned short GetDeform_Stiffness_Type(void); - + /*! * \brief Creates a tecplot file to visualize the volume deformation deformation made by the DEF software. * \return TRUE if the deformation is going to be plotted; otherwise FALSE. */ bool GetVisualize_Volume_Def(void); - + /*! * \brief Creates a teot file to visualize the surface deformation deformation made by the DEF software. * \return TRUE if the deformation is going to be plotted; otherwise FALSE. */ bool GetVisualize_Surface_Def(void); - + /*! * \brief Define the FFD box with a symetry plane. * \return TRUE if there is a symmetry plane in the FFD; otherwise FALSE. */ bool GetFFD_Symmetry_Plane(void); - + /*! * \brief Get the kind of SU2 software component. * \return Kind of the SU2 software component. */ unsigned short GetKind_SU2(void); - + /*! * \brief Get the kind of non-dimensionalization. * \return Kind of non-dimensionalization. */ unsigned short GetRef_NonDim(void); - + /*! * \brief Get the kind of incompressible non-dimensionalization. * \return Kind of incompressible non-dimensionalization. @@ -4096,13 +4095,13 @@ class CConfig { * \return Kind of the SU2 software component. */ void SetKind_SU2(unsigned short val_kind_su2); - + /*! * \brief Get the kind of the turbulence model. * \return Kind of the turbulence model. */ unsigned short GetKind_Turb_Model(void); - + /*! * \brief Get the kind of the transition model. * \return Kind of the transion model. @@ -4120,13 +4119,13 @@ class CConfig { * \return Kind of adaptation technique. */ unsigned short GetKind_Adaptation(void); - + /*! * \brief Get the number of new elements added in the adaptation process. * \return percentage of new elements that are going to be added in the adaptation. */ su2double GetNew_Elem_Adapt(void); - + /*! * \brief Get the kind of time integration method. * \note This is the information that the code will use, the method will @@ -4135,7 +4134,7 @@ class CConfig { * \return Kind of time integration method. */ unsigned short GetKind_TimeIntScheme(void); - + /*! * \brief Get the kind of convective numerical scheme. * \note This is the information that the code will use, the method will @@ -4144,7 +4143,7 @@ class CConfig { * \return Kind of the convective scheme. */ unsigned short GetKind_ConvNumScheme(void); - + /*! * \brief Get kind of center scheme for the convective terms. * \note This is the information that the code will use, the method will @@ -4153,7 +4152,7 @@ class CConfig { * \return Kind of center scheme for the convective terms. */ unsigned short GetKind_Centered(void); - + /*! * \brief Get kind of upwind scheme for the convective terms. * \note This is the information that the code will use, the method will @@ -4162,7 +4161,7 @@ class CConfig { * \return Kind of upwind scheme for the convective terms. */ unsigned short GetKind_Upwind(void); - + /*! * \brief Get if the upwind scheme used MUSCL or not. * \note This is the information that the code will use, the method will @@ -4171,7 +4170,7 @@ class CConfig { * \return MUSCL scheme. */ bool GetMUSCL(void); - + /*! * \brief Get if the upwind scheme used MUSCL or not. * \note This is the information that the code will use, the method will @@ -4180,7 +4179,7 @@ class CConfig { * \return MUSCL scheme. */ bool GetMUSCL_Flow(void); - + /*! * \brief Get if the upwind scheme used MUSCL or not. * \note This is the information that the code will use, the method will @@ -4198,7 +4197,7 @@ class CConfig { * \return MUSCL scheme. */ bool GetMUSCL_Turb(void); - + /*! * \brief Get if the upwind scheme used MUSCL or not. * \note This is the information that the code will use, the method will @@ -4207,7 +4206,7 @@ class CConfig { * \return MUSCL scheme. */ bool GetMUSCL_AdjFlow(void); - + /*! * \brief Get if the upwind scheme used MUSCL or not. * \note This is the information that the code will use, the method will @@ -4216,7 +4215,7 @@ class CConfig { * \return MUSCL scheme. */ bool GetMUSCL_AdjTurb(void); - + /*! * \brief Get whether to "Use Accurate Jacobians" for AUSM+up(2) and SLAU(2). * \return yes/no. @@ -4247,7 +4246,7 @@ class CConfig { * \return Kind of integration scheme for the plasma equations. */ unsigned short GetKind_TimeIntScheme_Heat(void); - + /*! * \brief Get the kind of time stepping * for the heat equation. @@ -4256,7 +4255,7 @@ class CConfig { * \return Kind of time stepping for the heat equation. */ unsigned short GetKind_TimeStep_Heat(void); - + /*! * \brief Get the kind of integration scheme (explicit or implicit) * for the flow equations. @@ -4265,7 +4264,7 @@ class CConfig { * \return Kind of integration scheme for the plasma equations. */ unsigned short GetKind_TimeIntScheme_FEA(void); - + /*! * \brief Get the kind of integration scheme (explicit or implicit) * for the template equations. @@ -4274,7 +4273,7 @@ class CConfig { * \return Kind of integration scheme for the plasma equations. */ unsigned short GetKind_TimeIntScheme_Template(void); - + /*! * \brief Get the kind of integration scheme (explicit or implicit) * for the flow equations. @@ -4283,7 +4282,7 @@ class CConfig { * \return Kind of integration scheme for the plasma equations. */ unsigned short GetKind_SpaceIteScheme_FEA(void); - + /*! * \brief Get the kind of convective numerical scheme for the flow * equations (centered or upwind). @@ -4310,7 +4309,7 @@ class CConfig { * \return Kind of convective numerical scheme for the flow equations. */ unsigned short GetKind_ConvNumScheme_Template(void); - + /*! * \brief Get the kind of center convective numerical scheme for the flow equations. * \note This value is obtained from the config file, and it is constant @@ -4318,7 +4317,7 @@ class CConfig { * \return Kind of center convective numerical scheme for the flow equations. */ unsigned short GetKind_Centered_Flow(void); - + /*! * \brief Get the kind of center convective numerical scheme for the plasma equations. * \note This value is obtained from the config file, and it is constant @@ -4326,7 +4325,7 @@ class CConfig { * \return Kind of center convective numerical scheme for the flow equations. */ unsigned short GetKind_Centered_Template(void); - + /*! * \brief Get the kind of upwind convective numerical scheme for the flow equations. * \note This value is obtained from the config file, and it is constant @@ -4364,44 +4363,44 @@ class CConfig { * \return Method for limiting the spatial gradients. */ unsigned short GetKind_SlopeLimit(void); - + /*! * \brief Get the method for limiting the spatial gradients. * \return Method for limiting the spatial gradients solving the flow equations. */ unsigned short GetKind_SlopeLimit_Flow(void); - + /*! * \brief Get the method for limiting the spatial gradients. * \return Method for limiting the spatial gradients solving the turbulent equation. */ unsigned short GetKind_SlopeLimit_Turb(void); - + /*! * \brief Get the method for limiting the spatial gradients. * \return Method for limiting the spatial gradients solving the adjoint turbulent equation. */ unsigned short GetKind_SlopeLimit_AdjTurb(void); - + /*! * \brief Get the method for limiting the spatial gradients. * \return Method for limiting the spatial gradients solving the adjoint flow equation. */ unsigned short GetKind_SlopeLimit_AdjFlow(void); - + /*! * \brief Value of the calibrated constant for the Lax method (center scheme). * \note This constant is used in coarse levels and with first order methods. * \return Calibrated constant for the Lax method. */ su2double GetKappa_1st_Flow(void); - + /*! * \brief Value of the calibrated constant for the JST method (center scheme). * \return Calibrated constant for the JST method for the flow equations. */ su2double GetKappa_2nd_Flow(void); - + /*! * \brief Value of the calibrated constant for the JST method (center scheme). * \return Calibrated constant for the JST method for the flow equations. @@ -4419,13 +4418,13 @@ class CConfig { * \return Calibrated constant for the JST-like method for the heat equation. */ su2double GetKappa_4th_Heat(void); - + /*! * \brief Factor by which to multiply the dissipation contribution to Jacobians of central schemes. * \return The factor. */ inline su2double GetCent_Jac_Fix_Factor(void) { return Cent_Jac_Fix_Factor; } - + /*! * \brief Get the kind of integration scheme (explicit or implicit) * for the adjoint flow equations. @@ -4434,7 +4433,7 @@ class CConfig { * \return Kind of integration scheme for the adjoint flow equations. */ unsigned short GetKind_TimeIntScheme_AdjFlow(void); - + /*! * \brief Get the kind of convective numerical scheme for the adjoint flow * equations (centered or upwind). @@ -4443,7 +4442,7 @@ class CConfig { * \return Kind of convective numerical scheme for the adjoint flow equations. */ unsigned short GetKind_ConvNumScheme_AdjFlow(void); - + /*! * \brief Get the kind of center convective numerical scheme for the adjoint flow equations. * \note This value is obtained from the config file, and it is constant @@ -4451,7 +4450,7 @@ class CConfig { * \return Kind of center convective numerical scheme for the adjoint flow equations. */ unsigned short GetKind_Centered_AdjFlow(void); - + /*! * \brief Get the kind of upwind convective numerical scheme for the adjoint flow equations. * \note This value is obtained from the config file, and it is constant @@ -4459,25 +4458,25 @@ class CConfig { * \return Kind of upwind convective numerical scheme for the adjoint flow equations. */ unsigned short GetKind_Upwind_AdjFlow(void); - + /*! * \brief Value of the calibrated constant for the high order method (center scheme). * \return Calibrated constant for the high order center method for the adjoint flow equations. */ su2double GetKappa_2nd_AdjFlow(void); - + /*! * \brief Value of the calibrated constant for the high order method (center scheme). * \return Calibrated constant for the high order center method for the adjoint flow equations. */ su2double GetKappa_4th_AdjFlow(void); - + /*! * \brief Value of the calibrated constant for the low order method (center scheme). * \return Calibrated constant for the low order center method for the adjoint flow equations. */ su2double GetKappa_1st_AdjFlow(void); - + /*! * \brief Get the kind of integration scheme (implicit) * for the turbulence equations. @@ -4486,7 +4485,7 @@ class CConfig { * \return Kind of integration scheme for the turbulence equations. */ unsigned short GetKind_TimeIntScheme_Turb(void); - + /*! * \brief Get the kind of convective numerical scheme for the turbulence * equations (upwind). @@ -4495,7 +4494,7 @@ class CConfig { * \return Kind of convective numerical scheme for the turbulence equations. */ unsigned short GetKind_ConvNumScheme_Turb(void); - + /*! * \brief Get the kind of center convective numerical scheme for the turbulence equations. * \note This value is obtained from the config file, and it is constant @@ -4503,7 +4502,7 @@ class CConfig { * \return Kind of center convective numerical scheme for the turbulence equations. */ unsigned short GetKind_Centered_Turb(void); - + /*! * \brief Get the kind of upwind convective numerical scheme for the turbulence equations. * \note This value is obtained from the config file, and it is constant @@ -4511,7 +4510,7 @@ class CConfig { * \return Kind of upwind convective numerical scheme for the turbulence equations. */ unsigned short GetKind_Upwind_Turb(void); - + /*! * \brief Get the kind of integration scheme (explicit or implicit) * for the adjoint turbulence equations. @@ -4520,7 +4519,7 @@ class CConfig { * \return Kind of integration scheme for the adjoint turbulence equations. */ unsigned short GetKind_TimeIntScheme_AdjTurb(void); - + /*! * \brief Get the kind of convective numerical scheme for the adjoint turbulence * equations (centered or upwind). @@ -4529,7 +4528,7 @@ class CConfig { * \return Kind of convective numerical scheme for the adjoint turbulence equations. */ unsigned short GetKind_ConvNumScheme_AdjTurb(void); - + /*! * \brief Get the kind of convective numerical scheme for the heat equation. * \note This value is obtained from the config file, and it is constant @@ -4545,7 +4544,7 @@ class CConfig { * \return Kind of center convective numerical scheme for the adjoint turbulence equations. */ unsigned short GetKind_Centered_AdjTurb(void); - + /*! * \brief Get the kind of upwind convective numerical scheme for the adjoint turbulence equations. * \note This value is obtained from the config file, and it is constant @@ -4553,21 +4552,21 @@ class CConfig { * \return Kind of upwind convective numerical scheme for the adjoint turbulence equations. */ unsigned short GetKind_Upwind_AdjTurb(void); - + /*! * \brief Provides information about the way in which the turbulence will be treated by the * cont. adjoint method. * \return FALSE means that the adjoint turbulence equations will be used. */ bool GetFrozen_Visc_Cont(void); - + /*! * \brief Provides information about the way in which the turbulence will be treated by the * disc. adjoint method. * \return FALSE means that the adjoint turbulence equations will be used. */ bool GetFrozen_Visc_Disc(void); - + /*! * \brief Provides information about using an inconsistent (primal/dual) discrete adjoint formulation * \return FALSE means that the adjoint use the same numerical methods than the primal problem. @@ -4580,19 +4579,19 @@ class CConfig { * \return FALSE means that the limiter computation is included. */ bool GetFrozen_Limiter_Disc(void); - + /*! * \brief Provides information about if the sharp edges are going to be removed from the sensitivity. * \return FALSE means that the sharp edges will be removed from the sensitivity. */ bool GetSens_Remove_Sharp(void); - + /*! * \brief Get the kind of inlet boundary condition treatment (total conditions or mass flow). * \return Kind of inlet boundary condition. */ unsigned short GetKind_Inlet(void); - + /*! * \brief Check if the inlet profile(s) are specified in an input file * \return True if an input file is to be used for the inlet profile(s) @@ -4610,7 +4609,7 @@ class CConfig { * \return Tolerance used for matching a point to a specified inlet */ su2double GetInlet_Profile_Matching_Tolerance(void); - + /*! * \brief Get the type of incompressible inlet from the list. * \return Kind of the incompressible inlet. @@ -4634,19 +4633,19 @@ class CConfig { * \return Kind of the incompressible outlet. */ unsigned short GetKind_Inc_Outlet(string val_marker); - + /*! * \brief Get the damping factor applied to velocity updates at incompressible pressure inlets. * \return Damping factor applied to velocity updates at incompressible pressure inlets. */ su2double GetInc_Inlet_Damping(void); - + /*! * \brief Get the damping factor applied to pressure updates at incompressible mass flow outlet. * \return Damping factor applied to pressure updates at incompressible mass flow outlet. */ su2double GetInc_Outlet_Damping(void); - + /*! * \brief Get the kind of mixing process for averaging quantities at the boundaries. * \return Kind of mixing process. @@ -4747,7 +4746,7 @@ class CConfig { * \return Kind of turbomachinery architecture. */ unsigned short GetKind_SpanWise(void); - + /*! * \brief Verify if there is mixing plane interface specified from config file. * \return boolean. @@ -4771,13 +4770,13 @@ class CConfig { * \return number of bound. */ unsigned short GetnMarker_MixingPlaneInterface(void); - + /*! * \brief Verify if there is Turbomachinery performance option specified from config file. * \return boolean. */ bool GetBoolTurbomachinery(void); - + /*! * \brief number Turbomachinery blades computed using the pitch information. * \return nBlades. @@ -4795,7 +4794,7 @@ class CConfig { * \return boolean. */ bool GetBoolGiles(void); - + /*! * \brief Verify if there is any Riemann Boundary Condition option specified from config file. * \return boolean. @@ -4848,7 +4847,7 @@ class CConfig { * \return number of max span-wise sections. */ unsigned short GetnSpanMaxAllZones(void); - + /*! * \brief set number span-wise sections to compute 3D BC and performance for turbomachinery. */ @@ -4869,62 +4868,62 @@ class CConfig { * \return name of the bound. */ string GetMarker_TurboPerf_BoundIn(unsigned short index); - + /*! * \brief get outlet bounds name for Turbomachinery performance calculation. * \return name of the bound. */ string GetMarker_TurboPerf_BoundOut(unsigned short index); - + /*! * \brief get marker kind for Turbomachinery performance calculation. * \return kind index. */ unsigned short GetKind_TurboPerf(unsigned short index); - + /*! * \brief get outlet bounds name for Turbomachinery performance calculation. * \return name of the bound. */ string GetMarker_PerBound(unsigned short val_marker); - + /*! * \brief Get the kind of inlet boundary condition treatment (total conditions or mass flow). * \return Kind of inlet boundary condition. */ unsigned short GetKind_Engine_Inflow(void); - + /*! * \brief Get the kind of inlet boundary condition treatment (total conditions or mass flow). * \return Kind of inlet boundary condition. */ unsigned short GetKind_ActDisk(void); - + /*! * \brief Get the number of sections. * \return Number of sections */ unsigned short GetnLocationStations(void); - + /*! * \brief Get the number of sections for computing internal volume. * \return Number of sections for computing internal volume. */ unsigned short GetnWingStations(void); - + /*! * \brief Get the location of the waterline. * \return Z location of the waterline. */ su2double GetGeo_Waterline_Location(void); - + /*! * \brief Provides information about the the nodes that are going to be moved on a deformation * volumetric grid deformation. * \return TRUE means that only the points on the FFD box will be moved. */ bool GetHold_GridFixed(void); - + /*! * \brief Get the kind of objective function. There are several options: Drag coefficient, * Lift coefficient, efficiency, etc. @@ -4932,7 +4931,7 @@ class CConfig { * \return Kind of objective function. */ unsigned short GetKind_ObjFunc(void); - + /*! * \author H. Kline * \brief Get the kind of objective function. There are several options: Drag coefficient, @@ -4941,7 +4940,7 @@ class CConfig { * \return Kind of objective function. */ unsigned short GetKind_ObjFunc(unsigned short val_obj); - + /*! * \author H. Kline * \brief Get the weight of objective function. There are several options: Drag coefficient, @@ -4950,7 +4949,7 @@ class CConfig { * \return Weight of objective function. */ su2double GetWeight_ObjFunc(unsigned short val_obj); - + /*! * \author H. Kline * \brief Set the weight of objective function. There are several options: Drag coefficient, @@ -4959,7 +4958,7 @@ class CConfig { * \return Weight of objective function. */ void SetWeight_ObjFunc(unsigned short val_obj, su2double val); - + /*! * \author H. Kline * \brief Get the coefficients of the objective defined by the chain rule with primitive variables. @@ -4968,19 +4967,19 @@ class CConfig { * Gradients are w.r.t density, velocity[3], and pressure. when 2D gradient w.r.t. 3rd component of velocity set to 0. */ su2double GetCoeff_ObjChainRule(unsigned short iVar); - + /*! * \author H. Kline * \brief Get the flag indicating whether to comput a combined objective. */ bool GetComboObj(void); - + /*! * \brief Get the kind of sensitivity smoothing technique. * \return Kind of sensitivity smoothing technique. */ unsigned short GetKind_SensSmooth(void); - + /*! * \brief Provides information about the time integration, and change the write in the output * files information about the iteration. @@ -4988,146 +4987,146 @@ class CConfig { * dual time stepping method (unsteady). */ unsigned short GetTime_Marching(void); - + /*! * \brief Provides the number of chemical reactions in the chemistry model * \return: The number of chemical reactions, read from input file */ unsigned short GetnReactions(void); - + /*! * \brief Provides the number of chemical reactions in the chemistry model * \return: The number of chemical reactions, read from input file */ su2double GetArrheniusCoeff(unsigned short iReaction); - + /*! * \brief Provides the number of chemical reactions in the chemistry model * \return: The number of chemical reactions, read from input file */ su2double GetArrheniusEta(unsigned short iReaction); - + /*! * \brief Provides the number of chemical reactions in the chemistry model * \return: The number of chemical reactions, read from input file */ su2double GetArrheniusTheta(unsigned short iReaction); - + /*! * \brief Provides the rate controlling temperature exponents for chemistry. * \return: Rate controlling temperature exponents. */ su2double* GetRxnTcf_a(void); - + /*! * \brief Provides the rate controlling temperature exponents for chemistry. * \return: Rate controlling temperature exponents. */ su2double* GetRxnTcf_b(void); - + /*! * \brief Provides the rate controlling temperature exponents for chemistry. * \return: Rate controlling temperature exponents. */ su2double* GetRxnTcb_a(void); - + /*! * \brief Provides the rate controlling temperature exponents for chemistry. * \return: Rate controlling temperature exponents. */ su2double* GetRxnTcb_b(void); - + /*! * \brief Dissociation potential of species. * \return: Dissociation potential. */ su2double* GetDissociationPot(void); - + /*! * \brief Provides the number of rotational modes of energy storage * \return: Vector of rotational mode count */ su2double* GetRotationModes(void); - + /*! * \brief Provides the characteristic vibrational temperature for calculating e_vib * \return: Vector of characteristic vibrational temperatures [K] */ su2double* GetCharVibTemp(void); - + /*! * \brief Provides the characteristic electronic temperature for calculating e_el * \return: Vector of characteristic vibrational temperatures [K] */ su2double** GetCharElTemp(void); - + /*! * \brief Provides the degeneracy of electron states for calculating e_el * \return: Vector of characteristic vibrational temperatures [K] */ su2double** GetElDegeneracy(void); - + /*! * \brief Provides number electron states for calculating e_el * \return: Vector of number of electron states for each species */ unsigned short* GetnElStates(void); - - + + /*! * \brief Provides the thermodynamic reference temperatures from the JANAF tables * \return: Vector of reference temperatures [K] */ su2double* GetRefTemperature(void); - + /*! * \brief Provides the characteristic vibrational temperature for calculating e_vib * \return: The number of chemical reactions, read from input file */ su2double GetCharVibTemp(unsigned short iSpecies); - + /*! * \brief Provides the molar mass of each species present in multi species fluid * \return: Vector of molar mass of each species in kg/kmol */ su2double* GetMolar_Mass(void); - + /*! * \brief Provides the molar mass of each species present in multi species fluid * \return: Mass of each species in Kg */ su2double GetMolar_Mass(unsigned short iSpecies); - + /*! * \brief Retrieves the number of monatomic species in the multicomponent gas. * \return: Number of monatomic species. */ unsigned short GetnMonatomics(void); - + /*! * \brief Retrieves the number of monatomic species in the multicomponent gas. * \return: Number of monatomic species. */ unsigned short GetnDiatomics(void); - + /*! * \brief Provides the molar mass of each species present in multi species fluid * \return: Molar mass of the specified gas consituent [kg/kmol] */ su2double GetInitial_Gas_Composition(unsigned short iSpecies); - + /*! * \brief Provides the formation enthalpy of the specified species at standard conditions * \return: Enthalpy of formation */ su2double* GetEnthalpy_Formation(void); - + /*! * \brief Provides the formation enthalpy of the specified species at standard conditions * \return: Enthalpy of formation */ su2double GetEnthalpy_Formation(unsigned short iSpecies); - + /*! * \brief Provides the restart information. * \return Restart information, if TRUE then the code will use the solution as restart. @@ -5151,72 +5150,72 @@ class CConfig { * \return Number of variables. */ unsigned short GetnVar(void); - + /*! * \brief Provides the number of varaibles. * \return Number of variables. */ unsigned short GetnZone(void); - + /*! * \brief Provides the number of varaibles. * \return Number of variables. */ unsigned short GetiZone(void); - + /*! * \brief For some problems like adjoint or the linearized equations it - * is necessary to restart the flow solution. + * is necessary to restart the flow solution. * \return Flow restart information, if TRUE then the code will restart the flow solution. */ - + bool GetRestart_Flow(void); - + /*! * \brief Indicates whether electron gas is present in the gas mixture. */ bool GetIonization(void); - + /*! * \brief Information about computing and plotting the equivalent area distribution. * \return TRUE or FALSE depending if we are computing the equivalent area. */ bool GetEquivArea(void); - + /*! * \brief Information about computing and plotting the equivalent area distribution. * \return TRUE or FALSE depending if we are computing the equivalent area. */ bool GetInvDesign_Cp(void); - + /*! * \brief Information about computing and plotting the equivalent area distribution. * \return TRUE or FALSE depending if we are computing the equivalent area. */ bool GetInvDesign_HeatFlux(void); - + /*! * \brief Get name of the input grid. * \return File name of the input grid. */ string GetMesh_FileName(void); - + /*! * \brief Get name of the output grid, this parameter is important for grid * adaptation and deformation. * \return File name of the output grid. */ string GetMesh_Out_FileName(void); - + /*! * \brief Get the name of the file with the solution of the flow problem. * \return Name of the file with the solution of the flow problem. */ string GetSolution_FileName(void); - + /*! * \brief Get the name of the file with the solution of the adjoint flow problem - * with drag objective function. + * with drag objective function. * \return Name of the file with the solution of the adjoint flow problem with * drag objective function. */ @@ -5227,25 +5226,25 @@ class CConfig { * \return Name of the file with the residual of the problem. */ string GetResidual_FileName(void); - + /*! * \brief Get the format of the input/output grid. * \return Format of the input/output grid. */ unsigned short GetMesh_FileFormat(void); - + /*! * \brief Get the format of the output solution. * \return Format of the output solution. */ unsigned short GetTabular_FileFormat(void); - + /*! * \brief Get the format of the output solution. * \return Format of the output solution. */ unsigned short GetActDisk_Jump(void); - + /*! * \brief Get the name of the file with the convergence history of the problem. * \return Name of the file with convergence history of the problem. @@ -5270,7 +5269,7 @@ class CConfig { * \return Name of the file with forces breakdown of the problem. */ string GetBreakdown_FileName(void); - + /*! * \brief Get the name of the file with the flow variables. * \return Name of the file with the primitive variables. @@ -5282,7 +5281,7 @@ class CConfig { * \return Name of the restart file for the flow variables. */ string GetRestart_HeatFileName(void); - + /*! * \brief Add any numbers necessary to the filename (iteration number, zone ID ...) * \param[in] config - Definition of the particular problem. @@ -5291,7 +5290,7 @@ class CConfig { * \return The new filename */ string GetFilename(string filename, string ext, unsigned long Iter); - + /*! * \brief Append the zone index to the restart or the solution files. * \return Name of the restart file for the flow variables. @@ -5303,7 +5302,7 @@ class CConfig { * \return Name of the restart file for the flow variables. */ string GetMultizone_HistoryFileName(string val_filename, int val_iZone, string ext); - + /*! * \brief Append the instance index to the restart or the solution files. * \return Name of the restart file for the flow variables. @@ -5321,7 +5320,7 @@ class CConfig { * \return Name of the restart file for the flow variables. */ string GetRestart_FileName(void); - + /*! * \brief Get the name of the restart file for the adjoint variables (drag objective function). * \return Name of the restart file for the adjoint variables (drag objective function). @@ -5333,43 +5332,43 @@ class CConfig { * \return Name of the file with the adjoint variables. */ string GetAdj_FileName(void); - + /*! * \brief Get the name of the file with the gradient of the objective function. * \return Name of the file with the gradient of the objective function. */ string GetObjFunc_Grad_FileName(void); - + /*! * \brief Get the name of the file with the gradient of the objective function. * \return Name of the file with the gradient of the objective function. */ string GetObjFunc_Value_FileName(void); - + /*! * \brief Get the name of the file with the surface information for the flow problem. * \return Name of the file with the surface information for the flow problem. */ string GetSurfCoeff_FileName(void); - + /*! * \brief Get the name of the file with the surface information for the adjoint problem. * \return Name of the file with the surface information for the adjoint problem. */ string GetSurfAdjCoeff_FileName(void); - + /*! * \brief Get the name of the file with the surface sensitivity (discrete adjoint). * \return Name of the file with the surface sensitivity (discrete adjoint). */ string GetSurfSens_FileName(void); - + /*! * \brief Get the name of the file with the volume sensitivity (discrete adjoint). * \return Name of the file with the volume sensitivity (discrete adjoint). */ string GetVolSens_FileName(void); - + /*! * \brief Augment the input filename with the iteration number for an unsteady file. * \param[in] val_filename - String value of the base filename. @@ -5377,122 +5376,122 @@ class CConfig { * \return Name of the file with the iteration number for an unsteady solution file. */ string GetUnsteady_FileName(string val_filename, int val_iter, string ext); - + /*! * \brief Append the input filename string with the appropriate objective function extension. * \param[in] val_filename - String value of the base filename. * \return Name of the file with the appropriate objective function extension. */ string GetObjFunc_Extension(string val_filename); - + /*! * \brief Get the criteria for structural residual (relative/absolute). * \return Relative/Absolute criteria for structural convergence. */ unsigned short GetResidual_Criteria_FEM(void); - + /*! * \brief Get functional that is going to be used to evaluate the residual flow convergence. * \return Functional that is going to be used to evaluate the residual flow convergence. */ unsigned short GetResidual_Func_Flow(void); - + /*! * \brief Get functional that is going to be used to evaluate the flow convergence. * \return Functional that is going to be used to evaluate the flow convergence. */ unsigned short GetCauchy_Func_Flow(void); - + /*! * \brief Get functional that is going to be used to evaluate the adjoint flow convergence. * \return Functional that is going to be used to evaluate the adjoint flow convergence. */ unsigned short GetCauchy_Func_AdjFlow(void); - + /*! * \brief Get the number of iterations that are considered in the Cauchy convergence criteria. * \return Number of elements in the Cauchy criteria. */ unsigned short GetCauchy_Elems(void); - + /*! * \brief Get the number of iterations that are not considered in the convergence criteria. * \return Number of iterations before starting with the convergence criteria. */ unsigned long GetStartConv_Iter(void); - + /*! * \brief Get the value of convergence criteria for the Cauchy method in the direct, * adjoint or linearized problem. * \return Value of the convergence criteria. */ su2double GetCauchy_Eps(void); - + /*! * \brief If we are prforming an unsteady simulation, there is only * one value of the time step for the complete simulation. * \return Value of the time step in an unsteady simulation (non dimensional). */ su2double GetDelta_UnstTimeND(void); - + /*! * \brief If we are prforming an unsteady simulation, there is only * one value of the time step for the complete simulation. * \return Value of the time step in an unsteady simulation (non dimensional). */ su2double GetTotal_UnstTimeND(void); - + /*! * \brief If we are prforming an unsteady simulation, there is only * one value of the time step for the complete simulation. * \return Value of the time step in an unsteady simulation. */ su2double GetDelta_UnstTime(void); - + /*! * \brief Set the value of the unsteadty time step using the CFL number. * \param[in] val_delta_unsttimend - Value of the unsteady time step using CFL number. */ void SetDelta_UnstTimeND(su2double val_delta_unsttimend); - + /*! * \brief If we are performing an unsteady simulation, this is the - * value of max physical time for which we run the simulation + * value of max physical time for which we run the simulation * \return Value of the physical time in an unsteady simulation. */ su2double GetTotal_UnstTime(void); - + /*! * \brief If we are performing an unsteady simulation, this is the - * value of current time. + * value of current time. * \return Value of the physical time in an unsteady simulation. */ su2double GetCurrent_UnstTime(void); - + /*! * \brief Divide the rectbles and hexahedron. * \return TRUE if the elements must be divided; otherwise FALSE. */ bool GetSubsonicEngine(void); - + /*! * \brief Actuator disk defined with a double surface. * \return TRUE if the elements must be divided; otherwise FALSE. */ bool GetActDisk_DoubleSurface(void); - + /*! * \brief Only halg of the engine is in the compputational grid. * \return TRUE if the engine is complete; otherwise FALSE. */ bool GetEngine_HalfModel(void); - + /*! * \brief Actuator disk defined with a double surface. * \return TRUE if the elements must be divided; otherwise FALSE. */ bool GetActDisk_SU2_DEF(void); - + /*! * \brief Value of the design variable step, we use this value in design problems. * \param[in] val_dv - Number of the design variable that we want to read. @@ -5500,14 +5499,14 @@ class CConfig { * \return Design variable step. */ su2double GetDV_Value(unsigned short val_dv, unsigned short val_val = 0); - + /*! * \brief Set the value of the design variable step, we use this value in design problems. * \param[in] val_dv - Number of the design variable that we want to read. * \param[in] val - Value of the design variable. */ void SetDV_Value(unsigned short val_dv, unsigned short val_ind, su2double val); - + /*! * \brief Get information about the grid movement. * \return TRUE if there is a grid movement; otherwise FALSE. @@ -5525,7 +5524,7 @@ class CConfig { * \return TRUE if there is a volumetric movement is required; otherwise FALSE. */ bool GetVolumetric_Movement(void); - + /*! * \brief Get information about deforming markers. * \param[in] kind_movement - Kind of surface movement. @@ -5540,84 +5539,84 @@ class CConfig { * \return TRUE at least one surface of kind_movement moving; otherwise FALSE. */ void SetSurface_Movement(unsigned short iMarker, unsigned short kind_movement); - + /*! * \brief Get the type of dynamic mesh motion. Each zone gets a config file. * \return Type of dynamic mesh motion. */ unsigned short GetKind_GridMovement(); - + /*! * \brief Set the type of dynamic mesh motion. * \param[in] val_iZone - Number for the current zone in the mesh (each zone has independent motion). * \param[in] motion_Type - Specify motion type. */ void SetKind_GridMovement(unsigned short motion_Type); - + /*! * \brief Get the type of surface motion. * \param[in] iMarkerMoving - Index of the moving marker (as specified in Marker_Moving). * \return Type of surface motion. */ unsigned short GetKind_SurfaceMovement(unsigned short iMarkerMoving); - + /*! * \brief Get the mach number based on the mesh velocity and freestream quantities. * \return Mach number based on the mesh velocity and freestream quantities. */ su2double GetMach_Motion(void); - + /*! * \brief Get the mesh motion origin. * \param[in] iDim - spatial component * \return The mesh motion origin. */ su2double GetMotion_Origin(unsigned short iDim); - + /*! * \brief Set the mesh motion origin. - * \param[in] val - new value of the origin + * \param[in] val - new value of the origin * \return The mesh motion origin. */ void SetMotion_Origin(su2double* val); - + /*! * \brief Get the mesh motion origin. - * \param[in] iMarkerMoving - Index of the moving marker (as specified in Marker_Moving) + * \param[in] iMarkerMoving - Index of the moving marker (as specified in Marker_Moving) * \param[in] iDim - spatial component * \return The motion origin of the marker. */ su2double GetMarkerMotion_Origin(unsigned short iMarkerMoving, unsigned short iDim); - + /*! * \brief Set the mesh motion origin. * \param[in] val - new value of the origin - * \param[in] iMarkerMoving - Index of the moving marker (as specified in Marker_Moving) + * \param[in] iMarkerMoving - Index of the moving marker (as specified in Marker_Moving) */ void SetMarkerMotion_Origin (su2double* val, unsigned short iMarkerMoving); - + /*! * \brief Get the translational velocity of the mesh. * \param[in] iDim - spatial component * \return Translational velocity of the mesh. */ su2double GetTranslation_Rate(unsigned short iDim); - + /*! * \brief Get the translational velocity of the marker. - * \param[in] iMarkerMoving - Index of the moving marker (as specified in Marker_Moving) - * \param[in] iDim - spatial component + * \param[in] iMarkerMoving - Index of the moving marker (as specified in Marker_Moving) + * \param[in] iDim - spatial component * \return Translational velocity of the marker. */ su2double GetMarkerTranslationRate(unsigned short iMarkerMoving, unsigned short iDim); - + /*! * \brief Get the rotation rate of the mesh. * \param[in] iDim - spatial component * \return Translational velocity of the mesh. */ su2double GetRotation_Rate(unsigned short iDim); - + /*! * \brief Get the rotation rate of the mesh. * \param[in] iDim - spatial component @@ -5625,40 +5624,40 @@ class CConfig { * \return Translational velocity of the mesh. */ void SetRotation_Rate(unsigned short iDim, su2double val); - + /*! * \brief Get the rotation rate of the marker. - * \param[in] iMarkerMoving - Index of the moving marker (as specified in Marker_Moving) - * \param[in] iDim - spatial component + * \param[in] iMarkerMoving - Index of the moving marker (as specified in Marker_Moving) + * \param[in] iDim - spatial component * \return Rotation velocity of the marker. */ su2double GetMarkerRotationRate(unsigned short iMarkerMoving, unsigned short iDim); - + /*! * \brief Get the pitching rate of the mesh. * \param[in] iDim - spatial component * \return Angular frequency of the mesh pitching. */ su2double GetPitching_Omega(unsigned short iDim); - + /*! * \brief Get pitching rate of the marker. - * \param[in] iMarkerMoving - Index of the moving marker (as specified in Marker_Moving) - * \param[in] iDim - spatial component + * \param[in] iMarkerMoving - Index of the moving marker (as specified in Marker_Moving) + * \param[in] iDim - spatial component * \return Angular frequency of the marker pitching. */ su2double GetMarkerPitching_Omega(unsigned short iMarkerMoving, unsigned short iDim); - + /*! * \brief Get the pitching amplitude of the mesh. - * \param[in] iDim - spatial component + * \param[in] iDim - spatial component * \return pitching amplitude of the mesh. */ su2double GetPitching_Ampl(unsigned short iDim); /*! * \brief Get pitching amplitude of the marker. - * \param[in] iMarkerMoving - Index of the moving marker (as specified in Marker_Moving) + * \param[in] iMarkerMoving - Index of the moving marker (as specified in Marker_Moving) * \param[in] iDim - spatial component * \return pitching amplitude of the marker. */ @@ -5670,7 +5669,7 @@ class CConfig { * \return pitching phase of the mesh. */ su2double GetPitching_Phase(unsigned short iDim); - + /*! * \brief Get pitching phase of the marker. * \param[in] iMarkerMoving - Index of the moving marker (as specified in Marker_Moving) \ @@ -5678,22 +5677,22 @@ class CConfig { * \return pitching phase of the marker. */ su2double GetMarkerPitching_Phase(unsigned short iMarkerMoving, unsigned short iDim); - + /*! * \brief Get the plunging rate of the mesh. * \param[in] iDim - spatial component * \return Angular frequency of the mesh plunging. */ su2double GetPlunging_Omega(unsigned short iDim); - + /*! * \brief Get plunging rate of the marker. - * \param[in] iMarkerMoving - Index of the moving marker (as specified in Marker_Moving) + * \param[in] iMarkerMoving - Index of the moving marker (as specified in Marker_Moving) * \param[in] iDim - spatial component * \return Angular frequency of the marker plunging. */ su2double GetMarkerPlunging_Omega(unsigned short iMarkerMoving, unsigned short iDim); - + /*! * \brief Get the plunging amplitude of the mesh. * \param[in] val_iZone - Number for the current zone in the mesh (each zone has independent motion). @@ -5701,88 +5700,88 @@ class CConfig { * \return Plunging amplitude of the mesh. */ su2double GetPlunging_Ampl(unsigned short iDim); - + /*! * \brief Get plunging amplitude of the marker. - * \param[in] iMarkerMoving - Index of the moving marker (as specified in Marker_Moving) + * \param[in] iMarkerMoving - Index of the moving marker (as specified in Marker_Moving) * \param[in] iDim - spatial component * \return Plunging amplitude of the marker. */ su2double GetMarkerPlunging_Ampl(unsigned short iMarkerMoving, unsigned short iDim); - + /*! * \brief Get the angular velocity of the mesh about the z-axis. * \return Angular velocity of the mesh about the z-axis. */ su2double GetFinalRotation_Rate_Z(); - + /*! * \brief Set the angular velocity of the mesh about the z-axis. * \param[in] newRotation_Rate_Z - new rotation rate after computing the ramp value. */ void SetRotation_Rate_Z(su2double newRotation_Rate_Z); - + /*! * \brief Get the Harmonic Balance frequency pointer. * \return Harmonic Balance Frequency pointer. */ su2double* GetOmega_HB(void); - + /*! * \brief Get if harmonic balance source term is to be preconditioned * \return yes or no to harmonic balance preconditioning */ bool GetHB_Precondition(void); - + /*! * \brief Get if we should update the motion origin. * \param[in] val_marker - Value of the marker in which we are interested. * \return yes or no to update motion origin. */ unsigned short GetMoveMotion_Origin(unsigned short val_marker); - + /*! * \brief Get the minimum value of Beta for Roe-Turkel preconditioner * \return the minimum value of Beta for Roe-Turkel preconditioner */ su2double GetminTurkelBeta(); - + /*! * \brief Get the minimum value of Beta for Roe-Turkel preconditioner * \return the minimum value of Beta for Roe-Turkel preconditioner */ su2double GetmaxTurkelBeta(); - + /*! * \brief Get information about the adibatic wall condition * \return TRUE if it is a adiabatic wall condition; otherwise FALSE. */ bool GetAdiabaticWall(void); - + /*! * \brief Get information about the isothermal wall condition * \return TRUE if it is a isothermal wall condition; otherwise FALSE. */ bool GetIsothermalWall(void); - + /*! * \brief Get information about the Low Mach Preconditioning * \return TRUE if we are using low Mach preconditioner; otherwise FALSE. */ bool Low_Mach_Preconditioning(void); - + /*! * \brief Get information about the Low Mach Correction * \return TRUE if we are using low Mach correction; otherwise FALSE. */ bool Low_Mach_Correction(void); - + /*! * \brief Get information about the poisson solver condition * \return TRUE if it is a poisson solver condition; otherwise FALSE. */ bool GetPoissonSolver(void); - + /*! * \brief Get information about the gravity force. * \return TRUE if it uses the gravity force; otherwise FALSE. @@ -5806,130 +5805,130 @@ class CConfig { * \return TRUE if there is a rotational frame; otherwise FALSE. */ bool GetRotating_Frame(void); - + /*! * \brief Get information about the axisymmetric frame. * \return TRUE if there is a rotational frame; otherwise FALSE. */ bool GetAxisymmetric(void); - + /*! * \brief Get information about the axisymmetric frame. * \return TRUE if there is a rotational frame; otherwise FALSE. */ bool GetDebugMode(void); - + /*! * \brief Get information about there is a smoothing of the grid coordinates. * \return TRUE if there is smoothing of the grid coordinates; otherwise FALSE. */ bool GetAdaptBoundary(void); - + /*! * \brief Get information about there is a smoothing of the grid coordinates. * \return TRUE if there is smoothing of the grid coordinates; otherwise FALSE. */ bool GetSmoothNumGrid(void); - + /*! * \brief Set information about there is a smoothing of the grid coordinates. * \param[in] val_smoothnumgrid - TRUE if there is smoothing of the grid coordinates; otherwise FALSE. */ void SetSmoothNumGrid(bool val_smoothnumgrid); - + /*! * \brief Subtract one to the index of the finest grid (full multigrid strategy). * \return Change the index of the finest grid. */ void SubtractFinestMesh(void); - + /*! * \brief Obtain the kind of design variable. * \param[in] val_dv - Number of the design variable that we want to read. * \return Design variable identification. */ unsigned short GetDesign_Variable(unsigned short val_dv); - + /*! * \brief Provides the buffet monitoring information. * \return Buffet monitoring information, if TRUE then the code will compute the buffet sensor. */ bool GetBuffet_Monitoring(void); - + /*! * \brief Get the buffet sensor sharpness coefficient. * \return Sharpness coefficient for buffet sensor. */ su2double GetBuffet_k(void); - + /*! * \brief Get the buffet sensor offset parameter. * \return Offset parameter for buffet sensor. */ su2double GetBuffet_lambda(void); - + /*! * \brief Obtain the kind of convergence criteria to establish the convergence of the CFD code. * \return Kind of convergence criteria. */ unsigned short GetConvCriteria(void); - + /*! * \brief Get the index in the config information of the marker val_marker. * \note When we read the config file, it stores the markers in a particular vector. * \return Index in the config information of the marker val_marker. */ unsigned short GetMarker_CfgFile_TagBound(string val_marker); - + /*! * \brief Get the name in the config information of the marker number val_marker. * \note When we read the config file, it stores the markers in a particular vector. * \return Name of the marker in the config information of the marker val_marker. */ string GetMarker_CfgFile_TagBound(unsigned short val_marker); - + /*! * \brief Get the boundary information (kind of boundary) in the config information of the marker val_marker. * \return Kind of boundary in the config information of the marker val_marker. */ unsigned short GetMarker_CfgFile_KindBC(string val_marker); - + /*! * \brief Get the monitoring information from the config definition for the marker val_marker. * \return Monitoring information of the boundary in the config information for the marker val_marker. */ unsigned short GetMarker_CfgFile_Monitoring(string val_marker); - + /*! * \brief Get the monitoring information from the config definition for the marker val_marker. * \return Monitoring information of the boundary in the config information for the marker val_marker. */ unsigned short GetMarker_CfgFile_GeoEval(string val_marker); - + /*! * \brief Get the monitoring information from the config definition for the marker val_marker. * \return Monitoring information of the boundary in the config information for the marker val_marker. */ unsigned short GetMarker_CfgFile_Designing(string val_marker); - + /*! * \brief Get the plotting information from the config definition for the marker val_marker. * \return Plotting information of the boundary in the config information for the marker val_marker. */ unsigned short GetMarker_CfgFile_Plotting(string val_marker); - + /*! * \brief Get the plotting information from the config definition for the marker val_marker. * \return Plotting information of the boundary in the config information for the marker val_marker. */ unsigned short GetMarker_CfgFile_Analyze(string val_marker); - + /*! * \brief Get the FSI interface information from the config definition for the marker val_marker. * \return Plotting information of the boundary in the config information for the marker val_marker. */ unsigned short GetMarker_CfgFile_ZoneInterface(string val_marker); - + /*! * \brief Get the TurboPerformance information from the config definition for the marker val_marker. * \return TurboPerformance information of the boundary in the config information for the marker val_marker. @@ -5947,13 +5946,13 @@ class CConfig { * \return Plotting information of the boundary in the config information for the marker val_marker. */ unsigned short GetMarker_CfgFile_MixingPlaneInterface(string val_marker); - + /*! * \brief Get the DV information from the config definition for the marker val_marker. * \return DV information of the boundary in the config information for the marker val_marker. */ unsigned short GetMarker_CfgFile_DV(string val_marker); - + /*! * \brief Get the motion information from the config definition for the marker val_marker. * \return Motion information of the boundary in the config information for the marker val_marker. @@ -5977,19 +5976,19 @@ class CConfig { * \return Python customization information of the boundary in the config information for the marker val_marker. */ unsigned short GetMarker_CfgFile_PyCustom(string val_marker); - + /*! * \brief Get the periodic information from the config definition of the marker val_marker. * \return Periodic information of the boundary in the config information of the marker val_marker. */ unsigned short GetMarker_CfgFile_PerBound(string val_marker); - + /*! * \brief Get the name of the marker val_marker. * \return The interface which owns that marker val_marker. */ int GetMarker_ZoneInterface(string val_marker); - + /*! * \brief Get the name of the marker val_iMarker. * \return The name of the marker in the interface @@ -6002,14 +6001,14 @@ class CConfig { */ unsigned short GetnMarker_ZoneInterface(void); - + /*! * \brief Determines whether a marker with index iMarker is a solid boundary. * \param iMarker * \return it marker with index iMarker is a solid boundary. */ bool GetSolid_Wall(unsigned short iMarker); - + /*! * \brief Determines whether a marker with index iMarker is a viscous no-slip boundary. * \param iMarker @@ -6022,196 +6021,196 @@ class CConfig { * \return true if Adjoint */ bool GetContinuous_Adjoint(void); - + /*! * \brief Determines if problem is viscous * \return true if Viscous */ bool GetViscous(void); - + /*! * \brief Provides the index of the solution in the container. * \param[in] val_eqsystem - Equation that is being solved. * \return Index on the solution container. */ unsigned short GetContainerPosition(unsigned short val_eqsystem); - + /*! * \brief Value of the minimum residual value (log10 scale). * \return Value of the minimum residual value (log10 scale). */ su2double GetMinLogResidual(void); - + /*! * \brief Value of the damping factor for the engine inlet bc. * \return Value of the damping factor. */ su2double GetDamp_Engine_Inflow(void); - + /*! * \brief Value of the damping factor for the engine exhaust inlet bc. * \return Value of the damping factor. */ su2double GetDamp_Engine_Exhaust(void); - + /*! * \brief Value of the damping factor for the residual restriction. * \return Value of the damping factor. */ su2double GetDamp_Res_Restric(void); - + /*! * \brief Value of the damping factor for the correction prolongation. * \return Value of the damping factor. */ su2double GetDamp_Correc_Prolong(void); - + /*! * \brief Value of the position of the Near Field (y coordinate for 2D, and z coordinate for 3D). * \return Value of the Near Field position. */ su2double GetPosition_Plane(void); - + /*! * \brief Value of the weight of the drag coefficient in the Sonic Boom optimization. * \return Value of the weight of the drag coefficient in the Sonic Boom optimization. */ su2double GetWeightCd(void); - + /*! * \brief Value of the weight of the CD, CL, CM optimization. * \return Value of the weight of the CD, CL, CM optimization. */ void SetdNetThrust_dBCThrust(su2double val_dnetthrust_dbcthrust); - + /*! * \brief Value of the azimuthal line to fix due to a misalignments of the nearfield. * \return Azimuthal line to fix due to a misalignments of the nearfield. */ su2double GetFixAzimuthalLine(void); - + /*! * \brief Value of the weight of the CD, CL, CM optimization. * \return Value of the weight of the CD, CL, CM optimization. */ su2double GetdCD_dCMy(void); - + /*! * \brief Value of the weight of the CD, CL, CM optimization. * \return Value of the weight of the CD, CL, CM optimization. */ su2double GetCM_Target(void); - + /*! * \brief Value of the weight of the CD, CL, CM optimization. * \return Value of the weight of the CD, CL, CM optimization. */ su2double GetdCD_dCL(void); - + /*! * \brief Value of the weight of the CD, CL, CM optimization. * \return Value of the weight of the CD, CL, CM optimization. */ void SetdCD_dCL(su2double val_dcd_dcl); - + /*! * \brief Value of the weight of the CD, CL, CM optimization. * \return Value of the weight of the CD, CL, CM optimization. */ su2double GetdCMx_dCL(void); - + /*! * \brief Value of the weight of the CD, CL, CM optimization. * \return Value of the weight of the CD, CL, CM optimization. */ void SetdCMx_dCL(su2double val_dcmx_dcl); - + /*! * \brief Value of the weight of the CD, CL, CM optimization. * \return Value of the weight of the CD, CL, CM optimization. */ su2double GetdCMy_dCL(void); - + /*! * \brief Value of the weight of the CD, CL, CM optimization. * \return Value of the weight of the CD, CL, CM optimization. */ void SetdCMy_dCL(su2double val_dcmy_dcl); - + /*! * \brief Value of the weight of the CD, CL, CM optimization. * \return Value of the weight of the CD, CL, CM optimization. */ su2double GetdCMz_dCL(void); - + /*! * \brief Value of the weight of the CD, CL, CM optimization. * \return Value of the weight of the CD, CL, CM optimization. */ void SetdCMz_dCL(su2double val_dcmz_dcl); - + /*! * \brief Value of the weight of the CD, CL, CM optimization. * \return Value of the weight of the CD, CL, CM optimization. */ void SetdCL_dAlpha(su2double val_dcl_dalpha); - + /*! * \brief Value of the weight of the CD, CL, CM optimization. * \return Value of the weight of the CD, CL, CM optimization. */ void SetdCM_diH(su2double val_dcm_dhi); - + /*! * \brief Value of the weight of the CD, CL, CM optimization. * \return Value of the weight of the CD, CL, CM optimization. */ void SetdCD_dCMy(su2double val_dcd_dcmy); - + /*! * \brief Value of the weight of the CD, CL, CM optimization. * \return Value of the weight of the CD, CL, CM optimization. */ su2double GetCL_Target(void); - + /*! * \brief Set the global parameters of each simulation for each runtime system. * \param[in] val_solver - Solver of the simulation. * \param[in] val_system - Runtime system that we are solving. */ void SetGlobalParam(unsigned short val_solver, unsigned short val_system); - + /*! * \brief Center of rotation for a rotational periodic boundary. */ su2double *GetPeriodicRotCenter(string val_marker); - + /*! * \brief Angles of rotation for a rotational periodic boundary. */ su2double *GetPeriodicRotAngles(string val_marker); - + /*! * \brief Translation vector for a rotational periodic boundary. */ su2double *GetPeriodicTranslation(string val_marker); - + /*! * \brief Get the rotationally periodic donor marker for boundary val_marker. * \return Periodic donor marker from the config information for the marker val_marker. */ unsigned short GetMarker_Periodic_Donor(string val_marker); - + /*! * \brief Get the origin of the actuator disk. */ su2double GetActDisk_NetThrust(string val_marker); - + /*! * \brief Get the origin of the actuator disk. */ su2double GetActDisk_Power(string val_marker); - + /*! * \brief Get the origin of the actuator disk. */ @@ -6224,54 +6223,54 @@ class CConfig { * \brief Get the origin of the actuator disk. */ su2double GetActDisk_Force(string val_marker); - + /*! * \brief Get the origin of the actuator disk. */ su2double GetActDisk_BCThrust(string val_marker); - + /*! * \brief Get the origin of the actuator disk. */ su2double GetActDisk_BCThrust_Old(string val_marker); - + /*! * \brief Get the tip radius of th actuator disk. */ su2double GetActDisk_Area(string val_marker); - + /*! * \brief Get the tip radius of th actuator disk. */ su2double GetActDisk_ReverseMassFlow(string val_marker); - + /*! * \brief Get the thrust corffient of the actuator disk. */ su2double GetActDisk_PressJump(string val_marker, unsigned short val_index); - + /*! * \brief Get the thrust corffient of the actuator disk. */ su2double GetActDisk_TempJump(string val_marker, unsigned short val_index); - + /*! * \brief Get the rev / min of the actuator disk. */ su2double GetActDisk_Omega(string val_marker, unsigned short val_index); - + /*! * \brief Get Actuator Disk Outlet for boundary val_marker (actuator disk inlet). * \return Actuator Disk Outlet from the config information for the marker val_marker. */ unsigned short GetMarker_CfgFile_ActDiskOutlet(string val_marker); - + /*! * \brief Get Actuator Disk Outlet for boundary val_marker (actuator disk inlet). * \return Actuator Disk Outlet from the config information for the marker val_marker. */ unsigned short GetMarker_CfgFile_EngineExhaust(string val_marker); - + /*! * \brief Get the internal index for a moving boundary val_marker. * \return Internal index for a moving boundary val_marker. @@ -6328,7 +6327,7 @@ class CConfig { * has the marker val_marker. */ string GetMarker_PyCustom_TagBound(unsigned short val_marker); - + /*! * \brief Get the name of the surface defined in the geometry file. * \param[in] val_marker - Value of the marker in which we are interested. @@ -6336,35 +6335,35 @@ class CConfig { * has the marker val_marker. */ string GetMarker_Analyze_TagBound(unsigned short val_marker); - + /*! * \brief Get the total temperature at a nacelle boundary. * \param[in] val_index - Index corresponding to the inlet boundary. * \return The total temperature. */ su2double GetExhaust_Temperature_Target(string val_index); - + /*! * \brief Get the total temperature at an inlet boundary. * \param[in] val_index - Index corresponding to the inlet boundary. * \return The total temperature. */ su2double GetInlet_Ttotal(string val_index); - + /*! * \brief Get the temperature at a supersonic inlet boundary. * \param[in] val_index - Index corresponding to the inlet boundary. * \return The inlet density. */ su2double GetInlet_Temperature(string val_index); - + /*! * \brief Get the pressure at a supersonic inlet boundary. * \param[in] val_index - Index corresponding to the inlet boundary. * \return The inlet pressure. */ su2double GetInlet_Pressure(string val_index); - + /*! * \brief Get the velocity vector at a supersonic inlet boundary. * \param[in] val_index - Index corresponding to the inlet boundary. @@ -6392,20 +6391,20 @@ class CConfig { * \return The total pressure. */ su2double GetExhaust_Pressure_Target(string val_index); - + /*! * \brief Value of the CFL reduction in LevelSet problems. * \return Value of the CFL reduction in LevelSet problems. */ su2double GetCFLRedCoeff_Turb(void); - + /*! * \brief Get the flow direction unit vector at an inlet boundary. * \param[in] val_index - Index corresponding to the inlet boundary. * \return The flow direction vector. */ su2double* GetInlet_FlowDir(string val_index); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. @@ -6426,56 +6425,56 @@ class CConfig { * \return The var1 */ su2double GetRiemann_Var1(string val_marker); - + /*! * \brief Get the var 2 at Riemann boundary. * \param[in] val_marker - Index corresponding to the Riemann boundary. * \return The var2 */ su2double GetRiemann_Var2(string val_marker); - + /*! * \brief Get the Flowdir at Riemann boundary. * \param[in] val_marker - Index corresponding to the Riemann boundary. * \return The Flowdir */ su2double* GetRiemann_FlowDir(string val_marker); - + /*! * \brief Get Kind Data of Riemann boundary. * \param[in] val_marker - Index corresponding to the Riemann boundary. * \return Kind data */ unsigned short GetKind_Data_Riemann(string val_marker); - + /*! * \brief Get the var 1 for the Giels BC. * \param[in] val_marker - Index corresponding to the Giles BC. * \return The var1 */ su2double GetGiles_Var1(string val_marker); - + /*! * \brief Get the var 2 for the Giles boundary. * \param[in] val_marker - Index corresponding to the Giles BC. * \return The var2 */ su2double GetGiles_Var2(string val_marker); - + /*! * \brief Get the Flowdir for the Giles BC. * \param[in] val_marker - Index corresponding to the Giles BC. * \return The Flowdir */ su2double* GetGiles_FlowDir(string val_marker); - + /*! * \brief Get Kind Data for the Giles BC. * \param[in] val_marker - Index corresponding to the Giles BC. * \return Kind data */ unsigned short GetKind_Data_Giles(string val_marker); - + /*! * \brief Set the var 1 for Giles BC. * \param[in] val_marker - Index corresponding to the Giles BC. @@ -6574,7 +6573,7 @@ class CConfig { * \return The wall temperature. */ su2double GetIsothermal_Temperature(string val_index); - + /*! * \brief Get the wall heat flux on a constant heat flux boundary. * \param[in] val_index - Index corresponding to the constant heat flux boundary. @@ -6604,666 +6603,666 @@ class CConfig { * \return Pointer to the double info for the given marker. */ su2double* GetWallFunction_DoubleInfo(string val_marker); - + /*! * \brief Get the target (pressure, massflow, etc) at an engine inflow boundary. * \param[in] val_index - Index corresponding to the engine inflow boundary. * \return Target (pressure, massflow, etc) . */ su2double GetEngineInflow_Target(string val_marker); - + /*! * \brief Get the fan face Mach number at an engine inflow boundary. * \param[in] val_marker - Name of the boundary. * \return The fan face Mach number. */ su2double GetInflow_Mach(string val_marker); - + /*! * \brief Get the back pressure (static) at an engine inflow boundary. * \param[in] val_marker - Name of the boundary. * \return The engine inflow pressure. */ su2double GetInflow_Pressure(string val_marker); - + /*! * \brief Get the mass flow rate at an engine inflow boundary. * \param[in] val_marker - Name of the boundary. * \return The engine mass flow rate. */ su2double GetInflow_MassFlow(string val_marker); - + /*! * \brief Get the percentage of reverse flow at an engine inflow boundary. * \param[in] val_marker - Name of the boundary. * \return The percentage of reverse flow. */ su2double GetInflow_ReverseMassFlow(string val_marker); - + /*! * \brief Get the percentage of reverse flow at an engine inflow boundary. * \param[in] val_index - Index corresponding to the engine inflow boundary. * \return The percentage of reverse flow. */ su2double GetInflow_ReverseMassFlow(unsigned short val_marker); - + /*! * \brief Get the total pressure at an engine inflow boundary. * \param[in] val_marker - Name of the boundary. * \return The total pressure. */ su2double GetInflow_TotalPressure(string val_marker); - + /*! * \brief Get the temperature (static) at an engine inflow boundary. * \param[in] val_marker - Name of the boundary. * \return The engine inflow temperature. */ su2double GetInflow_Temperature(string val_marker); - + /*! * \brief Get the total temperature at an engine inflow boundary. * \param[in] val_marker - Name of the boundary. * \return The engine inflow total temperature. */ su2double GetInflow_TotalTemperature(string val_marker); - + /*! * \brief Get the ram drag at an engine inflow boundary. * \param[in] val_marker - Name of the boundary. * \return The engine inflow ram drag. */ su2double GetInflow_RamDrag(string val_marker); - + /*! * \brief Get the force balance at an engine inflow boundary. * \param[in] val_marker - Name of the boundary. * \return The engine inflow force balance. */ su2double GetInflow_Force(string val_marker); - + /*! * \brief Get the power at an engine inflow boundary. * \param[in] val_marker - Name of the boundary. * \return The engine inflow power. */ su2double GetInflow_Power(string val_marker); - + /*! * \brief Get the back pressure (static) at an engine exhaust boundary. * \param[in] val_marker - Name of the boundary. * \return The engine exhaust pressure. */ su2double GetExhaust_Pressure(string val_marker); - + /*! * \brief Get the temperature (static) at an engine exhaust boundary. * \param[in] val_marker - Name of the boundary. * \return The engine exhaust temperature. */ su2double GetExhaust_Temperature(string val_marker); - + /*! * \brief Get the massflow at an engine exhaust boundary. * \param[in] val_marker - Name of the boundary. * \return The engine exhaust massflow. */ su2double GetExhaust_MassFlow(string val_marker); - + /*! * \brief Get the total pressure at an engine exhaust boundary. * \param[in] val_marker - Name of the boundary. * \return The engine exhaust total pressure. */ su2double GetExhaust_TotalPressure(string val_marker); - + /*! * \brief Get the total temperature at an engine exhaust boundary. * \param[in] val_marker - Name of the boundary. * \return The total temperature. */ su2double GetExhaust_TotalTemperature(string val_marker); - + /*! * \brief Get the gross thrust at an engine exhaust boundary. * \param[in] val_marker - Name of the boundary. * \return Gross thrust. */ su2double GetExhaust_GrossThrust(string val_marker); - + /*! * \brief Get the force balance at an engine exhaust boundary. * \param[in] val_marker - Name of the boundary. * \return Force balance. */ su2double GetExhaust_Force(string val_marker); - + /*! * \brief Get the power at an engine exhaust boundary. * \param[in] val_marker - Name of the boundary. * \return Power. */ su2double GetExhaust_Power(string val_marker); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ void SetInflow_Mach(unsigned short val_imarker, su2double val_fanface_mach); - + /*! * \brief Set the fan face static pressure at an engine inflow boundary. * \param[in] val_index - Index corresponding to the engine inflow boundary. * \param[in] val_fanface_pressure - Fan face static pressure. */ void SetInflow_Pressure(unsigned short val_imarker, su2double val_fanface_pressure); - + /*! * \brief Set the massflow at an engine inflow boundary. * \param[in] val_index - Index corresponding to the engine inflow boundary. * \param[in] val_fanface_massflow - Massflow. */ void SetInflow_MassFlow(unsigned short val_imarker, su2double val_fanface_massflow); - + /*! * \brief Set the reverse flow at an engine inflow boundary. * \param[in] val_index - Index corresponding to the engine inflow boundary. * \param[in] val_fanface_reversemassflow - reverse flow. */ void SetInflow_ReverseMassFlow(unsigned short val_imarker, su2double val_fanface_reversemassflow); - + /*! * \brief Set the fan face total pressure at an engine inflow boundary. * \param[in] val_index - Index corresponding to the engine inflow boundary. * \param[in] val_fanface_totalpressure - Fan face total pressure. */ void SetInflow_TotalPressure(unsigned short val_imarker, su2double val_fanface_totalpressure); - + /*! * \brief Set the fan face static temperature at an engine inflow boundary. * \param[in] val_index - Index corresponding to the engine inflow boundary. * \param[in] val_fanface_pressure - Fan face static temperature. */ void SetInflow_Temperature(unsigned short val_imarker, su2double val_fanface_temperature); - + /*! * \brief Set the fan face total temperature at an engine inflow boundary. * \param[in] val_index - Index corresponding to the engine inflow boundary. * \param[in] val_fanface_totaltemperature - Fan face total temperature. */ void SetInflow_TotalTemperature(unsigned short val_imarker, su2double val_fanface_totaltemperature); - + /*! * \brief Set the ram drag temperature at an engine inflow boundary. * \param[in] val_index - Index corresponding to the engine inflow boundary. * \param[in] val_fanface_ramdrag - Ram drag value. */ void SetInflow_RamDrag(unsigned short val_imarker, su2double val_fanface_ramdrag); - + /*! * \brief Set the force balance at an engine inflow boundary. * \param[in] val_index - Index corresponding to the engine inflow boundary. * \param[in] val_fanface_force - Fan face force. */ void SetInflow_Force(unsigned short val_imarker, su2double val_fanface_force); - + /*! * \brief Set the power at an engine inflow boundary. * \param[in] val_index - Index corresponding to the engine inflow boundary. * \param[in] val_fanface_force - Power. */ void SetInflow_Power(unsigned short val_imarker, su2double val_fanface_power); - + /*! * \brief Set the back pressure (static) at an engine exhaust boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \param[in] val_exhaust_pressure - Exhaust static pressure. */ void SetExhaust_Pressure(unsigned short val_imarker, su2double val_exhaust_pressure); - + /*! * \brief Set the temperature (static) at an engine exhaust boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \param[in] val_exhaust_temp - Exhaust static temperature. */ void SetExhaust_Temperature(unsigned short val_imarker, su2double val_exhaust_temp); - + /*! * \brief Set the back pressure (static) at an engine exhaust boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \param[in] val_exhaust_temp - Exhaust static temperature. */ void SetExhaust_MassFlow(unsigned short val_imarker, su2double val_exhaust_massflow); - + /*! * \brief Set the back pressure (total) at an engine exhaust boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \param[in] val_exhaust_totalpressure - Exhaust total pressure. */ void SetExhaust_TotalPressure(unsigned short val_imarker, su2double val_exhaust_totalpressure); - + /*! * \brief Set the total temperature at an engine exhaust boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \param[in] val_exhaust_totaltemp - Exhaust total temperature. */ void SetExhaust_TotalTemperature(unsigned short val_imarker, su2double val_exhaust_totaltemp); - + /*! * \brief Set the gross thrust at an engine exhaust boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \param[in] val_exhaust_grossthrust - Exhaust gross thrust temperature. */ void SetExhaust_GrossThrust(unsigned short val_imarker, su2double val_exhaust_grossthrust); - + /*! * \brief Set the force balance at an engine exhaust boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \param[in] val_exhaust_force - Exhaust force balance. */ void SetExhaust_Force(unsigned short val_imarker, su2double val_exhaust_force); - + /*! * \brief Set the power at an engine exhaust boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \param[in] val_exhaust_power - Exhaust power. */ void SetExhaust_Power(unsigned short val_imarker, su2double val_exhaust_power); - + /*! * \brief Set the back pressure (static) at an outlet boundary. * \param[in] val_imarker - Index corresponding to a particular engine boundary. * \param[in] val_engine_mach - Exhaust power. */ void SetEngine_Mach(unsigned short val_imarker, su2double val_engine_mach); - + /*! * \brief Set the back pressure (static) at an outlet boundary. * \param[in] val_imarker - Index corresponding to a particular engine boundary. * \param[in] val_engine_force - Exhaust power. */ void SetEngine_Force(unsigned short val_imarker, su2double val_engine_force); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_imarker - Index corresponding to a particular engine boundary. * \param[in] val_engine_power - Exhaust power. */ void SetEngine_Power(unsigned short val_imarker, su2double val_engine_power); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_imarker - Index corresponding to a particular engine boundary. * \param[in] val_engine_netthrust - Exhaust power. */ void SetEngine_NetThrust(unsigned short val_imarker, su2double val_engine_netthrust); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_imarker - Index corresponding to a particular engine boundary. * \param[in] val_engine_grossthrust - Exhaust power. */ void SetEngine_GrossThrust(unsigned short val_imarker, su2double val_engine_grossthrust); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_imarker - Index corresponding to a particular engine boundary. * \param[in] val_engine_area - Exhaust power. */ void SetEngine_Area(unsigned short val_imarker, su2double val_engine_area); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_imarker - Index corresponding to a particular engine boundary. * \return The outlet pressure. */ su2double GetEngine_Mach(unsigned short val_imarker); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_imarker - Index corresponding to a particular engine boundary. * \return The outlet pressure. */ su2double GetEngine_Force(unsigned short val_imarker); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_imarker - Index corresponding to a particular engine boundary. * \return The outlet pressure. */ su2double GetEngine_Power(unsigned short val_imarker); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_imarker - Index corresponding to a particular engine boundary. * \return The outlet pressure. */ - + su2double GetEngine_NetThrust(unsigned short val_imarker); /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_imarker - Index corresponding to a particular engine boundary. * \return The outlet pressure. */ - + su2double GetEngine_GrossThrust(unsigned short val_imarker); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_imarker - Index corresponding to a particular engine boundary. * \return The outlet pressure. */ su2double GetEngine_Area(unsigned short val_imarker); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ void SetActDiskInlet_Temperature(unsigned short val_imarker, su2double val_actdisk_temp); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ void SetActDiskInlet_TotalTemperature(unsigned short val_imarker, su2double val_actdisk_totaltemp); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ su2double GetActDiskInlet_Temperature(string val_marker); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ su2double GetActDiskInlet_TotalTemperature(string val_marker); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ void SetActDiskOutlet_Temperature(unsigned short val_imarker, su2double val_actdisk_temp); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ void SetActDiskOutlet_TotalTemperature(unsigned short val_imarker, su2double val_actdisk_totaltemp); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ su2double GetActDiskOutlet_Temperature(string val_marker); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ su2double GetActDiskOutlet_TotalTemperature(string val_marker); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ su2double GetActDiskInlet_MassFlow(string val_marker); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ void SetActDiskInlet_MassFlow(unsigned short val_imarker, su2double val_actdisk_massflow); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ su2double GetActDiskOutlet_MassFlow(string val_marker); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ void SetActDiskOutlet_MassFlow(unsigned short val_imarker, su2double val_actdisk_massflow); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ su2double GetActDiskInlet_Pressure(string val_marker); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ su2double GetActDiskInlet_TotalPressure(string val_marker); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ su2double GetActDisk_DeltaPress(unsigned short val_marker); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ su2double GetActDisk_DeltaTemp(unsigned short val_marker); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ su2double GetActDisk_TotalPressRatio(unsigned short val_marker); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ su2double GetActDisk_TotalTempRatio(unsigned short val_marker); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ su2double GetActDisk_StaticPressRatio(unsigned short val_marker); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ su2double GetActDisk_StaticTempRatio(unsigned short val_marker); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ su2double GetActDisk_NetThrust(unsigned short val_marker); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ su2double GetActDisk_BCThrust(unsigned short val_marker); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ su2double GetActDisk_BCThrust_Old(unsigned short val_marker); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ su2double GetActDisk_GrossThrust(unsigned short val_marker); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ su2double GetActDisk_Area(unsigned short val_marker); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ su2double GetActDisk_ReverseMassFlow(unsigned short val_marker); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ su2double GetActDiskInlet_RamDrag(string val_marker); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ su2double GetActDiskInlet_Force(string val_marker); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ su2double GetActDiskInlet_Power(string val_marker); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ void SetActDiskInlet_Pressure(unsigned short val_imarker, su2double val_actdisk_pressure); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ void SetActDiskInlet_TotalPressure(unsigned short val_imarker, su2double val_actdisk_totalpressure); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ void SetActDisk_DeltaPress(unsigned short val_imarker, su2double val_actdisk_deltapress); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ void SetActDisk_Power(unsigned short val_imarker, su2double val_actdisk_power); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ void SetActDisk_MassFlow(unsigned short val_imarker, su2double val_actdisk_massflow); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ void SetActDisk_Mach(unsigned short val_imarker, su2double val_actdisk_mach); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ void SetActDisk_Force(unsigned short val_imarker, su2double val_actdisk_force); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ su2double GetOutlet_MassFlow(string val_marker); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ void SetOutlet_MassFlow(unsigned short val_imarker, su2double val_massflow); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ su2double GetOutlet_Density(string val_marker); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ void SetOutlet_Density(unsigned short val_imarker, su2double val_density); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ su2double GetOutlet_Area(string val_marker); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ void SetOutlet_Area(unsigned short val_imarker, su2double val_area); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ void SetSurface_DC60(unsigned short val_imarker, su2double val_surface_distortion); - + /*! * \brief Set the massflow at the surface. * \param[in] val_imarker - Index corresponding to the outlet boundary. * \param[in] val_surface_massflow - Value of the mass flow. */ void SetSurface_MassFlow(unsigned short val_imarker, su2double val_surface_massflow); - + /*! * \brief Set the mach number at the surface. * \param[in] val_imarker - Index corresponding to the outlet boundary. @@ -7361,175 +7360,175 @@ class CConfig { * \return The outlet pressure. */ void SetSurface_IDC(unsigned short val_imarker, su2double val_surface_distortion); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ void SetSurface_IDC_Mach(unsigned short val_imarker, su2double val_surface_distortion); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ void SetSurface_IDR(unsigned short val_imarker, su2double val_surface_distortion); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ void SetActDisk_DeltaTemp(unsigned short val_imarker, su2double val_actdisk_deltatemp); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ void SetActDisk_TotalPressRatio(unsigned short val_imarker, su2double val_actdisk_pressratio); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ void SetActDisk_TotalTempRatio(unsigned short val_imarker, su2double val_actdisk_tempratio); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ void SetActDisk_StaticPressRatio(unsigned short val_imarker, su2double val_actdisk_pressratio); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ void SetActDisk_StaticTempRatio(unsigned short val_imarker, su2double val_actdisk_tempratio); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ void SetActDisk_NetThrust(unsigned short val_imarker, su2double val_actdisk_netthrust); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ void SetActDisk_BCThrust(string val_marker, su2double val_actdisk_bcthrust); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ void SetActDisk_BCThrust(unsigned short val_imarker, su2double val_actdisk_bcthrust); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ void SetActDisk_BCThrust_Old(string val_marker, su2double val_actdisk_bcthrust_old); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ void SetActDisk_BCThrust_Old(unsigned short val_imarker, su2double val_actdisk_bcthrust_old); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ void SetActDisk_GrossThrust(unsigned short val_imarker, su2double val_actdisk_grossthrust); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ void SetActDisk_Area(unsigned short val_imarker, su2double val_actdisk_area); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ void SetActDiskInlet_ReverseMassFlow(unsigned short val_imarker, su2double val_actdisk_area); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ void SetActDiskInlet_RamDrag(unsigned short val_imarker, su2double val_actdisk_ramdrag); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ void SetActDiskInlet_Force(unsigned short val_imarker, su2double val_actdisk_force); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ void SetActDiskInlet_Power(unsigned short val_imarker, su2double val_actdisk_power); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ su2double GetActDisk_Power(unsigned short val_imarker); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ su2double GetActDisk_MassFlow(unsigned short val_imarker); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ su2double GetActDisk_Mach(unsigned short val_imarker); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ su2double GetActDisk_Force(unsigned short val_imarker); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ su2double GetSurface_DC60(unsigned short val_imarker); - + /*! * \brief Get the massflow at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The massflow. */ su2double GetSurface_MassFlow(unsigned short val_imarker); - + /*! * \brief Get the mach number at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. @@ -7627,401 +7626,401 @@ class CConfig { * \return The outlet pressure. */ su2double GetSurface_IDC(unsigned short val_imarker); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ su2double GetSurface_IDC_Mach(unsigned short val_imarker); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ su2double GetSurface_IDR(unsigned short val_imarker); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ su2double GetActDiskOutlet_Pressure(string val_marker); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ su2double GetActDiskOutlet_TotalPressure(string val_marker); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ su2double GetActDiskOutlet_GrossThrust(string val_marker); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ su2double GetActDiskOutlet_Force(string val_marker); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ su2double GetActDiskOutlet_Power(string val_marker); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ void SetActDiskOutlet_Pressure(unsigned short val_imarker, su2double val_actdisk_pressure); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ void SetActDiskOutlet_TotalPressure(unsigned short val_imarker, su2double val_actdisk_totalpressure); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ void SetActDiskOutlet_GrossThrust(unsigned short val_imarker, su2double val_actdisk_grossthrust); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ void SetActDiskOutlet_Force(unsigned short val_imarker, su2double val_actdisk_force); - + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ void SetActDiskOutlet_Power(unsigned short val_imarker, su2double val_actdisk_power); - + /*! * \brief Get the displacement value at an displacement boundary. * \param[in] val_index - Index corresponding to the displacement boundary. * \return The displacement value. */ su2double GetDispl_Value(string val_index); - + /*! * \brief Get the force value at an load boundary. * \param[in] val_index - Index corresponding to the load boundary. * \return The load value. */ su2double GetLoad_Value(string val_index); - + /*! * \brief Get the constant value at a damper boundary. * \param[in] val_index - Index corresponding to the load boundary. * \return The damper constant. */ su2double GetDamper_Constant(string val_index); - + /*! * \brief Get the force value at a load boundary defined in cartesian coordinates. * \param[in] val_index - Index corresponding to the load boundary. * \return The load value. */ su2double GetLoad_Dir_Value(string val_index); - + /*! * \brief Get the force multiplier at a load boundary in cartesian coordinates. * \param[in] val_index - Index corresponding to the load boundary. * \return The load multiplier. */ su2double GetLoad_Dir_Multiplier(string val_index); - + /*! * \brief Get the force value at a load boundary defined in cartesian coordinates. * \param[in] val_index - Index corresponding to the load boundary. * \return The load value. */ su2double GetDisp_Dir_Value(string val_index); - + /*! * \brief Get the force multiplier at a load boundary in cartesian coordinates. * \param[in] val_index - Index corresponding to the load boundary. * \return The load multiplier. */ su2double GetDisp_Dir_Multiplier(string val_index); - + /*! * \brief Get the force direction at a loaded boundary in cartesian coordinates. * \param[in] val_index - Index corresponding to the load boundary. * \return The load direction. */ su2double* GetLoad_Dir(string val_index); - + /*! * \brief Get the force direction at a loaded boundary in cartesian coordinates. * \param[in] val_index - Index corresponding to the load boundary. * \return The load direction. */ su2double* GetDisp_Dir(string val_index); - + /*! * \brief Get the amplitude of the sine-wave at a load boundary defined in cartesian coordinates. * \param[in] val_index - Index corresponding to the load boundary. * \return The load value. */ su2double GetLoad_Sine_Amplitude(string val_index); - + /*! * \brief Get the frequency of the sine-wave at a load boundary in cartesian coordinates. * \param[in] val_index - Index corresponding to the load boundary. * \return The load frequency. */ su2double GetLoad_Sine_Frequency(string val_index); - + /*! * \brief Get the force direction at a sine-wave loaded boundary in cartesian coordinates. * \param[in] val_index - Index corresponding to the load boundary. * \return The load direction. */ su2double* GetLoad_Sine_Dir(string val_index); - + /*! * \brief Get the force value at an load boundary. * \param[in] val_index - Index corresponding to the load boundary. * \return The load value. */ su2double GetFlowLoad_Value(string val_index); - + /*! * \brief Cyclic pitch amplitude for rotor blades. * \return The specified cyclic pitch amplitude. */ su2double GetCyclic_Pitch(void); - + /*! * \brief Collective pitch setting for rotor blades. * \return The specified collective pitch setting. */ su2double GetCollective_Pitch(void); - + /*! * \brief Get name of the arbitrary mesh motion input file. * \return File name of the arbitrary mesh motion input file. */ string GetDV_Filename(void); - + /*! * \brief Get name of the unordered ASCII volume sensitivity file. * \return File name of the unordered ASCII volume sensitivity file. */ string GetDV_Unordered_Sens_Filename(void); - + /*! * \brief Get name of the unordered ASCII surface sensitivity file. * \return File name of the unordered ASCII surface sensitivity file. */ string GetDV_Sens_Filename(void); - + /*! * \brief Set the config options. */ void SetConfig_Options(); - + /*! * \brief Set the config options. */ void SetRunTime_Options(void); - + /*! * \brief Set the config file parsing. */ void SetConfig_Parsing(char case_filename[MAX_STRING_SIZE]); - + /*! * \brief Set the config file parsing. */ bool SetRunTime_Parsing(char case_filename[MAX_STRING_SIZE]); - + /*! * \brief Config file postprocessing. */ void SetPostprocessing(unsigned short val_software, unsigned short val_izone, unsigned short val_nDim); - + /*! * \brief Config file markers processing. */ void SetMarkers(unsigned short val_software); - + /*! * \brief Config file output. */ void SetOutput(unsigned short val_software, unsigned short val_izone); - + /*! * \brief Value of Aeroelastic solution coordinate at time n+1. */ vector > GetAeroelastic_np1(unsigned short iMarker); - + /*! * \brief Value of Aeroelastic solution coordinate at time n. */ vector > GetAeroelastic_n(unsigned short iMarker); - + /*! * \brief Value of Aeroelastic solution coordinate at time n-1. */ vector > GetAeroelastic_n1(unsigned short iMarker); - + /*! * \brief Value of Aeroelastic solution coordinate at time n+1. */ void SetAeroelastic_np1(unsigned short iMarker, vector > solution); - + /*! * \brief Value of Aeroelastic solution coordinate at time n from time n+1. */ void SetAeroelastic_n(void); - + /*! * \brief Value of Aeroelastic solution coordinate at time n-1 from time n. */ void SetAeroelastic_n1(void); - + /*! * \brief Aeroelastic Flutter Speed Index. */ su2double GetAeroelastic_Flutter_Speed_Index(void); - + /*! * \brief Uncoupled Aeroelastic Frequency Plunge. */ su2double GetAeroelastic_Frequency_Plunge(void); - + /*! * \brief Uncoupled Aeroelastic Frequency Pitch. */ su2double GetAeroelastic_Frequency_Pitch(void); - + /*! * \brief Aeroelastic Airfoil Mass Ratio. */ su2double GetAeroelastic_Airfoil_Mass_Ratio(void); - + /*! * \brief Aeroelastic center of gravity location. */ su2double GetAeroelastic_CG_Location(void); - + /*! * \brief Aeroelastic radius of gyration squared. */ su2double GetAeroelastic_Radius_Gyration_Squared(void); - + /*! * \brief Aeroelastic solve every x inner iteration. */ unsigned short GetAeroelasticIter(void); - + /*! * \brief Value of plunging coordinate. * \param[in] val_marker - the marker we are monitoring. * \return Value of plunging coordinate. */ su2double GetAeroelastic_plunge(unsigned short val_marker); - + /*! * \brief Value of pitching coordinate. * \param[in] val_marker - the marker we are monitoring. * \return Value of pitching coordinate. */ su2double GetAeroelastic_pitch(unsigned short val_marker); - + /*! * \brief Value of plunging coordinate. * \param[in] val_marker - the marker we are monitoring. * \param[in] val - value of plunging coordinate. */ void SetAeroelastic_plunge(unsigned short val_marker, su2double val); - + /*! * \brief Value of pitching coordinate. * \param[in] val_marker - the marker we are monitoring. * \param[in] val - value of pitching coordinate. */ void SetAeroelastic_pitch(unsigned short val_marker, su2double val); - + /*! * \brief Get information about the aeroelastic simulation. * \return TRUE if it is an aeroelastic case; otherwise FALSE. */ bool GetAeroelastic_Simulation(void); - + /*! * \brief Get information about the wind gust. * \return TRUE if there is a wind gust; otherwise FALSE. */ bool GetWind_Gust(void); - + /*! * \brief Get the type of gust to simulate. * \return type of gust to use for the simulation. */ unsigned short GetGust_Type(void); - + /*! * \brief Get the gust direction. * \return the gust direction. */ unsigned short GetGust_Dir(void); - + /*! * \brief Value of the gust wavelength. */ su2double GetGust_WaveLength(void); - + /*! * \brief Value of the number of gust periods. */ su2double GetGust_Periods(void); - + /*! * \brief Value of the gust amplitude. */ su2double GetGust_Ampl(void); - + /*! * \brief Value of the time at which to begin the gust. */ su2double GetGust_Begin_Time(void); - + /*! * \brief Value of the location ath which the gust begins. */ su2double GetGust_Begin_Loc(void); - + /*! * \brief Get the number of iterations to evaluate the parametric coordinates. * \return Number of iterations to evaluate the parametric coordinates. */ unsigned short GetnFFD_Iter(void); - + /*! * \brief Get the tolerance of the point inversion algorithm. * \return Tolerance of the point inversion algorithm. */ su2double GetFFD_Tol(void); - + /*! * \brief Get the scale factor for the line search. * \return Scale factor for the line search. @@ -8033,103 +8032,103 @@ class CConfig { * \return Bound for the line search. */ su2double GetOpt_LineSearch_Bound(void); - + /*! * \brief Set the scale factor for the line search. * \param[in] val_scale - scale of the deformation. */ void SetOpt_RelaxFactor(su2double val_scale); - + /*! * \brief Get the node number of the CV to visualize. * \return Node number of the CV to visualize. */ long GetVisualize_CV(void); - + /*! * \brief Get information about whether to use fixed CL mode. * \return TRUE if fixed CL mode is active; otherwise FALSE. */ bool GetFixed_CL_Mode(void); - + /*! * \brief Get information about whether to use fixed CL mode. * \return TRUE if fixed CL mode is active; otherwise FALSE. */ bool GetFixed_CM_Mode(void); - + /*! * \brief Get information about whether to use fixed CL mode. * \return TRUE if fixed CL mode is active; otherwise FALSE. */ bool GetEval_dOF_dCX(void); - + /*! * \brief Get information about whether to use fixed CL mode. * \return TRUE if fixed CL mode is active; otherwise FALSE. */ bool GetDiscard_InFiles(void); - + /*! * \brief Get the value specified for the target CL. * \return Value of the target CL. */ su2double GetTarget_CL(void); - + /*! * \brief Get the value for the lift curve slope for fixed CL mode. * \return Lift curve slope for fixed CL mode. */ su2double GetdCL_dAlpha(void); - + /*! * \brief Number of iterations to evaluate dCL_dAlpha. * \return Number of iterations. */ unsigned long GetIter_dCL_dAlpha(void); - + /*! * \brief Get the value of the damping coefficient for fixed CL mode. * \return Damping coefficient for fixed CL mode. */ su2double GetdCM_diH(void); - + /*! * \brief Get the value of iterations to re-evaluate the angle of attack. * \return Number of iterations. */ unsigned long GetIter_Fixed_NetThrust(void); - + /*! * \brief Get the value of the damping coefficient for fixed CL mode. * \return Damping coefficient for fixed CL mode. */ su2double GetdNetThrust_dBCThrust(void); - + /*! * \brief Get the value of iterations to re-evaluate the angle of attack. * \return Number of iterations. */ unsigned long GetUpdate_BCThrust(void); - + /*! * \brief Set the value of the boolean for updating AoA in fixed lift mode. * \param[in] val_update - the bool for whether to update the AoA. */ void SetUpdate_BCThrust_Bool(bool val_update); - + /*! * \brief Set the value of the boolean for updating AoA in fixed lift mode. * \param[in] val_update - the bool for whether to update the AoA. */ void SetUpdate_AoA(bool val_update); - + /*! * \brief Get information about whether to update the AoA for fixed lift mode. * \return TRUE if we should update the AoA for fixed lift mode; otherwise FALSE. */ bool GetUpdate_BCThrust_Bool(void); - + /*! * \brief Get information about whether to update the AoA for fixed lift mode. * \return TRUE if we should update the AoA for fixed lift mode; otherwise FALSE. @@ -8152,31 +8151,31 @@ class CConfig { * \brief Set whether at the end of finite differencing (Fixed CL mode) */ void SetFinite_Difference_Mode(bool val_fd_mode); - + /*! * \brief Set the current number of non-physical nodes in the solution. * \param[in] val_nonphys_points - current number of non-physical points. */ void SetNonphysical_Points(unsigned long val_nonphys_points); - + /*! * \brief Get the current number of non-physical nodes in the solution. * \return Current number of non-physical points. */ unsigned long GetNonphysical_Points(void); - + /*! * \brief Set the current number of non-physical reconstructions for 2nd-order upwinding. * \param[in] val_nonphys_reconstr - current number of non-physical reconstructions for 2nd-order upwinding. */ void SetNonphysical_Reconstr(unsigned long val_nonphys_reconstr); - + /*! * \brief Get the current number of non-physical reconstructions for 2nd-order upwinding. * \return Current number of non-physical reconstructions for 2nd-order upwinding. */ unsigned long GetNonphysical_Reconstr(void); - + /*! * \brief Given arrays x[1..n] and y[1..n] containing a tabulated function, i.e., yi = f(xi), with x1 < x2 < . . . < xN , and given values yp1 and ypn for the first derivative of the interpolating @@ -8187,7 +8186,7 @@ class CConfig { Numerical Recipes: The Art of Scientific Computing, Third Edition in C++. */ void SetSpline(vector &x, vector &y, unsigned long n, su2double yp1, su2double ypn, vector &y2); - + /*! * \brief Given the arrays xa[1..n] and ya[1..n], which tabulate a function (with the xai’s in order), and given the array y2a[1..n], which is the output from spline above, and given a value of @@ -8257,7 +8256,7 @@ class CConfig { * \return Verbosity level for the console output. */ unsigned short GetConsole_Output_Verb(void); - + /*! * \brief Get the kind of marker analyze marker (area-averaged, mass flux averaged, etc). * \return Kind of average. @@ -8270,7 +8269,7 @@ class CConfig { * \return direct differentiation method. */ unsigned short GetDirectDiff(); - + /*! * \brief Get the indicator whether we are solving an discrete adjoint problem. * \return the discrete adjoint indicator. @@ -8282,94 +8281,94 @@ class CConfig { * \return the full tape indicator. */ bool GetFull_Tape(void); - + /*! * \brief Get the indicator whether we want to benchmark the MPI performance of FSI problems * \return The value for checking */ bool CheckFSI_MPI(void); - + /*! * \brief Get the number of fluid subiterations roblems. * \return Number of FSI subiters. */ unsigned short GetnIterFSI(void); - + /*! * \brief Get the number of subiterations while a ramp is applied. * \return Number of FSI subiters. */ unsigned short GetnIterFSI_Ramp(void); - + /*! * \brief Get Aitken's relaxation parameter for static relaxation cases. * \return Aitken's relaxation parameters. */ su2double GetAitkenStatRelax(void); - + /*! * \brief Get Aitken's maximum relaxation parameter for dynamic relaxation cases and first iteration. * \return Aitken's relaxation parameters. */ su2double GetAitkenDynMaxInit(void); - + /*! * \brief Get Aitken's maximum relaxation parameter for dynamic relaxation cases and first iteration. * \return Aitken's relaxation parameters. */ su2double GetAitkenDynMinInit(void); - - + + /*! * \brief Decide whether to apply dead loads to the model. * \return TRUE if the dead loads are to be applied, FALSE otherwise. */ - + bool GetDeadLoad(void); - + /*! * \brief Identifies if the mesh is matching or not (temporary, while implementing interpolation procedures). * \return TRUE if the mesh is matching, FALSE otherwise. */ - + bool GetPseudoStatic(void); - + /*! * \brief Identifies if we want to restart from a steady or an unsteady solution. * \return TRUE if we restart from steady state solution, FALSE otherwise. */ - + bool GetSteadyRestart(void); - - + + /*! * \brief Provides information about the time integration of the structural analysis, and change the write in the output * files information about the iteration. * \return The kind of time integration: Static or dynamic analysis */ unsigned short GetDynamic_Analysis(void); - + /*! * \brief If we are prforming an unsteady simulation, there is only * one value of the time step for the complete simulation. * \return Value of the time step in an unsteady simulation (non dimensional). */ su2double GetDelta_DynTime(void); - + /*! * \brief If we are prforming an unsteady simulation, there is only * one value of the time step for the complete simulation. * \return Value of the time step in an unsteady simulation (non dimensional). */ su2double GetTotal_DynTime(void); - + /*! * \brief If we are prforming an unsteady simulation, there is only * one value of the time step for the complete simulation. * \return Value of the time step in an unsteady simulation (non dimensional). */ su2double GetCurrent_DynTime(void); - + /*! * \brief Get the current instance. * \return Current instance identifier. @@ -8384,98 +8383,98 @@ class CConfig { /*! * \brief Get information about writing dynamic structural analysis headers and file extensions. - * \return TRUE means that dynamic structural analysis solution files will be written. + * \return TRUE means that dynamic structural analysis solution files will be written. */ bool GetWrt_Dynamic(void); - + /*! * \brief Get Newmark alpha parameter. * \return Value of the Newmark alpha parameter. */ su2double GetNewmark_beta(void); - + /*! * \brief Get Newmark delta parameter. * \return Value of the Newmark delta parameter. */ su2double GetNewmark_gamma(void); - + /*! * \brief Get the number of integration coefficients provided by the user. * \return Number of integration coefficients. */ unsigned short GetnIntCoeffs(void); - + /*! * \brief Get the number of different values for the elasticity modulus. * \return Number of different values for the elasticity modulus. */ unsigned short GetnElasticityMod(void); - + /*! * \brief Get the number of different values for the Poisson ratio. * \return Number of different values for the Poisson ratio. */ unsigned short GetnPoissonRatio(void); - + /*! * \brief Get the number of different values for the Material density. * \return Number of different values for the Material density. */ unsigned short GetnMaterialDensity(void); - + /*! * \brief Get the integration coefficients for the Generalized Alpha - Newmark integration integration scheme. * \param[in] val_coeff - Index of the coefficient. * \return Alpha coefficient for the Runge-Kutta integration scheme. */ su2double Get_Int_Coeffs(unsigned short val_coeff); - + /*! * \brief Get the number of different values for the modulus of the electric field. * \return Number of different values for the modulus of the electric field. */ unsigned short GetnElectric_Field(void); - + /*! * \brief Get the dimensionality of the electric field. * \return Number of integration coefficients. */ unsigned short GetnDim_Electric_Field(void); - + /*! * \brief Get the values for the electric field modulus. * \param[in] val_coeff - Index of the coefficient. * \return Alpha coefficient for the Runge-Kutta integration scheme. */ su2double Get_Electric_Field_Mod(unsigned short val_coeff); - + /*! * \brief Set the values for the electric field modulus. * \param[in] val_coeff - Index of the electric field. * \param[in] val_el_field - Value of the electric field. */ void Set_Electric_Field_Mod(unsigned short val_coeff, su2double val_el_field); - + /*! * \brief Get the direction of the electric field in reference configuration. * \param[in] val_coeff - Index of the coefficient. * \return Alpha coefficient for the Runge-Kutta integration scheme. */ su2double* Get_Electric_Field_Dir(void); - + /*! * \brief Check if the user wants to apply the load as a ramp. - * \return TRUE means that the load is to be applied as a ramp. + * \return TRUE means that the load is to be applied as a ramp. */ bool GetRamp_Load(void); - + /*! * \brief Get the maximum time of the ramp. - * \return Value of the max time while the load is linearly increased + * \return Value of the max time while the load is linearly increased */ su2double GetRamp_Time(void); - + /*! * \brief Check if the user wants to apply the load as a ramp. * \return TRUE means that the load is to be applied as a ramp. @@ -8502,19 +8501,19 @@ class CConfig { * \return Kind of transfer method for multiphysics problems */ unsigned short GetDynamic_LoadTransfer(void); - + /*! * \brief Get the penalty weight value for the objective function. * \return Penalty weight value for the reference geometry objective function. */ su2double GetRefGeom_Penalty(void); - + /*! * \brief Get the penalty weight value for the objective function. * \return Penalty weight value for the reference geometry objective function. */ su2double GetTotalDV_Penalty(void); - + /*! * \brief Get whether a predictor is used for FSI applications. * \return Bool: determines if predictor is used or not @@ -8523,7 +8522,7 @@ class CConfig { /*! * \brief Get the order of the predictor for FSI applications. - * \return Order of predictor + * \return Order of predictor */ unsigned short GetPredictorOrder(void); @@ -8550,7 +8549,7 @@ class CConfig { * \return Value of the physical time in an unsteady simulation. */ bool GetFSI_Simulation(void); - + /*! * \brief Set that the simulation we are running is a FSI simulation * \param[in] FSI_sim - boolean that determines is FSI_Problem is true/false. @@ -8574,16 +8573,16 @@ class CConfig { * \return ID */ unsigned short GetnID_DV(void); - + /*! * \brief Check if we want to apply an incremental load to the nonlinear structural simulation * \return TRUE means that the load is to be applied in increments. */ bool GetIncrementalLoad(void); - + /*! * \brief Get the number of increments for an incremental load. - * \return Number of increments. + * \return Number of increments. */ unsigned long GetNumberIncrements(void); @@ -8592,7 +8591,7 @@ class CConfig { * \return Value of the log10 of the residual. */ su2double GetIncLoad_Criteria(unsigned short val_var); - + /*! * \brief Get the relaxation method chosen for the simulation * \return Value of the relaxation method @@ -8663,22 +8662,22 @@ class CConfig { * \brief Get the interpolation method used for matching between zones. */ inline unsigned short GetKindInterpolation(void); - - /*! - * \brief Get option of whether to use conservative interpolation between zones. - */ + + /*! + * \brief Get option of whether to use conservative interpolation between zones. + */ inline bool GetConservativeInterpolation(void); - + /*! * \brief Get the basis function to use for radial basis function interpolation for FSI. */ inline unsigned short GetKindRadialBasisFunction(void); - + /*! * \brief Get option of whether to use polynomial terms in Radial Basis Function interpolation. */ inline bool GetRadialBasisFunctionPolynomialOption(void); - + /*! * \brief Get the basis function radius to use for radial basis function interpolation for FSI. */ @@ -8713,7 +8712,7 @@ class CConfig { * \return TRUE means eigenspace perterturbation will be used */ bool GetUQ_Permute(void); - + /*! * \brief Get information about whether to use wall functions. * \return TRUE if wall functions are on; otherwise FALSE. @@ -8735,13 +8734,13 @@ class CConfig { * \return Value of the maximum velocity^2 in the domain for the incompressible preconditioner. */ su2double GetMax_Vel2(void); - + /*! * \brief Set the sum of the bandwidth for writing binary restarts (to be averaged later). * \param[in] Sum of the bandwidth for writing binary restarts. */ void SetRestart_Bandwidth_Agg(su2double val_restart_bandwidth_sum); - + /*! * \brief Set the sum of the bandwidth for writing binary restarts (to be averaged later). * \return Sum of the bandwidth for writing binary restarts. @@ -8753,7 +8752,7 @@ class CConfig { * \return It writes the surface solution file with this frequency. */ unsigned long GetWrt_Surf_Freq_DualTime(void); - + /*! * \brief Get the Kind of Hybrid RANS/LES. * \return Value of Hybrid RANS/LES method. @@ -8765,7 +8764,7 @@ class CConfig { * \return Value of Low dissipation approach. */ unsigned short GetKind_RoeLowDiss(void); - + /*! * \brief Get the DES Constant. * \return Value of DES constant. @@ -8799,7 +8798,7 @@ class CConfig { * \return YES if the passed values is the integrated heat flux over the marker's surface. */ bool GetIntegrated_HeatFlux(void); - + /*! * \brief Get Compute Average. * \return YES if start computing averages @@ -8811,7 +8810,7 @@ class CConfig { * \return The verification solution to be used. */ unsigned short GetVerification_Solution(void); - + /*! * \brief Get topology optimization. */ @@ -8831,12 +8830,12 @@ class CConfig { * \brief Get lower bound for density-based stiffness penalization. */ su2double GetSIMP_MinStiffness(void) const; - + /*! * \brief Number of kernels to use in filtering the design density field. */ unsigned short GetTopology_Optim_Num_Kernels(void) const; - + /*! * \brief Get the i'th kernel to use, its parameter, and the radius. */ @@ -8894,16 +8893,16 @@ class CConfig { /*! * \brief Get the number of time iterations - * \return Number of time steps run + * \return Number of time steps run */ unsigned long GetnTime_Iter(void); /*! * \brief Set the number of time iterations - * \param[in] val_iter - Number of time steps run + * \param[in] val_iter - Number of time steps run */ void SetnTime_Iter(unsigned long val_iter); - + /*! * \brief Get the number of pseudo-time iterations * \return Number of pseudo-time steps run for the single-zone problem @@ -8933,7 +8932,7 @@ class CConfig { * \return Level of MPI communications. */ unsigned short GetComm_Level(void); - + /*! * \brief Check if the mesh read supports multiple zones. * \return YES if multiple zones can be contained in the mesh file. @@ -8976,19 +8975,19 @@ class CConfig { * \return YES if the forces breakdown file is written. */ bool GetWrt_ForcesBreakdown(void); - + /*! * \brief Get the number of grid points in the analytic RECTANGLE or BOX grid in the specified coordinate direction. * \return Number of grid points in the analytic RECTANGLE or BOX grid in the specified coordinate direction. */ short GetMeshBoxSize(unsigned short val_iDim); - + /*! * \brief Get the length of the analytic RECTANGLE or BOX grid in the specified coordinate direction. * \return Length the analytic RECTANGLE or BOX grid in the specified coordinate direction. */ su2double GetMeshBoxLength(unsigned short val_iDim); - + /*! * \brief Get the offset from 0.0 of the analytic RECTANGLE or BOX grid in the specified coordinate direction. * \return Offset from 0.0 the analytic RECTANGLE or BOX grid in the specified coordinate direction. @@ -9075,14 +9074,14 @@ class CConfig { * \brief Get the number of convergence monitoring fields for inner convergence monitoring. * return Number of convergence monitoring fields. */ - unsigned short GetnConv_Field(); - + unsigned short GetnConv_Field(); + /*! * \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 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. @@ -9091,7 +9090,7 @@ class CConfig { /*! * \brief GetHistory_Wrt_Freq_Inner - * \return + * \return */ unsigned long GetHistory_Wrt_Freq(unsigned short iter); @@ -9101,38 +9100,38 @@ class CConfig { * \param[in] nIter: Number of iterations */ void SetHistory_Wrt_Freq(unsigned short iter, unsigned long nIter); - + /*! * \brief GetScreen_Wrt_Freq_Inner - * \return + * \return */ unsigned long GetScreen_Wrt_Freq(unsigned short iter); - + /*! * \brief SetScreen_Wrt_Freq_Inner * \param[in] iter: index for Time (0), Outer (1), or Inner (2) iterations * \param[in] nIter: Number of iterations */ void SetScreen_Wrt_Freq(unsigned short iter, unsigned long nIter); - + /*! * \brief GetScreen_Wrt_Freq_Inner - * \return + * \return */ unsigned long GetVolume_Wrt_Freq(); - + /*! * \brief GetVolumeOutputFiles - * \return + * \return */ unsigned short* GetVolumeOutputFiles(); - + /*! * \brief GetnVolumeOutputFiles - * \return + * \return */ unsigned short GetnVolumeOutputFiles(); - + /*! * \brief Get the desired factorization frequency for PaStiX * \return Number of calls to 'Build' that trigger re-factorization. @@ -9169,7 +9168,7 @@ class CConfig { * \brief Get the number of threads per rank to use for ILU and LU_SGS preconditioners. * \return Number of threads per rank. */ - inline unsigned long GetLinear_Solver_Prec_Threads(void) const {return Linear_Solver_Prec_Threads;} + inline unsigned long GetLinear_Solver_Prec_Threads(void) const {return Linear_Solver_Prec_Threads;} }; diff --git a/Common/include/option_structure.hpp b/Common/include/option_structure.hpp index 9c78c4ee859a..be559d4d605b 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -41,7 +41,9 @@ using namespace std; /*! * \class CEmptyMap - * \brief + * \brief We use this dummy class instead of std::map when + * we only need the enum definition and not the string to + * enum maps, this makes compilation much faster. */ template struct CEmptyMap { @@ -231,7 +233,7 @@ static const MapType Multizone_Map = { }; /*! - * \brief types of fluid solvers + * \brief Types of fluid solvers */ enum ENUM_FSI_FLUID_PROBLEM { NO_SOLVER_FFSI = 0, /*!< \brief Definition of no solver. */ @@ -247,7 +249,7 @@ static const MapType FSI_Fluid_Solver_Map = { }; /*! - * \brief types of structural solvers + * \brief Types of structural solvers */ enum ENUM_FSI_STRUC_PROBLEM { NO_SOLVER_SFSI = 0, /*!< \brief Definition of no solver. */ @@ -299,7 +301,7 @@ static const MapType MatComp_Map = { }; /*! - * \brief types of interpolators + * \brief Types of interpolators */ enum ENUM_INTERPOLATOR { NEAREST_NEIGHBOR = 0, /*!< \brief Nearest Neigbhor interpolation */ @@ -315,7 +317,7 @@ static const MapType Interpolator_Map = { }; /*! - * \brief types of radial basis functions + * \brief Types of radial basis functions */ enum ENUM_RADIALBASIS { WENDLAND_C2 = 0, /*!< \brief Wendland C2 radial basis function. */ @@ -333,7 +335,7 @@ static const MapType RadialBasisFunction_Map = { }; /*! - * \brief types of (coupling) transfers between distinct physical zones + * \brief Types of (coupling) transfers between distinct physical zones */ enum ENUM_TRANSFER { ZONES_ARE_EQUAL = 0, /*!< \brief Zones are equal - no transfer. */ @@ -443,7 +445,7 @@ const int MESH_SOL = 8; /*!< \brief Position of the mesh solver. */ const int ADJMESH_SOL = 9; /*!< \brief Position of the adjoint of the mesh solver. */ /*! - * \brief types of finite elements (in 2D or 3D) + * \brief Types of finite elements (in 2D or 3D) */ const int EL_TRIA = 0; /*!< \brief Elements of three nodes (2D). */ const int EL_QUAD = 1; /*!< \brief Elements of four nodes (2D). */ @@ -455,7 +457,7 @@ const int EL_PRISM = 3; /*!< \brief Elements of six nodes (3D). */ /*! - * \brief types of mathematical problem to solve + * \brief Types of mathematical problem to solve */ enum ENUM_MATH_PROBLEM { DIRECT = 0, /*!< \brief Direct problem */ @@ -469,7 +471,7 @@ static const MapType Math_Problem_Map = { }; /*! - * \brief types of spatial discretizations + * \brief Types of spatial discretizations */ enum ENUM_SPACE { NO_CONVECTIVE = 0, /*!< \brief No convective scheme is used. */ @@ -485,7 +487,7 @@ static const MapType Space_Map = { }; /*! - * \brief types of fluid model + * \brief Types of fluid model */ enum ENUM_FLUIDMODEL { STANDARD_AIR = 0, /*!< \brief Standard air gas model. */ @@ -507,7 +509,7 @@ static const MapType FluidModel_Map = { }; /*! - * \brief types of density models + * \brief Types of density models */ enum ENUM_DENSITYMODEL { CONSTANT = 0, @@ -521,7 +523,7 @@ static const MapType DensityModel_Map = { }; /*! - * \brief types of initialization option + * \brief Types of initialization option */ enum ENUM_INIT_OPTION { REYNOLDS = 0, /*!< \brief Reynold's number initalization. */ @@ -533,7 +535,7 @@ static const MapType InitOption_Map = { }; /*! - * \brief types of initialization option + * \brief Types of initialization option */ enum ENUM_FREESTREAM_OPTION { TEMPERATURE_FS = 0, /*!< \brief Temperature initialization. */ @@ -545,7 +547,7 @@ static const MapType FreeStreamOption_Map = { }; /*! - * \brief types of viscosity model + * \brief Types of viscosity model */ enum ENUM_VISCOSITYMODEL { CONSTANT_VISCOSITY = 0, /*!< \brief Constant viscosity. */ @@ -559,7 +561,7 @@ static const MapType ViscosityModel_Map = { }; /*! - * \brief types of thermal conductivity model + * \brief Types of thermal conductivity model */ enum ENUM_CONDUCTIVITYMODEL { CONSTANT_CONDUCTIVITY = 0, /*!< \brief Constant thermal conductivity. */ @@ -573,7 +575,7 @@ static const MapType ConductivityModel_Map = { }; /*! - * \brief types of turbulent thermal conductivity model + * \brief Types of turbulent thermal conductivity model */ enum ENUM_CONDUCTIVITYMODEL_TURB { NO_CONDUCTIVITY_TURB = 0, /*!< \brief No turbulent contribution to the effective thermal conductivity for RANS. */ @@ -585,7 +587,7 @@ static const MapType TurbConductivityModel_ }; /*! - * \brief types of unsteady mesh motion + * \brief Types of unsteady mesh motion */ enum ENUM_GRIDMOVEMENT { NO_MOVEMENT = 0, /*!< \brief Simulation on a static mesh. */ @@ -628,7 +630,7 @@ static const MapType SurfaceMovement_Map = { }; /*! - * \brief type of wind gusts + * \brief Type of wind gusts */ enum ENUM_GUST_TYPE { NO_GUST = 0, /*!< \brief No gust. */ @@ -648,7 +650,7 @@ static const MapType Gust_Type_Map = { }; /*! - * \brief type of wind direction + * \brief Type of wind direction */ enum ENUM_GUST_DIR { X_DIR = 0, /*!< \brief Gust direction-X. */ @@ -661,7 +663,7 @@ static const MapType Gust_Dir_Map = { // If you add to ENUM_CENTERED, you must also add the option to ENUM_CONVECTIVE /*! - * \brief types of centered spatial discretizations + * \brief Types of centered spatial discretizations */ enum ENUM_CENTERED { NO_CENTERED = 0, /*!< \brief No centered scheme is used. */ @@ -679,7 +681,7 @@ static const MapType Centered_Map = { // If you add to ENUM_UPWIND, you must also add the option to ENUM_CONVECTIVE /*! - * \brief types of upwind spatial discretizations + * \brief Types of upwind spatial discretizations */ enum ENUM_UPWIND { NO_UPWIND = 0, /*!< \brief No upwind scheme is used. */ @@ -723,7 +725,7 @@ static const MapType Upwind_Map = { }; /*! - * \brief types of FEM spatial discretizations + * \brief Types of FEM spatial discretizations */ enum ENUM_FEM { NO_FEM = 0, /*!< \brief No finite element scheme is used. */ @@ -735,7 +737,7 @@ static const MapType FEM_Map = { }; /*! - * \brief types of shock capturing method in Discontinuous Galerkin numerical method. + * \brief Types of shock capturing method in Discontinuous Galerkin numerical method. */ enum ENUM_SHOCK_CAPTURING_DG { NO_SHOCK_CAPTURING = 0, /*!< \brief Shock capturing is not used. */ @@ -747,7 +749,7 @@ static const MapType ShockCapturingDG_Map = { }; /*! - * \brief types of matrix coloring to compute a sparse Jacobian matrix. + * \brief Types of matrix coloring to compute a sparse Jacobian matrix. */ enum ENUM_MATRIX_COLORING { GREEDY_COLORING = 0, /*!< \brief Greedy type of algorithm for the coloring. */ @@ -759,7 +761,7 @@ static const MapType MatrixColoring_Map = { }; /*! - * \brief types of slope limiters + * \brief Types of slope limiters */ enum ENUM_LIMITER { NO_LIMITER = 0, /*!< \brief No limiter. */ @@ -781,7 +783,7 @@ static const MapType Limiter_Map = { }; /*! - * \brief types of turbulent models + * \brief Types of turbulent models */ enum ENUM_TURB_MODEL { NO_TURB_MODEL = 0, /*!< \brief No turbulence model. */ @@ -805,7 +807,7 @@ static const MapType Turb_Model_Map = { }; /*! - * \brief types of transition models + * \brief Types of transition models */ enum ENUM_TRANS_MODEL { NO_TRANS_MODEL = 0, /*!< \brief No transition model. */ @@ -819,7 +821,7 @@ static const MapType Trans_Model_Map = { }; /*! - * \brief types of subgrid scale models + * \brief Types of subgrid scale models */ enum ENUM_SGS_MODEL { NO_SGS_MODEL = 0, /*!< \brief No subgrid scale model. */ @@ -838,7 +840,7 @@ static const MapType SGS_Model_Map = { /*! - * \brief types of window (weight) functions for cost functional + * \brief Types of window (weight) functions for cost functional */ enum WINDOW_FUNCTION { SQUARE = 0, /*!< \brief No weight function (order 1)*/ @@ -854,7 +856,7 @@ static const MapType Window_Map = { }; /*! - * \brief types of hybrid RANS/LES models + * \brief Types of hybrid RANS/LES models */ enum ENUM_HYBRIDRANSLES { NO_HYBRIDRANSLES = 0, /*!< \brief No turbulence model. */ @@ -872,7 +874,7 @@ static const MapType HybridRANSLES_Map = { }; /*! - * \brief types of Roe Low Dissipation Schemes + * \brief Types of Roe Low Dissipation Schemes */ enum ENUM_ROELOWDISS { NO_ROELOWDISS = 0, /*!< \brief No Roe Low Dissipation model. */ @@ -890,7 +892,7 @@ static const MapType RoeLowDiss_Map = { }; /*! - * \brief types of wall functions. + * \brief Types of wall functions. */ enum ENUM_WALL_FUNCTIONS { NO_WALL_FUNCTION = 0, /*!< \brief No wall function treatment, integration to the wall. Default behavior. */ @@ -912,7 +914,7 @@ static const MapType Wall_Functions_Map = { }; /*! - * \brief type of time integration schemes + * \brief Type of time integration schemes */ enum ENUM_TIME_INT { RUNGE_KUTTA_EXPLICIT = 1, /*!< \brief Explicit Runge-Kutta time integration definition. */ @@ -930,7 +932,7 @@ static const MapType Time_Int_Map = { }; /*! - * \brief type of predictor for the ADER-DG time integration scheme. + * \brief Type of predictor for the ADER-DG time integration scheme. */ enum ENUM_ADER_PREDICTOR { ADER_ALIASED_PREDICTOR = 1, /*!< \brief Aliased predictor, easiest to do. */ @@ -942,7 +944,7 @@ static const MapType Ader_Predictor_Map = { }; /*! - * \brief type of heat timestep calculation + * \brief Type of heat timestep calculation */ enum ENUM_HEAT_TIMESTEP { MINIMUM = 1, /*!< \brief Local time stepping based on minimum lambda.*/ @@ -958,7 +960,7 @@ static const MapType Heat_TimeStep_Map = { }; /*! - * \brief type of time integration schemes + * \brief Type of time integration schemes */ enum ENUM_TIME_INT_FEA { CD_EXPLICIT = 1, /*!< \brief Support for implementing an explicit method. */ @@ -972,7 +974,7 @@ static const MapType Time_Int_Map_FEA = { }; /*! - * \brief type of time integration schemes + * \brief Type of time integration schemes */ enum ENUM_SPACE_ITE_FEA { NEWTON_RAPHSON = 1, /*!< \brief Full Newton-Rapshon method. */ @@ -984,7 +986,7 @@ static const MapType Space_Ite_Map_FEA = { }; /*! - * \brief types of schemes to compute the flow gradient + * \brief Types of schemes to compute the flow gradient */ enum ENUM_FLOW_GRADIENT { NO_GRADIENT = 0, /*!< \brief No gradient method. Only possible for reconstruction gradient, in which case, the option chosen for NUM_METHOD_GRAD is used. */ @@ -1000,7 +1002,7 @@ static const MapType Gradient_Map = { }; /*! - * \brief types of action to take on a geometry structure + * \brief Types of action to take on a geometry structure */ enum GEOMETRY_ACTION { ALLOCATE = 0, /*!< \brief Allocate geometry structure. */ @@ -1008,7 +1010,7 @@ enum GEOMETRY_ACTION { }; /*! - * \brief types of action to perform when doing the geometry evaluation + * \brief Types of action to perform when doing the geometry evaluation */ enum GEOMETRY_MODE { FUNCTION = 0, /*!< \brief Geometrical analysis. */ @@ -1020,7 +1022,7 @@ static const MapType GeometryMode_Map = { }; /*! - * \brief types of boundary conditions + * \brief Types of boundary conditions */ enum BC_TYPE { EULER_WALL = 1, /*!< \brief Boundary Euler wall definition. */ @@ -1087,7 +1089,7 @@ static const MapType AitkenForm_Map = { }; /*! - * \brief types of dynamic transfer methods + * \brief Types of dynamic transfer methods */ enum ENUM_DYN_TRANSFER_METHOD { INSTANTANEOUS = 1, /*!< \brief No ramp, load is transfer instantaneously. */ @@ -1145,7 +1147,7 @@ static const MapType CHT_Coupling_Map = { }; /*! - * \brief types Riemann boundary treatments + * \brief Types Riemann boundary treatments */ enum RIEMANN_TYPE { TOTAL_CONDITIONS_PT = 1, /*!< \brief User specifies total pressure, total temperature, and flow direction. */ @@ -1198,7 +1200,7 @@ static const MapType Giles_Map = { }; /*! - * \brief types of mixing process for averaging quantities at the boundaries. + * \brief Types of mixing process for averaging quantities at the boundaries. */ enum AVERAGEPROCESS_TYPE { ALGEBRAIC = 1, /*!< \brief an algebraic average is computed at the boundary of interest. */ @@ -1214,7 +1216,7 @@ static const MapType AverageProcess_Map = { }; /*! - * \brief types of mixing process for averaging quantities at the boundaries. + * \brief Types of mixing process for averaging quantities at the boundaries. */ enum MIXINGPLANE_INTERFACE_TYPE { MATCHING = 1, /*!< \brief an algebraic average is computed at the boundary of interest. */ @@ -1240,7 +1242,7 @@ static const MapType SpanWise_Map = { }; /*! - * \brief types of mixing process for averaging quantities at the boundaries. + * \brief Types of mixing process for averaging quantities at the boundaries. */ enum TURBOMACHINERY_TYPE { AXIAL = 1, /*!< \brief axial turbomachinery. */ @@ -1258,7 +1260,7 @@ static const MapType TurboMachinery_Map = { }; /*! - * \brief types of Turbomachinery performance flag. + * \brief Types of Turbomachinery performance flag. */ enum TURBO_MARKER_TYPE{ INFLOW = 1, /*!< \brief flag for inflow marker for compute turboperformance. */ @@ -1266,7 +1268,7 @@ enum TURBO_MARKER_TYPE{ }; /*! - * \brief types inlet boundary treatments + * \brief Types inlet boundary treatments */ enum INLET_TYPE { TOTAL_CONDITIONS = 1, /*!< \brief User specifies total pressure, total temperature, and flow direction. */ @@ -1284,7 +1286,7 @@ static const MapType Inlet_Map = { }; /*! - * \brief types outlet boundary treatments + * \brief Types outlet boundary treatments */ enum OUTLET_TYPE { PRESSURE_OUTLET = 1, /*!< \brief Gauge pressure outlet for incompressible flow */ @@ -1296,7 +1298,7 @@ static const MapType Outlet_Map = { }; /*! - * \brief types engine inflow boundary treatments + * \brief Types engine inflow boundary treatments */ enum ENGINE_INFLOW_TYPE { FAN_FACE_MACH = 1, /*!< \brief User specifies fan face mach number. */ @@ -1310,7 +1312,7 @@ static const MapType Engine_Inflow_Map = { }; /*! - * \brief types actuator disk boundary treatments + * \brief Types actuator disk boundary treatments */ enum ACTDISK_TYPE { VARIABLES_JUMP = 1, /*!< \brief User specifies the variables jump. */ @@ -1330,7 +1332,7 @@ static const MapType ActDisk_Map = { }; /*! - * \brief types of geometric entities based on VTK nomenclature + * \brief Types of geometric entities based on VTK nomenclature */ enum GEO_TYPE { VERTEX = 1, /*!< \brief VTK nomenclature for defining a vertex element. */ @@ -1344,7 +1346,7 @@ enum GEO_TYPE { }; /*! - * \brief types of objective functions + * \brief Types of objective functions */ enum ENUM_OBJECTIVE { DRAG_COEFFICIENT = 1, /*!< \brief Drag objective function definition. */ @@ -1448,7 +1450,7 @@ static const MapType Objective_Map = { }; /*! - * \brief types of residual criteria equations + * \brief Types of residual criteria equations */ enum ENUM_RESIDUAL { RHO_RESIDUAL = 1, /*!< \brief Rho equation residual criteria equation. */ @@ -1460,7 +1462,7 @@ static const MapType Residual_Map = { }; /*! - * \brief types of residual criteria for structural problems + * \brief Types of residual criteria for structural problems */ enum ENUM_RESFEM { RESFEM_RELATIVE = 1, /*!< \brief Relative criteria: Res/Res0. */ @@ -1472,7 +1474,7 @@ static const MapType ResFem_Map = { }; /*! - * \brief types of sensitivities to compute + * \brief Types of sensitivities to compute */ enum ENUM_SENS { SENS_GEOMETRY = 1, /*!< \brief Geometrical sensitivity. */ @@ -1488,7 +1490,7 @@ static const MapType Sens_Map = { }; /*! - * \brief types of grid adaptation/refinement + * \brief Types of grid adaptation/refinement */ enum ENUM_ADAPT { NO_ADAPT = 0, /*!< \brief No grid adaptation. */ @@ -1522,7 +1524,7 @@ static const MapType Adapt_Map = { }; /*! - * \brief types of input file formats + * \brief Types of input file formats */ enum ENUM_INPUT { SU2 = 1, /*!< \brief SU2 input format. */ @@ -1538,7 +1540,7 @@ static const MapType Input_Map = { }; /*! - * \brief type of solution output file formats + * \brief Type of solution output file formats */ enum ENUM_OUTPUT { TECPLOT = 1, /*!< \brief Tecplot format for the solution output. */ @@ -1583,7 +1585,7 @@ static const MapType Output_Map = { }; /*! - * \brief type of solution output file formats + * \brief Type of solution output file formats */ enum ENUM_TAB_OUTPUT { TAB_CSV = 1, /*!< \brief Comma-separated values format for the solution output. */ @@ -1595,7 +1597,7 @@ static const MapType TabOutput_Map = { }; /*! - * \brief type of volume sensitivity file formats (inout to SU2_DOT) + * \brief Type of volume sensitivity file formats (inout to SU2_DOT) */ enum ENUM_SENSITIVITY { SU2_NATIVE = 1, /*!< \brief SU2 native binary format for the volume sensitivity input. */ @@ -1607,7 +1609,7 @@ static const MapType Sensitivity_Map = { }; /*! - * \brief type of jump definition + * \brief Type of jump definition */ enum JUMP_DEFINITION { DIFFERENCE = 1, /*!< \brief Jump given by a difference in values. */ @@ -1619,7 +1621,7 @@ static const MapType Jump_Map = { }; /*! - * \brief type of multigrid cycle + * \brief Type of multigrid cycle */ enum MG_CYCLE { V_CYCLE = 0, /*!< \brief V cycle. */ @@ -1633,7 +1635,7 @@ static const MapType MG_Cycle_Map = { }; /*! - * \brief type of solution output variables + * \brief Type of solution output variables */ enum ENUM_OUTPUT_VARS { DENSITY = 1, /*!< \brief Density. */ @@ -1659,7 +1661,7 @@ static const MapType Output_Vars_Map = { }; /*! - * \brief types of design parameterizations + * \brief Types of design parameterizations */ enum ENUM_PARAM { NO_DEFORMATION = 0, /*!< \brief No deformation. */ @@ -1775,7 +1777,7 @@ static const MapType Linear_Solver_Map = { }; /*! - * \brief types surface continuity at the intersection with the FFD + * \brief Types surface continuity at the intersection with the FFD */ enum ENUM_FFD_CONTINUITY { DERIVATIVE_NONE = 0, /*!< \brief No derivative continuity. */ @@ -1791,7 +1793,7 @@ static const MapType Continuity_Map = { }; /*! - * \brief types of coordinates systems for the FFD + * \brief Types of coordinates systems for the FFD */ enum ENUM_FFD_COORD_SYSTEM { CARTESIAN = 0, /*!< \brief Cartesian coordinate system. */ @@ -1807,7 +1809,7 @@ static const MapType CoordSystem_Map = { }; /*! - * \brief types of sensitivity smoothing + * \brief Types of sensitivity smoothing */ enum ENUM_SENS_SMOOTHING { NO_SMOOTH = 0, /*!< \brief No smoothing. */ @@ -1821,7 +1823,7 @@ static const MapType Sens_Smoothing_Map = { }; /*! - * \brief types of preconditioners for the linear solver + * \brief Types of preconditioners for the linear solver */ enum ENUM_LINEAR_SOLVER_PREC { JACOBI = 1, /*!< \brief Jacobi preconditioner. */ @@ -1843,7 +1845,7 @@ static const MapType Linear_Solver_Prec_Map = { }; /*! - * \brief types of analytic definitions for various geometries + * \brief Types of analytic definitions for various geometries */ enum ENUM_GEO_ANALYTIC { NO_GEO_ANALYTIC = 0, /*!< \brief No analytic definition of the geometry. */ @@ -1861,7 +1863,7 @@ static const MapType Geo_Analytic_Map = { }; /*! - * \brief types of axis orientation + * \brief Types of axis orientation */ enum ENUM_GEO_DESCRIPTION { TWOD_AIRFOIL = 0, /*!< \brief Airfoil analysis. */ @@ -1877,7 +1879,7 @@ static const MapType Geo_Description_Map = { }; /*! - * \brief types of schemes for unsteady computations + * \brief Types of schemes for unsteady computations */ enum ENUM_UNSTEADY { STEADY = 0, /*!< \brief A steady computation. */ @@ -1897,7 +1899,7 @@ static const MapType TimeMarching_Map = { }; /*! - * \brief types of criteria to determine when the solution is converged + * \brief Types of criteria to determine when the solution is converged */ enum ENUM_CONVERGE_CRIT { CAUCHY = 1, /*!< \brief Cauchy criteria to establish the convergence of the code. */ @@ -1909,7 +1911,7 @@ static const MapType Converge_Crit_Map = { }; /*! - * \brief types of element stiffnesses imposed for FEA mesh deformation + * \brief Types of element stiffnesses imposed for FEA mesh deformation */ enum ENUM_DEFORM_STIFFNESS { CONSTANT_STIFFNESS = 0, /*!< \brief Impose a constant stiffness for each element (steel). */ @@ -1976,7 +1978,7 @@ enum ENUM_RECORDING { }; /*! - * \brief types of schemes for dynamic structural computations + * \brief Types of schemes for dynamic structural computations */ enum ENUM_DYNAMIC { STATIC = 0, /*!< \brief A static structural computation. */ @@ -1988,7 +1990,7 @@ static const MapType Dynamic_Map = { }; /*! - * \brief types of input file formats + * \brief Types of input file formats */ enum ENUM_INPUT_REF { SU2_REF = 1, /*!< \brief SU2 input format (from a restart). */ @@ -2074,7 +2076,7 @@ static const MapType Comm_Map = { }; /* - * \brief types of filter kernels, initially intended for structural topology optimization applications + * \brief Types of filter kernels, initially intended for structural topology optimization applications */ enum ENUM_FILTER_KERNEL { CONSTANT_WEIGHT_FILTER = 0, /*!< \brief Uniform weight. */ @@ -2092,7 +2094,7 @@ static const MapType Filter_Kernel_Map = { }; /*! - * \brief types of projection function, initially intended for structural topology optimization applications + * \brief Types of projection function, initially intended for structural topology optimization applications */ enum ENUM_PROJECTION_FUNCTION { NO_PROJECTION = 0, /*!< \brief No projection. */ From 7e307ea868a8e4645d3c6a41b49e23323a80b114 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Wed, 29 Jan 2020 00:38:55 +0000 Subject: [PATCH 035/118] fix a warning --- SU2_CFD/src/output/COutput.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/src/output/COutput.cpp b/SU2_CFD/src/output/COutput.cpp index 36609ccd116e..b09b11a828f7 100644 --- a/SU2_CFD/src/output/COutput.cpp +++ b/SU2_CFD/src/output/COutput.cpp @@ -2021,7 +2021,7 @@ void COutput::LoadCommonHistoryData(CConfig *config){ /*--- Update the current time only if the time iteration has changed ---*/ - if (SU2_TYPE::Int(GetHistoryFieldValue("TIME_ITER")) != curTimeIter){ + if (static_cast(GetHistoryFieldValue("TIME_ITER")) != curTimeIter){ SetHistoryOutputValue("CUR_TIME", GetHistoryFieldValue("CUR_TIME") + GetHistoryFieldValue("TIME_STEP")); } From d8aba8fe3e7657e45fcde0281b87309d23025574 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Wed, 29 Jan 2020 09:42:56 +0000 Subject: [PATCH 036/118] remove the config .inl --- Common/include/config_structure.hpp | 2139 ++++++++++++++------------- Common/include/config_structure.inl | 2092 -------------------------- Common/src/config_structure.cpp | 2 +- 3 files changed, 1082 insertions(+), 3151 deletions(-) delete mode 100644 Common/include/config_structure.inl diff --git a/Common/include/config_structure.hpp b/Common/include/config_structure.hpp index cbb5ab7d6ece..7c161bf6365b 100644 --- a/Common/include/config_structure.hpp +++ b/Common/include/config_structure.hpp @@ -1324,116 +1324,122 @@ class CConfig { * \param[in] str - the input line string * \param[out] option_name - the name of the option found at the beginning of the line * \param[out] option_value - the tokens found after the "=" sign on the line - * \returns false if the line is empty or a commment, true otherwise + * \return false if the line is empty or a commment, true otherwise */ - bool TokenizeString(string & str, string & option_name, - vector & option_value); + bool TokenizeString(string & str, string & option_name, vector & option_value); /*! * \brief Get reference origin for moment computation. * \param[in] val_marker - the marker we are monitoring. * \return Reference origin (in cartesians coordinates) for moment computation. */ - su2double *GetRefOriginMoment(unsigned short val_marker); + su2double *GetRefOriginMoment(unsigned short val_marker) { + if(val_marker < nMarker_Monitoring) { + RefOriginMoment[0] = RefOriginMoment_X[val_marker]; + RefOriginMoment[1] = RefOriginMoment_Y[val_marker]; + RefOriginMoment[2] = RefOriginMoment_Z[val_marker]; + } + return RefOriginMoment; + } /*! * \brief Get reference origin x-coordinate for moment computation. * \param[in] val_marker - the marker we are monitoring. * \return Reference origin x-coordinate (in cartesians coordinates) for moment computation. */ - su2double GetRefOriginMoment_X(unsigned short val_marker); + su2double GetRefOriginMoment_X(unsigned short val_marker) const { return RefOriginMoment_X[val_marker]; } /*! * \brief Get reference origin y-coordinate for moment computation. * \param[in] val_marker - the marker we are monitoring. * \return Reference origin y-coordinate (in cartesians coordinates) for moment computation. */ - su2double GetRefOriginMoment_Y(unsigned short val_marker); + su2double GetRefOriginMoment_Y(unsigned short val_marker) const { return RefOriginMoment_Y[val_marker]; } /*! * \brief Get reference origin z-coordinate for moment computation. * \param[in] val_marker - the marker we are monitoring. * \return Reference origin z-coordinate (in cartesians coordinates) for moment computation. */ - su2double GetRefOriginMoment_Z(unsigned short val_marker); + su2double GetRefOriginMoment_Z(unsigned short val_marker) const { return RefOriginMoment_Z[val_marker]; } /*! * \brief Set reference origin x-coordinate for moment computation. * \param[in] val_marker - the marker we are monitoring. * \param[in] val_origin - New x-coordinate of the mesh motion origin. */ - void SetRefOriginMoment_X(unsigned short val_marker, su2double val_origin); + void SetRefOriginMoment_X(unsigned short val_marker, su2double val_origin) { RefOriginMoment_X[val_marker] = val_origin; } /*! * \brief Set reference origin y-coordinate for moment computation. * \param[in] val_marker - the marker we are monitoring. * \param[in] val_origin - New y-coordinate of the mesh motion origin. */ - void SetRefOriginMoment_Y(unsigned short val_marker, su2double val_origin); + void SetRefOriginMoment_Y(unsigned short val_marker, su2double val_origin) { RefOriginMoment_Y[val_marker] = val_origin; } /*! * \brief Set reference origin z-coordinate for moment computation. * \param[in] val_marker - the marker we are monitoring. * \param[in] val_origin - New z-coordinate of the mesh motion origin. */ - void SetRefOriginMoment_Z(unsigned short val_marker, su2double val_origin); + void SetRefOriginMoment_Z(unsigned short val_marker, su2double val_origin) { RefOriginMoment_Z[val_marker] = val_origin; } /*! * \brief Get index of the upper and lower horizontal plane. * \param[in] index - 0 means upper surface, and 1 means lower surface. * \return Index of the upper and lower surface. */ - string GetPlaneTag(unsigned short index); + string GetPlaneTag(unsigned short index) const { return PlaneTag[index]; } /*! * \brief Get the integration limits for the equivalent area computation. * \param[in] index - 0 means x_min, and 1 means x_max. * \return Integration limits for the equivalent area computation. */ - su2double GetEA_IntLimit(unsigned short index); + su2double GetEA_IntLimit(unsigned short index) const { return EA_IntLimit[index]; } /*! * \brief Get the integration limits for the equivalent area computation. * \param[in] index - 0 means x_min, and 1 means x_max. * \return Integration limits for the equivalent area computation. */ - su2double GetEA_ScaleFactor(void); + su2double GetEA_ScaleFactor(void) const { return EA_ScaleFactor; } /*! * \brief Get the limit value for the adjoint variables. * \return Limit value for the adjoint variables. */ - su2double GetAdjointLimit(void); + su2double GetAdjointLimit(void) const { return AdjointLimit; } /*! * \brief Get the coordinates where of the box where the grid is going to be deformed. * \return Coordinates where of the box where the grid is going to be deformed. */ - su2double *GetHold_GridFixed_Coord(void); + su2double *GetHold_GridFixed_Coord(void) { return Hold_GridFixed_Coord; } /*! * \brief Get the values of subsonic engine. * \return Values of subsonic engine. */ - su2double *GetSubsonicEngine_Values(void); + su2double *GetSubsonicEngine_Values(void) { return SubsonicEngine_Values; } /*! * \brief Get the cycle of a subsonic engine. * \return Cyl of a subsonic engine. */ - su2double *GetSubsonicEngine_Cyl(void); + su2double *GetSubsonicEngine_Cyl(void) { return SubsonicEngine_Cyl; } /*! * \brief Get the distortion rack. * \return Distortion rack. */ - su2double *GetDistortionRack(void); + su2double *GetDistortionRack(void) { return DistortionRack; } /*! * \brief Get the power of the dual volume in the grid adaptation sensor. * \return Power of the dual volume in the grid adaptation sensor. */ - su2double GetDualVol_Power(void); + su2double GetDualVol_Power(void) const { return DualVol_Power; } /*! * \brief Get Information about if there is an analytical definition of the surface for doing the @@ -1441,127 +1447,127 @@ class CConfig { * \return Definition of the surfaces. NONE implies that there isn't any analytical definition * and it will use and interpolation. */ - unsigned short GetAnalytical_Surface(void); + unsigned short GetAnalytical_Surface(void) const { return Analytical_Surface; } /*! * \brief Get Description of the geometry to be analyzed */ - unsigned short GetGeo_Description(void); + unsigned short GetGeo_Description(void) const { return Geo_Description; } /*! * \brief Creates a tecplot file to visualize the partition made by the DDC software. * \return TRUE if the partition is going to be plotted; otherwise FALSE. */ - bool GetExtraOutput(void); + bool GetExtraOutput(void) const { return ExtraOutput; } /*! * \brief Heat solver zone with extra screen output. * \return Heat solver zone with extra screen output. */ - long GetExtraHeatOutputZone(void); + long GetExtraHeatOutputZone(void) const { return ExtraHeatOutputZone; } /*! * \brief Get the value of the Mach number (velocity divided by speed of sound). * \return Value of the Mach number. */ - su2double GetMach(void); + su2double GetMach(void) const { return Mach; } /*! * \brief Get the value of the Gamma of fluid (ratio of specific heats). * \return Value of the constant: Gamma */ - su2double GetGamma(void); + su2double GetGamma(void) const { return Gamma; } /*! * \brief Get the values of the CFL adaption parameters. * \return Value of CFL adaption parameter */ - su2double GetCFL_AdaptParam(unsigned short val_index); + su2double GetCFL_AdaptParam(unsigned short val_index) const { return CFL_AdaptParam[val_index]; } /*! * \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; } + void SetCFL_AdaptParam(unsigned short val_index, su2double val_cfl_param) { CFL_AdaptParam[val_index] = val_cfl_param; } /*! * \brief Get the value of the CFL adaption flag. * \return TRUE if CFL adaption is active; otherwise FALSE. */ - bool GetCFL_Adapt(void); + bool GetCFL_Adapt(void) const { return CFL_Adapt; } /*! * \brief Get the values of the CFL adapation. * \return Value of CFL adapation */ - su2double GetHTP_Axis(unsigned short val_index); + su2double GetHTP_Axis(unsigned short val_index) const { return HTP_Axis[val_index]; } /*! * \brief Get the value of the limits for the sections. * \return Value of the limits for the sections. */ - su2double GetStations_Bounds(unsigned short val_var); + su2double GetStations_Bounds(unsigned short val_var) const { return Stations_Bounds[val_var]; } /*! * \brief Get the value of the vector that connects the cartesian axis with a sherical or cylindrical one. * \return Coordinate of the Axis. */ - su2double GetFFD_Axis(unsigned short val_var); + su2double GetFFD_Axis(unsigned short val_var) const { return FFD_Axis[val_var]; } /*! * \brief Get the value of the bulk modulus. * \return Value of the bulk modulus. */ - su2double GetBulk_Modulus(void); + su2double GetBulk_Modulus(void) const { return Bulk_Modulus; } /*! * \brief Get the epsilon^2 multiplier for Beta in the incompressible preconditioner. * \return Value of the epsilon^2 multiplier for Beta in the incompressible preconditioner. */ - su2double GetBeta_Factor(void); + su2double GetBeta_Factor(void) const { return Beta_Factor; } /*! * \brief Get the value of specific gas constant. * \return Value of the constant: Gamma */ - su2double GetGas_Constant(void); + su2double GetGas_Constant(void) const { return Gas_Constant; } /*! * \brief Get the value of specific gas constant. * \return Value of the constant: Gamma */ - su2double GetGas_ConstantND(void); + su2double GetGas_ConstantND(void) const { return Gas_ConstantND; } /*! * \brief Get the value of the molecular weight for an incompressible ideal gas (g/mol). * \return Value of the molecular weight for an incompressible ideal gas (g/mol). */ - su2double GetMolecular_Weight(void); + su2double GetMolecular_Weight(void) const { return Molecular_Weight; } /*! * \brief Get the value of specific heat at constant pressure. * \return Value of the constant: Cp */ - su2double GetSpecific_Heat_Cp(void); + su2double GetSpecific_Heat_Cp(void) const { return Specific_Heat_Cp; } /*! * \brief Get the non-dimensional value of specific heat at constant pressure. * \return Value of the non-dim. constant: Cp */ - su2double GetSpecific_Heat_CpND(void); + su2double GetSpecific_Heat_CpND(void) const { return Specific_Heat_CpND; } /*! * \brief Get the value of specific heat at constant volume. * \return Value of the constant: Cv */ - su2double GetSpecific_Heat_Cv(void); + su2double GetSpecific_Heat_Cv(void) const { return Specific_Heat_Cv; } /*! * \brief Get the non-dimensional value of specific heat at constant volume. * \return Value of the non-dim. constant: Cv */ - su2double GetSpecific_Heat_CvND(void); + su2double GetSpecific_Heat_CvND(void) const { return Specific_Heat_CvND; } /*! * \brief Get the coefficients of the Blottner viscosity model @@ -1581,326 +1587,326 @@ class CConfig { * \brief Get the value of wall temperature. * \return Value of the constant: Temperature */ - su2double GetWallTemperature(void); + su2double GetWallTemperature(void) const { return Wall_Temperature; } /*! * \brief Get the reference value for the specific gas constant. * \return Reference value for the specific gas constant. */ - su2double GetGas_Constant_Ref(void); + su2double GetGas_Constant_Ref(void) const { return Gas_Constant_Ref; } /*! * \brief Get the reference value for the heat flux. * \return Reference value for the heat flux. */ - su2double GetHeat_Flux_Ref(void); + su2double GetHeat_Flux_Ref(void) const { return Heat_Flux_Ref; } /*! * \brief Get the value of the frestream temperature. * \return Freestream temperature. */ - su2double GetTemperature_FreeStream(void); + su2double GetTemperature_FreeStream(void) const { return Temperature_FreeStream; } /*! * \brief Get the value of the frestream temperature. * \return Freestream temperature. */ - su2double GetEnergy_FreeStream(void); + su2double GetEnergy_FreeStream(void) const { return Energy_FreeStream; } /*! * \brief Get the value of the frestream temperature. * \return Freestream temperature. */ - su2double GetViscosity_FreeStream(void); + su2double GetViscosity_FreeStream(void) const { return Viscosity_FreeStream; } /*! * \brief Get the value of the frestream temperature. * \return Freestream temperature. */ - su2double GetDensity_FreeStream(void); + su2double GetDensity_FreeStream(void) const { return Density_FreeStream; } /*! * \brief Get the value of the solid density. * \return Solid density. */ - su2double GetDensity_Solid(void); + su2double GetDensity_Solid(void) const { return Density_Solid; } /*! * \brief Get the value of the frestream temperature. * \return Freestream temperature. */ - su2double GetModVel_FreeStream(void); + su2double GetModVel_FreeStream(void) const { return ModVel_FreeStream; } /*! * \brief Get the value of the frestream temperature. * \return Freestream temperature. */ - su2double GetModVel_FreeStreamND(void); + su2double GetModVel_FreeStreamND(void) const { return ModVel_FreeStreamND; } /*! * \brief Get the value of the frestream vibrational-electronic temperature. * \return Freestream temperature ve. */ - su2double GetTemperature_ve_FreeStream(void); + su2double GetTemperature_ve_FreeStream(void) const { return Temperature_ve_FreeStream; } /*! * \brief Get the value of the laminar Prandtl number. * \return Laminar Prandtl number. */ - su2double GetPrandtl_Lam(void); + su2double GetPrandtl_Lam(void) const { return Prandtl_Lam; } /*! * \brief Get the value of the turbulent Prandtl number. * \return Turbulent Prandtl number. */ - su2double GetPrandtl_Turb(void); + su2double GetPrandtl_Turb(void) const { return Prandtl_Turb; } /*! * \brief Get the value of the thermal conductivity for solids. * \return Thermal conductivity (solid). */ - su2double GetThermalConductivity_Solid(void); + su2double GetThermalConductivity_Solid(void) const { return Thermal_Conductivity_Solid; } /*! * \brief Get the value of the thermal diffusivity for solids. * \return Thermal conductivity (solid). */ - su2double GetThermalDiffusivity_Solid(void); + su2double GetThermalDiffusivity_Solid(void) const { return Thermal_Diffusivity_Solid; } /*! * \brief Get the temperature in solids at initial conditions. * \return Freestream temperature (solid). */ - su2double GetTemperature_Initial_Solid(void); + su2double GetTemperature_Initial_Solid(void) const { return Temperature_Freestream_Solid; } /*! * \brief Get the value of the reference length for non-dimensionalization. * This value should always be 1 internally, and is not user-specified. * \return Reference length for non-dimensionalization. */ - su2double GetLength_Ref(void); + su2double GetLength_Ref(void) const { return Length_Ref; } /*! * \brief Get the value of the reference pressure for non-dimensionalization. * \return Reference pressure for non-dimensionalization. */ - su2double GetPressure_Ref(void); + su2double GetPressure_Ref(void) const { return Pressure_Ref; } /*! * \brief Get the value of the reference pressure for non-dimensionalization. * \return Reference pressure for non-dimensionalization. */ - su2double GetEnergy_Ref(void); + su2double GetEnergy_Ref(void) const { return Energy_Ref; } /*! * \brief Get the value of the reference temperature for non-dimensionalization. * \return Reference temperature for non-dimensionalization. */ - su2double GetTemperature_Ref(void); + su2double GetTemperature_Ref(void) const { return Temperature_Ref; } /*! * \brief Get the value of the reference density for non-dimensionalization. * \return Reference density for non-dimensionalization. */ - su2double GetDensity_Ref(void); + su2double GetDensity_Ref(void) const { return Density_Ref; } /*! * \brief Get the value of the reference velocity for non-dimensionalization. * \return Reference velocity for non-dimensionalization. */ - su2double GetVelocity_Ref(void); + su2double GetVelocity_Ref(void) const { return Velocity_Ref; } /*! * \brief Get the value of the reference time for non-dimensionalization. * \return Reference time for non-dimensionalization. */ - su2double GetTime_Ref(void); + su2double GetTime_Ref(void) const { return Time_Ref; } /*! * \brief Get the value of the reference viscosity for non-dimensionalization. * \return Reference viscosity for non-dimensionalization. */ - su2double GetViscosity_Ref(void); + su2double GetViscosity_Ref(void) const { return Viscosity_Ref; } /*! * \brief Get the value of the reference viscosity for non-dimensionalization. * \return Reference viscosity for non-dimensionalization. */ - su2double GetHighlite_Area(void); + su2double GetHighlite_Area(void) const { return Highlite_Area; } /*! * \brief Get the value of the reference viscosity for non-dimensionalization. * \return Reference viscosity for non-dimensionalization. */ - su2double GetFan_Poly_Eff(void); + su2double GetFan_Poly_Eff(void) const { return Fan_Poly_Eff; } /*! * \brief Get the value of the reference conductivity for non-dimensionalization. * \return Reference conductivity for non-dimensionalization. */ - su2double GetConductivity_Ref(void); + su2double GetConductivity_Ref(void) const { return Conductivity_Ref; } /*! * \brief Get the value of the reference angular velocity for non-dimensionalization. * \return Reference angular velocity for non-dimensionalization. */ - su2double GetOmega_Ref(void); + su2double GetOmega_Ref(void) const { return Omega_Ref; } /*! * \brief Get the value of the reference force for non-dimensionalization. * \return Reference force for non-dimensionalization. */ - su2double GetForce_Ref(void); + su2double GetForce_Ref(void) const { return Force_Ref; } /*! * \brief Get the value of the non-dimensionalized freestream pressure. * \return Non-dimensionalized freestream pressure. */ - su2double GetPressure_FreeStream(void); + su2double GetPressure_FreeStream(void) const { return Pressure_FreeStream; } /*! * \brief Get the value of the non-dimensionalized freestream pressure. * \return Non-dimensionalized freestream pressure. */ - su2double GetPressure_FreeStreamND(void); + su2double GetPressure_FreeStreamND(void) const { return Pressure_FreeStreamND; } /*! * \brief Get the value of the thermodynamic pressure. * \return Thermodynamic pressure. */ - su2double GetPressure_Thermodynamic(void); + su2double GetPressure_Thermodynamic(void) const { return Pressure_Thermodynamic; } /*! * \brief Get the value of the non-dimensionalized thermodynamic pressure. * \return Non-dimensionalized thermodynamic pressure. */ - su2double GetPressure_ThermodynamicND(void); + su2double GetPressure_ThermodynamicND(void) const { return Pressure_ThermodynamicND; } /*! * \brief Get the vector of the dimensionalized freestream velocity. * \return Dimensionalized freestream velocity vector. */ - su2double* GetVelocity_FreeStream(void); + su2double* GetVelocity_FreeStream(void) { return Velocity_FreeStream; } /*! * \brief Get the value of the non-dimensionalized freestream temperature. * \return Non-dimensionalized freestream temperature. */ - su2double GetTemperature_FreeStreamND(void); + su2double GetTemperature_FreeStreamND(void) const { return Temperature_FreeStreamND; } /*! * \brief Get the value of the non-dimensionalized freestream density. * \return Non-dimensionalized freestream density. */ - su2double GetDensity_FreeStreamND(void); + su2double GetDensity_FreeStreamND(void) const { return Density_FreeStreamND; } /*! * \brief Get the vector of the non-dimensionalized freestream velocity. * \return Non-dimensionalized freestream velocity vector. */ - su2double* GetVelocity_FreeStreamND(void); + su2double* GetVelocity_FreeStreamND(void) { return Velocity_FreeStreamND; } /*! * \brief Get the value of the non-dimensionalized freestream energy. * \return Non-dimensionalized freestream energy. */ - su2double GetEnergy_FreeStreamND(void); + su2double GetEnergy_FreeStreamND(void) const { return Energy_FreeStreamND; } /*! * \brief Get the value of the non-dimensionalized freestream viscosity. * \return Non-dimensionalized freestream viscosity. */ - su2double GetViscosity_FreeStreamND(void); + su2double GetViscosity_FreeStreamND(void) const { return Viscosity_FreeStreamND; } /*! * \brief Get the value of the non-dimensionalized freestream viscosity. * \return Non-dimensionalized freestream viscosity. */ - su2double GetTke_FreeStreamND(void); + su2double GetTke_FreeStreamND(void) const { return Tke_FreeStreamND; } /*! * \brief Get the value of the non-dimensionalized freestream viscosity. * \return Non-dimensionalized freestream viscosity. */ - su2double GetOmega_FreeStreamND(void); + su2double GetOmega_FreeStreamND(void) const { return Omega_FreeStreamND; } /*! * \brief Get the value of the non-dimensionalized freestream viscosity. * \return Non-dimensionalized freestream viscosity. */ - su2double GetTke_FreeStream(void); + su2double GetTke_FreeStream(void) const { return Tke_FreeStream; } /*! * \brief Get the value of the non-dimensionalized freestream viscosity. * \return Non-dimensionalized freestream viscosity. */ - su2double GetOmega_FreeStream(void); + su2double GetOmega_FreeStream(void) const { return Omega_FreeStream; } /*! * \brief Get the value of the non-dimensionalized freestream intermittency. * \return Non-dimensionalized freestream intermittency. */ - su2double GetIntermittency_FreeStream(void); + su2double GetIntermittency_FreeStream(void) const { return Intermittency_FreeStream; } /*! * \brief Get the value of the non-dimensionalized freestream turbulence intensity. * \return Non-dimensionalized freestream intensity. */ - su2double GetTurbulenceIntensity_FreeStream(void); + su2double GetTurbulenceIntensity_FreeStream(void) const { return TurbulenceIntensity_FreeStream; } /*! * \brief Get the value of the non-dimensionalized freestream turbulence intensity. * \return Non-dimensionalized freestream intensity. */ - su2double GetNuFactor_FreeStream(void); + su2double GetNuFactor_FreeStream(void) const { return NuFactor_FreeStream; } /*! * \brief Get the value of the non-dimensionalized engine turbulence intensity. * \return Non-dimensionalized engine intensity. */ - su2double GetNuFactor_Engine(void); + su2double GetNuFactor_Engine(void) const { return NuFactor_Engine; } /*! * \brief Get the value of the non-dimensionalized actuator disk turbulence intensity. * \return Non-dimensionalized actuator disk intensity. */ - su2double GetSecondaryFlow_ActDisk(void); + su2double GetSecondaryFlow_ActDisk(void) const { return SecondaryFlow_ActDisk; } /*! * \brief Get the value of the non-dimensionalized actuator disk turbulence intensity. * \return Non-dimensionalized actuator disk intensity. */ - su2double GetInitial_BCThrust(void); + su2double GetInitial_BCThrust(void) const { return Initial_BCThrust; } /*! * \brief Get the value of the non-dimensionalized actuator disk turbulence intensity. * \return Non-dimensionalized actuator disk intensity. */ - void SetInitial_BCThrust(su2double val_bcthrust); + void SetInitial_BCThrust(su2double val_bcthrust) { Initial_BCThrust = val_bcthrust; } /*! * \brief Get the value of the turbulent to laminar viscosity ratio. * \return Ratio of turbulent to laminar viscosity ratio. */ - su2double GetTurb2LamViscRatio_FreeStream(void); + su2double GetTurb2LamViscRatio_FreeStream(void) const { return Turb2LamViscRatio_FreeStream;} /*! * \brief Get the vector of free stream mass fraction values. * \return Ratio of species mass to mixture mass. */ - su2double* GetMassFrac_FreeStream(void); + su2double* GetMassFrac_FreeStream(void) { return MassFrac_FreeStream; } /*! * \brief Get the value of the Reynolds length. * \return Reynolds length. */ - su2double GetLength_Reynolds(void); + su2double GetLength_Reynolds(void) const { return Length_Reynolds; } /*! * \brief Get the start up iterations using the fine grid, this works only for multigrid problems. * \return Start up iterations using the fine grid. */ - unsigned short GetnStartUpIter(void); + unsigned short GetnStartUpIter(void) const { return nStartUpIter; } /*! * \brief Get the reference area for non dimensional coefficient computation. If the value from the @@ -1908,85 +1914,85 @@ class CConfig { * the z plane (3D) or the x plane (2D). * \return Value of the reference area for coefficient computation. */ - su2double GetRefArea(void); + su2double GetRefArea(void) const { return RefArea; } /*! * \brief Get the wave speed. * \return Value of the wave speed. */ - su2double GetThermalDiffusivity(void); + su2double GetThermalDiffusivity(void) const { return Thermal_Diffusivity; } /*! * \brief Get the thermal expansion coefficient. * \return Value of the thermal expansion coefficient. */ - su2double GetThermal_Expansion_Coeff(void); + su2double GetThermal_Expansion_Coeff(void) const { return Thermal_Expansion_Coeff; } /*! * \brief Get the non-dim. thermal expansion coefficient. * \return Value of the non-dim. thermal expansion coefficient. */ - su2double GetThermal_Expansion_CoeffND(void); + su2double GetThermal_Expansion_CoeffND(void) const { return Thermal_Expansion_CoeffND; } /*! * \brief Set the thermal expansion coefficient. * \param[in] val_thermal_expansion - thermal expansion coefficient */ - void SetThermal_Expansion_Coeff(su2double val_thermal_expansion); + void SetThermal_Expansion_Coeff(su2double val_thermal_expansion) { Thermal_Expansion_Coeff = val_thermal_expansion; } /*! * \brief Set the non-dim. thermal expansion coefficient. * \param[in] val_thermal_expansion - non-dim. thermal expansion coefficient */ - void SetThermal_Expansion_CoeffND(su2double val_thermal_expansionnd); + void SetThermal_Expansion_CoeffND(su2double val_thermal_expansionnd) { Thermal_Expansion_CoeffND = val_thermal_expansionnd; } /*! * \brief Get the value of the reference density for custom incompressible non-dimensionalization. * \return Reference density for custom incompressible non-dimensionalization. */ - su2double GetInc_Density_Ref(void); + su2double GetInc_Density_Ref(void) const { return Inc_Density_Ref; } /*! * \brief Get the value of the reference velocity for custom incompressible non-dimensionalization. * \return Reference velocity for custom incompressible non-dimensionalization. */ - su2double GetInc_Velocity_Ref(void); + su2double GetInc_Velocity_Ref(void) const { return Inc_Velocity_Ref; } /*! * \brief Get the value of the reference temperature for custom incompressible non-dimensionalization. * \return Reference temperature for custom incompressible non-dimensionalization. */ - su2double GetInc_Temperature_Ref(void); + su2double GetInc_Temperature_Ref(void) const { return Inc_Temperature_Ref; } /*! * \brief Get the value of the initial density for incompressible flows. * \return Initial density for incompressible flows. */ - su2double GetInc_Density_Init(void); + su2double GetInc_Density_Init(void) const { return Inc_Density_Init; } /*! * \brief Get the value of the initial velocity for incompressible flows. * \return Initial velocity for incompressible flows. */ - su2double* GetInc_Velocity_Init(void); + su2double* GetInc_Velocity_Init(void) { return Inc_Velocity_Init; } /*! * \brief Get the value of the initial temperature for incompressible flows. * \return Initial temperature for incompressible flows. */ - su2double GetInc_Temperature_Init(void); + su2double GetInc_Temperature_Init(void) const { return Inc_Temperature_Init; } /*! * \brief Get the Young's modulus of elasticity. * \return Value of the Young's modulus of elasticity. */ - su2double GetElasticyMod(unsigned short id_val); + su2double GetElasticyMod(unsigned short id_val) const { return ElasticityMod[id_val]; } /*! * \brief Decide whether to apply DE effects to the model. * \return TRUE if the DE effects are to be applied, FALSE otherwise. */ - bool GetDE_Effects(void); + bool GetDE_Effects(void) const { return DE_Effects; } /*! * \brief Decide whether to predict the DE effects for the next time step. @@ -1998,178 +2004,178 @@ class CConfig { * \brief Get the number of different electric constants. * \return Value of the DE modulus. */ - unsigned short GetnElectric_Constant(void); + unsigned short GetnElectric_Constant(void) const { return nElectric_Constant; } /*! * \brief Get the value of the DE modulus. * \return Value of the DE modulus. */ - su2double GetElectric_Constant(unsigned short iVar); + su2double GetElectric_Constant(unsigned short iVar) const { return Electric_Constant[iVar]; } /*! * \brief Get the value of the B constant in the Knowles material model. * \return Value of the B constant in the Knowles material model. */ - su2double GetKnowles_B(void); + su2double GetKnowles_B(void) const { return Knowles_B; } /*! * \brief Get the value of the N constant in the Knowles material model. * \return Value of the N constant in the Knowles material model. */ - su2double GetKnowles_N(void); + su2double GetKnowles_N(void) const { return Knowles_N; } /*! * \brief Get the kind of design variable for FEA. * \return Value of the DE voltage. */ - unsigned short GetDV_FEA(void); + unsigned short GetDV_FEA(void) const { return Kind_DV_FEA; } /*! * \brief Get the ID of the reference node. * \return Number of FSI subiters. */ - unsigned long GetRefNode_ID(void); + unsigned long GetRefNode_ID(void) const { return refNodeID; } /*! * \brief Get the values for the reference node displacement. * \param[in] val_coeff - Index of the displacement. */ - su2double GetRefNode_Displacement(unsigned short val_coeff); + su2double GetRefNode_Displacement(unsigned short val_coeff) const { return RefNode_Displacement[val_coeff]; } /*! * \brief Get the penalty weight value for the objective function. * \return Penalty weight value for the reference geometry objective function. */ - su2double GetRefNode_Penalty(void); + su2double GetRefNode_Penalty(void) const { return RefNode_Penalty; } /*! * \brief Decide whether it's necessary to read a reference geometry. * \return TRUE if it's necessary to read a reference geometry, FALSE otherwise. */ - bool GetRefGeom(void); + bool GetRefGeom(void) const { return RefGeom; } /*! * \brief Get the name of the file with the reference geometry of the structural problem. * \return Name of the file with the reference geometry of the structural problem. */ - string GetRefGeom_FEMFileName(void); + string GetRefGeom_FEMFileName(void) const { return RefGeom_FEMFileName; } /*! * \brief Get the format of the reference geometry file. * \return Format of the reference geometry file. */ - unsigned short GetRefGeom_FileFormat(void); + unsigned short GetRefGeom_FileFormat(void) const { return RefGeom_FileFormat; } /*! * \brief Formulation for 2D elasticity (plane stress - strain) * \return Flag to 2D elasticity model. */ - unsigned short GetElas2D_Formulation(void); + unsigned short GetElas2D_Formulation(void) const { return Kind_2DElasForm; } /*! * \brief Decide whether it's necessary to read a reference geometry. * \return TRUE if it's necessary to read a reference geometry, FALSE otherwise. */ - bool GetPrestretch(void); + bool GetPrestretch(void) const { return Prestretch; } /*! * \brief Decide whether it's necessary to add the cross term for adjoint FSI. * \return TRUE if it's necessary to add the cross term, FALSE otherwise. */ - bool Add_CrossTerm(void); + bool Add_CrossTerm(void) const { return addCrossTerm; } /*! * \brief Set the boolean addCrossTerm to true or false. */ - void Set_CrossTerm(bool needCrossTerm); + void Set_CrossTerm(bool needCrossTerm) { addCrossTerm = needCrossTerm; } /*! * \brief Get the name of the file with the element properties for structural problems. * \return Name of the file with the element properties of the structural problem. */ - string GetFEA_FileName(void); + string GetFEA_FileName(void) const { return FEA_FileName; } /*! * \brief Get the name of the file with the reference geometry of the structural problem. * \return Name of the file with the reference geometry of the structural problem. */ - string GetPrestretch_FEMFileName(void); + string GetPrestretch_FEMFileName(void) const { return Prestretch_FEMFileName; } /*! * \brief Get the Poisson's ratio. * \return Value of the Poisson's ratio. */ - su2double GetPoissonRatio(unsigned short id_val); + su2double GetPoissonRatio(unsigned short id_val) const { return PoissonRatio[id_val]; } /*! * \brief Get the Material Density. * \return Value of the Material Density. */ - su2double GetMaterialDensity(unsigned short id_val); + su2double GetMaterialDensity(unsigned short id_val) const { return MaterialDensity[id_val]; } /*! * \brief Compressibility/incompressibility of the solids analysed using the structural solver. * \return Compressible or incompressible. */ - unsigned short GetMaterialCompressibility(void); + unsigned short GetMaterialCompressibility(void) const { return Kind_Material_Compress; } /*! * \brief Compressibility/incompressibility of the solids analysed using the structural solver. * \return Compressible or incompressible. */ - unsigned short GetMaterialModel(void); + unsigned short GetMaterialModel(void) const { return Kind_Material; } /*! * \brief Geometric conditions for the structural solver. * \return Small or large deformation structural analysis. */ - unsigned short GetGeometricConditions(void); + unsigned short GetGeometricConditions(void) const { return Kind_Struct_Solver; } /*! * \brief Get the reference length for computing moment (the default value is 1). * \return Reference length for moment computation. */ - su2double GetRefLength(void); + su2double GetRefLength(void) const { return RefLength; } /*! * \brief Get the reference element length for computing the slope limiting epsilon. * \return Reference element length for slope limiting epsilon. */ - su2double GetRefElemLength(void); + su2double GetRefElemLength(void) const { return RefElemLength; } /*! * \brief Get the reference coefficient for detecting sharp edges. * \return Reference coefficient for detecting sharp edges. */ - su2double GetRefSharpEdges(void); + su2double GetRefSharpEdges(void) const { return RefSharpEdges; } /*! * \brief Get the volume of the whole domain using the fine grid, this value is common for all the grids * in the multigrid method. * \return Volume of the whole domain. */ - su2double GetDomainVolume(void); + su2double GetDomainVolume(void) const { return DomainVolume; } /*! * \brief In case the RefArea is equal to 0 then, it is necessary to compute a reference area, * with this function we set the value of the reference area. * \param[in] val_area - Value of the reference area for non dimensional coefficient computation. */ - void SetRefArea(su2double val_area); + void SetRefArea(su2double val_area) { RefArea = val_area; } /*! * \brief In case the SemiSpan is equal to 0 then, it is necessary to compute the max y distance, * with this function we set the value of the semi span. * \param[in] val_semispan - Value of the semispan. */ - void SetSemiSpan(su2double val_semispan); + void SetSemiSpan(su2double val_semispan) { SemiSpan = val_semispan; } /*! * \brief Set the value of the domain volume computed on the finest grid. * \note This volume do not include the volume of the body that is being simulated. * \param[in] val_volume - Value of the domain volume computed on the finest grid. */ - void SetDomainVolume(su2double val_volume); + void SetDomainVolume(su2double val_volume) { DomainVolume = val_volume; } /*! * \brief Set the finest mesh in a multigrid strategy. @@ -2177,7 +2183,7 @@ class CConfig { * to change several times the finest grid. * \param[in] val_finestmesh - Index of the finest grid. */ - void SetFinestMesh(unsigned short val_finestmesh); + void SetFinestMesh(unsigned short val_finestmesh) { FinestMesh = val_finestmesh; } /*! * \brief Set the kind of time integration scheme. @@ -2185,7 +2191,7 @@ class CConfig { * times the kind of time integration, to choose the right scheme. * \param[in] val_kind_timeintscheme - Kind of time integration scheme. */ - void SetKind_TimeIntScheme(unsigned short val_kind_timeintscheme); + void SetKind_TimeIntScheme(unsigned short val_kind_timeintscheme) { Kind_TimeNumScheme = val_kind_timeintscheme; } /*! * \brief Set the parameters of the convective numerical scheme. @@ -2205,19 +2211,19 @@ class CConfig { * \brief Get the value of limiter coefficient. * \return Value of the limiter coefficient. */ - su2double GetVenkat_LimiterCoeff(void); + su2double GetVenkat_LimiterCoeff(void) const { return Venkat_LimiterCoeff; } /*! * \brief Freeze the value of the limiter after a number of iterations. * \return Number of iterations. */ - unsigned long GetLimiterIter(void); + unsigned long GetLimiterIter(void) const { return LimiterIter; } /*! * \brief Get the value of sharp edge limiter. * \return Value of the sharp edge limiter coefficient. */ - su2double GetAdjSharp_LimiterCoeff(void); + su2double GetAdjSharp_LimiterCoeff(void) const { return AdjSharp_LimiterCoeff; } /*! * \brief Get the Reynolds number. Dimensionless number that gives a measure of the ratio of inertial forces @@ -2225,278 +2231,278 @@ class CConfig { * for given flow condition. * \return Value of the Reynolds number. */ - su2double GetReynolds(void); + su2double GetReynolds(void) const { return Reynolds; } /*! * \brief Get the Froude number for free surface problems. * \return Value of the Froude number. */ - su2double GetFroude(void); + su2double GetFroude(void) const { return Froude; } /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ - void SetFroude(su2double val_froude); + void SetFroude(su2double val_froude) { Froude = val_froude; } /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ - void SetMach(su2double val_mach); + void SetMach(su2double val_mach) { Mach = val_mach; } /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ - void SetReynolds(su2double val_reynolds); + void SetReynolds(su2double val_reynolds) { Reynolds = val_reynolds; } /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ - void SetLength_Ref(su2double val_length_ref); + void SetLength_Ref(su2double val_length_ref) { Length_Ref = val_length_ref; } /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ - void SetVelocity_Ref(su2double val_velocity_ref); + void SetVelocity_Ref(su2double val_velocity_ref) { Velocity_Ref = val_velocity_ref; } /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ - void SetPressure_Ref(su2double val_pressure_ref); + void SetPressure_Ref(su2double val_pressure_ref) { Pressure_Ref = val_pressure_ref; } /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ - void SetDensity_Ref(su2double val_density_ref); + void SetDensity_Ref(su2double val_density_ref) { Density_Ref = val_density_ref; } /*! * \brief Set the reference temperature. * \return Value of the Froude number. */ - void SetTemperature_Ref(su2double val_temperature_ref); + void SetTemperature_Ref(su2double val_temperature_ref) { Temperature_Ref = val_temperature_ref; } /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ - void SetTime_Ref(su2double val_time_ref); + void SetTime_Ref(su2double val_time_ref) { Time_Ref = val_time_ref; } /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ - void SetEnergy_Ref(su2double val_energy_ref); + void SetEnergy_Ref(su2double val_energy_ref) { Energy_Ref = val_energy_ref; } /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ - void SetOmega_Ref(su2double val_omega_ref); + void SetOmega_Ref(su2double val_omega_ref) { Omega_Ref = val_omega_ref; } /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ - void SetForce_Ref(su2double val_force_ref); + void SetForce_Ref(su2double val_force_ref) { Force_Ref = val_force_ref; } /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ - void SetGas_Constant_Ref(su2double val_gas_constant_ref); + void SetGas_Constant_Ref(su2double val_gas_constant_ref) { Gas_Constant_Ref = val_gas_constant_ref; } /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ - void SetGas_Constant(su2double val_gas_constant); + void SetGas_Constant(su2double val_gas_constant) { Gas_Constant = val_gas_constant; } /*! * \brief Set the value of the specific heat at constant pressure (incompressible fluids with energy equation). * \param[in] val_specific_heat_cp - specific heat at constant pressure. */ - void SetSpecific_Heat_Cp(su2double val_specific_heat_cp); + void SetSpecific_Heat_Cp(su2double val_specific_heat_cp) { Specific_Heat_Cp = val_specific_heat_cp; } /*! * \brief Set the non-dimensional value of the specific heat at constant pressure (incompressible fluids with energy equation). * \param[in] val_specific_heat_cpnd - non-dim. specific heat at constant pressure. */ - void SetSpecific_Heat_CpND(su2double val_specific_heat_cpnd); + void SetSpecific_Heat_CpND(su2double val_specific_heat_cpnd) { Specific_Heat_CpND = val_specific_heat_cpnd; } /*! * \brief Set the value of the specific heat at constant volume (incompressible fluids with energy equation). * \param[in] val_specific_heat_cv - specific heat at constant volume. */ - void SetSpecific_Heat_Cv(su2double val_specific_heat_cv); + void SetSpecific_Heat_Cv(su2double val_specific_heat_cv) { Specific_Heat_Cv = val_specific_heat_cv; } /*! * \brief Set the non-dimensional value of the specific heat at constant volume (incompressible fluids with energy equation). * \param[in] val_specific_heat_cvnd - non-dim. specific heat at constant pressure. */ - void SetSpecific_Heat_CvND(su2double val_specific_heat_cvnd); + void SetSpecific_Heat_CvND(su2double val_specific_heat_cvnd) { Specific_Heat_CvND = val_specific_heat_cvnd; } /*! * \brief Set the heat flux reference value. * \return Value of the reference heat flux. */ - void SetHeat_Flux_Ref(su2double val_heat_flux_ref); + void SetHeat_Flux_Ref(su2double val_heat_flux_ref) { Heat_Flux_Ref = val_heat_flux_ref; } /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ - void SetViscosity_Ref(su2double val_viscosity_ref); + void SetViscosity_Ref(su2double val_viscosity_ref) { Viscosity_Ref = val_viscosity_ref; } /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ - void SetConductivity_Ref(su2double val_conductivity_ref); + void SetConductivity_Ref(su2double val_conductivity_ref) { Conductivity_Ref = val_conductivity_ref; } /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ - void SetPressure_FreeStreamND(su2double val_pressure_freestreamnd); + void SetPressure_FreeStreamND(su2double val_pressure_freestreamnd) { Pressure_FreeStreamND = val_pressure_freestreamnd; } /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ - void SetPressure_FreeStream(su2double val_pressure_freestream); + void SetPressure_FreeStream(su2double val_pressure_freestream) { Pressure_FreeStream = val_pressure_freestream; } /*! * \brief Set the non-dimensionalized thermodynamic pressure for low Mach problems. * \return Value of the non-dimensionalized thermodynamic pressure. */ - void SetPressure_ThermodynamicND(su2double val_pressure_thermodynamicnd); + void SetPressure_ThermodynamicND(su2double val_pressure_thermodynamicnd) { Pressure_ThermodynamicND = val_pressure_thermodynamicnd; } /*! * \brief Set the thermodynamic pressure for low Mach problems. * \return Value of the thermodynamic pressure. */ - void SetPressure_Thermodynamic(su2double val_pressure_thermodynamic); + void SetPressure_Thermodynamic(su2double val_pressure_thermodynamic) { Pressure_Thermodynamic = val_pressure_thermodynamic; } /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ - void SetDensity_FreeStreamND(su2double val_density_freestreamnd); + void SetDensity_FreeStreamND(su2double val_density_freestreamnd) { Density_FreeStreamND = val_density_freestreamnd; } /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ - void SetDensity_FreeStream(su2double val_density_freestream); + void SetDensity_FreeStream(su2double val_density_freestream) { Density_FreeStream = val_density_freestream; } /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ - void SetViscosity_FreeStream(su2double val_viscosity_freestream); + void SetViscosity_FreeStream(su2double val_viscosity_freestream) { Viscosity_FreeStream = val_viscosity_freestream; } /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ - void SetModVel_FreeStream(su2double val_modvel_freestream); + void SetModVel_FreeStream(su2double val_modvel_freestream) { ModVel_FreeStream = val_modvel_freestream; } /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ - void SetModVel_FreeStreamND(su2double val_modvel_freestreamnd); + void SetModVel_FreeStreamND(su2double val_modvel_freestreamnd) { ModVel_FreeStreamND = val_modvel_freestreamnd; } /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ - void SetTemperature_FreeStream(su2double val_temperature_freestream); + void SetTemperature_FreeStream(su2double val_temperature_freestream) { Temperature_FreeStream = val_temperature_freestream; } /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ - void SetTemperature_FreeStreamND(su2double val_temperature_freestreamnd); + void SetTemperature_FreeStreamND(su2double val_temperature_freestreamnd) { Temperature_FreeStreamND = val_temperature_freestreamnd; } /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ - void SetGas_ConstantND(su2double val_gas_constantnd); + void SetGas_ConstantND(su2double val_gas_constantnd) { Gas_ConstantND = val_gas_constantnd; } /*! * \brief Set the free-stream velocity. * \param[in] val_velocity_freestream - Value of the free-stream velocity component. * \param[in] val_dim - Value of the current dimension. */ - void SetVelocity_FreeStream(su2double val_velocity_freestream, unsigned short val_dim); + void SetVelocity_FreeStream(su2double val_velocity_freestream, unsigned short val_dim) { Velocity_FreeStream[val_dim] = val_velocity_freestream; } /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ - void SetVelocity_FreeStreamND(su2double val_velocity_freestreamnd, unsigned short val_dim); + void SetVelocity_FreeStreamND(su2double val_velocity_freestreamnd, unsigned short val_dim) { Velocity_FreeStreamND[val_dim] = val_velocity_freestreamnd; } /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ - void SetViscosity_FreeStreamND(su2double val_viscosity_freestreamnd); + void SetViscosity_FreeStreamND(su2double val_viscosity_freestreamnd) { Viscosity_FreeStreamND = val_viscosity_freestreamnd; } /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ - void SetTke_FreeStreamND(su2double val_tke_freestreamnd); + void SetTke_FreeStreamND(su2double val_tke_freestreamnd) { Tke_FreeStreamND = val_tke_freestreamnd; } /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ - void SetOmega_FreeStreamND(su2double val_omega_freestreamnd); + void SetOmega_FreeStreamND(su2double val_omega_freestreamnd) { Omega_FreeStreamND = val_omega_freestreamnd; } /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ - void SetTke_FreeStream(su2double val_tke_freestream); + void SetTke_FreeStream(su2double val_tke_freestream) { Tke_FreeStream = val_tke_freestream; } /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ - void SetOmega_FreeStream(su2double val_omega_freestream); + void SetOmega_FreeStream(su2double val_omega_freestream) { Omega_FreeStream = val_omega_freestream; } /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ - void SetEnergy_FreeStreamND(su2double val_energy_freestreamnd); + void SetEnergy_FreeStreamND(su2double val_energy_freestreamnd) { Energy_FreeStreamND = val_energy_freestreamnd; } /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ - void SetEnergy_FreeStream(su2double val_energy_freestream); + void SetEnergy_FreeStream(su2double val_energy_freestream) { Energy_FreeStream = val_energy_freestream; } /*! * \brief Set the thermal diffusivity for solids. * \return Value of the Froude number. */ - void SetThermalDiffusivity_Solid(su2double val_thermal_diffusivity); + void SetThermalDiffusivity_Solid(su2double val_thermal_diffusivity) { Thermal_Diffusivity_Solid = val_thermal_diffusivity; } /*! * \brief Set the Froude number for free surface problems. * \return Value of the Froude number. */ - void SetTotal_UnstTimeND(su2double val_total_unsttimend); + void SetTotal_UnstTimeND(su2double val_total_unsttimend) { Total_UnstTimeND = val_total_unsttimend; } /*! * \brief Get the angle of attack of the body. This is the angle between a reference line on a lifting body @@ -2504,134 +2510,134 @@ class CConfig { * lifting body and the fluid through which it is moving. * \return Value of the angle of attack. */ - su2double GetAoA(void); + su2double GetAoA(void) const { return AoA; } /*! * \brief Get the off set angle of attack of the body. The solution and the geometry * file are able to modifity the angle of attack in the config file * \return Value of the off set angle of attack. */ - su2double GetAoA_Offset(void); + su2double GetAoA_Offset(void) const { return AoA_Offset; } /*! * \brief Get the off set sideslip angle of the body. The solution and the geometry * file are able to modifity the angle of attack in the config file * \return Value of the off set sideslip angle. */ - su2double GetAoS_Offset(void); + su2double GetAoS_Offset(void) const { return AoS_Offset; } /*! * \brief Get the functional sensitivity with respect to changes in the angle of attack. * \return Value of the angle of attack. */ - su2double GetAoA_Sens(void); + su2double GetAoA_Sens(void) const { return AoA_Sens; } /*! * \brief Set the angle of attack. * \param[in] val_AoA - Value of the angle of attack. */ - void SetAoA(su2double val_AoA); + void SetAoA(su2double val_AoA) { AoA = val_AoA; } /*! * \brief Set the off set angle of attack. * \param[in] val_AoA - Value of the angle of attack. */ - void SetAoA_Offset(su2double val_AoA_offset); + void SetAoA_Offset(su2double val_AoA_offset) { AoA_Offset = val_AoA_offset; } /*! * \brief Set the off set sideslip angle. * \param[in] val_AoA - Value of the off set sideslip angle. */ - void SetAoS_Offset(su2double val_AoS_offset); + void SetAoS_Offset(su2double val_AoS_offset) { AoS_Offset = val_AoS_offset; } /*! * \brief Set the angle of attack. * \param[in] val_AoA - Value of the angle of attack. */ - void SetAoA_Sens(su2double val_AoA_sens); + void SetAoA_Sens(su2double val_AoA_sens) { AoA_Sens = val_AoA_sens; } /*! * \brief Set the angle of attack. * \param[in] val_AoA - Value of the angle of attack. */ - void SetAoS(su2double val_AoS); + void SetAoS(su2double val_AoS) { AoS = val_AoS; } /*! * \brief Get the angle of sideslip of the body. It relates to the rotation of the aircraft centerline from * the relative wind. * \return Value of the angle of sideslip. */ - su2double GetAoS(void); + su2double GetAoS(void) const { return AoS; } /*! * \brief Get the charge coefficient that is used in the poissonal potential simulation. * \return Value of the charge coefficient. */ - su2double GetChargeCoeff(void); + su2double GetChargeCoeff(void) const { return ChargeCoeff; } /*! * \brief Get the number of multigrid levels. * \return Number of multigrid levels (without including the original grid). */ - unsigned short GetnMGLevels(void); + unsigned short GetnMGLevels(void) const { return nMGLevels; } /*! * \brief Set the number of multigrid levels. * \param[in] val_nMGLevels - Index of the mesh were the CFL is applied */ - void SetMGLevels(unsigned short val_nMGLevels); + void SetMGLevels(unsigned short val_nMGLevels) { nMGLevels = val_nMGLevels; } /*! * \brief Get the index of the finest grid. * \return Index of the finest grid in a multigrid strategy, this is 0 unless we are performing a Full multigrid. */ - unsigned short GetFinestMesh(void); + unsigned short GetFinestMesh(void) const { return FinestMesh; } /*! * \brief Get the kind of multigrid (V or W). * \note This variable is used in a recursive way to perform the different kind of cycles * \return 0 or 1 depending of we are dealing with a V or W cycle. */ - unsigned short GetMGCycle(void); + unsigned short GetMGCycle(void) const { return MGCycle; } /*! * \brief Get the king of evaluation in the geometrical module. * \return 0 or 1 depending of we are dealing with a V or W cycle. */ - unsigned short GetGeometryMode(void); + unsigned short GetGeometryMode(void) const { return GeometryMode; } /*! * \brief Get the Courant Friedrich Levi number for each grid. * \param[in] val_mesh - Index of the mesh were the CFL is applied. * \return CFL number for each grid. */ - su2double GetCFL(unsigned short val_mesh); + su2double GetCFL(unsigned short val_mesh) const { return CFL[val_mesh]; } /*! * \brief Get the Courant Friedrich Levi number for each grid. * \param[in] val_mesh - Index of the mesh were the CFL is applied. * \return CFL number for each grid. */ - void SetCFL(unsigned short val_mesh, su2double val_cfl); + void SetCFL(unsigned short val_mesh, su2double val_cfl) { CFL[val_mesh] = val_cfl; } /*! * \brief Get the Courant Friedrich Levi number for unsteady simulations. * \return CFL number for unsteady simulations. */ - su2double GetUnst_CFL(void); + su2double GetUnst_CFL(void) const { return Unst_CFL; } /*! * \brief Get information about element reorientation * \return TRUE means that elements can be reoriented if suspected unhealthy */ - bool GetReorientElements(void); + bool GetReorientElements(void) const { return ReorientElements; } /*! * \brief Get the Courant Friedrich Levi number for unsteady simulations. * \return CFL number for unsteady simulations. */ - su2double GetMax_DeltaTime(void); + su2double GetMax_DeltaTime(void) const { return Max_DeltaTime; } /*! * \brief Get a parameter of the particular design variable. @@ -2639,7 +2645,7 @@ class CConfig { * \param[in] val_param - Index of the parameter that we want to read. * \return Design variable parameter. */ - su2double GetParamDV(unsigned short val_dv, unsigned short val_param); + su2double GetParamDV(unsigned short val_dv, unsigned short val_param) const { return ParamDV[val_dv][val_param]; } /*! * \brief Get the coordinates of the FFD corner points. @@ -2647,7 +2653,7 @@ class CConfig { * \param[in] val_coord - Index of the coordinate that we want to read. * \return Value of the coordinate. */ - su2double GetCoordFFDBox(unsigned short val_ffd, unsigned short val_index); + su2double GetCoordFFDBox(unsigned short val_ffd, unsigned short val_index) const { return CoordFFDBox[val_ffd][val_index]; } /*! * \brief Get the degree of the FFD corner points. @@ -2655,374 +2661,374 @@ class CConfig { * \param[in] val_degree - Index (I,J,K) to obtain the degree. * \return Value of the degree in a particular direction. */ - unsigned short GetDegreeFFDBox(unsigned short val_ffd, unsigned short val_index); + unsigned short GetDegreeFFDBox(unsigned short val_ffd, unsigned short val_index) const { return DegreeFFDBox[val_ffd][val_index]; } /*! * \brief Get the FFD Tag of a particular design variable. * \param[in] val_dv - Number of the design variable that we want to read. * \return Name of the FFD box. */ - string GetFFDTag(unsigned short val_dv); + string GetFFDTag(unsigned short val_dv) const { return FFDTag[val_dv]; } /*! * \brief Get the FFD Tag of a particular FFD box. * \param[in] val_ffd - Number of the FFD box that we want to read. * \return Name of the FFD box. */ - string GetTagFFDBox(unsigned short val_ffd); + string GetTagFFDBox(unsigned short val_ffd) const { return TagFFDBox[val_ffd]; } /*! * \brief Get the number of design variables. * \return Number of the design variables. */ - unsigned short GetnDV(void); + unsigned short GetnDV(void) const { return nDV; } /*! * \brief Get the number of design variables. * \return Number of the design variables. */ - unsigned short GetnDV_Value(unsigned short iDV); + unsigned short GetnDV_Value(unsigned short iDV) const { return nDV_Value[iDV]; } /*! * \brief Get the number of FFD boxes. * \return Number of FFD boxes. */ - unsigned short GetnFFDBox(void); + unsigned short GetnFFDBox(void) const { return nFFDBox; } /*! * \brief Get the required continuity level at the surface intersection with the FFD * \return Continuity level at the surface intersection. */ - unsigned short GetFFD_Continuity(void); + unsigned short GetFFD_Continuity(void) const { return FFD_Continuity; } /*! * \brief Get the coordinate system that we are going to use to define the FFD * \return Coordinate system (cartesian, spherical, etc). */ - unsigned short GetFFD_CoordSystem(void); + unsigned short GetFFD_CoordSystem(void) const { return FFD_CoordSystem; } /*! * \brief Get the kind of FFD Blending function. * \return Kind of FFD Blending function. */ - unsigned short GetFFD_Blending(void); + unsigned short GetFFD_Blending(void) const { return FFD_Blending;} /*! * \brief Get the kind BSpline Order in i,j,k direction. * \return The kind BSpline Order in i,j,k direction. */ - su2double* GetFFD_BSplineOrder(); + su2double* GetFFD_BSplineOrder() { return FFD_BSpline_Order;} /*! * \brief Get the number of Runge-Kutta steps. * \return Number of Runge-Kutta steps. */ - unsigned short GetnRKStep(void); + unsigned short GetnRKStep(void) const { return nRKStep; } /*! * \brief Get the number of time levels for time accurate local time stepping. * \return Number of time levels. */ - unsigned short GetnLevels_TimeAccurateLTS(void); + unsigned short GetnLevels_TimeAccurateLTS(void) const { return nLevels_TimeAccurateLTS; } /*! * \brief Set the number of time levels for time accurate local time stepping. * \param[in] val_nLevels - The number of time levels to be set. */ - void SetnLevels_TimeAccurateLTS(unsigned short val_nLevels); + void SetnLevels_TimeAccurateLTS(unsigned short val_nLevels) { nLevels_TimeAccurateLTS = val_nLevels;} /*! * \brief Get the number time DOFs for ADER-DG. * \return Number of time DOFs used in ADER-DG. */ - unsigned short GetnTimeDOFsADER_DG(void); + unsigned short GetnTimeDOFsADER_DG(void) const { return nTimeDOFsADER_DG; } /*! * \brief Get the location of the time DOFs for ADER-DG on the interval [-1..1]. * \return The location of the time DOFs used in ADER-DG. */ - su2double *GetTimeDOFsADER_DG(void); + su2double *GetTimeDOFsADER_DG(void) { return TimeDOFsADER_DG; } /*! * \brief Get the number time integration points for ADER-DG. * \return Number of time integration points used in ADER-DG. */ - unsigned short GetnTimeIntegrationADER_DG(void); + unsigned short GetnTimeIntegrationADER_DG(void) const { return nTimeIntegrationADER_DG; } /*! * \brief Get the location of the time integration points for ADER-DG on the interval [-1..1]. * \return The location of the time integration points used in ADER-DG. */ - su2double *GetTimeIntegrationADER_DG(void); + su2double *GetTimeIntegrationADER_DG(void) { return TimeIntegrationADER_DG; } /*! * \brief Get the weights of the time integration points for ADER-DG. * \return The weights of the time integration points used in ADER-DG. */ - su2double *GetWeightsIntegrationADER_DG(void); + su2double *GetWeightsIntegrationADER_DG(void) { return WeightsIntegrationADER_DG; } /*! * \brief Get the total number of boundary markers including send/receive domains. * \return Total number of boundary markers. */ - unsigned short GetnMarker_All(void); + unsigned short GetnMarker_All(void) const { return nMarker_All; } /*! * \brief Get the total number of boundary markers in the config file. * \return Total number of boundary markers. */ - unsigned short GetnMarker_CfgFile(void); + unsigned short GetnMarker_CfgFile(void) const { return nMarker_CfgFile; } /*! * \brief Get the number of Euler boundary markers. * \return Number of Euler boundary markers. */ - unsigned short GetnMarker_Euler(void); + unsigned short GetnMarker_Euler(void) const { return nMarker_Euler; } /*! * \brief Get the number of symmetry boundary markers. * \return Number of symmetry boundary markers. */ - unsigned short GetnMarker_SymWall(void); + unsigned short GetnMarker_SymWall(void) const { return nMarker_SymWall; } /*! * \brief Get the total number of boundary markers. * \return Total number of boundary markers. */ - unsigned short GetnMarker_Max(void); + unsigned short GetnMarker_Max(void) const { return nMarker_Max; } /*! * \brief Get the total number of boundary markers. * \return Total number of boundary markers. */ - unsigned short GetnMarker_EngineInflow(void); + unsigned short GetnMarker_EngineInflow(void) const { return nMarker_EngineInflow; } /*! * \brief Get the total number of boundary markers. * \return Total number of boundary markers. */ - unsigned short GetnMarker_EngineExhaust(void); + unsigned short GetnMarker_EngineExhaust(void) const { return nMarker_EngineExhaust; } /*! * \brief Get the total number of boundary markers. * \return Total number of boundary markers. */ - unsigned short GetnMarker_NearFieldBound(void); + unsigned short GetnMarker_NearFieldBound(void) const { return nMarker_NearFieldBound; } /*! * \brief Get the total number of deformable markers at the boundary. * \return Total number of deformable markers at the boundary. */ - unsigned short GetnMarker_Deform_Mesh(void); + unsigned short GetnMarker_Deform_Mesh(void) const { return nMarker_Deform_Mesh; } /*! * \brief Get the total number of markers in which the flow load is computed/employed. * \return Total number of markers in which the flow load is computed/employed. */ - unsigned short GetnMarker_Fluid_Load(void); + unsigned short GetnMarker_Fluid_Load(void) const { return nMarker_Fluid_Load; } /*! * \brief Get the total number of boundary markers. * \return Total number of boundary markers. */ - unsigned short GetnMarker_Fluid_InterfaceBound(void); + unsigned short GetnMarker_Fluid_InterfaceBound(void) const { return nMarker_Fluid_InterfaceBound; } /*! * \brief Get the total number of boundary markers. * \return Total number of boundary markers. */ - unsigned short GetnMarker_ActDiskInlet(void); + unsigned short GetnMarker_ActDiskInlet(void) const { return nMarker_ActDiskInlet; } /*! * \brief Get the total number of boundary markers. * \return Total number of boundary markers. */ - unsigned short GetnMarker_ActDiskOutlet(void); + unsigned short GetnMarker_ActDiskOutlet(void) const { return nMarker_ActDiskOutlet; } /*! * \brief Get the total number of boundary markers. * \return Total number of boundary markers. */ - unsigned short GetnMarker_Outlet(void); + unsigned short GetnMarker_Outlet(void) const { return nMarker_Outlet; } /*! * \brief Get the total number of monitoring markers. * \return Total number of monitoring markers. */ - unsigned short GetnMarker_Monitoring(void); + unsigned short GetnMarker_Monitoring(void) const { return nMarker_Monitoring; } /*! * \brief Get the total number of DV markers. * \return Total number of DV markers. */ - unsigned short GetnMarker_DV(void); + unsigned short GetnMarker_DV(void) const { return nMarker_DV; } /*! * \brief Get the total number of moving markers. * \return Total number of moving markers. */ - unsigned short GetnMarker_Moving(void); + unsigned short GetnMarker_Moving(void) const { return nMarker_Moving; } /*! * \brief Get the total number of Python customizable markers. * \return Total number of Python customizable markers. */ - unsigned short GetnMarker_PyCustom(void); + unsigned short GetnMarker_PyCustom(void) const { return nMarker_PyCustom; } /*! * \brief Get the total number of moving markers. * \return Total number of moving markers. */ - unsigned short GetnMarker_Analyze(void); + unsigned short GetnMarker_Analyze(void) const { return nMarker_Analyze; } /*! * \brief Get the total number of periodic markers. * \return Total number of periodic markers. */ - unsigned short GetnMarker_Periodic(void); + unsigned short GetnMarker_Periodic(void) const { return nMarker_PerBound; } /*! * \brief Get the total number of heat flux markers. * \return Total number of heat flux markers. */ - unsigned short GetnMarker_HeatFlux(void); + unsigned short GetnMarker_HeatFlux(void) const { return nMarker_HeatFlux; } /*! * \brief Get the total number of objectives in kind_objective list * \return Total number of objectives in kind_objective list */ - unsigned short GetnObj(void); + unsigned short GetnObj(void) const { return nObj;} /*! * \brief Stores the number of marker in the simulation. * \param[in] val_nmarker - Number of markers of the problem. */ - void SetnMarker_All(unsigned short val_nmarker); + void SetnMarker_All(unsigned short val_nmarker) { nMarker_All = val_nmarker; } /*! * \brief Get the number of internal iterations. * \return Number of internal iterations. */ - unsigned long GetUnst_nIntIter(void); + unsigned long GetUnst_nIntIter(void) const { return Unst_nIntIter; } /*! * \brief Get the number of internal iterations for the Newton-Raphson Method in nonlinear structural applications. * \return Number of internal iterations. */ - unsigned long GetDyn_nIntIter(void); + unsigned long GetDyn_nIntIter(void) const { return Dyn_nIntIter; } /*! * \brief Get the starting direct iteration number for the unsteady adjoint (reverse time integration). * \return Starting direct iteration number for the unsteady adjoint. */ - long GetUnst_AdjointIter(void); + long GetUnst_AdjointIter(void) const { return Unst_AdjointIter; } /*! * \brief Number of iterations to average (reverse time integration). * \return Starting direct iteration number for the unsteady adjoint. */ - unsigned long GetIter_Avg_Objective(void); + unsigned long GetIter_Avg_Objective(void) const { return Iter_Avg_Objective ; } /*! * \brief Retrieves the number of periodic time instances for Harmonic Balance. * \return: Number of periodic time instances for Harmonic Balance. */ - unsigned short GetnTimeInstances(void); + unsigned short GetnTimeInstances(void) const { return nTimeInstances; } /*! * \brief Retrieves the period of oscillations to be used with Harmonic Balance. * \return: Period for Harmonic Balance. */ - su2double GetHarmonicBalance_Period(void); + su2double GetHarmonicBalance_Period(void) const { return HarmonicBalance_Period; } /*! * \brief Set the current external iteration number. * \param[in] val_iter - Current external iteration number. */ - void SetExtIter_OffSet(unsigned long val_iter); + void SetExtIter_OffSet(unsigned long val_iter) { ExtIter_OffSet = val_iter; } /*! * \brief Set the current FSI iteration number. * \param[in] val_iter - Current FSI iteration number. */ - void SetOuterIter(unsigned long val_iter); + void SetOuterIter(unsigned long val_iter) { OuterIter = val_iter; } /*! * \brief Set the current FSI iteration number. * \param[in] val_iter - Current FSI iteration number. */ - void SetInnerIter(unsigned long val_iter); + void SetInnerIter(unsigned long val_iter) { InnerIter = val_iter; } /*! * \brief Set the current time iteration number. * \param[in] val_iter - Current FSI iteration number. */ - void SetTimeIter(unsigned long val_iter); + void SetTimeIter(unsigned long val_iter) { TimeIter = val_iter; } /*! * \brief Get the current time iteration number. * \param[in] val_iter - Current time iterationnumber. */ - unsigned long GetTimeIter(); + unsigned long GetTimeIter() const { return TimeIter; } /*! * \brief Get the current internal iteration number. * \return Current external iteration. */ - unsigned long GetExtIter_OffSet(void); + unsigned long GetExtIter_OffSet(void) const { return ExtIter_OffSet; } /*! * \brief Get the current FSI iteration number. * \return Current FSI iteration. */ - unsigned long GetOuterIter(void); + unsigned long GetOuterIter(void) const { return OuterIter; } /*! * \brief Get the current FSI iteration number. * \return Current FSI iteration. */ - unsigned long GetInnerIter(void); + unsigned long GetInnerIter(void) const { return InnerIter; } /*! * \brief Set the current physical time. * \param[in] val_t - Current physical time. */ - void SetPhysicalTime(su2double val_t); + void SetPhysicalTime(su2double val_t) { PhysicalTime = val_t; } /*! * \brief Get the current physical time. * \return Current physical time. */ - su2double GetPhysicalTime(void); + su2double GetPhysicalTime(void) const { return PhysicalTime; } /*! * \brief Get the frequency for writing the solution file. * \return It writes the solution file with this frequency. */ - unsigned long GetWrt_Sol_Freq(void); + unsigned long GetWrt_Sol_Freq(void) const { return Wrt_Sol_Freq; } /*! * \brief Get the frequency for writing the solution file in Dual Time. * \return It writes the solution file with this frequency. */ - unsigned long GetWrt_Sol_Freq_DualTime(void); + unsigned long GetWrt_Sol_Freq_DualTime(void) const { return Wrt_Sol_Freq_DualTime; } /*! * \brief Get the frequency for writing the convergence file. * \return It writes the convergence file with this frequency. */ - unsigned long GetWrt_Con_Freq(void); + unsigned long GetWrt_Con_Freq(void) const { return Wrt_Con_Freq; } /*! * \brief Set the frequency for writing the convergence file. * \return It writes the convergence file with this frequency. */ - void SetWrt_Con_Freq(unsigned long val_freq); + void SetWrt_Con_Freq(unsigned long val_freq) { Wrt_Con_Freq = val_freq; } /*! * \brief Get the frequency for writing the convergence file in Dual Time. * \return It writes the convergence file with this frequency. */ - unsigned long GetWrt_Con_Freq_DualTime(void); + unsigned long GetWrt_Con_Freq_DualTime(void) const { return Wrt_Con_Freq_DualTime; } /*! * \brief Get information about writing unsteady headers and file extensions. @@ -3034,110 +3040,110 @@ class CConfig { * \brief Get information about writing output files. * \return TRUE means that output files will be written. */ - bool GetWrt_Output(void); + bool GetWrt_Output(void) const { return Wrt_Output; } /*! * \brief Get information about writing a volume solution file. * \return TRUE means that a volume solution file will be written. */ - bool GetWrt_Vol_Sol(void); + bool GetWrt_Vol_Sol(void) const { return Wrt_Vol_Sol; } /*! * \brief Get information about writing a surface solution file. * \return TRUE means that a surface solution file will be written. */ - bool GetWrt_Srf_Sol(void); + bool GetWrt_Srf_Sol(void) const { return Wrt_Srf_Sol; } /*! * \brief Get information about writing a surface comma-separated values (CSV) solution file. * \return TRUE means that a surface comma-separated values (CSV) solution file will be written. */ - bool GetWrt_Csv_Sol(void); + bool GetWrt_Csv_Sol(void) const { return Wrt_Csv_Sol; } /*! * \brief Get information about writing a binary coordinates file. * \return TRUE means that a binary coordinates file will be written. */ - bool GetWrt_Crd_Sol(void); + bool GetWrt_Crd_Sol(void) const { return Wrt_Crd_Sol; } /*! * \brief Get information about writing residuals to volume solution file. * \return TRUE means that residuals will be written to the solution file. */ - bool GetWrt_Residuals(void); + bool GetWrt_Residuals(void) const { return Wrt_Residuals; } /*! * \brief Get information about writing residuals to volume solution file. * \return TRUE means that residuals will be written to the solution file. */ - bool GetWrt_Limiters(void); + bool GetWrt_Limiters(void) const { return Wrt_Limiters; } /*! * \brief Write solution at each surface. * \return TRUE means that the solution at each surface will be written. */ - bool GetWrt_Surface(void); + bool GetWrt_Surface(void) const { return Wrt_Surface; } /*! * \brief Get information about writing residuals to volume solution file. * \return TRUE means that residuals will be written to the solution file. */ - bool GetWrt_SharpEdges(void); + bool GetWrt_SharpEdges(void) const { return Wrt_SharpEdges; } /*! * \brief Get information about writing rind layers to the solution files. * \return TRUE means that rind layers will be written to the solution file. */ - bool GetWrt_Halo(void); + bool GetWrt_Halo(void) const { return Wrt_Halo; } /*! * \brief Get information about writing the performance summary at the end of a calculation. * \return TRUE means that the performance summary will be written at the end of a calculation. */ - bool GetWrt_Performance(void); + bool GetWrt_Performance(void) const { return Wrt_Performance; } /*! * \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); + bool GetWrt_AD_Statistics(void) const { return Wrt_AD_Statistics; } /*! * \brief Get information about writing the mesh quality metrics to the visualization files. * \return TRUE means that the mesh quality metrics will be written to the visualization files. */ - bool GetWrt_MeshQuality(void); + bool GetWrt_MeshQuality(void) const { return Wrt_MeshQuality; } /*! * \brief Get information about writing a 1D slice of a 2D cartesian solution. * \return TRUE means that a 1D slice of a 2D cartesian solution will be written. */ - bool GetWrt_Slice(void); + bool GetWrt_Slice(void) const { return Wrt_Slice; } /*! * \brief Get information about writing projected sensitivities on surfaces to an ASCII file with rows as x, y, z, dJ/dx, dJ/dy, dJ/dz for each vertex. * \return TRUE means that projected sensitivities on surfaces in an ASCII file with rows as x, y, z, dJ/dx, dJ/dy, dJ/dz for each vertex will be written. */ - bool GetWrt_Projected_Sensitivity(void); + bool GetWrt_Projected_Sensitivity(void) const { return Wrt_Projected_Sensitivity; } /*! * \brief Get information about the format for the input volume sensitvities. * \return Format of the input volume sensitivities. */ - unsigned short GetSensitivity_Format(void); + unsigned short GetSensitivity_Format(void) const { return Sensitivity_FileFormat; } /*! * \brief Get information about writing sectional force files. * \return TRUE means that sectional force files will be written for specified markers. */ - bool GetPlot_Section_Forces(void); + bool GetPlot_Section_Forces(void) const { return Plot_Section_Forces; } /*! * \brief Get the alpha (convective) coefficients for the Runge-Kutta integration scheme. * \param[in] val_step - Index of the step. * \return Alpha coefficient for the Runge-Kutta integration scheme. */ - su2double Get_Alpha_RKStep(unsigned short val_step); + su2double Get_Alpha_RKStep(unsigned short val_step) const { return RK_Alpha_Step[val_step]; } /*! * \brief Get the index of the surface defined in the geometry file. @@ -3145,7 +3151,7 @@ class CConfig { * \return Value of the index that is in the geometry file for the surface that * has the marker val_marker. */ - string GetMarker_All_TagBound(unsigned short val_marker); + string GetMarker_All_TagBound(unsigned short val_marker) const { return Marker_All_TagBound[val_marker]; } /*! * \brief Get the index of the surface defined in the geometry file. @@ -3153,7 +3159,7 @@ class CConfig { * \return Value of the index that is in the geometry file for the surface that * has the marker val_marker. */ - string GetMarker_ActDiskInlet_TagBound(unsigned short val_marker); + string GetMarker_ActDiskInlet_TagBound(unsigned short val_marker) const { return Marker_ActDiskInlet[val_marker]; } /*! * \brief Get the index of the surface defined in the geometry file. @@ -3161,7 +3167,7 @@ class CConfig { * \return Value of the index that is in the geometry file for the surface that * has the marker val_marker. */ - string GetMarker_ActDiskOutlet_TagBound(unsigned short val_marker); + string GetMarker_ActDiskOutlet_TagBound(unsigned short val_marker) const { return Marker_ActDiskOutlet[val_marker]; } /*! * \brief Get the index of the surface defined in the geometry file. @@ -3169,7 +3175,7 @@ class CConfig { * \return Value of the index that is in the geometry file for the surface that * has the marker val_marker. */ - string GetMarker_Outlet_TagBound(unsigned short val_marker); + string GetMarker_Outlet_TagBound(unsigned short val_marker) const { return Marker_Outlet[val_marker]; } /*! * \brief Get the index of the surface defined in the geometry file. @@ -3177,7 +3183,7 @@ class CConfig { * \return Value of the index that is in the geometry file for the surface that * has the marker val_marker. */ - string GetMarker_EngineInflow_TagBound(unsigned short val_marker); + string GetMarker_EngineInflow_TagBound(unsigned short val_marker) const { return Marker_EngineInflow[val_marker]; } /*! * \brief Get the index of the surface defined in the geometry file. @@ -3185,7 +3191,7 @@ class CConfig { * \return Value of the index that is in the geometry file for the surface that * has the marker val_marker. */ - string GetMarker_EngineExhaust_TagBound(unsigned short val_marker); + string GetMarker_EngineExhaust_TagBound(unsigned short val_marker) const { return Marker_EngineExhaust[val_marker]; } /*! * \brief Get the name of the surface defined in the geometry file. @@ -3193,7 +3199,7 @@ class CConfig { * \return Name that is in the geometry file for the surface that * has the marker val_marker. */ - string GetMarker_Monitoring_TagBound(unsigned short val_marker); + string GetMarker_Monitoring_TagBound(unsigned short val_marker) const { return Marker_Monitoring[val_marker]; } /*! * \brief Get the name of the surface defined in the geometry file. @@ -3201,7 +3207,7 @@ class CConfig { * \return Name that is in the geometry file for the surface that * has the marker val_marker. */ - string GetMarker_HeatFlux_TagBound(unsigned short val_marker); + string GetMarker_HeatFlux_TagBound(unsigned short val_marker) const { return Marker_HeatFlux[val_marker]; } /*! * \brief Get the tag if the iMarker defined in the geometry file. @@ -3209,14 +3215,19 @@ class CConfig { * \return Value of the marker val_marker that is in the geometry file * for the surface that has the tag. */ - short GetMarker_All_TagBound(string val_tag); + short GetMarker_All_TagBound(string val_tag) { + for (unsigned short iMarker = 0; iMarker < nMarker_All; iMarker++) { + if (val_tag == Marker_All_TagBound[iMarker]) return iMarker; + } + return -1; + } /*! * \brief Get the kind of boundary for each marker. * \param[in] val_marker - Index of the marker in which we are interested. * \return Kind of boundary for the marker val_marker. */ - unsigned short GetMarker_All_KindBC(unsigned short val_marker); + unsigned short GetMarker_All_KindBC(unsigned short val_marker) const { return Marker_All_KindBC[val_marker]; } /*! * \brief Set the value of the boundary val_boundary (read from the config file) @@ -3224,7 +3235,7 @@ class CConfig { * \param[in] val_marker - Index of the marker in which we are interested. * \param[in] val_boundary - Kind of boundary read from config file. */ - void SetMarker_All_KindBC(unsigned short val_marker, unsigned short val_boundary); + void SetMarker_All_KindBC(unsigned short val_marker, unsigned short val_boundary) { Marker_All_KindBC[val_marker] = val_boundary; } /*! * \brief Set the value of the index val_index (read from the geometry file) for @@ -3232,7 +3243,7 @@ class CConfig { * \param[in] val_marker - Index of the marker in which we are interested. * \param[in] val_index - Index of the surface read from geometry file. */ - void SetMarker_All_TagBound(unsigned short val_marker, string val_index); + void SetMarker_All_TagBound(unsigned short val_marker, string val_index) { Marker_All_TagBound[val_marker] = val_index; } /*! * \brief Set if a marker val_marker is going to be monitored val_monitoring @@ -3241,7 +3252,7 @@ class CConfig { * \param[in] val_marker - Index of the marker in which we are interested. * \param[in] val_monitoring - 0 or 1 depending if the the marker is going to be monitored. */ - void SetMarker_All_Monitoring(unsigned short val_marker, unsigned short val_monitoring); + void SetMarker_All_Monitoring(unsigned short val_marker, unsigned short val_monitoring) { Marker_All_Monitoring[val_marker] = val_monitoring; } /*! * \brief Set if a marker val_marker is going to be monitored val_monitoring @@ -3250,7 +3261,7 @@ class CConfig { * \param[in] val_marker - Index of the marker in which we are interested. * \param[in] val_monitoring - 0 or 1 depending if the the marker is going to be monitored. */ - void SetMarker_All_GeoEval(unsigned short val_marker, unsigned short val_geoeval); + void SetMarker_All_GeoEval(unsigned short val_marker, unsigned short val_geoeval) { Marker_All_GeoEval[val_marker] = val_geoeval; } /*! * \brief Set if a marker val_marker is going to be designed val_designing @@ -3259,7 +3270,7 @@ class CConfig { * \param[in] val_marker - Index of the marker in which we are interested. * \param[in] val_monitoring - 0 or 1 depending if the the marker is going to be designed. */ - void SetMarker_All_Designing(unsigned short val_marker, unsigned short val_designing); + void SetMarker_All_Designing(unsigned short val_marker, unsigned short val_designing) { Marker_All_Designing[val_marker] = val_designing; } /*! * \brief Set if a marker val_marker is going to be plot val_plotting @@ -3267,7 +3278,7 @@ class CConfig { * \param[in] val_marker - Index of the marker in which we are interested. * \param[in] val_plotting - 0 or 1 depending if the the marker is going to be plot. */ - void SetMarker_All_Plotting(unsigned short val_marker, unsigned short val_plotting); + void SetMarker_All_Plotting(unsigned short val_marker, unsigned short val_plotting) { Marker_All_Plotting[val_marker] = val_plotting; } /*! * \brief Set if a marker val_marker is going to be plot val_plotting @@ -3275,7 +3286,7 @@ class CConfig { * \param[in] val_marker - Index of the marker in which we are interested. * \param[in] val_plotting - 0 or 1 depending if the the marker is going to be plot. */ - void SetMarker_All_Analyze(unsigned short val_marker, unsigned short val_analyze); + void SetMarker_All_Analyze(unsigned short val_marker, unsigned short val_analyze) { Marker_All_Analyze[val_marker] = val_analyze; } /*! * \brief Set if a marker val_marker is part of the FSI interface val_plotting @@ -3283,28 +3294,28 @@ class CConfig { * \param[in] val_marker - Index of the marker in which we are interested. * \param[in] val_plotting - 0 or 1 depending if the the marker is part of the FSI interface. */ - void SetMarker_All_ZoneInterface(unsigned short val_marker, unsigned short val_fsiinterface); + void SetMarker_All_ZoneInterface(unsigned short val_marker, unsigned short val_fsiinterface) { Marker_All_ZoneInterface[val_marker] = val_fsiinterface; } /*! * \brief Set if a marker val_marker is part of the Turbomachinery (read from the config file). * \param[in] val_marker - Index of the marker in which we are interested. * \param[in] val_turboperf - 0 if not part of Turbomachinery or greater than 1 if it is part. */ - void SetMarker_All_Turbomachinery(unsigned short val_marker, unsigned short val_turbo); + void SetMarker_All_Turbomachinery(unsigned short val_marker, unsigned short val_turbo) { Marker_All_Turbomachinery[val_marker] = val_turbo; } /*! * \brief Set a flag to the marker val_marker part of the Turbomachinery (read from the config file). * \param[in] val_marker - Index of the marker in which we are interested. * \param[in] val_turboperflag - 0 if is not part of the Turbomachinery, flag INFLOW or OUTFLOW if it is part. */ - void SetMarker_All_TurbomachineryFlag(unsigned short val_marker, unsigned short val_turboflag); + void SetMarker_All_TurbomachineryFlag(unsigned short val_marker, unsigned short val_turboflag) { Marker_All_TurbomachineryFlag[val_marker] = val_turboflag; } /*! * \brief Set if a marker val_marker is part of the MixingPlane interface (read from the config file). * \param[in] val_marker - Index of the marker in which we are interested. * \param[in] val_turboperf - 0 if not part of the MixingPlane interface or greater than 1 if it is part. */ - void SetMarker_All_MixingPlaneInterface(unsigned short val_marker, unsigned short val_mixplan_interface); + void SetMarker_All_MixingPlaneInterface(unsigned short val_marker, unsigned short val_mixpla_interface) { Marker_All_MixingPlaneInterface[val_marker] = val_mixpla_interface; } /*! * \brief Set if a marker val_marker is going to be affected by design variables val_moving @@ -3312,7 +3323,7 @@ class CConfig { * \param[in] val_marker - Index of the marker in which we are interested. * \param[in] val_DV - 0 or 1 depending if the the marker is affected by design variables. */ - void SetMarker_All_DV(unsigned short val_marker, unsigned short val_DV); + void SetMarker_All_DV(unsigned short val_marker, unsigned short val_DV) { Marker_All_DV[val_marker] = val_DV; } /*! * \brief Set if a marker val_marker is going to be moved val_moving @@ -3320,21 +3331,21 @@ class CConfig { * \param[in] val_marker - Index of the marker in which we are interested. * \param[in] val_moving - 0 or 1 depending if the the marker is going to be moved. */ - void SetMarker_All_Moving(unsigned short val_marker, unsigned short val_moving); + void SetMarker_All_Moving(unsigned short val_marker, unsigned short val_moving) { Marker_All_Moving[val_marker] = val_moving; } /*! * \brief Set if a marker val_marker allows deformation at the boundary. * \param[in] val_marker - Index of the marker in which we are interested. * \param[in] val_interface - 0 or 1 depending if the the marker is or not a DEFORM_MESH marker. */ - void SetMarker_All_Deform_Mesh(unsigned short val_marker, unsigned short val_interface); + void SetMarker_All_Deform_Mesh(unsigned short val_marker, unsigned short val_interface) { Marker_All_Deform_Mesh[val_marker] = val_interface; } /*! * \brief Set if a in marker val_marker the flow load will be computed/employed. * \param[in] val_marker - Index of the marker in which we are interested. * \param[in] val_interface - 0 or 1 depending if the the marker is or not a Fluid_Load marker. */ - void SetMarker_All_Fluid_Load(unsigned short val_marker, unsigned short val_interface); + void SetMarker_All_Fluid_Load(unsigned short val_marker, unsigned short val_interface) { Marker_All_Fluid_Load[val_marker] = val_interface; } /*! * \brief Set if a marker val_marker is going to be customized in Python val_PyCustom @@ -3342,7 +3353,7 @@ class CConfig { * \param[in] val_marker - Index of the marker in which we are interested. * \param[in] val_PyCustom - 0 or 1 depending if the the marker is going to be customized in Python. */ - void SetMarker_All_PyCustom(unsigned short val_marker, unsigned short val_PyCustom); + void SetMarker_All_PyCustom(unsigned short val_marker, unsigned short val_PyCustom) { Marker_All_PyCustom[val_marker] = val_PyCustom; } /*! * \brief Set if a marker val_marker is going to be periodic val_perbound @@ -3350,7 +3361,7 @@ class CConfig { * \param[in] val_marker - Index of the marker in which we are interested. * \param[in] val_perbound - Index of the surface with the periodic boundary. */ - void SetMarker_All_PerBound(unsigned short val_marker, short val_perbound); + void SetMarker_All_PerBound(unsigned short val_marker, short val_perbound) { Marker_All_PerBound[val_marker] = val_perbound; } /*! * \brief Set if a marker val_marker is going to be sent or receive val_index @@ -3358,7 +3369,7 @@ class CConfig { * \param[in] val_marker - 0 or 1 depending if the the marker is going to be moved. * \param[in] val_index - Index of the surface read from geometry file. */ - void SetMarker_All_SendRecv(unsigned short val_marker, short val_index); + void SetMarker_All_SendRecv(unsigned short val_marker, short val_index) { Marker_All_SendRecv[val_marker] = val_index; } /*! * \brief Get the send-receive information for a marker val_marker. @@ -3366,213 +3377,222 @@ class CConfig { * \return If positive, the information is sended to that domain, in case negative * the information is receive from that domain. */ - short GetMarker_All_SendRecv(unsigned short val_marker); + short GetMarker_All_SendRecv(unsigned short val_marker) const { return Marker_All_SendRecv[val_marker]; } /*! * \brief Get an internal index that identify the periodic boundary conditions. * \param[in] val_marker - Value of the marker that correspond with the periodic boundary. * \return The internal index of the periodic boundary condition. */ - short GetMarker_All_PerBound(unsigned short val_marker); + short GetMarker_All_PerBound(unsigned short val_marker) const { return Marker_All_PerBound[val_marker]; } /*! * \brief Get the monitoring information for a marker val_marker. * \param[in] val_marker - 0 or 1 depending if the the marker is going to be monitored. * \return 0 or 1 depending if the marker is going to be monitored. */ - unsigned short GetMarker_All_Monitoring(unsigned short val_marker); + unsigned short GetMarker_All_Monitoring(unsigned short val_marker) const { return Marker_All_Monitoring[val_marker]; } /*! * \brief Get the monitoring information for a marker val_marker. * \param[in] val_marker - 0 or 1 depending if the the marker is going to be monitored. * \return 0 or 1 depending if the marker is going to be monitored. */ - unsigned short GetMarker_All_GeoEval(unsigned short val_marker); + unsigned short GetMarker_All_GeoEval(unsigned short val_marker) const { return Marker_All_GeoEval[val_marker]; } /*! * \brief Get the design information for a marker val_marker. * \param[in] val_marker - 0 or 1 depending if the the marker is going to be monitored. * \return 0 or 1 depending if the marker is going to be monitored. */ - unsigned short GetMarker_All_Designing(unsigned short val_marker); + unsigned short GetMarker_All_Designing(unsigned short val_marker) const { return Marker_All_Designing[val_marker]; } /*! * \brief Get the plotting information for a marker val_marker. * \param[in] val_marker - 0 or 1 depending if the the marker is going to be moved. * \return 0 or 1 depending if the marker is going to be plotted. */ - unsigned short GetMarker_All_Plotting(unsigned short val_marker); + unsigned short GetMarker_All_Plotting(unsigned short val_marker) const { return Marker_All_Plotting[val_marker]; } /*! * \brief Get the plotting information for a marker val_marker. * \param[in] val_marker - 0 or 1 depending if the the marker is going to be moved. * \return 0 or 1 depending if the marker is going to be plotted. */ - unsigned short GetMarker_All_Analyze(unsigned short val_marker); + unsigned short GetMarker_All_Analyze(unsigned short val_marker) const { return Marker_All_Analyze[val_marker]; } /*! * \brief Get the FSI interface information for a marker val_marker. * \param[in] val_marker - 0 or 1 depending if the the marker is going to be moved. * \return 0 or 1 depending if the marker is part of the FSI interface. */ - unsigned short GetMarker_All_ZoneInterface(unsigned short val_marker); + unsigned short GetMarker_All_ZoneInterface(unsigned short val_marker) const { return Marker_All_ZoneInterface[val_marker]; } /*! * \brief Get the MixingPlane interface information for a marker val_marker. * \param[in] val_marker value of the marker on the grid. * \return 0 if is not part of the MixingPlane Interface and greater than 1 if it is part. */ - unsigned short GetMarker_All_MixingPlaneInterface(unsigned short val_marker); + unsigned short GetMarker_All_MixingPlaneInterface(unsigned short val_marker) const { return Marker_All_MixingPlaneInterface[val_marker]; } /*! * \brief Get the Turbomachinery information for a marker val_marker. * \param[in] val_marker value of the marker on the grid. * \return 0 if is not part of the Turbomachinery and greater than 1 if it is part. */ - unsigned short GetMarker_All_Turbomachinery(unsigned short val_marker); + unsigned short GetMarker_All_Turbomachinery(unsigned short val_marker) const { return Marker_All_Turbomachinery[val_marker]; } /*! * \brief Get the Turbomachinery flag information for a marker val_marker. * \param[in] val_marker value of the marker on the grid. * \return 0 if is not part of the Turbomachinery, flag INFLOW or OUTFLOW if it is part. */ - unsigned short GetMarker_All_TurbomachineryFlag(unsigned short val_marker); + unsigned short GetMarker_All_TurbomachineryFlag(unsigned short val_marker) const { return Marker_All_TurbomachineryFlag[val_marker]; } /*! * \brief Get the number of FSI interface markers val_marker. * \param[in] void. * \return Number of markers belonging to the FSI interface. */ - unsigned short GetMarker_n_ZoneInterface(void); + unsigned short GetMarker_n_ZoneInterface(void) const { return nMarker_ZoneInterface; } /*! * \brief Get the DV information for a marker val_marker. * \param[in] val_marker - 0 or 1 depending if the the marker is going to be affected by design variables. * \return 0 or 1 depending if the marker is going to be affected by design variables. */ - unsigned short GetMarker_All_DV(unsigned short val_marker); + unsigned short GetMarker_All_DV(unsigned short val_marker) const { return Marker_All_DV[val_marker]; } /*! * \brief Get the motion information for a marker val_marker. * \param[in] val_marker - 0 or 1 depending if the the marker is going to be moved. * \return 0 or 1 depending if the marker is going to be moved. */ - unsigned short GetMarker_All_Moving(unsigned short val_marker); + unsigned short GetMarker_All_Moving(unsigned short val_marker) const { return Marker_All_Moving[val_marker]; } /*! * \brief Get whether marker val_marker is a DEFORM_MESH marker * \param[in] val_marker - 0 or 1 depending if the the marker belongs to the DEFORM_MESH subset. * \return 0 or 1 depending if the marker belongs to the DEFORM_MESH subset. */ - unsigned short GetMarker_All_Deform_Mesh(unsigned short val_marker); + unsigned short GetMarker_All_Deform_Mesh(unsigned short val_marker) const { return Marker_All_Deform_Mesh[val_marker]; } /*! * \brief Get whether marker val_marker is a Fluid_Load marker * \param[in] val_marker - 0 or 1 depending if the the marker belongs to the Fluid_Load subset. * \return 0 or 1 depending if the marker belongs to the Fluid_Load subset. */ - unsigned short GetMarker_All_Fluid_Load(unsigned short val_marker); + unsigned short GetMarker_All_Fluid_Load(unsigned short val_marker) const { return Marker_All_Fluid_Load[val_marker]; } /*! * \brief Get the Python customization for a marker val_marker. * \param[in] val_marker - Index of the marker in which we are interested. * \return 0 or 1 depending if the marker is going to be customized in Python. */ - unsigned short GetMarker_All_PyCustom(unsigned short val_marker); + unsigned short GetMarker_All_PyCustom(unsigned short val_marker) const { return Marker_All_PyCustom[val_marker];} /*! * \brief Get the airfoil sections in the slicing process. * \param[in] val_section - Index of the section. * \return Coordinate of the airfoil to slice. */ - su2double GetLocationStations(unsigned short val_section); + su2double GetLocationStations(unsigned short val_section) const { return LocationStations[val_section]; } /*! * \brief Get the defintion of the nacelle location. * \param[in] val_index - Index of the section. * \return Coordinate of the nacelle location. */ - su2double GetNacelleLocation(unsigned short val_index); + su2double GetNacelleLocation(unsigned short val_index) const { return NacelleLocation[val_index]; } /*! * \brief Get the number of pre-smoothings in a multigrid strategy. * \param[in] val_mesh - Index of the grid. * \return Number of smoothing iterations. */ - unsigned short GetMG_PreSmooth(unsigned short val_mesh); + unsigned short GetMG_PreSmooth(unsigned short val_mesh) const { + if (nMG_PreSmooth == 0) return 1; + return MG_PreSmooth[val_mesh]; + } /*! * \brief Get the number of post-smoothings in a multigrid strategy. * \param[in] val_mesh - Index of the grid. * \return Number of smoothing iterations. */ - unsigned short GetMG_PostSmooth(unsigned short val_mesh); + unsigned short GetMG_PostSmooth(unsigned short val_mesh) const { + if (nMG_PostSmooth == 0) return 0; + return MG_PostSmooth[val_mesh]; + } /*! * \brief Get the number of implicit Jacobi smoothings of the correction in a multigrid strategy. * \param[in] val_mesh - Index of the grid. * \return Number of implicit smoothing iterations. */ - unsigned short GetMG_CorrecSmooth(unsigned short val_mesh); + unsigned short GetMG_CorrecSmooth(unsigned short val_mesh) const { + if (nMG_CorrecSmooth == 0) return 0; + return MG_CorrecSmooth[val_mesh]; + } /*! * \brief plane of the FFD (I axis) that should be fixed. * \param[in] val_index - Index of the arrray with all the planes in the I direction that should be fixed. * \return Index of the plane that is going to be freeze. */ - short GetFFD_Fix_IDir(unsigned short val_index); + short GetFFD_Fix_IDir(unsigned short val_index) const { return FFD_Fix_IDir[val_index]; } /*! * \brief plane of the FFD (J axis) that should be fixed. * \param[in] val_index - Index of the arrray with all the planes in the J direction that should be fixed. * \return Index of the plane that is going to be freeze. */ - short GetFFD_Fix_JDir(unsigned short val_index); + short GetFFD_Fix_JDir(unsigned short val_index) const { return FFD_Fix_JDir[val_index]; } /*! * \brief plane of the FFD (K axis) that should be fixed. * \param[in] val_index - Index of the arrray with all the planes in the K direction that should be fixed. * \return Index of the plane that is going to be freeze. */ - short GetFFD_Fix_KDir(unsigned short val_index); + short GetFFD_Fix_KDir(unsigned short val_index) const { return FFD_Fix_KDir[val_index]; } /*! * \brief Get the number of planes to fix in the I direction. * \return Number of planes to fix in the I direction. */ - unsigned short GetnFFD_Fix_IDir(void); + unsigned short GetnFFD_Fix_IDir(void) const { return nFFD_Fix_IDir; } /*! * \brief Get the number of planes to fix in the J direction. * \return Number of planes to fix in the J direction. */ - unsigned short GetnFFD_Fix_JDir(void); + unsigned short GetnFFD_Fix_JDir(void) const { return nFFD_Fix_JDir; } /*! * \brief Get the number of planes to fix in the K direction. * \return Number of planes to fix in the K direction. */ - unsigned short GetnFFD_Fix_KDir(void); + unsigned short GetnFFD_Fix_KDir(void) const { return nFFD_Fix_KDir; } /*! * \brief Governing equations of the flow (it can be different from the run time equation). * \param[in] val_zone - Zone where the soler is applied. * \return Governing equation that we are solving. */ - unsigned short GetKind_Solver(void); + unsigned short GetKind_Solver(void) const { return Kind_Solver; } /*! * \brief Governing equations of the flow (it can be different from the run time equation). * \param[in] val_zone - Zone where the soler is applied. * \return Governing equation that we are solving. */ - void SetKind_Solver(unsigned short val_solver); + void SetKind_Solver(unsigned short val_solver) { Kind_Solver = val_solver; } /*! * \brief Kind of Multizone Solver. * \return Governing equation that we are solving. */ - unsigned short GetKind_MZSolver(void); + unsigned short GetKind_MZSolver(void) const { return Kind_MZSolver; } /*! @@ -3580,551 +3600,551 @@ class CConfig { * \param[in] val_zone - Zone where the soler is applied. * \return Governing equation that we are solving. */ - unsigned short GetKind_Regime(void); + unsigned short GetKind_Regime(void) const { return Kind_Regime; } /*! * \brief Governing equations of the flow (it can be different from the run time equation). * \param[in] val_zone - Zone where the soler is applied. * \return Governing equation that we are solving. */ - unsigned short GetSystemMeasurements(void); + unsigned short GetSystemMeasurements(void) const { return SystemMeasurements; } /*! * \brief Gas model that we are using. * \return Gas model that we are using. */ - unsigned short GetKind_GasModel(void); + unsigned short GetKind_GasModel(void) const { return Kind_GasModel; } /*! * \brief Fluid model that we are using. * \return Fluid model that we are using. */ - unsigned short GetKind_FluidModel(void); + unsigned short GetKind_FluidModel(void) const { return Kind_FluidModel; } /*! * \brief Option to define the density model for incompressible flows. * \return Density model option */ - unsigned short GetKind_DensityModel(void); + unsigned short GetKind_DensityModel(void) const { return Kind_DensityModel; } /*! * \brief Flag for whether to solve the energy equation for incompressible flows. * \return Flag for energy equation */ - bool GetEnergy_Equation(void); + bool GetEnergy_Equation(void) const { return Energy_Equation; } /*! * \brief free stream option to initialize the solution * \return free stream option */ - unsigned short GetKind_FreeStreamOption(void); + unsigned short GetKind_FreeStreamOption(void) const { return Kind_FreeStreamOption; } /*! * \brief free stream option to initialize the solution * \return free stream option */ - unsigned short GetKind_InitOption(void); + unsigned short GetKind_InitOption(void) const { return Kind_InitOption; } /*! * \brief Get the value of the critical pressure. * \return Critical pressure. */ - su2double GetPressure_Critical(void); + su2double GetPressure_Critical(void) const { return Pressure_Critical; } /*! * \brief Get the value of the critical temperature. * \return Critical temperature. */ - su2double GetTemperature_Critical(void); + su2double GetTemperature_Critical(void) const { return Temperature_Critical; } /*! * \brief Get the value of the critical pressure. * \return Critical pressure. */ - su2double GetAcentric_Factor(void); + su2double GetAcentric_Factor(void) const { return Acentric_Factor; } /*! * \brief Get the value of the viscosity model. * \return Viscosity model. */ - unsigned short GetKind_ViscosityModel(void); + unsigned short GetKind_ViscosityModel(void) const { return Kind_ViscosityModel; } /*! * \brief Get the value of the thermal conductivity model. * \return Conductivity model. */ - unsigned short GetKind_ConductivityModel(void); + unsigned short GetKind_ConductivityModel(void) const { return Kind_ConductivityModel; } /*! * \brief Get the value of the turbulent thermal conductivity model. * \return Turbulent conductivity model. */ - unsigned short GetKind_ConductivityModel_Turb(void); + unsigned short GetKind_ConductivityModel_Turb(void) const { return Kind_ConductivityModel_Turb; } /*! * \brief Get the value of the constant viscosity. * \return Constant viscosity. */ - su2double GetMu_Constant(void); + su2double GetMu_Constant(void) const { return Mu_Constant; } /*! * \brief Get the value of the non-dimensional constant viscosity. * \return Non-dimensional constant viscosity. */ - su2double GetMu_ConstantND(void); + su2double GetMu_ConstantND(void) const { return Mu_ConstantND; } /*! * \brief Get the value of the thermal conductivity. * \return Thermal conductivity. */ - su2double GetKt_Constant(void); + su2double GetKt_Constant(void) const { return Kt_Constant; } /*! * \brief Get the value of the non-dimensional thermal conductivity. * \return Non-dimensional thermal conductivity. */ - su2double GetKt_ConstantND(void); + su2double GetKt_ConstantND(void) const { return Kt_ConstantND; } /*! * \brief Get the value of the reference viscosity for Sutherland model. * \return The reference viscosity. */ - su2double GetMu_Ref(void); + su2double GetMu_Ref(void) const { return Mu_Ref; } /*! * \brief Get the value of the non-dimensional reference viscosity for Sutherland model. * \return The non-dimensional reference viscosity. */ - su2double GetMu_RefND(void); + su2double GetMu_RefND(void) const { return Mu_RefND; } /*! * \brief Get the value of the reference temperature for Sutherland model. * \return The reference temperature. */ - su2double GetMu_Temperature_Ref(void); + su2double GetMu_Temperature_Ref(void) const { return Mu_Temperature_Ref; } /*! * \brief Get the value of the non-dimensional reference temperature for Sutherland model. * \return The non-dimensional reference temperature. */ - su2double GetMu_Temperature_RefND(void); + su2double GetMu_Temperature_RefND(void) const { return Mu_Temperature_RefND; } /*! * \brief Get the value of the reference S for Sutherland model. * \return The reference S. */ - su2double GetMu_S(void); + su2double GetMu_S(void) const { return Mu_S; } /*! * \brief Get the value of the non-dimensional reference S for Sutherland model. * \return The non-dimensional reference S. */ - su2double GetMu_SND(void); + su2double GetMu_SND(void) const { return Mu_SND; } /*! * \brief Get the number of coefficients in the temperature polynomial models. * \return The the number of coefficients in the temperature polynomial models. */ - unsigned short GetnPolyCoeffs(void); + unsigned short GetnPolyCoeffs(void) const { return nPolyCoeffs; } /*! * \brief Get the temperature polynomial coefficient for specific heat Cp. * \param[in] val_index - Index of the array with all polynomial coefficients. * \return Temperature polynomial coefficient for specific heat Cp. */ - su2double GetCp_PolyCoeff(unsigned short val_index); + su2double GetCp_PolyCoeff(unsigned short val_index) const { return CpPolyCoefficients[val_index]; } /*! * \brief Get the temperature polynomial coefficient for specific heat Cp. * \param[in] val_index - Index of the array with all polynomial coefficients. * \return Temperature polynomial coefficient for specific heat Cp. */ - su2double GetCp_PolyCoeffND(unsigned short val_index); + su2double GetCp_PolyCoeffND(unsigned short val_index) const { return CpPolyCoefficientsND[val_index]; } /*! * \brief Get the temperature polynomial coefficient for viscosity. * \param[in] val_index - Index of the array with all polynomial coefficients. * \return Temperature polynomial coefficient for viscosity. */ - su2double GetMu_PolyCoeff(unsigned short val_index); + su2double GetMu_PolyCoeff(unsigned short val_index) const { return MuPolyCoefficients[val_index]; } /*! * \brief Get the temperature polynomial coefficient for viscosity. * \param[in] val_index - Index of the array with all polynomial coefficients. * \return Non-dimensional temperature polynomial coefficient for viscosity. */ - su2double GetMu_PolyCoeffND(unsigned short val_index); + su2double GetMu_PolyCoeffND(unsigned short val_index) const { return MuPolyCoefficientsND[val_index]; } /*! * \brief Get the temperature polynomial coefficients for viscosity. * \return Non-dimensional temperature polynomial coefficients for viscosity. */ - su2double* GetMu_PolyCoeffND(void); + su2double* GetMu_PolyCoeffND(void) { return MuPolyCoefficientsND; } /*! * \brief Get the temperature polynomial coefficient for thermal conductivity. * \param[in] val_index - Index of the array with all polynomial coefficients. * \return Temperature polynomial coefficient for thermal conductivity. */ - su2double GetKt_PolyCoeff(unsigned short val_index); + su2double GetKt_PolyCoeff(unsigned short val_index) const { return KtPolyCoefficients[val_index]; } /*! * \brief Get the temperature polynomial coefficient for thermal conductivity. * \param[in] val_index - Index of the array with all polynomial coefficients. * \return Non-dimensional temperature polynomial coefficient for thermal conductivity. */ - su2double GetKt_PolyCoeffND(unsigned short val_index); + su2double GetKt_PolyCoeffND(unsigned short val_index) const { return KtPolyCoefficientsND[val_index]; } /*! * \brief Get the temperature polynomial coefficients for thermal conductivity. * \return Non-dimensional temperature polynomial coefficients for thermal conductivity. */ - su2double* GetKt_PolyCoeffND(void); + su2double* GetKt_PolyCoeffND(void) { return KtPolyCoefficientsND; } /*! * \brief Set the value of the non-dimensional constant viscosity. */ - void SetMu_ConstantND(su2double mu_const); + void SetMu_ConstantND(su2double mu_const) { Mu_ConstantND = mu_const; } /*! * \brief Set the value of the non-dimensional thermal conductivity. */ - void SetKt_ConstantND(su2double kt_const); + void SetKt_ConstantND(su2double kt_const) { Kt_ConstantND = kt_const; } /*! * \brief Set the value of the non-dimensional reference viscosity for Sutherland model. */ - void SetMu_RefND(su2double mu_ref); + void SetMu_RefND(su2double mu_ref) { Mu_RefND = mu_ref; } /*! * \brief Set the value of the non-dimensional reference temperature for Sutherland model. */ - void SetMu_Temperature_RefND(su2double mu_Tref); + void SetMu_Temperature_RefND(su2double mu_Tref) { Mu_Temperature_RefND = mu_Tref; } /*! * \brief Set the value of the non-dimensional S for Sutherland model. */ - void SetMu_SND(su2double mu_s); + void SetMu_SND(su2double mu_s) { Mu_SND = mu_s; } /*! * \brief Set the temperature polynomial coefficient for specific heat Cp. * \param[in] val_coeff - Temperature polynomial coefficient for specific heat Cp. * \param[in] val_index - Index of the array with all polynomial coefficients. */ - void SetCp_PolyCoeffND(su2double val_coeff, unsigned short val_index); + void SetCp_PolyCoeffND(su2double val_coeff, unsigned short val_index) { CpPolyCoefficientsND[val_index] = val_coeff; } /*! * \brief Set the temperature polynomial coefficient for viscosity. * \param[in] val_coeff - Non-dimensional temperature polynomial coefficient for viscosity. * \param[in] val_index - Index of the array with all polynomial coefficients. */ - void SetMu_PolyCoeffND(su2double val_coeff, unsigned short val_index); + void SetMu_PolyCoeffND(su2double val_coeff, unsigned short val_index) { MuPolyCoefficientsND[val_index] = val_coeff; } /*! * \brief Set the temperature polynomial coefficient for thermal conductivity. * \param[in] val_coeff - Non-dimensional temperature polynomial coefficient for thermal conductivity. * \param[in] val_index - Index of the array with all polynomial coefficients. */ - void SetKt_PolyCoeffND(su2double val_coeff, unsigned short val_index); + void SetKt_PolyCoeffND(su2double val_coeff, unsigned short val_index) { KtPolyCoefficientsND[val_index] = val_coeff; } /*! * \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); + unsigned short GetKind_Gradient_Method(void) const { return Kind_Gradient_Method; } /*! * \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); + unsigned short GetKind_Gradient_Method_Recon(void) const { return Kind_Gradient_Method_Recon; } /*! * \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); + bool GetReconstructionGradientRequired(void) { return ReconstructionGradientRequired; } /*! * \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); + bool GetLeastSquaresRequired(void) const { return LeastSquaresRequired; } /*! * \brief Get the kind of solver for the implicit solver. * \return Numerical solver for implicit formulation (solving the linear system). */ - unsigned short GetKind_Linear_Solver(void); + unsigned short GetKind_Linear_Solver(void) const { return Kind_Linear_Solver; } /*! * \brief Get the kind of preconditioner for the implicit solver. * \return Numerical preconditioner for implicit formulation (solving the linear system). */ - unsigned short GetKind_Linear_Solver_Prec(void); + unsigned short GetKind_Linear_Solver_Prec(void) const { return Kind_Linear_Solver_Prec; } /*! * \brief Get the kind of solver for the implicit solver. * \return Numerical solver for implicit formulation (solving the linear system). */ - unsigned short GetKind_Deform_Linear_Solver(void); + unsigned short GetKind_Deform_Linear_Solver(void) const { return Kind_Deform_Linear_Solver; } /*! * \brief Set the kind of preconditioner for the implicit solver. * \return Numerical preconditioner for implicit formulation (solving the linear system). */ - void SetKind_Deform_Linear_Solver_Prec(unsigned short val_kind_prec); + void SetKind_Deform_Linear_Solver_Prec(unsigned short val_kind_prec) { Kind_Deform_Linear_Solver_Prec = val_kind_prec; } /*! * \brief Set the kind of preconditioner for the implicit solver. * \return Numerical preconditioner for implicit formulation (solving the linear system). */ - void SetKind_Linear_Solver_Prec(unsigned short val_kind_prec); + void SetKind_Linear_Solver_Prec(unsigned short val_kind_prec) { Kind_Linear_Solver_Prec = val_kind_prec; } /*! * \brief Get min error of the linear solver for the implicit formulation. * \return Min error of the linear solver for the implicit formulation. */ - su2double GetLinear_Solver_Error(void); + su2double GetLinear_Solver_Error(void) const { return Linear_Solver_Error; } /*! * \brief Get min error of the linear solver for the implicit formulation. * \return Min error of the linear solver for the implicit formulation. */ - su2double GetDeform_Linear_Solver_Error(void); + su2double GetDeform_Linear_Solver_Error(void) const { return Deform_Linear_Solver_Error; } /*! * \brief Get max number of iterations of the linear solver for the implicit formulation. * \return Max number of iterations of the linear solver for the implicit formulation. */ - unsigned long GetLinear_Solver_Iter(void); + unsigned long GetLinear_Solver_Iter(void) const { return Linear_Solver_Iter; } /*! * \brief Get max number of iterations of the linear solver for the implicit formulation. * \return Max number of iterations of the linear solver for the implicit formulation. */ - unsigned long GetDeform_Linear_Solver_Iter(void); + unsigned long GetDeform_Linear_Solver_Iter(void) const { return Deform_Linear_Solver_Iter; } /*! * \brief Get the ILU fill-in level for the linear solver. * \return Fill in level of the ILU preconditioner for the linear solver. */ - unsigned short GetLinear_Solver_ILU_n(void); + unsigned short GetLinear_Solver_ILU_n(void) const { return Linear_Solver_ILU_n; } /*! * \brief Get restart frequency of the linear solver for the implicit formulation. * \return Restart frequency of the linear solver for the implicit formulation. */ - unsigned long GetLinear_Solver_Restart_Frequency(void); + unsigned long GetLinear_Solver_Restart_Frequency(void) const { return Linear_Solver_Restart_Frequency; } /*! * \brief Get the relaxation factor for iterative linear smoothers. * \return Relaxation factor. */ - su2double GetLinear_Solver_Smoother_Relaxation(void) const; + su2double GetLinear_Solver_Smoother_Relaxation(void) const { return Linear_Solver_Smoother_Relaxation; } /*! * \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); + su2double GetRelaxation_Factor_AdjFlow(void) const { return Relaxation_Factor_AdjFlow; } /*! * \brief Get the relaxation coefficient of the CHT coupling. * \return relaxation coefficient of the CHT coupling. */ - su2double GetRelaxation_Factor_CHT(void); + su2double GetRelaxation_Factor_CHT(void) const { return Relaxation_Factor_CHT; } /*! * \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 GetRoe_Kappa(void); + su2double GetRoe_Kappa(void) const { return Roe_Kappa; } /*! * \brief Get the wing semi span. * \return value of the wing semi span. */ - su2double GetSemiSpan(void); + su2double GetSemiSpan(void) const { return SemiSpan; } /*! * \brief Get the kind of solver for the implicit solver. * \return Numerical solver for implicit formulation (solving the linear system). */ - unsigned short GetKind_AdjTurb_Linear_Solver(void); + unsigned short GetKind_AdjTurb_Linear_Solver(void) const { return Kind_AdjTurb_Linear_Solver; } /*! * \brief Get the kind of preconditioner for the implicit solver. * \return Numerical preconditioner for implicit formulation (solving the linear system). */ - unsigned short GetKind_AdjTurb_Linear_Prec(void); + unsigned short GetKind_AdjTurb_Linear_Prec(void) const { return Kind_AdjTurb_Linear_Prec; } /*! * \brief Get the kind of solver for the implicit solver. * \return Numerical solver for implicit formulation (solving the linear system). */ - unsigned short GetKind_DiscAdj_Linear_Solver(void); + unsigned short GetKind_DiscAdj_Linear_Solver(void) const { return Kind_DiscAdj_Linear_Solver; } /*! * \brief Get the kind of preconditioner for the implicit solver. * \return Numerical preconditioner for implicit formulation (solving the linear system). */ - unsigned short GetKind_DiscAdj_Linear_Prec(void); + unsigned short GetKind_DiscAdj_Linear_Prec(void) const { return Kind_DiscAdj_Linear_Prec; } /*! * \brief Get the kind of preconditioner for the implicit solver. * \return Numerical preconditioner for implicit formulation (solving the linear system). */ - unsigned short GetKind_Deform_Linear_Solver_Prec(void); + unsigned short GetKind_Deform_Linear_Solver_Prec(void) const { return Kind_Deform_Linear_Solver_Prec; } /*! * \brief Set the kind of preconditioner for the implicit solver. * \return Numerical preconditioner for implicit formulation (solving the linear system). */ - void SetKind_AdjTurb_Linear_Prec(unsigned short val_kind_prec); + void SetKind_AdjTurb_Linear_Prec(unsigned short val_kind_prec) { Kind_AdjTurb_Linear_Prec = val_kind_prec; } /*! * \brief Get min error of the linear solver for the implicit formulation. * \return Min error of the linear solver for the implicit formulation. */ - su2double GetAdjTurb_Linear_Error(void); + su2double GetAdjTurb_Linear_Error(void) const { return AdjTurb_Linear_Error; } /*! * \brief Get the entropy fix. * \return Vaule of the entropy fix. */ - su2double GetEntropyFix_Coeff(void); + su2double GetEntropyFix_Coeff(void) const { return EntropyFix_Coeff; } /*! * \brief Get max number of iterations of the linear solver for the implicit formulation. * \return Max number of iterations of the linear solver for the implicit formulation. */ - unsigned short GetAdjTurb_Linear_Iter(void); + unsigned short GetAdjTurb_Linear_Iter(void) const { return AdjTurb_Linear_Iter; } /*! * \brief Get CFL reduction factor for adjoint turbulence model. * \return CFL reduction factor. */ - su2double GetCFLRedCoeff_AdjTurb(void); + su2double GetCFLRedCoeff_AdjTurb(void) const { return CFLRedCoeff_AdjTurb; } /*! * \brief Get the number of nonlinear increments for mesh deformation. * \return Number of nonlinear increments for mesh deformation. */ - unsigned long GetGridDef_Nonlinear_Iter(void); + unsigned long GetGridDef_Nonlinear_Iter(void) const { return GridDef_Nonlinear_Iter; } /*! * \brief Get information about whether the mesh will be deformed using pseudo linear elasticity. * \return TRUE means that grid deformation is active. */ - bool GetDeform_Mesh(void); + bool GetDeform_Mesh(void) const { return Deform_Mesh; } /*! * \brief Get information about writing grid deformation residuals to the console. * \return TRUE means that grid deformation residuals will be written to the console. */ - bool GetDeform_Output(void); + bool GetDeform_Output(void) const { return Deform_Output; } /*! * \brief Get factor to multiply smallest volume for deform tolerance. * \return Factor to multiply smallest volume for deform tolerance. */ - su2double GetDeform_Coeff(void); + su2double GetDeform_Coeff(void) const { return Deform_Coeff; } /*! * \brief Get limit for the volumetric deformation. * \return Distance to the surface to be deformed. */ - su2double GetDeform_Limit(void); + su2double GetDeform_Limit(void) const { return Deform_Limit; } /*! * \brief Get Young's modulus for deformation (constant stiffness deformation) */ - su2double GetDeform_ElasticityMod(void); + su2double GetDeform_ElasticityMod(void) const { return Deform_ElasticityMod; } /*! * \brief Get Poisson's ratio for deformation (constant stiffness deformation) * \ */ - su2double GetDeform_PoissonRatio(void); + su2double GetDeform_PoissonRatio(void) const { return Deform_PoissonRatio; } /*! * \brief Get the type of stiffness to impose for FEA mesh deformation. * \return type of stiffness to impose for FEA mesh deformation. */ - unsigned short GetDeform_Stiffness_Type(void); + unsigned short GetDeform_Stiffness_Type(void) const { return Deform_Stiffness_Type; } /*! * \brief Creates a tecplot file to visualize the volume deformation deformation made by the DEF software. * \return TRUE if the deformation is going to be plotted; otherwise FALSE. */ - bool GetVisualize_Volume_Def(void); + bool GetVisualize_Volume_Def(void) const { return Visualize_Volume_Def; } /*! * \brief Creates a teot file to visualize the surface deformation deformation made by the DEF software. * \return TRUE if the deformation is going to be plotted; otherwise FALSE. */ - bool GetVisualize_Surface_Def(void); + bool GetVisualize_Surface_Def(void) const { return Visualize_Surface_Def; } /*! * \brief Define the FFD box with a symetry plane. * \return TRUE if there is a symmetry plane in the FFD; otherwise FALSE. */ - bool GetFFD_Symmetry_Plane(void); + bool GetFFD_Symmetry_Plane(void) const { return FFD_Symmetry_Plane; } /*! * \brief Get the kind of SU2 software component. * \return Kind of the SU2 software component. */ - unsigned short GetKind_SU2(void); + unsigned short GetKind_SU2(void) const { return Kind_SU2; } /*! * \brief Get the kind of non-dimensionalization. * \return Kind of non-dimensionalization. */ - unsigned short GetRef_NonDim(void); + unsigned short GetRef_NonDim(void) const { return Ref_NonDim; } /*! * \brief Get the kind of incompressible non-dimensionalization. * \return Kind of incompressible non-dimensionalization. */ - unsigned short GetRef_Inc_NonDim(void); + unsigned short GetRef_Inc_NonDim(void) const { return Ref_Inc_NonDim; } /*! * \brief Get the kind of SU2 software component. * \return Kind of the SU2 software component. */ - void SetKind_SU2(unsigned short val_kind_su2); + void SetKind_SU2(unsigned short val_kind_su2) { Kind_SU2 = val_kind_su2 ; } /*! * \brief Get the kind of the turbulence model. * \return Kind of the turbulence model. */ - unsigned short GetKind_Turb_Model(void); + unsigned short GetKind_Turb_Model(void) const { return Kind_Turb_Model; } /*! * \brief Get the kind of the transition model. * \return Kind of the transion model. */ - unsigned short GetKind_Trans_Model(void); + unsigned short GetKind_Trans_Model(void) const { return Kind_Trans_Model; } /*! * \brief Get the kind of the subgrid scale model. * \return Kind of the subgrid scale model. */ - unsigned short GetKind_SGS_Model(void); + unsigned short GetKind_SGS_Model(void) const { return Kind_SGS_Model; } /*! * \brief Get the kind of adaptation technique. * \return Kind of adaptation technique. */ - unsigned short GetKind_Adaptation(void); + unsigned short GetKind_Adaptation(void) const { return Kind_Adaptation; } /*! * \brief Get the number of new elements added in the adaptation process. * \return percentage of new elements that are going to be added in the adaptation. */ - su2double GetNew_Elem_Adapt(void); + su2double GetNew_Elem_Adapt(void) const { return New_Elem_Adapt; } /*! * \brief Get the kind of time integration method. @@ -4133,7 +4153,7 @@ class CConfig { * linearized) that is being solved. * \return Kind of time integration method. */ - unsigned short GetKind_TimeIntScheme(void); + unsigned short GetKind_TimeIntScheme(void) const { return Kind_TimeNumScheme; } /*! * \brief Get the kind of convective numerical scheme. @@ -4142,7 +4162,7 @@ class CConfig { * linearized) that is being solved. * \return Kind of the convective scheme. */ - unsigned short GetKind_ConvNumScheme(void); + unsigned short GetKind_ConvNumScheme(void) const { return Kind_ConvNumScheme; } /*! * \brief Get kind of center scheme for the convective terms. @@ -4151,7 +4171,7 @@ class CConfig { * linearized) that is being solved. * \return Kind of center scheme for the convective terms. */ - unsigned short GetKind_Centered(void); + unsigned short GetKind_Centered(void) const { return Kind_Centered; } /*! * \brief Get kind of upwind scheme for the convective terms. @@ -4160,7 +4180,7 @@ class CConfig { * linearized) that is being solved. * \return Kind of upwind scheme for the convective terms. */ - unsigned short GetKind_Upwind(void); + unsigned short GetKind_Upwind(void) const { return Kind_Upwind; } /*! * \brief Get if the upwind scheme used MUSCL or not. @@ -4169,7 +4189,7 @@ class CConfig { * linearized) that is being solved. * \return MUSCL scheme. */ - bool GetMUSCL(void); + bool GetMUSCL(void) const { return MUSCL; } /*! * \brief Get if the upwind scheme used MUSCL or not. @@ -4178,7 +4198,7 @@ class CConfig { * linearized) that is being solved. * \return MUSCL scheme. */ - bool GetMUSCL_Flow(void); + bool GetMUSCL_Flow(void) const { return MUSCL_Flow; } /*! * \brief Get if the upwind scheme used MUSCL or not. @@ -4187,7 +4207,7 @@ class CConfig { * linearized) that is being solved. * \return MUSCL scheme. */ - bool GetMUSCL_Heat(void); + bool GetMUSCL_Heat(void) const { return MUSCL_Heat; } /*! * \brief Get if the upwind scheme used MUSCL or not. @@ -4196,7 +4216,7 @@ class CConfig { * linearized) that is being solved. * \return MUSCL scheme. */ - bool GetMUSCL_Turb(void); + bool GetMUSCL_Turb(void) const { return MUSCL_Turb; } /*! * \brief Get if the upwind scheme used MUSCL or not. @@ -4205,7 +4225,7 @@ class CConfig { * linearized) that is being solved. * \return MUSCL scheme. */ - bool GetMUSCL_AdjFlow(void); + bool GetMUSCL_AdjFlow(void) const { return MUSCL_AdjFlow; } /*! * \brief Get if the upwind scheme used MUSCL or not. @@ -4214,13 +4234,13 @@ class CConfig { * linearized) that is being solved. * \return MUSCL scheme. */ - bool GetMUSCL_AdjTurb(void); + bool GetMUSCL_AdjTurb(void) const { return MUSCL_AdjTurb; } /*! * \brief Get whether to "Use Accurate Jacobians" for AUSM+up(2) and SLAU(2). * \return yes/no. */ - inline bool GetUse_Accurate_Jacobians(void) { return Use_Accurate_Jacobians; } + bool GetUse_Accurate_Jacobians(void) { return Use_Accurate_Jacobians; } /*! * \brief Get the kind of integration scheme (explicit or implicit) @@ -4229,14 +4249,14 @@ class CConfig { * during the computation. * \return Kind of integration scheme for the flow equations. */ - unsigned short GetKind_TimeIntScheme_Flow(void); + unsigned short GetKind_TimeIntScheme_Flow(void) const { return Kind_TimeIntScheme_Flow; } /*! * \brief Get the kind of scheme (aliased or non-aliased) to be used in the * predictor step of ADER-DG. * \return Kind of scheme used in the predictor step of ADER-DG. */ - unsigned short GetKind_ADER_Predictor(void); + unsigned short GetKind_ADER_Predictor(void) const { return Kind_ADER_Predictor; } /*! * \brief Get the kind of integration scheme (explicit or implicit) @@ -4245,7 +4265,7 @@ class CConfig { * during the computation. * \return Kind of integration scheme for the plasma equations. */ - unsigned short GetKind_TimeIntScheme_Heat(void); + unsigned short GetKind_TimeIntScheme_Heat(void) const { return Kind_TimeIntScheme_Heat; } /*! * \brief Get the kind of time stepping @@ -4254,7 +4274,7 @@ class CConfig { * during the computation. * \return Kind of time stepping for the heat equation. */ - unsigned short GetKind_TimeStep_Heat(void); + unsigned short GetKind_TimeStep_Heat(void) const { return Kind_TimeStep_Heat; } /*! * \brief Get the kind of integration scheme (explicit or implicit) @@ -4263,7 +4283,7 @@ class CConfig { * during the computation. * \return Kind of integration scheme for the plasma equations. */ - unsigned short GetKind_TimeIntScheme_FEA(void); + unsigned short GetKind_TimeIntScheme_FEA(void) const { return Kind_TimeIntScheme_FEA; } /*! * \brief Get the kind of integration scheme (explicit or implicit) @@ -4281,7 +4301,7 @@ class CConfig { * during the computation. * \return Kind of integration scheme for the plasma equations. */ - unsigned short GetKind_SpaceIteScheme_FEA(void); + unsigned short GetKind_SpaceIteScheme_FEA(void) const { return Kind_SpaceIteScheme_FEA; } /*! * \brief Get the kind of convective numerical scheme for the flow @@ -4290,7 +4310,7 @@ class CConfig { * during the computation. * \return Kind of convective numerical scheme for the flow equations. */ - unsigned short GetKind_ConvNumScheme_Flow(void); + unsigned short GetKind_ConvNumScheme_Flow(void) const { return Kind_ConvNumScheme_Flow; } /*! * \brief Get the kind of convective numerical scheme for the flow @@ -4299,7 +4319,7 @@ class CConfig { * during the computation. * \return Kind of convective numerical scheme for the flow equations. */ - unsigned short GetKind_ConvNumScheme_FEM_Flow(void); + unsigned short GetKind_ConvNumScheme_FEM_Flow(void) const { return Kind_ConvNumScheme_FEM_Flow; } /*! * \brief Get the kind of convective numerical scheme for the template @@ -4308,7 +4328,7 @@ class CConfig { * during the computation. * \return Kind of convective numerical scheme for the flow equations. */ - unsigned short GetKind_ConvNumScheme_Template(void); + unsigned short GetKind_ConvNumScheme_Template(void) const { return Kind_ConvNumScheme_Template; } /*! * \brief Get the kind of center convective numerical scheme for the flow equations. @@ -4316,7 +4336,7 @@ class CConfig { * during the computation. * \return Kind of center convective numerical scheme for the flow equations. */ - unsigned short GetKind_Centered_Flow(void); + unsigned short GetKind_Centered_Flow(void) const { return Kind_Centered_Flow; } /*! * \brief Get the kind of center convective numerical scheme for the plasma equations. @@ -4332,7 +4352,7 @@ class CConfig { * during the computation. * \return Kind of upwind convective numerical scheme for the flow equations. */ - unsigned short GetKind_Upwind_Flow(void); + unsigned short GetKind_Upwind_Flow(void) const { return Kind_Upwind_Flow; } /*! * \brief Get the kind of finite element convective numerical scheme for the flow equations. @@ -4340,7 +4360,7 @@ class CConfig { * during the computation. * \return Kind of finite element convective numerical scheme for the flow equations. */ - unsigned short GetKind_FEM_Flow(void); + unsigned short GetKind_FEM_Flow(void) const { return Kind_FEM_Flow; } /*! * \brief Get the kind of shock capturing method in FEM DG solver. @@ -4348,7 +4368,7 @@ class CConfig { * during the computation. * \return Kind of shock capturing method in FEM DG solver. */ - unsigned short GetKind_FEM_DG_Shock(void); + unsigned short GetKind_FEM_DG_Shock(void) const { return Kind_FEM_DG_Shock; } /*! * \brief Get the kind of matrix coloring used for the sparse Jacobian computation. @@ -4356,74 +4376,74 @@ class CConfig { * during the computation. * \return Kind of matrix coloring used. */ - unsigned short GetKind_Matrix_Coloring(void); + unsigned short GetKind_Matrix_Coloring(void) const { return Kind_Matrix_Coloring; } /*! * \brief Get the method for limiting the spatial gradients. * \return Method for limiting the spatial gradients. */ - unsigned short GetKind_SlopeLimit(void); + unsigned short GetKind_SlopeLimit(void) const { return Kind_SlopeLimit; } /*! * \brief Get the method for limiting the spatial gradients. * \return Method for limiting the spatial gradients solving the flow equations. */ - unsigned short GetKind_SlopeLimit_Flow(void); + unsigned short GetKind_SlopeLimit_Flow(void) const { return Kind_SlopeLimit_Flow; } /*! * \brief Get the method for limiting the spatial gradients. * \return Method for limiting the spatial gradients solving the turbulent equation. */ - unsigned short GetKind_SlopeLimit_Turb(void); + unsigned short GetKind_SlopeLimit_Turb(void) const { return Kind_SlopeLimit_Turb; } /*! * \brief Get the method for limiting the spatial gradients. * \return Method for limiting the spatial gradients solving the adjoint turbulent equation. */ - unsigned short GetKind_SlopeLimit_AdjTurb(void); + unsigned short GetKind_SlopeLimit_AdjTurb(void) const { return Kind_SlopeLimit_AdjTurb; } /*! * \brief Get the method for limiting the spatial gradients. * \return Method for limiting the spatial gradients solving the adjoint flow equation. */ - unsigned short GetKind_SlopeLimit_AdjFlow(void); + unsigned short GetKind_SlopeLimit_AdjFlow(void) const { return Kind_SlopeLimit_AdjFlow; } /*! * \brief Value of the calibrated constant for the Lax method (center scheme). * \note This constant is used in coarse levels and with first order methods. * \return Calibrated constant for the Lax method. */ - su2double GetKappa_1st_Flow(void); + su2double GetKappa_1st_Flow(void) const { return Kappa_1st_Flow; } /*! * \brief Value of the calibrated constant for the JST method (center scheme). * \return Calibrated constant for the JST method for the flow equations. */ - su2double GetKappa_2nd_Flow(void); + su2double GetKappa_2nd_Flow(void) const { return Kappa_2nd_Flow; } /*! * \brief Value of the calibrated constant for the JST method (center scheme). * \return Calibrated constant for the JST method for the flow equations. */ - su2double GetKappa_4th_Flow(void); + su2double GetKappa_4th_Flow(void) const { return Kappa_4th_Flow; } /*! * \brief Value of the calibrated constant for the JST method (center scheme). * \return Calibrated constant for the JST-like method for the heat equations. */ - su2double GetKappa_2nd_Heat(void); + su2double GetKappa_2nd_Heat(void) const { return Kappa_2nd_Heat; } /*! * \brief Value of the calibrated constant for the JST-like method (center scheme). * \return Calibrated constant for the JST-like method for the heat equation. */ - su2double GetKappa_4th_Heat(void); + su2double GetKappa_4th_Heat(void) const { return Kappa_4th_Heat; } /*! * \brief Factor by which to multiply the dissipation contribution to Jacobians of central schemes. * \return The factor. */ - inline su2double GetCent_Jac_Fix_Factor(void) { return Cent_Jac_Fix_Factor; } + su2double GetCent_Jac_Fix_Factor(void) { return Cent_Jac_Fix_Factor; } /*! * \brief Get the kind of integration scheme (explicit or implicit) @@ -4432,7 +4452,7 @@ class CConfig { * during the computation. * \return Kind of integration scheme for the adjoint flow equations. */ - unsigned short GetKind_TimeIntScheme_AdjFlow(void); + unsigned short GetKind_TimeIntScheme_AdjFlow(void) const { return Kind_TimeIntScheme_AdjFlow; } /*! * \brief Get the kind of convective numerical scheme for the adjoint flow @@ -4441,7 +4461,7 @@ class CConfig { * during the computation. * \return Kind of convective numerical scheme for the adjoint flow equations. */ - unsigned short GetKind_ConvNumScheme_AdjFlow(void); + unsigned short GetKind_ConvNumScheme_AdjFlow(void) const { return Kind_ConvNumScheme_AdjFlow; } /*! * \brief Get the kind of center convective numerical scheme for the adjoint flow equations. @@ -4449,7 +4469,7 @@ class CConfig { * during the computation. * \return Kind of center convective numerical scheme for the adjoint flow equations. */ - unsigned short GetKind_Centered_AdjFlow(void); + unsigned short GetKind_Centered_AdjFlow(void) const { return Kind_Centered_AdjFlow; } /*! * \brief Get the kind of upwind convective numerical scheme for the adjoint flow equations. @@ -4457,25 +4477,25 @@ class CConfig { * during the computation. * \return Kind of upwind convective numerical scheme for the adjoint flow equations. */ - unsigned short GetKind_Upwind_AdjFlow(void); + unsigned short GetKind_Upwind_AdjFlow(void) const { return Kind_Upwind_AdjFlow; } /*! * \brief Value of the calibrated constant for the high order method (center scheme). * \return Calibrated constant for the high order center method for the adjoint flow equations. */ - su2double GetKappa_2nd_AdjFlow(void); + su2double GetKappa_2nd_AdjFlow(void) const { return Kappa_2nd_AdjFlow; } /*! * \brief Value of the calibrated constant for the high order method (center scheme). * \return Calibrated constant for the high order center method for the adjoint flow equations. */ - su2double GetKappa_4th_AdjFlow(void); + su2double GetKappa_4th_AdjFlow(void) const { return Kappa_4th_AdjFlow; } /*! * \brief Value of the calibrated constant for the low order method (center scheme). * \return Calibrated constant for the low order center method for the adjoint flow equations. */ - su2double GetKappa_1st_AdjFlow(void); + su2double GetKappa_1st_AdjFlow(void) const { return Kappa_1st_AdjFlow; } /*! * \brief Get the kind of integration scheme (implicit) @@ -4484,7 +4504,7 @@ class CConfig { * during the computation. * \return Kind of integration scheme for the turbulence equations. */ - unsigned short GetKind_TimeIntScheme_Turb(void); + unsigned short GetKind_TimeIntScheme_Turb(void) const { return Kind_TimeIntScheme_Turb; } /*! * \brief Get the kind of convective numerical scheme for the turbulence @@ -4493,7 +4513,7 @@ class CConfig { * during the computation. * \return Kind of convective numerical scheme for the turbulence equations. */ - unsigned short GetKind_ConvNumScheme_Turb(void); + unsigned short GetKind_ConvNumScheme_Turb(void) const { return Kind_ConvNumScheme_Turb; } /*! * \brief Get the kind of center convective numerical scheme for the turbulence equations. @@ -4501,7 +4521,7 @@ class CConfig { * during the computation. * \return Kind of center convective numerical scheme for the turbulence equations. */ - unsigned short GetKind_Centered_Turb(void); + unsigned short GetKind_Centered_Turb(void) const { return Kind_Centered_Turb; } /*! * \brief Get the kind of upwind convective numerical scheme for the turbulence equations. @@ -4509,7 +4529,7 @@ class CConfig { * during the computation. * \return Kind of upwind convective numerical scheme for the turbulence equations. */ - unsigned short GetKind_Upwind_Turb(void); + unsigned short GetKind_Upwind_Turb(void) const { return Kind_Upwind_Turb; } /*! * \brief Get the kind of integration scheme (explicit or implicit) @@ -4518,7 +4538,7 @@ class CConfig { * during the computation. * \return Kind of integration scheme for the adjoint turbulence equations. */ - unsigned short GetKind_TimeIntScheme_AdjTurb(void); + unsigned short GetKind_TimeIntScheme_AdjTurb(void) const { return Kind_TimeIntScheme_AdjTurb; } /*! * \brief Get the kind of convective numerical scheme for the adjoint turbulence @@ -4527,7 +4547,7 @@ class CConfig { * during the computation. * \return Kind of convective numerical scheme for the adjoint turbulence equations. */ - unsigned short GetKind_ConvNumScheme_AdjTurb(void); + unsigned short GetKind_ConvNumScheme_AdjTurb(void) const { return Kind_ConvNumScheme_AdjTurb; } /*! * \brief Get the kind of convective numerical scheme for the heat equation. @@ -4535,7 +4555,7 @@ class CConfig { * during the computation. * \return Kind of convective numerical scheme for the heat equation. */ - unsigned short GetKind_ConvNumScheme_Heat(void); + unsigned short GetKind_ConvNumScheme_Heat(void) const { return Kind_ConvNumScheme_Heat; } /*! * \brief Get the kind of center convective numerical scheme for the adjoint turbulence equations. @@ -4543,7 +4563,7 @@ class CConfig { * during the computation. * \return Kind of center convective numerical scheme for the adjoint turbulence equations. */ - unsigned short GetKind_Centered_AdjTurb(void); + unsigned short GetKind_Centered_AdjTurb(void) const { return Kind_Centered_AdjTurb; } /*! * \brief Get the kind of upwind convective numerical scheme for the adjoint turbulence equations. @@ -4551,64 +4571,64 @@ class CConfig { * during the computation. * \return Kind of upwind convective numerical scheme for the adjoint turbulence equations. */ - unsigned short GetKind_Upwind_AdjTurb(void); + unsigned short GetKind_Upwind_AdjTurb(void) const { return Kind_Upwind_AdjTurb; } /*! * \brief Provides information about the way in which the turbulence will be treated by the * cont. adjoint method. * \return FALSE means that the adjoint turbulence equations will be used. */ - bool GetFrozen_Visc_Cont(void); + bool GetFrozen_Visc_Cont(void) const { return Frozen_Visc_Cont; } /*! * \brief Provides information about the way in which the turbulence will be treated by the * disc. adjoint method. * \return FALSE means that the adjoint turbulence equations will be used. */ - bool GetFrozen_Visc_Disc(void); + bool GetFrozen_Visc_Disc(void) const { return Frozen_Visc_Disc; } /*! * \brief Provides information about using an inconsistent (primal/dual) discrete adjoint formulation * \return FALSE means that the adjoint use the same numerical methods than the primal problem. */ - bool GetInconsistent_Disc(void); + bool GetInconsistent_Disc(void) const { return Inconsistent_Disc; } /*! * \brief Provides information about the way in which the limiter will be treated by the * disc. adjoint method. * \return FALSE means that the limiter computation is included. */ - bool GetFrozen_Limiter_Disc(void); + bool GetFrozen_Limiter_Disc(void) const { return Frozen_Limiter_Disc; } /*! * \brief Provides information about if the sharp edges are going to be removed from the sensitivity. * \return FALSE means that the sharp edges will be removed from the sensitivity. */ - bool GetSens_Remove_Sharp(void); + bool GetSens_Remove_Sharp(void) const { return Sens_Remove_Sharp; } /*! * \brief Get the kind of inlet boundary condition treatment (total conditions or mass flow). * \return Kind of inlet boundary condition. */ - unsigned short GetKind_Inlet(void); + unsigned short GetKind_Inlet(void) const { return Kind_Inlet; } /*! * \brief Check if the inlet profile(s) are specified in an input file * \return True if an input file is to be used for the inlet profile(s) */ - bool GetInlet_Profile_From_File(void); + bool GetInlet_Profile_From_File(void) const { return Inlet_From_File; } /*! * \brief Get name of the input file for the specified inlet profile. * \return Name of the input file for the specified inlet profile. */ - string GetInlet_FileName(void); + string GetInlet_FileName(void) const { return Inlet_Filename; } /*! * \brief Get the tolerance used for matching two points on a specified inlet * \return Tolerance used for matching a point to a specified inlet */ - su2double GetInlet_Profile_Matching_Tolerance(void); + su2double GetInlet_Profile_Matching_Tolerance(void) const { return Inlet_Matching_Tol; } /*! * \brief Get the type of incompressible inlet from the list. @@ -4620,13 +4640,13 @@ class CConfig { * \brief Get the total number of types in Kind_Inc_Inlet list * \return Total number of types in Kind_Inc_Inlet list */ - unsigned short GetnInc_Inlet(void); + unsigned short GetnInc_Inlet(void) const { return nInc_Inlet;} /*! * \brief Flag for whether the local boundary normal is used as the flow direction for an incompressible pressure inlet. * \return FALSE means the prescribed flow direction is used. */ - bool GetInc_Inlet_UseNormal(void); + bool GetInc_Inlet_UseNormal(void) const { return Inc_Inlet_UseNormal;} /*! * \brief Get the type of incompressible outlet from the list. @@ -4638,242 +4658,242 @@ class CConfig { * \brief Get the damping factor applied to velocity updates at incompressible pressure inlets. * \return Damping factor applied to velocity updates at incompressible pressure inlets. */ - su2double GetInc_Inlet_Damping(void); + su2double GetInc_Inlet_Damping(void) const { return Inc_Inlet_Damping; } /*! * \brief Get the damping factor applied to pressure updates at incompressible mass flow outlet. * \return Damping factor applied to pressure updates at incompressible mass flow outlet. */ - su2double GetInc_Outlet_Damping(void); + su2double GetInc_Outlet_Damping(void) const { return Inc_Outlet_Damping; } /*! * \brief Get the kind of mixing process for averaging quantities at the boundaries. * \return Kind of mixing process. */ - unsigned short GetKind_AverageProcess(void); + unsigned short GetKind_AverageProcess(void) const { return Kind_AverageProcess; } /*! * \brief Get the kind of mixing process for averaging quantities at the boundaries. * \return Kind of mixing process. */ - unsigned short GetKind_PerformanceAverageProcess(void); + unsigned short GetKind_PerformanceAverageProcess(void) const { return Kind_PerformanceAverageProcess; } /*! * \brief Set the kind of mixing process for averaging quantities at the boundaries. * \return Kind of mixing process. */ - void SetKind_AverageProcess(unsigned short new_AverageProcess); + void SetKind_AverageProcess(unsigned short new_AverageProcess) { Kind_AverageProcess = new_AverageProcess; } /*! * \brief Set the kind of mixing process for averaging quantities at the boundaries. * \return Kind of mixing process. */ - void SetKind_PerformanceAverageProcess(unsigned short new_AverageProcess); + void SetKind_PerformanceAverageProcess(unsigned short new_AverageProcess) { Kind_PerformanceAverageProcess = new_AverageProcess; } /*! * \brief Get coeff for Rotating Frame Ramp. * \return coeff Ramp Rotating Frame. */ - su2double GetRampRotatingFrame_Coeff(unsigned short iCoeff); + su2double GetRampRotatingFrame_Coeff(unsigned short iCoeff) const { return RampRotatingFrame_Coeff[iCoeff];} /*! * \brief Get Rotating Frame Ramp option. * \return Ramp Rotating Frame option. */ - bool GetRampRotatingFrame(void); + bool GetRampRotatingFrame(void) const { return RampRotatingFrame;} /*! * \brief Get coeff for Outlet Pressure Ramp. * \return coeff Ramp Outlet Pressure. */ - su2double GetRampOutletPressure_Coeff(unsigned short iCoeff); + su2double GetRampOutletPressure_Coeff(unsigned short iCoeff) const { return RampOutletPressure_Coeff[iCoeff];} /*! * \brief Get final Outlet Pressure value for the ramp. * \return final Outlet Pressure value. */ - su2double GetFinalOutletPressure(void); + su2double GetFinalOutletPressure(void) const { return FinalOutletPressure; } /*! * \brief Get final Outlet Pressure value for the ramp. * \return Monitor Outlet Pressure value. */ - su2double GetMonitorOutletPressure(void); + su2double GetMonitorOutletPressure(void) const { return MonitorOutletPressure; } /*! * \brief Set Monitor Outlet Pressure value for the ramp. */ - void SetMonitotOutletPressure(su2double newMonPres); + void SetMonitotOutletPressure(su2double newMonPres) { MonitorOutletPressure = newMonPres;} /*! * \brief Get Outlet Pressure Ramp option. * \return Ramp Outlet pressure option. */ - bool GetRampOutletPressure(void); + bool GetRampOutletPressure(void) const { return RampOutletPressure;} /*! * \brief Get mixedout coefficients. * \return mixedout coefficient. */ - su2double GetMixedout_Coeff(unsigned short iCoeff); + su2double GetMixedout_Coeff(unsigned short iCoeff) const { return Mixedout_Coeff[iCoeff];} /*! * \brief Get extra relaxation factor coefficients for the Giels BC. * \return mixedout coefficient. */ - su2double GetExtraRelFacGiles(unsigned short iCoeff); + su2double GetExtraRelFacGiles(unsigned short iCoeff) const { return ExtraRelFacGiles[iCoeff];} /*! * \brief Get mach limit for average massflow-based procedure . * \return mach limit. */ - su2double GetAverageMachLimit(void); + su2double GetAverageMachLimit(void) const { return AverageMachLimit;} /*! * \brief Get the kind of mixing process for averaging quantities at the boundaries. * \return Kind of mixing process. */ - unsigned short GetKind_MixingPlaneInterface(void); + unsigned short GetKind_MixingPlaneInterface(void) const { return Kind_MixingPlaneInterface;} /*! * \brief Get the kind of turbomachinery architecture. * \return Kind of turbomachinery architecture. */ - unsigned short GetKind_TurboMachinery(unsigned short val_iZone); + unsigned short GetKind_TurboMachinery(unsigned short val_iZone) const { return Kind_TurboMachinery[val_iZone]; } /*! * \brief Get the kind of turbomachinery architecture. * \return Kind of turbomachinery architecture. */ - unsigned short GetKind_SpanWise(void); + unsigned short GetKind_SpanWise(void) const { return Kind_SpanWise; } /*! * \brief Verify if there is mixing plane interface specified from config file. * \return boolean. */ - bool GetBoolMixingPlaneInterface(void); + bool GetBoolMixingPlaneInterface(void) const { return (nMarker_MixingPlaneInterface !=0);} /*! * \brief Verify if there is mixing plane interface specified from config file. * \return boolean. */ - bool GetBoolTurbMixingPlane(void); + bool GetBoolTurbMixingPlane(void) const { return turbMixingPlane;} /*! * \brief Verify if there is mixing plane interface specified from config file. * \return boolean. */ - bool GetSpatialFourier(void); + bool GetSpatialFourier(void) const { return SpatialFourier;} /*! * \brief number mixing plane interface specified from config file. * \return number of bound. */ - unsigned short GetnMarker_MixingPlaneInterface(void); + unsigned short GetnMarker_MixingPlaneInterface(void) const { return nMarker_MixingPlaneInterface;} /*! * \brief Verify if there is Turbomachinery performance option specified from config file. * \return boolean. */ - bool GetBoolTurbomachinery(void); + bool GetBoolTurbomachinery(void) const { return (nMarker_Turbomachinery !=0);} /*! * \brief number Turbomachinery blades computed using the pitch information. * \return nBlades. */ - su2double GetnBlades(unsigned short val_iZone); + su2double GetnBlades(unsigned short val_iZone) const { return nBlades[val_iZone];} /*! * \brief number Turbomachinery blades computed using the pitch information. * \return nBlades. */ - void SetnBlades(unsigned short val_iZone, su2double nblades); + void SetnBlades(unsigned short val_iZone, su2double nblades) { nBlades[val_iZone] = nblades;} /*! * \brief Verify if there is any Giles Boundary Condition option specified from config file. * \return boolean. */ - bool GetBoolGiles(void); + bool GetBoolGiles(void) const { return (nMarker_Giles!=0);} /*! * \brief Verify if there is any Riemann Boundary Condition option specified from config file. * \return boolean. */ - bool GetBoolRiemann(void); + bool GetBoolRiemann(void) const { return (nMarker_Riemann!=0);} /*! * \brief number Turbomachinery performance option specified from config file. * \return number of bound. */ - unsigned short GetnMarker_Turbomachinery(void); + unsigned short GetnMarker_Turbomachinery(void) const { return nMarker_Turbomachinery;} /*! * \brief Get number of shroud markers. * \return number of marker shroud. */ - unsigned short GetnMarker_Shroud(void); + unsigned short GetnMarker_Shroud(void) const { return nMarker_Shroud;} /*! * \brief Get the marker shroud. * \return marker shroud. */ - string GetMarker_Shroud(unsigned short val_marker); + string GetMarker_Shroud(unsigned short val_marker) const { return Marker_Shroud[val_marker];} /*! * \brief number Turbomachinery performance option specified from config file. * \return number of bound. */ - unsigned short GetnMarker_TurboPerformance(void); + unsigned short GetnMarker_TurboPerformance(void) const { return nMarker_TurboPerformance;} /*! * \brief number span-wise sections to compute 3D BC and performance for turbomachinery specified by the user. * \return number of span-wise sections. */ - unsigned short Get_nSpanWiseSections_User(void); + unsigned short Get_nSpanWiseSections_User(void) const { return nSpanWiseSections_User;} /*! * \brief number span-wise sections to compute 3D BC and performance for turbomachinery. * \return number of span-wise sections. */ - unsigned short GetnSpanWiseSections(void); + unsigned short GetnSpanWiseSections(void) const { return nSpanWiseSections;} /*! * \brief set number of maximum span-wise sections among all zones . */ - void SetnSpanMaxAllZones(unsigned short val_nSpna_max); + void SetnSpanMaxAllZones(unsigned short val_nSpna_max) { nSpanMaxAllZones = val_nSpna_max;} /*! * \brief number span-wise sections to compute performance for turbomachinery. * \return number of max span-wise sections. */ - unsigned short GetnSpanMaxAllZones(void); + unsigned short GetnSpanMaxAllZones(void) const { return nSpanMaxAllZones;} /*! * \brief set number span-wise sections to compute 3D BC and performance for turbomachinery. */ - void SetnSpanWiseSections(unsigned short nSpan); + void SetnSpanWiseSections(unsigned short nSpan) { nSpanWiseSections = nSpan;} /*! * \brief set number span-wise sections to compute 3D BC and performance for turbomachinery. */ - unsigned short GetnSpan_iZones(unsigned short iZone); + unsigned short GetnSpan_iZones(unsigned short iZone) const { return nSpan_iZones[iZone];} /*! * \brief set number span-wise sections to compute 3D BC and performance for turbomachinery. */ - void SetnSpan_iZones(unsigned short nSpan, unsigned short iZone); + void SetnSpan_iZones(unsigned short nSpan, unsigned short iZone) { nSpan_iZones[iZone] = nSpan;} /*! * \brief get inlet bounds name for Turbomachinery performance calculation. * \return name of the bound. */ - string GetMarker_TurboPerf_BoundIn(unsigned short index); + string GetMarker_TurboPerf_BoundIn(unsigned short index) const { return Marker_TurboBoundIn[index];} /*! * \brief get outlet bounds name for Turbomachinery performance calculation. * \return name of the bound. */ - string GetMarker_TurboPerf_BoundOut(unsigned short index); + string GetMarker_TurboPerf_BoundOut(unsigned short index) const { return Marker_TurboBoundOut[index];} /*! * \brief get marker kind for Turbomachinery performance calculation. @@ -4885,44 +4905,44 @@ class CConfig { * \brief get outlet bounds name for Turbomachinery performance calculation. * \return name of the bound. */ - string GetMarker_PerBound(unsigned short val_marker); + string GetMarker_PerBound(unsigned short val_marker) const { return Marker_PerBound[val_marker];} /*! * \brief Get the kind of inlet boundary condition treatment (total conditions or mass flow). * \return Kind of inlet boundary condition. */ - unsigned short GetKind_Engine_Inflow(void); + unsigned short GetKind_Engine_Inflow(void) const { return Kind_Engine_Inflow; } /*! * \brief Get the kind of inlet boundary condition treatment (total conditions or mass flow). * \return Kind of inlet boundary condition. */ - unsigned short GetKind_ActDisk(void); + unsigned short GetKind_ActDisk(void) const { return Kind_ActDisk; } /*! * \brief Get the number of sections. * \return Number of sections */ - unsigned short GetnLocationStations(void); + unsigned short GetnLocationStations(void) const { return nLocationStations; } /*! * \brief Get the number of sections for computing internal volume. * \return Number of sections for computing internal volume. */ - unsigned short GetnWingStations(void); + unsigned short GetnWingStations(void) const { return nWingStations; } /*! * \brief Get the location of the waterline. * \return Z location of the waterline. */ - su2double GetGeo_Waterline_Location(void); + su2double GetGeo_Waterline_Location(void) const { return Geo_Waterline_Location; } /*! * \brief Provides information about the the nodes that are going to be moved on a deformation * volumetric grid deformation. * \return TRUE means that only the points on the FFD box will be moved. */ - bool GetHold_GridFixed(void); + bool GetHold_GridFixed(void) const { return Hold_GridFixed; } /*! * \brief Get the kind of objective function. There are several options: Drag coefficient, @@ -4930,7 +4950,7 @@ class CConfig { * \note The objective function will determine the boundary condition of the adjoint problem. * \return Kind of objective function. */ - unsigned short GetKind_ObjFunc(void); + unsigned short GetKind_ObjFunc(void) const { return Kind_ObjFunc[0]; } /*! * \author H. Kline @@ -4939,7 +4959,7 @@ class CConfig { * \note The objective function will determine the boundary condition of the adjoint problem. * \return Kind of objective function. */ - unsigned short GetKind_ObjFunc(unsigned short val_obj); + unsigned short GetKind_ObjFunc(unsigned short val_obj) const { return Kind_ObjFunc[val_obj]; } /*! * \author H. Kline @@ -4948,7 +4968,7 @@ class CConfig { * \note The objective function will determine the boundary condition of the adjoint problem. * \return Weight of objective function. */ - su2double GetWeight_ObjFunc(unsigned short val_obj); + su2double GetWeight_ObjFunc(unsigned short val_obj) const { return Weight_ObjFunc[val_obj]; } /*! * \author H. Kline @@ -4957,7 +4977,7 @@ class CConfig { * \note The objective function will determine the boundary condition of the adjoint problem. * \return Weight of objective function. */ - void SetWeight_ObjFunc(unsigned short val_obj, su2double val); + void SetWeight_ObjFunc(unsigned short val_obj, su2double val) { Weight_ObjFunc[val_obj] = val; } /*! * \author H. Kline @@ -4966,7 +4986,7 @@ class CConfig { * calculated using the area averaged outlet values of density, velocity, and pressure. * Gradients are w.r.t density, velocity[3], and pressure. when 2D gradient w.r.t. 3rd component of velocity set to 0. */ - su2double GetCoeff_ObjChainRule(unsigned short iVar); + su2double GetCoeff_ObjChainRule(unsigned short iVar) const { return Obj_ChainRuleCoeff[iVar]; } /*! * \author H. Kline @@ -4978,7 +4998,7 @@ class CConfig { * \brief Get the kind of sensitivity smoothing technique. * \return Kind of sensitivity smoothing technique. */ - unsigned short GetKind_SensSmooth(void); + unsigned short GetKind_SensSmooth(void) const { return Kind_SensSmooth; } /*! * \brief Provides information about the time integration, and change the write in the output @@ -4986,7 +5006,7 @@ class CConfig { * \return The kind of time integration: Steady state, time stepping method (unsteady) or * dual time stepping method (unsteady). */ - unsigned short GetTime_Marching(void); + unsigned short GetTime_Marching(void) const { return TimeMarching; } /*! * \brief Provides the number of chemical reactions in the chemistry model @@ -5131,19 +5151,19 @@ class CConfig { * \brief Provides the restart information. * \return Restart information, if TRUE then the code will use the solution as restart. */ - bool GetRestart(void); + bool GetRestart(void) const { return Restart; } /*! * \brief Flag for whether binary SU2 native restart files are written. * \return Flag for whether binary SU2 native restart files are written, if TRUE then the code will output binary restart files. */ - bool GetWrt_Binary_Restart(void); + bool GetWrt_Binary_Restart(void) const { return Wrt_Binary_Restart; } /*! * \brief Flag for whether binary SU2 native restart files are read. * \return Flag for whether binary SU2 native restart files are read, if TRUE then the code will load binary restart files. */ - bool GetRead_Binary_Restart(void); + bool GetRead_Binary_Restart(void) const { return Read_Binary_Restart; } /*! * \brief Provides the number of varaibles. @@ -5155,13 +5175,13 @@ class CConfig { * \brief Provides the number of varaibles. * \return Number of variables. */ - unsigned short GetnZone(void); + unsigned short GetnZone(void) const { return nZone; } /*! * \brief Provides the number of varaibles. * \return Number of variables. */ - unsigned short GetiZone(void); + unsigned short GetiZone(void) const { return iZone; } /*! * \brief For some problems like adjoint or the linearized equations it @@ -5169,7 +5189,7 @@ class CConfig { * \return Flow restart information, if TRUE then the code will restart the flow solution. */ - bool GetRestart_Flow(void); + bool GetRestart_Flow(void) const { return Restart_Flow; } /*! * \brief Indicates whether electron gas is present in the gas mixture. @@ -5180,38 +5200,38 @@ class CConfig { * \brief Information about computing and plotting the equivalent area distribution. * \return TRUE or FALSE depending if we are computing the equivalent area. */ - bool GetEquivArea(void); + bool GetEquivArea(void) const { return EquivArea; } /*! * \brief Information about computing and plotting the equivalent area distribution. * \return TRUE or FALSE depending if we are computing the equivalent area. */ - bool GetInvDesign_Cp(void); + bool GetInvDesign_Cp(void) const { return InvDesign_Cp; } /*! * \brief Information about computing and plotting the equivalent area distribution. * \return TRUE or FALSE depending if we are computing the equivalent area. */ - bool GetInvDesign_HeatFlux(void); + bool GetInvDesign_HeatFlux(void) const { return InvDesign_HeatFlux; } /*! * \brief Get name of the input grid. * \return File name of the input grid. */ - string GetMesh_FileName(void); + string GetMesh_FileName(void) const { return Mesh_FileName; } /*! * \brief Get name of the output grid, this parameter is important for grid * adaptation and deformation. * \return File name of the output grid. */ - string GetMesh_Out_FileName(void); + string GetMesh_Out_FileName(void) const { return Mesh_Out_FileName; } /*! * \brief Get the name of the file with the solution of the flow problem. * \return Name of the file with the solution of the flow problem. */ - string GetSolution_FileName(void); + string GetSolution_FileName(void) const { return Solution_FileName; } /*! * \brief Get the name of the file with the solution of the adjoint flow problem @@ -5219,7 +5239,7 @@ class CConfig { * \return Name of the file with the solution of the adjoint flow problem with * drag objective function. */ - string GetSolution_AdjFileName(void); + string GetSolution_AdjFileName(void) const { return Solution_AdjFileName; } /*! * \brief Get the name of the file with the residual of the problem. @@ -5231,50 +5251,50 @@ class CConfig { * \brief Get the format of the input/output grid. * \return Format of the input/output grid. */ - unsigned short GetMesh_FileFormat(void); + unsigned short GetMesh_FileFormat(void) const { return Mesh_FileFormat; } /*! * \brief Get the format of the output solution. * \return Format of the output solution. */ - unsigned short GetTabular_FileFormat(void); + unsigned short GetTabular_FileFormat(void) const { return Tab_FileFormat; } /*! * \brief Get the format of the output solution. * \return Format of the output solution. */ - unsigned short GetActDisk_Jump(void); + unsigned short GetActDisk_Jump(void) const { return ActDisk_Jump; } /*! * \brief Get the name of the file with the convergence history of the problem. * \return Name of the file with convergence history of the problem. */ - string GetConv_FileName(void); + string GetConv_FileName(void) const { return Conv_FileName; } /*! * \brief Get the Starting Iteration for the windowing approach * in Sensitivity Analysis for period-averaged outputs, which oscillate. * \return */ - unsigned long GetStartWindowIteration(void) const; + unsigned long GetStartWindowIteration(void) const { return StartWindowIteration; } /*! * \brief Get Index of the window function used as weight in the cost functional * \return */ - WINDOW_FUNCTION GetKindWindow(void) const; + WINDOW_FUNCTION GetKindWindow(void) const { return static_cast(Kind_WindowFct); } /*! * \brief Get the name of the file with the forces breakdown of the problem. * \return Name of the file with forces breakdown of the problem. */ - string GetBreakdown_FileName(void); + string GetBreakdown_FileName(void) const { return Breakdown_FileName; } /*! * \brief Get the name of the file with the flow variables. * \return Name of the file with the primitive variables. */ - string GetVolume_FileName(void); + string GetVolume_FileName(void) const { return Volume_FileName; } /*! * \brief Get the name of the restart file for the heat variables. @@ -5319,55 +5339,55 @@ class CConfig { * \brief Get the name of the restart file for the flow variables. * \return Name of the restart file for the flow variables. */ - string GetRestart_FileName(void); + string GetRestart_FileName(void) const { return Restart_FileName; } /*! * \brief Get the name of the restart file for the adjoint variables (drag objective function). * \return Name of the restart file for the adjoint variables (drag objective function). */ - string GetRestart_AdjFileName(void); + string GetRestart_AdjFileName(void) const { return Restart_AdjFileName; } /*! * \brief Get the name of the file with the adjoint variables. * \return Name of the file with the adjoint variables. */ - string GetAdj_FileName(void); + string GetAdj_FileName(void) const { return Adj_FileName; } /*! * \brief Get the name of the file with the gradient of the objective function. * \return Name of the file with the gradient of the objective function. */ - string GetObjFunc_Grad_FileName(void); + string GetObjFunc_Grad_FileName(void) const { return ObjFunc_Grad_FileName; } /*! * \brief Get the name of the file with the gradient of the objective function. * \return Name of the file with the gradient of the objective function. */ - string GetObjFunc_Value_FileName(void); + string GetObjFunc_Value_FileName(void) const { return ObjFunc_Value_FileName; } /*! * \brief Get the name of the file with the surface information for the flow problem. * \return Name of the file with the surface information for the flow problem. */ - string GetSurfCoeff_FileName(void); + string GetSurfCoeff_FileName(void) const { return SurfCoeff_FileName; } /*! * \brief Get the name of the file with the surface information for the adjoint problem. * \return Name of the file with the surface information for the adjoint problem. */ - string GetSurfAdjCoeff_FileName(void); + string GetSurfAdjCoeff_FileName(void) const { return SurfAdjCoeff_FileName; } /*! * \brief Get the name of the file with the surface sensitivity (discrete adjoint). * \return Name of the file with the surface sensitivity (discrete adjoint). */ - string GetSurfSens_FileName(void); + string GetSurfSens_FileName(void) const { return SurfSens_FileName; } /*! * \brief Get the name of the file with the volume sensitivity (discrete adjoint). * \return Name of the file with the volume sensitivity (discrete adjoint). */ - string GetVolSens_FileName(void); + string GetVolSens_FileName(void) const { return VolSens_FileName; } /*! * \brief Augment the input filename with the iteration number for an unsteady file. @@ -5388,136 +5408,138 @@ class CConfig { * \brief Get the criteria for structural residual (relative/absolute). * \return Relative/Absolute criteria for structural convergence. */ - unsigned short GetResidual_Criteria_FEM(void); + unsigned short GetResidual_Criteria_FEM(void) const { return Res_FEM_CRIT; } /*! * \brief Get functional that is going to be used to evaluate the residual flow convergence. * \return Functional that is going to be used to evaluate the residual flow convergence. */ - unsigned short GetResidual_Func_Flow(void); + unsigned short GetResidual_Func_Flow(void) const { return Residual_Func_Flow; } /*! * \brief Get functional that is going to be used to evaluate the flow convergence. * \return Functional that is going to be used to evaluate the flow convergence. */ - unsigned short GetCauchy_Func_Flow(void); + unsigned short GetCauchy_Func_Flow(void) const { return Cauchy_Func_Flow; } /*! * \brief Get functional that is going to be used to evaluate the adjoint flow convergence. * \return Functional that is going to be used to evaluate the adjoint flow convergence. */ - unsigned short GetCauchy_Func_AdjFlow(void); + unsigned short GetCauchy_Func_AdjFlow(void) const { return Cauchy_Func_AdjFlow; } /*! * \brief Get the number of iterations that are considered in the Cauchy convergence criteria. * \return Number of elements in the Cauchy criteria. */ - unsigned short GetCauchy_Elems(void); + unsigned short GetCauchy_Elems(void) const { return Cauchy_Elems; } /*! * \brief Get the number of iterations that are not considered in the convergence criteria. * \return Number of iterations before starting with the convergence criteria. */ - unsigned long GetStartConv_Iter(void); + unsigned long GetStartConv_Iter(void) const { return StartConv_Iter; } /*! * \brief Get the value of convergence criteria for the Cauchy method in the direct, * adjoint or linearized problem. * \return Value of the convergence criteria. */ - su2double GetCauchy_Eps(void); + su2double GetCauchy_Eps(void) const { return Cauchy_Eps; } /*! * \brief If we are prforming an unsteady simulation, there is only * one value of the time step for the complete simulation. * \return Value of the time step in an unsteady simulation (non dimensional). */ - su2double GetDelta_UnstTimeND(void); + su2double GetDelta_UnstTimeND(void) const { return Delta_UnstTimeND; } /*! * \brief If we are prforming an unsteady simulation, there is only * one value of the time step for the complete simulation. * \return Value of the time step in an unsteady simulation (non dimensional). */ - su2double GetTotal_UnstTimeND(void); + su2double GetTotal_UnstTimeND(void) const { return Total_UnstTimeND; } /*! * \brief If we are prforming an unsteady simulation, there is only * one value of the time step for the complete simulation. * \return Value of the time step in an unsteady simulation. */ - su2double GetDelta_UnstTime(void); + su2double GetDelta_UnstTime(void) const { return Delta_UnstTime; } /*! * \brief Set the value of the unsteadty time step using the CFL number. * \param[in] val_delta_unsttimend - Value of the unsteady time step using CFL number. */ - void SetDelta_UnstTimeND(su2double val_delta_unsttimend); + void SetDelta_UnstTimeND(su2double val_delta_unsttimend) { Delta_UnstTimeND = val_delta_unsttimend; } /*! * \brief If we are performing an unsteady simulation, this is the * value of max physical time for which we run the simulation * \return Value of the physical time in an unsteady simulation. */ - su2double GetTotal_UnstTime(void); + su2double GetTotal_UnstTime(void) const { return Total_UnstTime; } /*! * \brief If we are performing an unsteady simulation, this is the * value of current time. * \return Value of the physical time in an unsteady simulation. */ - su2double GetCurrent_UnstTime(void); + su2double GetCurrent_UnstTime(void) const { return Current_UnstTime; } /*! * \brief Divide the rectbles and hexahedron. * \return TRUE if the elements must be divided; otherwise FALSE. */ - bool GetSubsonicEngine(void); + bool GetSubsonicEngine(void) const { return SubsonicEngine; } /*! * \brief Actuator disk defined with a double surface. * \return TRUE if the elements must be divided; otherwise FALSE. */ - bool GetActDisk_DoubleSurface(void); + bool GetActDisk_DoubleSurface(void) const { return ActDisk_DoubleSurface; } /*! * \brief Only halg of the engine is in the compputational grid. * \return TRUE if the engine is complete; otherwise FALSE. */ - bool GetEngine_HalfModel(void); + bool GetEngine_HalfModel(void) const { return Engine_HalfModel; } /*! * \brief Actuator disk defined with a double surface. * \return TRUE if the elements must be divided; otherwise FALSE. */ - bool GetActDisk_SU2_DEF(void); + bool GetActDisk_SU2_DEF(void) const { return ActDisk_SU2_DEF; } /*! * \brief Value of the design variable step, we use this value in design problems. * \param[in] val_dv - Number of the design variable that we want to read. - * \param[in] val_value - Value of the design variable that we want to read. + * \param[in] val_val - Value of the design variable that we want to read. * \return Design variable step. */ - su2double GetDV_Value(unsigned short val_dv, unsigned short val_val = 0); + su2double GetDV_Value(unsigned short val_dv, unsigned short val_val = 0) const { return DV_Value[val_dv][val_val]; } /*! * \brief Set the value of the design variable step, we use this value in design problems. * \param[in] val_dv - Number of the design variable that we want to read. * \param[in] val - Value of the design variable. */ - void SetDV_Value(unsigned short val_dv, unsigned short val_ind, su2double val); + void SetDV_Value(unsigned short val_dv, unsigned short val_ind, su2double val) { DV_Value[val_dv][val_ind] = val; } /*! * \brief Get information about the grid movement. * \return TRUE if there is a grid movement; otherwise FALSE. */ - bool GetGrid_Movement(void); + bool GetGrid_Movement(void) const { + return (Kind_GridMovement != NO_MOVEMENT) || ((nKind_SurfaceMovement > 0) && !GetSurface_Movement(FLUID_STRUCTURE_STATIC)); + } /*! * \brief Get information about dynamic grids. * \return TRUE if there is a grid movement; otherwise FALSE. */ - bool GetDynamic_Grid(void); + bool GetDynamic_Grid(void) const { return GetGrid_Movement() || (Deform_Mesh && Time_Domain); } /*! * \brief Get information about the volumetric movement. @@ -5530,7 +5552,7 @@ class CConfig { * \param[in] kind_movement - Kind of surface movement. * \return TRUE at least one surface of kind_movement moving; otherwise FALSE. */ - bool GetSurface_Movement(unsigned short kind_movement); + bool GetSurface_Movement(unsigned short kind_movement) const; /*! * \brief Set a surface movement marker. @@ -5544,41 +5566,41 @@ class CConfig { * \brief Get the type of dynamic mesh motion. Each zone gets a config file. * \return Type of dynamic mesh motion. */ - unsigned short GetKind_GridMovement(); + unsigned short GetKind_GridMovement() const { return Kind_GridMovement; } /*! * \brief Set the type of dynamic mesh motion. * \param[in] val_iZone - Number for the current zone in the mesh (each zone has independent motion). * \param[in] motion_Type - Specify motion type. */ - void SetKind_GridMovement(unsigned short motion_Type); + void SetKind_GridMovement(unsigned short motion_Type) { Kind_GridMovement = motion_Type; } /*! * \brief Get the type of surface motion. * \param[in] iMarkerMoving - Index of the moving marker (as specified in Marker_Moving). * \return Type of surface motion. */ - unsigned short GetKind_SurfaceMovement(unsigned short iMarkerMoving); + unsigned short GetKind_SurfaceMovement(unsigned short iMarkerMoving) const { return Kind_SurfaceMovement[iMarkerMoving];} /*! * \brief Get the mach number based on the mesh velocity and freestream quantities. * \return Mach number based on the mesh velocity and freestream quantities. */ - su2double GetMach_Motion(void); + su2double GetMach_Motion(void) const { return Mach_Motion; } /*! * \brief Get the mesh motion origin. * \param[in] iDim - spatial component * \return The mesh motion origin. */ - su2double GetMotion_Origin(unsigned short iDim); + su2double GetMotion_Origin(unsigned short iDim) const { return Motion_Origin[iDim];} /*! * \brief Set the mesh motion origin. * \param[in] val - new value of the origin * \return The mesh motion origin. */ - void SetMotion_Origin(su2double* val); + void SetMotion_Origin(su2double* val) { for (int iDim = 0; iDim < 3; iDim++) Motion_Origin[iDim] = val[iDim]; } /*! * \brief Get the mesh motion origin. @@ -5586,21 +5608,23 @@ class CConfig { * \param[in] iDim - spatial component * \return The motion origin of the marker. */ - su2double GetMarkerMotion_Origin(unsigned short iMarkerMoving, unsigned short iDim); + su2double GetMarkerMotion_Origin(unsigned short iMarkerMoving, unsigned short iDim) const { return MarkerMotion_Origin[3*iMarkerMoving + iDim];} /*! * \brief Set the mesh motion origin. * \param[in] val - new value of the origin * \param[in] iMarkerMoving - Index of the moving marker (as specified in Marker_Moving) */ - void SetMarkerMotion_Origin (su2double* val, unsigned short iMarkerMoving); + void SetMarkerMotion_Origin(su2double* val, unsigned short iMarkerMoving) { + for (int iDim = 0; iDim < 3; iDim++) MarkerMotion_Origin[3*iMarkerMoving + iDim] = val[iDim]; + } /*! * \brief Get the translational velocity of the mesh. * \param[in] iDim - spatial component * \return Translational velocity of the mesh. */ - su2double GetTranslation_Rate(unsigned short iDim); + su2double GetTranslation_Rate(unsigned short iDim) const { return Translation_Rate[iDim];} /*! * \brief Get the translational velocity of the marker. @@ -5608,14 +5632,14 @@ class CConfig { * \param[in] iDim - spatial component * \return Translational velocity of the marker. */ - su2double GetMarkerTranslationRate(unsigned short iMarkerMoving, unsigned short iDim); + su2double GetMarkerTranslationRate(unsigned short iMarkerMoving, unsigned short iDim) const { return MarkerTranslation_Rate[3*iMarkerMoving + iDim];} /*! * \brief Get the rotation rate of the mesh. * \param[in] iDim - spatial component * \return Translational velocity of the mesh. */ - su2double GetRotation_Rate(unsigned short iDim); + su2double GetRotation_Rate(unsigned short iDim) const { return Rotation_Rate[iDim];} /*! * \brief Get the rotation rate of the mesh. @@ -5623,7 +5647,7 @@ class CConfig { * \param[in] val - new value of the rotation rate. * \return Translational velocity of the mesh. */ - void SetRotation_Rate(unsigned short iDim, su2double val); + void SetRotation_Rate(unsigned short iDim, su2double val) { Rotation_Rate[iDim] = val;} /*! * \brief Get the rotation rate of the marker. @@ -5631,14 +5655,14 @@ class CConfig { * \param[in] iDim - spatial component * \return Rotation velocity of the marker. */ - su2double GetMarkerRotationRate(unsigned short iMarkerMoving, unsigned short iDim); + su2double GetMarkerRotationRate(unsigned short iMarkerMoving, unsigned short iDim) const { return MarkerRotation_Rate[3*iMarkerMoving + iDim];} /*! * \brief Get the pitching rate of the mesh. * \param[in] iDim - spatial component * \return Angular frequency of the mesh pitching. */ - su2double GetPitching_Omega(unsigned short iDim); + su2double GetPitching_Omega(unsigned short iDim) const { return Pitching_Omega[iDim];} /*! * \brief Get pitching rate of the marker. @@ -5646,14 +5670,14 @@ class CConfig { * \param[in] iDim - spatial component * \return Angular frequency of the marker pitching. */ - su2double GetMarkerPitching_Omega(unsigned short iMarkerMoving, unsigned short iDim); + su2double GetMarkerPitching_Omega(unsigned short iMarkerMoving, unsigned short iDim) const { return MarkerPitching_Omega[3*iMarkerMoving + iDim];} /*! * \brief Get the pitching amplitude of the mesh. * \param[in] iDim - spatial component * \return pitching amplitude of the mesh. */ - su2double GetPitching_Ampl(unsigned short iDim); + su2double GetPitching_Ampl(unsigned short iDim) const { return Pitching_Ampl[iDim];} /*! * \brief Get pitching amplitude of the marker. @@ -5661,14 +5685,14 @@ class CConfig { * \param[in] iDim - spatial component * \return pitching amplitude of the marker. */ - su2double GetMarkerPitching_Ampl(unsigned short iMarkerMoving, unsigned short iDim); + su2double GetMarkerPitching_Ampl(unsigned short iMarkerMoving, unsigned short iDim) const { return MarkerPitching_Ampl[3*iMarkerMoving + iDim];} /*! * \brief Get the pitching phase of the mesh. * \param[in] val_iZone - Number for the current zone in the mesh (each zone has independent motion). * \return pitching phase of the mesh. */ - su2double GetPitching_Phase(unsigned short iDim); + su2double GetPitching_Phase(unsigned short iDim) const { return Pitching_Phase[iDim];} /*! * \brief Get pitching phase of the marker. @@ -5676,14 +5700,14 @@ class CConfig { * \param[in] iDim - spatial component * \return pitching phase of the marker. */ - su2double GetMarkerPitching_Phase(unsigned short iMarkerMoving, unsigned short iDim); + su2double GetMarkerPitching_Phase(unsigned short iMarkerMoving, unsigned short iDim) const { return MarkerPitching_Phase[3*iMarkerMoving + iDim];} /*! * \brief Get the plunging rate of the mesh. * \param[in] iDim - spatial component * \return Angular frequency of the mesh plunging. */ - su2double GetPlunging_Omega(unsigned short iDim); + su2double GetPlunging_Omega(unsigned short iDim) const { return Plunging_Omega[iDim];} /*! * \brief Get plunging rate of the marker. @@ -5691,7 +5715,7 @@ class CConfig { * \param[in] iDim - spatial component * \return Angular frequency of the marker plunging. */ - su2double GetMarkerPlunging_Omega(unsigned short iMarkerMoving, unsigned short iDim); + su2double GetMarkerPlunging_Omega(unsigned short iMarkerMoving, unsigned short iDim) const { return MarkerPlunging_Omega[3*iMarkerMoving + iDim];} /*! * \brief Get the plunging amplitude of the mesh. @@ -5699,7 +5723,7 @@ class CConfig { * \param[in] iDim - spatial component * \return Plunging amplitude of the mesh. */ - su2double GetPlunging_Ampl(unsigned short iDim); + su2double GetPlunging_Ampl(unsigned short iDim) const { return Plunging_Ampl[iDim];} /*! * \brief Get plunging amplitude of the marker. @@ -5707,13 +5731,13 @@ class CConfig { * \param[in] iDim - spatial component * \return Plunging amplitude of the marker. */ - su2double GetMarkerPlunging_Ampl(unsigned short iMarkerMoving, unsigned short iDim); + su2double GetMarkerPlunging_Ampl(unsigned short iMarkerMoving, unsigned short iDim) const { return MarkerPlunging_Ampl[3*iMarkerMoving + iDim];} /*! * \brief Get the angular velocity of the mesh about the z-axis. * \return Angular velocity of the mesh about the z-axis. */ - su2double GetFinalRotation_Rate_Z(); + su2double GetFinalRotation_Rate_Z() const { return FinalRotation_Rate_Z;} /*! * \brief Set the angular velocity of the mesh about the z-axis. @@ -5725,32 +5749,32 @@ class CConfig { * \brief Get the Harmonic Balance frequency pointer. * \return Harmonic Balance Frequency pointer. */ - su2double* GetOmega_HB(void); + su2double* GetOmega_HB(void) { return Omega_HB; } /*! * \brief Get if harmonic balance source term is to be preconditioned * \return yes or no to harmonic balance preconditioning */ - bool GetHB_Precondition(void); + bool GetHB_Precondition(void) const { return HB_Precondition; } /*! * \brief Get if we should update the motion origin. * \param[in] val_marker - Value of the marker in which we are interested. * \return yes or no to update motion origin. */ - unsigned short GetMoveMotion_Origin(unsigned short val_marker); + unsigned short GetMoveMotion_Origin(unsigned short val_marker) const { return MoveMotion_Origin[val_marker]; } /*! * \brief Get the minimum value of Beta for Roe-Turkel preconditioner * \return the minimum value of Beta for Roe-Turkel preconditioner */ - su2double GetminTurkelBeta(); + su2double GetminTurkelBeta() const { return Min_Beta_RoeTurkel; } /*! * \brief Get the minimum value of Beta for Roe-Turkel preconditioner * \return the minimum value of Beta for Roe-Turkel preconditioner */ - su2double GetmaxTurkelBeta(); + su2double GetmaxTurkelBeta() const { return Max_Beta_RoeTurkel; } /*! * \brief Get information about the adibatic wall condition @@ -5768,49 +5792,49 @@ class CConfig { * \brief Get information about the Low Mach Preconditioning * \return TRUE if we are using low Mach preconditioner; otherwise FALSE. */ - bool Low_Mach_Preconditioning(void); + bool Low_Mach_Preconditioning(void) const { return Low_Mach_Precon; } /*! * \brief Get information about the Low Mach Correction * \return TRUE if we are using low Mach correction; otherwise FALSE. */ - bool Low_Mach_Correction(void); + bool Low_Mach_Correction(void) const { return Low_Mach_Corr; } /*! * \brief Get information about the poisson solver condition * \return TRUE if it is a poisson solver condition; otherwise FALSE. */ - bool GetPoissonSolver(void); + bool GetPoissonSolver(void) const { return PoissonSolver; } /*! * \brief Get information about the gravity force. * \return TRUE if it uses the gravity force; otherwise FALSE. */ - bool GetGravityForce(void); + bool GetGravityForce(void) const { return GravityForce; } /*! * \brief Get information about the body force. * \return TRUE if it uses a body force; otherwise FALSE. */ - bool GetBody_Force(void); + bool GetBody_Force(void) const { return Body_Force; } /*! * \brief Get a pointer to the body force vector. * \return A pointer to the body force vector. */ - su2double* GetBody_Force_Vector(void); + su2double* GetBody_Force_Vector(void) { return Body_Force_Vector; } /*! * \brief Get information about the rotational frame. * \return TRUE if there is a rotational frame; otherwise FALSE. */ - bool GetRotating_Frame(void); + bool GetRotating_Frame(void) const { return Rotating_Frame; } /*! * \brief Get information about the axisymmetric frame. * \return TRUE if there is a rotational frame; otherwise FALSE. */ - bool GetAxisymmetric(void); + bool GetAxisymmetric(void) const { return Axisymmetric; } /*! * \brief Get information about the axisymmetric frame. @@ -5822,56 +5846,56 @@ class CConfig { * \brief Get information about there is a smoothing of the grid coordinates. * \return TRUE if there is smoothing of the grid coordinates; otherwise FALSE. */ - bool GetAdaptBoundary(void); + bool GetAdaptBoundary(void) const { return AdaptBoundary; } /*! * \brief Get information about there is a smoothing of the grid coordinates. * \return TRUE if there is smoothing of the grid coordinates; otherwise FALSE. */ - bool GetSmoothNumGrid(void); + bool GetSmoothNumGrid(void) const { return SmoothNumGrid; } /*! * \brief Set information about there is a smoothing of the grid coordinates. * \param[in] val_smoothnumgrid - TRUE if there is smoothing of the grid coordinates; otherwise FALSE. */ - void SetSmoothNumGrid(bool val_smoothnumgrid); + void SetSmoothNumGrid(bool val_smoothnumgrid) { SmoothNumGrid = val_smoothnumgrid; } /*! * \brief Subtract one to the index of the finest grid (full multigrid strategy). * \return Change the index of the finest grid. */ - void SubtractFinestMesh(void); + void SubtractFinestMesh(void) { FinestMesh = FinestMesh-1; } /*! * \brief Obtain the kind of design variable. * \param[in] val_dv - Number of the design variable that we want to read. * \return Design variable identification. */ - unsigned short GetDesign_Variable(unsigned short val_dv); + unsigned short GetDesign_Variable(unsigned short val_dv) const { return Design_Variable[val_dv]; } /*! * \brief Provides the buffet monitoring information. * \return Buffet monitoring information, if TRUE then the code will compute the buffet sensor. */ - bool GetBuffet_Monitoring(void); + bool GetBuffet_Monitoring(void) const { return Buffet_Monitoring; } /*! * \brief Get the buffet sensor sharpness coefficient. * \return Sharpness coefficient for buffet sensor. */ - su2double GetBuffet_k(void); + su2double GetBuffet_k(void) const { return Buffet_k; } /*! * \brief Get the buffet sensor offset parameter. * \return Offset parameter for buffet sensor. */ - su2double GetBuffet_lambda(void); + su2double GetBuffet_lambda(void) const { return Buffet_lambda; } /*! * \brief Obtain the kind of convergence criteria to establish the convergence of the CFD code. * \return Kind of convergence criteria. */ - unsigned short GetConvCriteria(void); + unsigned short GetConvCriteria(void) const { return ConvCriteria; } /*! * \brief Get the index in the config information of the marker val_marker. @@ -5993,13 +6017,13 @@ class CConfig { * \brief Get the name of the marker val_iMarker. * \return The name of the marker in the interface */ - string GetMarkerTag_ZoneInterface(unsigned short val_iMarker); + string GetMarkerTag_ZoneInterface(unsigned short val_iMarker) const { return Marker_ZoneInterface[val_iMarker]; } /*! * \brief Get the number of markers in the multizone interface. * \return The number markers in the multizone interface */ - unsigned short GetnMarker_ZoneInterface(void); + unsigned short GetnMarker_ZoneInterface(void) const { return nMarker_ZoneInterface; } /*! @@ -6020,13 +6044,13 @@ class CConfig { * \brief Determines if problem is adjoint * \return true if Adjoint */ - bool GetContinuous_Adjoint(void); + bool GetContinuous_Adjoint(void) const { return ContinuousAdjoint; } /*! * \brief Determines if problem is viscous * \return true if Viscous */ - bool GetViscous(void); + bool GetViscous(void) const { return Viscous; } /*! * \brief Provides the index of the solution in the container. @@ -6039,43 +6063,43 @@ class CConfig { * \brief Value of the minimum residual value (log10 scale). * \return Value of the minimum residual value (log10 scale). */ - su2double GetMinLogResidual(void); + su2double GetMinLogResidual(void) const { return MinLogResidual; } /*! * \brief Value of the damping factor for the engine inlet bc. * \return Value of the damping factor. */ - su2double GetDamp_Engine_Inflow(void); + su2double GetDamp_Engine_Inflow(void) const { return Damp_Engine_Inflow; } /*! * \brief Value of the damping factor for the engine exhaust inlet bc. * \return Value of the damping factor. */ - su2double GetDamp_Engine_Exhaust(void); + su2double GetDamp_Engine_Exhaust(void) const { return Damp_Engine_Exhaust; } /*! * \brief Value of the damping factor for the residual restriction. * \return Value of the damping factor. */ - su2double GetDamp_Res_Restric(void); + su2double GetDamp_Res_Restric(void) const { return Damp_Res_Restric; } /*! * \brief Value of the damping factor for the correction prolongation. * \return Value of the damping factor. */ - su2double GetDamp_Correc_Prolong(void); + su2double GetDamp_Correc_Prolong(void) const { return Damp_Correc_Prolong; } /*! * \brief Value of the position of the Near Field (y coordinate for 2D, and z coordinate for 3D). * \return Value of the Near Field position. */ - su2double GetPosition_Plane(void); + su2double GetPosition_Plane(void) const { return Position_Plane; } /*! * \brief Value of the weight of the drag coefficient in the Sonic Boom optimization. * \return Value of the weight of the drag coefficient in the Sonic Boom optimization. */ - su2double GetWeightCd(void); + su2double GetWeightCd(void) const { return WeightCd; } /*! * \brief Value of the weight of the CD, CL, CM optimization. @@ -6087,91 +6111,91 @@ class CConfig { * \brief Value of the azimuthal line to fix due to a misalignments of the nearfield. * \return Azimuthal line to fix due to a misalignments of the nearfield. */ - su2double GetFixAzimuthalLine(void); + su2double GetFixAzimuthalLine(void) const { return FixAzimuthalLine; } /*! * \brief Value of the weight of the CD, CL, CM optimization. * \return Value of the weight of the CD, CL, CM optimization. */ - su2double GetdCD_dCMy(void); + su2double GetdCD_dCMy(void) const { return dCD_dCMy; } /*! * \brief Value of the weight of the CD, CL, CM optimization. * \return Value of the weight of the CD, CL, CM optimization. */ - su2double GetCM_Target(void); + su2double GetCM_Target(void) const { return CM_Target; } /*! * \brief Value of the weight of the CD, CL, CM optimization. * \return Value of the weight of the CD, CL, CM optimization. */ - su2double GetdCD_dCL(void); + su2double GetdCD_dCL(void) const { return dCD_dCL; } /*! * \brief Value of the weight of the CD, CL, CM optimization. * \return Value of the weight of the CD, CL, CM optimization. */ - void SetdCD_dCL(su2double val_dcd_dcl); + void SetdCD_dCL(su2double val_dcd_dcl) { dCD_dCL = val_dcd_dcl; } /*! * \brief Value of the weight of the CD, CL, CM optimization. * \return Value of the weight of the CD, CL, CM optimization. */ - su2double GetdCMx_dCL(void); + su2double GetdCMx_dCL(void) const { return dCMx_dCL; } /*! * \brief Value of the weight of the CD, CL, CM optimization. * \return Value of the weight of the CD, CL, CM optimization. */ - void SetdCMx_dCL(su2double val_dcmx_dcl); + void SetdCMx_dCL(su2double val_dcmx_dcl) { dCMx_dCL = val_dcmx_dcl; } /*! * \brief Value of the weight of the CD, CL, CM optimization. * \return Value of the weight of the CD, CL, CM optimization. */ - su2double GetdCMy_dCL(void); + su2double GetdCMy_dCL(void) const { return dCMy_dCL; } /*! * \brief Value of the weight of the CD, CL, CM optimization. * \return Value of the weight of the CD, CL, CM optimization. */ - void SetdCMy_dCL(su2double val_dcmy_dcl); + void SetdCMy_dCL(su2double val_dcmy_dcl) { dCMy_dCL = val_dcmy_dcl; } /*! * \brief Value of the weight of the CD, CL, CM optimization. * \return Value of the weight of the CD, CL, CM optimization. */ - su2double GetdCMz_dCL(void); + su2double GetdCMz_dCL(void) const { return dCMz_dCL; } /*! * \brief Value of the weight of the CD, CL, CM optimization. * \return Value of the weight of the CD, CL, CM optimization. */ - void SetdCMz_dCL(su2double val_dcmz_dcl); + void SetdCMz_dCL(su2double val_dcmz_dcl) { dCMz_dCL = val_dcmz_dcl; } /*! * \brief Value of the weight of the CD, CL, CM optimization. * \return Value of the weight of the CD, CL, CM optimization. */ - void SetdCL_dAlpha(su2double val_dcl_dalpha); + void SetdCL_dAlpha(su2double val_dcl_dalpha) { dCL_dAlpha = val_dcl_dalpha; } /*! * \brief Value of the weight of the CD, CL, CM optimization. * \return Value of the weight of the CD, CL, CM optimization. */ - void SetdCM_diH(su2double val_dcm_dhi); + void SetdCM_diH(su2double val_dcm_dhi) { dCM_diH = val_dcm_dhi; } /*! * \brief Value of the weight of the CD, CL, CM optimization. * \return Value of the weight of the CD, CL, CM optimization. */ - void SetdCD_dCMy(su2double val_dcd_dcmy); + void SetdCD_dCMy(su2double val_dcd_dcmy) { dCD_dCMy = val_dcd_dcmy; } /*! * \brief Value of the weight of the CD, CL, CM optimization. * \return Value of the weight of the CD, CL, CM optimization. */ - su2double GetCL_Target(void); + su2double GetCL_Target(void) const { return CL_Target; } /*! * \brief Set the global parameters of each simulation for each runtime system. @@ -6302,7 +6326,7 @@ class CConfig { * \return Name that is in the geometry file for the surface that * has the marker val_marker. */ - string GetMarker_Moving_TagBound(unsigned short val_marker); + string GetMarker_Moving_TagBound(unsigned short val_marker) const { return Marker_Moving[val_marker]; } /*! * \brief Get the name of the DEFORM_MESH boundary defined in the geometry file. @@ -6310,7 +6334,7 @@ class CConfig { * \return Name that is in the geometry file for the surface that * has the marker val_marker. */ - string GetMarker_Deform_Mesh_TagBound(unsigned short val_marker); + string GetMarker_Deform_Mesh_TagBound(unsigned short val_marker) const { return Marker_Deform_Mesh[val_marker]; } /*! * \brief Get the name of the Fluid_Load boundary defined in the geometry file. @@ -6318,7 +6342,7 @@ class CConfig { * \return Name that is in the geometry file for the surface that * has the marker val_marker. */ - string GetMarker_Fluid_Load_TagBound(unsigned short val_marker); + string GetMarker_Fluid_Load_TagBound(unsigned short val_marker) const { return Marker_Fluid_Load[val_marker]; } /*! * \brief Get the name of the surface defined in the geometry file. @@ -6326,7 +6350,7 @@ class CConfig { * \return Name that is in the geometry file for the surface that * has the marker val_marker. */ - string GetMarker_PyCustom_TagBound(unsigned short val_marker); + string GetMarker_PyCustom_TagBound(unsigned short val_marker) const { return Marker_PyCustom[val_marker]; } /*! * \brief Get the name of the surface defined in the geometry file. @@ -6334,7 +6358,7 @@ class CConfig { * \return Name that is in the geometry file for the surface that * has the marker val_marker. */ - string GetMarker_Analyze_TagBound(unsigned short val_marker); + string GetMarker_Analyze_TagBound(unsigned short val_marker) const { return Marker_Analyze[val_marker]; } /*! * \brief Get the total temperature at a nacelle boundary. @@ -6396,7 +6420,7 @@ class CConfig { * \brief Value of the CFL reduction in LevelSet problems. * \return Value of the CFL reduction in LevelSet problems. */ - su2double GetCFLRedCoeff_Turb(void); + su2double GetCFLRedCoeff_Turb(void) const { return CFLRedCoeff_Turb; } /*! * \brief Get the flow direction unit vector at an inlet boundary. @@ -6644,7 +6668,7 @@ class CConfig { * \param[in] val_index - Index corresponding to the engine inflow boundary. * \return The percentage of reverse flow. */ - su2double GetInflow_ReverseMassFlow(unsigned short val_marker); + su2double GetInflow_ReverseMassFlow(unsigned short val_marker) const { return Inflow_ReverseMassFlow[val_marker]; } /*! * \brief Get the total pressure at an engine inflow boundary. @@ -6749,225 +6773,225 @@ class CConfig { * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - void SetInflow_Mach(unsigned short val_imarker, su2double val_fanface_mach); + void SetInflow_Mach(unsigned short val_marker, su2double val_fanface_mach) { Inflow_Mach[val_marker] = val_fanface_mach; } /*! * \brief Set the fan face static pressure at an engine inflow boundary. * \param[in] val_index - Index corresponding to the engine inflow boundary. * \param[in] val_fanface_pressure - Fan face static pressure. */ - void SetInflow_Pressure(unsigned short val_imarker, su2double val_fanface_pressure); + void SetInflow_Pressure(unsigned short val_marker, su2double val_fanface_pressure) { Inflow_Pressure[val_marker] = val_fanface_pressure; } /*! * \brief Set the massflow at an engine inflow boundary. * \param[in] val_index - Index corresponding to the engine inflow boundary. * \param[in] val_fanface_massflow - Massflow. */ - void SetInflow_MassFlow(unsigned short val_imarker, su2double val_fanface_massflow); + void SetInflow_MassFlow(unsigned short val_marker, su2double val_fanface_massflow) { Inflow_MassFlow[val_marker] = val_fanface_massflow; } /*! * \brief Set the reverse flow at an engine inflow boundary. * \param[in] val_index - Index corresponding to the engine inflow boundary. * \param[in] val_fanface_reversemassflow - reverse flow. */ - void SetInflow_ReverseMassFlow(unsigned short val_imarker, su2double val_fanface_reversemassflow); + void SetInflow_ReverseMassFlow(unsigned short val_marker, su2double val_fanface_reversemassflow) { Inflow_ReverseMassFlow[val_marker] = val_fanface_reversemassflow; } /*! * \brief Set the fan face total pressure at an engine inflow boundary. * \param[in] val_index - Index corresponding to the engine inflow boundary. * \param[in] val_fanface_totalpressure - Fan face total pressure. */ - void SetInflow_TotalPressure(unsigned short val_imarker, su2double val_fanface_totalpressure); + void SetInflow_TotalPressure(unsigned short val_marker, su2double val_fanface_totalpressure) { Inflow_TotalPressure[val_marker] = val_fanface_totalpressure; } /*! * \brief Set the fan face static temperature at an engine inflow boundary. * \param[in] val_index - Index corresponding to the engine inflow boundary. * \param[in] val_fanface_pressure - Fan face static temperature. */ - void SetInflow_Temperature(unsigned short val_imarker, su2double val_fanface_temperature); + void SetInflow_Temperature(unsigned short val_marker, su2double val_fanface_temperature) { Inflow_Temperature[val_marker] = val_fanface_temperature; } /*! * \brief Set the fan face total temperature at an engine inflow boundary. * \param[in] val_index - Index corresponding to the engine inflow boundary. * \param[in] val_fanface_totaltemperature - Fan face total temperature. */ - void SetInflow_TotalTemperature(unsigned short val_imarker, su2double val_fanface_totaltemperature); + void SetInflow_TotalTemperature(unsigned short val_marker, su2double val_fanface_totaltemperature) { Inflow_TotalTemperature[val_marker] = val_fanface_totaltemperature; } /*! * \brief Set the ram drag temperature at an engine inflow boundary. * \param[in] val_index - Index corresponding to the engine inflow boundary. * \param[in] val_fanface_ramdrag - Ram drag value. */ - void SetInflow_RamDrag(unsigned short val_imarker, su2double val_fanface_ramdrag); + void SetInflow_RamDrag(unsigned short val_marker, su2double val_fanface_ramdrag) { Inflow_RamDrag[val_marker] = val_fanface_ramdrag; } /*! * \brief Set the force balance at an engine inflow boundary. * \param[in] val_index - Index corresponding to the engine inflow boundary. * \param[in] val_fanface_force - Fan face force. */ - void SetInflow_Force(unsigned short val_imarker, su2double val_fanface_force); + void SetInflow_Force(unsigned short val_marker, su2double val_fanface_force) { Inflow_Force[val_marker] = val_fanface_force; } /*! * \brief Set the power at an engine inflow boundary. * \param[in] val_index - Index corresponding to the engine inflow boundary. * \param[in] val_fanface_force - Power. */ - void SetInflow_Power(unsigned short val_imarker, su2double val_fanface_power); + void SetInflow_Power(unsigned short val_marker, su2double val_fanface_power) { Inflow_Power[val_marker] = val_fanface_power; } /*! * \brief Set the back pressure (static) at an engine exhaust boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \param[in] val_exhaust_pressure - Exhaust static pressure. */ - void SetExhaust_Pressure(unsigned short val_imarker, su2double val_exhaust_pressure); + void SetExhaust_Pressure(unsigned short val_marker, su2double val_exhaust_pressure) { Exhaust_Pressure[val_marker] = val_exhaust_pressure; } /*! * \brief Set the temperature (static) at an engine exhaust boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \param[in] val_exhaust_temp - Exhaust static temperature. */ - void SetExhaust_Temperature(unsigned short val_imarker, su2double val_exhaust_temp); + void SetExhaust_Temperature(unsigned short val_marker, su2double val_exhaust_temp) { Exhaust_Temperature[val_marker] = val_exhaust_temp; } /*! * \brief Set the back pressure (static) at an engine exhaust boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \param[in] val_exhaust_temp - Exhaust static temperature. */ - void SetExhaust_MassFlow(unsigned short val_imarker, su2double val_exhaust_massflow); + void SetExhaust_MassFlow(unsigned short val_marker, su2double val_exhaust_massflow) { Exhaust_MassFlow[val_marker] = val_exhaust_massflow; } /*! * \brief Set the back pressure (total) at an engine exhaust boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \param[in] val_exhaust_totalpressure - Exhaust total pressure. */ - void SetExhaust_TotalPressure(unsigned short val_imarker, su2double val_exhaust_totalpressure); + void SetExhaust_TotalPressure(unsigned short val_marker, su2double val_exhaust_totalpressure) { Exhaust_TotalPressure[val_marker] = val_exhaust_totalpressure; } /*! * \brief Set the total temperature at an engine exhaust boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \param[in] val_exhaust_totaltemp - Exhaust total temperature. */ - void SetExhaust_TotalTemperature(unsigned short val_imarker, su2double val_exhaust_totaltemp); + void SetExhaust_TotalTemperature(unsigned short val_marker, su2double val_exhaust_totaltemp) { Exhaust_TotalTemperature[val_marker] = val_exhaust_totaltemp; } /*! * \brief Set the gross thrust at an engine exhaust boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \param[in] val_exhaust_grossthrust - Exhaust gross thrust temperature. */ - void SetExhaust_GrossThrust(unsigned short val_imarker, su2double val_exhaust_grossthrust); + void SetExhaust_GrossThrust(unsigned short val_marker, su2double val_exhaust_grossthrust) { Exhaust_GrossThrust[val_marker] = val_exhaust_grossthrust; } /*! * \brief Set the force balance at an engine exhaust boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \param[in] val_exhaust_force - Exhaust force balance. */ - void SetExhaust_Force(unsigned short val_imarker, su2double val_exhaust_force); + void SetExhaust_Force(unsigned short val_marker, su2double val_exhaust_force) { Exhaust_Force[val_marker] = val_exhaust_force; } /*! * \brief Set the power at an engine exhaust boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \param[in] val_exhaust_power - Exhaust power. */ - void SetExhaust_Power(unsigned short val_imarker, su2double val_exhaust_power); + void SetExhaust_Power(unsigned short val_marker, su2double val_exhaust_power) { Exhaust_Power[val_marker] = val_exhaust_power; } /*! * \brief Set the back pressure (static) at an outlet boundary. - * \param[in] val_imarker - Index corresponding to a particular engine boundary. + * \param[in] val_marker - Index corresponding to a particular engine boundary. * \param[in] val_engine_mach - Exhaust power. */ - void SetEngine_Mach(unsigned short val_imarker, su2double val_engine_mach); + void SetEngine_Mach(unsigned short val_marker, su2double val_engine_mach) { Engine_Mach[val_marker] = val_engine_mach; } /*! * \brief Set the back pressure (static) at an outlet boundary. - * \param[in] val_imarker - Index corresponding to a particular engine boundary. + * \param[in] val_marker - Index corresponding to a particular engine boundary. * \param[in] val_engine_force - Exhaust power. */ - void SetEngine_Force(unsigned short val_imarker, su2double val_engine_force); + void SetEngine_Force(unsigned short val_marker, su2double val_engine_force) { Engine_Force[val_marker] = val_engine_force; } /*! * \brief Get the back pressure (static) at an outlet boundary. - * \param[in] val_imarker - Index corresponding to a particular engine boundary. + * \param[in] val_marker - Index corresponding to a particular engine boundary. * \param[in] val_engine_power - Exhaust power. */ - void SetEngine_Power(unsigned short val_imarker, su2double val_engine_power); + void SetEngine_Power(unsigned short val_marker, su2double val_engine_power) { Engine_Power[val_marker] = val_engine_power; } /*! * \brief Get the back pressure (static) at an outlet boundary. - * \param[in] val_imarker - Index corresponding to a particular engine boundary. + * \param[in] val_marker - Index corresponding to a particular engine boundary. * \param[in] val_engine_netthrust - Exhaust power. */ - void SetEngine_NetThrust(unsigned short val_imarker, su2double val_engine_netthrust); + void SetEngine_NetThrust(unsigned short val_marker, su2double val_engine_netthrust) { Engine_NetThrust[val_marker] = val_engine_netthrust; } /*! * \brief Get the back pressure (static) at an outlet boundary. - * \param[in] val_imarker - Index corresponding to a particular engine boundary. + * \param[in] val_marker - Index corresponding to a particular engine boundary. * \param[in] val_engine_grossthrust - Exhaust power. */ - void SetEngine_GrossThrust(unsigned short val_imarker, su2double val_engine_grossthrust); + void SetEngine_GrossThrust(unsigned short val_marker, su2double val_engine_grossthrust) { Engine_GrossThrust[val_marker] = val_engine_grossthrust; } /*! * \brief Get the back pressure (static) at an outlet boundary. - * \param[in] val_imarker - Index corresponding to a particular engine boundary. + * \param[in] val_marker - Index corresponding to a particular engine boundary. * \param[in] val_engine_area - Exhaust power. */ - void SetEngine_Area(unsigned short val_imarker, su2double val_engine_area); + void SetEngine_Area(unsigned short val_marker, su2double val_engine_area) { Engine_Area[val_marker] = val_engine_area; } /*! * \brief Get the back pressure (static) at an outlet boundary. - * \param[in] val_imarker - Index corresponding to a particular engine boundary. + * \param[in] val_marker - Index corresponding to a particular engine boundary. * \return The outlet pressure. */ - su2double GetEngine_Mach(unsigned short val_imarker); + su2double GetEngine_Mach(unsigned short val_marker) const { return Engine_Mach[val_marker]; } /*! * \brief Get the back pressure (static) at an outlet boundary. - * \param[in] val_imarker - Index corresponding to a particular engine boundary. + * \param[in] val_marker - Index corresponding to a particular engine boundary. * \return The outlet pressure. */ - su2double GetEngine_Force(unsigned short val_imarker); + su2double GetEngine_Force(unsigned short val_marker) const { return Engine_Force[val_marker]; } /*! * \brief Get the back pressure (static) at an outlet boundary. - * \param[in] val_imarker - Index corresponding to a particular engine boundary. + * \param[in] val_marker - Index corresponding to a particular engine boundary. * \return The outlet pressure. */ - su2double GetEngine_Power(unsigned short val_imarker); + su2double GetEngine_Power(unsigned short val_marker) const { return Engine_Power[val_marker]; } /*! * \brief Get the back pressure (static) at an outlet boundary. - * \param[in] val_imarker - Index corresponding to a particular engine boundary. + * \param[in] val_marker - Index corresponding to a particular engine boundary. * \return The outlet pressure. */ - su2double GetEngine_NetThrust(unsigned short val_imarker); + su2double GetEngine_NetThrust(unsigned short val_marker) const { return Engine_NetThrust[val_marker]; } /*! * \brief Get the back pressure (static) at an outlet boundary. - * \param[in] val_imarker - Index corresponding to a particular engine boundary. + * \param[in] val_marker - Index corresponding to a particular engine boundary. * \return The outlet pressure. */ - su2double GetEngine_GrossThrust(unsigned short val_imarker); + su2double GetEngine_GrossThrust(unsigned short val_marker) const { return Engine_GrossThrust[val_marker]; } /*! * \brief Get the back pressure (static) at an outlet boundary. - * \param[in] val_imarker - Index corresponding to a particular engine boundary. + * \param[in] val_marker - Index corresponding to a particular engine boundary. * \return The outlet pressure. */ - su2double GetEngine_Area(unsigned short val_imarker); + su2double GetEngine_Area(unsigned short val_marker) const { return Engine_Area[val_marker]; } /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - void SetActDiskInlet_Temperature(unsigned short val_imarker, su2double val_actdisk_temp); + void SetActDiskInlet_Temperature(unsigned short val_marker, su2double val_actdisk_temp) { ActDiskInlet_Temperature[val_marker] = val_actdisk_temp; } /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - void SetActDiskInlet_TotalTemperature(unsigned short val_imarker, su2double val_actdisk_totaltemp); + void SetActDiskInlet_TotalTemperature(unsigned short val_marker, su2double val_actdisk_totaltemp) { ActDiskInlet_TotalTemperature[val_marker] = val_actdisk_totaltemp; } /*! * \brief Get the back pressure (static) at an outlet boundary. @@ -6988,14 +7012,14 @@ class CConfig { * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - void SetActDiskOutlet_Temperature(unsigned short val_imarker, su2double val_actdisk_temp); + void SetActDiskOutlet_Temperature(unsigned short val_marker, su2double val_actdisk_temp) { ActDiskOutlet_Temperature[val_marker] = val_actdisk_temp; } /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - void SetActDiskOutlet_TotalTemperature(unsigned short val_imarker, su2double val_actdisk_totaltemp); + void SetActDiskOutlet_TotalTemperature(unsigned short val_marker, su2double val_actdisk_totaltemp) { ActDiskOutlet_TotalTemperature[val_marker] = val_actdisk_totaltemp; } /*! * \brief Get the back pressure (static) at an outlet boundary. @@ -7023,7 +7047,7 @@ class CConfig { * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - void SetActDiskInlet_MassFlow(unsigned short val_imarker, su2double val_actdisk_massflow); + void SetActDiskInlet_MassFlow(unsigned short val_marker, su2double val_actdisk_massflow) { ActDiskInlet_MassFlow[val_marker] = val_actdisk_massflow; } /*! * \brief Get the back pressure (static) at an outlet boundary. @@ -7037,7 +7061,7 @@ class CConfig { * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - void SetActDiskOutlet_MassFlow(unsigned short val_imarker, su2double val_actdisk_massflow); + void SetActDiskOutlet_MassFlow(unsigned short val_marker, su2double val_actdisk_massflow) { ActDiskOutlet_MassFlow[val_marker] = val_actdisk_massflow; } /*! * \brief Get the back pressure (static) at an outlet boundary. @@ -7058,84 +7082,84 @@ class CConfig { * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - su2double GetActDisk_DeltaPress(unsigned short val_marker); + su2double GetActDisk_DeltaPress(unsigned short val_marker) const { return ActDisk_DeltaPress[val_marker]; } /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - su2double GetActDisk_DeltaTemp(unsigned short val_marker); + su2double GetActDisk_DeltaTemp(unsigned short val_marker) const { return ActDisk_DeltaTemp[val_marker]; } /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - su2double GetActDisk_TotalPressRatio(unsigned short val_marker); + su2double GetActDisk_TotalPressRatio(unsigned short val_marker) const { return ActDisk_TotalPressRatio[val_marker]; } /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - su2double GetActDisk_TotalTempRatio(unsigned short val_marker); + su2double GetActDisk_TotalTempRatio(unsigned short val_marker) const { return ActDisk_TotalTempRatio[val_marker]; } /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - su2double GetActDisk_StaticPressRatio(unsigned short val_marker); + su2double GetActDisk_StaticPressRatio(unsigned short val_marker) const { return ActDisk_StaticPressRatio[val_marker]; } /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - su2double GetActDisk_StaticTempRatio(unsigned short val_marker); + su2double GetActDisk_StaticTempRatio(unsigned short val_marker) const { return ActDisk_StaticTempRatio[val_marker]; } /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - su2double GetActDisk_NetThrust(unsigned short val_marker); + su2double GetActDisk_NetThrust(unsigned short val_marker) const { return ActDisk_NetThrust[val_marker]; } /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - su2double GetActDisk_BCThrust(unsigned short val_marker); + su2double GetActDisk_BCThrust(unsigned short val_marker) const { return ActDisk_BCThrust[val_marker]; } /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - su2double GetActDisk_BCThrust_Old(unsigned short val_marker); + su2double GetActDisk_BCThrust_Old(unsigned short val_marker) const { return ActDisk_BCThrust_Old[val_marker]; } /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - su2double GetActDisk_GrossThrust(unsigned short val_marker); + su2double GetActDisk_GrossThrust(unsigned short val_marker) const { return ActDisk_GrossThrust[val_marker]; } /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - su2double GetActDisk_Area(unsigned short val_marker); + su2double GetActDisk_Area(unsigned short val_marker) const { return ActDisk_Area[val_marker]; } /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - su2double GetActDisk_ReverseMassFlow(unsigned short val_marker); + su2double GetActDisk_ReverseMassFlow(unsigned short val_marker) const { return ActDisk_ReverseMassFlow[val_marker]; } /*! * \brief Get the back pressure (static) at an outlet boundary. @@ -7163,49 +7187,49 @@ class CConfig { * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - void SetActDiskInlet_Pressure(unsigned short val_imarker, su2double val_actdisk_pressure); + void SetActDiskInlet_Pressure(unsigned short val_marker, su2double val_actdisk_press) { ActDiskInlet_Pressure[val_marker] = val_actdisk_press; } /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - void SetActDiskInlet_TotalPressure(unsigned short val_imarker, su2double val_actdisk_totalpressure); + void SetActDiskInlet_TotalPressure(unsigned short val_marker, su2double val_actdisk_totalpress) { ActDiskInlet_TotalPressure[val_marker] = val_actdisk_totalpress; } /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - void SetActDisk_DeltaPress(unsigned short val_imarker, su2double val_actdisk_deltapress); + void SetActDisk_DeltaPress(unsigned short val_marker, su2double val_actdisk_deltapress) { ActDisk_DeltaPress[val_marker] = val_actdisk_deltapress; } /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - void SetActDisk_Power(unsigned short val_imarker, su2double val_actdisk_power); + void SetActDisk_Power(unsigned short val_marker, su2double val_actdisk_power) { ActDisk_Power[val_marker] = val_actdisk_power; } /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - void SetActDisk_MassFlow(unsigned short val_imarker, su2double val_actdisk_massflow); + void SetActDisk_MassFlow(unsigned short val_marker, su2double val_actdisk_massflow) { ActDisk_MassFlow[val_marker] = val_actdisk_massflow; } /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - void SetActDisk_Mach(unsigned short val_imarker, su2double val_actdisk_mach); + void SetActDisk_Mach(unsigned short val_marker, su2double val_actdisk_mach) { ActDisk_Mach[val_marker] = val_actdisk_mach; } /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - void SetActDisk_Force(unsigned short val_imarker, su2double val_actdisk_force); + void SetActDisk_Force(unsigned short val_marker, su2double val_actdisk_force) { ActDisk_Force[val_marker] = val_actdisk_force; } /*! * \brief Get the back pressure (static) at an outlet boundary. @@ -7219,7 +7243,7 @@ class CConfig { * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - void SetOutlet_MassFlow(unsigned short val_imarker, su2double val_massflow); + void SetOutlet_MassFlow(unsigned short val_marker, su2double val_massflow) { Outlet_MassFlow[val_marker] = val_massflow; } /*! * \brief Get the back pressure (static) at an outlet boundary. @@ -7233,7 +7257,7 @@ class CConfig { * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - void SetOutlet_Density(unsigned short val_imarker, su2double val_density); + void SetOutlet_Density(unsigned short val_marker, su2double val_density) { Outlet_Density[val_marker] = val_density; } /*! * \brief Get the back pressure (static) at an outlet boundary. @@ -7247,175 +7271,175 @@ class CConfig { * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - void SetOutlet_Area(unsigned short val_imarker, su2double val_area); + void SetOutlet_Area(unsigned short val_marker, su2double val_area) { Outlet_Area[val_marker] = val_area; } /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - void SetSurface_DC60(unsigned short val_imarker, su2double val_surface_distortion); + void SetSurface_DC60(unsigned short val_marker, su2double val_surface_distortion) { Surface_DC60[val_marker] = val_surface_distortion; } /*! * \brief Set the massflow at the surface. - * \param[in] val_imarker - Index corresponding to the outlet boundary. + * \param[in] val_marker - Index corresponding to the outlet boundary. * \param[in] val_surface_massflow - Value of the mass flow. */ - void SetSurface_MassFlow(unsigned short val_imarker, su2double val_surface_massflow); + void SetSurface_MassFlow(unsigned short val_marker, su2double val_surface_massflow) { Surface_MassFlow[val_marker] = val_surface_massflow; } /*! * \brief Set the mach number at the surface. - * \param[in] val_imarker - Index corresponding to the outlet boundary. + * \param[in] val_marker - Index corresponding to the outlet boundary. * \param[in] val_surface_massflow - Value of the mach number. */ - void SetSurface_Mach(unsigned short val_imarker, su2double val_surface_mach); + void SetSurface_Mach(unsigned short val_marker, su2double val_surface_mach) { Surface_Mach[val_marker] = val_surface_mach; } /*! * \brief Set the temperature at the surface. - * \param[in] val_imarker - Index corresponding to the outlet boundary. + * \param[in] val_marker - Index corresponding to the outlet boundary. * \param[in] val_surface_massflow - Value of the temperature. */ - void SetSurface_Temperature(unsigned short val_imarker, su2double val_surface_temperature); + void SetSurface_Temperature(unsigned short val_marker, su2double val_surface_temperature) { Surface_Temperature[val_marker] = val_surface_temperature; } /*! * \brief Set the pressure at the surface. - * \param[in] val_imarker - Index corresponding to the outlet boundary. + * \param[in] val_marker - Index corresponding to the outlet boundary. * \param[in] val_surface_massflow - Value of the pressure. */ - void SetSurface_Pressure(unsigned short val_imarker, su2double val_surface_pressure); + void SetSurface_Pressure(unsigned short val_marker, su2double val_surface_pressure) { Surface_Pressure[val_marker] = val_surface_pressure; } /*! * \brief Set the density at the surface. - * \param[in] val_imarker - Index corresponding to the outlet boundary. + * \param[in] val_marker - Index corresponding to the outlet boundary. * \param[in] val_surface_density - Value of the density. */ - void SetSurface_Density(unsigned short val_imarker, su2double val_surface_density); + void SetSurface_Density(unsigned short val_marker, su2double val_surface_density) { Surface_Density[val_marker] = val_surface_density; } /*! * \brief Set the enthalpy at the surface. - * \param[in] val_imarker - Index corresponding to the outlet boundary. + * \param[in] val_marker - Index corresponding to the outlet boundary. * \param[in] val_surface_density - Value of the density. */ - void SetSurface_Enthalpy(unsigned short val_imarker, su2double val_surface_enthalpy); + void SetSurface_Enthalpy(unsigned short val_marker, su2double val_surface_enthalpy) { Surface_Enthalpy[val_marker] = val_surface_enthalpy; } /*! * \brief Set the normal velocity at the surface. - * \param[in] val_imarker - Index corresponding to the outlet boundary. + * \param[in] val_marker - Index corresponding to the outlet boundary. * \param[in] val_surface_normalvelocity - Value of the normal velocity. */ - void SetSurface_NormalVelocity(unsigned short val_imarker, su2double val_surface_normalvelocity); + void SetSurface_NormalVelocity(unsigned short val_marker, su2double val_surface_normalvelocity) { Surface_NormalVelocity[val_marker] = val_surface_normalvelocity; } /*! * \brief Set the streamwise flow uniformity at the surface. - * \param[in] val_imarker - Index corresponding to the outlet boundary. + * \param[in] val_marker - Index corresponding to the outlet boundary. * \param[in] val_surface_streamwiseuniformity - Value of the streamwise flow uniformity. */ - void SetSurface_Uniformity(unsigned short val_imarker, su2double val_surface_streamwiseuniformity); + void SetSurface_Uniformity(unsigned short val_marker, su2double val_surface_streamwiseuniformity) { Surface_Uniformity[val_marker] = val_surface_streamwiseuniformity; } /*! * \brief Set the secondary flow strength at the surface. - * \param[in] val_imarker - Index corresponding to the outlet boundary. + * \param[in] val_marker - Index corresponding to the outlet boundary. * \param[in] val_surface_secondarystrength - Value of the secondary flow strength. */ - void SetSurface_SecondaryStrength(unsigned short val_imarker, su2double val_surface_secondarystrength); + void SetSurface_SecondaryStrength(unsigned short val_marker, su2double val_surface_secondarystrength) { Surface_SecondaryStrength[val_marker] = val_surface_secondarystrength; } /*! * \brief Set the relative secondary flow strength at the surface. - * \param[in] val_imarker - Index corresponding to the outlet boundary. + * \param[in] val_marker - Index corresponding to the outlet boundary. * \param[in] val_surface_secondaryoverstream - Value of the relative seondary flow strength. */ - void SetSurface_SecondOverUniform(unsigned short val_imarker, su2double val_surface_secondaryoverstream); + void SetSurface_SecondOverUniform(unsigned short val_marker, su2double val_surface_secondaryoverstream) { Surface_SecondOverUniform[val_marker] = val_surface_secondaryoverstream; } /*! * \brief Set the momentum distortion at the surface. - * \param[in] val_imarker - Index corresponding to the outlet boundary. + * \param[in] val_marker - Index corresponding to the outlet boundary. * \param[in] val_surface_momentumdistortion - Value of the momentum distortion. */ - void SetSurface_MomentumDistortion(unsigned short val_imarker, su2double val_surface_momentumdistortion); + void SetSurface_MomentumDistortion(unsigned short val_marker, su2double val_surface_momentumdistortion) { Surface_MomentumDistortion[val_marker] = val_surface_momentumdistortion; } /*! * \brief Set the total temperature at the surface. - * \param[in] val_imarker - Index corresponding to the outlet boundary. + * \param[in] val_marker - Index corresponding to the outlet boundary. * \param[in] val_surface_totaltemperature - Value of the total temperature. */ - void SetSurface_TotalTemperature(unsigned short val_imarker, su2double val_surface_totaltemperature); + void SetSurface_TotalTemperature(unsigned short val_marker, su2double val_surface_totaltemperature) { Surface_TotalTemperature[val_marker] = val_surface_totaltemperature; } /*! * \brief Set the total pressure at the surface. - * \param[in] val_imarker - Index corresponding to the outlet boundary. + * \param[in] val_marker - Index corresponding to the outlet boundary. * \param[in] val_surface_totalpressure - Value of the total pressure. */ - void SetSurface_TotalPressure(unsigned short val_imarker, su2double val_surface_totalpressure); + void SetSurface_TotalPressure(unsigned short val_marker, su2double val_surface_totalpressure) { Surface_TotalPressure[val_marker] = val_surface_totalpressure; } /*! * \brief Set the pressure drop between two surfaces. - * \param[in] val_imarker - Index corresponding to the outlet boundary. + * \param[in] val_marker - Index corresponding to the outlet boundary. * \param[in] val_surface_pressuredrop - Value of the pressure drop. */ - void SetSurface_PressureDrop(unsigned short val_imarker, su2double val_surface_pressuredrop); + void SetSurface_PressureDrop(unsigned short val_marker, su2double val_surface_pressuredrop) { Surface_PressureDrop[val_marker] = val_surface_pressuredrop; } /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - void SetSurface_IDC(unsigned short val_imarker, su2double val_surface_distortion); + void SetSurface_IDC(unsigned short val_marker, su2double val_surface_distortion) { Surface_IDC[val_marker] = val_surface_distortion; } /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - void SetSurface_IDC_Mach(unsigned short val_imarker, su2double val_surface_distortion); + void SetSurface_IDC_Mach(unsigned short val_marker, su2double val_surface_distortion) { Surface_IDC_Mach[val_marker] = val_surface_distortion; } /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - void SetSurface_IDR(unsigned short val_imarker, su2double val_surface_distortion); + void SetSurface_IDR(unsigned short val_marker, su2double val_surface_distortion) { Surface_IDR[val_marker] = val_surface_distortion; } /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - void SetActDisk_DeltaTemp(unsigned short val_imarker, su2double val_actdisk_deltatemp); + void SetActDisk_DeltaTemp(unsigned short val_marker, su2double val_actdisk_deltatemp) { ActDisk_DeltaTemp[val_marker] = val_actdisk_deltatemp; } /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - void SetActDisk_TotalPressRatio(unsigned short val_imarker, su2double val_actdisk_pressratio); + void SetActDisk_TotalPressRatio(unsigned short val_marker, su2double val_actdisk_pressratio) { ActDisk_TotalPressRatio[val_marker] = val_actdisk_pressratio; } /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - void SetActDisk_TotalTempRatio(unsigned short val_imarker, su2double val_actdisk_tempratio); + void SetActDisk_TotalTempRatio(unsigned short val_marker, su2double val_actdisk_tempratio) { ActDisk_TotalTempRatio[val_marker] = val_actdisk_tempratio; } /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - void SetActDisk_StaticPressRatio(unsigned short val_imarker, su2double val_actdisk_pressratio); + void SetActDisk_StaticPressRatio(unsigned short val_marker, su2double val_actdisk_pressratio) { ActDisk_StaticPressRatio[val_marker] = val_actdisk_pressratio; } /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - void SetActDisk_StaticTempRatio(unsigned short val_imarker, su2double val_actdisk_tempratio); + void SetActDisk_StaticTempRatio(unsigned short val_marker, su2double val_actdisk_tempratio) { ActDisk_StaticTempRatio[val_marker] = val_actdisk_tempratio; } /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - void SetActDisk_NetThrust(unsigned short val_imarker, su2double val_actdisk_netthrust); + void SetActDisk_NetThrust(unsigned short val_marker, su2double val_actdisk_netthrust) { ActDisk_NetThrust[val_marker] = val_actdisk_netthrust; } /*! * \brief Get the back pressure (static) at an outlet boundary. @@ -7429,7 +7453,7 @@ class CConfig { * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - void SetActDisk_BCThrust(unsigned short val_imarker, su2double val_actdisk_bcthrust); + void SetActDisk_BCThrust(unsigned short val_marker, su2double val_actdisk_bcthrust) { ActDisk_BCThrust[val_marker] = val_actdisk_bcthrust; } /*! * \brief Get the back pressure (static) at an outlet boundary. @@ -7443,203 +7467,203 @@ class CConfig { * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - void SetActDisk_BCThrust_Old(unsigned short val_imarker, su2double val_actdisk_bcthrust_old); + void SetActDisk_BCThrust_Old(unsigned short val_marker, su2double val_actdisk_bcthrust_old) { ActDisk_BCThrust_Old[val_marker] = val_actdisk_bcthrust_old; } /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - void SetActDisk_GrossThrust(unsigned short val_imarker, su2double val_actdisk_grossthrust); + void SetActDisk_GrossThrust(unsigned short val_marker, su2double val_actdisk_grossthrust) { ActDisk_GrossThrust[val_marker] = val_actdisk_grossthrust; } /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - void SetActDisk_Area(unsigned short val_imarker, su2double val_actdisk_area); + void SetActDisk_Area(unsigned short val_marker, su2double val_actdisk_area) { ActDisk_Area[val_marker] = val_actdisk_area; } /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - void SetActDiskInlet_ReverseMassFlow(unsigned short val_imarker, su2double val_actdisk_area); + void SetActDiskInlet_ReverseMassFlow(unsigned short val_marker, su2double val_actdisk_area) { ActDisk_ReverseMassFlow[val_marker] = val_actdisk_area; } /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - void SetActDiskInlet_RamDrag(unsigned short val_imarker, su2double val_actdisk_ramdrag); + void SetActDiskInlet_RamDrag(unsigned short val_marker, su2double val_actdisk_ramdrag) { ActDiskInlet_RamDrag[val_marker] = val_actdisk_ramdrag; } /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - void SetActDiskInlet_Force(unsigned short val_imarker, su2double val_actdisk_force); + void SetActDiskInlet_Force(unsigned short val_marker, su2double val_actdisk_force) { ActDiskInlet_Force[val_marker] = val_actdisk_force; } /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - void SetActDiskInlet_Power(unsigned short val_imarker, su2double val_actdisk_power); + void SetActDiskInlet_Power(unsigned short val_marker, su2double val_actdisk_power) { ActDiskInlet_Power[val_marker] = val_actdisk_power; } /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - su2double GetActDisk_Power(unsigned short val_imarker); + su2double GetActDisk_Power(unsigned short val_marker) const { return ActDisk_Power[val_marker]; } /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - su2double GetActDisk_MassFlow(unsigned short val_imarker); + su2double GetActDisk_MassFlow(unsigned short val_marker) const { return ActDisk_MassFlow[val_marker]; } /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - su2double GetActDisk_Mach(unsigned short val_imarker); + su2double GetActDisk_Mach(unsigned short val_marker) const { return ActDisk_Mach[val_marker]; } /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - su2double GetActDisk_Force(unsigned short val_imarker); + su2double GetActDisk_Force(unsigned short val_marker) const { return ActDisk_Force[val_marker]; } /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - su2double GetSurface_DC60(unsigned short val_imarker); + su2double GetSurface_DC60(unsigned short val_marker) const { return Surface_DC60[val_marker]; } /*! * \brief Get the massflow at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The massflow. */ - su2double GetSurface_MassFlow(unsigned short val_imarker); + su2double GetSurface_MassFlow(unsigned short val_marker) const { return Surface_MassFlow[val_marker]; } /*! * \brief Get the mach number at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The mach number. */ - su2double GetSurface_Mach(unsigned short val_imarker); + su2double GetSurface_Mach(unsigned short val_marker) const { return Surface_Mach[val_marker]; } /*! * \brief Get the temperature at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The temperature. */ - su2double GetSurface_Temperature(unsigned short val_imarker); + su2double GetSurface_Temperature(unsigned short val_marker) const { return Surface_Temperature[val_marker]; } /*! * \brief Get the pressure at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The pressure. */ - su2double GetSurface_Pressure(unsigned short val_imarker); + su2double GetSurface_Pressure(unsigned short val_marker) const { return Surface_Pressure[val_marker]; } /*! * \brief Get the density at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The density. */ - su2double GetSurface_Density(unsigned short val_imarker); + su2double GetSurface_Density(unsigned short val_marker) const { return Surface_Density[val_marker]; } /*! * \brief Get the enthalpy at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The density. */ - su2double GetSurface_Enthalpy(unsigned short val_imarker); + su2double GetSurface_Enthalpy(unsigned short val_marker) const { return Surface_Enthalpy[val_marker]; } /*! * \brief Get the normal velocity at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The normal velocity. */ - su2double GetSurface_NormalVelocity(unsigned short val_imarker); + su2double GetSurface_NormalVelocity(unsigned short val_marker) const { return Surface_NormalVelocity[val_marker]; } /*! * \brief Get the streamwise flow uniformity at the surface. - * \param[in] val_imarker - Index corresponding to the outlet boundary. + * \param[in] val_marker - Index corresponding to the outlet boundary. * \return The streamwise flow uniformity. */ - su2double GetSurface_Uniformity(unsigned short val_imarker); + su2double GetSurface_Uniformity(unsigned short val_marker) const { return Surface_Uniformity[val_marker]; } /*! * \brief Get the secondary flow strength at the surface. - * \param[in] val_imarker - Index corresponding to the outlet boundary. + * \param[in] val_marker - Index corresponding to the outlet boundary. * \return The secondary flow strength. */ - su2double GetSurface_SecondaryStrength(unsigned short val_imarker); + su2double GetSurface_SecondaryStrength(unsigned short val_marker) const { return Surface_SecondaryStrength[val_marker]; } /*! * \brief Get the relative secondary flow strength at the surface. - * \param[in] val_imarker - Index corresponding to the outlet boundary. + * \param[in] val_marker - Index corresponding to the outlet boundary. * \return The relative seondary flow strength. */ - su2double GetSurface_SecondOverUniform(unsigned short val_imarker); + su2double GetSurface_SecondOverUniform(unsigned short val_marker) const { return Surface_SecondOverUniform[val_marker]; } /*! * \brief Get the momentum distortion at the surface. - * \param[in] val_imarker - Index corresponding to the outlet boundary. + * \param[in] val_marker - Index corresponding to the outlet boundary. * \return The momentum distortion. */ - su2double GetSurface_MomentumDistortion(unsigned short val_imarker); + su2double GetSurface_MomentumDistortion(unsigned short val_marker) const { return Surface_MomentumDistortion[val_marker]; } /*! * \brief Get the total temperature at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The total temperature. */ - su2double GetSurface_TotalTemperature(unsigned short val_imarker); + su2double GetSurface_TotalTemperature(unsigned short val_marker) const { return Surface_TotalTemperature[val_marker]; } /*! * \brief Get the total pressure at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The total pressure. */ - su2double GetSurface_TotalPressure(unsigned short val_imarker); + su2double GetSurface_TotalPressure(unsigned short val_marker) const { return Surface_TotalPressure[val_marker]; } /*! * \brief Get the pressure drop between two surfaces. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The pressure drop. */ - su2double GetSurface_PressureDrop(unsigned short val_imarker); + su2double GetSurface_PressureDrop(unsigned short val_marker) const { return Surface_PressureDrop[val_marker]; } /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - su2double GetSurface_IDC(unsigned short val_imarker); + su2double GetSurface_IDC(unsigned short val_marker) const { return Surface_IDC[val_marker]; } /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - su2double GetSurface_IDC_Mach(unsigned short val_imarker); + su2double GetSurface_IDC_Mach(unsigned short val_marker) const { return Surface_IDC_Mach[val_marker]; } /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - su2double GetSurface_IDR(unsigned short val_imarker); + su2double GetSurface_IDR(unsigned short val_marker) const { return Surface_IDR[val_marker]; } /*! * \brief Get the back pressure (static) at an outlet boundary. @@ -7681,35 +7705,35 @@ class CConfig { * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - void SetActDiskOutlet_Pressure(unsigned short val_imarker, su2double val_actdisk_pressure); + void SetActDiskOutlet_Pressure(unsigned short val_marker, su2double val_actdisk_press) { ActDiskOutlet_Pressure[val_marker] = val_actdisk_press; } /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - void SetActDiskOutlet_TotalPressure(unsigned short val_imarker, su2double val_actdisk_totalpressure); + void SetActDiskOutlet_TotalPressure(unsigned short val_marker, su2double val_actdisk_totalpress) { ActDiskOutlet_TotalPressure[val_marker] = val_actdisk_totalpress; } /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - void SetActDiskOutlet_GrossThrust(unsigned short val_imarker, su2double val_actdisk_grossthrust); + void SetActDiskOutlet_GrossThrust(unsigned short val_marker, su2double val_actdisk_grossthrust) { ActDiskOutlet_GrossThrust[val_marker] = val_actdisk_grossthrust; } /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - void SetActDiskOutlet_Force(unsigned short val_imarker, su2double val_actdisk_force); + void SetActDiskOutlet_Force(unsigned short val_marker, su2double val_actdisk_force) { ActDiskOutlet_Force[val_marker] = val_actdisk_force; } /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. * \return The outlet pressure. */ - void SetActDiskOutlet_Power(unsigned short val_imarker, su2double val_actdisk_power); + void SetActDiskOutlet_Power(unsigned short val_marker, su2double val_actdisk_power) { ActDiskOutlet_Power[val_marker] = val_actdisk_power; } /*! * \brief Get the displacement value at an displacement boundary. @@ -7806,31 +7830,31 @@ class CConfig { * \brief Cyclic pitch amplitude for rotor blades. * \return The specified cyclic pitch amplitude. */ - su2double GetCyclic_Pitch(void); + su2double GetCyclic_Pitch(void) const { return Cyclic_Pitch; } /*! * \brief Collective pitch setting for rotor blades. * \return The specified collective pitch setting. */ - su2double GetCollective_Pitch(void); + su2double GetCollective_Pitch(void) const { return Collective_Pitch; } /*! * \brief Get name of the arbitrary mesh motion input file. * \return File name of the arbitrary mesh motion input file. */ - string GetDV_Filename(void); + string GetDV_Filename(void) const { return DV_Filename; } /*! * \brief Get name of the unordered ASCII volume sensitivity file. * \return File name of the unordered ASCII volume sensitivity file. */ - string GetDV_Unordered_Sens_Filename(void); + string GetDV_Unordered_Sens_Filename(void) const { return DV_Unordered_Sens_Filename; } /*! * \brief Get name of the unordered ASCII surface sensitivity file. * \return File name of the unordered ASCII surface sensitivity file. */ - string GetDV_Sens_Filename(void); + string GetDV_Sens_Filename(void) const { return DV_Sens_Filename; } /*! * \brief Set the config options. @@ -7870,311 +7894,311 @@ class CConfig { /*! * \brief Value of Aeroelastic solution coordinate at time n+1. */ - vector > GetAeroelastic_np1(unsigned short iMarker); + vector > GetAeroelastic_np1(unsigned short iMarker) const { return Aeroelastic_np1[iMarker]; } /*! * \brief Value of Aeroelastic solution coordinate at time n. */ - vector > GetAeroelastic_n(unsigned short iMarker); + vector > GetAeroelastic_n(unsigned short iMarker) const { return Aeroelastic_n[iMarker]; } /*! * \brief Value of Aeroelastic solution coordinate at time n-1. */ - vector > GetAeroelastic_n1(unsigned short iMarker); + vector > GetAeroelastic_n1(unsigned short iMarker) const { return Aeroelastic_n1[iMarker]; } /*! * \brief Value of Aeroelastic solution coordinate at time n+1. */ - void SetAeroelastic_np1(unsigned short iMarker, vector > solution); + void SetAeroelastic_np1(unsigned short iMarker, vector > solution) { Aeroelastic_np1[iMarker] = solution;} /*! * \brief Value of Aeroelastic solution coordinate at time n from time n+1. */ - void SetAeroelastic_n(void); + void SetAeroelastic_n(void) { Aeroelastic_n = Aeroelastic_np1; } /*! * \brief Value of Aeroelastic solution coordinate at time n-1 from time n. */ - void SetAeroelastic_n1(void); + void SetAeroelastic_n1(void) { Aeroelastic_n1 = Aeroelastic_n; } /*! * \brief Aeroelastic Flutter Speed Index. */ - su2double GetAeroelastic_Flutter_Speed_Index(void); + su2double GetAeroelastic_Flutter_Speed_Index(void) const { return FlutterSpeedIndex; } /*! * \brief Uncoupled Aeroelastic Frequency Plunge. */ - su2double GetAeroelastic_Frequency_Plunge(void); + su2double GetAeroelastic_Frequency_Plunge(void) const { return PlungeNaturalFrequency; } /*! * \brief Uncoupled Aeroelastic Frequency Pitch. */ - su2double GetAeroelastic_Frequency_Pitch(void); + su2double GetAeroelastic_Frequency_Pitch(void) const { return PitchNaturalFrequency; } /*! * \brief Aeroelastic Airfoil Mass Ratio. */ - su2double GetAeroelastic_Airfoil_Mass_Ratio(void); + su2double GetAeroelastic_Airfoil_Mass_Ratio(void) const { return AirfoilMassRatio; } /*! * \brief Aeroelastic center of gravity location. */ - su2double GetAeroelastic_CG_Location(void); + su2double GetAeroelastic_CG_Location(void) const { return CG_Location; } /*! * \brief Aeroelastic radius of gyration squared. */ - su2double GetAeroelastic_Radius_Gyration_Squared(void); + su2double GetAeroelastic_Radius_Gyration_Squared(void) const { return RadiusGyrationSquared; } /*! * \brief Aeroelastic solve every x inner iteration. */ - unsigned short GetAeroelasticIter(void); + unsigned short GetAeroelasticIter(void) const { return AeroelasticIter; } /*! * \brief Value of plunging coordinate. * \param[in] val_marker - the marker we are monitoring. * \return Value of plunging coordinate. */ - su2double GetAeroelastic_plunge(unsigned short val_marker); + su2double GetAeroelastic_plunge(unsigned short val_marker) const { return Aeroelastic_plunge[val_marker]; } /*! * \brief Value of pitching coordinate. * \param[in] val_marker - the marker we are monitoring. * \return Value of pitching coordinate. */ - su2double GetAeroelastic_pitch(unsigned short val_marker); + su2double GetAeroelastic_pitch(unsigned short val_marker) const { return Aeroelastic_pitch[val_marker]; } /*! * \brief Value of plunging coordinate. * \param[in] val_marker - the marker we are monitoring. * \param[in] val - value of plunging coordinate. */ - void SetAeroelastic_plunge(unsigned short val_marker, su2double val); + void SetAeroelastic_plunge(unsigned short val_marker, su2double val) { Aeroelastic_plunge[val_marker] = val; } /*! * \brief Value of pitching coordinate. * \param[in] val_marker - the marker we are monitoring. * \param[in] val - value of pitching coordinate. */ - void SetAeroelastic_pitch(unsigned short val_marker, su2double val); + void SetAeroelastic_pitch(unsigned short val_marker, su2double val) { Aeroelastic_pitch[val_marker] = val; } /*! * \brief Get information about the aeroelastic simulation. * \return TRUE if it is an aeroelastic case; otherwise FALSE. */ - bool GetAeroelastic_Simulation(void); + bool GetAeroelastic_Simulation(void) const { return Aeroelastic_Simulation; } /*! * \brief Get information about the wind gust. * \return TRUE if there is a wind gust; otherwise FALSE. */ - bool GetWind_Gust(void); + bool GetWind_Gust(void) const { return Wind_Gust; } /*! * \brief Get the type of gust to simulate. * \return type of gust to use for the simulation. */ - unsigned short GetGust_Type(void); + unsigned short GetGust_Type(void) const { return Gust_Type; } /*! * \brief Get the gust direction. * \return the gust direction. */ - unsigned short GetGust_Dir(void); + unsigned short GetGust_Dir(void) const { return Gust_Dir; } /*! * \brief Value of the gust wavelength. */ - su2double GetGust_WaveLength(void); + su2double GetGust_WaveLength(void) const { return Gust_WaveLength; } /*! * \brief Value of the number of gust periods. */ - su2double GetGust_Periods(void); + su2double GetGust_Periods(void) const { return Gust_Periods; } /*! * \brief Value of the gust amplitude. */ - su2double GetGust_Ampl(void); + su2double GetGust_Ampl(void) const { return Gust_Ampl; } /*! * \brief Value of the time at which to begin the gust. */ - su2double GetGust_Begin_Time(void); + su2double GetGust_Begin_Time(void) const { return Gust_Begin_Time; } /*! * \brief Value of the location ath which the gust begins. */ - su2double GetGust_Begin_Loc(void); + su2double GetGust_Begin_Loc(void) const { return Gust_Begin_Loc; } /*! * \brief Get the number of iterations to evaluate the parametric coordinates. * \return Number of iterations to evaluate the parametric coordinates. */ - unsigned short GetnFFD_Iter(void); + unsigned short GetnFFD_Iter(void) const { return nFFD_Iter; } /*! * \brief Get the tolerance of the point inversion algorithm. * \return Tolerance of the point inversion algorithm. */ - su2double GetFFD_Tol(void); + su2double GetFFD_Tol(void) const { return FFD_Tol; } /*! * \brief Get the scale factor for the line search. * \return Scale factor for the line search. */ - su2double GetOpt_RelaxFactor(void); + su2double GetOpt_RelaxFactor(void) const { return Opt_RelaxFactor; } /*! * \brief Get the bound for the line search. * \return Bound for the line search. */ - su2double GetOpt_LineSearch_Bound(void); + su2double GetOpt_LineSearch_Bound(void) const { return Opt_LineSearch_Bound; } /*! * \brief Set the scale factor for the line search. * \param[in] val_scale - scale of the deformation. */ - void SetOpt_RelaxFactor(su2double val_scale); + void SetOpt_RelaxFactor(su2double val_scale) { Opt_RelaxFactor = val_scale; } /*! * \brief Get the node number of the CV to visualize. * \return Node number of the CV to visualize. */ - long GetVisualize_CV(void); + long GetVisualize_CV(void) const { return Visualize_CV; } /*! * \brief Get information about whether to use fixed CL mode. * \return TRUE if fixed CL mode is active; otherwise FALSE. */ - bool GetFixed_CL_Mode(void); + bool GetFixed_CL_Mode(void) const { return Fixed_CL_Mode; } /*! * \brief Get information about whether to use fixed CL mode. * \return TRUE if fixed CL mode is active; otherwise FALSE. */ - bool GetFixed_CM_Mode(void); + bool GetFixed_CM_Mode(void) const { return Fixed_CM_Mode; } /*! * \brief Get information about whether to use fixed CL mode. * \return TRUE if fixed CL mode is active; otherwise FALSE. */ - bool GetEval_dOF_dCX(void); + bool GetEval_dOF_dCX(void) const { return Eval_dOF_dCX; } /*! * \brief Get information about whether to use fixed CL mode. * \return TRUE if fixed CL mode is active; otherwise FALSE. */ - bool GetDiscard_InFiles(void); + bool GetDiscard_InFiles(void) const { return Discard_InFiles; } /*! * \brief Get the value specified for the target CL. * \return Value of the target CL. */ - su2double GetTarget_CL(void); + su2double GetTarget_CL(void) const { return Target_CL; } /*! * \brief Get the value for the lift curve slope for fixed CL mode. * \return Lift curve slope for fixed CL mode. */ - su2double GetdCL_dAlpha(void); + su2double GetdCL_dAlpha(void) const { return dCL_dAlpha; } /*! * \brief Number of iterations to evaluate dCL_dAlpha. * \return Number of iterations. */ - unsigned long GetIter_dCL_dAlpha(void); + unsigned long GetIter_dCL_dAlpha(void) const { return Iter_dCL_dAlpha; } /*! * \brief Get the value of the damping coefficient for fixed CL mode. * \return Damping coefficient for fixed CL mode. */ - su2double GetdCM_diH(void); + su2double GetdCM_diH(void) const { return dCM_diH; } /*! * \brief Get the value of iterations to re-evaluate the angle of attack. * \return Number of iterations. */ - unsigned long GetIter_Fixed_NetThrust(void); + unsigned long GetIter_Fixed_NetThrust(void) const { return Iter_Fixed_NetThrust; } /*! * \brief Get the value of the damping coefficient for fixed CL mode. * \return Damping coefficient for fixed CL mode. */ - su2double GetdNetThrust_dBCThrust(void); + su2double GetdNetThrust_dBCThrust(void) const { return dNetThrust_dBCThrust; } /*! * \brief Get the value of iterations to re-evaluate the angle of attack. * \return Number of iterations. */ - unsigned long GetUpdate_BCThrust(void); + unsigned long GetUpdate_BCThrust(void) const { return Update_BCThrust; } /*! * \brief Set the value of the boolean for updating AoA in fixed lift mode. * \param[in] val_update - the bool for whether to update the AoA. */ - void SetUpdate_BCThrust_Bool(bool val_update); + void SetUpdate_BCThrust_Bool(bool val_update) { Update_BCThrust_Bool = val_update; } /*! * \brief Set the value of the boolean for updating AoA in fixed lift mode. * \param[in] val_update - the bool for whether to update the AoA. */ - void SetUpdate_AoA(bool val_update); + void SetUpdate_AoA(bool val_update) { Update_AoA = val_update; } /*! * \brief Get information about whether to update the AoA for fixed lift mode. * \return TRUE if we should update the AoA for fixed lift mode; otherwise FALSE. */ - bool GetUpdate_BCThrust_Bool(void); + bool GetUpdate_BCThrust_Bool(void) const { return Update_BCThrust_Bool; } /*! * \brief Get information about whether to update the AoA for fixed lift mode. * \return TRUE if we should update the AoA for fixed lift mode; otherwise FALSE. */ - bool GetUpdate_AoA(void); + bool GetUpdate_AoA(void) const { return Update_AoA; } /*! * \brief Get the maximum number of iterations between AoA updates for fixed C_L mode * \return Number of maximum iterations between AoA updates */ - unsigned long GetUpdate_AoA_Iter_Limit(void); + unsigned long GetUpdate_AoA_Iter_Limit(void) const { return Update_AoA_Iter_Limit; } /*! * \brief Get whether at the end of finite differencing (Fixed CL mode) * \return boolean indicating end of finite differencing mode (Fixed CL mode) */ - bool GetFinite_Difference_Mode(void); + bool GetFinite_Difference_Mode(void) const { return Finite_Difference_Mode; } /*! * \brief Set whether at the end of finite differencing (Fixed CL mode) */ - void SetFinite_Difference_Mode(bool val_fd_mode); + void SetFinite_Difference_Mode(bool val_fd_mode) { Finite_Difference_Mode = val_fd_mode; } /*! * \brief Set the current number of non-physical nodes in the solution. * \param[in] val_nonphys_points - current number of non-physical points. */ - void SetNonphysical_Points(unsigned long val_nonphys_points); + void SetNonphysical_Points(unsigned long val_nonphys_points) { Nonphys_Points = val_nonphys_points; } /*! * \brief Get the current number of non-physical nodes in the solution. * \return Current number of non-physical points. */ - unsigned long GetNonphysical_Points(void); + unsigned long GetNonphysical_Points(void) const { return Nonphys_Points; } /*! * \brief Set the current number of non-physical reconstructions for 2nd-order upwinding. * \param[in] val_nonphys_reconstr - current number of non-physical reconstructions for 2nd-order upwinding. */ - void SetNonphysical_Reconstr(unsigned long val_nonphys_reconstr); + void SetNonphysical_Reconstr(unsigned long val_nonphys_reconstr) { Nonphys_Reconstr = val_nonphys_reconstr; } /*! * \brief Get the current number of non-physical reconstructions for 2nd-order upwinding. * \return Current number of non-physical reconstructions for 2nd-order upwinding. */ - unsigned long GetNonphysical_Reconstr(void); + unsigned long GetNonphysical_Reconstr(void) { return Nonphys_Reconstr; } /*! * \brief Given arrays x[1..n] and y[1..n] containing a tabulated function, i.e., yi = f(xi), with @@ -8192,7 +8216,7 @@ class CConfig { and given the array y2a[1..n], which is the output from spline above, and given a value of x, this routine returns a cubic-spline interpolated value y. Numerical Recipes: The Art of Scientific Computing, Third Edition in C++. - * \returns The interpolated value of for x. + * \return The interpolated value of for x. */ su2double GetSpline(vector &xa, vector &ya, vector &y2a, unsigned long n, su2double x); @@ -8243,7 +8267,7 @@ class CConfig { * * \brief Set freestream turbonormal for initializing solution. */ - su2double* GetFreeStreamTurboNormal(void); + su2double* GetFreeStreamTurboNormal(void) { return FreeStreamTurboNormal; } /*! * @@ -8255,32 +8279,32 @@ class CConfig { * \brief Get the verbosity level of the console output. * \return Verbosity level for the console output. */ - unsigned short GetConsole_Output_Verb(void); + unsigned short GetConsole_Output_Verb(void) const { return Console_Output_Verb; } /*! * \brief Get the kind of marker analyze marker (area-averaged, mass flux averaged, etc). * \return Kind of average. */ - unsigned short GetKind_Average(void); + unsigned short GetKind_Average(void) const { return Kind_Average; } /*! * * \brief Get the direct differentation method. * \return direct differentiation method. */ - unsigned short GetDirectDiff(); + unsigned short GetDirectDiff() const { return DirectDiff;} /*! * \brief Get the indicator whether we are solving an discrete adjoint problem. * \return the discrete adjoint indicator. */ - bool GetDiscrete_Adjoint(void); + bool GetDiscrete_Adjoint(void) const { return DiscreteAdjoint; } /*! * \brief Get the indicator whether we want to use full (coupled) tapes. * \return the full tape indicator. */ - bool GetFull_Tape(void); + bool GetFull_Tape(void) const { return FullTape; } /*! * \brief Get the indicator whether we want to benchmark the MPI performance of FSI problems @@ -8292,207 +8316,202 @@ class CConfig { * \brief Get the number of fluid subiterations roblems. * \return Number of FSI subiters. */ - unsigned short GetnIterFSI(void); + unsigned short GetnIterFSI(void) const { return nIterFSI; } /*! * \brief Get the number of subiterations while a ramp is applied. * \return Number of FSI subiters. */ - unsigned short GetnIterFSI_Ramp(void); + unsigned short GetnIterFSI_Ramp(void) const { return nIterFSI_Ramp; } /*! * \brief Get Aitken's relaxation parameter for static relaxation cases. * \return Aitken's relaxation parameters. */ - su2double GetAitkenStatRelax(void); + su2double GetAitkenStatRelax(void) const { return AitkenStatRelax; } /*! * \brief Get Aitken's maximum relaxation parameter for dynamic relaxation cases and first iteration. * \return Aitken's relaxation parameters. */ - su2double GetAitkenDynMaxInit(void); + su2double GetAitkenDynMaxInit(void) const { return AitkenDynMaxInit; } /*! * \brief Get Aitken's maximum relaxation parameter for dynamic relaxation cases and first iteration. * \return Aitken's relaxation parameters. */ - su2double GetAitkenDynMinInit(void); - + su2double GetAitkenDynMinInit(void) const { return AitkenDynMinInit; } /*! * \brief Decide whether to apply dead loads to the model. * \return TRUE if the dead loads are to be applied, FALSE otherwise. */ - - bool GetDeadLoad(void); + bool GetDeadLoad(void) const { return DeadLoad; } /*! * \brief Identifies if the mesh is matching or not (temporary, while implementing interpolation procedures). * \return TRUE if the mesh is matching, FALSE otherwise. */ - - bool GetPseudoStatic(void); + bool GetPseudoStatic(void) const { return PseudoStatic; } /*! * \brief Identifies if we want to restart from a steady or an unsteady solution. * \return TRUE if we restart from steady state solution, FALSE otherwise. */ - - bool GetSteadyRestart(void); - + bool GetSteadyRestart(void) const { return SteadyRestart; } /*! * \brief Provides information about the time integration of the structural analysis, and change the write in the output * files information about the iteration. * \return The kind of time integration: Static or dynamic analysis */ - unsigned short GetDynamic_Analysis(void); + unsigned short GetDynamic_Analysis(void) const { return Dynamic_Analysis; } /*! * \brief If we are prforming an unsteady simulation, there is only * one value of the time step for the complete simulation. * \return Value of the time step in an unsteady simulation (non dimensional). */ - su2double GetDelta_DynTime(void); + su2double GetDelta_DynTime(void) const { return Delta_DynTime; } /*! * \brief If we are prforming an unsteady simulation, there is only * one value of the time step for the complete simulation. * \return Value of the time step in an unsteady simulation (non dimensional). */ - su2double GetTotal_DynTime(void); + su2double GetTotal_DynTime(void) const { return Total_DynTime; } /*! * \brief If we are prforming an unsteady simulation, there is only * one value of the time step for the complete simulation. * \return Value of the time step in an unsteady simulation (non dimensional). */ - su2double GetCurrent_DynTime(void); + su2double GetCurrent_DynTime(void) const { return Current_DynTime; } /*! * \brief Get the current instance. * \return Current instance identifier. */ - unsigned short GetiInst(void); + unsigned short GetiInst(void) const { return iInst; } /*! * \brief Set the current instance. * \param[in] iInst - current instance identifier. */ - void SetiInst(unsigned short val_iInst); + void SetiInst(unsigned short val_iInst) { iInst = val_iInst; } /*! * \brief Get information about writing dynamic structural analysis headers and file extensions. * \return TRUE means that dynamic structural analysis solution files will be written. */ - bool GetWrt_Dynamic(void); + bool GetWrt_Dynamic(void) const { return Wrt_Dynamic; } /*! * \brief Get Newmark alpha parameter. * \return Value of the Newmark alpha parameter. */ - su2double GetNewmark_beta(void); + su2double GetNewmark_beta(void) const { return Newmark_beta; } /*! * \brief Get Newmark delta parameter. * \return Value of the Newmark delta parameter. */ - su2double GetNewmark_gamma(void); + su2double GetNewmark_gamma(void) const { return Newmark_gamma; } /*! * \brief Get the number of integration coefficients provided by the user. * \return Number of integration coefficients. */ - unsigned short GetnIntCoeffs(void); + unsigned short GetnIntCoeffs(void) const { return nIntCoeffs; } /*! * \brief Get the number of different values for the elasticity modulus. * \return Number of different values for the elasticity modulus. */ - unsigned short GetnElasticityMod(void); + unsigned short GetnElasticityMod(void) const { return nElasticityMod; } /*! * \brief Get the number of different values for the Poisson ratio. * \return Number of different values for the Poisson ratio. */ - unsigned short GetnPoissonRatio(void); + unsigned short GetnPoissonRatio(void) const { return nPoissonRatio; } /*! * \brief Get the number of different values for the Material density. * \return Number of different values for the Material density. */ - unsigned short GetnMaterialDensity(void); + unsigned short GetnMaterialDensity(void) const { return nMaterialDensity; } /*! * \brief Get the integration coefficients for the Generalized Alpha - Newmark integration integration scheme. * \param[in] val_coeff - Index of the coefficient. * \return Alpha coefficient for the Runge-Kutta integration scheme. */ - su2double Get_Int_Coeffs(unsigned short val_coeff); + su2double Get_Int_Coeffs(unsigned short val_coeff) const { return Int_Coeffs[val_coeff]; } /*! * \brief Get the number of different values for the modulus of the electric field. * \return Number of different values for the modulus of the electric field. */ - unsigned short GetnElectric_Field(void); + unsigned short GetnElectric_Field(void) const { return nElectric_Field; } /*! * \brief Get the dimensionality of the electric field. * \return Number of integration coefficients. */ - unsigned short GetnDim_Electric_Field(void); + unsigned short GetnDim_Electric_Field(void) const { return nDim_Electric_Field; } /*! * \brief Get the values for the electric field modulus. * \param[in] val_coeff - Index of the coefficient. * \return Alpha coefficient for the Runge-Kutta integration scheme. */ - su2double Get_Electric_Field_Mod(unsigned short val_coeff); + su2double Get_Electric_Field_Mod(unsigned short val_coeff) const { return Electric_Field_Mod[val_coeff]; } /*! * \brief Set the values for the electric field modulus. * \param[in] val_coeff - Index of the electric field. * \param[in] val_el_field - Value of the electric field. */ - void Set_Electric_Field_Mod(unsigned short val_coeff, su2double val_el_field); + void Set_Electric_Field_Mod(unsigned short val_coeff, su2double val_el_field) { Electric_Field_Mod[val_coeff] = val_el_field; } /*! * \brief Get the direction of the electric field in reference configuration. * \param[in] val_coeff - Index of the coefficient. * \return Alpha coefficient for the Runge-Kutta integration scheme. */ - su2double* Get_Electric_Field_Dir(void); + su2double* Get_Electric_Field_Dir(void) { return Electric_Field_Dir; } /*! * \brief Check if the user wants to apply the load as a ramp. * \return TRUE means that the load is to be applied as a ramp. */ - bool GetRamp_Load(void); + bool GetRamp_Load(void) const { return Ramp_Load; } /*! * \brief Get the maximum time of the ramp. * \return Value of the max time while the load is linearly increased */ - su2double GetRamp_Time(void); + su2double GetRamp_Time(void) const { return Ramp_Time; } /*! * \brief Check if the user wants to apply the load as a ramp. * \return TRUE means that the load is to be applied as a ramp. */ - bool GetRampAndRelease_Load(void); + bool GetRampAndRelease_Load(void) const { return RampAndRelease; } /*! * \brief Check if the user wants to apply the load as a ramp. * \return TRUE means that the load is to be applied as a ramp. */ - bool GetSine_Load(void); + bool GetSine_Load(void) const { return Sine_Load; } /*! * \brief Get the sine load properties. * \param[in] val_index - Index corresponding to the load boundary. * \return The pointer to the sine load values. */ - su2double* GetLoad_Sine(void); + su2double* GetLoad_Sine(void) { return SineLoad_Coeff; } /*! * \brief Get the kind of load transfer method we want to use for dynamic problems @@ -8500,103 +8519,103 @@ class CConfig { * during the computation. * \return Kind of transfer method for multiphysics problems */ - unsigned short GetDynamic_LoadTransfer(void); + unsigned short GetDynamic_LoadTransfer(void) const { return Dynamic_LoadTransfer; } /*! * \brief Get the penalty weight value for the objective function. * \return Penalty weight value for the reference geometry objective function. */ - su2double GetRefGeom_Penalty(void); + su2double GetRefGeom_Penalty(void) const { return RefGeom_Penalty; } /*! * \brief Get the penalty weight value for the objective function. * \return Penalty weight value for the reference geometry objective function. */ - su2double GetTotalDV_Penalty(void); + su2double GetTotalDV_Penalty(void) const { return DV_Penalty; } /*! * \brief Get whether a predictor is used for FSI applications. * \return Bool: determines if predictor is used or not */ - bool GetPredictor(void); + bool GetPredictor(void) const { return Predictor; } /*! * \brief Get the order of the predictor for FSI applications. * \return Order of predictor */ - unsigned short GetPredictorOrder(void); + unsigned short GetPredictorOrder(void) const { return Pred_Order; } /*! * \brief Get boolean for using Persson's shock capturing method in Euler flow DG-FEM * \return Boolean for using Persson's shock capturing method in Euler flow DG-FEM */ - bool GetEulerPersson(void); + bool GetEulerPersson(void) const { return EulerPersson; } /*! * \brief Set boolean for using Persson's shock capturing method in Euler flow DG-FEM * \param[in] val_EulerPersson - Boolean for using Persson's shock capturing method in Euler flow DG-FEM */ - void SetEulerPersson(bool val_EulerPersson); + void SetEulerPersson(bool val_EulerPersson) { EulerPersson = val_EulerPersson; } /*! * \brief Get whether a relaxation parameter is used for FSI applications. * \return Bool: determines if relaxation parameter is used or not */ - bool GetRelaxation(void); + bool GetRelaxation(void) const { return Relaxation; } /*! * \brief Check if the simulation we are running is a FSI simulation * \return Value of the physical time in an unsteady simulation. */ - bool GetFSI_Simulation(void); + bool GetFSI_Simulation(void) const { return FSI_Problem || (nMarker_Fluid_Load > 0); } /*! * \brief Set that the simulation we are running is a FSI simulation * \param[in] FSI_sim - boolean that determines is FSI_Problem is true/false. */ - void SetFSI_Simulation(bool FSI_sim); + void SetFSI_Simulation(bool FSI_sim) { FSI_Problem = FSI_sim; } /*! * \brief Set that the simulation we are running is a multizone simulation * \param[in] MZ_problem - boolean that determines is Multizone_Problem is true/false. */ - void SetMultizone_Problem(bool MZ_problem); + void SetMultizone_Problem(bool MZ_problem) { Multizone_Problem = MZ_problem; } /*! * \brief Get whether the simulation we are running is a multizone simulation * \return Multizone_Problem - boolean that determines is Multizone_Problem is true/false. */ - bool GetMultizone_Problem(void); + bool GetMultizone_Problem(void) const { return Multizone_Problem; } /*! * \brief Get the ID for the FEA region that we want to compute the gradient for using direct differentiation * \return ID */ - unsigned short GetnID_DV(void); + unsigned short GetnID_DV(void) const { return nID_DV; } /*! * \brief Check if we want to apply an incremental load to the nonlinear structural simulation * \return TRUE means that the load is to be applied in increments. */ - bool GetIncrementalLoad(void); + bool GetIncrementalLoad(void) const { return IncrementalLoad; } /*! * \brief Get the number of increments for an incremental load. * \return Number of increments. */ - unsigned long GetNumberIncrements(void); + unsigned long GetNumberIncrements(void) const { return IncLoad_Nincrements; } /*! * \brief Get the value of the criteria for applying incremental loading. * \return Value of the log10 of the residual. */ - su2double GetIncLoad_Criteria(unsigned short val_var); + su2double GetIncLoad_Criteria(unsigned short val_var) const { return IncLoad_Criteria[val_var]; } /*! * \brief Get the relaxation method chosen for the simulation * \return Value of the relaxation method */ - unsigned short GetRelaxation_Method_FSI(void); + unsigned short GetRelaxation_Method_FSI(void) const { return Kind_BGS_RelaxMethod; } /*! * \brief Get the kind of Riemann solver for the DG method (FEM flow solver). @@ -8604,572 +8623,576 @@ class CConfig { * during the computation. * \return Kind of Riemann solver for the DG method (FEM flow solver). */ - unsigned short GetRiemann_Solver_FEM(void); + unsigned short GetRiemann_Solver_FEM(void) const { return Riemann_Solver_FEM; } /*! * \brief Get the factor applied during quadrature of straight elements. * \return The specified straight element quadrature factor. */ - su2double GetQuadrature_Factor_Straight(void); + su2double GetQuadrature_Factor_Straight(void) const { return Quadrature_Factor_Straight; } /*! * \brief Get the factor applied during quadrature of curved elements. * \return The specified curved element quadrature factor. */ - su2double GetQuadrature_Factor_Curved(void); + su2double GetQuadrature_Factor_Curved(void) const { return Quadrature_Factor_Curved; } /*! * \brief Get the factor applied during time quadrature for ADER-DG. * \return The specified ADER-DG time quadrature factor. */ - su2double GetQuadrature_Factor_Time_ADER_DG(void); + su2double GetQuadrature_Factor_Time_ADER_DG(void) const { return Quadrature_Factor_Time_ADER_DG; } /*! * \brief Function to make available the multiplication factor theta of the symmetrizing terms in the DG discretization of the viscous terms. * \return The specified factor for the DG discretization. */ - su2double GetTheta_Interior_Penalty_DGFEM(void); + su2double GetTheta_Interior_Penalty_DGFEM(void) const { return Theta_Interior_Penalty_DGFEM; } /*! * \brief Function to make available the matrix size in vectorization in order to optimize the gemm performance. * \return The matrix size in this direction. */ - unsigned short GetSizeMatMulPadding(void); + unsigned short GetSizeMatMulPadding(void) const { return sizeMatMulPadding; } /*! * \brief Function to make available whether or not the entropy must be computed. * \return The boolean whether or not the entropy must be computed. */ - bool GetCompute_Entropy(void); + bool GetCompute_Entropy(void) const { return Compute_Entropy; } /*! * \brief Function to make available whether or not the lumped mass matrix must be used for steady computations. * \return The boolean whether or not to use the lumped mass matrix. */ - bool GetUse_Lumped_MassMatrix_DGFEM(void); + bool GetUse_Lumped_MassMatrix_DGFEM(void) const { return Use_Lumped_MassMatrix_DGFEM; } /*! * \brief Function to make available whether or not only the exact Jacobian of the spatial discretization must be computed. * \return The boolean whether or not the Jacobian must be computed. */ - bool GetJacobian_Spatial_Discretization_Only(void); + bool GetJacobian_Spatial_Discretization_Only(void) const { return Jacobian_Spatial_Discretization_Only; } /*! * \brief Get the interpolation method used for matching between zones. */ - inline unsigned short GetKindInterpolation(void); + unsigned short GetKindInterpolation(void) const { return Kind_Interpolation; } /*! * \brief Get option of whether to use conservative interpolation between zones. */ - inline bool GetConservativeInterpolation(void); + bool GetConservativeInterpolation(void) const { return ConservativeInterpolation; } /*! * \brief Get the basis function to use for radial basis function interpolation for FSI. */ - inline unsigned short GetKindRadialBasisFunction(void); + unsigned short GetKindRadialBasisFunction(void) const { return Kind_RadialBasisFunction; } /*! * \brief Get option of whether to use polynomial terms in Radial Basis Function interpolation. */ - inline bool GetRadialBasisFunctionPolynomialOption(void); + bool GetRadialBasisFunctionPolynomialOption(void) const { return RadialBasisFunction_PolynomialOption; } /*! * \brief Get the basis function radius to use for radial basis function interpolation for FSI. */ - inline su2double GetRadialBasisFunctionParameter(void); + su2double GetRadialBasisFunctionParameter(void) const { return RadialBasisFunction_Parameter; } /*! * \brief Get information about using UQ methodology * \return TRUE means that UQ methodology of eigenspace perturbation will be used */ - bool GetUsing_UQ(void); + bool GetUsing_UQ(void) const { return using_uq; } /*! * \brief Get the amount of eigenvalue perturbation to be done * \return Value of the uq_delta_b parameter */ - su2double GetUQ_Delta_B(void); + su2double GetUQ_Delta_B(void) const { return uq_delta_b; } /*! * \brief Get the kind of eigenspace perturbation to be done * \return Value of the eig_val_comp */ - unsigned short GetEig_Val_Comp(void); + unsigned short GetEig_Val_Comp(void) const { return eig_val_comp; } /*! * \brief Get the underelaxation factor * \return Value of the uq_urlx parameter */ - su2double GetUQ_URLX(void); + su2double GetUQ_URLX(void) const { return uq_urlx; } /*! * \brief Get information about eigenspace perturbation * \return TRUE means eigenspace perterturbation will be used */ - bool GetUQ_Permute(void); + bool GetUQ_Permute(void) const { return uq_permute; } /*! * \brief Get information about whether to use wall functions. * \return TRUE if wall functions are on; otherwise FALSE. */ - bool GetWall_Functions(void); + bool GetWall_Functions(void) const { return Wall_Functions; } /*! * \brief Get the AD support. */ - bool GetAD_Mode(void); + bool GetAD_Mode(void) const { return AD_Mode;} /*! * \brief Set the maximum velocity^2 in the domain for the incompressible preconditioner. * \param[in] Value of the maximum velocity^2 in the domain for the incompressible preconditioner. */ - void SetMax_Vel2(su2double val_max_vel2); + void SetMax_Vel2(su2double val_max_vel2) { Max_Vel2 = val_max_vel2; } /*! * \brief Get the maximum velocity^2 in the domain for the incompressible preconditioner. * \return Value of the maximum velocity^2 in the domain for the incompressible preconditioner. */ - su2double GetMax_Vel2(void); + su2double GetMax_Vel2(void) const { return Max_Vel2; } /*! * \brief Set the sum of the bandwidth for writing binary restarts (to be averaged later). * \param[in] Sum of the bandwidth for writing binary restarts. */ - void SetRestart_Bandwidth_Agg(su2double val_restart_bandwidth_sum); + void SetRestart_Bandwidth_Agg(su2double val_restart_bandwidth_sum) { Restart_Bandwidth_Agg = val_restart_bandwidth_sum; } /*! * \brief Set the sum of the bandwidth for writing binary restarts (to be averaged later). * \return Sum of the bandwidth for writing binary restarts. */ - su2double GetRestart_Bandwidth_Agg(void); + su2double GetRestart_Bandwidth_Agg(void) const { return Restart_Bandwidth_Agg; } /*! * \brief Get the frequency for writing the surface solution file in Dual Time. * \return It writes the surface solution file with this frequency. */ - unsigned long GetWrt_Surf_Freq_DualTime(void); + unsigned long GetWrt_Surf_Freq_DualTime(void) const { return Wrt_Surf_Freq_DualTime; } /*! * \brief Get the Kind of Hybrid RANS/LES. * \return Value of Hybrid RANS/LES method. */ - unsigned short GetKind_HybridRANSLES(void); + unsigned short GetKind_HybridRANSLES(void) const { return Kind_HybridRANSLES; } /*! * \brief Get the Kind of Roe Low Dissipation Scheme for Unsteady flows. * \return Value of Low dissipation approach. */ - unsigned short GetKind_RoeLowDiss(void); + unsigned short GetKind_RoeLowDiss(void) const { return Kind_RoeLowDiss; } /*! * \brief Get the DES Constant. * \return Value of DES constant. */ - su2double GetConst_DES(void); + su2double GetConst_DES(void) const { return Const_DES; } /*! * \brief Get QCR (SA-QCR2000). */ - bool GetQCR(void); + bool GetQCR(void) const { return QCR;} /*! * \brief Get if AD preaccumulation should be performed. */ - bool GetAD_Preaccumulation(void); + bool GetAD_Preaccumulation(void) const { return AD_Preaccumulation;} /*! * \brief Get the heat equation. * \return YES if weakly coupled heat equation for inc. flow is enabled. */ - bool GetWeakly_Coupled_Heat(void); + bool GetWeakly_Coupled_Heat(void) const { return Weakly_Coupled_Heat; } /*! * \brief Get the CHT couling method. * \return Kind of the method. */ - unsigned short GetKind_CHT_Coupling(void) const; + unsigned short GetKind_CHT_Coupling(void) const { return Kind_CHT_Coupling; } /*! * \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. */ - bool GetIntegrated_HeatFlux(void); + bool GetIntegrated_HeatFlux(void) const { return Integrated_HeatFlux; } /*! * \brief Get Compute Average. * \return YES if start computing averages */ - bool GetCompute_Average(void); + bool GetCompute_Average(void) const { return Compute_Average;} /*! * \brief Get the verification solution. * \return The verification solution to be used. */ - unsigned short GetVerification_Solution(void); + unsigned short GetVerification_Solution(void) const { return Kind_Verification_Solution;} /*! * \brief Get topology optimization. */ - bool GetTopology_Optimization(void) const; + bool GetTopology_Optimization(void) const { return topology_optimization; } /*! * \brief Get name of output file for topology optimization derivatives. */ - string GetTopology_Optim_FileName(void) const; + string GetTopology_Optim_FileName(void) const { return top_optim_output_file; } /*! * \brief Get exponent for density-based stiffness penalization. */ - su2double GetSIMP_Exponent(void) const; + su2double GetSIMP_Exponent(void) const { return simp_exponent; } /*! * \brief Get lower bound for density-based stiffness penalization. */ - su2double GetSIMP_MinStiffness(void) const; + su2double GetSIMP_MinStiffness(void) const { return simp_minimum_stiffness; } /*! * \brief Number of kernels to use in filtering the design density field. */ - unsigned short GetTopology_Optim_Num_Kernels(void) const; + unsigned short GetTopology_Optim_Num_Kernels(void) const { return top_optim_nKernel; } /*! * \brief Get the i'th kernel to use, its parameter, and the radius. */ void GetTopology_Optim_Kernel(const unsigned short iKernel, unsigned short &type, - su2double ¶m, su2double &radius) const; + su2double ¶m, su2double &radius) const { + type = top_optim_kernels[iKernel]; + param = top_optim_kernel_params[iKernel]; + radius = top_optim_filter_radius[iKernel]; + } + /*! * \brief Get the maximum "logical radius" (degree of neighborhood) to consider in the neighbor search. */ - unsigned short GetTopology_Search_Limit(void) const; + unsigned short GetTopology_Search_Limit(void) const { return top_optim_search_lim; } /*! * \brief Get the type and parameter for the projection function used in topology optimization */ - void GetTopology_Optim_Projection(unsigned short &type, su2double ¶m) const; + void GetTopology_Optim_Projection(unsigned short &type, su2double ¶m) const { + type = top_optim_proj_type; param = top_optim_proj_param; + } /*! * \brief Retrieve the ofstream of the history file for the current zone. */ - ofstream* GetHistFile(void); + ofstream* GetHistFile(void) { return ConvHistFile; } /*! * \brief Set the ofstream of the history file for the current zone. */ - void SetHistFile(ofstream *HistFile); + void SetHistFile(ofstream *HistFile) { ConvHistFile = HistFile; } /*! * \brief Get the filenames of the individual config files * \return File name of the config file for zone "index" */ - string GetConfigFilename(unsigned short index); + string GetConfigFilename(unsigned short index) const { return Config_Filenames[index]; } /*! * \brief Get the number of config files * \return Number of config filenames in CONFIG_LIST */ - unsigned short GetnConfigFiles(void); + unsigned short GetnConfigFiles(void) const { return nConfig_Files; } /*! * \brief Check if the multizone problem is solved for time domain. * \return YES if time-domain is considered. */ - bool GetTime_Domain(void); + bool GetTime_Domain(void) const { return Time_Domain; } /*! * \brief Get the number of inner iterations * \return Number of inner iterations on each multizone block */ - unsigned long GetnInner_Iter(void); + unsigned long GetnInner_Iter(void) const { return nInnerIter; } /*! * \brief Get the number of outer iterations * \return Number of outer iterations for the multizone problem */ - unsigned long GetnOuter_Iter(void); + unsigned long GetnOuter_Iter(void) const { return nOuterIter; } /*! * \brief Get the number of time iterations * \return Number of time steps run */ - unsigned long GetnTime_Iter(void); + unsigned long GetnTime_Iter(void) const { return nTimeIter; } /*! * \brief Set the number of time iterations * \param[in] val_iter - Number of time steps run */ - void SetnTime_Iter(unsigned long val_iter); + void SetnTime_Iter(unsigned long val_iter) { nTimeIter = val_iter; } /*! * \brief Get the number of pseudo-time iterations * \return Number of pseudo-time steps run for the single-zone problem */ - unsigned long GetnIter(void); + unsigned long GetnIter(void) const { return nIter; } /*! * \brief Get the restart iteration * \return Iteration for the restart of multizone problems */ - unsigned long GetRestart_Iter(void); + unsigned long GetRestart_Iter(void) const { return Restart_Iter; } /*! * \brief Get the time step for multizone problems * \return Time step for multizone problems, it is set on all the zones */ - su2double GetTime_Step(void); + su2double GetTime_Step(void) const { return Time_Step; } /*! * \brief Get the maximum simulation time for time-domain problems * \return Simulation time for multizone problems, it is set on all the zones */ - su2double GetMax_Time(void); + su2double GetMax_Time(void) const { return Max_Time; } /*! * \brief Get the level of MPI communications to be performed. * \return Level of MPI communications. */ - unsigned short GetComm_Level(void); + unsigned short GetComm_Level(void) const { return Comm_Level; } /*! * \brief Check if the mesh read supports multiple zones. * \return YES if multiple zones can be contained in the mesh file. */ - bool GetMultizone_Mesh(void); + bool GetMultizone_Mesh(void) const { return Multizone_Mesh; } /*! * \brief Check if the mesh read supports multiple zones. * \return YES if multiple zones can be contained in the mesh file. */ - bool GetMultizone_Residual(void); + bool GetMultizone_Residual(void) const { return Multizone_Residual; } /*! * \brief Check if the (new) single-zone driver is to be used (temporary) * \return YES if the (new) single-zone driver is to be used. */ - bool GetSinglezone_Driver(void); + bool GetSinglezone_Driver(void) const { return SinglezoneDriver; } /*! * \brief Check if the convergence history of each individual zone is written to screen * \return YES if the zone convergence history of each individual zone must be written to screen */ - bool GetWrt_ZoneConv(void); + bool GetWrt_ZoneConv(void) const { return Wrt_ZoneConv; } /*! * \brief Check if the convergence history of each individual zone is written to file * \return YES if the zone convergence history of each individual zone must be written to file */ - bool GetWrt_ZoneHist(void); + bool GetWrt_ZoneHist(void) const { return Wrt_ZoneHist; } /*! * \brief Check if the special output is written * \return YES if the special output is written. */ - bool GetSpecial_Output(void); + bool GetSpecial_Output(void) const { return SpecialOutput; } /*! * \brief Check if the forces breakdown file is written * \return YES if the forces breakdown file is written. */ - bool GetWrt_ForcesBreakdown(void); + bool GetWrt_ForcesBreakdown(void) const { return Wrt_ForcesBreakdown; } /*! * \brief Get the number of grid points in the analytic RECTANGLE or BOX grid in the specified coordinate direction. * \return Number of grid points in the analytic RECTANGLE or BOX grid in the specified coordinate direction. */ - short GetMeshBoxSize(unsigned short val_iDim); + short GetMeshBoxSize(unsigned short val_iDim) const { return Mesh_Box_Size[val_iDim]; } /*! * \brief Get the length of the analytic RECTANGLE or BOX grid in the specified coordinate direction. * \return Length the analytic RECTANGLE or BOX grid in the specified coordinate direction. */ - su2double GetMeshBoxLength(unsigned short val_iDim); + su2double GetMeshBoxLength(unsigned short val_iDim) const { return Mesh_Box_Length[val_iDim]; } /*! * \brief Get the offset from 0.0 of the analytic RECTANGLE or BOX grid in the specified coordinate direction. * \return Offset from 0.0 the analytic RECTANGLE or BOX grid in the specified coordinate direction. */ - su2double GetMeshBoxOffset(unsigned short val_iDim); + su2double GetMeshBoxOffset(unsigned short val_iDim) const { return Mesh_Box_Offset[val_iDim]; } /*! * \brief Get the number of screen output variables requested (maximum 6) */ - unsigned short GetnScreenOutput(void); + unsigned short GetnScreenOutput(void) const { return nScreenOutput; } /*! * \brief Get the screen output field iField */ - string GetScreenOutput_Field(unsigned short iField); + string GetScreenOutput_Field(unsigned short iField) const { return ScreenOutput[iField]; } /*! * \brief Get the number of history output variables requested */ - unsigned short GetnHistoryOutput(void); + unsigned short GetnHistoryOutput(void) const { return nHistoryOutput; } /*! * \brief Get the history output field iField */ - string GetHistoryOutput_Field(unsigned short iField); + string GetHistoryOutput_Field(unsigned short iField) const { return HistoryOutput[iField]; } /*! * \brief Get the number of history output variables requested */ - unsigned short GetnVolumeOutput(void); + unsigned short GetnVolumeOutput(void) const { return nVolumeOutput; } /*! * \brief Get the history output field iField */ - string GetVolumeOutput_Field(unsigned short iField); + string GetVolumeOutput_Field(unsigned short iField) const { return VolumeOutput[iField]; } /*! * \brief Get the convergence fields for monitoring * \param[in] iField - Index of the field * return Field name for monitoring convergence */ - string GetConv_Field(unsigned short iField); + string GetConv_Field(unsigned short iField) const { return ConvField[iField]; } /*! * \brief Get functional that is going to be used to evaluate the convergence of the windowed time average of the unsteady problem. * \param[in] iField - Index of the field * \return Field name for monitoring convergence */ - string GetWndConv_Field(unsigned short iField) const; + string GetWndConv_Field(unsigned short iField) const { return WndConvField[iField]; } /*! * \brief Get the number of iterations that are considered in the Cauchy convergence criteria for the windowed time average of the unsteady problem. * \return Number of elements in the Cauchy criteria windowed time average of the unsteady problem. */ - unsigned short GetWnd_Cauchy_Elems(void) const; + unsigned short GetWnd_Cauchy_Elems(void) const { return Wnd_Cauchy_Elems; } /*! * \brief Get the value of convergence criteria for the Cauchy method for the time averaged * windowed objective functions for unsteady flows * \return Value of the convergence criteria. */ - su2double GetWnd_Cauchy_Eps(void) const; + su2double GetWnd_Cauchy_Eps(void) const { return Wnd_Cauchy_Eps; } /*! * \brief Get the number of iterations that are not considered in the convergence criteria for the windowed average output function * \return Number of iterations before starting with the convergence criteria for the windowed average output function. */ - unsigned long GetWnd_StartConv_Iter(void) const; + unsigned long GetWnd_StartConv_Iter(void) const { return Wnd_StartConv_Iter; } /*! * \brief Get the boolean value, whether the the Cauchy method for the time averaged * windowed objective functions for unsteady flows is used or not. * \return Boolean value, if the criterion is used. */ - bool GetWnd_Cauchy_Crit(void) const; + bool GetWnd_Cauchy_Crit(void) const { return Wnd_Cauchy_Crit; } /*! * \brief Get the number of convergence monitoring fields for time convergence monitoring. * return Number of convergence monitoring fields. */ - unsigned short GetnWndConv_Field() const; + unsigned short GetnWndConv_Field() const { return nWndConvField; } /*! * \brief Get the number of convergence monitoring fields for inner convergence monitoring. * return Number of convergence monitoring fields. */ - unsigned short GetnConv_Field(); + unsigned short GetnConv_Field() const { return nConvField; } /*! * \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); + void Set_StartTime(su2double starttime) { StartTime = starttime; } /*! * \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(); + su2double Get_StartTime() const { return StartTime; } /*! * \brief GetHistory_Wrt_Freq_Inner * \return */ - unsigned long GetHistory_Wrt_Freq(unsigned short iter); + unsigned long GetHistory_Wrt_Freq(unsigned short iter) const { return HistoryWrtFreq[iter];} /*! * \brief SetHistory_Wrt_Freq_Inner * \param[in] iter: index for Time (0), Outer (1), or Inner (2) iterations * \param[in] nIter: Number of iterations */ - void SetHistory_Wrt_Freq(unsigned short iter, unsigned long nIter); + void SetHistory_Wrt_Freq(unsigned short iter, unsigned long nIter) { HistoryWrtFreq[iter] = nIter;} /*! * \brief GetScreen_Wrt_Freq_Inner * \return */ - unsigned long GetScreen_Wrt_Freq(unsigned short iter); + unsigned long GetScreen_Wrt_Freq(unsigned short iter) const { return ScreenWrtFreq[iter]; } /*! * \brief SetScreen_Wrt_Freq_Inner * \param[in] iter: index for Time (0), Outer (1), or Inner (2) iterations * \param[in] nIter: Number of iterations */ - void SetScreen_Wrt_Freq(unsigned short iter, unsigned long nIter); + void SetScreen_Wrt_Freq(unsigned short iter, unsigned long nIter) { ScreenWrtFreq[iter] = nIter; } /*! * \brief GetScreen_Wrt_Freq_Inner * \return */ - unsigned long GetVolume_Wrt_Freq(); + unsigned long GetVolume_Wrt_Freq() const { return VolumeWrtFreq; } /*! * \brief GetVolumeOutputFiles * \return */ - unsigned short* GetVolumeOutputFiles(); + unsigned short* GetVolumeOutputFiles() { return VolumeOutputFiles; } /*! * \brief GetnVolumeOutputFiles * \return */ - unsigned short GetnVolumeOutputFiles(); + unsigned short GetnVolumeOutputFiles() const { return nVolumeOutputFiles; } /*! * \brief Get the desired factorization frequency for PaStiX * \return Number of calls to 'Build' that trigger re-factorization. */ - unsigned long GetPastixFactFreq(void); + unsigned long GetPastixFactFreq(void) const { return pastix_fact_freq; } /*! * \brief Get the desired level of verbosity for PaStiX * \return 0 - Quiet, 1 - During factorization and cleanup, 2 - Even more detail. */ - unsigned short GetPastixVerbLvl(void); + unsigned short GetPastixVerbLvl(void) const { return pastix_verb_lvl; } /*! * \brief Get the desired level of fill for the PaStiX ILU * \return Level of fill. */ - unsigned short GetPastixFillLvl(void); + unsigned short GetPastixFillLvl(void) const { return pastix_fill_lvl; } /*! * \brief Check if an option is present in the config file * \param[in] - Name of the option * \return if option was set in the config file */ - bool OptionIsSet(string option); + bool OptionIsSet(string option) const { return all_options.find(option) == all_options.end(); } /*! * \brief Get the name of the current case * \return the case name */ - const string& GetCaseName() const; - + const string& GetCaseName() const { return caseName; } /*! * \brief Get the number of threads per rank to use for ILU and LU_SGS preconditioners. * \return Number of threads per rank. */ - inline unsigned long GetLinear_Solver_Prec_Threads(void) const {return Linear_Solver_Prec_Threads;} + unsigned long GetLinear_Solver_Prec_Threads(void) const { return Linear_Solver_Prec_Threads; } }; - -#include "config_structure.inl" diff --git a/Common/include/config_structure.inl b/Common/include/config_structure.inl deleted file mode 100644 index 753c9558aa17..000000000000 --- a/Common/include/config_structure.inl +++ /dev/null @@ -1,2092 +0,0 @@ -/*! - * \file config_structure.inl - * \brief In-Line subroutines of the config_structure.hpp file. - * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -inline su2double CConfig::GetHTP_Axis(unsigned short val_index) { return HTP_Axis[val_index]; } - -inline su2double CConfig::GetCFL_AdaptParam(unsigned short val_index) { return CFL_AdaptParam[val_index]; } - -inline bool CConfig::GetCFL_Adapt(void) { return CFL_Adapt; } - -inline bool CConfig::GetHB_Precondition(void) { return HB_Precondition; } - -inline void CConfig::SetInflow_Mach(unsigned short val_imarker, su2double val_fanface_mach) { Inflow_Mach[val_imarker] = val_fanface_mach; } - -inline void CConfig::SetInflow_Pressure(unsigned short val_imarker, su2double val_fanface_pressure) { Inflow_Pressure[val_imarker] = val_fanface_pressure; } - -inline void CConfig::SetInflow_MassFlow(unsigned short val_imarker, su2double val_fanface_massflow) { Inflow_MassFlow[val_imarker] = val_fanface_massflow; } - -inline void CConfig::SetInflow_ReverseMassFlow(unsigned short val_imarker, su2double val_fanface_reversemassflow) { Inflow_ReverseMassFlow[val_imarker] = val_fanface_reversemassflow; } - -inline void CConfig::SetInflow_TotalPressure(unsigned short val_imarker, su2double val_fanface_totalpressure) { Inflow_TotalPressure[val_imarker] = val_fanface_totalpressure; } - -inline void CConfig::SetInflow_Temperature(unsigned short val_imarker, su2double val_fanface_temperature) { Inflow_Temperature[val_imarker] = val_fanface_temperature; } - -inline void CConfig::SetInflow_TotalTemperature(unsigned short val_imarker, su2double val_fanface_totaltemperature) { Inflow_TotalTemperature[val_imarker] = val_fanface_totaltemperature; } - -inline void CConfig::SetInflow_RamDrag(unsigned short val_imarker, su2double val_fanface_ramdrag) { Inflow_RamDrag[val_imarker] = val_fanface_ramdrag; } - -inline void CConfig::SetInflow_Force(unsigned short val_imarker, su2double val_fanface_force) { Inflow_Force[val_imarker] = val_fanface_force; } - -inline void CConfig::SetInflow_Power(unsigned short val_imarker, su2double val_fanface_power) { Inflow_Power[val_imarker] = val_fanface_power; } - -inline su2double CConfig::GetInflow_ReverseMassFlow(unsigned short val_imarker) { return Inflow_ReverseMassFlow[val_imarker]; } - -inline void CConfig::SetExhaust_Pressure(unsigned short val_imarker, su2double val_exhaust_pressure) { Exhaust_Pressure[val_imarker] = val_exhaust_pressure; } - -inline void CConfig::SetExhaust_Temperature(unsigned short val_imarker, su2double val_exhaust_temp) { Exhaust_Temperature[val_imarker] = val_exhaust_temp; } - -inline void CConfig::SetExhaust_MassFlow(unsigned short val_imarker, su2double val_exhaust_massflow) { Exhaust_MassFlow[val_imarker] = val_exhaust_massflow; } - -inline void CConfig::SetExhaust_TotalPressure(unsigned short val_imarker, su2double val_exhaust_totalpressure) { Exhaust_TotalPressure[val_imarker] = val_exhaust_totalpressure; } - -inline void CConfig::SetExhaust_TotalTemperature(unsigned short val_imarker, su2double val_exhaust_totaltemp) { Exhaust_TotalTemperature[val_imarker] = val_exhaust_totaltemp; } - -inline void CConfig::SetExhaust_GrossThrust(unsigned short val_imarker, su2double val_exhaust_grossthrust) { Exhaust_GrossThrust[val_imarker] = val_exhaust_grossthrust; } - -inline void CConfig::SetExhaust_Force(unsigned short val_imarker, su2double val_exhaust_force) { Exhaust_Force[val_imarker] = val_exhaust_force; } - -inline void CConfig::SetExhaust_Power(unsigned short val_imarker, su2double val_exhaust_power) { Exhaust_Power[val_imarker] = val_exhaust_power; } - -inline void CConfig::SetEngine_Mach(unsigned short val_imarker, su2double val_engine_mach) { Engine_Mach[val_imarker] = val_engine_mach; } - -inline void CConfig::SetEngine_Force(unsigned short val_imarker, su2double val_engine_force) { Engine_Force[val_imarker] = val_engine_force; } - -inline void CConfig::SetEngine_Power(unsigned short val_imarker, su2double val_engine_power) { Engine_Power[val_imarker] = val_engine_power; } - -inline void CConfig::SetEngine_NetThrust(unsigned short val_imarker, su2double val_engine_netthrust) { Engine_NetThrust[val_imarker] = val_engine_netthrust; } - -inline void CConfig::SetEngine_GrossThrust(unsigned short val_imarker, su2double val_engine_grossthrust) { Engine_GrossThrust[val_imarker] = val_engine_grossthrust; } - -inline void CConfig::SetEngine_Area(unsigned short val_imarker, su2double val_engine_area) { Engine_Area[val_imarker] = val_engine_area; } - -inline void CConfig::SetActDisk_DeltaPress(unsigned short val_imarker, su2double val_actdisk_deltapress) { ActDisk_DeltaPress[val_imarker] = val_actdisk_deltapress; } - -inline void CConfig::SetActDisk_Power(unsigned short val_imarker, su2double val_actdisk_power) { ActDisk_Power[val_imarker] = val_actdisk_power; } - -inline void CConfig::SetActDisk_MassFlow(unsigned short val_imarker, su2double val_actdisk_massflow) { ActDisk_MassFlow[val_imarker] = val_actdisk_massflow; } - -inline void CConfig::SetActDisk_Mach(unsigned short val_imarker, su2double val_actdisk_mach) { ActDisk_Mach[val_imarker] = val_actdisk_mach; } - -inline void CConfig::SetActDisk_Force(unsigned short val_imarker, su2double val_actdisk_force) { ActDisk_Force[val_imarker] = val_actdisk_force; } - -inline void CConfig::SetOutlet_MassFlow(unsigned short val_imarker, su2double val_massflow) { Outlet_MassFlow[val_imarker] = val_massflow; } - -inline void CConfig::SetOutlet_Density(unsigned short val_imarker, su2double val_density) { Outlet_Density[val_imarker] = val_density; } - -inline void CConfig::SetOutlet_Area(unsigned short val_imarker, su2double val_area) { Outlet_Area[val_imarker] = val_area; } - -inline void CConfig::SetSurface_DC60(unsigned short val_imarker, su2double val_surface_distortion) { Surface_DC60[val_imarker] = val_surface_distortion; } - -inline void CConfig::SetSurface_MassFlow(unsigned short val_imarker, su2double val_surface_massflow) { Surface_MassFlow[val_imarker] = val_surface_massflow; } - -inline void CConfig::SetSurface_Mach(unsigned short val_imarker, su2double val_surface_mach) { Surface_Mach[val_imarker] = val_surface_mach; } - -inline void CConfig::SetSurface_Temperature(unsigned short val_imarker, su2double val_surface_temperature) { Surface_Temperature[val_imarker] = val_surface_temperature; } - -inline void CConfig::SetSurface_Pressure(unsigned short val_imarker, su2double val_surface_pressure) { Surface_Pressure[val_imarker] = val_surface_pressure; } - -inline void CConfig::SetSurface_Density(unsigned short val_imarker, su2double val_surface_density) { Surface_Density[val_imarker] = val_surface_density; } - -inline void CConfig::SetSurface_Enthalpy(unsigned short val_imarker, su2double val_surface_enthalpy) { Surface_Enthalpy[val_imarker] = val_surface_enthalpy; } - -inline void CConfig::SetSurface_NormalVelocity(unsigned short val_imarker, su2double val_surface_normalvelocity) { Surface_NormalVelocity[val_imarker] = val_surface_normalvelocity; } - -inline void CConfig::SetSurface_Uniformity(unsigned short val_imarker, su2double val_surface_streamwiseuniformity) { Surface_Uniformity[val_imarker] = val_surface_streamwiseuniformity; } - -inline void CConfig::SetSurface_SecondaryStrength(unsigned short val_imarker, su2double val_surface_secondarystrength) { Surface_SecondaryStrength[val_imarker] = val_surface_secondarystrength; } - -inline void CConfig::SetSurface_SecondOverUniform(unsigned short val_imarker, su2double val_surface_secondaryoverstream) { Surface_SecondOverUniform[val_imarker] = val_surface_secondaryoverstream; } - -inline void CConfig::SetSurface_MomentumDistortion(unsigned short val_imarker, su2double val_surface_momentumdistortion) { Surface_MomentumDistortion[val_imarker] = val_surface_momentumdistortion; } - -inline void CConfig::SetSurface_TotalTemperature(unsigned short val_imarker, su2double val_surface_totaltemperature) { Surface_TotalTemperature[val_imarker] = val_surface_totaltemperature; } - -inline void CConfig::SetSurface_TotalPressure(unsigned short val_imarker, su2double val_surface_totalpressure) { Surface_TotalPressure[val_imarker] = val_surface_totalpressure; } - -inline void CConfig::SetSurface_PressureDrop(unsigned short val_imarker, su2double val_surface_pressuredrop) { Surface_PressureDrop[val_imarker] = val_surface_pressuredrop; } - -inline void CConfig::SetSurface_IDC(unsigned short val_imarker, su2double val_surface_distortion) { Surface_IDC[val_imarker] = val_surface_distortion; } - -inline void CConfig::SetSurface_IDC_Mach(unsigned short val_imarker, su2double val_surface_distortion) { Surface_IDC_Mach[val_imarker] = val_surface_distortion; } - -inline void CConfig::SetSurface_IDR(unsigned short val_imarker, su2double val_surface_distortion) { Surface_IDR[val_imarker] = val_surface_distortion; } - -inline void CConfig::SetActDisk_DeltaTemp(unsigned short val_imarker, su2double val_actdisk_deltatemp) { ActDisk_DeltaTemp[val_imarker] = val_actdisk_deltatemp; } - -inline void CConfig::SetActDisk_TotalPressRatio(unsigned short val_imarker, su2double val_actdisk_pressratio) { ActDisk_TotalPressRatio[val_imarker] = val_actdisk_pressratio; } - -inline void CConfig::SetActDisk_TotalTempRatio(unsigned short val_imarker, su2double val_actdisk_tempratio) { ActDisk_TotalTempRatio[val_imarker] = val_actdisk_tempratio; } - -inline void CConfig::SetActDisk_StaticPressRatio(unsigned short val_imarker, su2double val_actdisk_pressratio) { ActDisk_StaticPressRatio[val_imarker] = val_actdisk_pressratio; } - -inline void CConfig::SetActDisk_StaticTempRatio(unsigned short val_imarker, su2double val_actdisk_tempratio) { ActDisk_StaticTempRatio[val_imarker] = val_actdisk_tempratio; } - -inline void CConfig::SetActDisk_NetThrust(unsigned short val_imarker, su2double val_actdisk_netthrust) { ActDisk_NetThrust[val_imarker] = val_actdisk_netthrust; } - -inline void CConfig::SetActDisk_BCThrust(unsigned short val_imarker, su2double val_actdisk_bcthrust) { ActDisk_BCThrust[val_imarker] = val_actdisk_bcthrust; } - -inline void CConfig::SetActDisk_BCThrust_Old(unsigned short val_imarker, su2double val_actdisk_bcthrust_old) { ActDisk_BCThrust_Old[val_imarker] = val_actdisk_bcthrust_old; } - -inline void CConfig::SetActDisk_GrossThrust(unsigned short val_imarker, su2double val_actdisk_grossthrust) { ActDisk_GrossThrust[val_imarker] = val_actdisk_grossthrust; } - -inline void CConfig::SetActDisk_Area(unsigned short val_imarker, su2double val_actdisk_area) { ActDisk_Area[val_imarker] = val_actdisk_area; } - -inline void CConfig::SetActDiskInlet_ReverseMassFlow(unsigned short val_imarker, su2double val_actdisk_area) { ActDisk_ReverseMassFlow[val_imarker] = val_actdisk_area; } - -inline su2double CConfig::GetActDisk_DeltaPress(unsigned short val_imarker) { return ActDisk_DeltaPress[val_imarker]; } - -inline su2double CConfig::GetActDisk_DeltaTemp(unsigned short val_imarker) { return ActDisk_DeltaTemp[val_imarker]; } - -inline su2double CConfig::GetActDisk_TotalPressRatio(unsigned short val_imarker) { return ActDisk_TotalPressRatio[val_imarker]; } - -inline su2double CConfig::GetActDisk_TotalTempRatio(unsigned short val_imarker) { return ActDisk_TotalTempRatio[val_imarker]; } - -inline su2double CConfig::GetActDisk_StaticPressRatio(unsigned short val_imarker) { return ActDisk_StaticPressRatio[val_imarker]; } - -inline su2double CConfig::GetActDisk_StaticTempRatio(unsigned short val_imarker) { return ActDisk_StaticTempRatio[val_imarker]; } - -inline su2double CConfig::GetActDisk_Power(unsigned short val_imarker) { return ActDisk_Power[val_imarker]; } - -inline su2double CConfig::GetActDisk_MassFlow(unsigned short val_imarker) { return ActDisk_MassFlow[val_imarker]; } - -inline su2double CConfig::GetActDisk_Mach(unsigned short val_imarker) { return ActDisk_Mach[val_imarker]; } - -inline su2double CConfig::GetActDisk_Force(unsigned short val_imarker) { return ActDisk_Force[val_imarker]; } - -inline su2double CConfig::GetSurface_MassFlow(unsigned short val_imarker) { return Surface_MassFlow[val_imarker]; } - -inline su2double CConfig::GetSurface_Mach(unsigned short val_imarker) { return Surface_Mach[val_imarker]; } - -inline su2double CConfig::GetSurface_Temperature(unsigned short val_imarker) { return Surface_Temperature[val_imarker]; } - -inline su2double CConfig::GetSurface_Pressure(unsigned short val_imarker) { return Surface_Pressure[val_imarker]; } - -inline su2double CConfig::GetSurface_Density(unsigned short val_imarker) { return Surface_Density[val_imarker]; } - -inline su2double CConfig::GetSurface_Enthalpy(unsigned short val_imarker) { return Surface_Enthalpy[val_imarker]; } - -inline su2double CConfig::GetSurface_NormalVelocity(unsigned short val_imarker) { return Surface_NormalVelocity[val_imarker]; } - -inline su2double CConfig::GetSurface_Uniformity(unsigned short val_imarker) { return Surface_Uniformity[val_imarker]; } - -inline su2double CConfig::GetSurface_SecondaryStrength(unsigned short val_imarker) { return Surface_SecondaryStrength[val_imarker]; } - -inline su2double CConfig::GetSurface_SecondOverUniform(unsigned short val_imarker) { return Surface_SecondOverUniform[val_imarker]; } - -inline su2double CConfig::GetSurface_MomentumDistortion(unsigned short val_imarker) { return Surface_MomentumDistortion[val_imarker]; } - -inline su2double CConfig::GetSurface_TotalTemperature(unsigned short val_imarker) { return Surface_TotalTemperature[val_imarker]; } - -inline su2double CConfig::GetSurface_TotalPressure(unsigned short val_imarker) { return Surface_TotalPressure[val_imarker]; } - -inline su2double CConfig::GetSurface_PressureDrop(unsigned short val_imarker) { return Surface_PressureDrop[val_imarker]; } - -inline su2double CConfig::GetSurface_DC60(unsigned short val_imarker) { return Surface_DC60[val_imarker]; } - -inline su2double CConfig::GetSurface_IDC(unsigned short val_imarker) { return Surface_IDC[val_imarker]; } - -inline su2double CConfig::GetSurface_IDC_Mach(unsigned short val_imarker) { return Surface_IDC_Mach[val_imarker]; } - -inline su2double CConfig::GetSurface_IDR(unsigned short val_imarker) { return Surface_IDR[val_imarker]; } - -inline su2double CConfig::GetActDisk_NetThrust(unsigned short val_imarker) { return ActDisk_NetThrust[val_imarker]; } - -inline su2double CConfig::GetActDisk_BCThrust(unsigned short val_imarker) { return ActDisk_BCThrust[val_imarker]; } - -inline su2double CConfig::GetActDisk_BCThrust_Old(unsigned short val_imarker) { return ActDisk_BCThrust_Old[val_imarker]; } - -inline su2double CConfig::GetActDisk_GrossThrust(unsigned short val_imarker) { return ActDisk_GrossThrust[val_imarker]; } - -inline su2double CConfig::GetActDisk_Area(unsigned short val_imarker) { return ActDisk_Area[val_imarker]; } - -inline su2double CConfig::GetActDisk_ReverseMassFlow(unsigned short val_imarker) { return ActDisk_ReverseMassFlow[val_imarker]; } - -inline void CConfig::SetActDiskInlet_Pressure(unsigned short val_imarker, su2double val_actdisk_press) { ActDiskInlet_Pressure[val_imarker] = val_actdisk_press; } - -inline void CConfig::SetActDiskInlet_TotalPressure(unsigned short val_imarker, su2double val_actdisk_totalpress) { ActDiskInlet_TotalPressure[val_imarker] = val_actdisk_totalpress; } - -inline void CConfig::SetActDiskInlet_RamDrag(unsigned short val_imarker, su2double val_actdisk_ramdrag) { ActDiskInlet_RamDrag[val_imarker] = val_actdisk_ramdrag; } - -inline void CConfig::SetActDiskInlet_Force(unsigned short val_imarker, su2double val_actdisk_force) { ActDiskInlet_Force[val_imarker] = val_actdisk_force; } - -inline void CConfig::SetActDiskInlet_Power(unsigned short val_imarker, su2double val_actdisk_power) { ActDiskInlet_Power[val_imarker] = val_actdisk_power; } - -inline void CConfig::SetActDiskInlet_Temperature(unsigned short val_imarker, su2double val_actdisk_temp) { ActDiskInlet_Temperature[val_imarker] = val_actdisk_temp; } - -inline void CConfig::SetActDiskInlet_TotalTemperature(unsigned short val_imarker, su2double val_actdisk_totaltemp) { ActDiskInlet_TotalTemperature[val_imarker] = val_actdisk_totaltemp; } - -inline void CConfig::SetActDiskInlet_MassFlow(unsigned short val_imarker, su2double val_actdisk_massflow) { ActDiskInlet_MassFlow[val_imarker] = val_actdisk_massflow; } - -inline void CConfig::SetActDiskOutlet_Pressure(unsigned short val_imarker, su2double val_actdisk_press) { ActDiskOutlet_Pressure[val_imarker] = val_actdisk_press; } - -inline void CConfig::SetActDiskOutlet_TotalPressure(unsigned short val_imarker, su2double val_actdisk_totalpress) { ActDiskOutlet_TotalPressure[val_imarker] = val_actdisk_totalpress; } - -inline void CConfig::SetActDiskOutlet_GrossThrust(unsigned short val_imarker, su2double val_actdisk_grossthrust) { ActDiskOutlet_GrossThrust[val_imarker] = val_actdisk_grossthrust; } - -inline void CConfig::SetActDiskOutlet_Force(unsigned short val_imarker, su2double val_actdisk_force) { ActDiskOutlet_Force[val_imarker] = val_actdisk_force; } - -inline void CConfig::SetActDiskOutlet_Power(unsigned short val_imarker, su2double val_actdisk_power) { ActDiskOutlet_Power[val_imarker] = val_actdisk_power; } - -inline void CConfig::SetActDiskOutlet_Temperature(unsigned short val_imarker, su2double val_actdisk_temp) { ActDiskOutlet_Temperature[val_imarker] = val_actdisk_temp; } - -inline void CConfig::SetActDiskOutlet_TotalTemperature(unsigned short val_imarker, su2double val_actdisk_totaltemp) { ActDiskOutlet_TotalTemperature[val_imarker] = val_actdisk_totaltemp; } - -inline void CConfig::SetActDiskOutlet_MassFlow(unsigned short val_imarker, su2double val_actdisk_massflow) { ActDiskOutlet_MassFlow[val_imarker] = val_actdisk_massflow; } - -inline su2double CConfig::GetEngine_Mach(unsigned short val_imarker) { return Engine_Mach[val_imarker]; } - -inline su2double CConfig::GetEngine_Force(unsigned short val_imarker) { return Engine_Force[val_imarker]; } - -inline su2double CConfig::GetEngine_Power(unsigned short val_imarker) { return Engine_Power[val_imarker]; } - -inline su2double CConfig::GetEngine_NetThrust(unsigned short val_imarker) { return Engine_NetThrust[val_imarker]; } - -inline su2double CConfig::GetEngine_GrossThrust(unsigned short val_imarker) { return Engine_GrossThrust[val_imarker]; } - -inline su2double CConfig::GetEngine_Area(unsigned short val_imarker) { return Engine_Area[val_imarker]; } - -inline unsigned short CConfig::GetnZone(void) { return nZone; } - -inline unsigned short CConfig::GetiZone(void) { return iZone; } - -inline unsigned short CConfig::GetKind_SU2(void) { return Kind_SU2; } - -inline unsigned short CConfig::GetRef_NonDim(void) { return Ref_NonDim; } - -inline unsigned short CConfig::GetRef_Inc_NonDim(void) { return Ref_Inc_NonDim; } - -inline void CConfig::SetKind_SU2(unsigned short val_kind_su2) { Kind_SU2 = val_kind_su2 ; } - -inline bool CConfig::GetContinuous_Adjoint(void) { return ContinuousAdjoint; } - -inline bool CConfig::GetViscous(void) { return Viscous; } - -inline unsigned short CConfig::GetnTimeInstances(void) { return nTimeInstances; } - -inline su2double CConfig::GetHarmonicBalance_Period(void) { return HarmonicBalance_Period; } - -inline void CConfig::SetExtIter_OffSet(unsigned long val_iter) { ExtIter_OffSet = val_iter; } - -inline void CConfig::SetOuterIter(unsigned long val_iter) { OuterIter = val_iter; } - -inline void CConfig::SetInnerIter(unsigned long val_iter) { InnerIter = val_iter; } - -inline void CConfig::SetTimeIter(unsigned long val_iter) { TimeIter = val_iter; } - -inline unsigned long CConfig::GetExtIter_OffSet(void) { return ExtIter_OffSet; } - -inline unsigned long CConfig::GetOuterIter(void) { return OuterIter; } - -inline unsigned long CConfig::GetInnerIter(void) { return InnerIter; } - -inline unsigned long CConfig::GetTimeIter(void) { return TimeIter; } - -inline unsigned long CConfig::GetUnst_nIntIter(void) { return Unst_nIntIter; } - -inline unsigned long CConfig::GetDyn_nIntIter(void) { return Dyn_nIntIter; } - -inline long CConfig::GetUnst_AdjointIter(void) { return Unst_AdjointIter; } - -inline void CConfig::SetPhysicalTime(su2double val_t) { PhysicalTime = val_t; } - -inline su2double CConfig::GetPhysicalTime(void) { return PhysicalTime; } - -inline bool CConfig::GetReorientElements(void) { return ReorientElements; } - -inline unsigned long CConfig::GetIter_Avg_Objective(void) { return Iter_Avg_Objective ; } - -inline string CConfig::GetPlaneTag(unsigned short index) { return PlaneTag[index]; } - -inline su2double CConfig::GetEA_IntLimit(unsigned short index) { return EA_IntLimit[index]; } - -inline su2double CConfig::GetEA_ScaleFactor(void) { return EA_ScaleFactor; } - -inline su2double CConfig::GetAdjointLimit(void) { return AdjointLimit; } - -inline su2double *CConfig::GetHold_GridFixed_Coord(void) { return Hold_GridFixed_Coord; } - -inline su2double *CConfig::GetSubsonicEngine_Cyl(void) { return SubsonicEngine_Cyl; } - -inline su2double *CConfig::GetSubsonicEngine_Values(void) { return SubsonicEngine_Values; } - -inline su2double *CConfig::GetDistortionRack(void) { return DistortionRack; } - -inline unsigned short CConfig::GetAnalytical_Surface(void) { return Analytical_Surface; } - -inline unsigned short CConfig::GetGeo_Description(void) { return Geo_Description; } - -inline su2double CConfig::GetDualVol_Power(void) { return DualVol_Power; } - -inline bool CConfig::GetExtraOutput(void) { return ExtraOutput; } - -inline long CConfig::GetExtraHeatOutputZone(void) { return ExtraHeatOutputZone; } - -inline su2double CConfig::GetRefArea(void) { return RefArea; } - -inline su2double CConfig::GetThermalDiffusivity(void) { return Thermal_Diffusivity; } - -inline su2double CConfig::GetThermalDiffusivity_Solid(void) { return Thermal_Diffusivity_Solid; } - -inline su2double CConfig::GetTemperature_Initial_Solid(void) { return Temperature_Freestream_Solid; } - -inline su2double CConfig::GetElasticyMod(unsigned short id_val) { return ElasticityMod[id_val]; } - -inline bool CConfig::GetDE_Effects(void) { return DE_Effects; } - -inline unsigned short CConfig::GetnElectric_Constant(void) { return nElectric_Constant; } - -inline su2double CConfig::GetElectric_Constant(unsigned short iVar) { return Electric_Constant[iVar]; } - -inline su2double CConfig::GetKnowles_B(void) { return Knowles_B; } - -inline su2double CConfig::GetKnowles_N(void) { return Knowles_N; } - -inline unsigned short CConfig::GetDV_FEA(void) { return Kind_DV_FEA; } - -inline unsigned long CConfig::GetRefNode_ID(void) { return refNodeID; } - -inline su2double CConfig::GetRefNode_Displacement(unsigned short val_coeff) { return RefNode_Displacement[val_coeff]; } - -inline su2double CConfig::GetRefNode_Penalty(void) { return RefNode_Penalty; } - -inline bool CConfig::GetRefGeom(void) { return RefGeom; } - -inline string CConfig::GetRefGeom_FEMFileName(void) { return RefGeom_FEMFileName; } - -inline unsigned short CConfig::GetRefGeom_FileFormat(void) { return RefGeom_FileFormat; } - -inline unsigned short CConfig::GetElas2D_Formulation(void) { return Kind_2DElasForm; } - -inline su2double CConfig::GetPoissonRatio(unsigned short id_val) { return PoissonRatio[id_val]; } - -inline su2double CConfig::GetMaterialDensity(unsigned short id_val) { return MaterialDensity[id_val]; } - -inline unsigned short CConfig::GetnElasticityMod(void) { return nElasticityMod; } - -inline unsigned short CConfig::GetnPoissonRatio(void) { return nPoissonRatio; } - -inline unsigned short CConfig::GetnMaterialDensity(void) { return nMaterialDensity; } - -inline unsigned short CConfig::GetMaterialCompressibility(void) { return Kind_Material_Compress; } - -inline unsigned short CConfig::GetMaterialModel(void) { return Kind_Material; } - -inline unsigned short CConfig::GetGeometricConditions(void) { return Kind_Struct_Solver; } - -inline bool CConfig::GetPrestretch(void) { return Prestretch; } - -inline bool CConfig::Add_CrossTerm(void) { return addCrossTerm; } - -inline void CConfig::Set_CrossTerm(bool needCrossTerm) { addCrossTerm = needCrossTerm; } - -inline string CConfig::GetFEA_FileName(void) { return FEA_FileName; } - -inline string CConfig::GetPrestretch_FEMFileName(void) { return Prestretch_FEMFileName; } - -inline su2double CConfig::GetRefLength(void) { return RefLength; } - -inline su2double CConfig::GetRefElemLength(void) { return RefElemLength; } - -inline su2double CConfig::GetRefSharpEdges(void) { return RefSharpEdges; } - -inline su2double CConfig::GetDomainVolume(void) { return DomainVolume; } - -inline void CConfig::SetRefArea(su2double val_area) { RefArea = val_area; } - -inline void CConfig::SetSemiSpan(su2double val_semispan) { SemiSpan = val_semispan; } - -inline void CConfig::SetDomainVolume(su2double val_volume) { DomainVolume = val_volume; } - -inline su2double CConfig::GetMach(void) { return Mach; } - -inline su2double CConfig::GetGamma(void) { return Gamma; } - -inline su2double CConfig::GetStations_Bounds(unsigned short val_var) { return Stations_Bounds[val_var]; } - -inline su2double CConfig::GetFFD_Axis(unsigned short val_var) { return FFD_Axis[val_var]; } - -inline su2double CConfig::GetBulk_Modulus(void) { return Bulk_Modulus; } - -inline su2double CConfig::GetBeta_Factor(void) { return Beta_Factor; } - -inline su2double CConfig::GetGas_Constant(void) { return Gas_Constant; } - -inline su2double CConfig::GetGas_ConstantND(void) { return Gas_ConstantND; } - -inline su2double CConfig::GetMolecular_Weight(void) { return Molecular_Weight; } - -inline su2double CConfig::GetSpecific_Heat_Cp(void) { return Specific_Heat_Cp; } - -inline su2double CConfig::GetSpecific_Heat_CpND(void) { return Specific_Heat_CpND; } - -inline su2double CConfig::GetSpecific_Heat_Cv(void) { return Specific_Heat_Cv; } - -inline su2double CConfig::GetSpecific_Heat_CvND(void) { return Specific_Heat_CvND; } - -inline su2double CConfig::GetThermal_Expansion_Coeff(void) { return Thermal_Expansion_Coeff; } - -inline su2double CConfig::GetThermal_Expansion_CoeffND(void) { return Thermal_Expansion_CoeffND; } - -inline su2double CConfig::GetInc_Density_Ref(void) { return Inc_Density_Ref; } - -inline su2double CConfig::GetInc_Velocity_Ref(void) { return Inc_Velocity_Ref; } - -inline su2double CConfig::GetInc_Temperature_Ref(void) { return Inc_Temperature_Ref; } - -inline su2double CConfig::GetInc_Density_Init(void) { return Inc_Density_Init; } - -inline su2double* CConfig::GetInc_Velocity_Init(void) { return Inc_Velocity_Init; } - -inline su2double CConfig::GetInc_Temperature_Init(void) { return Inc_Temperature_Init; } - -inline su2double CConfig::GetHeat_Flux_Ref(void) { return Heat_Flux_Ref; } - -inline su2double CConfig::GetWallTemperature(void) { return Wall_Temperature; } - -inline su2double CConfig::GetGas_Constant_Ref(void) { return Gas_Constant_Ref; } - -inline su2double CConfig::GetTemperature_FreeStream(void) { return Temperature_FreeStream; } - -inline su2double CConfig::GetEnergy_FreeStream(void) { return Energy_FreeStream; } - -inline su2double CConfig::GetViscosity_FreeStream(void) { return Viscosity_FreeStream; } - -inline su2double CConfig::GetDensity_FreeStream(void) { return Density_FreeStream; } - -inline su2double CConfig::GetDensity_Solid(void) { return Density_Solid; } - -inline su2double CConfig::GetModVel_FreeStream(void) { return ModVel_FreeStream; } - -inline su2double CConfig::GetModVel_FreeStreamND(void) { return ModVel_FreeStreamND; } - -inline su2double CConfig::GetPressure_FreeStream(void) { return Pressure_FreeStream; } - -inline su2double CConfig::GetPressure_Thermodynamic(void) { return Pressure_Thermodynamic; } - -inline su2double CConfig::GetTemperature_ve_FreeStream(void) { return Temperature_ve_FreeStream; } - -inline su2double CConfig::GetPrandtl_Lam(void) { return Prandtl_Lam; } - -inline su2double CConfig::GetPrandtl_Turb(void) { return Prandtl_Turb; } - -inline su2double CConfig::GetThermalConductivity_Solid(void) { return Thermal_Conductivity_Solid; } - -inline su2double CConfig::GetLength_Ref(void) { return Length_Ref; } - -inline su2double CConfig::GetPressure_Ref(void) { return Pressure_Ref; } - -inline su2double CConfig::GetTemperature_Ref(void) { return Temperature_Ref; } - -inline su2double CConfig::GetDensity_Ref(void) { return Density_Ref; } - -inline su2double CConfig::GetVelocity_Ref(void) { return Velocity_Ref; } - -inline su2double CConfig::GetEnergy_Ref(void) { return Energy_Ref; } - -inline su2double CConfig::GetTime_Ref(void) { return Time_Ref; } - -inline su2double CConfig::GetViscosity_Ref(void) { return Viscosity_Ref; } - -inline su2double CConfig::GetConductivity_Ref(void) { return Conductivity_Ref; } - -inline su2double CConfig::GetHighlite_Area(void) { return Highlite_Area; } - -inline su2double CConfig::GetFan_Poly_Eff(void) { return Fan_Poly_Eff; } - -inline su2double CConfig::GetOmega_Ref(void) { return Omega_Ref; } - -inline su2double CConfig::GetForce_Ref(void) { return Force_Ref; } - -inline su2double CConfig::GetPressure_FreeStreamND(void) { return Pressure_FreeStreamND; } - -inline su2double CConfig::GetPressure_ThermodynamicND(void) { return Pressure_ThermodynamicND; } - -inline su2double CConfig::GetTemperature_FreeStreamND(void) { return Temperature_FreeStreamND; } - -inline su2double CConfig::GetDensity_FreeStreamND(void) { return Density_FreeStreamND; } - -inline su2double* CConfig::GetVelocity_FreeStreamND(void) { return Velocity_FreeStreamND; } - -inline su2double* CConfig::GetVelocity_FreeStream(void) { return Velocity_FreeStream; } - -inline su2double CConfig::GetEnergy_FreeStreamND(void) { return Energy_FreeStreamND; } - -inline su2double CConfig::GetViscosity_FreeStreamND(void) { return Viscosity_FreeStreamND; } - -inline su2double CConfig::GetTke_FreeStreamND(void) { return Tke_FreeStreamND; } - -inline su2double CConfig::GetOmega_FreeStreamND(void) { return Omega_FreeStreamND; } - -inline su2double CConfig::GetTke_FreeStream(void) { return Tke_FreeStream; } - -inline su2double CConfig::GetOmega_FreeStream(void) { return Omega_FreeStream; } - -inline su2double CConfig::GetNuFactor_FreeStream(void) { return NuFactor_FreeStream; } - -inline su2double CConfig::GetNuFactor_Engine(void) { return NuFactor_Engine; } - -inline su2double CConfig::GetSecondaryFlow_ActDisk(void) { return SecondaryFlow_ActDisk; } - -inline su2double CConfig::GetInitial_BCThrust(void) { return Initial_BCThrust; } - -inline void CConfig::SetInitial_BCThrust(su2double val_bcthrust) { Initial_BCThrust = val_bcthrust; } - -inline su2double CConfig::GetIntermittency_FreeStream(void) { return Intermittency_FreeStream; } - -inline su2double CConfig::GetTurbulenceIntensity_FreeStream(void) { return TurbulenceIntensity_FreeStream; } - -inline su2double CConfig::GetTurb2LamViscRatio_FreeStream(void) { return Turb2LamViscRatio_FreeStream;} - -inline su2double* CConfig::GetMassFrac_FreeStream(void) { return MassFrac_FreeStream; } - -inline su2double CConfig::GetLength_Reynolds(void) { return Length_Reynolds; } - -inline unsigned short CConfig::GetnStartUpIter(void) { return nStartUpIter; } - -inline su2double *CConfig::GetRefOriginMoment(unsigned short val_marker) { - if(val_marker < nMarker_Monitoring) { - RefOriginMoment[0] = RefOriginMoment_X[val_marker]; - RefOriginMoment[1] = RefOriginMoment_Y[val_marker]; - RefOriginMoment[2] = RefOriginMoment_Z[val_marker]; - } - return RefOriginMoment; -} - -inline su2double CConfig::GetRefOriginMoment_X(unsigned short val_marker) { return RefOriginMoment_X[val_marker]; } - -inline su2double CConfig::GetRefOriginMoment_Y(unsigned short val_marker) { return RefOriginMoment_Y[val_marker]; } - -inline su2double CConfig::GetRefOriginMoment_Z(unsigned short val_marker) { return RefOriginMoment_Z[val_marker]; } - -inline void CConfig::SetRefOriginMoment_X(unsigned short val_marker, su2double val_origin) { RefOriginMoment_X[val_marker] = val_origin; } - -inline void CConfig::SetRefOriginMoment_Y(unsigned short val_marker, su2double val_origin) { RefOriginMoment_Y[val_marker] = val_origin; } - -inline void CConfig::SetRefOriginMoment_Z(unsigned short val_marker, su2double val_origin) { RefOriginMoment_Z[val_marker] = val_origin; } - -inline su2double CConfig::GetChargeCoeff(void) { return ChargeCoeff; } - -inline su2double CConfig::GetVenkat_LimiterCoeff(void) { return Venkat_LimiterCoeff; } - -inline unsigned long CConfig::GetLimiterIter(void) { return LimiterIter; } - -inline su2double CConfig::GetAdjSharp_LimiterCoeff(void) { return AdjSharp_LimiterCoeff; } - -inline su2double CConfig::GetReynolds(void) { return Reynolds; } - -inline su2double CConfig::GetFroude(void) { return Froude; } - -inline void CConfig::SetPressure_FreeStreamND(su2double val_pressure_freestreamnd) { Pressure_FreeStreamND = val_pressure_freestreamnd; } - -inline void CConfig::SetPressure_FreeStream(su2double val_pressure_freestream) { Pressure_FreeStream = val_pressure_freestream; } - -inline void CConfig::SetPressure_ThermodynamicND(su2double val_pressure_thermodynamicnd) { Pressure_ThermodynamicND = val_pressure_thermodynamicnd; } - -inline void CConfig::SetPressure_Thermodynamic(su2double val_pressure_thermodynamic) { Pressure_Thermodynamic = val_pressure_thermodynamic; } - -inline void CConfig::SetDensity_FreeStreamND(su2double val_density_freestreamnd) { Density_FreeStreamND = val_density_freestreamnd; } - -inline void CConfig::SetDensity_FreeStream(su2double val_density_freestream) { Density_FreeStream = val_density_freestream; } - -inline void CConfig::SetViscosity_FreeStream(su2double val_viscosity_freestream) { Viscosity_FreeStream = val_viscosity_freestream; } - -inline void CConfig::SetModVel_FreeStream(su2double val_modvel_freestream) { ModVel_FreeStream = val_modvel_freestream; } - -inline void CConfig::SetModVel_FreeStreamND(su2double val_modvel_freestreamnd) { ModVel_FreeStreamND = val_modvel_freestreamnd; } - -inline void CConfig::SetTemperature_FreeStream(su2double val_temperature_freestream) { Temperature_FreeStream = val_temperature_freestream; } - -inline void CConfig::SetTemperature_FreeStreamND(su2double val_temperature_freestreamnd) { Temperature_FreeStreamND = val_temperature_freestreamnd; } - -inline void CConfig::SetGas_ConstantND(su2double val_gas_constantnd) { Gas_ConstantND = val_gas_constantnd; } - -inline void CConfig::SetSpecific_Heat_CpND(su2double val_specific_heat_cpnd) { Specific_Heat_CpND = val_specific_heat_cpnd; } - -inline void CConfig::SetSpecific_Heat_CvND(su2double val_specific_heat_cvnd) { Specific_Heat_CvND = val_specific_heat_cvnd; } - -inline void CConfig::SetThermal_Expansion_CoeffND(su2double val_thermal_expansion_coeffnd) { Thermal_Expansion_CoeffND = val_thermal_expansion_coeffnd; } - -inline void CConfig::SetVelocity_FreeStream(su2double val_velocity_freestream, unsigned short val_dim) { Velocity_FreeStream[val_dim] = val_velocity_freestream; } - -inline void CConfig::SetVelocity_FreeStreamND(su2double val_velocity_freestreamnd, unsigned short val_dim) { Velocity_FreeStreamND[val_dim] = val_velocity_freestreamnd; } - -inline void CConfig::SetViscosity_FreeStreamND(su2double val_viscosity_freestreamnd) { Viscosity_FreeStreamND = val_viscosity_freestreamnd; } - -inline void CConfig::SetTke_FreeStreamND(su2double val_tke_freestreamnd) { Tke_FreeStreamND = val_tke_freestreamnd; } - -inline void CConfig::SetOmega_FreeStreamND(su2double val_omega_freestreamnd) { Omega_FreeStreamND = val_omega_freestreamnd; } - -inline void CConfig::SetTke_FreeStream(su2double val_tke_freestream) { Tke_FreeStream = val_tke_freestream; } - -inline void CConfig::SetOmega_FreeStream(su2double val_omega_freestream) { Omega_FreeStream = val_omega_freestream; } - -inline void CConfig::SetEnergy_FreeStreamND(su2double val_energy_freestreamnd) { Energy_FreeStreamND = val_energy_freestreamnd; } - -inline void CConfig::SetEnergy_FreeStream(su2double val_energy_freestream) { Energy_FreeStream = val_energy_freestream; } - -inline void CConfig::SetTotal_UnstTimeND(su2double val_total_unsttimend) { Total_UnstTimeND = val_total_unsttimend; } - -inline void CConfig::SetFroude(su2double val_froude) { Froude = val_froude; } - -inline void CConfig::SetReynolds(su2double val_reynolds) { Reynolds = val_reynolds; } - -inline void CConfig::SetMach(su2double val_mach) { Mach = val_mach; } - -inline void CConfig::SetLength_Ref(su2double val_length_ref) { Length_Ref = val_length_ref; } - -inline void CConfig::SetVelocity_Ref(su2double val_velocity_ref) { Velocity_Ref = val_velocity_ref; } - -inline void CConfig::SetPressure_Ref(su2double val_pressure_ref) { Pressure_Ref = val_pressure_ref; } - -inline void CConfig::SetDensity_Ref(su2double val_density_ref) { Density_Ref = val_density_ref; } - -inline void CConfig::SetTemperature_Ref(su2double val_temperature_ref) { Temperature_Ref = val_temperature_ref; } - -inline void CConfig::SetTime_Ref(su2double val_time_ref) { Time_Ref = val_time_ref; } - -inline void CConfig::SetOmega_Ref(su2double val_omega_ref) { Omega_Ref = val_omega_ref; } - -inline void CConfig::SetForce_Ref(su2double val_force_ref) { Force_Ref = val_force_ref; } - -inline void CConfig::SetGas_Constant_Ref(su2double val_gas_constant_ref) { Gas_Constant_Ref = val_gas_constant_ref; } - -inline void CConfig::SetGas_Constant(su2double val_gas_constant) { Gas_Constant = val_gas_constant; } - -inline void CConfig::SetSpecific_Heat_Cp(su2double val_specific_heat_cp) { Specific_Heat_Cp = val_specific_heat_cp; } - -inline void CConfig::SetSpecific_Heat_Cv(su2double val_specific_heat_cv) { Specific_Heat_Cv = val_specific_heat_cv; } - -inline void CConfig::SetThermal_Expansion_Coeff(su2double val_thermal_expansion_coeff) { Thermal_Expansion_Coeff = val_thermal_expansion_coeff; } - -inline void CConfig::SetHeat_Flux_Ref(su2double val_heat_flux_ref) { Heat_Flux_Ref = val_heat_flux_ref; } - -inline void CConfig::SetViscosity_Ref(su2double val_viscosity_ref) { Viscosity_Ref = val_viscosity_ref; } - -inline void CConfig::SetConductivity_Ref(su2double val_conductivity_ref) { Conductivity_Ref = val_conductivity_ref; } - -inline void CConfig::SetEnergy_Ref(su2double val_energy_ref) { Energy_Ref = val_energy_ref; } - -inline void CConfig::SetThermalDiffusivity_Solid(su2double val_thermal_diffusivity) { Thermal_Diffusivity_Solid = val_thermal_diffusivity; } - -inline su2double CConfig::GetAoA(void) { return AoA; } - -inline void CConfig::SetAoA(su2double val_AoA) { AoA = val_AoA; } - -inline void CConfig::SetAoA_Offset(su2double val_AoA_offset) { AoA_Offset = val_AoA_offset; } - -inline void CConfig::SetAoS_Offset(su2double val_AoS_offset) { AoS_Offset = val_AoS_offset; } - -inline void CConfig::SetAoA_Sens(su2double val_AoA_sens) { AoA_Sens = val_AoA_sens; } - -inline void CConfig::SetAoS(su2double val_AoS) { AoS = val_AoS; } - -inline su2double CConfig::GetAoS(void) { return AoS; } - -inline su2double CConfig::GetAoA_Offset(void) { return AoA_Offset; } - -inline su2double CConfig::GetAoS_Offset(void) { return AoS_Offset; } - -inline su2double CConfig::GetAoA_Sens(void) { return AoA_Sens; } - -inline unsigned short CConfig::GetnMGLevels(void) { return nMGLevels; } - -inline void CConfig::SetMGLevels(unsigned short val_nMGLevels) { nMGLevels = val_nMGLevels; } - -inline unsigned short CConfig::GetFinestMesh(void) { return FinestMesh; } - -inline void CConfig::SetFinestMesh(unsigned short val_finestmesh) { FinestMesh = val_finestmesh; } - -inline void CConfig::SubtractFinestMesh(void) { FinestMesh = FinestMesh-1; } - -inline unsigned short CConfig::GetDesign_Variable(unsigned short val_dv) { return Design_Variable[val_dv]; } - -inline bool CConfig::GetBuffet_Monitoring(void) { return Buffet_Monitoring; } - -inline su2double CConfig::GetBuffet_k(void) { return Buffet_k; } - -inline su2double CConfig::GetBuffet_lambda(void) { return Buffet_lambda; } - -inline unsigned short CConfig::GetConvCriteria(void) { return ConvCriteria; } - -inline unsigned short CConfig::GetMGCycle(void) { return MGCycle; } - -inline unsigned short CConfig::GetGeometryMode(void) { return GeometryMode; } - -inline su2double CConfig::GetCFL(unsigned short val_mesh) { return CFL[val_mesh]; } - -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; } - -inline su2double CConfig::GetMax_DeltaTime(void) { return Max_DeltaTime; } - -inline su2double CConfig::GetParamDV(unsigned short val_dv, unsigned short val_param) { return ParamDV[val_dv][val_param]; } - -inline su2double CConfig::GetCoordFFDBox(unsigned short val_ffd, unsigned short val_index) { return CoordFFDBox[val_ffd][val_index]; } - -inline unsigned short CConfig::GetDegreeFFDBox(unsigned short val_ffd, unsigned short val_index) { return DegreeFFDBox[val_ffd][val_index]; } - -inline string CConfig::GetFFDTag(unsigned short val_dv) { return FFDTag[val_dv]; } - -inline string CConfig::GetTagFFDBox(unsigned short val_ffd) { return TagFFDBox[val_ffd]; } - -inline unsigned short CConfig::GetnDV(void) { return nDV; } - -inline unsigned short CConfig::GetnDV_Value(unsigned short iDV) { return nDV_Value[iDV]; } - -inline unsigned short CConfig::GetnFFDBox(void) { return nFFDBox; } - -inline unsigned short CConfig::GetFFD_Continuity(void) { return FFD_Continuity; } - -inline unsigned short CConfig::GetFFD_CoordSystem(void) { return FFD_CoordSystem; } - -inline unsigned short CConfig::GetnRKStep(void) { return nRKStep; } - -inline unsigned short CConfig::GetnLevels_TimeAccurateLTS(void) { return nLevels_TimeAccurateLTS; } - -inline void CConfig::SetnLevels_TimeAccurateLTS(unsigned short val_nLevels) {nLevels_TimeAccurateLTS = val_nLevels;} - -inline unsigned short CConfig::GetnTimeDOFsADER_DG(void) { return nTimeDOFsADER_DG; } - -inline su2double *CConfig::GetTimeDOFsADER_DG(void) { return TimeDOFsADER_DG; } - -inline unsigned short CConfig::GetnTimeIntegrationADER_DG(void) { return nTimeIntegrationADER_DG; } - -inline su2double *CConfig::GetTimeIntegrationADER_DG(void) { return TimeIntegrationADER_DG; } - -inline su2double *CConfig::GetWeightsIntegrationADER_DG(void) { return WeightsIntegrationADER_DG; } - -inline su2double CConfig::Get_Alpha_RKStep(unsigned short val_step) { return RK_Alpha_Step[val_step]; } - -inline su2double CConfig::GetLocationStations(unsigned short val_section) { return LocationStations[val_section]; } - -inline su2double CConfig::GetNacelleLocation(unsigned short val_index) { return NacelleLocation[val_index]; } - -inline unsigned short CConfig::GetnFFD_Fix_IDir(void) { return nFFD_Fix_IDir; } - -inline unsigned short CConfig::GetnFFD_Fix_JDir(void) { return nFFD_Fix_JDir; } - -inline unsigned short CConfig::GetnFFD_Fix_KDir(void) { return nFFD_Fix_KDir; } - -inline short CConfig::GetFFD_Fix_IDir(unsigned short val_index) { return FFD_Fix_IDir[val_index]; } - -inline short CConfig::GetFFD_Fix_JDir(unsigned short val_index) { return FFD_Fix_JDir[val_index]; } - -inline short CConfig::GetFFD_Fix_KDir(unsigned short val_index) { return FFD_Fix_KDir[val_index]; } - -inline unsigned short CConfig::GetMG_PreSmooth(unsigned short val_mesh) { - if (nMG_PreSmooth == 0) return 1; - else return MG_PreSmooth[val_mesh]; -} - -inline unsigned short CConfig::GetMG_PostSmooth(unsigned short val_mesh) { - if (nMG_PostSmooth == 0) return 0; - else return MG_PostSmooth[val_mesh]; -} - -inline unsigned short CConfig::GetMG_CorrecSmooth(unsigned short val_mesh) { - if (nMG_CorrecSmooth == 0) return 0; - else return MG_CorrecSmooth[val_mesh]; -} - -inline unsigned long CConfig::GetWrt_Sol_Freq(void) { return Wrt_Sol_Freq; } - -inline unsigned long CConfig::GetWrt_Sol_Freq_DualTime(void) { return Wrt_Sol_Freq_DualTime; } - -inline unsigned long CConfig::GetWrt_Con_Freq(void) { return Wrt_Con_Freq; } - -inline void CConfig::SetWrt_Con_Freq(unsigned long val_freq) { Wrt_Con_Freq = val_freq; } - -inline unsigned long CConfig::GetWrt_Con_Freq_DualTime(void) { return Wrt_Con_Freq_DualTime; } - -inline unsigned short CConfig::GetKind_Solver(void) { return Kind_Solver; } - -inline void CConfig::SetKind_Solver(unsigned short val_solver) { Kind_Solver = val_solver; } - -inline unsigned short CConfig::GetKind_MZSolver(void) { return Kind_MZSolver; } - -inline unsigned short CConfig::GetKind_Regime(void) { return Kind_Regime; } - -inline unsigned short CConfig::GetSystemMeasurements(void) { return SystemMeasurements; } - -inline unsigned short CConfig::GetKind_GasModel(void) { return Kind_GasModel; } - -inline unsigned short CConfig::GetKind_FluidModel(void) { return Kind_FluidModel; } - -inline unsigned short CConfig::GetKind_FreeStreamOption(void) { return Kind_FreeStreamOption; } - -inline unsigned short CConfig::GetKind_DensityModel(void) { return Kind_DensityModel; } - -inline bool CConfig::GetEnergy_Equation(void) { return Energy_Equation; } - -inline unsigned short CConfig::GetKind_InitOption(void) { return Kind_InitOption; } - -inline su2double CConfig::GetPressure_Critical(void) { return Pressure_Critical; } - -inline su2double CConfig::GetTemperature_Critical(void) { return Temperature_Critical; } - -inline su2double CConfig::GetAcentric_Factor(void) { return Acentric_Factor; } - -inline unsigned short CConfig::GetKind_ViscosityModel(void) { return Kind_ViscosityModel; } - -inline unsigned short CConfig::GetKind_ConductivityModel(void) { return Kind_ConductivityModel; } - -inline unsigned short CConfig::GetKind_ConductivityModel_Turb(void) { return Kind_ConductivityModel_Turb; } - -inline su2double CConfig::GetMu_Constant(void) { return Mu_Constant; } - -inline su2double CConfig::GetMu_ConstantND(void) { return Mu_ConstantND; } - -inline su2double CConfig::GetKt_Constant(void) { return Kt_Constant; } - -inline su2double CConfig::GetKt_ConstantND(void) { return Kt_ConstantND; } - -inline su2double CConfig::GetMu_Ref(void) { return Mu_Ref; } - -inline su2double CConfig::GetMu_RefND(void) { return Mu_RefND; } - -inline su2double CConfig::GetMu_Temperature_Ref(void) { return Mu_Temperature_Ref; } - -inline su2double CConfig::GetMu_Temperature_RefND(void) { return Mu_Temperature_RefND; } - -inline su2double CConfig::GetMu_S(void) { return Mu_S; } - -inline su2double CConfig::GetMu_SND(void) { return Mu_SND; } - -inline unsigned short CConfig::GetnPolyCoeffs(void) { return nPolyCoeffs; } - -inline su2double CConfig::GetCp_PolyCoeff(unsigned short val_index) { return CpPolyCoefficients[val_index]; } - -inline su2double CConfig::GetCp_PolyCoeffND(unsigned short val_index) { return CpPolyCoefficientsND[val_index]; } - -inline su2double CConfig::GetMu_PolyCoeff(unsigned short val_index) { return MuPolyCoefficients[val_index]; } - -inline su2double CConfig::GetMu_PolyCoeffND(unsigned short val_index) { return MuPolyCoefficientsND[val_index]; } - -inline su2double* CConfig::GetMu_PolyCoeffND(void) { return MuPolyCoefficientsND; } - -inline su2double CConfig::GetKt_PolyCoeff(unsigned short val_index) { return KtPolyCoefficients[val_index]; } - -inline su2double CConfig::GetKt_PolyCoeffND(unsigned short val_index) { return KtPolyCoefficientsND[val_index]; } - -inline su2double* CConfig::GetKt_PolyCoeffND(void) { return KtPolyCoefficientsND; } - -inline void CConfig::SetMu_ConstantND(su2double mu_const) { Mu_ConstantND = mu_const; } - -inline void CConfig::SetMu_RefND(su2double mu_ref) { Mu_RefND = mu_ref; } - -inline void CConfig::SetMu_Temperature_RefND(su2double mu_Tref) {Mu_Temperature_RefND = mu_Tref; } - -inline void CConfig::SetMu_SND(su2double mu_s) {Mu_SND = mu_s; } - -inline void CConfig::SetKt_ConstantND(su2double kt_const) { Kt_ConstantND = kt_const; } - -inline void CConfig::SetCp_PolyCoeffND(su2double val_coeff, unsigned short val_index) { CpPolyCoefficientsND[val_index] = val_coeff; } - -inline void CConfig::SetMu_PolyCoeffND(su2double val_coeff, unsigned short val_index) { MuPolyCoefficientsND[val_index] = val_coeff; } - -inline void CConfig::SetKt_PolyCoeffND(su2double val_coeff, unsigned short val_index) { KtPolyCoefficientsND[val_index] = val_coeff; } - -inline unsigned short CConfig::GetKind_GridMovement() { return Kind_GridMovement; } - -inline void CConfig::SetKind_GridMovement(unsigned short motion_Type) { Kind_GridMovement = motion_Type; } - -inline su2double CConfig::GetMotion_Origin(unsigned short iDim){return Motion_Origin[iDim];} - -inline su2double CConfig::GetMarkerMotion_Origin(unsigned short iMarkerMoving, unsigned short iDim){return MarkerMotion_Origin[3*iMarkerMoving + iDim];} - -inline void CConfig::SetMarkerMotion_Origin(su2double* val, unsigned short iMarkerMoving){ - for (unsigned short iDim = 0; iDim < 3; iDim++){ - MarkerMotion_Origin[3*iMarkerMoving + iDim] = val[iDim]; - } -} - -inline void CConfig::SetMotion_Origin(su2double* val){ - for (unsigned short iDim = 0; iDim < 3; iDim++){ - Motion_Origin[iDim] = val[iDim]; - } -} - -inline su2double CConfig::GetTranslation_Rate(unsigned short iDim){return Translation_Rate[iDim];} - -inline su2double CConfig::GetMarkerTranslationRate(unsigned short iMarkerMoving, unsigned short iDim){return MarkerTranslation_Rate[3*iMarkerMoving + iDim];} - -inline su2double CConfig::GetRotation_Rate(unsigned short iDim){return Rotation_Rate[iDim];} - -inline void CConfig::SetRotation_Rate(unsigned short iDim, su2double val){Rotation_Rate[iDim] = val;} - -inline su2double CConfig::GetFinalRotation_Rate_Z(){return FinalRotation_Rate_Z;} - -inline su2double CConfig::GetMarkerRotationRate(unsigned short iMarkerMoving, unsigned short iDim){return MarkerRotation_Rate[3*iMarkerMoving + iDim];} - -inline su2double CConfig::GetPitching_Omega(unsigned short iDim){return Pitching_Omega[iDim];} - -inline su2double CConfig::GetMarkerPitching_Omega(unsigned short iMarkerMoving, unsigned short iDim){return MarkerPitching_Omega[3*iMarkerMoving + iDim];} - -inline su2double CConfig::GetPitching_Ampl(unsigned short iDim){return Pitching_Ampl[iDim];} - -inline su2double CConfig::GetMarkerPitching_Ampl(unsigned short iMarkerMoving, unsigned short iDim){return MarkerPitching_Ampl[3*iMarkerMoving + iDim];} - -inline su2double CConfig::GetPitching_Phase(unsigned short iDim){return Pitching_Phase[iDim];} - -inline su2double CConfig::GetMarkerPitching_Phase(unsigned short iMarkerMoving, unsigned short iDim){return MarkerPitching_Phase[3*iMarkerMoving + iDim];} - -inline su2double CConfig::GetPlunging_Omega(unsigned short iDim){return Plunging_Omega[iDim];} - -inline su2double CConfig::GetMarkerPlunging_Omega(unsigned short iMarkerMoving, unsigned short iDim){return MarkerPlunging_Omega[3*iMarkerMoving + iDim];} - -inline su2double CConfig::GetPlunging_Ampl(unsigned short iDim){return Plunging_Ampl[iDim];} - -inline su2double CConfig::GetMarkerPlunging_Ampl(unsigned short iMarkerMoving, unsigned short iDim){return MarkerPlunging_Ampl[3*iMarkerMoving + iDim];} - -inline su2double CConfig::GetMach_Motion(void) { return Mach_Motion; } - -inline su2double* CConfig::GetOmega_HB(void) { return Omega_HB; } - -inline unsigned short CConfig::GetMoveMotion_Origin(unsigned short val_marker) { return MoveMotion_Origin[val_marker]; } - -inline su2double CConfig::GetminTurkelBeta() { return Min_Beta_RoeTurkel; } - -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; } - -inline void CConfig::SetKind_Deform_Linear_Solver_Prec(unsigned short val_kind_prec) { Kind_Deform_Linear_Solver_Prec = val_kind_prec; } - -inline unsigned short CConfig::GetKind_Linear_Solver_Prec(void) { return Kind_Linear_Solver_Prec; } - -inline void CConfig::SetKind_Linear_Solver_Prec(unsigned short val_kind_prec) { Kind_Linear_Solver_Prec = val_kind_prec; } - -inline su2double CConfig::GetLinear_Solver_Error(void) { return Linear_Solver_Error; } - -inline su2double CConfig::GetDeform_Linear_Solver_Error(void) { return Deform_Linear_Solver_Error; } - -inline unsigned long CConfig::GetLinear_Solver_Iter(void) { return Linear_Solver_Iter; } - -inline unsigned long CConfig::GetDeform_Linear_Solver_Iter(void) { return Deform_Linear_Solver_Iter; } - -inline unsigned short CConfig::GetLinear_Solver_ILU_n(void) { return Linear_Solver_ILU_n; } - -inline unsigned long CConfig::GetLinear_Solver_Restart_Frequency(void) { return Linear_Solver_Restart_Frequency; } - -inline su2double CConfig::GetLinear_Solver_Smoother_Relaxation(void) const { return Linear_Solver_Smoother_Relaxation; } - -inline su2double CConfig::GetRelaxation_Factor_AdjFlow(void) { return Relaxation_Factor_AdjFlow; } - -inline su2double CConfig::GetRelaxation_Factor_CHT(void) { return Relaxation_Factor_CHT; } - -inline su2double CConfig::GetRoe_Kappa(void) { return Roe_Kappa; } - -inline su2double CConfig::GetSemiSpan(void) { return SemiSpan; } - -inline unsigned short CConfig::GetKind_AdjTurb_Linear_Solver(void) { return Kind_AdjTurb_Linear_Solver; } - -inline unsigned short CConfig::GetKind_AdjTurb_Linear_Prec(void) { return Kind_AdjTurb_Linear_Prec; } - -inline unsigned short CConfig::GetKind_DiscAdj_Linear_Solver(void) { return Kind_DiscAdj_Linear_Solver; } - -inline unsigned short CConfig::GetKind_DiscAdj_Linear_Prec(void) { return Kind_DiscAdj_Linear_Prec; } - -inline unsigned short CConfig::GetKind_Deform_Linear_Solver_Prec(void) { return Kind_Deform_Linear_Solver_Prec; } - -inline void CConfig::SetKind_AdjTurb_Linear_Prec(unsigned short val_kind_prec) { Kind_AdjTurb_Linear_Prec = val_kind_prec; } - -inline su2double CConfig::GetAdjTurb_Linear_Error(void) { return AdjTurb_Linear_Error; } - -inline su2double CConfig::GetEntropyFix_Coeff(void) { return EntropyFix_Coeff; } - -inline unsigned short CConfig::GetAdjTurb_Linear_Iter(void) { return AdjTurb_Linear_Iter; } - -inline su2double CConfig::GetCFLRedCoeff_AdjTurb(void) { return CFLRedCoeff_AdjTurb; } - -inline unsigned long CConfig::GetGridDef_Nonlinear_Iter(void) { return GridDef_Nonlinear_Iter; } - -inline bool CConfig::GetDeform_Mesh(void) { return Deform_Mesh; } - -inline bool CConfig::GetDeform_Output(void) { return Deform_Output; } - -inline su2double CConfig::GetDeform_Coeff(void) { return Deform_Coeff; } - -inline su2double CConfig::GetDeform_Limit(void) { return Deform_Limit; } - -inline su2double CConfig::GetDeform_ElasticityMod(void) { return Deform_ElasticityMod; } - -inline su2double CConfig::GetDeform_PoissonRatio(void) { return Deform_PoissonRatio; } - -inline unsigned short CConfig::GetDeform_Stiffness_Type(void) { return Deform_Stiffness_Type; } - -inline bool CConfig::GetVisualize_Volume_Def(void) { return Visualize_Volume_Def; } - -inline bool CConfig::GetVisualize_Surface_Def(void) { return Visualize_Surface_Def; } - -inline bool CConfig::GetFFD_Symmetry_Plane(void) { return FFD_Symmetry_Plane; } - -inline unsigned short CConfig::GetKind_Adaptation(void) { return Kind_Adaptation; } - -inline su2double CConfig::GetNew_Elem_Adapt(void) { return New_Elem_Adapt; } - -inline unsigned short CConfig::GetKind_TimeIntScheme(void) { return Kind_TimeNumScheme; } - -inline unsigned short CConfig::GetKind_ConvNumScheme(void) { return Kind_ConvNumScheme; } - -inline unsigned short CConfig::GetKind_Centered(void) { return Kind_Centered; } - -inline unsigned short CConfig::GetKind_Upwind(void) { return Kind_Upwind; } - -inline bool CConfig::GetMUSCL(void) { return MUSCL; } - -inline bool CConfig::GetMUSCL_Flow(void) { return MUSCL_Flow; } - -inline bool CConfig::GetMUSCL_Turb(void) { return MUSCL_Turb; } - -inline bool CConfig::GetMUSCL_Heat(void) { return MUSCL_Heat; } - -inline bool CConfig::GetMUSCL_AdjFlow(void) { return MUSCL_AdjFlow; } - -inline bool CConfig::GetMUSCL_AdjTurb(void) { return MUSCL_AdjTurb; } - -inline unsigned short CConfig::GetKind_TimeIntScheme_Flow(void) { return Kind_TimeIntScheme_Flow; } - -inline unsigned short CConfig::GetKind_ADER_Predictor(void) { return Kind_ADER_Predictor; } - -inline unsigned short CConfig::GetKind_TimeIntScheme_Heat(void) { return Kind_TimeIntScheme_Heat; } - -inline unsigned short CConfig::GetKind_TimeStep_Heat(void) { return Kind_TimeStep_Heat; } - -inline unsigned short CConfig::GetKind_TimeIntScheme_FEA(void) { return Kind_TimeIntScheme_FEA; } - -inline unsigned short CConfig::GetKind_SpaceIteScheme_FEA(void) { return Kind_SpaceIteScheme_FEA; } - -inline unsigned short CConfig::GetKind_ConvNumScheme_Flow(void) { return Kind_ConvNumScheme_Flow; } - -inline unsigned short CConfig::GetKind_ConvNumScheme_FEM_Flow(void) { return Kind_ConvNumScheme_FEM_Flow; } - -inline unsigned short CConfig::GetKind_ConvNumScheme_Template(void) { return Kind_ConvNumScheme_Template; } - -inline unsigned short CConfig::GetKind_Centered_Flow(void) { return Kind_Centered_Flow; } - -inline unsigned short CConfig::GetKind_SlopeLimit(void) { return Kind_SlopeLimit; } - -inline unsigned short CConfig::GetKind_SlopeLimit_Flow(void) { return Kind_SlopeLimit_Flow; } - -inline unsigned short CConfig::GetKind_SlopeLimit_Turb(void) { return Kind_SlopeLimit_Turb; } - -inline unsigned short CConfig::GetKind_SlopeLimit_AdjTurb(void) { return Kind_SlopeLimit_AdjTurb; } - -inline unsigned short CConfig::GetKind_SlopeLimit_AdjFlow(void) { return Kind_SlopeLimit_AdjFlow; } - -inline unsigned short CConfig::GetKind_Upwind_Flow(void) { return Kind_Upwind_Flow; } - -inline unsigned short CConfig::GetKind_FEM_Flow(void) { return Kind_FEM_Flow; } - -inline unsigned short CConfig::GetKind_FEM_DG_Shock(void) { return Kind_FEM_DG_Shock; } - -inline unsigned short CConfig::GetKind_Matrix_Coloring(void) { return Kind_Matrix_Coloring; } - -inline su2double CConfig::GetKappa_1st_Flow(void) { return Kappa_1st_Flow; } - -inline su2double CConfig::GetKappa_2nd_Flow(void) { return Kappa_2nd_Flow; } - -inline su2double CConfig::GetKappa_4th_Flow(void) { return Kappa_4th_Flow; } - -inline su2double CConfig::GetKappa_2nd_Heat(void) { return Kappa_2nd_Heat; } - -inline su2double CConfig::GetKappa_4th_Heat(void) { return Kappa_4th_Heat; } - -inline unsigned short CConfig::GetKind_TimeIntScheme_AdjFlow(void) { return Kind_TimeIntScheme_AdjFlow; } - -inline unsigned short CConfig::GetKind_ConvNumScheme_AdjFlow(void) { return Kind_ConvNumScheme_AdjFlow; } - -inline unsigned short CConfig::GetKind_Centered_AdjFlow(void) { return Kind_Centered_AdjFlow; } - -inline unsigned short CConfig::GetKind_Upwind_AdjFlow(void) { return Kind_Upwind_AdjFlow; } - -inline su2double CConfig::GetKappa_1st_AdjFlow(void) { return Kappa_1st_AdjFlow; } - -inline su2double CConfig::GetKappa_2nd_AdjFlow(void) { return Kappa_2nd_AdjFlow; } - -inline su2double CConfig::GetKappa_4th_AdjFlow(void) { return Kappa_4th_AdjFlow; } - -inline unsigned short CConfig::GetKind_TimeIntScheme_Turb(void) { return Kind_TimeIntScheme_Turb; } - -inline unsigned short CConfig::GetKind_ConvNumScheme_Turb(void) { return Kind_ConvNumScheme_Turb; } - -inline unsigned short CConfig::GetKind_Centered_Turb(void) { return Kind_Centered_Turb; } - -inline unsigned short CConfig::GetKind_Upwind_Turb(void) { return Kind_Upwind_Turb; } - -inline unsigned short CConfig::GetKind_TimeIntScheme_AdjTurb(void) { return Kind_TimeIntScheme_AdjTurb; } - -inline unsigned short CConfig::GetKind_ConvNumScheme_AdjTurb(void) { return Kind_ConvNumScheme_AdjTurb; } - -inline unsigned short CConfig::GetKind_Centered_AdjTurb(void) { return Kind_Centered_AdjTurb; } - -inline unsigned short CConfig::GetKind_Upwind_AdjTurb(void) { return Kind_Upwind_AdjTurb; } - -inline unsigned short CConfig::GetKind_ConvNumScheme_Heat(void) { return Kind_ConvNumScheme_Heat; } - -inline unsigned short CConfig::GetKind_Inlet(void) { return Kind_Inlet; } - -inline bool CConfig::GetInlet_Profile_From_File(void) { return Inlet_From_File; } - -inline string CConfig::GetInlet_FileName(void) { return Inlet_Filename; } - -inline su2double CConfig::GetInlet_Profile_Matching_Tolerance(void) { return Inlet_Matching_Tol; } - -inline unsigned short CConfig::GetnInc_Inlet(void) { return nInc_Inlet;} - -inline bool CConfig::GetInc_Inlet_UseNormal(void) { return Inc_Inlet_UseNormal;} - -inline su2double CConfig::GetInc_Inlet_Damping(void) { return Inc_Inlet_Damping; } - -inline su2double CConfig::GetInc_Outlet_Damping(void) { return Inc_Outlet_Damping; } - -inline unsigned short CConfig::GetKind_Engine_Inflow(void) { return Kind_Engine_Inflow; } - -inline unsigned short CConfig::GetKind_ActDisk(void) { return Kind_ActDisk; } - -inline su2double* CConfig::GetFreeStreamTurboNormal(void){return FreeStreamTurboNormal;} - -inline unsigned short CConfig::GetKind_AverageProcess(void) { return Kind_AverageProcess; } - -inline unsigned short CConfig::GetKind_PerformanceAverageProcess(void) { return Kind_PerformanceAverageProcess; } - -inline void CConfig::SetKind_AverageProcess(unsigned short new_AverageProcess) {Kind_AverageProcess = new_AverageProcess; } - -inline void CConfig::SetKind_PerformanceAverageProcess(unsigned short new_AverageProcess) {Kind_PerformanceAverageProcess = new_AverageProcess; } - -inline su2double CConfig::GetRampRotatingFrame_Coeff(unsigned short iCoeff) { return RampRotatingFrame_Coeff[iCoeff];} - -inline bool CConfig::GetRampRotatingFrame(void) { return RampRotatingFrame;} - -inline su2double CConfig::GetRampOutletPressure_Coeff(unsigned short iCoeff) { return RampOutletPressure_Coeff[iCoeff];} - -inline su2double CConfig::GetFinalOutletPressure(void) { return FinalOutletPressure; } - -inline su2double CConfig::GetMonitorOutletPressure(void) { return MonitorOutletPressure; } - -inline void CConfig::SetMonitotOutletPressure(su2double newMonPres) {MonitorOutletPressure = newMonPres;} - -inline bool CConfig::GetRampOutletPressure(void) { return RampOutletPressure;} - -inline su2double CConfig::GetMixedout_Coeff(unsigned short iCoeff) { return Mixedout_Coeff[iCoeff];} - -inline su2double CConfig::GetExtraRelFacGiles(unsigned short iCoeff) { return ExtraRelFacGiles[iCoeff];} - -inline su2double CConfig::GetAverageMachLimit(void) { return AverageMachLimit;} - -inline unsigned short CConfig::GetKind_MixingPlaneInterface(void) { return Kind_MixingPlaneInterface;} - -inline unsigned short CConfig::GetKind_TurboMachinery(unsigned short val_iZone) { return Kind_TurboMachinery[val_iZone]; } - -inline unsigned short CConfig::GetKind_SpanWise(void) { return Kind_SpanWise; } - -inline bool CConfig::GetBoolMixingPlaneInterface(void) { return (nMarker_MixingPlaneInterface !=0);} - -inline bool CConfig::GetBoolTurbomachinery(void) { return (nMarker_Turbomachinery !=0);} - -inline bool CConfig::GetBoolTurbMixingPlane(void) { return turbMixingPlane;} - -inline bool CConfig::GetSpatialFourier(void){return SpatialFourier;} - -inline su2double CConfig::GetnBlades(unsigned short val_iZone) { return nBlades[val_iZone];} - -inline void CConfig::SetnBlades(unsigned short val_iZone, su2double nblades) { nBlades[val_iZone] = nblades;} - -inline bool CConfig::GetBoolGiles(void) { return (nMarker_Giles!=0);} - -inline bool CConfig::GetBoolRiemann(void) { return (nMarker_Riemann!=0);} - -inline unsigned short CConfig::GetnMarker_MixingPlaneInterface(void) { return nMarker_MixingPlaneInterface;} - -inline unsigned short CConfig::GetnMarker_Turbomachinery(void) { return nMarker_Turbomachinery;} - -inline unsigned short CConfig::GetnMarker_Shroud(void) { return nMarker_Shroud;} - -inline string CConfig::GetMarker_Shroud(unsigned short val_marker){return Marker_Shroud[val_marker];} - -inline unsigned short CConfig::GetnMarker_TurboPerformance(void) { return nMarker_TurboPerformance;} - -inline unsigned short CConfig::Get_nSpanWiseSections_User(void) { return nSpanWiseSections_User;} - -inline unsigned short CConfig::GetnSpanWiseSections(void) { return nSpanWiseSections;} - -inline void CConfig::SetnSpanWiseSections(unsigned short nSpan) {nSpanWiseSections = nSpan;} - -inline void CConfig::SetnSpanMaxAllZones(unsigned short val_nSpna_max) { nSpanMaxAllZones = val_nSpna_max;} - -inline unsigned short CConfig::GetnSpanMaxAllZones(void) { return nSpanMaxAllZones;} - -inline void CConfig::SetnSpan_iZones(unsigned short nSpan, unsigned short iZone) {nSpan_iZones[iZone] = nSpan;} - -inline unsigned short CConfig::GetnSpan_iZones(unsigned short iZone) { return nSpan_iZones[iZone];} - -inline string CConfig::GetMarker_TurboPerf_BoundIn(unsigned short index) { return Marker_TurboBoundIn[index];} - -inline string CConfig::GetMarker_TurboPerf_BoundOut(unsigned short index) { return Marker_TurboBoundOut[index];} - -inline string CConfig::GetMarker_PerBound(unsigned short val_marker){return Marker_PerBound[val_marker];} - -inline unsigned short CConfig::GetnLocationStations(void) { return nLocationStations; } - -inline unsigned short CConfig::GetnWingStations(void) { return nWingStations; } - -inline su2double CConfig::GetGeo_Waterline_Location(void) { return Geo_Waterline_Location; } - -inline void CConfig::SetKind_TimeIntScheme(unsigned short val_kind_timeintscheme) { Kind_TimeNumScheme = val_kind_timeintscheme; } - -inline unsigned short CConfig::GetKind_ObjFunc(void) { return Kind_ObjFunc[0]; } - -inline unsigned short CConfig::GetKind_ObjFunc(unsigned short val_obj) { return Kind_ObjFunc[val_obj]; } - -inline su2double CConfig::GetWeight_ObjFunc(unsigned short val_obj) { return Weight_ObjFunc[val_obj]; } - -inline void CConfig::SetWeight_ObjFunc(unsigned short val_obj, su2double val) {Weight_ObjFunc[val_obj] = val; } - -inline su2double CConfig::GetCoeff_ObjChainRule(unsigned short iVar) { return Obj_ChainRuleCoeff[iVar]; } - -inline unsigned short CConfig::GetKind_SensSmooth(void) { return Kind_SensSmooth; } - -inline unsigned short CConfig::GetTime_Marching(void) { return TimeMarching; } - -inline bool CConfig::GetRestart(void) { return Restart; } - -inline bool CConfig::GetWrt_Binary_Restart(void) { return Wrt_Binary_Restart; } - -inline bool CConfig::GetRead_Binary_Restart(void) { return Read_Binary_Restart; } - -inline bool CConfig::GetRestart_Flow(void) { return Restart_Flow; } - -inline bool CConfig::GetEquivArea(void) { return EquivArea; } - -inline bool CConfig::GetInvDesign_Cp(void) { return InvDesign_Cp; } - -inline bool CConfig::GetInvDesign_HeatFlux(void) { return InvDesign_HeatFlux; } - -inline void CConfig::SetnMarker_All(unsigned short val_nmarker) { nMarker_All = val_nmarker; } - -inline string CConfig::GetMarker_All_TagBound(unsigned short val_marker) { return Marker_All_TagBound[val_marker]; } - -inline string CConfig::GetMarker_ActDiskInlet_TagBound(unsigned short val_marker) { return Marker_ActDiskInlet[val_marker]; } - -inline string CConfig::GetMarker_ActDiskOutlet_TagBound(unsigned short val_marker) { return Marker_ActDiskOutlet[val_marker]; } - -inline string CConfig::GetMarker_Outlet_TagBound(unsigned short val_marker) { return Marker_Outlet[val_marker]; } - -inline string CConfig::GetMarker_EngineInflow_TagBound(unsigned short val_marker) { return Marker_EngineInflow[val_marker]; } - -inline string CConfig::GetMarker_EngineExhaust_TagBound(unsigned short val_marker) { return Marker_EngineExhaust[val_marker]; } - -inline string CConfig::GetMarker_Monitoring_TagBound(unsigned short val_marker) { return Marker_Monitoring[val_marker]; } - -inline string CConfig::GetMarker_HeatFlux_TagBound(unsigned short val_marker) { return Marker_HeatFlux[val_marker]; } - -inline string CConfig::GetMarker_Moving_TagBound(unsigned short val_marker) { return Marker_Moving[val_marker]; } - -inline string CConfig::GetMarker_Deform_Mesh_TagBound(unsigned short val_marker) { return Marker_Deform_Mesh[val_marker]; } - -inline string CConfig::GetMarker_Fluid_Load_TagBound(unsigned short val_marker) { return Marker_Fluid_Load[val_marker]; } - -inline string CConfig::GetMarker_PyCustom_TagBound(unsigned short val_marker){ return Marker_PyCustom[val_marker]; } - -inline string CConfig::GetMarker_Analyze_TagBound(unsigned short val_marker) { return Marker_Analyze[val_marker]; } - -inline short CConfig::GetMarker_All_TagBound(string val_tag) { - for (unsigned short iMarker = 0; iMarker < nMarker_All; iMarker++) { - if (val_tag == Marker_All_TagBound[iMarker]) return iMarker; - } - return -1; -} - -inline unsigned short CConfig::GetMarker_All_KindBC(unsigned short val_marker) { return Marker_All_KindBC[val_marker]; } - -inline void CConfig::SetMarker_All_KindBC(unsigned short val_marker, unsigned short val_boundary) { Marker_All_KindBC[val_marker] = val_boundary; } - -inline void CConfig::SetMarker_All_TagBound(unsigned short val_marker, string val_index) { Marker_All_TagBound[val_marker] = val_index; } - -inline void CConfig::SetMarker_All_Monitoring(unsigned short val_marker, unsigned short val_monitoring) { Marker_All_Monitoring[val_marker] = val_monitoring; } - -inline void CConfig::SetMarker_All_GeoEval(unsigned short val_marker, unsigned short val_geoeval) { Marker_All_GeoEval[val_marker] = val_geoeval; } - -inline void CConfig::SetMarker_All_Designing(unsigned short val_marker, unsigned short val_designing) { Marker_All_Designing[val_marker] = val_designing; } - -inline void CConfig::SetMarker_All_Plotting(unsigned short val_marker, unsigned short val_plotting) { Marker_All_Plotting[val_marker] = val_plotting; } - -inline void CConfig::SetMarker_All_Analyze(unsigned short val_marker, unsigned short val_analyze) { Marker_All_Analyze[val_marker] = val_analyze; } - -inline void CConfig::SetMarker_All_ZoneInterface(unsigned short val_marker, unsigned short val_fsiinterface) { Marker_All_ZoneInterface[val_marker] = val_fsiinterface; } - -inline void CConfig::SetMarker_All_Turbomachinery(unsigned short val_marker, unsigned short val_turbo) { Marker_All_Turbomachinery[val_marker] = val_turbo; } - -inline void CConfig::SetMarker_All_TurbomachineryFlag(unsigned short val_marker, unsigned short val_turboflag) { Marker_All_TurbomachineryFlag[val_marker] = val_turboflag; } - -inline void CConfig::SetMarker_All_MixingPlaneInterface(unsigned short val_marker, unsigned short val_mixpla_interface) { Marker_All_MixingPlaneInterface[val_marker] = val_mixpla_interface; } - -inline void CConfig::SetMarker_All_DV(unsigned short val_marker, unsigned short val_DV) { Marker_All_DV[val_marker] = val_DV; } - -inline void CConfig::SetMarker_All_Moving(unsigned short val_marker, unsigned short val_moving) { Marker_All_Moving[val_marker] = val_moving; } - -inline void CConfig::SetMarker_All_Deform_Mesh(unsigned short val_marker, unsigned short val_interface) { Marker_All_Deform_Mesh[val_marker] = val_interface; } - -inline void CConfig::SetMarker_All_Fluid_Load(unsigned short val_marker, unsigned short val_interface) { Marker_All_Fluid_Load[val_marker] = val_interface; } - -inline void CConfig::SetMarker_All_PyCustom(unsigned short val_marker, unsigned short val_PyCustom) { Marker_All_PyCustom[val_marker] = val_PyCustom; } - -inline void CConfig::SetMarker_All_PerBound(unsigned short val_marker, short val_perbound) { Marker_All_PerBound[val_marker] = val_perbound; } - -inline short CConfig::GetMarker_All_PerBound(unsigned short val_marker) { return Marker_All_PerBound[val_marker]; } - -inline unsigned short CConfig::GetMarker_All_Monitoring(unsigned short val_marker) { return Marker_All_Monitoring[val_marker]; } - -inline unsigned short CConfig::GetMarker_All_GeoEval(unsigned short val_marker) { return Marker_All_GeoEval[val_marker]; } - -inline unsigned short CConfig::GetMarker_All_Designing(unsigned short val_marker) { return Marker_All_Designing[val_marker]; } - -inline short CConfig::GetMarker_All_SendRecv(unsigned short val_marker) { return Marker_All_SendRecv[val_marker]; } - -inline void CConfig::SetMarker_All_SendRecv(unsigned short val_marker, short val_index) { Marker_All_SendRecv[val_marker] = val_index; } - -inline unsigned short CConfig::GetMarker_All_Plotting(unsigned short val_marker) { return Marker_All_Plotting[val_marker]; } - -inline unsigned short CConfig::GetMarker_All_Analyze(unsigned short val_marker) { return Marker_All_Analyze[val_marker]; } - -inline unsigned short CConfig::GetMarker_All_ZoneInterface(unsigned short val_marker) { return Marker_All_ZoneInterface[val_marker]; } - -inline unsigned short CConfig::GetMarker_n_ZoneInterface(void) { return nMarker_ZoneInterface; } - -inline unsigned short CConfig::GetMarker_All_Turbomachinery(unsigned short val_marker) { return Marker_All_Turbomachinery[val_marker]; } - -inline unsigned short CConfig::GetMarker_All_TurbomachineryFlag(unsigned short val_marker) { return Marker_All_TurbomachineryFlag[val_marker]; } - -inline unsigned short CConfig::GetMarker_All_MixingPlaneInterface(unsigned short val_marker) { return Marker_All_MixingPlaneInterface[val_marker]; } - -inline unsigned short CConfig::GetMarker_All_DV(unsigned short val_marker) { return Marker_All_DV[val_marker]; } - -inline unsigned short CConfig::GetMarker_All_Moving(unsigned short val_marker) { return Marker_All_Moving[val_marker]; } - -inline unsigned short CConfig::GetMarker_All_Deform_Mesh(unsigned short val_marker) { return Marker_All_Deform_Mesh[val_marker]; } - -inline unsigned short CConfig::GetMarker_All_Fluid_Load(unsigned short val_marker) { return Marker_All_Fluid_Load[val_marker]; } - -inline unsigned short CConfig::GetMarker_All_PyCustom(unsigned short val_marker) { return Marker_All_PyCustom[val_marker];} - -inline unsigned short CConfig::GetnMarker_All(void) { return nMarker_All; } - -inline unsigned short CConfig::GetnMarker_CfgFile(void) { return nMarker_CfgFile; } - -inline unsigned short CConfig::GetnMarker_Euler(void) { return nMarker_Euler; } - -inline unsigned short CConfig::GetnMarker_SymWall(void) { return nMarker_SymWall; } - -inline unsigned short CConfig::GetnMarker_Max(void) { return nMarker_Max; } - -inline unsigned short CConfig::GetnMarker_EngineInflow(void) { return nMarker_EngineInflow; } - -inline unsigned short CConfig::GetnMarker_EngineExhaust(void) { return nMarker_EngineExhaust; } - -inline unsigned short CConfig::GetnMarker_Deform_Mesh(void) { return nMarker_Deform_Mesh; } - -inline unsigned short CConfig::GetnMarker_Fluid_Load(void) { return nMarker_Fluid_Load; } - -inline unsigned short CConfig::GetnMarker_Fluid_InterfaceBound(void) { return nMarker_Fluid_InterfaceBound; } - -inline unsigned short CConfig::GetnMarker_Monitoring(void) { return nMarker_Monitoring; } - -inline unsigned short CConfig::GetnMarker_DV(void) { return nMarker_DV; } - -inline unsigned short CConfig::GetnMarker_Moving(void) { return nMarker_Moving; } - -inline unsigned short CConfig::GetnMarker_PyCustom(void) { return nMarker_PyCustom; } - -inline unsigned short CConfig::GetnMarker_Analyze(void) { return nMarker_Analyze; } - -inline unsigned short CConfig::GetnMarker_NearFieldBound(void) { return nMarker_NearFieldBound; } - -inline unsigned short CConfig::GetnMarker_ActDiskInlet(void) { return nMarker_ActDiskInlet; } - -inline unsigned short CConfig::GetnMarker_ActDiskOutlet(void) { return nMarker_ActDiskOutlet; } - -inline unsigned short CConfig::GetnMarker_Outlet(void) { return nMarker_Outlet; } - -inline unsigned short CConfig::GetnMarker_Periodic(void) { return nMarker_PerBound; } - -inline unsigned short CConfig::GetnMarker_HeatFlux(void) { return nMarker_HeatFlux; } - -inline unsigned short CConfig::GetnObj(void) { return nObj;} - -inline string CConfig::GetMesh_FileName(void) { return Mesh_FileName; } - -inline string CConfig::GetMesh_Out_FileName(void) { return Mesh_Out_FileName; } - -inline unsigned short CConfig::GetMesh_FileFormat(void) { return Mesh_FileFormat; } - -inline unsigned short CConfig::GetTabular_FileFormat(void) { return Tab_FileFormat; } - -inline unsigned long CConfig::GetStartWindowIteration(void) const{return StartWindowIteration; } - -inline WINDOW_FUNCTION CConfig::GetKindWindow(void) const{return static_cast(Kind_WindowFct); } - -inline unsigned short CConfig::GetActDisk_Jump(void) { return ActDisk_Jump; } - -inline string CConfig::GetConv_FileName(void) { return Conv_FileName; } - -inline string CConfig::GetBreakdown_FileName(void) { return Breakdown_FileName; } - -inline string CConfig::GetSolution_FileName(void) { return Solution_FileName; } - -inline string CConfig::GetSolution_AdjFileName(void) { return Solution_AdjFileName; } - -inline string CConfig::GetVolume_FileName(void) { return Volume_FileName; } - -inline string CConfig::GetRestart_FileName(void) { return Restart_FileName; } - -inline string CConfig::GetRestart_AdjFileName(void) { return Restart_AdjFileName; } - -inline string CConfig::GetAdj_FileName(void) { return Adj_FileName; } - -inline string CConfig::GetObjFunc_Grad_FileName(void) { return ObjFunc_Grad_FileName; } - -inline string CConfig::GetObjFunc_Value_FileName(void) { return ObjFunc_Value_FileName; } - -inline string CConfig::GetSurfCoeff_FileName(void) { return SurfCoeff_FileName; } - -inline string CConfig::GetSurfAdjCoeff_FileName(void) { return SurfAdjCoeff_FileName; } - -inline string CConfig::GetSurfSens_FileName(void) { return SurfSens_FileName; } - -inline string CConfig::GetVolSens_FileName(void) { return VolSens_FileName; } - -inline unsigned short CConfig::GetResidual_Criteria_FEM(void) { return Res_FEM_CRIT; } - -inline unsigned short CConfig::GetResidual_Func_Flow(void) { return Residual_Func_Flow; } - -inline unsigned short CConfig::GetCauchy_Func_Flow(void) { return Cauchy_Func_Flow; } - -inline unsigned short CConfig::GetCauchy_Func_AdjFlow(void) { return Cauchy_Func_AdjFlow; } - -inline unsigned short CConfig::GetCauchy_Elems(void) { return Cauchy_Elems; } - -inline unsigned long CConfig::GetStartConv_Iter(void) { return StartConv_Iter; } - -inline su2double CConfig::GetCauchy_Eps(void) { return Cauchy_Eps; } - -inline su2double CConfig::GetDelta_UnstTimeND(void) { return Delta_UnstTimeND; } - -inline su2double CConfig::GetTotal_UnstTimeND(void) { return Total_UnstTimeND; } - -inline su2double CConfig::GetDelta_UnstTime(void) { return Delta_UnstTime; } - -inline su2double CConfig::GetCurrent_UnstTime(void) { return Current_UnstTime; } - -inline void CConfig::SetDelta_UnstTimeND(su2double val_delta_unsttimend) { Delta_UnstTimeND = val_delta_unsttimend; } - -inline su2double CConfig::GetTotal_UnstTime(void) { return Total_UnstTime; } - -inline bool CConfig::GetSubsonicEngine(void) { return SubsonicEngine; } - -inline bool CConfig::GetActDisk_DoubleSurface(void) { return ActDisk_DoubleSurface; } - -inline bool CConfig::GetEngine_HalfModel(void) { return Engine_HalfModel; } - -inline bool CConfig::GetActDisk_SU2_DEF(void) { return ActDisk_SU2_DEF; } - -inline su2double CConfig::GetDV_Value(unsigned short val_dv, unsigned short val_value) { return DV_Value[val_dv][val_value]; } - -inline void CConfig::SetDV_Value(unsigned short val_dv, unsigned short val_ind, su2double val) { DV_Value[val_dv][val_ind] = val; } - -inline su2double CConfig::GetMinLogResidual(void) { return MinLogResidual; } - -inline su2double CConfig::GetDamp_Engine_Inflow(void) { return Damp_Engine_Inflow; } - -inline su2double CConfig::GetDamp_Engine_Exhaust(void) { return Damp_Engine_Exhaust; } - -inline su2double CConfig::GetDamp_Res_Restric(void) { return Damp_Res_Restric; } - -inline su2double CConfig::GetDamp_Correc_Prolong(void) { return Damp_Correc_Prolong; } - -inline su2double CConfig::GetPosition_Plane(void) { return Position_Plane; } - -inline su2double CConfig::GetWeightCd(void) { return WeightCd; } - -inline su2double CConfig::GetdCD_dCL(void) { return dCD_dCL; } - -inline su2double CConfig::GetdCMx_dCL(void) { return dCMx_dCL; } - -inline su2double CConfig::GetdCMy_dCL(void) { return dCMy_dCL; } - -inline su2double CConfig::GetdCMz_dCL(void) { return dCMz_dCL; } - -inline void CConfig::SetdCD_dCL(su2double val_dcd_dcl) { dCD_dCL = val_dcd_dcl; } - -inline void CConfig::SetdCMx_dCL(su2double val_dcmx_dcl) { dCMx_dCL = val_dcmx_dcl; } - -inline void CConfig::SetdCMy_dCL(su2double val_dcmy_dcl) { dCMy_dCL = val_dcmy_dcl; } - -inline void CConfig::SetdCMz_dCL(su2double val_dcmz_dcl) { dCMz_dCL = val_dcmz_dcl; } - -inline void CConfig::SetdCL_dAlpha(su2double val_dcl_dalpha) { dCL_dAlpha = val_dcl_dalpha; } - -inline void CConfig::SetdCM_diH(su2double val_dcm_dhi) { dCM_diH = val_dcm_dhi; } - -inline su2double CConfig::GetdCD_dCMy(void) { return dCD_dCMy; } - -inline void CConfig::SetdCD_dCMy(su2double val_dcd_dcmy) { dCD_dCMy = val_dcd_dcmy; } - -inline su2double CConfig::GetCL_Target(void) { return CL_Target; } - -inline su2double CConfig::GetCM_Target(void) { return CM_Target; } - -inline su2double CConfig::GetFixAzimuthalLine(void) { return FixAzimuthalLine; } - -inline su2double CConfig::GetCFLRedCoeff_Turb(void) { return CFLRedCoeff_Turb; } - -inline bool CConfig::GetGrid_Movement(void) { return (Kind_GridMovement != NO_MOVEMENT) || ((nKind_SurfaceMovement > 0) && !GetSurface_Movement(FLUID_STRUCTURE_STATIC)); } - -inline bool CConfig::GetDynamic_Grid(void) { - return (Kind_GridMovement != NO_MOVEMENT) - || ((nKind_SurfaceMovement > 0) && !GetSurface_Movement(FLUID_STRUCTURE_STATIC)) - || (Deform_Mesh && (Time_Domain)); -} - -inline unsigned short CConfig::GetKind_SurfaceMovement(unsigned short iMarkerMoving){return Kind_SurfaceMovement[iMarkerMoving];} - -inline bool CConfig::GetRotating_Frame(void) { return Rotating_Frame; } - -inline bool CConfig::GetAxisymmetric(void) { return Axisymmetric; } - -inline bool CConfig::GetAdaptBoundary(void) { return AdaptBoundary; } - -inline bool CConfig::GetPoissonSolver(void) { return PoissonSolver; } - -inline bool CConfig::Low_Mach_Preconditioning(void) { return Low_Mach_Precon; } - -inline bool CConfig::Low_Mach_Correction(void) { return Low_Mach_Corr; } - -inline bool CConfig::GetGravityForce(void) { return GravityForce; } - -inline bool CConfig::GetBody_Force(void) { return Body_Force; } - -inline su2double* CConfig::GetBody_Force_Vector(void) { return Body_Force_Vector; } - -inline bool CConfig::GetSmoothNumGrid(void) { return SmoothNumGrid; } - -inline void CConfig::SetSmoothNumGrid(bool val_smoothnumgrid) { SmoothNumGrid = val_smoothnumgrid; } - -inline unsigned short CConfig::GetKind_Turb_Model(void) { return Kind_Turb_Model; } - -inline unsigned short CConfig::GetKind_Trans_Model(void) { return Kind_Trans_Model; } - -inline unsigned short CConfig::GetKind_SGS_Model(void) { return Kind_SGS_Model; } - -inline bool CConfig::GetFrozen_Visc_Cont(void) { return Frozen_Visc_Cont; } - -inline bool CConfig::GetFrozen_Visc_Disc(void) { return Frozen_Visc_Disc; } - -inline bool CConfig::GetFrozen_Limiter_Disc(void){ return Frozen_Limiter_Disc; } - -inline bool CConfig::GetInconsistent_Disc(void){ return Inconsistent_Disc; } - -inline bool CConfig::GetSens_Remove_Sharp(void) { return Sens_Remove_Sharp; } - -inline bool CConfig::GetHold_GridFixed(void) { return Hold_GridFixed; } - -inline su2double CConfig::GetCyclic_Pitch(void) { return Cyclic_Pitch; } - -inline su2double CConfig::GetCollective_Pitch(void) { return Collective_Pitch; } - -inline string CConfig::GetDV_Filename(void) { return DV_Filename; } - -inline string CConfig::GetDV_Sens_Filename(void) { return DV_Sens_Filename; } - -inline string CConfig::GetDV_Unordered_Sens_Filename(void) { return DV_Unordered_Sens_Filename; } - -inline bool CConfig::GetWrt_Output(void) { return Wrt_Output; } - -inline bool CConfig::GetWrt_Vol_Sol(void) { return Wrt_Vol_Sol; } - -inline bool CConfig::GetWrt_Srf_Sol(void) { return Wrt_Srf_Sol; } - -inline bool CConfig::GetWrt_Csv_Sol(void) { return Wrt_Csv_Sol; } - -inline bool CConfig::GetWrt_Crd_Sol(void) { return Wrt_Crd_Sol; } - -inline bool CConfig::GetWrt_Residuals(void) { return Wrt_Residuals; } - -inline bool CConfig::GetWrt_Limiters(void) { return Wrt_Limiters; } - -inline bool CConfig::GetWrt_Surface(void) { return Wrt_Surface; } - -inline bool CConfig::GetWrt_SharpEdges(void) { return Wrt_SharpEdges; } - -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; } - -inline bool CConfig::GetWrt_Projected_Sensitivity(void) { return Wrt_Projected_Sensitivity; } - -inline unsigned short CConfig::GetSensitivity_Format(void) { return Sensitivity_FileFormat; } - -inline bool CConfig::GetPlot_Section_Forces(void) { return Plot_Section_Forces; } - -inline vector > CConfig::GetAeroelastic_np1(unsigned short iMarker) { return Aeroelastic_np1[iMarker]; } - -inline vector > CConfig::GetAeroelastic_n(unsigned short iMarker) { return Aeroelastic_n[iMarker]; } - -inline vector > CConfig::GetAeroelastic_n1(unsigned short iMarker) { return Aeroelastic_n1[iMarker]; } - -inline void CConfig::SetAeroelastic_np1(unsigned short iMarker, vector > solution) {Aeroelastic_np1[iMarker] = solution;} - -inline su2double CConfig::GetAeroelastic_plunge(unsigned short val_marker) { return Aeroelastic_plunge[val_marker]; } - -inline su2double CConfig::GetAeroelastic_pitch(unsigned short val_marker) { return Aeroelastic_pitch[val_marker]; } - -inline void CConfig::SetAeroelastic_plunge(unsigned short val_marker, su2double val) {Aeroelastic_plunge[val_marker] = val; } - -inline void CConfig::SetAeroelastic_pitch(unsigned short val_marker, su2double val) {Aeroelastic_pitch[val_marker] = val; } - -inline void CConfig::SetAeroelastic_n1(void) { - Aeroelastic_n1 = Aeroelastic_n; -} - -inline void CConfig::SetAeroelastic_n(void) { - Aeroelastic_n = Aeroelastic_np1; -} - -inline su2double CConfig::GetAeroelastic_Flutter_Speed_Index(void) { return FlutterSpeedIndex; } - -inline su2double CConfig::GetAeroelastic_Frequency_Plunge(void) { return PlungeNaturalFrequency; } - -inline su2double CConfig::GetAeroelastic_Frequency_Pitch(void) { return PitchNaturalFrequency; } - -inline su2double CConfig::GetAeroelastic_Airfoil_Mass_Ratio(void) { return AirfoilMassRatio; } - -inline su2double CConfig::GetAeroelastic_CG_Location(void) { return CG_Location; } - -inline su2double CConfig::GetAeroelastic_Radius_Gyration_Squared(void) { return RadiusGyrationSquared; } - -inline unsigned short CConfig::GetAeroelasticIter(void) { return AeroelasticIter; } - -inline bool CConfig::GetWind_Gust(void) { return Wind_Gust; } - -inline bool CConfig::GetAeroelastic_Simulation(void) { return Aeroelastic_Simulation; } - -inline unsigned short CConfig::GetGust_Type(void) { return Gust_Type; } - -inline unsigned short CConfig::GetGust_Dir(void) { return Gust_Dir; } - -inline su2double CConfig::GetGust_WaveLength(void) { return Gust_WaveLength; } - -inline su2double CConfig::GetGust_Periods(void) { return Gust_Periods; } - -inline su2double CConfig::GetGust_Ampl(void) { return Gust_Ampl; } - -inline su2double CConfig::GetGust_Begin_Time(void) { return Gust_Begin_Time; } - -inline su2double CConfig::GetGust_Begin_Loc(void) { return Gust_Begin_Loc; } - -inline unsigned short CConfig::GetnFFD_Iter(void) { return nFFD_Iter; } - -inline su2double CConfig::GetFFD_Tol(void) { return FFD_Tol; } - -inline su2double CConfig::GetOpt_LineSearch_Bound(void) {return Opt_LineSearch_Bound; } - -inline su2double CConfig::GetOpt_RelaxFactor(void) {return Opt_RelaxFactor; } - -inline void CConfig::SetOpt_RelaxFactor(su2double val_scale) {Opt_RelaxFactor = val_scale; } - -inline long CConfig::GetVisualize_CV(void) { return Visualize_CV; } - -inline bool CConfig::GetWall_Functions(void) { return Wall_Functions; } - -inline bool CConfig::GetFixed_CL_Mode(void) { return Fixed_CL_Mode; } - -inline bool CConfig::GetFixed_CM_Mode(void) { return Fixed_CM_Mode; } - -inline bool CConfig::GetEval_dOF_dCX(void) { return Eval_dOF_dCX; } - -inline bool CConfig::GetDiscard_InFiles(void) { return Discard_InFiles; } - -inline su2double CConfig::GetTarget_CL(void) { return Target_CL; } - -inline su2double CConfig::GetdCL_dAlpha(void) { return dCL_dAlpha; } - -inline su2double CConfig::GetdCM_diH(void) {return dCM_diH; } - -inline unsigned long CConfig::GetIter_Fixed_NetThrust(void) {return Iter_Fixed_NetThrust; } - -inline unsigned long CConfig::GetIter_dCL_dAlpha(void) {return Iter_dCL_dAlpha; } - -inline bool CConfig::GetUpdate_AoA(void) { return Update_AoA; } - -inline unsigned long CConfig::GetUpdate_AoA_Iter_Limit(void) { return Update_AoA_Iter_Limit; } - -inline bool CConfig::GetFinite_Difference_Mode(void) { return Finite_Difference_Mode; } - -inline void CConfig::SetFinite_Difference_Mode(bool val_fd_mode) { Finite_Difference_Mode = val_fd_mode; } - -inline bool CConfig::GetUpdate_BCThrust_Bool(void) { return Update_BCThrust_Bool; } - -inline void CConfig::SetUpdate_AoA(bool val_update) { Update_AoA = val_update; } - -inline unsigned long CConfig::GetUpdate_BCThrust(void) {return Update_BCThrust; } - -inline void CConfig::SetUpdate_BCThrust_Bool(bool val_update) { Update_BCThrust_Bool = val_update; } - -inline su2double CConfig::GetdNetThrust_dBCThrust(void) {return dNetThrust_dBCThrust; } - -inline void CConfig::SetNonphysical_Points(unsigned long val_nonphys_points) { Nonphys_Points = val_nonphys_points; } - -inline unsigned long CConfig::GetNonphysical_Points(void) { return Nonphys_Points; } - -inline void CConfig::SetNonphysical_Reconstr(unsigned long val_nonphys_reconstr) { Nonphys_Reconstr = val_nonphys_reconstr; } - -inline unsigned long CConfig::GetNonphysical_Reconstr(void) { return Nonphys_Reconstr; } - -inline unsigned short CConfig::GetConsole_Output_Verb(void) { return Console_Output_Verb; } - -inline unsigned short CConfig::GetKind_Average(void) { return Kind_Average; } - -inline unsigned short CConfig::GetnIterFSI(void) { return nIterFSI; } - -inline unsigned short CConfig::GetnIterFSI_Ramp(void) { return nIterFSI_Ramp; } - -inline su2double CConfig::GetAitkenStatRelax(void) { return AitkenStatRelax; } - -inline su2double CConfig::GetAitkenDynMaxInit(void) { return AitkenDynMaxInit; } - -inline su2double CConfig::GetAitkenDynMinInit(void) { return AitkenDynMinInit; } - -inline bool CConfig::GetDeadLoad(void) { return DeadLoad; } - -inline bool CConfig::GetPseudoStatic(void) { return PseudoStatic; } - -inline bool CConfig::GetSteadyRestart(void) { return SteadyRestart; } - -inline unsigned short CConfig::GetDynamic_Analysis(void) { return Dynamic_Analysis; } - -inline su2double CConfig::GetDelta_DynTime(void) { return Delta_DynTime; } - -inline su2double CConfig::GetTotal_DynTime(void) { return Total_DynTime; } - -inline su2double CConfig::GetCurrent_DynTime(void) { return Current_DynTime; } - -inline unsigned short CConfig::GetiInst(void) { return iInst; } - -inline void CConfig::SetiInst(unsigned short val_iInst) { iInst = val_iInst; } - -inline bool CConfig::GetWrt_Dynamic(void) { return Wrt_Dynamic; } - -inline su2double CConfig::GetNewmark_beta(void) { return Newmark_beta; } - -inline su2double CConfig::GetNewmark_gamma(void) { return Newmark_gamma; } - -inline unsigned short CConfig::GetnIntCoeffs(void) { return nIntCoeffs; } - -inline su2double CConfig::Get_Int_Coeffs(unsigned short val_coeff) { return Int_Coeffs[val_coeff]; } - -inline unsigned short CConfig::GetnElectric_Field(void) { return nElectric_Field; } - -inline unsigned short CConfig::GetnDim_Electric_Field(void) { return nDim_Electric_Field; } - -inline su2double CConfig::Get_Electric_Field_Mod(unsigned short val_coeff) { return Electric_Field_Mod[val_coeff]; } - -inline void CConfig::Set_Electric_Field_Mod(unsigned short val_coeff, su2double val_el_field) { Electric_Field_Mod[val_coeff] = val_el_field; } - -inline su2double* CConfig::Get_Electric_Field_Dir(void) { return Electric_Field_Dir; } - -inline bool CConfig::GetRamp_Load(void) { return Ramp_Load; } - -inline su2double CConfig::GetRamp_Time(void) { return Ramp_Time; } - -inline bool CConfig::GetRampAndRelease_Load(void) { return RampAndRelease; } - -inline bool CConfig::GetSine_Load(void) { return Sine_Load; } - -inline su2double* CConfig::GetLoad_Sine(void) { return SineLoad_Coeff; } - -inline su2double CConfig::GetRefGeom_Penalty(void) { return RefGeom_Penalty; } - -inline su2double CConfig::GetTotalDV_Penalty(void) { return DV_Penalty; } - -inline bool CConfig::GetPredictor(void) { return Predictor; } - -inline unsigned short CConfig::GetPredictorOrder(void) { return Pred_Order; } - -inline bool CConfig::GetRelaxation(void) { return Relaxation; } - -inline bool CConfig::GetIncrementalLoad(void) { return IncrementalLoad; } - -inline unsigned long CConfig::GetNumberIncrements(void) { return IncLoad_Nincrements; } - -inline su2double CConfig::GetIncLoad_Criteria(unsigned short val_var) { return IncLoad_Criteria[val_var]; } - -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 || (nMarker_Fluid_Load > 0); } - -inline void CConfig::SetFSI_Simulation(bool FSI_sim) { FSI_Problem = FSI_sim; } - -inline void CConfig::SetMultizone_Problem(bool MZ_problem) { Multizone_Problem = MZ_problem; } - -inline bool CConfig::GetMultizone_Problem(void) { return Multizone_Problem; } - -inline unsigned short CConfig::GetnID_DV(void) { return nID_DV; } - -inline unsigned short CConfig::GetKindInterpolation(void) { return Kind_Interpolation; } - -inline unsigned short CConfig::GetKindRadialBasisFunction(void) { return Kind_RadialBasisFunction; } - -inline bool CConfig::GetRadialBasisFunctionPolynomialOption(void) {return RadialBasisFunction_PolynomialOption; } - -inline su2double CConfig::GetRadialBasisFunctionParameter(void) {return RadialBasisFunction_Parameter; } - -inline bool CConfig::GetConservativeInterpolation(void) { return ConservativeInterpolation; } - -inline unsigned short CConfig::GetRelaxation_Method_FSI(void) { return Kind_BGS_RelaxMethod; } - -inline unsigned short CConfig::GetDynamic_LoadTransfer(void) { return Dynamic_LoadTransfer; } - -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;} - -inline su2double CConfig::GetQuadrature_Factor_Curved(void) {return Quadrature_Factor_Curved;} - -inline su2double CConfig::GetQuadrature_Factor_Time_ADER_DG(void) {return Quadrature_Factor_Time_ADER_DG;} - -inline su2double CConfig::GetTheta_Interior_Penalty_DGFEM(void) {return Theta_Interior_Penalty_DGFEM;} - -inline unsigned short CConfig::GetSizeMatMulPadding(void) {return sizeMatMulPadding;} - -inline bool CConfig::GetCompute_Entropy(void) {return Compute_Entropy;} - -inline bool CConfig::GetUse_Lumped_MassMatrix_DGFEM(void) {return Use_Lumped_MassMatrix_DGFEM;} - -inline bool CConfig::GetJacobian_Spatial_Discretization_Only(void) {return Jacobian_Spatial_Discretization_Only;} - -inline bool CConfig::GetWeakly_Coupled_Heat(void) { return Weakly_Coupled_Heat; } - -inline unsigned short CConfig::GetKind_CHT_Coupling(void) const { return Kind_CHT_Coupling; } - -inline bool CConfig::GetIntegrated_HeatFlux(void) { return Integrated_HeatFlux; } - -inline bool CConfig::GetAD_Mode(void) { return AD_Mode;} - -inline bool CConfig::GetAD_Preaccumulation(void) {return AD_Preaccumulation;} - -inline unsigned short CConfig::GetFFD_Blending(void){return FFD_Blending;} - -inline su2double* CConfig::GetFFD_BSplineOrder(){return FFD_BSpline_Order;} - -inline void CConfig::SetMax_Vel2(su2double val_max_vel2) { Max_Vel2 = val_max_vel2; } - -inline su2double CConfig::GetMax_Vel2(void) { return Max_Vel2; } - -inline void CConfig::SetRestart_Bandwidth_Agg(su2double val_restart_bandwidth_sum) { Restart_Bandwidth_Agg = val_restart_bandwidth_sum; } - -inline su2double CConfig::GetRestart_Bandwidth_Agg(void) { return Restart_Bandwidth_Agg; } - -inline unsigned long CConfig::GetWrt_Surf_Freq_DualTime(void) { return Wrt_Surf_Freq_DualTime; } - -inline unsigned short CConfig::GetKind_HybridRANSLES(void) {return Kind_HybridRANSLES; } - -inline unsigned short CConfig::GetKind_RoeLowDiss(void) {return Kind_RoeLowDiss; } - -inline su2double CConfig::GetConst_DES(void) {return Const_DES; } - -inline bool CConfig::GetQCR(void) {return QCR;} - -inline bool CConfig::GetCompute_Average(void) {return Compute_Average;} - -inline unsigned short CConfig::GetVerification_Solution(void) {return Kind_Verification_Solution;} - -inline ofstream* CConfig::GetHistFile(void) { return ConvHistFile; } - -inline void CConfig::SetHistFile(ofstream *HistFile) { ConvHistFile = HistFile; } - -inline unsigned short CConfig::GetComm_Level(void) { return Comm_Level; } - -inline bool CConfig::GetTopology_Optimization(void) const { return topology_optimization; } - -inline string CConfig::GetTopology_Optim_FileName(void) const { return top_optim_output_file; } - -inline su2double CConfig::GetSIMP_Exponent(void) const { return simp_exponent; } - -inline su2double CConfig::GetSIMP_MinStiffness(void) const { return simp_minimum_stiffness; } - -inline unsigned short CConfig::GetTopology_Optim_Num_Kernels(void) const { return top_optim_nKernel; } - -inline void CConfig::GetTopology_Optim_Kernel(const unsigned short iKernel, unsigned short &type, - su2double ¶m, su2double &radius) const { - type = top_optim_kernels[iKernel]; - param = top_optim_kernel_params[iKernel]; - radius = top_optim_filter_radius[iKernel]; -} - -inline unsigned short CConfig::GetTopology_Search_Limit(void) const { return top_optim_search_lim; } - -inline void CConfig::GetTopology_Optim_Projection(unsigned short &type, su2double ¶m) const { - type = top_optim_proj_type; param = top_optim_proj_param; -} - -inline string CConfig::GetConfigFilename(unsigned short index) { return Config_Filenames[index]; } - -inline unsigned short CConfig::GetnConfigFiles(void) { return nConfig_Files; } - -inline unsigned short CConfig::GetnMarker_ZoneInterface(void) { return nMarker_ZoneInterface; } - -inline string CConfig::GetMarkerTag_ZoneInterface(unsigned short val_iMarker) { return Marker_ZoneInterface[val_iMarker]; } - -inline bool CConfig::GetTime_Domain(void) { return Time_Domain; } - -inline unsigned long CConfig::GetnInner_Iter(void) { return nInnerIter; } - -inline unsigned long CConfig::GetnOuter_Iter(void) { return nOuterIter; } - -inline unsigned long CConfig::GetnTime_Iter(void) { return nTimeIter; } - -inline void CConfig::SetnTime_Iter(unsigned long val_iter) { nTimeIter = val_iter; } - -inline unsigned long CConfig::GetnIter(void) { return nIter; } - -inline unsigned long CConfig::GetRestart_Iter(void) { return Restart_Iter; } - -inline su2double CConfig::GetTime_Step(void) { return Time_Step; } - -inline su2double CConfig::GetMax_Time(void) { return Max_Time; } - -inline bool CConfig::GetMultizone_Mesh(void) { return Multizone_Mesh; } - -inline bool CConfig::GetMultizone_Residual(void) { return Multizone_Residual; } - -inline bool CConfig::GetSinglezone_Driver(void) { return SinglezoneDriver; } - -inline bool CConfig::GetWrt_ZoneConv(void) { return Wrt_ZoneConv; } - -inline bool CConfig::GetWrt_ZoneHist(void) { return Wrt_ZoneHist; } - -inline bool CConfig::GetSpecial_Output(void) { return SpecialOutput; } - -inline bool CConfig::GetWrt_ForcesBreakdown(void) { return Wrt_ForcesBreakdown; } - -inline unsigned short CConfig::GetnScreenOutput(void) { return nScreenOutput; } - -inline string CConfig::GetScreenOutput_Field(unsigned short iField) { return ScreenOutput[iField]; } - -inline unsigned short CConfig::GetnHistoryOutput(void) { return nHistoryOutput; } - -inline string CConfig::GetHistoryOutput_Field(unsigned short iField) { return HistoryOutput[iField]; } - -inline unsigned short CConfig::GetnVolumeOutput(void) { return nVolumeOutput; } - -inline string CConfig::GetVolumeOutput_Field(unsigned short iField) { return VolumeOutput[iField]; } - -inline bool CConfig::GetUsing_UQ(void) { return using_uq; } - -inline su2double CConfig::GetUQ_Delta_B(void) { return uq_delta_b; } - -inline unsigned short CConfig::GetEig_Val_Comp(void) {return eig_val_comp; } - -inline su2double CConfig::GetUQ_URLX(void) {return uq_urlx; } - -inline bool CConfig::GetUQ_Permute(void) { return uq_permute; } - -inline unsigned long CConfig::GetPastixFactFreq(void) { return pastix_fact_freq; } - -inline unsigned short CConfig::GetPastixVerbLvl(void) { return pastix_verb_lvl; } - -inline unsigned short CConfig::GetPastixFillLvl(void) { return pastix_fill_lvl; } - -inline short CConfig::GetMeshBoxSize(unsigned short val_iDim) { return Mesh_Box_Size[val_iDim]; } - -inline su2double CConfig::GetMeshBoxLength(unsigned short val_iDim) { return Mesh_Box_Length[val_iDim]; } - -inline su2double CConfig::GetMeshBoxOffset(unsigned short val_iDim) { return Mesh_Box_Offset[val_iDim]; } - -inline string CConfig::GetConv_Field(unsigned short iField){ return ConvField[iField]; } - -inline string CConfig::GetWndConv_Field(unsigned short iField) const { return WndConvField[iField]; } - -inline unsigned short CConfig::GetWnd_Cauchy_Elems(void) const { return Wnd_Cauchy_Elems; } - -inline su2double CConfig::GetWnd_Cauchy_Eps(void) const { return Wnd_Cauchy_Eps; } - -inline unsigned long CConfig::GetWnd_StartConv_Iter(void) const { return Wnd_StartConv_Iter; } - -inline bool CConfig::GetWnd_Cauchy_Crit(void) const {return Wnd_Cauchy_Crit;} - -inline unsigned short CConfig::GetnWndConv_Field() const{ return nWndConvField; } - -inline unsigned short CConfig::GetnConv_Field(){ return nConvField; } - -inline void CConfig::Set_StartTime(su2double starttime){StartTime = starttime;} - -inline su2double CConfig::Get_StartTime() {return StartTime;} - -inline unsigned long CConfig::GetHistory_Wrt_Freq(unsigned short iter) {return HistoryWrtFreq[iter];} - -inline void CConfig::SetHistory_Wrt_Freq(unsigned short iter, unsigned long nIter) { HistoryWrtFreq[iter] = nIter;} - -inline unsigned long CConfig::GetScreen_Wrt_Freq(unsigned short iter) {return ScreenWrtFreq[iter];} - -inline void CConfig::SetScreen_Wrt_Freq(unsigned short iter, unsigned long nIter) { ScreenWrtFreq[iter] = nIter;} - -inline unsigned long CConfig::GetVolume_Wrt_Freq() {return VolumeWrtFreq;} - -inline unsigned short* CConfig::GetVolumeOutputFiles() {return VolumeOutputFiles;} - -inline unsigned short CConfig::GetnVolumeOutputFiles() {return nVolumeOutputFiles;} - -inline bool CConfig::OptionIsSet(string option){ return all_options.find(option) == all_options.end();} - -inline const string& CConfig::GetCaseName() const { return caseName;} diff --git a/Common/src/config_structure.cpp b/Common/src/config_structure.cpp index e271c8aa225f..6913eb00900f 100644 --- a/Common/src/config_structure.cpp +++ b/Common/src/config_structure.cpp @@ -8426,7 +8426,7 @@ bool CConfig::GetVolumetric_Movement(){ return volumetric_movement; } -bool CConfig::GetSurface_Movement(unsigned short kind_movement){ +bool CConfig::GetSurface_Movement(unsigned short kind_movement) const { for (unsigned short iMarkerMoving = 0; iMarkerMoving < nKind_SurfaceMovement; iMarkerMoving++){ if (Kind_SurfaceMovement[iMarkerMoving] == kind_movement){ return true; From b6387e1754d566ccd23d927f890237b5a216d197 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Wed, 29 Jan 2020 10:18:34 +0000 Subject: [PATCH 037/118] fix merge --- SU2_DOT/include/SU2_DOT.hpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/SU2_DOT/include/SU2_DOT.hpp b/SU2_DOT/include/SU2_DOT.hpp index c1921d3b273c..4dfb0ed6248f 100644 --- a/SU2_DOT/include/SU2_DOT.hpp +++ b/SU2_DOT/include/SU2_DOT.hpp @@ -7,7 +7,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -35,9 +35,6 @@ #include "../../Common/include/mpi_structure.hpp" #include "../../Common/include/omp_structure.hpp" -#define ENABLE_MAPS -#include "../../Common/include/config_structure.hpp" - #include #include #include From 41d50e22998d9fdf00400e0dbc1e7f0e8410352b Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Wed, 29 Jan 2020 13:03:31 +0000 Subject: [PATCH 038/118] fix warning the right way --- SU2_CFD/src/output/COutput.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/src/output/COutput.cpp b/SU2_CFD/src/output/COutput.cpp index 7fdc1de4d0e3..9d69e9288859 100644 --- a/SU2_CFD/src/output/COutput.cpp +++ b/SU2_CFD/src/output/COutput.cpp @@ -2021,7 +2021,7 @@ void COutput::LoadCommonHistoryData(CConfig *config){ /*--- Update the current time only if the time iteration has changed ---*/ - if (static_cast(GetHistoryFieldValue("TIME_ITER")) != curTimeIter){ + if (SU2_TYPE::Int(GetHistoryFieldValue("TIME_ITER")) != static_cast(curTimeIter)) { SetHistoryOutputValue("CUR_TIME", GetHistoryFieldValue("CUR_TIME") + GetHistoryFieldValue("TIME_STEP")); } From 3ed72efda12c933116e03b1b379d46fee7a47ae1 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Wed, 29 Jan 2020 15:33:22 +0000 Subject: [PATCH 039/118] better ComputeResidual overload for the thread-safe classes + const CConfig* in CNumerics --- Common/include/config_structure.hpp | 6 +- SU2_CFD/include/numerics/CNumerics.hpp | 66 +++++--- .../numerics/elasticity/CFEAElasticity.hpp | 16 +- .../elasticity/CFEALinearElasticity.hpp | 10 +- .../elasticity/CFEANonlinearElasticity.hpp | 16 +- .../numerics/elasticity/nonlinear_models.hpp | 32 ++-- .../numerics/flow/convection/ausm_slau.hpp | 38 ++--- .../numerics/flow/convection/centered.hpp | 24 ++- .../include/numerics/flow/convection/cusp.hpp | 10 +- .../include/numerics/flow/convection/fvs.hpp | 9 +- .../include/numerics/flow/convection/hllc.hpp | 22 +-- .../include/numerics/flow/convection/roe.hpp | 45 +++--- SU2_CFD/src/numerics/CNumerics.cpp | 17 +- .../numerics/elasticity/CFEAElasticity.cpp | 10 +- .../elasticity/CFEALinearElasticity.cpp | 8 +- .../elasticity/CFEANonlinearElasticity.cpp | 14 +- .../numerics/elasticity/nonlinear_models.cpp | 30 ++-- .../numerics/flow/convection/ausm_slau.cpp | 59 +++---- .../src/numerics/flow/convection/centered.cpp | 25 ++- SU2_CFD/src/numerics/flow/convection/cusp.cpp | 12 +- SU2_CFD/src/numerics/flow/convection/fvs.cpp | 11 +- SU2_CFD/src/numerics/flow/convection/hllc.cpp | 34 ++-- SU2_CFD/src/numerics/flow/convection/roe.cpp | 64 +++----- SU2_CFD/src/solvers/CEulerSolver.cpp | 147 +++++++----------- 24 files changed, 318 insertions(+), 407 deletions(-) diff --git a/Common/include/config_structure.hpp b/Common/include/config_structure.hpp index 7c161bf6365b..5a590b5022e8 100644 --- a/Common/include/config_structure.hpp +++ b/Common/include/config_structure.hpp @@ -4240,7 +4240,7 @@ class CConfig { * \brief Get whether to "Use Accurate Jacobians" for AUSM+up(2) and SLAU(2). * \return yes/no. */ - bool GetUse_Accurate_Jacobians(void) { return Use_Accurate_Jacobians; } + bool GetUse_Accurate_Jacobians(void) const { return Use_Accurate_Jacobians; } /*! * \brief Get the kind of integration scheme (explicit or implicit) @@ -4443,7 +4443,7 @@ class CConfig { * \brief Factor by which to multiply the dissipation contribution to Jacobians of central schemes. * \return The factor. */ - su2double GetCent_Jac_Fix_Factor(void) { return Cent_Jac_Fix_Factor; } + su2double GetCent_Jac_Fix_Factor(void) const { return Cent_Jac_Fix_Factor; } /*! * \brief Get the kind of integration scheme (explicit or implicit) @@ -8480,7 +8480,7 @@ class CConfig { * \param[in] val_coeff - Index of the coefficient. * \return Alpha coefficient for the Runge-Kutta integration scheme. */ - su2double* Get_Electric_Field_Dir(void) { return Electric_Field_Dir; } + const su2double* Get_Electric_Field_Dir(void) const { return Electric_Field_Dir; } /*! * \brief Check if the user wants to apply the load as a ramp. diff --git a/SU2_CFD/include/numerics/CNumerics.hpp b/SU2_CFD/include/numerics/CNumerics.hpp index ab4a426fb8fa..0d3909e0b25c 100644 --- a/SU2_CFD/include/numerics/CNumerics.hpp +++ b/SU2_CFD/include/numerics/CNumerics.hpp @@ -220,6 +220,30 @@ class CNumerics { su2double *Eig_Val, *Barycentric_Coord, *New_Coord; public: + /*! + * \brief Return type used in some "ComputeResidual" overloads to give a + * const-view of the internally stored flux vector and Jacobians to the outside. + * \note The default template params make this an "all const" object, it cannot + * change after instantiation, nor can it be used to change the data. + */ + template + struct ResidualType { + const Vector_t residual; + const Matrix_t jacobian_i; + const Matrix_t jacobian_j; + + ResidualType() = delete; + + ResidualType(const Vector_t& res, const Matrix_t& jac_i, const Matrix_t& jac_j) : + residual(res), jacobian_i(jac_i), jacobian_j(jac_j) { } + + /*! + * \brief The object can be directly cast to the vector type, this + * allows discarding the Jacobians when they are not needed. + */ + operator Vector_t() { return residual; } + }; /*! * \brief Constructor of the class. @@ -232,7 +256,7 @@ class CNumerics { * \param[in] val_nVar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CNumerics(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + CNumerics(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config); /*! * \brief Destructor of the class. @@ -1009,7 +1033,7 @@ class CNumerics { * \param[out] val_residual - Pointer to the total residual. * \param[in] config - Definition of the particular problem. */ - inline virtual void ComputeResidual(su2double *val_residual, CConfig *config) { } + inline virtual void ComputeResidual(su2double *val_residual, const CConfig* config) { } /*! * \overload @@ -1019,19 +1043,14 @@ class CNumerics { * \param[in] config - Definition of the particular problem. */ inline virtual void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, - su2double **val_Jacobian_j, CConfig *config) { } + su2double **val_Jacobian_j, const CConfig* config) { } /*! * \overload For numerics classes that store the residual/flux and Jacobians internally. - * \param[out] residual - Pointer to the total residual. - * \param[out] jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] jacobian_j - Jacobian of the numerical method at node j (implicit computation). * \param[in] config - Definition of the particular problem. + * \return A lightweight const-view (read-only) of the residual/flux and Jacobians. */ - inline virtual void ComputeResidual(const su2double* &residual, - const su2double* const* &jacobian_i, - const su2double* const* &jacobian_j, - CConfig *config) { } + inline virtual ResidualType<> ComputeResidual(const CConfig* config) { return ResidualType<>(nullptr,nullptr,nullptr); } /*! * \overload @@ -1048,7 +1067,7 @@ class CNumerics { su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, su2double **val_Jacobian_ji, - su2double **val_Jacobian_jj, CConfig *config) { } + su2double **val_Jacobian_jj, const CConfig* config) { } /*! * \overload @@ -1067,7 +1086,7 @@ class CNumerics { su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, su2double **val_Jacobian_ji, - su2double **val_Jacobian_jj, CConfig *config) { } + su2double **val_Jacobian_jj, const CConfig* config) { } /*! * \overload @@ -1075,7 +1094,7 @@ class CNumerics { * \param[out] val_residual - residual of the source terms * \param[out] val_Jacobian_i - Jacobian of the source terms */ - inline virtual void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config) { } + inline virtual void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, const CConfig* config) { } /*! * \brief Residual for transition problems. @@ -1087,7 +1106,7 @@ class CNumerics { */ inline virtual void ComputeResidual_TransLM(su2double *val_residual, su2double **val_Jacobian_i, - su2double **val_Jacobian_j, CConfig *config, + su2double **val_Jacobian_j, const CConfig* config, su2double &gamma_sep) { } /*! @@ -1140,13 +1159,13 @@ class CNumerics { * \brief A virtual member to compute the tangent matrix in structural problems * \param[in] element_container - Element structure for the particular element integrated. */ - inline virtual void Compute_Tangent_Matrix(CElement *element_container, CConfig *config) { } + inline virtual void Compute_Tangent_Matrix(CElement *element_container, const CConfig* config) { } /*! * \brief A virtual member to compute the nodal stress term in non-linear structural problems * \param[in] element_container - Definition of the particular element integrated. */ - inline virtual void Compute_NodalStress_Term(CElement *element_container, CConfig *config) { } + inline virtual void Compute_NodalStress_Term(CElement *element_container, const CConfig* config) { } /*! * \brief Set the element-based local Young's modulus in mesh problems @@ -1194,19 +1213,19 @@ class CNumerics { * \brief A virtual member to compute the mass matrix * \param[in] element_container - Element structure for the particular element integrated. */ - inline virtual void Compute_Mass_Matrix(CElement *element_container, CConfig *config) { } + inline virtual void Compute_Mass_Matrix(CElement *element_container, const CConfig* config) { } /*! * \brief A virtual member to compute the residual component due to dead loads * \param[in] element_container - Element structure for the particular element integrated. */ - inline virtual void Compute_Dead_Load(CElement *element_container, CConfig *config) { } + inline virtual void Compute_Dead_Load(CElement *element_container, const CConfig* config) { } /*! * \brief A virtual member to compute the averaged nodal stresses * \param[in] element_container - Element structure for the particular element integrated. */ - inline virtual void Compute_Averaged_NodalStress(CElement *element_container, CConfig *config) { } + inline virtual void Compute_Averaged_NodalStress(CElement *element_container, const CConfig* config) { } /*! * \brief Computes a basis of orthogonal vectors from a supplied vector @@ -1233,12 +1252,11 @@ class CNumerics { * \param[in] Dissipation_j - Value of the bledning function at point j * \param[in] Sensor_i - Shock sensor at point i * \param[in] Sensor_j - Shock sensor at point j - * \param[out] Dissipation_ij - Blending parameter at face + * \param[in] config - The configuration of the problem + * \return Dissipation_ij - Blending parameter at face */ - void SetRoe_Dissipation(const su2double Dissipation_i, - const su2double Dissipation_j, - const su2double Sensor_i, const su2double Sensor_j, - su2double& Dissipation_ij, CConfig *config); + su2double GetRoe_Dissipation(const su2double Dissipation_i, const su2double Dissipation_j, + const su2double Sensor_i, const su2double Sensor_j, const CConfig* config) const; /*! * \brief Decomposes the symmetric matrix A_ij, into eigenvectors and eigenvalues diff --git a/SU2_CFD/include/numerics/elasticity/CFEAElasticity.hpp b/SU2_CFD/include/numerics/elasticity/CFEAElasticity.hpp index 50ab13bb0751..68129e4594ec 100644 --- a/SU2_CFD/include/numerics/elasticity/CFEAElasticity.hpp +++ b/SU2_CFD/include/numerics/elasticity/CFEAElasticity.hpp @@ -91,7 +91,7 @@ class CFEAElasticity : public CNumerics { * \param[in] val_nVar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CFEAElasticity(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + CFEAElasticity(unsigned short val_nDim, unsigned short val_nVar, const CConfig *config); /*! * \brief Destructor of the class. @@ -153,28 +153,28 @@ class CFEAElasticity : public CNumerics { * \param[in,out] element_container - Element whose mass matrix is being built. * \param[in] config - Definition of the problem. */ - void Compute_Mass_Matrix(CElement *element_container, CConfig *config) final; + void Compute_Mass_Matrix(CElement *element_container, const CConfig *config) final; /*! * \brief Compute the nodal gravity loads for an element. * \param[in,out] element_container - The element for which the dead loads are computed. * \param[in] config - Definition of the problem. */ - void Compute_Dead_Load(CElement *element_container, CConfig *config) final; + void Compute_Dead_Load(CElement *element_container, const CConfig *config) final; /*! * \brief Build the tangent stiffness matrix of an element. * \param[in,out] element_container - Element whose tangent matrix is being built. * \param[in] config - Definition of the problem. */ - inline void Compute_Tangent_Matrix(CElement *element_container, CConfig *config) override { }; + inline void Compute_Tangent_Matrix(CElement *element_container, const CConfig *config) override { }; /*! * \brief Compute averaged nodal stresses (for post processing). * \param[in,out] element_container - The finite element. * \param[in] config - Definition of the problem. */ - inline void Compute_Averaged_NodalStress(CElement *element_container, CConfig *config) override { }; + inline void Compute_Averaged_NodalStress(CElement *element_container, const CConfig *config) override { }; protected: /*! @@ -182,20 +182,20 @@ class CFEAElasticity : public CNumerics { * \param[in,out] element_container - The finite element. * \param[in] config - Definition of the problem. */ - virtual void Compute_Constitutive_Matrix(CElement *element_container, CConfig *config) = 0; + virtual void Compute_Constitutive_Matrix(CElement *element_container, const CConfig *config) = 0; /*! * \brief Set element material properties. * \param[in] element_container - Element defining the properties. * \param[in] config - Definition of the problem. */ - virtual void SetElement_Properties(const CElement *element_container, CConfig *config); + virtual void SetElement_Properties(const CElement *element_container, const CConfig *config); /*! * \brief Read design variables from file. * \param[in] config - Definition of the problem. */ - void ReadDV(CConfig *config); + void ReadDV(const CConfig *config); /*! * \brief Update the Lame parameters (required in AD to account for all dependencies). diff --git a/SU2_CFD/include/numerics/elasticity/CFEALinearElasticity.hpp b/SU2_CFD/include/numerics/elasticity/CFEALinearElasticity.hpp index b90eb5178ac9..92228e020248 100644 --- a/SU2_CFD/include/numerics/elasticity/CFEALinearElasticity.hpp +++ b/SU2_CFD/include/numerics/elasticity/CFEALinearElasticity.hpp @@ -53,7 +53,7 @@ class CFEALinearElasticity : public CFEAElasticity { * \param[in] val_nVar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CFEALinearElasticity(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + CFEALinearElasticity(unsigned short val_nDim, unsigned short val_nVar, const CConfig *config); /*! * \brief Destructor of the class. @@ -65,14 +65,14 @@ class CFEALinearElasticity : public CFEAElasticity { * \param[in,out] element_container - Element whose tangent matrix is being built. * \param[in] config - Definition of the problem. */ - void Compute_Tangent_Matrix(CElement *element_container, CConfig *config) final; + void Compute_Tangent_Matrix(CElement *element_container, const CConfig *config) final; /*! * \brief Compute averaged nodal stresses (for post processing). * \param[in,out] element_container - The finite element. * \param[in] config - Definition of the problem. */ - void Compute_Averaged_NodalStress(CElement *element_container, CConfig *config) final; + void Compute_Averaged_NodalStress(CElement *element_container, const CConfig *config) final; private: /*! @@ -80,7 +80,7 @@ class CFEALinearElasticity : public CFEAElasticity { * \param[in,out] element_container - The finite element. * \param[in] config - Definition of the problem. */ - void Compute_Constitutive_Matrix(CElement *element_container, CConfig *config) final; + void Compute_Constitutive_Matrix(CElement *element_container, const CConfig *config) final; }; @@ -131,7 +131,7 @@ class CFEAMeshElasticity final : public CFEALinearElasticity { * \param[in] element_container - Element defining the properties. * \param[in] config - Definition of the problem. */ - inline void SetElement_Properties(const CElement *element, CConfig *config) override { + inline void SetElement_Properties(const CElement *element, const CConfig *config) override { if (element_based) { E = E_i[element->Get_iProp()]; Compute_Lame_Parameters(); diff --git a/SU2_CFD/include/numerics/elasticity/CFEANonlinearElasticity.hpp b/SU2_CFD/include/numerics/elasticity/CFEANonlinearElasticity.hpp index 9023c071c4f6..ebf097970c91 100644 --- a/SU2_CFD/include/numerics/elasticity/CFEANonlinearElasticity.hpp +++ b/SU2_CFD/include/numerics/elasticity/CFEANonlinearElasticity.hpp @@ -92,7 +92,7 @@ class CFEANonlinearElasticity : public CFEAElasticity { * \param[in] val_nVar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CFEANonlinearElasticity(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + CFEANonlinearElasticity(unsigned short val_nDim, unsigned short val_nVar, const CConfig *config); /*! * \brief Destructor of the class. @@ -113,21 +113,21 @@ class CFEANonlinearElasticity : public CFEAElasticity { * \param[in,out] element_container - Element whose tangent matrix is being built. * \param[in] config - Definition of the problem. */ - void Compute_Tangent_Matrix(CElement *element_container, CConfig *config) final; + void Compute_Tangent_Matrix(CElement *element_container, const CConfig *config) final; /*! * \brief Compute the nodal stress terms for an element. * \param[in,out] element_container - The finite element. * \param[in] config - Definition of the problem. */ - void Compute_NodalStress_Term(CElement *element_container, CConfig *config) final; + void Compute_NodalStress_Term(CElement *element_container, const CConfig *config) final; /*! * \brief Compute averaged nodal stresses (for post processing). * \param[in,out] element_container - The finite element. * \param[in] config - Definition of the problem. */ - void Compute_Averaged_NodalStress(CElement *element_container, CConfig *config) final; + void Compute_Averaged_NodalStress(CElement *element_container, const CConfig *config) final; protected: /*! @@ -135,28 +135,28 @@ class CFEANonlinearElasticity : public CFEAElasticity { * \param[in,out] element_container - The finite element. * \param[in] config - Definition of the problem. */ - virtual void Compute_Plane_Stress_Term(CElement *element_container, CConfig *config) = 0; + virtual void Compute_Plane_Stress_Term(CElement *element_container, const CConfig *config) = 0; /*! * \brief Compute the stress tensor. * \param[in,out] element_container - The finite element. * \param[in] config - Definition of the problem. */ - virtual void Compute_Stress_Tensor(CElement *element_container, CConfig *config) = 0; + virtual void Compute_Stress_Tensor(CElement *element_container, const CConfig *config) = 0; /*! * \brief Update an element with Maxwell's stress. * \param[in,out] element_container - The finite element. * \param[in] config - Definition of the problem. */ - void Add_MaxwellStress(CElement *element_container, CConfig *config); + void Add_MaxwellStress(CElement *element_container, const CConfig *config); /*! * \brief Set element electric properties. * \param[in] element_container - Element defining the properties. * \param[in] config - Definition of the problem. */ - void SetElectric_Properties(const CElement *element_container, CConfig *config); + void SetElectric_Properties(const CElement *element_container, const CConfig *config); /*! * \brief TODO: Describe what this does. diff --git a/SU2_CFD/include/numerics/elasticity/nonlinear_models.hpp b/SU2_CFD/include/numerics/elasticity/nonlinear_models.hpp index 5777c0e84545..bf8f12071723 100644 --- a/SU2_CFD/include/numerics/elasticity/nonlinear_models.hpp +++ b/SU2_CFD/include/numerics/elasticity/nonlinear_models.hpp @@ -46,7 +46,7 @@ class CFEM_NeoHookean_Comp final : public CFEANonlinearElasticity { * \param[in] val_nVar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CFEM_NeoHookean_Comp(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + CFEM_NeoHookean_Comp(unsigned short val_nDim, unsigned short val_nVar, const CConfig *config); /*! * \brief Destructor of the class. @@ -59,21 +59,21 @@ class CFEM_NeoHookean_Comp final : public CFEANonlinearElasticity { * \param[in,out] element_container - The finite element. * \param[in] config - Definition of the problem. */ - void Compute_Plane_Stress_Term(CElement *element_container, CConfig *config) override; + void Compute_Plane_Stress_Term(CElement *element_container, const CConfig *config) override; /*! * \brief Compute the constitutive matrix. * \param[in,out] element_container - The finite element. * \param[in] config - Definition of the problem. */ - void Compute_Constitutive_Matrix(CElement *element_container, CConfig *config) override; + void Compute_Constitutive_Matrix(CElement *element_container, const CConfig *config) override; /*! * \brief Compute the stress tensor. * \param[in,out] element_container - The finite element. * \param[in] config - Definition of the problem. */ - void Compute_Stress_Tensor(CElement *element_container, CConfig *config) override; + void Compute_Stress_Tensor(CElement *element_container, const CConfig *config) override; }; @@ -97,7 +97,7 @@ class CFEM_Knowles_NearInc final : public CFEANonlinearElasticity { * \param[in] val_nVar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CFEM_Knowles_NearInc(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + CFEM_Knowles_NearInc(unsigned short val_nDim, unsigned short val_nVar, const CConfig *config); /*! * \brief Destructor of the class. @@ -110,21 +110,21 @@ class CFEM_Knowles_NearInc final : public CFEANonlinearElasticity { * \param[in,out] element_container - The finite element. * \param[in] config - Definition of the problem. */ - void Compute_Plane_Stress_Term(CElement *element_container, CConfig *config) override; + void Compute_Plane_Stress_Term(CElement *element_container, const CConfig *config) override; /*! * \brief Compute the constitutive matrix. * \param[in,out] element_container - The finite element. * \param[in] config - Definition of the problem. */ - void Compute_Constitutive_Matrix(CElement *element_container, CConfig *config) override; + void Compute_Constitutive_Matrix(CElement *element_container, const CConfig *config) override; /*! * \brief Compute the stress tensor. * \param[in,out] element_container - The finite element. * \param[in] config - Definition of the problem. */ - void Compute_Stress_Tensor(CElement *element_container, CConfig *config) override; + void Compute_Stress_Tensor(CElement *element_container, const CConfig *config) override; }; @@ -145,7 +145,7 @@ class CFEM_DielectricElastomer final : public CFEANonlinearElasticity { * \param[in] val_nVar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CFEM_DielectricElastomer(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + CFEM_DielectricElastomer(unsigned short val_nDim, unsigned short val_nVar, const CConfig *config); /*! * \brief Destructor of the class. @@ -158,21 +158,21 @@ class CFEM_DielectricElastomer final : public CFEANonlinearElasticity { * \param[in,out] element_container - The finite element. * \param[in] config - Definition of the problem. */ - inline void Compute_Plane_Stress_Term(CElement *element_container, CConfig *config) override { }; + inline void Compute_Plane_Stress_Term(CElement *element_container, const CConfig *config) override { }; /*! * \brief Compute the constitutive matrix. * \param[in,out] element_container - The finite element. * \param[in] config - Definition of the problem. */ - void Compute_Constitutive_Matrix(CElement *element_container, CConfig *config) override; + void Compute_Constitutive_Matrix(CElement *element_container, const CConfig *config) override; /*! * \brief Compute the stress tensor. * \param[in,out] element_container - The finite element. * \param[in] config - Definition of the problem. */ - void Compute_Stress_Tensor(CElement *element_container, CConfig *config) override; + void Compute_Stress_Tensor(CElement *element_container, const CConfig *config) override; }; @@ -195,7 +195,7 @@ class CFEM_IdealDE final : public CFEANonlinearElasticity { * \param[in] val_nVar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CFEM_IdealDE(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + CFEM_IdealDE(unsigned short val_nDim, unsigned short val_nVar, const CConfig *config); /*! * \brief Destructor of the class. @@ -208,20 +208,20 @@ class CFEM_IdealDE final : public CFEANonlinearElasticity { * \param[in,out] element_container - The finite element. * \param[in] config - Definition of the problem. */ - void Compute_Plane_Stress_Term(CElement *element_container, CConfig *config) override; + void Compute_Plane_Stress_Term(CElement *element_container, const CConfig *config) override; /*! * \brief Compute the constitutive matrix. * \param[in,out] element_container - The finite element. * \param[in] config - Definition of the problem. */ - void Compute_Constitutive_Matrix(CElement *element_container, CConfig *config) override; + void Compute_Constitutive_Matrix(CElement *element_container, const CConfig *config) override; /*! * \brief Compute the stress tensor. * \param[in,out] element_container - The finite element. * \param[in] config - Definition of the problem. */ - void Compute_Stress_Tensor(CElement *element_container, CConfig *config) override; + void Compute_Stress_Tensor(CElement *element_container, const CConfig *config) override; }; diff --git a/SU2_CFD/include/numerics/flow/convection/ausm_slau.hpp b/SU2_CFD/include/numerics/flow/convection/ausm_slau.hpp index b9e5576a0a61..384d107e6f0c 100644 --- a/SU2_CFD/include/numerics/flow/convection/ausm_slau.hpp +++ b/SU2_CFD/include/numerics/flow/convection/ausm_slau.hpp @@ -63,7 +63,7 @@ class CUpwAUSMPLUS_SLAU_Base_Flow : public CNumerics { * \param[out] mdot - The mass flux. * \param[out] pressure - The pressure at the control volume face. */ - virtual void ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure) = 0; + virtual void ComputeMassAndPressureFluxes(const CConfig* config, su2double &mdot, su2double &pressure) = 0; private: /*! @@ -78,7 +78,7 @@ class CUpwAUSMPLUS_SLAU_Base_Flow : public CNumerics { * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). */ - void AccurateJacobian(CConfig *config, su2double **val_Jacobian_i, su2double **val_Jacobian_j); + void AccurateJacobian(const CConfig* config, su2double **val_Jacobian_i, su2double **val_Jacobian_j); public: @@ -88,7 +88,7 @@ class CUpwAUSMPLUS_SLAU_Base_Flow : public CNumerics { * \param[in] val_nVar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CUpwAUSMPLUS_SLAU_Base_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + CUpwAUSMPLUS_SLAU_Base_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config); /*! * \brief Destructor of the class. @@ -97,13 +97,11 @@ class CUpwAUSMPLUS_SLAU_Base_Flow : public CNumerics { /*! * \brief Compute the AUSM+ and SLAU family of schemes. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). * \param[in] config - Definition of the particular problem. + * \return A lightweight const-view (read-only) of the residual/flux and Jacobians. */ - void ComputeResidual(const su2double* &residual, const su2double* const* &jacobian_i, - const su2double* const* &jacobian_j, CConfig *config) final; + ResidualType<> ComputeResidual(const CConfig* config) final; + }; /*! @@ -122,7 +120,7 @@ class CUpwAUSMPLUSUP_Flow final : public CUpwAUSMPLUS_SLAU_Base_Flow { * \param[out] mdot - The mass flux. * \param[out] pressure - The pressure at the control volume face. */ - void ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure) override; + void ComputeMassAndPressureFluxes(const CConfig* config, su2double &mdot, su2double &pressure) override; public: @@ -132,7 +130,7 @@ class CUpwAUSMPLUSUP_Flow final : public CUpwAUSMPLUS_SLAU_Base_Flow { * \param[in] val_nVar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CUpwAUSMPLUSUP_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + CUpwAUSMPLUSUP_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config); }; @@ -152,7 +150,7 @@ class CUpwAUSMPLUSUP2_Flow final : public CUpwAUSMPLUS_SLAU_Base_Flow { * \param[out] mdot - The mass flux. * \param[out] pressure - The pressure at the control volume face. */ - void ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure) override; + void ComputeMassAndPressureFluxes(const CConfig* config, su2double &mdot, su2double &pressure) override; public: @@ -162,7 +160,7 @@ class CUpwAUSMPLUSUP2_Flow final : public CUpwAUSMPLUS_SLAU_Base_Flow { * \param[in] val_nVar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CUpwAUSMPLUSUP2_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + CUpwAUSMPLUSUP2_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config); }; @@ -183,7 +181,7 @@ class CUpwSLAU_Flow : public CUpwAUSMPLUS_SLAU_Base_Flow { * \param[out] mdot - The mass flux. * \param[out] pressure - The pressure at the control volume face. */ - void ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure) final; + void ComputeMassAndPressureFluxes(const CConfig* config, su2double &mdot, su2double &pressure) final; public: @@ -193,7 +191,7 @@ class CUpwSLAU_Flow : public CUpwAUSMPLUS_SLAU_Base_Flow { * \param[in] val_nVar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CUpwSLAU_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, bool val_low_dissipation); + CUpwSLAU_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config, bool val_low_dissipation); }; @@ -211,7 +209,7 @@ class CUpwSLAU2_Flow final : public CUpwSLAU_Flow { * \param[in] val_nVar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CUpwSLAU2_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, bool val_low_dissipation); + CUpwSLAU2_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config, bool val_low_dissipation); }; @@ -247,7 +245,7 @@ class CUpwAUSM_Flow final : public CNumerics { * \param[in] val_nVar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CUpwAUSM_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + CUpwAUSM_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config); /*! * \brief Destructor of the class. @@ -256,11 +254,9 @@ class CUpwAUSM_Flow final : public CNumerics { /*! * \brief Compute the Roe's flux between two nodes i and j. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). * \param[in] config - Definition of the particular problem. + * \return A lightweight const-view (read-only) of the residual/flux and Jacobians. */ - void ComputeResidual(const su2double* &residual, const su2double* const* &jacobian_i, - const su2double* const* &jacobian_j, CConfig *config) override; + ResidualType<> ComputeResidual(const CConfig* config) override; + }; diff --git a/SU2_CFD/include/numerics/flow/convection/centered.hpp b/SU2_CFD/include/numerics/flow/convection/centered.hpp index a61997082845..82d306fc7286 100644 --- a/SU2_CFD/include/numerics/flow/convection/centered.hpp +++ b/SU2_CFD/include/numerics/flow/convection/centered.hpp @@ -91,7 +91,7 @@ class CCentBase_Flow : public CNumerics { * \param[in] val_nVar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CCentBase_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + CCentBase_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config); /*! * \brief Destructor of the class. @@ -100,13 +100,11 @@ class CCentBase_Flow : public CNumerics { /*! * \brief Compute the flow residual using a centered method with artificial dissipation. - * \param[out] residual - Pointer to the convective flux contribution to the residual. - * \param[out] jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] jacobian_j - Jacobian of the numerical method at node j (implicit computation). * \param[in] config - Definition of the particular problem. + * \return A lightweight const-view (read-only) of the residual/flux and Jacobians. */ - void ComputeResidual(const su2double* &residual, const su2double* const* &jacobian_i, - const su2double* const* &jacobian_j, CConfig *config) final; + ResidualType<> ComputeResidual(const CConfig* config) final; + }; /*! @@ -142,7 +140,7 @@ class CCentLax_Flow final : public CCentBase_Flow { * \param[in] val_nVar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CCentLax_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + CCentLax_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config); }; @@ -180,7 +178,7 @@ class CCentJST_KE_Flow final : public CCentBase_Flow { * \param[in] val_nVar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CCentJST_KE_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + CCentJST_KE_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config); }; @@ -218,7 +216,7 @@ class CCentJST_Flow final : public CCentBase_Flow { * \param[in] val_nVar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CCentJST_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + CCentJST_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config); }; @@ -261,7 +259,7 @@ class CCentLaxInc_Flow : public CNumerics { * \param[in] val_nVar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CCentLaxInc_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + CCentLaxInc_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config); /*! * \brief Destructor of the class. @@ -275,7 +273,7 @@ class CCentLaxInc_Flow : public CNumerics { * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). * \param[in] config - Definition of the particular problem. */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, const CConfig* config); }; /*! @@ -319,7 +317,7 @@ class CCentJSTInc_Flow : public CNumerics { * \param[in] val_nVar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CCentJSTInc_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + CCentJSTInc_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config); /*! * \brief Destructor of the class. @@ -333,5 +331,5 @@ class CCentJSTInc_Flow : public CNumerics { * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). * \param[in] config - Definition of the particular problem. */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, const CConfig* config); }; diff --git a/SU2_CFD/include/numerics/flow/convection/cusp.hpp b/SU2_CFD/include/numerics/flow/convection/cusp.hpp index 7c8a6f48b0e8..6e22a217244b 100644 --- a/SU2_CFD/include/numerics/flow/convection/cusp.hpp +++ b/SU2_CFD/include/numerics/flow/convection/cusp.hpp @@ -52,7 +52,7 @@ class CUpwCUSP_Flow final : public CNumerics { * \param[in] val_nVar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CUpwCUSP_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + CUpwCUSP_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config); /*! * \brief Destructor of the class. @@ -61,11 +61,9 @@ class CUpwCUSP_Flow final : public CNumerics { /*! * \brief Compute the flow residual using a JST method. - * \param[out] val_residual - Pointer to the residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). * \param[in] config - Definition of the particular problem. + * \return A lightweight const-view (read-only) of the residual/flux and Jacobians. */ - void ComputeResidual(const su2double* &residual, const su2double* const* &jacobian_i, - const su2double* const* &jacobian_j, CConfig *config) override; + ResidualType<> ComputeResidual(const CConfig* config) override; + }; diff --git a/SU2_CFD/include/numerics/flow/convection/fvs.hpp b/SU2_CFD/include/numerics/flow/convection/fvs.hpp index 5d96448bd82c..748ff0f96f2e 100644 --- a/SU2_CFD/include/numerics/flow/convection/fvs.hpp +++ b/SU2_CFD/include/numerics/flow/convection/fvs.hpp @@ -59,7 +59,7 @@ class CUpwMSW_Flow final : public CNumerics { * \param[in] val_nVar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CUpwMSW_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + CUpwMSW_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config); /*! * \brief Destructor of the class. @@ -68,12 +68,9 @@ class CUpwMSW_Flow final : public CNumerics { /*! * \brief Compute the Roe's flux between two nodes i and j. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). * \param[in] config - Definition of the particular problem. + * \return A lightweight const-view (read-only) of the residual/flux and Jacobians. */ - void ComputeResidual(const su2double* &residual, const su2double* const* &jacobian_i, - const su2double* const* &jacobian_j, CConfig *config) override; + ResidualType<> ComputeResidual(const CConfig* config) override; }; diff --git a/SU2_CFD/include/numerics/flow/convection/hllc.hpp b/SU2_CFD/include/numerics/flow/convection/hllc.hpp index 4c15ba2fa3a1..d57779674b65 100644 --- a/SU2_CFD/include/numerics/flow/convection/hllc.hpp +++ b/SU2_CFD/include/numerics/flow/convection/hllc.hpp @@ -65,7 +65,7 @@ class CUpwHLLC_Flow final : public CNumerics { * \param[in] val_nVar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CUpwHLLC_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + CUpwHLLC_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config); /*! * \brief Destructor of the class. @@ -74,13 +74,10 @@ class CUpwHLLC_Flow final : public CNumerics { /*! * \brief Compute the Roe's flux between two nodes i and j. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). * \param[in] config - Definition of the particular problem. + * \return A lightweight const-view (read-only) of the residual/flux and Jacobians. */ - void ComputeResidual(const su2double* &residual, const su2double* const* &jacobian_i, - const su2double* const* &jacobian_j, CConfig *config) override; + ResidualType<> ComputeResidual(const CConfig* config) override; }; @@ -121,7 +118,7 @@ class CUpwGeneralHLLC_Flow final : public CNumerics { * \param[in] val_nVar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CUpwGeneralHLLC_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + CUpwGeneralHLLC_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config); /*! * \brief Destructor of the class. @@ -130,17 +127,14 @@ class CUpwGeneralHLLC_Flow final : public CNumerics { /*! * \brief Compute the Roe's flux between two nodes i and j. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). * \param[in] config - Definition of the particular problem. + * \return A lightweight const-view (read-only) of the residual/flux and Jacobians. */ - void ComputeResidual(const su2double* &residual, const su2double* const* &jacobian_i, - const su2double* const* &jacobian_j, CConfig *config) override; + ResidualType<> ComputeResidual(const CConfig* config) override; - /*! + /*! * \brief Compute the Average quantities for a general fluid flux between two nodes i and j. * Using the approach of Vinokur and Montagne' */ - void VinokurMontagne(); + void VinokurMontagne(); }; diff --git a/SU2_CFD/include/numerics/flow/convection/roe.hpp b/SU2_CFD/include/numerics/flow/convection/roe.hpp index 3e0bf4099de4..ade2d66b5207 100644 --- a/SU2_CFD/include/numerics/flow/convection/roe.hpp +++ b/SU2_CFD/include/numerics/flow/convection/roe.hpp @@ -57,7 +57,8 @@ class CUpwRoeBase_Flow : public CNumerics { * \param[out] val_Jacobian_j - Flux Jacobian wrt node j conservatives (implicit computation). * \param[in] config - Definition of the particular problem. */ - virtual void FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) = 0; + virtual void FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, + su2double **val_Jacobian_j, const CConfig* config) = 0; public: /*! @@ -67,7 +68,7 @@ class CUpwRoeBase_Flow : public CNumerics { * \param[in] config - Definition of the particular problem. * \param[in] val_low_dissipation - Use a low dissipation formulation. */ - CUpwRoeBase_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, bool val_low_dissipation); + CUpwRoeBase_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config, bool val_low_dissipation); /*! * \brief Destructor of the class. @@ -76,13 +77,10 @@ class CUpwRoeBase_Flow : public CNumerics { /*! * \brief Compute the flux from node i to node j, part common to most Roe schemes. - * \param[out] val_residual - Convective flux. - * \param[out] val_Jacobian_i - Flux Jacobian wrt node i conservatives (implicit computation). - * \param[out] val_Jacobian_j - Flux Jacobian wrt node j conservatives (implicit computation). * \param[in] config - Definition of the particular problem. + * \return A lightweight const-view (read-only) of the residual/flux and Jacobians. */ - void ComputeResidual(const su2double* &residual, const su2double* const* &jacobian_i, - const su2double* const* &jacobian_j, CConfig *config) final; + ResidualType<> ComputeResidual(const CConfig* config) final; }; @@ -101,7 +99,8 @@ class CUpwRoe_Flow final : public CUpwRoeBase_Flow { * \param[out] val_Jacobian_j - Flux Jacobian wrt node j conservatives (implicit computation). * \param[in] config - Definition of the particular problem. */ - void FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) override; + void FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, + su2double **val_Jacobian_j, const CConfig* config) override; public: /*! @@ -111,7 +110,7 @@ class CUpwRoe_Flow final : public CUpwRoeBase_Flow { * \param[in] config - Definition of the particular problem. * \param[in] val_low_dissipation - Use a low dissipation formulation. */ - CUpwRoe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, bool val_low_dissipation); + CUpwRoe_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config, bool val_low_dissipation); }; @@ -131,7 +130,8 @@ class CUpwL2Roe_Flow final : public CUpwRoeBase_Flow { * \param[out] val_Jacobian_j - Flux Jacobian wrt node j conservatives (implicit computation). * \param[in] config - Definition of the particular problem. */ - void FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) override; + void FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, + su2double **val_Jacobian_j, const CConfig* config) override; public: /*! @@ -140,7 +140,7 @@ class CUpwL2Roe_Flow final : public CUpwRoeBase_Flow { * \param[in] val_nVar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CUpwL2Roe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + CUpwL2Roe_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config); }; @@ -160,7 +160,8 @@ class CUpwLMRoe_Flow final : public CUpwRoeBase_Flow { * \param[out] val_Jacobian_j - Flux Jacobian wrt node j conservatives (implicit computation). * \param[in] config - Definition of the particular problem. */ - void FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) override; + void FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, + su2double **val_Jacobian_j, const CConfig* config) override; public: /*! @@ -169,7 +170,7 @@ class CUpwLMRoe_Flow final : public CUpwRoeBase_Flow { * \param[in] val_nVar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CUpwLMRoe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + CUpwLMRoe_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config); }; @@ -207,7 +208,7 @@ class CUpwTurkel_Flow final : public CNumerics { * \param[in] val_nVar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CUpwTurkel_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + CUpwTurkel_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config); /*! * \brief Destructor of the class. @@ -216,13 +217,10 @@ class CUpwTurkel_Flow final : public CNumerics { /*! * \brief Compute the Roe's flux between two nodes i and j. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). * \param[in] config - Definition of the particular problem. + * \return A lightweight const-view (read-only) of the residual/flux and Jacobians. */ - void ComputeResidual(const su2double* &residual, const su2double* const* &jacobian_i, - const su2double* const* &jacobian_j, CConfig *config) override; + ResidualType<> ComputeResidual(const CConfig* config) override; }; @@ -263,7 +261,7 @@ class CUpwGeneralRoe_Flow final : public CNumerics { * \param[in] val_nVar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CUpwGeneralRoe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + CUpwGeneralRoe_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config); /*! * \brief Destructor of the class. @@ -272,13 +270,10 @@ class CUpwGeneralRoe_Flow final : public CNumerics { /*! * \brief Compute the Roe's flux between two nodes i and j. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). * \param[in] config - Definition of the particular problem. + * \return A lightweight const-view (read-only) of the residual/flux and Jacobians. */ - void ComputeResidual(const su2double* &residual, const su2double* const* &jacobian_i, - const su2double* const* &jacobian_j, CConfig *config) override; + ResidualType<> ComputeResidual(const CConfig* config) override; /*! * \brief Compute the Average for a general fluid flux between two nodes i and j. diff --git a/SU2_CFD/src/numerics/CNumerics.cpp b/SU2_CFD/src/numerics/CNumerics.cpp index 97ec33b7448d..e8b1630652f1 100644 --- a/SU2_CFD/src/numerics/CNumerics.cpp +++ b/SU2_CFD/src/numerics/CNumerics.cpp @@ -57,7 +57,7 @@ CNumerics::CNumerics(void) { } CNumerics::CNumerics(unsigned short val_nDim, unsigned short val_nVar, - CConfig *config) { + const CConfig* config) { unsigned short iVar, iDim, jDim; @@ -1822,17 +1822,18 @@ void CNumerics::CreateBasis(su2double *val_Normal) { } } -void CNumerics::SetRoe_Dissipation(const su2double Dissipation_i, - const su2double Dissipation_j, - const su2double Sensor_i, - const su2double Sensor_j, - su2double& Dissipation_ij, - CConfig *config) { +su2double CNumerics::GetRoe_Dissipation(const su2double Dissipation_i, + const su2double Dissipation_j, + const su2double Sensor_i, + const su2double Sensor_j, + const CConfig* config) const { /*--- Check for valid input ---*/ unsigned short roe_low_diss = config->GetKind_RoeLowDiss(); + su2double Dissipation_ij = 0.0; + assert((Dissipation_i >= 0) && (Dissipation_i <= 1)); assert((Dissipation_j >= 0) && (Dissipation_j <= 1)); if (roe_low_diss == FD_DUCROS || roe_low_diss == NTS_DUCROS) { @@ -1885,7 +1886,7 @@ void CNumerics::SetRoe_Dissipation(const su2double Dissipation_i, CURRENT_FUNCTION); } - + return Dissipation_ij; } void CNumerics::EigenDecomposition(su2double **A_ij, su2double **Eig_Vec, su2double *Eig_Val, unsigned short n){ diff --git a/SU2_CFD/src/numerics/elasticity/CFEAElasticity.cpp b/SU2_CFD/src/numerics/elasticity/CFEAElasticity.cpp index af4b71011839..44fb773a3a19 100644 --- a/SU2_CFD/src/numerics/elasticity/CFEAElasticity.cpp +++ b/SU2_CFD/src/numerics/elasticity/CFEAElasticity.cpp @@ -30,7 +30,7 @@ CFEAElasticity::CFEAElasticity(unsigned short val_nDim, unsigned short val_nVar, - CConfig *config) : CNumerics() { + const CConfig *config) : CNumerics() { nDim = val_nDim; nVar = val_nVar; @@ -178,7 +178,7 @@ CFEAElasticity::~CFEAElasticity(void) { } -void CFEAElasticity::Compute_Mass_Matrix(CElement *element, CConfig *config) { +void CFEAElasticity::Compute_Mass_Matrix(CElement *element, const CConfig *config) { /*--- Initialize values for the material model considered ---*/ SetElement_Properties(element, config); @@ -230,7 +230,7 @@ void CFEAElasticity::Compute_Mass_Matrix(CElement *element, CConfig *config) { } -void CFEAElasticity::Compute_Dead_Load(CElement *element, CConfig *config) { +void CFEAElasticity::Compute_Dead_Load(CElement *element, const CConfig *config) { /*--- Initialize values for the material model considered ---*/ SetElement_Properties(element, config); @@ -282,7 +282,7 @@ void CFEAElasticity::Compute_Dead_Load(CElement *element, CConfig *config) { } -void CFEAElasticity::SetElement_Properties(const CElement *element, CConfig *config) { +void CFEAElasticity::SetElement_Properties(const CElement *element, const CConfig *config) { /*--- These variables are set as preaccumulation inputs in Compute_Tangent_Matrix and Compute_NodalStress_Term, if you add variables here be sure to register them in those routines too. ---*/ @@ -311,7 +311,7 @@ void CFEAElasticity::SetElement_Properties(const CElement *element, CConfig *con } -void CFEAElasticity::ReadDV(CConfig *config) { +void CFEAElasticity::ReadDV(const CConfig *config) { int rank = SU2_MPI::GetRank(); bool master_node = false; diff --git a/SU2_CFD/src/numerics/elasticity/CFEALinearElasticity.cpp b/SU2_CFD/src/numerics/elasticity/CFEALinearElasticity.cpp index deb41a4c01e3..9f7deceaf4ad 100644 --- a/SU2_CFD/src/numerics/elasticity/CFEALinearElasticity.cpp +++ b/SU2_CFD/src/numerics/elasticity/CFEALinearElasticity.cpp @@ -29,14 +29,14 @@ CFEALinearElasticity::CFEALinearElasticity(unsigned short val_nDim, unsigned short val_nVar, - CConfig *config) : CFEAElasticity(val_nDim, val_nVar, config) { + const CConfig *config) : CFEAElasticity(val_nDim, val_nVar, config) { if (nDim == 2) nodalDisplacement.resize(NNODES_2D,nDim); else nodalDisplacement.resize(NNODES_3D,nDim); } -void CFEALinearElasticity::Compute_Tangent_Matrix(CElement *element, CConfig *config) { +void CFEALinearElasticity::Compute_Tangent_Matrix(CElement *element, const CConfig *config) { unsigned short iVar, jVar, kVar; unsigned short iGauss, nGauss; @@ -196,7 +196,7 @@ void CFEALinearElasticity::Compute_Tangent_Matrix(CElement *element, CConfig *co } -void CFEALinearElasticity::Compute_Constitutive_Matrix(CElement *element_container, CConfig *config) { +void CFEALinearElasticity::Compute_Constitutive_Matrix(CElement *element_container, const CConfig *config) { /*--- Compute the D Matrix (for plane stress and 2-D)---*/ @@ -234,7 +234,7 @@ void CFEALinearElasticity::Compute_Constitutive_Matrix(CElement *element_contain } -void CFEALinearElasticity::Compute_Averaged_NodalStress(CElement *element, CConfig *config) { +void CFEALinearElasticity::Compute_Averaged_NodalStress(CElement *element, const CConfig *config) { unsigned short iVar, jVar; unsigned short iGauss, nGauss; diff --git a/SU2_CFD/src/numerics/elasticity/CFEANonlinearElasticity.cpp b/SU2_CFD/src/numerics/elasticity/CFEANonlinearElasticity.cpp index 2d12da7fcddc..9caa43e4bf87 100644 --- a/SU2_CFD/src/numerics/elasticity/CFEANonlinearElasticity.cpp +++ b/SU2_CFD/src/numerics/elasticity/CFEANonlinearElasticity.cpp @@ -30,7 +30,7 @@ CFEANonlinearElasticity::CFEANonlinearElasticity(unsigned short val_nDim, unsigned short val_nVar, - CConfig *config) : CFEAElasticity(val_nDim, val_nVar, config) { + const CConfig *config) : CFEAElasticity(val_nDim, val_nVar, config) { nearly_incompressible = (config->GetMaterialCompressibility() == NEARLY_INCOMPRESSIBLE_MAT); @@ -88,7 +88,7 @@ CFEANonlinearElasticity::CFEANonlinearElasticity(unsigned short val_nDim, unsign if (maxwell_stress == true) { - su2double *Electric_Field_Dir = config->Get_Electric_Field_Dir(); + const su2double *Electric_Field_Dir = config->Get_Electric_Field_Dir(); unsigned short iVar, iDim; su2double ref_Efield_mod; @@ -217,7 +217,7 @@ CFEANonlinearElasticity::~CFEANonlinearElasticity(void) { } -void CFEANonlinearElasticity::Compute_Tangent_Matrix(CElement *element, CConfig *config) { +void CFEANonlinearElasticity::Compute_Tangent_Matrix(CElement *element, const CConfig *config) { unsigned short iVar, jVar, kVar; unsigned short iGauss, nGauss; @@ -468,7 +468,7 @@ void CFEANonlinearElasticity::Compute_Tangent_Matrix(CElement *element, CConfig } -void CFEANonlinearElasticity::Compute_NodalStress_Term(CElement *element, CConfig *config) { +void CFEANonlinearElasticity::Compute_NodalStress_Term(CElement *element, const CConfig *config) { unsigned short iVar, jVar, kVar; unsigned short iGauss, nGauss; @@ -599,7 +599,7 @@ void CFEANonlinearElasticity::Compute_NodalStress_Term(CElement *element, CConfi } -void CFEANonlinearElasticity::Add_MaxwellStress(CElement *element, CConfig *config) { +void CFEANonlinearElasticity::Add_MaxwellStress(CElement *element, const CConfig *config) { // Adds the Maxwell stress to the output of the stress Sxx, Syy, Szz, SVM... @@ -630,7 +630,7 @@ void CFEANonlinearElasticity::Add_MaxwellStress(CElement *element, CConfig *conf } -void CFEANonlinearElasticity::SetElectric_Properties(const CElement *element, CConfig *config) { +void CFEANonlinearElasticity::SetElectric_Properties(const CElement *element, const CConfig *config) { // Set the modulus of the electric field in the current element /*--- These variables are set as preaccumulation inputs in Compute_Tangent_Matrix and @@ -745,7 +745,7 @@ void CFEANonlinearElasticity::Assign_cijkl_D_Mat(void) { } -void CFEANonlinearElasticity::Compute_Averaged_NodalStress(CElement *element, CConfig *config) { +void CFEANonlinearElasticity::Compute_Averaged_NodalStress(CElement *element, const CConfig *config) { unsigned short iVar, jVar, kVar; unsigned short iGauss, nGauss; diff --git a/SU2_CFD/src/numerics/elasticity/nonlinear_models.cpp b/SU2_CFD/src/numerics/elasticity/nonlinear_models.cpp index 331f67347bce..e904d65546aa 100644 --- a/SU2_CFD/src/numerics/elasticity/nonlinear_models.cpp +++ b/SU2_CFD/src/numerics/elasticity/nonlinear_models.cpp @@ -30,11 +30,11 @@ CFEM_NeoHookean_Comp::CFEM_NeoHookean_Comp(unsigned short val_nDim, unsigned short val_nVar, - CConfig *config) : + const CConfig *config) : CFEANonlinearElasticity(val_nDim, val_nVar, config) { } -void CFEM_NeoHookean_Comp::Compute_Plane_Stress_Term(CElement *element, CConfig *config) { +void CFEM_NeoHookean_Comp::Compute_Plane_Stress_Term(CElement *element, const CConfig *config) { su2double j_red = 1.0; su2double fx = 0.0, fpx = 1.0; @@ -68,7 +68,7 @@ void CFEM_NeoHookean_Comp::Compute_Plane_Stress_Term(CElement *element, CConfig } -void CFEM_NeoHookean_Comp::Compute_Constitutive_Matrix(CElement *element, CConfig *config) { +void CFEM_NeoHookean_Comp::Compute_Constitutive_Matrix(CElement *element, const CConfig *config) { su2double Mu_p = 0.0, Lambda_p = 0.0; @@ -98,7 +98,7 @@ void CFEM_NeoHookean_Comp::Compute_Constitutive_Matrix(CElement *element, CConfi } -void CFEM_NeoHookean_Comp::Compute_Stress_Tensor(CElement *element, CConfig *config) { +void CFEM_NeoHookean_Comp::Compute_Stress_Tensor(CElement *element, const CConfig *config) { unsigned short iVar,jVar; su2double Mu_J = 0.0, Lambda_J = 0.0; @@ -119,7 +119,7 @@ void CFEM_NeoHookean_Comp::Compute_Stress_Tensor(CElement *element, CConfig *con } CFEM_Knowles_NearInc::CFEM_Knowles_NearInc(unsigned short val_nDim, unsigned short val_nVar, - CConfig *config) : CFEANonlinearElasticity(val_nDim, val_nVar, config) { + const CConfig *config) : CFEANonlinearElasticity(val_nDim, val_nVar, config) { /* -- The formulation adopted for this material model has been described by: * -- @@ -138,13 +138,13 @@ CFEM_Knowles_NearInc::CFEM_Knowles_NearInc(unsigned short val_nDim, unsigned sho } -void CFEM_Knowles_NearInc::Compute_Plane_Stress_Term(CElement *element, CConfig *config) { +void CFEM_Knowles_NearInc::Compute_Plane_Stress_Term(CElement *element, const CConfig *config) { SU2_MPI::Error("This material model cannot (yet) be used for plane stress.",CURRENT_FUNCTION); } -void CFEM_Knowles_NearInc::Compute_Constitutive_Matrix(CElement *element, CConfig *config) { +void CFEM_Knowles_NearInc::Compute_Constitutive_Matrix(CElement *element, const CConfig *config) { /* -- Suchocki (2011) (full reference in class constructor). ---*/ @@ -182,7 +182,7 @@ void CFEM_Knowles_NearInc::Compute_Constitutive_Matrix(CElement *element, CConfi } -void CFEM_Knowles_NearInc::Compute_Stress_Tensor(CElement *element, CConfig *config) { +void CFEM_Knowles_NearInc::Compute_Stress_Tensor(CElement *element, const CConfig *config) { /* -- Suchocki (2011) (full reference in class constructor). ---*/ @@ -208,12 +208,12 @@ void CFEM_Knowles_NearInc::Compute_Stress_Tensor(CElement *element, CConfig *con } -CFEM_DielectricElastomer::CFEM_DielectricElastomer(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : +CFEM_DielectricElastomer::CFEM_DielectricElastomer(unsigned short val_nDim, unsigned short val_nVar, const CConfig *config) : CFEANonlinearElasticity(val_nDim, val_nVar, config) { } -void CFEM_DielectricElastomer::Compute_Constitutive_Matrix(CElement *element, CConfig *config) { +void CFEM_DielectricElastomer::Compute_Constitutive_Matrix(CElement *element, const CConfig *config) { /*--- This reduces performance by now, but it is temporal ---*/ @@ -234,7 +234,7 @@ void CFEM_DielectricElastomer::Compute_Constitutive_Matrix(CElement *element, CC } -void CFEM_DielectricElastomer::Compute_Stress_Tensor(CElement *element, CConfig *config) { +void CFEM_DielectricElastomer::Compute_Stress_Tensor(CElement *element, const CConfig *config) { unsigned short iDim, jDim; @@ -264,7 +264,7 @@ void CFEM_DielectricElastomer::Compute_Stress_Tensor(CElement *element, CConfig } CFEM_IdealDE::CFEM_IdealDE(unsigned short val_nDim, unsigned short val_nVar, - CConfig *config) : CFEANonlinearElasticity(val_nDim, val_nVar, config) { + const CConfig *config) : CFEANonlinearElasticity(val_nDim, val_nVar, config) { /* -- The formulation adopted for this material model has been described by: * -- @@ -282,13 +282,13 @@ CFEM_IdealDE::CFEM_IdealDE(unsigned short val_nDim, unsigned short val_nVar, } -void CFEM_IdealDE::Compute_Plane_Stress_Term(CElement *element, CConfig *config) { +void CFEM_IdealDE::Compute_Plane_Stress_Term(CElement *element, const CConfig *config) { SU2_MPI::Error("This material model cannot (yet) be used for plane stress.", CURRENT_FUNCTION); } -void CFEM_IdealDE::Compute_Constitutive_Matrix(CElement *element, CConfig *config) { +void CFEM_IdealDE::Compute_Constitutive_Matrix(CElement *element, const CConfig *config) { /* -- Zhao, X. and Suo, Z. (2008) (full reference in class constructor). ---*/ @@ -315,7 +315,7 @@ void CFEM_IdealDE::Compute_Constitutive_Matrix(CElement *element, CConfig *confi } -void CFEM_IdealDE::Compute_Stress_Tensor(CElement *element, CConfig *config) { +void CFEM_IdealDE::Compute_Stress_Tensor(CElement *element, const CConfig *config) { /* -- Zhao, X. and Suo, Z. (2008) (full reference in class constructor). ---*/ diff --git a/SU2_CFD/src/numerics/flow/convection/ausm_slau.cpp b/SU2_CFD/src/numerics/flow/convection/ausm_slau.cpp index cab137b00c61..969b9de9bb72 100644 --- a/SU2_CFD/src/numerics/flow/convection/ausm_slau.cpp +++ b/SU2_CFD/src/numerics/flow/convection/ausm_slau.cpp @@ -27,7 +27,7 @@ #include "../../../../include/numerics/flow/convection/ausm_slau.hpp" -CUpwAUSMPLUS_SLAU_Base_Flow::CUpwAUSMPLUS_SLAU_Base_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : +CUpwAUSMPLUS_SLAU_Base_Flow::CUpwAUSMPLUS_SLAU_Base_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config) : CNumerics(val_nDim, val_nVar, config) { if (config->GetDynamic_Grid() && (SU2_MPI::GetRank() == MASTER_NODE)) @@ -80,7 +80,7 @@ CUpwAUSMPLUS_SLAU_Base_Flow::~CUpwAUSMPLUS_SLAU_Base_Flow(void) { } -void CUpwAUSMPLUS_SLAU_Base_Flow::ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure) +void CUpwAUSMPLUS_SLAU_Base_Flow::ComputeMassAndPressureFluxes(const CConfig* config, su2double &mdot, su2double &pressure) { /*--- For schemes that fit in the general form of AUSM+up and SLAU schemes you can inherit from this class and implement only the specifics, which should be the face mass flux (per unit area) and the face pressure. @@ -149,7 +149,7 @@ void CUpwAUSMPLUS_SLAU_Base_Flow::ApproximateJacobian(su2double **val_Jacobian_i } -void CUpwAUSMPLUS_SLAU_Base_Flow::AccurateJacobian(CConfig *config, su2double **val_Jacobian_i, su2double **val_Jacobian_j) { +void CUpwAUSMPLUS_SLAU_Base_Flow::AccurateJacobian(const CConfig* config, su2double **val_Jacobian_i, su2double **val_Jacobian_j) { /*--- Compute Jacobians using a mixed (numerical/analytical) formulation ---*/ @@ -312,10 +312,8 @@ void CUpwAUSMPLUS_SLAU_Base_Flow::AccurateJacobian(CConfig *config, su2double ** } -void CUpwAUSMPLUS_SLAU_Base_Flow::ComputeResidual(const su2double* &residual, - const su2double* const* &jacobian_i, - const su2double* const* &jacobian_j, - CConfig *config) { +CNumerics::ResidualType<> CUpwAUSMPLUS_SLAU_Base_Flow::ComputeResidual(const CConfig* config) { + unsigned short iDim, iVar; /*--- Space to start preaccumulation ---*/ @@ -377,22 +375,20 @@ void CUpwAUSMPLUS_SLAU_Base_Flow::ComputeResidual(const su2double* &residual, AD::SetPreaccOut(Flux, nVar); AD::EndPreacc(); - residual = Flux; - /*--- If required, compute Jacobians, either approximately (Roe) or numerically ---*/ - if (!implicit) return; + if (implicit) { + if (UseAccurateJacobian) + AccurateJacobian(config, Jacobian_i, Jacobian_j); + else + ApproximateJacobian(Jacobian_i, Jacobian_j); + } - if (UseAccurateJacobian) - AccurateJacobian(config, Jacobian_i, Jacobian_j); - else - ApproximateJacobian(Jacobian_i, Jacobian_j); + return ResidualType<>(Flux, Jacobian_i, Jacobian_j); - jacobian_i = Jacobian_i; - jacobian_j = Jacobian_j; } -CUpwAUSMPLUSUP_Flow::CUpwAUSMPLUSUP_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : +CUpwAUSMPLUSUP_Flow::CUpwAUSMPLUSUP_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config) : CUpwAUSMPLUS_SLAU_Base_Flow(val_nDim, val_nVar, config) { HasAnalyticalDerivatives = true; @@ -405,7 +401,7 @@ CUpwAUSMPLUSUP_Flow::CUpwAUSMPLUSUP_Flow(unsigned short val_nDim, unsigned short SU2_MPI::Error("AUSM+Up requires a reference Mach number (\"MACH_NUMBER\") greater than 0.", CURRENT_FUNCTION); } -void CUpwAUSMPLUSUP_Flow::ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure) { +void CUpwAUSMPLUSUP_Flow::ComputeMassAndPressureFluxes(const CConfig* config, su2double &mdot, su2double &pressure) { /*--- Projected velocities ---*/ @@ -618,7 +614,7 @@ void CUpwAUSMPLUSUP_Flow::ComputeMassAndPressureFluxes(CConfig *config, su2doubl } } -CUpwAUSMPLUSUP2_Flow::CUpwAUSMPLUSUP2_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : +CUpwAUSMPLUSUP2_Flow::CUpwAUSMPLUSUP2_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config) : CUpwAUSMPLUS_SLAU_Base_Flow(val_nDim, val_nVar, config) { Minf = config->GetMach(); @@ -629,7 +625,7 @@ CUpwAUSMPLUSUP2_Flow::CUpwAUSMPLUSUP2_Flow(unsigned short val_nDim, unsigned sho SU2_MPI::Error("AUSM+Up2 requires a reference Mach number (\"MACH_NUMBER\") greater than 0.", CURRENT_FUNCTION); } -void CUpwAUSMPLUSUP2_Flow::ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure) { +void CUpwAUSMPLUSUP2_Flow::ComputeMassAndPressureFluxes(const CConfig* config, su2double &mdot, su2double &pressure) { /*--- Projected velocities and squared magnitude ---*/ @@ -706,14 +702,14 @@ void CUpwAUSMPLUSUP2_Flow::ComputeMassAndPressureFluxes(CConfig *config, su2doub } -CUpwSLAU_Flow::CUpwSLAU_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, bool val_low_dissipation) : +CUpwSLAU_Flow::CUpwSLAU_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config, bool val_low_dissipation) : CUpwAUSMPLUS_SLAU_Base_Flow(val_nDim, val_nVar, config) { slau_low_diss = val_low_dissipation; slau2 = false; } -CUpwSLAU2_Flow::CUpwSLAU2_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, bool val_low_dissipation) : +CUpwSLAU2_Flow::CUpwSLAU2_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config, bool val_low_dissipation) : CUpwSLAU_Flow(val_nDim, val_nVar, config, val_low_dissipation) { /*--- The difference between SLAU and SLAU2 is minimal, so we derive from SLAU and set this flag @@ -722,7 +718,7 @@ CUpwSLAU2_Flow::CUpwSLAU2_Flow(unsigned short val_nDim, unsigned short val_nVar, slau2 = true; } -void CUpwSLAU_Flow::ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure) { +void CUpwSLAU_Flow::ComputeMassAndPressureFluxes(const CConfig* config, su2double &mdot, su2double &pressure) { /*--- Project velocities and speed of sound ---*/ @@ -777,7 +773,7 @@ void CUpwSLAU_Flow::ComputeMassAndPressureFluxes(CConfig *config, su2double &mdo else BetaR = 1.0; if (slau_low_diss) - SetRoe_Dissipation(Dissipation_i, Dissipation_j, Sensor_i, Sensor_j, Dissipation_ij, config); + Dissipation_ij = GetRoe_Dissipation(Dissipation_i, Dissipation_j, Sensor_i, Sensor_j, config); else Dissipation_ij = 1.0; @@ -788,7 +784,7 @@ void CUpwSLAU_Flow::ComputeMassAndPressureFluxes(CConfig *config, su2double &mdo } -CUpwAUSM_Flow::CUpwAUSM_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { +CUpwAUSM_Flow::CUpwAUSM_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config) : CNumerics(val_nDim, val_nVar, config) { if (config->GetDynamic_Grid() && (SU2_MPI::GetRank() == MASTER_NODE)) cout << "WARNING: Grid velocities are NOT yet considered in AUSM-type schemes." << endl; @@ -839,10 +835,8 @@ CUpwAUSM_Flow::~CUpwAUSM_Flow(void) { } -void CUpwAUSM_Flow::ComputeResidual(const su2double* &residual, - const su2double* const* &jacobian_i, - const su2double* const* &jacobian_j, - CConfig *config) { +CNumerics::ResidualType<> CUpwAUSM_Flow::ComputeResidual(const CConfig* config) { + AD::StartPreacc(); AD::SetPreaccIn(Normal, nDim); AD::SetPreaccIn(V_i, nDim+4); @@ -921,8 +915,6 @@ void CUpwAUSM_Flow::ComputeResidual(const su2double* &residual, AD::SetPreaccOut(Flux, nVar); AD::EndPreacc(); - residual = Flux; - /*--- Roe's Jacobian for AUSM (this must be fixed) ---*/ if (implicit) { @@ -971,8 +963,7 @@ void CUpwAUSM_Flow::ComputeResidual(const su2double* &residual, Jacobian_j[iVar][jVar] -= 0.5*Proj_ModJac_Tensor_ij*Area; } } - - jacobian_i = Jacobian_i; - jacobian_j = Jacobian_j; } + + return ResidualType<>(Flux, Jacobian_i, Jacobian_j); } diff --git a/SU2_CFD/src/numerics/flow/convection/centered.cpp b/SU2_CFD/src/numerics/flow/convection/centered.cpp index 2f50d3b59f59..888920527321 100644 --- a/SU2_CFD/src/numerics/flow/convection/centered.cpp +++ b/SU2_CFD/src/numerics/flow/convection/centered.cpp @@ -27,7 +27,7 @@ #include "../../../../include/numerics/flow/convection/centered.hpp" -CCentBase_Flow::CCentBase_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : +CCentBase_Flow::CCentBase_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config) : CNumerics(val_nDim, val_nVar, config) { implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); @@ -62,10 +62,7 @@ CCentBase_Flow::~CCentBase_Flow(void) { delete [] Jacobian_j; } -void CCentBase_Flow::ComputeResidual(const su2double* &residual, - const su2double* const* &jacobian_i, - const su2double* const* &jacobian_j, - CConfig *config) { +CNumerics::ResidualType<> CCentBase_Flow::ComputeResidual(const CConfig* config) { su2double U_i[5] = {0.0}, U_j[5] = {0.0}; @@ -183,9 +180,7 @@ void CCentBase_Flow::ComputeResidual(const su2double* &residual, AD::EndPreacc(); } - residual = ProjFlux; - jacobian_i = Jacobian_i; - jacobian_j = Jacobian_j; + return ResidualType<>(ProjFlux, Jacobian_i, Jacobian_j); } @@ -214,7 +209,7 @@ void CCentBase_Flow::ScalarDissipationJacobian(su2double **val_Jacobian_i, su2do } -CCentLax_Flow::CCentLax_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : +CCentLax_Flow::CCentLax_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config) : CCentBase_Flow(val_nDim, val_nVar, config) { /*--- Artifical dissipation parameters ---*/ @@ -251,7 +246,7 @@ bool CCentLax_Flow::SetPreaccInVars(void) { return true; } -CCentJST_KE_Flow::CCentJST_KE_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : +CCentJST_KE_Flow::CCentJST_KE_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config) : CCentBase_Flow(val_nDim, val_nVar, config) { /*--- Artifical dissipation parameters ---*/ @@ -289,7 +284,7 @@ bool CCentJST_KE_Flow::SetPreaccInVars(void) { return true; } -CCentJST_Flow::CCentJST_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : +CCentJST_Flow::CCentJST_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config) : CCentBase_Flow(val_nDim, val_nVar, config) { /*--- Artifical dissipation parameters ---*/ @@ -338,7 +333,7 @@ bool CCentJST_Flow::SetPreaccInVars(void) { return true; } -CCentLaxInc_Flow::CCentLaxInc_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { +CCentLaxInc_Flow::CCentLaxInc_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config) : CNumerics(val_nDim, val_nVar, config) { implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); variable_density = (config->GetKind_DensityModel() == VARIABLE); @@ -379,7 +374,7 @@ CCentLaxInc_Flow::~CCentLaxInc_Flow(void) { } -void CCentLaxInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { +void CCentLaxInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, const CConfig* config) { su2double U_i[5] = {0.0}, U_j[5] = {0.0}; su2double ProjGridVel = 0.0, ProjVelocity = 0.0; @@ -545,7 +540,7 @@ void CCentLaxInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_ } -CCentJSTInc_Flow::CCentJSTInc_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { +CCentJSTInc_Flow::CCentJSTInc_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config) : CNumerics(val_nDim, val_nVar, config) { implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); variable_density = (config->GetKind_DensityModel() == VARIABLE); @@ -589,7 +584,7 @@ CCentJSTInc_Flow::~CCentJSTInc_Flow(void) { } -void CCentJSTInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { +void CCentJSTInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, const CConfig* config) { su2double U_i[5] = {0.0}, U_j[5] = {0.0}; su2double ProjGridVel = 0.0; diff --git a/SU2_CFD/src/numerics/flow/convection/cusp.cpp b/SU2_CFD/src/numerics/flow/convection/cusp.cpp index b27d1dda6fa0..688fa827f161 100644 --- a/SU2_CFD/src/numerics/flow/convection/cusp.cpp +++ b/SU2_CFD/src/numerics/flow/convection/cusp.cpp @@ -27,7 +27,7 @@ #include "../../../../include/numerics/flow/convection/cusp.hpp" -CUpwCUSP_Flow::CUpwCUSP_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { +CUpwCUSP_Flow::CUpwCUSP_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config) : CNumerics(val_nDim, val_nVar, config) { implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); @@ -61,10 +61,8 @@ CUpwCUSP_Flow::~CUpwCUSP_Flow(void) { delete [] Jacobian_j; } -void CUpwCUSP_Flow::ComputeResidual(const su2double* &residual, - const su2double* const* &jacobian_i, - const su2double* const* &jacobian_j, - CConfig *config) { +CNumerics::ResidualType<> CUpwCUSP_Flow::ComputeResidual(const CConfig* config) { + unsigned short iDim, iVar; su2double Diff_U[5] = {0.0}; @@ -184,8 +182,6 @@ void CUpwCUSP_Flow::ComputeResidual(const su2double* &residual, AD::SetPreaccOut(Flux, nVar); AD::EndPreacc(); - residual = Flux; - jacobian_i = Jacobian_i; - jacobian_j = Jacobian_j; + return ResidualType<>(Flux, Jacobian_i, Jacobian_j); } diff --git a/SU2_CFD/src/numerics/flow/convection/fvs.cpp b/SU2_CFD/src/numerics/flow/convection/fvs.cpp index b3a2e66d9359..84b57b3e41cf 100644 --- a/SU2_CFD/src/numerics/flow/convection/fvs.cpp +++ b/SU2_CFD/src/numerics/flow/convection/fvs.cpp @@ -27,7 +27,7 @@ #include "../../../../include/numerics/flow/convection/fvs.hpp" -CUpwMSW_Flow::CUpwMSW_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { +CUpwMSW_Flow::CUpwMSW_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config) : CNumerics(val_nDim, val_nVar, config) { if (config->GetDynamic_Grid() && (SU2_MPI::GetRank() == MASTER_NODE)) cout << "WARNING: Grid velocities are NOT yet considered in the MSW scheme." << endl; @@ -99,10 +99,7 @@ CUpwMSW_Flow::~CUpwMSW_Flow(void) { } -void CUpwMSW_Flow::ComputeResidual(const su2double* &residual, - const su2double* const* &jacobian_i, - const su2double* const* &jacobian_j, - CConfig *config) { +CNumerics::ResidualType<> CUpwMSW_Flow::ComputeResidual(const CConfig* config) { unsigned short iDim, iVar, jVar, kVar; su2double P_i, P_j; @@ -247,9 +244,7 @@ void CUpwMSW_Flow::ComputeResidual(const su2double* &residual, for (iVar = 0; iVar < nVar; iVar++) { Fc_i[iVar] += Fc_j[iVar]; } - residual = Fc_i; - jacobian_i = Jacobian_i; - jacobian_j = Jacobian_j; + return ResidualType<>(Fc_i, Jacobian_i, Jacobian_j); } diff --git a/SU2_CFD/src/numerics/flow/convection/hllc.cpp b/SU2_CFD/src/numerics/flow/convection/hllc.cpp index 96d2d743abed..fe74a029b92e 100644 --- a/SU2_CFD/src/numerics/flow/convection/hllc.cpp +++ b/SU2_CFD/src/numerics/flow/convection/hllc.cpp @@ -27,7 +27,7 @@ #include "../../../../include/numerics/flow/convection/hllc.hpp" -CUpwHLLC_Flow::CUpwHLLC_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { +CUpwHLLC_Flow::CUpwHLLC_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config) : CNumerics(val_nDim, val_nVar, config) { implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); kappa = config->GetRoe_Kappa(); @@ -81,10 +81,7 @@ CUpwHLLC_Flow::~CUpwHLLC_Flow(void) { } -void CUpwHLLC_Flow::ComputeResidual(const su2double* &residual, - const su2double* const* &jacobian_i, - const su2double* const* &jacobian_j, - CConfig *config) { +CNumerics::ResidualType<> CUpwHLLC_Flow::ComputeResidual(const CConfig* config) { /*--- Face area (norm or the normal vector) ---*/ @@ -262,12 +259,10 @@ void CUpwHLLC_Flow::ComputeResidual(const su2double* &residual, for (iVar = 0; iVar < nVar; iVar++) Flux[iVar] *= Area; - residual = Flux; - /*--- Return early if the Jacobians do not need to be computed. ---*/ - if (!implicit) return; - + if (implicit) + { if (sM > 0.0) { if (sL > 0.0) { @@ -554,13 +549,13 @@ void CUpwHLLC_Flow::ComputeResidual(const su2double* &residual, Jacobian_j[iVar][jVar] *= Area; } } + } // end if implicit - jacobian_i = Jacobian_i; - jacobian_j = Jacobian_j; + return ResidualType<>(Flux, Jacobian_i, Jacobian_j); } -CUpwGeneralHLLC_Flow::CUpwGeneralHLLC_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { +CUpwGeneralHLLC_Flow::CUpwGeneralHLLC_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config) : CNumerics(val_nDim, val_nVar, config) { implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); kappa = config->GetRoe_Kappa(); @@ -612,10 +607,7 @@ CUpwGeneralHLLC_Flow::~CUpwGeneralHLLC_Flow(void) { } -void CUpwGeneralHLLC_Flow::ComputeResidual(const su2double* &residual, - const su2double* const* &jacobian_i, - const su2double* const* &jacobian_j, - CConfig *config) { +CNumerics::ResidualType<> CUpwGeneralHLLC_Flow::ComputeResidual(const CConfig* config) { /*--- Face area (norm or the normal vector) ---*/ @@ -806,12 +798,10 @@ void CUpwGeneralHLLC_Flow::ComputeResidual(const su2double* &residual, for (iVar = 0; iVar < nVar; iVar++) Flux[iVar] *= Area; - residual = Flux; - /*--- Return early if the Jacobians do not need to be computed. ---*/ - if (!implicit) return; - + if (implicit) + { if (sM > 0.0) { if (sL > 0.0) { @@ -1114,9 +1104,9 @@ void CUpwGeneralHLLC_Flow::ComputeResidual(const su2double* &residual, Jacobian_j[iVar][jVar] *= Area; } } + } // end if implicit - jacobian_i = Jacobian_i; - jacobian_j = Jacobian_j; + return ResidualType<>(Flux, Jacobian_i, Jacobian_j); } diff --git a/SU2_CFD/src/numerics/flow/convection/roe.cpp b/SU2_CFD/src/numerics/flow/convection/roe.cpp index 87dad4eca98c..2fdb15ece5e7 100644 --- a/SU2_CFD/src/numerics/flow/convection/roe.cpp +++ b/SU2_CFD/src/numerics/flow/convection/roe.cpp @@ -27,7 +27,7 @@ #include "../../../../include/numerics/flow/convection/roe.hpp" -CUpwRoeBase_Flow::CUpwRoeBase_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, +CUpwRoeBase_Flow::CUpwRoeBase_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config, bool val_low_dissipation) : CNumerics(val_nDim, val_nVar, config) { implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); @@ -81,7 +81,8 @@ CUpwRoeBase_Flow::~CUpwRoeBase_Flow(void) { } -void CUpwRoeBase_Flow::FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { +void CUpwRoeBase_Flow::FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, + su2double **val_Jacobian_j, const CConfig* config) { /*--- CUpwRoeBase_Flow::ComputeResidual initializes the residual (flux) and its Jacobians with the standard Roe averaging fc_{1/2} = kappa*(fc_i+fc_j)*Normal. It then calls this method, which derived classes specialize, to account for @@ -89,10 +90,8 @@ void CUpwRoeBase_Flow::FinalizeResidual(su2double *val_residual, su2double **val ---*/ } -void CUpwRoeBase_Flow::ComputeResidual(const su2double* &residual, - const su2double* const* &jacobian_i, - const su2double* const* &jacobian_j, - CConfig *config) { +CNumerics::ResidualType<> CUpwRoeBase_Flow::ComputeResidual(const CConfig* config) { + unsigned short iVar, jVar, iDim; su2double ProjGridVel = 0.0, Energy_i, Energy_j; @@ -162,10 +161,8 @@ void CUpwRoeBase_Flow::ComputeResidual(const su2double* &residual, } AD::SetPreaccOut(Flux, nVar); AD::EndPreacc(); - residual = Flux; - jacobian_i = Jacobian_i; - jacobian_j = Jacobian_j; - return; + + return ResidualType<>(Flux, Jacobian_i, Jacobian_j); } RoeSoundSpeed = sqrt(RoeSoundSpeed2); @@ -248,17 +245,15 @@ void CUpwRoeBase_Flow::ComputeResidual(const su2double* &residual, AD::SetPreaccOut(Flux, nVar); AD::EndPreacc(); - residual = Flux; - jacobian_i = Jacobian_i; - jacobian_j = Jacobian_j; + return ResidualType<>(Flux, Jacobian_i, Jacobian_j); } -CUpwRoe_Flow::CUpwRoe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, +CUpwRoe_Flow::CUpwRoe_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config, bool val_low_dissipation) : CUpwRoeBase_Flow(val_nDim, val_nVar, config, val_low_dissipation) {} void CUpwRoe_Flow::FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, - su2double **val_Jacobian_j, CConfig *config) { + su2double **val_Jacobian_j, const CConfig* config) { unsigned short iVar, jVar, kVar; @@ -271,7 +266,7 @@ void CUpwRoe_Flow::FinalizeResidual(su2double *val_residual, su2double **val_Jac /*--- Low dissipation formulation ---*/ if (roe_low_dissipation) - SetRoe_Dissipation(Dissipation_i, Dissipation_j, Sensor_i, Sensor_j, Dissipation_ij, config); + Dissipation_ij = GetRoe_Dissipation(Dissipation_i, Dissipation_j, Sensor_i, Sensor_j, config); else Dissipation_ij = 1.0; @@ -296,11 +291,11 @@ void CUpwRoe_Flow::FinalizeResidual(su2double *val_residual, su2double **val_Jac } -CUpwL2Roe_Flow::CUpwL2Roe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : +CUpwL2Roe_Flow::CUpwL2Roe_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config) : CUpwRoeBase_Flow(val_nDim, val_nVar, config, false) {} void CUpwL2Roe_Flow::FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, - su2double **val_Jacobian_j, CConfig *config) { + su2double **val_Jacobian_j, const CConfig* config) { /*--- L2Roe: a low dissipation version of Roe's approximate Riemann solver for low Mach numbers. IJNMF 2015 ---*/ @@ -369,11 +364,11 @@ void CUpwL2Roe_Flow::FinalizeResidual(su2double *val_residual, su2double **val_J } -CUpwLMRoe_Flow::CUpwLMRoe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : +CUpwLMRoe_Flow::CUpwLMRoe_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config) : CUpwRoeBase_Flow(val_nDim, val_nVar, config, false) {} void CUpwLMRoe_Flow::FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, - su2double **val_Jacobian_j, CConfig *config) { + su2double **val_Jacobian_j, const CConfig* config) { /*--- Rieper, A low-Mach number fix for Roe's approximate Riemman Solver, JCP 2011 ---*/ @@ -442,7 +437,7 @@ void CUpwLMRoe_Flow::FinalizeResidual(su2double *val_residual, su2double **val_J } -CUpwTurkel_Flow::CUpwTurkel_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { +CUpwTurkel_Flow::CUpwTurkel_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config) : CNumerics(val_nDim, val_nVar, config) { implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ @@ -511,10 +506,7 @@ CUpwTurkel_Flow::~CUpwTurkel_Flow(void) { } -void CUpwTurkel_Flow::ComputeResidual(const su2double* &residual, - const su2double* const* &jacobian_i, - const su2double* const* &jacobian_j, - CConfig *config) { +CNumerics::ResidualType<> CUpwTurkel_Flow::ComputeResidual(const CConfig* config) { su2double U_i[5] = {0.0}, U_j[5] = {0.0}; @@ -682,13 +674,11 @@ void CUpwTurkel_Flow::ComputeResidual(const su2double* &residual, } } - residual = Flux; - jacobian_i = Jacobian_i; - jacobian_j = Jacobian_j; + return ResidualType<>(Flux, Jacobian_i, Jacobian_j); } -CUpwGeneralRoe_Flow::CUpwGeneralRoe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { +CUpwGeneralRoe_Flow::CUpwGeneralRoe_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config) : CNumerics(val_nDim, val_nVar, config) { implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ @@ -745,10 +735,8 @@ CUpwGeneralRoe_Flow::~CUpwGeneralRoe_Flow(void) { } -void CUpwGeneralRoe_Flow::ComputeResidual(const su2double* &residual, - const su2double* const* &jacobian_i, - const su2double* const* &jacobian_j, - CConfig *config) { +CNumerics::ResidualType<> CUpwGeneralRoe_Flow::ComputeResidual(const CConfig* config) { + AD::StartPreacc(); AD::SetPreaccIn(V_i, nDim+4); AD::SetPreaccIn(V_j, nDim+4); AD::SetPreaccIn(Normal, nDim); AD::SetPreaccIn(S_i, 2); AD::SetPreaccIn(S_j, 2); @@ -830,10 +818,8 @@ void CUpwGeneralRoe_Flow::ComputeResidual(const su2double* &residual, } AD::SetPreaccOut(Flux, nVar); AD::EndPreacc(); - residual = Flux; - jacobian_i = Jacobian_i; - jacobian_j = Jacobian_j; - return; + + return ResidualType<>(Flux, Jacobian_i, Jacobian_j); } RoeSoundSpeed = sqrt(RoeSoundSpeed2); @@ -993,9 +979,7 @@ void CUpwGeneralRoe_Flow::ComputeResidual(const su2double* &residual, AD::SetPreaccOut(Flux, nVar); AD::EndPreacc(); - residual = Flux; - jacobian_i = Jacobian_i; - jacobian_j = Jacobian_j; + return ResidualType<>(Flux, Jacobian_i, Jacobian_j); } diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 14c22df0e2b2..fa48caf356e4 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -3300,19 +3300,16 @@ void CEulerSolver::Centered_Residual(CGeometry *geometry, CSolver **solver_conta /*--- Compute residuals, and Jacobians ---*/ - const su2double* flux; - const su2double* const* jacobian_i; - const su2double* const* jacobian_j; - numerics->ComputeResidual(flux, jacobian_i, jacobian_j, config); + auto residual = numerics->ComputeResidual(config); /*--- Update convective and artificial dissipation residuals ---*/ - LinSysRes.AddBlock(iPoint, flux); - LinSysRes.SubtractBlock(jPoint, flux); + LinSysRes.AddBlock(iPoint, residual); + LinSysRes.SubtractBlock(jPoint, residual); /*--- Set implicit computation ---*/ if (implicit) { - Jacobian.UpdateBlocks(iEdge, iPoint, jPoint, jacobian_i, jacobian_j); + Jacobian.UpdateBlocks(iEdge, iPoint, jPoint, residual.jacobian_i, residual.jacobian_j); } } } // end color loop @@ -3518,20 +3515,17 @@ void CEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_contain /*--- Compute the residual ---*/ - const su2double* flux; - const su2double* const* jacobian_i; - const su2double* const* jacobian_j; - numerics->ComputeResidual(flux, jacobian_i, jacobian_j, config); + auto residual = numerics->ComputeResidual(config); /*--- Update residual value ---*/ - LinSysRes.AddBlock(iPoint, flux); - LinSysRes.SubtractBlock(jPoint, flux); + LinSysRes.AddBlock(iPoint, residual); + LinSysRes.SubtractBlock(jPoint, residual); /*--- Set implicit Jacobians ---*/ if (implicit) { - Jacobian.UpdateBlocks(iEdge, iPoint, jPoint, jacobian_i, jacobian_j); + Jacobian.UpdateBlocks(iEdge, iPoint, jPoint, residual.jacobian_i, residual.jacobian_j); } /*--- Set the final value of the Roe dissipation coefficient ---*/ @@ -7458,17 +7452,15 @@ void CEulerSolver::BC_Sym_Plane(CGeometry *geometry, nodes->GetSecondary(iPoint)); /*--- Compute the residual using an upwind scheme. ---*/ - const su2double* flux; - const su2double* const* jacobian_i; - const su2double* const* jacobian_j; - conv_numerics->ComputeResidual(flux, jacobian_i, jacobian_j, config); + + auto residual = conv_numerics->ComputeResidual(config); /*--- Update residual value ---*/ - LinSysRes.AddBlock(iPoint, flux); + LinSysRes.AddBlock(iPoint, residual); /*--- Jacobian contribution for implicit integration. ---*/ if (implicit) { - Jacobian.AddBlock(iPoint, iPoint, jacobian_i); + Jacobian.AddBlock(iPoint, iPoint, residual.jacobian_i); } if (viscous) { @@ -7786,19 +7778,16 @@ void CEulerSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_container, /*--- Compute the convective residual using an upwind scheme ---*/ - const su2double* flux; - const su2double* const* jacobian_i; - const su2double* const* jacobian_j; - conv_numerics->ComputeResidual(flux, jacobian_i, jacobian_j, config); + auto residual = conv_numerics->ComputeResidual(config); /*--- Update residual value ---*/ - LinSysRes.AddBlock(iPoint, flux); + LinSysRes.AddBlock(iPoint, residual); /*--- Convective Jacobian contribution for implicit integration ---*/ if (implicit) - Jacobian.AddBlock(iPoint, iPoint, jacobian_i); + Jacobian.AddBlock(iPoint, iPoint, residual.jacobian_i); /*--- Viscous residual contribution ---*/ @@ -9651,17 +9640,14 @@ void CEulerSolver::BC_Giles(CGeometry *geometry, CSolver **solver_container, CNu /*--- Compute the residual using an upwind scheme ---*/ - const su2double* flux; - const su2double* const* jacobian_i; - const su2double* const* jacobian_j; - conv_numerics->ComputeResidual(flux, jacobian_i, jacobian_j, config); + auto residual = conv_numerics->ComputeResidual(config); /*--- Update residual value ---*/ - LinSysRes.AddBlock(iPoint, flux); + LinSysRes.AddBlock(iPoint, residual); /*--- Jacobian contribution for implicit integration ---*/ if (implicit) - Jacobian.AddBlock(iPoint, iPoint, jacobian_i); + Jacobian.AddBlock(iPoint, iPoint, residual.jacobian_i); /*--- Viscous contribution ---*/ @@ -9995,19 +9981,16 @@ void CEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, /*--- Compute the residual using an upwind scheme ---*/ - const su2double* flux; - const su2double* const* jacobian_i; - const su2double* const* jacobian_j; - conv_numerics->ComputeResidual(flux, jacobian_i, jacobian_j, config); + auto residual = conv_numerics->ComputeResidual(config); /*--- Update residual value ---*/ - LinSysRes.AddBlock(iPoint, flux); + LinSysRes.AddBlock(iPoint, residual); /*--- Jacobian contribution for implicit integration ---*/ if (implicit) - Jacobian.AddBlock(iPoint, iPoint, jacobian_i); + Jacobian.AddBlock(iPoint, iPoint, residual.jacobian_i); // /*--- Viscous contribution, commented out because serious convergence problems ---*/ // @@ -10174,16 +10157,14 @@ void CEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, conv_numerics->SetGridVel(geometry->node[iPoint]->GetGridVel(), geometry->node[iPoint]->GetGridVel()); /*--- Compute the residual using an upwind scheme ---*/ - const su2double* flux; - const su2double* const* jacobian_i; - const su2double* const* jacobian_j; - conv_numerics->ComputeResidual(flux, jacobian_i, jacobian_j, config); + + auto residual = conv_numerics->ComputeResidual(config); /*--- Add Residuals and Jacobians ---*/ - LinSysRes.AddBlock(iPoint, flux); + LinSysRes.AddBlock(iPoint, residual); if (implicit) - Jacobian.AddBlock(iPoint, iPoint, jacobian_i); + Jacobian.AddBlock(iPoint, iPoint, residual.jacobian_i); // /*--- Viscous contribution, commented out because serious convergence problems ---*/ // @@ -10318,16 +10299,14 @@ void CEulerSolver::BC_Supersonic_Inlet(CGeometry *geometry, CSolver **solver_con /*--- Compute the residual using an upwind scheme ---*/ - const su2double* flux; - const su2double* const* jacobian_i; - const su2double* const* jacobian_j; - conv_numerics->ComputeResidual(flux, jacobian_i, jacobian_j, config); - LinSysRes.AddBlock(iPoint, flux); + auto residual = conv_numerics->ComputeResidual(config); + + LinSysRes.AddBlock(iPoint, residual); /*--- Jacobian contribution for implicit integration ---*/ if (implicit) - Jacobian.AddBlock(iPoint, iPoint, jacobian_i); + Jacobian.AddBlock(iPoint, iPoint, residual.jacobian_i); // /*--- Viscous contribution, commented out because serious convergence problems ---*/ // @@ -10440,16 +10419,14 @@ void CEulerSolver::BC_Supersonic_Outlet(CGeometry *geometry, CSolver **solver_co /*--- Compute the residual using an upwind scheme ---*/ - const su2double* flux; - const su2double* const* jacobian_i; - const su2double* const* jacobian_j; - conv_numerics->ComputeResidual(flux, jacobian_i, jacobian_j, config); - LinSysRes.AddBlock(iPoint, flux); + auto residual = conv_numerics->ComputeResidual(config); + + LinSysRes.AddBlock(iPoint, residual); /*--- Jacobian contribution for implicit integration ---*/ if (implicit) - Jacobian.AddBlock(iPoint, iPoint, jacobian_i); + Jacobian.AddBlock(iPoint, iPoint, residual.jacobian_i); // /*--- Viscous contribution, commented out because serious convergence problems ---*/ // @@ -10664,16 +10641,14 @@ void CEulerSolver::BC_Engine_Inflow(CGeometry *geometry, CSolver **solver_contai /*--- Compute the residual using an upwind scheme ---*/ - const su2double* flux; - const su2double* const* jacobian_i; - const su2double* const* jacobian_j; - conv_numerics->ComputeResidual(flux, jacobian_i, jacobian_j, config); - LinSysRes.AddBlock(iPoint, flux); + auto residual = conv_numerics->ComputeResidual(config); + + LinSysRes.AddBlock(iPoint, residual); /*--- Jacobian contribution for implicit integration ---*/ if (implicit) - Jacobian.AddBlock(iPoint, iPoint, jacobian_i); + Jacobian.AddBlock(iPoint, iPoint, residual.jacobian_i); // /*--- Viscous contribution, commented out because serious convergence problems ---*/ // @@ -10920,16 +10895,14 @@ void CEulerSolver::BC_Engine_Exhaust(CGeometry *geometry, CSolver **solver_conta /*--- Compute the residual using an upwind scheme ---*/ - const su2double* flux; - const su2double* const* jacobian_i; - const su2double* const* jacobian_j; - conv_numerics->ComputeResidual(flux, jacobian_i, jacobian_j, config); - LinSysRes.AddBlock(iPoint, flux); + auto residual = conv_numerics->ComputeResidual(config); + + LinSysRes.AddBlock(iPoint, residual); /*--- Jacobian contribution for implicit integration ---*/ if (implicit) - Jacobian.AddBlock(iPoint, iPoint, jacobian_i); + Jacobian.AddBlock(iPoint, iPoint, residual.jacobian_i); // /*--- Viscous contribution, commented out because serious convergence problems ---*/ // @@ -11060,17 +11033,14 @@ void CEulerSolver::BC_Fluid_Interface(CGeometry *geometry, CSolver **solver_cont /*--- Compute the convective residual using an upwind scheme ---*/ - const su2double* flux; - const su2double* const* jacobian_i; - const su2double* const* jacobian_j; - conv_numerics->ComputeResidual(flux, jacobian_i, jacobian_j, config); + auto residual = conv_numerics->ComputeResidual(config); /*--- Accumulate the residuals to compute the average ---*/ for (iVar = 0; iVar < nVar; iVar++) { - Residual[iVar] += weight*flux[iVar]; + Residual[iVar] += weight*residual.residual[iVar]; for (jVar = 0; jVar < nVar; jVar++) - Jacobian_i[iVar][jVar] += weight*jacobian_i[iVar][jVar]; + Jacobian_i[iVar][jVar] += weight*residual.jacobian_i[iVar][jVar]; } } @@ -11184,15 +11154,13 @@ void CEulerSolver::BC_Interface_Boundary(CGeometry *geometry, CSolver **solver_c /*--- Compute the convective residual using an upwind scheme ---*/ - const su2double* flux; - const su2double* const* jacobian_i; - const su2double* const* jacobian_j; - numerics->ComputeResidual(flux, jacobian_i, jacobian_j, config); + + auto residual = numerics->ComputeResidual(config); /*--- Add Residuals and Jacobians ---*/ - LinSysRes.AddBlock(iPoint, flux); - if (implicit) Jacobian.AddBlock(iPoint, iPoint, jacobian_i); + LinSysRes.AddBlock(iPoint, residual); + if (implicit) Jacobian.AddBlock(iPoint, iPoint, residual.jacobian_i); } @@ -11248,16 +11216,14 @@ void CEulerSolver::BC_NearField_Boundary(CGeometry *geometry, CSolver **solver_c /*--- Compute the convective residual using an upwind scheme ---*/ - const su2double* flux; - const su2double* const* jacobian_i; - const su2double* const* jacobian_j; - numerics->ComputeResidual(flux, jacobian_i, jacobian_j, config); + auto residual = numerics->ComputeResidual(config); /*--- Add Residuals and Jacobians ---*/ - LinSysRes.AddBlock(iPoint, flux); - if (implicit) Jacobian.AddBlock(iPoint, iPoint, jacobian_i); + LinSysRes.AddBlock(iPoint, residual); + if (implicit) + Jacobian.AddBlock(iPoint, iPoint, residual.jacobian_i); } } @@ -11628,18 +11594,15 @@ void CEulerSolver::BC_ActDisk(CGeometry *geometry, CSolver **solver_container, C /*--- Compute the residual using an upwind scheme ---*/ - const su2double* flux; - const su2double* const* jacobian_i; - const su2double* const* jacobian_j; - conv_numerics->ComputeResidual(flux, jacobian_i, jacobian_j, config); + auto residual = conv_numerics->ComputeResidual(config); /*--- Update residual value ---*/ - LinSysRes.AddBlock(iPoint, flux); + LinSysRes.AddBlock(iPoint, residual); /*--- Jacobian contribution for implicit integration ---*/ - if (implicit) Jacobian.AddBlock(iPoint, iPoint, jacobian_i); + if (implicit) Jacobian.AddBlock(iPoint, iPoint, residual.jacobian_i); // /*--- Viscous contribution, commented out because serious convergence problems ---*/ // From 317753a628912b1bdb90d5e44e826551cbafd7d1 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Wed, 29 Jan 2020 16:03:11 +0000 Subject: [PATCH 040/118] parallel CEulerSolver::SourceResidual --- SU2_CFD/src/solvers/CEulerSolver.cpp | 81 ++++++++++++---------------- 1 file changed, 35 insertions(+), 46 deletions(-) diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index fa48caf356e4..4a8cce64259c 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -3610,8 +3610,6 @@ void CEulerSolver::LowMachPrimitiveCorrection(CFluidModel *fluidModel, unsigned void CEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics_container, CConfig *config, unsigned short iMesh) { - CNumerics* numerics = numerics_container[SOURCE_FIRST_TERM]; - const bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); const bool rotating_frame = config->GetRotating_Frame(); const bool axisymmetric = config->GetAxisymmetric(); @@ -3620,21 +3618,20 @@ void CEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_contain const bool windgust = config->GetWind_Gust(); const bool body_force = config->GetBody_Force(); -// /*--- Start OpenMP parallel section. ---*/ -// -// SU2_OMP_PARALLEL_(reduction(+:counter_local)) -// { + /*--- Start OpenMP parallel section. ---*/ + + SU2_OMP_PARALLEL + { + /*--- Pick one numerics object per thread. ---*/ + CNumerics* numerics = numerics_container[SOURCE_FIRST_TERM + omp_get_thread_num()*MAX_TERMS]; unsigned short iVar; unsigned long iPoint; - /*--- Initialize the source residual to zero ---*/ - - for (iVar = 0; iVar < nVar; iVar++) Residual[iVar] = 0.0; - if (body_force) { /*--- Loop over all points ---*/ + SU2_OMP_FOR_DYN(omp_chunk_size) for (iPoint = 0; iPoint < nPointDomain; iPoint++) { /*--- Load the conservative variables ---*/ @@ -3645,10 +3642,10 @@ void CEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_contain numerics->SetVolume(geometry->node[iPoint]->GetVolume()); /*--- Compute the rotating frame source residual ---*/ - numerics->ComputeResidual(Residual, config); + auto residual = numerics->ComputeResidual(config); /*--- Add the source residual to the total ---*/ - LinSysRes.AddBlock(iPoint, Residual); + LinSysRes.AddBlock(iPoint, residual); } } @@ -3658,9 +3655,12 @@ void CEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_contain /*--- Include the residual contribution from GCL due to the static mesh movement that is set for rotating frame. ---*/ + SU2_OMP_MASTER SetRotatingFrame_GCL(geometry, config); + SU2_OMP_BARRIER /*--- Loop over all points ---*/ + SU2_OMP_FOR_DYN(omp_chunk_size) for (iPoint = 0; iPoint < nPointDomain; iPoint++) { /*--- Load the conservative variables ---*/ @@ -3671,27 +3671,21 @@ void CEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_contain numerics->SetVolume(geometry->node[iPoint]->GetVolume()); /*--- Compute the rotating frame source residual ---*/ - numerics->ComputeResidual(Residual, Jacobian_i, config); + auto residual = numerics->ComputeResidual(config); /*--- Add the source residual to the total ---*/ - LinSysRes.AddBlock(iPoint, Residual); + LinSysRes.AddBlock(iPoint, residual); /*--- Add the implicit Jacobian contribution ---*/ - if (implicit) Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + if (implicit) Jacobian.AddBlock(iPoint, iPoint, residual.jacobian_i); } } if (axisymmetric) { - /*--- Zero out Jacobian structure ---*/ - if (implicit) { - for (iVar = 0; iVar < nVar; iVar ++) - for (unsigned short jVar = 0; jVar < nVar; jVar ++) - Jacobian_i[iVar][jVar] = 0.0; - } - /*--- loop over points ---*/ + SU2_OMP_FOR_DYN(omp_chunk_size) for (iPoint = 0; iPoint < nPointDomain; iPoint++) { /*--- Set solution ---*/ @@ -3704,20 +3698,21 @@ void CEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_contain numerics->SetCoord(geometry->node[iPoint]->GetCoord(), geometry->node[iPoint]->GetCoord()); /*--- Compute Source term Residual ---*/ - numerics->ComputeResidual(Residual, Jacobian_i, config); + auto residual = numerics->ComputeResidual(config); /*--- Add Residual ---*/ - LinSysRes.AddBlock(iPoint, Residual); + LinSysRes.AddBlock(iPoint, residual); /*--- Implicit part ---*/ if (implicit) - Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + Jacobian.AddBlock(iPoint, iPoint, residual.jacobian_i); } } if (gravity) { /*--- loop over points ---*/ + SU2_OMP_FOR_DYN(omp_chunk_size) for (iPoint = 0; iPoint < nPointDomain; iPoint++) { /*--- Set solution ---*/ @@ -3727,10 +3722,10 @@ void CEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_contain numerics->SetVolume(geometry->node[iPoint]->GetVolume()); /*--- Compute Source term Residual ---*/ - numerics->ComputeResidual(Residual, config); + auto residual = numerics->ComputeResidual(config); /*--- Add Residual ---*/ - LinSysRes.AddBlock(iPoint, Residual); + LinSysRes.AddBlock(iPoint, residual); } @@ -3738,29 +3733,24 @@ void CEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_contain if (harmonic_balance) { - su2double Volume, Source; - /*--- loop over points ---*/ + SU2_OMP_FOR_STAT(omp_chunk_size) for (iPoint = 0; iPoint < nPointDomain; iPoint++) { /*--- Get control volume ---*/ - Volume = geometry->node[iPoint]->GetVolume(); + su2double Volume = geometry->node[iPoint]->GetVolume(); - /*--- Get stored time spectral source term ---*/ + /*--- Get stored time spectral source term and add to residual ---*/ for (iVar = 0; iVar < nVar; iVar++) { - Source = nodes->GetHarmonicBalance_Source(iPoint,iVar); - Residual[iVar] = Source*Volume; + LinSysRes[iPoint*nVar+iVar] += Volume * nodes->GetHarmonicBalance_Source(iPoint,iVar); } - - /*--- Add Residual ---*/ - LinSysRes.AddBlock(iPoint, Residual); - } } if (windgust) { /*--- Loop over all points ---*/ + SU2_OMP_FOR_DYN(omp_chunk_size) for (iPoint = 0; iPoint < nPointDomain; iPoint++) { /*--- Load the wind gust ---*/ @@ -3776,13 +3766,13 @@ void CEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_contain numerics->SetVolume(geometry->node[iPoint]->GetVolume()); /*--- Compute the rotating frame source residual ---*/ - numerics->ComputeResidual(Residual, Jacobian_i, config); + auto residual = numerics->ComputeResidual(config); /*--- Add the source residual to the total ---*/ - LinSysRes.AddBlock(iPoint, Residual); + LinSysRes.AddBlock(iPoint, residual); /*--- Add the implicit Jacobian contribution ---*/ - if (implicit) Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + if (implicit) Jacobian.AddBlock(iPoint, iPoint, residual.jacobian_i); } } @@ -3797,6 +3787,7 @@ void CEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_contain if (config->GetTime_Marching()) time = config->GetPhysicalTime(); /*--- Loop over points ---*/ + SU2_OMP_FOR_DYN(omp_chunk_size) for (iPoint = 0; iPoint < nPointDomain; iPoint++) { /*--- Get control volume size. ---*/ @@ -3809,18 +3800,16 @@ void CEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_contain vector sourceMan(nVar,0.0); VerificationSolution->GetMMSSourceTerm(coor, time, sourceMan.data()); - /*--- Compute the residual for this control volume. ---*/ + /*--- Compute the residual for this control volume and subtract. ---*/ for (iVar = 0; iVar < nVar; iVar++) { - Residual[iVar] = sourceMan[iVar]*Volume; + LinSysRes[iPoint*nVar+iVar] -= sourceMan[iVar]*Volume; } - - /*--- Subtract Residual ---*/ - LinSysRes.SubtractBlock(iPoint, Residual); - } } } + } // end SU2_OMP_PARALLEL + } void CEulerSolver::Source_Template(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, From 4ff3d7116972bf93ab09b057738996196936a2cc Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Wed, 29 Jan 2020 17:33:06 +0000 Subject: [PATCH 041/118] fluid source classes made thread-safe --- Common/include/config_structure.hpp | 2 +- .../include/numerics/flow/flow_sources.hpp | 107 +++--- SU2_CFD/src/numerics/flow/flow_sources.cpp | 319 ++++++++++-------- 3 files changed, 239 insertions(+), 189 deletions(-) diff --git a/Common/include/config_structure.hpp b/Common/include/config_structure.hpp index 5a590b5022e8..603c91430601 100644 --- a/Common/include/config_structure.hpp +++ b/Common/include/config_structure.hpp @@ -5822,7 +5822,7 @@ class CConfig { * \brief Get a pointer to the body force vector. * \return A pointer to the body force vector. */ - su2double* GetBody_Force_Vector(void) { return Body_Force_Vector; } + const su2double* GetBody_Force_Vector(void) const { return Body_Force_Vector; } /*! * \brief Get information about the rotational frame. diff --git a/SU2_CFD/include/numerics/flow/flow_sources.hpp b/SU2_CFD/include/numerics/flow/flow_sources.hpp index 13ccb68187e1..89a4a7a8cb7a 100644 --- a/SU2_CFD/include/numerics/flow/flow_sources.hpp +++ b/SU2_CFD/include/numerics/flow/flow_sources.hpp @@ -29,13 +29,41 @@ #include "../CNumerics.hpp" +/*! + * \class CSourceBase_Flow + * \brief Intermediate source term class to allocate the internally + * stored residual and Jacobian. Not for stand alone use, + * just a helper to build more complicated classes. + * \ingroup SourceDiscr + */ +class CSourceBase_Flow : public CNumerics { +protected: + su2double* residual = nullptr; + su2double** jacobian = nullptr; + + /*! + * \brief Constructor of the class. + * \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. + */ + CSourceBase_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config); + +public: + /*! + * \brief Destructor of the class. + */ + virtual ~CSourceBase_Flow(); + +}; + /*! * \class CSourceAxisymmetric_Flow * \brief Class for source term for solving axisymmetric problems. * \ingroup SourceDiscr * \author F. Palacios */ -class CSourceAxisymmetric_Flow : public CNumerics { +class CSourceAxisymmetric_Flow final : public CSourceBase_Flow { public: /*! * \brief Constructor of the class. @@ -43,14 +71,14 @@ class CSourceAxisymmetric_Flow : public CNumerics { * \param[in] val_nVar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CSourceAxisymmetric_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + CSourceAxisymmetric_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config); /*! * \brief Residual of the rotational frame source term. - * \param[out] val_residual - Pointer to the total residual. * \param[in] config - Definition of the particular problem. + * \return Lightweight const-view of residual and Jacobian. */ - void ComputeResidual(su2double *val_residual, su2double **Jacobian_i, CConfig *config); + ResidualType<> ComputeResidual(const CConfig* config) override; }; @@ -60,7 +88,7 @@ class CSourceAxisymmetric_Flow : public CNumerics { * \ingroup SourceDiscr * \author T. Economon */ -class CSourceIncAxisymmetric_Flow : public CNumerics { +class CSourceIncAxisymmetric_Flow final : public CSourceBase_Flow { bool implicit, /*!< \brief Implicit calculation. */ viscous, /*!< \brief Viscous incompressible flows. */ energy; /*!< \brief computation with the energy equation. */ @@ -72,14 +100,14 @@ class CSourceIncAxisymmetric_Flow : public CNumerics { * \param[in] val_nVar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CSourceIncAxisymmetric_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + CSourceIncAxisymmetric_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config); /*! * \brief Residual of the rotational frame source term. - * \param[out] val_residual - Pointer to the total residual. * \param[in] config - Definition of the particular problem. + * \return Lightweight const-view of residual and Jacobian. */ - void ComputeResidual(su2double *val_residual, su2double **Jacobian_i, CConfig *config); + ResidualType<> ComputeResidual(const CConfig* config) override; }; @@ -89,24 +117,23 @@ class CSourceIncAxisymmetric_Flow : public CNumerics { * \ingroup SourceDiscr * \author T. Economon */ -class CSourceBodyForce : public CNumerics { +class CSourceBodyForce final : public CSourceBase_Flow { su2double Body_Force_Vector[3]; public: - /*! * \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. */ - CSourceBodyForce(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + CSourceBodyForce(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config); /*! * \brief Source term integration for a body force. - * \param[out] val_residual - Pointer to the residual vector. * \param[in] config - Definition of the particular problem. + * \return Lightweight const-view of residual and Jacobian. */ - void ComputeResidual(su2double *val_residual, CConfig *config); + ResidualType<> ComputeResidual(const CConfig* config) override; }; @@ -117,7 +144,7 @@ class CSourceBodyForce : public CNumerics { * \author T. Economon * \version 7.0.0 "Blackbird" */ -class CSourceIncBodyForce : public CNumerics { +class CSourceIncBodyForce final : public CSourceBase_Flow { su2double Body_Force_Vector[3]; public: @@ -126,14 +153,14 @@ class CSourceIncBodyForce : public CNumerics { * \param[in] val_nVar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CSourceIncBodyForce(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + CSourceIncBodyForce(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config); /*! * \brief Source term integration for a body force. - * \param[out] val_residual - Pointer to the residual vector. * \param[in] config - Definition of the particular problem. + * \return Lightweight const-view of residual and Jacobian. */ - void ComputeResidual(su2double *val_residual, CConfig *config); + ResidualType<> ComputeResidual(const CConfig* config) override; }; @@ -144,7 +171,7 @@ class CSourceIncBodyForce : public CNumerics { * \author T. Economon * \version 7.0.0 "Blackbird" */ -class CSourceBoussinesq : public CNumerics { +class CSourceBoussinesq final : public CSourceBase_Flow { su2double Gravity_Vector[3]; public: @@ -153,14 +180,14 @@ class CSourceBoussinesq : public CNumerics { * \param[in] val_nVar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CSourceBoussinesq(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + CSourceBoussinesq(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config); /*! * \brief Source term integration for the Boussinesq approximation. - * \param[out] val_residual - Pointer to the residual vector. * \param[in] config - Definition of the particular problem. + * \return Lightweight const-view of residual and Jacobian. */ - void ComputeResidual(su2double *val_residual, CConfig *config); + ResidualType<> ComputeResidual(const CConfig* config) override; }; @@ -170,21 +197,22 @@ class CSourceBoussinesq : public CNumerics { * \ingroup SourceDiscr * \author F. Palacios */ -class CSourceGravity : public CNumerics { +class CSourceGravity final : public CSourceBase_Flow { public: /*! * \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. */ - CSourceGravity(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + CSourceGravity(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config); /*! * \brief Source term integration for the poissonal potential. - * \param[out] val_residual - Pointer to the total residual. * \param[in] config - Definition of the particular problem. + * \return Lightweight const-view of residual and Jacobian. */ - void ComputeResidual(su2double *val_residual, CConfig *config); + ResidualType<> ComputeResidual(const CConfig* config) override; + }; /*! @@ -193,7 +221,7 @@ class CSourceGravity : public CNumerics { * \ingroup SourceDiscr * \author F. Palacios, T. Economon. */ -class CSourceRotatingFrame_Flow : public CNumerics { +class CSourceRotatingFrame_Flow final : public CSourceBase_Flow { public: /*! * \brief Constructor of the class. @@ -201,15 +229,15 @@ class CSourceRotatingFrame_Flow : public CNumerics { * \param[in] val_nVar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CSourceRotatingFrame_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + CSourceRotatingFrame_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config); /*! * \brief Residual of the rotational frame source term. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). * \param[in] config - Definition of the particular problem. + * \return Lightweight const-view of residual and Jacobian. */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config); + ResidualType<> ComputeResidual(const CConfig* config) override; + }; /*! @@ -217,7 +245,7 @@ class CSourceRotatingFrame_Flow : public CNumerics { * \brief Class for a rotating frame source term. * \ingroup SourceDiscr */ -class CSourceIncRotatingFrame_Flow : public CNumerics { +class CSourceIncRotatingFrame_Flow final : public CSourceBase_Flow { private: su2double Omega[3]; /*!< \brief Angular velocity */ @@ -230,15 +258,14 @@ class CSourceIncRotatingFrame_Flow : public CNumerics { * \param[in] val_nVar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CSourceIncRotatingFrame_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + CSourceIncRotatingFrame_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config); /*! * \brief Residual of the rotational frame source term. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). * \param[in] config - Definition of the particular problem. + * \return Lightweight const-view of residual and Jacobian. */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config); + ResidualType<> ComputeResidual(const CConfig* config) override; }; @@ -248,7 +275,7 @@ class CSourceIncRotatingFrame_Flow : public CNumerics { * \ingroup SourceDiscr * \author S. Padrón */ -class CSourceWindGust : public CNumerics { +class CSourceWindGust final : public CSourceBase_Flow { public: /*! * \brief Constructor of the class. @@ -256,13 +283,13 @@ class CSourceWindGust : public CNumerics { * \param[in] val_nVar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CSourceWindGust(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + CSourceWindGust(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config); /*! * \brief Residual of the wind gust source term. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). * \param[in] config - Definition of the particular problem. + * \return Lightweight const-view of residual and Jacobian. */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config); + ResidualType<> ComputeResidual(const CConfig* config) override; + }; diff --git a/SU2_CFD/src/numerics/flow/flow_sources.cpp b/SU2_CFD/src/numerics/flow/flow_sources.cpp index a3443e45f24b..6c813ab79f22 100644 --- a/SU2_CFD/src/numerics/flow/flow_sources.cpp +++ b/SU2_CFD/src/numerics/flow/flow_sources.cpp @@ -28,15 +28,32 @@ #include "../../../include/numerics/flow/flow_sources.hpp" -CSourceAxisymmetric_Flow::CSourceAxisymmetric_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : - CNumerics(val_nDim, val_nVar, config) { +CSourceBase_Flow::CSourceBase_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config) : + CNumerics(val_nDim, val_nVar, config) { + residual = new su2double [nVar](); + jacobian = new su2double* [nVar]; + for(unsigned short iVar = 0; iVar < nVar; ++iVar) + jacobian[iVar] = new su2double [nVar](); +} + +CSourceBase_Flow::~CSourceBase_Flow() { + delete [] residual; + if(jacobian) { + for(unsigned short iVar = 0; iVar < nVar; ++iVar) + delete [] jacobian[iVar]; + delete [] jacobian; + } +} + +CSourceAxisymmetric_Flow::CSourceAxisymmetric_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config) : + CSourceBase_Flow(val_nDim, val_nVar, config) { Gamma = config->GetGamma(); Gamma_Minus_One = Gamma - 1.0; } -void CSourceAxisymmetric_Flow::ComputeResidual(su2double *val_residual, su2double **Jacobian_i, CConfig *config) { +CNumerics::ResidualType<> CSourceAxisymmetric_Flow::ComputeResidual(const CConfig* config) { su2double yinv, Pressure_i, Enthalpy_i, Velocity_i, sq_vel; unsigned short iDim, iVar, jVar; @@ -56,35 +73,35 @@ void CSourceAxisymmetric_Flow::ComputeResidual(su2double *val_residual, su2doubl Pressure_i = (Gamma-1.0)*U_i[0]*(U_i[nDim+1]/U_i[0]-0.5*sq_vel); Enthalpy_i = (U_i[nDim+1] + Pressure_i) / U_i[0]; - val_residual[0] = yinv*Volume*U_i[2]; - val_residual[1] = yinv*Volume*U_i[1]*U_i[2]/U_i[0]; - val_residual[2] = yinv*Volume*(U_i[2]*U_i[2]/U_i[0]); - val_residual[3] = yinv*Volume*Enthalpy_i*U_i[2]; + residual[0] = yinv*Volume*U_i[2]; + residual[1] = yinv*Volume*U_i[1]*U_i[2]/U_i[0]; + residual[2] = yinv*Volume*(U_i[2]*U_i[2]/U_i[0]); + residual[3] = yinv*Volume*Enthalpy_i*U_i[2]; if (implicit) { - Jacobian_i[0][0] = 0.0; - Jacobian_i[0][1] = 0.0; - Jacobian_i[0][2] = 1.0; - Jacobian_i[0][3] = 0.0; - - Jacobian_i[1][0] = -U_i[1]*U_i[2]/(U_i[0]*U_i[0]); - Jacobian_i[1][1] = U_i[2]/U_i[0]; - Jacobian_i[1][2] = U_i[1]/U_i[0]; - Jacobian_i[1][3] = 0.0; - - Jacobian_i[2][0] = -U_i[2]*U_i[2]/(U_i[0]*U_i[0]); - Jacobian_i[2][1] = 0.0; - Jacobian_i[2][2] = 2*U_i[2]/U_i[0]; - Jacobian_i[2][3] = 0.0; - - Jacobian_i[3][0] = -Gamma*U_i[2]*U_i[3]/(U_i[0]*U_i[0]) + (Gamma-1)*U_i[2]*(U_i[1]*U_i[1]+U_i[2]*U_i[2])/(U_i[0]*U_i[0]*U_i[0]); - Jacobian_i[3][1] = -(Gamma-1)*U_i[2]*U_i[1]/(U_i[0]*U_i[0]); - Jacobian_i[3][2] = Gamma*U_i[3]/U_i[0] - 1/2*(Gamma-1)*( (U_i[1]*U_i[1]+U_i[2]*U_i[2])/(U_i[0]*U_i[0]) + 2*U_i[2]*U_i[2]/(U_i[0]*U_i[0]) ); - Jacobian_i[3][3] = Gamma*U_i[2]/U_i[0]; + jacobian[0][0] = 0.0; + jacobian[0][1] = 0.0; + jacobian[0][2] = 1.0; + jacobian[0][3] = 0.0; + + jacobian[1][0] = -U_i[1]*U_i[2]/(U_i[0]*U_i[0]); + jacobian[1][1] = U_i[2]/U_i[0]; + jacobian[1][2] = U_i[1]/U_i[0]; + jacobian[1][3] = 0.0; + + jacobian[2][0] = -U_i[2]*U_i[2]/(U_i[0]*U_i[0]); + jacobian[2][1] = 0.0; + jacobian[2][2] = 2*U_i[2]/U_i[0]; + jacobian[2][3] = 0.0; + + jacobian[3][0] = -Gamma*U_i[2]*U_i[3]/(U_i[0]*U_i[0]) + (Gamma-1)*U_i[2]*(U_i[1]*U_i[1]+U_i[2]*U_i[2])/(U_i[0]*U_i[0]*U_i[0]); + jacobian[3][1] = -(Gamma-1)*U_i[2]*U_i[1]/(U_i[0]*U_i[0]); + jacobian[3][2] = Gamma*U_i[3]/U_i[0] - 1/2*(Gamma-1)*( (U_i[1]*U_i[1]+U_i[2]*U_i[2])/(U_i[0]*U_i[0]) + 2*U_i[2]*U_i[2]/(U_i[0]*U_i[0]) ); + jacobian[3][3] = Gamma*U_i[2]/U_i[0]; for (iVar=0; iVar < nVar; iVar++) for (jVar=0; jVar < nVar; jVar++) - Jacobian_i[iVar][jVar] *= yinv*Volume; + jacobian[iVar][jVar] *= yinv*Volume; } @@ -93,21 +110,22 @@ void CSourceAxisymmetric_Flow::ComputeResidual(su2double *val_residual, su2doubl else { for (iVar=0; iVar < nVar; iVar++) - val_residual[iVar] = 0.0; + residual[iVar] = 0.0; if (implicit) { for (iVar=0; iVar < nVar; iVar++) { for (jVar=0; jVar < nVar; jVar++) - Jacobian_i[iVar][jVar] = 0.0; + jacobian[iVar][jVar] = 0.0; } } } + return ResidualType<>(residual, jacobian, nullptr); } -CSourceIncAxisymmetric_Flow::CSourceIncAxisymmetric_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : - CNumerics(val_nDim, val_nVar, config) { +CSourceIncAxisymmetric_Flow::CSourceIncAxisymmetric_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config) : + CSourceBase_Flow(val_nDim, val_nVar, config) { implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); energy = config->GetEnergy_Equation(); @@ -115,7 +133,7 @@ CSourceIncAxisymmetric_Flow::CSourceIncAxisymmetric_Flow(unsigned short val_nDim } -void CSourceIncAxisymmetric_Flow::ComputeResidual(su2double *val_residual, su2double **Jacobian_i, CConfig *config) { +CNumerics::ResidualType<> CSourceIncAxisymmetric_Flow::ComputeResidual(const CConfig* config) { su2double yinv, Velocity_i[3]; unsigned short iDim, jDim, iVar, jVar; @@ -138,36 +156,36 @@ void CSourceIncAxisymmetric_Flow::ComputeResidual(su2double *val_residual, su2do /*--- Inviscid component of the source term. ---*/ - val_residual[0] = yinv*Volume*DensityInc_i*Velocity_i[1]; - val_residual[1] = yinv*Volume*DensityInc_i*Velocity_i[0]*Velocity_i[1]; - val_residual[2] = yinv*Volume*DensityInc_i*Velocity_i[1]*Velocity_i[1]; - val_residual[3] = yinv*Volume*DensityInc_i*Enthalpy_i*Velocity_i[1]; + residual[0] = yinv*Volume*DensityInc_i*Velocity_i[1]; + residual[1] = yinv*Volume*DensityInc_i*Velocity_i[0]*Velocity_i[1]; + residual[2] = yinv*Volume*DensityInc_i*Velocity_i[1]*Velocity_i[1]; + residual[3] = yinv*Volume*DensityInc_i*Enthalpy_i*Velocity_i[1]; if (implicit) { - Jacobian_i[0][0] = 0.0; - Jacobian_i[0][1] = 0.0; - Jacobian_i[0][2] = 1.0; - Jacobian_i[0][3] = 0.0; + jacobian[0][0] = 0.0; + jacobian[0][1] = 0.0; + jacobian[0][2] = 1.0; + jacobian[0][3] = 0.0; - Jacobian_i[1][0] = 0.0; - Jacobian_i[1][1] = Velocity_i[1]; - Jacobian_i[1][2] = Velocity_i[0]; - Jacobian_i[1][3] = 0.0; + jacobian[1][0] = 0.0; + jacobian[1][1] = Velocity_i[1]; + jacobian[1][2] = Velocity_i[0]; + jacobian[1][3] = 0.0; - Jacobian_i[2][0] = 0.0; - Jacobian_i[2][1] = 0.0; - Jacobian_i[2][2] = 2.0*Velocity_i[1]; - Jacobian_i[2][3] = 0.0; + jacobian[2][0] = 0.0; + jacobian[2][1] = 0.0; + jacobian[2][2] = 2.0*Velocity_i[1]; + jacobian[2][3] = 0.0; - Jacobian_i[3][0] = 0.0; - Jacobian_i[3][1] = 0.0; - Jacobian_i[3][2] = Enthalpy_i; - Jacobian_i[3][3] = Cp_i*Velocity_i[1]; + jacobian[3][0] = 0.0; + jacobian[3][1] = 0.0; + jacobian[3][2] = Enthalpy_i; + jacobian[3][3] = Cp_i*Velocity_i[1]; for (iVar=0; iVar < nVar; iVar++) for (jVar=0; jVar < nVar; jVar++) - Jacobian_i[iVar][jVar] *= yinv*Volume*DensityInc_i; + jacobian[iVar][jVar] *= yinv*Volume*DensityInc_i; } @@ -197,42 +215,44 @@ void CSourceIncAxisymmetric_Flow::ComputeResidual(su2double *val_residual, su2do /*--- Viscous terms. ---*/ - val_residual[0] -= 0.0; - val_residual[1] -= Volume*(yinv*tau[0][1] - TWO3*AuxVar_Grad_i[0]); - val_residual[2] -= Volume*(yinv*2.0*total_viscosity*PrimVar_Grad_i[2][1] - + residual[0] -= 0.0; + residual[1] -= Volume*(yinv*tau[0][1] - TWO3*AuxVar_Grad_i[0]); + residual[2] -= Volume*(yinv*2.0*total_viscosity*PrimVar_Grad_i[2][1] - yinv*yinv*2.0*total_viscosity*Velocity_i[1] - TWO3*AuxVar_Grad_i[1]); - val_residual[3] -= Volume*yinv*Thermal_Conductivity_i*PrimVar_Grad_i[nDim+1][1]; + residual[3] -= Volume*yinv*Thermal_Conductivity_i*PrimVar_Grad_i[nDim+1][1]; } } else { for (iVar=0; iVar < nVar; iVar++) - val_residual[iVar] = 0.0; + residual[iVar] = 0.0; if (implicit) { for (iVar=0; iVar < nVar; iVar++) { for (jVar=0; jVar < nVar; jVar++) - Jacobian_i[iVar][jVar] = 0.0; + jacobian[iVar][jVar] = 0.0; } } } if (!energy) { - val_residual[nDim+1] = 0.0; + residual[nDim+1] = 0.0; if (implicit) { for (iVar = 0; iVar < nVar; iVar++) { - Jacobian_i[iVar][nDim+1] = 0.0; - Jacobian_i[nDim+1][iVar] = 0.0; + jacobian[iVar][nDim+1] = 0.0; + jacobian[nDim+1][iVar] = 0.0; } } } + + return ResidualType<>(residual, jacobian, nullptr); } -CSourceBodyForce::CSourceBodyForce(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : - CNumerics(val_nDim, val_nVar, config) { +CSourceBodyForce::CSourceBodyForce(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config) : + CSourceBase_Flow(val_nDim, val_nVar, config) { /*--- Store the pointer to the constant body force vector. ---*/ @@ -241,29 +261,31 @@ CSourceBodyForce::CSourceBodyForce(unsigned short val_nDim, unsigned short val_n } -void CSourceBodyForce::ComputeResidual(su2double *val_residual, CConfig *config) { +CNumerics::ResidualType<> CSourceBodyForce::ComputeResidual(const CConfig* config) { unsigned short iDim; su2double Force_Ref = config->GetForce_Ref(); /*--- Zero the continuity contribution ---*/ - val_residual[0] = 0.0; + residual[0] = 0.0; /*--- Momentum contribution ---*/ for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = -Volume * U_i[0] * Body_Force_Vector[iDim] / Force_Ref; + residual[iDim+1] = -Volume * U_i[0] * Body_Force_Vector[iDim] / Force_Ref; /*--- Energy contribution ---*/ - val_residual[nDim+1] = 0.0; + residual[nDim+1] = 0.0; for (iDim = 0; iDim < nDim; iDim++) - val_residual[nDim+1] += -Volume * U_i[iDim+1] * Body_Force_Vector[iDim] / Force_Ref; + residual[nDim+1] += -Volume * U_i[iDim+1] * Body_Force_Vector[iDim] / Force_Ref; + return ResidualType<>(residual, jacobian, nullptr); } -CSourceIncBodyForce::CSourceIncBodyForce(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { +CSourceIncBodyForce::CSourceIncBodyForce(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config) : + CSourceBase_Flow(val_nDim, val_nVar, config) { /*--- Store the pointer to the constant body force vector. ---*/ @@ -272,7 +294,7 @@ CSourceIncBodyForce::CSourceIncBodyForce(unsigned short val_nDim, unsigned short } -void CSourceIncBodyForce::ComputeResidual(su2double *val_residual, CConfig *config) { +CNumerics::ResidualType<> CSourceIncBodyForce::ComputeResidual(const CConfig* config) { unsigned short iDim; su2double DensityInc_0 = 0.0; @@ -286,23 +308,24 @@ void CSourceIncBodyForce::ComputeResidual(su2double *val_residual, CConfig *conf /*--- Zero the continuity contribution ---*/ - val_residual[0] = 0.0; + residual[0] = 0.0; /*--- Momentum contribution. Note that this form assumes we have subtracted the operating density * gravity, i.e., removed the hydrostatic pressure component (important for pressure BCs). ---*/ for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = -Volume * (DensityInc_i - DensityInc_0) * Body_Force_Vector[iDim] / Force_Ref; + residual[iDim+1] = -Volume * (DensityInc_i - DensityInc_0) * Body_Force_Vector[iDim] / Force_Ref; /*--- Zero the temperature contribution ---*/ - val_residual[nDim+1] = 0.0; + residual[nDim+1] = 0.0; + return ResidualType<>(residual, jacobian, nullptr); } - -CSourceBoussinesq::CSourceBoussinesq(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { +CSourceBoussinesq::CSourceBoussinesq(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config) : + CSourceBase_Flow(val_nDim, val_nVar, config) { /*--- Store the pointer to the constant body force vector. ---*/ @@ -315,7 +338,7 @@ CSourceBoussinesq::CSourceBoussinesq(unsigned short val_nDim, unsigned short val } -void CSourceBoussinesq::ComputeResidual(su2double *val_residual, CConfig *config) { +CNumerics::ResidualType<> CSourceBoussinesq::ComputeResidual(const CConfig* config) { unsigned short iDim; su2double Force_Ref = config->GetForce_Ref(); @@ -324,48 +347,52 @@ void CSourceBoussinesq::ComputeResidual(su2double *val_residual, CConfig *config /*--- Zero the continuity contribution ---*/ - val_residual[0] = 0.0; + residual[0] = 0.0; /*--- Momentum contribution. Note that this form assumes we have subtracted the operating density * gravity, i.e., removed the hydrostatic pressure component (important for pressure BCs). ---*/ for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = Volume * DensityInc_i * ( Beta * (U_i[nDim+1] - T0)) * Gravity_Vector[iDim] / Force_Ref; + residual[iDim+1] = Volume * DensityInc_i * ( Beta * (U_i[nDim+1] - T0)) * Gravity_Vector[iDim] / Force_Ref; /*--- Zero the energy contribution ---*/ - val_residual[nDim+1] = 0.0; + residual[nDim+1] = 0.0; + return ResidualType<>(residual, jacobian, nullptr); } -CSourceGravity::CSourceGravity(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : - CNumerics(val_nDim, val_nVar, config) { } +CSourceGravity::CSourceGravity(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config) : + CSourceBase_Flow(val_nDim, val_nVar, config) { } + +CNumerics::ResidualType<> CSourceGravity::ComputeResidual(const CConfig* config) { -void CSourceGravity::ComputeResidual(su2double *val_residual, CConfig *config) { unsigned short iVar; for (iVar = 0; iVar < nVar; iVar++) - val_residual[iVar] = 0.0; + residual[iVar] = 0.0; /*--- Evaluate the source term ---*/ - val_residual[nDim] = Volume * U_i[0] * STANDARD_GRAVITY; + residual[nDim] = Volume * U_i[0] * STANDARD_GRAVITY; + return ResidualType<>(residual, jacobian, nullptr); } -CSourceRotatingFrame_Flow::CSourceRotatingFrame_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { +CSourceRotatingFrame_Flow::CSourceRotatingFrame_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config) : + CSourceBase_Flow(val_nDim, val_nVar, config) { Gamma = config->GetGamma(); Gamma_Minus_One = Gamma - 1.0; } -void CSourceRotatingFrame_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config) { +CNumerics::ResidualType<> CSourceRotatingFrame_Flow::ComputeResidual(const CConfig* config) { unsigned short iDim, iVar, jVar; - su2double Omega[3] = {0,0,0}, Momentum[3] = {0,0,0}; + su2double Omega[MAXNDIM] = {0}, Momentum[MAXNDIM] = {0}; - bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); /*--- Retrieve the angular velocity vector from config. ---*/ @@ -381,16 +408,16 @@ void CSourceRotatingFrame_Flow::ComputeResidual(su2double *val_residual, su2doub /*--- Calculate rotating frame source term as ( Omega X Rho-U ) ---*/ if (nDim == 2) { - val_residual[0] = 0.0; - val_residual[1] = (Omega[1]*Momentum[2] - Omega[2]*Momentum[1])*Volume; - val_residual[2] = (Omega[2]*Momentum[0] - Omega[0]*Momentum[2])*Volume; - val_residual[3] = 0.0; + residual[0] = 0.0; + residual[1] = (Omega[1]*Momentum[2] - Omega[2]*Momentum[1])*Volume; + residual[2] = (Omega[2]*Momentum[0] - Omega[0]*Momentum[2])*Volume; + residual[3] = 0.0; } else { - val_residual[0] = 0.0; - val_residual[1] = (Omega[1]*Momentum[2] - Omega[2]*Momentum[1])*Volume; - val_residual[2] = (Omega[2]*Momentum[0] - Omega[0]*Momentum[2])*Volume; - val_residual[3] = (Omega[0]*Momentum[1] - Omega[1]*Momentum[0])*Volume; - val_residual[4] = 0.0; + residual[0] = 0.0; + residual[1] = (Omega[1]*Momentum[2] - Omega[2]*Momentum[1])*Volume; + residual[2] = (Omega[2]*Momentum[0] - Omega[0]*Momentum[2])*Volume; + residual[3] = (Omega[0]*Momentum[1] - Omega[1]*Momentum[0])*Volume; + residual[4] = 0.0; } /*--- Calculate the source term Jacobian ---*/ @@ -398,23 +425,25 @@ void CSourceRotatingFrame_Flow::ComputeResidual(su2double *val_residual, su2doub if (implicit) { for (iVar = 0; iVar < nVar; iVar++) for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_i[iVar][jVar] = 0.0; + jacobian[iVar][jVar] = 0.0; if (nDim == 2) { - val_Jacobian_i[1][2] = -Omega[2]*Volume; - val_Jacobian_i[2][1] = Omega[2]*Volume; + jacobian[1][2] = -Omega[2]*Volume; + jacobian[2][1] = Omega[2]*Volume; } else { - val_Jacobian_i[1][2] = -Omega[2]*Volume; - val_Jacobian_i[1][3] = Omega[1]*Volume; - val_Jacobian_i[2][1] = Omega[2]*Volume; - val_Jacobian_i[2][3] = -Omega[0]*Volume; - val_Jacobian_i[3][1] = -Omega[1]*Volume; - val_Jacobian_i[3][2] = Omega[0]*Volume; + jacobian[1][2] = -Omega[2]*Volume; + jacobian[1][3] = Omega[1]*Volume; + jacobian[2][1] = Omega[2]*Volume; + jacobian[2][3] = -Omega[0]*Volume; + jacobian[3][1] = -Omega[1]*Volume; + jacobian[3][2] = Omega[0]*Volume; } } + return ResidualType<>(residual, jacobian, nullptr); } -CSourceIncRotatingFrame_Flow::CSourceIncRotatingFrame_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { +CSourceIncRotatingFrame_Flow::CSourceIncRotatingFrame_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config) : + CSourceBase_Flow(val_nDim, val_nVar, config) { implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); @@ -427,11 +456,11 @@ CSourceIncRotatingFrame_Flow::CSourceIncRotatingFrame_Flow(unsigned short val_nD } -void CSourceIncRotatingFrame_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config) { +CNumerics::ResidualType<> CSourceIncRotatingFrame_Flow::ComputeResidual(const CConfig* config) { unsigned short iDim, iVar, jVar; - su2double Momentum[3] = {0,0,0}, - Velocity_i[3] = {0,0,0}; + su2double Momentum[MAXNDIM] = {0}, + Velocity_i[MAXNDIM] = {0}; /*--- Primitive variables plus momentum at the node (point i) ---*/ @@ -439,22 +468,22 @@ void CSourceIncRotatingFrame_Flow::ComputeResidual(su2double *val_residual, su2d for (iDim = 0; iDim < nDim; iDim++) { Velocity_i[iDim] = V_i[iDim+1]; - Momentum[iDim] = DensityInc_i*Velocity_i[iDim]; + Momentum[iDim] = DensityInc_i*Velocity_i[iDim]; } /*--- Calculate rotating frame source term residual as ( Omega X Rho-U ) ---*/ if (nDim == 2) { - val_residual[0] = 0.0; - val_residual[1] = (Omega[1]*Momentum[2] - Omega[2]*Momentum[1])*Volume; - val_residual[2] = (Omega[2]*Momentum[0] - Omega[0]*Momentum[2])*Volume; - val_residual[3] = 0.0; + residual[0] = 0.0; + residual[1] = (Omega[1]*Momentum[2] - Omega[2]*Momentum[1])*Volume; + residual[2] = (Omega[2]*Momentum[0] - Omega[0]*Momentum[2])*Volume; + residual[3] = 0.0; } else { - val_residual[0] = 0.0; - val_residual[1] = (Omega[1]*Momentum[2] - Omega[2]*Momentum[1])*Volume; - val_residual[2] = (Omega[2]*Momentum[0] - Omega[0]*Momentum[2])*Volume; - val_residual[3] = (Omega[0]*Momentum[1] - Omega[1]*Momentum[0])*Volume; - val_residual[4] = 0.0; + residual[0] = 0.0; + residual[1] = (Omega[1]*Momentum[2] - Omega[2]*Momentum[1])*Volume; + residual[2] = (Omega[2]*Momentum[0] - Omega[0]*Momentum[2])*Volume; + residual[3] = (Omega[0]*Momentum[1] - Omega[1]*Momentum[0])*Volume; + residual[4] = 0.0; } /*--- Calculate the source term Jacobian ---*/ @@ -462,28 +491,30 @@ void CSourceIncRotatingFrame_Flow::ComputeResidual(su2double *val_residual, su2d if (implicit) { for (iVar = 0; iVar < nVar; iVar++) for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_i[iVar][jVar] = 0.0; + jacobian[iVar][jVar] = 0.0; if (nDim == 2) { - val_Jacobian_i[1][2] = -DensityInc_i*Omega[2]*Volume; - val_Jacobian_i[2][1] = DensityInc_i*Omega[2]*Volume; + jacobian[1][2] = -DensityInc_i*Omega[2]*Volume; + jacobian[2][1] = DensityInc_i*Omega[2]*Volume; } else { - val_Jacobian_i[1][2] = -DensityInc_i*Omega[2]*Volume; - val_Jacobian_i[1][3] = DensityInc_i*Omega[1]*Volume; - val_Jacobian_i[2][1] = DensityInc_i*Omega[2]*Volume; - val_Jacobian_i[2][3] = -DensityInc_i*Omega[0]*Volume; - val_Jacobian_i[3][1] = -DensityInc_i*Omega[1]*Volume; - val_Jacobian_i[3][2] = DensityInc_i*Omega[0]*Volume; + jacobian[1][2] = -DensityInc_i*Omega[2]*Volume; + jacobian[1][3] = DensityInc_i*Omega[1]*Volume; + jacobian[2][1] = DensityInc_i*Omega[2]*Volume; + jacobian[2][3] = -DensityInc_i*Omega[0]*Volume; + jacobian[3][1] = -DensityInc_i*Omega[1]*Volume; + jacobian[3][2] = DensityInc_i*Omega[0]*Volume; } } + return ResidualType<>(residual, jacobian, nullptr); } -CSourceWindGust::CSourceWindGust(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : - CNumerics(val_nDim, val_nVar, config) { } +CSourceWindGust::CSourceWindGust(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config) : + CSourceBase_Flow(val_nDim, val_nVar, config) { } -void CSourceWindGust::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config) { +CNumerics::ResidualType<> CSourceWindGust::ComputeResidual(const CConfig* config) { - su2double u_gust, v_gust, du_gust_dx, du_gust_dy, du_gust_dt, dv_gust_dx, dv_gust_dy, dv_gust_dt, smx, smy, se, rho, u, v, p; + su2double u_gust, v_gust, du_gust_dx, du_gust_dy, du_gust_dt, dv_gust_dx, dv_gust_dy, dv_gust_dt; + su2double smx, smy, se, rho, u, v, p; unsigned short GustDir = config->GetGust_Dir(); //Gust direction u_gust = WindGust_i[0]; @@ -518,24 +549,16 @@ void CSourceWindGust::ComputeResidual(su2double *val_residual, su2double **val_J se = u*smx + v*smy + p*(du_gust_dx + dv_gust_dy); if (nDim == 2) { - val_residual[0] = 0.0; - val_residual[1] = smx*Volume; - val_residual[2] = smy*Volume; - val_residual[3] = se*Volume; + residual[0] = 0.0; + residual[1] = smx*Volume; + residual[2] = smy*Volume; + residual[3] = se*Volume; } else { SU2_MPI::Error("You should only be in the gust source term in two dimensions", CURRENT_FUNCTION); } /*--- For now the source term Jacobian is just set to zero ---*/ + //bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - unsigned short iVar, jVar; - bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - - /*--- Calculate the source term Jacobian ---*/ - - if (implicit) { - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_i[iVar][jVar] = 0.0; - } + return ResidualType<>(residual, jacobian, nullptr); } From 740f3b9d943a5b6608df2bd46b8de7f585859b7e Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Wed, 29 Jan 2020 21:12:36 +0000 Subject: [PATCH 042/118] remove a forgoten debug statement --- SU2_CFD/src/solvers/CNSSolver.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/src/solvers/CNSSolver.cpp b/SU2_CFD/src/solvers/CNSSolver.cpp index 6ab878f31de7..b3e355f5063a 100644 --- a/SU2_CFD/src/solvers/CNSSolver.cpp +++ b/SU2_CFD/src/solvers/CNSSolver.cpp @@ -753,7 +753,7 @@ CNSSolver::CNSSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) nodes = new CNSVariable(Density_Inf, Velocity_Inf, Energy_Inf, nPoint, nDim, nVar, config); SetBaseClassPointerToNodes(); - #ifndef HAVE_OMP +#ifdef HAVE_OMP /*--- Get the edge coloring. ---*/ const auto& coloring = geometry->GetEdgeColoring(); From be2824afa540fd2baa789d36f10cd1ab986c16ae Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Wed, 29 Jan 2020 22:05:12 +0000 Subject: [PATCH 043/118] carried away with const, caused overload resolution problems --- SU2_CFD/include/numerics/CNumerics.hpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/SU2_CFD/include/numerics/CNumerics.hpp b/SU2_CFD/include/numerics/CNumerics.hpp index 0d3909e0b25c..ff541673e870 100644 --- a/SU2_CFD/include/numerics/CNumerics.hpp +++ b/SU2_CFD/include/numerics/CNumerics.hpp @@ -1033,7 +1033,7 @@ class CNumerics { * \param[out] val_residual - Pointer to the total residual. * \param[in] config - Definition of the particular problem. */ - inline virtual void ComputeResidual(su2double *val_residual, const CConfig* config) { } + inline virtual void ComputeResidual(su2double *val_residual, CConfig* config) { } /*! * \overload @@ -1043,7 +1043,7 @@ class CNumerics { * \param[in] config - Definition of the particular problem. */ inline virtual void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, - su2double **val_Jacobian_j, const CConfig* config) { } + su2double **val_Jacobian_j, CConfig* config) { } /*! * \overload For numerics classes that store the residual/flux and Jacobians internally. @@ -1067,7 +1067,7 @@ class CNumerics { su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, su2double **val_Jacobian_ji, - su2double **val_Jacobian_jj, const CConfig* config) { } + su2double **val_Jacobian_jj, CConfig* config) { } /*! * \overload @@ -1086,7 +1086,7 @@ class CNumerics { su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, su2double **val_Jacobian_ji, - su2double **val_Jacobian_jj, const CConfig* config) { } + su2double **val_Jacobian_jj, CConfig* config) { } /*! * \overload @@ -1094,7 +1094,7 @@ class CNumerics { * \param[out] val_residual - residual of the source terms * \param[out] val_Jacobian_i - Jacobian of the source terms */ - inline virtual void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, const CConfig* config) { } + inline virtual void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig* config) { } /*! * \brief Residual for transition problems. @@ -1106,7 +1106,7 @@ class CNumerics { */ inline virtual void ComputeResidual_TransLM(su2double *val_residual, su2double **val_Jacobian_i, - su2double **val_Jacobian_j, const CConfig* config, + su2double **val_Jacobian_j, CConfig* config, su2double &gamma_sep) { } /*! From 3072afbf360bc0147e130e69d52ead13135af58b Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Thu, 30 Jan 2020 07:43:35 +0000 Subject: [PATCH 044/118] fix source residual of CIncEulerSolver --- SU2_CFD/src/solvers/CIncEulerSolver.cpp | 72 +++++++++---------------- 1 file changed, 26 insertions(+), 46 deletions(-) diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index f7a2a77661fe..067ec4a16676 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -2036,17 +2036,12 @@ void CIncEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_cont unsigned short iVar; unsigned long iPoint; - bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - bool rotating_frame = config->GetRotating_Frame(); - bool axisymmetric = config->GetAxisymmetric(); - bool body_force = config->GetBody_Force(); - bool boussinesq = (config->GetKind_DensityModel() == BOUSSINESQ); - bool viscous = config->GetViscous(); - - - /*--- Initialize the source residual to zero ---*/ - - for (iVar = 0; iVar < nVar; iVar++) Residual[iVar] = 0.0; + const bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + const bool rotating_frame = config->GetRotating_Frame(); + const bool axisymmetric = config->GetAxisymmetric(); + const bool body_force = config->GetBody_Force(); + const bool boussinesq = (config->GetKind_DensityModel() == BOUSSINESQ); + const bool viscous = config->GetViscous(); if (body_force) { @@ -2070,11 +2065,11 @@ void CIncEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_cont /*--- Compute the rotating frame source residual ---*/ - numerics->ComputeResidual(Residual, config); + auto residual = numerics->ComputeResidual(config); /*--- Add the source residual to the total ---*/ - LinSysRes.AddBlock(iPoint, Residual); + LinSysRes.AddBlock(iPoint, residual); } } @@ -2101,11 +2096,11 @@ void CIncEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_cont /*--- Compute the rotating frame source residual ---*/ - numerics->ComputeResidual(Residual, config); + auto residual = numerics->ComputeResidual(config); /*--- Add the source residual to the total ---*/ - LinSysRes.AddBlock(iPoint, Residual); + LinSysRes.AddBlock(iPoint, residual); } } @@ -2130,51 +2125,38 @@ void CIncEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_cont /*--- Compute the rotating frame source residual ---*/ - numerics->ComputeResidual(Residual, Jacobian_i, config); + auto residual = numerics->ComputeResidual(config); /*--- Add the source residual to the total ---*/ - LinSysRes.AddBlock(iPoint, Residual); + LinSysRes.AddBlock(iPoint, residual); /*--- Add the implicit Jacobian contribution ---*/ - if (implicit) Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + if (implicit) Jacobian.AddBlock(iPoint, iPoint, residual.jacobian_i); } } if (axisymmetric) { - /*--- Zero out Jacobian structure ---*/ - - if (implicit) { - for (iVar = 0; iVar < nVar; iVar ++) - for (unsigned short jVar = 0; jVar < nVar; jVar ++) - Jacobian_i[iVar][jVar] = 0.0; - } - /*--- For viscous problems, we need an additional gradient. ---*/ if (viscous) { - su2double AuxVar, Total_Viscosity, yCoord, yVelocity; - for (iPoint = 0; iPoint < nPoint; iPoint++) { - yCoord = geometry->node[iPoint]->GetCoord(1); - yVelocity = nodes->GetVelocity(iPoint,1); - Total_Viscosity = (nodes->GetLaminarViscosity(iPoint) + - nodes->GetEddyViscosity(iPoint)); - - if (yCoord > EPS) { + su2double yCoord = geometry->node[iPoint]->GetCoord(1); + su2double yVelocity = nodes->GetVelocity(iPoint,1); + su2double Total_Viscosity = (nodes->GetLaminarViscosity(iPoint) + + nodes->GetEddyViscosity(iPoint)); + su2double AuxVar = 0.0; + if (yCoord > EPS) AuxVar = Total_Viscosity*yVelocity/yCoord; - } else { - AuxVar = 0.0; - } /*--- Set the auxilairy variable for this node. ---*/ - nodes->SetAuxVar(iPoint,AuxVar); + nodes->SetAuxVar(iPoint, AuxVar); } @@ -2227,15 +2209,16 @@ void CIncEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_cont /*--- Compute Source term Residual ---*/ - numerics->ComputeResidual(Residual, Jacobian_i, config); + auto residual = numerics->ComputeResidual(config); /*--- Add Residual ---*/ - LinSysRes.AddBlock(iPoint, Residual); + LinSysRes.AddBlock(iPoint, residual); /*--- Implicit part ---*/ - if (implicit) Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + if (implicit) + Jacobian.AddBlock(iPoint, iPoint, residual.jacobian_i); } } @@ -2262,14 +2245,11 @@ void CIncEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_cont vector sourceMan(nVar,0.0); VerificationSolution->GetMMSSourceTerm(coor, time, sourceMan.data()); - /*--- Compute the residual for this control volume. ---*/ + /*--- Compute the residual for this control volume and subtract. ---*/ for (iVar = 0; iVar < nVar; iVar++) { - Residual[iVar] = sourceMan[iVar]*Volume; + LinSysRes[iPoint*nVar+iVar] -= sourceMan[iVar]*Volume; } - /*--- Subtract Residual ---*/ - LinSysRes.SubtractBlock(iPoint, Residual); - } } } From d97dddadc426811cd4f12d1001245ddeab16e6b1 Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Thu, 30 Jan 2020 08:32:11 +0000 Subject: [PATCH 045/118] fully exploit the fast lookup mechanisms in CSysMatrix --- Common/include/linear_algebra/CSysMatrix.hpp | 45 +++++++++++++ SU2_CFD/src/solvers/CAdjEulerSolver.cpp | 50 +++++++------- SU2_CFD/src/solvers/CAdjNSSolver.cpp | 10 +-- SU2_CFD/src/solvers/CAdjTurbSolver.cpp | 16 ++--- SU2_CFD/src/solvers/CEulerSolver.cpp | 68 ++++++++++---------- SU2_CFD/src/solvers/CHeatSolverFVM.cpp | 17 ++--- SU2_CFD/src/solvers/CIncEulerSolver.cpp | 30 ++++----- SU2_CFD/src/solvers/CIncNSSolver.cpp | 7 +- SU2_CFD/src/solvers/CNSSolver.cpp | 21 +++--- SU2_CFD/src/solvers/CSolver.cpp | 2 +- SU2_CFD/src/solvers/CTransLMSolver.cpp | 14 ++-- SU2_CFD/src/solvers/CTurbSASolver.cpp | 44 ++++++------- SU2_CFD/src/solvers/CTurbSSTSolver.cpp | 24 +++---- SU2_CFD/src/solvers/CTurbSolver.cpp | 6 +- 14 files changed, 192 insertions(+), 162 deletions(-) diff --git a/Common/include/linear_algebra/CSysMatrix.hpp b/Common/include/linear_algebra/CSysMatrix.hpp index 8e6ec422047f..9f4982de9af7 100644 --- a/Common/include/linear_algebra/CSysMatrix.hpp +++ b/Common/include/linear_algebra/CSysMatrix.hpp @@ -570,6 +570,51 @@ class CSysMatrix { } } + /*! + * \brief Short-hand for the "subtractive" version (sub from i* add to j*) of UpdateBlocks. + */ + template + inline void UpdateBlocksSub(unsigned long iEdge, unsigned long iPoint, unsigned long jPoint, + const OtherType* const* block_i, const OtherType* const* block_j) { + UpdateBlocks(iEdge, iPoint, jPoint, block_i, block_j); + } + + /*! + * \brief Adds the specified block to the (i, i) subblock of the matrix-by-blocks structure. + * \param[in] block_i - Diagonal index. + * \param[in] val_block - Block to add to the diagonal of the matrix. + */ + template + inline void AddBlock2Diag(unsigned long block_i, const OtherType* const* val_block) { + + ScalarType *bii = &matrix[dia_ptr[block_i]*nVar*nEqn]; + + unsigned long iVar, jVar, offset = 0; + + for (iVar = 0; iVar < nVar; iVar++) + for (jVar = 0; jVar < nEqn; jVar++) + bii[offset++] += PassiveAssign(val_block[iVar][jVar]); + + } + + /*! + * \brief Subtracts the specified block from the (i, i) subblock of the matrix-by-blocks structure. + * \param[in] block_i - Diagonal index. + * \param[in] val_block - Block to subtract from the diagonal of the matrix. + */ + template + inline void SubtractBlock2Diag(unsigned long block_i, const OtherType* const* val_block) { + + ScalarType *bii = &matrix[dia_ptr[block_i]*nVar*nEqn]; + + unsigned long iVar, jVar, offset = 0; + + for (iVar = 0; iVar < nVar; iVar++) + for (jVar = 0; jVar < nEqn; jVar++) + bii[offset++] -= PassiveAssign(val_block[iVar][jVar]); + + } + /*! * \brief Adds the specified value to the diagonal of the (i, i) subblock * of the matrix-by-blocks structure. diff --git a/SU2_CFD/src/solvers/CAdjEulerSolver.cpp b/SU2_CFD/src/solvers/CAdjEulerSolver.cpp index e733952c92b2..ea8fb47c4f5e 100644 --- a/SU2_CFD/src/solvers/CAdjEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CAdjEulerSolver.cpp @@ -1765,10 +1765,10 @@ void CAdjEulerSolver::Centered_Residual(CGeometry *geometry, CSolver **solver_co /*--- Implicit contribution to the residual ---*/ if (implicit) { - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_ii); + Jacobian.SubtractBlock2Diag(iPoint, Jacobian_ii); Jacobian.SubtractBlock(iPoint, jPoint, Jacobian_ij); Jacobian.SubtractBlock(jPoint, iPoint, Jacobian_ji); - Jacobian.SubtractBlock(jPoint, jPoint, Jacobian_jj); + Jacobian.SubtractBlock2Diag(jPoint, Jacobian_jj); } } @@ -1894,10 +1894,10 @@ void CAdjEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_cont /*--- Implicit contribution to the residual ---*/ if (implicit) { - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_ii); + Jacobian.SubtractBlock2Diag(iPoint, Jacobian_ii); Jacobian.SubtractBlock(iPoint, jPoint, Jacobian_ij); Jacobian.SubtractBlock(jPoint, iPoint, Jacobian_ji); - Jacobian.SubtractBlock(jPoint, jPoint, Jacobian_jj); + Jacobian.SubtractBlock2Diag(jPoint, Jacobian_jj); } } @@ -1950,7 +1950,7 @@ void CAdjEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_cont LinSysRes.AddBlock(iPoint, Residual); /*--- Add the implicit Jacobian contribution ---*/ - if (implicit) Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + if (implicit) Jacobian.AddBlock2Diag(iPoint, Jacobian_i); } } @@ -2009,7 +2009,7 @@ void CAdjEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_cont /*--- Implicit part ---*/ if (implicit) - Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + Jacobian.AddBlock2Diag(iPoint, Jacobian_i); } } @@ -3155,7 +3155,7 @@ void CAdjEulerSolver::BC_Euler_Wall(CGeometry *geometry, Jacobian_ii[nVar-1][nVar-1] -= ProjGridVel; } - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_ii); + Jacobian.SubtractBlock2Diag(iPoint, Jacobian_ii); } @@ -3316,7 +3316,7 @@ void CAdjEulerSolver::BC_Sym_Plane(CGeometry *geometry, CSolver **solver_contain /*--- Update jacobian ---*/ - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_ii); + Jacobian.SubtractBlock2Diag(iPoint, Jacobian_ii); } @@ -3380,7 +3380,7 @@ void CAdjEulerSolver::BC_Interface_Boundary(CGeometry *geometry, CSolver **solve /*--- Add Residuals and Jacobians ---*/ LinSysRes.SubtractBlock(iPoint, Res_Conv_i); - if (implicit) Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_ii); + if (implicit) Jacobian.SubtractBlock2Diag(iPoint, Jacobian_ii); } } @@ -3479,7 +3479,7 @@ void CAdjEulerSolver::BC_NearField_Boundary(CGeometry *geometry, CSolver **solve /*--- Add Residuals and Jacobians ---*/ LinSysRes.SubtractBlock(iPoint, Res_Conv_i); - if (implicit) Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_ii); + if (implicit) Jacobian.SubtractBlock2Diag(iPoint, Jacobian_ii); } } @@ -3559,7 +3559,7 @@ void CAdjEulerSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_contain /*--- Implicit contribution to the residual ---*/ if (implicit) - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_ii); + Jacobian.SubtractBlock2Diag(iPoint, Jacobian_ii); /*--- Viscous residual contribution, it doesn't work ---*/ @@ -3588,7 +3588,7 @@ void CAdjEulerSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_contain LinSysRes.SubtractBlock(iPoint, Residual_i); if (implicit) - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_ii); + Jacobian.SubtractBlock2Diag(iPoint, Jacobian_ii); } @@ -3668,7 +3668,7 @@ void CAdjEulerSolver::BC_Supersonic_Inlet(CGeometry *geometry, CSolver **solver_ /*--- Implicit contribution to the residual ---*/ if (implicit) - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_ii); + Jacobian.SubtractBlock2Diag(iPoint, Jacobian_ii); /*--- Viscous residual contribution, it doesn't work ---*/ @@ -3701,7 +3701,7 @@ void CAdjEulerSolver::BC_Supersonic_Inlet(CGeometry *geometry, CSolver **solver_ LinSysRes.SubtractBlock(iPoint, Residual_i); if (implicit) - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_ii); + Jacobian.SubtractBlock2Diag(iPoint, Jacobian_ii); } } @@ -3783,7 +3783,7 @@ void CAdjEulerSolver::BC_Supersonic_Outlet(CGeometry *geometry, CSolver **solver /*--- Implicit contribution to the residual ---*/ if (implicit) - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_ii); + Jacobian.SubtractBlock2Diag(iPoint, Jacobian_ii); /*--- Viscous residual contribution (check again, Point_Normal was not being initialized before) ---*/ @@ -3816,7 +3816,7 @@ void CAdjEulerSolver::BC_Supersonic_Outlet(CGeometry *geometry, CSolver **solver LinSysRes.SubtractBlock(iPoint, Residual_i); if (implicit) - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_ii); + Jacobian.SubtractBlock2Diag(iPoint, Jacobian_ii); } } @@ -3959,7 +3959,7 @@ void CAdjEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, /*--- Implicit contribution to the residual ---*/ if (implicit) - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_ii); + Jacobian.SubtractBlock2Diag(iPoint, Jacobian_ii); /*--- Viscous residual contribution, it doesn't work ---*/ @@ -3991,7 +3991,7 @@ void CAdjEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, LinSysRes.SubtractBlock(iPoint, Residual_i); if (implicit) - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_ii); + Jacobian.SubtractBlock2Diag(iPoint, Jacobian_ii); } } @@ -4241,7 +4241,7 @@ void CAdjEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, /*--- Implicit contribution to the residual ---*/ if (implicit) - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_ii); + Jacobian.SubtractBlock2Diag(iPoint, Jacobian_ii); /*--- Viscous residual contribution, it doesn't work ---*/ @@ -4278,7 +4278,7 @@ void CAdjEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, LinSysRes.SubtractBlock(iPoint, Residual_i); if (implicit) - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_ii); + Jacobian.SubtractBlock2Diag(iPoint, Jacobian_ii); } } @@ -4403,7 +4403,7 @@ void CAdjEulerSolver::BC_Engine_Inflow(CGeometry *geometry, CSolver **solver_con /*--- Implicit contribution to the residual ---*/ if (implicit) - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_ii); + Jacobian.SubtractBlock2Diag(iPoint, Jacobian_ii); } } @@ -4488,7 +4488,7 @@ void CAdjEulerSolver::BC_Engine_Exhaust(CGeometry *geometry, CSolver **solver_co /*--- Implicit contribution to the residual ---*/ if (implicit) - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_ii); + Jacobian.SubtractBlock2Diag(iPoint, Jacobian_ii); } } @@ -4617,7 +4617,7 @@ void CAdjEulerSolver::BC_ActDisk_Inlet(CGeometry *geometry, CSolver **solver_con /*--- Implicit contribution to the residual ---*/ if (implicit) - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_ii); + Jacobian.SubtractBlock2Diag(iPoint, Jacobian_ii); } } @@ -4707,7 +4707,7 @@ void CAdjEulerSolver::BC_ActDisk_Outlet(CGeometry *geometry, CSolver **solver_co /*--- Implicit contribution to the residual ---*/ if (implicit) - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_ii); + Jacobian.SubtractBlock2Diag(iPoint, Jacobian_ii); } @@ -4778,7 +4778,7 @@ void CAdjEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver if (config->GetTime_Marching() == DT_STEPPING_2ND) Jacobian_i[iVar][iVar] = (Volume_nP1*3.0)/(2.0*TimeStep); } - Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + Jacobian.AddBlock2Diag(iPoint, Jacobian_i); } } diff --git a/SU2_CFD/src/solvers/CAdjNSSolver.cpp b/SU2_CFD/src/solvers/CAdjNSSolver.cpp index f9c4c5502a0c..6569f563e43e 100644 --- a/SU2_CFD/src/solvers/CAdjNSSolver.cpp +++ b/SU2_CFD/src/solvers/CAdjNSSolver.cpp @@ -453,10 +453,10 @@ void CAdjNSSolver::Viscous_Residual(CGeometry *geometry, CSolver **solver_contai LinSysRes.AddBlock(jPoint, Residual_j); if (implicit) { - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_ii); + Jacobian.SubtractBlock2Diag(iPoint, Jacobian_ii); Jacobian.SubtractBlock(iPoint, jPoint, Jacobian_ij); Jacobian.AddBlock(jPoint, iPoint, Jacobian_ji); - Jacobian.AddBlock(jPoint, jPoint, Jacobian_jj); + Jacobian.AddBlock2Diag(jPoint, Jacobian_jj); } } @@ -599,7 +599,7 @@ void CAdjNSSolver::Source_Residual(CGeometry *geometry, CSolver **solver_contain LinSysRes.AddBlock(iPoint, Residual); /*--- Add the implicit Jacobian contribution ---*/ - if (implicit) Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + if (implicit) Jacobian.AddBlock2Diag(iPoint, Jacobian_i); } } @@ -1531,7 +1531,7 @@ void CAdjNSSolver::BC_HeatFlux_Wall(CGeometry *geometry, CSolver **solver_contai modifying the velocity-rows of the Jacobian (1 on the diagonal). ---*/ if (implicit) { - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_ii); + Jacobian.SubtractBlock2Diag(iPoint, Jacobian_ii); for (iVar = 1; iVar <= nDim; iVar++) { total_index = iPoint*nVar+iVar; Jacobian.DeleteValsRowi(total_index); @@ -1893,7 +1893,7 @@ void CAdjNSSolver::BC_Isothermal_Wall(CGeometry *geometry, CSolver **solver_cont LinSysRes.AddBlock(iPoint, Res_Conv_i); LinSysRes.SubtractBlock(iPoint, Res_Visc_i); if (implicit) { - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_ii); + Jacobian.SubtractBlock2Diag(iPoint, Jacobian_ii); } } diff --git a/SU2_CFD/src/solvers/CAdjTurbSolver.cpp b/SU2_CFD/src/solvers/CAdjTurbSolver.cpp index 00f2343891a7..713e7f22eb46 100644 --- a/SU2_CFD/src/solvers/CAdjTurbSolver.cpp +++ b/SU2_CFD/src/solvers/CAdjTurbSolver.cpp @@ -264,7 +264,7 @@ void CAdjTurbSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_containe /*--- Add Residuals and Jacobians ---*/ conv_numerics->ComputeResidual(Residual, Jacobian_ii, NULL, config); LinSysRes.AddBlock(iPoint, Residual); - Jacobian.AddBlock(iPoint, iPoint, Jacobian_ii); + Jacobian.AddBlock2Diag(iPoint, Jacobian_ii); } @@ -334,10 +334,10 @@ void CAdjTurbSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_conta /*--- Add and Subtract Residual ---*/ LinSysRes.AddBlock(iPoint, Residual_i); LinSysRes.AddBlock(jPoint, Residual_j); - Jacobian.AddBlock(iPoint, iPoint, Jacobian_ii); + Jacobian.AddBlock2Diag(iPoint, Jacobian_ii); Jacobian.AddBlock(iPoint, jPoint, Jacobian_ij); Jacobian.AddBlock(jPoint, iPoint, Jacobian_ji); - Jacobian.AddBlock(jPoint, jPoint, Jacobian_jj); + Jacobian.AddBlock2Diag(jPoint, Jacobian_jj); } @@ -380,10 +380,10 @@ void CAdjTurbSolver::Viscous_Residual(CGeometry *geometry, CSolver **solver_cont LinSysRes.AddBlock(iPoint, Residual_i); LinSysRes.AddBlock(jPoint, Residual_j); - Jacobian.AddBlock(iPoint, iPoint, Jacobian_ii); + Jacobian.AddBlock2Diag(iPoint, Jacobian_ii); Jacobian.AddBlock(iPoint, jPoint, Jacobian_ij); Jacobian.AddBlock(jPoint, iPoint, Jacobian_ji); - Jacobian.AddBlock(jPoint, jPoint, Jacobian_jj); + Jacobian.AddBlock2Diag(jPoint, Jacobian_jj); } @@ -437,7 +437,7 @@ void CAdjTurbSolver::Source_Residual(CGeometry *geometry, CSolver **solver_conta /*--- Add and Subtract Residual ---*/ numerics->ComputeResidual(Residual, Jacobian_ii, NULL, config); LinSysRes.AddBlock(iPoint, Residual); - Jacobian.AddBlock(iPoint, iPoint, Jacobian_ii); + Jacobian.AddBlock2Diag(iPoint, Jacobian_ii); } @@ -468,10 +468,10 @@ void CAdjTurbSolver::Source_Residual(CGeometry *geometry, CSolver **solver_conta // second_numerics->ComputeResidual(Residual, Jacobian_ii, Jacobian_jj, config); // LinSysRes.AddBlock(iPoint, Residual); // LinSysRes.SubtractBlock(jPoint, Residual); -// Jacobian.AddBlock(iPoint, iPoint, Jacobian_ii); +// Jacobian.AddBlock2Diag(iPoint, Jacobian_ii); // Jacobian.AddBlock(iPoint, jPoint, Jacobian_jj); // Jacobian.SubtractBlock(jPoint, iPoint, Jacobian_ii); -// Jacobian.SubtractBlock(jPoint, jPoint, Jacobian_jj); +// Jacobian.SubtractBlock2Diag(jPoint, Jacobian_jj); // // } diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 4a8cce64259c..e6c28bbca663 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -3677,7 +3677,7 @@ void CEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_contain LinSysRes.AddBlock(iPoint, residual); /*--- Add the implicit Jacobian contribution ---*/ - if (implicit) Jacobian.AddBlock(iPoint, iPoint, residual.jacobian_i); + if (implicit) Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); } } @@ -3705,7 +3705,7 @@ void CEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_contain /*--- Implicit part ---*/ if (implicit) - Jacobian.AddBlock(iPoint, iPoint, residual.jacobian_i); + Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); } } @@ -3772,7 +3772,7 @@ void CEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_contain LinSysRes.AddBlock(iPoint, residual); /*--- Add the implicit Jacobian contribution ---*/ - if (implicit) Jacobian.AddBlock(iPoint, iPoint, residual.jacobian_i); + if (implicit) Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); } } @@ -5110,7 +5110,7 @@ void CEulerSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver for (iVar = 0; iVar < nVar; iVar ++ ) for (jVar = 0; jVar < nVar; jVar ++ ) LowMach_Preconditioner[iVar][jVar] = Delta*LowMach_Preconditioner[iVar][jVar]; - Jacobian.AddBlock(iPoint, iPoint, LowMach_Preconditioner); + Jacobian.AddBlock2Diag(iPoint, LowMach_Preconditioner); } else { Jacobian.AddVal2Diag(iPoint, Delta); @@ -7449,7 +7449,7 @@ void CEulerSolver::BC_Sym_Plane(CGeometry *geometry, /*--- Jacobian contribution for implicit integration. ---*/ if (implicit) { - Jacobian.AddBlock(iPoint, iPoint, residual.jacobian_i); + Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); } if (viscous) { @@ -7552,7 +7552,7 @@ void CEulerSolver::BC_Sym_Plane(CGeometry *geometry, /*--- Jacobian contribution for implicit integration. ---*/ if (implicit) - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i); + Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); }//if viscous }//if GetDomain }//for iVertex @@ -7776,7 +7776,7 @@ void CEulerSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_container, /*--- Convective Jacobian contribution for implicit integration ---*/ if (implicit) - Jacobian.AddBlock(iPoint, iPoint, residual.jacobian_i); + Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); /*--- Viscous residual contribution ---*/ @@ -7817,7 +7817,7 @@ void CEulerSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_container, /*--- Viscous Jacobian contribution for implicit integration ---*/ if (implicit) - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i); + Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); } @@ -8229,7 +8229,7 @@ void CEulerSolver::BC_Riemann(CGeometry *geometry, CSolver **solver_container, /*--- Jacobian contribution for implicit integration ---*/ if (implicit) - Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + Jacobian.AddBlock2Diag(iPoint, Jacobian_i); /*--- Viscous contribution ---*/ @@ -8300,7 +8300,7 @@ void CEulerSolver::BC_Riemann(CGeometry *geometry, CSolver **solver_container, /*--- Jacobian contribution for implicit integration ---*/ if (implicit) - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i); + Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); } @@ -8732,7 +8732,7 @@ void CEulerSolver::BC_TurboRiemann(CGeometry *geometry, CSolver **solver_contain /*--- Jacobian contribution for implicit integration ---*/ if (implicit) - Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + Jacobian.AddBlock2Diag(iPoint, Jacobian_i); /*--- Viscous contribution ---*/ @@ -8803,7 +8803,7 @@ void CEulerSolver::BC_TurboRiemann(CGeometry *geometry, CSolver **solver_contain /*--- Jacobian contribution for implicit integration ---*/ if (implicit) - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i); + Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); } } @@ -9636,7 +9636,7 @@ void CEulerSolver::BC_Giles(CGeometry *geometry, CSolver **solver_container, CNu /*--- Jacobian contribution for implicit integration ---*/ if (implicit) - Jacobian.AddBlock(iPoint, iPoint, residual.jacobian_i); + Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); /*--- Viscous contribution ---*/ @@ -9695,7 +9695,7 @@ void CEulerSolver::BC_Giles(CGeometry *geometry, CSolver **solver_container, CNu /*--- Jacobian contribution for implicit integration ---*/ if (implicit) - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i); + Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); } @@ -9979,7 +9979,7 @@ void CEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, /*--- Jacobian contribution for implicit integration ---*/ if (implicit) - Jacobian.AddBlock(iPoint, iPoint, residual.jacobian_i); + Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); // /*--- Viscous contribution, commented out because serious convergence problems ---*/ // @@ -10017,7 +10017,7 @@ void CEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, // /*--- Jacobian contribution for implicit integration ---*/ // // if (implicit) -// Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i); +// Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); // // } @@ -10153,7 +10153,7 @@ void CEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, LinSysRes.AddBlock(iPoint, residual); if (implicit) - Jacobian.AddBlock(iPoint, iPoint, residual.jacobian_i); + Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); // /*--- Viscous contribution, commented out because serious convergence problems ---*/ // @@ -10190,7 +10190,7 @@ void CEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, // /*--- Jacobian contribution for implicit integration ---*/ // // if (implicit) -// Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i); +// Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); // // } @@ -10295,7 +10295,7 @@ void CEulerSolver::BC_Supersonic_Inlet(CGeometry *geometry, CSolver **solver_con /*--- Jacobian contribution for implicit integration ---*/ if (implicit) - Jacobian.AddBlock(iPoint, iPoint, residual.jacobian_i); + Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); // /*--- Viscous contribution, commented out because serious convergence problems ---*/ // @@ -10333,7 +10333,7 @@ void CEulerSolver::BC_Supersonic_Inlet(CGeometry *geometry, CSolver **solver_con // /*--- Jacobian contribution for implicit integration ---*/ // // if (implicit) -// Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i); +// Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); // } } @@ -10415,7 +10415,7 @@ void CEulerSolver::BC_Supersonic_Outlet(CGeometry *geometry, CSolver **solver_co /*--- Jacobian contribution for implicit integration ---*/ if (implicit) - Jacobian.AddBlock(iPoint, iPoint, residual.jacobian_i); + Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); // /*--- Viscous contribution, commented out because serious convergence problems ---*/ // @@ -10453,7 +10453,7 @@ void CEulerSolver::BC_Supersonic_Outlet(CGeometry *geometry, CSolver **solver_co // /*--- Jacobian contribution for implicit integration ---*/ // // if (implicit) -// Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i); +// Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); // } } @@ -10637,7 +10637,7 @@ void CEulerSolver::BC_Engine_Inflow(CGeometry *geometry, CSolver **solver_contai /*--- Jacobian contribution for implicit integration ---*/ if (implicit) - Jacobian.AddBlock(iPoint, iPoint, residual.jacobian_i); + Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); // /*--- Viscous contribution, commented out because serious convergence problems ---*/ // @@ -10675,7 +10675,7 @@ void CEulerSolver::BC_Engine_Inflow(CGeometry *geometry, CSolver **solver_contai // /*--- Jacobian contribution for implicit integration ---*/ // // if (implicit) -// Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i); +// Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); // // } @@ -10891,7 +10891,7 @@ void CEulerSolver::BC_Engine_Exhaust(CGeometry *geometry, CSolver **solver_conta /*--- Jacobian contribution for implicit integration ---*/ if (implicit) - Jacobian.AddBlock(iPoint, iPoint, residual.jacobian_i); + Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); // /*--- Viscous contribution, commented out because serious convergence problems ---*/ // @@ -10929,7 +10929,7 @@ void CEulerSolver::BC_Engine_Exhaust(CGeometry *geometry, CSolver **solver_conta // /*--- Jacobian contribution for implicit integration ---*/ // // if (implicit) -// Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i); +// Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); // // } @@ -11038,7 +11038,7 @@ void CEulerSolver::BC_Fluid_Interface(CGeometry *geometry, CSolver **solver_cont LinSysRes.AddBlock(iPoint, Residual); if (implicit) - Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + Jacobian.AddBlock2Diag(iPoint, Jacobian_i); if (viscous) { @@ -11091,7 +11091,7 @@ void CEulerSolver::BC_Fluid_Interface(CGeometry *geometry, CSolver **solver_cont /*--- Jacobian contribution for implicit integration ---*/ if (implicit) - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i); + Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); } } @@ -11149,7 +11149,7 @@ void CEulerSolver::BC_Interface_Boundary(CGeometry *geometry, CSolver **solver_c /*--- Add Residuals and Jacobians ---*/ LinSysRes.AddBlock(iPoint, residual); - if (implicit) Jacobian.AddBlock(iPoint, iPoint, residual.jacobian_i); + if (implicit) Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); } @@ -11212,7 +11212,7 @@ void CEulerSolver::BC_NearField_Boundary(CGeometry *geometry, CSolver **solver_c LinSysRes.AddBlock(iPoint, residual); if (implicit) - Jacobian.AddBlock(iPoint, iPoint, residual.jacobian_i); + Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); } } @@ -11591,7 +11591,7 @@ void CEulerSolver::BC_ActDisk(CGeometry *geometry, CSolver **solver_container, C /*--- Jacobian contribution for implicit integration ---*/ - if (implicit) Jacobian.AddBlock(iPoint, iPoint, residual.jacobian_i); + if (implicit) Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); // /*--- Viscous contribution, commented out because serious convergence problems ---*/ // @@ -11636,7 +11636,7 @@ void CEulerSolver::BC_ActDisk(CGeometry *geometry, CSolver **solver_container, C // // /*--- Jacobian contribution for implicit integration ---*/ // -// if (implicit) Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i); +// if (implicit) Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); // // } @@ -11800,7 +11800,7 @@ void CEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_co if (config->GetTime_Marching() == DT_STEPPING_2ND) Jacobian_i[iVar][iVar] = (Volume_nP1*3.0)/(2.0*TimeStep); } - Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + Jacobian.AddBlock2Diag(iPoint, Jacobian_i); } } @@ -11929,7 +11929,7 @@ void CEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_co if (config->GetTime_Marching() == DT_STEPPING_2ND) Jacobian_i[iVar][iVar] = (3.0*Volume_nP1)/(2.0*TimeStep); } - Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + Jacobian.AddBlock2Diag(iPoint, Jacobian_i); } } } diff --git a/SU2_CFD/src/solvers/CHeatSolverFVM.cpp b/SU2_CFD/src/solvers/CHeatSolverFVM.cpp index de738528e81b..60b43a901708 100644 --- a/SU2_CFD/src/solvers/CHeatSolverFVM.cpp +++ b/SU2_CFD/src/solvers/CHeatSolverFVM.cpp @@ -714,10 +714,7 @@ void CHeatSolverFVM::Viscous_Residual(CGeometry *geometry, CSolver **solver_cont LinSysRes.SubtractBlock(iPoint, Residual); LinSysRes.AddBlock(jPoint, Residual); - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i); - Jacobian.SubtractBlock(iPoint, jPoint, Jacobian_j); - Jacobian.AddBlock(jPoint, iPoint, Jacobian_i); - Jacobian.AddBlock(jPoint, jPoint, Jacobian_j); + Jacobian.UpdateBlocksSub(iEdge, iPoint, jPoint, Jacobian_i, Jacobian_j); } } @@ -850,7 +847,7 @@ void CHeatSolverFVM::BC_Isothermal_Wall(CGeometry *geometry, CSolver **solver_co } LinSysRes.SubtractBlock(iPoint, Res_Visc); - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i); + Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); } } } @@ -984,7 +981,7 @@ void CHeatSolverFVM::BC_Inlet(CGeometry *geometry, CSolver **solver_container, /*--- Jacobian contribution for implicit integration ---*/ if (implicit) - Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + Jacobian.AddBlock2Diag(iPoint, Jacobian_i); } /*--- Viscous contribution ---*/ @@ -1018,7 +1015,7 @@ void CHeatSolverFVM::BC_Inlet(CGeometry *geometry, CSolver **solver_container, /*--- Viscous contribution to the residual at the wall ---*/ LinSysRes.SubtractBlock(iPoint, Res_Visc); - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i); + Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); } } } @@ -1087,7 +1084,7 @@ void CHeatSolverFVM::BC_Outlet(CGeometry *geometry, CSolver **solver_container, /*--- Jacobian contribution for implicit integration ---*/ if (implicit) - Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + Jacobian.AddBlock2Diag(iPoint, Jacobian_i); } } } @@ -1180,7 +1177,7 @@ void CHeatSolverFVM::BC_ConjugateHeat_Interface(CGeometry *geometry, CSolver **s if (implicit) { Jacobian_i[0][0] = thermal_diffusivity*Area; - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i); + Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); } } } @@ -1810,7 +1807,7 @@ void CHeatSolverFVM::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_ Jacobian_i[iVar][iVar] = (Volume_nP1*3.0)/(2.0*TimeStep); } - Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + Jacobian.AddBlock2Diag(iPoint, Jacobian_i); } } } diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index 067ec4a16676..3bbe19c18d9d 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -2133,7 +2133,7 @@ void CIncEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_cont /*--- Add the implicit Jacobian contribution ---*/ - if (implicit) Jacobian.AddBlock(iPoint, iPoint, residual.jacobian_i); + if (implicit) Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); } } @@ -2218,7 +2218,7 @@ void CIncEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_cont /*--- Implicit part ---*/ if (implicit) - Jacobian.AddBlock(iPoint, iPoint, residual.jacobian_i); + Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); } } @@ -3433,7 +3433,7 @@ void CIncEulerSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **sol Preconditioner[iVar][jVar] = Delta*Preconditioner[iVar][jVar]; } } - Jacobian.AddBlock(iPoint, iPoint, Preconditioner); + Jacobian.AddBlock2Diag(iPoint, Preconditioner); } else { Jacobian.SetVal2Diag(iPoint, 1.0); for (iVar = 0; iVar < nVar; iVar++) { @@ -4075,7 +4075,7 @@ void CIncEulerSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_contain /*--- Convective Jacobian contribution for implicit integration ---*/ if (implicit) - Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + Jacobian.AddBlock2Diag(iPoint, Jacobian_i); /*--- Viscous residual contribution ---*/ @@ -4113,7 +4113,7 @@ void CIncEulerSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_contain /*--- Viscous Jacobian contribution for implicit integration ---*/ if (implicit) - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i); + Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); } @@ -4327,7 +4327,7 @@ void CIncEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, /*--- Jacobian contribution for implicit integration ---*/ if (implicit) - Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + Jacobian.AddBlock2Diag(iPoint, Jacobian_i); /*--- Viscous contribution, commented out because serious convergence problems ---*/ @@ -4366,7 +4366,7 @@ void CIncEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, /*--- Jacobian contribution for implicit integration ---*/ if (implicit) - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i); + Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); } @@ -4535,7 +4535,7 @@ void CIncEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, /*--- Jacobian contribution for implicit integration ---*/ if (implicit) { - Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + Jacobian.AddBlock2Diag(iPoint, Jacobian_i); } /*--- Viscous contribution, commented out because serious convergence problems ---*/ @@ -4574,7 +4574,7 @@ void CIncEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, /*--- Jacobian contribution for implicit integration ---*/ if (implicit) - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i); + Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); } @@ -4751,7 +4751,7 @@ void CIncEulerSolver::BC_Sym_Plane(CGeometry *geometry, /*--- Jacobian contribution for implicit integration. ---*/ if (implicit) { - Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + Jacobian.AddBlock2Diag(iPoint, Jacobian_i); } if (viscous) { @@ -4853,7 +4853,7 @@ void CIncEulerSolver::BC_Sym_Plane(CGeometry *geometry, /*--- Jacobian contribution for implicit integration. ---*/ if (implicit) - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i); + Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); }//if viscous }//if GetDomain }//for iVertex @@ -4948,7 +4948,7 @@ void CIncEulerSolver::BC_Fluid_Interface(CGeometry *geometry, CSolver **solver_c LinSysRes.AddBlock(iPoint, Residual); if (implicit) - Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + Jacobian.AddBlock2Diag(iPoint, Jacobian_i); if (viscous) { @@ -5001,7 +5001,7 @@ void CIncEulerSolver::BC_Fluid_Interface(CGeometry *geometry, CSolver **solver_c /*--- Jacobian contribution for implicit integration ---*/ if (implicit) - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i); + Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); } } @@ -5224,7 +5224,7 @@ void CIncEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver } } - Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + Jacobian.AddBlock2Diag(iPoint, Jacobian_i); } } @@ -5448,7 +5448,7 @@ void CIncEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver Jacobian_i[nDim+1][iVar] = 0.0; } } - Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + Jacobian.AddBlock2Diag(iPoint, Jacobian_i); } } } diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index e22d4398e7c9..18b8e09f6c6c 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -1129,10 +1129,7 @@ void CIncNSSolver::Viscous_Residual(CGeometry *geometry, CSolver **solver_contai /*--- Implicit part ---*/ if (implicit) { - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i); - Jacobian.SubtractBlock(iPoint, jPoint, Jacobian_j); - Jacobian.AddBlock(jPoint, iPoint, Jacobian_i); - Jacobian.AddBlock(jPoint, jPoint, Jacobian_j); + Jacobian.UpdateBlocksSub(iEdge, iPoint, jPoint, Jacobian_i, Jacobian_j); } } @@ -1823,7 +1820,7 @@ void CIncNSSolver::BC_Isothermal_Wall(CGeometry *geometry, CSolver **solver_cont Jacobian_i[nDim+1][nDim+1] = -thermal_conductivity*proj_vector_ij; - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i); + Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); } /*--- Viscous contribution to the residual at the wall ---*/ diff --git a/SU2_CFD/src/solvers/CNSSolver.cpp b/SU2_CFD/src/solvers/CNSSolver.cpp index b3e355f5063a..dd90b70efed6 100644 --- a/SU2_CFD/src/solvers/CNSSolver.cpp +++ b/SU2_CFD/src/solvers/CNSSolver.cpp @@ -1393,10 +1393,7 @@ void CNSSolver::Viscous_Residual(CGeometry *geometry, CSolver **solver_container /*--- Implicit part ---*/ if (implicit) { - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i); - Jacobian.SubtractBlock(iPoint, jPoint, Jacobian_j); - Jacobian.AddBlock(jPoint, iPoint, Jacobian_i); - Jacobian.AddBlock(jPoint, jPoint, Jacobian_j); + Jacobian.UpdateBlocksSub(iEdge, iPoint, jPoint, Jacobian_i, Jacobian_j); } } @@ -2193,7 +2190,7 @@ void CNSSolver::BC_HeatFlux_Wall(CGeometry *geometry, CSolver **solver_container /*--- Add the block to the Global Jacobian structure ---*/ - Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + Jacobian.AddBlock2Diag(iPoint, Jacobian_i); /*--- Now the Jacobian contribution related to the shear stress ---*/ @@ -2254,7 +2251,7 @@ void CNSSolver::BC_HeatFlux_Wall(CGeometry *geometry, CSolver **solver_container /*--- Subtract the block from the Global Jacobian structure ---*/ - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i); + Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); } } @@ -2431,7 +2428,7 @@ void CNSSolver::BC_Isothermal_Wall(CGeometry *geometry, CSolver **solver_contain /*--- Subtract the block from the Global Jacobian structure ---*/ - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i); + Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); } @@ -2507,7 +2504,7 @@ void CNSSolver::BC_Isothermal_Wall(CGeometry *geometry, CSolver **solver_contain /*--- Add the block to the Global Jacobian structure ---*/ - Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + Jacobian.AddBlock2Diag(iPoint, Jacobian_i); /*--- Now the Jacobian contribution related to the shear stress ---*/ @@ -2551,7 +2548,7 @@ void CNSSolver::BC_Isothermal_Wall(CGeometry *geometry, CSolver **solver_contain /*--- Subtract the block from the Global Jacobian structure ---*/ - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i); + Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); } } @@ -2773,7 +2770,7 @@ void CNSSolver::BC_ConjugateHeat_Interface(CGeometry *geometry, CSolver **solver /*--- Subtract the block from the Global Jacobian structure ---*/ - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i); + Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); } @@ -2850,7 +2847,7 @@ void CNSSolver::BC_ConjugateHeat_Interface(CGeometry *geometry, CSolver **solver /*--- Add the block to the Global Jacobian structure ---*/ - Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + Jacobian.AddBlock2Diag(iPoint, Jacobian_i); /*--- Now the Jacobian contribution related to the shear stress ---*/ @@ -2894,7 +2891,7 @@ void CNSSolver::BC_ConjugateHeat_Interface(CGeometry *geometry, CSolver **solver /*--- Subtract the block from the Global Jacobian structure ---*/ - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i); + Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); } } diff --git a/SU2_CFD/src/solvers/CSolver.cpp b/SU2_CFD/src/solvers/CSolver.cpp index 5cfb9cc348d2..7a461cca1b25 100644 --- a/SU2_CFD/src/solvers/CSolver.cpp +++ b/SU2_CFD/src/solvers/CSolver.cpp @@ -1664,7 +1664,7 @@ void CSolver::CompletePeriodicComms(CGeometry *geometry, if (implicit_periodic) { - Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + Jacobian.AddBlock2Diag(iPoint, Jacobian_i); if (iPeriodic == val_periodic_index + nPeriodic/2) { for (iVar = 0; iVar < nVar; iVar++) { diff --git a/SU2_CFD/src/solvers/CTransLMSolver.cpp b/SU2_CFD/src/solvers/CTransLMSolver.cpp index 4fdd1bbca056..ef809beab789 100644 --- a/SU2_CFD/src/solvers/CTransLMSolver.cpp +++ b/SU2_CFD/src/solvers/CTransLMSolver.cpp @@ -290,10 +290,7 @@ void CTransLMSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_conta LinSysRes.SubtractBlock(jPoint, Residual); /*--- Implicit part ---*/ - Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); - Jacobian.AddBlock(iPoint, jPoint, Jacobian_j); - Jacobian.SubtractBlock(jPoint, iPoint, Jacobian_i); - Jacobian.SubtractBlock(jPoint, jPoint, Jacobian_j); + Jacobian.UpdateBlocks(iEdge, iPoint, jPoint, Jacobian_i, Jacobian_j); } @@ -343,10 +340,7 @@ void CTransLMSolver::Viscous_Residual(CGeometry *geometry, CSolver **solver_cont LinSysRes.SubtractBlock(iPoint, Residual); LinSysRes.AddBlock(jPoint, Residual); - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i); - Jacobian.SubtractBlock(iPoint, jPoint, Jacobian_j); - Jacobian.AddBlock(jPoint, iPoint, Jacobian_i); - Jacobian.AddBlock(jPoint, jPoint, Jacobian_j); + Jacobian.UpdateBlocksSub(iEdge, iPoint, jPoint, Jacobian_i, Jacobian_j); } } @@ -401,7 +395,7 @@ void CTransLMSolver::Source_Residual(CGeometry *geometry, CSolver **solver_conta /*--- Subtract residual and the Jacobian ---*/ LinSysRes.SubtractBlock(iPoint, Residual); - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i); + Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); } } @@ -456,7 +450,7 @@ void CTransLMSolver::BC_HeatFlux_Wall(CGeometry *geometry, CSolver **solver_cont // cout << "Implicit part -AA" << endl; /*--- Jacobian contribution for implicit integration ---*/ if (implicit) { - Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + Jacobian.AddBlock2Diag(iPoint, Jacobian_i); } } } diff --git a/SU2_CFD/src/solvers/CTurbSASolver.cpp b/SU2_CFD/src/solvers/CTurbSASolver.cpp index 88d133e08a3d..9054233b057a 100644 --- a/SU2_CFD/src/solvers/CTurbSASolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSASolver.cpp @@ -448,7 +448,7 @@ void CTurbSASolver::Source_Residual(CGeometry *geometry, CSolver **solver_contai LinSysRes.SubtractBlock(iPoint, Residual); - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i); + Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); } @@ -606,7 +606,7 @@ void CTurbSASolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_container /*--- Add residuals and Jacobians ---*/ LinSysRes.AddBlock(iPoint, Residual); - Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + Jacobian.AddBlock2Diag(iPoint, Jacobian_i); } } @@ -677,7 +677,7 @@ void CTurbSASolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, CN /*--- Jacobian contribution for implicit integration ---*/ - Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + Jacobian.AddBlock2Diag(iPoint, Jacobian_i); // /*--- Viscous contribution, commented out because serious convergence problems ---*/ // @@ -700,7 +700,7 @@ void CTurbSASolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, CN // /*--- Subtract residual, and update Jacobians ---*/ // // LinSysRes.SubtractBlock(iPoint, Residual); -// Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i); +// Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); } } @@ -769,7 +769,7 @@ void CTurbSASolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, C /*--- Jacobian contribution for implicit integration ---*/ - Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + Jacobian.AddBlock2Diag(iPoint, Jacobian_i); // /*--- Viscous contribution, commented out because serious convergence problems ---*/ // @@ -792,7 +792,7 @@ void CTurbSASolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, C // /*--- Subtract residual, and update Jacobians ---*/ // // LinSysRes.SubtractBlock(iPoint, Residual); -// Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i); +// Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); } } @@ -859,7 +859,7 @@ void CTurbSASolver::BC_Engine_Inflow(CGeometry *geometry, CSolver **solver_conta /*--- Jacobian contribution for implicit integration ---*/ - Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + Jacobian.AddBlock2Diag(iPoint, Jacobian_i); // /*--- Viscous contribution, commented out because serious convergence problems ---*/ // @@ -882,7 +882,7 @@ void CTurbSASolver::BC_Engine_Inflow(CGeometry *geometry, CSolver **solver_conta // /*--- Subtract residual, and update Jacobians ---*/ // // LinSysRes.SubtractBlock(iPoint, Residual); -// Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i); +// Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); } @@ -955,7 +955,7 @@ void CTurbSASolver::BC_Engine_Exhaust(CGeometry *geometry, CSolver **solver_cont /*--- Jacobian contribution for implicit integration ---*/ - Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + Jacobian.AddBlock2Diag(iPoint, Jacobian_i); // /*--- Viscous contribution, commented out because serious convergence problems ---*/ // @@ -978,7 +978,7 @@ void CTurbSASolver::BC_Engine_Exhaust(CGeometry *geometry, CSolver **solver_cont // /*--- Subtract residual, and update Jacobians ---*/ // // LinSysRes.SubtractBlock(iPoint, Residual); -// Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i); +// Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); } } @@ -1117,7 +1117,7 @@ void CTurbSASolver::BC_ActDisk(CGeometry *geometry, CSolver **solver_container, /*--- Jacobian contribution for implicit integration ---*/ - Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + Jacobian.AddBlock2Diag(iPoint, Jacobian_i); // /*--- Viscous contribution, commented out because serious convergence problems ---*/ // @@ -1142,7 +1142,7 @@ void CTurbSASolver::BC_ActDisk(CGeometry *geometry, CSolver **solver_container, // /*--- Subtract residual, and update Jacobians ---*/ // // LinSysRes.SubtractBlock(iPoint, Residual); -// Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i); +// Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); } } @@ -1227,7 +1227,7 @@ void CTurbSASolver::BC_Inlet_MixingPlane(CGeometry *geometry, CSolver **solver_c /*--- Jacobian contribution for implicit integration ---*/ - Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + Jacobian.AddBlock2Diag(iPoint, Jacobian_i); /*--- Viscous contribution ---*/ @@ -1250,7 +1250,7 @@ void CTurbSASolver::BC_Inlet_MixingPlane(CGeometry *geometry, CSolver **solver_c /*--- Subtract residual, and update Jacobians ---*/ LinSysRes.SubtractBlock(iPoint, Residual); - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i); + Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); } } @@ -1343,7 +1343,7 @@ void CTurbSASolver::BC_Inlet_Turbo(CGeometry *geometry, CSolver **solver_contain /*--- Jacobian contribution for implicit integration ---*/ - Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + Jacobian.AddBlock2Diag(iPoint, Jacobian_i); /*--- Viscous contribution ---*/ @@ -1366,7 +1366,7 @@ void CTurbSASolver::BC_Inlet_Turbo(CGeometry *geometry, CSolver **solver_contain /*--- Subtract residual, and update Jacobians ---*/ LinSysRes.SubtractBlock(iPoint, Residual); - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i); + Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); } } @@ -1423,7 +1423,7 @@ void CTurbSASolver::BC_Interface_Boundary(CGeometry *geometry, CSolver **solver_ // /*--- Add Residuals and Jacobians ---*/ // numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); // LinSysRes.AddBlock(iPoint, Residual); - // Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + // Jacobian.AddBlock2Diag(iPoint, Jacobian_i); // // } // } @@ -1524,7 +1524,7 @@ void CTurbSASolver::BC_Interface_Boundary(CGeometry *geometry, CSolver **solver_ // // numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); // LinSysRes.AddBlock(iPoint, Residual); - // Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + // Jacobian.AddBlock2Diag(iPoint, Jacobian_i); // // } // } @@ -1619,7 +1619,7 @@ void CTurbSASolver::BC_Fluid_Interface(CGeometry *geometry, CSolver **solver_con LinSysRes.AddBlock(iPoint, Residual); - Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + Jacobian.AddBlock2Diag(iPoint, Jacobian_i); /*--- Set the normal vector and the coordinates ---*/ @@ -1644,7 +1644,7 @@ void CTurbSASolver::BC_Fluid_Interface(CGeometry *geometry, CSolver **solver_con /*--- Jacobian contribution for implicit integration ---*/ - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i); + Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); } } @@ -1707,7 +1707,7 @@ void CTurbSASolver::BC_NearField_Boundary(CGeometry *geometry, CSolver **solver_ // /*--- Add Residuals and Jacobians ---*/ // numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); // LinSysRes.AddBlock(iPoint, Residual); - // Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + // Jacobian.AddBlock2Diag(iPoint, Jacobian_i); // // } // } @@ -1808,7 +1808,7 @@ void CTurbSASolver::BC_NearField_Boundary(CGeometry *geometry, CSolver **solver_ // // numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); // LinSysRes.AddBlock(iPoint, Residual); - // Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + // Jacobian.AddBlock2Diag(iPoint, Jacobian_i); // // } // } diff --git a/SU2_CFD/src/solvers/CTurbSSTSolver.cpp b/SU2_CFD/src/solvers/CTurbSSTSolver.cpp index 4680e813a8b0..97a8eed16232 100644 --- a/SU2_CFD/src/solvers/CTurbSSTSolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSSTSolver.cpp @@ -436,7 +436,7 @@ void CTurbSSTSolver::Source_Residual(CGeometry *geometry, CSolver **solver_conta /*--- Subtract residual and the Jacobian ---*/ LinSysRes.SubtractBlock(iPoint, Residual); - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i); + Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); } @@ -597,7 +597,7 @@ void CTurbSSTSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_containe /*--- Add residuals and Jacobians ---*/ LinSysRes.AddBlock(iPoint, Residual); - Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + Jacobian.AddBlock2Diag(iPoint, Jacobian_i); } } @@ -672,7 +672,7 @@ void CTurbSSTSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, C /*--- Jacobian contribution for implicit integration ---*/ - Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + Jacobian.AddBlock2Diag(iPoint, Jacobian_i); // /*--- Viscous contribution, commented out because serious convergence problems ---*/ // @@ -699,7 +699,7 @@ void CTurbSSTSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, C // /*--- Subtract residual, and update Jacobians ---*/ // // LinSysRes.SubtractBlock(iPoint, Residual); - // Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i); + // Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); } @@ -770,7 +770,7 @@ void CTurbSSTSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, /*--- Jacobian contribution for implicit integration ---*/ - Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + Jacobian.AddBlock2Diag(iPoint, Jacobian_i); // /*--- Viscous contribution, commented out because serious convergence problems ---*/ // @@ -797,7 +797,7 @@ void CTurbSSTSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, // /*--- Subtract residual, and update Jacobians ---*/ // // LinSysRes.SubtractBlock(iPoint, Residual); -// Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i); +// Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); } } @@ -878,7 +878,7 @@ void CTurbSSTSolver::BC_Inlet_MixingPlane(CGeometry *geometry, CSolver **solver_ LinSysRes.AddBlock(iPoint, Residual); /*--- Jacobian contribution for implicit integration ---*/ - Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + Jacobian.AddBlock2Diag(iPoint, Jacobian_i); /*--- Viscous contribution ---*/ visc_numerics->SetCoord(geometry->node[iPoint]->GetCoord(), geometry->node[Point_Normal]->GetCoord()); @@ -899,7 +899,7 @@ void CTurbSSTSolver::BC_Inlet_MixingPlane(CGeometry *geometry, CSolver **solver_ /*--- Subtract residual, and update Jacobians ---*/ LinSysRes.SubtractBlock(iPoint, Residual); - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i); + Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); } } @@ -1003,7 +1003,7 @@ void CTurbSSTSolver::BC_Inlet_Turbo(CGeometry *geometry, CSolver **solver_contai LinSysRes.AddBlock(iPoint, Residual); /*--- Jacobian contribution for implicit integration ---*/ - Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + Jacobian.AddBlock2Diag(iPoint, Jacobian_i); /*--- Viscous contribution ---*/ visc_numerics->SetCoord(geometry->node[iPoint]->GetCoord(), geometry->node[Point_Normal]->GetCoord()); @@ -1024,7 +1024,7 @@ void CTurbSSTSolver::BC_Inlet_Turbo(CGeometry *geometry, CSolver **solver_contai /*--- Subtract residual, and update Jacobians ---*/ LinSysRes.SubtractBlock(iPoint, Residual); - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i); + Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); } } @@ -1117,7 +1117,7 @@ void CTurbSSTSolver::BC_Fluid_Interface(CGeometry *geometry, CSolver **solver_co LinSysRes.AddBlock(iPoint, Residual); - Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + Jacobian.AddBlock2Diag(iPoint, Jacobian_i); /*--- Set the normal vector and the coordinates ---*/ @@ -1142,7 +1142,7 @@ void CTurbSSTSolver::BC_Fluid_Interface(CGeometry *geometry, CSolver **solver_co /*--- Jacobian contribution for implicit integration ---*/ - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i); + Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); } } diff --git a/SU2_CFD/src/solvers/CTurbSolver.cpp b/SU2_CFD/src/solvers/CTurbSolver.cpp index b959386e3962..5dbeeea820a8 100644 --- a/SU2_CFD/src/solvers/CTurbSolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSolver.cpp @@ -241,7 +241,7 @@ void CTurbSolver::Viscous_Residual(CGeometry *geometry, CSolver **solver_contain LinSysRes.SubtractBlock(iPoint, Residual); LinSysRes.AddBlock(jPoint, Residual); - Jacobian.UpdateBlocks(iEdge, iPoint, jPoint, Jacobian_i, Jacobian_j); + Jacobian.UpdateBlocksSub(iEdge, iPoint, jPoint, Jacobian_i, Jacobian_j); } @@ -611,7 +611,7 @@ void CTurbSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_con if (config->GetTime_Marching() == DT_STEPPING_2ND) Jacobian_i[iVar][iVar] = (Volume_nP1*3.0)/(2.0*TimeStep); } - Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + Jacobian.AddBlock2Diag(iPoint, Jacobian_i); } } @@ -799,7 +799,7 @@ void CTurbSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_con if (config->GetTime_Marching() == DT_STEPPING_2ND) Jacobian_i[iVar][iVar] = (3.0*Volume_nP1)/(2.0*TimeStep); } - Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); + Jacobian.AddBlock2Diag(iPoint, Jacobian_i); } } } From c632de1dc2a87a62f665594ae709e73000ceb425 Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Thu, 30 Jan 2020 08:53:02 +0000 Subject: [PATCH 046/118] parallel SetMax_Eigenvalue --- SU2_CFD/src/solvers/CEulerSolver.cpp | 105 ++++++++++++++++----------- 1 file changed, 64 insertions(+), 41 deletions(-) diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index e6c28bbca663..c5bf2e23ddba 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -3828,86 +3828,104 @@ void CEulerSolver::Source_Template(CGeometry *geometry, CSolver **solver_contain void CEulerSolver::SetMax_Eigenvalue(CGeometry *geometry, CConfig *config) { - su2double *Normal, Area, Mean_SoundSpeed = 0.0, Mean_ProjVel = 0.0, Lambda, - ProjVel, ProjVel_i, ProjVel_j, *GridVel, *GridVel_i, *GridVel_j; - unsigned long iEdge, iVertex, iPoint, jPoint; - unsigned short iDim, iMarker; + /*--- Start OpenMP parallel section. ---*/ + SU2_OMP_PARALLEL + { /*--- Set maximum inviscid eigenvalue to zero, and compute sound speed ---*/ - for (iPoint = 0; iPoint < nPointDomain; iPoint++) { + SU2_OMP_FOR_STAT(omp_chunk_size) + for (unsigned long iPoint = 0; iPoint < nPointDomain; iPoint++) { nodes->SetLambda(iPoint,0.0); } /*--- Loop interior edges ---*/ - for (iEdge = 0; iEdge < geometry->GetnEdge(); iEdge++) { + #ifdef HAVE_OMP + /*--- Chunk size is at least OMP_MIN_SIZE and a multiple of the color group size. ---*/ + auto chunkSize = roundUpDiv(OMP_MIN_SIZE, ColorGroupSize)*ColorGroupSize; + /*--- Loop over edge colors. ---*/ + for (auto color : EdgeColoring) + { + SU2_OMP_FOR_STAT(chunkSize) + for(auto k = 0ul; k < color.size; ++k) { + + auto iEdge = color.indices[k]; +#else + /*--- Natural coloring. ---*/ + { + for (auto iEdge = 0ul; iEdge < geometry->GetnEdge(); iEdge++) { +#endif /*--- Point identification, Normal vector and area ---*/ - iPoint = geometry->edge[iEdge]->GetNode(0); - jPoint = geometry->edge[iEdge]->GetNode(1); + auto iPoint = geometry->edge[iEdge]->GetNode(0); + auto jPoint = geometry->edge[iEdge]->GetNode(1); - Normal = geometry->edge[iEdge]->GetNormal(); - Area = 0.0; for (iDim = 0; iDim < nDim; iDim++) Area += Normal[iDim]*Normal[iDim]; Area = sqrt(Area); + auto Normal = geometry->edge[iEdge]->GetNormal(); + su2double Area = 0.0; + for (unsigned short iDim = 0; iDim < nDim; iDim++) + Area += pow(Normal[iDim],2); + Area = sqrt(Area); /*--- Mean Values ---*/ - Mean_ProjVel = 0.5 * (nodes->GetProjVel(iPoint,Normal) + nodes->GetProjVel(jPoint,Normal)); - Mean_SoundSpeed = 0.5 * (nodes->GetSoundSpeed(iPoint) + nodes->GetSoundSpeed(jPoint)) * Area; + su2double Mean_ProjVel = 0.5 * (nodes->GetProjVel(iPoint,Normal) + nodes->GetProjVel(jPoint,Normal)); + su2double Mean_SoundSpeed = 0.5 * (nodes->GetSoundSpeed(iPoint) + nodes->GetSoundSpeed(jPoint)) * Area; /*--- Adjustment for grid movement ---*/ if (dynamic_grid) { - GridVel_i = geometry->node[iPoint]->GetGridVel(); - GridVel_j = geometry->node[jPoint]->GetGridVel(); - ProjVel_i = 0.0; ProjVel_j =0.0; - for (iDim = 0; iDim < nDim; iDim++) { - ProjVel_i += GridVel_i[iDim]*Normal[iDim]; - ProjVel_j += GridVel_j[iDim]*Normal[iDim]; + auto GridVel_i = geometry->node[iPoint]->GetGridVel(); + auto GridVel_j = geometry->node[jPoint]->GetGridVel(); + for (unsigned short iDim = 0; iDim < nDim; iDim++) { + Mean_ProjVel -= 0.5 * (GridVel_i[iDim] + GridVel_j[iDim])*Normal[iDim]; } - Mean_ProjVel -= 0.5 * (ProjVel_i + ProjVel_j); } /*--- Inviscid contribution ---*/ - Lambda = fabs(Mean_ProjVel) + Mean_SoundSpeed; + su2double Lambda = fabs(Mean_ProjVel) + Mean_SoundSpeed; if (geometry->node[iPoint]->GetDomain()) nodes->AddLambda(iPoint, Lambda); if (geometry->node[jPoint]->GetDomain()) nodes->AddLambda(jPoint, Lambda); } + } // end color loop /*--- Loop boundary edges ---*/ - for (iMarker = 0; iMarker < geometry->GetnMarker(); iMarker++) { + for (unsigned short iMarker = 0; iMarker < geometry->GetnMarker(); iMarker++) { if ((config->GetMarker_All_KindBC(iMarker) != INTERNAL_BOUNDARY) && (config->GetMarker_All_KindBC(iMarker) != PERIODIC_BOUNDARY)) { - for (iVertex = 0; iVertex < geometry->GetnVertex(iMarker); iVertex++) { + + SU2_OMP_FOR_STAT(OMP_MIN_SIZE) + for (unsigned long iVertex = 0; iVertex < geometry->GetnVertex(iMarker); iVertex++) { /*--- Point identification, Normal vector and area ---*/ - iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); - Normal = geometry->vertex[iMarker][iVertex]->GetNormal(); - Area = 0.0; for (iDim = 0; iDim < nDim; iDim++) Area += Normal[iDim]*Normal[iDim]; Area = sqrt(Area); + auto iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); + auto Normal = geometry->vertex[iMarker][iVertex]->GetNormal(); + su2double Area = 0.0; + for (unsigned short iDim = 0; iDim < nDim; iDim++) + Area += pow(Normal[iDim],2); + Area = sqrt(Area); /*--- Mean Values ---*/ - Mean_ProjVel = nodes->GetProjVel(iPoint,Normal); - Mean_SoundSpeed = nodes->GetSoundSpeed(iPoint) * Area; + su2double Mean_ProjVel = nodes->GetProjVel(iPoint,Normal); + su2double Mean_SoundSpeed = nodes->GetSoundSpeed(iPoint) * Area; /*--- Adjustment for grid movement ---*/ if (dynamic_grid) { - GridVel = geometry->node[iPoint]->GetGridVel(); - ProjVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjVel += GridVel[iDim]*Normal[iDim]; - Mean_ProjVel -= ProjVel; + auto GridVel = geometry->node[iPoint]->GetGridVel(); + for (unsigned short iDim = 0; iDim < nDim; iDim++) + Mean_ProjVel -= GridVel[iDim]*Normal[iDim]; } /*--- Inviscid contribution ---*/ - Lambda = fabs(Mean_ProjVel) + Mean_SoundSpeed; + su2double Lambda = fabs(Mean_ProjVel) + Mean_SoundSpeed; if (geometry->node[iPoint]->GetDomain()) { nodes->AddLambda(iPoint,Lambda); } @@ -3915,18 +3933,23 @@ void CEulerSolver::SetMax_Eigenvalue(CGeometry *geometry, CConfig *config) { } } - /*--- Correct the eigenvalue values across any periodic boundaries. ---*/ + SU2_OMP_BARRIER + SU2_OMP_MASTER + { + /*--- Correct the eigenvalue values across any periodic boundaries. ---*/ - for (unsigned short iPeriodic = 1; iPeriodic <= config->GetnMarker_Periodic()/2; iPeriodic++) { - InitiatePeriodicComms(geometry, config, iPeriodic, PERIODIC_MAX_EIG); - CompletePeriodicComms(geometry, config, iPeriodic, PERIODIC_MAX_EIG); - } + for (unsigned short iPeriodic = 1; iPeriodic <= config->GetnMarker_Periodic()/2; iPeriodic++) { + InitiatePeriodicComms(geometry, config, iPeriodic, PERIODIC_MAX_EIG); + CompletePeriodicComms(geometry, config, iPeriodic, PERIODIC_MAX_EIG); + } - /*--- MPI parallelization ---*/ + /*--- MPI parallelization ---*/ - InitiateComms(geometry, config, MAX_EIGENVALUE); - CompleteComms(geometry, config, MAX_EIGENVALUE); + InitiateComms(geometry, config, MAX_EIGENVALUE); + CompleteComms(geometry, config, MAX_EIGENVALUE); + } + } // end SU2_OMP_PARALLEL } void CEulerSolver::SetUndivided_Laplacian(CGeometry *geometry, CConfig *config) { From d4fd63d4dec79daf2a31c89a501014f5e1602d99 Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Thu, 30 Jan 2020 09:06:15 +0000 Subject: [PATCH 047/118] parallel SetUndivided_Laplacian --- SU2_CFD/src/solvers/CEulerSolver.cpp | 72 +++++++++++++++++----------- 1 file changed, 45 insertions(+), 27 deletions(-) diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index c5bf2e23ddba..44410b8c5cf9 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -3841,7 +3841,7 @@ void CEulerSolver::SetMax_Eigenvalue(CGeometry *geometry, CConfig *config) { /*--- Loop interior edges ---*/ - #ifdef HAVE_OMP +#ifdef HAVE_OMP /*--- Chunk size is at least OMP_MIN_SIZE and a multiple of the color group size. ---*/ auto chunkSize = roundUpDiv(OMP_MIN_SIZE, ColorGroupSize)*ColorGroupSize; @@ -3933,7 +3933,6 @@ void CEulerSolver::SetMax_Eigenvalue(CGeometry *geometry, CConfig *config) { } } - SU2_OMP_BARRIER SU2_OMP_MASTER { /*--- Correct the eigenvalue values across any periodic boundaries. ---*/ @@ -3954,33 +3953,49 @@ void CEulerSolver::SetMax_Eigenvalue(CGeometry *geometry, CConfig *config) { void CEulerSolver::SetUndivided_Laplacian(CGeometry *geometry, CConfig *config) { - unsigned long iPoint, jPoint, iEdge; - su2double Pressure_i = 0, Pressure_j = 0, *Diff; - unsigned short iVar; - bool boundary_i, boundary_j; - - Diff = new su2double[nVar]; + /*--- Start OpenMP parallel section. ---*/ + SU2_OMP_PARALLEL + { + /// TODO: Add worksharing to SetUnd_LaplZero and co. + SU2_OMP_MASTER nodes->SetUnd_LaplZero(); - for (iEdge = 0; iEdge < geometry->GetnEdge(); iEdge++) { + /*--- Loop interior edges ---*/ - iPoint = geometry->edge[iEdge]->GetNode(0); - jPoint = geometry->edge[iEdge]->GetNode(1); +#ifdef HAVE_OMP + /*--- Chunk size is at least OMP_MIN_SIZE and a multiple of the color group size. ---*/ + auto chunkSize = roundUpDiv(OMP_MIN_SIZE, ColorGroupSize)*ColorGroupSize; + + /*--- Loop over edge colors. ---*/ + for (auto color : EdgeColoring) + { + SU2_OMP_FOR_STAT(chunkSize) + for(auto k = 0ul; k < color.size; ++k) { + + auto iEdge = color.indices[k]; +#else + /*--- Natural coloring. ---*/ + { + for (auto iEdge = 0ul; iEdge < geometry->GetnEdge(); iEdge++) { +#endif + + auto iPoint = geometry->edge[iEdge]->GetNode(0); + auto jPoint = geometry->edge[iEdge]->GetNode(1); /*--- Solution differences ---*/ - for (iVar = 0; iVar < nVar; iVar++) + su2double Diff[MAXNVAR] = {0.0}; + + for (unsigned short iVar = 0; iVar < nVar; iVar++) Diff[iVar] = nodes->GetSolution(iPoint,iVar) - nodes->GetSolution(jPoint,iVar); /*--- Correction for compressible flows which use the enthalpy ---*/ - 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); + Diff[nVar-1] += nodes->GetPressure(iPoint) - nodes->GetPressure(jPoint); - boundary_i = geometry->node[iPoint]->GetPhysicalBoundary(); - boundary_j = geometry->node[jPoint]->GetPhysicalBoundary(); + bool boundary_i = geometry->node[iPoint]->GetPhysicalBoundary(); + bool boundary_j = geometry->node[jPoint]->GetPhysicalBoundary(); /*--- Both points inside the domain, or both in the boundary ---*/ @@ -4000,21 +4015,24 @@ void CEulerSolver::SetUndivided_Laplacian(CGeometry *geometry, CConfig *config) if (geometry->node[jPoint]->GetDomain()) nodes->AddUnd_Lapl(jPoint, Diff); } + } // end color loop - /*--- Correct the Laplacian values across any periodic boundaries. ---*/ - - for (unsigned short iPeriodic = 1; iPeriodic <= config->GetnMarker_Periodic()/2; iPeriodic++) { - InitiatePeriodicComms(geometry, config, iPeriodic, PERIODIC_LAPLACIAN); - CompletePeriodicComms(geometry, config, iPeriodic, PERIODIC_LAPLACIAN); - } + SU2_OMP_MASTER + { + /*--- Correct the Laplacian values across any periodic boundaries. ---*/ - /*--- MPI parallelization ---*/ + for (unsigned short iPeriodic = 1; iPeriodic <= config->GetnMarker_Periodic()/2; iPeriodic++) { + InitiatePeriodicComms(geometry, config, iPeriodic, PERIODIC_LAPLACIAN); + CompletePeriodicComms(geometry, config, iPeriodic, PERIODIC_LAPLACIAN); + } - InitiateComms(geometry, config, UNDIVIDED_LAPLACIAN); - CompleteComms(geometry, config, UNDIVIDED_LAPLACIAN); + /*--- MPI parallelization ---*/ - delete [] Diff; + InitiateComms(geometry, config, UNDIVIDED_LAPLACIAN); + CompleteComms(geometry, config, UNDIVIDED_LAPLACIAN); + } + } // end SU2_OMP_PARALLEL } void CEulerSolver::SetCentered_Dissipation_Sensor(CGeometry *geometry, CConfig *config) { From d18c17f16cfc540b94ce392fc20afc1ce2f72bfb Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Thu, 30 Jan 2020 09:12:43 +0000 Subject: [PATCH 048/118] parallel SetCentered_Dissipation_Sensor --- SU2_CFD/src/solvers/CEulerSolver.cpp | 65 ++++++++++++++++++---------- 1 file changed, 43 insertions(+), 22 deletions(-) diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 44410b8c5cf9..c20d6e91cb3f 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -3631,7 +3631,7 @@ void CEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_contain if (body_force) { /*--- Loop over all points ---*/ - SU2_OMP_FOR_DYN(omp_chunk_size) + SU2_OMP_FOR_STAT(omp_chunk_size) for (iPoint = 0; iPoint < nPointDomain; iPoint++) { /*--- Load the conservative variables ---*/ @@ -3979,7 +3979,6 @@ void CEulerSolver::SetUndivided_Laplacian(CGeometry *geometry, CConfig *config) { for (auto iEdge = 0ul; iEdge < geometry->GetnEdge(); iEdge++) { #endif - auto iPoint = geometry->edge[iEdge]->GetNode(0); auto jPoint = geometry->edge[iEdge]->GetNode(1); @@ -4037,29 +4036,42 @@ void CEulerSolver::SetUndivided_Laplacian(CGeometry *geometry, CConfig *config) void CEulerSolver::SetCentered_Dissipation_Sensor(CGeometry *geometry, CConfig *config) { - unsigned long iEdge, iPoint, jPoint; - su2double Pressure_i = 0.0, Pressure_j = 0.0; - bool boundary_i, boundary_j; + /*--- Start OpenMP parallel section. ---*/ + SU2_OMP_PARALLEL + { /*--- Reset variables to store the undivided pressure ---*/ - for (iPoint = 0; iPoint < nPointDomain; iPoint++) { + SU2_OMP_FOR_STAT(omp_chunk_size) + for (unsigned long iPoint = 0; iPoint < nPointDomain; iPoint++) { iPoint_UndLapl[iPoint] = 0.0; jPoint_UndLapl[iPoint] = 0.0; } - /*--- Evaluate the pressure sensor ---*/ +#ifdef HAVE_OMP + /*--- Chunk size is at least OMP_MIN_SIZE and a multiple of the color group size. ---*/ + auto chunkSize = roundUpDiv(OMP_MIN_SIZE, ColorGroupSize)*ColorGroupSize; - for (iEdge = 0; iEdge < geometry->GetnEdge(); iEdge++) { + /*--- Loop over edge colors. ---*/ + for (auto color : EdgeColoring) + { + SU2_OMP_FOR_STAT(chunkSize) + for(auto k = 0ul; k < color.size; ++k) { - iPoint = geometry->edge[iEdge]->GetNode(0); - jPoint = geometry->edge[iEdge]->GetNode(1); + auto iEdge = color.indices[k]; +#else + /*--- Natural coloring. ---*/ + { + for (auto iEdge = 0ul; iEdge < geometry->GetnEdge(); iEdge++) { +#endif + auto iPoint = geometry->edge[iEdge]->GetNode(0); + auto jPoint = geometry->edge[iEdge]->GetNode(1); - Pressure_i = nodes->GetPressure(iPoint); - Pressure_j = nodes->GetPressure(jPoint); + su2double Pressure_i = nodes->GetPressure(iPoint); + su2double Pressure_j = nodes->GetPressure(jPoint); - boundary_i = geometry->node[iPoint]->GetPhysicalBoundary(); - boundary_j = geometry->node[jPoint]->GetPhysicalBoundary(); + bool boundary_i = geometry->node[iPoint]->GetPhysicalBoundary(); + bool boundary_j = geometry->node[jPoint]->GetPhysicalBoundary(); /*--- Both points inside the domain, or both on the boundary ---*/ @@ -4077,26 +4089,35 @@ void CEulerSolver::SetCentered_Dissipation_Sensor(CGeometry *geometry, CConfig * if (boundary_i && !boundary_j) if (geometry->node[jPoint]->GetDomain()) { iPoint_UndLapl[jPoint] += (Pressure_i - Pressure_j); jPoint_UndLapl[jPoint] += (Pressure_i + Pressure_j); } - } + } // end color loop /*--- Correct the sensor values across any periodic boundaries. ---*/ - for (unsigned short iPeriodic = 1; iPeriodic <= config->GetnMarker_Periodic()/2; iPeriodic++) { - InitiatePeriodicComms(geometry, config, iPeriodic, PERIODIC_SENSOR); - CompletePeriodicComms(geometry, config, iPeriodic, PERIODIC_SENSOR); + SU2_OMP_MASTER + { + for (unsigned short iPeriodic = 1; iPeriodic <= config->GetnMarker_Periodic()/2; iPeriodic++) { + InitiatePeriodicComms(geometry, config, iPeriodic, PERIODIC_SENSOR); + CompletePeriodicComms(geometry, config, iPeriodic, PERIODIC_SENSOR); + } } + SU2_OMP_BARRIER /*--- Set pressure switch for each point ---*/ - for (iPoint = 0; iPoint < nPointDomain; iPoint++) - nodes->SetSensor(iPoint,fabs(iPoint_UndLapl[iPoint]) / jPoint_UndLapl[iPoint]); + SU2_OMP_FOR_STAT(omp_chunk_size) + for (unsigned long iPoint = 0; iPoint < nPointDomain; iPoint++) + nodes->SetSensor(iPoint, fabs(iPoint_UndLapl[iPoint]) / jPoint_UndLapl[iPoint]); /*--- MPI parallelization ---*/ - InitiateComms(geometry, config, SENSOR); - CompleteComms(geometry, config, SENSOR); + SU2_OMP_MASTER + { + InitiateComms(geometry, config, SENSOR); + CompleteComms(geometry, config, SENSOR); + } + } // end SU2_OMP_PARALLEL } void CEulerSolver::SetUpwind_Ducros_Sensor(CGeometry *geometry, CConfig *config){ From f9e9ba3122a99f93ceae0992c9fce9936a5bd414 Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Thu, 30 Jan 2020 09:47:41 +0000 Subject: [PATCH 049/118] parallel SetUpwind_Ducros_Sensor --- SU2_CFD/src/solvers/CEulerSolver.cpp | 77 +++++++++++----------------- 1 file changed, 31 insertions(+), 46 deletions(-) diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index c20d6e91cb3f..4793061d8443 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -4122,76 +4122,61 @@ void CEulerSolver::SetCentered_Dissipation_Sensor(CGeometry *geometry, CConfig * void CEulerSolver::SetUpwind_Ducros_Sensor(CGeometry *geometry, CConfig *config){ - unsigned long iPoint, jPoint; - unsigned short iNeigh, iDim; - - su2double *Vorticity; - - su2double uixi = 0.0, Ducros_i = 0.0, Ducros_j = 0.0, Omega = 0.0; - - for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++){ - - /*---- Dilatation for iPoint ---*/ - - uixi=0.0; - for(iDim = 0; iDim < nDim; iDim++){ - uixi += nodes->GetGradient_Primitive(iPoint,iDim+1, iDim); - } - - /*--- Compute norm of vorticity ---*/ - - Vorticity = nodes->GetVorticity(iPoint); - Omega = 0.0; - for (iDim = 0; iDim < nDim; iDim++){ - Omega += Vorticity[iDim]*Vorticity[iDim]; - } - Omega = sqrt(Omega); + /*--- Start OpenMP parallel section. ---*/ - /*---- Ducros sensor for iPoint ---*/ + SU2_OMP_PARALLEL + { - if (config->GetKind_RoeLowDiss() == FD_DUCROS){ - Ducros_i = -uixi / (fabs(uixi) + Omega + 1e-20); - } else if (config->GetKind_RoeLowDiss() == NTS_DUCROS){ - Ducros_i = pow(uixi,2.0) /(pow(uixi,2.0)+ pow(Omega,2.0) + 1e-20); - } + SU2_OMP_FOR_STAT(omp_chunk_size) + for (unsigned long iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { - nodes->SetSensor(iPoint,Ducros_i); + /*---- Ducros sensor for iPoint and its neighbor points to avoid lower dissipation near shocks. ---*/ - /*---- Ducros sensor for neighbor points of iPoint to avoid lower the dissipation in regions near the shock ---*/ + su2double Ducros_i = 0.0; + auto nNeigh = geometry->node[iPoint]->GetnNeighbor(); - for (iNeigh = 0; iNeigh > geometry->node[iPoint]->GetnNeighbor(); iNeigh++){ + for (unsigned short iNeigh = 0; iNeigh <= nNeigh; iNeigh++) { - jPoint = geometry->node[iPoint]->GetPoint(iNeigh); + auto jPoint = iPoint; + if (iNeigh < nNeigh) jPoint = geometry->node[iPoint]->GetPoint(iNeigh); /*---- Dilatation for jPoint ---*/ - uixi=0.0; - for(iDim = 0; iDim < nDim; iDim++){ + su2double uixi=0.0; + for(unsigned short iDim = 0; iDim < nDim; iDim++){ uixi += nodes->GetGradient_Primitive(jPoint,iDim+1, iDim); } /*--- Compute norm of vorticity ---*/ - Vorticity = nodes->GetVorticity(jPoint); - Omega = 0.0; - for (iDim = 0; iDim < nDim; iDim++){ - Omega += Vorticity[iDim]*Vorticity[iDim]; + const su2double* Vorticity = nodes->GetVorticity(jPoint); + su2double Omega = 0.0; + for (unsigned short iDim = 0; iDim < nDim; iDim++) { + Omega += pow(Vorticity[iDim], 2); } Omega = sqrt(Omega); - if (config->GetKind_RoeLowDiss() == FD_DUCROS){ + su2double Ducros_j = 0.0; + + if (config->GetKind_RoeLowDiss() == FD_DUCROS) { Ducros_j = -uixi / (fabs(uixi) + Omega + 1e-20); - } else if (config->GetKind_RoeLowDiss() == NTS_DUCROS){ + } + else if (config->GetKind_RoeLowDiss() == NTS_DUCROS) { Ducros_j = pow(uixi,2.0) /(pow(uixi,2.0)+ pow(Omega,2.0) + 1e-20); } - nodes->SetSensor(iPoint, max(nodes->GetSensor(iPoint), Ducros_j)); - + Ducros_i = max(Ducros_i, Ducros_j); } + + nodes->SetSensor(iPoint, Ducros_i); } - InitiateComms(geometry, config, SENSOR); - CompleteComms(geometry, config, SENSOR); + SU2_OMP_MASTER + { + InitiateComms(geometry, config, SENSOR); + CompleteComms(geometry, config, SENSOR); + } + } // end SU2_OMP_PARALLEL } void CEulerSolver::Pressure_Forces(CGeometry *geometry, CConfig *config) { From 08f9972436cdded9e24eae1e46ff9f8e7e144faa Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Thu, 30 Jan 2020 10:36:30 +0000 Subject: [PATCH 050/118] cleanup some mpi code --- SU2_CFD/src/solvers/CEulerSolver.cpp | 200 +++++++++++---------------- 1 file changed, 81 insertions(+), 119 deletions(-) diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 4793061d8443..b71fe2e434a5 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -4190,28 +4190,24 @@ void CEulerSolver::Pressure_Forces(CGeometry *geometry, CConfig *config) { su2double MomentX_Force[3] = {0.0,0.0,0.0}, MomentY_Force[3] = {0.0,0.0,0.0}, MomentZ_Force[3] = {0.0,0.0,0.0}; su2double AxiFactor; -#ifdef HAVE_MPI - su2double MyAllBound_CD_Inv, MyAllBound_CL_Inv, MyAllBound_CSF_Inv, MyAllBound_CMx_Inv, MyAllBound_CMy_Inv, MyAllBound_CMz_Inv, MyAllBound_CoPx_Inv, MyAllBound_CoPy_Inv, MyAllBound_CoPz_Inv, MyAllBound_CFx_Inv, MyAllBound_CFy_Inv, MyAllBound_CFz_Inv, MyAllBound_CT_Inv, MyAllBound_CQ_Inv, MyAllBound_CNearFieldOF_Inv, *MySurface_CL_Inv = NULL, *MySurface_CD_Inv = NULL, *MySurface_CSF_Inv = NULL, *MySurface_CEff_Inv = NULL, *MySurface_CFx_Inv = NULL, *MySurface_CFy_Inv = NULL, *MySurface_CFz_Inv = NULL, *MySurface_CMx_Inv = NULL, *MySurface_CMy_Inv = NULL, *MySurface_CMz_Inv = NULL; -#endif - - su2double Alpha = config->GetAoA()*PI_NUMBER/180.0; - su2double Beta = config->GetAoS()*PI_NUMBER/180.0; - su2double RefArea = config->GetRefArea(); + su2double Alpha = config->GetAoA()*PI_NUMBER/180.0; + su2double Beta = config->GetAoS()*PI_NUMBER/180.0; + su2double RefArea = config->GetRefArea(); su2double RefLength = config->GetRefLength(); - su2double Gas_Constant = config->GetGas_ConstantND(); - su2double *Origin = NULL; + su2double Gas_Constant = config->GetGas_ConstantND(); + const su2double *Origin = nullptr; if (config->GetnMarker_Monitoring() != 0){ Origin = config->GetRefOriginMoment(0); } - bool axisymmetric = config->GetAxisymmetric(); + bool axisymmetric = config->GetAxisymmetric(); /*--- Evaluate reference values for non-dimensionalization. For dynamic meshes, use the motion Mach number as a reference value for computing the force coefficients. Otherwise, use the freestream values, which is the standard convention. ---*/ - RefTemp = Temperature_Inf; - RefDensity = Density_Inf; + RefTemp = Temperature_Inf; + RefDensity = Density_Inf; RefPressure = Pressure_Inf; if (dynamic_grid) { Mach2Vel = sqrt(Gamma*Gas_Constant*RefTemp); @@ -4235,7 +4231,7 @@ void CEulerSolver::Pressure_Forces(CGeometry *geometry, CConfig *config) { Total_CT = 0.0; Total_CQ = 0.0; Total_CMerit = 0.0; Total_CNearFieldOF = 0.0; Total_Heat = 0.0; Total_MaxHeat = 0.0; - AllBound_CD_Inv = 0.0; AllBound_CL_Inv = 0.0; AllBound_CSF_Inv = 0.0; + AllBound_CD_Inv = 0.0; AllBound_CL_Inv = 0.0; AllBound_CSF_Inv = 0.0; AllBound_CMx_Inv = 0.0; AllBound_CMy_Inv = 0.0; AllBound_CMz_Inv = 0.0; AllBound_CoPx_Inv = 0.0; AllBound_CoPy_Inv = 0.0; AllBound_CoPz_Inv = 0.0; AllBound_CFx_Inv = 0.0; AllBound_CFy_Inv = 0.0; AllBound_CFz_Inv = 0.0; @@ -4243,16 +4239,16 @@ void CEulerSolver::Pressure_Forces(CGeometry *geometry, CConfig *config) { AllBound_CNearFieldOF_Inv = 0.0; AllBound_CEff_Inv = 0.0; for (iMarker_Monitoring = 0; iMarker_Monitoring < config->GetnMarker_Monitoring(); iMarker_Monitoring++) { - Surface_CL_Inv[iMarker_Monitoring] = 0.0; Surface_CD_Inv[iMarker_Monitoring] = 0.0; - Surface_CSF_Inv[iMarker_Monitoring] = 0.0; Surface_CEff_Inv[iMarker_Monitoring] = 0.0; - Surface_CFx_Inv[iMarker_Monitoring] = 0.0; Surface_CFy_Inv[iMarker_Monitoring] = 0.0; - Surface_CFz_Inv[iMarker_Monitoring] = 0.0; Surface_CMx_Inv[iMarker_Monitoring] = 0.0; - Surface_CMy_Inv[iMarker_Monitoring] = 0.0; Surface_CMz_Inv[iMarker_Monitoring] = 0.0; - Surface_CL[iMarker_Monitoring] = 0.0; Surface_CD[iMarker_Monitoring] = 0.0; - Surface_CSF[iMarker_Monitoring] = 0.0; Surface_CEff[iMarker_Monitoring] = 0.0; - Surface_CFx[iMarker_Monitoring] = 0.0; Surface_CFy[iMarker_Monitoring] = 0.0; - Surface_CFz[iMarker_Monitoring] = 0.0; Surface_CMx[iMarker_Monitoring] = 0.0; - Surface_CMy[iMarker_Monitoring] = 0.0; Surface_CMz[iMarker_Monitoring] = 0.0; + Surface_CL_Inv[iMarker_Monitoring] = 0.0; Surface_CD_Inv[iMarker_Monitoring] = 0.0; + Surface_CSF_Inv[iMarker_Monitoring] = 0.0; Surface_CEff_Inv[iMarker_Monitoring] = 0.0; + Surface_CFx_Inv[iMarker_Monitoring] = 0.0; Surface_CFy_Inv[iMarker_Monitoring] = 0.0; + Surface_CFz_Inv[iMarker_Monitoring] = 0.0; Surface_CMx_Inv[iMarker_Monitoring] = 0.0; + Surface_CMy_Inv[iMarker_Monitoring] = 0.0; Surface_CMz_Inv[iMarker_Monitoring] = 0.0; + Surface_CL[iMarker_Monitoring] = 0.0; Surface_CD[iMarker_Monitoring] = 0.0; + Surface_CSF[iMarker_Monitoring] = 0.0; Surface_CEff[iMarker_Monitoring] = 0.0; + Surface_CFx[iMarker_Monitoring] = 0.0; Surface_CFy[iMarker_Monitoring] = 0.0; + Surface_CFz[iMarker_Monitoring] = 0.0; Surface_CMx[iMarker_Monitoring] = 0.0; + Surface_CMy[iMarker_Monitoring] = 0.0; Surface_CMz[iMarker_Monitoring] = 0.0; } /*--- Loop over the Euler and Navier-Stokes markers ---*/ @@ -4282,18 +4278,18 @@ void CEulerSolver::Pressure_Forces(CGeometry *geometry, CConfig *config) { /*--- Forces initialization at each Marker ---*/ - CD_Inv[iMarker] = 0.0; CL_Inv[iMarker] = 0.0; CSF_Inv[iMarker] = 0.0; + CD_Inv[iMarker] = 0.0; CL_Inv[iMarker] = 0.0; CSF_Inv[iMarker] = 0.0; CMx_Inv[iMarker] = 0.0; CMy_Inv[iMarker] = 0.0; CMz_Inv[iMarker] = 0.0; - CoPx_Inv[iMarker] = 0.0; CoPy_Inv[iMarker] = 0.0; CoPz_Inv[iMarker] = 0.0; + CoPx_Inv[iMarker] = 0.0; CoPy_Inv[iMarker] = 0.0; CoPz_Inv[iMarker] = 0.0; CFx_Inv[iMarker] = 0.0; CFy_Inv[iMarker] = 0.0; CFz_Inv[iMarker] = 0.0; CT_Inv[iMarker] = 0.0; CQ_Inv[iMarker] = 0.0; CMerit_Inv[iMarker] = 0.0; CNearFieldOF_Inv[iMarker] = 0.0; CEff_Inv[iMarker] = 0.0; for (iDim = 0; iDim < nDim; iDim++) ForceInviscid[iDim] = 0.0; MomentInviscid[0] = 0.0; MomentInviscid[1] = 0.0; MomentInviscid[2] = 0.0; - MomentX_Force[0] = 0.0; MomentX_Force[1] = 0.0; MomentX_Force[2] = 0.0; - MomentY_Force[0] = 0.0; MomentY_Force[1] = 0.0; MomentY_Force[2] = 0.0; - MomentZ_Force[0] = 0.0; MomentZ_Force[1] = 0.0; MomentZ_Force[2] = 0.0; + MomentX_Force[0] = 0.0; MomentX_Force[1] = 0.0; MomentX_Force[2] = 0.0; + MomentY_Force[0] = 0.0; MomentY_Force[1] = 0.0; MomentY_Force[2] = 0.0; + MomentZ_Force[0] = 0.0; MomentZ_Force[1] = 0.0; MomentZ_Force[2] = 0.0; NFPressOF = 0.0; @@ -4438,7 +4434,6 @@ void CEulerSolver::Pressure_Forces(CGeometry *geometry, CConfig *config) { } - } } @@ -4446,99 +4441,66 @@ void CEulerSolver::Pressure_Forces(CGeometry *geometry, CConfig *config) { /*--- Add AllBound information using all the nodes ---*/ - MyAllBound_CD_Inv = AllBound_CD_Inv; AllBound_CD_Inv = 0.0; - MyAllBound_CL_Inv = AllBound_CL_Inv; AllBound_CL_Inv = 0.0; - MyAllBound_CSF_Inv = AllBound_CSF_Inv; AllBound_CSF_Inv = 0.0; - AllBound_CEff_Inv = 0.0; - MyAllBound_CMx_Inv = AllBound_CMx_Inv; AllBound_CMx_Inv = 0.0; - MyAllBound_CMy_Inv = AllBound_CMy_Inv; AllBound_CMy_Inv = 0.0; - MyAllBound_CMz_Inv = AllBound_CMz_Inv; AllBound_CMz_Inv = 0.0; - MyAllBound_CoPx_Inv = AllBound_CoPx_Inv; AllBound_CoPx_Inv = 0.0; - MyAllBound_CoPy_Inv = AllBound_CoPy_Inv; AllBound_CoPy_Inv = 0.0; - MyAllBound_CoPz_Inv = AllBound_CoPz_Inv; AllBound_CoPz_Inv = 0.0; - MyAllBound_CFx_Inv = AllBound_CFx_Inv; AllBound_CFx_Inv = 0.0; - MyAllBound_CFy_Inv = AllBound_CFy_Inv; AllBound_CFy_Inv = 0.0; - MyAllBound_CFz_Inv = AllBound_CFz_Inv; AllBound_CFz_Inv = 0.0; - MyAllBound_CT_Inv = AllBound_CT_Inv; AllBound_CT_Inv = 0.0; - MyAllBound_CQ_Inv = AllBound_CQ_Inv; AllBound_CQ_Inv = 0.0; - AllBound_CMerit_Inv = 0.0; - MyAllBound_CNearFieldOF_Inv = AllBound_CNearFieldOF_Inv; AllBound_CNearFieldOF_Inv = 0.0; - if (config->GetComm_Level() == COMM_FULL) { - SU2_MPI::Allreduce(&MyAllBound_CD_Inv, &AllBound_CD_Inv, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&MyAllBound_CL_Inv, &AllBound_CL_Inv, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&MyAllBound_CSF_Inv, &AllBound_CSF_Inv, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); + + auto Allreduce = [](su2double x) { + su2double tmp = x; x = 0.0; + SU2_MPI::Allreduce(&tmp, &x, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); + return x; + }; + AllBound_CD_Inv = Allreduce(AllBound_CD_Inv); + AllBound_CL_Inv = Allreduce(AllBound_CL_Inv); + AllBound_CSF_Inv = Allreduce(AllBound_CSF_Inv); AllBound_CEff_Inv = AllBound_CL_Inv / (AllBound_CD_Inv + EPS); - SU2_MPI::Allreduce(&MyAllBound_CMx_Inv, &AllBound_CMx_Inv, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&MyAllBound_CMy_Inv, &AllBound_CMy_Inv, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&MyAllBound_CMz_Inv, &AllBound_CMz_Inv, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&MyAllBound_CoPx_Inv, &AllBound_CoPx_Inv, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&MyAllBound_CoPy_Inv, &AllBound_CoPy_Inv, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&MyAllBound_CoPz_Inv, &AllBound_CoPz_Inv, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&MyAllBound_CFx_Inv, &AllBound_CFx_Inv, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&MyAllBound_CFy_Inv, &AllBound_CFy_Inv, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&MyAllBound_CFz_Inv, &AllBound_CFz_Inv, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&MyAllBound_CT_Inv, &AllBound_CT_Inv, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&MyAllBound_CQ_Inv, &AllBound_CQ_Inv, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); + AllBound_CMx_Inv = Allreduce(AllBound_CMx_Inv); + AllBound_CMy_Inv = Allreduce(AllBound_CMy_Inv); + AllBound_CMz_Inv = Allreduce(AllBound_CMz_Inv); + AllBound_CoPx_Inv = Allreduce(AllBound_CoPx_Inv); + AllBound_CoPy_Inv = Allreduce(AllBound_CoPy_Inv); + AllBound_CoPz_Inv = Allreduce(AllBound_CoPz_Inv); + AllBound_CFx_Inv = Allreduce(AllBound_CFx_Inv); + AllBound_CFy_Inv = Allreduce(AllBound_CFy_Inv); + AllBound_CFz_Inv = Allreduce(AllBound_CFz_Inv); + AllBound_CT_Inv = Allreduce(AllBound_CT_Inv); + AllBound_CQ_Inv = Allreduce(AllBound_CQ_Inv); AllBound_CMerit_Inv = AllBound_CT_Inv / (AllBound_CQ_Inv + EPS); - SU2_MPI::Allreduce(&MyAllBound_CNearFieldOF_Inv, &AllBound_CNearFieldOF_Inv, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); + AllBound_CNearFieldOF_Inv = Allreduce(AllBound_CNearFieldOF_Inv); + } /*--- Add the forces on the surfaces using all the nodes ---*/ - MySurface_CL_Inv = new su2double[config->GetnMarker_Monitoring()]; - MySurface_CD_Inv = new su2double[config->GetnMarker_Monitoring()]; - MySurface_CSF_Inv = new su2double[config->GetnMarker_Monitoring()]; - MySurface_CEff_Inv = new su2double[config->GetnMarker_Monitoring()]; - MySurface_CFx_Inv = new su2double[config->GetnMarker_Monitoring()]; - MySurface_CFy_Inv = new su2double[config->GetnMarker_Monitoring()]; - MySurface_CFz_Inv = new su2double[config->GetnMarker_Monitoring()]; - MySurface_CMx_Inv = new su2double[config->GetnMarker_Monitoring()]; - MySurface_CMy_Inv = new su2double[config->GetnMarker_Monitoring()]; - MySurface_CMz_Inv = new su2double[config->GetnMarker_Monitoring()]; + if (config->GetComm_Level() == COMM_FULL) { - for (iMarker_Monitoring = 0; iMarker_Monitoring < config->GetnMarker_Monitoring(); iMarker_Monitoring++) { - MySurface_CL_Inv[iMarker_Monitoring] = Surface_CL_Inv[iMarker_Monitoring]; - MySurface_CD_Inv[iMarker_Monitoring] = Surface_CD_Inv[iMarker_Monitoring]; - MySurface_CSF_Inv[iMarker_Monitoring] = Surface_CSF_Inv[iMarker_Monitoring]; - MySurface_CEff_Inv[iMarker_Monitoring] = Surface_CEff_Inv[iMarker_Monitoring]; - MySurface_CFx_Inv[iMarker_Monitoring] = Surface_CFx_Inv[iMarker_Monitoring]; - MySurface_CFy_Inv[iMarker_Monitoring] = Surface_CFy_Inv[iMarker_Monitoring]; - MySurface_CFz_Inv[iMarker_Monitoring] = Surface_CFz_Inv[iMarker_Monitoring]; - MySurface_CMx_Inv[iMarker_Monitoring] = Surface_CMx_Inv[iMarker_Monitoring]; - MySurface_CMy_Inv[iMarker_Monitoring] = Surface_CMy_Inv[iMarker_Monitoring]; - MySurface_CMz_Inv[iMarker_Monitoring] = Surface_CMz_Inv[iMarker_Monitoring]; - - Surface_CL_Inv[iMarker_Monitoring] = 0.0; - Surface_CD_Inv[iMarker_Monitoring] = 0.0; - Surface_CSF_Inv[iMarker_Monitoring] = 0.0; - Surface_CEff_Inv[iMarker_Monitoring] = 0.0; - Surface_CFx_Inv[iMarker_Monitoring] = 0.0; - Surface_CFy_Inv[iMarker_Monitoring] = 0.0; - Surface_CFz_Inv[iMarker_Monitoring] = 0.0; - Surface_CMx_Inv[iMarker_Monitoring] = 0.0; - Surface_CMy_Inv[iMarker_Monitoring] = 0.0; - Surface_CMz_Inv[iMarker_Monitoring] = 0.0; - } + int nMarkerMon = config->GetnMarker_Monitoring(); - if (config->GetComm_Level() == COMM_FULL) { - SU2_MPI::Allreduce(MySurface_CL_Inv, Surface_CL_Inv, config->GetnMarker_Monitoring(), MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(MySurface_CD_Inv, Surface_CD_Inv, config->GetnMarker_Monitoring(), MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(MySurface_CSF_Inv, Surface_CSF_Inv, config->GetnMarker_Monitoring(), MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - for (iMarker_Monitoring = 0; iMarker_Monitoring < config->GetnMarker_Monitoring(); iMarker_Monitoring++) + /*--- Use the same heap buffer for all reductions. We could avoid the copy back into + * the original variable by swaping pointers, but it is safer this way... ---*/ + + su2double* buffer = new su2double [nMarkerMon]; + + auto Allreduce_inplace = [buffer](int size, su2double* x) { + SU2_MPI::Allreduce(x, buffer, size, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); + for(int i=0; iGetnMarker_Monitoring(), MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(MySurface_CFy_Inv, Surface_CFy_Inv, config->GetnMarker_Monitoring(), MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(MySurface_CFz_Inv, Surface_CFz_Inv, config->GetnMarker_Monitoring(), MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(MySurface_CMx_Inv, Surface_CMx_Inv, config->GetnMarker_Monitoring(), MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(MySurface_CMy_Inv, Surface_CMy_Inv, config->GetnMarker_Monitoring(), MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(MySurface_CMz_Inv, Surface_CMz_Inv, config->GetnMarker_Monitoring(), MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - } - delete [] MySurface_CL_Inv; delete [] MySurface_CD_Inv; delete [] MySurface_CSF_Inv; - delete [] MySurface_CEff_Inv; delete [] MySurface_CFx_Inv; delete [] MySurface_CFy_Inv; - delete [] MySurface_CFz_Inv; delete [] MySurface_CMx_Inv; delete [] MySurface_CMy_Inv; - delete [] MySurface_CMz_Inv; + Allreduce_inplace(nMarkerMon, Surface_CFx_Inv); + Allreduce_inplace(nMarkerMon, Surface_CFy_Inv); + Allreduce_inplace(nMarkerMon, Surface_CFz_Inv); + Allreduce_inplace(nMarkerMon, Surface_CMx_Inv); + Allreduce_inplace(nMarkerMon, Surface_CMy_Inv); + Allreduce_inplace(nMarkerMon, Surface_CMz_Inv); + + delete [] buffer; + + } #endif @@ -4567,14 +4529,14 @@ void CEulerSolver::Pressure_Forces(CGeometry *geometry, CConfig *config) { for (iMarker_Monitoring = 0; iMarker_Monitoring < config->GetnMarker_Monitoring(); iMarker_Monitoring++) { Surface_CL[iMarker_Monitoring] = Surface_CL_Inv[iMarker_Monitoring]; Surface_CD[iMarker_Monitoring] = Surface_CD_Inv[iMarker_Monitoring]; - Surface_CSF[iMarker_Monitoring] = Surface_CSF_Inv[iMarker_Monitoring]; - Surface_CEff[iMarker_Monitoring] = Surface_CL_Inv[iMarker_Monitoring] / (Surface_CD_Inv[iMarker_Monitoring] + EPS); - Surface_CFx[iMarker_Monitoring] = Surface_CFx_Inv[iMarker_Monitoring]; - Surface_CFy[iMarker_Monitoring] = Surface_CFy_Inv[iMarker_Monitoring]; - Surface_CFz[iMarker_Monitoring] = Surface_CFz_Inv[iMarker_Monitoring]; - Surface_CMx[iMarker_Monitoring] = Surface_CMx_Inv[iMarker_Monitoring]; - Surface_CMy[iMarker_Monitoring] = Surface_CMy_Inv[iMarker_Monitoring]; - Surface_CMz[iMarker_Monitoring] = Surface_CMz_Inv[iMarker_Monitoring]; + Surface_CSF[iMarker_Monitoring] = Surface_CSF_Inv[iMarker_Monitoring]; + Surface_CEff[iMarker_Monitoring] = Surface_CL_Inv[iMarker_Monitoring] / (Surface_CD_Inv[iMarker_Monitoring] + EPS); + Surface_CFx[iMarker_Monitoring] = Surface_CFx_Inv[iMarker_Monitoring]; + Surface_CFy[iMarker_Monitoring] = Surface_CFy_Inv[iMarker_Monitoring]; + Surface_CFz[iMarker_Monitoring] = Surface_CFz_Inv[iMarker_Monitoring]; + Surface_CMx[iMarker_Monitoring] = Surface_CMx_Inv[iMarker_Monitoring]; + Surface_CMy[iMarker_Monitoring] = Surface_CMy_Inv[iMarker_Monitoring]; + Surface_CMz[iMarker_Monitoring] = Surface_CMz_Inv[iMarker_Monitoring]; } } From e8eec6d7f9452b11a8f6718d20b4624ecb9dcc5f Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Thu, 30 Jan 2020 11:12:15 +0000 Subject: [PATCH 051/118] clean more postprocessing code --- SU2_CFD/src/solvers/CEulerSolver.cpp | 600 ++++++++++----------------- 1 file changed, 227 insertions(+), 373 deletions(-) diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index b71fe2e434a5..940e90466dd7 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -4183,9 +4183,9 @@ void CEulerSolver::Pressure_Forces(CGeometry *geometry, CConfig *config) { unsigned long iVertex, iPoint; unsigned short iDim, iMarker, Boundary, Monitoring, iMarker_Monitoring; - su2double Pressure = 0.0, *Normal = NULL, MomentDist[3] = {0.0,0.0,0.0}, *Coord, - factor, NFPressOF, RefVel2, RefTemp, RefDensity, RefPressure, Mach2Vel, Mach_Motion, - Force[3] = {0.0,0.0,0.0}; + su2double Pressure = 0.0, MomentDist[3] = {0.0,0.0,0.0}, factor, NFPressOF, RefVel2, + RefTemp, RefDensity, RefPressure, Mach2Vel, Mach_Motion, Force[3] = {0.0,0.0,0.0}; + const su2double *Normal = nullptr, *Coord = nullptr; string Marker_Tag, Monitoring_Tag; su2double MomentX_Force[3] = {0.0,0.0,0.0}, MomentY_Force[3] = {0.0,0.0,0.0}, MomentZ_Force[3] = {0.0,0.0,0.0}; su2double AxiFactor; @@ -4452,15 +4452,19 @@ void CEulerSolver::Pressure_Forces(CGeometry *geometry, CConfig *config) { AllBound_CL_Inv = Allreduce(AllBound_CL_Inv); AllBound_CSF_Inv = Allreduce(AllBound_CSF_Inv); AllBound_CEff_Inv = AllBound_CL_Inv / (AllBound_CD_Inv + EPS); + AllBound_CMx_Inv = Allreduce(AllBound_CMx_Inv); AllBound_CMy_Inv = Allreduce(AllBound_CMy_Inv); AllBound_CMz_Inv = Allreduce(AllBound_CMz_Inv); + AllBound_CoPx_Inv = Allreduce(AllBound_CoPx_Inv); AllBound_CoPy_Inv = Allreduce(AllBound_CoPy_Inv); AllBound_CoPz_Inv = Allreduce(AllBound_CoPz_Inv); + AllBound_CFx_Inv = Allreduce(AllBound_CFx_Inv); AllBound_CFy_Inv = Allreduce(AllBound_CFy_Inv); AllBound_CFz_Inv = Allreduce(AllBound_CFz_Inv); + AllBound_CT_Inv = Allreduce(AllBound_CT_Inv); AllBound_CQ_Inv = Allreduce(AllBound_CQ_Inv); AllBound_CMerit_Inv = AllBound_CT_Inv / (AllBound_CQ_Inv + EPS); @@ -4474,7 +4478,7 @@ void CEulerSolver::Pressure_Forces(CGeometry *geometry, CConfig *config) { int nMarkerMon = config->GetnMarker_Monitoring(); - /*--- Use the same heap buffer for all reductions. We could avoid the copy back into + /*--- Use the same buffer for all reductions. We could avoid the copy back into * the original variable by swaping pointers, but it is safer this way... ---*/ su2double* buffer = new su2double [nMarkerMon]; @@ -4494,6 +4498,7 @@ void CEulerSolver::Pressure_Forces(CGeometry *geometry, CConfig *config) { Allreduce_inplace(nMarkerMon, Surface_CFx_Inv); Allreduce_inplace(nMarkerMon, Surface_CFy_Inv); Allreduce_inplace(nMarkerMon, Surface_CFz_Inv); + Allreduce_inplace(nMarkerMon, Surface_CMx_Inv); Allreduce_inplace(nMarkerMon, Surface_CMy_Inv); Allreduce_inplace(nMarkerMon, Surface_CMz_Inv); @@ -4545,31 +4550,20 @@ void CEulerSolver::Momentum_Forces(CGeometry *geometry, CConfig *config) { unsigned long iVertex, iPoint; unsigned short iDim, iMarker, Boundary, Monitoring, iMarker_Monitoring; - su2double *Normal = NULL, MomentDist[3] = {0.0,0.0,0.0}, *Coord, Area, + su2double MomentDist[3] = {0.0,0.0,0.0}, Area, factor, RefVel2, RefTemp, RefDensity, Mach2Vel, Mach_Motion, - Force[3] = {0.0,0.0,0.0}, Velocity[3], MassFlow, Density; + Force[3] = {0.0,0.0,0.0}, Velocity[3] = {0.0,0.0,0.0}, MassFlow, Density; + const su2double *Normal = nullptr, *Coord = nullptr; string Marker_Tag, Monitoring_Tag; su2double MomentX_Force[3] = {0.0,0.0,0.0}, MomentY_Force[3] = {0.0,0.0,0.0}, MomentZ_Force[3] = {0.0,0.0,0.0}; su2double AxiFactor; -#ifdef HAVE_MPI - su2double MyAllBound_CD_Mnt, MyAllBound_CL_Mnt, MyAllBound_CSF_Mnt, - MyAllBound_CMx_Mnt, MyAllBound_CMy_Mnt, MyAllBound_CMz_Mnt, - MyAllBound_CoPx_Mnt, MyAllBound_CoPy_Mnt, MyAllBound_CoPz_Mnt, - MyAllBound_CFx_Mnt, MyAllBound_CFy_Mnt, MyAllBound_CFz_Mnt, MyAllBound_CT_Mnt, - MyAllBound_CQ_Mnt, - *MySurface_CL_Mnt = NULL, *MySurface_CD_Mnt = NULL, *MySurface_CSF_Mnt = NULL, - *MySurface_CEff_Mnt = NULL, *MySurface_CFx_Mnt = NULL, *MySurface_CFy_Mnt = NULL, - *MySurface_CFz_Mnt = NULL, - *MySurface_CMx_Mnt = NULL, *MySurface_CMy_Mnt = NULL, *MySurface_CMz_Mnt = NULL; -#endif - - su2double Alpha = config->GetAoA()*PI_NUMBER/180.0; - su2double Beta = config->GetAoS()*PI_NUMBER/180.0; - su2double RefArea = config->GetRefArea(); - su2double RefLength = config->GetRefLength(); - su2double Gas_Constant = config->GetGas_ConstantND(); - su2double *Origin = NULL; + su2double Alpha = config->GetAoA()*PI_NUMBER/180.0; + su2double Beta = config->GetAoS()*PI_NUMBER/180.0; + su2double RefArea = config->GetRefArea(); + su2double RefLength = config->GetRefLength(); + su2double Gas_Constant = config->GetGas_ConstantND(); + const su2double *Origin = nullptr; if (config->GetnMarker_Monitoring() != 0){ Origin = config->GetRefOriginMoment(0); } @@ -4597,19 +4591,19 @@ void CEulerSolver::Momentum_Forces(CGeometry *geometry, CConfig *config) { /*-- Variables initialization ---*/ - AllBound_CD_Mnt = 0.0; AllBound_CL_Mnt = 0.0; AllBound_CSF_Mnt = 0.0; - AllBound_CMx_Mnt = 0.0; AllBound_CMy_Mnt = 0.0; AllBound_CMz_Mnt = 0.0; - AllBound_CoPx_Mnt = 0.0; AllBound_CoPy_Mnt = 0.0; AllBound_CoPz_Mnt = 0.0; - AllBound_CFx_Mnt = 0.0; AllBound_CFy_Mnt = 0.0; AllBound_CFz_Mnt = 0.0; - AllBound_CT_Mnt = 0.0; AllBound_CQ_Mnt = 0.0; AllBound_CMerit_Mnt = 0.0; + AllBound_CD_Mnt = 0.0; AllBound_CL_Mnt = 0.0; AllBound_CSF_Mnt = 0.0; + AllBound_CMx_Mnt = 0.0; AllBound_CMy_Mnt = 0.0; AllBound_CMz_Mnt = 0.0; + AllBound_CoPx_Mnt = 0.0; AllBound_CoPy_Mnt = 0.0; AllBound_CoPz_Mnt = 0.0; + AllBound_CFx_Mnt = 0.0; AllBound_CFy_Mnt = 0.0; AllBound_CFz_Mnt = 0.0; + AllBound_CT_Mnt = 0.0; AllBound_CQ_Mnt = 0.0; AllBound_CMerit_Mnt = 0.0; AllBound_CEff_Mnt = 0.0; for (iMarker_Monitoring = 0; iMarker_Monitoring < config->GetnMarker_Monitoring(); iMarker_Monitoring++) { - Surface_CL_Mnt[iMarker_Monitoring] = 0.0; Surface_CD_Mnt[iMarker_Monitoring] = 0.0; - Surface_CSF_Mnt[iMarker_Monitoring] = 0.0; Surface_CEff_Mnt[iMarker_Monitoring] = 0.0; - Surface_CFx_Mnt[iMarker_Monitoring] = 0.0; Surface_CFy_Mnt[iMarker_Monitoring] = 0.0; - Surface_CFz_Mnt[iMarker_Monitoring] = 0.0; - Surface_CMx_Mnt[iMarker_Monitoring] = 0.0; Surface_CMy_Mnt[iMarker_Monitoring] = 0.0; Surface_CMz_Mnt[iMarker_Monitoring] = 0.0; + Surface_CL_Mnt[iMarker_Monitoring] = 0.0; Surface_CD_Mnt[iMarker_Monitoring] = 0.0; + Surface_CSF_Mnt[iMarker_Monitoring] = 0.0; Surface_CEff_Mnt[iMarker_Monitoring] = 0.0; + Surface_CFx_Mnt[iMarker_Monitoring] = 0.0; Surface_CFy_Mnt[iMarker_Monitoring] = 0.0; + Surface_CFz_Mnt[iMarker_Monitoring] = 0.0; + Surface_CMx_Mnt[iMarker_Monitoring] = 0.0; Surface_CMy_Mnt[iMarker_Monitoring] = 0.0; Surface_CMz_Mnt[iMarker_Monitoring] = 0.0; } /*--- Loop over the Inlet -Outlet Markers ---*/ @@ -4780,7 +4774,6 @@ void CEulerSolver::Momentum_Forces(CGeometry *geometry, CConfig *config) { } - } } @@ -4788,95 +4781,71 @@ void CEulerSolver::Momentum_Forces(CGeometry *geometry, CConfig *config) { /*--- Add AllBound information using all the nodes ---*/ - MyAllBound_CD_Mnt = AllBound_CD_Mnt; AllBound_CD_Mnt = 0.0; - MyAllBound_CL_Mnt = AllBound_CL_Mnt; AllBound_CL_Mnt = 0.0; - MyAllBound_CSF_Mnt = AllBound_CSF_Mnt; AllBound_CSF_Mnt = 0.0; - MyAllBound_CFx_Mnt = AllBound_CFx_Mnt; AllBound_CFx_Mnt = 0.0; - MyAllBound_CFy_Mnt = AllBound_CFy_Mnt; AllBound_CFy_Mnt = 0.0; - MyAllBound_CFz_Mnt = AllBound_CFz_Mnt; AllBound_CFz_Mnt = 0.0; - MyAllBound_CMx_Mnt = AllBound_CMx_Mnt; AllBound_CMx_Mnt = 0.0; - MyAllBound_CMy_Mnt = AllBound_CMy_Mnt; AllBound_CMy_Mnt = 0.0; - MyAllBound_CMz_Mnt = AllBound_CMz_Mnt; AllBound_CMz_Mnt = 0.0; - MyAllBound_CoPx_Mnt = AllBound_CoPx_Mnt; AllBound_CoPx_Mnt = 0.0; - MyAllBound_CoPy_Mnt = AllBound_CoPy_Mnt; AllBound_CoPy_Mnt = 0.0; - MyAllBound_CoPz_Mnt = AllBound_CoPz_Mnt; AllBound_CoPz_Mnt = 0.0; - MyAllBound_CT_Mnt = AllBound_CT_Mnt; AllBound_CT_Mnt = 0.0; - MyAllBound_CQ_Mnt = AllBound_CQ_Mnt; AllBound_CQ_Mnt = 0.0; - if (config->GetComm_Level() == COMM_FULL) { - SU2_MPI::Allreduce(&MyAllBound_CD_Mnt, &AllBound_CD_Mnt, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&MyAllBound_CL_Mnt, &AllBound_CL_Mnt, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&MyAllBound_CSF_Mnt, &AllBound_CSF_Mnt, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); + + auto Allreduce = [](su2double x) { + su2double tmp = x; x = 0.0; + SU2_MPI::Allreduce(&tmp, &x, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); + return x; + }; + + AllBound_CD_Mnt = Allreduce(AllBound_CD_Mnt); + AllBound_CL_Mnt = Allreduce(AllBound_CL_Mnt); + AllBound_CSF_Mnt = Allreduce(AllBound_CSF_Mnt); AllBound_CEff_Mnt = AllBound_CL_Mnt / (AllBound_CD_Mnt + EPS); - SU2_MPI::Allreduce(&MyAllBound_CFx_Mnt, &AllBound_CFx_Mnt, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&MyAllBound_CFy_Mnt, &AllBound_CFy_Mnt, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&MyAllBound_CFz_Mnt, &AllBound_CFz_Mnt, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&MyAllBound_CMx_Mnt, &AllBound_CMx_Mnt, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&MyAllBound_CMy_Mnt, &AllBound_CMy_Mnt, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&MyAllBound_CMz_Mnt, &AllBound_CMz_Mnt, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&MyAllBound_CoPx_Mnt, &AllBound_CoPx_Mnt, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&MyAllBound_CoPy_Mnt, &AllBound_CoPy_Mnt, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&MyAllBound_CoPz_Mnt, &AllBound_CoPz_Mnt, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&MyAllBound_CT_Mnt, &AllBound_CT_Mnt, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&MyAllBound_CQ_Mnt, &AllBound_CQ_Mnt, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); + + AllBound_CFx_Mnt = Allreduce(AllBound_CFx_Mnt); + AllBound_CFy_Mnt = Allreduce(AllBound_CFy_Mnt); + AllBound_CFz_Mnt = Allreduce(AllBound_CFz_Mnt); + + AllBound_CMx_Mnt = Allreduce(AllBound_CMx_Mnt); + AllBound_CMy_Mnt = Allreduce(AllBound_CMy_Mnt); + AllBound_CMz_Mnt = Allreduce(AllBound_CMz_Mnt); + + AllBound_CoPx_Mnt = Allreduce(AllBound_CoPx_Mnt); + AllBound_CoPy_Mnt = Allreduce(AllBound_CoPy_Mnt); + AllBound_CoPz_Mnt = Allreduce(AllBound_CoPz_Mnt); + + AllBound_CT_Mnt = Allreduce(AllBound_CT_Mnt); + AllBound_CQ_Mnt = Allreduce(AllBound_CQ_Mnt); AllBound_CMerit_Mnt = AllBound_CT_Mnt / (AllBound_CQ_Mnt + EPS); + } /*--- Add the forces on the surfaces using all the nodes ---*/ - MySurface_CL_Mnt = new su2double[config->GetnMarker_Monitoring()]; - MySurface_CD_Mnt = new su2double[config->GetnMarker_Monitoring()]; - MySurface_CSF_Mnt = new su2double[config->GetnMarker_Monitoring()]; - MySurface_CEff_Mnt = new su2double[config->GetnMarker_Monitoring()]; - MySurface_CFx_Mnt = new su2double[config->GetnMarker_Monitoring()]; - MySurface_CFy_Mnt = new su2double[config->GetnMarker_Monitoring()]; - MySurface_CFz_Mnt = new su2double[config->GetnMarker_Monitoring()]; - MySurface_CMx_Mnt = new su2double[config->GetnMarker_Monitoring()]; - MySurface_CMy_Mnt = new su2double[config->GetnMarker_Monitoring()]; - MySurface_CMz_Mnt = new su2double[config->GetnMarker_Monitoring()]; + if (config->GetComm_Level() == COMM_FULL) { - for (iMarker_Monitoring = 0; iMarker_Monitoring < config->GetnMarker_Monitoring(); iMarker_Monitoring++) { - MySurface_CL_Mnt[iMarker_Monitoring] = Surface_CL_Mnt[iMarker_Monitoring]; - MySurface_CD_Mnt[iMarker_Monitoring] = Surface_CD_Mnt[iMarker_Monitoring]; - MySurface_CSF_Mnt[iMarker_Monitoring] = Surface_CSF_Mnt[iMarker_Monitoring]; - MySurface_CEff_Mnt[iMarker_Monitoring] = Surface_CEff_Mnt[iMarker_Monitoring]; - MySurface_CFx_Mnt[iMarker_Monitoring] = Surface_CFx_Mnt[iMarker_Monitoring]; - MySurface_CFy_Mnt[iMarker_Monitoring] = Surface_CFy_Mnt[iMarker_Monitoring]; - MySurface_CFz_Mnt[iMarker_Monitoring] = Surface_CFz_Mnt[iMarker_Monitoring]; - MySurface_CMx_Mnt[iMarker_Monitoring] = Surface_CMx_Mnt[iMarker_Monitoring]; - MySurface_CMy_Mnt[iMarker_Monitoring] = Surface_CMy_Mnt[iMarker_Monitoring]; - MySurface_CMz_Mnt[iMarker_Monitoring] = Surface_CMz_Mnt[iMarker_Monitoring]; - - Surface_CL_Mnt[iMarker_Monitoring] = 0.0; - Surface_CD_Mnt[iMarker_Monitoring] = 0.0; - Surface_CSF_Mnt[iMarker_Monitoring] = 0.0; - Surface_CEff_Mnt[iMarker_Monitoring] = 0.0; - Surface_CFx_Mnt[iMarker_Monitoring] = 0.0; - Surface_CFy_Mnt[iMarker_Monitoring] = 0.0; - Surface_CFz_Mnt[iMarker_Monitoring] = 0.0; - Surface_CMx_Mnt[iMarker_Monitoring] = 0.0; - Surface_CMy_Mnt[iMarker_Monitoring] = 0.0; - Surface_CMz_Mnt[iMarker_Monitoring] = 0.0; - } + int nMarkerMon = config->GetnMarker_Monitoring(); - if (config->GetComm_Level() == COMM_FULL) { - SU2_MPI::Allreduce(MySurface_CL_Mnt, Surface_CL_Mnt, config->GetnMarker_Monitoring(), MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(MySurface_CD_Mnt, Surface_CD_Mnt, config->GetnMarker_Monitoring(), MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(MySurface_CSF_Mnt, Surface_CSF_Mnt, config->GetnMarker_Monitoring(), MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - for (iMarker_Monitoring = 0; iMarker_Monitoring < config->GetnMarker_Monitoring(); iMarker_Monitoring++) + /*--- Use the same buffer for all reductions. We could avoid the copy back into + * the original variable by swaping pointers, but it is safer this way... ---*/ + + su2double* buffer = new su2double [nMarkerMon]; + + auto Allreduce_inplace = [buffer](int size, su2double* x) { + SU2_MPI::Allreduce(x, buffer, size, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); + for(int i=0; iGetnMarker_Monitoring(), MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(MySurface_CFy_Mnt, Surface_CFy_Mnt, config->GetnMarker_Monitoring(), MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(MySurface_CFz_Mnt, Surface_CFz_Mnt, config->GetnMarker_Monitoring(), MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(MySurface_CMx_Mnt, Surface_CMx_Mnt, config->GetnMarker_Monitoring(), MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(MySurface_CMy_Mnt, Surface_CMy_Mnt, config->GetnMarker_Monitoring(), MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(MySurface_CMz_Mnt, Surface_CMz_Mnt, config->GetnMarker_Monitoring(), MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - } - delete [] MySurface_CL_Mnt; delete [] MySurface_CD_Mnt; delete [] MySurface_CSF_Mnt; - delete [] MySurface_CEff_Mnt; delete [] MySurface_CFx_Mnt; delete [] MySurface_CFy_Mnt; - delete [] MySurface_CFz_Mnt; - delete [] MySurface_CMx_Mnt; delete [] MySurface_CMy_Mnt; delete [] MySurface_CMz_Mnt; + Allreduce_inplace(nMarkerMon, Surface_CFx_Mnt); + Allreduce_inplace(nMarkerMon, Surface_CFy_Mnt); + Allreduce_inplace(nMarkerMon, Surface_CFz_Mnt); + + Allreduce_inplace(nMarkerMon, Surface_CMx_Mnt); + Allreduce_inplace(nMarkerMon, Surface_CMy_Mnt); + Allreduce_inplace(nMarkerMon, Surface_CMz_Mnt); + + delete [] buffer; + + } #endif @@ -5351,74 +5320,55 @@ void CEulerSolver::GetPower_Properties(CGeometry *geometry, CConfig *config, uns NetThrust = 0.0, GrossThrust = 0.0, Power = 0.0, MassFlow = 0.0, Mach = 0.0, Force = 0.0; bool ReverseFlow, Engine = false, Pair = true; - su2double Gas_Constant = config->GetGas_ConstantND(); - su2double Cp = Gas_Constant*Gamma / (Gamma-1.0); - su2double Alpha = config->GetAoA()*PI_NUMBER/180.0; - su2double Beta = config->GetAoS()*PI_NUMBER/180.0; - bool write_heads = ((((config->GetInnerIter() % (config->GetWrt_Con_Freq()*40)) == 0) && (config->GetInnerIter()!= 0)) - || (config->GetInnerIter() == 1)); - bool Evaluate_BC = ((((config->GetInnerIter() % (config->GetWrt_Con_Freq()*40)) == 0)) - || (config->GetInnerIter() == 1) || (config->GetDiscrete_Adjoint())); + su2double Gas_Constant = config->GetGas_ConstantND(); + su2double Cp = Gas_Constant*Gamma / (Gamma-1.0); + su2double Alpha = config->GetAoA()*PI_NUMBER/180.0; + su2double Beta = config->GetAoS()*PI_NUMBER/180.0; + bool write_heads = ((((config->GetInnerIter() % (config->GetWrt_Con_Freq()*40)) == 0) && (config->GetInnerIter()!= 0)) || (config->GetInnerIter() == 1)); + bool Evaluate_BC = ((((config->GetInnerIter() % (config->GetWrt_Con_Freq()*40)) == 0)) || (config->GetInnerIter() == 1) || (config->GetDiscrete_Adjoint())); if ((config->GetnMarker_EngineInflow() != 0) || (config->GetnMarker_EngineExhaust() != 0)) Engine = true; if ((config->GetnMarker_ActDiskInlet() != 0) || (config->GetnMarker_ActDiskOutlet() != 0)) Engine = false; if ((config->GetnMarker_EngineInflow()) != (config->GetnMarker_EngineExhaust())) Pair = false; - if (Engine) { nMarker_Inlet = config->GetnMarker_EngineInflow(); nMarker_Outlet = config->GetnMarker_EngineExhaust(); } - else { nMarker_Inlet = config->GetnMarker_ActDiskInlet(); nMarker_Outlet = config->GetnMarker_ActDiskOutlet(); } + else { nMarker_Inlet = config->GetnMarker_ActDiskInlet(); nMarker_Outlet = config->GetnMarker_ActDiskOutlet(); } /*--- Evaluate the MPI for the actuator disk IO ---*/ if (Evaluate_BC) { - /*--- Allocate memory ---*/ - - su2double *Inlet_MassFlow = new su2double [config->GetnMarker_All()]; - su2double *Inlet_ReverseMassFlow = new su2double [config->GetnMarker_All()]; - su2double *Inlet_Pressure = new su2double [config->GetnMarker_All()]; - su2double *Inlet_Mach = new su2double [config->GetnMarker_All()]; - su2double *Inlet_MaxPressure = new su2double [config->GetnMarker_All()]; - su2double *Inlet_MinPressure = new su2double [config->GetnMarker_All()]; - su2double *Inlet_TotalPressure = new su2double [config->GetnMarker_All()]; - su2double *Inlet_Temperature = new su2double [config->GetnMarker_All()]; - su2double *Inlet_TotalTemperature = new su2double [config->GetnMarker_All()]; - su2double *Inlet_Area = new su2double [config->GetnMarker_All()]; - su2double *Inlet_RamDrag = new su2double [config->GetnMarker_All()]; - su2double *Inlet_Force = new su2double [config->GetnMarker_All()]; - su2double *Inlet_Power = new su2double [config->GetnMarker_All()]; - su2double *Inlet_XCG = new su2double [config->GetnMarker_All()]; - su2double *Inlet_YCG = new su2double [config->GetnMarker_All()]; - su2double *Inlet_ZCG = new su2double [config->GetnMarker_All()]; - - su2double *Outlet_MassFlow = new su2double [config->GetnMarker_All()]; - su2double *Outlet_Pressure = new su2double [config->GetnMarker_All()]; - su2double *Outlet_TotalPressure = new su2double [config->GetnMarker_All()]; - su2double *Outlet_Temperature = new su2double [config->GetnMarker_All()]; - su2double *Outlet_TotalTemperature = new su2double [config->GetnMarker_All()]; - su2double *Outlet_Area = new su2double [config->GetnMarker_All()]; - su2double *Outlet_GrossThrust = new su2double [config->GetnMarker_All()]; - su2double *Outlet_Force = new su2double [config->GetnMarker_All()]; - su2double *Outlet_Power = new su2double [config->GetnMarker_All()]; + su2double *Inlet_MassFlow = new su2double [config->GetnMarker_All()](); + su2double *Inlet_ReverseMassFlow = new su2double [config->GetnMarker_All()](); + su2double *Inlet_Pressure = new su2double [config->GetnMarker_All()](); + su2double *Inlet_Mach = new su2double [config->GetnMarker_All()](); + su2double *Inlet_MaxPressure = new su2double [config->GetnMarker_All()](); + su2double *Inlet_MinPressure = new su2double [config->GetnMarker_All()](); + su2double *Inlet_TotalPressure = new su2double [config->GetnMarker_All()](); + su2double *Inlet_Temperature = new su2double [config->GetnMarker_All()](); + su2double *Inlet_TotalTemperature = new su2double [config->GetnMarker_All()](); + su2double *Inlet_Area = new su2double [config->GetnMarker_All()](); + su2double *Inlet_RamDrag = new su2double [config->GetnMarker_All()](); + su2double *Inlet_Force = new su2double [config->GetnMarker_All()](); + su2double *Inlet_Power = new su2double [config->GetnMarker_All()](); + su2double *Inlet_XCG = new su2double [config->GetnMarker_All()](); + su2double *Inlet_YCG = new su2double [config->GetnMarker_All()](); + su2double *Inlet_ZCG = new su2double [config->GetnMarker_All()](); + + su2double *Outlet_MassFlow = new su2double [config->GetnMarker_All()](); + su2double *Outlet_Pressure = new su2double [config->GetnMarker_All()](); + su2double *Outlet_TotalPressure = new su2double [config->GetnMarker_All()](); + su2double *Outlet_Temperature = new su2double [config->GetnMarker_All()](); + su2double *Outlet_TotalTemperature = new su2double [config->GetnMarker_All()](); + su2double *Outlet_Area = new su2double [config->GetnMarker_All()](); + su2double *Outlet_GrossThrust = new su2double [config->GetnMarker_All()](); + su2double *Outlet_Force = new su2double [config->GetnMarker_All()](); + su2double *Outlet_Power = new su2double [config->GetnMarker_All()](); /*--- Comute MassFlow, average temp, press, etc. ---*/ for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { - Inlet_MassFlow[iMarker] = 0.0; Inlet_ReverseMassFlow[iMarker] = 0.0; Inlet_MinPressure[iMarker] = 0.0; - Inlet_Pressure[iMarker] = 0.0; Inlet_Mach[iMarker] = 0.0; Inlet_Temperature[iMarker] = 0.0; - Inlet_MinPressure[iMarker] = +1E10; Inlet_MaxPressure[iMarker] = -1E10; Inlet_Power[iMarker] = 0.0; - Inlet_TotalPressure[iMarker] = 0.0; Inlet_TotalTemperature[iMarker] = 0.0; - Inlet_Area[iMarker] = 0.0; - Inlet_RamDrag[iMarker] = 0.0; Inlet_Force[iMarker] = 0.0; - Inlet_XCG[iMarker] = 0.0; Inlet_YCG[iMarker] = 0.0; Inlet_ZCG[iMarker] = 0.0; - - Outlet_MassFlow[iMarker] = 0.0; - Outlet_Pressure[iMarker] = 0.0; Outlet_Temperature[iMarker] = 0.0; - Outlet_TotalPressure[iMarker] = 0.0; Outlet_TotalTemperature[iMarker] = 0.0; - Outlet_Area[iMarker] = 0.0; - Outlet_GrossThrust[iMarker] = 0.0; Outlet_Force[iMarker] = 0.0; Outlet_Power[iMarker] = 0.0; - MinPressure = +1E10; MaxPressure = -1E10; if ((config->GetMarker_All_KindBC(iMarker) == ACTDISK_INLET) || @@ -5434,11 +5384,11 @@ void CEulerSolver::GetPower_Properties(CGeometry *geometry, CConfig *config, uns geometry->vertex[iMarker][iVertex]->GetNormal(Vector); - Temperature = V_inlet[0]; - Pressure = V_inlet[nDim+1]; + Temperature = V_inlet[0]; + Pressure = V_inlet[nDim+1]; - Density = V_inlet[nDim+2]; - SoundSpeed = sqrt(Gamma*Pressure/Density); + Density = V_inlet[nDim+2]; + SoundSpeed = sqrt(Gamma*Pressure/Density); Velocity2 = 0.0; Area = 0.0; MassFlow = 0.0; Vel_Infty2 =0.0; for (iDim = 0; iDim < nDim; iDim++) { @@ -5453,15 +5403,15 @@ void CEulerSolver::GetPower_Properties(CGeometry *geometry, CConfig *config, uns for (iDim = 0; iDim < nDim; iDim++) { Vn -= Velocity[iDim]*Vector[iDim]/Area; } if (Vn < 0.0) { ReverseFlow = true; } - Vel_Infty = sqrt (Vel_Infty2); - Area = sqrt (Area); - Mach = sqrt(Velocity2)/SoundSpeed; - TotalPressure = Pressure * pow( 1.0 + Mach * Mach * 0.5 * (Gamma - 1.0), Gamma / (Gamma - 1.0)); - TotalTemperature = Temperature * (1.0 + Mach * Mach * 0.5 * (Gamma - 1.0)); - MinPressure = min(MinPressure, TotalPressure); - MaxPressure = max(MaxPressure, TotalPressure); + Vel_Infty = sqrt (Vel_Infty2); + Area = sqrt (Area); + Mach = sqrt(Velocity2)/SoundSpeed; + TotalPressure = Pressure * pow( 1.0 + Mach * Mach * 0.5 * (Gamma - 1.0), Gamma / (Gamma - 1.0)); + TotalTemperature = Temperature * (1.0 + Mach * Mach * 0.5 * (Gamma - 1.0)); + MinPressure = min(MinPressure, TotalPressure); + MaxPressure = max(MaxPressure, TotalPressure); - RamDrag = MassFlow * Vel_Infty; + RamDrag = MassFlow * Vel_Infty; Inlet_MassFlow[iMarker] += MassFlow; Inlet_Pressure[iMarker] += Pressure*MassFlow; @@ -5476,14 +5426,14 @@ void CEulerSolver::GetPower_Properties(CGeometry *geometry, CConfig *config, uns Inlet_Power[iMarker] += MassFlow*Cp*TotalTemperature; if (ReverseFlow) Inlet_ReverseMassFlow[iMarker] += MassFlow; - su2double Inlet_ForceX = -(Pressure - Pressure_Inf)*Vector[0] + MassFlow*Velocity[0]; + su2double Inlet_ForceX = -(Pressure - Pressure_Inf)*Vector[0] + MassFlow*Velocity[0]; su2double Inlet_ForceY = -(Pressure - Pressure_Inf)*Vector[1] + MassFlow*Velocity[1]; su2double Inlet_ForceZ = 0.0; if (nDim == 3) Inlet_ForceZ = -(Pressure - Pressure_Inf)*Vector[2] + MassFlow*Velocity[2]; Inlet_Force[iMarker] += Inlet_ForceX*cos(Alpha)*cos(Beta) + Inlet_ForceY*sin(Beta) +Inlet_ForceZ*sin(Alpha)*cos(Beta); - Inlet_XCG[iMarker] += geometry->node[iPoint]->GetCoord(0)*Area; - Inlet_YCG[iMarker] += geometry->node[iPoint]->GetCoord(1)*Area; + Inlet_XCG[iMarker] += geometry->node[iPoint]->GetCoord(0)*Area; + Inlet_YCG[iMarker] += geometry->node[iPoint]->GetCoord(1)*Area; if (nDim == 3) Inlet_ZCG[iMarker] += geometry->node[iPoint]->GetCoord(2)*Area; } @@ -5504,10 +5454,10 @@ void CEulerSolver::GetPower_Properties(CGeometry *geometry, CConfig *config, uns geometry->vertex[iMarker][iVertex]->GetNormal(Vector); - Temperature = V_outlet[0]; - Pressure = V_outlet[nDim+1]; + Temperature = V_outlet[0]; + Pressure = V_outlet[nDim+1]; - Density = V_outlet[nDim+2]; + Density = V_outlet[nDim+2]; SoundSpeed = sqrt(Gamma*Pressure/Density); Velocity2 = 0.0; Area = 0.0; MassFlow = 0.0; Vel_Infty2 = 0.0; @@ -5519,26 +5469,26 @@ void CEulerSolver::GetPower_Properties(CGeometry *geometry, CConfig *config, uns MassFlow += Vector[iDim]*Velocity[iDim]*Density; } - Vel_Infty = sqrt (Vel_Infty2); - Area = sqrt (Area); - Mach = sqrt(Velocity2)/SoundSpeed; - TotalPressure = Pressure * pow( 1.0 + Mach * Mach * 0.5 * (Gamma - 1.0), Gamma / (Gamma - 1.0)); - TotalTemperature = Temperature * (1.0 + Mach * Mach * 0.5 * (Gamma - 1.0)); - VelocityJet = sqrt(Velocity2) ; - - GrossThrust = MassFlow * VelocityJet; - - Outlet_MassFlow[iMarker] += MassFlow; - Outlet_Pressure[iMarker] += Pressure*MassFlow; - Outlet_TotalPressure[iMarker] += TotalPressure*MassFlow; - Outlet_Temperature[iMarker] += Temperature*MassFlow; - Outlet_TotalTemperature[iMarker] += TotalTemperature*MassFlow; - Outlet_Area[iMarker] += Area; - Outlet_GrossThrust[iMarker] += GrossThrust; + Vel_Infty = sqrt (Vel_Infty2); + Area = sqrt (Area); + Mach = sqrt(Velocity2)/SoundSpeed; + TotalPressure = Pressure * pow( 1.0 + Mach * Mach * 0.5 * (Gamma - 1.0), Gamma / (Gamma - 1.0)); + TotalTemperature = Temperature * (1.0 + Mach * Mach * 0.5 * (Gamma - 1.0)); + VelocityJet = sqrt(Velocity2) ; + + GrossThrust = MassFlow * VelocityJet; + + Outlet_MassFlow[iMarker] += MassFlow; + Outlet_Pressure[iMarker] += Pressure*MassFlow; + Outlet_TotalPressure[iMarker] += TotalPressure*MassFlow; + Outlet_Temperature[iMarker] += Temperature*MassFlow; + Outlet_TotalTemperature[iMarker] += TotalTemperature*MassFlow; + Outlet_Area[iMarker] += Area; + Outlet_GrossThrust[iMarker] += GrossThrust; Outlet_Power[iMarker] += MassFlow*Cp*TotalTemperature; su2double Outlet_ForceX = -(Pressure - Pressure_Inf)*Vector[0] -MassFlow*Velocity[0]; - su2double Outlet_ForceY = -(Pressure - Pressure_Inf)*Vector[1] -MassFlow*Velocity[1]; + su2double Outlet_ForceY = -(Pressure - Pressure_Inf)*Vector[1] -MassFlow*Velocity[1]; su2double Outlet_ForceZ = 0.0; if (nDim == 3) Outlet_ForceZ = -(Pressure - Pressure_Inf)*Vector[2] -MassFlow*Velocity[2]; @@ -5554,117 +5504,59 @@ void CEulerSolver::GetPower_Properties(CGeometry *geometry, CConfig *config, uns /*--- Copy to the appropriate structure ---*/ - su2double *Inlet_MassFlow_Local = new su2double [nMarker_Inlet]; - su2double *Inlet_ReverseMassFlow_Local = new su2double [nMarker_Inlet]; - su2double *Inlet_Temperature_Local = new su2double [nMarker_Inlet]; - su2double *Inlet_TotalTemperature_Local = new su2double [nMarker_Inlet]; - su2double *Inlet_Pressure_Local = new su2double [nMarker_Inlet]; - su2double *Inlet_Mach_Local = new su2double [nMarker_Inlet]; - su2double *Inlet_MinPressure_Local = new su2double [nMarker_Inlet]; - su2double *Inlet_MaxPressure_Local = new su2double [nMarker_Inlet]; - su2double *Inlet_Power_Local = new su2double [nMarker_Inlet]; - su2double *Inlet_TotalPressure_Local = new su2double [nMarker_Inlet]; - su2double *Inlet_RamDrag_Local = new su2double [nMarker_Inlet]; - su2double *Inlet_Force_Local = new su2double [nMarker_Inlet]; - su2double *Inlet_Area_Local = new su2double [nMarker_Inlet]; - su2double *Inlet_XCG_Local = new su2double [nMarker_Inlet]; - su2double *Inlet_YCG_Local = new su2double [nMarker_Inlet]; - su2double *Inlet_ZCG_Local = new su2double [nMarker_Inlet]; - - su2double *Inlet_MassFlow_Total = new su2double [nMarker_Inlet]; - su2double *Inlet_ReverseMassFlow_Total = new su2double [nMarker_Inlet]; - su2double *Inlet_Pressure_Total = new su2double [nMarker_Inlet]; - su2double *Inlet_Mach_Total = new su2double [nMarker_Inlet]; - su2double *Inlet_MinPressure_Total = new su2double [nMarker_Inlet]; - su2double *Inlet_MaxPressure_Total = new su2double [nMarker_Inlet]; - su2double *Inlet_Power_Total = new su2double [nMarker_Inlet]; - su2double *Inlet_TotalPressure_Total = new su2double [nMarker_Inlet]; - su2double *Inlet_Temperature_Total = new su2double [nMarker_Inlet]; - su2double *Inlet_TotalTemperature_Total = new su2double [nMarker_Inlet]; - su2double *Inlet_RamDrag_Total = new su2double [nMarker_Inlet]; - su2double *Inlet_Force_Total = new su2double [nMarker_Inlet]; - su2double *Inlet_Area_Total = new su2double [nMarker_Inlet]; - su2double *Inlet_XCG_Total = new su2double [nMarker_Inlet]; - su2double *Inlet_YCG_Total = new su2double [nMarker_Inlet]; - su2double *Inlet_ZCG_Total = new su2double [nMarker_Inlet]; - - for (iMarker_Inlet = 0; iMarker_Inlet < nMarker_Inlet; iMarker_Inlet++) { - Inlet_MassFlow_Local[iMarker_Inlet] = 0.0; - Inlet_ReverseMassFlow_Local[iMarker_Inlet] = 0.0; - Inlet_Pressure_Local[iMarker_Inlet] = 0.0; - Inlet_Mach_Local[iMarker_Inlet] = 0.0; - Inlet_MinPressure_Local[iMarker_Inlet] = 0.0; - Inlet_MaxPressure_Local[iMarker_Inlet] = 0.0; - Inlet_TotalPressure_Local[iMarker_Inlet] = 0.0; - Inlet_Temperature_Local[iMarker_Inlet] = 0.0; - Inlet_TotalTemperature_Local[iMarker_Inlet] = 0.0; - Inlet_RamDrag_Local[iMarker_Inlet] = 0.0; - Inlet_Force_Local[iMarker_Inlet] = 0.0; - Inlet_Power_Local[iMarker_Inlet] = 0.0; - Inlet_Area_Local[iMarker_Inlet] = 0.0; - Inlet_XCG_Local[iMarker_Inlet] = 0.0; - Inlet_YCG_Local[iMarker_Inlet] = 0.0; - Inlet_ZCG_Local[iMarker_Inlet] = 0.0; - - Inlet_MassFlow_Total[iMarker_Inlet] = 0.0; - Inlet_ReverseMassFlow_Total[iMarker_Inlet] = 0.0; - Inlet_Pressure_Total[iMarker_Inlet] = 0.0; - Inlet_Mach_Total[iMarker_Inlet] = 0.0; - Inlet_MinPressure_Total[iMarker_Inlet] = 0.0; - Inlet_MaxPressure_Total[iMarker_Inlet] = 0.0; - Inlet_TotalPressure_Total[iMarker_Inlet] = 0.0; - Inlet_Temperature_Total[iMarker_Inlet] = 0.0; - Inlet_TotalTemperature_Total[iMarker_Inlet] = 0.0; - Inlet_RamDrag_Total[iMarker_Inlet] = 0.0; - Inlet_Force_Total[iMarker_Inlet] = 0.0; - Inlet_Power_Total[iMarker_Inlet] = 0.0; - Inlet_Area_Total[iMarker_Inlet] = 0.0; - Inlet_XCG_Total[iMarker_Inlet] = 0.0; - Inlet_YCG_Total[iMarker_Inlet] = 0.0; - Inlet_ZCG_Total[iMarker_Inlet] = 0.0; - } - - su2double *Outlet_MassFlow_Local = new su2double [nMarker_Outlet]; - su2double *Outlet_Pressure_Local = new su2double [nMarker_Outlet]; - su2double *Outlet_TotalPressure_Local = new su2double [nMarker_Outlet]; - su2double *Outlet_Temperature_Local = new su2double [nMarker_Outlet]; - su2double *Outlet_TotalTemperature_Local = new su2double [nMarker_Outlet]; - su2double *Outlet_GrossThrust_Local = new su2double [nMarker_Outlet]; - su2double *Outlet_Force_Local = new su2double [nMarker_Outlet]; - su2double *Outlet_Power_Local = new su2double [nMarker_Outlet]; - su2double *Outlet_Area_Local = new su2double [nMarker_Outlet]; - - su2double *Outlet_MassFlow_Total = new su2double [nMarker_Outlet]; - su2double *Outlet_Pressure_Total = new su2double [nMarker_Outlet]; - su2double *Outlet_TotalPressure_Total = new su2double [nMarker_Outlet]; - su2double *Outlet_Temperature_Total = new su2double [nMarker_Outlet]; - su2double *Outlet_TotalTemperature_Total = new su2double [nMarker_Outlet]; - su2double *Outlet_GrossThrust_Total = new su2double [nMarker_Outlet]; - su2double *Outlet_Force_Total = new su2double [nMarker_Outlet]; - su2double *Outlet_Power_Total = new su2double [nMarker_Outlet]; - su2double *Outlet_Area_Total = new su2double [nMarker_Outlet]; - - for (iMarker_Outlet = 0; iMarker_Outlet < nMarker_Outlet; iMarker_Outlet++) { - Outlet_MassFlow_Local[iMarker_Outlet] = 0.0; - Outlet_Pressure_Local[iMarker_Outlet] = 0.0; - Outlet_TotalPressure_Local[iMarker_Outlet] = 0.0; - Outlet_Temperature_Local[iMarker_Outlet] = 0.0; - Outlet_TotalTemperature_Local[iMarker_Outlet] = 0.0; - Outlet_GrossThrust_Local[iMarker_Outlet] = 0.0; - Outlet_Force_Local[iMarker_Outlet] = 0.0; - Outlet_Power_Local[iMarker_Outlet] = 0.0; - Outlet_Area_Local[iMarker_Outlet] = 0.0; - - Outlet_MassFlow_Total[iMarker_Outlet] = 0.0; - Outlet_Pressure_Total[iMarker_Outlet] = 0.0; - Outlet_TotalPressure_Total[iMarker_Outlet] = 0.0; - Outlet_Temperature_Total[iMarker_Outlet] = 0.0; - Outlet_TotalTemperature_Total[iMarker_Outlet] = 0.0; - Outlet_GrossThrust_Total[iMarker_Outlet] = 0.0; - Outlet_Force_Total[iMarker_Outlet] = 0.0; - Outlet_Power_Total[iMarker_Outlet] = 0.0; - Outlet_Area_Total[iMarker_Outlet] = 0.0; - } + su2double *Inlet_MassFlow_Local = new su2double [nMarker_Inlet](); + su2double *Inlet_ReverseMassFlow_Local = new su2double [nMarker_Inlet](); + su2double *Inlet_Temperature_Local = new su2double [nMarker_Inlet](); + su2double *Inlet_TotalTemperature_Local = new su2double [nMarker_Inlet](); + su2double *Inlet_Pressure_Local = new su2double [nMarker_Inlet](); + su2double *Inlet_Mach_Local = new su2double [nMarker_Inlet](); + su2double *Inlet_MinPressure_Local = new su2double [nMarker_Inlet](); + su2double *Inlet_MaxPressure_Local = new su2double [nMarker_Inlet](); + su2double *Inlet_Power_Local = new su2double [nMarker_Inlet](); + su2double *Inlet_TotalPressure_Local = new su2double [nMarker_Inlet](); + su2double *Inlet_RamDrag_Local = new su2double [nMarker_Inlet](); + su2double *Inlet_Force_Local = new su2double [nMarker_Inlet](); + su2double *Inlet_Area_Local = new su2double [nMarker_Inlet](); + su2double *Inlet_XCG_Local = new su2double [nMarker_Inlet](); + su2double *Inlet_YCG_Local = new su2double [nMarker_Inlet](); + su2double *Inlet_ZCG_Local = new su2double [nMarker_Inlet](); + + su2double *Inlet_MassFlow_Total = new su2double [nMarker_Inlet](); + su2double *Inlet_ReverseMassFlow_Total = new su2double [nMarker_Inlet](); + su2double *Inlet_Pressure_Total = new su2double [nMarker_Inlet](); + su2double *Inlet_Mach_Total = new su2double [nMarker_Inlet](); + su2double *Inlet_MinPressure_Total = new su2double [nMarker_Inlet](); + su2double *Inlet_MaxPressure_Total = new su2double [nMarker_Inlet](); + su2double *Inlet_Power_Total = new su2double [nMarker_Inlet](); + su2double *Inlet_TotalPressure_Total = new su2double [nMarker_Inlet](); + su2double *Inlet_Temperature_Total = new su2double [nMarker_Inlet](); + su2double *Inlet_TotalTemperature_Total = new su2double [nMarker_Inlet](); + su2double *Inlet_RamDrag_Total = new su2double [nMarker_Inlet](); + su2double *Inlet_Force_Total = new su2double [nMarker_Inlet](); + su2double *Inlet_Area_Total = new su2double [nMarker_Inlet](); + su2double *Inlet_XCG_Total = new su2double [nMarker_Inlet](); + su2double *Inlet_YCG_Total = new su2double [nMarker_Inlet](); + su2double *Inlet_ZCG_Total = new su2double [nMarker_Inlet](); + + su2double *Outlet_MassFlow_Local = new su2double [nMarker_Outlet](); + su2double *Outlet_Pressure_Local = new su2double [nMarker_Outlet](); + su2double *Outlet_TotalPressure_Local = new su2double [nMarker_Outlet](); + su2double *Outlet_Temperature_Local = new su2double [nMarker_Outlet](); + su2double *Outlet_TotalTemperature_Local = new su2double [nMarker_Outlet](); + su2double *Outlet_GrossThrust_Local = new su2double [nMarker_Outlet](); + su2double *Outlet_Force_Local = new su2double [nMarker_Outlet](); + su2double *Outlet_Power_Local = new su2double [nMarker_Outlet](); + su2double *Outlet_Area_Local = new su2double [nMarker_Outlet](); + + su2double *Outlet_MassFlow_Total = new su2double [nMarker_Outlet](); + su2double *Outlet_Pressure_Total = new su2double [nMarker_Outlet](); + su2double *Outlet_TotalPressure_Total = new su2double [nMarker_Outlet](); + su2double *Outlet_Temperature_Total = new su2double [nMarker_Outlet](); + su2double *Outlet_TotalTemperature_Total = new su2double [nMarker_Outlet](); + su2double *Outlet_GrossThrust_Total = new su2double [nMarker_Outlet](); + su2double *Outlet_Force_Total = new su2double [nMarker_Outlet](); + su2double *Outlet_Power_Total = new su2double [nMarker_Outlet](); + su2double *Outlet_Area_Total = new su2double [nMarker_Outlet](); /*--- Copy the values to the local array for MPI ---*/ @@ -5677,22 +5569,22 @@ void CEulerSolver::GetPower_Properties(CGeometry *geometry, CConfig *config, uns if (config->GetMarker_All_KindBC(iMarker) == ENGINE_INFLOW) Inlet_TagBound = config->GetMarker_EngineInflow_TagBound(iMarker_Inlet); if (config->GetMarker_All_TagBound(iMarker) == Inlet_TagBound) { - Inlet_MassFlow_Local[iMarker_Inlet] += Inlet_MassFlow[iMarker]; - Inlet_ReverseMassFlow_Local[iMarker_Inlet] += Inlet_ReverseMassFlow[iMarker]; - Inlet_Pressure_Local[iMarker_Inlet] += Inlet_Pressure[iMarker]; - Inlet_Mach_Local[iMarker_Inlet] += Inlet_Mach[iMarker]; - Inlet_MinPressure_Local[iMarker_Inlet] += Inlet_MinPressure[iMarker]; + Inlet_MassFlow_Local[iMarker_Inlet] += Inlet_MassFlow[iMarker]; + Inlet_ReverseMassFlow_Local[iMarker_Inlet] += Inlet_ReverseMassFlow[iMarker]; + Inlet_Pressure_Local[iMarker_Inlet] += Inlet_Pressure[iMarker]; + Inlet_Mach_Local[iMarker_Inlet] += Inlet_Mach[iMarker]; + Inlet_MinPressure_Local[iMarker_Inlet] += Inlet_MinPressure[iMarker]; Inlet_MaxPressure_Local[iMarker_Inlet] += Inlet_MaxPressure[iMarker]; - Inlet_TotalPressure_Local[iMarker_Inlet] += Inlet_TotalPressure[iMarker]; - Inlet_Temperature_Local[iMarker_Inlet] += Inlet_Temperature[iMarker]; - Inlet_TotalTemperature_Local[iMarker_Inlet] += Inlet_TotalTemperature[iMarker]; - Inlet_RamDrag_Local[iMarker_Inlet] += Inlet_RamDrag[iMarker]; - Inlet_Force_Local[iMarker_Inlet] += Inlet_Force[iMarker]; - Inlet_Power_Local[iMarker_Inlet] += Inlet_Power[iMarker]; - Inlet_Area_Local[iMarker_Inlet] += Inlet_Area[iMarker]; - Inlet_XCG_Local[iMarker_Inlet] += Inlet_XCG[iMarker]; - Inlet_YCG_Local[iMarker_Inlet] += Inlet_YCG[iMarker]; - if (nDim == 3) Inlet_ZCG_Local[iMarker_Inlet] += Inlet_ZCG[iMarker]; + Inlet_TotalPressure_Local[iMarker_Inlet] += Inlet_TotalPressure[iMarker]; + Inlet_Temperature_Local[iMarker_Inlet] += Inlet_Temperature[iMarker]; + Inlet_TotalTemperature_Local[iMarker_Inlet] += Inlet_TotalTemperature[iMarker]; + Inlet_RamDrag_Local[iMarker_Inlet] += Inlet_RamDrag[iMarker]; + Inlet_Force_Local[iMarker_Inlet] += Inlet_Force[iMarker]; + Inlet_Power_Local[iMarker_Inlet] += Inlet_Power[iMarker]; + Inlet_Area_Local[iMarker_Inlet] += Inlet_Area[iMarker]; + Inlet_XCG_Local[iMarker_Inlet] += Inlet_XCG[iMarker]; + Inlet_YCG_Local[iMarker_Inlet] += Inlet_YCG[iMarker]; + if (nDim == 3) Inlet_ZCG_Local[iMarker_Inlet] += Inlet_ZCG[iMarker]; } } @@ -5705,15 +5597,15 @@ void CEulerSolver::GetPower_Properties(CGeometry *geometry, CConfig *config, uns if (config->GetMarker_All_KindBC(iMarker) == ENGINE_EXHAUST) Outlet_TagBound = config->GetMarker_EngineExhaust_TagBound(iMarker_Outlet); if (config->GetMarker_All_TagBound(iMarker) == Outlet_TagBound) { - Outlet_MassFlow_Local[iMarker_Outlet] += Outlet_MassFlow[iMarker]; - Outlet_Pressure_Local[iMarker_Outlet] += Outlet_Pressure[iMarker]; + Outlet_MassFlow_Local[iMarker_Outlet] += Outlet_MassFlow[iMarker]; + Outlet_Pressure_Local[iMarker_Outlet] += Outlet_Pressure[iMarker]; Outlet_TotalPressure_Local[iMarker_Outlet] += Outlet_TotalPressure[iMarker]; - Outlet_Temperature_Local[iMarker_Outlet] += Outlet_Temperature[iMarker]; - Outlet_TotalTemperature_Local[iMarker_Outlet] += Outlet_TotalTemperature[iMarker]; - Outlet_GrossThrust_Local[iMarker_Outlet] += Outlet_GrossThrust[iMarker]; - Outlet_Force_Local[iMarker_Outlet] += Outlet_Force[iMarker]; - Outlet_Power_Local[iMarker_Outlet] += Outlet_Power[iMarker]; - Outlet_Area_Local[iMarker_Outlet] += Outlet_Area[iMarker]; + Outlet_Temperature_Local[iMarker_Outlet] += Outlet_Temperature[iMarker]; + Outlet_TotalTemperature_Local[iMarker_Outlet] += Outlet_TotalTemperature[iMarker]; + Outlet_GrossThrust_Local[iMarker_Outlet] += Outlet_GrossThrust[iMarker]; + Outlet_Force_Local[iMarker_Outlet] += Outlet_Force[iMarker]; + Outlet_Power_Local[iMarker_Outlet] += Outlet_Power[iMarker]; + Outlet_Area_Local[iMarker_Outlet] += Outlet_Area[iMarker]; } } @@ -5731,15 +5623,13 @@ void CEulerSolver::GetPower_Properties(CGeometry *geometry, CConfig *config, uns if (!ActDisk) { for (iMarker_Inlet = 0; iMarker_Inlet < nMarker_Inlet; iMarker_Inlet++) { - Inlet_MinPressure_Local[iMarker_Inlet] = 1E10; + Inlet_MinPressure_Local[iMarker_Inlet] = 1E10; Inlet_MaxPressure_Local[iMarker_Inlet] = -1E10; } } /*--- All the ranks to compute the total value ---*/ -#ifdef HAVE_MPI - SU2_MPI::Allreduce(Inlet_MassFlow_Local, Inlet_MassFlow_Total, nMarker_Inlet, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); SU2_MPI::Allreduce(Inlet_ReverseMassFlow_Local, Inlet_ReverseMassFlow_Total, nMarker_Inlet, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); SU2_MPI::Allreduce(Inlet_Pressure_Local, Inlet_Pressure_Total, nMarker_Inlet, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); @@ -5767,41 +5657,6 @@ void CEulerSolver::GetPower_Properties(CGeometry *geometry, CConfig *config, uns SU2_MPI::Allreduce(Outlet_Power_Local, Outlet_Power_Total, nMarker_Outlet, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); SU2_MPI::Allreduce(Outlet_Area_Local, Outlet_Area_Total, nMarker_Outlet, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); -#else - - for (iMarker_Inlet = 0; iMarker_Inlet < nMarker_Inlet; iMarker_Inlet++) { - Inlet_MassFlow_Total[iMarker_Inlet] = Inlet_MassFlow_Local[iMarker_Inlet]; - Inlet_ReverseMassFlow_Total[iMarker_Inlet] = Inlet_ReverseMassFlow_Local[iMarker_Inlet]; - Inlet_Pressure_Total[iMarker_Inlet] = Inlet_Pressure_Local[iMarker_Inlet]; - Inlet_Mach_Total[iMarker_Inlet] = Inlet_Mach_Local[iMarker_Inlet]; - Inlet_MinPressure_Total[iMarker_Inlet] = Inlet_MinPressure_Local[iMarker_Inlet]; - Inlet_MaxPressure_Total[iMarker_Inlet] = Inlet_MaxPressure_Local[iMarker_Inlet]; - Inlet_TotalPressure_Total[iMarker_Inlet] = Inlet_TotalPressure_Local[iMarker_Inlet]; - Inlet_Temperature_Total[iMarker_Inlet] = Inlet_Temperature_Local[iMarker_Inlet]; - Inlet_TotalTemperature_Total[iMarker_Inlet] = Inlet_TotalTemperature_Local[iMarker_Inlet]; - Inlet_RamDrag_Total[iMarker_Inlet] = Inlet_RamDrag_Local[iMarker_Inlet]; - Inlet_Force_Total[iMarker_Inlet] = Inlet_Force_Local[iMarker_Inlet]; - Inlet_Power_Total[iMarker_Inlet] = Inlet_Power_Local[iMarker_Inlet]; - Inlet_Area_Total[iMarker_Inlet] = Inlet_Area_Local[iMarker_Inlet]; - Inlet_XCG_Total[iMarker_Inlet] = Inlet_XCG_Local[iMarker_Inlet]; - Inlet_YCG_Total[iMarker_Inlet] = Inlet_YCG_Local[iMarker_Inlet]; - if (nDim == 3) Inlet_ZCG_Total[iMarker_Inlet] = Inlet_ZCG_Local[iMarker_Inlet]; - } - - for (iMarker_Outlet = 0; iMarker_Outlet < nMarker_Outlet; iMarker_Outlet++) { - Outlet_MassFlow_Total[iMarker_Outlet] = Outlet_MassFlow_Local[iMarker_Outlet]; - Outlet_Pressure_Total[iMarker_Outlet] = Outlet_Pressure_Local[iMarker_Outlet]; - Outlet_TotalPressure_Total[iMarker_Outlet] = Outlet_TotalPressure_Local[iMarker_Outlet]; - Outlet_Temperature_Total[iMarker_Outlet] = Outlet_Temperature_Local[iMarker_Outlet]; - Outlet_TotalTemperature_Total[iMarker_Outlet] = Outlet_TotalTemperature_Local[iMarker_Outlet]; - Outlet_GrossThrust_Total[iMarker_Outlet] = Outlet_GrossThrust_Local[iMarker_Outlet]; - Outlet_Force_Total[iMarker_Outlet] = Outlet_Force_Local[iMarker_Outlet]; - Outlet_Power_Total[iMarker_Outlet] = Outlet_Power_Local[iMarker_Outlet]; - Outlet_Area_Total[iMarker_Outlet] = Outlet_Area_Local[iMarker_Outlet]; - } - -#endif - /*--- Compute the value of the average surface temperature and pressure and set the value in the config structure for future use ---*/ @@ -6256,7 +6111,6 @@ void CEulerSolver::GetPower_Properties(CGeometry *geometry, CConfig *config, uns } - delete [] Outlet_MassFlow_Local; delete [] Outlet_Temperature_Local; delete [] Outlet_TotalTemperature_Local; From 3471e4d56007fa143ce6b3026d0ee8a3fa30d7cb Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Thu, 30 Jan 2020 12:17:27 +0000 Subject: [PATCH 052/118] parallel explicit iterations --- SU2_CFD/include/solvers/CEulerSolver.hpp | 6 + SU2_CFD/src/solvers/CEulerSolver.cpp | 213 ++++++++++------------- SU2_CFD/src/solvers/CSolver.cpp | 24 +-- 3 files changed, 110 insertions(+), 133 deletions(-) diff --git a/SU2_CFD/include/solvers/CEulerSolver.hpp b/SU2_CFD/include/solvers/CEulerSolver.hpp index c0e5c77b3245..751132ff59a1 100644 --- a/SU2_CFD/include/solvers/CEulerSolver.hpp +++ b/SU2_CFD/include/solvers/CEulerSolver.hpp @@ -328,6 +328,12 @@ class CEulerSolver : public CSolver { */ inline CVariable* GetBaseClassPointerToNodes() final { return nodes; } + /*! + * \brief Generic implementation of explicit iterations (RK, Classic RK and EULER). + */ + template + void Explicit_Iteration(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iRKStep); + public: diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 940e90466dd7..0fef27fabe8e 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -4885,167 +4885,138 @@ void CEulerSolver::Momentum_Forces(CGeometry *geometry, CConfig *config) { } -void CEulerSolver::ExplicitRK_Iteration(CGeometry *geometry, CSolver **solver_container, - CConfig *config, unsigned short iRKStep) { - su2double *Residual, *Res_TruncError, Vol, Delta, Res; - unsigned short iVar; - unsigned long iPoint; - - su2double RK_AlphaCoeff = config->Get_Alpha_RKStep(iRKStep); - bool adjoint = config->GetContinuous_Adjoint(); - - for (iVar = 0; iVar < nVar; iVar++) { - SetRes_RMS(iVar, 0.0); - SetRes_Max(iVar, 0.0, 0); - } - - /*--- Update the solution ---*/ - - for (iPoint = 0; iPoint < nPointDomain; iPoint++) { - Vol = (geometry->node[iPoint]->GetVolume() + - geometry->node[iPoint]->GetPeriodicVolume()); - Delta = nodes->GetDelta_Time(iPoint) / Vol; - - Res_TruncError = nodes->GetResTruncError(iPoint); - Residual = LinSysRes.GetBlock(iPoint); - - if (!adjoint) { - for (iVar = 0; iVar < nVar; iVar++) { - Res = Residual[iVar] + Res_TruncError[iVar]; - 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()); - } - } - - } - - /*--- MPI solution ---*/ - - InitiateComms(geometry, config, SOLUTION); - CompleteComms(geometry, config, SOLUTION); - - /*--- Compute the root mean square residual ---*/ +template +void CEulerSolver::Explicit_Iteration(CGeometry *geometry, CSolver **solver_container, + CConfig *config, unsigned short iRKStep) { - SetResidual_RMS(geometry, config); + static_assert(IntegrationType == CLASSICAL_RK4_EXPLICIT || + IntegrationType == RUNGE_KUTTA_EXPLICIT || + IntegrationType == EULER_EXPLICIT, ""); - /*--- For verification cases, compute the global error metrics. ---*/ + const bool adjoint = config->GetContinuous_Adjoint(); - ComputeVerificationError(geometry, config); + const su2double RK_AlphaCoeff = config->Get_Alpha_RKStep(iRKStep); -} + /*--- Hard-coded classical RK4 coefficients. Will be added to config. ---*/ + const su2double RK_FuncCoeff[] = {1.0/6.0, 1.0/3.0, 1.0/3.0, 1.0/6.0}; + const su2double RK_TimeCoeff[] = {0.5, 0.5, 1.0, 1.0}; -void CEulerSolver::ClassicalRK4_Iteration(CGeometry *geometry, CSolver **solver_container, - CConfig *config, unsigned short iRKStep) { - su2double *Residual, *Res_TruncError, Vol, Delta, Res, tmp_time, tmp_func; - unsigned short iVar; - unsigned long iPoint; - /*--- Hard-coded classical RK4 coefficients. Will be added to config. ---*/ - su2double RK_FuncCoeff[4] = {1.0/6.0, 1.0/3.0, 1.0/3.0, 1.0/6.0}; - su2double RK_TimeCoeff[4] = {0.5, 0.5, 1.0, 1.0}; + /*--- Start OpenMP parallel section. ---*/ - bool adjoint = config->GetContinuous_Adjoint(); + SU2_OMP_PARALLEL + { + /*--- Set shared residual variables to 0 and declare + * local ones for current thread to work on. ---*/ - for (iVar = 0; iVar < nVar; iVar++) { + SU2_OMP_MASTER + for (unsigned short iVar = 0; iVar < nVar; iVar++) { SetRes_RMS(iVar, 0.0); SetRes_Max(iVar, 0.0, 0); } + SU2_OMP_BARRIER - /*--- Update the solution ---*/ + su2double resMax[MAXNVAR] = {0.0}, resRMS[MAXNVAR] = {0.0}; + const su2double* coordMax[MAXNVAR] = {nullptr}; + unsigned long idxMax[MAXNVAR] = {0}; - for (iPoint = 0; iPoint < nPointDomain; iPoint++) { + /*--- Update the solution and residuals ---*/ - Vol = (geometry->node[iPoint]->GetVolume() + - geometry->node[iPoint]->GetPeriodicVolume()); - Delta = nodes->GetDelta_Time(iPoint) / Vol; + SU2_OMP(for schedule(static,omp_chunk_size) nowait) + for (unsigned long iPoint = 0; iPoint < nPointDomain; iPoint++) { - Res_TruncError = nodes->GetResTruncError(iPoint); - Residual = LinSysRes.GetBlock(iPoint); + su2double Vol = geometry->node[iPoint]->GetVolume() + geometry->node[iPoint]->GetPeriodicVolume(); + su2double Delta = nodes->GetDelta_Time(iPoint) / Vol; - tmp_time = -1.0*RK_TimeCoeff[iRKStep]*Delta; - tmp_func = -1.0*RK_FuncCoeff[iRKStep]*Delta; + const su2double* Res_TruncError = nodes->GetResTruncError(iPoint); + const su2double* Residual = LinSysRes.GetBlock(iPoint); if (!adjoint) { - for (iVar = 0; iVar < nVar; iVar++) { - Res = Residual[iVar] + Res_TruncError[iVar]; - if (iRKStep < 3) { - /* Base Solution Update */ - nodes->AddSolution(iPoint,iVar, tmp_time*Res); - - /* New Solution Update */ - nodes->AddSolution_New(iPoint,iVar, tmp_func*Res); - } else { - nodes->SetSolution(iPoint, iVar, nodes->GetSolution_New(iPoint, iVar) + tmp_func*Res); - } - - AddRes_RMS(iVar, Res*Res); - AddRes_Max(iVar, fabs(Res), geometry->node[iPoint]->GetGlobalIndex(), geometry->node[iPoint]->GetCoord()); - } - } - - } + for (unsigned short iVar = 0; iVar < nVar; iVar++) { - /*--- MPI solution ---*/ + su2double Res = Residual[iVar] + Res_TruncError[iVar]; - InitiateComms(geometry, config, SOLUTION); - CompleteComms(geometry, config, SOLUTION); + /*--- "Static" switch which should be optimized at compile time. ---*/ + switch(IntegrationType) { - /*--- Compute the root mean square residual ---*/ + case CLASSICAL_RK4_EXPLICIT: + nodes->AddSolution(iPoint, iVar, -Res*Delta*RK_AlphaCoeff); + break; - SetResidual_RMS(geometry, config); + case RUNGE_KUTTA_EXPLICIT: + { + su2double tmp_time = -1.0*RK_TimeCoeff[iRKStep]*Delta; + su2double tmp_func = -1.0*RK_FuncCoeff[iRKStep]*Delta; - /*--- For verification cases, compute the global error metrics. ---*/ + if (iRKStep < 3) { + /* Base Solution Update */ + nodes->AddSolution(iPoint,iVar, tmp_time*Res); - ComputeVerificationError(geometry, config); + /* New Solution Update */ + nodes->AddSolution_New(iPoint,iVar, tmp_func*Res); + } else { + nodes->SetSolution(iPoint, iVar, nodes->GetSolution_New(iPoint, iVar) + tmp_func*Res); + } + } + break; -} + case EULER_EXPLICIT: + nodes->AddSolution(iPoint,iVar, -Res*Delta); + break; + } -void CEulerSolver::ExplicitEuler_Iteration(CGeometry *geometry, CSolver **solver_container, CConfig *config) { - su2double *local_Residual, *local_Res_TruncError, Vol, Delta, Res; - unsigned short iVar; - unsigned long iPoint; + resRMS[iVar] += Res*Res; + if (fabs(Res) > resMax[iVar]) { + resMax[iVar] = fabs(Res); + idxMax[iVar] = iPoint; + coordMax[iVar] = geometry->node[iPoint]->GetCoord(); + } + } + } + } + if (!adjoint) { + SU2_OMP_CRITICAL + for (unsigned short iVar = 0; iVar < nVar; iVar++) { + AddRes_RMS(iVar, resRMS[iVar]); + AddRes_Max(iVar, resMax[iVar], idxMax[iVar], coordMax[iVar]); + } + } + SU2_OMP_BARRIER - bool adjoint = config->GetContinuous_Adjoint(); + SU2_OMP_MASTER + { + /*--- MPI solution ---*/ - for (iVar = 0; iVar < nVar; iVar++) { - SetRes_RMS(iVar, 0.0); - SetRes_Max(iVar, 0.0, 0); - } + InitiateComms(geometry, config, SOLUTION); + CompleteComms(geometry, config, SOLUTION); - /*--- Update the solution ---*/ + /*--- Compute the root mean square residual ---*/ - for (iPoint = 0; iPoint < nPointDomain; iPoint++) { - Vol = (geometry->node[iPoint]->GetVolume() + - geometry->node[iPoint]->GetPeriodicVolume()); - Delta = nodes->GetDelta_Time(iPoint) / Vol; + SetResidual_RMS(geometry, config); - 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]; - nodes->AddSolution(iPoint,iVar, -Res*Delta); - AddRes_RMS(iVar, Res*Res); - AddRes_Max(iVar, fabs(Res), geometry->node[iPoint]->GetGlobalIndex(), geometry->node[iPoint]->GetCoord()); - } - } + /*--- For verification cases, compute the global error metrics. ---*/ + ComputeVerificationError(geometry, config); } - /*--- MPI solution ---*/ + } // end SU2_OMP_PARALLEL +} - InitiateComms(geometry, config, SOLUTION); - CompleteComms(geometry, config, SOLUTION); +void CEulerSolver::ExplicitRK_Iteration(CGeometry *geometry, CSolver **solver_container, + CConfig *config, unsigned short iRKStep) { - /*--- Compute the root mean square residual ---*/ + Explicit_Iteration(geometry, solver_container, config, iRKStep); +} - SetResidual_RMS(geometry, config); +void CEulerSolver::ClassicalRK4_Iteration(CGeometry *geometry, CSolver **solver_container, + CConfig *config, unsigned short iRKStep) { - /*--- For verification cases, compute the global error metrics. ---*/ + Explicit_Iteration(geometry, solver_container, config, iRKStep); +} - ComputeVerificationError(geometry, config); +void CEulerSolver::ExplicitEuler_Iteration(CGeometry *geometry, CSolver **solver_container, CConfig *config) { + Explicit_Iteration(geometry, solver_container, config, 0); } void CEulerSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver_container, CConfig *config) { diff --git a/SU2_CFD/src/solvers/CSolver.cpp b/SU2_CFD/src/solvers/CSolver.cpp index 7a461cca1b25..51a09d576787 100644 --- a/SU2_CFD/src/solvers/CSolver.cpp +++ b/SU2_CFD/src/solvers/CSolver.cpp @@ -2548,8 +2548,8 @@ void CSolver::SetResidual_RMS(CGeometry *geometry, CConfig *config) { /*--- Set the L2 Norm residual in all the processors ---*/ - sbuf_residual = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) sbuf_residual[iVar] = 0.0; - rbuf_residual = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) rbuf_residual[iVar] = 0.0; + sbuf_residual = new su2double[nVar]; + rbuf_residual = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) sbuf_residual[iVar] = GetRes_RMS(iVar); @@ -2559,16 +2559,16 @@ void CSolver::SetResidual_RMS(CGeometry *geometry, CConfig *config) { SU2_MPI::Allreduce(sbuf_residual, rbuf_residual, nVar, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); SU2_MPI::Allreduce(&Local_nPointDomain, &Global_nPointDomain, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); - } else { - + } + else { /*--- Reduced MPI comms have been requested. Use a local residual only. ---*/ - for (iVar = 0; iVar < nVar; iVar++) rbuf_residual[iVar] = sbuf_residual[iVar]; + for (iVar = 0; iVar < nVar; iVar++) + rbuf_residual[iVar] = sbuf_residual[iVar]; Global_nPointDomain = geometry->GetnPointDomain(); } - for (iVar = 0; iVar < nVar; iVar++) { if (rbuf_residual[iVar] != rbuf_residual[iVar]) { @@ -2586,13 +2586,13 @@ void CSolver::SetResidual_RMS(CGeometry *geometry, CConfig *config) { if (config->GetComm_Level() == COMM_FULL) { - sbuf_residual = new su2double [nVar]; for (iVar = 0; iVar < nVar; iVar++) sbuf_residual[iVar] = 0.0; - sbuf_point = new unsigned long [nVar]; for (iVar = 0; iVar < nVar; iVar++) sbuf_point[iVar] = 0; - sbuf_coord = new su2double[nVar*nDim]; for (iVar = 0; iVar < nVar*nDim; iVar++) sbuf_coord[iVar] = 0.0; + sbuf_residual = new su2double [nVar](); + sbuf_point = new unsigned long [nVar](); + sbuf_coord = new su2double[nVar*nDim](); - rbuf_residual = new su2double [nProcessor*nVar]; for (iVar = 0; iVar < nProcessor*nVar; iVar++) rbuf_residual[iVar] = 0.0; - rbuf_point = new unsigned long [nProcessor*nVar]; for (iVar = 0; iVar < nProcessor*nVar; iVar++) rbuf_point[iVar] = 0; - rbuf_coord = new su2double[nProcessor*nVar*nDim]; for (iVar = 0; iVar < nProcessor*nVar*nDim; iVar++) rbuf_coord[iVar] = 0.0; + rbuf_residual = new su2double [nProcessor*nVar](); + rbuf_point = new unsigned long [nProcessor*nVar](); + rbuf_coord = new su2double[nProcessor*nVar*nDim](); for (iVar = 0; iVar < nVar; iVar++) { sbuf_residual[iVar] = GetRes_Max(iVar); From 684f39bc2568b062e85522f56b7509ab43e0e33d Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Thu, 30 Jan 2020 12:56:19 +0000 Subject: [PATCH 053/118] wrong order of cases in switch --- SU2_CFD/src/solvers/CEulerSolver.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 0fef27fabe8e..2442d1d6ef68 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -4939,12 +4939,16 @@ void CEulerSolver::Explicit_Iteration(CGeometry *geometry, CSolver **solver_cont /*--- "Static" switch which should be optimized at compile time. ---*/ switch(IntegrationType) { - case CLASSICAL_RK4_EXPLICIT: - nodes->AddSolution(iPoint, iVar, -Res*Delta*RK_AlphaCoeff); + case EULER_EXPLICIT: + nodes->AddSolution(iPoint,iVar, -Res*Delta); break; case RUNGE_KUTTA_EXPLICIT: - { + nodes->AddSolution(iPoint, iVar, -Res*Delta*RK_AlphaCoeff); + break; + + case CLASSICAL_RK4_EXPLICIT: + { su2double tmp_time = -1.0*RK_TimeCoeff[iRKStep]*Delta; su2double tmp_func = -1.0*RK_FuncCoeff[iRKStep]*Delta; @@ -4957,12 +4961,8 @@ void CEulerSolver::Explicit_Iteration(CGeometry *geometry, CSolver **solver_cont } else { nodes->SetSolution(iPoint, iVar, nodes->GetSolution_New(iPoint, iVar) + tmp_func*Res); } - } - break; - - case EULER_EXPLICIT: - nodes->AddSolution(iPoint,iVar, -Res*Delta); - break; + } + break; } resRMS[iVar] += Res*Res; From a5427c073c96091f0553f829f8a6b541b24c23f1 Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Thu, 30 Jan 2020 13:52:22 +0000 Subject: [PATCH 054/118] parallel implicit Euler iteration --- SU2_CFD/include/solvers/CEulerSolver.hpp | 8 +- SU2_CFD/src/solvers/CEulerSolver.cpp | 198 +++++++++++++---------- SU2_CFD/src/solvers/CNSSolver.cpp | 11 -- 3 files changed, 119 insertions(+), 98 deletions(-) diff --git a/SU2_CFD/include/solvers/CEulerSolver.hpp b/SU2_CFD/include/solvers/CEulerSolver.hpp index 751132ff59a1..a90bae05dffa 100644 --- a/SU2_CFD/include/solvers/CEulerSolver.hpp +++ b/SU2_CFD/include/solvers/CEulerSolver.hpp @@ -243,7 +243,6 @@ class CEulerSolver : public CSolver { *Surface_HF_Visc, /*!< \brief Total (integrated) heat flux for each monitored surface. */ *Surface_MaxHF_Visc; /*!< \brief Maximum heat flux for each monitored surface. */ - su2double **LowMach_Preconditioner; /*!< \brief Auxiliary vector for storing the inverse of Roe-turkel preconditioner. */ bool space_centered, /*!< \brief True if space centered scheeme used. */ euler_implicit, /*!< \brief True if euler implicit scheme used. */ least_squares; /*!< \brief True if computing gradients by least squares. */ @@ -606,10 +605,13 @@ class CEulerSolver : public CSolver { /*! * \brief Compute the preconditioner for convergence acceleration by Roe-Turkel method. - * \param[in] iPoint - Index of the grid point * \param[in] config - Definition of the particular problem. + * \param[in] iPoint - Index of the grid point. + * \param[in] delta - Volume over delta t. + * \param[in,out] preconditioner - The preconditioner matrix, must be allocated outside. */ - void SetPreconditioner(CConfig *config, unsigned long iPoint) final; + void SetPreconditioner(const CConfig *config, unsigned long iPoint, + su2double delta, su2double** preconditioner) const; /*! * \brief Compute the undivided laplacian for the solution, except the energy equation. diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 2442d1d6ef68..2e9d8cfec212 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -84,7 +84,6 @@ CEulerSolver::CEulerSolver(void) : CSolver() { /*--- Numerical methods array initialization ---*/ - LowMach_Preconditioner = NULL; CharacPrimVar = NULL; DonorPrimVar = NULL; DonorGlobalIndex = NULL; @@ -160,7 +159,6 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short su2double StaticEnergy, Density, Velocity2, Pressure, Temperature; unsigned short nZone = geometry->GetnZone(); bool restart = (config->GetRestart() || config->GetRestart_Flow()); - bool roe_turkel = (config->GetKind_Upwind_Flow() == TURKEL); bool rans = (config->GetKind_Turb_Model() != NONE); unsigned short direct_diff = config->GetDirectDiff(); int Unst_RestartIter = 0; @@ -171,8 +169,6 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ dynamic_grid = config->GetDynamic_Grid(); - bool low_mach_prec = config->Low_Mach_Preconditioning(); - bool adjoint = (config->GetContinuous_Adjoint()) || (config->GetDiscrete_Adjoint()); bool fsi = config->GetFSI_Simulation(); bool multizone = config->GetMultizone_Problem(); @@ -265,7 +261,6 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short iPoint_UndLapl = NULL; jPoint_UndLapl = NULL; - LowMach_Preconditioner = NULL; CharacPrimVar = NULL; DonorPrimVar = NULL; DonorGlobalIndex = NULL; ActDisk_DeltaP = NULL; ActDisk_DeltaT = NULL; @@ -405,14 +400,6 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short jPoint_UndLapl = new su2double [nPoint]; } - /*--- Define some auxiliary vectors related to low-speed preconditioning ---*/ - - if (roe_turkel || low_mach_prec) { - LowMach_Preconditioner = new su2double* [nVar]; - for (iVar = 0; iVar < nVar; iVar ++) - LowMach_Preconditioner[iVar] = new su2double[nVar]; - } - /*--- Initialize the solution and right hand side vectors for storing the residuals and updating the solution (always needed even for explicit schemes). ---*/ @@ -939,12 +926,6 @@ CEulerSolver::~CEulerSolver(void) { delete [] Exhaust_Pressure; delete [] Exhaust_Temperature; - if (LowMach_Preconditioner != NULL) { - for (iVar = 0; iVar < nVar; iVar ++) - delete [] LowMach_Preconditioner[iVar]; - delete [] LowMach_Preconditioner; - } - if (CPressure != NULL) { for (iMarker = 0; iMarker < nMarker; iMarker++) delete [] CPressure[iMarker]; @@ -4965,6 +4946,7 @@ void CEulerSolver::Explicit_Iteration(CGeometry *geometry, CSolver **solver_cont break; } + /*--- Update residual information for current thread. ---*/ resRMS[iVar] += Res*Res; if (fabs(Res) > resMax[iVar]) { resMax[iVar] = fabs(Res); @@ -4975,10 +4957,11 @@ void CEulerSolver::Explicit_Iteration(CGeometry *geometry, CSolver **solver_cont } } if (!adjoint) { + /*--- Reduce residual information over all threads in this rank. ---*/ SU2_OMP_CRITICAL for (unsigned short iVar = 0; iVar < nVar; iVar++) { AddRes_RMS(iVar, resRMS[iVar]); - AddRes_Max(iVar, resMax[iVar], idxMax[iVar], coordMax[iVar]); + AddRes_Max(iVar, resMax[iVar], geometry->node[idxMax[iVar]]->GetGlobalIndex(), coordMax[iVar]); } } SU2_OMP_BARRIER @@ -5021,45 +5004,58 @@ void CEulerSolver::ExplicitEuler_Iteration(CGeometry *geometry, CSolver **solver void CEulerSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver_container, CConfig *config) { - unsigned short iVar, jVar; - unsigned long iPoint, total_index, IterLinSol = 0; - su2double Delta, *local_Res_TruncError, Vol; + const bool adjoint = config->GetContinuous_Adjoint(); + const bool roe_turkel = config->GetKind_Upwind_Flow() == TURKEL; + const bool low_mach_prec = config->Low_Mach_Preconditioning(); - bool adjoint = config->GetContinuous_Adjoint(); - bool roe_turkel = config->GetKind_Upwind_Flow() == TURKEL; - bool low_mach_prec = config->Low_Mach_Preconditioning(); + /*--- Start OpenMP parallel section. ---*/ - /*--- Set maximum residual to zero ---*/ + SU2_OMP_PARALLEL + { + /*--- Local matrix for preconditioning. ---*/ + su2double** LowMachPrec = nullptr; + if (roe_turkel || low_mach_prec) { + LowMachPrec = new su2double* [nVar]; + for(unsigned short iVar = 0; iVar < nVar; ++iVar) + LowMachPrec[iVar] = new su2double [nVar]; + } - for (iVar = 0; iVar < nVar; iVar++) { + /*--- Set shared residual variables to 0 and declare + * local ones for current thread to work on. ---*/ + + SU2_OMP_MASTER + for (unsigned short iVar = 0; iVar < nVar; iVar++) { SetRes_RMS(iVar, 0.0); SetRes_Max(iVar, 0.0, 0); } + SU2_OMP_BARRIER + + su2double resMax[MAXNVAR] = {0.0}, resRMS[MAXNVAR] = {0.0}; + const su2double* coordMax[MAXNVAR] = {nullptr}; + unsigned long idxMax[MAXNVAR] = {0}; /*--- Build implicit system ---*/ - for (iPoint = 0; iPoint < nPointDomain; iPoint++) { + SU2_OMP(for schedule(static,omp_chunk_size) nowait) + for (unsigned long iPoint = 0; iPoint < nPointDomain; iPoint++) { /*--- Read the residual ---*/ - local_Res_TruncError = nodes->GetResTruncError(iPoint); + su2double* local_Res_TruncError = nodes->GetResTruncError(iPoint); /*--- Read the volume ---*/ - Vol = (geometry->node[iPoint]->GetVolume() + - geometry->node[iPoint]->GetPeriodicVolume()); + su2double Vol = geometry->node[iPoint]->GetVolume() + geometry->node[iPoint]->GetPeriodicVolume(); /*--- Modify matrix diagonal to assure diagonal dominance ---*/ - if (nodes->GetDelta_Time(iPoint) != 0.0) { - Delta = Vol / nodes->GetDelta_Time(iPoint); + + su2double Delta = Vol / nodes->GetDelta_Time(iPoint); + if (roe_turkel || low_mach_prec) { - SetPreconditioner(config, iPoint); - for (iVar = 0; iVar < nVar; iVar ++ ) - for (jVar = 0; jVar < nVar; jVar ++ ) - LowMach_Preconditioner[iVar][jVar] = Delta*LowMach_Preconditioner[iVar][jVar]; - Jacobian.AddBlock2Diag(iPoint, LowMach_Preconditioner); + SetPreconditioner(config, iPoint, Delta, LowMachPrec); + Jacobian.AddBlock2Diag(iPoint, LowMachPrec); } else { Jacobian.AddVal2Diag(iPoint, Delta); @@ -5067,76 +5063,104 @@ void CEulerSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver } else { Jacobian.SetVal2Diag(iPoint, 1.0); - for (iVar = 0; iVar < nVar; iVar++) { - total_index = iPoint*nVar + iVar; - LinSysRes[total_index] = 0.0; + for (unsigned short iVar = 0; iVar < nVar; iVar++) { + LinSysRes[iPoint*nVar + iVar] = 0.0; local_Res_TruncError[iVar] = 0.0; } } /*--- Right hand side of the system (-Residual) and initial guess (x = 0) ---*/ - for (iVar = 0; iVar < nVar; iVar++) { - total_index = iPoint*nVar + iVar; + for (unsigned short iVar = 0; iVar < nVar; iVar++) { + unsigned long total_index = iPoint*nVar + iVar; LinSysRes[total_index] = - (LinSysRes[total_index] + local_Res_TruncError[iVar]); LinSysSol[total_index] = 0.0; - AddRes_RMS(iVar, LinSysRes[total_index]*LinSysRes[total_index]); - AddRes_Max(iVar, fabs(LinSysRes[total_index]), geometry->node[iPoint]->GetGlobalIndex(), geometry->node[iPoint]->GetCoord()); + + su2double Res = fabs(LinSysRes[total_index]); + resRMS[iVar] += Res*Res; + if (fabs(Res) > resMax[iVar]) { + resMax[iVar] = fabs(Res); + idxMax[iVar] = iPoint; + coordMax[iVar] = geometry->node[iPoint]->GetCoord(); + } } } + SU2_OMP_CRITICAL + for (unsigned short iVar = 0; iVar < nVar; iVar++) { + AddRes_RMS(iVar, resRMS[iVar]); + AddRes_Max(iVar, resMax[iVar], geometry->node[idxMax[iVar]]->GetGlobalIndex(), coordMax[iVar]); + } /*--- Initialize residual and solution at the ghost points ---*/ - for (iPoint = nPointDomain; iPoint < nPoint; iPoint++) { - for (iVar = 0; iVar < nVar; iVar++) { - total_index = iPoint*nVar + iVar; - LinSysRes[total_index] = 0.0; - LinSysSol[total_index] = 0.0; - } + SU2_OMP(sections nowait) + { + SU2_OMP(section) + for (unsigned long iPoint = nPointDomain; iPoint < nPoint; iPoint++) + LinSysRes.SetBlock_Zero(iPoint); + + SU2_OMP(section) + for (unsigned long iPoint = nPointDomain; iPoint < nPoint; iPoint++) + LinSysSol.SetBlock_Zero(iPoint); } - /*--- Solve or smooth the linear system ---*/ + /*--- Free local preconditioner. ---*/ + if (LowMachPrec) { + for(unsigned short iVar = 0; iVar < nVar; ++iVar) + delete [] LowMachPrec[iVar]; + delete [] LowMachPrec; + } + + } // end SU2_OMP_PARALLEL - IterLinSol = System.Solve(Jacobian, LinSysRes, LinSysSol, geometry, config); + /// TODO: We should be able to call the linear solver inside the parallel region. - /*--- Store the value of the residual. ---*/ + /*--- Solve or smooth the linear system. ---*/ + auto IterLinSol = System.Solve(Jacobian, LinSysRes, LinSysSol, geometry, config); SetResLinSolver(System.GetResidual()); + SetIterLinSolver(IterLinSol); - /*--- The the number of iterations of the linear solver ---*/ + /*--- Go back to parallel. ---*/ - SetIterLinSolver(IterLinSol); + SU2_OMP_PARALLEL + { ComputeUnderRelaxationFactor(solver_container, config); /*--- Update solution (system written in terms of increments) ---*/ if (!adjoint) { - for (iPoint = 0; iPoint < nPointDomain; iPoint++) { - for (iVar = 0; iVar < nVar; iVar++) { + SU2_OMP_FOR_STAT(omp_chunk_size) + for (unsigned long iPoint = 0; iPoint < nPointDomain; iPoint++) { + for (unsigned short iVar = 0; iVar < nVar; iVar++) { nodes->AddSolution(iPoint, iVar, nodes->GetUnderRelaxation(iPoint)*LinSysSol[iPoint*nVar+iVar]); } } } - for (unsigned short iPeriodic = 1; iPeriodic <= config->GetnMarker_Periodic()/2; iPeriodic++) { - InitiatePeriodicComms(geometry, config, iPeriodic, PERIODIC_IMPLICIT); - CompletePeriodicComms(geometry, config, iPeriodic, PERIODIC_IMPLICIT); - } + SU2_OMP_MASTER + { + for (unsigned short iPeriodic = 1; iPeriodic <= config->GetnMarker_Periodic()/2; iPeriodic++) { + InitiatePeriodicComms(geometry, config, iPeriodic, PERIODIC_IMPLICIT); + CompletePeriodicComms(geometry, config, iPeriodic, PERIODIC_IMPLICIT); + } - /*--- MPI solution ---*/ + /*--- MPI solution ---*/ - InitiateComms(geometry, config, SOLUTION); - CompleteComms(geometry, config, SOLUTION); + InitiateComms(geometry, config, SOLUTION); + CompleteComms(geometry, config, SOLUTION); - /*--- Compute the root mean square residual ---*/ + /*--- Compute the root mean square residual ---*/ - SetResidual_RMS(geometry, config); + SetResidual_RMS(geometry, config); - /*--- For verification cases, compute the global error metrics. ---*/ + /*--- For verification cases, compute the global error metrics. ---*/ - ComputeVerificationError(geometry, config); + ComputeVerificationError(geometry, config); + } + } // end SU2_OMP_PARALLEL } void CEulerSolver::ComputeUnderRelaxationFactor(CSolver **solver_container, CConfig *config) { @@ -5144,11 +5168,13 @@ void CEulerSolver::ComputeUnderRelaxationFactor(CSolver **solver_container, CCon /* Loop over the solution update given by relaxing the linear system for this nonlinear iteration. */ - su2double localUnderRelaxation = 1.0; const su2double allowableRatio = 0.2; + + SU2_OMP_FOR_STAT(omp_chunk_size) for (unsigned long iPoint = 0; iPoint < nPointDomain; iPoint++) { - localUnderRelaxation = 1.0; + su2double localUnderRelaxation = 1.0; + for (unsigned short iVar = 0; iVar < nVar; iVar++) { /* We impose a limit on the maximum percentage that the @@ -5224,7 +5250,9 @@ void CEulerSolver::SetPrimitive_Limiter(CGeometry *geometry, CConfig *config) { *geometry, *config, 0, nPrimVarGrad, primitives, gradient, primMin, primMax, limiter); } -void CEulerSolver::SetPreconditioner(CConfig *config, unsigned long iPoint) { +void CEulerSolver::SetPreconditioner(const CConfig *config, unsigned long iPoint, + su2double delta, su2double** preconditioner) const { + unsigned short iDim, jDim, iVar, jVar; su2double local_Mach, rho, enthalpy, soundspeed, sq_vel; su2double *U_i = NULL; @@ -5248,30 +5276,32 @@ void CEulerSolver::SetPreconditioner(CConfig *config, unsigned long iPoint) { sq_vel = nodes->GetVelocity2(iPoint); /*---Calculating the inverse of the preconditioning matrix that multiplies the time derivative */ - LowMach_Preconditioner[0][0] = 0.5*sq_vel; - LowMach_Preconditioner[0][nVar-1] = 1.0; + preconditioner[0][0] = 0.5*sq_vel; + preconditioner[0][nVar-1] = 1.0; for (iDim = 0; iDim < nDim; iDim ++) - LowMach_Preconditioner[0][1+iDim] = -1.0*U_i[iDim+1]/rho; + preconditioner[0][1+iDim] = -1.0*U_i[iDim+1]/rho; for (iDim = 0; iDim < nDim; iDim ++) { - LowMach_Preconditioner[iDim+1][0] = 0.5*sq_vel*U_i[iDim+1]/rho; - LowMach_Preconditioner[iDim+1][nVar-1] = U_i[iDim+1]/rho; + preconditioner[iDim+1][0] = 0.5*sq_vel*U_i[iDim+1]/rho; + preconditioner[iDim+1][nVar-1] = U_i[iDim+1]/rho; for (jDim = 0; jDim < nDim; jDim ++) { - LowMach_Preconditioner[iDim+1][1+jDim] = -1.0*U_i[jDim+1]/rho*U_i[iDim+1]/rho; + preconditioner[iDim+1][1+jDim] = -1.0*U_i[jDim+1]/rho*U_i[iDim+1]/rho; } } - LowMach_Preconditioner[nVar-1][0] = 0.5*sq_vel*enthalpy; - LowMach_Preconditioner[nVar-1][nVar-1] = enthalpy; + preconditioner[nVar-1][0] = 0.5*sq_vel*enthalpy; + preconditioner[nVar-1][nVar-1] = enthalpy; for (iDim = 0; iDim < nDim; iDim ++) - LowMach_Preconditioner[nVar-1][1+iDim] = -1.0*U_i[iDim+1]/rho*enthalpy; + preconditioner[nVar-1][1+iDim] = -1.0*U_i[iDim+1]/rho*enthalpy; for (iVar = 0; iVar < nVar; iVar ++ ) { for (jVar = 0; jVar < nVar; jVar ++ ) { - LowMach_Preconditioner[iVar][jVar] = (parameter - 1.0) * ((Gamma-1.0)/(soundspeed*soundspeed))*LowMach_Preconditioner[iVar][jVar]; + preconditioner[iVar][jVar] = (parameter - 1.0) * ((Gamma-1.0)/(soundspeed*soundspeed))*preconditioner[iVar][jVar]; if (iVar == jVar) - LowMach_Preconditioner[iVar][iVar] += 1.0; + preconditioner[iVar][iVar] += 1.0; + + preconditioner[iVar][jVar] *= delta; } } diff --git a/SU2_CFD/src/solvers/CNSSolver.cpp b/SU2_CFD/src/solvers/CNSSolver.cpp index dd90b70efed6..d1c5b85fd301 100644 --- a/SU2_CFD/src/solvers/CNSSolver.cpp +++ b/SU2_CFD/src/solvers/CNSSolver.cpp @@ -85,9 +85,6 @@ CNSSolver::CNSSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ dynamic_grid = config->GetDynamic_Grid(); - bool roe_turkel = (config->GetKind_Upwind_Flow() == TURKEL); - bool low_mach_prec = config->Low_Mach_Preconditioning(); - bool adjoint = (config->GetContinuous_Adjoint()) || (config->GetDiscrete_Adjoint()); string filename_ = "flow"; @@ -271,14 +268,6 @@ CNSSolver::CNSSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) jPoint_UndLapl = new su2double [nPoint]; } - /*--- Define some auxiliary vectors related to low-speed preconditioning ---*/ - - if (roe_turkel || low_mach_prec) { - LowMach_Preconditioner = new su2double* [nVar]; - for (iVar = 0; iVar < nVar; iVar ++) - LowMach_Preconditioner[iVar] = new su2double[nVar]; - } - /*--- Initialize the solution and right hand side vectors for storing the residuals and updating the solution (always needed even for explicit schemes). ---*/ From 2f823584760ec88c06aaeb2a5194945bf19616fa Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Thu, 30 Jan 2020 14:13:19 +0000 Subject: [PATCH 055/118] more cleanup of turbo stuff --- SU2_CFD/src/solvers/CEulerSolver.cpp | 159 ++++++++------------------- 1 file changed, 45 insertions(+), 114 deletions(-) diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 2e9d8cfec212..0d238b1e06c2 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -4582,8 +4582,7 @@ void CEulerSolver::Momentum_Forces(CGeometry *geometry, CConfig *config) { for (iMarker_Monitoring = 0; iMarker_Monitoring < config->GetnMarker_Monitoring(); iMarker_Monitoring++) { Surface_CL_Mnt[iMarker_Monitoring] = 0.0; Surface_CD_Mnt[iMarker_Monitoring] = 0.0; Surface_CSF_Mnt[iMarker_Monitoring] = 0.0; Surface_CEff_Mnt[iMarker_Monitoring] = 0.0; - Surface_CFx_Mnt[iMarker_Monitoring] = 0.0; Surface_CFy_Mnt[iMarker_Monitoring] = 0.0; - Surface_CFz_Mnt[iMarker_Monitoring] = 0.0; + Surface_CFx_Mnt[iMarker_Monitoring] = 0.0; Surface_CFy_Mnt[iMarker_Monitoring] = 0.0; Surface_CFz_Mnt[iMarker_Monitoring] = 0.0; Surface_CMx_Mnt[iMarker_Monitoring] = 0.0; Surface_CMy_Mnt[iMarker_Monitoring] = 0.0; Surface_CMz_Mnt[iMarker_Monitoring] = 0.0; } @@ -6200,7 +6199,8 @@ void CEulerSolver::GetPower_Properties(CGeometry *geometry, CConfig *config, uns void CEulerSolver::SetActDisk_BCThrust(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh, bool Output) { - su2double Massflow = 0.0 , Target_Massflow = 0.0, DragMinusThrust = 0.0 , Target_DragMinusThrust = 0.0, Target_NetThrust = 0.0, BCThrust = 0.0, BCThrust_inc = 0.0; + su2double Massflow = 0.0 , Target_Massflow = 0.0, DragMinusThrust = 0.0 , + Target_DragMinusThrust = 0.0, Target_NetThrust = 0.0, BCThrust = 0.0, BCThrust_inc = 0.0; unsigned short iDim, iMarker; unsigned long iVertex, iPoint; su2double *V_inlet = NULL, Pressure, @@ -6633,11 +6633,7 @@ void CEulerSolver::SetActDisk_BCThrust(CGeometry *geometry, CSolver **solver_con if (!ActDisk_Info) config->SetInitial_BCThrust(0.0); MyBCThrust = config->GetInitial_BCThrust(); -#ifdef HAVE_MPI SU2_MPI::Allreduce(&MyBCThrust, &BCThrust, 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD); -#else - BCThrust = MyBCThrust; -#endif config->SetInitial_BCThrust(BCThrust); } @@ -8212,18 +8208,18 @@ void CEulerSolver::BC_TurboRiemann(CGeometry *geometry, CSolver **solver_contain su2double *gridVel; su2double *V_boundary, *V_domain, *S_boundary, *S_domain; su2double AverageEnthalpy, AverageEntropy; - unsigned short iZone = config->GetiZone(); - bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - string Marker_Tag = config->GetMarker_All_TagBound(val_marker); + unsigned short iZone = config->GetiZone(); + bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + string Marker_Tag = config->GetMarker_All_TagBound(val_marker); unsigned short nSpanWiseSections = geometry->GetnSpanWiseSections(config->GetMarker_All_TurbomachineryFlag(val_marker)); - bool viscous = config->GetViscous(); + bool viscous = config->GetViscous(); bool gravity = (config->GetGravityForce()); bool tkeNeeded = (config->GetKind_Turb_Model() == SST) || (config->GetKind_Turb_Model() == SST_SUST); su2double *Normal, *turboNormal, *UnitNormal, *FlowDirMix, FlowDirMixMag, *turboVelocity; Normal = new su2double[nDim]; - turboNormal = new su2double[nDim]; - UnitNormal = new su2double[nDim]; + turboNormal = new su2double[nDim]; + UnitNormal = new su2double[nDim]; Velocity_i = new su2double[nDim]; Velocity_b = new su2double[nDim]; @@ -12125,9 +12121,8 @@ void CEulerSolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConfig /*--- Delete the class memory that is used to load the restart. ---*/ - if (Restart_Vars != NULL) delete [] Restart_Vars; - if (Restart_Data != NULL) delete [] Restart_Data; - Restart_Vars = NULL; Restart_Data = NULL; + delete [] Restart_Vars; Restart_Vars = nullptr; + delete [] Restart_Data; Restart_Data = nullptr; } @@ -12212,14 +12207,9 @@ void CEulerSolver::PreprocessAverage(CSolver **solver, CGeometry *geometry, CCon TurboVelocity = new su2double[nDim]; TotalAreaVelocity = new su2double[nDim]; -#ifdef HAVE_MPI - su2double MyTotalAreaDensity, MyTotalAreaPressure; - su2double *MyTotalAreaVelocity = NULL; -#endif for (iSpan= 0; iSpan < nSpanWiseSections; iSpan++){ - for (iDim=0; iDimGetnMarker_All(); iMarker++){ @@ -13120,7 +13072,6 @@ void CEulerSolver::GatherInOutAverageValues(CConfig *config, CGeometry *geometry omegaIn = OmegaIn[iMarkerTP -1][iSpan]; nuIn = NuIn[iMarkerTP -1][iSpan]; - #ifdef HAVE_MPI TurbPerfIn[0] = densityIn; TurbPerfIn[1] = pressureIn; @@ -13146,8 +13097,6 @@ void CEulerSolver::GatherInOutAverageValues(CConfig *config, CGeometry *geometry omegaOut = OmegaOut[iMarkerTP -1][iSpan]; nuOut = NuOut[iMarkerTP -1][iSpan]; - - #ifdef HAVE_MPI TurbPerfOut[0] = densityOut; TurbPerfOut[1] = pressureOut; @@ -13186,43 +13135,25 @@ void CEulerSolver::GatherInOutAverageValues(CConfig *config, CGeometry *geometry if (rank == MASTER_NODE){ for (i=0;i 0.0){ - densityIn = 0.0; densityIn = TotTurbPerfIn[n1*i]; - pressureIn = 0.0; pressureIn = TotTurbPerfIn[n1*i+1]; - normalVelocityIn = 0.0; normalVelocityIn = TotTurbPerfIn[n1*i+2]; - tangVelocityIn = 0.0; tangVelocityIn = TotTurbPerfIn[n1*i+3]; - radialVelocityIn = 0.0; radialVelocityIn = TotTurbPerfIn[n1*i+4]; - kineIn = 0.0; kineIn = TotTurbPerfIn[n1*i+5]; - omegaIn = 0.0; omegaIn = TotTurbPerfIn[n1*i+6]; - nuIn = 0.0; nuIn = TotTurbPerfIn[n1*i+7]; - - markerTP = -1; markerTP = TotMarkerTP[i]; } if(TotTurbPerfOut[n2*i] > 0.0){ - densityOut = 0.0; densityOut = TotTurbPerfOut[n1*i]; - pressureOut = 0.0; pressureOut = TotTurbPerfOut[n1*i+1]; - normalVelocityOut = 0.0; normalVelocityOut = TotTurbPerfOut[n1*i+2]; - tangVelocityOut = 0.0; tangVelocityOut = TotTurbPerfOut[n1*i+3]; - radialVelocityOut = 0.0; radialVelocityOut = TotTurbPerfOut[n1*i+4]; - kineOut = 0.0; kineOut = TotTurbPerfOut[n1*i+5]; - omegaOut = 0.0; omegaOut = TotTurbPerfOut[n1*i+6]; - nuOut = 0.0; nuOut = TotTurbPerfOut[n1*i+7]; } } From 31bc0bf85e74bd6b35b15c4e60686b345537cd5a Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Thu, 30 Jan 2020 14:45:38 +0000 Subject: [PATCH 056/118] more postprocessing cleanup in NS solver --- SU2_CFD/src/solvers/CEulerSolver.cpp | 15 +- SU2_CFD/src/solvers/CNSSolver.cpp | 302 ++++++++++++--------------- 2 files changed, 140 insertions(+), 177 deletions(-) diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 0d238b1e06c2..fa6fff1189ba 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -2855,6 +2855,8 @@ void CEulerSolver::SetInitialCondition(CGeometry **geometry, CSolver ***solver_c void CEulerSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh, unsigned short iRKStep, unsigned short RunTime_EqSystem, bool Output) { + /// TODO: Try to start a parallel section here encompassing all "heavy" methods. + unsigned long ErrorCounter = 0; unsigned long InnerIter = config->GetInnerIter(); @@ -2947,11 +2949,11 @@ void CEulerSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container /*--- Error message ---*/ 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); -#endif - if (iMesh == MESH_0) config->SetNonphysical_Points(ErrorCounter); + if (iMesh == MESH_0) { + unsigned long tmp = ErrorCounter; + SU2_MPI::Allreduce(&tmp, &ErrorCounter, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); + config->SetNonphysical_Points(ErrorCounter); + } } } @@ -2963,7 +2965,7 @@ unsigned long CEulerSolver::SetPrimitive_Variables(CSolver **solver_container, C unsigned long nonPhysicalPoints = 0; - SU2_OMP(parallel for schedule(static,omp_chunk_size) reduction(+:nonPhysicalPoints)) + SU2_OMP_PARALLEL_(for schedule(static,omp_chunk_size) reduction(+:nonPhysicalPoints)) for (unsigned long iPoint = 0; iPoint < nPoint; iPoint ++) { /*--- Compressible flow, primitive variables nDim+5, (T, vx, vy, vz, P, rho, h, c, lamMu, eddyMu, ThCond, Cp) ---*/ @@ -2983,6 +2985,7 @@ unsigned long CEulerSolver::SetPrimitive_Variables(CSolver **solver_container, C return nonPhysicalPoints; } + void CEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh, unsigned long Iteration) { diff --git a/SU2_CFD/src/solvers/CNSSolver.cpp b/SU2_CFD/src/solvers/CNSSolver.cpp index d1c5b85fd301..60e1eb5e95ae 100644 --- a/SU2_CFD/src/solvers/CNSSolver.cpp +++ b/SU2_CFD/src/solvers/CNSSolver.cpp @@ -185,7 +185,6 @@ CNSSolver::CNSSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) CkOutflow2 = NULL; - /*--- Set the gamma value ---*/ Gamma = config->GetGamma(); @@ -1393,42 +1392,38 @@ void CNSSolver::Friction_Forces(CGeometry *geometry, CConfig *config) { unsigned long iVertex, iPoint, iPointNormal; unsigned short Boundary, Monitoring, iMarker, iMarker_Monitoring, iDim, jDim; - su2double Viscosity = 0.0, div_vel, *Normal, MomentDist[3] = {0.0, 0.0, 0.0}, WallDist[3] = {0.0, 0.0, 0.0}, - *Coord, *Coord_Normal, Area, WallShearStress, TauNormal, factor, RefTemp, RefVel2, - RefDensity, GradTemperature, Density = 0.0, WallDistMod, FrictionVel, + su2double Viscosity = 0.0, div_vel, MomentDist[3] = {0.0, 0.0, 0.0}, WallDist[3] = {0.0, 0.0, 0.0}, + Area, WallShearStress, TauNormal, factor, RefTemp, RefVel2, RefDensity, GradTemperature, Density = 0.0, WallDistMod, FrictionVel, Mach2Vel, Mach_Motion, UnitNormal[3] = {0.0, 0.0, 0.0}, TauElem[3] = {0.0, 0.0, 0.0}, TauTangent[3] = {0.0, 0.0, 0.0}, Tau[3][3] = {{0.0, 0.0, 0.0},{0.0, 0.0, 0.0},{0.0, 0.0, 0.0}}, Force[3] = {0.0, 0.0, 0.0}, Cp, thermal_conductivity, MaxNorm = 8.0, Grad_Vel[3][3] = {{0.0, 0.0, 0.0},{0.0, 0.0, 0.0},{0.0, 0.0, 0.0}}, Grad_Temp[3] = {0.0, 0.0, 0.0}, delta[3][3] = {{1.0, 0.0, 0.0},{0.0,1.0,0.0},{0.0,0.0,1.0}}; su2double MomentX_Force[3] = {0.0,0.0,0.0}, MomentY_Force[3] = {0.0,0.0,0.0}, MomentZ_Force[3] = {0.0,0.0,0.0}; su2double AxiFactor; - -#ifdef HAVE_MPI - su2double MyAllBound_CD_Visc, MyAllBound_CL_Visc, MyAllBound_CSF_Visc, MyAllBound_CMx_Visc, MyAllBound_CMy_Visc, MyAllBound_CMz_Visc, MyAllBound_CoPx_Visc, MyAllBound_CoPy_Visc, MyAllBound_CoPz_Visc, MyAllBound_CFx_Visc, MyAllBound_CFy_Visc, MyAllBound_CFz_Visc, MyAllBound_CT_Visc, MyAllBound_CQ_Visc, MyAllBound_HF_Visc, MyAllBound_MaxHF_Visc, *MySurface_CL_Visc = NULL, *MySurface_CD_Visc = NULL, *MySurface_CSF_Visc = NULL, *MySurface_CEff_Visc = NULL, *MySurface_CFx_Visc = NULL, *MySurface_CFy_Visc = NULL, *MySurface_CFz_Visc = NULL, *MySurface_CMx_Visc = NULL, *MySurface_CMy_Visc = NULL, *MySurface_CMz_Visc = NULL, *MySurface_HF_Visc = NULL, *MySurface_MaxHF_Visc; -#endif + const su2double *Coord = nullptr, *Coord_Normal = nullptr, *Normal = nullptr; string Marker_Tag, Monitoring_Tag; - su2double Alpha = config->GetAoA()*PI_NUMBER/180.0; - su2double Beta = config->GetAoS()*PI_NUMBER/180.0; - su2double RefArea = config->GetRefArea(); - su2double RefLength = config->GetRefLength(); - su2double RefHeatFlux = config->GetHeat_Flux_Ref(); - su2double Gas_Constant = config->GetGas_ConstantND(); - su2double *Origin = NULL; + su2double Alpha = config->GetAoA()*PI_NUMBER/180.0; + su2double Beta = config->GetAoS()*PI_NUMBER/180.0; + su2double RefArea = config->GetRefArea(); + su2double RefLength = config->GetRefLength(); + su2double RefHeatFlux = config->GetHeat_Flux_Ref(); + su2double Gas_Constant = config->GetGas_ConstantND(); + const su2double *Origin = nullptr; if (config->GetnMarker_Monitoring() != 0) { Origin = config->GetRefOriginMoment(0); } - su2double Prandtl_Lam = config->GetPrandtl_Lam(); - bool QCR = config->GetQCR(); - bool axisymmetric = config->GetAxisymmetric(); + su2double Prandtl_Lam = config->GetPrandtl_Lam(); + bool QCR = config->GetQCR(); + bool axisymmetric = config->GetAxisymmetric(); /*--- Evaluate reference values for non-dimensionalization. For dynamic meshes, use the motion Mach number as a reference value for computing the force coefficients. Otherwise, use the freestream values, which is the standard convention. ---*/ - RefTemp = Temperature_Inf; + RefTemp = Temperature_Inf; RefDensity = Density_Inf; if (dynamic_grid) { Mach2Vel = sqrt(Gamma*Gas_Constant*RefTemp); @@ -1444,20 +1439,20 @@ void CNSSolver::Friction_Forces(CGeometry *geometry, CConfig *config) { /*--- Variables initialization ---*/ - AllBound_CD_Visc = 0.0; AllBound_CL_Visc = 0.0; AllBound_CSF_Visc = 0.0; + AllBound_CD_Visc = 0.0; AllBound_CL_Visc = 0.0; AllBound_CSF_Visc = 0.0; AllBound_CFx_Visc = 0.0; AllBound_CFy_Visc = 0.0; AllBound_CFz_Visc = 0.0; AllBound_CMx_Visc = 0.0; AllBound_CMy_Visc = 0.0; AllBound_CMz_Visc = 0.0; - AllBound_CoPx_Visc = 0.0; AllBound_CoPy_Visc = 0.0; AllBound_CoPz_Visc = 0.0; + AllBound_CoPx_Visc = 0.0; AllBound_CoPy_Visc = 0.0; AllBound_CoPz_Visc = 0.0; AllBound_CT_Visc = 0.0; AllBound_CQ_Visc = 0.0; AllBound_CMerit_Visc = 0.0; - AllBound_HF_Visc = 0.0; AllBound_MaxHF_Visc = 0.0; AllBound_CEff_Visc = 0.0; + AllBound_HF_Visc = 0.0; AllBound_MaxHF_Visc = 0.0; AllBound_CEff_Visc = 0.0; for (iMarker_Monitoring = 0; iMarker_Monitoring < config->GetnMarker_Monitoring(); iMarker_Monitoring++) { - Surface_CL_Visc[iMarker_Monitoring] = 0.0; Surface_CD_Visc[iMarker_Monitoring] = 0.0; - Surface_CSF_Visc[iMarker_Monitoring] = 0.0; Surface_CEff_Visc[iMarker_Monitoring] = 0.0; - Surface_CFx_Visc[iMarker_Monitoring] = 0.0; Surface_CFy_Visc[iMarker_Monitoring] = 0.0; - Surface_CFz_Visc[iMarker_Monitoring] = 0.0; Surface_CMx_Visc[iMarker_Monitoring] = 0.0; - Surface_CMy_Visc[iMarker_Monitoring] = 0.0; Surface_CMz_Visc[iMarker_Monitoring] = 0.0; - Surface_HF_Visc[iMarker_Monitoring] = 0.0; Surface_MaxHF_Visc[iMarker_Monitoring] = 0.0; + Surface_CL_Visc[iMarker_Monitoring] = 0.0; Surface_CD_Visc[iMarker_Monitoring] = 0.0; + Surface_CSF_Visc[iMarker_Monitoring] = 0.0; Surface_CEff_Visc[iMarker_Monitoring] = 0.0; + Surface_CFx_Visc[iMarker_Monitoring] = 0.0; Surface_CFy_Visc[iMarker_Monitoring] = 0.0; + Surface_CFz_Visc[iMarker_Monitoring] = 0.0; Surface_CMx_Visc[iMarker_Monitoring] = 0.0; + Surface_CMy_Visc[iMarker_Monitoring] = 0.0; Surface_CMz_Visc[iMarker_Monitoring] = 0.0; + Surface_HF_Visc[iMarker_Monitoring] = 0.0; Surface_MaxHF_Visc[iMarker_Monitoring] = 0.0; } /*--- Loop over the Navier-Stokes markers ---*/ @@ -1482,12 +1477,12 @@ void CNSSolver::Friction_Forces(CGeometry *geometry, CConfig *config) { /*--- Forces initialization at each Marker ---*/ - CD_Visc[iMarker] = 0.0; CL_Visc[iMarker] = 0.0; CSF_Visc[iMarker] = 0.0; - CFx_Visc[iMarker] = 0.0; CFy_Visc[iMarker] = 0.0; CFz_Visc[iMarker] = 0.0; - CMx_Visc[iMarker] = 0.0; CMy_Visc[iMarker] = 0.0; CMz_Visc[iMarker] = 0.0; - CoPx_Visc[iMarker] = 0.0; CoPy_Visc[iMarker] = 0.0; CoPz_Visc[iMarker] = 0.0; - CT_Visc[iMarker] = 0.0; CQ_Visc[iMarker] = 0.0; CMerit_Visc[iMarker] = 0.0; - HF_Visc[iMarker] = 0.0; MaxHF_Visc[iMarker] = 0.0; CEff_Visc[iMarker] = 0.0; + CD_Visc[iMarker] = 0.0; CL_Visc[iMarker] = 0.0; CSF_Visc[iMarker] = 0.0; + CFx_Visc[iMarker] = 0.0; CFy_Visc[iMarker] = 0.0; CFz_Visc[iMarker] = 0.0; + CMx_Visc[iMarker] = 0.0; CMy_Visc[iMarker] = 0.0; CMz_Visc[iMarker] = 0.0; + CoPx_Visc[iMarker] = 0.0; CoPy_Visc[iMarker] = 0.0; CoPz_Visc[iMarker] = 0.0; + CT_Visc[iMarker] = 0.0; CQ_Visc[iMarker] = 0.0; CMerit_Visc[iMarker] = 0.0; + HF_Visc[iMarker] = 0.0; MaxHF_Visc[iMarker] = 0.0; CEff_Visc[iMarker] = 0.0; for (iDim = 0; iDim < nDim; iDim++) ForceViscous[iDim] = 0.0; MomentViscous[0] = 0.0; MomentViscous[1] = 0.0; MomentViscous[2] = 0.0; @@ -1702,16 +1697,16 @@ void CNSSolver::Friction_Forces(CGeometry *geometry, CConfig *config) { if (Marker_Tag == Monitoring_Tag) { Surface_CL_Visc[iMarker_Monitoring] += CL_Visc[iMarker]; Surface_CD_Visc[iMarker_Monitoring] += CD_Visc[iMarker]; - Surface_CSF_Visc[iMarker_Monitoring] += CSF_Visc[iMarker]; - Surface_CEff_Visc[iMarker_Monitoring] += CEff_Visc[iMarker]; - Surface_CFx_Visc[iMarker_Monitoring] += CFx_Visc[iMarker]; - Surface_CFy_Visc[iMarker_Monitoring] += CFy_Visc[iMarker]; - Surface_CFz_Visc[iMarker_Monitoring] += CFz_Visc[iMarker]; - Surface_CMx_Visc[iMarker_Monitoring] += CMx_Visc[iMarker]; - Surface_CMy_Visc[iMarker_Monitoring] += CMy_Visc[iMarker]; - Surface_CMz_Visc[iMarker_Monitoring] += CMz_Visc[iMarker]; - Surface_HF_Visc[iMarker_Monitoring] += HF_Visc[iMarker]; - Surface_MaxHF_Visc[iMarker_Monitoring] += pow(MaxHF_Visc[iMarker],MaxNorm); + Surface_CSF_Visc[iMarker_Monitoring] += CSF_Visc[iMarker]; + Surface_CEff_Visc[iMarker_Monitoring] += CEff_Visc[iMarker]; + Surface_CFx_Visc[iMarker_Monitoring] += CFx_Visc[iMarker]; + Surface_CFy_Visc[iMarker_Monitoring] += CFy_Visc[iMarker]; + Surface_CFz_Visc[iMarker_Monitoring] += CFz_Visc[iMarker]; + Surface_CMx_Visc[iMarker_Monitoring] += CMx_Visc[iMarker]; + Surface_CMy_Visc[iMarker_Monitoring] += CMy_Visc[iMarker]; + Surface_CMz_Visc[iMarker_Monitoring] += CMz_Visc[iMarker]; + Surface_HF_Visc[iMarker_Monitoring] += HF_Visc[iMarker]; + Surface_MaxHF_Visc[iMarker_Monitoring] += pow(MaxHF_Visc[iMarker],MaxNorm); } } @@ -1731,111 +1726,76 @@ void CNSSolver::Friction_Forces(CGeometry *geometry, CConfig *config) { /*--- Add AllBound information using all the nodes ---*/ - MyAllBound_CD_Visc = AllBound_CD_Visc; AllBound_CD_Visc = 0.0; - MyAllBound_CL_Visc = AllBound_CL_Visc; AllBound_CL_Visc = 0.0; - MyAllBound_CSF_Visc = AllBound_CSF_Visc; AllBound_CSF_Visc = 0.0; - AllBound_CEff_Visc = 0.0; - MyAllBound_CMx_Visc = AllBound_CMx_Visc; AllBound_CMx_Visc = 0.0; - MyAllBound_CMy_Visc = AllBound_CMy_Visc; AllBound_CMy_Visc = 0.0; - MyAllBound_CMz_Visc = AllBound_CMz_Visc; AllBound_CMz_Visc = 0.0; - MyAllBound_CoPx_Visc = AllBound_CoPx_Visc; AllBound_CoPx_Visc = 0.0; - MyAllBound_CoPy_Visc = AllBound_CoPy_Visc; AllBound_CoPy_Visc = 0.0; - MyAllBound_CoPz_Visc = AllBound_CoPz_Visc; AllBound_CoPz_Visc = 0.0; - MyAllBound_CFx_Visc = AllBound_CFx_Visc; AllBound_CFx_Visc = 0.0; - MyAllBound_CFy_Visc = AllBound_CFy_Visc; AllBound_CFy_Visc = 0.0; - MyAllBound_CFz_Visc = AllBound_CFz_Visc; AllBound_CFz_Visc = 0.0; - MyAllBound_CT_Visc = AllBound_CT_Visc; AllBound_CT_Visc = 0.0; - MyAllBound_CQ_Visc = AllBound_CQ_Visc; AllBound_CQ_Visc = 0.0; - AllBound_CMerit_Visc = 0.0; - MyAllBound_HF_Visc = AllBound_HF_Visc; AllBound_HF_Visc = 0.0; - MyAllBound_MaxHF_Visc = pow(AllBound_MaxHF_Visc, MaxNorm); AllBound_MaxHF_Visc = 0.0; - if (config->GetComm_Level() == COMM_FULL) { - SU2_MPI::Allreduce(&MyAllBound_CD_Visc, &AllBound_CD_Visc, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&MyAllBound_CL_Visc, &AllBound_CL_Visc, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&MyAllBound_CSF_Visc, &AllBound_CSF_Visc, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); + + auto Allreduce = [](su2double x) { + su2double tmp = x; x = 0.0; + SU2_MPI::Allreduce(&tmp, &x, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); + return x; + }; + AllBound_CD_Visc = Allreduce(AllBound_CD_Visc); + AllBound_CL_Visc = Allreduce(AllBound_CL_Visc); + AllBound_CSF_Visc = Allreduce(AllBound_CSF_Visc); AllBound_CEff_Visc = AllBound_CL_Visc / (AllBound_CD_Visc + EPS); - SU2_MPI::Allreduce(&MyAllBound_CMx_Visc, &AllBound_CMx_Visc, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&MyAllBound_CMy_Visc, &AllBound_CMy_Visc, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&MyAllBound_CMz_Visc, &AllBound_CMz_Visc, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&MyAllBound_CFx_Visc, &AllBound_CFx_Visc, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&MyAllBound_CFy_Visc, &AllBound_CFy_Visc, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&MyAllBound_CFz_Visc, &AllBound_CFz_Visc, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&MyAllBound_CoPx_Visc, &AllBound_CoPx_Visc, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&MyAllBound_CoPy_Visc, &AllBound_CoPy_Visc, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&MyAllBound_CoPz_Visc, &AllBound_CoPz_Visc, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&MyAllBound_CT_Visc, &AllBound_CT_Visc, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&MyAllBound_CQ_Visc, &AllBound_CQ_Visc, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); + + AllBound_CMx_Visc = Allreduce(AllBound_CMx_Visc); + AllBound_CMy_Visc = Allreduce(AllBound_CMy_Visc); + AllBound_CMz_Visc = Allreduce(AllBound_CMz_Visc); + + AllBound_CFx_Visc = Allreduce(AllBound_CFx_Visc); + AllBound_CFy_Visc = Allreduce(AllBound_CFy_Visc); + AllBound_CFz_Visc = Allreduce(AllBound_CFz_Visc); + + AllBound_CoPx_Visc = Allreduce(AllBound_CoPx_Visc); + AllBound_CoPy_Visc = Allreduce(AllBound_CoPy_Visc); + AllBound_CoPz_Visc = Allreduce(AllBound_CoPz_Visc); + + AllBound_CT_Visc = Allreduce(AllBound_CT_Visc); + AllBound_CQ_Visc = Allreduce(AllBound_CQ_Visc); + AllBound_HF_Visc = Allreduce(AllBound_HF_Visc); AllBound_CMerit_Visc = AllBound_CT_Visc / (AllBound_CQ_Visc + EPS); - SU2_MPI::Allreduce(&MyAllBound_HF_Visc, &AllBound_HF_Visc, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&MyAllBound_MaxHF_Visc, &AllBound_MaxHF_Visc, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - AllBound_MaxHF_Visc = pow(AllBound_MaxHF_Visc, 1.0/MaxNorm); + + AllBound_MaxHF_Visc = pow(Allreduce(pow(AllBound_MaxHF_Visc, MaxNorm)), 1.0/MaxNorm); + } /*--- Add the forces on the surfaces using all the nodes ---*/ - MySurface_CL_Visc = new su2double[config->GetnMarker_Monitoring()]; - MySurface_CD_Visc = new su2double[config->GetnMarker_Monitoring()]; - MySurface_CSF_Visc = new su2double[config->GetnMarker_Monitoring()]; - MySurface_CEff_Visc = new su2double[config->GetnMarker_Monitoring()]; - MySurface_CFx_Visc = new su2double[config->GetnMarker_Monitoring()]; - MySurface_CFy_Visc = new su2double[config->GetnMarker_Monitoring()]; - MySurface_CFz_Visc = new su2double[config->GetnMarker_Monitoring()]; - MySurface_CMx_Visc = new su2double[config->GetnMarker_Monitoring()]; - MySurface_CMy_Visc = new su2double[config->GetnMarker_Monitoring()]; - MySurface_CMz_Visc = new su2double[config->GetnMarker_Monitoring()]; - MySurface_HF_Visc = new su2double[config->GetnMarker_Monitoring()]; - MySurface_MaxHF_Visc = new su2double[config->GetnMarker_Monitoring()]; + if (config->GetComm_Level() == COMM_FULL) { - for (iMarker_Monitoring = 0; iMarker_Monitoring < config->GetnMarker_Monitoring(); iMarker_Monitoring++) { + int nMarkerMon = config->GetnMarker_Monitoring(); - MySurface_CL_Visc[iMarker_Monitoring] = Surface_CL_Visc[iMarker_Monitoring]; - MySurface_CD_Visc[iMarker_Monitoring] = Surface_CD_Visc[iMarker_Monitoring]; - MySurface_CSF_Visc[iMarker_Monitoring] = Surface_CSF_Visc[iMarker_Monitoring]; - MySurface_CEff_Visc[iMarker_Monitoring] = Surface_CEff_Visc[iMarker_Monitoring]; - MySurface_CFx_Visc[iMarker_Monitoring] = Surface_CFx_Visc[iMarker_Monitoring]; - MySurface_CFy_Visc[iMarker_Monitoring] = Surface_CFy_Visc[iMarker_Monitoring]; - MySurface_CFz_Visc[iMarker_Monitoring] = Surface_CFz_Visc[iMarker_Monitoring]; - MySurface_CMx_Visc[iMarker_Monitoring] = Surface_CMx_Visc[iMarker_Monitoring]; - MySurface_CMy_Visc[iMarker_Monitoring] = Surface_CMy_Visc[iMarker_Monitoring]; - MySurface_CMz_Visc[iMarker_Monitoring] = Surface_CMz_Visc[iMarker_Monitoring]; - MySurface_HF_Visc[iMarker_Monitoring] = Surface_HF_Visc[iMarker_Monitoring]; - MySurface_MaxHF_Visc[iMarker_Monitoring] = Surface_MaxHF_Visc[iMarker_Monitoring]; - - Surface_CL_Visc[iMarker_Monitoring] = 0.0; - Surface_CD_Visc[iMarker_Monitoring] = 0.0; - Surface_CSF_Visc[iMarker_Monitoring] = 0.0; - Surface_CEff_Visc[iMarker_Monitoring] = 0.0; - Surface_CFx_Visc[iMarker_Monitoring] = 0.0; - Surface_CFy_Visc[iMarker_Monitoring] = 0.0; - Surface_CFz_Visc[iMarker_Monitoring] = 0.0; - Surface_CMx_Visc[iMarker_Monitoring] = 0.0; - Surface_CMy_Visc[iMarker_Monitoring] = 0.0; - Surface_CMz_Visc[iMarker_Monitoring] = 0.0; - Surface_HF_Visc[iMarker_Monitoring] = 0.0; - Surface_MaxHF_Visc[iMarker_Monitoring] = 0.0; - } + /*--- Use the same buffer for all reductions. We could avoid the copy back into + * the original variable by swaping pointers, but it is safer this way... ---*/ - if (config->GetComm_Level() == COMM_FULL) { - SU2_MPI::Allreduce(MySurface_CL_Visc, Surface_CL_Visc, config->GetnMarker_Monitoring(), MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(MySurface_CD_Visc, Surface_CD_Visc, config->GetnMarker_Monitoring(), MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(MySurface_CSF_Visc, Surface_CSF_Visc, config->GetnMarker_Monitoring(), MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - for (iMarker_Monitoring = 0; iMarker_Monitoring < config->GetnMarker_Monitoring(); iMarker_Monitoring++) + su2double* buffer = new su2double [nMarkerMon]; + + auto Allreduce_inplace = [buffer](int size, su2double* x) { + SU2_MPI::Allreduce(x, buffer, size, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); + for(int i=0; iGetnMarker_Monitoring(), MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(MySurface_CFy_Visc, Surface_CFy_Visc, config->GetnMarker_Monitoring(), MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(MySurface_CFz_Visc, Surface_CFz_Visc, config->GetnMarker_Monitoring(), MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(MySurface_CMx_Visc, Surface_CMx_Visc, config->GetnMarker_Monitoring(), MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(MySurface_CMy_Visc, Surface_CMy_Visc, config->GetnMarker_Monitoring(), MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(MySurface_CMz_Visc, Surface_CMz_Visc, config->GetnMarker_Monitoring(), MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(MySurface_HF_Visc, Surface_HF_Visc, config->GetnMarker_Monitoring(), MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(MySurface_MaxHF_Visc, Surface_MaxHF_Visc, config->GetnMarker_Monitoring(), MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - } - delete [] MySurface_CL_Visc; delete [] MySurface_CD_Visc; delete [] MySurface_CSF_Visc; - delete [] MySurface_CEff_Visc; delete [] MySurface_CFx_Visc; delete [] MySurface_CFy_Visc; - delete [] MySurface_CFz_Visc; delete [] MySurface_CMx_Visc; delete [] MySurface_CMy_Visc; - delete [] MySurface_CMz_Visc; delete [] MySurface_HF_Visc; delete [] MySurface_MaxHF_Visc; + Allreduce_inplace(nMarkerMon, Surface_CFx_Visc); + Allreduce_inplace(nMarkerMon, Surface_CFy_Visc); + Allreduce_inplace(nMarkerMon, Surface_CFz_Visc); + + Allreduce_inplace(nMarkerMon, Surface_CMx_Visc); + Allreduce_inplace(nMarkerMon, Surface_CMy_Visc); + Allreduce_inplace(nMarkerMon, Surface_CMz_Visc); + + Allreduce_inplace(nMarkerMon, Surface_HF_Visc); + Allreduce_inplace(nMarkerMon, Surface_MaxHF_Visc); + + delete [] buffer; + + } #endif @@ -1844,7 +1804,7 @@ void CNSSolver::Friction_Forces(CGeometry *geometry, CConfig *config) { Total_CD += AllBound_CD_Visc; Total_CL += AllBound_CL_Visc; Total_CSF += AllBound_CSF_Visc; - Total_CEff = Total_CL / (Total_CD + EPS); + Total_CEff = Total_CL / (Total_CD + EPS); Total_CFx += AllBound_CFx_Visc; Total_CFy += AllBound_CFy_Visc; Total_CFz += AllBound_CFz_Visc; @@ -1856,17 +1816,17 @@ void CNSSolver::Friction_Forces(CGeometry *geometry, CConfig *config) { Total_CoPz += AllBound_CoPz_Visc; Total_CT += AllBound_CT_Visc; Total_CQ += AllBound_CQ_Visc; - Total_CMerit = AllBound_CT_Visc / (AllBound_CQ_Visc + EPS); - Total_Heat = AllBound_HF_Visc; - Total_MaxHeat = AllBound_MaxHF_Visc; + Total_CMerit = AllBound_CT_Visc / (AllBound_CQ_Visc + EPS); + Total_Heat = AllBound_HF_Visc; + Total_MaxHeat = AllBound_MaxHF_Visc; /*--- Update the total coefficients per surface (note that all the nodes have the same value)---*/ for (iMarker_Monitoring = 0; iMarker_Monitoring < config->GetnMarker_Monitoring(); iMarker_Monitoring++) { - Surface_CL[iMarker_Monitoring] += Surface_CL_Visc[iMarker_Monitoring]; - Surface_CD[iMarker_Monitoring] += Surface_CD_Visc[iMarker_Monitoring]; - Surface_CSF[iMarker_Monitoring] += Surface_CSF_Visc[iMarker_Monitoring]; - Surface_CEff[iMarker_Monitoring] = Surface_CL[iMarker_Monitoring] / (Surface_CD[iMarker_Monitoring] + EPS); + Surface_CL[iMarker_Monitoring] += Surface_CL_Visc[iMarker_Monitoring]; + Surface_CD[iMarker_Monitoring] += Surface_CD_Visc[iMarker_Monitoring]; + Surface_CSF[iMarker_Monitoring] += Surface_CSF_Visc[iMarker_Monitoring]; + Surface_CEff[iMarker_Monitoring] = Surface_CL[iMarker_Monitoring] / (Surface_CD[iMarker_Monitoring] + EPS); Surface_CFx[iMarker_Monitoring] += Surface_CFx_Visc[iMarker_Monitoring]; Surface_CFy[iMarker_Monitoring] += Surface_CFy_Visc[iMarker_Monitoring]; Surface_CFz[iMarker_Monitoring] += Surface_CFz_Visc[iMarker_Monitoring]; @@ -1996,28 +1956,28 @@ void CNSSolver::Buffet_Monitoring(CGeometry *geometry, CConfig *config) { void CNSSolver::Evaluate_ObjFunc(CConfig *config) { - unsigned short iMarker_Monitoring, Kind_ObjFunc; - su2double Weight_ObjFunc; + unsigned short iMarker_Monitoring, Kind_ObjFunc; + su2double Weight_ObjFunc; - /*--- Evaluate objective functions common to Euler and NS solvers ---*/ + /*--- Evaluate objective functions common to Euler and NS solvers ---*/ - CEulerSolver::Evaluate_ObjFunc(config); + CEulerSolver::Evaluate_ObjFunc(config); - /*--- Evaluate objective functions specific to NS solver ---*/ + /*--- Evaluate objective functions specific to NS solver ---*/ - for (iMarker_Monitoring = 0; iMarker_Monitoring < config->GetnMarker_Monitoring(); iMarker_Monitoring++) { + for (iMarker_Monitoring = 0; iMarker_Monitoring < config->GetnMarker_Monitoring(); iMarker_Monitoring++) { - Weight_ObjFunc = config->GetWeight_ObjFunc(iMarker_Monitoring); - Kind_ObjFunc = config->GetKind_ObjFunc(iMarker_Monitoring); + Weight_ObjFunc = config->GetWeight_ObjFunc(iMarker_Monitoring); + Kind_ObjFunc = config->GetKind_ObjFunc(iMarker_Monitoring); - switch(Kind_ObjFunc) { - case BUFFET_SENSOR: - Total_ComboObj +=Weight_ObjFunc*Surface_Buffet_Metric[iMarker_Monitoring]; - break; - default: - break; - } - } + switch(Kind_ObjFunc) { + case BUFFET_SENSOR: + Total_ComboObj +=Weight_ObjFunc*Surface_Buffet_Metric[iMarker_Monitoring]; + break; + default: + break; + } + } } @@ -2142,7 +2102,8 @@ void CNSSolver::BC_HeatFlux_Wall(CGeometry *geometry, CSolver **solver_container for (iDim = 0; iDim < nDim; iDim++) { for (jDim = 0; jDim < nDim; jDim++) { - tau[iDim][jDim] = total_viscosity*( Grad_Vel[jDim][iDim]+Grad_Vel[iDim][jDim] ) - TWO3*total_viscosity*div_vel*delta[iDim][jDim]; + tau[iDim][jDim] = total_viscosity*( Grad_Vel[jDim][iDim]+Grad_Vel[iDim][jDim] ) - + TWO3*total_viscosity*div_vel*delta[iDim][jDim]; } } @@ -2566,26 +2527,25 @@ void CNSSolver::BC_Isothermal_Wall(CGeometry *geometry, CSolver **solver_contain void CNSSolver::SetRoe_Dissipation(CGeometry *geometry, CConfig *config){ - unsigned long iPoint; - su2double wall_distance; + const unsigned short kind_roe_dissipation = config->GetKind_RoeLowDiss(); - unsigned short kind_roe_dissipation = config->GetKind_RoeLowDiss(); - - for (iPoint = 0; iPoint < nPoint; iPoint++){ + SU2_OMP_PARALLEL_(for schedule(static,omp_chunk_size)) + for (unsigned long iPoint = 0; iPoint < nPoint; iPoint++) { if (kind_roe_dissipation == FD || kind_roe_dissipation == FD_DUCROS){ - wall_distance = geometry->node[iPoint]->GetWall_Distance(); + su2double wall_distance = geometry->node[iPoint]->GetWall_Distance(); - nodes->SetRoe_Dissipation_FD(iPoint,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 - nodes->SetRoe_Dissipation_NTS(iPoint,delta, config->GetConst_DES()); + assert(delta > 0 && "Delta must be initialized and non-negative"); + nodes->SetRoe_Dissipation_NTS(iPoint, delta, config->GetConst_DES()); } } + } void CNSSolver::BC_ConjugateHeat_Interface(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, From e5096f170594438795d5c1eb4f2373ba93d5acb8 Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Thu, 30 Jan 2020 15:07:39 +0000 Subject: [PATCH 057/118] parallel SetVorticity_StrainMag --- SU2_CFD/src/solvers/CNSSolver.cpp | 65 +++++++++++++++++---------- SU2_CFD/src/variables/CNSVariable.cpp | 5 ++- 2 files changed, 44 insertions(+), 26 deletions(-) diff --git a/SU2_CFD/src/solvers/CNSSolver.cpp b/SU2_CFD/src/solvers/CNSSolver.cpp index 60e1eb5e95ae..24bdda334795 100644 --- a/SU2_CFD/src/solvers/CNSSolver.cpp +++ b/SU2_CFD/src/solvers/CNSSolver.cpp @@ -927,10 +927,11 @@ CNSSolver::~CNSSolver(void) { void CNSSolver::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; - su2double StrainMag = 0.0, Omega = 0.0, *Vorticity; + /// TODO: Try to start a parallel section here encompassing all "heavy" methods. - unsigned long InnerIter = config->GetInnerIter(); + unsigned long ErrorCounter = 0; + + unsigned long InnerIter = config->GetInnerIter(); bool cont_adjoint = config->GetContinuous_Adjoint(); bool disc_adjoint = config->GetDiscrete_Adjoint(); bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); @@ -1021,19 +1022,32 @@ 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++) { - 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]); + SU2_OMP_PARALLEL + { + solver_container[FLOW_SOL]->GetNodes()->SetVorticity_StrainMag(); - StrainMag_Max = max(StrainMag_Max, StrainMag); - Omega_Max = max(Omega_Max, Omega); + su2double strainMax = 0.0, omegaMax = 0.0; - } + SU2_OMP(for schedule(static,omp_chunk_size) nowait) + for (unsigned long iPoint = 0; iPoint < nPoint; iPoint++) { + + su2double StrainMag = solver_container[FLOW_SOL]->GetNodes()->GetStrainMag(iPoint); + const su2double* Vorticity = solver_container[FLOW_SOL]->GetNodes()->GetVorticity(iPoint); + su2double Omega = sqrt(Vorticity[0]*Vorticity[0]+ Vorticity[1]*Vorticity[1]+ Vorticity[2]*Vorticity[2]); + + strainMax = max(strainMax, StrainMag); + omegaMax = max(omegaMax, Omega); + + } + SU2_OMP_CRITICAL + { + StrainMag_Max = max(StrainMag_Max, strainMax); + Omega_Max = max(Omega_Max, omegaMax); + } + + } // end SU2_OMP_PARALLEL /*--- Compute the TauWall from the wall functions ---*/ @@ -1048,20 +1062,20 @@ void CNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container, C if (config->GetComm_Level() == COMM_FULL) { -#ifdef HAVE_MPI - unsigned long MyErrorCounter = ErrorCounter; ErrorCounter = 0; - su2double MyOmega_Max = Omega_Max; Omega_Max = 0.0; - su2double MyStrainMag_Max = StrainMag_Max; StrainMag_Max = 0.0; + if (iMesh == MESH_0) { - SU2_MPI::Allreduce(&MyErrorCounter, &ErrorCounter, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&MyStrainMag_Max, &StrainMag_Max, 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&MyOmega_Max, &Omega_Max, 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD); -#endif + unsigned long MyErrorCounter = ErrorCounter; + su2double MyOmega_Max = Omega_Max; + su2double MyStrainMag_Max = StrainMag_Max; + + SU2_MPI::Allreduce(&MyErrorCounter, &ErrorCounter, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); + SU2_MPI::Allreduce(&MyStrainMag_Max, &StrainMag_Max, 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD); + SU2_MPI::Allreduce(&MyOmega_Max, &Omega_Max, 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD); - if (iMesh == MESH_0) { config->SetNonphysical_Points(ErrorCounter); solver_container[FLOW_SOL]->SetStrainMag_Max(StrainMag_Max); solver_container[FLOW_SOL]->SetOmega_Max(Omega_Max); + } } @@ -1982,7 +1996,8 @@ void CNSSolver::Evaluate_ObjFunc(CConfig *config) { } -void CNSSolver::BC_HeatFlux_Wall(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { +void CNSSolver::BC_HeatFlux_Wall(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, + CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { unsigned short iDim, jDim, iVar, jVar; unsigned long iVertex, iPoint, Point_Normal, total_index; @@ -2228,7 +2243,8 @@ void CNSSolver::BC_HeatFlux_Wall(CGeometry *geometry, CSolver **solver_container } } -void CNSSolver::BC_Isothermal_Wall(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { +void CNSSolver::BC_Isothermal_Wall(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, + CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { unsigned short iVar, jVar, iDim, jDim; unsigned long iVertex, iPoint, Point_Normal, total_index; @@ -2417,7 +2433,8 @@ void CNSSolver::BC_Isothermal_Wall(CGeometry *geometry, CSolver **solver_contain for (iDim = 0; iDim < nDim; iDim++) for (jDim = 0; jDim < nDim; jDim++) { - tau[iDim][jDim] = total_viscosity*( Grad_Vel[jDim][iDim] + Grad_Vel[iDim][jDim] ) - TWO3*total_viscosity*div_vel*delta[iDim][jDim]; + tau[iDim][jDim] = total_viscosity*( Grad_Vel[jDim][iDim] + Grad_Vel[iDim][jDim] ) - + TWO3*total_viscosity*div_vel*delta[iDim][jDim]; } /*--- Dot product of the stress tensor with the grid velocity ---*/ diff --git a/SU2_CFD/src/variables/CNSVariable.cpp b/SU2_CFD/src/variables/CNSVariable.cpp index 7ea1a19068c9..abdcfe8cda9b 100644 --- a/SU2_CFD/src/variables/CNSVariable.cpp +++ b/SU2_CFD/src/variables/CNSVariable.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -25,8 +25,8 @@ * License along with SU2. If not, see . */ - #include "../../include/variables/CNSVariable.hpp" +#include "../../../Common/include/omp_structure.hpp" CNSVariable::CNSVariable(su2double density, const su2double *velocity, su2double energy, @@ -46,6 +46,7 @@ CNSVariable::CNSVariable(su2double density, const su2double *velocity, su2double bool CNSVariable::SetVorticity_StrainMag() { + SU2_OMP_FOR_STAT(256) for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) { /*--- Vorticity ---*/ From 81de82f2a7b0d631e27c6990ff8d17d653efdad6 Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Thu, 30 Jan 2020 15:23:41 +0000 Subject: [PATCH 058/118] primitive variables loop --- SU2_CFD/src/solvers/CNSSolver.cpp | 34 +++++++++++++++---------------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/SU2_CFD/src/solvers/CNSSolver.cpp b/SU2_CFD/src/solvers/CNSSolver.cpp index 24bdda334795..093bb777b2ba 100644 --- a/SU2_CFD/src/solvers/CNSSolver.cpp +++ b/SU2_CFD/src/solvers/CNSSolver.cpp @@ -1084,38 +1084,36 @@ void CNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container, C unsigned long CNSSolver::SetPrimitive_Variables(CSolver **solver_container, CConfig *config, bool Output) { - 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; + unsigned long nonPhysicalPoints = 0; - bool tkeNeeded = ((turb_model == SST) || (turb_model == SST_SUST)) ; + const unsigned short turb_model = config->GetKind_Turb_Model(); + const bool tkeNeeded = (turb_model == SST) || (turb_model == SST_SUST); - for (iPoint = 0; iPoint < nPoint; iPoint ++) { + SU2_OMP_PARALLEL_(for schedule(static,omp_chunk_size) reduction(+:nonPhysicalPoints)) + for (unsigned long iPoint = 0; iPoint < nPoint; iPoint ++) { - /*--- Retrieve the value of the kinetic energy (if need it) ---*/ + /*--- Retrieve the value of the kinetic energy (if needed). ---*/ + + su2double eddy_visc = 0.0, turb_ke = 0.0; if (turb_model != NONE) { 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]->GetNodes()->GetDES_LengthScale(iPoint); + if (config->GetKind_HybridRANSLES() != NO_HYBRIDRANSLES) { + su2double DES_LengthScale = solver_container[TURB_SOL]->GetNodes()->GetDES_LengthScale(iPoint); + nodes->SetDES_LengthScale(iPoint, DES_LengthScale); } } /*--- Compressible flow, primitive variables nDim+5, (T, vx, vy, vz, P, rho, h, c, lamMu, eddyMu, ThCond, Cp) ---*/ - physical = static_cast(nodes)->SetPrimVar(iPoint,eddy_visc, turb_ke, GetFluidModel()); + bool physical = static_cast(nodes)->SetPrimVar(iPoint, eddy_visc, turb_ke, GetFluidModel()); nodes->SetSecondaryVar(iPoint, GetFluidModel()); - /* Check for non-realizable states for reporting. */ - - if (!physical) nonPhysicalPoints++; - - /*--- Set the DES length scale ---*/ + /*--- Check for non-realizable states for reporting. ---*/ - nodes->SetDES_LengthScale(iPoint,DES_LengthScale); + nonPhysicalPoints += !physical; /*--- Initialize the convective, source and viscous residual vector ---*/ @@ -1135,8 +1133,8 @@ void CNSSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, CC su2double ProjVel, ProjVel_i, ProjVel_j; bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - 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); Min_Delta_Time = 1.E30; Max_Delta_Time = 0.0; From 49f928f4e8711ffcfdfd000143ecafb42741520c Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Thu, 30 Jan 2020 16:25:08 +0000 Subject: [PATCH 059/118] SetTime_Step of the NS solver --- SU2_CFD/src/solvers/CNSSolver.cpp | 263 +++++++++++++++++------------- 1 file changed, 154 insertions(+), 109 deletions(-) diff --git a/SU2_CFD/src/solvers/CNSSolver.cpp b/SU2_CFD/src/solvers/CNSSolver.cpp index 093bb777b2ba..b84de0e57d57 100644 --- a/SU2_CFD/src/solvers/CNSSolver.cpp +++ b/SU2_CFD/src/solvers/CNSSolver.cpp @@ -1124,22 +1124,36 @@ unsigned long CNSSolver::SetPrimitive_Variables(CSolver **solver_container, CCon return nonPhysicalPoints; } -void CNSSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh, unsigned long Iteration) { +void CNSSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, CConfig *config, + unsigned short iMesh, unsigned long Iteration) { - su2double *Normal, Area, Vol, Mean_SoundSpeed = 0.0, Mean_ProjVel = 0.0, Lambda, Local_Delta_Time, Local_Delta_Time_Visc, - Global_Delta_Time = 1E6, Mean_LaminarVisc = 0.0, Mean_EddyVisc = 0.0, Mean_Density = 0.0, Lambda_1, Lambda_2, K_v = 0.25, Global_Delta_UnstTimeND; - unsigned long iEdge, iVertex, iPoint = 0, jPoint = 0; - unsigned short iDim, iMarker; - su2double ProjVel, ProjVel_i, ProjVel_j; + const bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + const bool dual_time = (config->GetTime_Marching() == DT_STEPPING_1ST) || + (config->GetTime_Marching() == DT_STEPPING_2ND); + const su2double K_v = 0.25; - bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - bool dual_time = (config->GetTime_Marching() == DT_STEPPING_1ST) || - (config->GetTime_Marching() == DT_STEPPING_2ND); + /*--- Init thread-shared variables to compute min/max values. + * Critical sections are used for this instead of reduction + * clauses for compatibility with OpenMP 2.0 (Windows...). ---*/ + + Min_Delta_Time = 1e30; Max_Delta_Time = 0.0; + + su2double Global_Delta_Time, Global_Delta_UnstTimeND = 1e30; + + /*--- Start OpenMP parallel section. ---*/ - Min_Delta_Time = 1.E30; Max_Delta_Time = 0.0; + SU2_OMP_PARALLEL + { + + const su2double *Normal = nullptr; + su2double Area, Vol, Mean_SoundSpeed = 0.0, Mean_ProjVel = 0.0, Lambda, Local_Delta_Time, Local_Delta_Time_Visc, + Mean_LaminarVisc = 0.0, Mean_EddyVisc = 0.0, Mean_Density = 0.0, Lambda_1, Lambda_2, ProjVel; + unsigned long iEdge, iVertex, iPoint = 0, jPoint; + unsigned short iDim, iMarker; /*--- Set maximum inviscid eigenvalue to zero, and compute sound speed and viscosity ---*/ + SU2_OMP_FOR_STAT(omp_chunk_size) for (iPoint = 0; iPoint < nPointDomain; iPoint++) { nodes->SetMax_Lambda_Inv(iPoint,0.0); nodes->SetMax_Lambda_Visc(iPoint,0.0); @@ -1147,15 +1161,29 @@ void CNSSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, CC /*--- Loop interior edges ---*/ - for (iEdge = 0; iEdge < geometry->GetnEdge(); iEdge++) { +#ifdef HAVE_OMP + /*--- Chunk size is at least OMP_MIN_SIZE and a multiple of the color group size. ---*/ + auto chunkSize = roundUpDiv(OMP_MIN_SIZE, ColorGroupSize)*ColorGroupSize; + + /*--- Loop over edge colors. ---*/ + for (auto color : EdgeColoring) + { + SU2_OMP_FOR_DYN(chunkSize) + for(auto k = 0ul; k < color.size; ++k) { + iEdge = color.indices[k]; +#else + /*--- Natural coloring. ---*/ + { + for (iEdge = 0; iEdge < geometry->GetnEdge(); iEdge++) { +#endif /*--- Point identification, Normal vector and area ---*/ iPoint = geometry->edge[iEdge]->GetNode(0); jPoint = geometry->edge[iEdge]->GetNode(1); Normal = geometry->edge[iEdge]->GetNormal(); - Area = 0; for (iDim = 0; iDim < nDim; iDim++) Area += Normal[iDim]*Normal[iDim]; Area = sqrt(Area); + Area = 0.0; for (iDim = 0; iDim < nDim; iDim++) Area += pow(Normal[iDim],2); Area = sqrt(Area); /*--- Mean Values ---*/ @@ -1165,14 +1193,11 @@ void CNSSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, CC /*--- Adjustment for grid movement ---*/ if (dynamic_grid) { - su2double *GridVel_i = geometry->node[iPoint]->GetGridVel(); - su2double *GridVel_j = geometry->node[jPoint]->GetGridVel(); - ProjVel_i = 0.0; ProjVel_j =0.0; - for (iDim = 0; iDim < nDim; iDim++) { - ProjVel_i += GridVel_i[iDim]*Normal[iDim]; - ProjVel_j += GridVel_j[iDim]*Normal[iDim]; - } - Mean_ProjVel -= 0.5 * (ProjVel_i + ProjVel_j) ; + const su2double *GridVel_i = geometry->node[iPoint]->GetGridVel(); + const su2double *GridVel_j = geometry->node[jPoint]->GetGridVel(); + + for (iDim = 0; iDim < nDim; iDim++) + Mean_ProjVel -= 0.5 * (GridVel_i[iDim] + GridVel_j[iDim]) * Normal[iDim]; } /*--- Inviscid contribution ---*/ @@ -1196,155 +1221,175 @@ void CNSSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, CC if (geometry->node[jPoint]->GetDomain()) nodes->AddMax_Lambda_Visc(jPoint, Lambda); } + } // end color loop /*--- Loop boundary edges ---*/ for (iMarker = 0; iMarker < geometry->GetnMarker(); iMarker++) { if ((config->GetMarker_All_KindBC(iMarker) != INTERNAL_BOUNDARY) && (config->GetMarker_All_KindBC(iMarker) != PERIODIC_BOUNDARY)) { - for (iVertex = 0; iVertex < geometry->GetnVertex(iMarker); iVertex++) { - /*--- Point identification, Normal vector and area ---*/ + SU2_OMP_FOR_STAT(OMP_MIN_SIZE) + for (iVertex = 0; iVertex < geometry->GetnVertex(iMarker); iVertex++) { - iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); - Normal = geometry->vertex[iMarker][iVertex]->GetNormal(); - Area = 0.0; for (iDim = 0; iDim < nDim; iDim++) Area += Normal[iDim]*Normal[iDim]; Area = sqrt(Area); + /*--- Point identification, Normal vector and area ---*/ - /*--- Mean Values ---*/ + iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); - Mean_ProjVel = nodes->GetProjVel(iPoint,Normal); - Mean_SoundSpeed = nodes->GetSoundSpeed(iPoint) * Area; + if (!geometry->node[iPoint]->GetDomain()) continue; - /*--- Adjustment for grid movement ---*/ + Normal = geometry->vertex[iMarker][iVertex]->GetNormal(); + Area = 0.0; for (iDim = 0; iDim < nDim; iDim++) Area += Normal[iDim]*Normal[iDim]; Area = sqrt(Area); - if (dynamic_grid) { - su2double *GridVel = geometry->node[iPoint]->GetGridVel(); - ProjVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjVel += GridVel[iDim]*Normal[iDim]; - Mean_ProjVel -= ProjVel; - } + /*--- Mean Values ---*/ + + Mean_ProjVel = nodes->GetProjVel(iPoint,Normal); + Mean_SoundSpeed = nodes->GetSoundSpeed(iPoint) * Area; - /*--- Inviscid contribution ---*/ + /*--- Adjustment for grid movement ---*/ - Lambda = fabs(Mean_ProjVel) + Mean_SoundSpeed; - if (geometry->node[iPoint]->GetDomain()) { + if (dynamic_grid) { + su2double *GridVel = geometry->node[iPoint]->GetGridVel(); + ProjVel = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + ProjVel += GridVel[iDim]*Normal[iDim]; + Mean_ProjVel -= ProjVel; + } + + /*--- Inviscid contribution ---*/ + + Lambda = fabs(Mean_ProjVel) + Mean_SoundSpeed; nodes->AddMax_Lambda_Inv(iPoint,Lambda); - } - /*--- Viscous contribution ---*/ + /*--- Viscous contribution ---*/ - Mean_LaminarVisc = nodes->GetLaminarViscosity(iPoint); - Mean_EddyVisc = nodes->GetEddyViscosity(iPoint); - Mean_Density = nodes->GetDensity(iPoint); + 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; + 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()) nodes->AddMax_Lambda_Visc(iPoint, Lambda); + nodes->AddMax_Lambda_Visc(iPoint, Lambda); - } + } } } - /*--- Each element uses their own speed, steady state simulation ---*/ + /*--- Each element uses their own speed, steady state simulation. ---*/ + { + /*--- Thread-local variables for min/max reduction. ---*/ + su2double minDt = 1e30, maxDt = 0.0; + SU2_OMP(for schedule(static,omp_chunk_size) nowait) + for (iPoint = 0; iPoint < nPointDomain; iPoint++) { - for (iPoint = 0; iPoint < nPointDomain; iPoint++) { + Vol = geometry->node[iPoint]->GetVolume(); - Vol = geometry->node[iPoint]->GetVolume(); - - if (Vol != 0.0) { - 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(); - nodes->SetDelta_Time(iPoint,Local_Delta_Time); + if (Vol != 0.0) { + 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); + + minDt = min(minDt, Local_Delta_Time); + maxDt = max(maxDt, Local_Delta_Time); + + nodes->SetDelta_Time(iPoint, min(Local_Delta_Time, config->GetMax_DeltaTime())); + } + else { + nodes->SetDelta_Time(iPoint,0.0); + } } - else { - nodes->SetDelta_Time(iPoint,0.0); + /*--- Min/max over threads. ---*/ + SU2_OMP_CRITICAL + { + Min_Delta_Time = min(Min_Delta_Time, minDt); + Max_Delta_Time = max(Max_Delta_Time, maxDt); + Global_Delta_Time = Min_Delta_Time; } - + SU2_OMP_BARRIER } + /*--- Compute the min/max dt (in parallel, now over mpi ranks). ---*/ - /*--- Compute the max and the min dt (in parallel) ---*/ + SU2_OMP_MASTER if (config->GetComm_Level() == COMM_FULL) { -#ifdef HAVE_MPI - su2double rbuf_time, sbuf_time; - sbuf_time = Min_Delta_Time; - SU2_MPI::Reduce(&sbuf_time, &rbuf_time, 1, MPI_DOUBLE, MPI_MIN, MASTER_NODE, MPI_COMM_WORLD); - SU2_MPI::Bcast(&rbuf_time, 1, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); + su2double rbuf_time; + SU2_MPI::Allreduce(&Min_Delta_Time, &rbuf_time, 1, MPI_DOUBLE, MPI_MIN, MPI_COMM_WORLD); Min_Delta_Time = rbuf_time; - sbuf_time = Max_Delta_Time; - SU2_MPI::Reduce(&sbuf_time, &rbuf_time, 1, MPI_DOUBLE, MPI_MAX, MASTER_NODE, MPI_COMM_WORLD); - SU2_MPI::Bcast(&rbuf_time, 1, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); + SU2_MPI::Allreduce(&Max_Delta_Time, &rbuf_time, 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD); Max_Delta_Time = rbuf_time; -#endif } + SU2_OMP_BARRIER /*--- For exact time solution use the minimum delta time of the whole mesh ---*/ if (config->GetTime_Marching() == TIME_STEPPING) { -#ifdef HAVE_MPI - su2double rbuf_time, sbuf_time; - sbuf_time = Global_Delta_Time; - SU2_MPI::Reduce(&sbuf_time, &rbuf_time, 1, MPI_DOUBLE, MPI_MIN, MASTER_NODE, MPI_COMM_WORLD); - 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(); + /*--- 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. ---*/ + + SU2_OMP_MASTER + { + if (config->GetUnst_CFL() == 0.0) { + Global_Delta_Time = config->GetDelta_UnstTime(); + } + else { + Global_Delta_Time = Min_Delta_Time; + } + Max_Delta_Time = Global_Delta_Time; + + config->SetDelta_UnstTimeND(Global_Delta_Time); } - config->SetDelta_UnstTimeND(Global_Delta_Time); - for (iPoint = 0; iPoint < nPointDomain; iPoint++){ + SU2_OMP_BARRIER - /*--- Sets the regular CFL equal to the unsteady CFL ---*/ + /*--- Sets the regular CFL equal to the unsteady CFL. ---*/ + SU2_OMP_FOR_STAT(omp_chunk_size) + for (iPoint = 0; iPoint < nPointDomain; iPoint++) { 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; - } + } /*--- 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 = 1e30; - for (iPoint = 0; iPoint < nPointDomain; iPoint++){ + /*--- Thread-local variable for reduction. ---*/ + su2double glbDtND = 1e30; + + SU2_OMP(for schedule(static,omp_chunk_size) nowait) + for (iPoint = 0; iPoint < nPointDomain; iPoint++) { Global_Delta_UnstTimeND = min(Global_Delta_UnstTimeND,config->GetUnst_CFL()*Global_Delta_Time/nodes->GetLocalCFL(iPoint)); } + SU2_OMP_CRITICAL + Global_Delta_UnstTimeND = min(Global_Delta_UnstTimeND, glbDtND); + SU2_OMP_BARRIER -#ifdef HAVE_MPI - su2double rbuf_time, sbuf_time; - sbuf_time = Global_Delta_UnstTimeND; - SU2_MPI::Reduce(&sbuf_time, &rbuf_time, 1, MPI_DOUBLE, MPI_MIN, MASTER_NODE, MPI_COMM_WORLD); - SU2_MPI::Bcast(&rbuf_time, 1, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); - Global_Delta_UnstTimeND = rbuf_time; -#endif - config->SetDelta_UnstTimeND(Global_Delta_UnstTimeND); + SU2_OMP_MASTER + { + SU2_MPI::Allreduce(&Global_Delta_UnstTimeND, &glbDtND, 1, MPI_DOUBLE, MPI_MIN, MPI_COMM_WORLD); + Global_Delta_UnstTimeND = glbDtND; + + config->SetDelta_UnstTimeND(Global_Delta_UnstTimeND); + } + SU2_OMP_BARRIER } /*--- The pseudo local time (explicit integration) cannot be greater than the physical time ---*/ - if (dual_time) + + if (dual_time && !implicit) { + SU2_OMP_FOR_STAT(omp_chunk_size) for (iPoint = 0; iPoint < nPointDomain; iPoint++) { - if (!implicit) { - Local_Delta_Time = min((2.0/3.0)*config->GetDelta_UnstTimeND(), nodes->GetDelta_Time(iPoint)); - nodes->SetDelta_Time(iPoint,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); } + } + + } // end SU2_OMP_PARALLEL } From bbc7dafbedb5241bcd6cb47c34902245e6ab75fe Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Thu, 30 Jan 2020 17:10:48 +0000 Subject: [PATCH 060/118] reduce duplication off SetTime_Step --- SU2_CFD/include/solvers/CEulerSolver.hpp | 5 +- SU2_CFD/include/solvers/CNSSolver.hpp | 18 +- SU2_CFD/src/solvers/CEulerSolver.cpp | 61 ++++- SU2_CFD/src/solvers/CNSSolver.cpp | 269 ----------------------- 4 files changed, 56 insertions(+), 297 deletions(-) diff --git a/SU2_CFD/include/solvers/CEulerSolver.hpp b/SU2_CFD/include/solvers/CEulerSolver.hpp index a90bae05dffa..7b8a09785504 100644 --- a/SU2_CFD/include/solvers/CEulerSolver.hpp +++ b/SU2_CFD/include/solvers/CEulerSolver.hpp @@ -55,6 +55,9 @@ class CEulerSolver : public CSolver { Pressure_Inf, /*!< \brief Pressure at the infinity. */ *Velocity_Inf; /*!< \brief Flow Velocity vector at the infinity. */ + su2double Prandtl_Lam, /*!< \brief Laminar Prandtl number. */ + Prandtl_Turb; /*!< \brief Turbulent Prandtl number. */ + su2double *CD_Inv, /*!< \brief Drag coefficient (inviscid contribution) for each boundary. */ *CL_Inv, /*!< \brief Lift coefficient (inviscid contribution) for each boundary. */ @@ -428,7 +431,7 @@ class CEulerSolver : public CSolver { CSolver **solver_container, CConfig *config, unsigned short iMesh, - unsigned long Iteration) override; + unsigned long Iteration) final; /*! * \brief Compute the spatial integration using a centered scheme. diff --git a/SU2_CFD/include/solvers/CNSSolver.hpp b/SU2_CFD/include/solvers/CNSSolver.hpp index 86343ccbf0e9..ae61da93cbe1 100644 --- a/SU2_CFD/include/solvers/CNSSolver.hpp +++ b/SU2_CFD/include/solvers/CNSSolver.hpp @@ -39,8 +39,6 @@ class CNSSolver final : public CEulerSolver { private: su2double Viscosity_Inf; /*!< \brief Viscosity at the infinity. */ su2double Tke_Inf; /*!< \brief Turbulent kinetic energy at the infinity. */ - su2double Prandtl_Lam, /*!< \brief Laminar Prandtl number. */ - Prandtl_Turb; /*!< \brief Turbulent Prandtl number. */ su2double *CD_Visc, /*!< \brief Drag coefficient (viscous contribution) for each boundary. */ *CL_Visc, /*!< \brief Lift coefficient (viscous contribution) for each boundary. */ *CSF_Visc, /*!< \brief Side force coefficient (viscous contribution) for each boundary. */ @@ -292,20 +290,6 @@ class CNSSolver final : public CEulerSolver { */ inline su2double GetTke_Inf(void) const override { return Tke_Inf; } - /*! - * \brief Compute the time step for solving the Navier-Stokes equations with turbulence model. - * \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] Iteration - Index of the current iteration. - */ - void SetTime_Step(CGeometry *geometry, - CSolver **solver_container, - CConfig *config, - unsigned short iMesh, - unsigned long Iteration) override; - /*! * \brief Restart residual and compute gradients. * \param[in] geometry - Geometrical definition of the problem. @@ -583,4 +567,4 @@ class CNSSolver final : public CEulerSolver { CSolver** solver_container, CConfig* config) override; -}; \ No newline at end of file +}; diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index fa6fff1189ba..34d09e125412 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -2989,10 +2989,12 @@ unsigned long CEulerSolver::SetPrimitive_Variables(CSolver **solver_container, C void CEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh, unsigned long Iteration) { + const bool viscous = config->GetViscous(); const bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); const bool time_stepping = (config->GetTime_Marching() == TIME_STEPPING); const bool dual_time = (config->GetTime_Marching() == DT_STEPPING_1ST) || (config->GetTime_Marching() == DT_STEPPING_2ND); + const su2double K_v = 0.25; /*--- Init thread-shared variables to compute min/max values. * Critical sections are used for this instead of reduction @@ -3008,15 +3010,18 @@ void CEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, { const su2double *Normal = nullptr; - su2double Area, Vol, Mean_SoundSpeed = 0.0, Mean_ProjVel = 0.0, Lambda, Local_Delta_Time; + su2double Area, Vol, Mean_SoundSpeed, Mean_ProjVel, Lambda, Local_Delta_Time, Local_Delta_Time_Visc; + su2double Mean_LaminarVisc, Mean_EddyVisc, Mean_Density, Lambda_1, Lambda_2; unsigned long iEdge, iVertex, iPoint, jPoint; unsigned short iDim, iMarker; - /*--- Set maximum inviscid eigenvalue to zero, and compute sound speed ---*/ + /*--- Set maximum inviscid eigenvalue to zero, and compute sound speed and viscosity ---*/ SU2_OMP_FOR_STAT(omp_chunk_size) - for (iPoint = 0; iPoint < nPointDomain; iPoint++) + for (iPoint = 0; iPoint < nPointDomain; iPoint++) { nodes->SetMax_Lambda_Inv(iPoint,0.0); + nodes->SetMax_Lambda_Visc(iPoint,0.0); + } /*--- Loop interior edges ---*/ @@ -3052,8 +3057,8 @@ void CEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, /*--- Adjustment for grid movement ---*/ if (dynamic_grid) { - const su2double* GridVel_i = geometry->node[iPoint]->GetGridVel(); - const su2double* GridVel_j = geometry->node[jPoint]->GetGridVel(); + const su2double *GridVel_i = geometry->node[iPoint]->GetGridVel(); + const su2double *GridVel_j = geometry->node[jPoint]->GetGridVel(); for (iDim = 0; iDim < nDim; iDim++) Mean_ProjVel -= 0.5 * (GridVel_i[iDim] + GridVel_j[iDim]) * Normal[iDim]; @@ -3061,10 +3066,26 @@ void CEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, /*--- Inviscid contribution ---*/ - Lambda = fabs(Mean_ProjVel) + Mean_SoundSpeed; + Lambda = fabs(Mean_ProjVel) + Mean_SoundSpeed ; if (geometry->node[iPoint]->GetDomain()) nodes->AddMax_Lambda_Inv(iPoint,Lambda); if (geometry->node[jPoint]->GetDomain()) nodes->AddMax_Lambda_Inv(jPoint,Lambda); + /*--- Viscous contribution ---*/ + + if (!viscous) continue; + + 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()) nodes->AddMax_Lambda_Visc(iPoint, Lambda); + if (geometry->node[jPoint]->GetDomain()) nodes->AddMax_Lambda_Visc(jPoint, Lambda); + } } // end color loop @@ -3084,7 +3105,7 @@ void CEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, if (!geometry->node[iPoint]->GetDomain()) continue; Normal = geometry->vertex[iMarker][iVertex]->GetNormal(); - Area = 0.0; for (iDim = 0; iDim < nDim; iDim++) Area += pow(Normal[iDim],2); Area = sqrt(Area); + Area = 0.0; for (iDim = 0; iDim < nDim; iDim++) Area += Normal[iDim]*Normal[iDim]; Area = sqrt(Area); /*--- Mean Values ---*/ @@ -3094,15 +3115,31 @@ void CEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, /*--- Adjustment for grid movement ---*/ if (dynamic_grid) { - const su2double* GridVel = geometry->node[iPoint]->GetGridVel(); + const su2double *GridVel = geometry->node[iPoint]->GetGridVel(); for (iDim = 0; iDim < nDim; iDim++) Mean_ProjVel -= GridVel[iDim]*Normal[iDim]; } /*--- Inviscid contribution ---*/ + Lambda = fabs(Mean_ProjVel) + Mean_SoundSpeed; nodes->AddMax_Lambda_Inv(iPoint,Lambda); + + /*--- Viscous contribution ---*/ + + if (!viscous) continue; + + 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; + + nodes->AddMax_Lambda_Visc(iPoint, Lambda); + } } } @@ -3120,6 +3157,11 @@ void CEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, if (Vol != 0.0) { Local_Delta_Time = nodes->GetLocalCFL(iPoint)*Vol / nodes->GetMax_Lambda_Inv(iPoint); + if(viscous) { + 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); + } + minDt = min(minDt, Local_Delta_Time); maxDt = max(maxDt, Local_Delta_Time); @@ -3153,7 +3195,6 @@ void CEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, SU2_OMP_BARRIER /*--- For exact time solution use the minimum delta time of the whole mesh. ---*/ - if (time_stepping) { /*--- If the unsteady CFL is set to zero, it uses the defined unsteady time step, @@ -3192,7 +3233,7 @@ void CEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, SU2_OMP(for schedule(static,omp_chunk_size) nowait) for (iPoint = 0; iPoint < nPointDomain; iPoint++) { - glbDtND = min(glbDtND, config->GetUnst_CFL()*Global_Delta_Time/nodes->GetLocalCFL(iPoint)); + Global_Delta_UnstTimeND = min(Global_Delta_UnstTimeND,config->GetUnst_CFL()*Global_Delta_Time/nodes->GetLocalCFL(iPoint)); } SU2_OMP_CRITICAL Global_Delta_UnstTimeND = min(Global_Delta_UnstTimeND, glbDtND); diff --git a/SU2_CFD/src/solvers/CNSSolver.cpp b/SU2_CFD/src/solvers/CNSSolver.cpp index b84de0e57d57..cbabd6a8053d 100644 --- a/SU2_CFD/src/solvers/CNSSolver.cpp +++ b/SU2_CFD/src/solvers/CNSSolver.cpp @@ -1124,275 +1124,6 @@ unsigned long CNSSolver::SetPrimitive_Variables(CSolver **solver_container, CCon return nonPhysicalPoints; } -void CNSSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, CConfig *config, - unsigned short iMesh, unsigned long Iteration) { - - const bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - const bool dual_time = (config->GetTime_Marching() == DT_STEPPING_1ST) || - (config->GetTime_Marching() == DT_STEPPING_2ND); - const su2double K_v = 0.25; - - /*--- Init thread-shared variables to compute min/max values. - * Critical sections are used for this instead of reduction - * clauses for compatibility with OpenMP 2.0 (Windows...). ---*/ - - Min_Delta_Time = 1e30; Max_Delta_Time = 0.0; - - su2double Global_Delta_Time, Global_Delta_UnstTimeND = 1e30; - - /*--- Start OpenMP parallel section. ---*/ - - SU2_OMP_PARALLEL - { - - const su2double *Normal = nullptr; - su2double Area, Vol, Mean_SoundSpeed = 0.0, Mean_ProjVel = 0.0, Lambda, Local_Delta_Time, Local_Delta_Time_Visc, - Mean_LaminarVisc = 0.0, Mean_EddyVisc = 0.0, Mean_Density = 0.0, Lambda_1, Lambda_2, ProjVel; - unsigned long iEdge, iVertex, iPoint = 0, jPoint; - unsigned short iDim, iMarker; - - /*--- Set maximum inviscid eigenvalue to zero, and compute sound speed and viscosity ---*/ - - SU2_OMP_FOR_STAT(omp_chunk_size) - for (iPoint = 0; iPoint < nPointDomain; iPoint++) { - nodes->SetMax_Lambda_Inv(iPoint,0.0); - nodes->SetMax_Lambda_Visc(iPoint,0.0); - } - - /*--- Loop interior edges ---*/ - -#ifdef HAVE_OMP - /*--- Chunk size is at least OMP_MIN_SIZE and a multiple of the color group size. ---*/ - auto chunkSize = roundUpDiv(OMP_MIN_SIZE, ColorGroupSize)*ColorGroupSize; - - /*--- Loop over edge colors. ---*/ - for (auto color : EdgeColoring) - { - SU2_OMP_FOR_DYN(chunkSize) - for(auto k = 0ul; k < color.size; ++k) { - - iEdge = color.indices[k]; -#else - /*--- Natural coloring. ---*/ - { - for (iEdge = 0; iEdge < geometry->GetnEdge(); iEdge++) { -#endif - /*--- Point identification, Normal vector and area ---*/ - - iPoint = geometry->edge[iEdge]->GetNode(0); - jPoint = geometry->edge[iEdge]->GetNode(1); - - Normal = geometry->edge[iEdge]->GetNormal(); - Area = 0.0; for (iDim = 0; iDim < nDim; iDim++) Area += pow(Normal[iDim],2); Area = sqrt(Area); - - /*--- Mean Values ---*/ - - 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 ---*/ - - if (dynamic_grid) { - const su2double *GridVel_i = geometry->node[iPoint]->GetGridVel(); - const su2double *GridVel_j = geometry->node[jPoint]->GetGridVel(); - - for (iDim = 0; iDim < nDim; iDim++) - Mean_ProjVel -= 0.5 * (GridVel_i[iDim] + GridVel_j[iDim]) * Normal[iDim]; - } - - /*--- Inviscid contribution ---*/ - - Lambda = fabs(Mean_ProjVel) + Mean_SoundSpeed ; - 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*(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()) nodes->AddMax_Lambda_Visc(iPoint, Lambda); - if (geometry->node[jPoint]->GetDomain()) nodes->AddMax_Lambda_Visc(jPoint, Lambda); - - } - } // end color loop - - /*--- Loop boundary edges ---*/ - - for (iMarker = 0; iMarker < geometry->GetnMarker(); iMarker++) { - if ((config->GetMarker_All_KindBC(iMarker) != INTERNAL_BOUNDARY) && - (config->GetMarker_All_KindBC(iMarker) != PERIODIC_BOUNDARY)) { - - SU2_OMP_FOR_STAT(OMP_MIN_SIZE) - for (iVertex = 0; iVertex < geometry->GetnVertex(iMarker); iVertex++) { - - /*--- Point identification, Normal vector and area ---*/ - - iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); - - if (!geometry->node[iPoint]->GetDomain()) continue; - - Normal = geometry->vertex[iMarker][iVertex]->GetNormal(); - Area = 0.0; for (iDim = 0; iDim < nDim; iDim++) Area += Normal[iDim]*Normal[iDim]; Area = sqrt(Area); - - /*--- Mean Values ---*/ - - Mean_ProjVel = nodes->GetProjVel(iPoint,Normal); - Mean_SoundSpeed = nodes->GetSoundSpeed(iPoint) * Area; - - /*--- Adjustment for grid movement ---*/ - - if (dynamic_grid) { - su2double *GridVel = geometry->node[iPoint]->GetGridVel(); - ProjVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjVel += GridVel[iDim]*Normal[iDim]; - Mean_ProjVel -= ProjVel; - } - - /*--- Inviscid contribution ---*/ - - Lambda = fabs(Mean_ProjVel) + Mean_SoundSpeed; - nodes->AddMax_Lambda_Inv(iPoint,Lambda); - - /*--- Viscous contribution ---*/ - - 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; - - nodes->AddMax_Lambda_Visc(iPoint, Lambda); - - } - } - } - - /*--- Each element uses their own speed, steady state simulation. ---*/ - { - /*--- Thread-local variables for min/max reduction. ---*/ - su2double minDt = 1e30, maxDt = 0.0; - - SU2_OMP(for schedule(static,omp_chunk_size) nowait) - for (iPoint = 0; iPoint < nPointDomain; iPoint++) { - - Vol = geometry->node[iPoint]->GetVolume(); - - if (Vol != 0.0) { - 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); - - minDt = min(minDt, Local_Delta_Time); - maxDt = max(maxDt, Local_Delta_Time); - - nodes->SetDelta_Time(iPoint, min(Local_Delta_Time, config->GetMax_DeltaTime())); - } - else { - nodes->SetDelta_Time(iPoint,0.0); - } - } - /*--- Min/max over threads. ---*/ - SU2_OMP_CRITICAL - { - Min_Delta_Time = min(Min_Delta_Time, minDt); - Max_Delta_Time = max(Max_Delta_Time, maxDt); - Global_Delta_Time = Min_Delta_Time; - } - SU2_OMP_BARRIER - } - - /*--- Compute the min/max dt (in parallel, now over mpi ranks). ---*/ - - SU2_OMP_MASTER - if (config->GetComm_Level() == COMM_FULL) { - su2double rbuf_time; - SU2_MPI::Allreduce(&Min_Delta_Time, &rbuf_time, 1, MPI_DOUBLE, MPI_MIN, MPI_COMM_WORLD); - Min_Delta_Time = rbuf_time; - - SU2_MPI::Allreduce(&Max_Delta_Time, &rbuf_time, 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD); - Max_Delta_Time = rbuf_time; - } - SU2_OMP_BARRIER - - /*--- For exact time solution use the minimum delta time of the whole mesh ---*/ - if (config->GetTime_Marching() == TIME_STEPPING) { - - /*--- 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. ---*/ - - SU2_OMP_MASTER - { - if (config->GetUnst_CFL() == 0.0) { - Global_Delta_Time = config->GetDelta_UnstTime(); - } - else { - Global_Delta_Time = Min_Delta_Time; - } - Max_Delta_Time = Global_Delta_Time; - - config->SetDelta_UnstTimeND(Global_Delta_Time); - } - SU2_OMP_BARRIER - - /*--- Sets the regular CFL equal to the unsteady CFL. ---*/ - - SU2_OMP_FOR_STAT(omp_chunk_size) - for (iPoint = 0; iPoint < nPointDomain; iPoint++) { - nodes->SetLocalCFL(iPoint, config->GetUnst_CFL()); - nodes->SetDelta_Time(iPoint, 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)) { - - /*--- Thread-local variable for reduction. ---*/ - su2double glbDtND = 1e30; - - SU2_OMP(for schedule(static,omp_chunk_size) nowait) - for (iPoint = 0; iPoint < nPointDomain; iPoint++) { - Global_Delta_UnstTimeND = min(Global_Delta_UnstTimeND,config->GetUnst_CFL()*Global_Delta_Time/nodes->GetLocalCFL(iPoint)); - } - SU2_OMP_CRITICAL - Global_Delta_UnstTimeND = min(Global_Delta_UnstTimeND, glbDtND); - SU2_OMP_BARRIER - - SU2_OMP_MASTER - { - SU2_MPI::Allreduce(&Global_Delta_UnstTimeND, &glbDtND, 1, MPI_DOUBLE, MPI_MIN, MPI_COMM_WORLD); - Global_Delta_UnstTimeND = glbDtND; - - config->SetDelta_UnstTimeND(Global_Delta_UnstTimeND); - } - SU2_OMP_BARRIER - } - - /*--- The pseudo local time (explicit integration) cannot be greater than the physical time ---*/ - - if (dual_time && !implicit) { - SU2_OMP_FOR_STAT(omp_chunk_size) - for (iPoint = 0; iPoint < nPointDomain; iPoint++) { - Local_Delta_Time = min((2.0/3.0)*config->GetDelta_UnstTimeND(), nodes->GetDelta_Time(iPoint)); - nodes->SetDelta_Time(iPoint, Local_Delta_Time); - } - } - - } // end SU2_OMP_PARALLEL - -} - void CNSSolver::Viscous_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, CConfig *config, unsigned short iMesh, unsigned short iRKStep) { From 713c84f741818f58fdc31d5bef6284feda6ca1f2 Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Thu, 30 Jan 2020 17:17:59 +0000 Subject: [PATCH 061/118] pass one more dim of numerics in viscous residual --- SU2_CFD/include/solvers/CAdjNSSolver.hpp | 4 ++-- SU2_CFD/include/solvers/CAdjTurbSolver.hpp | 4 ++-- SU2_CFD/include/solvers/CHeatSolverFVM.hpp | 4 ++-- SU2_CFD/include/solvers/CIncNSSolver.hpp | 6 +++--- SU2_CFD/include/solvers/CNSSolver.hpp | 4 ++-- SU2_CFD/include/solvers/CSolver.hpp | 4 ++-- SU2_CFD/include/solvers/CTransLMSolver.hpp | 4 ++-- SU2_CFD/include/solvers/CTurbSolver.hpp | 4 ++-- SU2_CFD/src/integration_structure.cpp | 2 +- SU2_CFD/src/solvers/CAdjNSSolver.cpp | 5 ++++- SU2_CFD/src/solvers/CAdjTurbSolver.cpp | 7 +++++-- SU2_CFD/src/solvers/CHeatSolverFVM.cpp | 5 ++++- SU2_CFD/src/solvers/CIncNSSolver.cpp | 4 +++- SU2_CFD/src/solvers/CNSSolver.cpp | 4 +++- SU2_CFD/src/solvers/CTransLMSolver.cpp | 5 ++++- SU2_CFD/src/solvers/CTurbSolver.cpp | 5 ++++- 16 files changed, 45 insertions(+), 26 deletions(-) diff --git a/SU2_CFD/include/solvers/CAdjNSSolver.hpp b/SU2_CFD/include/solvers/CAdjNSSolver.hpp index 2abf49f71452..73fb457d55e8 100644 --- a/SU2_CFD/include/solvers/CAdjNSSolver.hpp +++ b/SU2_CFD/include/solvers/CAdjNSSolver.hpp @@ -124,7 +124,7 @@ class CAdjNSSolver final : public CAdjEulerSolver { * \brief Compute the viscous sensitivity of the functional. * \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] numerics_container - Description of the numerical method. * \param[in] config - Definition of the particular problem. */ void Viscous_Sensitivity(CGeometry *geometry, @@ -143,7 +143,7 @@ class CAdjNSSolver final : public CAdjEulerSolver { */ void Viscous_Residual(CGeometry *geometry, CSolver **solver_container, - CNumerics *numerics, + CNumerics **numerics_container, CConfig *config, unsigned short iMesh, unsigned short iRKStep) override; diff --git a/SU2_CFD/include/solvers/CAdjTurbSolver.hpp b/SU2_CFD/include/solvers/CAdjTurbSolver.hpp index 48a85fb6afc2..db3744316d56 100644 --- a/SU2_CFD/include/solvers/CAdjTurbSolver.hpp +++ b/SU2_CFD/include/solvers/CAdjTurbSolver.hpp @@ -153,14 +153,14 @@ class CAdjTurbSolver final : public CSolver { * \brief Compute the viscous residuals for the turbulent adjoint equation. * \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] numerics_container - Description of the numerical method. * \param[in] config - Definition of the particular problem. * \param[in] iMesh - Index of the mesh in multigrid computations. * \param[in] iRKStep - Current step of the Runge-Kutta iteration. */ void Viscous_Residual(CGeometry *geometry, CSolver **solver_container, - CNumerics *numerics, + CNumerics **numerics_container, CConfig *config, unsigned short iMesh, unsigned short iRKStep) override; diff --git a/SU2_CFD/include/solvers/CHeatSolverFVM.hpp b/SU2_CFD/include/solvers/CHeatSolverFVM.hpp index 0d7df2235d2e..62a7a18be397 100644 --- a/SU2_CFD/include/solvers/CHeatSolverFVM.hpp +++ b/SU2_CFD/include/solvers/CHeatSolverFVM.hpp @@ -166,14 +166,14 @@ class CHeatSolverFVM final : public CSolver { * \brief Compute the viscous residuals for the turbulent equation. * \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] numerics_container - Description of the numerical method. * \param[in] config - Definition of the particular problem. * \param[in] iMesh - Index of the mesh in multigrid computations. * \param[in] iRKStep - Current step of the Runge-Kutta iteration. */ void Viscous_Residual(CGeometry *geometry, CSolver **solver_container, - CNumerics *numerics, + CNumerics **numerics_container, CConfig *config, unsigned short iMesh, unsigned short iRKStep) override; diff --git a/SU2_CFD/include/solvers/CIncNSSolver.hpp b/SU2_CFD/include/solvers/CIncNSSolver.hpp index 628b799d987c..6b980c4d5919 100644 --- a/SU2_CFD/include/solvers/CIncNSSolver.hpp +++ b/SU2_CFD/include/solvers/CIncNSSolver.hpp @@ -437,14 +437,14 @@ class CIncNSSolver final : public CIncEulerSolver { * \brief Compute the viscous residuals. * \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] numerics_container - Description of the numerical method. * \param[in] config - Definition of the particular problem. * \param[in] iMesh - Index of the mesh in multigrid computations. * \param[in] iRKStep - Current step of the Runge-Kutta iteration. */ void Viscous_Residual(CGeometry *geometry, CSolver **solver_container, - CNumerics *numerics, + CNumerics **numerics_container, CConfig *config, unsigned short iMesh, unsigned short iRKStep) override; @@ -525,4 +525,4 @@ class CIncNSSolver final : public CIncEulerSolver { */ inline void SetOmega_Max(su2double val_omega_max) override { Omega_Max = val_omega_max; } -}; \ No newline at end of file +}; diff --git a/SU2_CFD/include/solvers/CNSSolver.hpp b/SU2_CFD/include/solvers/CNSSolver.hpp index ae61da93cbe1..4abfe3be1f8b 100644 --- a/SU2_CFD/include/solvers/CNSSolver.hpp +++ b/SU2_CFD/include/solvers/CNSSolver.hpp @@ -452,14 +452,14 @@ class CNSSolver final : public CEulerSolver { * \brief Compute the viscous residuals. * \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] numerics_container - Description of the numerical method. * \param[in] config - Definition of the particular problem. * \param[in] iMesh - Index of the mesh in multigrid computations. * \param[in] iRKStep - Current step of the Runge-Kutta iteration. */ void Viscous_Residual(CGeometry *geometry, CSolver **solver_container, - CNumerics *numerics, + CNumerics **numerics_container, CConfig *config, unsigned short iMesh, unsigned short iRKStep) override; diff --git a/SU2_CFD/include/solvers/CSolver.hpp b/SU2_CFD/include/solvers/CSolver.hpp index 05014bb78ce0..edce9df2958e 100644 --- a/SU2_CFD/include/solvers/CSolver.hpp +++ b/SU2_CFD/include/solvers/CSolver.hpp @@ -1707,14 +1707,14 @@ class CSolver { * \brief A virtual member. * \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] numerics_container - Description of the numerical method. * \param[in] config - Definition of the particular problem. * \param[in] iMesh - Index of the mesh in multigrid computations. * \param[in] iRKStep - Current step of the Runge-Kutta iteration. */ inline virtual void Viscous_Residual(CGeometry *geometry, CSolver **solver_container, - CNumerics *numerics, + CNumerics **numerics_container, CConfig *config, unsigned short iMesh, unsigned short iRKStep) { } diff --git a/SU2_CFD/include/solvers/CTransLMSolver.hpp b/SU2_CFD/include/solvers/CTransLMSolver.hpp index 6099ca4573a7..c6058279a814 100644 --- a/SU2_CFD/include/solvers/CTransLMSolver.hpp +++ b/SU2_CFD/include/solvers/CTransLMSolver.hpp @@ -106,14 +106,14 @@ class CTransLMSolver final : public CTurbSolver { * \brief Compute the viscous residuals for the turbulent equation. * \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] numerics_container - Description of the numerical method. * \param[in] config - Definition of the particular problem. * \param[in] iMesh - Index of the mesh in multigrid computations. * \param[in] iRKStep - Current step of the Runge-Kutta iteration. */ void Viscous_Residual(CGeometry *geometry, CSolver **solver_container, - CNumerics *numerics, + CNumerics **numerics_container, CConfig *config, unsigned short iMesh, unsigned short iRKStep) override; diff --git a/SU2_CFD/include/solvers/CTurbSolver.hpp b/SU2_CFD/include/solvers/CTurbSolver.hpp index 464b86eb8b04..40db35850d69 100644 --- a/SU2_CFD/include/solvers/CTurbSolver.hpp +++ b/SU2_CFD/include/solvers/CTurbSolver.hpp @@ -98,14 +98,14 @@ class CTurbSolver : public CSolver { * \brief Compute the viscous residuals for the turbulent equation. * \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] numerics_container - Description of the numerical method. * \param[in] config - Definition of the particular problem. * \param[in] iMesh - Index of the mesh in multigrid computations. * \param[in] iRKStep - Current step of the Runge-Kutta iteration. */ void Viscous_Residual(CGeometry *geometry, CSolver **solver_container, - CNumerics *numerics, + CNumerics **numerics_container, CConfig *config, unsigned short iMesh, unsigned short iRKStep) override; diff --git a/SU2_CFD/src/integration_structure.cpp b/SU2_CFD/src/integration_structure.cpp index f0aa3b49af3c..a59f1bc15dee 100644 --- a/SU2_CFD/src/integration_structure.cpp +++ b/SU2_CFD/src/integration_structure.cpp @@ -75,7 +75,7 @@ void CIntegration::Space_Integration(CGeometry *geometry, /*--- Compute viscous residuals ---*/ - solver_container[MainSolver]->Viscous_Residual(geometry, solver_container, numerics[VISC_TERM], config, iMesh, iRKStep); + solver_container[MainSolver]->Viscous_Residual(geometry, solver_container, numerics, config, iMesh, iRKStep); /*--- Compute source term residuals ---*/ diff --git a/SU2_CFD/src/solvers/CAdjNSSolver.cpp b/SU2_CFD/src/solvers/CAdjNSSolver.cpp index 6569f563e43e..66bf404f5a1a 100644 --- a/SU2_CFD/src/solvers/CAdjNSSolver.cpp +++ b/SU2_CFD/src/solvers/CAdjNSSolver.cpp @@ -416,8 +416,11 @@ void CAdjNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container } -void CAdjNSSolver::Viscous_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, +void CAdjNSSolver::Viscous_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics_container, CConfig *config, unsigned short iMesh, unsigned short iRKStep) { + + CNumerics* numerics = numerics_container[VISC_TERM]; + unsigned long iPoint, jPoint, iEdge; bool implicit = (config->GetKind_TimeIntScheme_AdjFlow() == EULER_IMPLICIT); diff --git a/SU2_CFD/src/solvers/CAdjTurbSolver.cpp b/SU2_CFD/src/solvers/CAdjTurbSolver.cpp index 713e7f22eb46..3eb219c70317 100644 --- a/SU2_CFD/src/solvers/CAdjTurbSolver.cpp +++ b/SU2_CFD/src/solvers/CAdjTurbSolver.cpp @@ -343,8 +343,11 @@ void CAdjTurbSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_conta } -void CAdjTurbSolver::Viscous_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, CConfig *config, - unsigned short iMesh, unsigned short iRKStep) { +void CAdjTurbSolver::Viscous_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics_container, + CConfig *config, unsigned short iMesh, unsigned short iRKStep) { + + CNumerics* numerics = numerics_container[VISC_TERM]; + unsigned long iEdge, iPoint, jPoint; su2double *Coord_i, *Coord_j; diff --git a/SU2_CFD/src/solvers/CHeatSolverFVM.cpp b/SU2_CFD/src/solvers/CHeatSolverFVM.cpp index 60b43a901708..ed38a00bcfb1 100644 --- a/SU2_CFD/src/solvers/CHeatSolverFVM.cpp +++ b/SU2_CFD/src/solvers/CHeatSolverFVM.cpp @@ -650,7 +650,10 @@ void CHeatSolverFVM::Upwind_Residual(CGeometry *geometry, CSolver **solver_conta } -void CHeatSolverFVM::Viscous_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, CConfig *config, unsigned short iMesh, unsigned short iRKStep) { +void CHeatSolverFVM::Viscous_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics_container, + CConfig *config, unsigned short iMesh, unsigned short iRKStep) { + + CNumerics* numerics = numerics_container[VISC_TERM]; su2double laminar_viscosity, Prandtl_Lam, Prandtl_Turb, eddy_viscosity_i, eddy_viscosity_j, thermal_diffusivity_i, thermal_diffusivity_j, Temp_i, Temp_j, **Temp_i_Grad, **Temp_j_Grad; diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index 18b8e09f6c6c..927704904064 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -1086,9 +1086,11 @@ void CIncNSSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, } -void CIncNSSolver::Viscous_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, +void CIncNSSolver::Viscous_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics_container, CConfig *config, unsigned short iMesh, unsigned short iRKStep) { + CNumerics* numerics = numerics_container[VISC_TERM]; + unsigned long iPoint, jPoint, iEdge; bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); diff --git a/SU2_CFD/src/solvers/CNSSolver.cpp b/SU2_CFD/src/solvers/CNSSolver.cpp index cbabd6a8053d..31331e9602b6 100644 --- a/SU2_CFD/src/solvers/CNSSolver.cpp +++ b/SU2_CFD/src/solvers/CNSSolver.cpp @@ -1124,9 +1124,11 @@ unsigned long CNSSolver::SetPrimitive_Variables(CSolver **solver_container, CCon return nonPhysicalPoints; } -void CNSSolver::Viscous_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, +void CNSSolver::Viscous_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics_container, CConfig *config, unsigned short iMesh, unsigned short iRKStep) { + CNumerics* numerics = numerics_container[VISC_TERM]; + unsigned long iPoint, jPoint, iEdge; bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); diff --git a/SU2_CFD/src/solvers/CTransLMSolver.cpp b/SU2_CFD/src/solvers/CTransLMSolver.cpp index ef809beab789..291e12d6c4cd 100644 --- a/SU2_CFD/src/solvers/CTransLMSolver.cpp +++ b/SU2_CFD/src/solvers/CTransLMSolver.cpp @@ -297,8 +297,11 @@ void CTransLMSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_conta } -void CTransLMSolver::Viscous_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, +void CTransLMSolver::Viscous_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics_container, CConfig *config, unsigned short iMesh, unsigned short iRKStep) { + + CNumerics* numerics = numerics_container[VISC_TERM]; + unsigned long iEdge, iPoint, jPoint; for (iEdge = 0; iEdge < geometry->GetnEdge(); iEdge++) { diff --git a/SU2_CFD/src/solvers/CTurbSolver.cpp b/SU2_CFD/src/solvers/CTurbSolver.cpp index 5dbeeea820a8..2e5c312b552d 100644 --- a/SU2_CFD/src/solvers/CTurbSolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSolver.cpp @@ -201,8 +201,11 @@ void CTurbSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_containe } -void CTurbSolver::Viscous_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, +void CTurbSolver::Viscous_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics_container, CConfig *config, unsigned short iMesh, unsigned short iRKStep) { + + CNumerics* numerics = numerics_container[VISC_TERM]; + unsigned long iEdge, iPoint, jPoint; for (iEdge = 0; iEdge < geometry->GetnEdge(); iEdge++) { From df42c31e26e74942a305790ac27ce72d002014a9 Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Thu, 30 Jan 2020 18:00:18 +0000 Subject: [PATCH 062/118] parallel NSSolver viscous residual loop --- .../include/numerics/flow/flow_diffusion.hpp | 76 ++++---- SU2_CFD/src/numerics/flow/flow_diffusion.cpp | 175 +++++++++--------- SU2_CFD/src/solvers/CIncNSSolver.cpp | 8 +- SU2_CFD/src/solvers/CNSSolver.cpp | 80 +++++--- 4 files changed, 183 insertions(+), 156 deletions(-) diff --git a/SU2_CFD/include/numerics/flow/flow_diffusion.hpp b/SU2_CFD/include/numerics/flow/flow_diffusion.hpp index 8c1e4807eef7..688fe8d79225 100644 --- a/SU2_CFD/include/numerics/flow/flow_diffusion.hpp +++ b/SU2_CFD/include/numerics/flow/flow_diffusion.hpp @@ -43,23 +43,29 @@ */ class CAvgGrad_Base : public CNumerics { protected: - const unsigned short nPrimVar; /*!< \brief The size of the primitive variable array used in the numerics class. */ - const bool correct_gradient; /*!< \brief Apply a correction to the gradient term */ - bool implicit; /*!< \brief Implicit calculus. */ - su2double *heat_flux_vector, /*!< \brief Flux of total energy due to molecular and turbulent diffusion */ - *heat_flux_jac_i, /*!< \brief Jacobian of the molecular + turbulent heat flux vector, projected onto the normal vector. */ - **tau_jacobian_i; /*!< \brief Jacobian of the viscous + turbulent stress tensor, projected onto the normal vector. */ - su2double *Mean_PrimVar, /*!< \brief Mean primitive variables. */ - *PrimVar_i, *PrimVar_j, /*!< \brief Primitives variables at point i and 1. */ - **Mean_GradPrimVar, /*!< \brief Mean value of the gradient. */ - Mean_Laminar_Viscosity, /*!< \brief Mean value of the viscosity. */ - Mean_Eddy_Viscosity, /*!< \brief Mean value of the eddy viscosity. */ - Mean_turb_ke, /*!< \brief Mean value of the turbulent kinetic energy. */ - Mean_TauWall, /*!< \brief Mean wall shear stress (wall functions). */ - TauWall_i, TauWall_j, /*!< \brief Wall shear stress at point i and j (wall functions). */ - dist_ij_2, /*!< \brief Length of the edge and face, squared */ - *Proj_Mean_GradPrimVar_Edge, /*!< \brief Inner product of the Mean gradient and the edge vector. */ - *Edge_Vector; /*!< \brief Vector from point i to point j. */ + const unsigned short nPrimVar; /*!< \brief The size of the primitive variable array used in the numerics class. */ + const bool correct_gradient; /*!< \brief Apply a correction to the gradient term */ + bool implicit = false; /*!< \brief Implicit calculus. */ + su2double + heat_flux_vector[MAXNDIM] = {0.0}, /*!< \brief Flux of total energy due to molecular and turbulent diffusion */ + *heat_flux_jac_i = nullptr, /*!< \brief Jacobian of the molecular + turbulent heat flux vector, projected onto the normal vector. */ + **tau_jacobian_i = nullptr; /*!< \brief Jacobian of the viscous + turbulent stress tensor, projected onto the normal vector. */ + su2double *Mean_PrimVar = nullptr; /*!< \brief Mean primitive variables. */ + const su2double + *PrimVar_i = nullptr, + *PrimVar_j = nullptr; /*!< \brief Primitives variables at point i and j. */ + su2double **Mean_GradPrimVar = nullptr, /*!< \brief Mean value of the gradient. */ + Mean_Laminar_Viscosity, /*!< \brief Mean value of the viscosity. */ + Mean_Eddy_Viscosity, /*!< \brief Mean value of the eddy viscosity. */ + Mean_turb_ke, /*!< \brief Mean value of the turbulent kinetic energy. */ + Mean_TauWall, /*!< \brief Mean wall shear stress (wall functions). */ + TauWall_i, TauWall_j, /*!< \brief Wall shear stress at point i and j (wall functions). */ + dist_ij_2, /*!< \brief Length of the edge and face, squared */ + Edge_Vector[MAXNDIM] = {0.0}, /*!< \brief Vector from point i to point j. */ + *Proj_Mean_GradPrimVar_Edge = nullptr; /*!< \brief Inner product of the Mean gradient and the edge vector. */ + + su2double** Jacobian_i = nullptr; /*!< \brief The Jacobian w.r.t. point i after computation. */ + su2double** Jacobian_j = nullptr; /*!< \brief The Jacobian w.r.t. point j after computation. */ /*! * \brief Add a correction using a Quadratic Constitutive Relation @@ -182,7 +188,7 @@ class CAvgGrad_Base : public CNumerics { * \param[in] Eig_Val_Comp: Defines type of eigenspace perturbation * \param[in] beta_delta: Defines the amount of eigenvalue perturbation */ - void SetPerturbedRSM(su2double turb_ke, CConfig *config); + void SetPerturbedRSM(su2double turb_ke, const CConfig* config); /*! * \brief Get the mean rate of strain matrix based on velocity gradients @@ -202,7 +208,7 @@ class CAvgGrad_Base : public CNumerics { */ CAvgGrad_Base(unsigned short val_nDim, unsigned short val_nVar, unsigned short val_nPrimVar, - bool val_correct_grad, CConfig *config); + bool val_correct_grad, const CConfig* config); /*! * \brief Destructor of the class. @@ -257,7 +263,7 @@ class CAvgGrad_Base : public CNumerics { * \ingroup ViscDiscr * \author A. Bueno, and F. Palacios */ -class CAvgGrad_Flow : public CAvgGrad_Base { +class CAvgGrad_Flow final : public CAvgGrad_Base { public: /*! * \brief Constructor of the class. @@ -267,16 +273,14 @@ class CAvgGrad_Flow : public CAvgGrad_Base { * \param[in] config - Definition of the particular problem. */ CAvgGrad_Flow(unsigned short val_nDim, unsigned short val_nVar, - bool val_correct_grad, CConfig *config); + bool val_correct_grad, const CConfig* config); /*! * \brief Compute the viscous flow residual using an average of gradients. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). * \param[in] config - Definition of the particular problem. + * \return A lightweight const-view (read-only) of the residual/flux and Jacobians. */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + ResidualType<> ComputeResidual(const CConfig* config) override; /*! * \brief Compute the heat flux due to molecular and turbulent diffusivity @@ -314,7 +318,7 @@ class CAvgGrad_Flow : public CAvgGrad_Base { * \ingroup ViscDiscr * \author A. Bueno, F. Palacios, T. Economon */ -class CAvgGradInc_Flow : public CAvgGrad_Base { +class CAvgGradInc_Flow final : public CAvgGrad_Base { private: su2double Mean_Thermal_Conductivity; /*!< \brief Mean value of the effective thermal conductivity. */ bool energy; /*!< \brief computation with the energy equation. */ @@ -357,16 +361,15 @@ class CAvgGradInc_Flow : public CAvgGrad_Base { * \param[in] config - Definition of the particular problem. */ CAvgGradInc_Flow(unsigned short val_nDim, unsigned short val_nVar, - bool val_correct_grad, CConfig *config); + bool val_correct_grad, const CConfig* config); /*! * \brief Compute the viscous flow residual using an average of gradients. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). * \param[in] config - Definition of the particular problem. + * \return A lightweight const-view (read-only) of the residual/flux and Jacobians. */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + ResidualType<> ComputeResidual(const CConfig* config) override; + }; @@ -376,7 +379,7 @@ class CAvgGradInc_Flow : public CAvgGrad_Base { * \ingroup ViscDiscr * \author M.Pini, S. Vitale */ -class CGeneralAvgGrad_Flow : public CAvgGrad_Base { +class CGeneralAvgGrad_Flow final : public CAvgGrad_Base { private: su2double Mean_SecVar[2], /*!< \brief Mean secondary variables. */ Mean_Thermal_Conductivity, /*!< \brief Mean value of the thermal conductivity. */ @@ -425,14 +428,13 @@ class CGeneralAvgGrad_Flow : public CAvgGrad_Base { * \param[in] val_correct_grad - Apply a correction to the gradient * \param[in] config - Definition of the particular problem. */ - CGeneralAvgGrad_Flow(unsigned short val_nDim, unsigned short val_nVar, bool val_correct_grad, CConfig *config); + CGeneralAvgGrad_Flow(unsigned short val_nDim, unsigned short val_nVar, bool val_correct_grad, const CConfig* config); /*! * \brief Compute the viscous flow residual using an average of gradients. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). * \param[in] config - Definition of the particular problem. + * \return A lightweight const-view (read-only) of the residual/flux and Jacobians. */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + ResidualType<> ComputeResidual(const CConfig* config) override; + }; diff --git a/SU2_CFD/src/numerics/flow/flow_diffusion.cpp b/SU2_CFD/src/numerics/flow/flow_diffusion.cpp index c5c2c5892e8d..229fece2d824 100644 --- a/SU2_CFD/src/numerics/flow/flow_diffusion.cpp +++ b/SU2_CFD/src/numerics/flow/flow_diffusion.cpp @@ -32,7 +32,7 @@ CAvgGrad_Base::CAvgGrad_Base(unsigned short val_nDim, unsigned short val_nVar, unsigned short val_nPrimVar, bool val_correct_grad, - CConfig *config) + const CConfig* config) : CNumerics(val_nDim, val_nVar, config), nPrimVar(val_nPrimVar), correct_gradient(val_correct_grad) { @@ -43,56 +43,60 @@ CAvgGrad_Base::CAvgGrad_Base(unsigned short val_nDim, TauWall_i = 0; TauWall_j = 0; - PrimVar_i = new su2double [nPrimVar]; - PrimVar_j = new su2double [nPrimVar]; Mean_PrimVar = new su2double [nPrimVar]; Mean_GradPrimVar = new su2double* [nPrimVar]; for (iVar = 0; iVar < nPrimVar; iVar++) Mean_GradPrimVar[iVar] = new su2double [nDim]; - Edge_Vector = new su2double[nDim]; - - if (correct_gradient) { - Proj_Mean_GradPrimVar_Edge = new su2double[val_nPrimVar]; - } else { - Proj_Mean_GradPrimVar_Edge = NULL; - } + Proj_Mean_GradPrimVar_Edge = new su2double[val_nPrimVar]; tau_jacobian_i = new su2double* [nDim]; for (iDim = 0; iDim < nDim; iDim++) { tau_jacobian_i[iDim] = new su2double [nVar]; } - heat_flux_vector = new su2double[nDim]; + heat_flux_jac_i = new su2double[nVar]; + Jacobian_i = new su2double* [nVar]; + Jacobian_j = new su2double* [nVar]; + for (iVar = 0; iVar < nVar; iVar++) { + Jacobian_i[iVar] = new su2double [nVar]; + Jacobian_j[iVar] = new su2double [nVar]; + } + } CAvgGrad_Base::~CAvgGrad_Base() { - delete [] PrimVar_i; - delete [] PrimVar_j; delete [] Mean_PrimVar; - for (unsigned short iVar = 0; iVar < nPrimVar; iVar++) - delete [] Mean_GradPrimVar[iVar]; - delete [] Mean_GradPrimVar; - if (tau_jacobian_i != NULL) { + if (Mean_GradPrimVar != nullptr) { + for (unsigned short iVar = 0; iVar < nPrimVar; iVar++) + delete [] Mean_GradPrimVar[iVar]; + delete [] Mean_GradPrimVar; + } + + delete [] Proj_Mean_GradPrimVar_Edge; + + if (tau_jacobian_i != nullptr) { for (unsigned short iDim = 0; iDim < nDim; iDim++) { delete [] tau_jacobian_i[iDim]; } delete [] tau_jacobian_i; } - if (heat_flux_vector != NULL) { - delete [] heat_flux_vector; - } - if (heat_flux_jac_i != NULL) { - delete [] heat_flux_jac_i; + + delete [] heat_flux_jac_i; + + if (Jacobian_i != nullptr) { + for (unsigned short iVar = 0; iVar < nVar; iVar++) { + delete [] Jacobian_i[iVar]; + delete [] Jacobian_j[iVar]; + } + delete [] Jacobian_i; + delete [] Jacobian_j; } - delete [] Edge_Vector; - if (Proj_Mean_GradPrimVar_Edge != NULL) - delete [] Proj_Mean_GradPrimVar_Edge; } void CAvgGrad_Base::CorrectGradient(su2double** GradPrimVar, @@ -276,7 +280,7 @@ void CAvgGrad_Base::SetReynoldsStressMatrix(su2double turb_ke){ delete [] S_ij; } -void CAvgGrad_Base::SetPerturbedRSM(su2double turb_ke, CConfig *config){ +void CAvgGrad_Base::SetPerturbedRSM(su2double turb_ke, const CConfig* config){ unsigned short iDim,jDim; @@ -563,11 +567,10 @@ void CAvgGrad_Base::GetViscousProjJacs(const su2double *val_Mean_PrimVar, CAvgGrad_Flow::CAvgGrad_Flow(unsigned short val_nDim, unsigned short val_nVar, bool val_correct_grad, - CConfig *config) + const CConfig* config) : CAvgGrad_Base(val_nDim, val_nVar, val_nDim+3, val_correct_grad, config) { } -void CAvgGrad_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, - su2double **val_Jacobian_j, CConfig *config) { +CNumerics::ResidualType<> CAvgGrad_Flow::ComputeResidual(const CConfig* config) { AD::StartPreacc(); AD::SetPreaccIn(V_i, nDim+9); AD::SetPreaccIn(V_j, nDim+9); @@ -589,9 +592,10 @@ void CAvgGrad_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jac for (iDim = 0; iDim < nDim; iDim++) UnitNormal[iDim] = Normal[iDim]/Area; + PrimVar_i = V_i; + PrimVar_j = V_j; + for (iVar = 0; iVar < nPrimVar; iVar++) { - PrimVar_i[iVar] = V_i[iVar]; - PrimVar_j[iVar] = V_j[iVar]; Mean_PrimVar[iVar] = 0.5*(PrimVar_i[iVar]+PrimVar_j[iVar]); } @@ -644,7 +648,7 @@ void CAvgGrad_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jac SetPerturbedRSM(Mean_turb_ke, config); } - /*--- Get projected flux tensor ---*/ + /*--- Get projected flux tensor (viscous residual) ---*/ SetStressTensor(Mean_PrimVar, Mean_GradPrimVar, Mean_turb_ke, Mean_Laminar_Viscosity, Mean_Eddy_Viscosity); @@ -656,11 +660,6 @@ void CAvgGrad_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jac GetViscousProjFlux(Mean_PrimVar, Normal); - /*--- Update viscous residual ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_residual[iVar] = Proj_Flux_Tensor[iVar]; - /*--- Compute the implicit part ---*/ if (implicit) { @@ -668,25 +667,27 @@ void CAvgGrad_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jac if (dist_ij_2 == 0.0) { for (iVar = 0; iVar < nVar; iVar++) { for (jVar = 0; jVar < nVar; jVar++) { - val_Jacobian_i[iVar][jVar] = 0.0; - val_Jacobian_j[iVar][jVar] = 0.0; + Jacobian_i[iVar][jVar] = 0.0; + Jacobian_j[iVar][jVar] = 0.0; } } } else { const su2double dist_ij = sqrt(dist_ij_2); - SetTauJacobian(Mean_PrimVar, Mean_Laminar_Viscosity, Mean_Eddy_Viscosity, - dist_ij, UnitNormal); + SetTauJacobian(Mean_PrimVar, Mean_Laminar_Viscosity, Mean_Eddy_Viscosity, dist_ij, UnitNormal); + SetHeatFluxJacobian(Mean_PrimVar, Mean_Laminar_Viscosity, Mean_Eddy_Viscosity, dist_ij, UnitNormal); - GetViscousProjJacs(Mean_PrimVar, Area, Proj_Flux_Tensor, - val_Jacobian_i, val_Jacobian_j); + + GetViscousProjJacs(Mean_PrimVar, Area, Proj_Flux_Tensor, Jacobian_i, Jacobian_j); } } - AD::SetPreaccOut(val_residual, nVar); + AD::SetPreaccOut(Proj_Flux_Tensor, nVar); AD::EndPreacc(); + return ResidualType<>(Proj_Flux_Tensor, Jacobian_i, Jacobian_j); + } void CAvgGrad_Flow::SetHeatFluxVector(const su2double* const *val_gradprimvar, @@ -749,15 +750,14 @@ void CAvgGrad_Flow::SetHeatFluxJacobian(const su2double *val_Mean_PrimVar, CAvgGradInc_Flow::CAvgGradInc_Flow(unsigned short val_nDim, unsigned short val_nVar, - bool val_correct_grad, CConfig *config) + bool val_correct_grad, const CConfig* config) : CAvgGrad_Base(val_nDim, val_nVar, val_nDim+3, val_correct_grad, config) { energy = config->GetEnergy_Equation(); } -void CAvgGradInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, - su2double **val_Jacobian_j, CConfig *config) { +CNumerics::ResidualType<> CAvgGradInc_Flow::ComputeResidual(const CConfig* config) { AD::StartPreacc(); AD::SetPreaccIn(V_i, nDim+9); AD::SetPreaccIn(V_j, nDim+9); @@ -779,9 +779,10 @@ void CAvgGradInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_ for (iDim = 0; iDim < nDim; iDim++) UnitNormal[iDim] = Normal[iDim]/Area; + PrimVar_i = V_i; + PrimVar_j = V_j; + for (iVar = 0; iVar < nPrimVar; iVar++) { - PrimVar_i[iVar] = V_i[iVar]; - PrimVar_j[iVar] = V_j[iVar]; Mean_PrimVar[iVar] = 0.5*(PrimVar_i[iVar]+PrimVar_j[iVar]); } @@ -819,16 +820,10 @@ void CAvgGradInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_ dist_ij_2, nVar); } - /*--- Get projected flux tensor ---*/ - SetStressTensor(Mean_PrimVar, Mean_GradPrimVar, Mean_turb_ke, - Mean_Laminar_Viscosity, Mean_Eddy_Viscosity); - GetViscousIncProjFlux(Mean_GradPrimVar, Normal, Mean_Thermal_Conductivity); - - /*--- Update viscous residual ---*/ + /*--- Get projected flux tensor (viscous residual) ---*/ + SetStressTensor(Mean_PrimVar, Mean_GradPrimVar, Mean_turb_ke, Mean_Laminar_Viscosity, Mean_Eddy_Viscosity); - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] = Proj_Flux_Tensor[iVar]; - } + GetViscousIncProjFlux(Mean_GradPrimVar, Normal, Mean_Thermal_Conductivity); /*--- Implicit part ---*/ @@ -837,16 +832,16 @@ void CAvgGradInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_ if (dist_ij_2 == 0.0) { for (iVar = 0; iVar < nVar; iVar++) { for (jVar = 0; jVar < nVar; jVar++) { - val_Jacobian_i[iVar][jVar] = 0.0; - val_Jacobian_j[iVar][jVar] = 0.0; + Jacobian_i[iVar][jVar] = 0.0; + Jacobian_j[iVar][jVar] = 0.0; } } } else { const su2double dist_ij = sqrt(dist_ij_2); - SetIncTauJacobian(Mean_Laminar_Viscosity, Mean_Eddy_Viscosity, - dist_ij, UnitNormal); - GetViscousIncProjJacs(Area, val_Jacobian_i, val_Jacobian_j); + SetIncTauJacobian(Mean_Laminar_Viscosity, Mean_Eddy_Viscosity, dist_ij, UnitNormal); + + GetViscousIncProjJacs(Area, Jacobian_i, Jacobian_j); /*--- Include the temperature equation Jacobian. ---*/ su2double proj_vector_ij = 0.0; @@ -854,28 +849,30 @@ void CAvgGradInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_ proj_vector_ij += (Coord_j[iDim]-Coord_i[iDim])*Normal[iDim]; } proj_vector_ij = proj_vector_ij/dist_ij_2; - val_Jacobian_i[nDim+1][nDim+1] = -Mean_Thermal_Conductivity*proj_vector_ij; - val_Jacobian_j[nDim+1][nDim+1] = Mean_Thermal_Conductivity*proj_vector_ij; + Jacobian_i[nDim+1][nDim+1] = -Mean_Thermal_Conductivity*proj_vector_ij; + Jacobian_j[nDim+1][nDim+1] = Mean_Thermal_Conductivity*proj_vector_ij; } } if (!energy) { - val_residual[nDim+1] = 0.0; + Proj_Flux_Tensor[nDim+1] = 0.0; if (implicit) { for (iVar = 0; iVar < nVar; iVar++) { - val_Jacobian_i[iVar][nDim+1] = 0.0; - val_Jacobian_j[iVar][nDim+1] = 0.0; + Jacobian_i[iVar][nDim+1] = 0.0; + Jacobian_j[iVar][nDim+1] = 0.0; - val_Jacobian_i[nDim+1][iVar] = 0.0; - val_Jacobian_j[nDim+1][iVar] = 0.0; + Jacobian_i[nDim+1][iVar] = 0.0; + Jacobian_j[nDim+1][iVar] = 0.0; } } } - AD::SetPreaccOut(val_residual, nVar); + AD::SetPreaccOut(Proj_Flux_Tensor, nVar); AD::EndPreacc(); + return ResidualType<>(Proj_Flux_Tensor, Jacobian_i, Jacobian_j); + } void CAvgGradInc_Flow::GetViscousIncProjFlux(const su2double* const *val_gradprimvar, @@ -993,7 +990,7 @@ void CAvgGradInc_Flow::GetViscousIncProjJacs(su2double val_dS, CGeneralAvgGrad_Flow::CGeneralAvgGrad_Flow(unsigned short val_nDim, unsigned short val_nVar, bool val_correct_grad, - CConfig *config) + const CConfig* config) : CAvgGrad_Base(val_nDim, val_nVar, val_nDim+4, val_correct_grad, config) { } void CGeneralAvgGrad_Flow::SetHeatFluxVector(const su2double* const *val_gradprimvar, @@ -1059,8 +1056,7 @@ void CGeneralAvgGrad_Flow::SetHeatFluxJacobian(const su2double *val_Mean_PrimVar } -void CGeneralAvgGrad_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, - su2double **val_Jacobian_j, CConfig *config) { +CNumerics::ResidualType<> CGeneralAvgGrad_Flow::ComputeResidual(const CConfig* config) { AD::StartPreacc(); AD::SetPreaccIn(V_i, nDim+9); AD::SetPreaccIn(V_j, nDim+9); @@ -1085,9 +1081,10 @@ void CGeneralAvgGrad_Flow::ComputeResidual(su2double *val_residual, su2double ** /*--- Mean primitive variables ---*/ + PrimVar_i = V_i; + PrimVar_j = V_j; + for (iVar = 0; iVar < nPrimVar; iVar++) { - PrimVar_i[iVar] = V_i[iVar]; - PrimVar_j[iVar] = V_j[iVar]; Mean_PrimVar[iVar] = 0.5*(PrimVar_i[iVar]+PrimVar_j[iVar]); } @@ -1142,21 +1139,16 @@ void CGeneralAvgGrad_Flow::ComputeResidual(su2double *val_residual, su2double ** SetPerturbedRSM(Mean_turb_ke, config); } - /*--- Get projected flux tensor ---*/ + /*--- Get projected flux tensor (viscous residual) ---*/ SetStressTensor(Mean_PrimVar, Mean_GradPrimVar, Mean_turb_ke, - Mean_Laminar_Viscosity, Mean_Eddy_Viscosity); + Mean_Laminar_Viscosity, Mean_Eddy_Viscosity); SetHeatFluxVector(Mean_GradPrimVar, Mean_Laminar_Viscosity, Mean_Eddy_Viscosity, Mean_Thermal_Conductivity, Mean_Cp); GetViscousProjFlux(Mean_PrimVar, Normal); - /*--- Update viscous residual ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_residual[iVar] = Proj_Flux_Tensor[iVar]; - /*--- Compute the implicit part ---*/ if (implicit) { @@ -1164,23 +1156,26 @@ void CGeneralAvgGrad_Flow::ComputeResidual(su2double *val_residual, su2double ** if (dist_ij_2 == 0.0) { for (iVar = 0; iVar < nVar; iVar++) { for (jVar = 0; jVar < nVar; jVar++) { - val_Jacobian_i[iVar][jVar] = 0.0; - val_Jacobian_j[iVar][jVar] = 0.0; + Jacobian_i[iVar][jVar] = 0.0; + Jacobian_j[iVar][jVar] = 0.0; } } } else { const su2double dist_ij = sqrt(dist_ij_2); - SetTauJacobian(Mean_PrimVar, Mean_Laminar_Viscosity, Mean_Eddy_Viscosity, - dist_ij, UnitNormal); + + SetTauJacobian(Mean_PrimVar, Mean_Laminar_Viscosity, Mean_Eddy_Viscosity, dist_ij, UnitNormal); + SetHeatFluxJacobian(Mean_PrimVar, Mean_SecVar, Mean_Eddy_Viscosity, Mean_Thermal_Conductivity, Mean_Cp, dist_ij); - GetViscousProjJacs(Mean_PrimVar, Area, Proj_Flux_Tensor, - val_Jacobian_i, val_Jacobian_j); + + GetViscousProjJacs(Mean_PrimVar, Area, Proj_Flux_Tensor, Jacobian_i, Jacobian_j); } } - AD::SetPreaccOut(val_residual, nVar); + AD::SetPreaccOut(Proj_Flux_Tensor, nVar); AD::EndPreacc(); + return ResidualType<>(Proj_Flux_Tensor, Jacobian_i, Jacobian_j); + } diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index 927704904064..670f9a42720c 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -1123,15 +1123,15 @@ void CIncNSSolver::Viscous_Residual(CGeometry *geometry, CSolver **solver_contai /*--- Compute and update residual ---*/ - numerics->ComputeResidual(Res_Visc, Jacobian_i, Jacobian_j, config); + auto residual = numerics->ComputeResidual(config); - LinSysRes.SubtractBlock(iPoint, Res_Visc); - LinSysRes.AddBlock(jPoint, Res_Visc); + LinSysRes.SubtractBlock(iPoint, residual); + LinSysRes.AddBlock(jPoint, residual); /*--- Implicit part ---*/ if (implicit) { - Jacobian.UpdateBlocksSub(iEdge, iPoint, jPoint, Jacobian_i, Jacobian_j); + Jacobian.UpdateBlocksSub(iEdge, iPoint, jPoint, residual.jacobian_i, residual.jacobian_j); } } diff --git a/SU2_CFD/src/solvers/CNSSolver.cpp b/SU2_CFD/src/solvers/CNSSolver.cpp index 31331e9602b6..3434060f6e2c 100644 --- a/SU2_CFD/src/solvers/CNSSolver.cpp +++ b/SU2_CFD/src/solvers/CNSSolver.cpp @@ -1127,55 +1127,85 @@ unsigned long CNSSolver::SetPrimitive_Variables(CSolver **solver_container, CCon void CNSSolver::Viscous_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics_container, CConfig *config, unsigned short iMesh, unsigned short iRKStep) { - CNumerics* numerics = numerics_container[VISC_TERM]; + const bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + const bool tkeNeeded = (config->GetKind_Turb_Model() == SST) || + (config->GetKind_Turb_Model() == SST_SUST); - unsigned long iPoint, jPoint, iEdge; + CVariable* turbNodes = solver_container[TURB_SOL]->GetNodes(); - bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + /*--- Start OpenMP parallel section. ---*/ - for (iEdge = 0; iEdge < geometry->GetnEdge(); iEdge++) { + SU2_OMP_PARALLEL + { + /*--- Pick one numerics object per thread. ---*/ + CNumerics* numerics = numerics_container[VISC_TERM + omp_get_thread_num()*MAX_TERMS]; + /*--- Loop over all the edges ---*/ + +#ifdef HAVE_OMP + /*--- Chunk size is at least OMP_MIN_SIZE and a multiple of the color group size. ---*/ + auto chunkSize = roundUpDiv(OMP_MIN_SIZE, ColorGroupSize)*ColorGroupSize; + + /*--- Loop over edge colors. ---*/ + for (auto color : EdgeColoring) + { + SU2_OMP_FOR_DYN(chunkSize) + for(auto k = 0ul; k < color.size; ++k) { + + auto iEdge = color.indices[k]; +#else + /*--- Natural coloring. ---*/ + { + for (auto iEdge = 0ul; iEdge < geometry->GetnEdge(); iEdge++) { +#endif /*--- Points, coordinates and normal vector in edge ---*/ - iPoint = geometry->edge[iEdge]->GetNode(0); - jPoint = geometry->edge[iEdge]->GetNode(1); - numerics->SetCoord(geometry->node[iPoint]->GetCoord(), geometry->node[jPoint]->GetCoord()); + auto iPoint = geometry->edge[iEdge]->GetNode(0); + auto jPoint = geometry->edge[iEdge]->GetNode(1); + + numerics->SetCoord(geometry->node[iPoint]->GetCoord(), + geometry->node[jPoint]->GetCoord()); + numerics->SetNormal(geometry->edge[iEdge]->GetNormal()); - /*--- Primitive and secondary variables ---*/ + /*--- Primitive and secondary variables. ---*/ + + numerics->SetPrimitive(nodes->GetPrimitive(iPoint), + nodes->GetPrimitive(jPoint)); - numerics->SetPrimitive(nodes->GetPrimitive(iPoint), nodes->GetPrimitive(jPoint)); - numerics->SetSecondary(nodes->GetSecondary(iPoint), nodes->GetSecondary(jPoint)); + numerics->SetSecondary(nodes->GetSecondary(iPoint), + nodes->GetSecondary(jPoint)); - /*--- Gradient and limiters ---*/ + /*--- Gradients. ---*/ - numerics->SetPrimVarGradient(nodes->GetGradient_Primitive(iPoint), nodes->GetGradient_Primitive(jPoint)); + numerics->SetPrimVarGradient(nodes->GetGradient_Primitive(iPoint), + nodes->GetGradient_Primitive(jPoint)); - /*--- Turbulent kinetic energy ---*/ + /*--- Turbulent kinetic energy. ---*/ - if ((config->GetKind_Turb_Model() == SST) || (config->GetKind_Turb_Model() == SST_SUST)) - numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0), - solver_container[TURB_SOL]->GetNodes()->GetSolution(jPoint,0)); + if (tkeNeeded) + numerics->SetTurbKineticEnergy(turbNodes->GetSolution(iPoint,0), + turbNodes->GetSolution(jPoint,0)); /*--- Wall shear stress values (wall functions) ---*/ - numerics->SetTauWall(nodes->GetTauWall(iPoint), nodes->GetTauWall(iPoint)); + numerics->SetTauWall(nodes->GetTauWall(iPoint), + nodes->GetTauWall(iPoint)); /*--- Compute and update residual ---*/ - numerics->ComputeResidual(Res_Visc, Jacobian_i, Jacobian_j, config); + auto residual = numerics->ComputeResidual(config); - LinSysRes.SubtractBlock(iPoint, Res_Visc); - LinSysRes.AddBlock(jPoint, Res_Visc); + LinSysRes.SubtractBlock(iPoint, residual); + LinSysRes.AddBlock(jPoint, residual); /*--- Implicit part ---*/ - if (implicit) { - Jacobian.UpdateBlocksSub(iEdge, iPoint, jPoint, Jacobian_i, Jacobian_j); - } - + if (implicit) + Jacobian.UpdateBlocksSub(iEdge, iPoint, jPoint, residual.jacobian_i, residual.jacobian_j); } - + } // end color loop + } // end SU2_OMP_PARALLEL } void CNSSolver::Friction_Forces(CGeometry *geometry, CConfig *config) { From 064ff3d6e8d9079126ef8da88c670532f787bfee Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Thu, 30 Jan 2020 18:03:02 +0000 Subject: [PATCH 063/118] small cleanup --- SU2_CFD/src/solvers/CNSSolver.cpp | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/SU2_CFD/src/solvers/CNSSolver.cpp b/SU2_CFD/src/solvers/CNSSolver.cpp index 3434060f6e2c..4afb5870e0ea 100644 --- a/SU2_CFD/src/solvers/CNSSolver.cpp +++ b/SU2_CFD/src/solvers/CNSSolver.cpp @@ -1751,8 +1751,6 @@ void CNSSolver::Buffet_Monitoring(CGeometry *geometry, CConfig *config) { /*--- Add buffet metric information using all the nodes ---*/ su2double MyTotal_Buffet_Metric = Total_Buffet_Metric; - Total_Buffet_Metric = 0.0; - SU2_MPI::Allreduce(&MyTotal_Buffet_Metric, &Total_Buffet_Metric, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); /*--- Add the buffet metric on the surfaces using all the nodes ---*/ @@ -1760,10 +1758,7 @@ void CNSSolver::Buffet_Monitoring(CGeometry *geometry, CConfig *config) { su2double *MySurface_Buffet_Metric = new su2double[config->GetnMarker_Monitoring()]; for (iMarker_Monitoring = 0; iMarker_Monitoring < config->GetnMarker_Monitoring(); iMarker_Monitoring++) { - MySurface_Buffet_Metric[iMarker_Monitoring] = Surface_Buffet_Metric[iMarker_Monitoring]; - Surface_Buffet_Metric[iMarker_Monitoring] = 0.0; - } SU2_MPI::Allreduce(MySurface_Buffet_Metric, Surface_Buffet_Metric, config->GetnMarker_Monitoring(), MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); @@ -1787,16 +1782,16 @@ void CNSSolver::Evaluate_ObjFunc(CConfig *config) { for (iMarker_Monitoring = 0; iMarker_Monitoring < config->GetnMarker_Monitoring(); iMarker_Monitoring++) { - Weight_ObjFunc = config->GetWeight_ObjFunc(iMarker_Monitoring); - Kind_ObjFunc = config->GetKind_ObjFunc(iMarker_Monitoring); + Weight_ObjFunc = config->GetWeight_ObjFunc(iMarker_Monitoring); + Kind_ObjFunc = config->GetKind_ObjFunc(iMarker_Monitoring); - switch(Kind_ObjFunc) { - case BUFFET_SENSOR: - Total_ComboObj +=Weight_ObjFunc*Surface_Buffet_Metric[iMarker_Monitoring]; - break; - default: - break; - } + switch(Kind_ObjFunc) { + case BUFFET_SENSOR: + Total_ComboObj +=Weight_ObjFunc*Surface_Buffet_Metric[iMarker_Monitoring]; + break; + default: + break; + } } } From 29138ee22ca0d0a80f2dce13b42550b56f95ab55 Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Thu, 30 Jan 2020 18:39:52 +0000 Subject: [PATCH 064/118] update boundary conditions to use the right overload of ComputeResidual --- SU2_CFD/src/solvers/CEulerSolver.cpp | 89 +++++++++++++------------ SU2_CFD/src/solvers/CIncEulerSolver.cpp | 48 +++++++------ SU2_CFD/src/solvers/CIncNSSolver.cpp | 8 ++- 3 files changed, 79 insertions(+), 66 deletions(-) diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 34d09e125412..10e49539c984 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -7450,13 +7450,13 @@ void CEulerSolver::BC_Sym_Plane(CGeometry *geometry, /*--- Compute and update residual. Note that the viscous shear stress tensor is computed in the following routine based upon the velocity-component gradients. ---*/ - visc_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); + auto residual = visc_numerics->ComputeResidual(config); - LinSysRes.SubtractBlock(iPoint, Residual); + LinSysRes.SubtractBlock(iPoint, residual); /*--- Jacobian contribution for implicit integration. ---*/ if (implicit) - Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); + Jacobian.SubtractBlock2Diag(iPoint, residual.jacobian_i); }//if viscous }//if GetDomain }//for iVertex @@ -7715,13 +7715,13 @@ void CEulerSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_container, /*--- Compute and update viscous residual ---*/ - visc_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); - LinSysRes.SubtractBlock(iPoint, Residual); + auto residual = visc_numerics->ComputeResidual(config); + LinSysRes.SubtractBlock(iPoint, residual); /*--- Viscous Jacobian contribution for implicit integration ---*/ if (implicit) - Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); + Jacobian.SubtractBlock2Diag(iPoint, residual.jacobian_i); } @@ -8198,13 +8198,13 @@ void CEulerSolver::BC_Riemann(CGeometry *geometry, CSolver **solver_container, /*--- Compute and update residual ---*/ - visc_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); - LinSysRes.SubtractBlock(iPoint, Residual); + auto residual = visc_numerics->ComputeResidual(config); + LinSysRes.SubtractBlock(iPoint, residual); /*--- Jacobian contribution for implicit integration ---*/ if (implicit) - Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); + Jacobian.SubtractBlock2Diag(iPoint, residual.jacobian_i); } @@ -8701,13 +8701,13 @@ void CEulerSolver::BC_TurboRiemann(CGeometry *geometry, CSolver **solver_contain /*--- Compute and update residual ---*/ - visc_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); - LinSysRes.SubtractBlock(iPoint, Residual); + auto residual = visc_numerics->ComputeResidual(config); + LinSysRes.SubtractBlock(iPoint, residual); /*--- Jacobian contribution for implicit integration ---*/ if (implicit) - Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); + Jacobian.SubtractBlock2Diag(iPoint, residual.jacobian_i); } } @@ -9593,13 +9593,13 @@ void CEulerSolver::BC_Giles(CGeometry *geometry, CSolver **solver_container, CNu /*--- Compute and update residual ---*/ - visc_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); - LinSysRes.SubtractBlock(iPoint, Residual); + auto residual = visc_numerics->ComputeResidual(config); + LinSysRes.SubtractBlock(iPoint, residual); /*--- Jacobian contribution for implicit integration ---*/ if (implicit) - Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); + Jacobian.SubtractBlock2Diag(iPoint, residual.jacobian_i); } @@ -9915,13 +9915,13 @@ void CEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, // // /*--- Compute and update residual ---*/ // -// visc_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); -// LinSysRes.SubtractBlock(iPoint, Residual); +// auto residual = visc_numerics->ComputeResidual(config); +// LinSysRes.SubtractBlock(iPoint, residual); // // /*--- Jacobian contribution for implicit integration ---*/ // // if (implicit) -// Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); +// Jacobian.SubtractBlock2Diag(iPoint, residual.jacobian_i); // // } @@ -10088,13 +10088,13 @@ void CEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, // // /*--- Compute and update residual ---*/ // -// visc_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); -// LinSysRes.SubtractBlock(iPoint, Residual); +// auto residual = visc_numerics->ComputeResidual(config); +// LinSysRes.SubtractBlock(iPoint, residual); // // /*--- Jacobian contribution for implicit integration ---*/ // // if (implicit) -// Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); +// Jacobian.SubtractBlock2Diag(iPoint, residual.acobian_i); // // } @@ -10231,13 +10231,13 @@ void CEulerSolver::BC_Supersonic_Inlet(CGeometry *geometry, CSolver **solver_con // // /*--- Compute and update residual ---*/ // -// visc_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); -// LinSysRes.SubtractBlock(iPoint, Residual); +// auto residual = visc_numerics->ComputeResidual(config); +// LinSysRes.SubtractBlock(iPoint, residual); // // /*--- Jacobian contribution for implicit integration ---*/ // // if (implicit) -// Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); +// Jacobian.SubtractBlock2Diag(iPoint, residual.jacobian_i); // } } @@ -10351,13 +10351,13 @@ void CEulerSolver::BC_Supersonic_Outlet(CGeometry *geometry, CSolver **solver_co // // /*--- Compute and update residual ---*/ // -// visc_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); -// LinSysRes.SubtractBlock(iPoint, Residual); +// auto residual = visc_numerics->ComputeResidual(config); +// LinSysRes.SubtractBlock(iPoint, residual); // // /*--- Jacobian contribution for implicit integration ---*/ // // if (implicit) -// Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); +// Jacobian.SubtractBlock2Diag(iPoint, residual.jacobian_i); // } } @@ -10573,13 +10573,13 @@ void CEulerSolver::BC_Engine_Inflow(CGeometry *geometry, CSolver **solver_contai // // /*--- Compute and update residual ---*/ // -// visc_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); -// LinSysRes.SubtractBlock(iPoint, Residual); +// auto residual = visc_numerics->ComputeResidual(config); +// LinSysRes.SubtractBlock(iPoint, residual); // // /*--- Jacobian contribution for implicit integration ---*/ // // if (implicit) -// Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); +// Jacobian.SubtractBlock2Diag(iPoint, residual.jacobian_i); // // } @@ -10827,13 +10827,13 @@ void CEulerSolver::BC_Engine_Exhaust(CGeometry *geometry, CSolver **solver_conta // // /*--- Compute and update residual ---*/ // -// visc_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); -// LinSysRes.SubtractBlock(iPoint, Residual); +// auto residual = visc_numerics->ComputeResidual(config) +// LinSysRes.SubtractBlock(iPoint, residual); // // /*--- Jacobian contribution for implicit integration ---*/ // // if (implicit) -// Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); +// Jacobian.SubtractBlock2Diag(iPoint, residual.jacobian_i); // // } @@ -10856,7 +10856,6 @@ void CEulerSolver::BC_Fluid_Interface(CGeometry *geometry, CSolver **solver_cont su2double Normal[MAXNDIM] = {0.0}; su2double PrimVar_i[MAXNVAR] = {0.0}; su2double PrimVar_j[MAXNVAR] = {0.0}; - su2double tmp_residual[MAXNVAR] = {0.0}; su2double Secondary_j[MAXNVAR] = {0.0}; su2double weight; @@ -10948,12 +10947,15 @@ void CEulerSolver::BC_Fluid_Interface(CGeometry *geometry, CSolver **solver_cont /*--- Initialize Residual, this will serve to accumulate the average ---*/ - for (iVar = 0; iVar < nVar; iVar++) + for (iVar = 0; iVar < nVar; iVar++) { Residual[iVar] = 0.0; + for (jVar = 0; jVar < nVar; jVar++) + Jacobian_i[iVar][jVar] = 0.0; + } /*--- Loop over the nDonorVertexes and compute the averaged flux ---*/ - for (jVertex = 0; jVertex < nDonorVertex; jVertex++){ + for (jVertex = 0; jVertex < nDonorVertex; jVertex++) { PrimVar_j[nDim+5] = GetSlidingState(iMarker, iVertex, nDim+5, jVertex); PrimVar_j[nDim+6] = GetSlidingState(iMarker, iVertex, nDim+6, jVertex); @@ -10982,12 +10984,15 @@ void CEulerSolver::BC_Fluid_Interface(CGeometry *geometry, CSolver **solver_cont /*--- Compute and update residual ---*/ - visc_numerics->ComputeResidual(tmp_residual, Jacobian_i, Jacobian_j, config); + auto residual = visc_numerics->ComputeResidual(config); /*--- Accumulate the residuals to compute the average ---*/ - for (iVar = 0; iVar < nVar; iVar++) - Residual[iVar] += weight*tmp_residual[iVar]; + for (iVar = 0; iVar < nVar; iVar++) { + Residual[iVar] += weight*residual.residual[iVar]; + for (jVar = 0; jVar < nVar; jVar++) + Jacobian_i[iVar][jVar] += weight*residual.jacobian_i[iVar][jVar]; + } } LinSysRes.SubtractBlock(iPoint, Residual); @@ -11535,12 +11540,12 @@ void CEulerSolver::BC_ActDisk(CGeometry *geometry, CSolver **solver_container, C // // /*--- Compute and update residual ---*/ // -// visc_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); -// LinSysRes.SubtractBlock(iPoint, Residual); +// auto residual = visc_numerics->ComputeResidual(config); +// LinSysRes.SubtractBlock(iPoint, residual); // // /*--- Jacobian contribution for implicit integration ---*/ // -// if (implicit) Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); +// if (implicit) Jacobian.SubtractBlock2Diag(iPoint, residual.jacobian_i); // // } diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index 3bbe19c18d9d..9672bcc4fa20 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -4107,13 +4107,13 @@ void CIncEulerSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_contain /*--- Compute and update viscous residual ---*/ - visc_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); - LinSysRes.SubtractBlock(iPoint, Residual); + auto residual = visc_numerics->ComputeResidual(config); + LinSysRes.SubtractBlock(iPoint, residual); /*--- Viscous Jacobian contribution for implicit integration ---*/ if (implicit) - Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); + Jacobian.SubtractBlock2Diag(iPoint, residual.jacobian_i); } @@ -4359,14 +4359,14 @@ void CIncEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, /*--- Compute and update residual ---*/ - visc_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); + auto residual = visc_numerics->ComputeResidual(config); - LinSysRes.SubtractBlock(iPoint, Residual); + LinSysRes.SubtractBlock(iPoint, residual); /*--- Jacobian contribution for implicit integration ---*/ if (implicit) - Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); + Jacobian.SubtractBlock2Diag(iPoint, residual.jacobian_i); } @@ -4568,13 +4568,13 @@ void CIncEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, /*--- Compute and update residual ---*/ - visc_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); + auto residual = visc_numerics->ComputeResidual(config); - LinSysRes.SubtractBlock(iPoint, Residual); + LinSysRes.SubtractBlock(iPoint, residual); /*--- Jacobian contribution for implicit integration ---*/ if (implicit) - Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); + Jacobian.SubtractBlock2Diag(iPoint, residual.jacobian_i); } @@ -4847,13 +4847,13 @@ void CIncEulerSolver::BC_Sym_Plane(CGeometry *geometry, /*--- Compute and update residual. Note that the viscous shear stress tensor is computed in the following routine based upon the velocity-component gradients. ---*/ - visc_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); + auto residual = visc_numerics->ComputeResidual(config); - LinSysRes.SubtractBlock(iPoint, Residual); + LinSysRes.SubtractBlock(iPoint, residual); /*--- Jacobian contribution for implicit integration. ---*/ if (implicit) - Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); + Jacobian.SubtractBlock2Diag(iPoint, residual.jacobian_i); }//if viscous }//if GetDomain }//for iVertex @@ -4871,14 +4871,14 @@ void CIncEulerSolver::BC_Sym_Plane(CGeometry *geometry, } -void CIncEulerSolver::BC_Fluid_Interface(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CNumerics *visc_numerics, - CConfig *config) { +void CIncEulerSolver::BC_Fluid_Interface(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, + CNumerics *visc_numerics, CConfig *config) { unsigned long iVertex, jVertex, iPoint, Point_Normal = 0; - unsigned short iDim, iVar, iMarker, nDonorVertex; + unsigned short iDim, iVar, jVar, iMarker, nDonorVertex; - bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - bool viscous = config->GetViscous(); + bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + bool viscous = config->GetViscous(); su2double *Normal = new su2double[nDim]; su2double *PrimVar_i = new su2double[nPrimVar]; @@ -4954,8 +4954,11 @@ void CIncEulerSolver::BC_Fluid_Interface(CGeometry *geometry, CSolver **solver_c /*--- Initialize Residual, this will serve to accumulate the average ---*/ - for (iVar = 0; iVar < nVar; iVar++) + for (iVar = 0; iVar < nVar; iVar++) { Residual[iVar] = 0.0; + for (jVar = 0; jVar < nVar; jVar++) + Jacobian_i[iVar][jVar] = 0.0; + } /*--- Loop over the nDonorVertexes and compute the averaged flux ---*/ @@ -4988,12 +4991,15 @@ void CIncEulerSolver::BC_Fluid_Interface(CGeometry *geometry, CSolver **solver_c /*--- Compute and update residual ---*/ - visc_numerics->ComputeResidual(tmp_residual, Jacobian_i, Jacobian_j, config); + auto residual = visc_numerics->ComputeResidual(config); /*--- Accumulate the residuals to compute the average ---*/ - for (iVar = 0; iVar < nVar; iVar++) - Residual[iVar] += weight*tmp_residual[iVar]; + for (iVar = 0; iVar < nVar; iVar++) { + Residual[iVar] += weight*residual.residual[iVar]; + for (jVar = 0; jVar < nVar; jVar++) + Jacobian_i[iVar][jVar] += weight*residual.jacobian_i[iVar][jVar]; + } } LinSysRes.SubtractBlock(iPoint, Residual); diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index 670f9a42720c..e11eab439753 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -1087,7 +1087,7 @@ void CIncNSSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, } void CIncNSSolver::Viscous_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics_container, - CConfig *config, unsigned short iMesh, unsigned short iRKStep) { + CConfig *config, unsigned short iMesh, unsigned short iRKStep) { CNumerics* numerics = numerics_container[VISC_TERM]; @@ -1600,7 +1600,8 @@ void CIncNSSolver::Friction_Forces(CGeometry *geometry, CConfig *config) { } -void CIncNSSolver::BC_HeatFlux_Wall(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { +void CIncNSSolver::BC_HeatFlux_Wall(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, + CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { unsigned short iDim, iVar, jVar;// Wall_Function; unsigned long iVertex, iPoint, total_index; @@ -1701,7 +1702,8 @@ void CIncNSSolver::BC_HeatFlux_Wall(CGeometry *geometry, CSolver **solver_contai } } -void CIncNSSolver::BC_Isothermal_Wall(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { +void CIncNSSolver::BC_Isothermal_Wall(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, + CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { unsigned short iDim, iVar, jVar, Wall_Function; unsigned long iVertex, iPoint, Point_Normal, total_index; From b3619c3ee702c081d08c753d61a29a30493fe514 Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Thu, 30 Jan 2020 19:17:03 +0000 Subject: [PATCH 065/118] fix segfault --- SU2_CFD/src/solvers/CEulerSolver.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 10e49539c984..67dfa7a9fa66 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -3015,13 +3015,18 @@ void CEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, unsigned long iEdge, iVertex, iPoint, jPoint; unsigned short iDim, iMarker; - /*--- Set maximum inviscid eigenvalue to zero, and compute sound speed and viscosity ---*/ + /*--- Set maximum eigenvalues to zero. ---*/ - SU2_OMP_FOR_STAT(omp_chunk_size) - for (iPoint = 0; iPoint < nPointDomain; iPoint++) { + SU2_OMP(for schedule(static,omp_chunk_size) nowait) + for (iPoint = 0; iPoint < nPointDomain; iPoint++) nodes->SetMax_Lambda_Inv(iPoint,0.0); - nodes->SetMax_Lambda_Visc(iPoint,0.0); + + if (viscous) { + SU2_OMP(for schedule(static,omp_chunk_size) nowait) + for (iPoint = 0; iPoint < nPointDomain; iPoint++) + nodes->SetMax_Lambda_Visc(iPoint,0.0); } + SU2_OMP_BARRIER /*--- Loop interior edges ---*/ From bbc47be12b907ce4364bb7d3c30c83d5266d3009 Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Fri, 31 Jan 2020 13:45:49 +0000 Subject: [PATCH 066/118] fix segfault on laminar cases --- SU2_CFD/src/solvers/CNSSolver.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/SU2_CFD/src/solvers/CNSSolver.cpp b/SU2_CFD/src/solvers/CNSSolver.cpp index 4afb5870e0ea..439f3277a0e3 100644 --- a/SU2_CFD/src/solvers/CNSSolver.cpp +++ b/SU2_CFD/src/solvers/CNSSolver.cpp @@ -1131,7 +1131,8 @@ void CNSSolver::Viscous_Residual(CGeometry *geometry, CSolver **solver_container const bool tkeNeeded = (config->GetKind_Turb_Model() == SST) || (config->GetKind_Turb_Model() == SST_SUST); - CVariable* turbNodes = solver_container[TURB_SOL]->GetNodes(); + CVariable* turbNodes = nullptr; + if (tkeNeeded) turbNodes = solver_container[TURB_SOL]->GetNodes(); /*--- Start OpenMP parallel section. ---*/ From 42a39824b6649d2523e0773983e22c7ed5a923d9 Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Fri, 31 Jan 2020 14:05:06 +0000 Subject: [PATCH 067/118] messed up the merge --- SU2_CFD/include/numerics_structure.hpp | 5381 --------------------- SU2_CFD/include/numerics_structure.inl | 494 -- SU2_CFD/src/numerics_adjoint_mean.cpp | 1598 ------ SU2_CFD/src/numerics_direct_mean.cpp | 5210 -------------------- SU2_CFD/src/numerics_direct_mean_inc.cpp | 1219 ----- SU2_CFD/src/numerics_direct_turbulent.cpp | 1505 ------ SU2_CFD/src/numerics_template.cpp | 233 - 7 files changed, 15640 deletions(-) delete mode 100644 SU2_CFD/include/numerics_structure.hpp delete mode 100644 SU2_CFD/include/numerics_structure.inl delete mode 100644 SU2_CFD/src/numerics_adjoint_mean.cpp delete mode 100644 SU2_CFD/src/numerics_direct_mean.cpp delete mode 100644 SU2_CFD/src/numerics_direct_mean_inc.cpp delete mode 100644 SU2_CFD/src/numerics_direct_turbulent.cpp delete mode 100644 SU2_CFD/src/numerics_template.cpp diff --git a/SU2_CFD/include/numerics_structure.hpp b/SU2_CFD/include/numerics_structure.hpp deleted file mode 100644 index 3895babb54f1..000000000000 --- a/SU2_CFD/include/numerics_structure.hpp +++ /dev/null @@ -1,5381 +0,0 @@ -/*! - * \file numerics_structure.hpp - * \brief Headers of the main subroutines for the dumerical definition of the problem. - * The subroutines and functions are in the numerics_structure.cpp, - * numerics_convective.cpp, numerics_viscous.cpp, and - * numerics_source.cpp files. - * \author F. Palacios, T. Economon - * \version 7.0.1 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../../Common/include/mpi_structure.hpp" - -#include -#include -#include -#include - -#include "../../Common/include/CConfig.hpp" -#include "../../Common/include/geometry/elements/CElement.hpp" -#include "fluid_model.hpp" - -using namespace std; - -/*! - * \class CNumerics - * \brief Class for defining the numerical methods. - * \author F. Palacios, T. Economon - */ -class CNumerics { -protected: - unsigned short nDim, nVar; /*!< \brief Number of dimensions and variables. */ - su2double Gamma; /*!< \brief Fluid's Gamma constant (ratio of specific heats). */ - su2double Gamma_Minus_One; /*!< \brief Fluids's Gamma - 1.0 . */ - su2double Minf; /*!< \brief Free stream Mach number . */ - su2double Gas_Constant; /*!< \brief Gas constant. */ - su2double *Vector; /*!< \brief Auxiliary vector. */ - su2double *Enthalpy_formation; /*!< \brief Enthalpy of formation. */ - su2double Prandtl_Lam; /*!< \brief Laminar Prandtl's number. */ - su2double Prandtl_Turb; /*!< \brief Turbulent Prandtl's number. */ - -public: - - su2double - **Flux_Tensor, /*!< \brief Flux tensor (used for viscous and inviscid purposes. */ - *Proj_Flux_Tensor; /*!< \brief Flux tensor projected in a direction. */ - - su2double - **tau, /*!< \brief Viscous stress tensor. */ - **delta, /*!< \brief Identity matrix. */ - **delta3; /*!< \brief 3 row Identity matrix. */ - su2double - *Diffusion_Coeff_i, /*!< \brief Species diffusion coefficients at point i. */ - *Diffusion_Coeff_j; /*!< \brief Species diffusion coefficients at point j. */ - su2double - Laminar_Viscosity_i, /*!< \brief Laminar viscosity at point i. */ - Laminar_Viscosity_j, /*!< \brief Laminar viscosity at point j. */ - Laminar_Viscosity_id, /*!< \brief Variation of laminar viscosity at point i. */ - Laminar_Viscosity_jd; /*!< \brief Variation of laminar viscosity at point j. */ - su2double - Thermal_Conductivity_i, /*!< \brief Thermal conductivity at point i. */ - Thermal_Conductivity_j, /*!< \brief Thermal conductivity at point j. */ - Thermal_Conductivity_ve_i, /*!< \brief Thermal conductivity at point i. */ - Thermal_Conductivity_ve_j, /*!< \brief Thermal conductivity at point j. */ - Thermal_Diffusivity_i, /*!< \brief Thermal diffusivity at point i. */ - Thermal_Diffusivity_j; /*!< \brief Thermal diffusivity at point j. */ - su2double - Cp_i, /*!< \brief Cp at point i. */ - Cp_j; /*!< \brief Cp at point j. */ - su2double *Theta_v; /*!< \brief Characteristic vibrational temperature */ - su2double - Eddy_Viscosity_i, /*!< \brief Eddy viscosity at point i. */ - Eddy_Viscosity_j; /*!< \brief Eddy viscosity at point j. */ - su2double - turb_ke_i, /*!< \brief Turbulent kinetic energy at point i. */ - turb_ke_j; /*!< \brief Turbulent kinetic energy at point j. */ - su2double - Pressure_i, /*!< \brief Pressure at point i. */ - Pressure_j; /*!< \brief Pressure at point j. */ - su2double - GravityForce_i, /*!< \brief Gravity force at point i. */ - GravityForce_j; /*!< \brief Gravity force at point j. */ - su2double - Density_i, /*!< \brief Density at point i. */ - Density_j; /*!< \brief Density at point j. */ - su2double - DensityInc_i, /*!< \brief Incompressible density at point i. */ - DensityInc_j; /*!< \brief Incompressible density at point j. */ - su2double - BetaInc2_i, /*!< \brief Beta incompressible at point i. */ - BetaInc2_j; /*!< \brief Beta incompressible at point j. */ - su2double - Lambda_i, /*!< \brief Spectral radius at point i. */ - Lambda_j; /*!< \brief Spectral radius at point j. */ - su2double - LambdaComb_i, /*!< \brief Spectral radius at point i. */ - LambdaComb_j; /*!< \brief Spectral radius at point j. */ - su2double - SoundSpeed_i, /*!< \brief Sound speed at point i. */ - SoundSpeed_j; /*!< \brief Sound speed at point j. */ - su2double - Enthalpy_i, /*!< \brief Enthalpy at point i. */ - Enthalpy_j; /*!< \brief Enthalpy at point j. */ - su2double - dist_i, /*!< \brief Distance of point i to the nearest wall. */ - dist_j; /*!< \brief Distance of point j to the nearest wall. */ - su2double - Temp_i, /*!< \brief Temperature at point i. */ - Temp_j; /*!< \brief Temperature at point j. */ - su2double - *Temp_tr_i, /*!< \brief Temperature transl-rot at point i. */ - *Temp_tr_j; /*!< \brief Temperature transl-rot at point j. */ - su2double - *Temp_vib_i, /*!< \brief Temperature vibrational at point i. */ - *Temp_vib_j; /*!< \brief Temperature vibrational at point j. */ - su2double - *Und_Lapl_i, /*!< \brief Undivided laplacians at point i. */ - *Und_Lapl_j; /*!< \brief Undivided laplacians at point j. */ - su2double - Sensor_i, /*!< \brief Pressure sensor at point i. */ - Sensor_j; /*!< \brief Pressure sensor at point j. */ - su2double - *GridVel_i, /*!< \brief Grid velocity at point i. */ - *GridVel_j; /*!< \brief Grid velocity at point j. */ - su2double - *U_i, /*!< \brief Vector of conservative variables at point i. */ - *U_id, /*!< \brief Vector of derivative of conservative variables at point i. */ - *UZeroOrder_i, /*!< \brief Vector of conservative variables at point i without reconstruction. */ - *U_j, /*!< \brief Vector of conservative variables at point j. */ - *UZeroOrder_j, /*!< \brief Vector of conservative variables at point j without reconstruction. */ - *U_jd, /*!< \brief Vector of derivative of conservative variables at point j. */ - *U_0, /*!< \brief Vector of conservative variables at node 0. */ - *U_1, /*!< \brief Vector of conservative variables at node 1. */ - *U_2, /*!< \brief Vector of conservative variables at node 2. */ - *U_3; /*!< \brief Vector of conservative variables at node 3. */ - su2double - *V_i, /*!< \brief Vector of primitive variables at point i. */ - *V_j; /*!< \brief Vector of primitive variables at point j. */ - su2double - *S_i, /*!< \brief Vector of secondary variables at point i. */ - *S_j; /*!< \brief Vector of secondary variables at point j. */ - su2double - *Psi_i, /*!< \brief Vector of adjoint variables at point i. */ - *Psi_j; /*!< \brief Vector of adjoint variables at point j. */ - su2double - *DeltaU_i, /*!< \brief Vector of linearized variables at point i. */ - *DeltaU_j; /*!< \brief Vector of linearized variables at point j. */ - su2double - *TurbVar_i, /*!< \brief Vector of turbulent variables at point i. */ - *TurbVar_id, /*!< \brief Vector of derivative of turbulent variables at point i. */ - *TurbVar_j, /*!< \brief Vector of turbulent variables at point j. */ - *TurbVar_jd; /*!< \brief Vector of derivative of turbulent variables at point j. */ - su2double - *TransVar_i, /*!< \brief Vector of turbulent variables at point i. */ - *TransVar_j; /*!< \brief Vector of turbulent variables at point j. */ - su2double - *TurbPsi_i, /*!< \brief Vector of adjoint turbulent variables at point i. */ - *TurbPsi_j; /*!< \brief Vector of adjoint turbulent variables at point j. */ - su2double - **ConsVar_Grad_i, /*!< \brief Gradient of conservative variables at point i. */ - **ConsVar_Grad_j, /*!< \brief Gradient of conservative variables at point j. */ - **ConsVar_Grad_0, /*!< \brief Gradient of conservative variables at point 0. */ - **ConsVar_Grad_1, /*!< \brief Gradient of conservative variables at point 1. */ - **ConsVar_Grad_2, /*!< \brief Gradient of conservative variables at point 2. */ - **ConsVar_Grad_3, /*!< \brief Gradient of conservative variables at point 3. */ - **ConsVar_Grad; /*!< \brief Gradient of conservative variables which is a scalar. */ - su2double - **PrimVar_Grad_i, /*!< \brief Gradient of primitive variables at point i. */ - **PrimVar_Grad_j; /*!< \brief Gradient of primitive variables at point j. */ - su2double - **PsiVar_Grad_i, /*!< \brief Gradient of adjoint variables at point i. */ - **PsiVar_Grad_j; /*!< \brief Gradient of adjoint variables at point j. */ - su2double - **TurbVar_Grad_i, /*!< \brief Gradient of turbulent variables at point i. */ - **TurbVar_Grad_j; /*!< \brief Gradient of turbulent variables at point j. */ - su2double - **TransVar_Grad_i, /*!< \brief Gradient of turbulent variables at point i. */ - **TransVar_Grad_j; /*!< \brief Gradient of turbulent variables at point j. */ - su2double - **TurbPsi_Grad_i, /*!< \brief Gradient of adjoint turbulent variables at point i. */ - **TurbPsi_Grad_j; /*!< \brief Gradient of adjoint turbulent variables at point j. */ - su2double - *AuxVar_Grad_i, /*!< \brief Gradient of an auxiliary variable at point i. */ - *AuxVar_Grad_j; /*!< \brief Gradient of an auxiliary variable at point i. */ - su2double - *Coord_i, /*!< \brief Cartesians coordinates of point i. */ - *Coord_j, /*!< \brief Cartesians coordinates of point j. */ - *Coord_0, /*!< \brief Cartesians coordinates of point 0 (Galerkin method, triangle). */ - *Coord_1, /*!< \brief Cartesians coordinates of point 1 (Galerkin method, tetrahedra). */ - *Coord_2, /*!< \brief Cartesians coordinates of point 2 (Galerkin method, triangle). */ - *Coord_3; /*!< \brief Cartesians coordinates of point 3 (Galerkin method, tetrahedra). */ - unsigned short - Neighbor_i, /*!< \brief Number of neighbors of the point i. */ - Neighbor_j; /*!< \brief Number of neighbors of the point j. */ - su2double - *Normal, /*!< \brief Normal vector, it norm is the area of the face. */ - *UnitNormal, /*!< \brief Unitary normal vector. */ - *UnitNormald; /*!< \brief derivatve of unitary normal vector. */ - su2double - TimeStep, /*!< \brief Time step useful in dual time method. */ - Area, /*!< \brief Area of the face i-j. */ - Volume; /*!< \brief Volume of the control volume around point i. */ - su2double - Volume_n, /*!< \brief Volume of the control volume at time n. */ - Volume_nM1, /*!< \brief Volume of the control volume at time n-1. */ - Volume_nP1; /*!< \brief Volume of the control volume at time n+1. */ - su2double - *U_n, /*!< \brief Vector of conservative variables at time n. */ - *U_nM1, /*!< \brief Vector of conservative variables at time n-1. */ - *U_nP1; /*!< \brief Vector of conservative variables at time n+1. */ - su2double vel2_inf; /*!< \brief value of the square of freestream speed. */ - su2double - *WindGust_i, /*!< \brief Wind gust at point i. */ - *WindGust_j; /*!< \brief Wind gust at point j. */ - su2double - *WindGustDer_i, /*!< \brief Wind gust derivatives at point i. */ - *WindGustDer_j; /*!< \brief Wind gust derivatives at point j. */ - su2double *Vorticity_i, *Vorticity_j; /*!< \brief Vorticity. */ - su2double StrainMag_i, StrainMag_j; /*!< \brief Strain rate magnitude. */ - su2double Dissipation_i, Dissipation_j; /*!< \brief Dissipation. */ - su2double Dissipation_ij; - - su2double *l, *m; - - su2double **MeanReynoldsStress; /*!< \brief Mean Reynolds stress tensor */ - su2double **MeanPerturbedRSM; /*!< \brief Perturbed Reynolds stress tensor */ - bool using_uq; /*!< \brief Flag for UQ methodology */ - su2double PerturbedStrainMag; /*!< \brief Strain magnitude calculated using perturbed stress tensor */ - unsigned short Eig_Val_Comp; /*!< \brief Component towards which perturbation is perfromed */ - su2double uq_delta_b; /*!< \brief Magnitude of perturbation */ - su2double uq_urlx; /*!< \brief Under-relaxation factor for numerical stability */ - bool uq_permute; /*!< \brief Flag for eigenvector permutation */ - - /* Supporting data structures for the eigenspace perturbation for UQ methodology */ - su2double **A_ij, **newA_ij, **Eig_Vec, **New_Eig_Vec, **Corners; - su2double *Eig_Val, *Barycentric_Coord, *New_Coord; - - /*! - * \brief Constructor of the class. - */ - CNumerics(void); - - /*! - * \overload - * \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. - */ - CNumerics(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - virtual ~CNumerics(void); - - /*! - * \brief Compute the determinant of a 3 by 3 matrix. - * \param[in] val_matrix 3 by 3 matrix. - * \result Determinant of the matrix - */ - su2double Determinant_3x3(su2double A00, su2double A01, su2double A02, - su2double A10, su2double A11, su2double A12, - su2double A20, su2double A21, su2double A22); - - /*! - * \brief Set the solution at different times. - * \param[in] val_u_nM1 Conservative solution at time n-1. - * \param[in] val_u_n Conservative solution at time n. - * \param[in] val_u_nP1 Conservative solution at time n+1. - */ - void SetPastSol(su2double *val_u_nM1, su2double *val_u_n, su2double *val_u_nP1); - - /*! - * \brief Set the control volume at different times. - * \param[in] val_volume_nM1 - Control volume at time n-1. - * \param[in] val_volume_n - Control volume at time n. - * \param[in] val_volume_nP1 - Control volume at time n+1. - */ - void SetPastVolume(su2double val_volume_nM1, su2double val_volume_n, su2double val_volume_nP1); - - /*! - * \brief Set the time step. - * \param[in] val_timestep - Value of the time step. - */ - void SetTimeStep(su2double val_timestep); - - /*! - * \brief Set the freestream velocity square. - * \param[in] SetVelocity2_Inf - Value of the square of the freestream velocity. - */ - void SetVelocity2_Inf(su2double val_velocity2); - - /*! - * \brief Set the value of the vorticity - * \param[in] val_vorticity - Value of the vorticity. - */ - void SetVorticity(su2double *val_vorticity_i, su2double *val_vorticity_j); - - /*! - * \brief Set the value of the rate of strain magnitude. - * \param[in] val_StrainMag_i - Value of the magnitude of rate of strain at point i. - * \param[in] val_StrainMag_j - Value of the magnitude of rate of strain at point j. - */ - void SetStrainMag(su2double val_strainmag_i, su2double val_strainmag_j); - - /*! - * \brief Set the value of the conservative variables. - * \param[in] val_u_i - Value of the conservative variable at point i. - * \param[in] val_u_j - Value of the conservative variable at point j. - */ - void SetConservative(su2double *val_u_i, su2double *val_u_j); - - /*! - * \brief Set the value of the conservative variables withour reconstruction. - * \param[in] val_u_i - Value of the conservative variable at point i. - * \param[in] val_u_j - Value of the conservative variable at point j. - */ - void SetConservative_ZeroOrder(su2double *val_u_i, su2double *val_u_j); - - /*! - * \brief Set the value of the primitive variables. - * \param[in] val_v_i - Value of the primitive variable at point i. - * \param[in] val_v_j - Value of the primitive variable at point j. - */ - void SetPrimitive(su2double *val_v_i, su2double *val_v_j); - - /*! - * \brief Set the value of the primitive variables. - * \param[in] val_v_i - Value of the primitive variable at point i. - * \param[in] val_v_j - Value of the primitive variable at point j. - */ - void SetSecondary(su2double *val_s_i, su2double *val_s_j); - - /*! - * \brief Set the value of the conservative variables. - * \param[in] val_u_0 - Value of the conservative variable at point 0. - * \param[in] val_u_1 - Value of the conservative variable at point 1. - * \param[in] val_u_2 - Value of the conservative variable at point 2. - */ - void SetConservative(su2double *val_u_0, su2double *val_u_1, su2double *val_u_2); - - /*! - * \brief Set the value of the conservative variables. - * \param[in] val_u_0 - Value of the conservative variable at point 0. - * \param[in] val_u_1 - Value of the conservative variable at point 1. - * \param[in] val_u_2 - Value of the conservative variable at point 2. - * \param[in] val_u_3 - Value of the conservative variable at point 3. - */ - void SetConservative(su2double *val_u_0, su2double *val_u_1, su2double *val_u_2, su2double *val_u_3); - - /*! - * \brief Set the gradient of the conservative variables. - * \param[in] val_consvar_grad_i - Gradient of the conservative variable at point i. - * \param[in] val_consvar_grad_j - Gradient of the conservative variable at point j. - */ - void SetConsVarGradient(su2double **val_consvar_grad_i, su2double **val_consvar_grad_j); - - /*! - * \brief Set the gradient of the conservative variables. - * \param[in] val_consvar_grad_0 - Gradient of the conservative variable at point 0. - * \param[in] val_consvar_grad_1 - Gradient of the conservative variable at point 1. - * \param[in] val_consvar_grad_2 - Gradient of the conservative variable at point 2. - */ - void SetConsVarGradient(su2double **val_consvar_grad_0, - su2double **val_consvar_grad_1, - su2double **val_consvar_grad_2); - - /*! - * \brief Set the gradient of the conservative variables. - * \param[in] val_consvar_grad_0 - Gradient of the conservative variable at point 0. - * \param[in] val_consvar_grad_1 - Gradient of the conservative variable at point 1. - * \param[in] val_consvar_grad_2 - Gradient of the conservative variable at point 2. - * \param[in] val_consvar_grad_3 - Gradient of the conservative variable at point 3. - */ - void SetConsVarGradient(su2double **val_consvar_grad_0, - su2double **val_consvar_grad_1, - su2double **val_consvar_grad_2, - su2double **val_consvar_grad_3); - - /*! - * \brief Set the gradient of the conservative variables. - * \param[in] val_consvar_grad - Gradient of the conservative variable which is a scalar. - */ - void SetConsVarGradient(su2double **val_consvar_grad); - - /*! - * \brief Set the gradient of the primitive variables. - * \param[in] val_primvar_grad_i - Gradient of the primitive variable at point i. - * \param[in] val_primvar_grad_j - Gradient of the primitive variable at point j. - */ - void SetPrimVarGradient(su2double **val_primvar_grad_i, - su2double **val_primvar_grad_j); - - /*! - * \brief Set the value of the adjoint variable. - * \param[in] val_psi_i - Value of the adjoint variable at point i. - * \param[in] val_psi_j - Value of the adjoint variable at point j. - */ - void SetAdjointVar(su2double *val_psi_i, su2double *val_psi_j); - - /*! - * \brief Set the gradient of the adjoint variables. - * \param[in] val_psivar_grad_i - Gradient of the adjoint variable at point i. - * \param[in] val_psivar_grad_j - Gradient of the adjoint variable at point j. - */ - void SetAdjointVarGradient(su2double **val_psivar_grad_i, su2double **val_psivar_grad_j); - - /*! - * \brief Set the value of the turbulent variable. - * \param[in] val_turbvar_i - Value of the turbulent variable at point i. - * \param[in] val_turbvar_j - Value of the turbulent variable at point j. - */ - void SetTurbVar(su2double *val_turbvar_i, su2double *val_turbvar_j); - - /*! - * \brief Set the value of the turbulent variable. - * \param[in] val_transvar_i - Value of the turbulent variable at point i. - * \param[in] val_transvar_j - Value of the turbulent variable at point j. - */ - void SetTransVar(su2double *val_transvar_i, su2double *val_transvar_j); - - /*! - * \brief Set the gradient of the turbulent variables. - * \param[in] val_turbvar_grad_i - Gradient of the turbulent variable at point i. - * \param[in] val_turbvar_grad_j - Gradient of the turbulent variable at point j. - */ - void SetTurbVarGradient(su2double **val_turbvar_grad_i, su2double **val_turbvar_grad_j); - - /*! - * \brief Set the gradient of the turbulent variables. - * \param[in] val_turbvar_grad_i - Gradient of the turbulent variable at point i. - * \param[in] val_turbvar_grad_j - Gradient of the turbulent variable at point j. - */ - void SetTransVarGradient(su2double **val_transvar_grad_i, su2double **val_transvar_grad_j); - - /*! - * \brief Set the value of the adjoint turbulent variable. - * \param[in] val_turbpsivar_i - Value of the adjoint turbulent variable at point i. - * \param[in] val_turbpsivar_j - Value of the adjoint turbulent variable at point j. - */ - void SetTurbAdjointVar(su2double *val_turbpsivar_i, su2double *val_turbpsivar_j); - - /*! - * \brief Set the gradient of the adjoint turbulent variables. - * \param[in] val_turbpsivar_grad_i - Gradient of the adjoint turbulent variable at point i. - * \param[in] val_turbpsivar_grad_j - Gradient of the adjoint turbulent variable at point j. - */ - void SetTurbAdjointGradient (su2double **val_turbpsivar_grad_i, su2double **val_turbpsivar_grad_j); - - /*! - * \brief Set the value of the first blending function. - * \param[in] val_F1_i - Value of the first Menter blending function at point i. - * \param[in] val_F1_j - Value of the first Menter blending function at point j. - */ - virtual void SetF1blending(su2double val_F1_i, su2double val_F1_j) {/* empty */}; - - /*! - * \brief Set the value of the second blending function. - * \param[in] val_F1_i - Value of the second Menter blending function at point i. - * \param[in] val_F1_j - Value of the second Menter blending function at point j. - */ - virtual void SetF2blending(su2double val_F1_i, su2double val_F1_j) {/* empty */}; - - /*! - * \brief Set the value of the cross diffusion for the SST model. - * \param[in] val_CDkw_i - Value of the cross diffusion at point i. - * \param[in] val_CDkw_j - Value of the cross diffusion at point j. - */ - virtual void SetCrossDiff(su2double val_CDkw_i, su2double val_CDkw_j) {/* empty */}; - - /*! - * \brief Set the gradient of the auxiliary variables. - * \param[in] val_auxvargrad_i - Gradient of the auxiliary variable at point i. - * \param[in] val_auxvargrad_j - Gradient of the auxiliary variable at point j. - */ - void SetAuxVarGrad(su2double *val_auxvargrad_i, su2double *val_auxvargrad_j); - - /*! - * \brief Set the diffusion coefficient - * \param[in] val_diffusioncoeff_i - Value of the diffusion coefficients at i. - * \param[in] val_diffusioncoeff_j - Value of the diffusion coefficients at j - */ - void SetDiffusionCoeff(su2double* val_diffusioncoeff_i, - su2double* val_diffusioncoeff_j); - - /*! - * \brief Set the laminar viscosity. - * \param[in] val_laminar_viscosity_i - Value of the laminar viscosity at point i. - * \param[in] val_laminar_viscosity_j - Value of the laminar viscosity at point j. - */ - void SetLaminarViscosity(su2double val_laminar_viscosity_i, - su2double val_laminar_viscosity_j); - - /*! - * \brief Set the thermal conductivity (translational/rotational) - * \param[in] val_thermal_conductivity_i - Value of the thermal conductivity at point i. - * \param[in] val_thermal_conductivity_j - Value of the thermal conductivity at point j. - * \param[in] iSpecies - Value of the species. - */ - void SetThermalConductivity(su2double val_thermal_conductivity_i, - su2double val_thermal_conductivity_j); - - /*! - * \brief Set the thermal conductivity (translational/rotational) - * \param[in] val_thermal_conductivity_i - Value of the thermal conductivity at point i. - * \param[in] val_thermal_conductivity_j - Value of the thermal conductivity at point j. - * \param[in] iSpecies - Value of the species. - */ - void SetThermalConductivity_ve(su2double val_thermal_conductivity_ve_i, - su2double val_thermal_conductivity_ve_j); - - /*! - * \brief Set the thermal diffusivity (translational/rotational) - * \param[in] val_thermal_diffusivity_i - Value of the thermal diffusivity at point i. - * \param[in] val_thermal_diffusivity_j - Value of the thermal diffusivity at point j. - * \param[in] iSpecies - Value of the species. - */ - void SetThermalDiffusivity(su2double val_thermal_diffusivity_i, - su2double val_thermal_diffusivity_j); - /*! - * \brief Set the eddy viscosity. - * \param[in] val_eddy_viscosity_i - Value of the eddy viscosity at point i. - * \param[in] val_eddy_viscosity_j - Value of the eddy viscosity at point j. - */ - void SetEddyViscosity(su2double val_eddy_viscosity_i, - su2double val_eddy_viscosity_j); - - /*! - * \brief Set the turbulent kinetic energy. - * \param[in] val_turb_ke_i - Value of the turbulent kinetic energy at point i. - * \param[in] val_turb_ke_j - Value of the turbulent kinetic energy at point j. - */ - void SetTurbKineticEnergy(su2double val_turb_ke_i, su2double val_turb_ke_j); - - /*! - * \brief Set the value of the distance from the nearest wall. - * \param[in] val_dist_i - Value of of the distance from point i to the nearest wall. - * \param[in] val_dist_j - Value of of the distance from point j to the nearest wall. - */ - void SetDistance(su2double val_dist_i, su2double val_dist_j); - - /*! - * \brief Set coordinates of the points. - * \param[in] val_coord_i - Coordinates of the point i. - * \param[in] val_coord_j - Coordinates of the point j. - */ - void SetCoord(su2double *val_coord_i, su2double *val_coord_j); - - /*! - * \overload - * \param[in] val_coord_0 - Coordinates of the point 0. - * \param[in] val_coord_1 - Coordinates of the point 1. - * \param[in] val_coord_2 - Coordinates of the point 2. - */ - void SetCoord(su2double *val_coord_0, su2double *val_coord_1, su2double *val_coord_2); - - /*! - * \overload - * \param[in] val_coord_0 - Coordinates of the point 0. - * \param[in] val_coord_1 - Coordinates of the point 1. - * \param[in] val_coord_2 - Coordinates of the point 2. - * \param[in] val_coord_3 - Coordinates of the point 3. - */ - void SetCoord(su2double *val_coord_0, su2double *val_coord_1, su2double *val_coord_2, - su2double *val_coord_3); - - /*! - * \brief Set the velocity of the computational grid. - * \param[in] val_gridvel_i - Grid velocity of the point i. - * \param[in] val_gridvel_j - Grid velocity of the point j. - */ - void SetGridVel(su2double *val_gridvel_i, su2double *val_gridvel_j); - - /*! - * \brief Set the wind gust value. - * \param[in] val_windgust_i - Wind gust of the point i. - * \param[in] val_windgust_j - Wind gust of the point j. - */ - void SetWindGust(su2double *val_windgust_i, su2double *val_windgust_j); - - /*! - * \brief Set the wind gust derivatives values. - * \param[in] val_windgust_i - Wind gust derivatives of the point i. - * \param[in] val_windgust_j - Wind gust derivatives of the point j. - */ - void SetWindGustDer(su2double *val_windgustder_i, su2double *val_windgustder_j); - - /*! - * \brief Set the value of the pressure. - * \param[in] val_pressure_i - Value of the pressure at point i. - * \param[in] val_pressure_j - Value of the pressure at point j. - */ - void SetPressure(su2double val_pressure_i, su2double val_pressure_j); - - /*! - * \brief Set the value of the density for the incompressible solver. - * \param[in] val_densityinc_i - Value of the pressure at point i. - * \param[in] val_densityinc_j - Value of the pressure at point j. - */ - void SetDensity(su2double val_densityinc_i, su2double val_densityinc_j); - - /*! - * \brief Set the value of the beta for incompressible flows. - * \param[in] val_betainc2_i - Value of beta for incompressible flows at point i. - * \param[in] val_betainc2_j - Value of beta for incompressible flows at point j. - */ - void SetBetaInc2(su2double val_betainc2_i, su2double val_betainc2_j); - - /*! - * \brief Set the value of the sound speed. - * \param[in] val_soundspeed_i - Value of the sound speed at point i. - * \param[in] val_soundspeed_j - Value of the sound speed at point j. - */ - void SetSoundSpeed(su2double val_soundspeed_i, su2double val_soundspeed_j); - - /*! - * \brief Set the value of the temperature. - * \param[in] val_temp_i - Value of the temperature at point i. - * \param[in] val_temp_j - Value of the temperature at point j. - */ - void SetTemperature(su2double val_temp_i, su2double val_temp_j); - - /*! - * \brief Set the value of the enthalpy. - * \param[in] val_enthalpy_i - Value of the enthalpy at point i. - * \param[in] val_enthalpy_j - Value of the enthalpy at point j. - */ - void SetEnthalpy(su2double val_enthalpy_i, su2double val_enthalpy_j); - - /*! - * \brief Set the value of the spectral radius. - * \param[in] val_lambda_i - Value of the spectral radius at point i. - * \param[in] val_lambda_j - Value of the spectral radius at point j. - */ - void SetLambda(su2double val_lambda_i, su2double val_lambda_j); - - /*! - * \brief Set the value of undivided laplacian. - * \param[in] val_und_lapl_i Undivided laplacian at point i. - * \param[in] val_und_lapl_j Undivided laplacian at point j. - */ - void SetUndivided_Laplacian(su2double *val_und_lapl_i, su2double *val_und_lapl_j); - - /*! - * \brief Set the value of the pressure sensor. - * \param[in] val_sensor_i Pressure sensor at point i. - * \param[in] val_sensor_j Pressure sensor at point j. - */ - void SetSensor(su2double val_sensor_i, su2double val_sensor_j); - - /*! - * \brief Set the number of neighbor to a point. - * \param[in] val_neighbor_i - Number of neighbor to point i. - * \param[in] val_neighbor_j - Number of neighbor to point j. - */ - void SetNeighbor(unsigned short val_neighbor_i, unsigned short val_neighbor_j); - - /*! - * \brief Set the value of the normal vector to the face between two points. - * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. - */ - void SetNormal(su2double *val_normal); - - /*! - * \brief Set the value of the volume of the control volume. - * \param[in] val_volume Volume of the control volume. - */ - void SetVolume(su2double val_volume); - - /*! - * \brief Retrieves the value of the species density in the primitive variable vector. - * \param[in] iRho_s - */ - void SetRhosIndex(unsigned short val_Index); - - /*! - * \brief Retrieves the value of the species density in the primitive variable vector. - * \param[in] iRho_s - */ - void SetRhoIndex(unsigned short val_Index); - - /*! - * \brief Retrieves the value of the species density in the primitive variable vector. - * \param[in] iRho_s - */ - void SetPIndex(unsigned short val_Index); - - /*! - * \brief Retrieves the value of the species density in the primitive variable vector. - * \param[in] iRho_s - */ - void SetTIndex(unsigned short val_Index); - - /*! - * \brief Retrieves the value of the species density in the primitive variable vector. - * \param[in] iRho_s - */ - void SetTveIndex(unsigned short val_Index); - - /*! - * \brief Retrieves the value of the velocity index in the primitive variable vector. - * \param[in] i(rho*u) - */ - void SetVelIndex(unsigned short val_Index); - - /*! - * \brief Retrieves the value of the species density in the primitive variable vector. - * \param[in] iRho_s - */ - void SetHIndex(unsigned short val_Index); - - /*! - * \brief Retrieves the value of the species density in the primitive variable vector. - * \param[in] iRho_s - */ - void SetAIndex(unsigned short val_Index); - - /*! - * \brief Retrieves the value of the species density in the primitive variable vector. - * \param[in] iRho_s - */ - void SetRhoCvtrIndex(unsigned short val_Index); - - /*! - * \brief Retrieves the value of the species density in the primitive variable vector. - * \param[in] iRho_s - */ - void SetRhoCvveIndex(unsigned short val_Index); - - /*! - * \brief Sets the value of the derivative of pressure w.r.t. species density. - * \param[in] iRho_s - */ - void SetdPdU(su2double *val_dPdU_i, su2double *val_dPdU_j); - - /*! - * \brief Sets the value of the derivative of temperature w.r.t. species density. - * \param[in] iRho_s - */ - void SetdTdU(su2double *val_dTdU_i, su2double *val_dTdU_j); - - /*! - * \brief Sets the value of the derivative of vib-el. temperature w.r.t. species density. - * \param[in] iRho_s - */ - void SetdTvedU(su2double *val_dTvedU_i, su2double *val_dTvedU_j); - - /*! - * \brief Sets the values of the roe dissipation. - * \param[in] diss_i - Dissipation value at node i - * \param[in] diss_j - Dissipation value at node j - */ - void SetDissipation(su2double diss_i, su2double diss_j); - - /*! - * \brief Get the final Roe dissipation factor. - */ - su2double GetDissipation(); - - /*! - * \brief Get the inviscid fluxes. - * \param[in] val_density - Value of the density. - * \param[in] val_velocity - Value of the velocity. - * \param[in] val_pressure - Value of the pressure. - * \param[in] val_enthalpy - Value of the enthalpy. - */ - void GetInviscidFlux(su2double val_density, su2double *val_velocity, su2double val_pressure, su2double val_enthalpy); - - /*! - * \brief Compute the projected inviscid flux vector. - * \param[in] val_density - Pointer to the density. - * \param[in] val_velocity - Pointer to the velocity. - * \param[in] val_pressure - Pointer to the pressure. - * \param[in] val_enthalpy - Pointer to the enthalpy. - * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. - * \param[out] val_Proj_Flux - Pointer to the projected flux. - */ - void GetInviscidProjFlux(su2double *val_density, su2double *val_velocity, - su2double *val_pressure, su2double *val_enthalpy, - su2double *val_normal, su2double *val_Proj_Flux); - - /*! - * \brief Compute the projected inviscid flux vector for incompresible simulations - * \param[in] val_density - Pointer to the density. - * \param[in] val_velocity - Pointer to the velocity. - * \param[in] val_pressure - Pointer to the pressure. - * \param[in] val_betainc2 - Value of the artificial compresibility factor. - * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. - * \param[out] val_Proj_Flux - Pointer to the projected flux. - */ - void GetInviscidIncProjFlux(su2double *val_density, su2double *val_velocity, - su2double *val_pressure, su2double *val_betainc2, - su2double *val_enthalpy, - su2double *val_normal, su2double *val_Proj_Flux); - - /*! - * \brief Compute the projection of the inviscid Jacobian matrices. - * \param[in] val_velocity Pointer to the velocity. - * \param[in] val_energy Value of the energy. - * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. - * \param[in] val_scale - Scale of the projection. - * \param[out] val_Proj_Jac_tensor - Pointer to the projected inviscid Jacobian. - */ - void GetInviscidProjJac(su2double *val_velocity, su2double *val_energy, - su2double *val_normal, su2double val_scale, - su2double **val_Proj_Jac_tensor); - - /*! - * \brief Compute the projection of the inviscid Jacobian matrices (incompressible). - * \param[in] val_density - Value of the density. - * \param[in] val_velocity - Pointer to the velocity. - * \param[in] val_betainc2 - Value of the artificial compresibility factor. - * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. - * \param[in] val_scale - Scale of the projection. - * \param[out] val_Proj_Jac_tensor - Pointer to the projected inviscid Jacobian. - */ - void GetInviscidIncProjJac(su2double *val_density, su2double *val_velocity, - su2double *val_betainc2, su2double *val_normal, - su2double val_scale, - su2double **val_Proj_Jac_tensor); - - /*! - * \brief Compute the projection of the inviscid Jacobian matrices (overload for low speed preconditioner version). - * \param[in] val_density - Value of the density. - * \param[in] val_velocity - Pointer to the velocity. - * \param[in] val_betainc2 - Value of the artificial compresibility factor. - * \param[in] val_cp - Value of the specific heat at constant pressure. - * \param[in] val_temperature - Value of the temperature. - * \param[in] val_dRhodT - Value of the derivative of density w.r.t. temperature. - * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. - * \param[in] val_scale - Scale of the projection. - * \param[out] val_Proj_Jac_tensor - Pointer to the projected inviscid Jacobian. - */ - void GetInviscidIncProjJac(su2double *val_density, - su2double *val_velocity, - su2double *val_betainc2, - su2double *val_cp, - su2double *val_temperature, - su2double *val_dRhodT, - su2double *val_normal, - su2double val_scale, - su2double **val_Proj_Jac_Tensor); - - /*! - * \brief Compute the low speed preconditioning matrix. - * \param[in] val_density - Value of the density. - * \param[in] val_velocity - Pointer to the velocity. - * \param[in] val_betainc2 - Value of the artificial compresibility factor. - * \param[in] val_cp - Value of the specific heat at constant pressure. - * \param[in] val_temperature - Value of the temperature. - * \param[in] val_dRhodT - Value of the derivative of density w.r.t. temperature. - * \param[out] val_Precon - Pointer to the preconditioning matrix. - */ - void GetPreconditioner(su2double *val_density, - su2double *val_velocity, - su2double *val_betainc2, - su2double *val_cp, - su2double *val_temperature, - su2double *val_drhodt, - su2double **val_Precon); - - /*! - * \brief Compute the projection of the preconditioned inviscid Jacobian matrices. - * \param[in] val_density - Value of the density. - * \param[in] val_velocity - Pointer to the velocity. - * \param[in] val_betainc2 - Value of the artificial compresibility factor. - * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. - * \param[out] val_Proj_Jac_tensor - Pointer to the projected inviscid Jacobian. - */ - void GetPreconditionedProjJac(su2double *val_density, - su2double *val_velocity, - su2double *val_betainc2, - su2double *val_normal, - su2double **val_Proj_Jac_Tensor); - - /*! - * \brief Compute the projection of the inviscid Jacobian matrices for general fluid model. - * \param[in] val_velocity Pointer to the velocity. - * \param[in] val_energy Value of the energy. - * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. - * \param[in] val_scale - Scale of the projection. - * \param[out] val_Proj_Jac_tensor - Pointer to the projected inviscid Jacobian. - */ - void GetInviscidProjJac(su2double *val_velocity, su2double *val_enthalphy, - su2double *val_chi, su2double *val_kappa, - su2double *val_normal, su2double val_scale, - su2double **val_Proj_Jac_tensor); - - /*! - * \brief Mapping between primitives variables P and conservatives variables C. - * \param[in] val_Mean_PrimVar - Mean value of the primitive variables. - * \param[in] val_Mean_PrimVar - Mean Value of the secondary variables. - * \param[out] val_Jac_PC - Pointer to the Jacobian dPdC. - */ - void GetPrimitive2Conservative (su2double *val_Mean_PrimVar, - su2double *val_Mean_SecVar, - su2double **val_Jac_PC); - - /*! - * \overload - * \brief Computation of the matrix P for a generic fluid model - * \param[in] val_density - Value of the density. - * \param[in] val_velocity - Value of the velocity. - * \param[in] val_soundspeed - Value of the sound speed. - * \param[in] val_enthalpy - Value of the Enthalpy - * \param[in] val_chi - Value of the derivative of Pressure with respect to the Density. - * \param[in] val_kappa - Value of the derivative of Pressure with respect to the volume specific Static Energy. - * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. - * \param[out] val_p_tensor - Pointer to the P matrix. - */ - void GetPMatrix(su2double *val_density, su2double *val_velocity, - su2double *val_soundspeed, su2double *val_enthalpy, su2double *val_chi, su2double *val_kappa, - su2double *val_normal, su2double **val_p_tensor); - - /*! - * \brief Computation of the matrix P, this matrix diagonalize the conservative Jacobians in - * the form $P^{-1}(A.Normal)P=Lambda$. - * \param[in] val_density - Value of the density. - * \param[in] val_velocity - Value of the velocity. - * \param[in] val_soundspeed - Value of the sound speed. - * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. - * \param[out] val_p_tensor - Pointer to the P matrix. - */ - void GetPMatrix(su2double *val_density, su2double *val_velocity, - su2double *val_soundspeed, su2double *val_normal, - su2double **val_p_tensor); - - /*! - * \brief Computation of the matrix Rinv*Pe. - * \param[in] Beta2 - A variable in used to define Pe matrix. - * \param[in] val_enthalpy - value of the enthalpy. - * \param[in] val_soundspeed - value of the sound speed. - * \param[in] val_density - value of the density. - * \param[in] val_velocity - value of the velocity. - * \param[out] val_invR_invPe - Pointer to the matrix of conversion from entropic to conserved variables. - */ - void GetinvRinvPe(su2double Beta2, su2double val_enthalpy, su2double val_soundspeed, - su2double val_density, su2double* val_velocity, - su2double** val_invR_invPe); - - /*! - * \brief Computation of the matrix R. - * \param[in] val_pressure - value of the pressure. - * \param[in] val_soundspeed - value of the sound speed. - * \param[in] val_density - value of the density. - * \param[in] val_velocity - value of the velocity. - * \param[out] val_invR_invPe - Pointer to the matrix of conversion from entropic to conserved variables. - */ - - void GetRMatrix(su2double val_pressure, su2double val_soundspeed, - su2double val_density, su2double* val_velocity, - su2double** val_invR_invPe); - /*! - * \brief Computation of the matrix R. - * \param[in] val_soundspeed - value of the sound speed. - * \param[in] val_density - value of the density. - * \param[out] R_Matrix - Pointer to the matrix of conversion from entropic to conserved variables. - */ - void GetRMatrix(su2double val_soundspeed, su2double val_density, su2double **R_Matrix); - - /*! - * \brief Computation of the matrix R. - * \param[in] val_soundspeed - value of the sound speed. - * \param[in] val_density - value of the density. - * \param[out] L_Matrix - Pointer to the matrix of conversion from conserved to entropic variables. - */ - void GetLMatrix(su2double val_soundspeed, su2double val_density, su2double **L_Matrix); - - /*! - * \brief Computation of the flow Residual Jacoboan Matrix for Non Reflecting BC. - * \param[in] val_soundspeed - value of the sound speed. - * \param[in] val_density - value of the density. - * \param[out] R_c - Residual Jacoboan Matrix - * \param[out] R_c_inv- inverse of the Residual Jacoboan Matrix . - */ - void ComputeResJacobianGiles(CFluidModel *FluidModel, su2double pressure, su2double density, su2double *turboVel, - su2double alphaInBC, su2double gammaInBC, su2double **R_c, su2double **R_c_inv); - - /*! - * \brief Computate the inverse of a 3x3 matrix - * \param[in] matrix - the matrix to invert - * \param[out] invMatrix - inverse matrix. - */ - void InvMatrix3D(su2double **matrix, su2double **invMatrix); - - /*! - * \brief Computate the inverse of a 4x4 matrix - * \param[in] matrix - the matrix to invert - * \param[out] invMatrix - inverse matrix. - */ - void InvMatrix4D(su2double **matrix, su2double **invMatrix); - - /*! - * \brief Computation of the matrix R. - * \param[in] val_soundspeed - value of the sound speed. - * \param[in] val_density - value of the density. - * \param[in] prim_jump - pointer to the vector containing the primitive variable jump (drho, dV, dp). - * \param[out]char_jump - pointer to the vector containing the characteristic variable jump. - */ - void GetCharJump(su2double val_soundspeed, su2double val_density, su2double *prim_jump, su2double *char_jump); - - /*! - * \brief Computation of the matrix Td, this matrix diagonalize the preconditioned conservative Jacobians - * in the form $Tg |Lambda| Td = Pc{-1}|Pc (A.Normal)|$. - * \param[in] Beta2 - A variable in used to define absPeJacobian matrix. - * \param[in] r_hat - A variable in used to define absPeJacobian matrix. - * \param[in] s_hat - A variable in used to define absPeJacobian matrix. - * \param[in] t_hat - A variable in used to define absPeJacobian matrix. - * \param[in] rB2a2 - A variable in used to define absPeJacobian matrix. - * \param[in] val_Lambda - Eigenvalues of the Preconditioned Jacobian. - * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. - * \param[out] val_absPeJac - Pointer to the Preconditioned Jacobian matrix. - */ - void GetPrecondJacobian(su2double Beta2, su2double r_hat, su2double s_hat, su2double t_hat, su2double rB2a2, su2double* val_Lambda, su2double* val_normal, su2double** val_absPeJac); - - - /*! - * \brief Computation of the matrix P^{-1}, this matrix diagonalize the conservative Jacobians - * in the form $P^{-1}(A.Normal)P=Lambda$. - * \param[in] val_density - Value of the density. - * \param[in] val_velocity - Value of the velocity. - * \param[in] val_soundspeed - Value of the sound speed. - * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. - * \param[out] val_invp_tensor - Pointer to inverse of the P matrix. - */ - void GetPMatrix_inv(su2double **val_invp_tensor, su2double *val_density, - su2double *val_velocity, su2double *val_soundspeed, - su2double *val_chi, su2double *val_kappa, - su2double *val_normal); - - /*! - * \brief Computation of the matrix P^{-1}, this matrix diagonalize the conservative Jacobians - * in the form $P^{-1}(A.Normal)P=Lambda$. - * \param[in] val_density - Value of the density. - * \param[in] val_velocity - Value of the velocity. - * \param[in] val_soundspeed - Value of the sound speed. - * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. - * \param[out] val_invp_tensor - Pointer to inverse of the P matrix. - */ - void GetPMatrix_inv(su2double *val_density, su2double *val_velocity, - su2double *val_soundspeed, su2double *val_normal, - su2double **val_invp_tensor); - - /*! - * \brief Compute viscous residual and jacobian. - */ - void GetAdjViscousFlux_Jac(su2double Pressure_i, su2double Pressure_j, su2double Density_i, su2double Density_j, - su2double ViscDens_i, su2double ViscDens_j, su2double *Velocity_i, su2double *Velocity_j, - su2double sq_vel_i, su2double sq_vel_j, - su2double XiDens_i, su2double XiDens_j, su2double **Mean_GradPhi, su2double *Mean_GradPsiE, - su2double dPhiE_dn, su2double *Normal, su2double *Edge_Vector, su2double dist_ij_2, su2double *val_residual_i, - su2double *val_residual_j, - su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, su2double **val_Jacobian_ji, - su2double **val_Jacobian_jj, bool implicit); - - /*! - * \brief Computation of the projected inviscid lambda (eingenvalues). - * \param[in] val_velocity - Value of the velocity. - * \param[in] val_soundspeed - Value of the sound speed. - * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. - * \param[in] val_Lambda_Vector - Pointer to Lambda matrix. - */ - void GetJacInviscidLambda_fabs(su2double *val_velocity, su2double val_soundspeed, - su2double *val_normal, su2double *val_Lambda_Vector); - - /*! - * \brief Compute the numerical residual. - * \param[out] val_residual - Pointer to the total residual. - * \param[in] config - Definition of the particular problem. - */ - virtual void ComputeResidual(su2double *val_residual, CConfig *config); - - /*! - * \overload - * \param[out] val_residual_i - Pointer to the total residual at point i. - * \param[out] val_residual_j - Pointer to the total residual at point j. - */ - virtual void ComputeResidual(su2double *val_residual_i, su2double *val_residual_j); - - virtual void ComputeResidual_TransLM(su2double *val_residual, - su2double **val_Jacobian_i, - su2double **val_Jacobian_j, CConfig *config, - su2double &gamma_sep) ; - - /*! - * \overload - * \param[out] val_residual_i - Pointer to the total residual at point i. - * \param[out] val_residual_j - Pointer to the total residual at point j. - * \param[in] config - Definition of the particular problem. - */ - virtual void ComputeResidual(su2double *val_residual_i, - su2double *val_residual_j, CConfig *config); - - /*! - * \overload - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - virtual void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, - su2double **val_Jacobian_j, CConfig *config); - - /*! - * \overload - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[out] val_JacobianMeanFlow_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_JacobianMeanFlow_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - virtual void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, - su2double **val_Jacobian_j, - su2double **val_JacobianMeanFlow_i, - su2double **val_JacobianMeanFlow_j, - CConfig *config); - - /*! - * \overload - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - virtual void ComputeResidual(su2double **val_Jacobian_i, su2double **val_Jacobian_j, - CConfig *config); - - /*! - * \overload - * \param[out] val_resconv - Pointer to the convective residual. - * \param[out] val_resvisc - Pointer to the artificial viscosity residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - virtual void ComputeResidual(su2double *val_resconv, su2double *val_resvisc, - su2double **val_Jacobian_i, su2double **val_Jacobian_j, - CConfig *config); - - /*! - * \overload - * \param[out] val_residual_i - Pointer to the total residual at point i. - * \param[out] val_residual_j - Pointer to the total viscosity residual at point j. - * \param[out] val_Jacobian_ii - Jacobian of the numerical method at node i (implicit computation) from node i. - * \param[out] val_Jacobian_ij - Jacobian of the numerical method at node i (implicit computation) from node j. - * \param[out] val_Jacobian_ji - Jacobian of the numerical method at node j (implicit computation) from node i. - * \param[out] val_Jacobian_jj - Jacobian of the numerical method at node j (implicit computation) from node j. - * \param[in] config - Definition of the particular problem. - */ - virtual void ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, - su2double **val_Jacobian_ii, - su2double **val_Jacobian_ij, - su2double **val_Jacobian_ji, - su2double **val_Jacobian_jj, CConfig *config); - - /*! - * \overload - * \param[out] val_resconv_i - Pointer to the convective residual at point i. - * \param[out] val_resvisc_i - Pointer to the artificial viscosity residual at point i. - * \param[out] val_resconv_j - Pointer to the convective residual at point j. - * \param[out] val_resvisc_j - Pointer to the artificial viscosity residual at point j. - * \param[out] val_Jacobian_ii - Jacobian of the numerical method at node i (implicit computation) from node i. - * \param[out] val_Jacobian_ij - Jacobian of the numerical method at node i (implicit computation) from node j. - * \param[out] val_Jacobian_ji - Jacobian of the numerical method at node j (implicit computation) from node i. - * \param[out] val_Jacobian_jj - Jacobian of the numerical method at node j (implicit computation) from node j. - * \param[in] config - Definition of the particular problem. - */ - virtual void ComputeResidual(su2double *val_resconv_i, su2double *val_resvisc_i, - su2double *val_resconv_j, su2double *val_resvisc_j, - su2double **val_Jacobian_ii, - su2double **val_Jacobian_ij, - su2double **val_Jacobian_ji, - su2double **val_Jacobian_jj, CConfig *config); - - /*! - * \overload - * \param[out] val_stiffmatrix_elem - Stiffness matrix for Galerkin computation. - * \param[in] config - Definition of the particular problem. - */ - virtual void ComputeResidual(su2double **val_stiffmatrix_elem, CConfig *config); - - /*! - * \overload - * \param[in] config - Definition of the particular problem. - * \param[out] val_residual - residual of the source terms - * \param[out] val_Jacobian_i - Jacobian of the source terms - */ - virtual void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, - CConfig *config); - - /*! - * \overload - * \param[out] - Matrix for storing the constants to be used in the calculation of the equilibrium extent of reaction Keq. - * \param[in] config - Definition of the particular problem. - */ - virtual void GetEq_Rxn_Coefficients(su2double **EqnRxnConstants, CConfig *config); - - /*! - * \brief Residual for source term integration. - * \param[out] val_residual - Pointer to the source residual containing chemistry terms. - * \param[in] config - Definition of the particular problem. - */ - virtual void ComputeResidual_Axisymmetric(su2double *val_residual, CConfig *config); - - /*! - * \brief Residual for source term integration. - * \param[out] val_residual - Pointer to the source residual containing chemistry terms. - * \param[in] config - Definition of the particular problem. - */ - virtual void ComputeResidual_Axisymmetric_ad(su2double *val_residual, su2double *val_residuald, CConfig *config); - - /*! - * \brief Calculation of axisymmetric source term Jacobian - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - virtual void SetJacobian_Axisymmetric(su2double **val_Jacobian_i, CConfig *config); - - /*! - * \brief Calculation of the translational-vibrational energy exchange source term - * \param[in] config - Definition of the particular problem. - * \param[out] val_residual - residual of the source terms - * \param[out] val_Jacobian_i - Jacobian of the source terms - */ - virtual void ComputeVibRelaxation(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config); - - /*! - * \brief Calculation of the chemistry source term - * \param[in] config - Definition of the particular problem. - * \param[out] val_residual - residual of the source terms - * \param[out] val_Jacobian_i - Jacobian of the source terms - */ - virtual void ComputeChemistry(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config); - - /*! - * \brief Calculates constants used for Keq correlation. - * \param[out] A - Pointer to coefficient array. - * \param[in] val_reaction - Reaction number indicator. - * \param[in] config - Definition of the particular problem. - */ - virtual void GetKeqConstants(su2double *A, unsigned short val_reaction, CConfig *config); - - /*! - * \brief Set intermittency for numerics (used in SA with LM transition model) - */ - virtual void SetIntermittency(su2double intermittency_in); - - /*! - * \brief Residual for source term integration. - * \param[in] val_production - Value of the Production. - */ - virtual void SetProduction(su2double val_production); - - /*! - * \brief Residual for source term integration. - * \param[in] val_destruction - Value of the Destruction. - */ - virtual void SetDestruction(su2double val_destruction); - - /*! - * \brief Residual for source term integration. - * \param[in] val_crossproduction - Value of the CrossProduction. - */ - virtual void SetCrossProduction(su2double val_crossproduction); - - /*! - * \brief Residual for source term integration. - * \param[in] val_production - Value of the Production. - */ - virtual su2double GetProduction(void); - - /*! - * \brief Residual for source term integration. - * \param[in] val_destruction - Value of the Destruction. - */ - virtual su2double GetDestruction(void); - - /*! - * \brief Residual for source term integration. - * \param[in] val_crossproduction - Value of the CrossProduction. - */ - virtual su2double GetCrossProduction(void); - - /*! - * \brief A virtual member. - */ - virtual su2double GetGammaBC(void); - - /*! - * \overload - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i - * \param[in] config - Definition of the particular problem. - */ - virtual void ComputeResidual(su2double **val_Jacobian_i, - su2double *val_Jacobian_mui, - su2double ***val_Jacobian_gradi, CConfig *config); - - /*! - * \overload - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i - * \param[in] config - Definition of the particular problem. - */ - virtual void ComputeResidual(su2double **val_Jacobian_i, - su2double *val_Jacobian_mui, - su2double ***val_Jacobian_gradi, - su2double **val_Jacobian_j, - su2double *val_Jacobian_muj, - su2double ***val_Jacobian_gradj, CConfig *config); - - /*! - * \brief A virtual member to compute the tangent matrix in structural problems - * \param[in] element_container - Element structure for the particular element integrated. - */ - virtual void Compute_Tangent_Matrix(CElement *element_container, CConfig *config); - - /*! - * \brief A virtual member to compute the nodal stress term in non-linear structural problems - * \param[in] element_container - Definition of the particular element integrated. - */ - virtual void Compute_NodalStress_Term(CElement *element_container, CConfig *config); - - /*! - * \brief Set the element-based local Young's modulus in mesh problems - * \param[in] iElem - Element index. - * \param[in] val_E - Value of elasticity modulus. - */ - virtual void SetMeshElasticProperties(unsigned long iElem, su2double val_E); - - /*! - * \brief A virtual member to set the value of the design variables - * \param[in] i_DV - Index of the design variable. - * \param[in] val_DV - Value of the design variable - */ - virtual void Set_DV_Val(unsigned short i_DV, su2double val_DV); - - /*! - * \brief A virtual member to retrieve the value of the design variables - * \param[in] i_DV - Index of the design variable. - */ - virtual su2double Get_DV_Val(unsigned short i_DV) const; - - /*! - * \brief A virtual member to set the electric field - * \param[in] EField_DV - New electric field computed by adjoint methods. - */ - virtual void Set_ElectricField(unsigned short i_DV, su2double val_EField); - - /*! - * \brief A virtual member to set the material properties - * \param[in] iVal - Index of the region of concern - * \param[in] val_E - Value of the Young Modulus. - * \param[in] val_Nu - Value of the Poisson's ratio. - */ - virtual void SetMaterial_Properties(unsigned short iVal, su2double val_E, su2double val_Nu); - - /*! - * \brief A virtual member to set the material properties - * \param[in] iVal - Index of the region of concern - * \param[in] val_Rho - Value of the density (inertial effects). - * \param[in] val_Rho_DL - Value of the density (dead load effects). - */ - virtual void SetMaterial_Density(unsigned short iVal, su2double val_Rho, su2double val_Rho_DL); - - /*! - * \brief A virtual member to compute the mass matrix - * \param[in] element_container - Element structure for the particular element integrated. - */ - virtual void Compute_Mass_Matrix(CElement *element_container, CConfig *config); - - /*! - * \brief A virtual member to compute the residual component due to dead loads - * \param[in] element_container - Element structure for the particular element integrated. - */ - virtual void Compute_Dead_Load(CElement *element_container, CConfig *config); - - /*! - * \brief A virtual member to compute the averaged nodal stresses - * \param[in] element_container - Element structure for the particular element integrated. - */ - virtual void Compute_Averaged_NodalStress(CElement *element_container, CConfig *config); - - /*! - * \brief Computes a basis of orthogonal vectors from a suppled vector - * \param[in] config - Normal vector - */ - void CreateBasis(su2double *val_Normal); - - /*! - * \brief Set the value of the Tauwall - * \param[in] val_tauwall_i - Tauwall at point i - * \param[in] val_tauwall_j - Tauwall at point j - */ - virtual void SetTauWall(su2double val_tauwall_i, su2double val_tauwall_j); - - /*! - * \brief - Calculate the central/upwind blending function for a face - * - * At its simplest level, this function will calculate the average - * value of the "Roe dissipation" or central/upwind blending function - * at a face. If Ducros shock sensors are used, then this method will - * also adjust the central/upwind blending to account for shocks. - * - * \param[in] Dissipation_i - Value of the blending function at point i - * \param[in] Dissipation_j - Value of the bledning function at point j - * \param[in] Sensor_i - Shock sensor at point i - * \param[in] Sensor_j - Shock sensor at point j - * \param[out] Dissipation_ij - Blending parameter at face - */ - void SetRoe_Dissipation(const su2double Dissipation_i, - const su2double Dissipation_j, - const su2double Sensor_i, const su2double Sensor_j, - su2double& Dissipation_ij, CConfig *config); - - /*! - * \brief Setting the UQ framework usage - * \param[in] val_using_uq - */ - void SetUsing_UQ(bool val_using_uq); - - /*! - * \brief Decomposes the symmetric matrix A_ij, into eigenvectors and eigenvalues - * \param[in] A_i: symmetric matrix to be decomposed - * \param[in] Eig_Vec: strores the eigenvectors - * \param[in] Eig_Val: stores the eigenvalues - * \param[in] n: order of matrix A_ij - */ - static void EigenDecomposition(su2double **A_ij, su2double **Eig_Vec, su2double *Eig_Val, unsigned short n); - - /*! - * \brief Recomposes the eigenvectors and eigenvalues into a matrix - * \param[in] A_ij: recomposed matrix - * \param[in] Eig_Vec: eigenvectors - * \param[in] Eig_Val: eigenvalues - * \param[in] n: order of matrix A_ij - */ - static void EigenRecomposition(su2double **A_ij, su2double **Eig_Vec, su2double *Eig_Val, unsigned short n); - - /*! - * \brief tred2 - * \param[in] V: matrix that needs to be decomposed - * \param[in] d: holds eigenvalues - * \param[in] e: supplemental data structure - * \param[in] n: order of matrix V - */ - static void tred2(su2double **V, su2double *d, su2double *e, unsigned short n); - - /*! - * \brief tql2 - * \param[in] V: matrix that will hold the eigenvectors - * \param[in] d: array that will hold the ordered eigenvalues - * \param[in] e: supplemental data structure - * \param[in] n: order of matrix V - - */ - static void tql2(su2double **V, su2double *d, su2double *e, unsigned short n); - -}; - -/*! - * \class CUpwCUSP_Flow - * \brief Class for centered scheme - CUSP. - * \ingroup ConvDiscr - * \author F. Palacios - */ -class CUpwCUSP_Flow : public CNumerics { - -private: - su2double *Velocity_i, *Velocity_j, *ProjFlux_i, *ProjFlux_j; - bool implicit; - -public: - - /*! - * \brief Constructor of the class. - * \param[in] val_nDim - Number of dimension of the problem. - * \param[in] val_nVar - Number of variables of the problem. - * \param[in] config - Definition of the particular problem. - */ - CUpwCUSP_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwCUSP_Flow(void); - - /*! - * \brief Compute the flow residual using a JST method. - * \param[out] val_residual - Pointer to the residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, - CConfig *config); -}; - -/*! - * \class CUpwRoeBase_Flow - * \brief Intermediate base class for Roe schemes on ideal gas. - * \ingroup ConvDiscr - * \author A. Bueno, F. Palacios - */ -class CUpwRoeBase_Flow : public CNumerics { -protected: - bool implicit, dynamic_grid, roe_low_dissipation; - su2double *Velocity_i, *Velocity_j, *ProjFlux_i, *ProjFlux_j, *Conservatives_i, *Conservatives_j; - su2double *Diff_U, *Lambda, **P_Tensor, **invP_Tensor; - su2double *RoeVelocity, RoeDensity, RoeEnthalpy, RoeSoundSpeed, ProjVelocity, RoeSoundSpeed2, kappa; - - /*! - * \brief Derived classes must specialize this method to add the specifics of the scheme they implement (e.g. low-Mach precond.). - * \param[out] val_residual - Convective flux. - * \param[out] val_Jacobian_i - Flux Jacobian wrt node i conservatives (implicit computation). - * \param[out] val_Jacobian_j - Flux Jacobian wrt node j conservatives (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - virtual void FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) = 0; - -public: - - /*! - * \brief Constructor of the class. - * \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. - * \param[in] val_low_dissipation - Use a low dissipation formulation. - */ - CUpwRoeBase_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, bool val_low_dissipation); - - /*! - * \brief Destructor of the class. - */ - ~CUpwRoeBase_Flow(void); - - /*! - * \brief Compute the flux from node i to node j, part common to most Roe schemes. - * \param[out] val_residual - Convective flux. - * \param[out] val_Jacobian_i - Flux Jacobian wrt node i conservatives (implicit computation). - * \param[out] val_Jacobian_j - Flux Jacobian wrt node j conservatives (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - -}; - -/*! - * \class CUpwRoe_Flow - * \brief Class for solving an approximate Riemann solver of Roe for the flow equations. - * \ingroup ConvDiscr - * \author A. Bueno, F. Palacios - */ -class CUpwRoe_Flow : public CUpwRoeBase_Flow { -private: - /*! - * \brief Add standard Roe dissipation to the flux. - * \param[out] val_residual - Convective flux. - * \param[out] val_Jacobian_i - Flux Jacobian wrt node i conservatives (implicit computation). - * \param[out] val_Jacobian_j - Flux Jacobian wrt node j conservatives (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - -public: - - /*! - * \brief Constructor of the class. - * \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. - * \param[in] val_low_dissipation - Use a low dissipation formulation. - */ - CUpwRoe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, bool val_low_dissipation); - - /*! - * \brief Destructor of the class. - */ - ~CUpwRoe_Flow(void); - -}; - - -/*! - * \class CUpwGeneralRoe_Flow - * \brief Class for solving an approximate Riemann solver of Roe for the flow equations for a general fluid model. - * \ingroup ConvDiscr - * \author S.Vitale, G.Gori, M.Pini - */ -class CUpwGeneralRoe_Flow : public CNumerics { -private: - - bool implicit, dynamic_grid; - - su2double *Diff_U; - su2double *Velocity_i, *Velocity_j, *RoeVelocity; - su2double *ProjFlux_i, *ProjFlux_j; - su2double *delta_wave, *delta_vel; - su2double *Lambda, *Epsilon, MaxLambda, Delta; - su2double **P_Tensor, **invP_Tensor; - su2double sq_vel, Proj_ModJac_Tensor_ij, Density_i, Energy_i, SoundSpeed_i, Pressure_i, Enthalpy_i, - - Density_j, Energy_j, SoundSpeed_j, Pressure_j, Enthalpy_j, R, RoeDensity, RoeEnthalpy, RoeSoundSpeed, RoeSoundSpeed2, - ProjVelocity, ProjVelocity_i, ProjVelocity_j, proj_delta_vel, delta_p, delta_rho, kappa; - unsigned short iDim, iVar, jVar, kVar; - - - su2double StaticEnthalpy_i, StaticEnergy_i, StaticEnthalpy_j, StaticEnergy_j, Kappa_i, Kappa_j, Chi_i, Chi_j, Velocity2_i, Velocity2_j; - su2double RoeKappa, RoeChi; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwGeneralRoe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwGeneralRoe_Flow(void); - - /*! - * \brief Compute the Roe's flux between two nodes i and j. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - - /*! - * \brief Compute the Average for a general fluid flux between two nodes i and j. - * Using the approach of Vinokur and Montagne' - */ - - void ComputeRoeAverage(); -}; - -/*! - * \class CUpwL2Roe_Flow - * \brief Class for solving an approximate Riemann solver of L2Roe for the flow equations. - * \ingroup ConvDiscr - * \author E. Molina, A. Bueno, F. Palacios - * \version 7.0.1 "Blackbird" - */ -class CUpwL2Roe_Flow : public CUpwRoeBase_Flow { -private: - /*! - * \brief Add L^2 Roe dissipation to the flux (low-Mach scheme). - * \param[out] val_residual - Convective flux. - * \param[out] val_Jacobian_i - Flux Jacobian wrt node i conservatives (implicit computation). - * \param[out] val_Jacobian_j - Flux Jacobian wrt node j conservatives (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - -public: - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwL2Roe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwL2Roe_Flow(void); -}; - -/*! - * \class CUpwLMRoe_Flow - * \brief Class for solving an approximate Riemann solver of LMRoe for the flow equations. - * \ingroup ConvDiscr - * \author E. Molina, A. Bueno, F. Palacios - * \version 7.0.1 "Blackbird" - */ -class CUpwLMRoe_Flow : public CUpwRoeBase_Flow { -private: - /*! - * \brief Add LMRoe dissipation to the flux (low-Mach scheme). - * \param[out] val_residual - Convective flux. - * \param[out] val_Jacobian_i - Flux Jacobian wrt node i conservatives (implicit computation). - * \param[out] val_Jacobian_j - Flux Jacobian wrt node j conservatives (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - -public: - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwLMRoe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwLMRoe_Flow(void); -}; - -/*! - * \class CUpwMSW_Flow - * \brief Class for solving a flux-vector splitting method by Steger & Warming, modified version. - * \ingroup ConvDiscr - * \author S. Copeland - */ -class CUpwMSW_Flow : public CNumerics { -private: - bool implicit; - su2double *Diff_U; - su2double *u_i, *u_j, *ust_i, *ust_j; - su2double *Fc_i, *Fc_j; - su2double *Lambda_i, *Lambda_j; - su2double rhos_i, rhos_j; - su2double *Ust_i, *Ust_j, *Vst_i, *Vst_j, *Velst_i, *Velst_j; - su2double **P_Tensor, **invP_Tensor; - unsigned short nPrimVar, nVar, nDim; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwMSW_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwMSW_Flow(void); - - /*! - * \brief Compute the Roe's flux between two nodes i and j. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - -}; - -/*! - * \class CUpwTurkel_Flow - * \brief Class for solving an approximate Riemann solver of Roe with Turkel Preconditioning for the flow equations. - * \ingroup ConvDiscr - * \author A. K. Lonkar - */ -class CUpwTurkel_Flow : public CNumerics { -private: - bool implicit, dynamic_grid; - su2double *Diff_U; - su2double *Velocity_i, *Velocity_j, *RoeVelocity; - su2double *ProjFlux_i, *ProjFlux_j; - su2double *Lambda, *Epsilon; - su2double **absPeJac, **invRinvPe, **R_Tensor, **Matrix, **Art_Visc; - su2double sq_vel, Density_i, Energy_i, SoundSpeed_i, Pressure_i, Enthalpy_i, - Density_j, Energy_j, SoundSpeed_j, Pressure_j, Enthalpy_j, R, RoePressure, RoeDensity, RoeEnthalpy, RoeSoundSpeed, - ProjVelocity, ProjVelocity_i, ProjVelocity_j; - unsigned short iDim, iVar, jVar, kVar; - su2double Beta, Beta_min, Beta_max; - su2double r_hat, s_hat, t_hat, rhoB2a2, sqr_one_m_Betasqr_Lam1; - su2double Beta2, one_m_Betasqr, one_p_Betasqr, sqr_two_Beta_c_Area; - su2double local_Mach; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwTurkel_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwTurkel_Flow(void); - - /*! - * \brief Compute the Roe's flux between two nodes i and j. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - -}; - -/*! - * \class CUpwFDSInc_Flow - * \brief Class for solving a Flux Difference Splitting (FDS) upwind method for the incompressible flow equations. - * \ingroup ConvDiscr - * \author F. Palacios, T. Economon - */ -class CUpwFDSInc_Flow : public CNumerics { -private: - bool implicit, /*!< \brief Implicit calculation. */ - dynamic_grid, /*!< \brief Modification for grid movement. */ - variable_density, /*!< \brief Variable density incompressible flows. */ - energy; /*!< \brief computation with the energy equation. */ - su2double *Diff_V; - su2double *Velocity_i, *Velocity_j, *MeanVelocity; - su2double *ProjFlux_i, *ProjFlux_j; - su2double *Lambda, *Epsilon; - su2double **Precon, **invPrecon_A; - su2double Proj_ModJac_Tensor_ij, Pressure_i, - Pressure_j, ProjVelocity, - MeandRhodT, dRhodT_i, dRhodT_j, /*!< \brief Derivative of density w.r.t. temperature (variable density flows). */ - Temperature_i, Temperature_j, /*!< \brief Temperature at node 0 and 1. */ - MeanDensity, MeanPressure, MeanSoundSpeed, MeanBetaInc2, MeanEnthalpy, MeanCp, MeanTemperature; /*!< \brief Mean values of primitive variables. */ - unsigned short iDim, iVar, jVar, kVar; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwFDSInc_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwFDSInc_Flow(void); - - /*! - * \brief Compute the upwind flux between two nodes i and j. - * \param[out] val_residual - Pointer to the residual array. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, - CConfig *config); -}; - -/*! - * \class CUpwRoe_AdjFlow - * \brief Class for solving an approximate Riemann solver of Roe - * for the adjoint flow equations. - * \ingroup ConvDiscr - * \author F. Palacios - */ -class CUpwRoe_AdjFlow : public CNumerics { -private: - su2double *Residual_Roe; - su2double area, Sx, Sy, Sz, rarea, nx, ny, nz, rho_l, u_l, v_l, w_l, h_l, rho_r, - u_r, v_r, w_r, h_r, psi1, psi2, psi3, psi4, psi5; - su2double h, u, v, w, c, psi1_l, psi2_l, psi3_l, psi4_l, psi5_l, - psi1_r, psi2_r, psi3_r, psi4_r, psi5_r, q_l, q_r, Q_l, Q_r, vn, - rrho_l, weight, rweight1, cc; - su2double l1psi, l2psi, absQ, absQp, absQm, q2, alpha, beta_u, beta_v, beta_w, Q, l1l2p, l1l2m, eta; - su2double RoeDensity, RoeSoundSpeed, *RoeVelocity, *Lambda, *Velocity_i, *Velocity_j, **ProjFlux_i, **ProjFlux_j, - Proj_ModJac_Tensor_ij, **Proj_ModJac_Tensor, Energy_i, Energy_j, **P_Tensor, **invP_Tensor; - unsigned short iDim, iVar, jVar, kVar; - bool implicit, grid_movement; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwRoe_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwRoe_AdjFlow(void); - - /*! - * \brief Compute the adjoint Roe's flux between two nodes i and j. - * \param[out] val_residual_i - Pointer to the total residual at point i. - * \param[out] val_residual_j - Pointer to the total residual at point j. - * \param[out] val_Jacobian_ii - Jacobian of the numerical method at node i (implicit computation) from node i. - * \param[out] val_Jacobian_ij - Jacobian of the numerical method at node i (implicit computation) from node j. - * \param[out] val_Jacobian_ji - Jacobian of the numerical method at node j (implicit computation) from node i. - * \param[out] val_Jacobian_jj - Jacobian of the numerical method at node j (implicit computation) from node j. - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, su2double **val_Jacobian_ii, - su2double **val_Jacobian_ij, su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config); -}; - -/*! - * \class CUpwAUSM_Flow - * \brief Class for solving an approximate Riemann AUSM. - * \ingroup ConvDiscr - * \author F. Palacios - */ -class CUpwAUSM_Flow : public CNumerics { -private: - bool implicit; - su2double *Diff_U; - su2double *Velocity_i, *Velocity_j, *RoeVelocity; - su2double *ProjFlux_i, *ProjFlux_j; - su2double *delta_wave, *delta_vel; - su2double *Lambda, *Epsilon; - su2double **P_Tensor, **invP_Tensor; - su2double sq_vel, Proj_ModJac_Tensor_ij, Density_i, Energy_i, SoundSpeed_i, Pressure_i, Enthalpy_i, - Density_j, Energy_j, SoundSpeed_j, Pressure_j, Enthalpy_j, R, RoeDensity, RoeEnthalpy, RoeSoundSpeed, - ProjVelocity, ProjVelocity_i, ProjVelocity_j; - unsigned short iDim, iVar, jVar, kVar; - su2double mL, mR, mLP, mRM, mF, pLP, pRM, pF, Phi; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwAUSM_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwAUSM_Flow(void); - - /*! - * \brief Compute the Roe's flux between two nodes i and j. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); -}; - -/*! - * \class CUpwAUSMPLUS_SLAU_Base_Flow - * \brief Base class for AUSM+up(2) and SLAU(2) convective schemes. - * \ingroup ConvDiscr - * \author Amit Sachdeva - */ -class CUpwAUSMPLUS_SLAU_Base_Flow : public CNumerics { -protected: - bool implicit; - bool UseAccurateJacobian; - bool HasAnalyticalDerivatives; - su2double FinDiffStep; - - su2double MassFlux, DissFlux, Pressure; - su2double *Velocity_i, *Velocity_j; - su2double *psi_i, *psi_j; - su2double dmdot_dVi[6], dmdot_dVj[6], dpres_dVi[6], dpres_dVj[6]; - - /*--- Roe variables (for approximate Jacobian) ---*/ - su2double *Lambda, *Epsilon, *RoeVelocity, **P_Tensor, **invP_Tensor; - - /*! - * \brief Compute the mass flux and pressure based on Primitives_i/j, derived classes must implement this method. - * \note See the body of the (empty) default implementation for instructions on how to implement the method. - * \param[in] config - Definition of the particular problem. - * \param[out] mdot - The mass flux. - * \param[out] pressure - The pressure at the control volume face. - */ - virtual void ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure) = 0; - - /*! - * \brief Compute the flux Jacobians of the Roe scheme to use as an approximation. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - */ - void ApproximateJacobian(su2double **val_Jacobian_i, su2double **val_Jacobian_j); - - /*! - * \brief Compute the flux Jacobians using a mix of finite differences and manual differentiation. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - */ - void AccurateJacobian(CConfig *config, su2double **val_Jacobian_i, su2double **val_Jacobian_j); - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwAUSMPLUS_SLAU_Base_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwAUSMPLUS_SLAU_Base_Flow(void); - - /*! - * \brief Compute the AUSM+ and SLAU family of schemes. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); -}; - -/*! - * \class CUpwAUSMPLUSUP_Flow - * \brief Class for solving an approximate Riemann AUSM+ -up. - * \ingroup ConvDiscr - * \author Amit Sachdeva - */ -class CUpwAUSMPLUSUP_Flow : public CUpwAUSMPLUS_SLAU_Base_Flow { -private: - su2double Kp, Ku, sigma; - - /*! - * \brief Mass flux and pressure for the AUSM+up scheme. - * \param[in] config - Definition of the particular problem. - * \param[out] mdot - The mass flux. - * \param[out] pressure - The pressure at the control volume face. - */ - void ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure); - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwAUSMPLUSUP_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwAUSMPLUSUP_Flow(void); -}; - -/*! - * \class CUpwAUSMPLUSUP2_Flow - * \brief Class for solving an approximate Riemann AUSM+ -up. - * \ingroup ConvDiscr - * \author Amit Sachdeva - */ -class CUpwAUSMPLUSUP2_Flow : public CUpwAUSMPLUS_SLAU_Base_Flow { -private: - su2double Kp, sigma; - - /*! - * \brief Mass flux and pressure for the AUSM+up2 scheme. - * \param[in] config - Definition of the particular problem. - * \param[out] mdot - The mass flux. - * \param[out] pressure - The pressure at the control volume face. - */ - void ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure); - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwAUSMPLUSUP2_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwAUSMPLUSUP2_Flow(void); - -}; - -/*! - * \class CUpwSLAU_Flow - * \brief Class for solving the Low-Dissipation AUSM. - * \ingroup ConvDiscr - * \author E. Molina - */ -class CUpwSLAU_Flow : public CUpwAUSMPLUS_SLAU_Base_Flow { -protected: - bool slau_low_diss; - bool slau2; - - /*! - * \brief Mass flux and pressure for the SLAU and SLAU2 schemes. - * \param[in] config - Definition of the particular problem. - * \param[out] mdot - The mass flux. - * \param[out] pressure - The pressure at the control volume face. - */ - void ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure); - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwSLAU_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, bool val_low_dissipation); - - /*! - * \brief Destructor of the class. - */ - ~CUpwSLAU_Flow(void); - -}; - -/*! - * \class CUpwSLAU2_Flow - * \brief Class for solving the Simple Low-Dissipation AUSM 2. - * \ingroup ConvDiscr - * \author E. Molina - */ -class CUpwSLAU2_Flow : public CUpwSLAU_Flow { -public: - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwSLAU2_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, bool val_low_dissipation); - - /*! - * \brief Destructor of the class. - */ - ~CUpwSLAU2_Flow(void); - -}; - -/*! - * \class CUpwHLLC_Flow - * \brief Class for solving an approximate Riemann HLLC. - * \ingroup ConvDiscr - * \author G. Gori, Politecnico di Milano - * \version 7.0.1 "Blackbird" - */ -class CUpwHLLC_Flow : public CNumerics { -private: - bool implicit, dynamic_grid; - unsigned short iDim, jDim, iVar, jVar; - - su2double *IntermediateState; - su2double *Velocity_i, *Velocity_j, *RoeVelocity; - - su2double sq_vel_i, Density_i, Energy_i, SoundSpeed_i, Pressure_i, Enthalpy_i, ProjVelocity_i; - su2double sq_vel_j, Density_j, Energy_j, SoundSpeed_j, Pressure_j, Enthalpy_j, ProjVelocity_j; - - su2double sq_velRoe, RoeDensity, RoeEnthalpy, RoeSoundSpeed, RoeProjVelocity, ProjInterfaceVel; - - su2double sL, sR, sM, pStar, EStar, rhoSL, rhoSR, Rrho, kappa; - - su2double Omega, RHO, OmegaSM; - su2double *dSm_dU, *dPI_dU, *drhoStar_dU, *dpStar_dU, *dEStar_dU; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwHLLC_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwHLLC_Flow(void); - - /*! - * \brief Compute the Roe's flux between two nodes i and j. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - -}; - -/*! - * \class CUpwGeneralHLLC_Flow - * \brief Class for solving an approximate Riemann HLLC. - * \ingroup ConvDiscr - * \author G. Gori, Politecnico di Milano - * \version 7.0.1 "Blackbird" - */ -class CUpwGeneralHLLC_Flow : public CNumerics { -private: - bool implicit, dynamic_grid; - unsigned short iDim, jDim, iVar, jVar; - - su2double *IntermediateState; - su2double *Velocity_i, *Velocity_j, *RoeVelocity; - - su2double sq_vel_i, Density_i, Energy_i, SoundSpeed_i, Pressure_i, Enthalpy_i, ProjVelocity_i, StaticEnthalpy_i, StaticEnergy_i; - su2double sq_vel_j, Density_j, Energy_j, SoundSpeed_j, Pressure_j, Enthalpy_j, ProjVelocity_j, StaticEnthalpy_j, StaticEnergy_j; - - su2double sq_velRoe, RoeDensity, RoeEnthalpy, RoeSoundSpeed, RoeProjVelocity, ProjInterfaceVel; - su2double Kappa_i, Kappa_j, Chi_i, Chi_j, RoeKappa, RoeChi, RoeKappaStaticEnthalpy; - - su2double sL, sR, sM, pStar, EStar, rhoSL, rhoSR, Rrho, kappa; - - su2double Omega, RHO, OmegaSM; - su2double *dSm_dU, *dPI_dU, *drhoStar_dU, *dpStar_dU, *dEStar_dU; - - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwGeneralHLLC_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwGeneralHLLC_Flow(void); - - /*! - - * \brief Compute the Roe's flux between two nodes i and j. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - - /*! - * \brief Compute the Average quantities for a general fluid flux between two nodes i and j. - * Using the approach of Vinokur and Montagne' - */ - void VinokurMontagne(); -}; - -/*! - * \class CUpwLin_TransLM - * \brief Class for performing a linear upwind solver for the Spalart-Allmaras turbulence model equations with transition - * \ingroup ConvDiscr - * \author A. Aranake - */ -class CUpwLin_TransLM : public CNumerics { -private: - su2double *Velocity_i; - su2double *Velocity_j; - bool implicit, incompressible; - su2double Density_i, Density_j, q_ij, a0, a1; - unsigned short iDim; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwLin_TransLM(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwLin_TransLM(void); - - /*! - * \brief Compute the upwind flux between two nodes i and j. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual (su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); -}; - -/*! - * \class CUpwLin_AdjTurb - * \brief Class for performing a linear upwind solver for the adjoint turbulence equations. - * \ingroup ConvDiscr - * \author A. Bueno. - */ -class CUpwLin_AdjTurb : public CNumerics { -private: - su2double *Velocity_i; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwLin_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwLin_AdjTurb(void); - - /*! - * \brief Compute the adjoint upwind flux between two nodes i and j. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual (su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); -}; - -/*! - * \class CUpwScalar - * \brief Template class for scalar upwind fluxes between nodes i and j. - * \details This class serves as a template for the scalar upwinding residual - * classes. The general structure of a scalar upwinding calculation is the - * same for many different models, which leads to a lot of repeated code. - * By using the template design pattern, these sections of repeated code are - * moved to this shared base class, and the specifics of each model - * are implemented by derived classes. In order to add a new residual - * calculation for a convection residual, extend this class and implement - * the pure virtual functions with model-specific behavior. - * \ingroup ConvDiscr - * \author C. Pederson, A. Bueno., and A. Campos. - */ -class CUpwScalar : public CNumerics { -private: - - /*! - * \brief A pure virtual function; Adds any extra variables to AD - */ - virtual void ExtraADPreaccIn() = 0; - - /*! - * \brief Model-specific steps in the ComputeResidual method - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - virtual void FinishResidualCalc(su2double *val_residual, - su2double **Jacobian_i, - su2double **Jacobian_j, - CConfig *config) = 0; - -protected: - su2double *Velocity_i, *Velocity_j; /*!< \brief Velocity, minus any grid movement. */ - su2double Density_i, Density_j; - bool implicit, dynamic_grid, incompressible; - su2double q_ij, /*!< \brief Projected velocity at the face. */ - a0, /*!< \brief The maximum of the face-normal velocity and 0 */ - a1; /*!< \brief The minimum of the face-normal velocity and 0 */ - unsigned short iDim; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwScalar(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwScalar(void); - - /*! - * \brief Compute the scalar upwind flux between two nodes i and j. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); -}; - -/*! - * \class CUpwSca_TurbSA - * \brief Class for doing a scalar upwind solver for the Spalar-Allmaras turbulence model equations. - * \ingroup ConvDiscr - * \author A. Bueno. - */ -class CUpwSca_TurbSA : public CUpwScalar { -private: - - /*! - * \brief Adds any extra variables to AD - */ - void ExtraADPreaccIn(); - - /*! - * \brief SA specific steps in the ComputeResidual method - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void FinishResidualCalc(su2double *val_residual, su2double **Jacobian_i, - su2double **Jacobian_j, CConfig *config); - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwSca_TurbSA(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwSca_TurbSA(void); -}; - -/*! - * \class CUpwSca_TurbSST - * \brief Class for doing a scalar upwind solver for the Menter SST turbulence model equations. - * \ingroup ConvDiscr - * \author A. Campos. - */ -class CUpwSca_TurbSST : public CUpwScalar { -private: - - /*! - * \brief Adds any extra variables to AD - */ - void ExtraADPreaccIn(); - - /*! - * \brief SST specific steps in the ComputeResidual method - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void FinishResidualCalc(su2double *val_residual, su2double **Jacobian_i, - su2double **Jacobian_j, CConfig *config); - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwSca_TurbSST(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwSca_TurbSST(void); -}; - -/*! - * \class CUpwSca_TransLM - * \brief Class for doing a scalar upwind solver for the Spalart-Allmaras turbulence model equations with transition. - * \ingroup ConvDiscr - * \author A. Aranake. - */ -class CUpwSca_TransLM : public CNumerics { -private: - su2double *Velocity_i, *Velocity_j; - bool implicit; - su2double q_ij, a0, a1; - unsigned short iDim; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwSca_TransLM(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwSca_TransLM(void); - - /*! - * \brief Compute the scalar upwind flux between two nodes i and j. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); -}; - -/*! - * \class CUpwSca_AdjTurb - * \brief Class for doing a scalar upwind solver for the adjoint turbulence equations. - * \ingroup ConvDiscr - * \author A. Bueno. - */ -class CUpwSca_AdjTurb : public CNumerics { -private: - su2double *Velocity_i, *Velocity_j; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwSca_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwSca_AdjTurb(void); - - /*! - * \param[out] val_residual_i - Pointer to the total residual at point i. - * \param[out] val_residual_j - Pointer to the total viscosity residual at point j. - * \param[out] val_Jacobian_ii - Jacobian of the numerical method at node i (implicit computation) from node i. - * \param[out] val_Jacobian_ij - Jacobian of the numerical method at node i (implicit computation) from node j. - * \param[out] val_Jacobian_ji - Jacobian of the numerical method at node j (implicit computation) from node i. - * \param[out] val_Jacobian_jj - Jacobian of the numerical method at node j (implicit computation) from node j. - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, - su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config); -}; - -/*! - * \class CUpwSca_Heat - * \brief Class for doing a scalar upwind solver for the heat convection equation. - * \ingroup ConvDiscr - * \author O. Burghardt. - * \version 7.0.1 "Blackbird" - */ -class CUpwSca_Heat : public CNumerics { -private: - su2double *Velocity_i, *Velocity_j; - bool implicit, dynamic_grid; - su2double q_ij, a0, a1; - unsigned short iDim; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CUpwSca_Heat(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CUpwSca_Heat(void); - - /*! - * \brief Compute the scalar upwind flux between two nodes i and j. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); -}; - -/*! - * \class CCentBase_Flow - * \brief Intermediate class to define centered schemes. - * \ingroup ConvDiscr - * \author F. Palacios - */ -class CCentBase_Flow : public CNumerics { - -protected: - unsigned short iDim, iVar, jVar; /*!< \brief Iteration on dimension and variables. */ - bool dynamic_grid; /*!< \brief Consider grid movement. */ - bool implicit; /*!< \brief Implicit calculation (compute Jacobians). */ - su2double fix_factor; /*!< \brief Fix factor for dissipation Jacobians (more diagonal dominance). */ - - su2double *Velocity_i, *Velocity_j, *MeanVelocity; /*!< \brief Velocity at nodes i and j and mean. */ - su2double ProjVelocity_i, ProjVelocity_j; /*!< \brief Velocities in the face normal direction. */ - su2double sq_vel_i, sq_vel_j; /*!< \brief Squared norm of the velocity vectors. */ - su2double Energy_i, Energy_j, MeanEnergy; /*!< \brief Energy at nodes i and j and mean. */ - su2double MeanDensity, MeanPressure, MeanEnthalpy; /*!< \brief Mean density, pressure, and enthalpy. */ - su2double *ProjFlux; /*!< \brief Projected inviscid flux. */ - - su2double *Diff_U, *Diff_Lapl; /*!< \brief Differences of conservatives and undiv. Laplacians. */ - su2double Local_Lambda_i, Local_Lambda_j, MeanLambda; /*!< \brief Local eingenvalues. */ - su2double Param_p, Phi_i, Phi_j, StretchingFactor; /*!< \brief Streching parameters. */ - su2double cte_0, cte_1; /*!< \brief Constants for the scalar dissipation Jacobian. */ - - su2double ProjGridVel; /*!< \brief Projected grid velocity. */ - - /*! - * \brief Hook method for derived classes to define preaccumulated variables, optional to implement. - * \return true if any variable was set as preacc. input, in which case the residual will be output. - */ - virtual bool SetPreaccInVars(void) {return false;} - - /*! - * \brief Derived classes must implement this method, called in ComputeResidual after inviscid part. - * \param[in,out] val_residual - Pointer to the convective flux contribution to the residual. - * \param[in,out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[in,out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - */ - virtual void DissipationTerm(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j) = 0; - - /*! - * \brief Add the contribution of a scalar dissipation term to the Jacobians. - * \param[in,out] val_Jacobian_i - Jacobian of the numerical method at node i. - * \param[in,out] val_Jacobian_j - Jacobian of the numerical method at node j. - */ - void ScalarDissipationJacobian(su2double **val_Jacobian_i, su2double **val_Jacobian_j); - -public: - - /*! - * \brief Constructor of the class. - * \param[in] val_nDim - Number of dimension of the problem. - * \param[in] val_nVar - Number of variables of the problem. - * \param[in] config - Definition of the particular problem. - */ - CCentBase_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - virtual ~CCentBase_Flow(void); - - /*! - * \brief Compute the flow residual using a centered method with artificial dissipation. - * \param[out] val_residual - Pointer to the convective flux contribution to the residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - -}; - -/*! - * \class CCentLax_Flow - * \brief Class for computing the Lax-Friedrich centered scheme. - * \ingroup ConvDiscr - * \author F. Palacios - */ -class CCentLax_Flow : public CCentBase_Flow { -private: - su2double Param_Kappa_0; /*!< \brief Artificial dissipation parameter. */ - su2double sc0; /*!< \brief Streching parameter. */ - su2double Epsilon_0; /*!< \brief Artificial dissipation coefficient. */ - - /*! - * \brief Lax-Friedrich first order dissipation term. - * \param[in,out] val_residual - Pointer to the convective flux contribution to the residual. - * \param[in,out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[in,out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - */ - void DissipationTerm(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j); - - /*! - * \brief Set input variables for AD preaccumulation. - * \return true, as we will define inputs. - */ - bool SetPreaccInVars(void); - -public: - - /*! - * \brief Constructor of the class. - * \param[in] val_nDim - Number of dimension of the problem. - * \param[in] val_nVar - Number of variables of the problem. - * \param[in] config - Definition of the particular problem. - */ - CCentLax_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CCentLax_Flow(void); - -}; - -/*! - * \class CCentJST_KE_Flow - * \brief Class for centered scheme - JST_KE (no 4th dissipation order term). - * \ingroup ConvDiscr - * \author F. Palacios - */ -class CCentJST_KE_Flow : public CCentBase_Flow { - -private: - su2double Param_Kappa_2; /*!< \brief Artificial dissipation parameter. */ - su2double sc2; /*!< \brief Streching parameter. */ - su2double Epsilon_2; /*!< \brief Artificial dissipation coefficient. */ - - /*! - * \brief JST_KE second order dissipation term. - * \param[in,out] val_residual - Pointer to the convective flux contribution to the residual. - * \param[in,out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[in,out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - */ - void DissipationTerm(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j); - - /*! - * \brief Set input variables for AD preaccumulation. - * \return true, as we will define inputs. - */ - bool SetPreaccInVars(void); - -public: - - /*! - * \brief Constructor of the class. - * \param[in] val_nDim - Number of dimension of the problem. - * \param[in] val_nVar - Number of variables of the problem. - * \param[in] config - Definition of the particular problem. - */ - CCentJST_KE_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CCentJST_KE_Flow(void); - -}; - -/*! - * \class CCentJST_Flow - * \brief Class for centered scheme - JST. - * \ingroup ConvDiscr - * \author F. Palacios - */ -class CCentJST_Flow : public CCentBase_Flow { - -private: - su2double Param_Kappa_2, Param_Kappa_4; /*!< \brief Artificial dissipation parameters. */ - su2double sc2, sc4; /*!< \brief Streching parameters. */ - su2double Epsilon_2, Epsilon_4; /*!< \brief Artificial dissipation coefficients. */ - - /*! - * \brief JST second and forth order dissipation terms. - * \param[in,out] val_residual - Pointer to the convective flux contribution to the residual. - * \param[in,out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[in,out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - */ - void DissipationTerm(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j); - - /*! - * \brief Set input variables for AD preaccumulation. - * \return true, as we will define inputs. - */ - bool SetPreaccInVars(void); - -public: - - /*! - * \brief Constructor of the class. - * \param[in] val_nDim - Number of dimension of the problem. - * \param[in] val_nVar - Number of variables of the problem. - * \param[in] config - Definition of the particular problem. - */ - CCentJST_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CCentJST_Flow(void); - -}; - -/*! - * \class CCentJSTInc_Flow - * \brief Class for centered scheme - modified JST with incompressible preconditioning. - * \ingroup ConvDiscr - * \author F. Palacios, T. Economon - */ -class CCentJSTInc_Flow : public CNumerics { - -private: - unsigned short iDim, iVar, jVar; /*!< \brief Iteration on dimension and variables. */ - su2double *Diff_V, *Diff_Lapl, /*!< \brief Diference of primitive variables and undivided laplacians. */ - *Velocity_i, *Velocity_j, /*!< \brief Velocity at node 0 and 1. */ - *MeanVelocity, ProjVelocity_i, - ProjVelocity_j, /*!< \brief Mean and projected velocities. */ - sq_vel_i, sq_vel_j, /*!< \brief Modulus of the velocity and the normal vector. */ - Temperature_i, Temperature_j, /*!< \brief Temperature at node 0 and 1. */ - MeanDensity, MeanPressure, - MeanBetaInc2, MeanEnthalpy, - MeanCp, MeanTemperature, /*!< \brief Mean values of primitive variables. */ - MeandRhodT, /*!< \brief Derivative of density w.r.t. temperature (variable density flows). */ - Param_p, Param_Kappa_2, - Param_Kappa_4, /*!< \brief Artificial dissipation parameters. */ - Local_Lambda_i, Local_Lambda_j, - MeanLambda, /*!< \brief Local eingenvalues. */ - Phi_i, Phi_j, sc2, sc4, - StretchingFactor, /*!< \brief Streching parameters. */ - *ProjFlux, /*!< \brief Projected inviscid flux tensor. */ - Epsilon_2, Epsilon_4; /*!< \brief Artificial dissipation values. */ - su2double **Precon; - bool implicit, /*!< \brief Implicit calculation. */ - dynamic_grid, /*!< \brief Modification for grid movement. */ - variable_density, /*!< \brief Variable density incompressible flows. */ - energy; /*!< \brief computation with the energy equation. */ - -public: - - /*! - * \brief Constructor of the class. - * \param[in] val_nDim - Number of dimension of the problem. - * \param[in] val_nVar - Number of variables of the problem. - * \param[in] config - Definition of the particular problem. - */ - CCentJSTInc_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CCentJSTInc_Flow(void); - - /*! - * \brief Compute the flow residual using a JST method. - * \param[out] val_residual - Pointer to the residual array. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); -}; - -/*! - * \class CCentJST_AdjFlow - * \brief Class for and adjoint centered scheme - JST. - * \ingroup ConvDiscr - * \author F. Palacios - */ -class CCentJST_AdjFlow : public CNumerics { -private: - su2double *Diff_Psi, *Diff_Lapl; - su2double *Velocity_i, *Velocity_j; - su2double *MeanPhi; - unsigned short iDim, jDim, iVar, jVar; - su2double Residual, ProjVelocity_i, ProjVelocity_j, ProjPhi, ProjPhi_Vel, sq_vel, phis1, phis2; - su2double MeanPsiRho, MeanPsiE, Param_p, Param_Kappa_4, Param_Kappa_2, Local_Lambda_i, Local_Lambda_j, MeanLambda; - su2double Phi_i, Phi_j, sc4, StretchingFactor, Epsilon_4, Epsilon_2; - bool implicit, grid_movement; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CCentJST_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CCentJST_AdjFlow(void); - - /*! - * \brief Compute the adjoint flow residual using a JST method. - * \param[out] val_resconv_i - Pointer to the convective residual at point i. - * \param[out] val_resvisc_i - Pointer to the artificial viscosity residual at point i. - * \param[out] val_resconv_j - Pointer to the convective residual at point j. - * \param[out] val_resvisc_j - Pointer to the artificial viscosity residual at point j. - * \param[out] val_Jacobian_ii - Jacobian of the numerical method at node i (implicit computation) from node i. - * \param[out] val_Jacobian_ij - Jacobian of the numerical method at node i (implicit computation) from node j. - * \param[out] val_Jacobian_ji - Jacobian of the numerical method at node j (implicit computation) from node i. - * \param[out] val_Jacobian_jj - Jacobian of the numerical method at node j (implicit computation) from node j. - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual (su2double *val_resconv_i, su2double *val_resvisc_i, su2double *val_resconv_j, su2double *val_resvisc_j, - su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, - CConfig *config); -}; - -/*! - * \class CCentSca_Heat - * \brief Class for scalar centered scheme. - * \ingroup ConvDiscr - * \author O. Burghardt - * \version 7.0.1 "Blackbird" - */ -class CCentSca_Heat : public CNumerics { - -private: - unsigned short iDim; /*!< \brief Iteration on dimension and variables. */ - su2double *Diff_Lapl, /*!< \brief Diference of conservative variables and undivided laplacians. */ - *MeanVelocity, ProjVelocity, - ProjVelocity_i, ProjVelocity_j, /*!< \brief Mean and projected velocities. */ - Param_Kappa_4, /*!< \brief Artificial dissipation parameters. */ - Local_Lambda_i, Local_Lambda_j, - MeanLambda, /*!< \brief Local eingenvalues. */ - cte_0, cte_1; /*!< \brief Artificial dissipation values. */ - bool implicit, /*!< \brief Implicit calculation. */ - dynamic_grid; /*!< \brief Modification for grid movement. */ - - -public: - - /*! - * \brief Constructor of the class. - * \param[in] val_nDim - Number of dimension of the problem. - * \param[in] val_nVar - Number of variables of the problem. - * \param[in] config - Definition of the particular problem. - */ - CCentSca_Heat(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CCentSca_Heat(void); - - /*! - * \brief Compute the flow residual using a JST method. - * \param[out] val_resconv - Pointer to the convective residual. - * \param[out] val_resvisc - Pointer to the artificial viscosity residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, - CConfig *config); -}; - -/*! - * \class CCentLaxInc_Flow - * \brief Class for computing the Lax-Friedrich centered scheme (modified with incompressible preconditioning). - * \ingroup ConvDiscr - * \author F. Palacios, T. Economon - */ -class CCentLaxInc_Flow : public CNumerics { -private: - unsigned short iDim, iVar, jVar; /*!< \brief Iteration on dimension and variables. */ - su2double *Diff_V, /*!< \brief Difference of primitive variables. */ - *Velocity_i, *Velocity_j, /*!< \brief Velocity at node 0 and 1. */ - *MeanVelocity, ProjVelocity_i, - ProjVelocity_j, /*!< \brief Mean and projected velocities. */ - *ProjFlux, /*!< \brief Projected inviscid flux tensor. */ - sq_vel_i, sq_vel_j, /*!< \brief Modulus of the velocity and the normal vector. */ - Temperature_i, Temperature_j, /*!< \brief Temperature at node 0 and 1. */ - MeanDensity, MeanPressure, - MeanBetaInc2, MeanEnthalpy, - MeanCp, MeanTemperature, /*!< \brief Mean values of primitive variables. */ - MeandRhodT, /*!< \brief Derivative of density w.r.t. temperature (variable density flows). */ - Param_p, Param_Kappa_0, /*!< \brief Artificial dissipation parameters. */ - Local_Lambda_i, Local_Lambda_j, - MeanLambda, /*!< \brief Local eingenvalues. */ - Phi_i, Phi_j, sc0, - StretchingFactor, /*!< \brief Streching parameters. */ - Epsilon_0; /*!< \brief Artificial dissipation values. */ - su2double **Precon; - bool implicit, /*!< \brief Implicit calculation. */ - dynamic_grid, /*!< \brief Modification for grid movement. */ - variable_density, /*!< \brief Variable density incompressible flows. */ - energy; /*!< \brief computation with the energy equation. */ - -public: - - /*! - * \brief Constructor of the class. - * \param[in] val_nDim - Number of dimension of the problem. - * \param[in] val_nVar - Number of variables of the problem. - * \param[in] config - Definition of the particular problem. - */ - CCentLaxInc_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CCentLaxInc_Flow(void); - - /*! - * \brief Compute the flow residual using a Lax method. - * \param[out] val_residual - Pointer to the residual array. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); -}; - -/*! - * \class CCentLax_AdjFlow - * \brief Class for computing the Lax-Friedrich adjoint centered scheme. - * \ingroup ConvDiscr - * \author F. Palacios - */ -class CCentLax_AdjFlow : public CNumerics { -private: - su2double *Diff_Psi; - su2double *Velocity_i, *Velocity_j; - su2double *MeanPhi; - unsigned short iDim, jDim, iVar, jVar; - su2double Residual, ProjVelocity_i, ProjVelocity_j, ProjPhi, ProjPhi_Vel, sq_vel, phis1, phis2, - MeanPsiRho, MeanPsiE, Param_p, Param_Kappa_0, Local_Lambda_i, Local_Lambda_j, MeanLambda, - Phi_i, Phi_j, sc2, StretchingFactor, Epsilon_0; - bool implicit, grid_movement; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CCentLax_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CCentLax_AdjFlow(void); - - /*! - * \brief Compute the adjoint flow residual using a Lax method. - * \param[out] val_resconv_i - Pointer to the convective residual at point i. - * \param[out] val_resvisc_i - Pointer to the artificial viscosity residual at point i. - * \param[out] val_resconv_j - Pointer to the convective residual at point j. - * \param[out] val_resvisc_j - Pointer to the artificial viscosity residual at point j. - * \param[out] val_Jacobian_ii - Jacobian of the numerical method at node i (implicit computation) from node i. - * \param[out] val_Jacobian_ij - Jacobian of the numerical method at node i (implicit computation) from node j. - * \param[out] val_Jacobian_ji - Jacobian of the numerical method at node j (implicit computation) from node i. - * \param[out] val_Jacobian_jj - Jacobian of the numerical method at node j (implicit computation) from node j. - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual (su2double *val_resconv_i, su2double *val_resvisc_i, su2double *val_resconv_j, su2double *val_resvisc_j, - su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, - CConfig *config); -}; - - -/*! - * \class CAvgGrad_Base - * \brief A base class for computing viscous terms using an average of gradients. - * \details This is the base class for the numerics classes that compute the - * viscous fluxes for the flow solvers (i.e. compressible or incompressible - * Navier Stokes). The actual numerics classes derive from this class. - * This class is used to share functions and variables that are common to all - * of the flow viscous numerics. For example, the turbulent stress tensor - * is computed identically for all three derived classes. - * \ingroup ViscDiscr - * \author C. Pederson, A. Bueno, F. Palacios, T. Economon - */ -class CAvgGrad_Base : public CNumerics { - protected: - const unsigned short nPrimVar; /*!< \brief The size of the primitive variable array used in the numerics class. */ - const bool correct_gradient; /*!< \brief Apply a correction to the gradient term */ - bool implicit; /*!< \brief Implicit calculus. */ - su2double *heat_flux_vector, /*!< \brief Flux of total energy due to molecular and turbulent diffusion */ - *heat_flux_jac_i, /*!< \brief Jacobian of the molecular + turbulent heat flux vector, projected onto the normal vector. */ - **tau_jacobian_i; /*!< \brief Jacobian of the viscous + turbulent stress tensor, projected onto the normal vector. */ - su2double *Mean_PrimVar, /*!< \brief Mean primitive variables. */ - *PrimVar_i, *PrimVar_j, /*!< \brief Primitives variables at point i and 1. */ - **Mean_GradPrimVar, /*!< \brief Mean value of the gradient. */ - Mean_Laminar_Viscosity, /*!< \brief Mean value of the viscosity. */ - Mean_Eddy_Viscosity, /*!< \brief Mean value of the eddy viscosity. */ - Mean_turb_ke, /*!< \brief Mean value of the turbulent kinetic energy. */ - Mean_TauWall, /*!< \brief Mean wall shear stress (wall functions). */ - TauWall_i, TauWall_j, /*!< \brief Wall shear stress at point i and j (wall functions). */ - dist_ij_2, /*!< \brief Length of the edge and face, squared */ - *Proj_Mean_GradPrimVar_Edge, /*!< \brief Inner product of the Mean gradient and the edge vector. */ - *Edge_Vector; /*!< \brief Vector from point i to point j. */ - - - - /*! - * \brief Add a correction using a Quadratic Constitutive Relation - * - * This function requires that the stress tensor already be - * computed using \ref GetStressTensor - * - * See: Spalart, P. R., "Strategies for Turbulence Modelling and - * Simulation," International Journal of Heat and Fluid Flow, Vol. 21, - * 2000, pp. 252-263 - * - * \param[in] val_gradprimvar - */ - void AddQCR(const su2double* const *val_gradprimvar); - - /*! - * \brief Scale the stress tensor using a predefined wall stress. - * - * This function requires that the stress tensor already be - * computed using \ref GetStressTensor - * - * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. - * \param[in] val_tau_wall - The wall stress - */ - void AddTauWall(const su2double *val_normal, - su2double val_tau_wall); - - /** - * \brief Calculate the Jacobian of the viscous + turbulent stress tensor - * - * This function is intended only for the compressible flow solver. - * This Jacobian is projected onto the normal vector, so it is of dimension - * [nDim][nVar] - * - * \param[in] val_Mean_PrimVar - Mean value of the primitive variables. - * \param[in] val_laminar_viscosity - Value of the laminar viscosity. - * \param[in] val_eddy_viscosity - Value of the eddy viscosity. - * \param[in] val_dist_ij - Distance between the points. - * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. - */ - void SetTauJacobian(const su2double* val_Mean_PrimVar, - su2double val_laminar_viscosity, - su2double val_eddy_viscosity, - su2double val_dist_ij, - const su2double *val_normal); - - - /** - * \brief Calculate the Jacobian of the viscous and turbulent stress tensor - * - * This function is intended only for the incompressible flow solver. - * This Jacobian is projected onto the normal vector, so it is of dimension - * [nDim][nVar] - * - * \param[in] val_laminar_viscosity - Value of the laminar viscosity. - * \param[in] val_eddy_viscosity - Value of the eddy viscosity. - * \param[in] val_dist_ij - Distance between the points. - * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. - */ - void SetIncTauJacobian(su2double val_laminar_viscosity, - su2double val_eddy_viscosity, - su2double val_dist_ij, - const su2double *val_normal); - - /*! - * \brief Compute the projection of the viscous fluxes into a direction. - * - * The heat flux vector and the stress tensor must be calculated before - * calling this function. - * - * \param[in] val_primvar - Primitive variables. - * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. - */ - void GetViscousProjFlux(const su2double *val_primvar, - const su2double *val_normal); - - /*! - * \brief TSL-Approximation of Viscous NS Jacobians. - * - * The Jacobians of the heat flux vector and the stress tensor must be - * calculated before calling this function. - * - * \param[in] val_Mean_PrimVar - Mean value of the primitive variables. - * \param[in] val_dS - Area of the face between two nodes. - * \param[in] val_Proj_Visc_Flux - Pointer to the projected viscous flux. - * \param[out] val_Proj_Jac_Tensor_i - Pointer to the projected viscous Jacobian at point i. - * \param[out] val_Proj_Jac_Tensor_j - Pointer to the projected viscous Jacobian at point j. - */ - void GetViscousProjJacs(const su2double *val_Mean_PrimVar, - su2double val_dS, - const su2double *val_Proj_Visc_Flux, - su2double **val_Proj_Jac_Tensor_i, - su2double **val_Proj_Jac_Tensor_j); - - /*! - * \brief Apply a correction to the gradient to reduce the truncation error - * - * \param[in] val_PrimVar_i - Primitive variables at point i - * \param[in] val_PrimVar_j - Primitive variables at point j - * \param[in] val_edge_vector - The vector between points i and j - * \param[in] val_dist_ij_2 - The distance between points i and j, squared - * \param[in] val_nPrimVar - The number of primitive variables - */ - void CorrectGradient(su2double** GradPrimVar, - const su2double* val_PrimVar_i, - const su2double* val_PrimVar_j, - const su2double* val_edge_vector, - su2double val_dist_ij_2, - const unsigned short val_nPrimVar); - - /*! - * \brief Initialize the Reynolds Stress Matrix - * \param[in] turb_ke turbulent kinetic energy of node - */ - void SetReynoldsStressMatrix(su2double turb_ke); - - /*! - * \brief Perturb the Reynolds stress tensor based on parameters - * \param[in] turb_ke: turbulent kinetic energy of the noce - * \param[in] Eig_Val_Comp: Defines type of eigenspace perturbation - * \param[in] beta_delta: Defines the amount of eigenvalue perturbation - */ - void SetPerturbedRSM(su2double turb_ke, CConfig *config); - - /*! - * \brief Get the mean rate of strain matrix based on velocity gradients - * \param[in] S_ij - */ - void GetMeanRateOfStrainMatrix(su2double **S_ij) const; - - public: - - /*! - * \brief Constructor of the class. - * \param[in] val_nDim - Number of dimension of the problem. - * \param[in] val_nVar - Number of variables of the problem. - * \param[in] val_nPrimVar - Number of primitive variables to use. - * \param[in] val_correct_grad - Apply a correction to the gradient - * \param[in] config - Definition of the particular problem. - */ - CAvgGrad_Base(unsigned short val_nDim, unsigned short val_nVar, - unsigned short val_nPrimVar, - bool val_correct_grad, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CAvgGrad_Base(); - - /*! - * \brief Set the value of the wall shear stress at point i and j (wall functions). - * \param[in] val_tauwall_i - Value of the wall shear stress at point i. - * \param[in] val_tauwall_j - Value of the wall shear stress at point j. - */ - void SetTauWall(su2double val_tauwall_i, su2double val_tauwall_j); - - /*! - * \brief Calculate the viscous + turbulent stress tensor - * \param[in] val_primvar - Primitive variables. - * \param[in] val_gradprimvar - Gradient of the primitive variables. - * \param[in] val_turb_ke - Turbulent kinetic energy - * \param[in] val_laminar_viscosity - Laminar viscosity. - * \param[in] val_eddy_viscosity - Eddy viscosity. - */ - void SetStressTensor(const su2double *val_primvar, - const su2double* const *val_gradprimvar, - su2double val_turb_ke, - su2double val_laminar_viscosity, - su2double val_eddy_viscosity); - - /*! - * \brief Get a component of the viscous stress tensor. - * - * \param[in] iDim - The first index - * \param[in] jDim - The second index - * \return The component of the viscous stress tensor at iDim, jDim - */ - su2double GetStressTensor(unsigned short iDim, unsigned short jDim) const; - - /*! - * \brief Get a component of the heat flux vector. - * \param[in] iDim - The index of the component - * \return The component of the heat flux vector at iDim - */ - su2double GetHeatFluxVector(unsigned short iDim) const; - -}; - -/*! - * \class CAvgGrad_Flow - * \brief Class for computing viscous term using the average of gradients. - * \ingroup ViscDiscr - * \author A. Bueno, and F. Palacios - */ -class CAvgGrad_Flow : public CAvgGrad_Base { -public: - - /*! - * \brief Constructor of the class. - * \param[in] val_nDim - Number of dimension of the problem. - * \param[in] val_nVar - Number of variables of the problem. - * \param[in] val_correct_grad - Apply a correction to the gradient - * \param[in] config - Definition of the particular problem. - */ - CAvgGrad_Flow(unsigned short val_nDim, unsigned short val_nVar, - bool val_correct_grad, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CAvgGrad_Flow(void); - - /*! - * \brief Compute the viscous flow residual using an average of gradients. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - - /*! - * \brief Compute the heat flux due to molecular and turbulent diffusivity - * \param[in] val_gradprimvar - Gradient of the primitive variables. - * \param[in] val_laminar_viscosity - Laminar viscosity. - * \param[in] val_eddy_viscosity - Eddy viscosity. - */ - void SetHeatFluxVector(const su2double* const *val_gradprimvar, - su2double val_laminar_viscosity, - su2double val_eddy_viscosity); - - /*! - * \brief Compute the Jacobian of the heat flux vector - * - * This Jacobian is projected onto the normal vector, so it is of - * dimension nVar. - * - * \param[in] val_Mean_PrimVar - Mean value of the primitive variables. - * \param[in] val_gradprimvar - Mean value of the gradient of the primitive variables. - * \param[in] val_laminar_viscosity - Value of the laminar viscosity. - * \param[in] val_eddy_viscosity - Value of the eddy viscosity. - * \param[in] val_dist_ij - Distance between the points. - * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. - */ - void SetHeatFluxJacobian(const su2double *val_Mean_PrimVar, - su2double val_laminar_viscosity, - su2double val_eddy_viscosity, - su2double val_dist_ij, - const su2double *val_normal); -}; - -/*! - * \class CGeneralAvgGrad_Flow - * \brief Class for computing viscous term using the average of gradients. - * \ingroup ViscDiscr - * \author M.Pini, S. Vitale - */ -class CGeneralAvgGrad_Flow : public CAvgGrad_Base { -private: - su2double *Mean_SecVar, /*!< \brief Mean secondary variables. */ - Mean_Thermal_Conductivity, /*!< \brief Mean value of the thermal conductivity. */ - Mean_Cp; /*!< \brief Mean value of the Cp. */ - - /*! - * \brief Compute the heat flux due to molecular and turbulent diffusivity - * \param[in] val_gradprimvar - Gradient of the primitive variables. - * \param[in] val_laminar_viscosity - Laminar viscosity. - * \param[in] val_eddy_viscosity - Eddy viscosity. - * \param[in] val_thermal_conductivity - Thermal Conductivity. - * \param[in] val_heat_capacity_cp - Heat Capacity at constant pressure. - */ - void SetHeatFluxVector(const su2double* const *val_gradprimvar, - su2double val_laminar_viscosity, - su2double val_eddy_viscosity, - su2double val_thermal_conductivity, - su2double val_heat_capacity_cp); - - /*! - * \brief Compute the Jacobian of the heat flux vector - * - * This Jacobian is projected onto the normal vector, so it is of - * dimension nVar. - * - * \param[in] val_Mean_PrimVar - Mean value of the primitive variables. - * \param[in] val_Mean_SecVar - Mean value of the secondary variables. - * \param[in] val_eddy_viscosity - Value of the eddy viscosity. - * \param[in] val_thermal_conductivity - Value of the thermal conductivity. - * \param[in] val_heat_capacity_cp - Value of the specific heat at constant pressure. - * \param[in] val_dist_ij - Distance between the points. - */ - void SetHeatFluxJacobian(const su2double *val_Mean_PrimVar, - const su2double *val_Mean_SecVar, - su2double val_eddy_viscosity, - su2double val_thermal_conductivity, - su2double val_heat_capacity_cp, - su2double val_dist_ij); - -public: - - /*! - * \brief Constructor of the class. - * \param[in] val_nDim - Number of dimension of the problem. - * \param[in] val_nVar - Number of variables of the problem. - * \param[in] val_correct_grad - Apply a correction to the gradient - * \param[in] config - Definition of the particular problem. - */ - CGeneralAvgGrad_Flow(unsigned short val_nDim, unsigned short val_nVar, bool val_correct_grad, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CGeneralAvgGrad_Flow(void); - - /*! - * \brief Compute the viscous flow residual using an average of gradients. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); -}; - - -/*! - * \class CAvgGradInc_Flow - * \brief Class for computing viscous term using an average of gradients. - * \ingroup ViscDiscr - * \author A. Bueno, F. Palacios, T. Economon - */ -class CAvgGradInc_Flow : public CAvgGrad_Base { -private: - su2double Mean_Thermal_Conductivity; /*!< \brief Mean value of the effective thermal conductivity. */ - bool energy; /*!< \brief computation with the energy equation. */ - - /* - * \brief Compute the projection of the viscous fluxes into a direction - * - * The viscous + turbulent stress tensor must be calculated before calling - * this function. - * - * \param[in] val_gradprimvar - Gradient of the primitive variables. - * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. - * \param[in] val_thermal_conductivity - Thermal conductivity. - */ - void GetViscousIncProjFlux(const su2double* const *val_gradprimvar, - const su2double *val_normal, - su2double val_thermal_conductivity); - - /*! - * \brief Compute the projection of the viscous Jacobian matrices. - * - * The Jacobian of the stress tensor must be calculated before calling - * this function. - * - * \param[in] val_dS - Area of the face between two nodes. - * \param[out] val_Proj_Jac_Tensor_i - Pointer to the projected viscous Jacobian at point i. - * \param[out] val_Proj_Jac_Tensor_j - Pointer to the projected viscous Jacobian at point j. - */ - void GetViscousIncProjJacs(su2double val_dS, - su2double **val_Proj_Jac_Tensor_i, - su2double **val_Proj_Jac_Tensor_j); - -public: - - /*! - * \brief Constructor of the class. - * \param[in] val_nDim - Number of dimension of the problem. - * \param[in] val_nVar - Number of variables of the problem. - * \param[in] val_correct_grad - Apply a correction to the gradient - * \param[in] config - Definition of the particular problem. - */ - CAvgGradInc_Flow(unsigned short val_nDim, unsigned short val_nVar, - bool val_correct_grad, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CAvgGradInc_Flow(void); - - /*! - * \brief Compute the viscous flow residual using an average of gradients. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); -}; - -/*! - * \class CAvgGrad_Scalar - * \brief Template class for computing viscous residual of scalar values - * \details This class serves as a template for the scalar viscous residual - * classes. The general structure of a viscous residual calculation is the - * same for many different models, which leads to a lot of repeated code. - * By using the template design pattern, these sections of repeated code are - * moved to a shared base class, and the specifics of each model - * are implemented by derived classes. In order to add a new residual - * calculation for a viscous residual, extend this class and implement - * the pure virtual functions with model-specific behavior. - * \ingroup ViscDiscr - * \author C. Pederson, A. Bueno, and F. Palacios - */ -class CAvgGrad_Scalar : public CNumerics { - private: - - /*! - * \brief A pure virtual function; Adds any extra variables to AD - */ - virtual void ExtraADPreaccIn() = 0; - - /*! - * \brief Model-specific steps in the ComputeResidual method - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - virtual void FinishResidualCalc(su2double *val_residual, - su2double **Jacobian_i, - su2double **Jacobian_j, - CConfig *config) = 0; - - protected: - bool implicit, incompressible; - bool correct_gradient; - unsigned short iVar, iDim; - su2double **Mean_GradTurbVar; /*!< \brief Average of gradients at cell face */ - su2double *Edge_Vector, /*!< \brief Vector from node i to node j. */ - *Proj_Mean_GradTurbVar_Normal, /*!< \brief Mean_gradTurbVar DOT normal */ - *Proj_Mean_GradTurbVar_Edge, /*!< \brief Mean_gradTurbVar DOT Edge_Vector */ - *Proj_Mean_GradTurbVar; /*!< \brief Mean_gradTurbVar DOT normal, corrected if required*/ - su2double dist_ij_2, /*!< \brief |Edge_Vector|^2 */ - proj_vector_ij; /*!< \brief (Edge_Vector DOT normal)/|Edge_Vector|^2 */ - - public: - /*! - * \brief Constructor of the class. - * \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. - */ - CAvgGrad_Scalar(unsigned short val_nDim, unsigned short val_nVar, - bool correct_gradient, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CAvgGrad_Scalar(void); - - /*! - * \brief Compute the viscous residual using an average of gradients without correction. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **Jacobian_i, - su2double **Jacobian_j, CConfig *config); -}; - -/*! - * \class CAvgGrad_TurbSA - * \brief Class for computing viscous term using average of gradients (Spalart-Allmaras Turbulence model). - * \ingroup ViscDiscr - * \author A. Bueno. - */ -class CAvgGrad_TurbSA : public CAvgGrad_Scalar { -private: - - const su2double sigma; - su2double nu_i, nu_j, nu_e; - - /*! - * \brief Adds any extra variables to AD - */ - void ExtraADPreaccIn(void); - - /*! - * \brief SA specific steps in the ComputeResidual method - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void FinishResidualCalc(su2double *val_residual, su2double **Jacobian_i, - su2double **Jacobian_j, CConfig *config); - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CAvgGrad_TurbSA(unsigned short val_nDim, unsigned short val_nVar, - bool correct_grad, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CAvgGrad_TurbSA(void); -}; - -/*! - * \class CAvgGrad_TurbSA_Neg - * \brief Class for computing viscous term using average of gradients (Spalart-Allmaras Turbulence model). - * \ingroup ViscDiscr - * \author F. Palacios - */ -class CAvgGrad_TurbSA_Neg : public CAvgGrad_Scalar { -private: - - const su2double sigma; - const su2double cn1; - su2double fn, Xi; - su2double nu_i, nu_j, nu_ij, nu_tilde_ij, nu_e; - - /*! - * \brief Adds any extra variables to AD - */ - void ExtraADPreaccIn(void); - - /*! - * \brief SA specific steps in the ComputeResidual method - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void FinishResidualCalc(su2double *val_residual, su2double **Jacobian_i, - su2double **Jacobian_j, CConfig *config); - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CAvgGrad_TurbSA_Neg(unsigned short val_nDim, unsigned short val_nVar, - bool correct_grad, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CAvgGrad_TurbSA_Neg(void); -}; - -/*! - * \class CAvgGrad_TransLM - * \brief Class for computing viscous term using average of gradients (Spalart-Allmaras Turbulence model). - * \ingroup ViscDiscr - * \author A. Bueno. - */ -class CAvgGrad_TransLM : public CNumerics { -private: - su2double **Mean_GradTransVar; - su2double *Proj_Mean_GradTransVar_Kappa, *Proj_Mean_GradTransVar_Edge; - su2double *Edge_Vector; - bool implicit, incompressible; - su2double sigma; - //su2double dist_ij_2; - //su2double proj_vector_ij; - //unsigned short iVar, iDim; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CAvgGrad_TransLM(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CAvgGrad_TransLM(void); - - /*! - * \brief Compute the viscous turbulence terms residual using an average of gradients. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config); -}; - -/*! - * \class CAvgGrad_AdjFlow - * \brief Class for computing the adjoint viscous terms. - * \ingroup ViscDiscr - * \author F. Palacios - */ -class CAvgGrad_AdjFlow : public CNumerics { -private: - su2double *Velocity_i; /*!< \brief Auxiliary vector for storing the velocity of point i. */ - su2double *Velocity_j; /*!< \brief Auxiliary vector for storing the velocity of point j. */ - su2double *Mean_Velocity; - su2double *Mean_GradPsiE; /*!< \brief Counter for dimensions of the problem. */ - su2double **Mean_GradPhi; /*!< \brief Counter for dimensions of the problem. */ - su2double *Edge_Vector; /*!< \brief Vector going from node i to node j. */ - bool implicit; /*!< \brief Implicit calculus. */ - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CAvgGrad_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CAvgGrad_AdjFlow(void); - - /*! - * \brief Residual computation. - * \param[out] val_residual_i - Pointer to the total residual at point i. - * \param[out] val_residual_j - Pointer to the total residual at point j. - */ - void ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, - su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, - su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config); -}; - -/*! - * \class CAvgGradCorrected_TransLM - * \brief Class for computing viscous term using average of gradients with correction (Spalart-Allmaras turbulence model). - * \ingroup ViscDiscr - * \author A. Bueno. - */ -class CAvgGradCorrected_TransLM : public CNumerics { -private: - su2double **Mean_GradTurbVar; - su2double *Proj_Mean_GradTurbVar_Kappa, *Proj_Mean_GradTurbVar_Edge, *Proj_Mean_GradTurbVar_Corrected; - su2double *Edge_Vector; - bool implicit, incompressible; - su2double sigma; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CAvgGradCorrected_TransLM(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CAvgGradCorrected_TransLM(void); - - /*! - * \brief Compute the viscous turbulent residual using an average of gradients with correction. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config); -}; - -/*! - * \class CAvgGrad_TurbSST - * \brief Class for computing viscous term using average of gradient with correction (Menter SST turbulence model). - * \ingroup ViscDiscr - * \author A. Bueno. - */ -class CAvgGrad_TurbSST : public CAvgGrad_Scalar { -private: - su2double sigma_k1, /*!< \brief Constants for the viscous terms, k-w (1), k-eps (2)*/ - sigma_k2, - sigma_om1, - sigma_om2; - - su2double diff_kine, /*!< \brief Diffusivity for viscous terms of tke eq */ - diff_omega; /*!< \brief Diffusivity for viscous terms of omega eq */ - - su2double F1_i, F1_j; /*!< \brief Menter's first blending function */ - - /*! - * \brief Adds any extra variables to AD - */ - void ExtraADPreaccIn(void); - - /*! - * \brief SST specific steps in the ComputeResidual method - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void FinishResidualCalc(su2double *val_residual, su2double **Jacobian_i, - su2double **Jacobian_j, CConfig *config); - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CAvgGrad_TurbSST(unsigned short val_nDim, unsigned short val_nVar, - su2double* constants, bool correct_grad, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CAvgGrad_TurbSST(void); - - /*! - * \brief Sets value of first blending function. - */ - void SetF1blending(su2double val_F1_i, su2double val_F1_j) { - F1_i = val_F1_i; F1_j = val_F1_j; - } - -}; - -/*! - * \class CAvgGradCorrected_AdjFlow - * \brief Class for computing the adjoint viscous terms, including correction. - * \ingroup ViscDiscr - * \author A. Bueno. - */ -class CAvgGradCorrected_AdjFlow : public CNumerics { -private: - su2double *Velocity_i; /*!< \brief Auxiliary vector for storing the velocity of point i. */ - su2double *Velocity_j; /*!< \brief Auxiliary vector for storing the velocity of point j. */ - su2double *Mean_Velocity; - su2double **Mean_GradPsiVar; /*!< \brief Counter for dimensions of the problem. */ - su2double *Edge_Vector; /*!< \brief Vector going from node i to node j. */ - su2double *Proj_Mean_GradPsiVar_Edge; /*!< \brief Projection of Mean_GradPsiVar onto Edge_Vector. */ - su2double *Mean_GradPsiE; /*!< \brief Counter for dimensions of the problem. */ - su2double **Mean_GradPhi; /*!< \brief Counter for dimensions of the problem. */ - bool implicit; /*!< \brief Boolean controlling Jacobian calculations. */ - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CAvgGradCorrected_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CAvgGradCorrected_AdjFlow(void); - - /*! - * \brief Compute the adjoint flow viscous residual in a non-conservative way using an average of gradients and derivative correction. - * \param[out] val_residual_i - Pointer to the viscous residual at point i. - * \param[out] val_residual_j - Pointer to the viscous residual at point j. - * \param[out] val_Jacobian_ii - Jacobian of the numerical method at node i (implicit computation) from node i. - * \param[out] val_Jacobian_ij - Jacobian of the numerical method at node i (implicit computation) from node j. - * \param[out] val_Jacobian_ji - Jacobian of the numerical method at node j (implicit computation) from node i. - * \param[out] val_Jacobian_jj - Jacobian of the numerical method at node j (implicit computation) from node j. - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, - su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config); -}; - -/*! - * \class CAvgGradCorrected_AdjTurb - * \brief Class for adjoint turbulent using average of gradients with a correction. - * \ingroup ViscDiscr - * \author A. Bueno. - */ -class CAvgGradCorrected_AdjTurb : public CNumerics { -private: - su2double **Mean_GradTurbPsi; - su2double *Proj_Mean_GradTurbPsi_Kappa, *Proj_Mean_GradTurbPsi_Edge, *Proj_Mean_GradTurbPsi_Corrected; - su2double *Edge_Vector; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CAvgGradCorrected_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CAvgGradCorrected_AdjTurb(void); - - /*! - * \brief Compute the adjoint turbulent residual using average of gradients and a derivative correction. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - - /*! - * \overload - * \param[out] val_residual_i - Pointer to the total residual at point i. - * \param[out] val_residual_j - Pointer to the total viscosity residual at point j. - * \param[out] val_Jacobian_ii - Jacobian of the numerical method at node i (implicit computation) from node i. - * \param[out] val_Jacobian_ij - Jacobian of the numerical method at node i (implicit computation) from node j. - * \param[out] val_Jacobian_ji - Jacobian of the numerical method at node j (implicit computation) from node i. - * \param[out] val_Jacobian_jj - Jacobian of the numerical method at node j (implicit computation) from node j. - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, - su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config); -}; - -/*! - * \class CAvgGrad_AdjTurb - * \brief Class for adjoint turbulent using average of gradients with a correction. - * \ingroup ViscDiscr - * \author F. Palacios - */ -class CAvgGrad_AdjTurb : public CNumerics { -private: - su2double **Mean_GradTurbPsi; - su2double *Proj_Mean_GradTurbPsi_Kappa, *Proj_Mean_GradTurbPsi_Edge, *Proj_Mean_GradTurbPsi_Corrected; - su2double *Edge_Vector; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CAvgGrad_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CAvgGrad_AdjTurb(void); - - /*! - * \brief Compute the adjoint turbulent residual using average of gradients and a derivative correction. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - - /*! - * \overload - * \param[out] val_residual_i - Pointer to the total residual at point i. - * \param[out] val_residual_j - Pointer to the total viscosity residual at point j. - * \param[out] val_Jacobian_ii - Jacobian of the numerical method at node i (implicit computation) from node i. - * \param[out] val_Jacobian_ij - Jacobian of the numerical method at node i (implicit computation) from node j. - * \param[out] val_Jacobian_ji - Jacobian of the numerical method at node j (implicit computation) from node i. - * \param[out] val_Jacobian_jj - Jacobian of the numerical method at node j (implicit computation) from node j. - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, - su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config); -}; - - -/*! - * \class CAvgGrad_Heat - * \brief Class for computing viscous term using average of gradients without correction (heat equation). - * \ingroup ViscDiscr - * \author O. Burghardt. - * \version 7.0.1 "Blackbird" - */ -class CAvgGrad_Heat : public CNumerics { -private: - su2double **Mean_GradHeatVar; - su2double *Proj_Mean_GradHeatVar_Normal, *Proj_Mean_GradHeatVar_Corrected; - su2double *Edge_Vector; - bool implicit; - su2double dist_ij_2, proj_vector_ij, Thermal_Diffusivity_Mean; - unsigned short iVar, iDim; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CAvgGrad_Heat(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CAvgGrad_Heat(void); - - /*! - * \brief Compute the viscous heat residual using an average of gradients with correction. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config); -}; - -/*! - * \class CAvgGradCorrected_Heat - * \brief Class for computing viscous term using average of gradients with correction (heat equation). - * \ingroup ViscDiscr - * \author O. Burghardt. - * \version 7.0.1 "Blackbird" - */ -class CAvgGradCorrected_Heat : public CNumerics { -private: - su2double **Mean_GradHeatVar; - su2double *Proj_Mean_GradHeatVar_Kappa, *Proj_Mean_GradHeatVar_Edge, *Proj_Mean_GradHeatVar_Corrected; - su2double *Edge_Vector; - bool implicit; - su2double dist_ij_2, proj_vector_ij, Thermal_Diffusivity_Mean; - unsigned short iVar, iDim; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CAvgGradCorrected_Heat(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CAvgGradCorrected_Heat(void); - - /*! - * \brief Compute the viscous heat residual using an average of gradients with correction. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config); -}; - -/*! - * \class CGalerkin_Flow - * \brief Class for computing the stiffness matrix of the Galerkin method. - * \ingroup ViscDiscr - * \author F. Palacios - */ -class CGalerkin_Flow : public CNumerics { -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CGalerkin_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CGalerkin_Flow(void); - - /*! - * \brief Computing stiffness matrix of the Galerkin method. - * \param[out] val_stiffmatrix_elem - Stiffness matrix for Galerkin computation. - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual (su2double **val_stiffmatrix_elem, CConfig *config); -}; - -/*! - * \class CSourceNothing - * \brief Dummy class. - * \ingroup SourceDiscr - * \author F. Palacios - */ -class CSourceNothing : public CNumerics { -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourceNothing(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourceNothing(void); -}; - -/*! - * \class CSourcePieceWise_TurbSA - * \brief Class for integrating the source terms of the Spalart-Allmaras turbulence model equation. - * \ingroup SourceDiscr - * \author A. Bueno. - */ -class CSourcePieceWise_TurbSA : public CNumerics { -private: - su2double cv1_3; - su2double k2; - su2double cb1; - su2double cw2; - su2double ct3; - su2double ct4; - su2double cw3_6; - su2double cb2_sigma; - su2double sigma; - su2double cb2; - su2double cw1; - unsigned short iDim; - su2double nu, Ji, fv1, fv2, ft2, Omega, S, Shat, inv_Shat, dist_i_2, Ji_2, Ji_3, inv_k2_d2; - su2double r, g, g_6, glim, fw; - su2double norm2_Grad; - su2double dfv1, dfv2, dShat; - su2double dr, dg, dfw; - bool incompressible; - bool rotating_frame; - bool transition; - su2double gamma_BC; - su2double intermittency; - su2double Production, Destruction, CrossProduction; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourcePieceWise_TurbSA(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourcePieceWise_TurbSA(void); - - /*! - * \brief Residual for source term integration. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - - /*! - * \brief Residual for source term integration. - * \param[in] intermittency_in - Value of the intermittency. - */ - void SetIntermittency(su2double intermittency_in); - - /*! - * \brief Residual for source term integration. - * \param[in] val_production - Value of the Production. - */ - void SetProduction(su2double val_production); - - /*! - * \brief Residual for source term integration. - * \param[in] val_destruction - Value of the Destruction. - */ - void SetDestruction(su2double val_destruction); - - /*! - * \brief Residual for source term integration. - * \param[in] val_crossproduction - Value of the CrossProduction. - */ - void SetCrossProduction(su2double val_crossproduction); - - /*! - * \brief ______________. - */ - su2double GetProduction(void); - - /*! - * \brief Get the intermittency for the BC trans. model. - * \return Value of the intermittency. - */ - su2double GetGammaBC(void); - - /*! - * \brief ______________. - */ - su2double GetDestruction(void); - - /*! - * \brief ______________. - */ - su2double GetCrossProduction(void); -}; - -/*! - * \class CSourcePieceWise_TurbSA_E - * \brief Class for integrating the source terms of the Spalart-Allmaras Edwards modification turbulence model equation. - * \ingroup SourceDiscr - * \author E.Molina, A. Bueno. - * \version 7.0.1 "Blackbird" - */ -class CSourcePieceWise_TurbSA_E : public CNumerics { -private: - su2double cv1_3; - su2double k2; - su2double cb1; - su2double cw2; - su2double ct3; - su2double ct4; - su2double cw3_6; - su2double cb2_sigma; - su2double sigma; - su2double cb2; - su2double cw1; - unsigned short iDim; - su2double nu, Ji, fv1, fv2, ft2, Omega, S, Shat, inv_Shat, dist_i_2, Ji_2, Ji_3, inv_k2_d2; - su2double r, g, g_6, glim, fw; - su2double norm2_Grad; - su2double dfv1, dfv2, dShat; - su2double dr, dg, dfw; - bool incompressible; - bool rotating_frame; - su2double intermittency; - su2double Production, Destruction, CrossProduction; - su2double Sbar; - unsigned short jDim; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourcePieceWise_TurbSA_E(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourcePieceWise_TurbSA_E(void); - - /*! - * \brief Residual for source term integration. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - - /*! - * \brief Residual for source term integration. - * \param[in] intermittency_in - Value of the intermittency. - */ - void SetIntermittency(su2double intermittency_in); - - /*! - * \brief Residual for source term integration. - * \param[in] val_production - Value of the Production. - */ - void SetProduction(su2double val_production); - - /*! - * \brief Residual for source term integration. - * \param[in] val_destruction - Value of the Destruction. - */ - void SetDestruction(su2double val_destruction); - - /*! - * \brief Residual for source term integration. - * \param[in] val_crossproduction - Value of the CrossProduction. - */ - void SetCrossProduction(su2double val_crossproduction); - - /*! - * \brief ______________. - */ - su2double GetProduction(void); - - /*! - * \brief ______________. - */ - su2double GetDestruction(void); - - /*! - * \brief ______________. - */ - su2double GetCrossProduction(void); -}; - -/*! - * \class CSourcePieceWise_TurbSA_COMP - * \brief Class for integrating the source terms of the Spalart-Allmaras CC modification turbulence model equation. - * \ingroup SourceDiscr - * \author E.Molina, A. Bueno. - * \version 7.0.1 "Blackbird" - */ -class CSourcePieceWise_TurbSA_COMP : public CNumerics { -private: - su2double cv1_3; - su2double k2; - su2double cb1; - su2double cw2; - su2double ct3; - su2double ct4; - su2double cw3_6; - su2double cb2_sigma; - su2double sigma; - su2double cb2; - su2double cw1; - unsigned short iDim; - su2double nu, Ji, fv1, fv2, ft2, Omega, S, Shat, inv_Shat, dist_i_2, Ji_2, Ji_3, inv_k2_d2; - su2double r, g, g_6, glim, fw; - su2double norm2_Grad; - su2double dfv1, dfv2, dShat; - su2double dr, dg, dfw; - bool incompressible; - bool rotating_frame; - su2double intermittency; - su2double Production, Destruction, CrossProduction; - su2double aux_cc, CompCorrection, c5; - unsigned short jDim; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourcePieceWise_TurbSA_COMP(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourcePieceWise_TurbSA_COMP(void); - - /*! - * \brief Residual for source term integration. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - - /*! - * \brief Residual for source term integration. - * \param[in] intermittency_in - Value of the intermittency. - */ - void SetIntermittency(su2double intermittency_in); - - /*! - * \brief Residual for source term integration. - * \param[in] val_production - Value of the Production. - */ - void SetProduction(su2double val_production); - - /*! - * \brief Residual for source term integration. - * \param[in] val_destruction - Value of the Destruction. - */ - void SetDestruction(su2double val_destruction); - - /*! - * \brief Residual for source term integration. - * \param[in] val_crossproduction - Value of the CrossProduction. - */ - void SetCrossProduction(su2double val_crossproduction); - - /*! - * \brief ______________. - */ - su2double GetProduction(void); - - /*! - * \brief ______________. - */ - su2double GetDestruction(void); - - /*! - * \brief ______________. - */ - su2double GetCrossProduction(void); -}; - -/*! - * \class CSourcePieceWise_TurbSA_E_COMP - * \brief Class for integrating the source terms of the Spalart-Allmaras Edwards modification with CC turbulence model equation. - * \ingroup SourceDiscr - * \author E.Molina, A. Bueno. - * \version 7.0.1 "Blackbird" - */ -class CSourcePieceWise_TurbSA_E_COMP : public CNumerics { -private: - su2double cv1_3; - su2double k2; - su2double cb1; - su2double cw2; - su2double ct3; - su2double ct4; - su2double cw3_6; - su2double cb2_sigma; - su2double sigma; - su2double cb2; - su2double cw1; - unsigned short iDim; - su2double nu, Ji, fv1, fv2, ft2, Omega, S, Shat, inv_Shat, dist_i_2, Ji_2, Ji_3, inv_k2_d2; - su2double r, g, g_6, glim, fw; - su2double norm2_Grad; - su2double dfv1, dfv2, dShat; - su2double dr, dg, dfw; - bool incompressible; - bool rotating_frame; - su2double intermittency; - su2double Production, Destruction, CrossProduction; - su2double Sbar; - unsigned short jDim; - su2double aux_cc, CompCorrection, c5; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourcePieceWise_TurbSA_E_COMP(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourcePieceWise_TurbSA_E_COMP(void); - - /*! - * \brief Residual for source term integration. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - - /*! - * \brief Residual for source term integration. - * \param[in] intermittency_in - Value of the intermittency. - */ - void SetIntermittency(su2double intermittency_in); - - /*! - * \brief Residual for source term integration. - * \param[in] val_production - Value of the Production. - */ - void SetProduction(su2double val_production); - - /*! - * \brief Residual for source term integration. - * \param[in] val_destruction - Value of the Destruction. - */ - void SetDestruction(su2double val_destruction); - - /*! - * \brief Residual for source term integration. - * \param[in] val_crossproduction - Value of the CrossProduction. - */ - void SetCrossProduction(su2double val_crossproduction); - - /*! - * \brief ______________. - */ - su2double GetProduction(void); - - /*! - * \brief ______________. - */ - su2double GetDestruction(void); - - /*! - * \brief ______________. - */ - su2double GetCrossProduction(void); -}; - -/*! - * \class CSourcePieceWise_TurbSA_Neg - * \brief Class for integrating the source terms of the Spalart-Allmaras turbulence model equation. - * \ingroup SourceDiscr - * \author F. Palacios - */ -class CSourcePieceWise_TurbSA_Neg : public CNumerics { -private: - su2double cv1_3; - su2double k2; - su2double cb1; - su2double cw2; - su2double ct3; - su2double ct4; - su2double cw3_6; - su2double cb2_sigma; - su2double sigma; - su2double cb2; - su2double cw1; - unsigned short iDim; - su2double nu, Ji, fv1, fv2, ft2, Omega, S, Shat, inv_Shat, dist_i_2, Ji_2, Ji_3, inv_k2_d2; - su2double r, g, g_6, glim, fw; - su2double norm2_Grad; - su2double dfv1, dfv2, dShat; - su2double dr, dg, dfw; - bool incompressible; - bool rotating_frame; - su2double intermittency; - su2double Production, Destruction, CrossProduction; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourcePieceWise_TurbSA_Neg(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourcePieceWise_TurbSA_Neg(void); - - /*! - * \brief Residual for source term integration. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - - /*! - * \brief Residual for source term integration. - * \param[in] intermittency_in - Value of the intermittency. - */ - void SetIntermittency(su2double intermittency_in); - - /*! - * \brief Residual for source term integration. - * \param[in] val_production - Value of the Production. - */ - void SetProduction(su2double val_production); - - /*! - * \brief Residual for source term integration. - * \param[in] val_destruction - Value of the Destruction. - */ - void SetDestruction(su2double val_destruction); - - /*! - * \brief Residual for source term integration. - * \param[in] val_crossproduction - Value of the CrossProduction. - */ - void SetCrossProduction(su2double val_crossproduction); - - /*! - * \brief ______________. - */ - su2double GetProduction(void); - - /*! - * \brief ______________. - */ - su2double GetDestruction(void); - - /*! - * \brief ______________. - */ - su2double GetCrossProduction(void); -}; - -/*! - * \class CSourcePieceWise_TransLM - * \brief Class for integrating the source terms of the Spalart-Allmaras turbulence model equation. - * \ingroup SourceDiscr - * \author A. Bueno. - */ -class CSourcePieceWise_TransLM : public CNumerics { -private: - - /*-- SA model constants --*/ - su2double cv1_3; - su2double k2; - su2double cb1; - su2double cw2; - su2double cw3_6; - su2double sigma; - su2double cb2; - su2double cw1; - - /*-- gamma-theta model constants --*/ - su2double c_e1; - su2double c_a1; - su2double c_e2; - su2double c_a2; - su2double sigmaf; - su2double s1; - su2double c_theta; - su2double sigmat; - - /*-- Correlation constants --*/ - su2double flen_global; - su2double alpha_global; - su2double Vorticity; - - bool implicit; - -public: - bool debugme; // For debugging only, remove this. -AA - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourcePieceWise_TransLM(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourcePieceWise_TransLM(void); - - /*! - * \brief Residual for source term integration. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual_TransLM(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config, su2double &gamma_sep); - - void CSourcePieceWise_TransLM__ComputeResidual_TransLM_d(su2double *TransVar_i, su2double *TransVar_id, su2double *val_residual, su2double *val_residuald, CConfig *config); -}; - -/*! - * \class CSourcePieceWise_TurbSST - * \brief Class for integrating the source terms of the Menter SST turbulence model equations. - * \ingroup SourceDiscr - * \author A. Campos. - */ -class CSourcePieceWise_TurbSST : public CNumerics { -private: - su2double F1_i, - F1_j, - F2_i, - F2_j; - - su2double alfa_1, - alfa_2, - beta_1, - beta_2, - sigma_omega_1, - sigma_omega_2, - beta_star, - a1; - - su2double CDkw_i, CDkw_j; - - su2double kAmb, omegaAmb; - - bool incompressible; - bool sustaining_terms; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourcePieceWise_TurbSST(unsigned short val_nDim, unsigned short val_nVar, su2double* constants, - su2double val_kine_Inf, su2double val_omega_Inf, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourcePieceWise_TurbSST(void); - - /*! - * \brief Set the value of the first blending function. - * \param[in] val_F1_i - Value of the first blending function at point i. - * \param[in] val_F1_j - Value of the first blending function at point j. - */ - void SetF1blending(su2double val_F1_i, su2double val_F1_j); - - /*! - * \brief Set the value of the second blending function. - * \param[in] val_F2_i - Value of the second blending function at point i. - * \param[in] val_F2_j - Value of the second blending function at point j. - */ - void SetF2blending(su2double val_F2_i, su2double val_F2_j); - - /*! - * \brief Set the value of the cross diffusion for the SST model. - * \param[in] val_CDkw_i - Value of the cross diffusion at point i. - * \param[in] val_CDkw_j - Value of the cross diffusion at point j. - */ - virtual void SetCrossDiff(su2double val_CDkw_i, su2double val_CDkw_j); - - /*! - * \brief Residual for source term integration. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - - /*! - * \brief Initialize the Reynolds Stress Matrix - * \param[in] turb_ke turbulent kinetic energy of node - */ - void SetReynoldsStressMatrix(su2double turb_ke); - - /*! - * \brief Perturb the Reynolds stress tensor based on parameters - * \param[in] turb_ke: turbulent kinetic energy of the noce - * \param[in] config: config file - */ - void SetPerturbedRSM(su2double turb_ke, CConfig *config); - /*! - * \brief A virtual member. Get strain magnitude based on perturbed reynolds stress matrix - * \param[in] turb_ke: turbulent kinetic energy of the node - */ - void SetPerturbedStrainMag(su2double turb_ke); - - /*! - * \brief Get the mean rate of strain matrix based on velocity gradients - * \param[in] S_ij - */ - void GetMeanRateOfStrainMatrix(su2double **S_ij); - -}; - -/*! - * \class CSourceGravity - * \brief Class for the source term integration of the gravity force. - * \ingroup SourceDiscr - * \author F. Palacios - */ -class CSourceGravity : public CNumerics { - -public: - - /*! - * \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. - */ - CSourceGravity(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourceGravity(void); - - /*! - * \brief Source term integration for the poissonal potential. - * \param[out] val_residual - Pointer to the total residual. - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, CConfig *config); -}; - -/*! - * \class CSourceBodyForce - * \brief Class for the source term integration of a body force. - * \ingroup SourceDiscr - * \author T. Economon - */ -class CSourceBodyForce : public CNumerics { - su2double *Body_Force_Vector; - -public: - - /*! - * \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. - */ - CSourceBodyForce(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourceBodyForce(void); - - /*! - * \brief Source term integration for a body force. - * \param[out] val_residual - Pointer to the residual vector. - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, CConfig *config); - -}; - -/*! - * \class CSourceIncBodyForce - * \brief Class for the source term integration of a body force in the incompressible solver. - * \ingroup SourceDiscr - * \author T. Economon - * \version 7.0.1 "Blackbird" - */ -class CSourceIncBodyForce : public CNumerics { - su2double *Body_Force_Vector; - -public: - - /*! - * \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. - */ - CSourceIncBodyForce(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourceIncBodyForce(void); - - /*! - * \brief Source term integration for a body force. - * \param[out] val_residual - Pointer to the residual vector. - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, CConfig *config); - -}; - -/*! - * \class CSourceIncRotatingFrame_Flow - * \brief Class for a rotating frame source term. - * \ingroup SourceDiscr - */ -class CSourceIncRotatingFrame_Flow : public CNumerics { - -private: - su2double Omega[3]; /*!< \brief Angular velocity */ - bool implicit; /*!< \brief Implicit calculation. */ - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourceIncRotatingFrame_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourceIncRotatingFrame_Flow(void); - - /*! - * \brief Residual of the rotational frame source term. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config); - -}; - -/*! - * \class CSourceBoussinesq - * \brief Class for the source term integration of the Boussinesq approximation for incompressible flow. - * \ingroup SourceDiscr - * \author T. Economon - * \version 7.0.1 "Blackbird" - */ -class CSourceBoussinesq : public CNumerics { - su2double *Gravity_Vector; - -public: - - /*! - * \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. - */ - CSourceBoussinesq(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourceBoussinesq(void); - - /*! - * \brief Source term integration for the Boussinesq approximation. - * \param[out] val_residual - Pointer to the residual vector. - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, CConfig *config); - -}; - -/*! - * \class CSourceIncAxisymmetric_Flow - * \brief Class for source term for solving incompressible axisymmetric problems. - * \ingroup SourceDiscr - * \author T. Economon - */ -class CSourceIncAxisymmetric_Flow : public CNumerics { - bool implicit, /*!< \brief Implicit calculation. */ - viscous, /*!< \brief Viscous incompressible flows. */ - energy; /*!< \brief computation with the energy equation. */ - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourceIncAxisymmetric_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourceIncAxisymmetric_Flow(void); - - /*! - * \brief Residual of the rotational frame source term. - * \param[out] val_residual - Pointer to the total residual. - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **Jacobian_i, CConfig *config); - -}; - -/*! - * \class CSourceViscous_AdjFlow - * \brief Class for source term integration in adjoint problem. - * \ingroup SourceDiscr - * \author F. Palacios - */ -class CSourceViscous_AdjFlow : public CNumerics { -private: - su2double *Velocity, *GradDensity, *GradInvDensity, *dPoDensity2, *alpha, *beta, *Sigma_5_vec; - su2double **GradVel_o_Rho, **sigma, **Sigma_phi, **Sigma_5_Tensor, **Sigma; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourceViscous_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourceViscous_AdjFlow(void); - - /*! - * \brief Source term integration of the flow adjoint equation. - * \param[out] val_residual - Pointer to the total residual. - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual (su2double *val_residual, CConfig *config); - -}; - -/*! - * \class CSourcePieceWise_AdjTurb - * \brief Class for source term integration of the adjoint turbulent equation. - * \ingroup SourceDiscr - * \author A. Bueno. - */ -class CSourcePieceWise_AdjTurb : public CNumerics { -private: - su2double **tau, *Velocity; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourcePieceWise_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourcePieceWise_AdjTurb(void); - - /*! - * \brief Source term integration of the adjoint turbulence equation. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); -}; - -class CSourceConservative_AdjFlow : public CNumerics { -private: - su2double *Velocity, *Residual_i, *Residual_j, *Mean_Residual; - su2double **Mean_PrimVar_Grad; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourceConservative_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourceConservative_AdjFlow(void); - - /*! - * \brief Source term integration using a conservative scheme. - * \param[out] val_residual - Pointer to the total residual. - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, CConfig *config); -}; - -/*! - * \class CSourceConservative_AdjTurb - * \brief Class for source term integration in adjoint turbulent problem using a conservative scheme. - * \ingroup SourceDiscr - * \author A. Bueno. - */ -class CSourceConservative_AdjTurb : public CNumerics { -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourceConservative_AdjTurb(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourceConservative_AdjTurb(void); - - /*! - * \brief Source term integration using a conservative scheme. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); -}; - -/*! - * \class CSourceRotatingFrame_Flow - * \brief Class for a rotating frame source term. - * \ingroup SourceDiscr - * \author F. Palacios, T. Economon. - */ -class CSourceRotatingFrame_Flow : public CNumerics { -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourceRotatingFrame_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourceRotatingFrame_Flow(void); - - /*! - * \brief Residual of the rotational frame source term. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config); -}; - -/*! - * \class CSourceRotatingFrame_AdjFlow - * \brief Source term class for rotating frame adjoint. - * \ingroup SourceDiscr - * \author T. Economon. - */ -class CSourceRotatingFrame_AdjFlow : public CNumerics { -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourceRotatingFrame_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourceRotatingFrame_AdjFlow(void); - - /*! - * \brief Residual of the adjoint rotating frame source term. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config); -}; - -/*! - * \class CSourceAxisymmetric_Flow - * \brief Class for source term for solving axisymmetric problems. - * \ingroup SourceDiscr - * \author F. Palacios - */ -class CSourceAxisymmetric_Flow : public CNumerics { -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourceAxisymmetric_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourceAxisymmetric_Flow(void); - - /*! - * \brief Residual of the rotational frame source term. - * \param[out] val_residual - Pointer to the total residual. - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **Jacobian_i, CConfig *config); - -}; - -/*! - * \class CSourceAxisymmetric_AdjFlow - * \brief Class for source term for solving axisymmetric problems. - * \ingroup SourceDiscr - * \author F. Palacios - */ -class CSourceAxisymmetric_AdjFlow : public CNumerics { -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourceAxisymmetric_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourceAxisymmetric_AdjFlow(void); - - /*! - * \brief Residual of the rotational frame source term. - * \param[out] val_residual - Pointer to the total residual. - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **Jacobian_i, CConfig *config); -}; - -/*! - * \class CSourceWindGust - * \brief Class for a source term due to a wind gust. - * \ingroup SourceDiscr - * \author S. Padrón - */ -class CSourceWindGust : public CNumerics { -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CSourceWindGust(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourceWindGust(void); - - /*! - * \brief Residual of the wind gust source term. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config); -}; - -/*! - * \class CSource_Template - * \brief Dummy class. - * \ingroup SourceDiscr - * \author A. Lonkar. - */ -class CSource_Template : public CNumerics { -public: - - /*! - * \brief Constructor of the class. - * \param[in] val_nDim - Number of dimensions of the problem. - * \param[in] val_nVar - Number of variables of the problem. - * \param[in] config - Name of the input config file - * - */ - CSource_Template(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - - /*! - * \brief Residual for source term integration. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSource_Template(void); -}; - -/*! - * \class CConvectiveTemplate - * \brief Class for setting up new method for spatial discretization of convective terms in flow Equations - * \ingroup ConvDiscr - * \author A. Lonkar - */ -class CConvective_Template : public CNumerics { -private: - - /* define private variables here */ - bool implicit; - su2double *Diff_U; - su2double *Velocity_i, *Velocity_j, *RoeVelocity; - su2double *ProjFlux_i, *ProjFlux_j; - su2double *delta_wave, *delta_vel; - su2double *Lambda, *Epsilon; - su2double **P_Tensor, **invP_Tensor; - su2double sq_vel, Proj_ModJac_Tensor_ij, Density_i, Energy_i, SoundSpeed_i, Pressure_i, Enthalpy_i, - Density_j, Energy_j, SoundSpeed_j, Pressure_j, Enthalpy_j, R, RoeDensity, RoeEnthalpy, RoeSoundSpeed, - ProjVelocity, ProjVelocity_i, ProjVelocity_j, proj_delta_vel, delta_p, delta_rho; - unsigned short iDim, iVar, jVar, kVar; - -public: - - /*! - * \brief Constructor of the class. - * \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. - */ - CConvective_Template(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CConvective_Template(void); - - /*! - * \brief Compute the Roe's flux between two nodes i and j. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); -}; - -/*! - * \class CViscous_Template - * \brief Class for computing viscous term using average of gradients. - * \ingroup ViscDiscr - * \author F. Palacios - */ -class CViscous_Template : public CNumerics { -private: - -public: - - /*! - * \brief Constructor of the class. - * \param[in] val_nDim - Number of dimension of the problem. - * \param[in] val_nVar - Number of variables of the problem. - * \param[in] config - Definition of the particular problem. - */ - CViscous_Template(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CViscous_Template(void); - - /*! - * \brief Compute the viscous flow residual using an average of gradients. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); -}; - -#include "numerics_structure.inl" diff --git a/SU2_CFD/include/numerics_structure.inl b/SU2_CFD/include/numerics_structure.inl deleted file mode 100644 index b3cedf282b89..000000000000 --- a/SU2_CFD/include/numerics_structure.inl +++ /dev/null @@ -1,494 +0,0 @@ -/*! - * \file numerics_structure.inl - * \brief In-Line subroutines of the numerics_structure.hpp file. - * \author F. Palacios, T. Economon - * \version 7.0.1 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -inline su2double CNumerics::Determinant_3x3(su2double A00, - su2double A01, - su2double A02, - su2double A10, - su2double A11, - su2double A12, - su2double A20, - su2double A21, - su2double A22) { - - return A00*(A11*A22-A12*A21) - A01*(A10*A22-A12*A20) + A02*(A10*A21-A11*A20); - -} - -inline void CNumerics::Compute_Mass_Matrix(CElement *element_container, CConfig *config) { } - -inline void CNumerics::Compute_Dead_Load(CElement *element_container, CConfig *config) { } - -inline void CNumerics::Compute_Tangent_Matrix(CElement *element_container, CConfig *config) { } - -inline void CNumerics::Compute_NodalStress_Term(CElement *element_container, CConfig *config) { } - -inline void CNumerics::Compute_Averaged_NodalStress(CElement *element_container, CConfig *config) { } - -inline void CNumerics::SetMeshElasticProperties(unsigned long iElem, su2double val_E) { } - -inline void CNumerics::Set_DV_Val(unsigned short i_DV, su2double val_DV) { } - -inline su2double CNumerics::Get_DV_Val(unsigned short i_DV) const { return 0.0; } - -inline void CNumerics::Set_ElectricField(unsigned short i_DV, su2double val_EField) { } - -inline void CNumerics::SetMaterial_Properties(unsigned short iVal, su2double val_E, su2double val_Nu) { } - -inline void CNumerics::SetMaterial_Density(unsigned short iVal, su2double val_Rho, su2double val_Rho_DL) { } - -inline void CNumerics::ComputeResidual(su2double *val_residual, CConfig *config) { } - -inline void CNumerics::ComputeResidual(su2double *val_residual_i, su2double *val_residual_j) { } - -inline void CNumerics::ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, CConfig *config) { } - -inline void CNumerics::ComputeResidual(su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { } - -inline void CNumerics::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, - CConfig *config) { } - -inline void CNumerics::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, - su2double **val_JacobianMeanFlow_i, su2double **val_JacobianMeanFlow_j, CConfig *config) { } - -inline void CNumerics::ComputeResidual(su2double *val_resconv, su2double *val_resvisc, su2double **val_Jacobian_i, - su2double **val_Jacobian_j, CConfig *config) { } - -inline void CNumerics::ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, - su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, - su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config) { } - -inline void CNumerics::ComputeResidual(su2double *val_resconv_i, su2double *val_resvisc_i, su2double *val_resconv_j, - su2double *val_resvisc_j, su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, - su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config) { } - -inline void CNumerics::ComputeResidual(su2double **val_stiffmatrix_elem, CConfig *config) { } - -inline void CNumerics::GetEq_Rxn_Coefficients(su2double **EqnRxnConstants, CConfig *config) { }; - -inline void CNumerics::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config) { } - -inline void CNumerics::ComputeResidual_TransLM(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config, su2double &gamma_sep) {} - -inline void CNumerics::ComputeResidual_Axisymmetric(su2double *val_residual, CConfig *config) { } - -inline void CNumerics::ComputeResidual_Axisymmetric_ad(su2double *val_residual, su2double *val_residuald, CConfig *config) { } - -inline void CNumerics::SetJacobian_Axisymmetric(su2double **val_Jacobian_i, CConfig *config) { } - -inline void CNumerics::ComputeVibRelaxation(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config) { } - -inline void CNumerics::ComputeChemistry(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config) { } - -inline void CNumerics::GetKeqConstants(su2double *A, unsigned short val_reaction, CConfig *config) { } - -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; -} - -inline void CNumerics::SetSensor( su2double val_sensor_i, su2double val_sensor_j) { - Sensor_i = val_sensor_i; - Sensor_j = val_sensor_j; -} - -inline void CNumerics::SetConservative(su2double *val_u_i, su2double *val_u_j) { - U_i = val_u_i; - U_j = val_u_j; -} - -inline void CNumerics::SetConservative_ZeroOrder(su2double *val_u_i, su2double *val_u_j) { - UZeroOrder_i = val_u_i; - UZeroOrder_j = val_u_j; -} - -inline void CNumerics::SetPrimitive(su2double *val_v_i, su2double *val_v_j) { - V_i = val_v_i; - V_j = val_v_j; -} - -inline void CNumerics::SetSecondary(su2double *val_s_i, su2double *val_s_j) { - S_i = val_s_i; - S_j = val_s_j; -} - -inline void CNumerics::SetConservative(su2double *val_u_0, su2double *val_u_1, su2double *val_u_2) { - U_0 = val_u_0; - U_1 = val_u_1; - U_2 = val_u_2; -} - -inline void CNumerics::SetConservative(su2double *val_u_0, su2double *val_u_1, su2double *val_u_2, su2double *val_u_3) { - U_0 = val_u_0; - U_1 = val_u_1; - U_2 = val_u_2; - U_3 = val_u_3; -} - -inline void CNumerics::SetVelocity2_Inf(su2double velocity2) { - vel2_inf = velocity2; -} - -inline void CNumerics::SetVorticity(su2double *val_vorticity_i, su2double *val_vorticity_j) { - Vorticity_i = val_vorticity_i; - Vorticity_j = val_vorticity_j; -} - -inline void CNumerics::SetStrainMag(su2double val_strainmag_i, su2double val_strainmag_j) { - StrainMag_i = val_strainmag_i; - StrainMag_j = val_strainmag_j; -} - -inline void CNumerics::SetTimeStep(su2double val_timestep) {TimeStep = val_timestep;} - -inline void CNumerics::SetLaminarViscosity(su2double val_lam_viscosity_i, su2double val_lam_viscosity_j) { - Laminar_Viscosity_i = val_lam_viscosity_i; - Laminar_Viscosity_j = val_lam_viscosity_j; -} - -inline void CNumerics::SetThermalConductivity(su2double val_therm_conductivity_i, su2double val_therm_conductivity_j) { - Thermal_Conductivity_i = val_therm_conductivity_i; - Thermal_Conductivity_j = val_therm_conductivity_j; -} - -inline void CNumerics::SetThermalConductivity_ve(su2double val_therm_conductivity_ve_i, su2double val_therm_conductivity_ve_j) { - Thermal_Conductivity_ve_i = val_therm_conductivity_ve_i; - Thermal_Conductivity_ve_j = val_therm_conductivity_ve_j; -} - -inline void CNumerics::SetThermalDiffusivity(su2double val_thermal_diffusivity_i,su2double val_thermal_diffusivity_j) { - Thermal_Diffusivity_i = val_thermal_diffusivity_i; - Thermal_Diffusivity_j = val_thermal_diffusivity_j; -} - -inline void CNumerics::SetDiffusionCoeff(su2double* val_diffusioncoeff_i, su2double* val_diffusioncoeff_j) { - Diffusion_Coeff_i = val_diffusioncoeff_i; - Diffusion_Coeff_j = val_diffusioncoeff_j; -} - -inline void CNumerics::SetEddyViscosity(su2double val_eddy_viscosity_i, su2double val_eddy_viscosity_j) { - Eddy_Viscosity_i = val_eddy_viscosity_i; - Eddy_Viscosity_j = val_eddy_viscosity_j; -} - -inline void CNumerics::SetIntermittency(su2double intermittency_in) { } - -inline void CNumerics::SetProduction(su2double val_production) { } - -inline void CNumerics::SetDestruction(su2double val_destruction) { } - -inline void CNumerics::SetCrossProduction(su2double val_crossproduction) { } - -inline su2double CNumerics::GetProduction(void) { return 0; } - -inline su2double CNumerics::GetDestruction(void) { return 0; } - -inline su2double CNumerics::GetCrossProduction(void) { return 0; } - -inline su2double CNumerics::GetGammaBC(void) { return 0.0; } - -inline void CNumerics::SetTurbKineticEnergy(su2double val_turb_ke_i, su2double val_turb_ke_j) { - turb_ke_i = val_turb_ke_i; - turb_ke_j = val_turb_ke_j; -} - -inline void CNumerics::SetDistance(su2double val_dist_i, su2double val_dist_j) { - dist_i = val_dist_i; - dist_j = val_dist_j; -} - -inline void CNumerics::SetAdjointVar(su2double *val_psi_i, su2double *val_psi_j) { - Psi_i = val_psi_i; - Psi_j = val_psi_j; -} - -inline void CNumerics::SetAdjointVarGradient(su2double **val_psivar_grad_i, su2double **val_psivar_grad_j) { - PsiVar_Grad_i = val_psivar_grad_i; - PsiVar_Grad_j = val_psivar_grad_j; -} - -inline void CNumerics::SetTurbVar(su2double *val_turbvar_i, su2double *val_turbvar_j) { - TurbVar_i = val_turbvar_i; - TurbVar_j = val_turbvar_j; -} - -inline void CNumerics::SetTransVar(su2double *val_transvar_i, su2double *val_transvar_j) { - TransVar_i = val_transvar_i; - TransVar_j = val_transvar_j; -} - -inline void CNumerics::SetTurbVarGradient(su2double **val_turbvar_grad_i, su2double **val_turbvar_grad_j) { - TurbVar_Grad_i = val_turbvar_grad_i; - TurbVar_Grad_j = val_turbvar_grad_j; -} - -inline void CNumerics::SetTransVarGradient(su2double **val_transvar_grad_i, su2double **val_transvar_grad_j) { - TransVar_Grad_i = val_transvar_grad_i; - TransVar_Grad_j = val_transvar_grad_j; -} - -inline void CNumerics::SetPrimVarGradient(su2double **val_primvar_grad_i, su2double **val_primvar_grad_j) { - PrimVar_Grad_i = val_primvar_grad_i; - PrimVar_Grad_j = val_primvar_grad_j; -} - - -inline void CNumerics::SetConsVarGradient(su2double **val_consvar_grad_i, su2double **val_consvar_grad_j) { - ConsVar_Grad_i = val_consvar_grad_i; - ConsVar_Grad_j = val_consvar_grad_j; -} - -inline void CNumerics::SetConsVarGradient(su2double **val_consvar_grad_0, su2double **val_consvar_grad_1, su2double **val_consvar_grad_2) { - ConsVar_Grad_0 = val_consvar_grad_0; - ConsVar_Grad_1 = val_consvar_grad_1; - ConsVar_Grad_2 = val_consvar_grad_2; -} - -inline void CNumerics::SetConsVarGradient(su2double **val_consvar_grad_0, su2double **val_consvar_grad_1, su2double **val_consvar_grad_2, su2double **val_consvar_grad_3) { - ConsVar_Grad_0 = val_consvar_grad_0; - ConsVar_Grad_1 = val_consvar_grad_1; - ConsVar_Grad_2 = val_consvar_grad_2; - ConsVar_Grad_3 = val_consvar_grad_3; -} - -inline void CNumerics::SetConsVarGradient(su2double **val_consvar_grad) { - ConsVar_Grad = val_consvar_grad; -} - -inline void CNumerics::SetCoord(su2double *val_coord_i, su2double *val_coord_j) { - Coord_i = val_coord_i; - Coord_j = val_coord_j; -} - -inline void CNumerics::SetCoord(su2double *val_coord_0, su2double *val_coord_1, - su2double *val_coord_2) { - Coord_0 = val_coord_0; - Coord_1 = val_coord_1; - Coord_2 = val_coord_2; -} - -inline void CNumerics::SetCoord(su2double *val_coord_0, su2double *val_coord_1, - su2double *val_coord_2, su2double *val_coord_3) { - Coord_0 = val_coord_0; - Coord_1 = val_coord_1; - Coord_2 = val_coord_2; - Coord_3 = val_coord_3; -} - -inline void CNumerics::SetGridVel(su2double *val_gridvel_i, su2double *val_gridvel_j) { - GridVel_i = val_gridvel_i; - GridVel_j = val_gridvel_j; -} - -inline void CNumerics::SetWindGust(su2double *val_windgust_i, su2double *val_windgust_j) { - WindGust_i = val_windgust_i; - WindGust_j = val_windgust_j; -} - -inline void CNumerics::SetWindGustDer(su2double *val_windgustder_i, su2double *val_windgustder_j) { - WindGustDer_i = val_windgustder_i; - WindGustDer_j = val_windgustder_j; -} - -inline void CNumerics::SetPressure(su2double val_pressure_i, su2double val_pressure_j) { - Pressure_i = val_pressure_i; - Pressure_j = val_pressure_j; -} - -inline void CNumerics::SetDensity(su2double val_densityinc_i, su2double val_densityinc_j) { - DensityInc_i = val_densityinc_i; - DensityInc_j = val_densityinc_j; -} - -inline void CNumerics::SetBetaInc2(su2double val_betainc2_i, su2double val_betainc2_j) { - BetaInc2_i = val_betainc2_i; - BetaInc2_j = val_betainc2_j; -} - -inline void CNumerics::SetSoundSpeed(su2double val_soundspeed_i, su2double val_soundspeed_j) { - SoundSpeed_i = val_soundspeed_i; - SoundSpeed_j = val_soundspeed_j; -} - -inline void CNumerics::SetEnthalpy(su2double val_enthalpy_i, su2double val_enthalpy_j) { - Enthalpy_i = val_enthalpy_i; - Enthalpy_j = val_enthalpy_j; -} - -inline void CNumerics::SetLambda(su2double val_lambda_i, su2double val_lambda_j) { - Lambda_i = val_lambda_i; - Lambda_j = val_lambda_j; -} - -inline void CNumerics::SetNeighbor(unsigned short val_neighbor_i, unsigned short val_neighbor_j) { - Neighbor_i = val_neighbor_i; - Neighbor_j = val_neighbor_j; -} - -inline void CNumerics::SetTurbAdjointVar(su2double *val_turbpsivar_i, su2double *val_turbpsivar_j) { - TurbPsi_i = val_turbpsivar_i; - TurbPsi_j = val_turbpsivar_j; -} - -inline void CNumerics::SetTurbAdjointGradient(su2double **val_turbpsivar_grad_i, su2double **val_turbpsivar_grad_j) { - TurbPsi_Grad_i = val_turbpsivar_grad_i; - TurbPsi_Grad_j = val_turbpsivar_grad_j; -} - -inline void CNumerics::SetTemperature(su2double val_temp_i, su2double val_temp_j) { - Temp_i = val_temp_i; - Temp_j = val_temp_j; -} - -inline void CNumerics::SetAuxVarGrad(su2double *val_auxvargrad_i, su2double *val_auxvargrad_j) { - AuxVar_Grad_i = val_auxvargrad_i; - AuxVar_Grad_j = val_auxvargrad_j; -} - -inline void CNumerics::SetNormal(su2double *val_normal) { Normal = val_normal; } - -inline void CNumerics::SetVolume(su2double val_volume) { Volume = val_volume; } - -inline void CNumerics::SetDissipation(su2double diss_i, su2double diss_j) { - Dissipation_i = diss_i; - Dissipation_j = diss_j; -} - -inline su2double CNumerics::GetDissipation(){ - return Dissipation_ij; -} - -inline void CSourcePieceWise_TurbSST::SetF1blending(su2double val_F1_i, su2double val_F1_j) { - F1_i = val_F1_i; - F1_j = val_F1_j; -} - -inline void CSourcePieceWise_TurbSST::SetF2blending(su2double val_F2_i, su2double val_F2_j) { - F2_i = val_F2_i; - F2_j = val_F2_j; -} - -inline void CSourcePieceWise_TurbSST::SetCrossDiff(su2double val_CDkw_i, su2double val_CDkw_j) { - CDkw_i = val_CDkw_i; - CDkw_j = val_CDkw_j; -} - -inline void CSourcePieceWise_TurbSA::SetIntermittency(su2double intermittency_in) { intermittency = intermittency_in; } - -inline void CSourcePieceWise_TurbSA::SetProduction(su2double val_production) { Production = val_production; } - -inline void CSourcePieceWise_TurbSA::SetDestruction(su2double val_destruction) { Destruction = val_destruction; } - -inline void CSourcePieceWise_TurbSA::SetCrossProduction(su2double val_crossproduction) { CrossProduction = val_crossproduction; } - -inline su2double CSourcePieceWise_TurbSA::GetProduction(void) { return Production; } - -inline su2double CSourcePieceWise_TurbSA::GetGammaBC(void) { return gamma_BC; } - -inline su2double CSourcePieceWise_TurbSA::GetDestruction(void) { return Destruction; } - -inline su2double CSourcePieceWise_TurbSA::GetCrossProduction(void) { return CrossProduction; } - -inline void CSourcePieceWise_TurbSA_E::SetIntermittency(su2double intermittency_in) { intermittency = intermittency_in; } - -inline void CSourcePieceWise_TurbSA_E::SetProduction(su2double val_production) { Production = val_production; } - -inline void CSourcePieceWise_TurbSA_E::SetDestruction(su2double val_destruction) { Destruction = val_destruction; } - -inline void CSourcePieceWise_TurbSA_E::SetCrossProduction(su2double val_crossproduction) { CrossProduction = val_crossproduction; } - -inline su2double CSourcePieceWise_TurbSA_E::GetProduction(void) { return Production; } - -inline su2double CSourcePieceWise_TurbSA_E::GetDestruction(void) { return Destruction; } - -inline su2double CSourcePieceWise_TurbSA_E::GetCrossProduction(void) { return CrossProduction; } - -inline void CSourcePieceWise_TurbSA_E_COMP::SetIntermittency(su2double intermittency_in) { intermittency = intermittency_in; } - -inline void CSourcePieceWise_TurbSA_E_COMP::SetProduction(su2double val_production) { Production = val_production; } - -inline void CSourcePieceWise_TurbSA_E_COMP::SetDestruction(su2double val_destruction) { Destruction = val_destruction; } - -inline void CSourcePieceWise_TurbSA_E_COMP::SetCrossProduction(su2double val_crossproduction) { CrossProduction = val_crossproduction; } - -inline su2double CSourcePieceWise_TurbSA_E_COMP::GetProduction(void) { return Production; } - -inline su2double CSourcePieceWise_TurbSA_E_COMP::GetDestruction(void) { return Destruction; } - -inline su2double CSourcePieceWise_TurbSA_E_COMP::GetCrossProduction(void) { return CrossProduction; } - -inline void CSourcePieceWise_TurbSA_COMP::SetIntermittency(su2double intermittency_in) { intermittency = intermittency_in; } - -inline void CSourcePieceWise_TurbSA_COMP::SetProduction(su2double val_production) { Production = val_production; } - -inline void CSourcePieceWise_TurbSA_COMP::SetDestruction(su2double val_destruction) { Destruction = val_destruction; } - -inline void CSourcePieceWise_TurbSA_COMP::SetCrossProduction(su2double val_crossproduction) { CrossProduction = val_crossproduction; } - -inline su2double CSourcePieceWise_TurbSA_COMP::GetProduction(void) { return Production; } - -inline su2double CSourcePieceWise_TurbSA_COMP::GetDestruction(void) { return Destruction; } - -inline su2double CSourcePieceWise_TurbSA_COMP::GetCrossProduction(void) { return CrossProduction; } - -inline void CSourcePieceWise_TurbSA_Neg::SetIntermittency(su2double intermittency_in) { intermittency = intermittency_in; } - -inline void CSourcePieceWise_TurbSA_Neg::SetProduction(su2double val_production) { Production = val_production; } - -inline void CSourcePieceWise_TurbSA_Neg::SetDestruction(su2double val_destruction) { Destruction = val_destruction; } - -inline void CSourcePieceWise_TurbSA_Neg::SetCrossProduction(su2double val_crossproduction) { CrossProduction = val_crossproduction; } - -inline su2double CSourcePieceWise_TurbSA_Neg::GetProduction(void) { return Production; } - -inline su2double CSourcePieceWise_TurbSA_Neg::GetDestruction(void) { return Destruction; } - -inline su2double CSourcePieceWise_TurbSA_Neg::GetCrossProduction(void) { return CrossProduction; } - -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, - su2double **val_Jacobian_j, su2double *val_Jacobian_muj, su2double ***val_Jacobian_gradj, CConfig *config) { } - -inline void CNumerics::SetTauWall(su2double val_tauwall_i, su2double val_tauwall_j) { } - -inline void CAvgGrad_Base::SetTauWall(su2double val_tauwall_i, su2double val_tauwall_j) { - TauWall_i = val_tauwall_i; - TauWall_j = val_tauwall_j; -} - -inline su2double CAvgGrad_Base::GetStressTensor(unsigned short iDim, unsigned short jDim) const { - return tau[iDim][jDim]; -} - -inline su2double CAvgGrad_Base::GetHeatFluxVector(unsigned short iDim) const { - return heat_flux_vector[iDim]; -} - -inline void CNumerics::SetUsing_UQ(bool val_using_uq) { using_uq = val_using_uq; } diff --git a/SU2_CFD/src/numerics_adjoint_mean.cpp b/SU2_CFD/src/numerics_adjoint_mean.cpp deleted file mode 100644 index beb0a038c31f..000000000000 --- a/SU2_CFD/src/numerics_adjoint_mean.cpp +++ /dev/null @@ -1,1598 +0,0 @@ -/*! - * \file numerics_adjoint_mean.cpp - * \brief This file contains the numerical methods for adjoint compressible flow. - * \author F. Palacios, T. Economon - * \version 7.0.1 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - - -#include "../include/numerics_structure.hpp" -#include - -CUpwRoe_AdjFlow::CUpwRoe_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_AdjFlow() == EULER_IMPLICIT); - grid_movement = config->GetGrid_Movement(); - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - Residual_Roe = new su2double [nVar]; - RoeVelocity = new su2double [nDim]; - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; - Lambda = new su2double [nVar]; - P_Tensor = new su2double* [nVar]; - invP_Tensor = new su2double* [nVar]; - ProjFlux_i = new su2double*[nVar]; - ProjFlux_j = new su2double*[nVar]; - Proj_ModJac_Tensor = new su2double*[nVar]; - for (iVar = 0; iVar < nVar; iVar++) { - P_Tensor[iVar] = new su2double [nVar]; - invP_Tensor[iVar] = new su2double [nVar]; - ProjFlux_i[iVar] = new su2double[nVar]; - ProjFlux_j[iVar] = new su2double[nVar]; - Proj_ModJac_Tensor[iVar] = new su2double[nVar]; - } - -} - -CUpwRoe_AdjFlow::~CUpwRoe_AdjFlow(void) { - - delete [] Residual_Roe; - delete [] RoeVelocity; - delete [] Velocity_i; - delete [] Velocity_j; - delete [] Lambda; - for (iVar = 0; iVar < nVar; iVar++) { - delete [] P_Tensor[iVar]; - delete [] invP_Tensor[iVar]; - delete [] ProjFlux_i[iVar]; - delete [] ProjFlux_j[iVar]; - delete [] Proj_ModJac_Tensor[iVar]; - } - delete [] P_Tensor; - delete [] invP_Tensor; - delete [] ProjFlux_i; - delete [] ProjFlux_j; - delete [] Proj_ModJac_Tensor; - -} - -void CUpwRoe_AdjFlow::ComputeResidual (su2double *val_residual_i, su2double *val_residual_j, su2double **val_Jacobian_ii, - su2double **val_Jacobian_ij, su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config) { - - /*--- Compute the area ---*/ - - area = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - area += Normal[iDim]*Normal[iDim]; - area = sqrt(area); - rarea = 1.0 / area; - - /*--- Components of the normal & unit normal vector of the current face ---*/ - - Sx = Normal[0]; - Sy = Normal[1]; - Sz = 0.0; if (nDim == 3) Sz = Normal[2]; - nx = Sx * rarea; - ny = Sy * rarea; - nz = Sz * rarea; - - /*--- Flow variable states at point i (left, _l) and j (right, _r)---*/ - - rho_l = V_i[nDim+2]; rho_r = V_j[nDim+2]; - u_l = V_i[1]; v_l = V_i[2]; w_l = 0.0; if (nDim == 3) w_l = V_i[3]; - u_r = V_j[1]; v_r = V_j[2]; w_r = 0.0; if (nDim == 3) w_r = V_j[3]; - h_l = V_i[nDim+3]; h_r = V_j[nDim+3]; - - /*--- One-half speed squared ---*/ - - q_l = ONE2 * ((u_l*u_l) + (v_l*v_l) + (w_l*w_l)); - q_r = ONE2 * ((u_r*u_r) + (v_r*v_r) + (w_r*w_r)); - - /*--- Projected velocity ---*/ - - Q_l = (u_l * Sx) + (v_l * Sy) + (w_l * Sz); - Q_r = (u_r * Sx) + (v_r * Sy) + (w_r * Sz); - - /*--- Mean adjoint variables ---*/ - - psi1 = ONE2 * (Psi_i[0] + Psi_j[0]); - psi2 = ONE2 * (Psi_i[1] + Psi_j[1]); - psi3 = ONE2 * (Psi_i[2] + Psi_j[2]); - psi4 = 0.0; if (nDim == 3) psi4 = ONE2 * (Psi_i[3] + Psi_j[3]); - psi5 = ONE2 * (Psi_i[nVar-1] + Psi_j[nVar-1]); - - /*--- Left state ---*/ - - l1psi = (Sx * psi2) + (Sy * psi3) + (Sz * psi4) + (Q_l * psi5); - l2psi = psi1 + (u_l * psi2) + (v_l * psi3) + (w_l * psi4) + (h_l * psi5); - - val_residual_i[0] = Q_l * psi1 - l2psi * Q_l + l1psi * Gamma_Minus_One * q_l; - val_residual_i[1] = Q_l * psi2 + l2psi * Sx - l1psi * Gamma_Minus_One * u_l; - val_residual_i[2] = Q_l * psi3 + l2psi * Sy - l1psi * Gamma_Minus_One * v_l; - if (nDim == 3) val_residual_i[3] = Q_l * psi4 + l2psi * Sz - l1psi * Gamma_Minus_One * w_l; - val_residual_i[nVar-1] = Q_l * psi5 + l1psi * Gamma_Minus_One; - - /*--- Right state ---*/ - - l1psi = (Sx * psi2) + (Sy * psi3) + (Sz * psi4) + (Q_r * psi5); - l2psi = psi1 + (u_r * psi2) + (v_r * psi3) + (w_r * psi4) + (h_r * psi5); - - val_residual_j[0] = -(Q_r * psi1 - l2psi * Q_r + l1psi * Gamma_Minus_One * q_r); - val_residual_j[1] = -(Q_r * psi2 + l2psi * Sx - l1psi * Gamma_Minus_One * u_r); - val_residual_j[2] = -(Q_r * psi3 + l2psi * Sy - l1psi * Gamma_Minus_One * v_r); - if (nDim == 3) val_residual_j[3] = -(Q_r * psi4 + l2psi * Sz - l1psi * Gamma_Minus_One * w_r); - val_residual_j[nVar-1] = -(Q_r * psi5 + l1psi * Gamma_Minus_One); - - - /*--- f_{roe} = P^{-T} |lambda| P^T \delta \psi ---*/ - - psi1_l = Psi_i[0]; - psi2_l = Psi_i[1]; - psi3_l = Psi_i[2]; - psi4_l = 0.0; if (nDim == 3) psi4_l = Psi_i[3]; - psi5_l = Psi_i[nVar-1]; - - psi1_r = Psi_j[0]; - psi2_r = Psi_j[1]; - psi3_r = Psi_j[2]; - psi4_r = 0.0; if (nDim == 3) psi4_r = Psi_j[3]; - psi5_r = Psi_j[nVar-1]; - - /*--- Roe averaging ---*/ - - rrho_l = 1.0 / rho_l; - weight = sqrt(rho_r * rrho_l); - rweight1 = 1.0 / (1.0 + weight); - weight *= rweight1; - - h = h_l * rweight1 + weight * h_r; - u = u_l * rweight1 + weight * u_r; - v = v_l * rweight1 + weight * v_r; - w = w_l * rweight1 + weight * w_r; - - psi1 = ONE2 * (psi1_r - psi1_l); - psi2 = ONE2 * (psi2_r - psi2_l); - psi3 = ONE2 * (psi3_r - psi3_l); - psi4 = ONE2 * (psi4_r - psi4_l); - psi5 = ONE2 * (psi5_r - psi5_l); - - q2 = (u*u) + (v*v) + (w*w); - Q = (u * Sx) + (v * Sy) + (w * Sz); - vn = nx * u + ny * v + nz * w; - cc = Gamma_Minus_One * h - 0.5 * Gamma_Minus_One * q2; - c = sqrt(cc); - - /*--- Contribution to velocity projection due to grid movement ---*/ - - if (grid_movement) { - su2double ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - Q -= ProjGridVel; - } - - /*--- Eigenvalues from the primal solution ---*/ - - absQ = fabs(Q); - absQp = fabs(Q + c * area); - absQm = fabs(Q - c * area); - - alpha = ONE2 * Gamma_Minus_One * q2 / cc; - beta_u = psi2 + u * psi5; - beta_v = psi3 + v * psi5; - beta_w = psi4 + w * psi5; - eta = Gamma_Minus_One / cc; - l1psi = (nx * psi2) + (ny * psi3) + (nz * psi4) + (vn * psi5); - l2psi = psi1 + (u * psi2) + (v * psi3) + (w * psi4) + (h * psi5); - l1l2p = (l2psi + c * l1psi) * absQp; - l1l2m = (l2psi - c * l1psi) * absQm; - - /*--- adjoint flux computation in the x, y and z coordinate system ---*/ - - Residual_Roe[0] = ((1.0-alpha)*l2psi - (1.0-alpha)*cc/Gamma_Minus_One*psi5 - - u*beta_u*(1.0-(nx*nx)) - v*beta_v*(1.0-(ny*ny)) - - w*beta_w*(1.0-(nz*nz)) + ny*nz*(w*beta_v + v*beta_w) - + nx*nz*(w*beta_u + u*beta_w) + ny*nx*(v*beta_u + u*beta_v) ) * absQ - - ONE2 / c * vn * (l1l2p - l1l2m) + ONE2 * alpha * (l1l2p + l1l2m); - - Residual_Roe[1] = (l2psi*u*eta - u*psi5 + beta_u*(1.0-(nx*nx)) - - nx*(beta_v*ny + beta_w*nz) ) * absQ + ONE2*nx/c * (l1l2p - l1l2m ) - - ONE2*eta*u * (l1l2p + l1l2m ); - - Residual_Roe[2] = (l2psi*v*eta - v*psi5 + beta_v*(1.0-(ny*ny)) - - ny*(beta_w*nz + beta_u*nx) ) * absQ + ONE2*ny/c * (l1l2p - l1l2m ) - - ONE2*eta*v * (l1l2p + l1l2m ); - - if (nDim == 3) Residual_Roe[3] = (l2psi*w*eta - w*psi5 + beta_w*(1.0-(nz*nz)) - nz*(beta_u*nx + beta_v*ny) ) * absQ - + ONE2*nz/c * (l1l2p - l1l2m ) - ONE2*eta*w * (l1l2p + l1l2m ); - - Residual_Roe[nVar-1] = (psi5 - l2psi*eta) * absQ + ONE2*eta*(l1l2p + l1l2m); - - for (iVar = 0; iVar < nVar; iVar++) { - val_residual_i[iVar] += Residual_Roe[iVar]; - val_residual_j[iVar] -= Residual_Roe[iVar]; - } - - /*--- Flux contribution due to grid movement ---*/ - - if (grid_movement) { - su2double ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - for (iVar = 0; iVar < nVar; iVar++) { - val_residual_i[iVar] -= ProjGridVel * 0.5*(Psi_i[iVar]+Psi_j[iVar]); - val_residual_j[iVar] += ProjGridVel * 0.5*(Psi_i[iVar]+Psi_j[iVar]); - } - } - - /*--- Implicit Contributions ---*/ - - if (implicit) { - - /*--- Prepare variables for use in matrix routines ---*/ - - RoeDensity = V_i[nDim+2]*sqrt(V_j[nDim+2]/V_i[nDim+2]); - RoeSoundSpeed = c; - UnitNormal[0] = nx; UnitNormal[1] = ny; if (nDim == 3 ) UnitNormal[2] = nz; - RoeVelocity[0] = u; RoeVelocity[1] = v; if (nDim == 3 ) RoeVelocity[2] = w; - Velocity_i[0] = u_l; Velocity_i[1] = v_l; if (nDim == 3 ) Velocity_i[2] = w_l; - Velocity_j[0] = u_r; Velocity_j[1] = v_r; if (nDim == 3 ) Velocity_j[2] = w_r; - - Pressure_i = V_i[nDim+1]; - Density_i = V_i[nDim+2]; - Enthalpy_i = V_i[nDim+3]; - Energy_i = Enthalpy_i - Pressure_i/Density_i; - - Pressure_j = V_i[nDim+1]; - Density_j = V_i[nDim+2]; - Enthalpy_j = V_i[nDim+3]; - Energy_j = Enthalpy_j - Pressure_j/Density_j; - - /*--- Jacobians of the inviscid flux, scaled by - 0.5 because val_resconv ~ 0.5*(fc_i+fc_j)*Normal ---*/ - - GetInviscidProjJac(Velocity_i, &Energy_i, Normal, 0.5, ProjFlux_i); - GetInviscidProjJac(Velocity_j, &Energy_j, Normal, 0.5, ProjFlux_j); - - /*--- Compute P, inverse P, and store eigenvalues ---*/ - - GetPMatrix_inv(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, invP_Tensor); - GetPMatrix(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, P_Tensor); - - /*--- Flow eigenvalues ---*/ - - for (iDim = 0; iDim < nDim; iDim++) - Lambda[iDim] = absQ; - Lambda[nVar-2] = absQp; - Lambda[nVar-1] = absQm; - - /*--- Roe's Flux approximation ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - Proj_ModJac_Tensor_ij = 0.0; - - /*--- Compute |Proj_ModJac_Tensor| = P x |Lambda| x inverse P ---*/ - - for (kVar = 0; kVar < nVar; kVar++) - Proj_ModJac_Tensor_ij += P_Tensor[iVar][kVar]*Lambda[kVar]*invP_Tensor[kVar][jVar]; - Proj_ModJac_Tensor[iVar][jVar] = 0.5*Proj_ModJac_Tensor_ij*area; - } - } - - /*--- Transpose the matrices and store the Jacobians. Note the negative - sign for the ji and jj Jacobians bc the normal direction is flipped. ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - val_Jacobian_ii[jVar][iVar] = ProjFlux_i[iVar][jVar] - Proj_ModJac_Tensor[iVar][jVar]; - val_Jacobian_ij[jVar][iVar] = ProjFlux_i[iVar][jVar] + Proj_ModJac_Tensor[iVar][jVar]; - val_Jacobian_ji[jVar][iVar] = -(ProjFlux_j[iVar][jVar] - Proj_ModJac_Tensor[iVar][jVar]); - val_Jacobian_jj[jVar][iVar] = -(ProjFlux_j[iVar][jVar] + Proj_ModJac_Tensor[iVar][jVar]); - } - } - - /*--- Jacobian contribution due to grid movement ---*/ - - if (grid_movement) { - su2double ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - for (iVar = 0; iVar < nVar; iVar++) { - - /*--- Adjust Jacobian main diagonal ---*/ - - val_Jacobian_ii[iVar][iVar] -= 0.5*ProjGridVel; - val_Jacobian_ij[iVar][iVar] -= 0.5*ProjGridVel; - val_Jacobian_ji[iVar][iVar] += 0.5*ProjGridVel; - val_Jacobian_jj[iVar][iVar] += 0.5*ProjGridVel; - } - } - - } -} - -CCentJST_AdjFlow::CCentJST_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - grid_movement = config->GetGrid_Movement(); - - Diff_Psi = new su2double [nVar]; Diff_Lapl = new su2double [nVar]; - Velocity_i = new su2double [nDim]; Velocity_j = new su2double [nDim]; - MeanPhi = new su2double [nDim]; - - Param_p = 0.3; - Param_Kappa_2 = config->GetKappa_2nd_AdjFlow(); - Param_Kappa_4 = config->GetKappa_4th_AdjFlow(); - implicit = (config->GetKind_TimeIntScheme_AdjFlow() == EULER_IMPLICIT); - -} - -CCentJST_AdjFlow::~CCentJST_AdjFlow(void) { - - delete [] Diff_Psi; delete [] Diff_Lapl; - delete [] Velocity_i; delete [] Velocity_j; - delete [] MeanPhi; -} - -void CCentJST_AdjFlow::ComputeResidual (su2double *val_resconv_i, su2double *val_resvisc_i, su2double *val_resconv_j, su2double *val_resvisc_j, - su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, - CConfig *config) { - - /*--- Mean Values ---*/ - - MeanPsiRho = 0.5*(Psi_i[0]+Psi_j[0]); - for (iDim = 0; iDim < nDim; iDim++) - MeanPhi[iDim] = 0.5*(Psi_i[iDim+1]+Psi_j[iDim+1]); - MeanPsiE = 0.5*(Psi_i[nVar-1]+Psi_j[nVar-1]); - - /*--- Point i convective residual evaluation ---*/ - - ProjVelocity_i = 0; ProjPhi = 0; ProjPhi_Vel = 0; sq_vel = 0; Area = 0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = U_i[iDim+1] / U_i[0]; - ProjVelocity_i += Velocity_i[iDim]*Normal[iDim]; - ProjPhi += MeanPhi[iDim]*Normal[iDim]; - ProjPhi_Vel += MeanPhi[iDim]*Velocity_i[iDim]; - sq_vel += 0.5*Velocity_i[iDim]*Velocity_i[iDim]; - Area += Normal[iDim]*Normal[iDim]; - } - Area = sqrt(Area); - phis1 = ProjPhi + ProjVelocity_i*MeanPsiE; - phis2 = MeanPsiRho + ProjPhi_Vel + Enthalpy_i*MeanPsiE; - - val_resconv_i[0] = ProjVelocity_i*MeanPsiRho - phis2*ProjVelocity_i + Gamma_Minus_One*phis1*sq_vel; - for (iDim = 0; iDim < nDim; iDim++) - val_resconv_i[iDim+1] = ProjVelocity_i*MeanPhi[iDim] + phis2*Normal[iDim] - Gamma_Minus_One*phis1*Velocity_i[iDim]; - val_resconv_i[nVar-1] = ProjVelocity_i*MeanPsiE + Gamma_Minus_One*phis1; - - /*--- Flux contributions due to grid movement at point i ---*/ - - if (grid_movement) { - su2double ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - val_resconv_i[0] -= ProjGridVel*MeanPsiRho; - for (iDim = 0; iDim < nDim; iDim++) - val_resconv_i[iDim+1] -= ProjGridVel*MeanPhi[iDim]; - val_resconv_i[nVar-1] -= ProjGridVel*MeanPsiE; - } - - /*--- Jacobians of the inviscid flux ---*/ - - if (implicit) { - val_Jacobian_ii[0][0] = 0.0; - for (jDim = 0; jDim < nDim; jDim++) - val_Jacobian_ii[0][jDim+1] = -0.5*ProjVelocity_i*Velocity_i[jDim] + Gamma_Minus_One*sq_vel*0.5*Normal[jDim]; - val_Jacobian_ii[0][nVar-1] = 0.5*ProjVelocity_i*(Gamma_Minus_One*sq_vel - Enthalpy_i); - for (iDim = 0; iDim < nDim; iDim++) { - val_Jacobian_ii[iDim+1][0] = 0.5*Normal[iDim]; - for (jDim = 0; jDim < nDim; jDim++) - val_Jacobian_ii[iDim+1][jDim+1] = 0.5*Normal[iDim]*Velocity_i[jDim] - 0.5*Gamma_Minus_One*Velocity_i[iDim]*Normal[jDim]; - val_Jacobian_ii[iDim+1][iDim+1] += 0.5*ProjVelocity_i; - val_Jacobian_ii[iDim+1][nVar-1] = 0.5*Enthalpy_i*Normal[iDim] - 0.5*Gamma_Minus_One*Velocity_i[iDim]*ProjVelocity_i; - } - val_Jacobian_ii[nVar-1][0] = 0; - for (jDim = 0; jDim < nDim; jDim++) - val_Jacobian_ii[nVar-1][jDim+1] = 0.5*Gamma_Minus_One*Normal[jDim]; - val_Jacobian_ii[nVar-1][nVar-1] = 0.5*Gamma*ProjVelocity_i; - - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_ij[iVar][jVar] = val_Jacobian_ii[iVar][jVar]; - - /*--- Jacobian contributions due to grid movement at point i ---*/ - - if (grid_movement) { - su2double ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - for (iVar = 0; iVar < nVar; iVar++) { - val_Jacobian_ii[iVar][iVar] -= 0.5*ProjGridVel; - val_Jacobian_ij[iVar][iVar] -= 0.5*ProjGridVel; - } - } - } - - - /*--- Point j convective residual evaluation ---*/ - - ProjVelocity_j = 0; ProjPhi_Vel = 0; sq_vel = 0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_j[iDim] = U_j[iDim+1] / U_j[0]; - ProjVelocity_j += Velocity_j[iDim]*Normal[iDim]; - ProjPhi_Vel += MeanPhi[iDim]*Velocity_j[iDim]; - sq_vel += 0.5*Velocity_j[iDim]*Velocity_j[iDim]; - } - - phis1 = ProjPhi + ProjVelocity_j*MeanPsiE; - phis2 = MeanPsiRho + ProjPhi_Vel + Enthalpy_j*MeanPsiE; - - val_resconv_j[0] = -(ProjVelocity_j*MeanPsiRho - phis2*ProjVelocity_j + Gamma_Minus_One*phis1*sq_vel); - for (iDim = 0; iDim < nDim; iDim++) - val_resconv_j[iDim+1] = -(ProjVelocity_j*MeanPhi[iDim] + phis2*Normal[iDim] - Gamma_Minus_One*phis1*Velocity_j[iDim]); - val_resconv_j[nVar-1] = -(ProjVelocity_j*MeanPsiE + Gamma_Minus_One*phis1); - - /*--- Flux contributions due to grid motion at point j ---*/ - - if (grid_movement) { - su2double ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - val_resconv_j[0] += ProjGridVel*MeanPsiRho; - for (iDim = 0; iDim < nDim; iDim++) - val_resconv_j[iDim+1] += ProjGridVel*MeanPhi[iDim]; - val_resconv_j[nVar-1] += ProjGridVel*MeanPsiE; - } - - /*--- Jacobians of the inviscid flux ---*/ - - if (implicit) { - val_Jacobian_jj[0][0] = 0.0; - for (jDim = 0; jDim < nDim; jDim++) - val_Jacobian_jj[0][jDim+1] = 0.5*ProjVelocity_j*Velocity_j[jDim] - Gamma_Minus_One*sq_vel*0.5*Normal[jDim]; - val_Jacobian_jj[0][nVar-1] = -0.5*ProjVelocity_j*(Gamma_Minus_One*sq_vel - Enthalpy_j); - for (iDim = 0; iDim < nDim; iDim++) { - val_Jacobian_jj[iDim+1][0] = -0.5*Normal[iDim]; - for (jDim = 0; jDim < nDim; jDim++) - val_Jacobian_jj[iDim+1][jDim+1] = -0.5*Normal[iDim]*Velocity_j[jDim] + 0.5*Gamma_Minus_One*Velocity_j[iDim]*Normal[jDim]; - val_Jacobian_jj[iDim+1][iDim+1] -= 0.5*ProjVelocity_j; - val_Jacobian_jj[iDim+1][nVar-1] = -0.5*Enthalpy_j*Normal[iDim] + 0.5*Gamma_Minus_One*Velocity_j[iDim]*ProjVelocity_j; - } - val_Jacobian_jj[nVar-1][0] = 0; - for (jDim = 0; jDim < nDim; jDim++) - val_Jacobian_jj[nVar-1][jDim+1] = -0.5*Gamma_Minus_One*Normal[jDim]; - val_Jacobian_jj[nVar-1][nVar-1] = -0.5*Gamma*ProjVelocity_j; - - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_ji[iVar][jVar] = val_Jacobian_jj[iVar][jVar]; - - /*--- Jacobian contributions due to grid motion at point j ---*/ - - if (grid_movement) { - su2double ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - for (iVar = 0; iVar < nVar; iVar++) { - val_Jacobian_jj[iVar][iVar] += 0.5*ProjGridVel; - val_Jacobian_ji[iVar][iVar] += 0.5*ProjGridVel; - } - } - } - - /*--- Computes differences btw. variables and Laplacians ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - Diff_Lapl[iVar] = Und_Lapl_i[iVar]-Und_Lapl_j[iVar]; - Diff_Psi[iVar] = Psi_i[iVar]-Psi_j[iVar]; - } - - /*--- Adjustment to projected velocity due to grid motion ---*/ - - if (grid_movement) { - su2double ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - } - ProjVelocity_i -= ProjGridVel; - ProjVelocity_j += ProjGridVel; - } - - /*--- Compute the spectral radius and stretching factor ---*/ - - Local_Lambda_i = (fabs(ProjVelocity_i)+SoundSpeed_i*Area); - Local_Lambda_j = (fabs(ProjVelocity_j)+SoundSpeed_j*Area); - MeanLambda = 0.5*(Local_Lambda_i+Local_Lambda_j); - - Phi_i = pow(Lambda_i/(4.0*MeanLambda), Param_p); - Phi_j = pow(Lambda_j/(4.0*MeanLambda), Param_p); - StretchingFactor = 4.0*Phi_i*Phi_j/(Phi_i+Phi_j); - - su2double sc2 = 3.0*(su2double(Neighbor_i)+su2double(Neighbor_j))/(su2double(Neighbor_i)*su2double(Neighbor_j)); - sc4 = sc2*sc2/4.0; - Epsilon_2 = Param_Kappa_2*0.5*(Sensor_i+Sensor_j)*sc2; - Epsilon_4 = max(0.0, Param_Kappa_4-Epsilon_2)*sc4; - - /*--- Compute viscous residual 1st- & 3rd-order dissipation ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - Residual = (Epsilon_2*Diff_Psi[iVar]-Epsilon_4*Diff_Lapl[iVar])*StretchingFactor*MeanLambda; - val_resvisc_i[iVar] = -Residual; - val_resvisc_j[iVar] = Residual; - if (implicit) { - val_Jacobian_ii[iVar][iVar] -= Epsilon_2 + su2double(Neighbor_i+1)*Epsilon_4*StretchingFactor*MeanLambda; - val_Jacobian_ij[iVar][iVar] += Epsilon_2 + su2double(Neighbor_j+1)*Epsilon_4*StretchingFactor*MeanLambda; - val_Jacobian_ji[iVar][iVar] += Epsilon_2 + su2double(Neighbor_i+1)*Epsilon_4*StretchingFactor*MeanLambda; - val_Jacobian_jj[iVar][iVar] -= Epsilon_2 + su2double(Neighbor_j+1)*Epsilon_4*StretchingFactor*MeanLambda; - } - } - -} - -CCentLax_AdjFlow::CCentLax_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - Diff_Psi = new su2double [nVar]; MeanPhi = new su2double [nDim]; - Velocity_i = new su2double [nDim]; Velocity_j = new su2double [nDim]; - - implicit = (config->GetKind_TimeIntScheme_AdjFlow() == EULER_IMPLICIT); - - grid_movement = config->GetGrid_Movement(); - - Param_p = 0.3; - Param_Kappa_0 = config->GetKappa_1st_AdjFlow(); - -} - -CCentLax_AdjFlow::~CCentLax_AdjFlow(void) { - - delete [] Diff_Psi; delete [] MeanPhi; - delete [] Velocity_i; delete [] Velocity_j; - -} - -void CCentLax_AdjFlow::ComputeResidual (su2double *val_resconv_i, su2double *val_resvisc_i, su2double *val_resconv_j, su2double *val_resvisc_j, - su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, - CConfig *config) { - - /*--- Mean value of the adjoint variables ---*/ - MeanPsiRho = 0.5*(Psi_i[0]+Psi_j[0]); - for (iDim = 0; iDim < nDim; iDim++) - MeanPhi[iDim] = 0.5*(Psi_i[iDim+1]+Psi_j[iDim+1]); - MeanPsiE = 0.5*(Psi_i[nVar-1]+Psi_j[nVar-1]); - - /*--- Evaluation at point i ---*/ - ProjVelocity_i = 0; ProjPhi = 0; ProjPhi_Vel = 0; sq_vel = 0; Area = 0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = U_i[iDim+1] / U_i[0]; - ProjVelocity_i += Velocity_i[iDim]*Normal[iDim]; - ProjPhi += MeanPhi[iDim]*Normal[iDim]; - ProjPhi_Vel += MeanPhi[iDim]*Velocity_i[iDim]; - sq_vel += 0.5*Velocity_i[iDim]*Velocity_i[iDim]; - Area += Normal[iDim]*Normal[iDim]; - } - Area = sqrt(Area); - phis1 = ProjPhi + ProjVelocity_i*MeanPsiE; - phis2 = MeanPsiRho + ProjPhi_Vel + Enthalpy_i*MeanPsiE; - - /*--- Compute inviscid residual at point i ---*/ - val_resconv_i[0] = ProjVelocity_i*MeanPsiRho - phis2*ProjVelocity_i + Gamma_Minus_One*phis1*sq_vel; - for (iDim = 0; iDim < nDim; iDim++) - val_resconv_i[iDim+1] = ProjVelocity_i*MeanPhi[iDim] + phis2*Normal[iDim] - Gamma_Minus_One*phis1*Velocity_i[iDim]; - val_resconv_i[nVar-1] = ProjVelocity_i*MeanPsiE + Gamma_Minus_One*phis1; - - /*--- Flux contributions due to grid motion at point i ---*/ - if (grid_movement) { - su2double ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - val_resconv_i[0] -= ProjGridVel*MeanPsiRho; - for (iDim = 0; iDim < nDim; iDim++) - val_resconv_i[iDim+1] -= ProjGridVel*MeanPhi[iDim]; - val_resconv_i[nVar-1] -= ProjGridVel*MeanPsiE; - } - - /*--- Inviscid contribution to the implicit part ---*/ - if (implicit) { - val_Jacobian_ii[0][0] = 0.0; - for (jDim = 0; jDim < nDim; jDim++) - val_Jacobian_ii[0][jDim+1] = -0.5*ProjVelocity_i*Velocity_i[jDim] + Gamma_Minus_One*sq_vel*0.5*Normal[jDim]; - val_Jacobian_ii[0][nVar-1] = 0.5*ProjVelocity_i*(Gamma_Minus_One*sq_vel - Enthalpy_i); - for (iDim = 0; iDim < nDim; iDim++) { - val_Jacobian_ii[iDim+1][0] = 0.5*Normal[iDim]; - for (jDim = 0; jDim < nDim; jDim++) - val_Jacobian_ii[iDim+1][jDim+1] = 0.5*Normal[iDim]*Velocity_i[jDim] - 0.5*Gamma_Minus_One*Velocity_i[iDim]*Normal[jDim]; - val_Jacobian_ii[iDim+1][iDim+1] += 0.5*ProjVelocity_i; - val_Jacobian_ii[iDim+1][nVar-1] = 0.5*Enthalpy_i*Normal[iDim] - 0.5*Gamma_Minus_One*Velocity_i[iDim]*ProjVelocity_i; - } - val_Jacobian_ii[nVar-1][0] = 0; - for (jDim = 0; jDim < nDim; jDim++) - val_Jacobian_ii[nVar-1][jDim+1] = 0.5*Gamma_Minus_One*Normal[jDim]; - val_Jacobian_ii[nVar-1][nVar-1] = 0.5*Gamma*ProjVelocity_i; - - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_ij[iVar][jVar] = val_Jacobian_ii[iVar][jVar]; - - /*--- Jacobian contributions due to grid motion at point i ---*/ - if (grid_movement) { - su2double ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - for (iVar = 0; iVar < nVar; iVar++) { - val_Jacobian_ii[iVar][iVar] -= 0.5*ProjGridVel; - val_Jacobian_ij[iVar][iVar] -= 0.5*ProjGridVel; - } - } - } - - /*--- Evaluation at point j ---*/ - ProjVelocity_j = 0; ProjPhi_Vel = 0; sq_vel = 0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_j[iDim] = U_j[iDim+1] / U_j[0]; - ProjVelocity_j += Velocity_j[iDim]*Normal[iDim]; - ProjPhi_Vel += MeanPhi[iDim]*Velocity_j[iDim]; - sq_vel += 0.5*Velocity_j[iDim]*Velocity_j[iDim]; - } - - phis1 = ProjPhi + ProjVelocity_j*MeanPsiE; - phis2 = MeanPsiRho + ProjPhi_Vel + Enthalpy_j*MeanPsiE; - - /*--- Compute inviscid residual at point j ---*/ - val_resconv_j[0] = -(ProjVelocity_j*MeanPsiRho - phis2*ProjVelocity_j + Gamma_Minus_One*phis1*sq_vel); - for (iDim = 0; iDim < nDim; iDim++) - val_resconv_j[iDim+1] = -(ProjVelocity_j*MeanPhi[iDim] + phis2*Normal[iDim] - Gamma_Minus_One*phis1*Velocity_j[iDim]); - val_resconv_j[nVar-1] = -(ProjVelocity_j*MeanPsiE + Gamma_Minus_One*phis1); - - /*--- Flux contributions due to grid movement at point j ---*/ - if (grid_movement) { - su2double ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - val_resconv_j[0] += ProjGridVel*MeanPsiRho; - for (iDim = 0; iDim < nDim; iDim++) - val_resconv_j[iDim+1] += ProjGridVel*MeanPhi[iDim]; - val_resconv_j[nVar-1] += ProjGridVel*MeanPsiE; - } - - /*--- Inviscid contribution to the implicit part ---*/ - if (implicit) { - val_Jacobian_jj[0][0] = 0.0; - for (jDim = 0; jDim < nDim; jDim++) - val_Jacobian_jj[0][jDim+1] = 0.5*ProjVelocity_j*Velocity_j[jDim] - Gamma_Minus_One*sq_vel*0.5*Normal[jDim]; - val_Jacobian_jj[0][nVar-1] = -0.5*ProjVelocity_j*(Gamma_Minus_One*sq_vel - Enthalpy_j); - for (iDim = 0; iDim < nDim; iDim++) { - val_Jacobian_jj[iDim+1][0] = -0.5*Normal[iDim]; - for (jDim = 0; jDim < nDim; jDim++) - val_Jacobian_jj[iDim+1][jDim+1] = -0.5*Normal[iDim]*Velocity_j[jDim] + 0.5*Gamma_Minus_One*Velocity_j[iDim]*Normal[jDim]; - val_Jacobian_jj[iDim+1][iDim+1] -= 0.5*ProjVelocity_j; - val_Jacobian_jj[iDim+1][nVar-1] = -0.5*Enthalpy_j*Normal[iDim] + 0.5*Gamma_Minus_One*Velocity_j[iDim]*ProjVelocity_j; - } - val_Jacobian_jj[nVar-1][0] = 0; - for (jDim = 0; jDim < nDim; jDim++) - val_Jacobian_jj[nVar-1][jDim+1] = -0.5*Gamma_Minus_One*Normal[jDim]; - val_Jacobian_jj[nVar-1][nVar-1] = -0.5*Gamma*ProjVelocity_j; - - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_ji[iVar][jVar] = val_Jacobian_jj[iVar][jVar]; - - /*--- Jacobian contributions due to grid movement at point j ---*/ - if (grid_movement) { - su2double ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - for (iVar = 0; iVar < nVar; iVar++) { - val_Jacobian_jj[iVar][iVar] += 0.5*ProjGridVel; - val_Jacobian_ji[iVar][iVar] += 0.5*ProjGridVel; - } - } - } - - /*--- Computes differences btw. variables ---*/ - for (iVar = 0; iVar < nVar; iVar++) - Diff_Psi[iVar] = Psi_i[iVar]-Psi_j[iVar]; - - /*--- Adjustment to projected velocity due to grid motion ---*/ - if (grid_movement) { - su2double ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - ProjVelocity_i -= ProjGridVel; - ProjVelocity_j += ProjGridVel; - } - - /*--- Compute spectral radius ---*/ - Local_Lambda_i = (fabs(ProjVelocity_i)+SoundSpeed_i*Area); - Local_Lambda_j = (fabs(ProjVelocity_j)+SoundSpeed_j*Area); - MeanLambda = 0.5*(Local_Lambda_i+Local_Lambda_j); - - /*--- Compute streching factor ---*/ - Phi_i = pow(Lambda_i/(4.0*MeanLambda), Param_p); - Phi_j = pow(Lambda_j/(4.0*MeanLambda), Param_p); - StretchingFactor = 4.0*Phi_i*Phi_j/(Phi_i+Phi_j); - - sc2 = 3.0*(su2double(Neighbor_i)+su2double(Neighbor_j))/(su2double(Neighbor_i)*su2double(Neighbor_j)); - Epsilon_0 = Param_Kappa_0*sc2*su2double(nDim)/3.0; - - /*--- Artifical dissipation evaluation ---*/ - for (iVar = 0; iVar < nVar; iVar++) { - Residual = Epsilon_0*StretchingFactor*MeanLambda*Diff_Psi[iVar]; - val_resvisc_i[iVar] = -Residual; - val_resvisc_j[iVar] = Residual; - } - - /*--- Contribution to implicit part ---*/ - if (implicit) { - for (iVar = 0; iVar < nVar; iVar++) { - val_Jacobian_ii[iVar][iVar] -= Epsilon_0*StretchingFactor*MeanLambda; - val_Jacobian_ij[iVar][iVar] += Epsilon_0*StretchingFactor*MeanLambda; - val_Jacobian_ji[iVar][iVar] += Epsilon_0*StretchingFactor*MeanLambda; - val_Jacobian_jj[iVar][iVar] -= Epsilon_0*StretchingFactor*MeanLambda; - } - } - -} - -CAvgGrad_AdjFlow::CAvgGrad_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - unsigned short iDim; - - implicit = (config->GetKind_TimeIntScheme_AdjFlow() == EULER_IMPLICIT); - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; - Mean_Velocity = new su2double [nDim]; - Mean_GradPhi = new su2double* [nDim]; - for (iDim = 0; iDim < nDim; iDim++) - Mean_GradPhi[iDim] = new su2double [nDim]; - Mean_GradPsiE = new su2double [nDim]; - Edge_Vector = new su2double [nDim]; - -} - -CAvgGrad_AdjFlow::~CAvgGrad_AdjFlow(void) { - delete [] Velocity_i; - delete [] Velocity_j; - delete [] Mean_Velocity; - delete [] Edge_Vector; - delete [] Mean_GradPsiE; - for (unsigned short iDim = 0; iDim < nDim; iDim++) - delete [] Mean_GradPhi[iDim]; -} - -void CAvgGrad_AdjFlow::ComputeResidual(su2double *val_residual_i, su2double *val_residual_j, - su2double **val_Jacobian_ii, su2double **val_Jacobian_ij, - su2double **val_Jacobian_ji, su2double **val_Jacobian_jj, CConfig *config) { - unsigned short iDim, jDim; - su2double sq_vel_i, ViscDens_i, XiDens_i; - su2double sq_vel_j, ViscDens_j, XiDens_j; - su2double dist_ij_2, dPhiE_dn; - - su2double Prandtl_Lam = config->GetPrandtl_Lam(); - su2double Prandtl_Turb = config->GetPrandtl_Turb(); - - /*--- States in point i ---*/ - - sq_vel_i = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = V_i[iDim+1]; - sq_vel_i += 0.5*Velocity_i[iDim]*Velocity_i[iDim]; - } - Pressure_i = V_i[nDim+1]; - Density_i = V_i[nDim+2]; - Enthalpy_i = V_i[nDim+3]; - SoundSpeed_i = sqrt(fabs(Pressure_i*Gamma/Density_i)); - - /*--- Laminar and Eddy viscosity ---*/ - - Laminar_Viscosity_i = V_i[nDim+5]; - Eddy_Viscosity_i = V_i[nDim+6]; - - ViscDens_i = (Laminar_Viscosity_i + Eddy_Viscosity_i) / Density_i; - XiDens_i = Gamma*(Laminar_Viscosity_i/Prandtl_Lam + Eddy_Viscosity_i/Prandtl_Turb) / Density_i; - - /*--- States in point j ---*/ - - sq_vel_j = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_j[iDim] = V_j[iDim+1]; - sq_vel_j += 0.5*Velocity_j[iDim]*Velocity_j[iDim]; - } - Pressure_j = V_j[nDim+1]; - Density_j = V_j[nDim+2]; - Enthalpy_j = V_j[nDim+3]; - SoundSpeed_j = sqrt(fabs(Pressure_j*Gamma/Density_j)); - - /*--- Laminar and Eddy viscosity ---*/ - - Laminar_Viscosity_j = V_j[nDim+5]; - Eddy_Viscosity_j = V_j[nDim+6]; - - ViscDens_j = (Laminar_Viscosity_j + Eddy_Viscosity_j) / Density_j; - XiDens_j = Gamma*(Laminar_Viscosity_j/Prandtl_Lam + Eddy_Viscosity_j/Prandtl_Turb) / Density_j; - - /*--- Compute vector going from iPoint to jPoint ---*/ - - dist_ij_2 = 0.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]; - } - - /*--- Average of the derivatives of the adjoint variables ---*/ - - for (iDim = 0; iDim < nDim; iDim++) { - Mean_GradPsiE[iDim] = 0.5*(PsiVar_Grad_i[nVar-1][iDim]+PsiVar_Grad_j[nVar-1][iDim]); - for (jDim = 0; jDim < nDim; jDim++) - Mean_GradPhi[iDim][jDim] = 0.5*(PsiVar_Grad_i[iDim+1][jDim]+PsiVar_Grad_j[iDim+1][jDim]); - } - - dPhiE_dn = 0; - for (iDim = 0; iDim < nDim; iDim++) - dPhiE_dn += Mean_GradPsiE[iDim]*Normal[iDim]; - - /*--- Compute the viscous residual and jacobian ---*/ - - GetAdjViscousFlux_Jac(Pressure_i, Pressure_j, Density_i, Density_j, - ViscDens_i, ViscDens_j, Velocity_i, Velocity_j, sq_vel_i, sq_vel_j, - XiDens_i, XiDens_j, Mean_GradPhi, Mean_GradPsiE, - dPhiE_dn, Normal, Edge_Vector, dist_ij_2, val_residual_i, val_residual_j, - val_Jacobian_ii, val_Jacobian_ij, val_Jacobian_ji, val_Jacobian_jj, - implicit); - -} - -CAvgGradCorrected_AdjFlow::CAvgGradCorrected_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_AdjFlow() == EULER_IMPLICIT); - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; - Mean_Velocity = new su2double [nDim]; - - Mean_GradPsiVar = new su2double* [nVar]; - for (unsigned short iVar = 0; iVar < nVar; iVar++) - Mean_GradPsiVar[iVar] = new su2double [nDim]; - - Edge_Vector = new su2double [nDim]; - Proj_Mean_GradPsiVar_Edge = new su2double [nVar]; - - Mean_GradPhi = new su2double* [nDim]; - for (unsigned short iDim = 0; iDim < nDim; iDim++) - Mean_GradPhi[iDim] = new su2double [nDim]; - Mean_GradPsiE = new su2double [nDim]; - -} - -CAvgGradCorrected_AdjFlow::~CAvgGradCorrected_AdjFlow(void) { - - delete [] Velocity_i; - delete [] Velocity_j; - delete [] Mean_Velocity; - delete [] Edge_Vector; - delete [] Proj_Mean_GradPsiVar_Edge; - - for (unsigned short iVar = 0; iVar < nVar; iVar++) - delete [] Mean_GradPsiVar[iVar]; - delete [] Mean_GradPsiVar; - - for (unsigned short iDim = 0; iDim < nDim; iDim++) - delete [] Mean_GradPhi[iDim]; - delete [] Mean_GradPhi; - delete [] Mean_GradPsiE; - -} - -void CAvgGradCorrected_AdjFlow::ComputeResidual(su2double *val_residual_i, - su2double *val_residual_j, - su2double **val_Jacobian_ii, - su2double **val_Jacobian_ij, - su2double **val_Jacobian_ji, - su2double **val_Jacobian_jj, - CConfig *config) { - - unsigned short iVar, iDim, jDim; - su2double Density_i, sq_vel_i, Pressure_i, ViscDens_i, XiDens_i; - su2double Density_j, sq_vel_j, Pressure_j, ViscDens_j, XiDens_j; - su2double dist_ij_2, dPhiE_dn; - - su2double Prandtl_Lam = config->GetPrandtl_Lam(); - su2double Prandtl_Turb = config->GetPrandtl_Turb(); - - /*--- States in point i ---*/ - - sq_vel_i = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = V_i[iDim+1]; - sq_vel_i += 0.5*Velocity_i[iDim]*Velocity_i[iDim]; - } - Pressure_i = V_i[nDim+1]; - Density_i = V_i[nDim+2]; - Enthalpy_i = V_i[nDim+3]; - - /*--- Laminar and Eddy viscosity ---*/ - - Laminar_Viscosity_i = V_i[nDim+5]; - Eddy_Viscosity_i = V_i[nDim+6]; - - ViscDens_i = (Laminar_Viscosity_i + Eddy_Viscosity_i) / Density_i; - XiDens_i = Gamma*(Laminar_Viscosity_i/Prandtl_Lam + - Eddy_Viscosity_i/Prandtl_Turb) / Density_i; - - /*--- States in point j ---*/ - - sq_vel_j = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_j[iDim] = V_j[iDim+1]; - sq_vel_j += 0.5*Velocity_j[iDim]*Velocity_j[iDim]; - } - Pressure_j = V_j[nDim+1]; - Density_j = V_j[nDim+2]; - Enthalpy_j = V_j[nDim+3]; - - /*--- Laminar and Eddy viscosity ---*/ - - Laminar_Viscosity_j = V_j[nDim+5]; - Eddy_Viscosity_j = V_j[nDim+6]; - - ViscDens_j = (Laminar_Viscosity_j + Eddy_Viscosity_j) / Density_j; - XiDens_j = Gamma*(Laminar_Viscosity_j/Prandtl_Lam + - Eddy_Viscosity_j/Prandtl_Turb) / Density_j; - - /*--- Compute vector going from iPoint to jPoint ---*/ - - dist_ij_2 = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Mean_Velocity[iDim] = 0.5*(Velocity_i[iDim]+Velocity_j[iDim]); - Edge_Vector[iDim] = Coord_j[iDim]-Coord_i[iDim]; - dist_ij_2 += Edge_Vector[iDim]*Edge_Vector[iDim]; - } - - /*--- Mean gradient approximation. Projection of the mean gradient in the direction of the edge, weiss correction ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - Proj_Mean_GradPsiVar_Edge[iVar] = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Mean_GradPsiVar[iVar][iDim] = 0.5*(PsiVar_Grad_i[iVar][iDim] + PsiVar_Grad_j[iVar][iDim]); - Proj_Mean_GradPsiVar_Edge[iVar] += Mean_GradPsiVar[iVar][iDim]*Edge_Vector[iDim]; - } - for (iDim = 0; iDim < nDim; iDim++) - Mean_GradPsiVar[iVar][iDim] -= (Proj_Mean_GradPsiVar_Edge[iVar] - - (Psi_j[iVar]-Psi_i[iVar]))*Edge_Vector[iDim]/dist_ij_2; - } - - /*--- Average of the derivatives of the adjoint variables ---*/ - - for (iDim = 0; iDim < nDim; iDim++) { - Mean_GradPsiE[iDim] = Mean_GradPsiVar[nVar-1][iDim]; - for (jDim = 0; jDim < nDim; jDim++) - Mean_GradPhi[iDim][jDim] = Mean_GradPsiVar[iDim+1][jDim]; - } - - dPhiE_dn = 0; - for (iDim = 0; iDim < nDim; iDim++) - dPhiE_dn += Mean_GradPsiE[iDim]*Normal[iDim]; - - /*--- Compute the viscous residual and jacobian ---*/ - - GetAdjViscousFlux_Jac(Pressure_i, Pressure_j, Density_i, Density_j, - ViscDens_i, ViscDens_j, Velocity_i, Velocity_j, sq_vel_i, sq_vel_j, - XiDens_i, XiDens_j, Mean_GradPhi, Mean_GradPsiE, - dPhiE_dn, Normal, Edge_Vector, dist_ij_2, val_residual_i, val_residual_j, - val_Jacobian_ii, val_Jacobian_ij, val_Jacobian_ji, val_Jacobian_jj, - implicit); - -} - -CSourceViscous_AdjFlow::CSourceViscous_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - unsigned short iDim; - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - Velocity = new su2double [nVar]; - GradDensity = new su2double [nDim]; - GradInvDensity = new su2double [nDim]; - dPoDensity2 = new su2double [nDim]; - alpha = new su2double [nDim]; - beta = new su2double [nDim]; - Sigma_5_vec = new su2double [nDim]; - - GradVel_o_Rho = new su2double* [nDim]; - sigma = new su2double* [nDim]; - Sigma_phi = new su2double* [nDim]; - Sigma_5_Tensor = new su2double* [nDim]; - Sigma = new su2double* [nDim]; - - for (iDim = 0; iDim < nDim; iDim++) { - GradVel_o_Rho[iDim] = new su2double [nDim]; - sigma[iDim] = new su2double [nDim]; - Sigma_phi[iDim] = new su2double [nDim]; - Sigma_5_Tensor[iDim] = new su2double [nDim]; - Sigma[iDim] = new su2double [nDim]; - } - -} - -CSourceViscous_AdjFlow::~CSourceViscous_AdjFlow(void) { - unsigned short iDim; - - for (iDim = 0; iDim < nDim; iDim++) { - delete [] GradVel_o_Rho[iDim]; - delete [] sigma[iDim]; - delete [] Sigma_phi[iDim]; - delete [] Sigma_5_Tensor[iDim]; - delete [] Sigma[iDim]; - } - - delete [] GradVel_o_Rho; - delete [] sigma; - delete [] Sigma_phi; - delete [] Sigma_5_Tensor; - delete [] Sigma; - - delete [] Velocity; - delete [] GradDensity; - delete [] GradInvDensity; - delete [] dPoDensity2; - delete [] alpha; - delete [] beta; - delete [] Sigma_5_vec; - -} - -void CSourceViscous_AdjFlow::ComputeResidual (su2double *val_residual, CConfig *config) { - - unsigned short iDim, jDim; - -// su2double Temperature = V_i[0]; - su2double Pressure = V_i[nDim+1]; - su2double Density = V_i[nDim+2]; -// su2double Enthalpy = V_i[nDim+3]; - su2double Laminar_Viscosity = V_i[nDim+5]; - su2double Eddy_Viscosity = V_i[nDim+6]; - -// su2double Energy = Enthalpy - Pressure/Density; - su2double invDensity = 1.0/Density; - su2double invDensitysq = invDensity*invDensity; - su2double invDensitycube = invDensitysq*invDensity; - su2double Prandtl_Lam = config->GetPrandtl_Lam(); - su2double Prandtl_Turb = config->GetPrandtl_Turb(); - su2double mu_tot_1 = Laminar_Viscosity + Eddy_Viscosity; - su2double mu_tot_2 = Laminar_Viscosity/Prandtl_Lam + Eddy_Viscosity/Prandtl_Turb; -// su2double Gas_Constant = config->GetGas_ConstantND(); - - /*--- Required gradients of the flow variables, point j ---*/ - - for (iDim = 0; iDim < nDim; iDim++) { - - /*--- Gradient density ---*/ - - GradDensity[iDim] = PrimVar_Grad_i[nDim+2][iDim]; - - /*--- Gradient (1/rho) ---*/ - - GradInvDensity[iDim] = -GradDensity[iDim]*invDensitysq; - - /*--- Computation of the derivatives of P/(Density^2) ---*/ - - dPoDensity2[iDim] = (PrimVar_Grad_i[nVar-1][iDim]*Density - 2.0*GradDensity[iDim]*Pressure)*invDensitycube; - - /*--- Abbreviations: alpha, beta, sigma_5_vec ---*/ - - alpha[iDim] = Gamma*mu_tot_2*GradInvDensity[iDim]; - beta[iDim] = Gamma*mu_tot_2*dPoDensity2[iDim]/Gamma_Minus_One; - Sigma_5_vec[iDim] = Gamma*mu_tot_2*PsiVar_Grad_i[nVar-1][iDim]; - - } - - /*--- Definition of tensors and derivatives of velocity over density ---*/ - - su2double div_vel = 0.0, div_phi = 0.0, vel_gradpsi5 = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - div_vel += PrimVar_Grad_i[iDim+1][iDim]; - div_phi += PsiVar_Grad_i[iDim+1][iDim]; - vel_gradpsi5 += V_i[iDim+1]*PsiVar_Grad_i[nVar-1][iDim]; - for (jDim = 0; jDim < nDim; jDim++) { - sigma[iDim][jDim] = mu_tot_1*(PrimVar_Grad_i[iDim+1][jDim]+PrimVar_Grad_i[jDim+1][iDim]); - Sigma_phi[iDim][jDim] = mu_tot_1*(PsiVar_Grad_i[iDim+1][jDim]+PsiVar_Grad_i[jDim+1][iDim]); - Sigma_5_Tensor[iDim][jDim] = mu_tot_1*(V_i[jDim+1]*PsiVar_Grad_i[nVar-1][iDim]+V_i[iDim+1]*PsiVar_Grad_i[nVar-1][jDim]); - GradVel_o_Rho[iDim][jDim] = (PrimVar_Grad_i[iDim+1][jDim]*Density - V_i[iDim+1]*GradDensity[jDim])*invDensitysq; - } - } - - for (iDim = 0; iDim < nDim; iDim++) { - sigma[iDim][iDim] -= TWO3*mu_tot_1*div_vel; - Sigma_phi[iDim][iDim] -= TWO3*mu_tot_1*div_phi; - Sigma_5_Tensor[iDim][iDim] -= TWO3*mu_tot_1*vel_gradpsi5; - } - - for (iDim = 0; iDim < nDim; iDim++) { - for (jDim = 0; jDim < nDim; jDim++) { - Sigma[iDim][jDim] = Sigma_phi[iDim][jDim] + Sigma_5_Tensor[iDim][jDim]; - } - } - - /*--- Vector-Tensors products ---*/ - - su2double gradT_gradpsi5 = 0.0, sigma_gradpsi = 0.0, vel_sigma_gradpsi5 = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - gradT_gradpsi5 += PrimVar_Grad_i[0][iDim]*PsiVar_Grad_i[nVar-1][iDim]; - for (jDim = 0; jDim < nDim; jDim++) { - sigma_gradpsi += sigma[iDim][jDim]*PsiVar_Grad_i[jDim+1][iDim]; - vel_sigma_gradpsi5 += V_i[iDim+1]*sigma[iDim][jDim]*PsiVar_Grad_i[nVar-1][jDim]; - } - } - - /*--- Residuals ---*/ - - su2double alpha_gradpsi5 = 0.0, beta_gradpsi5 = 0.0, Sigma_gradvel_o_rho = 0.0, Sigma5_vel_gradvel = 0.0, sq_vel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - alpha_gradpsi5 += alpha[iDim]*PsiVar_Grad_i[nVar-1][iDim]; - beta_gradpsi5 += beta[iDim]*PsiVar_Grad_i[nVar-1][iDim]; - for (jDim = 0; jDim < nDim; jDim++) { - Sigma_gradvel_o_rho += Sigma[iDim][jDim]*GradVel_o_Rho[iDim][jDim]; - Sigma5_vel_gradvel += Sigma_5_vec[iDim]*(V_i[jDim+1]*PrimVar_Grad_i[jDim+1][iDim]); - } - sq_vel += V_i[iDim+1]*V_i[iDim+1]; - } - - val_residual[0] = (-vel_sigma_gradpsi5*invDensity + 0.5*sq_vel*alpha_gradpsi5 - - beta_gradpsi5) * Volume; - for (iDim = 0; iDim < nDim; iDim++) { - val_residual[iDim+1] = 0.0; - for (jDim = 0; jDim < nDim; jDim++) { - val_residual[iDim+1] += (sigma[iDim][jDim]*PsiVar_Grad_i[nVar-1][jDim]*invDensity - V_i[iDim+1]*alpha[jDim]*PsiVar_Grad_i[nVar-1][jDim]) * Volume; - } - } - val_residual[nVar-1] = alpha_gradpsi5 * Volume; - -// val_residual[0] += (Sigma5_vel_gradvel*invDensity - Sigma_gradvel_o_rho) * Volume; -// for (iDim = 0; iDim < nDim; iDim++) { -// for (jDim = 0; jDim < nDim; jDim++) { -// val_residual[iDim+1] += (Sigma[iDim][jDim]*GradInvDensity[jDim] - -// Sigma_5_vec[jDim]*PrimVar_Grad_i[iDim+1][jDim]*invDensity) * Volume; -// } -// } - - /*--- Laminar viscosity sensitivity for NS ---*/ - - if (config->GetKind_Solver() != ADJ_RANS) { - -// su2double Temperature_Ref = config->GetTemperature_Ref(); -// su2double Temperature_Dim = Temperature*Temperature_Ref; -// -// su2double S = 0.0; -// if (config->GetSystemMeasurements() == SI) { S = 110.4; } -// if (config->GetSystemMeasurements() == US) { S = 198.72; } -// su2double dVisc_T = ((Laminar_Viscosity)/(2.0*Temperature_Dim*(Temperature_Dim + S)))*(Temperature_Dim + 3.0*S)*Temperature_Ref; -// -// su2double Cp = (Gamma/Gamma_Minus_One)*Gas_Constant; -// su2double kappa_psi = (sigma_gradpsi + vel_sigma_gradpsi5)/mu_tot_1; -// su2double theta = (kappa_psi + Cp/Prandtl_Lam*gradT_gradpsi5)*dVisc_T*Gamma_Minus_One/(Gas_Constant*Density); -// -// val_residual[0] += (theta*(sq_vel-Energy))*Volume; -// for (iDim = 0; iDim < nDim; iDim++) -// val_residual[iDim+1] -= theta*V_i[iDim+1]*Volume; -// val_residual[nVar-1] += theta*Volume; - - } - -// /*--- Coupling terms coming from the continuous adjoint turbulent equations ---*/ -// -// if ((config->GetKind_Solver() == ADJ_RANS) && (!config->GetFrozen_Visc_Cont())) { -// -// /*--- Closure constants ---*/ -// -// su2double cv1_3 = 7.1*7.1*7.1; -// su2double k2 = 0.41*0.41; -// su2double cb1 = 0.1355; -// su2double cw2 = 0.3; -// su2double cw3_6 = pow(2.0,6.0); -// su2double sigma = 2./3.; -// su2double cb2 = 0.622; -// su2double cw1 = cb1/k2+(1+cb2)/sigma; -// -// su2double nu, Ji, Ji_2, Ji_3, fv1; -// nu = Laminar_Viscosity/Density; -// Ji = TurbVar_i[0]/nu; -// Ji_2 = Ji*Ji; -// Ji_3 = Ji_2*Ji; -// fv1 = Ji_3/(Ji_3+cv1_3); -// -// /*--- Contributions due to variation of viscosities ---*/ -// -// su2double Temperature_Ref = config->GetTemperature_Ref(); -// su2double Temperature_Dim = Temperature*Temperature_Ref; -// -// su2double S = 0.0; -// if (config->GetSystemMeasurements() == SI) { S = 110.4; } -// if (config->GetSystemMeasurements() == US) { S = 198.72; } -// su2double dVisc_T = ((Laminar_Viscosity)/(2.0*Temperature_Dim*(Temperature_Dim + S)))*(Temperature_Dim + 3.0*S)*Temperature_Ref; -// -// su2double Cp = (Gamma/Gamma_Minus_One)*Gas_Constant; -// su2double kappa_psi = (sigma_gradpsi + vel_sigma_gradpsi5)/mu_tot_1 + Cp/Prandtl_Turb*gradT_gradpsi5; -// su2double cv1_const = 3.0*cv1_3/(Ji_3+cv1_3); -// su2double theta = (kappa_psi*(1.0-Eddy_Viscosity/Laminar_Viscosity*cv1_const) - -// Cp/Prandtl_Turb*gradT_gradpsi5*(1.0-Prandtl_Turb/Prandtl_Lam))*dVisc_T*Gamma_Minus_One/(Gas_Constant*Density); -// su2double xi = kappa_psi*(1.0+cv1_const)*Eddy_Viscosity/Density; -// -// val_residual[0] += (theta*(sq_vel-Energy) + xi)*Volume; -// for (iDim = 0; iDim < nDim; iDim++) -// val_residual[iDim+1] -= theta*V_i[iDim+1]*Volume; -// val_residual[nVar-1] += theta*Volume; -// -// /*--- Coupling residuals ---*/ -// -// if (dist_i > 0.0) { -// su2double fv2, Omega, Shat, dist_0_2, one_o_oneplusJifv1; -// su2double r, g, g_6, glim, fw; -// su2double dfw_g, dg_r, dr_nuhat, dr_Shat; -// su2double dShat_fv2, dfv2_fv1, dfv1_Ji, dJi_nu, dJi_nuhat, dfv2_Ji; -// -// /*--- Vorticity ---*/ -// Omega = (PrimVar_Grad_i[1][1]-PrimVar_Grad_i[2][0])*(PrimVar_Grad_i[1][1]-PrimVar_Grad_i[2][0]); -// if (nDim == 3) Omega += (PrimVar_Grad_i[1][2]-PrimVar_Grad_i[3][0])*(PrimVar_Grad_i[1][2]-PrimVar_Grad_i[3][0]) + -// (PrimVar_Grad_i[2][2]-PrimVar_Grad_i[3][1])*(PrimVar_Grad_i[2][2]-PrimVar_Grad_i[3][1]); -// Omega = sqrt(Omega); -// -// dist_0_2 = dist_i*dist_i; -// one_o_oneplusJifv1 = 1.0/(1.0+Ji*fv1); -// fv2 = 1.0 - Ji*one_o_oneplusJifv1; -// Shat = max(Omega + TurbVar_i[0]*fv2/(k2*dist_0_2), TURB_EPS); -// -// r = min(TurbVar_i[0]/(Shat*k2*dist_0_2), 10.); -// g = r + cw2*(pow(r,6.)-r); -// g_6 = pow(g,6.); -// glim = pow((1+cw3_6)/(g_6+cw3_6),1./6.); -// fw = g*glim; -// -// dfw_g = glim*cw3_6/(g_6+cw3_6); -// dg_r = 1.0 + cw2*(6.0*pow(r,5.0)-1.0); -// dr_nuhat = 1.0/(Shat*k2*dist_0_2); -// dr_Shat = -dr_nuhat*TurbVar_i[0]/Shat; -// -// dShat_fv2 = TurbVar_i[0]/(k2*dist_0_2); -// dfv2_fv1 = Ji_2*one_o_oneplusJifv1*one_o_oneplusJifv1; -// dfv1_Ji = 3.0*cv1_3*Ji_2/((Ji_3+cv1_3)*(Ji_3+cv1_3)); -// dJi_nuhat = 1.0/nu; -// dJi_nu = -Ji/nu; -// dfv2_Ji = -one_o_oneplusJifv1*one_o_oneplusJifv1; -// -// /*--- Terms 1 & 2: -Fcv\B7nabla(TurbPsi_i) - Fs\B7TurbPsi_i ---*/ -// -// su2double gradTurbVar_gradTurbPsi = 0, vel_gradTurbPsi = 0; -// for (iDim = 0; iDim < nDim; iDim++) { -// gradTurbVar_gradTurbPsi += TurbVar_Grad_i[0][iDim]*TurbPsi_Grad_i[0][iDim]; -// vel_gradTurbPsi += V_i[iDim+1]*TurbPsi_Grad_i[0][iDim]; -// } -// -// su2double alpha_coeff = Gamma_Minus_One/(Gas_Constant*Density)*dVisc_T; -// su2double beta_coeff = alpha_coeff*(sq_vel-Energy)-Laminar_Viscosity_i/Density; -// su2double Fs_coeff = TurbPsi_i[0]*(cb1*TurbVar_i[0]-cw1*TurbVar_i[0]*TurbVar_i[0]/dist_0_2*dfw_g*dg_r*dr_Shat)* -// dShat_fv2*(dfv2_Ji+dfv2_fv1*dfv1_Ji)*dJi_nu; -// su2double Gamma = Fs_coeff - gradTurbVar_gradTurbPsi/sigma; -// -// val_residual[0] -= (Gamma*beta_coeff - TurbVar_i[0]*vel_gradTurbPsi)/Density*Volume; -// for (iDim = 0; iDim < nDim; iDim++) -// val_residual[iDim+1] += (Gamma*alpha_coeff*V_i[iDim+1] - TurbVar_i[0]*TurbPsi_Grad_i[0][iDim])/Density*Volume; -// val_residual[nVar-1] -= (Gamma*alpha_coeff)/Density*Volume; -// -// // this should improve stability (when commented): -// /*--- Terms 3: -partial{T^s}_GradVel x GradN ---*/ -// // su2double Ms_coeff = (cb1*TurbVar_i[0]-cw1*TurbVar_i[0]*TurbVar_i[0]/dist_0_2*dfw_g*dg_r*dr_Shat); -// // Ms_coeff *= TurbPsi_i[0]/(Omega + TURB_EPS); -// // -// // for (iDim = 0; iDim < nDim; iDim++) { -// // for (jDim = 0; jDim < nDim; jDim++) { -// // val_residual[0] += Ms_coeff*(PrimVar_Grad_i[iDim+1][jDim]-PrimVar_Grad_i[jDim+1][iDim])* -// // GradVel_o_Rho[iDim][jDim]*dV; -// // val_residual[iDim+1] -= Ms_coeff*(PrimVar_Grad_i[iDim+1][jDim]-PrimVar_Grad_i[jDim+1][iDim])* -// // GradInvDensity[jDim]*dV; -// // } -// // } -// -// } -// } - -} - -CSourceConservative_AdjFlow::CSourceConservative_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - Velocity = new su2double [nDim]; - Residual_i = new su2double [nVar]; - Residual_j = new su2double [nVar]; - Mean_Residual = new su2double [nVar]; - - Mean_PrimVar_Grad = new su2double* [nVar]; - for (unsigned short iVar = 0; iVar < nVar; iVar++) - Mean_PrimVar_Grad[iVar] = new su2double [nDim]; -} - -CSourceConservative_AdjFlow::~CSourceConservative_AdjFlow(void) { - delete [] Mean_Residual; - delete [] Residual_j; - delete [] Residual_i; - delete [] Velocity; - - for (unsigned short iVar = 0; iVar < nVar; iVar++) - delete [] Mean_PrimVar_Grad[iVar]; - delete [] Mean_PrimVar_Grad; -} - -void CSourceConservative_AdjFlow::ComputeResidual (su2double *val_residual, CConfig *config) { - unsigned short iDim, jDim, iVar; - su2double rho, nu, Ji, fv1, fv2, Omega, Shat, dist_sq, Ji_2, Ji_3, one_o_oneplusJifv1; - su2double r, g, g_6, glim, dfw_g, dg_r, dr_nuhat, dr_Shat, Ms_coeff, invOmega; - - su2double cv1_3 = 7.1*7.1*7.1; - su2double k2 = 0.41*0.41; - su2double cb1 = 0.1355; - su2double cw2 = 0.3; - su2double cw3_6 = pow(2.0,6.0); - su2double sigma = 2./3.; - su2double cb2 = 0.622; - su2double cw1 = cb1/k2+(1+cb2)/sigma; - - for (iVar = 0; iVar < nVar; iVar++) { - Residual_i[iVar] = 0.0; - Residual_j[iVar] = 0.0; - } - - /*--- iPoint ---*/ - - /*--- Density and velocities ---*/ - - rho = U_i[0]; - for (iDim = 0; iDim < nDim; iDim++) - Velocity[iDim] = U_i[iDim+1]/rho; - - /*--- Vorticity ---*/ - - Omega = (PrimVar_Grad_i[1][1]-PrimVar_Grad_i[2][0])*(PrimVar_Grad_i[1][1]-PrimVar_Grad_i[2][0]); - if (nDim == 3) Omega += (PrimVar_Grad_i[1][2]-PrimVar_Grad_i[3][0])*(PrimVar_Grad_i[1][2]-PrimVar_Grad_i[3][0]) + - (PrimVar_Grad_i[2][2]-PrimVar_Grad_i[3][1])*(PrimVar_Grad_i[2][2]-PrimVar_Grad_i[3][1]); - Omega = sqrt(Omega); - invOmega = 1.0/(Omega + TURB_EPS); - - /*--- Compute Ms_coeff -> coming from partial derivatives ---*/ - - Ms_coeff = 0.0; - if (dist_i > 0) { - dist_sq = dist_i*dist_i; - nu = Laminar_Viscosity_i/rho; - Ji = TurbVar_i[0]/nu; - Ji_2 = Ji*Ji; - Ji_3 = Ji_2*Ji; - fv1 = Ji_3/(Ji_3+cv1_3); - one_o_oneplusJifv1 = 1.0/(1.0+Ji*fv1); - fv2 = 1.0 - Ji*one_o_oneplusJifv1; - Shat = max(Omega + TurbVar_i[0]*fv2/(k2*dist_sq), TURB_EPS); - - r = min(TurbVar_i[0]/(Shat*k2*dist_sq),10.); - g = r + cw2*(pow(r,6.)-r); - g_6 = pow(g,6.); - glim = pow((1+cw3_6)/(g_6+cw3_6),1./6.); - - dfw_g = glim*cw3_6/(g_6+cw3_6); - dg_r = 1.0 + cw2*(6.0*pow(r,5.0)-1.0); - dr_nuhat = 1.0/(Shat*k2*dist_sq); - dr_Shat = -dr_nuhat*TurbVar_i[0]/Shat; - - Ms_coeff = (cb1*TurbVar_i[0]-cw1*TurbVar_i[0]*TurbVar_i[0]/dist_sq*dfw_g*dg_r*dr_Shat); - } - Ms_coeff *= TurbPsi_i[0]*invOmega/rho; - - /*--- Compute residual of iPoint ---*/ - - for (iDim = 0; iDim < nDim; iDim++) { - for (jDim = 0; jDim < nDim; jDim++) { - Residual_i[0] -= Ms_coeff*(Velocity[jDim]*PrimVar_Grad_i[jDim+1][iDim]*Normal[iDim] - - Velocity[jDim]*PrimVar_Grad_i[iDim+1][jDim]*Normal[iDim]); - Residual_i[iDim+1] += Ms_coeff*(PrimVar_Grad_i[iDim+1][jDim]*Normal[jDim] - - PrimVar_Grad_i[jDim+1][iDim]*Normal[jDim]); - } - } - - /*--- jPoint ---*/ - - /*--- Density and velocities ---*/ - - rho = U_j[0]; - for (iDim = 0; iDim < nDim; iDim++) - Velocity[iDim] = U_j[iDim+1]/rho; - - /*--- Vorticity ---*/ - - Omega = (PrimVar_Grad_j[1][1]-PrimVar_Grad_j[2][0])*(PrimVar_Grad_j[1][1]-PrimVar_Grad_j[2][0]); - if (nDim == 3) Omega += (PrimVar_Grad_j[1][2]-PrimVar_Grad_j[3][0])*(PrimVar_Grad_j[1][2]-PrimVar_Grad_j[3][0]) + - (PrimVar_Grad_j[2][2]-PrimVar_Grad_j[3][1])*(PrimVar_Grad_j[2][2]-PrimVar_Grad_j[3][1]); - Omega = sqrt(Omega); - invOmega = 1.0/(Omega + TURB_EPS); - - /*--- Compute Ms_coeff -> coming from partial derivatives ---*/ - - Ms_coeff = 0.0; - if (dist_j > 0) { - dist_sq = dist_j*dist_j; - nu = Laminar_Viscosity_j/rho; - Ji = TurbVar_j[0]/nu; - Ji_2 = Ji*Ji; - Ji_3 = Ji_2*Ji; - fv1 = Ji_3/(Ji_3+cv1_3); - one_o_oneplusJifv1 = 1.0/(1.0+Ji*fv1); - fv2 = 1.0 - Ji*one_o_oneplusJifv1; - Shat = max(Omega + TurbVar_j[0]*fv2/(k2*dist_sq), TURB_EPS); - - r = min(TurbVar_j[0]/(Shat*k2*dist_sq),10.); - g = r + cw2*(pow(r,6.)-r); - g_6 = pow(g,6.); - glim = pow((1+cw3_6)/(g_6+cw3_6),1./6.); - - dfw_g = glim*cw3_6/(g_6+cw3_6); - dg_r = 1.0 + cw2*(6.0*pow(r,5.0)-1.0); - dr_nuhat = 1.0/(Shat*k2*dist_sq); - dr_Shat = -dr_nuhat*TurbVar_j[0]/Shat; - - Ms_coeff = (cb1*TurbVar_j[0]-cw1*TurbVar_j[0]*TurbVar_j[0]/dist_sq*dfw_g*dg_r*dr_Shat); - } - Ms_coeff *= TurbPsi_j[0]*invOmega/rho; - - /*--- Compute residual of jPoint ---*/ - - for (iDim = 0; iDim < nDim; iDim++) { - for (jDim = 0; jDim < nDim; jDim++) { - Residual_j[0] -= Ms_coeff*(Velocity[jDim]*PrimVar_Grad_j[jDim+1][iDim]*Normal[iDim] - - Velocity[jDim]*PrimVar_Grad_j[iDim+1][jDim]*Normal[iDim]); - Residual_j[iDim+1] += Ms_coeff*(PrimVar_Grad_j[iDim+1][jDim]*Normal[jDim] - - PrimVar_Grad_j[jDim+1][iDim]*Normal[jDim]); - } - } - - /*--- Compute the mean residual ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_residual[iVar] = 0.5*(Residual_i[iVar] + Residual_j[iVar]); - -} - -CSourceRotatingFrame_AdjFlow::CSourceRotatingFrame_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { } - -CSourceRotatingFrame_AdjFlow::~CSourceRotatingFrame_AdjFlow(void) { } - -void CSourceRotatingFrame_AdjFlow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config) { - - unsigned short iDim, iVar, jVar; - su2double Omega[3] = {0,0,0}, Phi[3] = {0,0,0}; - bool implicit = (config->GetKind_TimeIntScheme_AdjFlow() == EULER_IMPLICIT); - - /*--- Retrieve the angular velocity vector from config. ---*/ - - for (iDim = 0; iDim < 3; iDim++){ - Omega[iDim] = config->GetRotation_Rate(iDim)/config->GetOmega_Ref(); - } - - /*--- Get the adjoint velocity vector at the current node. ---*/ - - for (iDim = 0; iDim < nDim; iDim++) - Phi[iDim] = Psi_i[iDim+1]; - - /*--- Compute the source term as the Jacobian of the rotating frame - source term multiplied by the adjoint state and the dual cell volume. ---*/ - - if (nDim == 2) { - val_residual[0] = 0.0; - val_residual[1] = Omega[2]*Phi[1]*Volume; - val_residual[2] = -Omega[2]*Phi[0]*Volume; - val_residual[3] = 0.0; - } else { - val_residual[0] = 0.0; - val_residual[1] = (Omega[2]*Phi[1] - Omega[1]*Phi[2])*Volume; - val_residual[2] = (Omega[0]*Phi[2] - Omega[2]*Phi[0])*Volume; - val_residual[3] = (Omega[1]*Phi[0] - Omega[0]*Phi[1])*Volume; - val_residual[4] = 0.0; - } - - /*--- Calculate the source term Jacobian ---*/ - - if (implicit) { - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_i[iVar][jVar] = 0.0; - if (nDim == 2) { - val_Jacobian_i[1][2] = Omega[2]*Volume; - val_Jacobian_i[2][1] = -Omega[2]*Volume; - } else { - val_Jacobian_i[1][2] = Omega[2]*Volume; - val_Jacobian_i[1][3] = -Omega[1]*Volume; - val_Jacobian_i[2][1] = -Omega[2]*Volume; - val_Jacobian_i[2][3] = Omega[0]*Volume; - val_Jacobian_i[3][1] = Omega[1]*Volume; - val_Jacobian_i[3][2] = -Omega[0]*Volume; - } - } - -} - -CSourceAxisymmetric_AdjFlow::CSourceAxisymmetric_AdjFlow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { } - -CSourceAxisymmetric_AdjFlow::~CSourceAxisymmetric_AdjFlow(void) { } - -void CSourceAxisymmetric_AdjFlow::ComputeResidual(su2double *val_residual, su2double **Jacobian_ii, CConfig *config) { - - su2double yinv; - su2double Jacobian_Axisymmetric[4][4]; - - if (Coord_i[1] > 0.0) yinv = 1.0/Coord_i[1]; - else yinv = 0.0; - - Jacobian_Axisymmetric[0][0] = 0; - Jacobian_Axisymmetric[0][1] = 0; - Jacobian_Axisymmetric[0][2] = 1.; - Jacobian_Axisymmetric[0][3] = 0; - - Jacobian_Axisymmetric[1][0] = -U_i[1]*U_i[2]/(U_i[0]*U_i[0]); - Jacobian_Axisymmetric[1][1] = U_i[2]/U_i[0]; - Jacobian_Axisymmetric[1][2] = U_i[1]/U_i[0]; - Jacobian_Axisymmetric[1][3] = 0; - - Jacobian_Axisymmetric[2][0] = -U_i[2]*U_i[2]/(U_i[0]*U_i[0]); - Jacobian_Axisymmetric[2][1] = 0; - Jacobian_Axisymmetric[2][2] = 2*U_i[2]/U_i[0]; - Jacobian_Axisymmetric[2][3] = 0; - - Jacobian_Axisymmetric[3][0] = -Gamma*U_i[2]*U_i[3]/(U_i[0]*U_i[0]) + (Gamma-1)*U_i[2]*(U_i[1]*U_i[1]+U_i[2]*U_i[2])/(U_i[0]*U_i[0]*U_i[0]); - Jacobian_Axisymmetric[3][1] = -(Gamma-1)*U_i[2]*U_i[1]/(U_i[0]*U_i[0]); - Jacobian_Axisymmetric[3][2] = Gamma*U_i[3]/U_i[0] - 1/2*(Gamma-1)*( (U_i[1]*U_i[1]+U_i[2]*U_i[2])/(U_i[0]*U_i[0]) + 2*U_i[2]*U_i[2]/(U_i[0]*U_i[0]) ); - Jacobian_Axisymmetric[3][3] = Gamma*U_i[2]/U_i[0]; - - for (int iVar=0; iVar<4; iVar++) - for (int jVar=0; jVar<4; jVar++) - Jacobian_Axisymmetric[iVar][jVar] *= yinv*Volume; - - /* -- Residual = transpose(Jacobian) * psi --*/ - for (int iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] = 0.0; - for (int jVar = 0; jVar < nVar; jVar++) { - val_residual[iVar] += Jacobian_Axisymmetric[jVar][iVar]*Psi_i[jVar]; - Jacobian_ii[iVar][jVar] = Jacobian_Axisymmetric[jVar][iVar]; - } - } -} diff --git a/SU2_CFD/src/numerics_direct_mean.cpp b/SU2_CFD/src/numerics_direct_mean.cpp deleted file mode 100644 index 828cd6883de5..000000000000 --- a/SU2_CFD/src/numerics_direct_mean.cpp +++ /dev/null @@ -1,5210 +0,0 @@ -/*! - * \file numerics_direct_mean.cpp - * \brief This file contains the numerical methods for compressible flow. - * \author F. Palacios, T. Economon - * \version 7.0.1 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - - -#include "../include/numerics_structure.hpp" -#include - -CCentBase_Flow::CCentBase_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : - CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ - dynamic_grid = config->GetDynamic_Grid(); - fix_factor = config->GetCent_Jac_Fix_Factor(); - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - /*--- Allocate required structures ---*/ - Diff_U = new su2double [nVar]; - Diff_Lapl = new su2double [nVar]; - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; - MeanVelocity = new su2double [nDim]; - ProjFlux = new su2double [nVar]; -} - -CCentBase_Flow::~CCentBase_Flow(void) { - delete [] Diff_U; - delete [] Diff_Lapl; - delete [] Velocity_i; - delete [] Velocity_j; - delete [] MeanVelocity; - delete [] ProjFlux; -} - -void CCentBase_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, - CConfig *config) { - - su2double U_i[5] = {0.0,0.0,0.0,0.0,0.0}, U_j[5] = {0.0,0.0,0.0,0.0,0.0}; - - bool preacc = SetPreaccInVars(); - - if (preacc) { - AD::SetPreaccIn(Normal, nDim); - AD::SetPreaccIn(V_i, nDim+5); AD::SetPreaccIn(V_j, nDim+5); - AD::SetPreaccIn(Lambda_i); AD::SetPreaccIn(Lambda_j); - if (dynamic_grid) { - AD::SetPreaccIn(GridVel_i, nDim); AD::SetPreaccIn(GridVel_j, nDim); - } - } - - /*--- Pressure, density, enthalpy, energy, and velocity at points i and j ---*/ - - Pressure_i = V_i[nDim+1]; Pressure_j = V_j[nDim+1]; - Density_i = V_i[nDim+2]; Density_j = V_j[nDim+2]; - Enthalpy_i = V_i[nDim+3]; Enthalpy_j = V_j[nDim+3]; - SoundSpeed_i = V_i[nDim+4]; SoundSpeed_j = V_j[nDim+4]; - Energy_i = Enthalpy_i - Pressure_i/Density_i; Energy_j = Enthalpy_j - Pressure_j/Density_j; - - sq_vel_i = 0.0; sq_vel_j = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = V_i[iDim+1]; - Velocity_j[iDim] = V_j[iDim+1]; - sq_vel_i += 0.5*Velocity_i[iDim]*Velocity_i[iDim]; - sq_vel_j += 0.5*Velocity_j[iDim]*Velocity_j[iDim]; - } - - /*--- Recompute conservative variables ---*/ - - U_i[0] = Density_i; U_j[0] = Density_j; - for (iDim = 0; iDim < nDim; iDim++) { - U_i[iDim+1] = Density_i*Velocity_i[iDim]; U_j[iDim+1] = Density_j*Velocity_j[iDim]; - } - U_i[nDim+1] = Density_i*Energy_i; U_j[nDim+1] = Density_j*Energy_j; - - /*--- Compute mean values of the variables ---*/ - - MeanDensity = 0.5*(Density_i+Density_j); - MeanPressure = 0.5*(Pressure_i+Pressure_j); - MeanEnthalpy = 0.5*(Enthalpy_i+Enthalpy_j); - for (iDim = 0; iDim < nDim; iDim++) - MeanVelocity[iDim] = 0.5*(Velocity_i[iDim]+Velocity_j[iDim]); - MeanEnergy = 0.5*(Energy_i+Energy_j); - - /*--- Get projected flux tensor ---*/ - - GetInviscidProjFlux(&MeanDensity, MeanVelocity, &MeanPressure, &MeanEnthalpy, Normal, ProjFlux); - - /*--- Residual of the inviscid flux ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_residual[iVar] = ProjFlux[iVar]; - - /*--- Jacobians of the inviscid flux, scale = 0.5 because val_residual ~ 0.5*(fc_i+fc_j)*Normal ---*/ - - if (implicit) { - GetInviscidProjJac(MeanVelocity, &MeanEnergy, Normal, 0.5, val_Jacobian_i); - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_j[iVar][jVar] = val_Jacobian_i[iVar][jVar]; - } - - /*--- Adjustment due to grid motion ---*/ - - if (dynamic_grid) { - ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] -= ProjGridVel * 0.5*(U_i[iVar] + U_j[iVar]); - if (implicit) { - val_Jacobian_i[iVar][iVar] -= 0.5*ProjGridVel; - val_Jacobian_j[iVar][iVar] -= 0.5*ProjGridVel; - } - } - } - - /*--- Compute the local spectral radius and the stretching factor ---*/ - - ProjVelocity_i = 0.0; ProjVelocity_j = 0.0; Area = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - ProjVelocity_i += Velocity_i[iDim]*Normal[iDim]; - ProjVelocity_j += Velocity_j[iDim]*Normal[iDim]; - Area += Normal[iDim]*Normal[iDim]; - } - Area = sqrt(Area); - - /*--- Adjustment due to mesh motion ---*/ - - if (dynamic_grid) { - ProjVelocity_i -= ProjGridVel; - ProjVelocity_j -= ProjGridVel; - } - - /*--- Dissipation term ---*/ - - Local_Lambda_i = (fabs(ProjVelocity_i)+SoundSpeed_i*Area); - Local_Lambda_j = (fabs(ProjVelocity_j)+SoundSpeed_j*Area); - MeanLambda = 0.5*(Local_Lambda_i+Local_Lambda_j); - - Phi_i = pow(Lambda_i/(4.0*MeanLambda), Param_p); - Phi_j = pow(Lambda_j/(4.0*MeanLambda), Param_p); - StretchingFactor = 4.0*Phi_i*Phi_j/(Phi_i+Phi_j); - - /*--- Compute differences btw. conservative variables, with a correction for enthalpy ---*/ - - for (iVar = 0; iVar < nVar-1; iVar++) { - Diff_U[iVar] = U_i[iVar]-U_j[iVar]; - } - Diff_U[nVar-1] = Density_i*Enthalpy_i-Density_j*Enthalpy_j; - - DissipationTerm(val_residual, val_Jacobian_i, val_Jacobian_j); - - if (preacc) { - AD::SetPreaccOut(val_residual, nVar); - AD::EndPreacc(); - } -} - -void CCentBase_Flow::ScalarDissipationJacobian(su2double **val_Jacobian_i, su2double **val_Jacobian_j) { - - /*--- n-1 diagonal entries ---*/ - - for (iVar = 0; iVar < (nVar-1); iVar++) { - val_Jacobian_i[iVar][iVar] += fix_factor*cte_0; - val_Jacobian_j[iVar][iVar] -= fix_factor*cte_1; - } - - /*--- Last row of Jacobian_i ---*/ - - val_Jacobian_i[nVar-1][0] += fix_factor*cte_0*Gamma_Minus_One*sq_vel_i; - for (iDim = 0; iDim < nDim; iDim++) - val_Jacobian_i[nVar-1][iDim+1] -= fix_factor*cte_0*Gamma_Minus_One*Velocity_i[iDim]; - val_Jacobian_i[nVar-1][nVar-1] += fix_factor*cte_0*Gamma; - - /*--- Last row of Jacobian_j ---*/ - - val_Jacobian_j[nVar-1][0] -= fix_factor*cte_1*Gamma_Minus_One*sq_vel_j; - for (iDim = 0; iDim < nDim; iDim++) - val_Jacobian_j[nVar-1][iDim+1] += fix_factor*cte_1*Gamma_Minus_One*Velocity_j[iDim]; - val_Jacobian_j[nVar-1][nVar-1] -= fix_factor*cte_1*Gamma; - -} - -CCentJST_Flow::CCentJST_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : - CCentBase_Flow(val_nDim, val_nVar, config) { - - /*--- Artifical dissipation parameters ---*/ - Param_p = 0.3; - Param_Kappa_2 = config->GetKappa_2nd_Flow(); - Param_Kappa_4 = config->GetKappa_4th_Flow(); - -} - -CCentJST_Flow::~CCentJST_Flow(void) { - -} - -void CCentJST_Flow::DissipationTerm(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j) { - - /*--- Compute differences btw. Laplacians ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - Diff_Lapl[iVar] = Und_Lapl_i[iVar]-Und_Lapl_j[iVar]; - } - - /*--- Compute dissipation coefficients ---*/ - - sc2 = 3.0*(su2double(Neighbor_i)+su2double(Neighbor_j))/(su2double(Neighbor_i)*su2double(Neighbor_j)); - sc4 = sc2*sc2/4.0; - - Epsilon_2 = Param_Kappa_2*0.5*(Sensor_i+Sensor_j)*sc2; - Epsilon_4 = max(0.0, Param_Kappa_4-Epsilon_2)*sc4; - - /*--- Compute viscous part of the residual ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_residual[iVar] += (Epsilon_2*Diff_U[iVar] - Epsilon_4*Diff_Lapl[iVar])*StretchingFactor*MeanLambda; - - /*--- Jacobian computation ---*/ - - if (implicit) { - - cte_0 = (Epsilon_2 + Epsilon_4*su2double(Neighbor_i+1))*StretchingFactor*MeanLambda; - cte_1 = (Epsilon_2 + Epsilon_4*su2double(Neighbor_j+1))*StretchingFactor*MeanLambda; - - ScalarDissipationJacobian(val_Jacobian_i, val_Jacobian_j); - } -} - -bool CCentJST_Flow::SetPreaccInVars(void) { - AD::StartPreacc(); - AD::SetPreaccIn(Sensor_i); AD::SetPreaccIn(Und_Lapl_i, nVar); - AD::SetPreaccIn(Sensor_j); AD::SetPreaccIn(Und_Lapl_j, nVar); - return true; -} - -CCentJST_KE_Flow::CCentJST_KE_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : - CCentBase_Flow(val_nDim, val_nVar, config) { - - /*--- Artifical dissipation parameters ---*/ - Param_p = 0.3; - Param_Kappa_2 = config->GetKappa_2nd_Flow(); - -} - -CCentJST_KE_Flow::~CCentJST_KE_Flow(void) { - -} - -void CCentJST_KE_Flow::DissipationTerm(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j) { - - /*--- Compute dissipation coefficient ---*/ - - sc2 = 3.0*(su2double(Neighbor_i)+su2double(Neighbor_j))/(su2double(Neighbor_i)*su2double(Neighbor_j)); - Epsilon_2 = Param_Kappa_2*0.5*(Sensor_i+Sensor_j)*sc2; - - /*--- Compute viscous part of the residual ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_residual[iVar] += Epsilon_2*(Diff_U[iVar])*StretchingFactor*MeanLambda; - - /*--- Jacobian computation ---*/ - - if (implicit) { - - cte_0 = Epsilon_2*StretchingFactor*MeanLambda; - cte_1 = cte_0; - - ScalarDissipationJacobian(val_Jacobian_i, val_Jacobian_j); - } -} - -bool CCentJST_KE_Flow::SetPreaccInVars(void) { - AD::StartPreacc(); - AD::SetPreaccIn(Sensor_i); AD::SetPreaccIn(Sensor_j); - return true; -} - -CCentLax_Flow::CCentLax_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : - CCentBase_Flow(val_nDim, val_nVar, config) { - - /*--- Artifical dissipation parameters ---*/ - Param_p = 0.3; - Param_Kappa_0 = config->GetKappa_1st_Flow(); - -} - -CCentLax_Flow::~CCentLax_Flow(void) { - -} - -void CCentLax_Flow::DissipationTerm(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j) { - - /*--- Compute dissipation coefficient ---*/ - - sc0 = 3.0*(su2double(Neighbor_i)+su2double(Neighbor_j))/(su2double(Neighbor_i)*su2double(Neighbor_j)); - Epsilon_0 = Param_Kappa_0*sc0*su2double(nDim)/3.0; - - /*--- Compute viscous part of the residual ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_residual[iVar] += Epsilon_0*Diff_U[iVar]*StretchingFactor*MeanLambda; - - /*--- Jacobian computation ---*/ - - if (implicit) { - - cte_0 = Epsilon_0*StretchingFactor*MeanLambda; - cte_1 = cte_0; - - ScalarDissipationJacobian(val_Jacobian_i, val_Jacobian_j); - } -} - -bool CCentLax_Flow::SetPreaccInVars(void) { - AD::StartPreacc(); - return true; -} - -CUpwCUSP_Flow::CUpwCUSP_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - if (config->GetDynamic_Grid() && (SU2_MPI::GetRank() == MASTER_NODE)) - cout << "WARNING: Grid velocities are NOT yet considered by the CUSP scheme." << endl; - - /*--- Allocate some structures ---*/ - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; - ProjFlux_i = new su2double [nVar]; - ProjFlux_j = new su2double [nVar]; -} - -CUpwCUSP_Flow::~CUpwCUSP_Flow(void) { - delete [] Velocity_i; - delete [] Velocity_j; - delete [] ProjFlux_i; - delete [] ProjFlux_j; -} - -void CUpwCUSP_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, - CConfig *config) { - - unsigned short iDim, iVar; - su2double Diff_U[5] = {0.0,0.0,0.0,0.0,0.0}; - - AD::SetPreaccIn(Normal, nDim); - AD::SetPreaccIn(V_i, nDim+4); - AD::SetPreaccIn(V_j, nDim+4); - - /*--- Pressure, density, enthalpy, energy, and velocity at points i and j ---*/ - - Pressure_i = V_i[nDim+1]; Pressure_j = V_j[nDim+1]; - Density_i = V_i[nDim+2]; Density_j = V_j[nDim+2]; - Enthalpy_i = V_i[nDim+3]; Enthalpy_j = V_j[nDim+3]; - su2double Energy_i = Enthalpy_i - Pressure_i/Density_i; - su2double Energy_j = Enthalpy_j - Pressure_j/Density_j; - - su2double sq_vel_i = 0.0, sq_vel_j = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = V_i[iDim+1]; - Velocity_j[iDim] = V_j[iDim+1]; - sq_vel_i += Velocity_i[iDim]*Velocity_i[iDim]; - sq_vel_j += Velocity_j[iDim]*Velocity_j[iDim]; - } - - /*-- Face area and unit normal ---*/ - - 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; - - /*--- Computes differences of conservative variables, with a correction for the enthalpy ---*/ - - Diff_U[0] = Density_i - Density_j; - for (iDim = 0; iDim < nDim; iDim++) - Diff_U[iDim+1] = Density_i*Velocity_i[iDim] - Density_j*Velocity_j[iDim]; - Diff_U[nVar-1] = Density_i*Enthalpy_i - Density_j*Enthalpy_j; - - /*--- Get left and right fluxes ---*/ - - GetInviscidProjFlux(&Density_i, Velocity_i, &Pressure_i, &Enthalpy_i, UnitNormal, ProjFlux_i); - GetInviscidProjFlux(&Density_j, Velocity_j, &Pressure_j, &Enthalpy_j, UnitNormal, ProjFlux_j); - - /*--- Compute dissipation parameters based on Roe-averaged values ---*/ - - su2double Beta, Nu_c; - - su2double R = sqrt(Density_j/Density_i), ProjVelocity = 0.0, sq_vel = 0.0; - - for (iDim = 0; iDim < nDim; iDim++) { - su2double MeanVel = (R*Velocity_j[iDim]+Velocity_i[iDim])/(R+1.0); - ProjVelocity += MeanVel*UnitNormal[iDim]; - sq_vel += MeanVel*MeanVel; - } - su2double MeanEnthalpy = (R*Enthalpy_j+Enthalpy_i)/(R+1.0); - su2double MeanSoundSpeed = sqrt(Gamma_Minus_One*fabs(MeanEnthalpy-0.5*sq_vel)); - - su2double Mach = ProjVelocity / MeanSoundSpeed; - - su2double tmp1 = 0.5*(Gamma+1.0)/Gamma*ProjVelocity; - su2double tmp2 = sqrt(pow(tmp1-ProjVelocity/Gamma, 2.0) + pow(MeanSoundSpeed,2.0)/Gamma); - su2double LamdaNeg = tmp1 - tmp2, LamdaPos = tmp1 + tmp2; - - if (fabs(Mach) >= 1.0) Beta = Mach/fabs(Mach); - else if (Mach >= 0.0) Beta = max(0.0, (ProjVelocity + LamdaNeg)/(ProjVelocity - LamdaNeg)); - else Beta =-max(0.0, (ProjVelocity + LamdaPos)/(ProjVelocity - LamdaPos)); - - if (fabs(Mach) >= 1.0) Nu_c = 0.0; - else { - if (Beta > 0.0) Nu_c =-(1.0+Beta)*LamdaNeg; - else if (Beta < 0.0) Nu_c = (1.0-Beta)*LamdaPos; - /*--- Limit the minimum scalar dissipation ---*/ - else Nu_c = max(fabs(ProjVelocity), config->GetEntropyFix_Coeff()*MeanSoundSpeed); - } - - /*--- Compute the residual ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_residual[iVar] = 0.5*((1.0+Beta)*ProjFlux_i[iVar] + (1.0-Beta)*ProjFlux_j[iVar] + Nu_c*Diff_U[iVar])*Area; - - /*--- Jacobian computation ---*/ - - if (implicit) { - - /*--- Flux average and difference contributions ---*/ - - GetInviscidProjJac(Velocity_i, &Energy_i, Normal, 0.5*(1.0+Beta), val_Jacobian_i); - GetInviscidProjJac(Velocity_j, &Energy_j, Normal, 0.5*(1.0-Beta), val_Jacobian_j); - - /*--- Solution difference (scalar dissipation) contribution ---*/ - - su2double cte_0 = 0.5*Nu_c*Area*config->GetCent_Jac_Fix_Factor(); - - /*--- n-1 diagonal entries ---*/ - - for (iVar = 0; iVar < (nVar-1); iVar++) { - val_Jacobian_i[iVar][iVar] += cte_0; - val_Jacobian_j[iVar][iVar] -= cte_0; - } - - /*--- Last rows ---*/ - - val_Jacobian_i[nVar-1][0] += cte_0*Gamma_Minus_One*0.5*sq_vel_i; - for (iDim = 0; iDim < nDim; iDim++) - val_Jacobian_i[nVar-1][iDim+1] -= cte_0*Gamma_Minus_One*Velocity_i[iDim]; - val_Jacobian_i[nVar-1][nVar-1] += cte_0*Gamma; - - val_Jacobian_j[nVar-1][0] -= cte_0*Gamma_Minus_One*0.5*sq_vel_j; - for (iDim = 0; iDim < nDim; iDim++) - val_Jacobian_j[nVar-1][iDim+1] += cte_0*Gamma_Minus_One*Velocity_j[iDim]; - val_Jacobian_j[nVar-1][nVar-1] -= cte_0*Gamma; - - } - - AD::SetPreaccOut(val_residual, nVar); - AD::EndPreacc(); -} - -CUpwAUSM_Flow::CUpwAUSM_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - if (config->GetDynamic_Grid() && (SU2_MPI::GetRank() == MASTER_NODE)) - cout << "WARNING: Grid velocities are NOT yet considered in AUSM-type schemes." << endl; - - implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - Diff_U = new su2double [nVar]; - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; - RoeVelocity = new su2double [nDim]; - delta_vel = new su2double [nDim]; - delta_wave = new su2double [nVar]; - ProjFlux_i = new su2double [nVar]; - ProjFlux_j = new su2double [nVar]; - Lambda = new su2double [nVar]; - Epsilon = new su2double [nVar]; - P_Tensor = new su2double* [nVar]; - invP_Tensor = new su2double* [nVar]; - for (iVar = 0; iVar < nVar; iVar++) { - P_Tensor[iVar] = new su2double [nVar]; - invP_Tensor[iVar] = new su2double [nVar]; - } -} - -CUpwAUSM_Flow::~CUpwAUSM_Flow(void) { - - delete [] Diff_U; - delete [] Velocity_i; - delete [] Velocity_j; - delete [] RoeVelocity; - delete [] delta_vel; - delete [] delta_wave; - delete [] ProjFlux_i; - delete [] ProjFlux_j; - delete [] Lambda; - delete [] Epsilon; - for (iVar = 0; iVar < nVar; iVar++) { - delete [] P_Tensor[iVar]; - delete [] invP_Tensor[iVar]; - } - delete [] P_Tensor; - delete [] invP_Tensor; - -} - -void CUpwAUSM_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - AD::StartPreacc(); - AD::SetPreaccIn(Normal, nDim); - AD::SetPreaccIn(V_i, nDim+4); - AD::SetPreaccIn(V_j, nDim+4); - - /*--- Face area (norm or the normal vector) ---*/ - Area = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - Area += Normal[iDim]*Normal[iDim]; - Area = sqrt(Area); - - /*-- Unit Normal ---*/ - for (iDim = 0; iDim < nDim; iDim++) - UnitNormal[iDim] = Normal[iDim]/Area; - - /*--- Primitive variables at point i ---*/ - sq_vel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = V_i[iDim+1]; - sq_vel += Velocity_i[iDim]*Velocity_i[iDim]; - } - Pressure_i = V_i[nDim+1]; - Density_i = V_i[nDim+2]; - Enthalpy_i = V_i[nDim+3]; - Energy_i = Enthalpy_i - Pressure_i/Density_i; - SoundSpeed_i = sqrt(fabs(Gamma*Gamma_Minus_One*(Energy_i-0.5*sq_vel))); - - /*--- Primitive variables at point j ---*/ - sq_vel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_j[iDim] = V_j[iDim+1]; - sq_vel += Velocity_j[iDim]*Velocity_j[iDim]; - } - Pressure_j = V_j[nDim+1]; - Density_j = V_j[nDim+2]; - Enthalpy_j = V_j[nDim+3]; - Energy_j = Enthalpy_j - Pressure_j/Density_j; - SoundSpeed_j = sqrt(fabs(Gamma*Gamma_Minus_One*(Energy_j-0.5*sq_vel))); - - /*--- Projected velocities ---*/ - ProjVelocity_i = 0.0; ProjVelocity_j = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - ProjVelocity_i += Velocity_i[iDim]*UnitNormal[iDim]; - ProjVelocity_j += Velocity_j[iDim]*UnitNormal[iDim]; - } - - mL = ProjVelocity_i/SoundSpeed_i; - mR = ProjVelocity_j/SoundSpeed_j; - - if (fabs(mL) <= 1.0) mLP = 0.25*(mL+1.0)*(mL+1.0); - else mLP = 0.5*(mL+fabs(mL)); - - if (fabs(mR) <= 1.0) mRM = -0.25*(mR-1.0)*(mR-1.0); - else mRM = 0.5*(mR-fabs(mR)); - - mF = mLP + mRM; - - if (fabs(mL) <= 1.0) pLP = 0.25*Pressure_i*(mL+1.0)*(mL+1.0)*(2.0-mL); - else pLP = 0.5*Pressure_i*(mL+fabs(mL))/mL; - - if (fabs(mR) <= 1.0) pRM = 0.25*Pressure_j*(mR-1.0)*(mR-1.0)*(2.0+mR); - else pRM = 0.5*Pressure_j*(mR-fabs(mR))/mR; - - pF = pLP + pRM; - Phi = fabs(mF); - - val_residual[0] = 0.5*(mF*((Density_i*SoundSpeed_i)+(Density_j*SoundSpeed_j))-Phi*((Density_j*SoundSpeed_j)-(Density_i*SoundSpeed_i))); - for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = 0.5*(mF*((Density_i*SoundSpeed_i*Velocity_i[iDim])+(Density_j*SoundSpeed_j*Velocity_j[iDim])) - -Phi*((Density_j*SoundSpeed_j*Velocity_j[iDim])-(Density_i*SoundSpeed_i*Velocity_i[iDim])))+UnitNormal[iDim]*pF; - val_residual[nVar-1] = 0.5*(mF*((Density_i*SoundSpeed_i*Enthalpy_i)+(Density_j*SoundSpeed_j*Enthalpy_j))-Phi*((Density_j*SoundSpeed_j*Enthalpy_j)-(Density_i*SoundSpeed_i*Enthalpy_i))); - - for (iVar = 0; iVar < nVar; iVar++) - val_residual[iVar] *= Area; - - AD::SetPreaccOut(val_residual, nVar); - AD::EndPreacc(); - - /*--- Roe's Jacobian for AUSM (this must be fixed) ---*/ - if (implicit) { - - /*--- Mean Roe variables iPoint and jPoint ---*/ - R = sqrt(fabs(Density_j/Density_i)); - RoeDensity = R*Density_i; - sq_vel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - RoeVelocity[iDim] = (R*Velocity_j[iDim]+Velocity_i[iDim])/(R+1); - sq_vel += RoeVelocity[iDim]*RoeVelocity[iDim]; - } - RoeEnthalpy = (R*Enthalpy_j+Enthalpy_i)/(R+1); - RoeSoundSpeed = sqrt(fabs((Gamma-1)*(RoeEnthalpy-0.5*sq_vel))); - - /*--- Compute P and Lambda (do it with the Normal) ---*/ - GetPMatrix(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, P_Tensor); - - ProjVelocity = 0.0; ProjVelocity_i = 0.0; ProjVelocity_j = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - ProjVelocity += RoeVelocity[iDim]*UnitNormal[iDim]; - ProjVelocity_i += Velocity_i[iDim]*UnitNormal[iDim]; - ProjVelocity_j += Velocity_j[iDim]*UnitNormal[iDim]; - } - - /*--- Flow eigenvalues and Entropy correctors ---*/ - for (iDim = 0; iDim < nDim; iDim++) - Lambda[iDim] = ProjVelocity; - Lambda[nVar-2] = ProjVelocity + RoeSoundSpeed; - Lambda[nVar-1] = ProjVelocity - RoeSoundSpeed; - - /*--- Compute inverse P ---*/ - GetPMatrix_inv(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, invP_Tensor); - - /*--- Jacobias of the inviscid flux, scale = 0.5 because val_residual ~ 0.5*(fc_i+fc_j)*Normal ---*/ - GetInviscidProjJac(Velocity_i, &Energy_i, Normal, 0.5, val_Jacobian_i); - GetInviscidProjJac(Velocity_j, &Energy_j, Normal, 0.5, val_Jacobian_j); - - /*--- Roe's Flux approximation ---*/ - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - Proj_ModJac_Tensor_ij = 0.0; - /*--- Compute |Proj_ModJac_Tensor| = P x |Lambda| x inverse P ---*/ - for (kVar = 0; kVar < nVar; kVar++) - Proj_ModJac_Tensor_ij += P_Tensor[iVar][kVar]*fabs(Lambda[kVar])*invP_Tensor[kVar][jVar]; - val_Jacobian_i[iVar][jVar] += 0.5*Proj_ModJac_Tensor_ij*Area; - val_Jacobian_j[iVar][jVar] -= 0.5*Proj_ModJac_Tensor_ij*Area; - } - } - } -} - -CUpwAUSMPLUS_SLAU_Base_Flow::CUpwAUSMPLUS_SLAU_Base_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : - CNumerics(val_nDim, val_nVar, config) { - - if (config->GetDynamic_Grid() && (SU2_MPI::GetRank() == MASTER_NODE)) - cout << "WARNING: Grid velocities are NOT yet considered in AUSM-type schemes." << endl; - - implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - UseAccurateJacobian = config->GetUse_Accurate_Jacobians(); - HasAnalyticalDerivatives = false; - FinDiffStep = 1e-4; - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; - psi_i = new su2double [nVar]; - psi_j = new su2double [nVar]; - - RoeVelocity = new su2double [nDim]; - Lambda = new su2double [nVar]; - Epsilon = new su2double [nVar]; - P_Tensor = new su2double* [nVar]; - invP_Tensor = new su2double* [nVar]; - for (unsigned short iVar = 0; iVar < nVar; iVar++) { - P_Tensor[iVar] = new su2double [nVar]; - invP_Tensor[iVar] = new su2double [nVar]; - } -} - -CUpwAUSMPLUS_SLAU_Base_Flow::~CUpwAUSMPLUS_SLAU_Base_Flow(void) { - - delete [] Velocity_i; - delete [] Velocity_j; - delete [] psi_i; - delete [] psi_j; - - delete [] RoeVelocity; - delete [] Lambda; - delete [] Epsilon; - for (unsigned short iVar = 0; iVar < nVar; iVar++) { - delete [] P_Tensor[iVar]; - delete [] invP_Tensor[iVar]; - } - delete [] P_Tensor; - delete [] invP_Tensor; - -} - -void CUpwAUSMPLUS_SLAU_Base_Flow::ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure) -{ - /*--- For schemes that fit in the general form of AUSM+up and SLAU schemes you can inherit from this class - and implement only the specifics, which should be the face mass flux (per unit area) and the face pressure. - For implicit solution methods this class can either approximate the flux Jacobians (using those of the Roe - scheme) or compute accurate ones. This is done either numerically, differentiating "mdot" and "pressure" - using 1st order finite differences, or analytically if you use this function to set the values of - "dmdot_dVi/j", "dpres_dVi/j" and set "HasAnalyticalDerivatives" to true in the ctor of the derived class. - For accurate numerical differentiation "mdot" and "pressure" can be functions of, at most, the velocities, - pressures, densities, and enthalpies at nodes i/j. This is also the order expected for the partial derivatives - of "mdot" and "pressure" in "d?_dVi/j" (in case they are known analytically, see the AUSM+up implementation). - ---*/ -} - -void CUpwAUSMPLUS_SLAU_Base_Flow::ApproximateJacobian(su2double **val_Jacobian_i, su2double **val_Jacobian_j) { - - unsigned short iDim, iVar, jVar, kVar; - su2double R, RoeDensity, RoeEnthalpy, RoeSoundSpeed, ProjVelocity, sq_vel, Energy_i, Energy_j; - - Energy_i = Enthalpy_i - Pressure_i/Density_i; - Energy_j = Enthalpy_j - Pressure_j/Density_j; - - /*--- Mean Roe variables iPoint and jPoint ---*/ - - R = sqrt(fabs(Density_j/Density_i)); - RoeDensity = R*Density_i; - ProjVelocity = 0.0; - sq_vel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - RoeVelocity[iDim] = (R*Velocity_j[iDim]+Velocity_i[iDim])/(R+1); - ProjVelocity += RoeVelocity[iDim]*UnitNormal[iDim]; - sq_vel += RoeVelocity[iDim]*RoeVelocity[iDim]; - } - RoeEnthalpy = (R*Enthalpy_j+Enthalpy_i)/(R+1); - RoeSoundSpeed = sqrt(fabs((Gamma-1)*(RoeEnthalpy-0.5*sq_vel))); - - /*--- Compute P and Lambda (do it with the Normal) ---*/ - - GetPMatrix(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, P_Tensor); - - /*--- Flow eigenvalues and Entropy correctors ---*/ - - for (iDim = 0; iDim < nDim; iDim++) - Lambda[iDim] = ProjVelocity; - Lambda[nVar-2] = ProjVelocity + RoeSoundSpeed; - Lambda[nVar-1] = ProjVelocity - RoeSoundSpeed; - - /*--- Compute inverse P ---*/ - GetPMatrix_inv(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, invP_Tensor); - - /*--- Jacobians of the inviscid flux, scale = 0.5 because val_residual ~ 0.5*(fc_i+fc_j)*Normal ---*/ - GetInviscidProjJac(Velocity_i, &Energy_i, Normal, 0.5, val_Jacobian_i); - GetInviscidProjJac(Velocity_j, &Energy_j, Normal, 0.5, val_Jacobian_j); - - /*--- Roe's Flux approximation ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - su2double Proj_ModJac_Tensor_ij = 0.0; - /*--- Compute |Proj_ModJac_Tensor| = P x |Lambda| x inverse P ---*/ - for (kVar = 0; kVar < nVar; kVar++) - Proj_ModJac_Tensor_ij += P_Tensor[iVar][kVar]*fabs(Lambda[kVar])*invP_Tensor[kVar][jVar]; - val_Jacobian_i[iVar][jVar] += 0.5*Proj_ModJac_Tensor_ij*Area; - val_Jacobian_j[iVar][jVar] -= 0.5*Proj_ModJac_Tensor_ij*Area; - } - } - -} - -void CUpwAUSMPLUS_SLAU_Base_Flow::AccurateJacobian(CConfig *config, su2double **val_Jacobian_i, su2double **val_Jacobian_j) { - - /*--- Compute Jacobians using a mixed (numerical/analytical) formulation ---*/ - - unsigned short iDim, iVar, jVar; - - /*--- If not computed analytically, numerically differentiate the fluxes wrt primitives ---*/ - - if (!HasAnalyticalDerivatives) { - - /*--- Create arrays of pointers to the primitive variables so - we can loop through and perturb them in a general way. ---*/ - - su2double *primitives_i[6], *primitives_j[6]; - - for (iDim = 0; iDim < nDim; ++iDim) { - primitives_i[iDim] = &Velocity_i[iDim]; - primitives_j[iDim] = &Velocity_j[iDim]; - } - primitives_i[ nDim ] = &Pressure_i; primitives_j[ nDim ] = &Pressure_j; - primitives_i[nDim+1] = &Density_i; primitives_j[nDim+1] = &Density_j; - primitives_i[nDim+2] = &Enthalpy_i; primitives_j[nDim+2] = &Enthalpy_j; - - /*--- Initialize the gradient arrays with the negative of the quantity, - then for forward finite differences we add to it and divide. ---*/ - - for (iVar = 0; iVar < 6; ++iVar) { - dmdot_dVi[iVar] = -MassFlux; dpres_dVi[iVar] = -Pressure; - dmdot_dVj[iVar] = -MassFlux; dpres_dVj[iVar] = -Pressure; - } - - for (iVar = 0; iVar < nDim+3; ++iVar) { - /*--- Perturb side i ---*/ - su2double epsilon = FinDiffStep * max(1.0, fabs(*primitives_i[iVar])); - *primitives_i[iVar] += epsilon; - ComputeMassAndPressureFluxes(config, MassFlux, Pressure); - dmdot_dVi[iVar] += MassFlux; dpres_dVi[iVar] += Pressure; - dmdot_dVi[iVar] /= epsilon; dpres_dVi[iVar] /= epsilon; - *primitives_i[iVar] -= epsilon; - - /*--- Perturb side j ---*/ - epsilon = FinDiffStep * max(1.0, fabs(*primitives_j[iVar])); - *primitives_j[iVar] += epsilon; - ComputeMassAndPressureFluxes(config, MassFlux, Pressure); - dmdot_dVj[iVar] += MassFlux; dpres_dVj[iVar] += Pressure; - dmdot_dVj[iVar] /= epsilon; dpres_dVj[iVar] /= epsilon; - *primitives_j[iVar] -= epsilon; - } - } - - /*--- Differentiation of fluxes wrt conservatives assuming ideal gas ---*/ - - su2double dmdot_dUi[5], dmdot_dUj[5], dpres_dUi[5], dpres_dUj[5]; - su2double sq_veli = 0.0, sq_velj = 0.0, dHi_drhoi = 0.0, dHj_drhoj = 0.0; - su2double oneOnRhoi = 1.0/Density_i, oneOnRhoj = 1.0/Density_j; - - for (jVar = 0; jVar < nVar; ++jVar) { - - /*--- Partial derivatives of the primitives wrt conservative "jVar" ---*/ - su2double dVi_dUi[6] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; - su2double dVj_dUj[6] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; - - if (jVar == 0) { // Density - for (iDim = 0; iDim < nDim; ++iDim) { - // -u,v,w / rho - dVi_dUi[iDim] = -Velocity_i[iDim] * oneOnRhoi; - dVj_dUj[iDim] = -Velocity_j[iDim] * oneOnRhoj; - // ||V||^2 - sq_veli += Velocity_i[iDim] * Velocity_i[iDim]; - sq_velj += Velocity_j[iDim] * Velocity_j[iDim]; - } - dVi_dUi[nDim] = 0.5*Gamma_Minus_One*sq_veli; - dVj_dUj[nDim] = 0.5*Gamma_Minus_One*sq_velj; - - dVi_dUi[nDim+1] = dVj_dUj[nDim+1] = 1.0; - - dHi_drhoi = 0.5*(Gamma-2.0)*sq_veli - Gamma*Pressure_i/((Gamma-1.0)*Density_i); - dHj_drhoj = 0.5*(Gamma-2.0)*sq_velj - Gamma*Pressure_j/((Gamma-1.0)*Density_j); - dVi_dUi[nDim+2] = dHi_drhoi * oneOnRhoi; - dVj_dUj[nDim+2] = dHj_drhoj * oneOnRhoj; - } - else if (jVar == nVar-1) { // rho*Energy - dVi_dUi[nDim] = dVj_dUj[nDim] = Gamma_Minus_One; - dVi_dUi[nDim+2] = Gamma * oneOnRhoi; - dVj_dUj[nDim+2] = Gamma * oneOnRhoj; - } - else { // Momentum - dVi_dUi[jVar-1] = oneOnRhoi; - dVj_dUj[jVar-1] = oneOnRhoj; - - dVi_dUi[nDim] = -Gamma_Minus_One*Velocity_i[jVar-1]; - dVj_dUj[nDim] = -Gamma_Minus_One*Velocity_j[jVar-1]; - - dVi_dUi[nDim+2] = dVi_dUi[nDim] * oneOnRhoi; - dVj_dUj[nDim+2] = dVj_dUj[nDim] * oneOnRhoj; - } - - /*--- Dot product to complete chain rule ---*/ - dmdot_dUi[jVar] = 0.0; dpres_dUi[jVar] = 0.0; - dmdot_dUj[jVar] = 0.0; dpres_dUj[jVar] = 0.0; - for (iVar = 0; iVar < 6; ++iVar) { - dmdot_dUi[jVar] += dmdot_dVi[iVar]*dVi_dUi[iVar]; - dpres_dUi[jVar] += dpres_dVi[iVar]*dVi_dUi[iVar]; - dmdot_dUj[jVar] += dmdot_dVj[iVar]*dVj_dUj[iVar]; - dpres_dUj[jVar] += dpres_dVj[iVar]*dVj_dUj[iVar]; - } - } - - /*--- Assemble final Jacobians (assuming phi = |mdot|) ---*/ - - su2double mdot_hat, psi_hat[5]; - - if (MassFlux > 0.0) { - mdot_hat = Area*MassFlux*oneOnRhoi; - for (iVar = 0; iVar < nVar; ++iVar) psi_hat[iVar] = Area*psi_i[iVar]; - } - else { - mdot_hat = Area*MassFlux*oneOnRhoj; - for (iVar = 0; iVar < nVar; ++iVar) psi_hat[iVar] = Area*psi_j[iVar]; - } - - /*--- Contribution from the mass flux derivatives ---*/ - for (iVar = 0; iVar < nVar; ++iVar) { - for (jVar = 0; jVar < nVar; ++jVar) { - val_Jacobian_i[iVar][jVar] = psi_hat[iVar] * dmdot_dUi[jVar]; - val_Jacobian_j[iVar][jVar] = psi_hat[iVar] * dmdot_dUj[jVar]; - } - } - - /*--- Contribution from the pressure derivatives ---*/ - for (iDim = 0; iDim < nDim; ++iDim) { - for (jVar = 0; jVar < nVar; ++jVar) { - val_Jacobian_i[iDim+1][jVar] += Normal[iDim] * dpres_dUi[jVar]; - val_Jacobian_j[iDim+1][jVar] += Normal[iDim] * dpres_dUj[jVar]; - } - } - - /*--- Contributions from the derivatives of PSI wrt the conservatives ---*/ - if (MassFlux > 0.0) { - /*--- Velocity terms ---*/ - for (iDim = 0; iDim < nDim; ++iDim) { - val_Jacobian_i[iDim+1][0] -= mdot_hat*Velocity_i[iDim]; - val_Jacobian_i[iDim+1][iDim+1] += mdot_hat; - val_Jacobian_i[nVar-1][iDim+1] -= mdot_hat*Gamma_Minus_One*Velocity_i[iDim]; - } - /*--- Energy terms ---*/ - val_Jacobian_i[nVar-1][0] += mdot_hat*dHi_drhoi; - val_Jacobian_i[nVar-1][nVar-1] += mdot_hat*Gamma; - } - else { - /*--- Velocity terms ---*/ - for (iDim = 0; iDim < nDim; ++iDim) { - val_Jacobian_j[iDim+1][0] -= mdot_hat*Velocity_j[iDim]; - val_Jacobian_j[iDim+1][iDim+1] += mdot_hat; - val_Jacobian_j[nVar-1][iDim+1] -= mdot_hat*Gamma_Minus_One*Velocity_j[iDim]; - } - /*--- Energy terms ---*/ - val_Jacobian_j[nVar-1][0] += mdot_hat*dHj_drhoj; - val_Jacobian_j[nVar-1][nVar-1] += mdot_hat*Gamma; - } - -} - -void CUpwAUSMPLUS_SLAU_Base_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - unsigned short iDim, iVar; - - /*--- Space to start preaccumulation ---*/ - - AD::StartPreacc(); - AD::SetPreaccIn(Normal, nDim); - AD::SetPreaccIn(V_i, nDim+4); - AD::SetPreaccIn(V_j, nDim+4); - - /*--- Variables for the general form and primitives for mass flux and pressure calculation. ---*/ - /*--- F_{1/2} = ||A|| ( 0.5 * mdot * (psi_i+psi_j) - 0.5 * |mdot| * (psi_i-psi_j) + N * pf ) ---*/ - - psi_i[0] = 1.0; psi_j[0] = 1.0; - - for (iDim = 0; iDim < nDim; iDim++) { - /*--- Velocities ---*/ - Velocity_i[iDim] = psi_i[iDim+1] = V_i[iDim+1]; - Velocity_j[iDim] = psi_j[iDim+1] = V_j[iDim+1]; - } - - /*--- Pressure and Density ---*/ - Pressure_i = V_i[nDim+1]; Pressure_j = V_j[nDim+1]; - Density_i = V_i[nDim+2]; Density_j = V_j[nDim+2]; - - /*--- Enthalpy ---*/ - Enthalpy_i = psi_i[nVar-1] = V_i[nDim+3]; - Enthalpy_j = psi_j[nVar-1] = V_j[nDim+3]; - - /*--- Face area (norm or the normal vector) ---*/ - - Area = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - Area += Normal[iDim]*Normal[iDim]; - Area = sqrt(Area); - - /*-- Unit Normal ---*/ - for (iDim = 0; iDim < nDim; iDim++) - UnitNormal[iDim] = Normal[iDim]/Area; - - /*--- Mass and pressure fluxes defined by derived classes ---*/ - - ComputeMassAndPressureFluxes(config, MassFlux, Pressure); - DissFlux = fabs(MassFlux); - - val_residual[0] = MassFlux; - - for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = 0.5*MassFlux*(psi_i[iDim+1]+psi_j[iDim+1]) + - 0.5*DissFlux*(psi_i[iDim+1]-psi_j[iDim+1]) + - UnitNormal[iDim]*Pressure; - - val_residual[nVar-1] = 0.5*MassFlux*(psi_i[nVar-1]+psi_j[nVar-1]) + - 0.5*DissFlux*(psi_i[nVar-1]-psi_j[nVar-1]); - - for (iVar = 0; iVar < nVar; iVar++) val_residual[iVar] *= Area; - - /*--- Space to end preaccumulation ---*/ - - AD::SetPreaccOut(val_residual, nVar); - AD::EndPreacc(); - - /*--- If required, compute Jacobians, either approximately (Roe) or numerically ---*/ - - if (!implicit) return; - - if (UseAccurateJacobian) - AccurateJacobian(config, val_Jacobian_i, val_Jacobian_j); - else - ApproximateJacobian(val_Jacobian_i, val_Jacobian_j); - -} - - -CUpwAUSMPLUSUP_Flow::CUpwAUSMPLUSUP_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : - CUpwAUSMPLUS_SLAU_Base_Flow(val_nDim, val_nVar, config) { - - HasAnalyticalDerivatives = true; - Minf = config->GetMach(); - 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) { - -} - -void CUpwAUSMPLUSUP_Flow::ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure) { - - /*--- Projected velocities ---*/ - - su2double ProjVelocity_i = 0.0, ProjVelocity_j = 0.0; - - for (unsigned short iDim = 0; iDim < nDim; iDim++) { - ProjVelocity_i += Velocity_i[iDim]*UnitNormal[iDim]; - ProjVelocity_j += Velocity_j[iDim]*UnitNormal[iDim]; - } - - /*--- Compute interface speed of sound (aF) ---*/ - - su2double astarL = sqrt(2.0*(Gamma-1.0)/(Gamma+1.0)*Enthalpy_i); - su2double astarR = sqrt(2.0*(Gamma-1.0)/(Gamma+1.0)*Enthalpy_j); - - su2double ahatL = astarL*astarL/max(astarL, ProjVelocity_i); - su2double ahatR = astarR*astarR/max(astarR,-ProjVelocity_j); - - su2double aF = min(ahatL,ahatR); - - /*--- Left and right pressures and Mach numbers ---*/ - - su2double mLP, betaLP, mRM, betaRM; - - su2double mL = ProjVelocity_i/aF; - su2double mR = ProjVelocity_j/aF; - - su2double MFsq = 0.5*(mL*mL+mR*mR); - su2double param1 = max(MFsq, Minf*Minf); - su2double Mrefsq = min(1.0, param1); - - su2double fa = 2.0*sqrt(Mrefsq)-Mrefsq; - - su2double alpha = 3.0/16.0*(-4.0+5.0*fa*fa); - su2double beta = 1.0/8.0; - - if (fabs(mL) <= 1.0) { - su2double p1 = 0.25*(mL+1.0)*(mL+1.0); - su2double p2 = (mL*mL-1.0)*(mL*mL-1.0); - - mLP = p1 + beta*p2; - betaLP = p1*(2.0-mL) + alpha*mL*p2; - } - else { - mLP = 0.5*(mL+fabs(mL)); - betaLP = mLP/mL; - } - - if (fabs(mR) <= 1.0) { - su2double p1 = 0.25*(mR-1.0)*(mR-1.0); - su2double p2 = (mR*mR-1.0)*(mR*mR-1.0); - - mRM = -p1 - beta*p2; - betaRM = p1*(2.0+mR) - alpha*mR*p2; - } - else { - mRM = 0.5*(mR-fabs(mR)); - betaRM = mRM/mR; - } - - /*--- Pressure and velocity diffusion terms ---*/ - - su2double rhoF = 0.5*(Density_i+Density_j); - su2double Mp = -(Kp/fa)*max((1.0-sigma*MFsq),0.0)*(Pressure_j-Pressure_i)/(rhoF*aF*aF); - - su2double Pu = -Ku*fa*betaLP*betaRM*2.0*rhoF*aF*(ProjVelocity_j-ProjVelocity_i); - - /*--- Finally the fluxes ---*/ - - su2double mF = mLP + mRM + Mp; - mdot = aF * (max(mF,0.0)*Density_i + min(mF,0.0)*Density_j); - - pressure = betaLP*Pressure_i + betaRM*Pressure_j + Pu; - - if (!implicit || !UseAccurateJacobian) return; - - /*--- Analytical differentiation of the face mass flux and - pressure (in reverse mode, "?_b" denotes dmot_d?). ---*/ - - /*--- limited mean Mach number (used in division...) ---*/ - su2double MF = max(numeric_limits::epsilon(),sqrt(MFsq)); - - for (int outVar=0; outVar<2; ++outVar) { - - su2double aF_b = 0.0, mF_b = 0.0, MF_b = 0.0, rhoF_b = 0.0, fa_b = 0.0, alpha_b = 0.0, - rho_i_b = 0.0, rho_j_b = 0.0, p_i_b = 0.0, p_j_b = 0.0, Vn_i_b = 0.0, Vn_j_b = 0.0, - mR_b = 0.0, mL_b = 0.0, betaLP_b = 0.0, betaRM_b = 0.0, tmp = 0.0; - - if (outVar==0) { - /*--- mdot = ... ---*/ - if (mF > 0.0) { - aF_b += mF*Density_i; - mF_b += aF*Density_i; - rho_i_b += mF*aF; - } - else { - aF_b += mF*Density_j; - mF_b += aF*Density_j; - rho_j_b += mF*aF; - } - - /*--- Mp = ... ---*/ - if (sigma*MFsq < 1.0) { - rhoF_b -= Mp/rhoF * mF_b; - fa_b -= Mp/fa * mF_b; - aF_b -= 2.0*Mp/aF * mF_b; - MF_b += 2.0*sigma*MF*(Kp/fa)*(Pressure_j-Pressure_i)/(rhoF*aF*aF) * mF_b; - tmp = -(Kp/fa)*(1.0-sigma*MFsq)/(rhoF*aF*aF); - p_i_b -= tmp * mF_b; - p_j_b += tmp * mF_b; - } - - /*--- rhoF = ... ---*/ - rho_i_b += 0.5*rhoF_b; rho_j_b += 0.5*rhoF_b; - - /*--- mRM = ... ---*/ - if (fabs(mR) < 1.0) mR_b += (1.0-mR)*(0.5+4.0*beta*mR*(mR+1.0)) * mF_b; - else if (mR <=-1.0) mR_b += mF_b; - - /*--- mLP = ... ---*/ - if (fabs(mL) < 1.0) mL_b += (1.0+mL)*(0.5+4.0*beta*mL*(mL-1.0)) * mF_b; - else if (mL >= 1.0) mL_b += mF_b; - } - else { - /*--- pressure = ... ---*/ - p_i_b += betaLP; betaLP_b += Pressure_i; - p_j_b += betaRM; betaRM_b += Pressure_j; - - /*--- Pu = ... ---*/ - rhoF_b += Pu/rhoF; - fa_b += Pu/fa; - aF_b += Pu/aF; - tmp = -Ku*fa*2.0*rhoF*aF*(ProjVelocity_j-ProjVelocity_i); - betaLP_b += tmp*betaRM; - betaRM_b += tmp*betaLP; - tmp = -Ku*fa*betaLP*betaRM*2.0*rhoF*aF; - Vn_i_b -= tmp; - Vn_j_b += tmp; - - /*--- rhoF = ... ---*/ - rho_i_b += 0.5*rhoF_b; rho_j_b += 0.5*rhoF_b; - - /*--- betaRM = ... ---*/ - if (fabs(mR) < 1.0) { - tmp = mR*mR-1.0; - mR_b += tmp*(0.75-alpha*(5.0*tmp+4.0)) * betaRM_b; - alpha_b -= mR*tmp*tmp * betaRM_b; - } - - /*--- betaLP = ... ---*/ - if (fabs(mL) < 1.0) { - tmp = mL*mL-1.0; - mL_b -= tmp*(0.75-alpha*(5.0*tmp+4.0)) * betaLP_b; - alpha_b += mL*tmp*tmp * betaLP_b; - } - - /*--- alpha = ... ---*/ - fa_b += 1.875*fa * alpha_b; - } - - /*--- steps shared by both ---*/ - /*--- fa = ... ---*/ - su2double Mref_b = 2.0*(1.0-sqrt(Mrefsq)) * fa_b; - - /*--- Mrefsq = ... ---*/ - if (MF < 1.0 && MF > Minf) MF_b += Mref_b; - - /*--- MFsq = ... ---*/ - mL_b += 0.5*mL/MF * MF_b; mR_b += 0.5*mR/MF * MF_b; - - /*--- mL/R = ... ---*/ - Vn_i_b += mL_b/aF; Vn_j_b += mR_b/aF; - aF_b -= (mL*mL_b+mR*mR_b)/aF; - - /*--- aF,ahat,astar = f(H_i,H_j) ---*/ - su2double astar_b = aF_b, H_i_b, H_j_b; - - if (ahatL < ahatR) { - if (astarL <= ProjVelocity_i) { - tmp = astarL/ProjVelocity_i; - astar_b *= 2.0*tmp; - Vn_i_b -= tmp*tmp * aF_b; - } - H_i_b = sqrt(0.5*(Gamma-1.0)/((Gamma+1.0)*Enthalpy_i)) * astar_b; - H_j_b = 0.0; - } - else { - if (astarR <= -ProjVelocity_j) { - tmp = -astarR/ProjVelocity_j; - astar_b *= 2.0*tmp; - Vn_j_b += tmp*tmp * aF_b; - } - H_j_b = sqrt(0.5*(Gamma-1.0)/((Gamma+1.0)*Enthalpy_j)) * astar_b; - H_i_b = 0.0; - } - - /*--- store derivatives ---*/ - su2double *target_i = (outVar==0 ? dmdot_dVi : dpres_dVi), - *target_j = (outVar==0 ? dmdot_dVj : dpres_dVj); - target_i[5] = target_j[5] = 0.0; - - /*--- ProjVelocity = ... ---*/ - for (unsigned short iDim = 0; iDim < nDim; ++iDim) { - target_i[iDim] = UnitNormal[iDim] * Vn_i_b; - target_j[iDim] = UnitNormal[iDim] * Vn_j_b; - } - target_i[ nDim ] = p_i_b; target_j[ nDim ] = p_j_b; - target_i[nDim+1] = rho_i_b; target_j[nDim+1] = rho_j_b; - target_i[nDim+2] = H_i_b; target_j[nDim+2] = H_j_b; - } -} - -CUpwAUSMPLUSUP2_Flow::CUpwAUSMPLUSUP2_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : - CUpwAUSMPLUS_SLAU_Base_Flow(val_nDim, val_nVar, config) { - - 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) { - -} - -void CUpwAUSMPLUSUP2_Flow::ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure) { - - /*--- Projected velocities and squared magnitude ---*/ - - su2double ProjVelocity_i = 0.0, ProjVelocity_j = 0.0, sq_vel = 0.0; - - for (unsigned short iDim = 0; iDim < nDim; iDim++) { - ProjVelocity_i += Velocity_i[iDim]*UnitNormal[iDim]; - ProjVelocity_j += Velocity_j[iDim]*UnitNormal[iDim]; - - sq_vel += 0.5*(Velocity_i[iDim]*Velocity_i[iDim] + Velocity_j[iDim]*Velocity_j[iDim]); - } - - /*--- Compute interface speed of sound (aF) ---*/ - - su2double astarL = sqrt(2.0*(Gamma-1.0)/(Gamma+1.0)*Enthalpy_i); - su2double astarR = sqrt(2.0*(Gamma-1.0)/(Gamma+1.0)*Enthalpy_j); - - su2double ahatL = astarL*astarL/max(astarL, ProjVelocity_i); - su2double ahatR = astarR*astarR/max(astarR,-ProjVelocity_j); - - su2double aF = min(ahatL,ahatR); - - /*--- Left and right pressure functions and Mach numbers ---*/ - - su2double mLP, pLP, mRM, pRM; - - su2double mL = ProjVelocity_i/aF; - su2double mR = ProjVelocity_j/aF; - - su2double MFsq = 0.5*(mL*mL+mR*mR); - su2double param1 = max(MFsq, Minf*Minf); - su2double Mrefsq = min(1.0, param1); - - su2double fa = 2.0*sqrt(Mrefsq)-Mrefsq; - - su2double alpha = 3.0/16.0*(-4.0+5.0*fa*fa); - su2double beta = 1.0/8.0; - - if (fabs(mL) <= 1.0) { - su2double p1 = 0.25*(mL+1.0)*(mL+1.0); - su2double p2 = (mL*mL-1.0)*(mL*mL-1.0); - - mLP = p1 + beta*p2; - pLP = p1*(2.0-mL) + alpha*mL*p2; - } - else { - mLP = 0.5*(mL+fabs(mL)); - pLP = mLP/mL; - } - - if (fabs(mR) <= 1.0) { - su2double p1 = 0.25*(mR-1.0)*(mR-1.0); - su2double p2 = (mR*mR-1.0)*(mR*mR-1.0); - - mRM = -p1 - beta*p2; - pRM = p1*(2.0+mR) - alpha*mR*p2; - } - else { - mRM = 0.5*(mR-fabs(mR)); - pRM = mRM/mR; - } - - /*--- Mass flux with pressure diffusion term ---*/ - - su2double rhoF = 0.5*(Density_i+Density_j); - su2double Mp = -(Kp/fa)*max((1.0-sigma*MFsq),0.0)*(Pressure_j-Pressure_i)/(rhoF*aF*aF); - - su2double mF = mLP + mRM + Mp; - mdot = aF * (max(mF,0.0)*Density_i + min(mF,0.0)*Density_j); - - /*--- Modified pressure flux ---*/ - - pressure = 0.5*(Pressure_j+Pressure_i) + 0.5*(pLP-pRM)*(Pressure_i-Pressure_j) + sqrt(sq_vel)*(pLP+pRM-1.0)*rhoF*aF; - -} - -CUpwSLAU_Flow::CUpwSLAU_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, bool val_low_dissipation) : - CUpwAUSMPLUS_SLAU_Base_Flow(val_nDim, val_nVar, config) { - - slau_low_diss = val_low_dissipation; - slau2 = false; -} - -CUpwSLAU_Flow::~CUpwSLAU_Flow(void) { - -} - -void CUpwSLAU_Flow::ComputeMassAndPressureFluxes(CConfig *config, su2double &mdot, su2double &pressure) { - - /*--- Project velocities and speed of sound ---*/ - - su2double ProjVelocity_i = 0.0, ProjVelocity_j = 0.0, sq_veli = 0.0, sq_velj = 0.0; - - for (unsigned short iDim = 0; iDim < nDim; iDim++) { - ProjVelocity_i += Velocity_i[iDim]*UnitNormal[iDim]; - ProjVelocity_j += Velocity_j[iDim]*UnitNormal[iDim]; - - sq_veli += Velocity_i[iDim]*Velocity_i[iDim]; - sq_velj += Velocity_j[iDim]*Velocity_j[iDim]; - } - - su2double Energy_i = Enthalpy_i - Pressure_i/Density_i; - SoundSpeed_i = sqrt(fabs(Gamma*Gamma_Minus_One*(Energy_i-0.5*sq_veli))); - - su2double Energy_j = Enthalpy_j - Pressure_j/Density_j; - SoundSpeed_j = sqrt(fabs(Gamma*Gamma_Minus_One*(Energy_j-0.5*sq_velj))); - - /*--- Compute interface speed of sound (aF), and left/right Mach number ---*/ - - su2double aF = 0.5 * (SoundSpeed_i + SoundSpeed_j); - su2double mL = ProjVelocity_i/aF; - su2double mR = ProjVelocity_j/aF; - - /*--- Smooth function of the local Mach number---*/ - - su2double Mach_tilde = min(1.0, (1.0/aF) * sqrt(0.5*(sq_veli+sq_velj))); - su2double Chi = pow((1.0 - Mach_tilde),2.0); - su2double f_rho = -max(min(mL,0.0),-1.0) * min(max(mR,0.0),1.0); - - /*--- Mean normal velocity with density weighting ---*/ - - su2double Vn_Mag = (Density_i*fabs(ProjVelocity_i) + Density_j*fabs(ProjVelocity_j)) / (Density_i + Density_j); - su2double Vn_MagL= (1.0 - f_rho)*Vn_Mag + f_rho*fabs(ProjVelocity_i); - su2double Vn_MagR= (1.0 - f_rho)*Vn_Mag + f_rho*fabs(ProjVelocity_j); - - /*--- Mass flux function ---*/ - - mdot = 0.5 * (Density_i*(ProjVelocity_i+Vn_MagL) + Density_j*(ProjVelocity_j-Vn_MagR) - (Chi/aF)*(Pressure_j-Pressure_i)); - - /*--- Pressure function ---*/ - - su2double BetaL, BetaR, Dissipation_ij; - - if (fabs(mL) < 1.0) BetaL = 0.25*(2.0-mL)*pow((mL+1.0),2.0); - else if (mL >= 0) BetaL = 1.0; - else BetaL = 0.0; - - if (fabs(mR) < 1.0) BetaR = 0.25*(2.0+mR)*pow((mR-1.0),2.0); - else if (mR >= 0) BetaR = 0.0; - else BetaR = 1.0; - - if (slau_low_diss) - SetRoe_Dissipation(Dissipation_i, Dissipation_j, Sensor_i, Sensor_j, Dissipation_ij, config); - else - Dissipation_ij = 1.0; - - pressure = 0.5*(Pressure_i+Pressure_j) + 0.5*(BetaL-BetaR)*(Pressure_i-Pressure_j); - - if (!slau2) pressure += Dissipation_ij*(1.0-Chi)*(BetaL+BetaR-1.0)*0.5*(Pressure_i+Pressure_j); - else pressure += Dissipation_ij*sqrt(0.5*(sq_veli+sq_velj))*(BetaL+BetaR-1.0)*aF*0.5*(Density_i+Density_j); - -} - -CUpwSLAU2_Flow::CUpwSLAU2_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, bool val_low_dissipation) : - CUpwSLAU_Flow(val_nDim, val_nVar, config, val_low_dissipation) { - - /*--- The difference between SLAU and SLAU2 is minimal, so we derive from SLAU and set this flag - so that the ComputeMassAndPressureFluxes function modifies the pressure according to SLAU2. - This is safe since this constructor is guaranteed to execute after SLAU's one. ---*/ - slau2 = true; -} - -CUpwSLAU2_Flow::~CUpwSLAU2_Flow(void) { - -} - -CUpwHLLC_Flow::CUpwHLLC_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - kappa = config->GetRoe_Kappa(); - /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ - dynamic_grid = config->GetDynamic_Grid(); - - Gamma = config->GetGamma(); - - Gamma_Minus_One = Gamma - 1.0; - - IntermediateState = new su2double [nVar]; - dSm_dU = new su2double [nVar]; - dPI_dU = new su2double [nVar]; - drhoStar_dU = new su2double [nVar]; - dpStar_dU = new su2double [nVar]; - dEStar_dU = new su2double [nVar]; - - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; - RoeVelocity = new su2double [nDim]; - -} - -CUpwHLLC_Flow::~CUpwHLLC_Flow(void) { - - delete [] IntermediateState; - delete [] dSm_dU; - delete [] dPI_dU; - delete [] drhoStar_dU; - delete [] dpStar_dU; - delete [] dEStar_dU; - - delete [] Velocity_i; - delete [] Velocity_j; - delete [] RoeVelocity; - -} - -void CUpwHLLC_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - /*--- Face area (norm or the normal vector) ---*/ - - Area = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - Area += Normal[iDim] * Normal[iDim]; - - Area = sqrt(Area); - - /*-- Unit Normal ---*/ - - for (iDim = 0; iDim < nDim; iDim++) - UnitNormal[iDim] = Normal[iDim] / Area; - - /*-- Fluid velocity at node i,j ---*/ - - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = V_i[iDim+1]; - Velocity_j[iDim] = V_j[iDim+1]; - } - - /*--- Primitive variables at point i ---*/ - - Pressure_i = V_i[nDim+1]; - Density_i = V_i[nDim+2]; - Enthalpy_i = V_i[nDim+3]; - - /*--- Primitive variables at point j ---*/ - - Pressure_j = V_j[nDim+1]; - Density_j = V_j[nDim+2]; - Enthalpy_j = V_j[nDim+3]; - - - sq_vel_i = 0.0; - sq_vel_j = 0.0; - - for (iDim = 0; iDim < nDim; iDim++) { - sq_vel_i += Velocity_i[iDim] * Velocity_i[iDim]; - sq_vel_j += Velocity_j[iDim] * Velocity_j[iDim]; - } - - Energy_i = Enthalpy_i - Pressure_i / Density_i; - Energy_j = Enthalpy_j - Pressure_j / Density_j; - - SoundSpeed_i = sqrt( (Enthalpy_i - 0.5 * sq_vel_i) * Gamma_Minus_One ); - SoundSpeed_j = sqrt( (Enthalpy_j - 0.5 * sq_vel_j) * Gamma_Minus_One ); - - /*--- Projected velocities ---*/ - - ProjVelocity_i = 0; - ProjVelocity_j = 0; - - for (iDim = 0; iDim < nDim; iDim++) { - ProjVelocity_i += Velocity_i[iDim] * UnitNormal[iDim]; - ProjVelocity_j += Velocity_j[iDim] * UnitNormal[iDim]; - } - - /*--- Projected Grid Velocity ---*/ - - ProjInterfaceVel = 0; - - if (dynamic_grid) { - - for (iDim = 0; iDim < nDim; iDim++) - ProjInterfaceVel += 0.5 * ( GridVel_i[iDim] + GridVel_j[iDim] )*UnitNormal[iDim]; - - SoundSpeed_i -= ProjInterfaceVel; - SoundSpeed_j += ProjInterfaceVel; - - ProjVelocity_i -= ProjInterfaceVel; - ProjVelocity_j -= ProjInterfaceVel; - } - - /*--- Roe's averaging ---*/ - - Rrho = ( sqrt(Density_i) + sqrt(Density_j) ); - - sq_velRoe = 0.0; - RoeProjVelocity = - ProjInterfaceVel; - - for (iDim = 0; iDim < nDim; iDim++) { - RoeVelocity[iDim] = ( Velocity_i[iDim] * sqrt(Density_i) + Velocity_j[iDim] * sqrt(Density_j) ) / Rrho; - sq_velRoe += RoeVelocity[iDim] * RoeVelocity[iDim]; - RoeProjVelocity += RoeVelocity[iDim] * UnitNormal[iDim]; - } - - /*--- Mean Roe variables iPoint and jPoint ---*/ - - RoeDensity = sqrt( Density_i * Density_j ); - RoeEnthalpy = ( sqrt(Density_j) * Enthalpy_j + sqrt(Density_i) * Enthalpy_i) / Rrho; - - /*--- Roe-averaged speed of sound ---*/ - - //RoeSoundSpeed2 = Gamma_Minus_One * ( RoeEnthalpy - 0.5 * sq_velRoe ); - RoeSoundSpeed = sqrt( Gamma_Minus_One * ( RoeEnthalpy - 0.5 * sq_velRoe ) ) - ProjInterfaceVel; - - - /*--- Speed of sound at L and R ---*/ - - sL = min( RoeProjVelocity - RoeSoundSpeed, ProjVelocity_i - SoundSpeed_i); - sR = max( RoeProjVelocity + RoeSoundSpeed, ProjVelocity_j + SoundSpeed_j); - - /*--- speed of contact surface ---*/ - - RHO = Density_j * (sR - ProjVelocity_j) - Density_i * (sL - ProjVelocity_i); - sM = ( Pressure_i - Pressure_j - Density_i * ProjVelocity_i * ( sL - ProjVelocity_i ) + Density_j * ProjVelocity_j * ( sR - ProjVelocity_j ) ) / RHO; - - /*--- Pressure at right and left (Pressure_j=Pressure_i) side of contact surface ---*/ - - pStar = Density_j * ( ProjVelocity_j - sR ) * ( ProjVelocity_j - sM ) + Pressure_j; - - -if (sM > 0.0) { - - if (sL > 0.0) { - - /*--- Compute Left Flux ---*/ - - val_residual[0] = Density_i * ProjVelocity_i; - for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = Density_i * Velocity_i[iDim] * ProjVelocity_i + Pressure_i * UnitNormal[iDim]; - val_residual[nVar-1] = Enthalpy_i * Density_i * ProjVelocity_i; - } - else { - - /*--- Compute Flux Left Star from Left Star State ---*/ - - rhoSL = ( sL - ProjVelocity_i ) / ( sL - sM ); - - IntermediateState[0] = rhoSL * Density_i; - for (iDim = 0; iDim < nDim; iDim++) - IntermediateState[iDim+1] = rhoSL * ( Density_i * Velocity_i[iDim] + ( pStar - Pressure_i ) / ( sL - ProjVelocity_i ) * UnitNormal[iDim] ) ; - IntermediateState[nVar-1] = rhoSL * ( Density_i * Energy_i - ( Pressure_i * ProjVelocity_i - pStar * sM) / ( sL - ProjVelocity_i ) ); - - - val_residual[0] = sM * IntermediateState[0]; - for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = sM * IntermediateState[iDim+1] + pStar * UnitNormal[iDim]; - val_residual[nVar-1] = sM * ( IntermediateState[nVar-1] + pStar ) + pStar * ProjInterfaceVel; - } - } - else { - - if (sR < 0.0) { - - /*--- Compute Right Flux ---*/ - - val_residual[0] = Density_j * ProjVelocity_j; - for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = Density_j * Velocity_j[iDim] * ProjVelocity_j + Pressure_j * UnitNormal[iDim]; - val_residual[nVar-1] = Enthalpy_j * Density_j * ProjVelocity_j; - } - else { - - /*--- Compute Flux Right Star from Right Star State ---*/ - - rhoSR = ( sR - ProjVelocity_j ) / ( sR - sM ); - - IntermediateState[0] = rhoSR * Density_j; - for (iDim = 0; iDim < nDim; iDim++) - IntermediateState[iDim+1] = rhoSR * ( Density_j * Velocity_j[iDim] + ( pStar - Pressure_j ) / ( sR - ProjVelocity_j ) * UnitNormal[iDim] ) ; - IntermediateState[nVar-1] = rhoSR * ( Density_j * Energy_j - ( Pressure_j * ProjVelocity_j - pStar * sM ) / ( sR - ProjVelocity_j ) ); - - - val_residual[0] = sM * IntermediateState[0]; - for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = sM * IntermediateState[iDim+1] + pStar * UnitNormal[iDim]; - val_residual[nVar-1] = sM * (IntermediateState[nVar-1] + pStar ) + pStar * ProjInterfaceVel; - } - } - - - for (iVar = 0; iVar < nVar; iVar++) - val_residual[iVar] *= Area; - - - if (implicit) { - - if (sM > 0.0) { - - if (sL > 0.0) { - - /*--- Compute Jacobian based on Left State ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_j[iVar][jVar] = 0; - - GetInviscidProjJac(Velocity_i, &Energy_i, UnitNormal, 1.0, val_Jacobian_i); - - } - else { - /*--- Compute Jacobian based on Left Star State ---*/ - - EStar = IntermediateState[nVar-1]; - Omega = 1/(sL-sM); - OmegaSM = Omega * sM; - - - /*--------- Left Jacobian ---------*/ - - - /*--- Computing pressure derivatives d/dU_L (PI) ---*/ - - dPI_dU[0] = 0.5 * Gamma_Minus_One * sq_vel_i; - for (iDim = 0; iDim < nDim; iDim++) - dPI_dU[iDim+1] = - Gamma_Minus_One * Velocity_i[iDim]; - dPI_dU[nVar-1] = Gamma_Minus_One; - - - /*--- Computing d/dU_L (Sm) ---*/ - - dSm_dU[0] = ( - ProjVelocity_i * ProjVelocity_i + sM * sL + dPI_dU[0] ) / RHO; - for (iDim = 0; iDim < nDim; iDim++) - dSm_dU[iDim+1] = ( UnitNormal[iDim] * ( 2 * ProjVelocity_i - sL - sM ) + dPI_dU[iDim+1] ) / RHO; - dSm_dU[nVar-1] = dPI_dU[nVar-1] / RHO; - - - /*--- Computing d/dU_L (rhoStar) ---*/ - - drhoStar_dU[0] = Omega * ( sL + IntermediateState[0] * dSm_dU[0] ); - for (iDim = 0; iDim < nDim; iDim++) - drhoStar_dU[iDim+1] = Omega * ( - UnitNormal[iDim] + IntermediateState[0] * dSm_dU[iDim+1] ); - drhoStar_dU[nVar-1] = Omega * IntermediateState[0] * dSm_dU[nVar-1]; - - - /*--- Computing d/dU_L (pStar) ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - dpStar_dU[iVar] = Density_i * (sR - ProjVelocity_j) * dSm_dU[iVar]; - - - /*--- Computing d/dU_L (EStar) ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); - - dEStar_dU[0] += Omega * ProjVelocity_i * ( Enthalpy_i - dPI_dU[0] ); - for (iDim = 0; iDim < nDim; iDim++) - dEStar_dU[iDim+1] += Omega * ( - UnitNormal[iDim] * Enthalpy_i - ProjVelocity_i * dPI_dU[iDim+1] ); - dEStar_dU[nVar-1] += Omega * ( sL - ProjVelocity_i - ProjVelocity_i * dPI_dU[nVar-1] ); - - - - /*--- Jacobian First Row ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[0][iVar] = sM * drhoStar_dU[iVar] + IntermediateState[0] * dSm_dU[iVar]; - - /*--- Jacobian Middle Rows ---*/ - - for (jDim = 0; jDim < nDim; jDim++) { - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[jDim+1][iVar] = ( OmegaSM + 1 ) * ( UnitNormal[jDim] * dpStar_dU[iVar] + IntermediateState[jDim+1] * dSm_dU[iVar] ); - - val_Jacobian_i[jDim+1][0] += OmegaSM * Velocity_i[jDim] * ProjVelocity_i; - - val_Jacobian_i[jDim+1][jDim+1] += OmegaSM * (sL - ProjVelocity_i); - - for (iDim = 0; iDim < nDim; iDim++) - val_Jacobian_i[jDim+1][iDim+1] -= OmegaSM * Velocity_i[jDim] * UnitNormal[iDim]; - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[jDim+1][iVar] -= OmegaSM * dPI_dU[iVar] * UnitNormal[jDim]; - } - - /*--- Jacobian Last Row ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[nVar-1][iVar] = sM * ( dEStar_dU[iVar] + dpStar_dU[iVar] ) + ( EStar + pStar ) * dSm_dU[iVar]; - - - - - /*--------- Right Jacobian ---------*/ - - - /*--- Computing d/dU_R (Sm) ---*/ - - dSm_dU[0] = ( ProjVelocity_j * ProjVelocity_j - sM * sR - 0.5 * Gamma_Minus_One * sq_vel_j ) / RHO; - for (iDim = 0; iDim < nDim; iDim++) - dSm_dU[iDim+1] = - ( UnitNormal[iDim] * ( 2 * ProjVelocity_j - sR - sM) - Gamma_Minus_One * Velocity_j[iDim] ) / RHO; - dSm_dU[nVar-1] = - Gamma_Minus_One / RHO; - - - /*--- Computing d/dU_R (pStar) ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - dpStar_dU[iVar] = Density_j * (sL - ProjVelocity_i) * dSm_dU[iVar]; - - - /*--- Computing d/dU_R (EStar) ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); - - - - /*--- Jacobian First Row ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[0][iVar] = IntermediateState[0] * ( OmegaSM + 1 ) * dSm_dU[iVar]; - - /*--- Jacobian Middle Rows ---*/ - - for (iDim = 0; iDim < nDim; iDim++) { - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[iDim+1][iVar] = ( OmegaSM + 1 ) * ( IntermediateState[iDim+1] * dSm_dU[iVar] + UnitNormal[iDim] * dpStar_dU[iVar] ); - } - - /*--- Jacobian Last Row ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[nVar-1][iVar] = sM * (dEStar_dU[iVar] + dpStar_dU[iVar]) + (EStar + pStar) * dSm_dU[iVar]; - } - } - else { - if (sR < 0.0) { - - /*--- Compute Jacobian based on Right State ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_i[iVar][jVar] = 0; - - GetInviscidProjJac(Velocity_j, &Energy_j, UnitNormal, 1.0, val_Jacobian_j); - - } - else { - /*--- Compute Jacobian based on Right Star State ---*/ - - EStar = IntermediateState[nVar-1]; - Omega = 1/(sR-sM); - OmegaSM = Omega * sM; - - - /*--------- Left Jacobian ---------*/ - - - /*--- Computing d/dU_L (Sm) ---*/ - - dSm_dU[0] = ( - ProjVelocity_i * ProjVelocity_i + sM * sL + 0.5 * Gamma_Minus_One * sq_vel_i ) / RHO; - for (iDim = 0; iDim < nDim; iDim++) - dSm_dU[iDim+1] = ( UnitNormal[iDim] * ( 2 * ProjVelocity_i - sL - sM ) - Gamma_Minus_One * Velocity_i[iDim] ) / RHO; - dSm_dU[nVar-1] = Gamma_Minus_One / RHO; - - - /*--- Computing d/dU_L (pStar) ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - dpStar_dU[iVar] = Density_i * (sR - ProjVelocity_j) * dSm_dU[iVar]; - - - /*--- Computing d/dU_L (EStar) ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); - - - - /*--- Jacobian First Row ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[0][iVar] = IntermediateState[0] * ( OmegaSM + 1 ) * dSm_dU[iVar]; - - /*--- Jacobian Middle Rows ---*/ - - for (iDim = 0; iDim < nDim; iDim++) { - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[iDim+1][iVar] = (OmegaSM + 1) * ( IntermediateState[iDim+1] * dSm_dU[iVar] + UnitNormal[iDim] * dpStar_dU[iVar] ); - } - - /*--- Jacobian Last Row ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[nVar-1][iVar] = sM * (dEStar_dU[iVar] + dpStar_dU[iVar]) + (EStar + pStar) * dSm_dU[iVar]; - - - - /*--------- Right Jacobian ---------*/ - - - /*--- Computing pressure derivatives d/dU_R (PI) ---*/ - - dPI_dU[0] = 0.5 * Gamma_Minus_One * sq_vel_j; - for (iDim = 0; iDim < nDim; iDim++) - dPI_dU[iDim+1] = - Gamma_Minus_One * Velocity_j[iDim]; - dPI_dU[nVar-1] = Gamma_Minus_One; - - - - /*--- Computing d/dU_R (Sm) ---*/ - - dSm_dU[0] = - ( - ProjVelocity_j * ProjVelocity_j + sM * sR + dPI_dU[0] ) / RHO; - for (iDim = 0; iDim < nDim; iDim++) - dSm_dU[iDim+1] = - ( UnitNormal[iDim] * ( 2 * ProjVelocity_j - sR - sM) + dPI_dU[iDim+1] ) / RHO; - dSm_dU[nVar-1] = - dPI_dU[nVar-1] / RHO; - - - /*--- Computing d/dU_R (pStar) ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - dpStar_dU[iVar] = Density_j * (sL - ProjVelocity_i) * dSm_dU[iVar]; - - - /*--- Computing d/dU_R (rhoStar) ---*/ - - drhoStar_dU[0] = Omega * ( sR + IntermediateState[0] * dSm_dU[0] ); - for (iDim = 0; iDim < nDim; iDim++) - drhoStar_dU[iDim+1] = Omega * ( - UnitNormal[iDim] + IntermediateState[0] * dSm_dU[iDim+1] ); - drhoStar_dU[nVar-1] = Omega * IntermediateState[0] * dSm_dU[nVar-1]; - - - /*--- Computing d/dU_R (EStar) ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); - - dEStar_dU[0] += Omega * ProjVelocity_j * ( Enthalpy_j - dPI_dU[0] ); - for (iDim = 0; iDim < nDim; iDim++) - dEStar_dU[iDim+1] += Omega * ( - UnitNormal[iDim] * Enthalpy_j - ProjVelocity_j * dPI_dU[iDim+1] ); - dEStar_dU[nVar-1] += Omega * ( sR - ProjVelocity_j - ProjVelocity_j * dPI_dU[nVar-1] ); - - - - /*--- Jacobian First Row ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[0][iVar] = sM * drhoStar_dU[iVar] + IntermediateState[0] * dSm_dU[iVar]; - - /*--- Jacobian Middle Rows ---*/ - - for (jDim = 0; jDim < nDim; jDim++) { - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[jDim+1][iVar] = ( OmegaSM + 1 ) * ( UnitNormal[jDim] * dpStar_dU[iVar] + IntermediateState[jDim+1] * dSm_dU[iVar] ); - - val_Jacobian_j[jDim+1][0] += OmegaSM * Velocity_j[jDim] * ProjVelocity_j; - - val_Jacobian_j[jDim+1][jDim+1] += OmegaSM * (sR - ProjVelocity_j); - - for (iDim = 0; iDim < nDim; iDim++) - val_Jacobian_j[jDim+1][iDim+1] -= OmegaSM * Velocity_j[jDim] * UnitNormal[iDim]; - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[jDim+1][iVar] -= OmegaSM * dPI_dU[iVar] * UnitNormal[jDim]; - } - - /*--- Jacobian Last Row ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[nVar-1][iVar] = sM * ( dEStar_dU[iVar] + dpStar_dU[iVar] ) + ( EStar + pStar ) * dSm_dU[iVar]; - - } - } - - - /*--- Jacobians of the inviscid flux, scale = k because val_residual ~ 0.5*(fc_i+fc_j)*Normal ---*/ - - Area *= kappa; - - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - val_Jacobian_i[iVar][jVar] *= Area; - val_Jacobian_j[iVar][jVar] *= Area; - } - } -} - -} - -CUpwGeneralHLLC_Flow::CUpwGeneralHLLC_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - kappa = config->GetRoe_Kappa(); - /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ - dynamic_grid = config->GetDynamic_Grid(); - - Gamma = config->GetGamma(); - - IntermediateState = new su2double [nVar]; - dSm_dU = new su2double [nVar]; - dPI_dU = new su2double [nVar]; - drhoStar_dU = new su2double [nVar]; - dpStar_dU = new su2double [nVar]; - dEStar_dU = new su2double [nVar]; - - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; - RoeVelocity = new su2double [nDim]; - -} - -CUpwGeneralHLLC_Flow::~CUpwGeneralHLLC_Flow(void) { - - delete [] IntermediateState; - delete [] dSm_dU; - delete [] dPI_dU; - delete [] drhoStar_dU; - delete [] dpStar_dU; - delete [] dEStar_dU; - - delete [] Velocity_i; - delete [] Velocity_j; - delete [] RoeVelocity; - -} - -void CUpwGeneralHLLC_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - /*--- Face area (norm or the normal vector) ---*/ - - Area = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - Area += Normal[iDim] * Normal[iDim]; - - Area = sqrt(Area); - - /*-- Unit Normal ---*/ - - for (iDim = 0; iDim < nDim; iDim++) - UnitNormal[iDim] = Normal[iDim] / Area; - - /*-- Fluid velocity at node i,j ---*/ - - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = V_i[iDim+1]; - Velocity_j[iDim] = V_j[iDim+1]; - } - - /*--- Primitive variables at point i ---*/ - - Pressure_i = V_i[nDim+1]; - Density_i = V_i[nDim+2]; - Enthalpy_i = V_i[nDim+3]; - - /*--- Primitive variables at point j ---*/ - - Pressure_j = V_j[nDim+1]; - Density_j = V_j[nDim+2]; - Enthalpy_j = V_j[nDim+3]; - - - sq_vel_i = 0.0; - sq_vel_j = 0.0; - - for (iDim = 0; iDim < nDim; iDim++) { - sq_vel_i += Velocity_i[iDim] * Velocity_i[iDim]; - sq_vel_j += Velocity_j[iDim] * Velocity_j[iDim]; - } - - Energy_i = Enthalpy_i - Pressure_i / Density_i; - StaticEnthalpy_i = Enthalpy_i - 0.5 * sq_vel_i; - StaticEnergy_i = Energy_i - 0.5 * sq_vel_i; - - Kappa_i = S_i[1] / Density_i; - Chi_i = S_i[0] - Kappa_i * StaticEnergy_i; - SoundSpeed_i = sqrt(Chi_i + StaticEnthalpy_i * Kappa_i); - - - Energy_j = Enthalpy_j - Pressure_j / Density_j; - StaticEnthalpy_j = Enthalpy_j - 0.5 * sq_vel_j; - StaticEnergy_j = Energy_j - 0.5 * sq_vel_j; - - Kappa_j = S_j[1] / Density_j; - Chi_j = S_j[0] - Kappa_j * StaticEnergy_j; - SoundSpeed_j = sqrt(Chi_j + StaticEnthalpy_j * Kappa_j); - - /*--- Projected velocities ---*/ - - ProjVelocity_i = 0.0; - ProjVelocity_j = 0.0; - - for (iDim = 0; iDim < nDim; iDim++) { - ProjVelocity_i += Velocity_i[iDim] * UnitNormal[iDim]; - ProjVelocity_j += Velocity_j[iDim] * UnitNormal[iDim]; - } - - - /*--- Projected Grid Velocity ---*/ - - ProjInterfaceVel = 0; - - if (dynamic_grid) { - - for (iDim = 0; iDim < nDim; iDim++) - ProjInterfaceVel += 0.5 * ( GridVel_i[iDim] + GridVel_j[iDim] )*UnitNormal[iDim]; - - SoundSpeed_i -= ProjInterfaceVel; - SoundSpeed_j += ProjInterfaceVel; - - ProjVelocity_i -= ProjInterfaceVel; - ProjVelocity_j -= ProjInterfaceVel; - } - - /*--- Roe's averaging ---*/ - - Rrho = ( sqrt(Density_i) + sqrt(Density_j) ); - - sq_velRoe = 0.0; - RoeProjVelocity = - ProjInterfaceVel; - - for (iDim = 0; iDim < nDim; iDim++) { - RoeVelocity[iDim] = ( Velocity_i[iDim] * sqrt(Density_i) + Velocity_j[iDim] * sqrt(Density_j) ) / Rrho; - sq_velRoe += RoeVelocity[iDim] * RoeVelocity[iDim]; - RoeProjVelocity += RoeVelocity[iDim] * UnitNormal[iDim]; - } - - /*--- Mean Roe variables iPoint and jPoint ---*/ - - RoeKappa = 0.5 * ( Kappa_i + Kappa_j ); - RoeChi = 0.5 * ( Chi_i + Chi_j ); - RoeDensity = sqrt( Density_i * Density_j ); - RoeEnthalpy = ( sqrt(Density_j) * Enthalpy_j + sqrt(Density_i) * Enthalpy_i) / Rrho; - - VinokurMontagne(); - - /*--- Roe-averaged speed of sound ---*/ - - //RoeSoundSpeed2 = RoeChi + RoeKappa * ( RoeEnthalpy - 0.5 * sq_velRoe ); - RoeSoundSpeed = sqrt( RoeChi + RoeKappa * ( RoeEnthalpy - 0.5 * sq_velRoe ) ) - ProjInterfaceVel; - - /*--- Speed of sound at L and R ---*/ - - sL = min( RoeProjVelocity - RoeSoundSpeed, ProjVelocity_i - SoundSpeed_i ); - sR = max( RoeProjVelocity + RoeSoundSpeed, ProjVelocity_j + SoundSpeed_j ); - - /*--- speed of contact surface ---*/ - - RHO = Density_j * (sR - ProjVelocity_j) - Density_i * (sL - ProjVelocity_i); - sM = ( Pressure_i - Pressure_j - Density_i * ProjVelocity_i * ( sL - ProjVelocity_i ) + Density_j * ProjVelocity_j * ( sR - ProjVelocity_j ) ) / RHO; - - /*--- Pressure at right and left (Pressure_j=Pressure_i) side of contact surface ---*/ - - pStar = Density_j * ( ProjVelocity_j - sR ) * ( ProjVelocity_j - sM ) + Pressure_j; - - -if (sM > 0.0) { - - if (sL > 0.0) { - - /*--- Compute Left Flux ---*/ - - val_residual[0] = Density_i * ProjVelocity_i; - for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = Density_i * Velocity_i[iDim] * ProjVelocity_i + Pressure_i * UnitNormal[iDim]; - val_residual[nVar-1] = Enthalpy_i * Density_i * ProjVelocity_i; - } - else { - - /*--- Compute Flux Left Star from Left Star State ---*/ - - rhoSL = ( sL - ProjVelocity_i ) / ( sL - sM ); - - IntermediateState[0] = rhoSL * Density_i; - for (iDim = 0; iDim < nDim; iDim++) - IntermediateState[iDim+1] = rhoSL * ( Density_i * Velocity_i[iDim] + ( pStar - Pressure_i ) / ( sL - ProjVelocity_i ) * UnitNormal[iDim] ) ; - IntermediateState[nVar-1] = rhoSL * ( Density_i * Energy_i - ( Pressure_i * ProjVelocity_i - pStar * sM) / ( sL - ProjVelocity_i ) ); - - - val_residual[0] = sM * IntermediateState[0]; - for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = sM * IntermediateState[iDim+1] + pStar * UnitNormal[iDim]; - val_residual[nVar-1] = sM * ( IntermediateState[nVar-1] + pStar ) + pStar * ProjInterfaceVel; - } - } - else { - - if (sR < 0.0) { - - /*--- Compute Right Flux ---*/ - - val_residual[0] = Density_j * ProjVelocity_j; - for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = Density_j * Velocity_j[iDim] * ProjVelocity_j + Pressure_j * UnitNormal[iDim]; - val_residual[nVar-1] = Enthalpy_j * Density_j * ProjVelocity_j; - } - else { - - /*--- Compute Flux Right Star from Right Star State ---*/ - - rhoSR = ( sR - ProjVelocity_j ) / ( sR - sM ); - - IntermediateState[0] = rhoSR * Density_j; - for (iDim = 0; iDim < nDim; iDim++) - IntermediateState[iDim+1] = rhoSR * ( Density_j * Velocity_j[iDim] + ( pStar - Pressure_j ) / ( sR - ProjVelocity_j ) * UnitNormal[iDim] ) ; - IntermediateState[nVar-1] = rhoSR * ( Density_j * Energy_j - ( Pressure_j * ProjVelocity_j - pStar * sM ) / ( sR - ProjVelocity_j ) ); - - - val_residual[0] = sM * IntermediateState[0]; - for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = sM * IntermediateState[iDim+1] + pStar * UnitNormal[iDim]; - val_residual[nVar-1] = sM * (IntermediateState[nVar-1] + pStar ) + pStar * ProjInterfaceVel; - } - } - - for (iVar = 0; iVar < nVar; iVar++) - val_residual[iVar] *= Area; - - - if (implicit) { - - if (sM > 0.0) { - - if (sL > 0.0) { - - /*--- Compute Jacobian based on Left State ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_j[iVar][jVar] = 0; - - - GetInviscidProjJac(Velocity_i, &Enthalpy_i, &Chi_i, &Kappa_i, UnitNormal, 1.0, val_Jacobian_i); - - } - else { - /*--- Compute Jacobian based on Left Star State ---*/ - - EStar = IntermediateState[nVar-1]; - Omega = 1/(sL-sM); - OmegaSM = Omega * sM; - - - /*--------- Left Jacobian ---------*/ - - - /*--- Computing pressure derivatives d/dU_L (PI) ---*/ - - dPI_dU[0] = Chi_i - 0.5 * Kappa_i * sq_vel_i; - for (iDim = 0; iDim < nDim; iDim++) - dPI_dU[iDim+1] = - Kappa_i * Velocity_i[iDim]; - dPI_dU[nVar-1] = Kappa_i; - - - /*--- Computing d/dU_L (Sm) ---*/ - - dSm_dU[0] = ( - ProjVelocity_i * ProjVelocity_i + sM * sL + dPI_dU[0] ) / RHO; - for (iDim = 0; iDim < nDim; iDim++) - dSm_dU[iDim+1] = ( UnitNormal[iDim] * ( 2 * ProjVelocity_i - sL - sM ) + dPI_dU[iDim+1] ) / RHO; - dSm_dU[nVar-1] = dPI_dU[nVar-1] / RHO; - - - /*--- Computing d/dU_L (rhoStar) ---*/ - - drhoStar_dU[0] = Omega * ( sL + IntermediateState[0] * dSm_dU[0] ); - for (iDim = 0; iDim < nDim; iDim++) - drhoStar_dU[iDim+1] = Omega * ( - UnitNormal[iDim] + IntermediateState[0] * dSm_dU[iDim+1] ); - drhoStar_dU[nVar-1] = Omega * IntermediateState[0] * dSm_dU[nVar-1]; - - - /*--- Computing d/dU_L (pStar) ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - dpStar_dU[iVar] = Density_i * (sR - ProjVelocity_j) * dSm_dU[iVar]; - - - /*--- Computing d/dU_L (EStar) ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); - - dEStar_dU[0] += Omega * ProjVelocity_i * ( Enthalpy_i - dPI_dU[0] ); - for (iDim = 0; iDim < nDim; iDim++) - dEStar_dU[iDim+1] += Omega * ( - UnitNormal[iDim] * Enthalpy_i - ProjVelocity_i * dPI_dU[iDim+1] ); - dEStar_dU[nVar-1] += Omega * ( sL - ProjVelocity_i - ProjVelocity_i * dPI_dU[nVar-1] ); - - - - /*--- Jacobian First Row ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[0][iVar] = sM * drhoStar_dU[iVar] + IntermediateState[0] * dSm_dU[iVar]; - - /*--- Jacobian Middle Rows ---*/ - - for (jDim = 0; jDim < nDim; jDim++) { - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[jDim+1][iVar] = ( OmegaSM + 1 ) * ( UnitNormal[jDim] * dpStar_dU[iVar] + IntermediateState[jDim+1] * dSm_dU[iVar] ); - - val_Jacobian_i[jDim+1][0] += OmegaSM * Velocity_i[jDim] * ProjVelocity_i; - - val_Jacobian_i[jDim+1][jDim+1] += OmegaSM * (sL - ProjVelocity_i); - - for (iDim = 0; iDim < nDim; iDim++) - val_Jacobian_i[jDim+1][iDim+1] -= OmegaSM * Velocity_i[jDim] * UnitNormal[iDim]; - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[jDim+1][iVar] -= OmegaSM * dPI_dU[iVar] * UnitNormal[jDim]; - } - - /*--- Jacobian Last Row ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[nVar-1][iVar] = sM * ( dEStar_dU[iVar] + dpStar_dU[iVar] ) + ( EStar + pStar ) * dSm_dU[iVar]; - - - - - /*--------- Right Jacobian ---------*/ - - - /*--- Computing pressure derivatives d/dU_R (PI) ---*/ - - dPI_dU[0] = Chi_j - 0.5 * Kappa_j * sq_vel_j; - for (iDim = 0; iDim < nDim; iDim++) - dPI_dU[iDim+1] = - Kappa_j * Velocity_j[iDim]; - dPI_dU[nVar-1] = Kappa_j; - - - /*--- Computing d/dU_R (Sm) ---*/ - - dSm_dU[0] = ( ProjVelocity_j * ProjVelocity_j - sM * sR - dPI_dU[0] ) / RHO; - for (iDim = 0; iDim < nDim; iDim++) - dSm_dU[iDim+1] = - ( UnitNormal[iDim] * ( 2 * ProjVelocity_j - sR - sM) + dPI_dU[iDim+1] ) / RHO; - dSm_dU[nVar-1] = - dPI_dU[nVar-1] / RHO; - - - /*--- Computing d/dU_R (pStar) ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - dpStar_dU[iVar] = Density_j * (sL - ProjVelocity_i) * dSm_dU[iVar]; - - - /*--- Computing d/dU_R (EStar) ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); - - - - /*--- Jacobian First Row ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[0][iVar] = IntermediateState[0] * ( OmegaSM + 1 ) * dSm_dU[iVar]; - - /*--- Jacobian Middle Rows ---*/ - - for (iDim = 0; iDim < nDim; iDim++) { - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[iDim+1][iVar] = ( OmegaSM + 1 ) * ( IntermediateState[iDim+1] * dSm_dU[iVar] + UnitNormal[iDim] * dpStar_dU[iVar] ); - } - - /*--- Jacobian Last Row ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[nVar-1][iVar] = sM * (dEStar_dU[iVar] + dpStar_dU[iVar]) + (EStar + pStar) * dSm_dU[iVar]; - } - } - else { - if (sR < 0.0) { - - /*--- Compute Jacobian based on Right State ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_i[iVar][jVar] = 0; - - GetInviscidProjJac(Velocity_j, &Enthalpy_j, &Chi_j, &Kappa_j, UnitNormal, 1.0, val_Jacobian_j); - - } - else { - /*--- Compute Jacobian based on Right Star State ---*/ - - EStar = IntermediateState[nVar-1]; - Omega = 1/(sR-sM); - OmegaSM = Omega * sM; - - - /*--------- Left Jacobian ---------*/ - - - /*--- Computing pressure derivatives d/dU_L (PI) ---*/ - - dPI_dU[0] = Chi_i - 0.5 * Kappa_i * sq_vel_i; - for (iDim = 0; iDim < nDim; iDim++) - dPI_dU[iDim+1] = - Kappa_i * Velocity_i[iDim]; - dPI_dU[nVar-1] = Kappa_i; - - - /*--- Computing d/dU_L (Sm) ---*/ - - dSm_dU[0] = ( - ProjVelocity_i * ProjVelocity_i + sM * sL + dPI_dU[0] ) / RHO; - for (iDim = 0; iDim < nDim; iDim++) - dSm_dU[iDim+1] = ( UnitNormal[iDim] * ( 2 * ProjVelocity_i - sL - sM ) + dPI_dU[iDim+1] ) / RHO; - dSm_dU[nVar-1] = dPI_dU[nVar-1] / RHO; - - - /*--- Computing d/dU_L (pStar) ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - dpStar_dU[iVar] = Density_i * (sR - ProjVelocity_j) * dSm_dU[iVar]; - - - /*--- Computing d/dU_L (EStar) ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); - - - - /*--- Jacobian First Row ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[0][iVar] = IntermediateState[0] * ( OmegaSM + 1 ) * dSm_dU[iVar]; - - /*--- Jacobian Middle Rows ---*/ - - for (iDim = 0; iDim < nDim; iDim++) { - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[iDim+1][iVar] = (OmegaSM + 1) * ( IntermediateState[iDim+1] * dSm_dU[iVar] + UnitNormal[iDim] * dpStar_dU[iVar] ); - } - - /*--- Jacobian Last Row ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_i[nVar-1][iVar] = sM * (dEStar_dU[iVar] + dpStar_dU[iVar]) + (EStar + pStar) * dSm_dU[iVar]; - - - - /*--------- Right Jacobian ---------*/ - - - /*--- Computing pressure derivatives d/dU_R (PI) ---*/ - - dPI_dU[0] = Chi_j - 0.5 * Kappa_j * sq_vel_j; - for (iDim = 0; iDim < nDim; iDim++) - dPI_dU[iDim+1] = - Kappa_j * Velocity_j[iDim]; - dPI_dU[nVar-1] = Kappa_j; - - - /*--- Computing d/dU_R (Sm) ---*/ - - dSm_dU[0] = - ( - ProjVelocity_j * ProjVelocity_j + sM * sR + dPI_dU[0] ) / RHO; - for (iDim = 0; iDim < nDim; iDim++) - dSm_dU[iDim+1] = - ( UnitNormal[iDim] * ( 2 * ProjVelocity_j - sR - sM) + dPI_dU[iDim+1] ) / RHO; - dSm_dU[nVar-1] = - dPI_dU[nVar-1] / RHO; - - - /*--- Computing d/dU_R (pStar) ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - dpStar_dU[iVar] = Density_j * (sL - ProjVelocity_i) * dSm_dU[iVar]; - - - /*--- Computing d/dU_R (rhoStar) ---*/ - - drhoStar_dU[0] = Omega * ( sR + IntermediateState[0] * dSm_dU[0] ); - for (iDim = 0; iDim < nDim; iDim++) - drhoStar_dU[iDim+1] = Omega * ( - UnitNormal[iDim] + IntermediateState[0] * dSm_dU[iDim+1] ); - drhoStar_dU[nVar-1] = Omega * IntermediateState[0] * dSm_dU[nVar-1]; - - - /*--- Computing d/dU_R (EStar) ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - dEStar_dU[iVar] = Omega * ( sM * dpStar_dU[iVar] + ( EStar + pStar ) * dSm_dU[iVar] ); - - dEStar_dU[0] += Omega * ProjVelocity_j * ( Enthalpy_j - dPI_dU[0] ); - for (iDim = 0; iDim < nDim; iDim++) - dEStar_dU[iDim+1] += Omega * ( - UnitNormal[iDim] * Enthalpy_j - ProjVelocity_j * dPI_dU[iDim+1] ); - dEStar_dU[nVar-1] += Omega * ( sR - ProjVelocity_j - ProjVelocity_j * dPI_dU[nVar-1] ); - - - - /*--- Jacobian First Row ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[0][iVar] = sM * drhoStar_dU[iVar] + IntermediateState[0] * dSm_dU[iVar]; - - /*--- Jacobian Middle Rows ---*/ - - for (jDim = 0; jDim < nDim; jDim++) { - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[jDim+1][iVar] = ( OmegaSM + 1 ) * ( UnitNormal[jDim] * dpStar_dU[iVar] + IntermediateState[jDim+1] * dSm_dU[iVar] ); - - val_Jacobian_j[jDim+1][0] += OmegaSM * Velocity_j[jDim] * ProjVelocity_j; - - val_Jacobian_j[jDim+1][jDim+1] += OmegaSM * (sR - ProjVelocity_j); - - for (iDim = 0; iDim < nDim; iDim++) - val_Jacobian_j[jDim+1][iDim+1] -= OmegaSM * Velocity_j[jDim] * UnitNormal[iDim]; - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[jDim+1][iVar] -= OmegaSM * dPI_dU[iVar] * UnitNormal[jDim]; - } - - /*--- Jacobian Last Row ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_Jacobian_j[nVar-1][iVar] = sM * ( dEStar_dU[iVar] + dpStar_dU[iVar] ) + ( EStar + pStar ) * dSm_dU[iVar]; - } - } - - - /*--- Jacobians of the inviscid flux, scale = kappa because val_residual ~ 0.5*(fc_i+fc_j)*Normal ---*/ - - Area *= kappa; - - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - val_Jacobian_i[iVar][jVar] *= Area; - val_Jacobian_j[iVar][jVar] *= Area; - } - } - - } - -} - -void CUpwGeneralHLLC_Flow::VinokurMontagne() { - - su2double delta_rhoStaticEnergy, delta_rho, delta_p, err_P, s, D; - - delta_rho = Density_j - Density_i; - delta_p = Pressure_j - Pressure_i; - - RoeKappaStaticEnthalpy = 0.5 * ( StaticEnthalpy_i * Kappa_i + StaticEnthalpy_j * Kappa_j ); - - s = RoeChi + RoeKappaStaticEnthalpy; - - D = s*s * delta_rho * delta_rho + delta_p * delta_p; - - delta_rhoStaticEnergy = Density_j * StaticEnergy_j - Density_i * StaticEnergy_i; - - err_P = delta_p - RoeChi * delta_rho - RoeKappa * delta_rhoStaticEnergy; - - if (abs((D - delta_p*err_P)/Density_i) > 1e-3 && abs(delta_rho/Density_i) > 1e-3 && s/Density_i > 1e-3) { - - RoeKappa = ( D * RoeKappa ) / ( D - delta_p * err_P ); - RoeChi = ( D * RoeChi+ s*s * delta_rho * err_P ) / ( D - delta_p * err_P ); - - } -} - -#ifdef CHECK - -int UgpWithCvCompFlow::calcEulerFluxMatrices_HLLC(su2double (*val_Jacobian_i)[5], su2double (*val_Jacobian_j)[5], su2double (*val_Jacobian_i_Scal)[6], su2double (*val_Jacobian_j_Scal)[6], - const su2double Density_i, const su2double *uL, const su2double pL, const su2double TL, const su2double h0, const su2double RL, const su2double gammaL, const su2double *scalL, const su2double kL, - const su2double Density_j, const su2double *uR, const su2double pR, const su2double TR, const su2double h1, const su2double RR, const su2double gammaR, const su2double *scalR, const su2double kR, - const su2double area, const su2double *nVec, const int nScal, const su2double surfVeloc) -{ - - su2double unL = vecDotVec3d(uL, nVec); - su2double uLuL = vecDotVec3d(uL, uL); - su2double cL = sqrt(gammaL*pL/Density_i); - su2double hL = gammaL/(gammaL-1.0)*pL/Density_i + 0.5*uLuL + kL; - // su2double hL = h0 + 0.5*uLuL + kL; - su2double eL = hL*Density_i-pL; - - su2double unR = vecDotVec3d(uR, nVec); - su2double uRuR = vecDotVec3d(uR, uR); - su2double cR = sqrt(gammaR*pR/Density_j); - su2double hR = gammaR/(gammaR-1.0)*pR/Density_j + 0.5*uRuR + kR; - // su2double hR = h1 + 0.5*uRuR + kR; - su2double eR = hR*Density_j-pR; - - - // Roe's aveaging - su2double Rrho = sqrt(Density_j/Density_i); - su2double tmp = 1.0/(1.0+Rrho); - su2double velRoe[3]; - for (int i=0; i<3; i++) - velRoe[i] = tmp*(uL[i] + uR[i]*Rrho); - su2double uRoe = vecDotVec3d(velRoe, nVec); - su2double hRoe = tmp*(hL + hR*Rrho); - - // su2double cRoe = sqrt((gammaL-1.0)*(hRoe- 0.5*vecDotVec3d(velRoe, velRoe))); - su2double gamPdivRho = tmp*((gammaL*pL/Density_i+0.5*(gammaL-1.0)*uLuL) + (gammaR*pR/Density_j+0.5*(gammaR-1.0)*uRuR)*Rrho); - su2double cRoe = sqrt(gamPdivRho - ((gammaL+gammaR)*0.5-1.0)*0.5*vecDotVec3d(velRoe, velRoe)); - - // speed of sound at L and R - su2double sL = min(uRoe-cRoe, unL-cL); - su2double sR = max(uRoe+cRoe, unR+cR); - - // speed of contact surface - su2double sM = (pL-pR-Density_i*unL*(sL-unL)+Density_j*unR*(sR-unR))/(Density_j*(sR-unR)-Density_i*(sL-unL)); - - // pressure at right and left (pR=pL) side of contact surface - su2double pStar = Density_j*(unR-sR)*(unR-sM)+pR; - - if (sM >= 0.0) { - - if (sL > 0.0) { - - su2double nVecArea[3]; - for (int i=0; i<3; i++) nVecArea[i] = nVec[i]*area; - - calcJacobianA(val_Jacobian_i, uL, pL, Density_i, nVecArea, 0.5*(gammaL+gammaR), 0.0); - - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_j[i][j] = 0.0; - - } - else { - - su2double invSLmSs = 1.0/(sL-sM); - su2double sLmuL = sL-unL; - su2double rhoSL = Density_i*sLmuL*invSLmSs; - su2double rhouSL[3]; - - for (int i=0; i<3; i++) - rhouSL[i] = (Density_i*uL[i]*sLmuL+(pStar-pL)*nVec[i])*invSLmSs; - - su2double eSL = (sLmuL*eL-pL*unL+pStar*sM)*invSLmSs; - su2double gammaLM1 = (gammaL-1.0); - su2double gammaRM1 = (gammaR-1.0); - su2double invrhotld = 1.0/(Density_j*(sR-unR)-Density_i*(sL-unL)); - - su2double dSMdUL[5], dSMdUR[5]; - su2double dpsdUL[5], dpsdUR[5]; - - dSMdUL[0] = -unL*unL + uLuL*gammaLM1/2.0 + sM*sL; - dSMdUL[1] = nVec[0]*(2.0*unL-sL-sM) - gammaLM1*uL[0]; - dSMdUL[2] = nVec[1]*(2.0*unL-sL-sM) - gammaLM1*uL[1]; - dSMdUL[3] = nVec[2]*(2.0*unL-sL-sM) - gammaLM1*uL[2]; - dSMdUL[4] = gammaLM1; - - for (iVar = 0; iVar < nVar; iVar++) - { - dSMdUL[i] *= invrhotld; - dpsdUL[i] = Density_j*(sR-unR)*dSMdUL[i]; - } - - dSMdUR[0] = unR*unR - uRuR*gammaRM1/2.0 - sM*sR; - dSMdUR[1] = -nVec[0]*(2.0*unR-sR-sM) + gammaRM1*uR[0]; - dSMdUR[2] = -nVec[1]*(2.0*unR-sR-sM) + gammaRM1*uR[1]; - dSMdUR[3] = -nVec[2]*(2.0*unR-sR-sM) + gammaRM1*uR[2]; - dSMdUR[4] = -gammaRM1; - - for (iVar = 0; iVar < nVar; iVar++) - { - dSMdUR[i] *= invrhotld; - dpsdUR[i] = Density_i*(sL-unL)*dSMdUR[i]; - } - - calcSubSonicJacobeanHLLC(val_Jacobian_i, val_Jacobian_j, - Density_i, uL, pL, eL, unL, uLuL, sL, - rhoSL, rhouSL, eSL, dSMdUL, - dSMdUR, dpsdUL, dpsdUR, sM, pStar, 0.5*(gammaL+gammaR), nVec); - - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[0][i] = val_Jacobian_i[0][i]*sM + dSMdUL[i]*rhoSL; - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[1][i] = val_Jacobian_i[1][i]*sM + dSMdUL[i]*rhouSL[0] + dpsdUL[i]*nVec[0]; - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[2][i] = val_Jacobian_i[2][i]*sM + dSMdUL[i]*rhouSL[1] + dpsdUL[i]*nVec[1]; - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[3][i] = val_Jacobian_i[3][i]*sM + dSMdUL[i]*rhouSL[2] + dpsdUL[i]*nVec[2]; - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[4][i] = (val_Jacobian_i[4][i]+dpsdUL[i])*sM + (eSL+pStar)*dSMdUL[i]; - - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_i[i][j] *= area; - - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[0][i] = val_Jacobian_j[0][i]*sM + dSMdUR[i]*rhoSL; - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[1][i] = val_Jacobian_j[1][i]*sM + dSMdUR[i]*rhouSL[0] + dpsdUR[i]*nVec[0]; - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[2][i] = val_Jacobian_j[2][i]*sM + dSMdUR[i]*rhouSL[1] + dpsdUR[i]*nVec[1]; - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[3][i] = val_Jacobian_j[3][i]*sM + dSMdUR[i]*rhouSL[2] + dpsdUR[i]*nVec[2]; - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[4][i] = (val_Jacobian_j[4][i]+dpsdUR[i])*sM + (eSL+pStar)*dSMdUR[i]; - - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_j[i][j] *= area; - - } - } - - else { - - if (sR >= 0.0) { - - su2double invSRmSs = 1.0/(sR-sM); - su2double sRmuR = sR-unR; - su2double rhoSR = Density_j*sRmuR*invSRmSs; - su2double rhouSR[3]; - for (int i=0; i<3; i++) - rhouSR[i] = (Density_j*uR[i]*sRmuR+(pStar-pR)*nVec[i])*invSRmSs; - su2double eSR = (sRmuR*eR-pR*unR+pStar*sM)*invSRmSs; - su2double gammaLM1 = (gammaL-1.0); - su2double gammaRM1 = (gammaR-1.0); - su2double invrhotld = 1.0/(Density_j*(sR-unR)-Density_i*(sL-unL)); - - su2double dSMdUL[5], dSMdUR[5]; - su2double dpsdUL[5], dpsdUR[5]; - - dSMdUL[0] = -unL*unL + uLuL*gammaLM1/2.0 + sM*sL; - dSMdUL[1] = nVec[0]*(2.0*unL-sL-sM) - gammaLM1*uL[0]; - dSMdUL[2] = nVec[1]*(2.0*unL-sL-sM) - gammaLM1*uL[1]; - dSMdUL[3] = nVec[2]*(2.0*unL-sL-sM) - gammaLM1*uL[2]; - dSMdUL[4] = gammaLM1; - - for (iVar = 0; iVar < nVar; iVar++) { - dSMdUL[i] *= invrhotld; - dpsdUL[i] = Density_j*(sR-unR)*dSMdUL[i]; - } - - dSMdUR[0] = unR*unR - uRuR*gammaRM1/2.0 - sM*sR; - dSMdUR[1] = -nVec[0]*(2.0*unR-sR-sM) + gammaRM1*uR[0]; - dSMdUR[2] = -nVec[1]*(2.0*unR-sR-sM) + gammaRM1*uR[1]; - dSMdUR[3] = -nVec[2]*(2.0*unR-sR-sM) + gammaRM1*uR[2]; - dSMdUR[4] = -gammaRM1; - - for (iVar = 0; iVar < nVar; iVar++) { - dSMdUR[i] *= invrhotld; - dpsdUR[i] = Density_i*(sL-unL)*dSMdUR[i]; - } - - calcSubSonicJacobeanHLLC(val_Jacobian_j, val_Jacobian_i, - Density_j, uR, pR, eR, unR, uRuR, sR, - rhoSR, rhouSR, eSR, - dSMdUR, dSMdUL, dpsdUR, dpsdUL, sM, pStar, 0.5*(gammaL+gammaR), nVec); - - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[0][i] = val_Jacobian_i[0][i]*sM + dSMdUL[i]*rhoSR; - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[1][i] = val_Jacobian_i[1][i]*sM + dSMdUL[i]*rhouSR[0] + dpsdUL[i]*nVec[0]; - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[2][i] = val_Jacobian_i[2][i]*sM + dSMdUL[i]*rhouSR[1] + dpsdUL[i]*nVec[1]; - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[3][i] = val_Jacobian_i[3][i]*sM + dSMdUL[i]*rhouSR[2] + dpsdUL[i]*nVec[2]; - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_i[4][i] = (val_Jacobian_i[4][i]+dpsdUL[i])*sM + (eSR+pStar)*dSMdUL[i]; - - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_i[i][j] *= area; - - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[0][i] = val_Jacobian_j[0][i]*sM + dSMdUR[i]*rhoSR; - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[1][i] = val_Jacobian_j[1][i]*sM + dSMdUR[i]*rhouSR[0] + dpsdUR[i]*nVec[0]; - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[2][i] = val_Jacobian_j[2][i]*sM + dSMdUR[i]*rhouSR[1] + dpsdUR[i]*nVec[1]; - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[3][i] = val_Jacobian_j[3][i]*sM + dSMdUR[i]*rhouSR[2] + dpsdUR[i]*nVec[2]; - for (iVar = 0; iVar < nVar; iVar++) val_Jacobian_j[4][i] = (val_Jacobian_j[4][i]+dpsdUR[i])*sM + (eSR+pStar)*dSMdUR[i]; - - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_j[i][j] *= area; - - } - - else { - - su2double nVecArea[3]; - for (int i=0; i<3; i++) nVecArea[i] = nVec[i]*area; - calcJacobianA(val_Jacobian_j, uR, pR, Density_j, nVecArea, 0.5*(gammaL+gammaR), 0.0); - - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_i[i][j] = 0.0; - - } - - } - -} - -void UgpWithCvCompFlow::calcSubSonicJacobeanHLLC(su2double (*AL)[5], su2double (*AR)[5], - su2double Density_i, const su2double *uL, su2double pL, su2double eL, su2double qL, su2double psiL, su2double SL, - su2double rhoSL, su2double *rhouSL, su2double eSL, - su2double *dSMdUL, su2double *dSMdUR, su2double *dpsdUL, su2double *dpsdUR, su2double SM, su2double pS, - su2double gamma, const su2double *nV) // nV is not normalized -{ - - su2double gammaMinus1 = (gamma-1.0); - su2double omL = 1.0/(SL-SM); - - AL[0][0] = SL + rhoSL*dSMdUL[0]; - AL[0][1] = -nV[0] + rhoSL*dSMdUL[1]; - AL[0][2] = -nV[1] + rhoSL*dSMdUL[2]; - AL[0][3] = -nV[2] + rhoSL*dSMdUL[3]; - AL[0][4] = + rhoSL*dSMdUL[4]; - - AL[1][0] = qL*uL[0] - nV[0]*psiL*gammaMinus1/2.0 + nV[0]*dpsdUL[0] + rhouSL[0]*dSMdUL[0]; - AL[1][1] = SL - qL + nV[0]*(gamma-2.0)*uL[0] + nV[0]*dpsdUL[1] + rhouSL[0]*dSMdUL[1]; - AL[1][2] = - uL[0]*nV[1] + nV[0]*gammaMinus1*uL[1] + nV[0]*dpsdUL[2] + rhouSL[0]*dSMdUL[2]; - AL[1][3] = - uL[0]*nV[2] + nV[0]*gammaMinus1*uL[2] + nV[0]*dpsdUL[3] + rhouSL[0]*dSMdUL[3]; - AL[1][4] = -gammaMinus1*nV[0] + nV[0]*dpsdUL[4] + rhouSL[0]*dSMdUL[4]; - - AL[2][0] = qL*uL[1] - nV[1]*psiL*gammaMinus1/2.0 + nV[1]*dpsdUL[0] + rhouSL[1]*dSMdUL[0]; - AL[2][1] = - uL[1]*nV[0] + nV[1]*gammaMinus1*uL[0] + nV[1]*dpsdUL[1] + rhouSL[1]*dSMdUL[1]; - AL[2][2] = SL - qL + nV[1]*(gamma-2.0)*uL[1] + nV[1]*dpsdUL[2] + rhouSL[1]*dSMdUL[2]; - AL[2][3] = - uL[1]*nV[2] + nV[1]*gammaMinus1*uL[2] + nV[1]*dpsdUL[3] + rhouSL[1]*dSMdUL[3]; - AL[2][4] = -gammaMinus1*nV[1] + nV[1]*dpsdUL[4] + rhouSL[1]*dSMdUL[4]; - - AL[3][0] = qL*uL[2] - nV[2]*psiL*gammaMinus1/2.0 + nV[2]*dpsdUL[0] + rhouSL[2]*dSMdUL[0]; - AL[3][1] = - uL[2]*nV[0] + nV[2]*gammaMinus1*uL[0] + nV[2]*dpsdUL[1] + rhouSL[2]*dSMdUL[1]; - AL[3][2] = - uL[2]*nV[1] + nV[2]*gammaMinus1*uL[1] + nV[2]*dpsdUL[2] + rhouSL[2]*dSMdUL[2]; - AL[3][3] = SL - qL + nV[2]*(gamma-2.0)*uL[2] + nV[2]*dpsdUL[3] + rhouSL[2]*dSMdUL[3]; - AL[3][4] = -gammaMinus1*nV[2] + nV[2]*dpsdUL[4] + rhouSL[2]*dSMdUL[4]; - - AL[4][0] = qL*(eL+pL)/Density_i - qL*psiL*(gamma-1.0)/2.0 + SM*dpsdUL[0] + (pS+eSL)*dSMdUL[0]; - AL[4][1] = - nV[0]*(eL+pL)/Density_i + gammaMinus1*uL[0]*qL + SM*dpsdUL[1] + (pS+eSL)*dSMdUL[1]; - AL[4][2] = - nV[1]*(eL+pL)/Density_i + gammaMinus1*uL[1]*qL + SM*dpsdUL[2] + (pS+eSL)*dSMdUL[2]; - AL[4][3] = - nV[2]*(eL+pL)/Density_i + gammaMinus1*uL[2]*qL + SM*dpsdUL[3] + (pS+eSL)*dSMdUL[3]; - AL[4][4] = SL-qL*gamma + SM*dpsdUL[4] + (pS+eSL)*dSMdUL[4]; - - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - AL[i][j] *= omL; - - for (iVar = 0; iVar < nVar; iVar++) AR[0][i] = omL*rhoSL*dSMdUR[i]; - for (iVar = 0; iVar < nVar; iVar++) AR[1][i] = omL*(nV[0]*dpsdUR[i]+rhouSL[0]*dSMdUR[i]); - for (iVar = 0; iVar < nVar; iVar++) AR[2][i] = omL*(nV[1]*dpsdUR[i]+rhouSL[1]*dSMdUR[i]); - for (iVar = 0; iVar < nVar; iVar++) AR[3][i] = omL*(nV[2]*dpsdUR[i]+rhouSL[2]*dSMdUR[i]); - for (iVar = 0; iVar < nVar; iVar++) AR[4][i] = omL*(dpsdUR[i]*SM+(pS+eSL)*dSMdUR[i]); - -} - -void UgpWithCvCompFlow::calcJacobianA(su2double (*A)[5], const su2double *vel, su2double pp, su2double rrho, const su2double *nV, su2double gamma, su2double surfVeloc) // nV is not normalized -{ - - su2double kapm1 = (gamma - 1.0); - - su2double nVel[3]; - nVel[0] = vel[0]*nV[0]; - nVel[1] = vel[1]*nV[1]; - nVel[2] = vel[2]*nV[2]; - su2double U_k = nVel[0]+nVel[1]+nVel[2]; - su2double vSquHlf = 0.5*vecDotVec3d(vel, vel); - su2double c = sqrt(gamma*pp/rrho); - su2double inv_kap_m1 = 1.0/kapm1; - - A[0][0] =-surfVeloc; - A[0][1] = nV[0]; - A[0][2] = nV[1]; - A[0][3] = nV[2]; - A[0][4] = 0.0; - - A[1][0] = -vel[0]*(nVel[1]+nVel[2])+nV[0]*(kapm1*vSquHlf-vel[0]*vel[0]); - A[1][1] = (2.-gamma)*nVel[0]+U_k-surfVeloc; - A[1][2] = vel[0]*nV[1]-kapm1*vel[1]*nV[0]; - A[1][3] = vel[0]*nV[2]-kapm1*vel[2]*nV[0]; - A[1][4] = kapm1*nV[0]; - - A[2][0] = -vel[1]*(nVel[0]+nVel[2])+nV[1]*(kapm1*vSquHlf-vel[1]*vel[1]); - A[2][1] = -kapm1*vel[0]*nV[1]+ vel[1]*nV[0]; - A[2][2] = (2.-gamma)*nVel[1]+U_k-surfVeloc; - A[2][3] = vel[1]*nV[2]-kapm1*vel[2]*nV[1]; - A[2][4] = kapm1*nV[1]; - - A[3][0] = -vel[2]*(nVel[0]+nVel[1])+nV[2]*(kapm1*vSquHlf-vel[2]*vel[2]); - A[3][1] = -kapm1*vel[0]*nV[2]+vel[2]*nV[0]; - A[3][2] = -kapm1*vel[1]*nV[2]+vel[2]*nV[1]; - A[3][3] = (2.-gamma)*nVel[2]+U_k-surfVeloc; - A[3][4] = kapm1*nV[2]; - - A[4][0] = U_k*((gamma-2.)*vSquHlf-c*c*inv_kap_m1); - A[4][1] = c*c*inv_kap_m1*nV[0]-kapm1*vel[0]*(nVel[1]+nVel[2])-(kapm1*vel[0]*vel[0]-vSquHlf)*nV[0]; - A[4][2] = c*c*inv_kap_m1*nV[1]-kapm1*vel[1]*(nVel[0]+nVel[2])-(kapm1*vel[1]*vel[1]-vSquHlf)*nV[1]; - A[4][3] = c*c*inv_kap_m1*nV[2]-kapm1*vel[2]*(nVel[0]+nVel[1])-(kapm1*vel[2]*vel[2]-vSquHlf)*nV[2]; - A[4][4] = gamma*U_k-surfVeloc; - -} - - -#endif - - -CUpwRoeBase_Flow::CUpwRoeBase_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, - bool val_low_dissipation) : CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ - dynamic_grid = config->GetDynamic_Grid(); - kappa = config->GetRoe_Kappa(); // 1 is unstable - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - roe_low_dissipation = val_low_dissipation; - - Diff_U = new su2double [nVar]; - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; - RoeVelocity = new su2double [nDim]; - ProjFlux_i = new su2double [nVar]; - ProjFlux_j = new su2double [nVar]; - Conservatives_i = new su2double [nVar]; - Conservatives_j = new su2double [nVar]; - Lambda = new su2double [nVar]; - P_Tensor = new su2double* [nVar]; - invP_Tensor = new su2double* [nVar]; - for (unsigned short iVar = 0; iVar < nVar; iVar++) { - P_Tensor[iVar] = new su2double [nVar]; - invP_Tensor[iVar] = new su2double [nVar]; - } -} - -CUpwRoeBase_Flow::~CUpwRoeBase_Flow(void) { - - delete [] Diff_U; - delete [] Velocity_i; - delete [] Velocity_j; - delete [] RoeVelocity; - delete [] ProjFlux_i; - delete [] ProjFlux_j; - delete [] Conservatives_i; - delete [] Conservatives_j; - delete [] Lambda; - for (unsigned short iVar = 0; iVar < nVar; iVar++) { - delete [] P_Tensor[iVar]; - delete [] invP_Tensor[iVar]; - } - delete [] P_Tensor; - delete [] invP_Tensor; - -} - -void CUpwRoeBase_Flow::FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { -/*--- - CUpwRoeBase_Flow::ComputeResidual initializes the residual (flux) and its Jacobians with the standard Roe averaging - fc_{1/2} = kappa*(fc_i+fc_j)*Normal. It then calls this method, which derived classes specialize, to account for - the dissipation part. ----*/ -} - -void CUpwRoeBase_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - unsigned short iVar, jVar, iDim; - su2double ProjGridVel = 0.0, Energy_i, Energy_j; - - AD::StartPreacc(); - AD::SetPreaccIn(V_i, nDim+4); AD::SetPreaccIn(V_j, nDim+4); AD::SetPreaccIn(Normal, nDim); - if (dynamic_grid) { - AD::SetPreaccIn(GridVel_i, nDim); AD::SetPreaccIn(GridVel_j, nDim); - } - if (roe_low_dissipation){ - AD::SetPreaccIn(Sensor_i); AD::SetPreaccIn(Sensor_j); - AD::SetPreaccIn(Dissipation_i); AD::SetPreaccIn(Dissipation_j); - } - - /*--- Face area (norm or the normal vector) and unit normal ---*/ - - 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; - - /*--- Primitive variables at point i ---*/ - - for (iDim = 0; iDim < nDim; iDim++) - Velocity_i[iDim] = V_i[iDim+1]; - Pressure_i = V_i[nDim+1]; - Density_i = V_i[nDim+2]; - Enthalpy_i = V_i[nDim+3]; - Energy_i = Enthalpy_i - Pressure_i/Density_i; - - /*--- Primitive variables at point j ---*/ - - for (iDim = 0; iDim < nDim; iDim++) - Velocity_j[iDim] = V_j[iDim+1]; - Pressure_j = V_j[nDim+1]; - Density_j = V_j[nDim+2]; - Enthalpy_j = V_j[nDim+3]; - Energy_j = Enthalpy_j - Pressure_j/Density_j; - - /*--- Compute variables that are common to the derived schemes ---*/ - - /*--- Roe-averaged variables at interface between i & j ---*/ - - su2double R = sqrt(fabs(Density_j/Density_i)); - RoeDensity = R*Density_i; - su2double sq_vel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - RoeVelocity[iDim] = (R*Velocity_j[iDim]+Velocity_i[iDim])/(R+1); - sq_vel += RoeVelocity[iDim]*RoeVelocity[iDim]; - } - RoeEnthalpy = (R*Enthalpy_j+Enthalpy_i)/(R+1); - RoeSoundSpeed2 = (Gamma-1)*(RoeEnthalpy-0.5*sq_vel); - - /*--- Negative RoeSoundSpeed^2, the jump variables is too large, clear fluxes and exit. ---*/ - - if (RoeSoundSpeed2 <= 0.0) { - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] = 0.0; - if (implicit){ - for (jVar = 0; jVar < nVar; jVar++) { - val_Jacobian_i[iVar][jVar] = 0.0; - val_Jacobian_j[iVar][jVar] = 0.0; - } - } - } - AD::SetPreaccOut(val_residual, nVar); - AD::EndPreacc(); - return; - } - - RoeSoundSpeed = sqrt(RoeSoundSpeed2); - - /*--- P tensor ---*/ - - GetPMatrix(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, P_Tensor); - - /*--- Projected velocity adjusted for mesh motion ---*/ - - ProjVelocity = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjVelocity += RoeVelocity[iDim]*UnitNormal[iDim]; - - if (dynamic_grid) { - for (iDim = 0; iDim < nDim; iDim++) - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*UnitNormal[iDim]; - ProjVelocity -= ProjGridVel; - } - - /*--- Flow eigenvalues ---*/ - - for (iDim = 0; iDim < nDim; iDim++) - Lambda[iDim] = ProjVelocity; - - Lambda[nVar-2] = ProjVelocity + RoeSoundSpeed; - Lambda[nVar-1] = ProjVelocity - RoeSoundSpeed; - - /*--- Apply Mavriplis' entropy correction to eigenvalues ---*/ - - su2double MaxLambda = fabs(ProjVelocity) + RoeSoundSpeed; - - for (iVar = 0; iVar < nVar; iVar++) - Lambda[iVar] = max(fabs(Lambda[iVar]), config->GetEntropyFix_Coeff()*MaxLambda); - - /*--- Reconstruct conservative variables ---*/ - - Conservatives_i[0] = Density_i; - Conservatives_j[0] = Density_j; - - for (iDim = 0; iDim < nDim; iDim++) { - Conservatives_i[iDim+1] = Density_i*Velocity_i[iDim]; - Conservatives_j[iDim+1] = Density_j*Velocity_j[iDim]; - } - Conservatives_i[nDim+1] = Density_i*Energy_i; - Conservatives_j[nDim+1] = Density_j*Energy_j; - - /*--- Compute left and right fluxes ---*/ - - GetInviscidProjFlux(&Density_i, Velocity_i, &Pressure_i, &Enthalpy_i, Normal, ProjFlux_i); - GetInviscidProjFlux(&Density_j, Velocity_j, &Pressure_j, &Enthalpy_j, Normal, ProjFlux_j); - - /*--- Initialize residual (flux) and Jacobians ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_residual[iVar] = kappa*(ProjFlux_i[iVar]+ProjFlux_j[iVar]); - - if (implicit) { - GetInviscidProjJac(Velocity_i, &Energy_i, Normal, kappa, val_Jacobian_i); - GetInviscidProjJac(Velocity_j, &Energy_j, Normal, kappa, val_Jacobian_j); - } - - /*--- Finalize in children class ---*/ - - FinalizeResidual(val_residual, val_Jacobian_i, val_Jacobian_j, config); - - /*--- Correct for grid motion ---*/ - - if (dynamic_grid) { - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] -= ProjGridVel*Area * 0.5*(Conservatives_i[iVar]+Conservatives_j[iVar]); - - if (implicit) { - val_Jacobian_i[iVar][iVar] -= 0.5*ProjGridVel*Area; - val_Jacobian_j[iVar][iVar] -= 0.5*ProjGridVel*Area; - } - } - } - - AD::SetPreaccOut(val_residual, nVar); - AD::EndPreacc(); - -} - -CUpwRoe_Flow::CUpwRoe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config, - bool val_low_dissipation) : CUpwRoeBase_Flow(val_nDim, val_nVar, config, val_low_dissipation) {} - -CUpwRoe_Flow::~CUpwRoe_Flow() {} - -void CUpwRoe_Flow::FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, - su2double **val_Jacobian_j, CConfig *config) { - - unsigned short iVar, jVar, kVar; - - /*--- Compute inverse P tensor ---*/ - GetPMatrix_inv(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, invP_Tensor); - - /*--- Diference between conservative variables at jPoint and iPoint ---*/ - for (iVar = 0; iVar < nVar; iVar++) - Diff_U[iVar] = Conservatives_j[iVar]-Conservatives_i[iVar]; - - /*--- Low dissipation formulation ---*/ - if (roe_low_dissipation) - SetRoe_Dissipation(Dissipation_i, Dissipation_j, Sensor_i, Sensor_j, Dissipation_ij, config); - else - Dissipation_ij = 1.0; - - /*--- Standard Roe "dissipation" ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - /*--- Compute |Proj_ModJac_Tensor| = P x |Lambda| x inverse P ---*/ - su2double Proj_ModJac_Tensor_ij = 0.0; - for (kVar = 0; kVar < nVar; kVar++) - Proj_ModJac_Tensor_ij += P_Tensor[iVar][kVar]*Lambda[kVar]*invP_Tensor[kVar][jVar]; - - /*--- Update residual and Jacobians ---*/ - val_residual[iVar] -= (1.0-kappa)*Proj_ModJac_Tensor_ij*Diff_U[jVar]*Area*Dissipation_ij; - - if(implicit){ - val_Jacobian_i[iVar][jVar] += (1.0-kappa)*Proj_ModJac_Tensor_ij*Area; - val_Jacobian_j[iVar][jVar] -= (1.0-kappa)*Proj_ModJac_Tensor_ij*Area; - } - } - } - -} - -CUpwL2Roe_Flow::CUpwL2Roe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : - CUpwRoeBase_Flow(val_nDim, val_nVar, config, false) {} - -CUpwL2Roe_Flow::~CUpwL2Roe_Flow() {} - -void CUpwL2Roe_Flow::FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, - su2double **val_Jacobian_j, CConfig *config) { - - /*--- L2Roe: a low dissipation version of Roe's approximate Riemann solver for low Mach numbers. IJNMF 2015 ---*/ - - unsigned short iVar, jVar, kVar, iDim; - - /*--- Clamped Mach number ---*/ - - su2double M_i = 0.0, M_j = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - M_i += Velocity_i[iDim]*Velocity_i[iDim]; - M_j += Velocity_j[iDim]*Velocity_j[iDim]; - } - M_i = sqrt(M_i / fabs(Pressure_i*Gamma/Density_i)); - M_j = sqrt(M_j / fabs(Pressure_j*Gamma/Density_j)); - - su2double zeta = max(0.05,min(max(M_i,M_j),1.0)); - - /*--- Compute wave amplitudes (characteristics) ---*/ - - su2double proj_delta_vel = 0.0, delta_vel[3]; - for (iDim = 0; iDim < nDim; iDim++) { - delta_vel[iDim] = Velocity_j[iDim] - Velocity_i[iDim]; - proj_delta_vel += delta_vel[iDim]*UnitNormal[iDim]; - } - proj_delta_vel *= zeta; - su2double delta_p = Pressure_j - Pressure_i; - su2double delta_rho = Density_j - Density_i; - - su2double delta_wave[5] = {0.0, 0.0, 0.0, 0.0, 0.0}; - if (nDim == 2) { - delta_wave[0] = delta_rho - delta_p/RoeSoundSpeed2; - delta_wave[1] = (UnitNormal[1]*delta_vel[0]-UnitNormal[0]*delta_vel[1])*zeta; - delta_wave[2] = proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); - delta_wave[3] = -proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); - } else { - delta_wave[0] = delta_rho - delta_p/RoeSoundSpeed2; - delta_wave[1] = (UnitNormal[0]*delta_vel[2]-UnitNormal[2]*delta_vel[0])*zeta; - delta_wave[2] = (UnitNormal[1]*delta_vel[0]-UnitNormal[0]*delta_vel[1])*zeta; - delta_wave[3] = proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); - delta_wave[4] = -proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); - } - - /*--- Update residual ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - for (kVar = 0; kVar < nVar; kVar++) - val_residual[iVar] -= (1.0-kappa)*Lambda[kVar]*delta_wave[kVar]*P_Tensor[iVar][kVar]*Area; - - if (!implicit) return; - - /*--- If implicit use the Jacobians of the standard Roe scheme as an approximation ---*/ - - GetPMatrix_inv(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, invP_Tensor); - - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - /*--- Compute |Proj_ModJac_Tensor| = P x |Lambda| x inverse P ---*/ - su2double Proj_ModJac_Tensor_ij = 0.0; - for (kVar = 0; kVar < nVar; kVar++) - Proj_ModJac_Tensor_ij += P_Tensor[iVar][kVar]*Lambda[kVar]*invP_Tensor[kVar][jVar]; - - val_Jacobian_i[iVar][jVar] += (1.0-kappa)*Proj_ModJac_Tensor_ij*Area; - val_Jacobian_j[iVar][jVar] -= (1.0-kappa)*Proj_ModJac_Tensor_ij*Area; - } - } - -} - -CUpwLMRoe_Flow::CUpwLMRoe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : - CUpwRoeBase_Flow(val_nDim, val_nVar, config, false) {} - -CUpwLMRoe_Flow::~CUpwLMRoe_Flow() {} - -void CUpwLMRoe_Flow::FinalizeResidual(su2double *val_residual, su2double **val_Jacobian_i, - su2double **val_Jacobian_j, CConfig *config) { - - /*--- Rieper, A low-Mach number fix for Roe's approximate Riemman Solver, JCP 2011 ---*/ - - unsigned short iVar, jVar, kVar, iDim; - - /*--- Clamped Mach number ---*/ - - su2double M_i = 0.0, M_j = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - M_i += Velocity_i[iDim]*Velocity_i[iDim]; - M_j += Velocity_j[iDim]*Velocity_j[iDim]; - } - M_i = sqrt(M_i / fabs(Pressure_i*Gamma/Density_i)); - M_j = sqrt(M_j / fabs(Pressure_j*Gamma/Density_j)); - - su2double zeta = max(0.05,min(max(M_i,M_j),1.0)); - - /*--- Compute wave amplitudes (characteristics) ---*/ - - su2double proj_delta_vel = 0.0, delta_vel[3]; - for (iDim = 0; iDim < nDim; iDim++) { - delta_vel[iDim] = Velocity_j[iDim] - Velocity_i[iDim]; - proj_delta_vel += delta_vel[iDim]*UnitNormal[iDim]; - } - proj_delta_vel *= zeta; - su2double delta_p = Pressure_j - Pressure_i; - su2double delta_rho = Density_j - Density_i; - - su2double delta_wave[5] = {0.0, 0.0, 0.0, 0.0, 0.0}; - if (nDim == 2) { - delta_wave[0] = delta_rho - delta_p/RoeSoundSpeed2; - delta_wave[1] = (UnitNormal[1]*delta_vel[0]-UnitNormal[0]*delta_vel[1]); - delta_wave[2] = proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); - delta_wave[3] = -proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); - } else { - delta_wave[0] = delta_rho - delta_p/RoeSoundSpeed2; - delta_wave[1] = (UnitNormal[0]*delta_vel[2]-UnitNormal[2]*delta_vel[0]); - delta_wave[2] = (UnitNormal[1]*delta_vel[0]-UnitNormal[0]*delta_vel[1]); - delta_wave[3] = proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); - delta_wave[4] = -proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); - } - - /*--- Update residual ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - for (kVar = 0; kVar < nVar; kVar++) - val_residual[iVar] -= (1.0-kappa)*Lambda[kVar]*delta_wave[kVar]*P_Tensor[iVar][kVar]*Area; - - if (!implicit) return; - - /*--- If implicit use the Jacobians of the standard Roe scheme as an approximation ---*/ - - GetPMatrix_inv(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, invP_Tensor); - - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - /*--- Compute |Proj_ModJac_Tensor| = P x |Lambda| x inverse P ---*/ - su2double Proj_ModJac_Tensor_ij = 0.0; - for (kVar = 0; kVar < nVar; kVar++) - Proj_ModJac_Tensor_ij += P_Tensor[iVar][kVar]*Lambda[kVar]*invP_Tensor[kVar][jVar]; - - val_Jacobian_i[iVar][jVar] += (1.0-kappa)*Proj_ModJac_Tensor_ij*Area; - val_Jacobian_j[iVar][jVar] -= (1.0-kappa)*Proj_ModJac_Tensor_ij*Area; - } - } - -} - -CUpwGeneralRoe_Flow::CUpwGeneralRoe_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ - dynamic_grid = config->GetDynamic_Grid(); - kappa = config->GetRoe_Kappa(); // 1 is unstable - - - Diff_U = new su2double [nVar]; - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; - RoeVelocity = new su2double [nDim]; - delta_vel = new su2double [nDim]; - delta_wave = new su2double [nVar]; - ProjFlux_i = new su2double [nVar]; - ProjFlux_j = new su2double [nVar]; - Lambda = new su2double [nVar]; - Epsilon = new su2double [nVar]; - P_Tensor = new su2double* [nVar]; - invP_Tensor = new su2double* [nVar]; - - for (iVar = 0; iVar < nVar; iVar++) { - P_Tensor[iVar] = new su2double [nVar]; - invP_Tensor[iVar] = new su2double [nVar]; - } -} - -CUpwGeneralRoe_Flow::~CUpwGeneralRoe_Flow(void) { - - delete [] Diff_U; - delete [] Velocity_i; - delete [] Velocity_j; - delete [] RoeVelocity; - delete [] delta_vel; - delete [] delta_wave; - delete [] ProjFlux_i; - delete [] ProjFlux_j; - delete [] Lambda; - delete [] Epsilon; - for (iVar = 0; iVar < nVar; iVar++) { - delete [] P_Tensor[iVar]; - delete [] invP_Tensor[iVar]; - } - delete [] P_Tensor; - delete [] invP_Tensor; - -} - -void CUpwGeneralRoe_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - AD::StartPreacc(); - AD::SetPreaccIn(V_i, nDim+4); AD::SetPreaccIn(V_j, nDim+4); AD::SetPreaccIn(Normal, nDim); - AD::SetPreaccIn(S_i, 2); AD::SetPreaccIn(S_j, 2); - if (dynamic_grid) { - AD::SetPreaccIn(GridVel_i, nDim); AD::SetPreaccIn(GridVel_j, nDim); - } - su2double U_i[5] = {0.0,0.0,0.0,0.0,0.0}, U_j[5] = {0.0,0.0,0.0,0.0,0.0}; - - /*--- Face area (norm or the normal vector) ---*/ - - Area = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - Area += Normal[iDim]*Normal[iDim]; - Area = sqrt(Area); - - /*-- Unit Normal ---*/ - - for (iDim = 0; iDim < nDim; iDim++) - UnitNormal[iDim] = Normal[iDim]/Area; - - /*--- Primitive variables at point i ---*/ - - Velocity2_i = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = V_i[iDim+1]; - Velocity2_i += Velocity_i[iDim]*Velocity_i[iDim]; - } - - Pressure_i = V_i[nDim+1]; - Density_i = V_i[nDim+2]; - Enthalpy_i = V_i[nDim+3]; - Energy_i = Enthalpy_i - Pressure_i/Density_i; - StaticEnthalpy_i = Enthalpy_i - 0.5*Velocity2_i; - StaticEnergy_i = StaticEnthalpy_i - Pressure_i/Density_i; - - Kappa_i = S_i[1]/Density_i; - Chi_i = S_i[0] - Kappa_i*StaticEnergy_i; - SoundSpeed_i = sqrt(Chi_i + StaticEnthalpy_i*Kappa_i); - - /*--- Primitive variables at point j ---*/ - - - Velocity2_j = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_j[iDim] = V_j[iDim+1]; - Velocity2_j += Velocity_j[iDim]*Velocity_j[iDim]; - } - - Pressure_j = V_j[nDim+1]; - Density_j = V_j[nDim+2]; - Enthalpy_j = V_j[nDim+3]; - Energy_j = Enthalpy_j - Pressure_j/Density_j; - - StaticEnthalpy_j = Enthalpy_j - 0.5*Velocity2_j; - StaticEnergy_j = StaticEnthalpy_j - Pressure_j/Density_j; - - Kappa_j = S_j[1]/Density_j; - Chi_j = S_j[0] - Kappa_j*StaticEnergy_j; - SoundSpeed_j = sqrt(Chi_j + StaticEnthalpy_j*Kappa_j); - - /*--- Recompute conservative variables ---*/ - - U_i[0] = Density_i; U_j[0] = Density_j; - for (iDim = 0; iDim < nDim; iDim++) { - U_i[iDim+1] = Density_i*Velocity_i[iDim]; U_j[iDim+1] = Density_j*Velocity_j[iDim]; - } - U_i[nDim+1] = Density_i*Energy_i; U_j[nDim+1] = Density_j*Energy_j; - -// /*--- Roe-averaged variables at interface between i & j ---*/ - - ComputeRoeAverage(); - - if (RoeSoundSpeed2 <= 0.0) { - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] = 0.0; - for (jVar = 0; jVar < nVar; jVar++) { - val_Jacobian_i[iVar][iVar] = 0.0; - val_Jacobian_j[iVar][iVar] = 0.0; - } - } - return; - } - - RoeSoundSpeed = sqrt(RoeSoundSpeed2); - - /*--- Compute ProjFlux_i ---*/ - GetInviscidProjFlux(&Density_i, Velocity_i, &Pressure_i, &Enthalpy_i, Normal, ProjFlux_i); - - /*--- Compute ProjFlux_j ---*/ - GetInviscidProjFlux(&Density_j, Velocity_j, &Pressure_j, &Enthalpy_j, Normal, ProjFlux_j); - - /*--- Compute P and Lambda (do it with the Normal) ---*/ - - GetPMatrix(&RoeDensity, RoeVelocity, &RoeSoundSpeed, &RoeEnthalpy, &RoeChi, &RoeKappa, UnitNormal, P_Tensor); - - ProjVelocity = 0.0; ProjVelocity_i = 0.0; ProjVelocity_j = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - ProjVelocity += RoeVelocity[iDim]*UnitNormal[iDim]; - ProjVelocity_i += Velocity_i[iDim]*UnitNormal[iDim]; - ProjVelocity_j += Velocity_j[iDim]*UnitNormal[iDim]; - } - - /*--- Projected velocity adjustment due to mesh motion ---*/ - if (dynamic_grid) { - su2double ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*UnitNormal[iDim]; - } - ProjVelocity -= ProjGridVel; - ProjVelocity_i -= ProjGridVel; - ProjVelocity_j -= ProjGridVel; - } - - /*--- Flow eigenvalues and entropy correctors ---*/ - for (iDim = 0; iDim < nDim; iDim++) - Lambda[iDim] = ProjVelocity; - - Lambda[nVar-2] = ProjVelocity + RoeSoundSpeed; - Lambda[nVar-1] = ProjVelocity - RoeSoundSpeed; - - /*--- Compute absolute value with Mavriplis' entropy correction ---*/ - - MaxLambda = fabs(ProjVelocity) + RoeSoundSpeed; - Delta = config->GetEntropyFix_Coeff(); - - for (iVar = 0; iVar < nVar; iVar++) { - Lambda[iVar] = max(fabs(Lambda[iVar]), Delta*MaxLambda); - } - -// /*--- Harten and Hyman (1983) entropy correction ---*/ -// for (iDim = 0; iDim < nDim; iDim++) -// Epsilon[iDim] = 4.0*max(0.0, max(Lambda[iDim]-ProjVelocity_i, ProjVelocity_j-Lambda[iDim])); -// -// Epsilon[nVar-2] = 4.0*max(0.0, max(Lambda[nVar-2]-(ProjVelocity_i+SoundSpeed_i),(ProjVelocity_j+SoundSpeed_j)-Lambda[nVar-2])); -// Epsilon[nVar-1] = 4.0*max(0.0, max(Lambda[nVar-1]-(ProjVelocity_i-SoundSpeed_i),(ProjVelocity_j-SoundSpeed_j)-Lambda[nVar-1])); -// -// for (iVar = 0; iVar < nVar; iVar++) -// if ( fabs(Lambda[iVar]) < Epsilon[iVar] ) -// Lambda[iVar] = (Lambda[iVar]*Lambda[iVar] + Epsilon[iVar]*Epsilon[iVar])/(2.0*Epsilon[iVar]); -// else -// Lambda[iVar] = fabs(Lambda[iVar]); - -// for (iVar = 0; iVar < nVar; iVar++) -// Lambda[iVar] = fabs(Lambda[iVar]); - - if (!implicit) { - - /*--- Compute wave amplitudes (characteristics) ---*/ - proj_delta_vel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - delta_vel[iDim] = Velocity_j[iDim] - Velocity_i[iDim]; - proj_delta_vel += delta_vel[iDim]*Normal[iDim]; - } - delta_p = Pressure_j - Pressure_i; - delta_rho = Density_j - Density_i; - proj_delta_vel = proj_delta_vel/Area; - - if (nDim == 2) { - delta_wave[0] = delta_rho - delta_p/(RoeSoundSpeed*RoeSoundSpeed); - delta_wave[1] = UnitNormal[1]*delta_vel[0]-UnitNormal[0]*delta_vel[1]; - delta_wave[2] = proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); - delta_wave[3] = -proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); - } else { - delta_wave[0] = delta_rho - delta_p/(RoeSoundSpeed*RoeSoundSpeed); - delta_wave[1] = UnitNormal[0]*delta_vel[2]-UnitNormal[2]*delta_vel[0]; - delta_wave[2] = UnitNormal[1]*delta_vel[0]-UnitNormal[0]*delta_vel[1]; - delta_wave[3] = proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); - delta_wave[4] = -proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); - } - - /*--- Roe's Flux approximation ---*/ - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] = 0.5*(ProjFlux_i[iVar]+ProjFlux_j[iVar]); - for (jVar = 0; jVar < nVar; jVar++) - val_residual[iVar] -= 0.5*Lambda[jVar]*delta_wave[jVar]*P_Tensor[iVar][jVar]*Area; - } - - /*--- Flux contribution due to grid motion ---*/ - if (dynamic_grid) { - ProjVelocity = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjVelocity += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] -= ProjVelocity * 0.5*(U_i[iVar]+U_j[iVar]); - } - } - } - else { - - /*--- Compute inverse P ---*/ - - GetPMatrix_inv(invP_Tensor, &RoeDensity, RoeVelocity, &RoeSoundSpeed, &RoeChi , &RoeKappa, UnitNormal); - - /*--- Jacobians of the inviscid flux, scaled by - kappa because val_resconv ~ kappa*(fc_i+fc_j)*Normal ---*/ - - GetInviscidProjJac(Velocity_i, &Enthalpy_i, &Chi_i, &Kappa_i, Normal, kappa, val_Jacobian_i); - - GetInviscidProjJac(Velocity_j, &Enthalpy_j, &Chi_j, &Kappa_j, Normal, kappa, val_Jacobian_j); - - - /*--- Diference variables iPoint and jPoint ---*/ - for (iVar = 0; iVar < nVar; iVar++) - Diff_U[iVar] = U_j[iVar]-U_i[iVar]; - - /*--- Roe's Flux approximation ---*/ - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] = kappa*(ProjFlux_i[iVar]+ProjFlux_j[iVar]); - for (jVar = 0; jVar < nVar; jVar++) { - Proj_ModJac_Tensor_ij = 0.0; - - /*--- Compute |Proj_ModJac_Tensor| = P x |Lambda| x inverse P ---*/ - - for (kVar = 0; kVar < nVar; kVar++) - Proj_ModJac_Tensor_ij += P_Tensor[iVar][kVar]*Lambda[kVar]*invP_Tensor[kVar][jVar]; - - val_residual[iVar] -= (1.0-kappa)*Proj_ModJac_Tensor_ij*Diff_U[jVar]*Area; - val_Jacobian_i[iVar][jVar] += (1.0-kappa)*Proj_ModJac_Tensor_ij*Area; - val_Jacobian_j[iVar][jVar] -= (1.0-kappa)*Proj_ModJac_Tensor_ij*Area; - } - } - - /*--- Jacobian contributions due to grid motion ---*/ - if (dynamic_grid) { - ProjVelocity = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjVelocity += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] -= ProjVelocity * 0.5*(U_i[iVar]+U_j[iVar]); - /*--- Implicit terms ---*/ - val_Jacobian_i[iVar][iVar] -= 0.5*ProjVelocity; - val_Jacobian_j[iVar][iVar] -= 0.5*ProjVelocity; - } - } - - } - - AD::SetPreaccOut(val_residual, nVar); - AD::EndPreacc(); -} - - -void CUpwGeneralRoe_Flow::ComputeRoeAverage() { - - //su2double delta_rhoStaticEnergy, err_P, s, D; - // su2double tol = 10-6; - - R = sqrt(fabs(Density_j/Density_i)); - RoeDensity = R*Density_i; - sq_vel = 0; for (iDim = 0; iDim < nDim; iDim++) { - RoeVelocity[iDim] = (R*Velocity_j[iDim]+Velocity_i[iDim])/(R+1); - sq_vel += RoeVelocity[iDim]*RoeVelocity[iDim]; - } - - RoeEnthalpy = (R*Enthalpy_j+Enthalpy_i)/(R+1); - delta_rho = Density_j - Density_i; - delta_p = Pressure_j - Pressure_i; - RoeKappa = 0.5*(Kappa_i + Kappa_j); - RoeKappa = (Kappa_i + Kappa_j + 4*RoeKappa)/6; - RoeChi = 0.5*(Chi_i + Chi_j); - RoeChi = (Chi_i + Chi_j + 4*RoeChi)/6; - - -// RoeKappaStaticEnthalpy = 0.5*(StaticEnthalpy_i*Kappa_i + StaticEnthalpy_j*Kappa_j); -// RoeKappaStaticEnthalpy = (StaticEnthalpy_i*Kappa_i + StaticEnthalpy_j*Kappa_j + 4*RoeKappaStaticEnthalpy)/6; -// s = RoeChi + RoeKappaStaticEnthalpy; -// D = s*s*delta_rho*delta_rho + delta_p*delta_p; -// delta_rhoStaticEnergy = Density_j*StaticEnergy_j - Density_i*StaticEnergy_i; -// err_P = delta_p - RoeChi*delta_rho - RoeKappa*delta_rhoStaticEnergy; -// -// -// if (abs((D - delta_p*err_P)/Density_i)>1e-3 && abs(delta_rho/Density_i)>1e-3 && s/Density_i > 1e-3) { -// -// RoeKappa = (D*RoeKappa)/(D - delta_p*err_P); -// RoeChi = (D*RoeChi+ s*s*delta_rho*err_P)/(D - delta_p*err_P); -// -// } - - RoeSoundSpeed2 = RoeChi + RoeKappa*(RoeEnthalpy-0.5*sq_vel); - -} - -CUpwMSW_Flow::CUpwMSW_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - if (config->GetDynamic_Grid() && (SU2_MPI::GetRank() == MASTER_NODE)) - cout << "WARNING: Grid velocities are NOT yet considered in the MSW scheme." << endl; - - /*--- Set booleans from CConfig settings ---*/ - implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - - /*--- Allocate arrays ---*/ - Diff_U = new su2double [nVar]; - Fc_i = new su2double [nVar]; - Fc_j = new su2double [nVar]; - Lambda_i = new su2double [nVar]; - Lambda_j = new su2double [nVar]; - - u_i = new su2double [nDim]; - u_j = new su2double [nDim]; - ust_i = new su2double [nDim]; - ust_j = new su2double [nDim]; - Vst_i = new su2double [nPrimVar]; - Vst_j = new su2double [nPrimVar]; - Ust_i = new su2double [nVar]; - Ust_j = new su2double [nVar]; - - Velst_i = new su2double [nDim]; - Velst_j = new su2double [nDim]; - - P_Tensor = new su2double* [nVar]; - invP_Tensor = new su2double* [nVar]; - for (unsigned short iVar = 0; iVar < nVar; iVar++) { - P_Tensor[iVar] = new su2double [nVar]; - invP_Tensor[iVar] = new su2double [nVar]; - } - -} - -CUpwMSW_Flow::~CUpwMSW_Flow(void) { - - delete [] Diff_U; - delete [] Fc_i; - delete [] Fc_j; - delete [] Lambda_i; - delete [] Lambda_j; - - delete [] u_i; - delete [] u_j; - delete [] ust_i; - delete [] ust_j; - delete [] Ust_i; - delete [] Vst_i; - delete [] Ust_j; - delete [] Vst_j; - delete [] Velst_i; - delete [] Velst_j; - - for (unsigned short iVar = 0; iVar < nVar; iVar++) { - delete [] P_Tensor[iVar]; - delete [] invP_Tensor[iVar]; - } - delete [] P_Tensor; - delete [] invP_Tensor; - -} - -void CUpwMSW_Flow::ComputeResidual(su2double *val_residual, - su2double **val_Jacobian_i, - su2double **val_Jacobian_j, CConfig *config) { - - unsigned short iDim, iVar, jVar, kVar; - su2double P_i, P_j; - su2double ProjVel_i, ProjVel_j, ProjVelst_i, ProjVelst_j; - su2double sqvel_i, sqvel_j; - su2double alpha, w, dp, onemw; - su2double Proj_ModJac_Tensor_i, Proj_ModJac_Tensor_j; - - /*--- Set parameters in the numerical method ---*/ - alpha = 6.0; - - /*--- Calculate supporting geometry parameters ---*/ - - Area = 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; - - /*--- Initialize flux & Jacobian vectors ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - Fc_i[iVar] = 0.0; - Fc_j[iVar] = 0.0; - } - if (implicit) { - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - val_Jacobian_i[iVar][jVar] = 0.0; - val_Jacobian_j[iVar][jVar] = 0.0; - } - } - } - - /*--- Load variables from nodes i & j ---*/ - - rhos_i = V_i[0]; - rhos_j = V_j[0]; - for (iDim = 0; iDim < nDim; iDim++) { - u_i[iDim] = V_i[iDim+1]; - u_j[iDim] = V_j[iDim+1]; - } - P_i = V_i[nDim+1]; - P_j = V_j[nDim+1]; - - /*--- Calculate supporting quantities ---*/ - - sqvel_i = 0.0; sqvel_j = 0.0; - ProjVel_i = 0.0; ProjVel_j = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - sqvel_i += u_i[iDim]*u_i[iDim]; - sqvel_j += u_j[iDim]*u_j[iDim]; - ProjVel_i += u_i[iDim]*UnitNormal[iDim]; - ProjVel_j += u_j[iDim]*UnitNormal[iDim]; - } - - /*--- Calculate the state weighting function ---*/ - - dp = fabs(P_j-P_i) / min(P_j, P_i); - w = 0.5 * (1.0/(pow(alpha*dp,2.0) +1.0)); - onemw = 1.0 - w; - - /*--- Calculate weighted state vector (*) for i & j ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - Ust_i[iVar] = onemw*U_i[iVar] + w*U_j[iVar]; - Ust_j[iVar] = onemw*U_j[iVar] + w*U_i[iVar]; - } - for (iVar = 0; iVar < nDim+5; iVar++) { - Vst_i[iVar] = onemw*V_i[iVar] + w*V_j[iVar]; - Vst_j[iVar] = onemw*V_j[iVar] + w*V_i[iVar]; - } - ProjVelst_i = onemw*ProjVel_i + w*ProjVel_j; - ProjVelst_j = onemw*ProjVel_j + w*ProjVel_i; - - for (iDim = 0; iDim < nDim; iDim++) { - Velst_i[iDim] = Vst_i[iDim+1]; - Velst_j[iDim] = Vst_j[iDim+1]; - } - - /*--- Flow eigenvalues at i (Lambda+) ---*/ - - for (iDim = 0; iDim < nDim; iDim++) { - Lambda_i[iDim] = 0.5*(ProjVelst_i + fabs(ProjVelst_i)); - } - - Lambda_i[nDim] = 0.5*( ProjVelst_i + Vst_i[nDim+4] + fabs(ProjVelst_i + Vst_i[nDim+4]) ); - Lambda_i[nDim+1] = 0.5*( ProjVelst_i - Vst_i[nDim+4] + fabs(ProjVelst_i - Vst_i[nDim+4]) ); - - /*--- Compute projected P, invP, and Lambda ---*/ - - GetPMatrix(&Vst_i[nDim+2], Velst_i, &Vst_i[nDim+4], UnitNormal, P_Tensor); - GetPMatrix_inv(&Vst_i[nDim+2], Velst_i, &Vst_i[nDim+4], UnitNormal, invP_Tensor); - - /*--- Projected flux (f+) at i ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - Proj_ModJac_Tensor_i = 0.0; - - /*--- Compute Proj_ModJac_Tensor = P x Lambda+ x inverse P ---*/ - - for (kVar = 0; kVar < nVar; kVar++) - Proj_ModJac_Tensor_i += P_Tensor[iVar][kVar]*Lambda_i[kVar]*invP_Tensor[kVar][jVar]; - Fc_i[iVar] += Proj_ModJac_Tensor_i*U_i[jVar]*Area; - if (implicit) - val_Jacobian_i[iVar][jVar] += Proj_ModJac_Tensor_i*Area; - } - } - - /*--- Flow eigenvalues at j (Lambda-) ---*/ - - for (iDim = 0; iDim < nDim; iDim++) { - Lambda_j[iDim] = 0.5*(ProjVelst_j - fabs(ProjVelst_j)); - } - Lambda_j[nDim] = 0.5*( ProjVelst_j + Vst_j[nDim+4] - - fabs(ProjVelst_j + Vst_j[nDim+4]) ); - Lambda_j[nDim+1] = 0.5*( ProjVelst_j - Vst_j[nDim+4] - - fabs(ProjVelst_j - Vst_j[nDim+4]) ); - - /*--- Compute projected P, invP, and Lambda ---*/ - - GetPMatrix(&Vst_j[nDim+2], Velst_j, &Vst_j[nDim+4], UnitNormal, P_Tensor); - GetPMatrix_inv(&Vst_j[nDim+2], Velst_j, &Vst_j[nDim+4], UnitNormal, invP_Tensor); - - /*--- Projected flux (f-) ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - Proj_ModJac_Tensor_j = 0.0; - /*--- Compute Proj_ModJac_Tensor = P x Lambda- x inverse P ---*/ - for (kVar = 0; kVar < nVar; kVar++) - Proj_ModJac_Tensor_j += P_Tensor[iVar][kVar]*Lambda_j[kVar]*invP_Tensor[kVar][jVar]; - Fc_j[iVar] += Proj_ModJac_Tensor_j*U_j[jVar]*Area; - if (implicit) - val_Jacobian_j[iVar][jVar] += Proj_ModJac_Tensor_j*Area; - } - } - - /*--- Flux splitting ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] = Fc_i[iVar]+Fc_j[iVar]; - } - -} - -CUpwTurkel_Flow::CUpwTurkel_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ - dynamic_grid = config->GetDynamic_Grid(); - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - Beta_min = config->GetminTurkelBeta(); - Beta_max = config->GetmaxTurkelBeta(); - - Diff_U = new su2double [nVar]; - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; - RoeVelocity = new su2double [nDim]; - ProjFlux_i = new su2double [nVar]; - ProjFlux_j = new su2double [nVar]; - Lambda = new su2double [nVar]; - Epsilon = new su2double [nVar]; - absPeJac = new su2double* [nVar]; - invRinvPe = new su2double* [nVar]; - R_Tensor = new su2double* [nVar]; - Matrix = new su2double* [nVar]; - Art_Visc = new su2double* [nVar]; - for (iVar = 0; iVar < nVar; iVar++) { - absPeJac[iVar] = new su2double [nVar]; - invRinvPe[iVar] = new su2double [nVar]; - Matrix[iVar] = new su2double [nVar]; - Art_Visc[iVar] = new su2double [nVar]; - R_Tensor[iVar] = new su2double [nVar]; - } -} - -CUpwTurkel_Flow::~CUpwTurkel_Flow(void) { - - delete [] Diff_U; - delete [] Velocity_i; - delete [] Velocity_j; - delete [] RoeVelocity; - delete [] ProjFlux_i; - delete [] ProjFlux_j; - delete [] Lambda; - delete [] Epsilon; - for (iVar = 0; iVar < nVar; iVar++) { - delete [] absPeJac[iVar]; - delete [] invRinvPe[iVar]; - delete [] Matrix[iVar]; - delete [] Art_Visc[iVar]; - delete [] R_Tensor[iVar]; - } - delete [] Matrix; - delete [] Art_Visc; - delete [] absPeJac; - delete [] invRinvPe; - delete [] R_Tensor; - -} - -void CUpwTurkel_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - su2double U_i[5] = {0.0,0.0,0.0,0.0,0.0}, U_j[5] = {0.0,0.0,0.0,0.0,0.0}; - - /*--- Face area (norm or the normal vector) ---*/ - - Area = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - Area += Normal[iDim]*Normal[iDim]; - Area = sqrt(Area); - - /*-- Unit Normal ---*/ - - for (iDim = 0; iDim < nDim; iDim++) - UnitNormal[iDim] = Normal[iDim]/Area; - - /*--- Primitive variables at point i ---*/ - - for (iDim = 0; iDim < nDim; iDim++) - Velocity_i[iDim] = V_i[iDim+1]; - Pressure_i = V_i[nDim+1]; - Density_i = V_i[nDim+2]; - Enthalpy_i = V_i[nDim+3]; - Energy_i = Enthalpy_i - Pressure_i/Density_i; - SoundSpeed_i = sqrt(fabs(Pressure_i*Gamma/Density_i)); - - /*--- Primitive variables at point j ---*/ - - for (iDim = 0; iDim < nDim; iDim++) - Velocity_j[iDim] = V_j[iDim+1]; - Pressure_j = V_j[nDim+1]; - Density_j = V_j[nDim+2]; - Enthalpy_j = V_j[nDim+3]; - Energy_j = Enthalpy_j - Pressure_j/Density_j; - SoundSpeed_j = sqrt(fabs(Pressure_j*Gamma/Density_j)); - - /*--- Recompute conservative variables ---*/ - - U_i[0] = Density_i; U_j[0] = Density_j; - for (iDim = 0; iDim < nDim; iDim++) { - U_i[iDim+1] = Density_i*Velocity_i[iDim]; U_j[iDim+1] = Density_j*Velocity_j[iDim]; - } - U_i[nDim+1] = Density_i*Energy_i; U_j[nDim+1] = Density_j*Energy_j; - - /*--- Roe-averaged variables at interface between i & j ---*/ - - R = sqrt(fabs(Density_j/Density_i)); - RoeDensity = R*Density_i; - sq_vel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - RoeVelocity[iDim] = (R*Velocity_j[iDim]+Velocity_i[iDim])/(R+1); - sq_vel += RoeVelocity[iDim]*RoeVelocity[iDim]; - } - RoeEnthalpy = (R*Enthalpy_j+Enthalpy_i)/(R+1); - RoeSoundSpeed = sqrt(fabs((Gamma-1)*(RoeEnthalpy-0.5*sq_vel))); - RoePressure = RoeDensity/Gamma*RoeSoundSpeed*RoeSoundSpeed; - - /*--- Compute ProjFlux_i ---*/ - GetInviscidProjFlux(&Density_i, Velocity_i, &Pressure_i, &Enthalpy_i, Normal, ProjFlux_i); - - /*--- Compute ProjFlux_j ---*/ - GetInviscidProjFlux(&Density_j, Velocity_j, &Pressure_j, &Enthalpy_j, Normal, ProjFlux_j); - - ProjVelocity = 0.0; ProjVelocity_i = 0.0; ProjVelocity_j = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - ProjVelocity += RoeVelocity[iDim]*UnitNormal[iDim]; - ProjVelocity_i += Velocity_i[iDim]*UnitNormal[iDim]; - ProjVelocity_j += Velocity_j[iDim]*UnitNormal[iDim]; - } - - /*--- Projected velocity adjustment due to mesh motion ---*/ - if (dynamic_grid) { - su2double ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*UnitNormal[iDim]; - } - ProjVelocity -= ProjGridVel; - ProjVelocity_i -= ProjGridVel; - ProjVelocity_j -= ProjGridVel; - } - - /*--- First few flow eigenvalues of A.Normal with the normal---*/ - for (iDim = 0; iDim < nDim; iDim++) - Lambda[iDim] = ProjVelocity; - - local_Mach = sqrt(sq_vel)/RoeSoundSpeed; - Beta = max(Beta_min, min(local_Mach, Beta_max)); - Beta2 = Beta*Beta; - - one_m_Betasqr = 1.0 - Beta2; // 1-Beta*Beta - one_p_Betasqr = 1.0 + Beta2; // 1+Beta*Beta - sqr_one_m_Betasqr_Lam1 = pow((one_m_Betasqr*Lambda[0]),2); // [(1-Beta^2)*Lambda[0]]^2 - sqr_two_Beta_c_Area = pow(2.0*Beta*RoeSoundSpeed*Area,2); // [2*Beta*c*Area]^2 - - /*--- The rest of the flow eigenvalues of preconditioned matrix---*/ - Lambda[nVar-2] = 0.5 * ( one_p_Betasqr*Lambda[0] + sqrt( sqr_one_m_Betasqr_Lam1 + sqr_two_Beta_c_Area)); - Lambda[nVar-1] = 0.5 * ( one_p_Betasqr*Lambda[0] - sqrt( sqr_one_m_Betasqr_Lam1 + sqr_two_Beta_c_Area)); - - s_hat = 1.0/Area * (Lambda[nVar-1] - Lambda[0]*Beta2); - r_hat = 1.0/Area * (Lambda[nVar-2] - Lambda[0]*Beta2); - t_hat = 0.5/Area * (Lambda[nVar-1] - Lambda[nVar-2]); - rhoB2a2 = RoeDensity*Beta2*RoeSoundSpeed*RoeSoundSpeed; - - /*--- Diference variables iPoint and jPoint and absolute value of the eigen values---*/ - for (iVar = 0; iVar < nVar; iVar++) { - Diff_U[iVar] = U_j[iVar]-U_i[iVar]; - Lambda[iVar] = fabs(Lambda[iVar]); - } - - /*--- Compute the absolute Preconditioned Jacobian in entropic Variables (do it with the Unitary Normal) ---*/ - GetPrecondJacobian(Beta2, r_hat, s_hat, t_hat, rhoB2a2, Lambda, UnitNormal, absPeJac); - - /*--- Compute the matrix from entropic variables to conserved variables ---*/ - GetinvRinvPe(Beta2, RoeEnthalpy, RoeSoundSpeed, RoeDensity, RoeVelocity, invRinvPe); - - /*--- Compute the matrix from entropic variables to conserved variables ---*/ - GetRMatrix(RoePressure, RoeSoundSpeed, RoeDensity, RoeVelocity, R_Tensor); - - if (implicit) { - /*--- Jacobians of the inviscid flux, scaled by - 0.5 because val_residual ~ 0.5*(fc_i+fc_j)*Normal ---*/ - GetInviscidProjJac(Velocity_i, &Energy_i, Normal, 0.5, val_Jacobian_i); - GetInviscidProjJac(Velocity_j, &Energy_j, Normal, 0.5, val_Jacobian_j); - } - - for (iVar = 0; iVar < nVar; iVar ++) { - for (jVar = 0; jVar < nVar; jVar ++) { - Matrix[iVar][jVar] = 0.0; - for (kVar = 0; kVar < nVar; kVar++) - Matrix[iVar][jVar] += absPeJac[iVar][kVar]*R_Tensor[kVar][jVar]; - } - } - - for (iVar = 0; iVar < nVar; iVar ++) { - for (jVar = 0; jVar < nVar; jVar ++) { - Art_Visc[iVar][jVar] = 0.0; - for (kVar = 0; kVar < nVar; kVar++) - Art_Visc[iVar][jVar] += invRinvPe[iVar][kVar]*Matrix[kVar][jVar]; - } - } - - /*--- Roe's Flux approximation ---*/ - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] = 0.5*(ProjFlux_i[iVar]+ProjFlux_j[iVar]); - for (jVar = 0; jVar < nVar; jVar++) { - val_residual[iVar] -= 0.5*Art_Visc[iVar][jVar]*Diff_U[jVar]; - if (implicit) { - val_Jacobian_i[iVar][jVar] += 0.5*Art_Visc[iVar][jVar]; - val_Jacobian_j[iVar][jVar] -= 0.5*Art_Visc[iVar][jVar]; - } - } - } - - /*--- Contributions due to mesh motion---*/ - if (dynamic_grid) { - ProjVelocity = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjVelocity += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*UnitNormal[iDim]; - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] -= ProjVelocity * 0.5*(U_i[iVar]+U_j[iVar]); - /*--- Implicit terms ---*/ - if (implicit) { - val_Jacobian_i[iVar][iVar] -= 0.5*ProjVelocity; - val_Jacobian_j[iVar][iVar] -= 0.5*ProjVelocity; - } - } - } - -} - -CAvgGrad_Base::CAvgGrad_Base(unsigned short val_nDim, - unsigned short val_nVar, - unsigned short val_nPrimVar, - bool val_correct_grad, - CConfig *config) - : CNumerics(val_nDim, val_nVar, config), - nPrimVar(val_nPrimVar), - correct_gradient(val_correct_grad) { - - unsigned short iVar, iDim; - - implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - - TauWall_i = 0; TauWall_j = 0; - - PrimVar_i = new su2double [nPrimVar]; - PrimVar_j = new su2double [nPrimVar]; - Mean_PrimVar = new su2double [nPrimVar]; - - Mean_GradPrimVar = new su2double* [nPrimVar]; - for (iVar = 0; iVar < nPrimVar; iVar++) - Mean_GradPrimVar[iVar] = new su2double [nDim]; - - Edge_Vector = new su2double[nDim]; - - if (correct_gradient) { - Proj_Mean_GradPrimVar_Edge = new su2double[val_nPrimVar]; - } else { - Proj_Mean_GradPrimVar_Edge = NULL; - } - - tau_jacobian_i = new su2double* [nDim]; - for (iDim = 0; iDim < nDim; iDim++) { - tau_jacobian_i[iDim] = new su2double [nVar]; - } - heat_flux_vector = new su2double[nDim]; - heat_flux_jac_i = new su2double[nVar]; - -} - -CAvgGrad_Base::~CAvgGrad_Base() { - - delete [] PrimVar_i; - delete [] PrimVar_j; - delete [] Mean_PrimVar; - for (unsigned short iVar = 0; iVar < nPrimVar; iVar++) - delete [] Mean_GradPrimVar[iVar]; - delete [] Mean_GradPrimVar; - - if (tau_jacobian_i != NULL) { - for (unsigned short iDim = 0; iDim < nDim; iDim++) { - delete [] tau_jacobian_i[iDim]; - } - delete [] tau_jacobian_i; - } - if (heat_flux_vector != NULL) { - delete [] heat_flux_vector; - } - if (heat_flux_jac_i != NULL) { - delete [] heat_flux_jac_i; - } - - delete [] Edge_Vector; - if (Proj_Mean_GradPrimVar_Edge != NULL) - delete [] Proj_Mean_GradPrimVar_Edge; -} - -void CAvgGrad_Base::CorrectGradient(su2double** GradPrimVar, - const su2double* val_PrimVar_i, - const su2double* val_PrimVar_j, - const su2double* val_edge_vector, - const su2double val_dist_ij_2, - const unsigned short val_nPrimVar) { - for (unsigned short iVar = 0; iVar < val_nPrimVar; iVar++) { - Proj_Mean_GradPrimVar_Edge[iVar] = 0.0; - for (unsigned short iDim = 0; iDim < nDim; iDim++) { - Proj_Mean_GradPrimVar_Edge[iVar] += GradPrimVar[iVar][iDim]*val_edge_vector[iDim]; - } - for (unsigned short iDim = 0; iDim < nDim; iDim++) { - GradPrimVar[iVar][iDim] -= (Proj_Mean_GradPrimVar_Edge[iVar] - - (val_PrimVar_j[iVar]-val_PrimVar_i[iVar]))*val_edge_vector[iDim] / val_dist_ij_2; - } - } -} - -void CAvgGrad_Base::SetStressTensor(const su2double *val_primvar, - const su2double* const *val_gradprimvar, - const su2double val_turb_ke, - const su2double val_laminar_viscosity, - const su2double val_eddy_viscosity) { - - unsigned short iDim, jDim; - const su2double Density = val_primvar[nDim+2]; - const su2double total_viscosity = val_laminar_viscosity + val_eddy_viscosity; - - su2double div_vel = 0.0; - for (iDim = 0 ; iDim < nDim; iDim++) - div_vel += val_gradprimvar[iDim+1][iDim]; - - /* --- If UQ methodology is used, calculate tau using the perturbed reynolds stress tensor --- */ - - if (using_uq){ - for (iDim = 0 ; iDim < nDim; iDim++) - for (jDim = 0 ; jDim < nDim; jDim++) - tau[iDim][jDim] = val_laminar_viscosity*( val_gradprimvar[jDim+1][iDim] + val_gradprimvar[iDim+1][jDim] ) - - TWO3*val_laminar_viscosity*div_vel*delta[iDim][jDim] - Density * MeanPerturbedRSM[iDim][jDim]; - - } else { - - 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]; - } -} - -void CAvgGrad_Base::AddQCR(const su2double* const *val_gradprimvar) { - - su2double den_aux, c_cr1= 0.3, O_ik, O_jk; - unsigned short iDim, jDim, kDim; - - /*--- Denominator Antisymmetric normalized rotation tensor ---*/ - - den_aux = 0.0; - for (iDim = 0 ; iDim < nDim; iDim++) - for (jDim = 0 ; jDim < nDim; jDim++) - den_aux += val_gradprimvar[iDim+1][jDim] * val_gradprimvar[iDim+1][jDim]; - den_aux = sqrt(max(den_aux,1E-10)); - - /*--- Adding the QCR contribution ---*/ - - for (iDim = 0 ; iDim < nDim; iDim++){ - for (jDim = 0 ; jDim < nDim; jDim++){ - for (kDim = 0 ; kDim < nDim; kDim++){ - O_ik = (val_gradprimvar[iDim+1][kDim] - val_gradprimvar[kDim+1][iDim])/ den_aux; - O_jk = (val_gradprimvar[jDim+1][kDim] - val_gradprimvar[kDim+1][jDim])/ den_aux; - tau[iDim][jDim] -= c_cr1 * ((O_ik * tau[jDim][kDim]) + (O_jk * tau[iDim][kDim])); - } - } - } -} - -void CAvgGrad_Base::AddTauWall(const su2double *val_normal, - const su2double val_tau_wall) { - - unsigned short iDim, jDim; - su2double TauNormal, TauElem[3], TauTangent[3], WallShearStress, Area, UnitNormal[3]; - - Area = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - Area += val_normal[iDim]*val_normal[iDim]; - Area = sqrt(Area); - - for (iDim = 0; iDim < nDim; iDim++) - UnitNormal[iDim] = val_normal[iDim]/Area; - - /*--- First, compute wall shear stress as the magnitude of the wall-tangential - component of the shear stress tensor---*/ - - for (iDim = 0; iDim < nDim; iDim++) { - TauElem[iDim] = 0.0; - for (jDim = 0; jDim < nDim; jDim++) - TauElem[iDim] += tau[iDim][jDim]*UnitNormal[jDim]; - } - - TauNormal = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - TauNormal += TauElem[iDim] * UnitNormal[iDim]; - - for (iDim = 0; iDim < nDim; iDim++) - TauTangent[iDim] = TauElem[iDim] - TauNormal * UnitNormal[iDim]; - - WallShearStress = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - WallShearStress += TauTangent[iDim]*TauTangent[iDim]; - WallShearStress = sqrt(WallShearStress); - - /*--- Scale the stress tensor by the ratio of the wall shear stress - to the computed representation of the shear stress ---*/ - - for (iDim = 0 ; iDim < nDim; iDim++) - for (jDim = 0 ; jDim < nDim; jDim++) - tau[iDim][jDim] = tau[iDim][jDim]*(val_tau_wall/WallShearStress); -} - -void CAvgGrad_Base::GetMeanRateOfStrainMatrix(su2double **S_ij) const -{ - /* --- Calculate the rate of strain tensor, using mean velocity gradients --- */ - - if (nDim == 3){ - S_ij[0][0] = Mean_GradPrimVar[1][0]; - S_ij[1][1] = Mean_GradPrimVar[2][1]; - S_ij[2][2] = Mean_GradPrimVar[3][2]; - S_ij[0][1] = 0.5 * (Mean_GradPrimVar[1][1] + Mean_GradPrimVar[2][0]); - S_ij[0][2] = 0.5 * (Mean_GradPrimVar[1][2] + Mean_GradPrimVar[3][0]); - S_ij[1][2] = 0.5 * (Mean_GradPrimVar[2][2] + Mean_GradPrimVar[3][1]); - S_ij[1][0] = S_ij[0][1]; - S_ij[2][1] = S_ij[1][2]; - S_ij[2][0] = S_ij[0][2]; - } - else { - S_ij[0][0] = Mean_GradPrimVar[1][0]; - S_ij[1][1] = Mean_GradPrimVar[2][1]; - S_ij[2][2] = 0.0; - S_ij[0][1] = 0.5 * (Mean_GradPrimVar[1][1] + Mean_GradPrimVar[2][0]); - S_ij[0][2] = 0.0; - S_ij[1][2] = 0.0; - S_ij[1][0] = S_ij[0][1]; - S_ij[2][1] = S_ij[1][2]; - S_ij[2][0] = S_ij[0][2]; - - } -} - -void CAvgGrad_Base::SetReynoldsStressMatrix(su2double turb_ke){ - unsigned short iDim, jDim; - su2double **S_ij = new su2double* [3]; - su2double muT = Mean_Eddy_Viscosity; - su2double divVel = 0; - su2double density; - su2double TWO3 = 2.0/3.0; - density = Mean_PrimVar[nDim+2]; - - for (iDim = 0; iDim < 3; iDim++){ - S_ij[iDim] = new su2double [3]; - } - - - GetMeanRateOfStrainMatrix(S_ij); - - /* --- Using rate of strain matrix, calculate Reynolds stress tensor --- */ - - for (iDim = 0; iDim < 3; iDim++){ - divVel += S_ij[iDim][iDim]; - } - - for (iDim = 0; iDim < 3; iDim++){ - for (jDim = 0; jDim < 3; jDim++){ - MeanReynoldsStress[iDim][jDim] = TWO3 * turb_ke * delta3[iDim][jDim] - - muT / density * (2 * S_ij[iDim][jDim] - TWO3 * divVel * delta3[iDim][jDim]); - } - } - - for (iDim = 0; iDim < 3; iDim++) - delete [] S_ij[iDim]; - delete [] S_ij; -} - -void CAvgGrad_Base::SetPerturbedRSM(su2double turb_ke, CConfig *config){ - - unsigned short iDim,jDim; - - /* --- Calculate anisotropic part of Reynolds Stress tensor --- */ - - for (iDim = 0; iDim< 3; iDim++){ - for (jDim = 0; jDim < 3; jDim++){ - A_ij[iDim][jDim] = .5 * MeanReynoldsStress[iDim][jDim] / turb_ke - delta3[iDim][jDim] / 3.0; - Eig_Vec[iDim][jDim] = A_ij[iDim][jDim]; - } - } - - /* --- Get ordered eigenvectors and eigenvalues of A_ij --- */ - - EigenDecomposition(A_ij, Eig_Vec, Eig_Val, 3); - - /* compute convex combination coefficients */ - su2double c1c = Eig_Val[2] - Eig_Val[1]; - su2double c2c = 2.0 * (Eig_Val[1] - Eig_Val[0]); - su2double c3c = 3.0 * Eig_Val[0] + 1.0; - - /* define barycentric traingle corner points */ - Corners[0][0] = 1.0; - Corners[0][1] = 0.0; - Corners[1][0] = 0.0; - Corners[1][1] = 0.0; - Corners[2][0] = 0.5; - Corners[2][1] = 0.866025; - - /* define barycentric coordinates */ - Barycentric_Coord[0] = Corners[0][0] * c1c + Corners[1][0] * c2c + Corners[2][0] * c3c; - Barycentric_Coord[1] = Corners[0][1] * c1c + Corners[1][1] * c2c + Corners[2][1] * c3c; - - if (Eig_Val_Comp == 1) { - /* 1C turbulence */ - New_Coord[0] = Corners[0][0]; - New_Coord[1] = Corners[0][1]; - } - else if (Eig_Val_Comp== 2) { - /* 2C turbulence */ - New_Coord[0] = Corners[1][0]; - New_Coord[1] = Corners[1][1]; - } - else if (Eig_Val_Comp == 3) { - /* 3C turbulence */ - New_Coord[0] = Corners[2][0]; - New_Coord[1] = Corners[2][1]; - } - else { - /* 2C turbulence */ - New_Coord[0] = Corners[1][0]; - New_Coord[1] = Corners[1][1]; - } - - /* calculate perturbed barycentric coordinates */ - Barycentric_Coord[0] = Barycentric_Coord[0] + (uq_delta_b) * (New_Coord[0] - Barycentric_Coord[0]); - Barycentric_Coord[1] = Barycentric_Coord[1] + (uq_delta_b) * (New_Coord[1] - Barycentric_Coord[1]); - - /* rebuild c1c,c2c,c3c based on perturbed barycentric coordinates */ - c3c = Barycentric_Coord[1] / Corners[2][1]; - c1c = Barycentric_Coord[0] - Corners[2][0] * c3c; - c2c = 1 - c1c - c3c; - - /* build new anisotropy eigenvalues */ - Eig_Val[0] = (c3c - 1) / 3.0; - Eig_Val[1] = 0.5 *c2c + Eig_Val[0]; - Eig_Val[2] = c1c + Eig_Val[1]; - - /* permute eigenvectors if required */ - if (uq_permute) { - for (iDim=0; iDim<3; iDim++) { - for (jDim=0; jDim<3; jDim++) { - New_Eig_Vec[iDim][jDim] = Eig_Vec[2-iDim][jDim]; - } - } - } - - else { - for (iDim=0; iDim<3; iDim++) { - for (jDim=0; jDim<3; jDim++) { - New_Eig_Vec[iDim][jDim] = Eig_Vec[iDim][jDim]; - } - } - } - - EigenRecomposition(newA_ij, New_Eig_Vec, Eig_Val, 3); - - /* compute perturbed Reynolds stress matrix; use under-relaxation factor (uq_urlx)*/ - for (iDim = 0; iDim< 3; iDim++){ - for (jDim = 0; jDim < 3; jDim++){ - MeanPerturbedRSM[iDim][jDim] = 2.0 * turb_ke * (newA_ij[iDim][jDim] + 1.0/3.0 * delta3[iDim][jDim]); - MeanPerturbedRSM[iDim][jDim] = MeanReynoldsStress[iDim][jDim] + - uq_urlx*(MeanPerturbedRSM[iDim][jDim] - MeanReynoldsStress[iDim][jDim]); - } - } - -} - - -void CAvgGrad_Base::SetTauJacobian(const su2double *val_Mean_PrimVar, - const su2double val_laminar_viscosity, - const su2double val_eddy_viscosity, - const su2double val_dist_ij, - const su2double *val_normal) { - - /*--- QCR and wall functions are **not** accounted for here ---*/ - - const su2double Density = val_Mean_PrimVar[nDim+2]; - const su2double total_viscosity = val_laminar_viscosity + val_eddy_viscosity; - const su2double xi = total_viscosity/(Density*val_dist_ij); - - for (unsigned short iDim = 0; iDim < nDim; iDim++) { - for (unsigned short jDim = 0; jDim < nDim; jDim++) { - // Jacobian w.r.t. momentum - tau_jacobian_i[iDim][jDim+1] = -xi*(delta[iDim][jDim] + val_normal[iDim]*val_normal[jDim]/3.0); - } - // Jacobian w.r.t. density - tau_jacobian_i[iDim][0] = 0; - for (unsigned short jDim = 0; jDim < nDim; jDim++) { - tau_jacobian_i[iDim][0] -= tau_jacobian_i[iDim][jDim+1]*val_Mean_PrimVar[jDim+1]; - } - // Jacobian w.r.t. energy - tau_jacobian_i[iDim][nDim+1] = 0; - } -} - -void CAvgGrad_Base::SetIncTauJacobian(const su2double val_laminar_viscosity, - const su2double val_eddy_viscosity, - const su2double val_dist_ij, - const su2double *val_normal) { - - const su2double total_viscosity = val_laminar_viscosity + val_eddy_viscosity; - const su2double xi = total_viscosity/val_dist_ij; - - for (unsigned short iDim = 0; iDim < nDim; iDim++) { - tau_jacobian_i[iDim][0] = 0; - for (unsigned short jDim = 0; jDim < nDim; jDim++) { - tau_jacobian_i[iDim][jDim+1] = -xi*(delta[iDim][jDim] + val_normal[iDim]*val_normal[jDim]/3.0); - } - tau_jacobian_i[iDim][nDim+1] = 0; - } -} - -void CAvgGrad_Base::GetViscousProjFlux(const su2double *val_primvar, - const su2double *val_normal) { - - /*--- Primitive variables -> [Temp vel_x vel_y vel_z Pressure] ---*/ - - if (nDim == 2) { - Flux_Tensor[0][0] = 0.0; - Flux_Tensor[1][0] = tau[0][0]; - Flux_Tensor[2][0] = tau[0][1]; - Flux_Tensor[3][0] = tau[0][0]*val_primvar[1] + tau[0][1]*val_primvar[2]+ - heat_flux_vector[0]; - Flux_Tensor[0][1] = 0.0; - Flux_Tensor[1][1] = tau[1][0]; - Flux_Tensor[2][1] = tau[1][1]; - Flux_Tensor[3][1] = tau[1][0]*val_primvar[1] + tau[1][1]*val_primvar[2]+ - heat_flux_vector[1]; - } else { - Flux_Tensor[0][0] = 0.0; - Flux_Tensor[1][0] = tau[0][0]; - Flux_Tensor[2][0] = tau[0][1]; - Flux_Tensor[3][0] = tau[0][2]; - Flux_Tensor[4][0] = tau[0][0]*val_primvar[1] + tau[0][1]*val_primvar[2] + tau[0][2]*val_primvar[3] + - heat_flux_vector[0]; - Flux_Tensor[0][1] = 0.0; - Flux_Tensor[1][1] = tau[1][0]; - Flux_Tensor[2][1] = tau[1][1]; - Flux_Tensor[3][1] = tau[1][2]; - Flux_Tensor[4][1] = tau[1][0]*val_primvar[1] + tau[1][1]*val_primvar[2] + tau[1][2]*val_primvar[3] + - heat_flux_vector[1]; - Flux_Tensor[0][2] = 0.0; - Flux_Tensor[1][2] = tau[2][0]; - Flux_Tensor[2][2] = tau[2][1]; - Flux_Tensor[3][2] = tau[2][2]; - Flux_Tensor[4][2] = tau[2][0]*val_primvar[1] + tau[2][1]*val_primvar[2] + tau[2][2]*val_primvar[3] + - heat_flux_vector[2]; - } - - for (unsigned short iVar = 0; iVar < nVar; iVar++) { - Proj_Flux_Tensor[iVar] = 0.0; - for (unsigned short iDim = 0; iDim < nDim; iDim++) - Proj_Flux_Tensor[iVar] += Flux_Tensor[iVar][iDim] * val_normal[iDim]; - } - -} - -void CAvgGrad_Base::GetViscousProjJacs(const su2double *val_Mean_PrimVar, - const su2double val_dS, - const su2double *val_Proj_Visc_Flux, - su2double **val_Proj_Jac_Tensor_i, - su2double **val_Proj_Jac_Tensor_j) { - - const su2double Density = val_Mean_PrimVar[nDim+2]; - const su2double factor = 0.5/Density; - - if (nDim == 2) { - - val_Proj_Jac_Tensor_i[0][0] = 0.0; - val_Proj_Jac_Tensor_i[0][1] = 0.0; - val_Proj_Jac_Tensor_i[0][2] = 0.0; - val_Proj_Jac_Tensor_i[0][3] = 0.0; - val_Proj_Jac_Tensor_i[1][0] = val_dS*tau_jacobian_i[0][0]; - val_Proj_Jac_Tensor_i[1][1] = val_dS*tau_jacobian_i[0][1]; - val_Proj_Jac_Tensor_i[1][2] = val_dS*tau_jacobian_i[0][2]; - val_Proj_Jac_Tensor_i[1][3] = val_dS*tau_jacobian_i[0][3]; - val_Proj_Jac_Tensor_i[2][0] = val_dS*tau_jacobian_i[1][0]; - val_Proj_Jac_Tensor_i[2][1] = val_dS*tau_jacobian_i[1][1]; - val_Proj_Jac_Tensor_i[2][2] = val_dS*tau_jacobian_i[1][2]; - val_Proj_Jac_Tensor_i[2][3] = val_dS*tau_jacobian_i[1][3]; - const su2double contraction = tau_jacobian_i[0][0]*val_Mean_PrimVar[1] + - tau_jacobian_i[1][0]*val_Mean_PrimVar[2]; - val_Proj_Jac_Tensor_i[3][0] = val_dS*(contraction - heat_flux_jac_i[0]); - val_Proj_Jac_Tensor_i[3][1] = -val_dS*(tau_jacobian_i[0][0] + heat_flux_jac_i[1]); - val_Proj_Jac_Tensor_i[3][2] = -val_dS*(tau_jacobian_i[1][0] + heat_flux_jac_i[2]); - val_Proj_Jac_Tensor_i[3][3] = -val_dS*heat_flux_jac_i[3]; - - for (unsigned short iVar = 0; iVar < nVar; iVar++) - for (unsigned short jVar = 0; jVar < nVar; jVar++) - val_Proj_Jac_Tensor_j[iVar][jVar] = -val_Proj_Jac_Tensor_i[iVar][jVar]; - - const su2double proj_viscousflux_vel= val_Proj_Visc_Flux[1]*val_Mean_PrimVar[1] + - val_Proj_Visc_Flux[2]*val_Mean_PrimVar[2]; - val_Proj_Jac_Tensor_i[3][0] -= factor*proj_viscousflux_vel; - val_Proj_Jac_Tensor_j[3][0] -= factor*proj_viscousflux_vel; - val_Proj_Jac_Tensor_i[3][1] += factor*val_Proj_Visc_Flux[1]; - val_Proj_Jac_Tensor_j[3][1] += factor*val_Proj_Visc_Flux[1]; - val_Proj_Jac_Tensor_i[3][2] += factor*val_Proj_Visc_Flux[2]; - val_Proj_Jac_Tensor_j[3][2] += factor*val_Proj_Visc_Flux[2]; - - - } else { - - val_Proj_Jac_Tensor_i[0][0] = 0.0; - val_Proj_Jac_Tensor_i[0][1] = 0.0; - val_Proj_Jac_Tensor_i[0][2] = 0.0; - val_Proj_Jac_Tensor_i[0][3] = 0.0; - val_Proj_Jac_Tensor_i[0][4] = 0.0; - val_Proj_Jac_Tensor_i[1][0] = val_dS*tau_jacobian_i[0][0]; - val_Proj_Jac_Tensor_i[1][1] = val_dS*tau_jacobian_i[0][1]; - val_Proj_Jac_Tensor_i[1][2] = val_dS*tau_jacobian_i[0][2]; - val_Proj_Jac_Tensor_i[1][3] = val_dS*tau_jacobian_i[0][3]; - val_Proj_Jac_Tensor_i[1][4] = val_dS*tau_jacobian_i[0][4]; - val_Proj_Jac_Tensor_i[2][0] = val_dS*tau_jacobian_i[1][0]; - val_Proj_Jac_Tensor_i[2][1] = val_dS*tau_jacobian_i[1][1]; - val_Proj_Jac_Tensor_i[2][2] = val_dS*tau_jacobian_i[1][2]; - val_Proj_Jac_Tensor_i[2][3] = val_dS*tau_jacobian_i[1][3]; - val_Proj_Jac_Tensor_i[2][4] = val_dS*tau_jacobian_i[1][4]; - val_Proj_Jac_Tensor_i[3][0] = val_dS*tau_jacobian_i[2][0]; - val_Proj_Jac_Tensor_i[3][1] = val_dS*tau_jacobian_i[2][1]; - val_Proj_Jac_Tensor_i[3][2] = val_dS*tau_jacobian_i[2][2]; - val_Proj_Jac_Tensor_i[3][3] = val_dS*tau_jacobian_i[2][3]; - val_Proj_Jac_Tensor_i[3][4] = val_dS*tau_jacobian_i[2][4]; - const su2double contraction = tau_jacobian_i[0][0]*val_Mean_PrimVar[1] + - tau_jacobian_i[1][0]*val_Mean_PrimVar[2] + - tau_jacobian_i[2][0]*val_Mean_PrimVar[3]; - val_Proj_Jac_Tensor_i[4][0] = val_dS*(contraction - heat_flux_jac_i[0]); - val_Proj_Jac_Tensor_i[4][1] = -val_dS*(tau_jacobian_i[0][0] + heat_flux_jac_i[1]); - val_Proj_Jac_Tensor_i[4][2] = -val_dS*(tau_jacobian_i[1][0] + heat_flux_jac_i[2]); - val_Proj_Jac_Tensor_i[4][3] = -val_dS*(tau_jacobian_i[2][0] + heat_flux_jac_i[3]); - val_Proj_Jac_Tensor_i[4][4] = -val_dS*heat_flux_jac_i[4]; - - for (unsigned short iVar = 0; iVar < nVar; iVar++) - for (unsigned short jVar = 0; jVar < nVar; jVar++) - val_Proj_Jac_Tensor_j[iVar][jVar] = -val_Proj_Jac_Tensor_i[iVar][jVar]; - - const su2double proj_viscousflux_vel= val_Proj_Visc_Flux[1]*val_Mean_PrimVar[1] + - val_Proj_Visc_Flux[2]*val_Mean_PrimVar[2] + - val_Proj_Visc_Flux[3]*val_Mean_PrimVar[3]; - val_Proj_Jac_Tensor_i[4][0] -= factor*proj_viscousflux_vel; - val_Proj_Jac_Tensor_j[4][0] -= factor*proj_viscousflux_vel; - val_Proj_Jac_Tensor_i[4][1] += factor*val_Proj_Visc_Flux[1]; - val_Proj_Jac_Tensor_j[4][1] += factor*val_Proj_Visc_Flux[1]; - val_Proj_Jac_Tensor_i[4][2] += factor*val_Proj_Visc_Flux[2]; - val_Proj_Jac_Tensor_j[4][2] += factor*val_Proj_Visc_Flux[2]; - val_Proj_Jac_Tensor_i[4][3] += factor*val_Proj_Visc_Flux[3]; - val_Proj_Jac_Tensor_j[4][3] += factor*val_Proj_Visc_Flux[3]; - - } - -} - -CAvgGrad_Flow::CAvgGrad_Flow(unsigned short val_nDim, - unsigned short val_nVar, - bool val_correct_grad, - CConfig *config) - : CAvgGrad_Base(val_nDim, val_nVar, val_nDim+3, val_correct_grad, config) { - -} - -CAvgGrad_Flow::~CAvgGrad_Flow(void) { - -} - -void CAvgGrad_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - AD::StartPreacc(); - AD::SetPreaccIn(V_i, nDim+9); AD::SetPreaccIn(V_j, nDim+9); - AD::SetPreaccIn(Coord_i, nDim); AD::SetPreaccIn(Coord_j, nDim); - AD::SetPreaccIn(PrimVar_Grad_i, nDim+1, nDim); - AD::SetPreaccIn(PrimVar_Grad_j, nDim+1, nDim); - AD::SetPreaccIn(turb_ke_i); AD::SetPreaccIn(turb_ke_j); - AD::SetPreaccIn(Normal, nDim); - - unsigned short iVar, jVar, iDim; - - /*--- Normalized normal vector ---*/ - - 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; - - for (iVar = 0; iVar < nPrimVar; iVar++) { - PrimVar_i[iVar] = V_i[iVar]; - PrimVar_j[iVar] = V_j[iVar]; - Mean_PrimVar[iVar] = 0.5*(PrimVar_i[iVar]+PrimVar_j[iVar]); - } - - - /*--- Compute vector going from iPoint to jPoint ---*/ - - dist_ij_2 = 0.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]; - } - - /*--- Laminar and Eddy viscosity ---*/ - - Laminar_Viscosity_i = V_i[nDim+5]; Laminar_Viscosity_j = V_j[nDim+5]; - Eddy_Viscosity_i = V_i[nDim+6]; Eddy_Viscosity_j = V_j[nDim+6]; - - /*--- Mean Viscosities and turbulent kinetic energy---*/ - - Mean_Laminar_Viscosity = 0.5*(Laminar_Viscosity_i + Laminar_Viscosity_j); - Mean_Eddy_Viscosity = 0.5*(Eddy_Viscosity_i + Eddy_Viscosity_j); - Mean_turb_ke = 0.5*(turb_ke_i + turb_ke_j); - - /*--- Mean gradient approximation ---*/ - - for (iVar = 0; iVar < nDim+1; iVar++) { - for (iDim = 0; iDim < nDim; iDim++) { - Mean_GradPrimVar[iVar][iDim] = 0.5*(PrimVar_Grad_i[iVar][iDim] + PrimVar_Grad_j[iVar][iDim]); - } - } - - /*--- Projection of the mean gradient in the direction of the edge ---*/ - - if (correct_gradient && dist_ij_2 != 0.0) { - CorrectGradient(Mean_GradPrimVar, PrimVar_i, PrimVar_j, Edge_Vector, - dist_ij_2, nDim+1); - } - - /*--- Wall shear stress values (wall functions) ---*/ - - if (TauWall_i > 0.0 && TauWall_j > 0.0) Mean_TauWall = 0.5*(TauWall_i + TauWall_j); - else if (TauWall_i > 0.0) Mean_TauWall = TauWall_i; - else if (TauWall_j > 0.0) Mean_TauWall = TauWall_j; - else Mean_TauWall = -1.0; - - /* --- If using UQ methodology, set Reynolds Stress tensor and perform perturbation--- */ - - if (using_uq){ - SetReynoldsStressMatrix(Mean_turb_ke); - SetPerturbedRSM(Mean_turb_ke, config); - } - - /*--- Get projected flux tensor ---*/ - - SetStressTensor(Mean_PrimVar, Mean_GradPrimVar, Mean_turb_ke, - Mean_Laminar_Viscosity, Mean_Eddy_Viscosity); - if (config->GetQCR()) AddQCR(Mean_GradPrimVar); - if (Mean_TauWall > 0) AddTauWall(Normal, Mean_TauWall); - - SetHeatFluxVector(Mean_GradPrimVar, Mean_Laminar_Viscosity, - Mean_Eddy_Viscosity); - - GetViscousProjFlux(Mean_PrimVar, Normal); - - /*--- Update viscous residual ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_residual[iVar] = Proj_Flux_Tensor[iVar]; - - /*--- Compute the implicit part ---*/ - - if (implicit) { - - if (dist_ij_2 == 0.0) { - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - val_Jacobian_i[iVar][jVar] = 0.0; - val_Jacobian_j[iVar][jVar] = 0.0; - } - } - } else { - const su2double dist_ij = sqrt(dist_ij_2); - SetTauJacobian(Mean_PrimVar, Mean_Laminar_Viscosity, Mean_Eddy_Viscosity, - dist_ij, UnitNormal); - SetHeatFluxJacobian(Mean_PrimVar, Mean_Laminar_Viscosity, - Mean_Eddy_Viscosity, dist_ij, UnitNormal); - GetViscousProjJacs(Mean_PrimVar, Area, Proj_Flux_Tensor, - val_Jacobian_i, val_Jacobian_j); - } - - } - - AD::SetPreaccOut(val_residual, nVar); - AD::EndPreacc(); - -} - - - -void CAvgGrad_Flow::SetHeatFluxVector(const su2double* const *val_gradprimvar, - const su2double val_laminar_viscosity, - const su2double val_eddy_viscosity) { - - const su2double Cp = (Gamma / Gamma_Minus_One) * Gas_Constant; - const su2double heat_flux_factor = Cp * (val_laminar_viscosity/Prandtl_Lam + val_eddy_viscosity/Prandtl_Turb); - - /*--- Gradient of primitive variables -> [Temp vel_x vel_y vel_z Pressure] ---*/ - - for (unsigned short iDim = 0; iDim < nDim; iDim++) { - heat_flux_vector[iDim] = heat_flux_factor*val_gradprimvar[0][iDim]; - } -} - -void CAvgGrad_Flow::SetHeatFluxJacobian(const su2double *val_Mean_PrimVar, - const su2double val_laminar_viscosity, - const su2double val_eddy_viscosity, - const su2double val_dist_ij, - const su2double *val_normal) { - su2double sqvel = 0.0; - - for (unsigned short iDim = 0; iDim < nDim; iDim++) { - sqvel += val_Mean_PrimVar[iDim+1]*val_Mean_PrimVar[iDim+1]; - } - - const su2double Density = val_Mean_PrimVar[nDim+2]; - const su2double Pressure = val_Mean_PrimVar[nDim+1]; - const su2double phi = Gamma_Minus_One/Density; - - /*--- R times partial derivatives of temp. ---*/ - - const su2double R_dTdu0 = -Pressure/(Density*Density) + 0.5*sqvel*phi; - const su2double R_dTdu1 = -phi*val_Mean_PrimVar[1]; - const su2double R_dTdu2 = -phi*val_Mean_PrimVar[2]; - - const su2double heat_flux_factor = val_laminar_viscosity/Prandtl_Lam + val_eddy_viscosity/Prandtl_Turb; - const su2double cpoR = Gamma/Gamma_Minus_One; // cp over R - const su2double conductivity_over_Rd = cpoR*heat_flux_factor/val_dist_ij; - - heat_flux_jac_i[0] = conductivity_over_Rd * R_dTdu0; - heat_flux_jac_i[1] = conductivity_over_Rd * R_dTdu1; - heat_flux_jac_i[2] = conductivity_over_Rd * R_dTdu2; - - if (nDim == 2) { - - const su2double R_dTdu3 = phi; - heat_flux_jac_i[3] = conductivity_over_Rd * R_dTdu3; - - } else { - - const su2double R_dTdu3 = -phi*val_Mean_PrimVar[3]; - const su2double R_dTdu4 = phi; - heat_flux_jac_i[3] = conductivity_over_Rd * R_dTdu3; - heat_flux_jac_i[4] = conductivity_over_Rd * R_dTdu4; - - } -} - - -CGeneralAvgGrad_Flow::CGeneralAvgGrad_Flow(unsigned short val_nDim, - unsigned short val_nVar, - bool val_correct_grad, - CConfig *config) - : CAvgGrad_Base(val_nDim, val_nVar, val_nDim+4, val_correct_grad, config) { - - Mean_SecVar = new su2double [2]; - -} - -CGeneralAvgGrad_Flow::~CGeneralAvgGrad_Flow(void) { - - delete [] Mean_SecVar; - -} - -void CGeneralAvgGrad_Flow::SetHeatFluxVector(const su2double* const *val_gradprimvar, - const su2double val_laminar_viscosity, - const su2double val_eddy_viscosity, - const su2double val_thermal_conductivity, - const su2double val_heat_capacity_cp) { - - const su2double heat_flux_factor = val_thermal_conductivity + val_heat_capacity_cp*val_eddy_viscosity/Prandtl_Turb; - - /*--- Gradient of primitive variables -> [Temp vel_x vel_y vel_z Pressure] ---*/ - for (unsigned short iDim = 0; iDim < nDim; iDim++) { - heat_flux_vector[iDim] = heat_flux_factor*val_gradprimvar[0][iDim]; - } -} - -void CGeneralAvgGrad_Flow::SetHeatFluxJacobian(const su2double *val_Mean_PrimVar, - const su2double *val_Mean_SecVar, - const su2double val_eddy_viscosity, - const su2double val_thermal_conductivity, - const su2double val_heat_capacity_cp, - const su2double val_dist_ij) { - /* Viscous flux Jacobians for arbitrary equations of state */ - - //order of val_mean_primitives: T, vx, vy, vz, P, rho, ht - //order of secondary:dTdrho_e, dTde_rho - - su2double sqvel = 0.0; - for (unsigned short iDim = 0; iDim < nDim; iDim++) { - sqvel += val_Mean_PrimVar[iDim+1]*val_Mean_PrimVar[iDim+1]; - } - - su2double rho = val_Mean_PrimVar[nDim+2]; - su2double P= val_Mean_PrimVar[nDim+1]; - su2double h= val_Mean_PrimVar[nDim+3]; - su2double dTdrho_e= val_Mean_SecVar[0]; - su2double dTde_rho= val_Mean_SecVar[1]; - - su2double dTdu0= dTdrho_e + dTde_rho*(-(h-P/rho) + sqvel)*(1/rho); - su2double dTdu1= dTde_rho*(-val_Mean_PrimVar[1])*(1/rho); - su2double dTdu2= dTde_rho*(-val_Mean_PrimVar[2])*(1/rho); - - su2double total_conductivity = val_thermal_conductivity + val_heat_capacity_cp*val_eddy_viscosity/Prandtl_Turb; - su2double factor2 = total_conductivity/val_dist_ij; - - heat_flux_jac_i[0] = factor2*dTdu0; - heat_flux_jac_i[1] = factor2*dTdu1; - heat_flux_jac_i[2] = factor2*dTdu2; - - if (nDim == 2) { - - su2double dTdu3= dTde_rho*(1/rho); - heat_flux_jac_i[3] = factor2*dTdu3; - - } else { - - su2double dTdu3= dTde_rho*(-val_Mean_PrimVar[3])*(1/rho); - su2double dTdu4= dTde_rho*(1/rho); - heat_flux_jac_i[3] = factor2*dTdu3; - heat_flux_jac_i[4] = factor2*dTdu4; - - } - -} - -void CGeneralAvgGrad_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - AD::StartPreacc(); - AD::SetPreaccIn(V_i, nDim+9); AD::SetPreaccIn(V_j, nDim+9); - AD::SetPreaccIn(Coord_i, nDim); AD::SetPreaccIn(Coord_j, nDim); - AD::SetPreaccIn(S_i, 4); AD::SetPreaccIn(S_j, 4); - AD::SetPreaccIn(PrimVar_Grad_i, nDim+1, nDim); - AD::SetPreaccIn(PrimVar_Grad_j, nDim+1, nDim); - AD::SetPreaccIn(turb_ke_i); AD::SetPreaccIn(turb_ke_j); - AD::SetPreaccIn(Normal, nDim); - - unsigned short iVar, jVar, iDim; - - /*--- Normalized normal vector ---*/ - - 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; - - /*--- Mean primitive variables ---*/ - - for (iVar = 0; iVar < nPrimVar; iVar++) { - PrimVar_i[iVar] = V_i[iVar]; - PrimVar_j[iVar] = V_j[iVar]; - Mean_PrimVar[iVar] = 0.5*(PrimVar_i[iVar]+PrimVar_j[iVar]); - } - - /*--- Compute vector going from iPoint to jPoint ---*/ - - dist_ij_2 = 0.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]; - } - - /*--- Laminar and Eddy viscosity ---*/ - - Laminar_Viscosity_i = V_i[nDim+5]; Laminar_Viscosity_j = V_j[nDim+5]; - Eddy_Viscosity_i = V_i[nDim+6]; Eddy_Viscosity_j = V_j[nDim+6]; - Thermal_Conductivity_i = V_i[nDim+7]; Thermal_Conductivity_j = V_j[nDim+7]; - Cp_i = V_i[nDim+8]; Cp_j = V_j[nDim+8]; - - /*--- Mean secondary variables ---*/ - - for (iVar = 0; iVar < 2; iVar++) { - Mean_SecVar[iVar] = 0.5*(S_i[iVar+2]+S_j[iVar+2]); - } - - /*--- Mean Viscosities and turbulent kinetic energy---*/ - - Mean_Laminar_Viscosity = 0.5*(Laminar_Viscosity_i + Laminar_Viscosity_j); - Mean_Eddy_Viscosity = 0.5*(Eddy_Viscosity_i + Eddy_Viscosity_j); - Mean_turb_ke = 0.5*(turb_ke_i + turb_ke_j); - Mean_Thermal_Conductivity = 0.5*(Thermal_Conductivity_i + Thermal_Conductivity_j); - Mean_Cp = 0.5*(Cp_i + Cp_j); - - /*--- Mean gradient approximation ---*/ - - for (iVar = 0; iVar < nDim+1; iVar++) { - for (iDim = 0; iDim < nDim; iDim++) { - Mean_GradPrimVar[iVar][iDim] = 0.5*(PrimVar_Grad_i[iVar][iDim] + PrimVar_Grad_j[iVar][iDim]); - } - } - - /*--- Projection of the mean gradient in the direction of the edge ---*/ - - if (correct_gradient && dist_ij_2 != 0.0) { - CorrectGradient(Mean_GradPrimVar, PrimVar_i, PrimVar_j, Edge_Vector, - dist_ij_2, nDim+1); - } - - /* --- If using UQ methodology, set Reynolds Stress tensor and perform perturbation--- */ - - if (using_uq){ - SetReynoldsStressMatrix(Mean_turb_ke); - SetPerturbedRSM(Mean_turb_ke, config); - } - - /*--- Get projected flux tensor ---*/ - - SetStressTensor(Mean_PrimVar, Mean_GradPrimVar, Mean_turb_ke, - Mean_Laminar_Viscosity, Mean_Eddy_Viscosity); - - SetHeatFluxVector(Mean_GradPrimVar, Mean_Laminar_Viscosity, - Mean_Eddy_Viscosity, Mean_Thermal_Conductivity, Mean_Cp); - - GetViscousProjFlux(Mean_PrimVar, Normal); - - /*--- Update viscous residual ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - val_residual[iVar] = Proj_Flux_Tensor[iVar]; - - /*--- Compute the implicit part ---*/ - - if (implicit) { - - if (dist_ij_2 == 0.0) { - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - val_Jacobian_i[iVar][jVar] = 0.0; - val_Jacobian_j[iVar][jVar] = 0.0; - } - } - } else { - const su2double dist_ij = sqrt(dist_ij_2); - SetTauJacobian(Mean_PrimVar, Mean_Laminar_Viscosity, Mean_Eddy_Viscosity, - dist_ij, UnitNormal); - SetHeatFluxJacobian(Mean_PrimVar, Mean_SecVar, Mean_Eddy_Viscosity, - Mean_Thermal_Conductivity, Mean_Cp, dist_ij); - GetViscousProjJacs(Mean_PrimVar, Area, Proj_Flux_Tensor, - val_Jacobian_i, val_Jacobian_j); - } - - } - - AD::SetPreaccOut(val_residual, nVar); - AD::EndPreacc(); - -} - -CSourceGravity::CSourceGravity(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - -} - -CSourceGravity::~CSourceGravity(void) { } - -void CSourceGravity::ComputeResidual(su2double *val_residual, CConfig *config) { - unsigned short iVar; - - for (iVar = 0; iVar < nVar; iVar++) - val_residual[iVar] = 0.0; - - /*--- Evaluate the source term ---*/ - val_residual[nDim] = Volume * U_i[0] * STANDARD_GRAVITY; - -} - -CSourceBodyForce::CSourceBodyForce(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - /*--- Store the pointer to the constant body force vector. ---*/ - - Body_Force_Vector = new su2double[nDim]; - for (unsigned short iDim = 0; iDim < nDim; iDim++) - Body_Force_Vector[iDim] = config->GetBody_Force_Vector()[iDim]; - -} - -CSourceBodyForce::~CSourceBodyForce(void) { - - if (Body_Force_Vector != NULL) delete [] Body_Force_Vector; - -} - -void CSourceBodyForce::ComputeResidual(su2double *val_residual, CConfig *config) { - - unsigned short iDim; - su2double Force_Ref = config->GetForce_Ref(); - - /*--- Zero the continuity contribution ---*/ - - val_residual[0] = 0.0; - - /*--- Momentum contribution ---*/ - - for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = -Volume * U_i[0] * Body_Force_Vector[iDim] / Force_Ref; - - /*--- Energy contribution ---*/ - - val_residual[nDim+1] = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - val_residual[nDim+1] += -Volume * U_i[iDim+1] * Body_Force_Vector[iDim] / Force_Ref; - -} - -CSourceRotatingFrame_Flow::CSourceRotatingFrame_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - -} - -CSourceRotatingFrame_Flow::~CSourceRotatingFrame_Flow(void) { } - -void CSourceRotatingFrame_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config) { - - unsigned short iDim, iVar, jVar; - su2double Omega[3] = {0,0,0}, Momentum[3] = {0,0,0}; - - bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - - /*--- Retrieve the angular velocity vector from config. ---*/ - - for (iDim = 0; iDim < 3; iDim++){ - Omega[iDim] = config->GetRotation_Rate(iDim)/config->GetOmega_Ref(); - } - - /*--- Get the momentum vector at the current node. ---*/ - - for (iDim = 0; iDim < nDim; iDim++) - Momentum[iDim] = U_i[iDim+1]; - - /*--- Calculate rotating frame source term as ( Omega X Rho-U ) ---*/ - - if (nDim == 2) { - val_residual[0] = 0.0; - val_residual[1] = (Omega[1]*Momentum[2] - Omega[2]*Momentum[1])*Volume; - val_residual[2] = (Omega[2]*Momentum[0] - Omega[0]*Momentum[2])*Volume; - val_residual[3] = 0.0; - } else { - val_residual[0] = 0.0; - val_residual[1] = (Omega[1]*Momentum[2] - Omega[2]*Momentum[1])*Volume; - val_residual[2] = (Omega[2]*Momentum[0] - Omega[0]*Momentum[2])*Volume; - val_residual[3] = (Omega[0]*Momentum[1] - Omega[1]*Momentum[0])*Volume; - val_residual[4] = 0.0; - } - - /*--- Calculate the source term Jacobian ---*/ - - if (implicit) { - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_i[iVar][jVar] = 0.0; - if (nDim == 2) { - val_Jacobian_i[1][2] = -Omega[2]*Volume; - val_Jacobian_i[2][1] = Omega[2]*Volume; - } else { - val_Jacobian_i[1][2] = -Omega[2]*Volume; - val_Jacobian_i[1][3] = Omega[1]*Volume; - val_Jacobian_i[2][1] = Omega[2]*Volume; - val_Jacobian_i[2][3] = -Omega[0]*Volume; - val_Jacobian_i[3][1] = -Omega[1]*Volume; - val_Jacobian_i[3][2] = Omega[0]*Volume; - } - } - -} - -CSourceAxisymmetric_Flow::CSourceAxisymmetric_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - -} - -CSourceAxisymmetric_Flow::~CSourceAxisymmetric_Flow(void) { } - -void CSourceAxisymmetric_Flow::ComputeResidual(su2double *val_residual, su2double **Jacobian_i, CConfig *config) { - - su2double yinv, Pressure_i, Enthalpy_i, Velocity_i, sq_vel; - unsigned short iDim, iVar, jVar; - - bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - - if (Coord_i[1] > EPS) { - - yinv = 1.0/Coord_i[1]; - - sq_vel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i = U_i[iDim+1] / U_i[0]; - sq_vel += Velocity_i *Velocity_i; - } - - Pressure_i = (Gamma-1.0)*U_i[0]*(U_i[nDim+1]/U_i[0]-0.5*sq_vel); - Enthalpy_i = (U_i[nDim+1] + Pressure_i) / U_i[0]; - - val_residual[0] = yinv*Volume*U_i[2]; - val_residual[1] = yinv*Volume*U_i[1]*U_i[2]/U_i[0]; - val_residual[2] = yinv*Volume*(U_i[2]*U_i[2]/U_i[0]); - val_residual[3] = yinv*Volume*Enthalpy_i*U_i[2]; - - if (implicit) { - Jacobian_i[0][0] = 0.0; - Jacobian_i[0][1] = 0.0; - Jacobian_i[0][2] = 1.0; - Jacobian_i[0][3] = 0.0; - - Jacobian_i[1][0] = -U_i[1]*U_i[2]/(U_i[0]*U_i[0]); - Jacobian_i[1][1] = U_i[2]/U_i[0]; - Jacobian_i[1][2] = U_i[1]/U_i[0]; - Jacobian_i[1][3] = 0.0; - - Jacobian_i[2][0] = -U_i[2]*U_i[2]/(U_i[0]*U_i[0]); - Jacobian_i[2][1] = 0.0; - Jacobian_i[2][2] = 2*U_i[2]/U_i[0]; - Jacobian_i[2][3] = 0.0; - - Jacobian_i[3][0] = -Gamma*U_i[2]*U_i[3]/(U_i[0]*U_i[0]) + (Gamma-1)*U_i[2]*(U_i[1]*U_i[1]+U_i[2]*U_i[2])/(U_i[0]*U_i[0]*U_i[0]); - Jacobian_i[3][1] = -(Gamma-1)*U_i[2]*U_i[1]/(U_i[0]*U_i[0]); - Jacobian_i[3][2] = Gamma*U_i[3]/U_i[0] - 1/2*(Gamma-1)*( (U_i[1]*U_i[1]+U_i[2]*U_i[2])/(U_i[0]*U_i[0]) + 2*U_i[2]*U_i[2]/(U_i[0]*U_i[0]) ); - Jacobian_i[3][3] = Gamma*U_i[2]/U_i[0]; - - for (iVar=0; iVar < nVar; iVar++) - for (jVar=0; jVar < nVar; jVar++) - Jacobian_i[iVar][jVar] *= yinv*Volume; - - } - - } - - else { - - for (iVar=0; iVar < nVar; iVar++) - val_residual[iVar] = 0.0; - - if (implicit) { - for (iVar=0; iVar < nVar; iVar++) { - for (jVar=0; jVar < nVar; jVar++) - Jacobian_i[iVar][jVar] = 0.0; - } - } - - } - -} - -CSourceWindGust::CSourceWindGust(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - -} - -CSourceWindGust::~CSourceWindGust(void) { } - -void CSourceWindGust::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config) { - - su2double u_gust, v_gust, du_gust_dx, du_gust_dy, du_gust_dt, dv_gust_dx, dv_gust_dy, dv_gust_dt, smx, smy, se, rho, u, v, p; - unsigned short GustDir = config->GetGust_Dir(); //Gust direction - - u_gust = WindGust_i[0]; - v_gust = WindGust_i[1]; - - if (GustDir == X_DIR) { - du_gust_dx = WindGustDer_i[0]; - du_gust_dy = WindGustDer_i[1]; - du_gust_dt = WindGustDer_i[2]; - dv_gust_dx = 0.0; - dv_gust_dy = 0.0; - dv_gust_dt = 0.0; - } else { - du_gust_dx = 0.0; - du_gust_dy = 0.0; - du_gust_dt = 0.0; - dv_gust_dx = WindGustDer_i[0]; - dv_gust_dy = WindGustDer_i[1]; - dv_gust_dt = WindGustDer_i[2]; - - } - - /*--- Primitive variables at point i ---*/ - u = V_i[1]; - v = V_i[2]; - p = V_i[nDim+1]; - rho = V_i[nDim+2]; - - /*--- Source terms ---*/ - smx = rho*(du_gust_dt + (u+u_gust)*du_gust_dx + (v+v_gust)*du_gust_dy); - smy = rho*(dv_gust_dt + (u+u_gust)*dv_gust_dx + (v+v_gust)*dv_gust_dy); - se = u*smx + v*smy + p*(du_gust_dx + dv_gust_dy); - - if (nDim == 2) { - val_residual[0] = 0.0; - val_residual[1] = smx*Volume; - val_residual[2] = smy*Volume; - val_residual[3] = se*Volume; - } else { - SU2_MPI::Error("You should only be in the gust source term in two dimensions", CURRENT_FUNCTION); - } - - /*--- For now the source term Jacobian is just set to zero ---*/ - - unsigned short iVar, jVar; - bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - - /*--- Calculate the source term Jacobian ---*/ - - if (implicit) { - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_i[iVar][jVar] = 0.0; - } - -} diff --git a/SU2_CFD/src/numerics_direct_mean_inc.cpp b/SU2_CFD/src/numerics_direct_mean_inc.cpp deleted file mode 100644 index 6e8a58f985db..000000000000 --- a/SU2_CFD/src/numerics_direct_mean_inc.cpp +++ /dev/null @@ -1,1219 +0,0 @@ -/*! - * \file numerics_direct_mean_inc.cpp - * \brief This file contains the numerical methods for incompressible flow. - * \author F. Palacios, T. Economon - * \version 7.0.1 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - - -#include "../include/numerics_structure.hpp" -#include - -CUpwFDSInc_Flow::CUpwFDSInc_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - variable_density = (config->GetKind_DensityModel() == VARIABLE); - energy = config->GetEnergy_Equation(); - /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ - dynamic_grid = config->GetDynamic_Grid(); - - Diff_V = new su2double[nVar]; - Velocity_i = new su2double[nDim]; - Velocity_j = new su2double[nDim]; - MeanVelocity = new su2double[nDim]; - ProjFlux_i = new su2double[nVar]; - ProjFlux_j = new su2double[nVar]; - Lambda = new su2double[nVar]; - Epsilon = new su2double[nVar]; - Precon = new su2double*[nVar]; - invPrecon_A = new su2double*[nVar]; - - for (iVar = 0; iVar < nVar; iVar++) { - Precon[iVar] = new su2double[nVar]; - invPrecon_A[iVar] = new su2double[nVar]; - } - -} - -CUpwFDSInc_Flow::~CUpwFDSInc_Flow(void) { - - delete [] Diff_V; - delete [] Velocity_i; - delete [] Velocity_j; - delete [] MeanVelocity; - delete [] ProjFlux_i; - delete [] ProjFlux_j; - delete [] Lambda; - delete [] Epsilon; - - for (iVar = 0; iVar < nVar; iVar++) { - delete [] Precon[iVar]; - delete [] invPrecon_A[iVar]; - } - delete [] Precon; - delete [] invPrecon_A; - -} - -void CUpwFDSInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - su2double U_i[5] = {0.0,0.0,0.0,0.0,0.0}, U_j[5] = {0.0,0.0,0.0,0.0,0.0}; - su2double ProjGridVel = 0.0; - - AD::StartPreacc(); - AD::SetPreaccIn(V_i, nDim+9); AD::SetPreaccIn(V_j, nDim+9); AD::SetPreaccIn(Normal, nDim); - if (dynamic_grid) { - AD::SetPreaccIn(GridVel_i, nDim); - AD::SetPreaccIn(GridVel_j, nDim); - } - - /*--- Face area (norm or the normal vector) ---*/ - - Area = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - Area += Normal[iDim]*Normal[iDim]; - Area = sqrt(Area); - - /*--- Compute and unitary normal vector ---*/ - - for (iDim = 0; iDim < nDim; iDim++) { - UnitNormal[iDim] = Normal[iDim]/Area; - if (fabs(UnitNormal[iDim]) < EPS) UnitNormal[iDim] = EPS; - } - - /*--- Set primitive variables at points iPoint and jPoint ---*/ - - Pressure_i = V_i[0]; Pressure_j = V_j[0]; - Temperature_i = V_i[nDim+1]; Temperature_j = V_j[nDim+1]; - DensityInc_i = V_i[nDim+2]; DensityInc_j = V_j[nDim+2]; - BetaInc2_i = V_i[nDim+3]; BetaInc2_j = V_j[nDim+3]; - Cp_i = V_i[nDim+7]; Cp_j = V_j[nDim+7]; - Enthalpy_i = Cp_i*Temperature_i; Enthalpy_j = Cp_j*Temperature_j; - - ProjVelocity = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = V_i[iDim+1]; - Velocity_j[iDim] = V_j[iDim+1]; - MeanVelocity[iDim] = 0.5*(Velocity_i[iDim] + Velocity_j[iDim]); - ProjVelocity += MeanVelocity[iDim]*Normal[iDim]; - } - - /*--- Projected velocity adjustment due to mesh motion ---*/ - - if (dynamic_grid) { - ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - } - ProjVelocity -= ProjGridVel; - } - - /*--- Mean variables at points iPoint and jPoint ---*/ - - MeanDensity = 0.5*(DensityInc_i + DensityInc_j); - MeanPressure = 0.5*(Pressure_i + Pressure_j); - MeanBetaInc2 = 0.5*(BetaInc2_i + BetaInc2_j); - MeanEnthalpy = 0.5*(Enthalpy_i + Enthalpy_j); - MeanCp = 0.5*(Cp_i + Cp_j); - MeanTemperature = 0.5*(Temperature_i + Temperature_j); - - /*--- Artificial sound speed based on eigs of preconditioned system ---*/ - - MeanSoundSpeed = sqrt(MeanBetaInc2*Area*Area); - - /*--- We need the derivative of the equation of state to build the - preconditioning matrix. For now, the only option is the ideal gas - law, but in the future, dRhodT should be in the fluid model. ---*/ - - MeandRhodT = 0.0; dRhodT_i = 0.0; dRhodT_j = 0.0; - if (variable_density) { - MeandRhodT = -MeanDensity/MeanTemperature; - dRhodT_i = -DensityInc_i/Temperature_i; - dRhodT_j = -DensityInc_j/Temperature_j; - } - - /*--- Compute ProjFlux_i ---*/ - - GetInviscidIncProjFlux(&DensityInc_i, Velocity_i, &Pressure_i, &BetaInc2_i, &Enthalpy_i, Normal, ProjFlux_i); - - /*--- Compute ProjFlux_j ---*/ - - GetInviscidIncProjFlux(&DensityInc_j, Velocity_j, &Pressure_j, &BetaInc2_j, &Enthalpy_j, Normal, ProjFlux_j); - - /*--- Eigenvalues of the preconditioned system ---*/ - - if (nDim == 2) { - Lambda[0] = ProjVelocity; - Lambda[1] = ProjVelocity; - Lambda[2] = ProjVelocity - MeanSoundSpeed; - Lambda[3] = ProjVelocity + MeanSoundSpeed; - } - if (nDim == 3) { - Lambda[0] = ProjVelocity; - Lambda[1] = ProjVelocity; - Lambda[2] = ProjVelocity; - Lambda[3] = ProjVelocity - MeanSoundSpeed; - Lambda[4] = ProjVelocity + MeanSoundSpeed; - } - - /*--- Absolute value of the eigenvalues ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - Lambda[iVar] = fabs(Lambda[iVar]); - - /*--- Build the preconditioning matrix using mean values ---*/ - - GetPreconditioner(&MeanDensity, MeanVelocity, &MeanBetaInc2, &MeanCp, &MeanTemperature, &MeandRhodT, Precon); - - /*--- Build the absolute value of the preconditioned Jacobian, i.e., - |A_precon| = P x |Lambda| x inv(P), where P diagonalizes the matrix - inv(Precon) x dF/dV and Lambda is the diag. matrix of its eigenvalues. ---*/ - - GetPreconditionedProjJac(&MeanDensity, Lambda, &MeanBetaInc2, UnitNormal, invPrecon_A); - - /*--- Difference of primitive variables at iPoint and jPoint ---*/ - - Diff_V[0] = Pressure_j - Pressure_i; - for (iDim = 0; iDim < nDim; iDim++) - Diff_V[iDim+1] = Velocity_j[iDim] - Velocity_i[iDim]; - Diff_V[nDim+1] = Temperature_j - Temperature_i; - - /*--- Build the inviscid Jacobian w.r.t. the primitive variables ---*/ - - if (implicit) { - GetInviscidIncProjJac(&DensityInc_i, Velocity_i, &BetaInc2_i, &Cp_i, &Temperature_i, &dRhodT_i, Normal, 0.5, val_Jacobian_i); - GetInviscidIncProjJac(&DensityInc_j, Velocity_j, &BetaInc2_j, &Cp_j, &Temperature_j, &dRhodT_j, Normal, 0.5, val_Jacobian_j); - } - - /*--- Compute dissipation as Precon x |A_precon| x dV. If implicit, - store Precon x |A_precon| from dissipation term. ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] = 0.5*(ProjFlux_i[iVar]+ProjFlux_j[iVar]); - for (jVar = 0; jVar < nVar; jVar++) { - Proj_ModJac_Tensor_ij = 0.0; - for (kVar = 0; kVar < nVar; kVar++) - Proj_ModJac_Tensor_ij += Precon[iVar][kVar]*invPrecon_A[kVar][jVar]; - val_residual[iVar] -= 0.5*Proj_ModJac_Tensor_ij*Diff_V[jVar]; - if (implicit) { - val_Jacobian_i[iVar][jVar] += 0.5*Proj_ModJac_Tensor_ij; - val_Jacobian_j[iVar][jVar] -= 0.5*Proj_ModJac_Tensor_ij; - } - } - } - - /*--- Corrections due to grid motion ---*/ - if (dynamic_grid) { - - /*--- Recompute conservative variables ---*/ - - U_i[0] = DensityInc_i; U_j[0] = DensityInc_j; - for (iDim = 0; iDim < nDim; iDim++) { - U_i[iDim+1] = DensityInc_i*Velocity_i[iDim]; U_j[iDim+1] = DensityInc_j*Velocity_j[iDim]; - } - U_i[nDim+1] = DensityInc_i*Enthalpy_i; U_j[nDim+1] = DensityInc_j*Enthalpy_j; - - ProjVelocity = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjVelocity += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - - /*--- Residual contributions ---*/ - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] -= ProjVelocity * 0.5*(U_i[iVar]+U_j[iVar]); - - /*--- Jacobian contributions ---*/ - /*--- Implicit terms ---*/ - if (implicit) { - for (iDim = 0; iDim < nDim; iDim++){ - val_Jacobian_i[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_i; - val_Jacobian_j[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_j; - } - val_Jacobian_i[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_i*Cp_i; - val_Jacobian_j[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_j*Cp_j; - } - } - } - - if (!energy) { - val_residual[nDim+1] = 0.0; - if (implicit) { - for (iVar = 0; iVar < nVar; iVar++) { - val_Jacobian_i[iVar][nDim+1] = 0.0; - val_Jacobian_j[iVar][nDim+1] = 0.0; - - val_Jacobian_i[nDim+1][iVar] = 0.0; - val_Jacobian_j[nDim+1][iVar] = 0.0; - } - } - } - - AD::SetPreaccOut(val_residual, nVar); - AD::EndPreacc(); -} - -CCentJSTInc_Flow::CCentJSTInc_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - variable_density = (config->GetKind_DensityModel() == VARIABLE); - energy = config->GetEnergy_Equation(); - /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ - dynamic_grid = config->GetDynamic_Grid(); - - /*--- Artifical dissipation part ---*/ - - Param_p = 0.3; - Param_Kappa_2 = config->GetKappa_2nd_Flow(); - Param_Kappa_4 = config->GetKappa_4th_Flow(); - - /*--- Allocate some structures ---*/ - - Diff_V = new su2double [nVar]; - Diff_Lapl = new su2double [nVar]; - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; - MeanVelocity = new su2double [nDim]; - ProjFlux = new su2double [nVar]; - Precon = new su2double*[nVar]; - - for (iVar = 0; iVar < nVar; iVar++) - Precon[iVar] = new su2double[nVar]; - -} - -CCentJSTInc_Flow::~CCentJSTInc_Flow(void) { - - delete [] Diff_V; - delete [] Diff_Lapl; - delete [] Velocity_i; - delete [] Velocity_j; - delete [] MeanVelocity; - delete [] ProjFlux; - - for (iVar = 0; iVar < nVar; iVar++) - delete [] Precon[iVar]; - delete [] Precon; - -} - -void CCentJSTInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - su2double U_i[5] = {0.0,0.0,0.0,0.0,0.0}, U_j[5] = {0.0,0.0,0.0,0.0,0.0}; - su2double ProjGridVel = 0.0; - - /*--- Primitive variables at point i and j ---*/ - - Pressure_i = V_i[0]; Pressure_j = V_j[0]; - Temperature_i = V_i[nDim+1]; Temperature_j = V_j[nDim+1]; - DensityInc_i = V_i[nDim+2]; DensityInc_j = V_j[nDim+2]; - BetaInc2_i = V_i[nDim+3]; BetaInc2_j = V_j[nDim+3]; - Cp_i = V_i[nDim+7]; Cp_j = V_j[nDim+7]; - Enthalpy_i = Cp_i*Temperature_i; Enthalpy_j = Cp_j*Temperature_j; - - Area = 0.0; - sq_vel_i = 0.0; sq_vel_j = 0.0; ProjVelocity_i = 0.0; ProjVelocity_j = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = V_i[iDim+1]; - Velocity_j[iDim] = V_j[iDim+1]; - MeanVelocity[iDim] = 0.5*(Velocity_i[iDim]+Velocity_j[iDim]); - sq_vel_i += 0.5*Velocity_i[iDim]*Velocity_i[iDim]; - sq_vel_j += 0.5*Velocity_j[iDim]*Velocity_j[iDim]; - ProjVelocity_i += Velocity_i[iDim]*Normal[iDim]; - ProjVelocity_j += Velocity_j[iDim]*Normal[iDim]; - Area += Normal[iDim]*Normal[iDim]; - } - Area = sqrt(Area); - - /*--- Compute mean values of the variables ---*/ - - MeanDensity = 0.5*(DensityInc_i + DensityInc_j); - MeanPressure = 0.5*(Pressure_i + Pressure_j); - MeanBetaInc2 = 0.5*(BetaInc2_i + BetaInc2_j); - MeanEnthalpy = 0.5*(Enthalpy_i + Enthalpy_j); - MeanCp = 0.5*(Cp_i + Cp_j); - MeanTemperature = 0.5*(Temperature_i + Temperature_j); - - /*--- We need the derivative of the equation of state to build the - preconditioning matrix. For now, the only option is the ideal gas - law, but in the future, dRhodT should be in the fluid model. ---*/ - - MeandRhodT = 0.0; - if (variable_density) { - MeandRhodT = -MeanDensity/MeanTemperature; - } - - /*--- Get projected flux tensor ---*/ - - GetInviscidIncProjFlux(&MeanDensity, MeanVelocity, &MeanPressure, &MeanBetaInc2, &MeanEnthalpy, Normal, ProjFlux); - - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] = ProjFlux[iVar]; - } - - /*--- Jacobians of the inviscid flux ---*/ - - if (implicit) { - GetInviscidIncProjJac(&MeanDensity, MeanVelocity, &MeanBetaInc2, &MeanCp, &MeanTemperature, &MeandRhodT, Normal, 0.5, val_Jacobian_i); - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - val_Jacobian_j[iVar][jVar] = val_Jacobian_i[iVar][jVar]; - } - } - } - - /*--- Corrections due to grid motion ---*/ - if (dynamic_grid) { - - /*--- Recompute conservative variables ---*/ - - U_i[0] = DensityInc_i; U_j[0] = DensityInc_j; - for (iDim = 0; iDim < nDim; iDim++) { - U_i[iDim+1] = DensityInc_i*Velocity_i[iDim]; U_j[iDim+1] = DensityInc_j*Velocity_j[iDim]; - } - U_i[nDim+1] = DensityInc_i*Enthalpy_i; U_j[nDim+1] = DensityInc_j*Enthalpy_j; - - su2double ProjVelocity = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjVelocity += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - - /*--- Residual contributions ---*/ - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] -= ProjVelocity * 0.5*(U_i[iVar]+U_j[iVar]); - - /*--- Jacobian contributions ---*/ - /*--- Implicit terms ---*/ - if (implicit) { - for (iDim = 0; iDim < nDim; iDim++){ - val_Jacobian_i[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_i; - val_Jacobian_j[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_j; - } - val_Jacobian_i[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_i*Cp_i; - val_Jacobian_j[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_j*Cp_j; - } - } - } - - /*--- Computes differences between Laplacians and conservative variables ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - Diff_Lapl[iVar] = Und_Lapl_i[iVar]-Und_Lapl_j[iVar]; - Diff_V[iVar] = V_i[iVar]-V_j[iVar]; - } - - /*--- Build the preconditioning matrix using mean values ---*/ - - GetPreconditioner(&MeanDensity, MeanVelocity, &MeanBetaInc2, &MeanCp, &MeanTemperature, &MeandRhodT, Precon); - - /*--- Compute the local spectral radius of the preconditioned system - and the stretching factor. ---*/ - - /*--- Projected velocity adjustment due to mesh motion ---*/ - - if (dynamic_grid) { - ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - } - ProjVelocity_i -= ProjGridVel; - ProjVelocity_j -= ProjGridVel; - } - - SoundSpeed_i = sqrt(BetaInc2_i*Area*Area); - SoundSpeed_j = sqrt(BetaInc2_j*Area*Area); - - Local_Lambda_i = fabs(ProjVelocity_i)+SoundSpeed_i; - Local_Lambda_j = fabs(ProjVelocity_j)+SoundSpeed_j; - - MeanLambda = 0.5*(Local_Lambda_i+Local_Lambda_j); - - Phi_i = pow(Lambda_i/(4.0*MeanLambda), Param_p); - Phi_j = pow(Lambda_j/(4.0*MeanLambda), Param_p); - - StretchingFactor = 4.0*Phi_i*Phi_j/(Phi_i+Phi_j); - - sc2 = 3.0*(su2double(Neighbor_i)+su2double(Neighbor_j))/(su2double(Neighbor_i)*su2double(Neighbor_j)); - sc4 = sc2*sc2/4.0; - - Epsilon_2 = Param_Kappa_2*0.5*(Sensor_i+Sensor_j)*sc2; - Epsilon_4 = max(0.0, Param_Kappa_4-Epsilon_2)*sc4; - - /*--- Compute viscous part of the residual ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - val_residual[iVar] += Precon[iVar][jVar]*(Epsilon_2*Diff_V[jVar] - Epsilon_4*Diff_Lapl[jVar])*StretchingFactor*MeanLambda; - if (implicit) { - val_Jacobian_i[iVar][jVar] += Precon[iVar][jVar]*(Epsilon_2 + Epsilon_4*su2double(Neighbor_i+1))*StretchingFactor*MeanLambda; - val_Jacobian_j[iVar][jVar] -= Precon[iVar][jVar]*(Epsilon_2 + Epsilon_4*su2double(Neighbor_j+1))*StretchingFactor*MeanLambda; - } - } - } - - /*--- Remove energy contributions if not solving the energy equation. ---*/ - - if (!energy) { - val_residual[nDim+1] = 0.0; - if (implicit) { - for (iVar = 0; iVar < nVar; iVar++) { - val_Jacobian_i[iVar][nDim+1] = 0.0; - val_Jacobian_j[iVar][nDim+1] = 0.0; - - val_Jacobian_i[nDim+1][iVar] = 0.0; - val_Jacobian_j[nDim+1][iVar] = 0.0; - } - } - } -} - -CCentLaxInc_Flow::CCentLaxInc_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - variable_density = (config->GetKind_DensityModel() == VARIABLE); - /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ - dynamic_grid = config->GetDynamic_Grid(); - energy = config->GetEnergy_Equation(); - - /*--- Artificial dissipation part ---*/ - - Param_p = 0.3; - Param_Kappa_0 = config->GetKappa_1st_Flow(); - - /*--- Allocate some structures ---*/ - - Diff_V = new su2double[nVar]; - Velocity_i = new su2double[nDim]; - Velocity_j = new su2double[nDim]; - MeanVelocity = new su2double[nDim]; - ProjFlux = new su2double[nVar]; - Precon = new su2double*[nVar]; - - for (iVar = 0; iVar < nVar; iVar++) - Precon[iVar] = new su2double[nVar]; - -} - -CCentLaxInc_Flow::~CCentLaxInc_Flow(void) { - - delete [] Diff_V; - delete [] Velocity_i; - delete [] Velocity_j; - delete [] MeanVelocity; - delete [] ProjFlux; - - for (iVar = 0; iVar < nVar; iVar++) - delete [] Precon[iVar]; - delete [] Precon; - -} - -void CCentLaxInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - su2double U_i[5] = {0.0,0.0,0.0,0.0,0.0}, U_j[5] = {0.0,0.0,0.0,0.0,0.0}; - su2double ProjGridVel = 0.0, ProjVelocity = 0.0; - - /*--- Primitive variables at point i and j ---*/ - - Pressure_i = V_i[0]; Pressure_j = V_j[0]; - Temperature_i = V_i[nDim+1]; Temperature_j = V_j[nDim+1]; - DensityInc_i = V_i[nDim+2]; DensityInc_j = V_j[nDim+2]; - BetaInc2_i = V_i[nDim+3]; BetaInc2_j = V_j[nDim+3]; - Cp_i = V_i[nDim+7]; Cp_j = V_j[nDim+7]; - Enthalpy_i = Cp_i*Temperature_i; Enthalpy_j = Cp_j*Temperature_j; - - Area = 0.0; - sq_vel_i = 0.0; sq_vel_j = 0.0; ProjVelocity_i = 0.0; ProjVelocity_j = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = V_i[iDim+1]; - Velocity_j[iDim] = V_j[iDim+1]; - MeanVelocity[iDim] = 0.5*(Velocity_i[iDim]+Velocity_j[iDim]); - sq_vel_i += 0.5*Velocity_i[iDim]*Velocity_i[iDim]; - sq_vel_j += 0.5*Velocity_j[iDim]*Velocity_j[iDim]; - ProjVelocity_i += Velocity_i[iDim]*Normal[iDim]; - ProjVelocity_j += Velocity_j[iDim]*Normal[iDim]; - Area += Normal[iDim]*Normal[iDim]; - } - Area = sqrt(Area); - - /*--- Compute mean values of the variables ---*/ - - MeanDensity = 0.5*(DensityInc_i + DensityInc_j); - MeanPressure = 0.5*(Pressure_i + Pressure_j); - MeanBetaInc2 = 0.5*(BetaInc2_i + BetaInc2_j); - MeanEnthalpy = 0.5*(Enthalpy_i + Enthalpy_j); - MeanCp = 0.5*(Cp_i + Cp_j); - MeanTemperature = 0.5*(Temperature_i + Temperature_j); - - /*--- We need the derivative of the equation of state to build the - preconditioning matrix. For now, the only option is the ideal gas - law, but in the future, dRhodT should be in the fluid model. ---*/ - - MeandRhodT = 0.0; - if (variable_density) { - MeandRhodT = -MeanDensity/MeanTemperature; - } - - /*--- Get projected flux tensor ---*/ - - GetInviscidIncProjFlux(&MeanDensity, MeanVelocity, &MeanPressure, &MeanBetaInc2, &MeanEnthalpy, Normal, ProjFlux); - - /*--- Compute inviscid residual ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] = ProjFlux[iVar]; - } - - /*--- Jacobians of the inviscid flux ---*/ - - if (implicit) { - GetInviscidIncProjJac(&MeanDensity, MeanVelocity, &MeanBetaInc2, &MeanCp, &MeanTemperature, &MeandRhodT, Normal, 0.5, val_Jacobian_i); - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - val_Jacobian_j[iVar][jVar] = val_Jacobian_i[iVar][jVar]; - } - } - } - - /*--- Corrections due to grid motion ---*/ - if (dynamic_grid) { - - /*--- Recompute conservative variables ---*/ - - U_i[0] = DensityInc_i; U_j[0] = DensityInc_j; - for (iDim = 0; iDim < nDim; iDim++) { - U_i[iDim+1] = DensityInc_i*Velocity_i[iDim]; U_j[iDim+1] = DensityInc_j*Velocity_j[iDim]; - } - U_i[nDim+1] = DensityInc_i*Enthalpy_i; U_j[nDim+1] = DensityInc_j*Enthalpy_j; - - for (iDim = 0; iDim < nDim; iDim++) - ProjVelocity += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - - /*--- Residual contributions ---*/ - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] -= ProjVelocity * 0.5*(U_i[iVar]+U_j[iVar]); - - /*--- Jacobian contributions ---*/ - /*--- Implicit terms ---*/ - if (implicit) { - for (iDim = 0; iDim < nDim; iDim++){ - val_Jacobian_i[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_i; - val_Jacobian_j[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_j; - } - val_Jacobian_i[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_i*Cp_i; - val_Jacobian_j[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_j*Cp_j; - } - } - } - - /*--- Computes differences btw. conservative variables ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - Diff_V[iVar] = V_i[iVar]-V_j[iVar]; - - /*--- Build the preconditioning matrix using mean values ---*/ - - GetPreconditioner(&MeanDensity, MeanVelocity, &MeanBetaInc2, &MeanCp, &MeanTemperature, &MeandRhodT, Precon); - - /*--- Compute the local espectral radius of the preconditioned system - and the stretching factor. ---*/ - - SoundSpeed_i = sqrt(BetaInc2_i*Area*Area); - SoundSpeed_j = sqrt(BetaInc2_j*Area*Area); - - /*--- Projected velocity adjustment due to mesh motion ---*/ - - if (dynamic_grid) { - ProjGridVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; - } - ProjVelocity_i -= ProjGridVel; - ProjVelocity_j -= ProjGridVel; - } - - Local_Lambda_i = fabs(ProjVelocity_i)+SoundSpeed_i; - Local_Lambda_j = fabs(ProjVelocity_j)+SoundSpeed_j; - - MeanLambda = 0.5*(Local_Lambda_i+Local_Lambda_j); - - Phi_i = pow(Lambda_i/(4.0*MeanLambda), Param_p); - Phi_j = pow(Lambda_j/(4.0*MeanLambda), Param_p); - - StretchingFactor = 4.0*Phi_i*Phi_j/(Phi_i+Phi_j); - - sc0 = 3.0*(su2double(Neighbor_i)+su2double(Neighbor_j))/(su2double(Neighbor_i)*su2double(Neighbor_j)); - Epsilon_0 = Param_Kappa_0*sc0*su2double(nDim)/3.0; - - /*--- Compute viscous part of the residual ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - val_residual[iVar] += Precon[iVar][jVar]*Epsilon_0*Diff_V[jVar]*StretchingFactor*MeanLambda; - if (implicit) { - val_Jacobian_i[iVar][jVar] += Precon[iVar][jVar]*Epsilon_0*StretchingFactor*MeanLambda; - val_Jacobian_j[iVar][jVar] -= Precon[iVar][jVar]*Epsilon_0*StretchingFactor*MeanLambda; - } - } - } - - /*--- Remove energy contributions if we aren't solving the energy equation. ---*/ - - if (!energy) { - val_residual[nDim+1] = 0.0; - if (implicit) { - for (iVar = 0; iVar < nVar; iVar++) { - val_Jacobian_i[iVar][nDim+1] = 0.0; - val_Jacobian_j[iVar][nDim+1] = 0.0; - - val_Jacobian_i[nDim+1][iVar] = 0.0; - val_Jacobian_j[nDim+1][iVar] = 0.0; - } - } - } -} - -CAvgGradInc_Flow::CAvgGradInc_Flow(unsigned short val_nDim, - unsigned short val_nVar, - bool val_correct_grad, CConfig *config) - : CAvgGrad_Base(val_nDim, val_nVar, val_nDim+3, val_correct_grad, config) { - - energy = config->GetEnergy_Equation(); - -} - -CAvgGradInc_Flow::~CAvgGradInc_Flow(void) { -} - -void CAvgGradInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - AD::StartPreacc(); - AD::SetPreaccIn(V_i, nDim+9); AD::SetPreaccIn(V_j, nDim+9); - AD::SetPreaccIn(Coord_i, nDim); AD::SetPreaccIn(Coord_j, nDim); - AD::SetPreaccIn(PrimVar_Grad_i, nVar, nDim); - AD::SetPreaccIn(PrimVar_Grad_j, nVar, nDim); - AD::SetPreaccIn(turb_ke_i); AD::SetPreaccIn(turb_ke_j); - AD::SetPreaccIn(Normal, nDim); - - unsigned short iVar, jVar, iDim; - - /*--- Normalized normal vector ---*/ - - 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; - - for (iVar = 0; iVar < nPrimVar; iVar++) { - PrimVar_i[iVar] = V_i[iVar]; - PrimVar_j[iVar] = V_j[iVar]; - Mean_PrimVar[iVar] = 0.5*(PrimVar_i[iVar]+PrimVar_j[iVar]); - } - - /*--- Compute vector going from iPoint to jPoint ---*/ - - dist_ij_2 = 0.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]; - } - - /*--- Density and transport properties ---*/ - - Laminar_Viscosity_i = V_i[nDim+4]; Laminar_Viscosity_j = V_j[nDim+4]; - Eddy_Viscosity_i = V_i[nDim+5]; Eddy_Viscosity_j = V_j[nDim+5]; - Thermal_Conductivity_i = V_i[nDim+6]; Thermal_Conductivity_j = V_j[nDim+6]; - - /*--- Mean transport properties ---*/ - - Mean_Laminar_Viscosity = 0.5*(Laminar_Viscosity_i + Laminar_Viscosity_j); - Mean_Eddy_Viscosity = 0.5*(Eddy_Viscosity_i + Eddy_Viscosity_j); - Mean_turb_ke = 0.5*(turb_ke_i + turb_ke_j); - Mean_Thermal_Conductivity = 0.5*(Thermal_Conductivity_i + Thermal_Conductivity_j); - - /*--- Mean gradient approximation ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - for (iDim = 0; iDim < nDim; iDim++) - Mean_GradPrimVar[iVar][iDim] = 0.5*(PrimVar_Grad_i[iVar][iDim] + PrimVar_Grad_j[iVar][iDim]); - - /*--- Projection of the mean gradient in the direction of the edge ---*/ - - if (correct_gradient && dist_ij_2 != 0.0) { - CorrectGradient(Mean_GradPrimVar, PrimVar_i, PrimVar_j, Edge_Vector, - dist_ij_2, nVar); - } - - /*--- Get projected flux tensor ---*/ - SetStressTensor(Mean_PrimVar, Mean_GradPrimVar, Mean_turb_ke, - Mean_Laminar_Viscosity, Mean_Eddy_Viscosity); - GetViscousIncProjFlux(Mean_GradPrimVar, Normal, Mean_Thermal_Conductivity); - - /*--- Update viscous residual ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] = Proj_Flux_Tensor[iVar]; - } - - /*--- Implicit part ---*/ - - if (implicit) { - - if (dist_ij_2 == 0.0) { - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) { - val_Jacobian_i[iVar][jVar] = 0.0; - val_Jacobian_j[iVar][jVar] = 0.0; - } - } - } else { - - const su2double dist_ij = sqrt(dist_ij_2); - SetIncTauJacobian(Mean_Laminar_Viscosity, Mean_Eddy_Viscosity, - dist_ij, UnitNormal); - GetViscousIncProjJacs(Area, val_Jacobian_i, val_Jacobian_j); - - /*--- Include the temperature equation Jacobian. ---*/ - su2double proj_vector_ij = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - proj_vector_ij += (Coord_j[iDim]-Coord_i[iDim])*Normal[iDim]; - } - proj_vector_ij = proj_vector_ij/dist_ij_2; - val_Jacobian_i[nDim+1][nDim+1] = -Mean_Thermal_Conductivity*proj_vector_ij; - val_Jacobian_j[nDim+1][nDim+1] = Mean_Thermal_Conductivity*proj_vector_ij; - } - - } - - if (!energy) { - val_residual[nDim+1] = 0.0; - if (implicit) { - for (iVar = 0; iVar < nVar; iVar++) { - val_Jacobian_i[iVar][nDim+1] = 0.0; - val_Jacobian_j[iVar][nDim+1] = 0.0; - - val_Jacobian_i[nDim+1][iVar] = 0.0; - val_Jacobian_j[nDim+1][iVar] = 0.0; - } - } - } - - AD::SetPreaccOut(val_residual, nVar); - AD::EndPreacc(); - -} - -void CAvgGradInc_Flow::GetViscousIncProjFlux(const su2double* const *val_gradprimvar, - const su2double *val_normal, - su2double val_thermal_conductivity) { - - /*--- Gradient of primitive variables -> [Pressure vel_x vel_y vel_z Temperature] ---*/ - - if (nDim == 2) { - Flux_Tensor[0][0] = 0.0; - Flux_Tensor[1][0] = tau[0][0]; - Flux_Tensor[2][0] = tau[0][1]; - Flux_Tensor[3][0] = val_thermal_conductivity*val_gradprimvar[nDim+1][0]; - - Flux_Tensor[0][1] = 0.0; - Flux_Tensor[1][1] = tau[1][0]; - Flux_Tensor[2][1] = tau[1][1]; - Flux_Tensor[3][1] = val_thermal_conductivity*val_gradprimvar[nDim+1][1]; - - } else { - - Flux_Tensor[0][0] = 0.0; - Flux_Tensor[1][0] = tau[0][0]; - Flux_Tensor[2][0] = tau[0][1]; - Flux_Tensor[3][0] = tau[0][2]; - Flux_Tensor[4][0] = val_thermal_conductivity*val_gradprimvar[nDim+1][0]; - - Flux_Tensor[0][1] = 0.0; - Flux_Tensor[1][1] = tau[1][0]; - Flux_Tensor[2][1] = tau[1][1]; - Flux_Tensor[3][1] = tau[1][2]; - Flux_Tensor[4][1] = val_thermal_conductivity*val_gradprimvar[nDim+1][1]; - - Flux_Tensor[0][2] = 0.0; - Flux_Tensor[1][2] = tau[2][0]; - Flux_Tensor[2][2] = tau[2][1]; - Flux_Tensor[3][2] = tau[2][2]; - Flux_Tensor[4][2] = val_thermal_conductivity*val_gradprimvar[nDim+1][2]; - - } - - for (unsigned short iVar = 0; iVar < nVar; iVar++) { - Proj_Flux_Tensor[iVar] = 0.0; - for (unsigned short iDim = 0; iDim < nDim; iDim++) - Proj_Flux_Tensor[iVar] += Flux_Tensor[iVar][iDim] * val_normal[iDim]; - } - -} - -void CAvgGradInc_Flow::GetViscousIncProjJacs(su2double val_dS, - su2double **val_Proj_Jac_Tensor_i, - su2double **val_Proj_Jac_Tensor_j) { - - if (nDim == 2) { - - val_Proj_Jac_Tensor_i[0][0] = 0.0; - val_Proj_Jac_Tensor_i[0][1] = 0.0; - val_Proj_Jac_Tensor_i[0][2] = 0.0; - val_Proj_Jac_Tensor_i[0][3] = 0.0; - - val_Proj_Jac_Tensor_i[1][0] = val_dS*tau_jacobian_i[0][0]; - val_Proj_Jac_Tensor_i[1][1] = val_dS*tau_jacobian_i[0][1]; - val_Proj_Jac_Tensor_i[1][2] = val_dS*tau_jacobian_i[0][2]; - val_Proj_Jac_Tensor_i[1][3] = val_dS*tau_jacobian_i[0][3]; - - val_Proj_Jac_Tensor_i[2][0] = val_dS*tau_jacobian_i[1][0]; - val_Proj_Jac_Tensor_i[2][1] = val_dS*tau_jacobian_i[1][1]; - val_Proj_Jac_Tensor_i[2][2] = val_dS*tau_jacobian_i[1][2]; - val_Proj_Jac_Tensor_i[2][3] = val_dS*tau_jacobian_i[1][3]; - - val_Proj_Jac_Tensor_i[3][0] = 0.0; - val_Proj_Jac_Tensor_i[3][1] = 0.0; - val_Proj_Jac_Tensor_i[3][2] = 0.0; - val_Proj_Jac_Tensor_i[3][3] = 0.0; - - } else { - - val_Proj_Jac_Tensor_i[0][0] = 0.0; - val_Proj_Jac_Tensor_i[0][1] = 0.0; - val_Proj_Jac_Tensor_i[0][2] = 0.0; - val_Proj_Jac_Tensor_i[0][3] = 0.0; - val_Proj_Jac_Tensor_i[0][4] = 0.0; - - val_Proj_Jac_Tensor_i[1][0] = val_dS*tau_jacobian_i[0][0]; - val_Proj_Jac_Tensor_i[1][1] = val_dS*tau_jacobian_i[0][1]; - val_Proj_Jac_Tensor_i[1][2] = val_dS*tau_jacobian_i[0][2]; - val_Proj_Jac_Tensor_i[1][3] = val_dS*tau_jacobian_i[0][3]; - val_Proj_Jac_Tensor_i[1][4] = val_dS*tau_jacobian_i[0][4]; - - val_Proj_Jac_Tensor_i[2][0] = val_dS*tau_jacobian_i[1][0]; - val_Proj_Jac_Tensor_i[2][1] = val_dS*tau_jacobian_i[1][1]; - val_Proj_Jac_Tensor_i[2][2] = val_dS*tau_jacobian_i[1][2]; - val_Proj_Jac_Tensor_i[2][3] = val_dS*tau_jacobian_i[1][3]; - val_Proj_Jac_Tensor_i[2][4] = val_dS*tau_jacobian_i[1][4]; - - val_Proj_Jac_Tensor_i[3][0] = val_dS*tau_jacobian_i[2][0]; - val_Proj_Jac_Tensor_i[3][1] = val_dS*tau_jacobian_i[2][1]; - val_Proj_Jac_Tensor_i[3][2] = val_dS*tau_jacobian_i[2][2]; - val_Proj_Jac_Tensor_i[3][3] = val_dS*tau_jacobian_i[2][3]; - val_Proj_Jac_Tensor_i[3][4] = val_dS*tau_jacobian_i[2][4]; - - val_Proj_Jac_Tensor_i[4][0] = 0.0; - val_Proj_Jac_Tensor_i[4][1] = 0.0; - val_Proj_Jac_Tensor_i[4][2] = 0.0; - val_Proj_Jac_Tensor_i[4][3] = 0.0; - val_Proj_Jac_Tensor_i[4][4] = 0.0; - - } - - for (unsigned short iVar = 0; iVar < nVar; iVar++) - for (unsigned short jVar = 0; jVar < nVar; jVar++) - val_Proj_Jac_Tensor_j[iVar][jVar] = -val_Proj_Jac_Tensor_i[iVar][jVar]; - -} - -CSourceIncBodyForce::CSourceIncBodyForce(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - /*--- Store the pointer to the constant body force vector. ---*/ - - Body_Force_Vector = new su2double[nDim]; - for (unsigned short iDim = 0; iDim < nDim; iDim++) - Body_Force_Vector[iDim] = config->GetBody_Force_Vector()[iDim]; - -} - -CSourceIncBodyForce::~CSourceIncBodyForce(void) { - - if (Body_Force_Vector != NULL) delete [] Body_Force_Vector; - -} - -void CSourceIncBodyForce::ComputeResidual(su2double *val_residual, CConfig *config) { - - unsigned short iDim; - su2double DensityInc_0 = 0.0; - su2double Force_Ref = config->GetForce_Ref(); - bool variable_density = (config->GetKind_DensityModel() == VARIABLE); - - /*--- Check for variable density. If we have a variable density - problem, we should subtract out the hydrostatic pressure component. ---*/ - - if (variable_density) DensityInc_0 = config->GetDensity_FreeStreamND(); - - /*--- Zero the continuity contribution ---*/ - - val_residual[0] = 0.0; - - /*--- Momentum contribution. Note that this form assumes we have - subtracted the operating density * gravity, i.e., removed the - hydrostatic pressure component (important for pressure BCs). ---*/ - - for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = -Volume * (DensityInc_i - DensityInc_0) * Body_Force_Vector[iDim] / Force_Ref; - - /*--- Zero the temperature contribution ---*/ - - val_residual[nDim+1] = 0.0; - -} - -CSourceIncRotatingFrame_Flow::CSourceIncRotatingFrame_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - /*--- Retrieve the angular velocity vector from config. ---*/ - for (unsigned short iDim = 0; iDim < 3; iDim++) - Omega[iDim] = config->GetRotation_Rate(iDim)/config->GetOmega_Ref(); - -} - -CSourceIncRotatingFrame_Flow::~CSourceIncRotatingFrame_Flow(void) { } - -void CSourceIncRotatingFrame_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config) { - - unsigned short iDim, iVar, jVar; - su2double Momentum[3] = {0,0,0}, - Velocity_i[3] = {0,0,0}; - - /*--- Primitive variables plus momentum at the node (point i) ---*/ - - DensityInc_i = V_i[nDim+2]; - - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = V_i[iDim+1]; - Momentum[iDim] = DensityInc_i*Velocity_i[iDim]; - } - - /*--- Calculate rotating frame source term residual as ( Omega X Rho-U ) ---*/ - - if (nDim == 2) { - val_residual[0] = 0.0; - val_residual[1] = (Omega[1]*Momentum[2] - Omega[2]*Momentum[1])*Volume; - val_residual[2] = (Omega[2]*Momentum[0] - Omega[0]*Momentum[2])*Volume; - val_residual[3] = 0.0; - } else { - val_residual[0] = 0.0; - val_residual[1] = (Omega[1]*Momentum[2] - Omega[2]*Momentum[1])*Volume; - val_residual[2] = (Omega[2]*Momentum[0] - Omega[0]*Momentum[2])*Volume; - val_residual[3] = (Omega[0]*Momentum[1] - Omega[1]*Momentum[0])*Volume; - val_residual[4] = 0.0; - } - - /*--- Calculate the source term Jacobian ---*/ - - if (implicit) { - for (iVar = 0; iVar < nVar; iVar++) - for (jVar = 0; jVar < nVar; jVar++) - val_Jacobian_i[iVar][jVar] = 0.0; - if (nDim == 2) { - val_Jacobian_i[1][2] = -DensityInc_i*Omega[2]*Volume; - val_Jacobian_i[2][1] = DensityInc_i*Omega[2]*Volume; - } else { - val_Jacobian_i[1][2] = -DensityInc_i*Omega[2]*Volume; - val_Jacobian_i[1][3] = DensityInc_i*Omega[1]*Volume; - val_Jacobian_i[2][1] = DensityInc_i*Omega[2]*Volume; - val_Jacobian_i[2][3] = -DensityInc_i*Omega[0]*Volume; - val_Jacobian_i[3][1] = -DensityInc_i*Omega[1]*Volume; - val_Jacobian_i[3][2] = DensityInc_i*Omega[0]*Volume; - } - } - -} - -CSourceBoussinesq::CSourceBoussinesq(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - /*--- Store the pointer to the constant body force vector. ---*/ - - Gravity_Vector = new su2double[nDim]; - for (unsigned short iDim = 0; iDim < nDim; iDim++) - Gravity_Vector[iDim] = 0.0; - - /*--- Gravity is downward in y-dir for 2D and downward z-dir for 3D. ---*/ - - Gravity_Vector[nDim-1] = -STANDARD_GRAVITY; - -} - -CSourceBoussinesq::~CSourceBoussinesq(void) { - - if (Gravity_Vector != NULL) delete [] Gravity_Vector; - -} - -void CSourceBoussinesq::ComputeResidual(su2double *val_residual, CConfig *config) { - - unsigned short iDim; - su2double Force_Ref = config->GetForce_Ref(); - su2double T0 = config->GetTemperature_FreeStreamND(); - su2double Beta = config->GetThermal_Expansion_CoeffND(); - - /*--- Zero the continuity contribution ---*/ - - val_residual[0] = 0.0; - - /*--- Momentum contribution. Note that this form assumes we have - subtracted the operating density * gravity, i.e., removed the - hydrostatic pressure component (important for pressure BCs). ---*/ - - for (iDim = 0; iDim < nDim; iDim++) - val_residual[iDim+1] = Volume * DensityInc_i * ( Beta * (U_i[nDim+1] - T0)) * Gravity_Vector[iDim] / Force_Ref; - - /*--- Zero the energy contribution ---*/ - - val_residual[nDim+1] = 0.0; - -} - -CSourceIncAxisymmetric_Flow::CSourceIncAxisymmetric_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - energy = config->GetEnergy_Equation(); - viscous = config->GetViscous(); - -} - -CSourceIncAxisymmetric_Flow::~CSourceIncAxisymmetric_Flow(void) { } - -void CSourceIncAxisymmetric_Flow::ComputeResidual(su2double *val_residual, su2double **Jacobian_i, CConfig *config) { - - su2double yinv, Velocity_i[3]; - unsigned short iDim, jDim, iVar, jVar; - - if (Coord_i[1] > EPS) { - - yinv = 1.0/Coord_i[1]; - - /*--- Set primitive variables at points iPoint. ---*/ - - Pressure_i = V_i[0]; - Temp_i = V_i[nDim+1]; - DensityInc_i = V_i[nDim+2]; - BetaInc2_i = V_i[nDim+3]; - Cp_i = V_i[nDim+7]; - Enthalpy_i = Cp_i*Temp_i; - - for (iDim = 0; iDim < nDim; iDim++) - Velocity_i[iDim] = V_i[iDim+1]; - - /*--- Inviscid component of the source term. ---*/ - - val_residual[0] = yinv*Volume*DensityInc_i*Velocity_i[1]; - val_residual[1] = yinv*Volume*DensityInc_i*Velocity_i[0]*Velocity_i[1]; - val_residual[2] = yinv*Volume*DensityInc_i*Velocity_i[1]*Velocity_i[1]; - val_residual[3] = yinv*Volume*DensityInc_i*Enthalpy_i*Velocity_i[1]; - - if (implicit) { - - Jacobian_i[0][0] = 0.0; - Jacobian_i[0][1] = 0.0; - Jacobian_i[0][2] = 1.0; - Jacobian_i[0][3] = 0.0; - - Jacobian_i[1][0] = 0.0; - Jacobian_i[1][1] = Velocity_i[1]; - Jacobian_i[1][2] = Velocity_i[0]; - Jacobian_i[1][3] = 0.0; - - Jacobian_i[2][0] = 0.0; - Jacobian_i[2][1] = 0.0; - Jacobian_i[2][2] = 2.0*Velocity_i[1]; - Jacobian_i[2][3] = 0.0; - - Jacobian_i[3][0] = 0.0; - Jacobian_i[3][1] = 0.0; - Jacobian_i[3][2] = Enthalpy_i; - Jacobian_i[3][3] = Cp_i*Velocity_i[1]; - - for (iVar=0; iVar < nVar; iVar++) - for (jVar=0; jVar < nVar; jVar++) - Jacobian_i[iVar][jVar] *= yinv*Volume*DensityInc_i; - - } - - /*--- Add the viscous terms if necessary. ---*/ - - if (viscous) { - - Laminar_Viscosity_i = V_i[nDim+4]; - Eddy_Viscosity_i = V_i[nDim+5]; - Thermal_Conductivity_i = V_i[nDim+6]; - - su2double total_viscosity, div_vel; - - total_viscosity = (Laminar_Viscosity_i + Eddy_Viscosity_i); - - /*--- The full stress tensor is needed for variable density ---*/ - - div_vel = 0.0; - for (iDim = 0 ; iDim < nDim; iDim++) - div_vel += PrimVar_Grad_i[iDim+1][iDim]; - - for (iDim = 0 ; iDim < nDim; iDim++) - for (jDim = 0 ; jDim < nDim; jDim++) - tau[iDim][jDim] = (total_viscosity*(PrimVar_Grad_i[jDim+1][iDim] + - PrimVar_Grad_i[iDim+1][jDim] ) - -TWO3*total_viscosity*div_vel*delta[iDim][jDim]); - - /*--- Viscous terms. ---*/ - - val_residual[0] -= 0.0; - val_residual[1] -= Volume*(yinv*tau[0][1] - TWO3*AuxVar_Grad_i[0]); - val_residual[2] -= Volume*(yinv*2.0*total_viscosity*PrimVar_Grad_i[2][1] - - yinv*yinv*2.0*total_viscosity*Velocity_i[1] - - TWO3*AuxVar_Grad_i[1]); - val_residual[3] -= Volume*yinv*Thermal_Conductivity_i*PrimVar_Grad_i[nDim+1][1]; - - } - - } else { - - for (iVar=0; iVar < nVar; iVar++) - val_residual[iVar] = 0.0; - - if (implicit) { - for (iVar=0; iVar < nVar; iVar++) { - for (jVar=0; jVar < nVar; jVar++) - Jacobian_i[iVar][jVar] = 0.0; - } - } - - } - - if (!energy) { - val_residual[nDim+1] = 0.0; - if (implicit) { - for (iVar = 0; iVar < nVar; iVar++) { - Jacobian_i[iVar][nDim+1] = 0.0; - Jacobian_i[nDim+1][iVar] = 0.0; - } - } - } - -} diff --git a/SU2_CFD/src/numerics_direct_turbulent.cpp b/SU2_CFD/src/numerics_direct_turbulent.cpp deleted file mode 100644 index fff1df4be577..000000000000 --- a/SU2_CFD/src/numerics_direct_turbulent.cpp +++ /dev/null @@ -1,1505 +0,0 @@ -/*! - * \file numerics_direct_turbulent.cpp - * \brief This file contains all the convective term discretization. - * \author F. Palacios, A. Bueno - * \version 7.0.1 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - - -#include "../include/numerics_structure.hpp" -#include - -CUpwScalar::CUpwScalar(unsigned short val_nDim, - unsigned short val_nVar, - CConfig *config) - : CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_Turb() == EULER_IMPLICIT); - incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); - /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ - dynamic_grid = config->GetDynamic_Grid(); - - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; - -} - -CUpwScalar::~CUpwScalar(void) { - - delete [] Velocity_i; - delete [] Velocity_j; - -} - -void CUpwScalar::ComputeResidual(su2double *val_residual, - su2double **val_Jacobian_i, - su2double **val_Jacobian_j, - CConfig *config) { - - AD::StartPreacc(); - AD::SetPreaccIn(Normal, nDim); - AD::SetPreaccIn(TurbVar_i, nVar); AD::SetPreaccIn(TurbVar_j, nVar); - if (dynamic_grid) { - AD::SetPreaccIn(GridVel_i, nDim); AD::SetPreaccIn(GridVel_j, nDim); - } - - ExtraADPreaccIn(); - - Density_i = V_i[nDim+2]; - Density_j = V_j[nDim+2]; - - q_ij = 0.0; - if (dynamic_grid) { - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = V_i[iDim+1] - GridVel_i[iDim]; - Velocity_j[iDim] = V_j[iDim+1] - GridVel_j[iDim]; - q_ij += 0.5*(Velocity_i[iDim]+Velocity_j[iDim])*Normal[iDim]; - } - } - else { - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = V_i[iDim+1]; - Velocity_j[iDim] = V_j[iDim+1]; - q_ij += 0.5*(Velocity_i[iDim]+Velocity_j[iDim])*Normal[iDim]; - } - } - - a0 = 0.5*(q_ij+fabs(q_ij)); - a1 = 0.5*(q_ij-fabs(q_ij)); - - FinishResidualCalc(val_residual, val_Jacobian_i, val_Jacobian_j, config); - - - AD::SetPreaccOut(val_residual, nVar); - AD::EndPreacc(); - -} - -CUpwSca_TurbSA::CUpwSca_TurbSA(unsigned short val_nDim, - unsigned short val_nVar, - CConfig *config) - : CUpwScalar(val_nDim, val_nVar, config) { -} - -CUpwSca_TurbSA::~CUpwSca_TurbSA(void) { -} - -void CUpwSca_TurbSA::ExtraADPreaccIn() { - AD::SetPreaccIn(V_i, nDim+1); AD::SetPreaccIn(V_j, nDim+1); -} - -void CUpwSca_TurbSA::FinishResidualCalc(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - val_residual[0] = a0*TurbVar_i[0]+a1*TurbVar_j[0]; - - if (implicit) { - val_Jacobian_i[0][0] = a0; - val_Jacobian_j[0][0] = a1; - } -} - -CAvgGrad_Scalar::CAvgGrad_Scalar(unsigned short val_nDim, - unsigned short val_nVar, - bool correct_grad, - CConfig *config) - : CNumerics(val_nDim, val_nVar, config), correct_gradient(correct_grad) { - - implicit = (config->GetKind_TimeIntScheme_Turb() == EULER_IMPLICIT); - incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); - - Edge_Vector = new su2double [nDim]; - Proj_Mean_GradTurbVar_Normal = new su2double [nVar]; - Proj_Mean_GradTurbVar_Edge = new su2double [nVar]; - Proj_Mean_GradTurbVar = new su2double [nVar]; - Mean_GradTurbVar = new su2double* [nVar]; - for (iVar = 0; iVar < nVar; iVar++) - Mean_GradTurbVar[iVar] = new su2double [nDim]; - -} - -CAvgGrad_Scalar::~CAvgGrad_Scalar(void) { - - delete [] Edge_Vector; - delete [] Proj_Mean_GradTurbVar_Normal; - delete [] Proj_Mean_GradTurbVar_Edge; - delete [] Proj_Mean_GradTurbVar; - for (iVar = 0; iVar < nVar; iVar++) - delete [] Mean_GradTurbVar[iVar]; - delete [] Mean_GradTurbVar; - -} - -void CAvgGrad_Scalar::ComputeResidual(su2double *val_residual, - su2double **Jacobian_i, - su2double **Jacobian_j, - CConfig *config) { - - AD::StartPreacc(); - AD::SetPreaccIn(Coord_i, nDim); AD::SetPreaccIn(Coord_j, nDim); - AD::SetPreaccIn(Normal, nDim); - AD::SetPreaccIn(TurbVar_Grad_i, nVar, nDim); - AD::SetPreaccIn(TurbVar_Grad_j, nVar, nDim); - if (correct_gradient) { - AD::SetPreaccIn(TurbVar_i, nVar); AD::SetPreaccIn(TurbVar_j ,nVar); - } - ExtraADPreaccIn(); - - if (incompressible) { - AD::SetPreaccIn(V_i, nDim+6); AD::SetPreaccIn(V_j, nDim+6); - - Density_i = V_i[nDim+2]; Density_j = V_j[nDim+2]; - Laminar_Viscosity_i = V_i[nDim+4]; Laminar_Viscosity_j = V_j[nDim+4]; - Eddy_Viscosity_i = V_i[nDim+5]; Eddy_Viscosity_j = V_j[nDim+5]; - } - else { - AD::SetPreaccIn(V_i, nDim+7); AD::SetPreaccIn(V_j, nDim+7); - - Density_i = V_i[nDim+2]; Density_j = V_j[nDim+2]; - Laminar_Viscosity_i = V_i[nDim+5]; Laminar_Viscosity_j = V_j[nDim+5]; - Eddy_Viscosity_i = V_i[nDim+6]; Eddy_Viscosity_j = V_j[nDim+6]; - } - - /*--- Compute vector going from iPoint to jPoint ---*/ - - 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; - - /*--- Mean gradient approximation ---*/ - for (iVar = 0; iVar < nVar; iVar++) { - Proj_Mean_GradTurbVar_Normal[iVar] = 0.0; - Proj_Mean_GradTurbVar_Edge[iVar] = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Mean_GradTurbVar[iVar][iDim] = 0.5*(TurbVar_Grad_i[iVar][iDim] + - TurbVar_Grad_j[iVar][iDim]); - Proj_Mean_GradTurbVar_Normal[iVar] += Mean_GradTurbVar[iVar][iDim] * - Normal[iDim]; - if (correct_gradient) - Proj_Mean_GradTurbVar_Edge[iVar] += Mean_GradTurbVar[iVar][iDim]*Edge_Vector[iDim]; - } - Proj_Mean_GradTurbVar[iVar] = Proj_Mean_GradTurbVar_Normal[iVar]; - if (correct_gradient) { - Proj_Mean_GradTurbVar[iVar] -= Proj_Mean_GradTurbVar_Edge[iVar]*proj_vector_ij - - (TurbVar_j[iVar]-TurbVar_i[iVar])*proj_vector_ij; - } - } - - FinishResidualCalc(val_residual, Jacobian_i, Jacobian_j, config); - - AD::SetPreaccOut(val_residual, nVar); - AD::EndPreacc(); - -} - -CAvgGrad_TurbSA::CAvgGrad_TurbSA(unsigned short val_nDim, - unsigned short val_nVar, bool correct_grad, - CConfig *config) - : CAvgGrad_Scalar(val_nDim, val_nVar, correct_grad, config), sigma(2./3.) { -} - -CAvgGrad_TurbSA::~CAvgGrad_TurbSA(void) { -} - -void CAvgGrad_TurbSA::ExtraADPreaccIn() { -} - -void CAvgGrad_TurbSA::FinishResidualCalc(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config) { - - /*--- Compute mean effective viscosity ---*/ - - nu_i = Laminar_Viscosity_i/Density_i; - nu_j = Laminar_Viscosity_j/Density_j; - nu_e = 0.5*(nu_i+nu_j+TurbVar_i[0]+TurbVar_j[0]); - - val_residual[0] = nu_e*Proj_Mean_GradTurbVar[0]/sigma; - - /*--- For Jacobians -> Use of TSL approx. to compute derivatives of the gradients ---*/ - - if (implicit) { - Jacobian_i[0][0] = (0.5*Proj_Mean_GradTurbVar[0]-nu_e*proj_vector_ij)/sigma; - Jacobian_j[0][0] = (0.5*Proj_Mean_GradTurbVar[0]+nu_e*proj_vector_ij)/sigma; - } - -} - -CAvgGrad_TurbSA_Neg::CAvgGrad_TurbSA_Neg(unsigned short val_nDim, - unsigned short val_nVar, - bool correct_grad, - CConfig *config) - : CAvgGrad_Scalar(val_nDim, val_nVar, correct_grad, config), - sigma(2./3.), cn1(16.0), fn(0.0) { -} - -CAvgGrad_TurbSA_Neg::~CAvgGrad_TurbSA_Neg(void) { -} - -void CAvgGrad_TurbSA_Neg::ExtraADPreaccIn() { -} - -void CAvgGrad_TurbSA_Neg::FinishResidualCalc(su2double *val_residual, - su2double **Jacobian_i, - su2double **Jacobian_j, - CConfig *config) { - - /*--- Compute mean effective viscosity ---*/ - - nu_i = Laminar_Viscosity_i/Density_i; - nu_j = Laminar_Viscosity_j/Density_j; - - nu_ij = 0.5*(nu_i+nu_j); - nu_tilde_ij = 0.5*(TurbVar_i[0]+TurbVar_j[0]); - - Xi = nu_tilde_ij/nu_ij; - - if (nu_tilde_ij > 0.0) { - nu_e = nu_ij + nu_tilde_ij; - } - else { - fn = (cn1 + Xi*Xi*Xi)/(cn1 - Xi*Xi*Xi); - nu_e = nu_ij + fn*nu_tilde_ij; - } - - val_residual[0] = nu_e*Proj_Mean_GradTurbVar_Normal[0]/sigma; - - /*--- For Jacobians -> Use of TSL approx. to compute derivatives of the gradients ---*/ - - if (implicit) { - Jacobian_i[0][0] = (0.5*Proj_Mean_GradTurbVar[0]-nu_e*proj_vector_ij)/sigma; - Jacobian_j[0][0] = (0.5*Proj_Mean_GradTurbVar[0]+nu_e*proj_vector_ij)/sigma; - } - -} - -CSourcePieceWise_TurbSA::CSourcePieceWise_TurbSA(unsigned short val_nDim, unsigned short val_nVar, - CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); - rotating_frame = config->GetRotating_Frame(); - transition = (config->GetKind_Trans_Model() == BC); - - /*--- Spalart-Allmaras closure constants ---*/ - - cv1_3 = pow(7.1, 3.0); - k2 = pow(0.41, 2.0); - cb1 = 0.1355; - cw2 = 0.3; - ct3 = 1.2; - ct4 = 0.5; - cw3_6 = pow(2.0, 6.0); - sigma = 2./3.; - cb2 = 0.622; - cb2_sigma = cb2/sigma; - cw1 = cb1/k2+(1.0+cb2)/sigma; - -} - -CSourcePieceWise_TurbSA::~CSourcePieceWise_TurbSA(void) { } - -void CSourcePieceWise_TurbSA::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - -// AD::StartPreacc(); -// AD::SetPreaccIn(V_i, nDim+6); -// AD::SetPreaccIn(Vorticity_i, nDim); -// AD::SetPreaccIn(StrainMag_i); -// AD::SetPreaccIn(TurbVar_i[0]); -// AD::SetPreaccIn(TurbVar_Grad_i[0], nDim); -// AD::SetPreaccIn(Volume); AD::SetPreaccIn(dist_i); - -// BC Transition Model variables - su2double vmag, rey, re_theta, re_theta_t, re_v; - su2double tu , nu_cr, nu_t, nu_BC, chi_1, chi_2, term1, term2, term_exponential; - - if (incompressible) { - Density_i = V_i[nDim+2]; - Laminar_Viscosity_i = V_i[nDim+4]; - } - else { - Density_i = V_i[nDim+2]; - Laminar_Viscosity_i = V_i[nDim+5]; - } - - val_residual[0] = 0.0; - Production = 0.0; - Destruction = 0.0; - CrossProduction = 0.0; - val_Jacobian_i[0][0] = 0.0; - - gamma_BC = 0.0; - vmag = 0.0; - tu = config->GetTurbulenceIntensity_FreeStream(); - rey = config->GetReynolds(); - - if (nDim==2) { - vmag = sqrt(V_i[1]*V_i[1]+V_i[2]*V_i[2]); - } - else if (nDim==3) { - vmag = sqrt(V_i[1]*V_i[1]+V_i[2]*V_i[2]+V_i[3]*V_i[3]); - } - - /*--- Evaluate Omega ---*/ - - Omega = sqrt(Vorticity_i[0]*Vorticity_i[0] + Vorticity_i[1]*Vorticity_i[1] + Vorticity_i[2]*Vorticity_i[2]); - - /*--- Rotational correction term ---*/ - - if (rotating_frame) { Omega += 2.0*min(0.0, StrainMag_i-Omega); } - - if (dist_i > 1e-10) { - - /*--- Production term ---*/ - - dist_i_2 = dist_i*dist_i; - nu = Laminar_Viscosity_i/Density_i; - Ji = TurbVar_i[0]/nu; - Ji_2 = Ji*Ji; - Ji_3 = Ji_2*Ji; - fv1 = Ji_3/(Ji_3+cv1_3); - fv2 = 1.0 - Ji/(1.0+Ji*fv1); - ft2 = ct3*exp(-ct4*Ji_2); - S = Omega; - inv_k2_d2 = 1.0/(k2*dist_i_2); - - Shat = S + TurbVar_i[0]*fv2*inv_k2_d2; - Shat = max(Shat, 1.0e-10); - inv_Shat = 1.0/Shat; - -// Original SA model -// Production = cb1*(1.0-ft2)*Shat*TurbVar_i[0]*Volume; - - if (transition) { - -// BC model constants - chi_1 = 0.002; - chi_2 = 5.0; - - nu_t = (TurbVar_i[0]*fv1); //S-A variable - nu_cr = chi_2/rey; - nu_BC = (nu_t)/(vmag*dist_i); - - re_v = ((Density_i*pow(dist_i,2.))/(Laminar_Viscosity_i))*Omega; - re_theta = re_v/2.193; - re_theta_t = (803.73 * pow((tu + 0.6067),-1.027)); //MENTER correlation - //re_theta_t = 163.0 + exp(6.91-tu); //ABU-GHANNAM & SHAW correlation - - term1 = sqrt(max(re_theta-re_theta_t,0.)/(chi_1*re_theta_t)); - term2 = sqrt(max(nu_BC-nu_cr,0.)/(nu_cr)); - term_exponential = (term1 + term2); - gamma_BC = 1.0 - exp(-term_exponential); - - Production = gamma_BC*cb1*Shat*TurbVar_i[0]*Volume; - } - else { - Production = cb1*Shat*TurbVar_i[0]*Volume; - } - - /*--- Destruction term ---*/ - - r = min(TurbVar_i[0]*inv_Shat*inv_k2_d2,10.0); - g = r + cw2*(pow(r,6.0)-r); - g_6 = pow(g,6.0); - glim = pow((1.0+cw3_6)/(g_6+cw3_6),1.0/6.0); - fw = g*glim; - -// Original SA model -// Destruction = (cw1*fw-cb1*ft2/k2)*TurbVar_i[0]*TurbVar_i[0]/dist_i_2*Volume; - - Destruction = cw1*fw*TurbVar_i[0]*TurbVar_i[0]/dist_i_2*Volume; - - /*--- Diffusion term ---*/ - - norm2_Grad = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - norm2_Grad += TurbVar_Grad_i[0][iDim]*TurbVar_Grad_i[0][iDim]; - - CrossProduction = cb2_sigma*norm2_Grad*Volume; - - val_residual[0] = Production - Destruction + CrossProduction; - - /*--- Implicit part, production term ---*/ - - dfv1 = 3.0*Ji_2*cv1_3/(nu*pow(Ji_3+cv1_3,2.)); - dfv2 = -(1/nu-Ji_2*dfv1)/pow(1.+Ji*fv1,2.); - if ( Shat <= 1.0e-10 ) dShat = 0.0; - else dShat = (fv2+TurbVar_i[0]*dfv2)*inv_k2_d2; - - if (transition) { - val_Jacobian_i[0][0] += gamma_BC*cb1*(TurbVar_i[0]*dShat+Shat)*Volume; - } - else { - val_Jacobian_i[0][0] += cb1*(TurbVar_i[0]*dShat+Shat)*Volume; - } - - /*--- Implicit part, destruction term ---*/ - - dr = (Shat-TurbVar_i[0]*dShat)*inv_Shat*inv_Shat*inv_k2_d2; - if (r == 10.0) dr = 0.0; - dg = dr*(1.+cw2*(6.0*pow(r,5.0)-1.0)); - dfw = dg*glim*(1.-g_6/(g_6+cw3_6)); - val_Jacobian_i[0][0] -= cw1*(dfw*TurbVar_i[0] + 2.0*fw)*TurbVar_i[0]/dist_i_2*Volume; - - } - -// AD::SetPreaccOut(val_residual[0]); -// AD::EndPreacc(); - -} - -CSourcePieceWise_TurbSA_E::CSourcePieceWise_TurbSA_E(unsigned short val_nDim, unsigned short val_nVar, - CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); - rotating_frame = config->GetRotating_Frame(); - - /*--- Spalart-Allmaras closure constants ---*/ - - cv1_3 = pow(7.1, 3.0); - k2 = pow(0.41, 2.0); - cb1 = 0.1355; - cw2 = 0.3; - ct3 = 1.2; - ct4 = 0.5; - cw3_6 = pow(2.0, 6.0); - sigma = 2./3.; - cb2 = 0.622; - cb2_sigma = cb2/sigma; - cw1 = cb1/k2+(1.0+cb2)/sigma; - -} - -CSourcePieceWise_TurbSA_E::~CSourcePieceWise_TurbSA_E(void) { } - -void CSourcePieceWise_TurbSA_E::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - // AD::StartPreacc(); - // AD::SetPreaccIn(V_i, nDim+6); - // AD::SetPreaccIn(Vorticity_i, nDim); - // AD::SetPreaccIn(StrainMag_i); - // AD::SetPreaccIn(TurbVar_i[0]); - // AD::SetPreaccIn(TurbVar_Grad_i[0], nDim); - // AD::SetPreaccIn(Volume); AD::SetPreaccIn(dist_i); - - if (incompressible) { - Density_i = V_i[nDim+2]; - Laminar_Viscosity_i = V_i[nDim+4]; - } - else { - Density_i = V_i[nDim+2]; - Laminar_Viscosity_i = V_i[nDim+5]; - } - - val_residual[0] = 0.0; - Production = 0.0; - Destruction = 0.0; - CrossProduction = 0.0; - val_Jacobian_i[0][0] = 0.0; - - - /* - From NASA Turbulence model site. http://turbmodels.larc.nasa.gov/spalart.html - This form was developed primarily to improve the near-wall numerical behavior of the model (i.e., the goal was to improve the convergence behavior). The reference is: - Edwards, J. R. and Chandra, S. "Comparison of Eddy Viscosity-Transport Turbulence Models for Three-Dimensional, Shock-Separated Flowfields," AIAA Journal, Vol. 34, No. 4, 1996, pp. 756-763. - In this modificaton Omega is replaced by Strain Rate - */ - - /*--- Evaluate Omega, here Omega is the Strain Rate ---*/ - - Sbar = 0.0; - for(iDim=0;iDim 1e-10) { - - /*--- Production term ---*/ - - dist_i_2 = dist_i*dist_i; - nu = Laminar_Viscosity_i/Density_i; - Ji = TurbVar_i[0]/nu; - Ji_2 = Ji*Ji; - Ji_3 = Ji_2*Ji; - fv1 = Ji_3/(Ji_3+cv1_3); - fv2 = 1.0 - Ji/(1.0+Ji*fv1); - ft2 = ct3*exp(-ct4*Ji_2); - S = Omega; - inv_k2_d2 = 1.0/(k2*dist_i_2); - - //Shat = S + TurbVar_i[0]*fv2*inv_k2_d2; - Shat = max(S*((1.0/max(Ji,1.0e-16))+fv1),1.0e-16); - - Shat = max(Shat, 1.0e-10); - inv_Shat = 1.0/Shat; - - /*--- Production term ---*/; - - Production = cb1*Shat*TurbVar_i[0]*Volume; - - /*--- Destruction term ---*/ - - r = min(TurbVar_i[0]*inv_Shat*inv_k2_d2,10.0); - r=tanh(r)/tanh(1.0); - - g = r + cw2*(pow(r,6.0)-r); - g_6 = pow(g,6.0); - glim = pow((1.0+cw3_6)/(g_6+cw3_6),1.0/6.0); - fw = g*glim; - - Destruction = cw1*fw*TurbVar_i[0]*TurbVar_i[0]/dist_i_2*Volume; - - /*--- Diffusion term ---*/ - - norm2_Grad = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - norm2_Grad += TurbVar_Grad_i[0][iDim]*TurbVar_Grad_i[0][iDim]; - - CrossProduction = cb2_sigma*norm2_Grad*Volume; - - val_residual[0] = Production - Destruction + CrossProduction; - - /*--- Implicit part, production term ---*/ - - dfv1 = 3.0*Ji_2*cv1_3/(nu*pow(Ji_3+cv1_3,2.)); - dfv2 = -(1/nu-Ji_2*dfv1)/pow(1.+Ji*fv1,2.); - - if ( Shat <= 1.0e-10 ) dShat = 0.0; - else dShat = -S*pow(Ji,-2.0)/nu + S*dfv1; - val_Jacobian_i[0][0] += cb1*(TurbVar_i[0]*dShat+Shat)*Volume; - - /*--- Implicit part, destruction term ---*/ - - dr = (Shat-TurbVar_i[0]*dShat)*inv_Shat*inv_Shat*inv_k2_d2; - dr=(1-pow(tanh(r),2.0))*(dr)/tanh(1.0); - dg = dr*(1.+cw2*(6.0*pow(r,5.0)-1.0)); - dfw = dg*glim*(1.-g_6/(g_6+cw3_6)); - val_Jacobian_i[0][0] -= cw1*(dfw*TurbVar_i[0] + 2.0*fw)*TurbVar_i[0]/dist_i_2*Volume; - - } - - // AD::SetPreaccOut(val_residual[0]); - // AD::EndPreacc(); - -} - -CSourcePieceWise_TurbSA_COMP::CSourcePieceWise_TurbSA_COMP(unsigned short val_nDim, unsigned short val_nVar, - CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); - rotating_frame = config->GetRotating_Frame(); - - /*--- Spalart-Allmaras closure constants ---*/ - - cv1_3 = pow(7.1, 3.0); - k2 = pow(0.41, 2.0); - cb1 = 0.1355; - cw2 = 0.3; - ct3 = 1.2; - ct4 = 0.5; - cw3_6 = pow(2.0, 6.0); - sigma = 2./3.; - cb2 = 0.622; - cb2_sigma = cb2/sigma; - cw1 = cb1/k2+(1.0+cb2)/sigma; - c5 = 3.5; - -} - -CSourcePieceWise_TurbSA_COMP::~CSourcePieceWise_TurbSA_COMP(void) { } - -void CSourcePieceWise_TurbSA_COMP::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - // AD::StartPreacc(); - // AD::SetPreaccIn(V_i, nDim+6); - // AD::SetPreaccIn(Vorticity_i, nDim); - // AD::SetPreaccIn(StrainMag_i); - // AD::SetPreaccIn(TurbVar_i[0]); - // AD::SetPreaccIn(TurbVar_Grad_i[0], nDim); - // AD::SetPreaccIn(Volume); AD::SetPreaccIn(dist_i); - - if (incompressible) { - Density_i = V_i[nDim+2]; - Laminar_Viscosity_i = V_i[nDim+4]; - } - else { - Density_i = V_i[nDim+2]; - Laminar_Viscosity_i = V_i[nDim+5]; - } - - val_residual[0] = 0.0; - Production = 0.0; - Destruction = 0.0; - CrossProduction = 0.0; - val_Jacobian_i[0][0] = 0.0; - - /*--- Evaluate Omega ---*/ - - Omega = sqrt(Vorticity_i[0]*Vorticity_i[0] + Vorticity_i[1]*Vorticity_i[1] + Vorticity_i[2]*Vorticity_i[2]); - - /*--- Rotational correction term ---*/ - - if (rotating_frame) { Omega += 2.0*min(0.0, StrainMag_i-Omega); } - - if (dist_i > 1e-10) { - - /*--- Production term ---*/ - - dist_i_2 = dist_i*dist_i; - nu = Laminar_Viscosity_i/Density_i; - Ji = TurbVar_i[0]/nu; - Ji_2 = Ji*Ji; - Ji_3 = Ji_2*Ji; - fv1 = Ji_3/(Ji_3+cv1_3); - fv2 = 1.0 - Ji/(1.0+Ji*fv1); - ft2 = ct3*exp(-ct4*Ji_2); - S = Omega; - inv_k2_d2 = 1.0/(k2*dist_i_2); - - Shat = S + TurbVar_i[0]*fv2*inv_k2_d2; - Shat = max(Shat, 1.0e-10); - inv_Shat = 1.0/Shat; - - /*--- Production term ---*/; - - Production = cb1*Shat*TurbVar_i[0]*Volume; - - /*--- Destruction term ---*/ - - r = min(TurbVar_i[0]*inv_Shat*inv_k2_d2,10.0); - g = r + cw2*(pow(r,6.0)-r); - g_6 = pow(g,6.0); - glim = pow((1.0+cw3_6)/(g_6+cw3_6),1.0/6.0); - fw = g*glim; - - Destruction = cw1*fw*TurbVar_i[0]*TurbVar_i[0]/dist_i_2*Volume; - - /*--- Diffusion term ---*/ - - norm2_Grad = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - norm2_Grad += TurbVar_Grad_i[0][iDim]*TurbVar_Grad_i[0][iDim]; - - CrossProduction = cb2_sigma*norm2_Grad*Volume; - - val_residual[0] = Production - Destruction + CrossProduction; - - /*--- Compressibility Correction term ---*/ - Pressure_i = V_i[nDim+1]; - SoundSpeed_i = sqrt(Pressure_i*Gamma/Density_i); - aux_cc=0; - for(iDim=0;iDimGetKind_Regime() == INCOMPRESSIBLE); - rotating_frame = config->GetRotating_Frame(); - - /*--- Spalart-Allmaras closure constants ---*/ - - cv1_3 = pow(7.1, 3.0); - k2 = pow(0.41, 2.0); - cb1 = 0.1355; - cw2 = 0.3; - ct3 = 1.2; - ct4 = 0.5; - cw3_6 = pow(2.0, 6.0); - sigma = 2./3.; - cb2 = 0.622; - cb2_sigma = cb2/sigma; - cw1 = cb1/k2+(1.0+cb2)/sigma; - -} - -CSourcePieceWise_TurbSA_E_COMP::~CSourcePieceWise_TurbSA_E_COMP(void) { } - -void CSourcePieceWise_TurbSA_E_COMP::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - // AD::StartPreacc(); - // AD::SetPreaccIn(V_i, nDim+6); - // AD::SetPreaccIn(Vorticity_i, nDim); - // AD::SetPreaccIn(StrainMag_i); - // AD::SetPreaccIn(TurbVar_i[0]); - // AD::SetPreaccIn(TurbVar_Grad_i[0], nDim); - // AD::SetPreaccIn(Volume); AD::SetPreaccIn(dist_i); - - if (incompressible) { - Density_i = V_i[nDim+2]; - Laminar_Viscosity_i = V_i[nDim+4]; - } - else { - Density_i = V_i[nDim+2]; - Laminar_Viscosity_i = V_i[nDim+5]; - } - - val_residual[0] = 0.0; - Production = 0.0; - Destruction = 0.0; - CrossProduction = 0.0; - val_Jacobian_i[0][0] = 0.0; - - /* - From NASA Turbulence model site. http://turbmodels.larc.nasa.gov/spalart.html - This form was developed primarily to improve the near-wall numerical behavior of the model (i.e., the goal was to improve the convergence behavior). The reference is: - Edwards, J. R. and Chandra, S. "Comparison of Eddy Viscosity-Transport Turbulence Models for Three-Dimensional, Shock-Separated Flowfields," AIAA Journal, Vol. 34, No. 4, 1996, pp. 756-763. - In this modificaton Omega is replaced by Strain Rate - */ - - /*--- Evaluate Omega, here Omega is the Strain Rate ---*/ - - Sbar = 0.0; - for(iDim=0;iDim 1e-10) { - - /*--- Production term ---*/ - - dist_i_2 = dist_i*dist_i; - nu = Laminar_Viscosity_i/Density_i; - Ji = TurbVar_i[0]/nu; - Ji_2 = Ji*Ji; - Ji_3 = Ji_2*Ji; - fv1 = Ji_3/(Ji_3+cv1_3); - fv2 = 1.0 - Ji/(1.0+Ji*fv1); - ft2 = ct3*exp(-ct4*Ji_2); - S = Omega; - inv_k2_d2 = 1.0/(k2*dist_i_2); - - Shat = max(S*((1.0/max(Ji,1.0e-16))+fv1),1.0e-16); - - Shat = max(Shat, 1.0e-10); - inv_Shat = 1.0/Shat; - - /*--- Production term ---*/; - - Production = cb1*Shat*TurbVar_i[0]*Volume; - - /*--- Destruction term ---*/ - - r = min(TurbVar_i[0]*inv_Shat*inv_k2_d2,10.0); - r=tanh(r)/tanh(1.0); - - g = r + cw2*(pow(r,6.0)-r); - g_6 = pow(g,6.0); - glim = pow((1.0+cw3_6)/(g_6+cw3_6),1.0/6.0); - fw = g*glim; - - Destruction = cw1*fw*TurbVar_i[0]*TurbVar_i[0]/dist_i_2*Volume; - - /*--- Diffusion term ---*/ - - norm2_Grad = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - norm2_Grad += TurbVar_Grad_i[0][iDim]*TurbVar_Grad_i[0][iDim]; - - CrossProduction = cb2_sigma*norm2_Grad*Volume; - - val_residual[0] = Production - Destruction + CrossProduction; - - /*--- Compressibility Correction term ---*/ - Pressure_i = V_i[nDim+1]; - SoundSpeed_i = sqrt(Pressure_i*Gamma/Density_i); - aux_cc=0; - for(iDim=0;iDimGetKind_Regime() == INCOMPRESSIBLE); - rotating_frame = config->GetRotating_Frame(); - - /*--- Negative Spalart-Allmaras closure constants ---*/ - - cv1_3 = pow(7.1, 3.0); - k2 = pow(0.41, 2.0); - cb1 = 0.1355; - cw2 = 0.3; - ct3 = 1.2; - ct4 = 0.5; - cw3_6 = pow(2.0, 6.0); - sigma = 2./3.; - cb2 = 0.622; - cb2_sigma = cb2/sigma; - cw1 = cb1/k2+(1.0+cb2)/sigma; - -} - -CSourcePieceWise_TurbSA_Neg::~CSourcePieceWise_TurbSA_Neg(void) { - -} - -void CSourcePieceWise_TurbSA_Neg::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - -// AD::StartPreacc(); -// AD::SetPreaccIn(V_i, nDim+6); -// AD::SetPreaccIn(Vorticity_i, nDim); -// AD::SetPreaccIn(StrainMag_i); -// AD::SetPreaccIn(TurbVar_i[0]); -// AD::SetPreaccIn(TurbVar_Grad_i[0], nDim); -// AD::SetPreaccIn(Volume); AD::SetPreaccIn(dist_i); - - if (incompressible) { - Density_i = V_i[nDim+2]; - Laminar_Viscosity_i = V_i[nDim+4]; - } - else { - Density_i = V_i[nDim+2]; - Laminar_Viscosity_i = V_i[nDim+5]; - } - - val_residual[0] = 0.0; - Production = 0.0; - Destruction = 0.0; - CrossProduction = 0.0; - val_Jacobian_i[0][0] = 0.0; - - /*--- Evaluate Omega ---*/ - - Omega = sqrt(Vorticity_i[0]*Vorticity_i[0] + Vorticity_i[1]*Vorticity_i[1] + Vorticity_i[2]*Vorticity_i[2]); - - /*--- Rotational correction term ---*/ - - if (rotating_frame) { Omega += 2.0*min(0.0, StrainMag_i-Omega); } - - if (dist_i > 1e-10) { - - if (TurbVar_i[0] > 0.0) { - - /*--- Production term ---*/ - - dist_i_2 = dist_i*dist_i; - nu = Laminar_Viscosity_i/Density_i; - Ji = TurbVar_i[0]/nu; - Ji_2 = Ji*Ji; - Ji_3 = Ji_2*Ji; - fv1 = Ji_3/(Ji_3+cv1_3); - fv2 = 1.0 - Ji/(1.0+Ji*fv1); - ft2 = ct3*exp(-ct4*Ji_2); - S = Omega; - inv_k2_d2 = 1.0/(k2*dist_i_2); - - Shat = S + TurbVar_i[0]*fv2*inv_k2_d2; - Shat = max(Shat, 1.0e-10); - inv_Shat = 1.0/Shat; - - /*--- Production term ---*/; - - // Original SA model - // Production = cb1*(1.0-ft2)*Shat*TurbVar_i[0]*Volume; - - Production = cb1*Shat*TurbVar_i[0]*Volume; - - /*--- Destruction term ---*/ - - r = min(TurbVar_i[0]*inv_Shat*inv_k2_d2,10.0); - g = r + cw2*(pow(r,6.0)-r); - g_6 = pow(g,6.0); - glim = pow((1.0+cw3_6)/(g_6+cw3_6),1.0/6.0); - fw = g*glim; - - Destruction = cw1*fw*TurbVar_i[0]*TurbVar_i[0]/dist_i_2*Volume; - - /*--- Diffusion term ---*/ - - norm2_Grad = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - norm2_Grad += TurbVar_Grad_i[0][iDim]*TurbVar_Grad_i[0][iDim]; - - CrossProduction = cb2_sigma*norm2_Grad*Volume; - - val_residual[0] = Production - Destruction + CrossProduction; - - /*--- Implicit part, production term ---*/ - - dfv1 = 3.0*Ji_2*cv1_3/(nu*pow(Ji_3+cv1_3,2.)); - dfv2 = -(1/nu-Ji_2*dfv1)/pow(1.+Ji*fv1,2.); - if ( Shat <= 1.0e-10 ) dShat = 0.0; - else dShat = (fv2+TurbVar_i[0]*dfv2)*inv_k2_d2; - val_Jacobian_i[0][0] += cb1*(TurbVar_i[0]*dShat+Shat)*Volume; - - /*--- Implicit part, destruction term ---*/ - - dr = (Shat-TurbVar_i[0]*dShat)*inv_Shat*inv_Shat*inv_k2_d2; - if (r == 10.0) dr = 0.0; - dg = dr*(1.+cw2*(6.0*pow(r,5.0)-1.0)); - dfw = dg*glim*(1.-g_6/(g_6+cw3_6)); - val_Jacobian_i[0][0] -= cw1*(dfw*TurbVar_i[0] + 2.0*fw)*TurbVar_i[0]/dist_i_2*Volume; - - } - - else { - - /*--- Production term ---*/ - - dist_i_2 = dist_i*dist_i; - - /*--- Production term ---*/; - - Production = cb1*(1.0-ct3)*Omega*TurbVar_i[0]*Volume; - - /*--- Destruction term ---*/ - - Destruction = cw1*TurbVar_i[0]*TurbVar_i[0]/dist_i_2*Volume; - - /*--- Diffusion term ---*/ - - norm2_Grad = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - norm2_Grad += TurbVar_Grad_i[0][iDim]*TurbVar_Grad_i[0][iDim]; - - CrossProduction = cb2_sigma*norm2_Grad*Volume; - - val_residual[0] = Production + Destruction + CrossProduction; - - /*--- Implicit part, production term ---*/ - - val_Jacobian_i[0][0] += cb1*(1.0-ct3)*Omega*Volume; - - /*--- Implicit part, destruction term ---*/ - - val_Jacobian_i[0][0] += 2.0*cw1*TurbVar_i[0]/dist_i_2*Volume; - - } - - } - -// AD::SetPreaccOut(val_residual, nVar); -// AD::EndPreacc(); -} - -CUpwSca_TurbSST::CUpwSca_TurbSST(unsigned short val_nDim, - unsigned short val_nVar, - CConfig *config) - : CUpwScalar(val_nDim, val_nVar, config) { -} - -CUpwSca_TurbSST::~CUpwSca_TurbSST(void) { -} - -void CUpwSca_TurbSST::ExtraADPreaccIn() { - - AD::SetPreaccIn(V_i, nDim+3); - AD::SetPreaccIn(V_j, nDim+3); - -} - -void CUpwSca_TurbSST::FinishResidualCalc(su2double *val_residual, - su2double **val_Jacobian_i, - su2double **val_Jacobian_j, - CConfig *config) { - - val_residual[0] = a0*Density_i*TurbVar_i[0]+a1*Density_j*TurbVar_j[0]; - val_residual[1] = a0*Density_i*TurbVar_i[1]+a1*Density_j*TurbVar_j[1]; - - if (implicit) { - val_Jacobian_i[0][0] = a0; val_Jacobian_i[0][1] = 0.0; - val_Jacobian_i[1][0] = 0.0; val_Jacobian_i[1][1] = a0; - - val_Jacobian_j[0][0] = a1; val_Jacobian_j[0][1] = 0.0; - val_Jacobian_j[1][0] = 0.0; val_Jacobian_j[1][1] = a1; - } -} - -CAvgGrad_TurbSST::CAvgGrad_TurbSST(unsigned short val_nDim, - unsigned short val_nVar, - su2double *constants, bool correct_grad, - CConfig *config) - : CAvgGrad_Scalar(val_nDim, val_nVar, correct_grad, config) { - - sigma_k1 = constants[0]; - sigma_om1 = constants[2]; - sigma_k2 = constants[1]; - sigma_om2 = constants[3]; - - F1_i = 0.0; F1_j = 0.0; - diff_kine = 0.0; - diff_omega = 0.0; - -} - -CAvgGrad_TurbSST::~CAvgGrad_TurbSST(void) { -} - -void CAvgGrad_TurbSST::ExtraADPreaccIn() { - AD::SetPreaccIn(F1_i); AD::SetPreaccIn(F1_j); -} - -void CAvgGrad_TurbSST::FinishResidualCalc(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config) { - - su2double sigma_kine_i, sigma_kine_j, sigma_omega_i, sigma_omega_j; - su2double diff_i_kine, diff_i_omega, diff_j_kine, diff_j_omega; - - /*--- Compute the blended constant for the viscous terms ---*/ - sigma_kine_i = F1_i*sigma_k1 + (1.0 - F1_i)*sigma_k2; - sigma_kine_j = F1_j*sigma_k1 + (1.0 - F1_j)*sigma_k2; - sigma_omega_i = F1_i*sigma_om1 + (1.0 - F1_i)*sigma_om2; - sigma_omega_j = F1_j*sigma_om1 + (1.0 - F1_j)*sigma_om2; - - /*--- Compute mean effective viscosity ---*/ - diff_i_kine = Laminar_Viscosity_i + sigma_kine_i*Eddy_Viscosity_i; - diff_j_kine = Laminar_Viscosity_j + sigma_kine_j*Eddy_Viscosity_j; - diff_i_omega = Laminar_Viscosity_i + sigma_omega_i*Eddy_Viscosity_i; - diff_j_omega = Laminar_Viscosity_j + sigma_omega_j*Eddy_Viscosity_j; - - diff_kine = 0.5*(diff_i_kine + diff_j_kine); // Could instead use weighted average! - diff_omega = 0.5*(diff_i_omega + diff_j_omega); - - val_residual[0] = diff_kine*Proj_Mean_GradTurbVar[0]; - val_residual[1] = diff_omega*Proj_Mean_GradTurbVar[1]; - - /*--- For Jacobians -> Use of TSL approx. to compute derivatives of the gradients ---*/ - if (implicit) { - Jacobian_i[0][0] = -diff_kine*proj_vector_ij/Density_i; Jacobian_i[0][1] = 0.0; - Jacobian_i[1][0] = 0.0; Jacobian_i[1][1] = -diff_omega*proj_vector_ij/Density_i; - - Jacobian_j[0][0] = diff_kine*proj_vector_ij/Density_j; Jacobian_j[0][1] = 0.0; - Jacobian_j[1][0] = 0.0; Jacobian_j[1][1] = diff_omega*proj_vector_ij/Density_j; - } - -} - -CSourcePieceWise_TurbSST::CSourcePieceWise_TurbSST(unsigned short val_nDim, unsigned short val_nVar, su2double *constants, - su2double val_kine_Inf, su2double val_omega_Inf, CConfig *config) - : CNumerics(val_nDim, val_nVar, config) { - - incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); - sustaining_terms = (config->GetKind_Turb_Model() == SST_SUST); - - /*--- Closure constants ---*/ - beta_star = constants[6]; - sigma_omega_1 = constants[2]; - sigma_omega_2 = constants[3]; - beta_1 = constants[4]; - beta_2 = constants[5]; - alfa_1 = constants[8]; - alfa_2 = constants[9]; - a1 = constants[7]; - - /*--- Set the ambient values of k and omega to the free stream values. ---*/ - kAmb = val_kine_Inf; - omegaAmb = val_omega_Inf; -} - -CSourcePieceWise_TurbSST::~CSourcePieceWise_TurbSST(void) { } - -void CSourcePieceWise_TurbSST::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - AD::StartPreacc(); - AD::SetPreaccIn(StrainMag_i); - AD::SetPreaccIn(TurbVar_i, nVar); - AD::SetPreaccIn(TurbVar_Grad_i, nVar, nDim); - AD::SetPreaccIn(Volume); AD::SetPreaccIn(dist_i); - AD::SetPreaccIn(F1_i); AD::SetPreaccIn(F2_i); AD::SetPreaccIn(CDkw_i); - AD::SetPreaccIn(PrimVar_Grad_i, nDim+1, nDim); - - unsigned short iDim; - su2double alfa_blended, beta_blended; - su2double diverg, pk, pw, zeta; - - if (incompressible) { - AD::SetPreaccIn(V_i, nDim+6); - - Density_i = V_i[nDim+2]; - Laminar_Viscosity_i = V_i[nDim+4]; - Eddy_Viscosity_i = V_i[nDim+5]; - } - else { - AD::SetPreaccIn(V_i, nDim+7); - - Density_i = V_i[nDim+2]; - Laminar_Viscosity_i = V_i[nDim+5]; - Eddy_Viscosity_i = V_i[nDim+6]; - } - - val_residual[0] = 0.0; val_residual[1] = 0.0; - val_Jacobian_i[0][0] = 0.0; val_Jacobian_i[0][1] = 0.0; - val_Jacobian_i[1][0] = 0.0; val_Jacobian_i[1][1] = 0.0; - - /*--- Computation of blended constants for the source terms---*/ - - alfa_blended = F1_i*alfa_1 + (1.0 - F1_i)*alfa_2; - beta_blended = F1_i*beta_1 + (1.0 - F1_i)*beta_2; - - if (dist_i > 1e-10) { - - /*--- Production ---*/ - - diverg = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - diverg += PrimVar_Grad_i[iDim+1][iDim]; - - /* if using UQ methodolgy, calculate production using perturbed Reynolds stress matrix */ - - if (using_uq){ - SetReynoldsStressMatrix(TurbVar_i[0]); - SetPerturbedRSM(TurbVar_i[0], config); - SetPerturbedStrainMag(TurbVar_i[0]); - pk = Eddy_Viscosity_i*PerturbedStrainMag*PerturbedStrainMag - - 2.0/3.0*Density_i*TurbVar_i[0]*diverg; - } - else { - pk = Eddy_Viscosity_i*StrainMag_i*StrainMag_i - 2.0/3.0*Density_i*TurbVar_i[0]*diverg; - } - - - pk = min(pk,20.0*beta_star*Density_i*TurbVar_i[1]*TurbVar_i[0]); - pk = max(pk,0.0); - - zeta = max(TurbVar_i[1], StrainMag_i*F2_i/a1); - - /* if using UQ methodolgy, calculate production using perturbed Reynolds stress matrix */ - - if (using_uq){ - pw = PerturbedStrainMag * PerturbedStrainMag - 2.0/3.0*zeta*diverg; - } - else { - pw = StrainMag_i*StrainMag_i - 2.0/3.0*zeta*diverg; - } - pw = alfa_blended*Density_i*max(pw,0.0); - - /*--- Sustaining terms, if desired. Note that if the production terms are - larger equal than the sustaining terms, the original formulation is - obtained again. This is in contrast to the version in literature - where the sustaining terms are simply added. This latter approach could - lead to problems for very big values of the free-stream turbulence - intensity. ---*/ - - if ( sustaining_terms ) { - const su2double sust_k = beta_star*Density_i*kAmb*omegaAmb; - const su2double sust_w = beta_blended*Density_i*omegaAmb*omegaAmb; - - pk = max(pk, sust_k); - pw = max(pw, sust_w); - } - - /*--- Add the production terms to the residuals. ---*/ - - val_residual[0] += pk*Volume; - val_residual[1] += pw*Volume; - - /*--- Dissipation ---*/ - - val_residual[0] -= beta_star*Density_i*TurbVar_i[1]*TurbVar_i[0]*Volume; - val_residual[1] -= beta_blended*Density_i*TurbVar_i[1]*TurbVar_i[1]*Volume; - - /*--- Cross diffusion ---*/ - - val_residual[1] += (1.0 - F1_i)*CDkw_i*Volume; - - /*--- Implicit part ---*/ - - val_Jacobian_i[0][0] = -beta_star*TurbVar_i[1]*Volume; - val_Jacobian_i[0][1] = -beta_star*TurbVar_i[0]*Volume; - val_Jacobian_i[1][0] = 0.0; - val_Jacobian_i[1][1] = -2.0*beta_blended*TurbVar_i[1]*Volume; - } - - AD::SetPreaccOut(val_residual, nVar); - AD::EndPreacc(); - -} - -void CSourcePieceWise_TurbSST::GetMeanRateOfStrainMatrix(su2double **S_ij) -{ - /* --- Calculate the rate of strain tensor, using mean velocity gradients --- */ - - if (nDim == 3){ - S_ij[0][0] = PrimVar_Grad_i[1][0]; - S_ij[1][1] = PrimVar_Grad_i[2][1]; - S_ij[2][2] = PrimVar_Grad_i[3][2]; - S_ij[0][1] = 0.5 * (PrimVar_Grad_i[1][1] + PrimVar_Grad_i[2][0]); - S_ij[0][2] = 0.5 * (PrimVar_Grad_i[1][2] + PrimVar_Grad_i[3][0]); - S_ij[1][2] = 0.5 * (PrimVar_Grad_i[2][2] + PrimVar_Grad_i[3][1]); - S_ij[1][0] = S_ij[0][1]; - S_ij[2][1] = S_ij[1][2]; - S_ij[2][0] = S_ij[0][2]; - } - else { - S_ij[0][0] = PrimVar_Grad_i[1][0]; - S_ij[1][1] = PrimVar_Grad_i[2][1]; - S_ij[2][2] = 0.0; - S_ij[0][1] = 0.5 * (PrimVar_Grad_i[1][1] + PrimVar_Grad_i[2][0]); - S_ij[0][2] = 0.0; - S_ij[1][2] = 0.0; - S_ij[1][0] = S_ij[0][1]; - S_ij[2][1] = S_ij[1][2]; - S_ij[2][0] = S_ij[0][2]; - - } -} - -void CSourcePieceWise_TurbSST::SetReynoldsStressMatrix(su2double turb_ke){ - unsigned short iDim, jDim; - su2double **S_ij = new su2double* [3]; - su2double divVel = 0; - su2double TWO3 = 2.0/3.0; - - - - for (iDim = 0; iDim < 3; iDim++){ - S_ij[iDim] = new su2double [3]; - } - - GetMeanRateOfStrainMatrix(S_ij); - - /* --- Using rate of strain matrix, calculate Reynolds stress tensor --- */ - - for (iDim = 0; iDim < 3; iDim++){ - divVel += S_ij[iDim][iDim]; - } - - for (iDim = 0; iDim < 3; iDim++){ - for (jDim = 0; jDim < 3; jDim++){ - MeanReynoldsStress[iDim][jDim] = TWO3 * turb_ke * delta3[iDim][jDim] - - Eddy_Viscosity_i / Density_i * (2 * S_ij[iDim][jDim] - TWO3 * divVel * delta3[iDim][jDim]); - } - } - - for (iDim = 0; iDim < 3; iDim++) - delete [] S_ij[iDim]; - delete [] S_ij; -} - -void CSourcePieceWise_TurbSST::SetPerturbedRSM(su2double turb_ke, CConfig *config){ - - unsigned short iDim,jDim; - - /* --- Calculate anisotropic part of Reynolds Stress tensor --- */ - - for (iDim = 0; iDim< 3; iDim++){ - for (jDim = 0; jDim < 3; jDim++){ - A_ij[iDim][jDim] = .5 * MeanReynoldsStress[iDim][jDim] / turb_ke - delta3[iDim][jDim] / 3.0; - Eig_Vec[iDim][jDim] = A_ij[iDim][jDim]; - } - } - - /* --- Get ordered eigenvectors and eigenvalues of A_ij --- */ - - EigenDecomposition(A_ij, Eig_Vec, Eig_Val, 3); - - /* compute convex combination coefficients */ - su2double c1c = Eig_Val[2] - Eig_Val[1]; - su2double c2c = 2.0 * (Eig_Val[1] - Eig_Val[0]); - su2double c3c = 3.0 * Eig_Val[0] + 1.0; - - /* define barycentric traingle corner points */ - Corners[0][0] = 1.0; - Corners[0][1] = 0.0; - Corners[1][0] = 0.0; - Corners[1][1] = 0.0; - Corners[2][0] = 0.5; - Corners[2][1] = 0.866025; - - /* define barycentric coordinates */ - Barycentric_Coord[0] = Corners[0][0] * c1c + Corners[1][0] * c2c + Corners[2][0] * c3c; - Barycentric_Coord[1] = Corners[0][1] * c1c + Corners[1][1] * c2c + Corners[2][1] * c3c; - - if (Eig_Val_Comp == 1) { - /* 1C turbulence */ - New_Coord[0] = Corners[0][0]; - New_Coord[1] = Corners[0][1]; - } - else if (Eig_Val_Comp == 2) { - /* 2C turbulence */ - New_Coord[0] = Corners[1][0]; - New_Coord[1] = Corners[1][1]; - } - else if (Eig_Val_Comp == 3) { - /* 3C turbulence */ - New_Coord[0] = Corners[2][0]; - New_Coord[1] = Corners[2][1]; - } - else { - /* 2C turbulence */ - New_Coord[0] = Corners[1][0]; - New_Coord[1] = Corners[1][1]; - } - /* calculate perturbed barycentric coordinates */ - - Barycentric_Coord[0] = Barycentric_Coord[0] + (uq_delta_b) * (New_Coord[0] - Barycentric_Coord[0]); - Barycentric_Coord[1] = Barycentric_Coord[1] + (uq_delta_b) * (New_Coord[1] - Barycentric_Coord[1]); - - /* rebuild c1c,c2c,c3c based on new barycentric coordinates */ - c3c = Barycentric_Coord[1] / Corners[2][1]; - c1c = Barycentric_Coord[0] - Corners[2][0] * c3c; - c2c = 1 - c1c - c3c; - - /* build new anisotropy eigenvalues */ - Eig_Val[0] = (c3c - 1) / 3.0; - Eig_Val[1] = 0.5 *c2c + Eig_Val[0]; - Eig_Val[2] = c1c + Eig_Val[1]; - - /* permute eigenvectors if required */ - if (uq_permute) { - for (iDim=0; iDim<3; iDim++) { - for (jDim=0; jDim<3; jDim++) { - New_Eig_Vec[iDim][jDim] = Eig_Vec[2-iDim][jDim]; - } - } - } - - else { - for (iDim=0; iDim<3; iDim++) { - for (jDim=0; jDim<3; jDim++) { - New_Eig_Vec[iDim][jDim] = Eig_Vec[iDim][jDim]; - } - } - } - - EigenRecomposition(newA_ij, New_Eig_Vec, Eig_Val, 3); - - /* compute perturbed Reynolds stress matrix; use under-relaxation factor (urlx)*/ - for (iDim = 0; iDim< 3; iDim++){ - for (jDim = 0; jDim < 3; jDim++){ - MeanPerturbedRSM[iDim][jDim] = 2.0 * turb_ke * (newA_ij[iDim][jDim] + 1.0/3.0 * delta3[iDim][jDim]); - MeanPerturbedRSM[iDim][jDim] = MeanReynoldsStress[iDim][jDim] + - uq_urlx*(MeanPerturbedRSM[iDim][jDim] - MeanReynoldsStress[iDim][jDim]); - } - } - -} - -void CSourcePieceWise_TurbSST::SetPerturbedStrainMag(su2double turb_ke){ - unsigned short iDim, jDim; - PerturbedStrainMag = 0; - su2double **StrainRate = new su2double* [nDim]; - for (iDim= 0; iDim< nDim; iDim++){ - StrainRate[iDim] = new su2double [nDim]; - } - - /* compute perturbed strain rate tensor */ - - for (iDim = 0; iDim < nDim; iDim++){ - for (jDim =0; jDim < nDim; jDim++){ - StrainRate[iDim][jDim] = MeanPerturbedRSM[iDim][jDim] - - TWO3 * turb_ke * delta[iDim][jDim]; - StrainRate[iDim][jDim] = - StrainRate[iDim][jDim] * Density_i / (2 * Eddy_Viscosity_i); - } - } - - /*--- Add diagonal part ---*/ - - for (iDim = 0; iDim < nDim; iDim++) { - PerturbedStrainMag += pow(StrainRate[iDim][iDim], 2.0); - } - - /*--- Add off diagonals ---*/ - - PerturbedStrainMag += 2.0*pow(StrainRate[1][0], 2.0); - - if (nDim == 3) { - PerturbedStrainMag += 2.0*pow(StrainRate[0][2], 2.0); - PerturbedStrainMag += 2.0*pow(StrainRate[1][2], 2.0); - } - - PerturbedStrainMag = sqrt(2.0*PerturbedStrainMag); - - for (iDim= 0; iDim< nDim; iDim++){ - delete [] StrainRate[iDim]; - } - - delete [] StrainRate; -} diff --git a/SU2_CFD/src/numerics_template.cpp b/SU2_CFD/src/numerics_template.cpp deleted file mode 100644 index 1f66f32f895d..000000000000 --- a/SU2_CFD/src/numerics_template.cpp +++ /dev/null @@ -1,233 +0,0 @@ -/*! - * \file numerics_template.cpp - * \brief This file contains all the convective term discretization. - * \author F. Palacios - * \version 7.0.1 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - - -#include "../include/numerics_structure.hpp" -#include - -CConvective_Template::CConvective_Template(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - - implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - Diff_U = new su2double [nVar]; - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; - RoeVelocity = new su2double [nDim]; - delta_vel = new su2double [nDim]; - delta_wave = new su2double [nVar]; - ProjFlux_i = new su2double [nVar]; - ProjFlux_j = new su2double [nVar]; - Lambda = new su2double [nVar]; - Epsilon = new su2double [nVar]; - P_Tensor = new su2double* [nVar]; - invP_Tensor = new su2double* [nVar]; - for (iVar = 0; iVar < nVar; iVar++) { - P_Tensor[iVar] = new su2double [nVar]; - invP_Tensor[iVar] = new su2double [nVar]; - } -} - -CConvective_Template::~CConvective_Template(void) { - unsigned short iVar; - - delete [] Diff_U; - delete [] Velocity_i; - delete [] Velocity_j; - delete [] RoeVelocity; - delete [] delta_vel; - delete [] delta_wave; - delete [] ProjFlux_i; - delete [] ProjFlux_j; - delete [] Lambda; - delete [] Epsilon; - for (iVar = 0; iVar < nVar; iVar++) { - delete [] P_Tensor[iVar]; - delete [] invP_Tensor[iVar]; - } - delete [] P_Tensor; - delete [] invP_Tensor; -} - -void CConvective_Template::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { - - Area = 0; - for (iDim = 0; iDim < nDim; iDim++) - /*!< \brief Normal: Normal vector, it norm is the area of the face. */ - Area += Normal[iDim]*Normal[iDim]; - Area = sqrt(Area); /*! Area of the face*/ - - for (iDim = 0; iDim < nDim; iDim++) - UnitNormal[iDim] = Normal[iDim]/Area; /* ! Unit Normal*/ - - /*--- Point i, Needs to recompute SoundSpeed / Pressure / Enthalpy in case of 2nd order reconstruction ---*/ - Density_i = U_i[0]; - sq_vel = 0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = U_i[iDim+1] / Density_i; - sq_vel += Velocity_i[iDim]*Velocity_i[iDim]; - } - Energy_i = U_i[nDim+1] / Density_i; - SoundSpeed_i = sqrt(Gamma*Gamma_Minus_One*(Energy_i-0.5*sq_vel)); - Pressure_i = (SoundSpeed_i * SoundSpeed_i * Density_i) / Gamma; - Enthalpy_i = (U_i[nDim+1] + Pressure_i) / Density_i; - - /*--- Point j, Needs to recompute SoundSpeed / Pressure / Enthalpy in case of 2nd order reconstruction ---*/ - Density_j = U_j[0]; - sq_vel = 0; - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_j[iDim] = U_j[iDim+1] / Density_j; - sq_vel += Velocity_j[iDim]*Velocity_j[iDim]; - } - Energy_j = U_j[nDim+1] / Density_j; - SoundSpeed_j = sqrt(Gamma*Gamma_Minus_One*(Energy_j-0.5*sq_vel)); - Pressure_j = (SoundSpeed_j * SoundSpeed_j * Density_j) / Gamma; - Enthalpy_j = (U_j[nDim+1] + Pressure_j) / Density_j; - - /*--- Mean Roe variables iPoint and jPoint ---*/ - R = sqrt(Density_j/Density_i); - RoeDensity = R*Density_i; - sq_vel = 0; - for (iDim = 0; iDim < nDim; iDim++) { - RoeVelocity[iDim] = (R*Velocity_j[iDim]+Velocity_i[iDim])/(R+1); - sq_vel += RoeVelocity[iDim]*RoeVelocity[iDim]; - } - RoeEnthalpy = (R*Enthalpy_j+Enthalpy_i)/(R+1); - RoeSoundSpeed = sqrt((Gamma-1)*(RoeEnthalpy-0.5*sq_vel)); - - /*--- Compute ProjFlux_i ---*/ - GetInviscidProjFlux(&Density_i, Velocity_i, &Pressure_i, &Enthalpy_i, Normal, ProjFlux_i); - - /*--- Compute ProjFlux_j ---*/ - GetInviscidProjFlux(&Density_j, Velocity_j, &Pressure_j, &Enthalpy_j, Normal, ProjFlux_j); - - /*--- Compute P and Lambda (do it with the Normal) ---*/ - GetPMatrix(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, P_Tensor); - - ProjVelocity = 0.0; ProjVelocity_i = 0.0; ProjVelocity_j = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - ProjVelocity += RoeVelocity[iDim]*UnitNormal[iDim]; - ProjVelocity_i += Velocity_i[iDim]*UnitNormal[iDim]; - ProjVelocity_j += Velocity_j[iDim]*UnitNormal[iDim]; - } - - /*--- Flow eigenvalues and Entropy correctors ---*/ - for (iDim = 0; iDim < nDim; iDim++) { - Lambda[iDim] = ProjVelocity; - Epsilon[iDim] = 4.0*max(0.0, max(Lambda[iDim]-ProjVelocity_i, ProjVelocity_j-Lambda[iDim])); - } - Lambda[nVar-2] = ProjVelocity + RoeSoundSpeed; - Epsilon[nVar-2] = 4.0*max(0.0, max(Lambda[nVar-2]-(ProjVelocity_i+SoundSpeed_i),(ProjVelocity_j+SoundSpeed_j)-Lambda[nVar-2])); - Lambda[nVar-1] = ProjVelocity - RoeSoundSpeed; - Epsilon[nVar-1] = 4.0*max(0.0, max(Lambda[nVar-1]-(ProjVelocity_i-SoundSpeed_i),(ProjVelocity_j-SoundSpeed_j)-Lambda[nVar-1])); - - /*--- Entropy correction ---*/ - for (iVar = 0; iVar < nVar; iVar++) - if ( fabs(Lambda[iVar]) < Epsilon[iVar] ) - Lambda[iVar] = (Lambda[iVar]*Lambda[iVar] + Epsilon[iVar]*Epsilon[iVar])/(2.0*Epsilon[iVar]); - else - Lambda[iVar] = fabs(Lambda[iVar]); - - - if (!implicit) { - /*--- Compute wave amplitudes (characteristics) ---*/ - proj_delta_vel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - delta_vel[iDim] = Velocity_j[iDim] - Velocity_i[iDim]; - proj_delta_vel += delta_vel[iDim]*Normal[iDim]; - } - delta_p = Pressure_j - Pressure_i; - delta_rho = Density_j - Density_i; - proj_delta_vel = proj_delta_vel/Area; - - if (nDim == 3) { - delta_wave[0] = delta_rho - delta_p/(RoeSoundSpeed*RoeSoundSpeed); - delta_wave[1] = UnitNormal[0]*delta_vel[2]-UnitNormal[2]*delta_vel[0]; - delta_wave[2] = UnitNormal[1]*delta_vel[0]-UnitNormal[0]*delta_vel[1]; - delta_wave[3] = proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); - delta_wave[4] = -proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); - } - else { - delta_wave[0] = delta_rho - delta_p/(RoeSoundSpeed*RoeSoundSpeed); - delta_wave[1] = UnitNormal[1]*delta_vel[0]-UnitNormal[0]*delta_vel[1]; - delta_wave[2] = proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); - delta_wave[3] = -proj_delta_vel + delta_p/(RoeDensity*RoeSoundSpeed); - } - - /*--- Roe's Flux approximation ---*/ - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] = 0.5*(ProjFlux_i[iVar]+ProjFlux_j[iVar]); - for (jVar = 0; jVar < nVar; jVar++) - val_residual[iVar] -= 0.5*Lambda[jVar]*delta_wave[jVar]*P_Tensor[iVar][jVar]*Area; - } - } - else { - - /*--- Compute inverse P ---*/ - GetPMatrix_inv(&RoeDensity, RoeVelocity, &RoeSoundSpeed, UnitNormal, invP_Tensor); - - /*--- Jacobias of the inviscid flux, scale = 0.5 because val_resconv ~ 0.5*(fc_i+fc_j)*Normal ---*/ - GetInviscidProjJac(Velocity_i, &Energy_i, Normal, 0.5, val_Jacobian_i); - GetInviscidProjJac(Velocity_j, &Energy_j, Normal, 0.5, val_Jacobian_j); - - /*--- Diference variables iPoint and jPoint ---*/ - for (iVar = 0; iVar < nVar; iVar++) - Diff_U[iVar] = U_j[iVar]-U_i[iVar]; - - /*--- Roe's Flux approximation ---*/ - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] = 0.5*(ProjFlux_i[iVar]+ProjFlux_j[iVar]); - for (jVar = 0; jVar < nVar; jVar++) { - Proj_ModJac_Tensor_ij = 0.0; - /*--- Compute |Proj_ModJac_Tensor| = P x |Lambda| x inverse P ---*/ - for (kVar = 0; kVar < nVar; kVar++) - Proj_ModJac_Tensor_ij += P_Tensor[iVar][kVar]*Lambda[kVar]*invP_Tensor[kVar][jVar]; - val_residual[iVar] -= 0.5*Proj_ModJac_Tensor_ij*Diff_U[jVar]*Area; - val_Jacobian_i[iVar][jVar] += 0.5*Proj_ModJac_Tensor_ij*Area; - val_Jacobian_j[iVar][jVar] -= 0.5*Proj_ModJac_Tensor_ij*Area; - } - } - } -} - -CSource_Template::CSource_Template(unsigned short val_nDim, unsigned short val_nVar, - CConfig *config) : CNumerics(val_nDim, val_nVar, config) {} - -CSource_Template::~CSource_Template(void) { - -} - -void CSource_Template::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config) {} - -CViscous_Template::CViscous_Template(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { } - -CViscous_Template::~CViscous_Template(void) { } - -void CViscous_Template::ComputeResidual(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config) { } From a1213944ab3228d11f06f7f0bf8ab8968ff94728 Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Fri, 31 Jan 2020 19:14:43 +0000 Subject: [PATCH 068/118] cleanup computation of aero coefficients --- SU2_CFD/include/solvers/CEulerSolver.hpp | 569 ++++----- .../include/solvers/CFEM_DG_EulerSolver.hpp | 2 +- SU2_CFD/include/solvers/CIncEulerSolver.hpp | 2 +- SU2_CFD/include/solvers/CNSSolver.hpp | 119 +- SU2_CFD/include/solvers/CSolver.hpp | 2 +- SU2_CFD/src/solvers/CEulerSolver.cpp | 1059 +++++------------ SU2_CFD/src/solvers/CNSSolver.cpp | 754 ++++-------- 7 files changed, 815 insertions(+), 1692 deletions(-) diff --git a/SU2_CFD/include/solvers/CEulerSolver.hpp b/SU2_CFD/include/solvers/CEulerSolver.hpp index a44b70b1a6c9..7a277f588183 100644 --- a/SU2_CFD/include/solvers/CEulerSolver.hpp +++ b/SU2_CFD/include/solvers/CEulerSolver.hpp @@ -48,209 +48,143 @@ class CEulerSolver : public CSolver { unsigned long omp_chunk_size; /*!< \brief Chunk size used in light point loops. */ su2double - Mach_Inf, /*!< \brief Mach number at the infinity. */ - Density_Inf, /*!< \brief Density at the infinity. */ - Energy_Inf, /*!< \brief Energy at the infinity. */ - Temperature_Inf, /*!< \brief Energy at the infinity. */ - Pressure_Inf, /*!< \brief Pressure at the infinity. */ - *Velocity_Inf; /*!< \brief Flow Velocity vector at the infinity. */ + Mach_Inf = 0.0, /*!< \brief Mach number at the infinity. */ + Density_Inf = 0.0, /*!< \brief Density at the infinity. */ + Energy_Inf = 0.0, /*!< \brief Energy at the infinity. */ + Temperature_Inf = 0.0, /*!< \brief Energy at the infinity. */ + Pressure_Inf = 0.0, /*!< \brief Pressure at the infinity. */ + *Velocity_Inf = nullptr; /*!< \brief Flow Velocity vector at the infinity. */ - su2double Prandtl_Lam, /*!< \brief Laminar Prandtl number. */ - Prandtl_Turb; /*!< \brief Turbulent Prandtl number. */ + su2double + Prandtl_Lam = 0.0, /*!< \brief Laminar Prandtl number. */ + Prandtl_Turb = 0.0; /*!< \brief Turbulent Prandtl number. */ + + /*! + * \brief Auxilary type to store common aero coefficients (avoids repeating oneself so much). + * \tparam The type can be used to store scalars (Type = su2double) or arrays + * (Type = su2double*) e.g. for when the coeffs are computed over surfaces. + */ + template + struct AerodynamicCoefficients { + Type CD = 0; /*!< \brief Drag coefficient. */ + Type CL = 0; /*!< \brief Lift coefficient. */ + Type CSF = 0; /*!< \brief Sideforce coefficient. */ + Type CEff = 0; /*!< \brief Efficiency (Cl/Cd). */ + Type CFx = 0; /*!< \brief x Force coefficient. */ + Type CFy = 0; /*!< \brief y Force coefficient. */ + Type CFz = 0; /*!< \brief z Force coefficient. */ + Type CMx = 0; /*!< \brief x Moment coefficient. */ + Type CMy = 0; /*!< \brief y Moment coefficient. */ + Type CMz = 0; /*!< \brief z Moment coefficient. */ + Type CoPx = 0; /*!< \brief x Moment coefficient. */ + Type CoPy = 0; /*!< \brief y Moment coefficient. */ + Type CoPz = 0; /*!< \brief z Moment coefficient. */ + Type CT = 0; /*!< \brief Thrust coefficient. */ + Type CQ = 0; /*!< \brief Torque coefficient. */ + Type CMerit = 0; /*!< \brief Rotor Figure of Merit. */ + int _size; + + void allocate(int size); /*!< \brief Allocates arrays (for Type = su2double*). */ + + void setZero(); /*!< \brief Sets all values to zero for all indices. */ + void setZero(int i); /*!< \brief Sets all values to zero at a particular index. */ + + AerodynamicCoefficients(int size = 0) : _size(size) { allocate(size); } + + ~AerodynamicCoefficients(); + }; + using Coefficients = AerodynamicCoefficients; + using CoefficientsArray = AerodynamicCoefficients; + + CoefficientsArray InvCoeff; /*!< \brief Inviscid pressure contributions for each boundary. */ + CoefficientsArray SurfaceInvCoeff; /*!< \brief Inviscid pressure contributions for each monitoring boundary. */ + Coefficients AllBoundInvCoeff; /*!< \brief Total pressure contribution for all the boundaries. */ + + CoefficientsArray MntCoeff; /*!< \brief Inviscid momentum contributions for each boundary. */ + CoefficientsArray SurfaceMntCoeff; /*!< \brief Inviscid momentum contributions for each monitoring boundary. */ + Coefficients AllBoundMntCoeff; /*!< \brief Total momentum contribution for all the boundaries. */ + + CoefficientsArray SurfaceCoeff; /*!< \brief Totals for each monitoring surface. */ + Coefficients TotalCoeff; /*!< \brief Totals for all boundaries. */ + + su2double + AllBound_CEquivArea_Inv = 0.0, /*!< \brief equivalent area coefficient (inviscid contribution) for all the boundaries. */ + AllBound_CNearFieldOF_Inv = 0.0, /*!< \brief Near-Field press coefficient (inviscid contribution) for all the boundaries. */ + *CEquivArea_Inv = nullptr, /*!< \brief Equivalent area (inviscid contribution) for each boundary. */ + *CNearFieldOF_Inv = nullptr; /*!< \brief Near field pressure (inviscid contribution) for each boundary. */ su2double - *CD_Inv, /*!< \brief Drag coefficient (inviscid contribution) for each boundary. */ - *CL_Inv, /*!< \brief Lift coefficient (inviscid contribution) for each boundary. */ - *CSF_Inv, /*!< \brief Sideforce coefficient (inviscid contribution) for each boundary. */ - *CMx_Inv, /*!< \brief x Moment coefficient (inviscid contribution) for each boundary. */ - *CMy_Inv, /*!< \brief y Moment coefficient (inviscid contribution) for each boundary. */ - *CMz_Inv, /*!< \brief z Moment coefficient (inviscid contribution) for each boundary. */ - *CoPx_Inv, /*!< \brief x Moment coefficient (inviscid contribution) for each boundary. */ - *CoPy_Inv, /*!< \brief y Moment coefficient (inviscid contribution) for each boundary. */ - *CoPz_Inv, /*!< \brief z Moment coefficient (inviscid contribution) for each boundary. */ - *CFx_Inv, /*!< \brief x Force coefficient (inviscid contribution) for each boundary. */ - *CFy_Inv, /*!< \brief y Force coefficient (inviscid contribution) for each boundary. */ - *CFz_Inv, /*!< \brief z Force coefficient (inviscid contribution) for each boundary. */ - *Surface_CL_Inv, /*!< \brief Lift coefficient (inviscid contribution) for each monitoring surface. */ - *Surface_CD_Inv, /*!< \brief Drag coefficient (inviscid contribution) for each monitoring surface. */ - *Surface_CSF_Inv, /*!< \brief Side-force coefficient (inviscid contribution) for each monitoring surface. */ - *Surface_CEff_Inv, /*!< \brief Side-force coefficient (inviscid contribution) for each monitoring surface. */ - *Surface_CFx_Inv, /*!< \brief x Force coefficient (inviscid contribution) for each monitoring surface. */ - *Surface_CFy_Inv, /*!< \brief y Force coefficient (inviscid contribution) for each monitoring surface. */ - *Surface_CFz_Inv, /*!< \brief z Force coefficient (inviscid contribution) for each monitoring surface. */ - *Surface_CMx_Inv, /*!< \brief x Moment coefficient (inviscid contribution) for each monitoring surface. */ - *Surface_CMy_Inv, /*!< \brief y Moment coefficient (inviscid contribution) for each monitoring surface. */ - *Surface_CMz_Inv, /*!< \brief z Moment coefficient (inviscid contribution) for each monitoring surface. */ - *CEff_Inv, /*!< \brief Efficiency (Cl/Cd) (inviscid contribution) for each boundary. */ - *CMerit_Inv, /*!< \brief Rotor Figure of Merit (inviscid contribution) for each boundary. */ - *CT_Inv, /*!< \brief Thrust coefficient (force in -x direction, inviscid contribution) for each boundary. */ - *CQ_Inv, /*!< \brief Torque coefficient (moment in -x direction, inviscid contribution) for each boundary. */ - *CEquivArea_Inv, /*!< \brief Equivalent area (inviscid contribution) for each boundary. */ - *CNearFieldOF_Inv, /*!< \brief Near field pressure (inviscid contribution) for each boundary. */ - *CD_Mnt, /*!< \brief Drag coefficient (inviscid contribution) for each boundary. */ - *CL_Mnt, /*!< \brief Lift coefficient (inviscid contribution) for each boundary. */ - *CSF_Mnt, /*!< \brief Sideforce coefficient (inviscid contribution) for each boundary. */ - *CMx_Mnt, /*!< \brief x Moment coefficient (inviscid contribution) for each boundary. */ - *CMy_Mnt, /*!< \brief y Moment coefficient (inviscid contribution) for each boundary. */ - *CMz_Mnt, /*!< \brief z Moment coefficient (inviscid contribution) for each boundary. */ - *CoPx_Mnt, /*!< \brief x Moment coefficient (inviscid contribution) for each boundary. */ - *CoPy_Mnt, /*!< \brief y Moment coefficient (inviscid contribution) for each boundary. */ - *CoPz_Mnt, /*!< \brief z Moment coefficient (inviscid contribution) for each boundary. */ - *CFx_Mnt, /*!< \brief x Force coefficient (inviscid contribution) for each boundary. */ - *CFy_Mnt, /*!< \brief y Force coefficient (inviscid contribution) for each boundary. */ - *CFz_Mnt, /*!< \brief z Force coefficient (inviscid contribution) for each boundary. */ - *Surface_CL_Mnt, /*!< \brief Lift coefficient (inviscid contribution) for each monitoring surface. */ - *Surface_CD_Mnt, /*!< \brief Drag coefficient (inviscid contribution) for each monitoring surface. */ - *Surface_CSF_Mnt, /*!< \brief Side-force coefficient (inviscid contribution) for each monitoring surface. */ - *Surface_CEff_Mnt, /*!< \brief Side-force coefficient (inviscid contribution) for each monitoring surface. */ - *Surface_CFx_Mnt, /*!< \brief x Force coefficient (inviscid contribution) for each monitoring surface. */ - *Surface_CFy_Mnt, /*!< \brief y Force coefficient (inviscid contribution) for each monitoring surface. */ - *Surface_CFz_Mnt, /*!< \brief z Force coefficient (inviscid contribution) for each monitoring surface. */ - *Surface_CMx_Mnt, /*!< \brief x Moment coefficient (inviscid contribution) for each monitoring surface. */ - *Surface_CMy_Mnt, /*!< \brief y Moment coefficient (inviscid contribution) for each monitoring surface. */ - *Surface_CMz_Mnt, /*!< \brief z Moment coefficient (inviscid contribution) for each monitoring surface. */ - *CEff_Mnt, /*!< \brief Efficiency (Cl/Cd) (inviscid contribution) for each boundary. */ - *CMerit_Mnt, /*!< \brief Rotor Figure of Merit (inviscid contribution) for each boundary. */ - *CT_Mnt, /*!< \brief Thrust coefficient (force in -x direction, inviscid contribution) for each boundary. */ - *CQ_Mnt, /*!< \brief Torque coefficient (moment in -x direction, inviscid contribution) for each boundary. */ - *CEquivArea_Mnt, /*!< \brief Equivalent area (inviscid contribution) for each boundary. */ - **CPressure, /*!< \brief Pressure coefficient for each boundary and vertex. */ - **CPressureTarget, /*!< \brief Target Pressure coefficient for each boundary and vertex. */ - **HeatFlux, /*!< \brief Heat transfer coefficient for each boundary and vertex. */ - **HeatFluxTarget, /*!< \brief Heat transfer coefficient for each boundary and vertex. */ - **YPlus, /*!< \brief Yplus for each boundary and vertex. */ - ***CharacPrimVar, /*!< \brief Value of the characteristic variables at each boundary. */ - ***DonorPrimVar, /*!< \brief Value of the donor variables at each boundary. */ - *ForceInviscid, /*!< \brief Inviscid force for each boundary. */ - *MomentInviscid, /*!< \brief Inviscid moment for each boundary. */ - *ForceMomentum, /*!< \brief Inviscid force for each boundary. */ - *MomentMomentum; /*!< \brief Inviscid moment for each boundary. */ + *CEquivArea_Mnt = nullptr, /*!< \brief Equivalent area (inviscid contribution) for each boundary. */ + **CPressure = nullptr, /*!< \brief Pressure coefficient for each boundary and vertex. */ + **CPressureTarget = nullptr, /*!< \brief Target Pressure coefficient for each boundary and vertex. */ + **HeatFlux = nullptr, /*!< \brief Heat transfer coefficient for each boundary and vertex. */ + **HeatFluxTarget = nullptr, /*!< \brief Heat transfer coefficient for each boundary and vertex. */ + **YPlus = nullptr, /*!< \brief Yplus for each boundary and vertex. */ + ***CharacPrimVar = nullptr, /*!< \brief Value of the characteristic variables at each boundary. */ + ***DonorPrimVar = nullptr; /*!< \brief Value of the donor variables at each boundary. */ + su2double - *Inflow_MassFlow, /*!< \brief Mass flow rate for each boundary. */ - *Exhaust_MassFlow, /*!< \brief Mass flow rate for each boundary. */ - *Inflow_Pressure, /*!< \brief Fan face pressure for each boundary. */ - *Inflow_Mach, /*!< \brief Fan face mach number for each boundary. */ - *Inflow_Area, /*!< \brief Boundary total area. */ - *Exhaust_Area, /*!< \brief Boundary total area. */ - *Exhaust_Pressure, /*!< \brief Fan face pressure for each boundary. */ - *Exhaust_Temperature, /*!< \brief Fan face mach number for each boundary. */ - Inflow_MassFlow_Total, /*!< \brief Mass flow rate for each boundary. */ - Exhaust_MassFlow_Total, /*!< \brief Mass flow rate for each boundary. */ - Inflow_Pressure_Total, /*!< \brief Fan face pressure for each boundary. */ - Inflow_Mach_Total, /*!< \brief Fan face mach number for each boundary. */ - InverseDesign; /*!< \brief Inverse design functional for each boundary. */ + *Inflow_MassFlow = nullptr, /*!< \brief Mass flow rate for each boundary. */ + *Exhaust_MassFlow = nullptr, /*!< \brief Mass flow rate for each boundary. */ + *Inflow_Pressure = nullptr, /*!< \brief Fan face pressure for each boundary. */ + *Inflow_Mach = nullptr, /*!< \brief Fan face mach number for each boundary. */ + *Inflow_Area = nullptr, /*!< \brief Boundary total area. */ + *Exhaust_Area = nullptr, /*!< \brief Boundary total area. */ + *Exhaust_Pressure = nullptr, /*!< \brief Fan face pressure for each boundary. */ + *Exhaust_Temperature = nullptr,/*!< \brief Fan face mach number for each boundary. */ + Inflow_MassFlow_Total = 0.0, /*!< \brief Mass flow rate for each boundary. */ + Exhaust_MassFlow_Total = 0.0, /*!< \brief Mass flow rate for each boundary. */ + Inflow_Pressure_Total = 0.0, /*!< \brief Fan face pressure for each boundary. */ + Inflow_Mach_Total = 0.0, /*!< \brief Fan face mach number for each boundary. */ + InverseDesign = 0.0; /*!< \brief Inverse design functional for each boundary. */ unsigned long - **DonorGlobalIndex; /*!< \brief Value of the donor global index. */ - su2double - **ActDisk_DeltaP, /*!< \brief Value of the Delta P. */ - **ActDisk_DeltaT; /*!< \brief Value of the Delta T. */ + **DonorGlobalIndex = nullptr; /*!< \brief Value of the donor global index. */ su2double - **Inlet_Ptotal, /*!< \brief Value of the Total P. */ - **Inlet_Ttotal, /*!< \brief Value of the Total T. */ - ***Inlet_FlowDir; /*!< \brief Value of the Flow Direction. */ + **ActDisk_DeltaP = nullptr, /*!< \brief Value of the Delta P. */ + **ActDisk_DeltaT = nullptr, /*!< \brief Value of the Delta T. */ + **Inlet_Ptotal = nullptr, /*!< \brief Value of the Total P. */ + **Inlet_Ttotal = nullptr, /*!< \brief Value of the Total T. */ + ***Inlet_FlowDir = nullptr; /*!< \brief Value of the Flow Direction. */ su2double - AllBound_CD_Inv, /*!< \brief Total drag coefficient (inviscid contribution) for all the boundaries. */ - AllBound_CL_Inv, /*!< \brief Total lift coefficient (inviscid contribution) for all the boundaries. */ - AllBound_CSF_Inv, /*!< \brief Total sideforce coefficient (inviscid contribution) for all the boundaries. */ - AllBound_CMx_Inv, /*!< \brief Total x moment coefficient (inviscid contribution) for all the boundaries. */ - AllBound_CMy_Inv, /*!< \brief Total y moment coefficient (inviscid contribution) for all the boundaries. */ - AllBound_CMz_Inv, /*!< \brief Total z moment coefficient (inviscid contribution) for all the boundaries. */ - AllBound_CoPx_Inv, /*!< \brief Total x moment coefficient (inviscid contribution) for all the boundaries. */ - AllBound_CoPy_Inv, /*!< \brief Total y moment coefficient (inviscid contribution) for all the boundaries. */ - AllBound_CoPz_Inv, /*!< \brief Total z moment coefficient (inviscid contribution) for all the boundaries. */ - AllBound_CFx_Inv, /*!< \brief Total x force coefficient (inviscid contribution) for all the boundaries. */ - AllBound_CFy_Inv, /*!< \brief Total y force coefficient (inviscid contribution) for all the boundaries. */ - AllBound_CFz_Inv, /*!< \brief Total z force coefficient (inviscid contribution) for all the boundaries. */ - AllBound_CEff_Inv, /*!< \brief Efficient coefficient (inviscid contribution) for all the boundaries. */ - AllBound_CMerit_Inv, /*!< \brief Rotor Figure of Merit (inviscid contribution) for all the boundaries. */ - AllBound_CT_Inv, /*!< \brief Total thrust coefficient (inviscid contribution) for all the boundaries. */ - AllBound_CQ_Inv, /*!< \brief Total torque coefficient (inviscid contribution) for all the boundaries. */ - AllBound_CEquivArea_Inv, /*!< \brief equivalent area coefficient (inviscid contribution) for all the boundaries. */ - AllBound_CNearFieldOF_Inv; /*!< \brief Near-Field press coefficient (inviscid contribution) for all the boundaries. */ + Total_ComboObj = 0.0, /*!< \brief Total 'combo' objective for all monitored boundaries */ + Total_CL_Prev = 0.0, /*!< \brief Total lift coefficient for all the boundaries (fixed lift mode). */ + Total_SolidCD = 0.0, /*!< \brief Total drag coefficient for all the boundaries. */ + Total_CD_Prev = 0.0, /*!< \brief Total drag coefficient for all the boundaries (fixed lift mode). */ + Total_NetThrust = 0.0, /*!< \brief Total drag coefficient for all the boundaries. */ + Total_Power = 0.0, /*!< \brief Total drag coefficient for all the boundaries. */ + Total_ReverseFlow = 0.0, /*!< \brief Total drag coefficient for all the boundaries. */ + Total_IDC = 0.0, /*!< \brief Total IDC coefficient for all the boundaries. */ + Total_IDC_Mach = 0.0, /*!< \brief Total IDC coefficient for all the boundaries. */ + Total_IDR = 0.0, /*!< \brief Total IDC coefficient for all the boundaries. */ + Total_DC60 = 0.0, /*!< \brief Total IDC coefficient for all the boundaries. */ + Total_MFR = 0.0, /*!< \brief Total Mass Flow Ratio for all the boundaries. */ + Total_Prop_Eff = 0.0, /*!< \brief Total Mass Flow Ratio for all the boundaries. */ + Total_ByPassProp_Eff = 0.0, /*!< \brief Total Mass Flow Ratio for all the boundaries. */ + Total_Adiab_Eff = 0.0, /*!< \brief Total Mass Flow Ratio for all the boundaries. */ + Total_Poly_Eff = 0.0, /*!< \brief Total Mass Flow Ratio for all the boundaries. */ + Total_Custom_ObjFunc = 0.0, /*!< \brief Total custom objective function for all the boundaries. */ + Total_CMx_Prev = 0.0, /*!< \brief Total drag coefficient for all the boundaries (fixed lift mode). */ + Total_CMy_Prev = 0.0, /*!< \brief Total drag coefficient for all the boundaries (fixed lift mode). */ + Total_CMz_Prev = 0.0, /*!< \brief Total drag coefficient for all the boundaries (fixed lift mode). */ + Total_Heat = 0.0, /*!< \brief Total heat load for all the boundaries. */ + Total_MaxHeat = 0.0, /*!< \brief Maximum heat flux on all boundaries. */ + Total_AeroCD = 0.0, /*!< \brief Total aero drag coefficient for all the boundaries. */ + Total_CEquivArea = 0.0, /*!< \brief Total Equivalent Area coefficient for all the boundaries. */ + Total_CNearFieldOF = 0.0, /*!< \brief Total Near-Field Pressure coefficient for all the boundaries. */ + Total_CpDiff = 0.0, /*!< \brief Total Equivalent Area coefficient for all the boundaries. */ + Total_HeatFluxDiff = 0.0, /*!< \brief Total Equivalent Area coefficient for all the boundaries. */ + Total_MassFlowRate = 0.0; /*!< \brief Total Mass Flow Rate on monitored boundaries. */ su2double - AllBound_CD_Mnt, /*!< \brief Total drag coefficient (inviscid contribution) for all the boundaries. */ - AllBound_CL_Mnt, /*!< \brief Total lift coefficient (inviscid contribution) for all the boundaries. */ - AllBound_CSF_Mnt, /*!< \brief Total sideforce coefficient (inviscid contribution) for all the boundaries. */ - AllBound_CMx_Mnt, /*!< \brief Total x moment coefficient (inviscid contribution) for all the boundaries. */ - AllBound_CMy_Mnt, /*!< \brief Total y moment coefficient (inviscid contribution) for all the boundaries. */ - AllBound_CMz_Mnt, /*!< \brief Total z moment coefficient (inviscid contribution) for all the boundaries. */ - AllBound_CoPx_Mnt, /*!< \brief Total x moment coefficient (inviscid contribution) for all the boundaries. */ - AllBound_CoPy_Mnt, /*!< \brief Total y moment coefficient (inviscid contribution) for all the boundaries. */ - AllBound_CoPz_Mnt, /*!< \brief Total z moment coefficient (inviscid contribution) for all the boundaries. */ - AllBound_CFx_Mnt, /*!< \brief Total x force coefficient (inviscid contribution) for all the boundaries. */ - AllBound_CFy_Mnt, /*!< \brief Total y force coefficient (inviscid contribution) for all the boundaries. */ - AllBound_CFz_Mnt, /*!< \brief Total z force coefficient (inviscid contribution) for all the boundaries. */ - AllBound_CEff_Mnt, /*!< \brief Efficient coefficient (inviscid contribution) for all the boundaries. */ - AllBound_CMerit_Mnt, /*!< \brief Rotor Figure of Merit (inviscid contribution) for all the boundaries. */ - AllBound_CT_Mnt, /*!< \brief Total thrust coefficient (inviscid contribution) for all the boundaries. */ - AllBound_CQ_Mnt; /*!< \brief Total torque coefficient (inviscid contribution) for all the boundaries. */ + *Surface_HF_Visc = nullptr, /*!< \brief Total (integrated) heat flux for each monitored surface. */ + *Surface_MaxHF_Visc = nullptr; /*!< \brief Maximum heat flux for each monitored surface. */ - su2double - Total_ComboObj, /*!< \brief Total 'combo' objective for all monitored boundaries */ - Total_CD, /*!< \brief Total drag coefficient for all the boundaries. */ - Total_CL, /*!< \brief Total lift coefficient for all the boundaries. */ - Total_CL_Prev, /*!< \brief Total lift coefficient for all the boundaries (fixed lift mode). */ - Total_SolidCD, /*!< \brief Total drag coefficient for all the boundaries. */ - Total_CD_Prev, /*!< \brief Total drag coefficient for all the boundaries (fixed lift mode). */ - Total_NetThrust, /*!< \brief Total drag coefficient for all the boundaries. */ - Total_Power, /*!< \brief Total drag coefficient for all the boundaries. */ - Total_ReverseFlow, /*!< \brief Total drag coefficient for all the boundaries. */ - Total_IDC, /*!< \brief Total IDC coefficient for all the boundaries. */ - Total_IDC_Mach, /*!< \brief Total IDC coefficient for all the boundaries. */ - Total_IDR, /*!< \brief Total IDC coefficient for all the boundaries. */ - Total_DC60, /*!< \brief Total IDC coefficient for all the boundaries. */ - Total_MFR, /*!< \brief Total Mass Flow Ratio for all the boundaries. */ - Total_Prop_Eff, /*!< \brief Total Mass Flow Ratio for all the boundaries. */ - Total_ByPassProp_Eff, /*!< \brief Total Mass Flow Ratio for all the boundaries. */ - Total_Adiab_Eff, /*!< \brief Total Mass Flow Ratio for all the boundaries. */ - Total_Poly_Eff, /*!< \brief Total Mass Flow Ratio for all the boundaries. */ - Total_Custom_ObjFunc, /*!< \brief Total custom objective function for all the boundaries. */ - Total_CSF, /*!< \brief Total sideforce coefficient for all the boundaries. */ - Total_CMx, /*!< \brief Total x moment coefficient for all the boundaries. */ - Total_CMx_Prev, /*!< \brief Total drag coefficient for all the boundaries (fixed lift mode). */ - Total_CMy, /*!< \brief Total y moment coefficient for all the boundaries. */ - Total_CMy_Prev, /*!< \brief Total drag coefficient for all the boundaries (fixed lift mode). */ - Total_CMz, /*!< \brief Total z moment coefficient for all the boundaries. */ - Total_CMz_Prev, /*!< \brief Total drag coefficient for all the boundaries (fixed lift mode). */ - Total_CoPx, /*!< \brief Total x moment coefficient for all the boundaries. */ - Total_CoPy, /*!< \brief Total y moment coefficient for all the boundaries. */ - Total_CoPz, /*!< \brief Total z moment coefficient for all the boundaries. */ - Total_CFx, /*!< \brief Total x force coefficient for all the boundaries. */ - Total_CFy, /*!< \brief Total y force coefficient for all the boundaries. */ - Total_CFz, /*!< \brief Total z force coefficient for all the boundaries. */ - Total_CEff, /*!< \brief Total efficiency coefficient for all the boundaries. */ - Total_CMerit, /*!< \brief Total rotor Figure of Merit for all the boundaries. */ - Total_CT, /*!< \brief Total thrust coefficient for all the boundaries. */ - Total_CQ, /*!< \brief Total torque coefficient for all the boundaries. */ - Total_Heat, /*!< \brief Total heat load for all the boundaries. */ - Total_MaxHeat, /*!< \brief Maximum heat flux on all boundaries. */ - Total_AeroCD, /*!< \brief Total aero drag coefficient for all the boundaries. */ - Total_CEquivArea, /*!< \brief Total Equivalent Area coefficient for all the boundaries. */ - Total_CNearFieldOF, /*!< \brief Total Near-Field Pressure coefficient for all the boundaries. */ - Total_CpDiff, /*!< \brief Total Equivalent Area coefficient for all the boundaries. */ - Total_HeatFluxDiff, /*!< \brief Total Equivalent Area coefficient for all the boundaries. */ - Total_MassFlowRate; /*!< \brief Total Mass Flow Rate on monitored boundaries. */ - su2double - *Surface_CL, /*!< \brief Lift coefficient for each monitoring surface. */ - *Surface_CD, /*!< \brief Drag coefficient for each monitoring surface. */ - *Surface_CSF, /*!< \brief Side-force coefficient for each monitoring surface. */ - *Surface_CEff, /*!< \brief Side-force coefficient for each monitoring surface. */ - *Surface_CFx, /*!< \brief x Force coefficient for each monitoring surface. */ - *Surface_CFy, /*!< \brief y Force coefficient for each monitoring surface. */ - *Surface_CFz, /*!< \brief z Force coefficient for each monitoring surface. */ - *Surface_CMx, /*!< \brief x Moment coefficient for each monitoring surface. */ - *Surface_CMy, /*!< \brief y Moment coefficient for each monitoring surface. */ - *Surface_CMz, /*!< \brief z Moment coefficient for each monitoring surface. */ - *Surface_HF_Visc, /*!< \brief Total (integrated) heat flux for each monitored surface. */ - *Surface_MaxHF_Visc; /*!< \brief Maximum heat flux for each monitored surface. */ - - bool space_centered, /*!< \brief True if space centered scheeme used. */ - euler_implicit, /*!< \brief True if euler implicit scheme used. */ - least_squares; /*!< \brief True if computing gradients by least squares. */ - su2double Gamma; /*!< \brief Fluid's Gamma constant (ratio of specific heats). */ - su2double Gamma_Minus_One; /*!< \brief Fluids's Gamma - 1.0 . */ + bool space_centered, /*!< \brief True if space centered scheeme used. */ + euler_implicit, /*!< \brief True if euler implicit scheme used. */ + least_squares; /*!< \brief True if computing gradients by least squares. */ + su2double Gamma; /*!< \brief Fluid's Gamma constant (ratio of specific heats). */ + su2double Gamma_Minus_One; /*!< \brief Fluids's Gamma - 1.0 . */ su2double AoA_Prev, /*!< \brief Old value of the angle of attack (monitored). */ AoA_inc; @@ -267,49 +201,50 @@ class CEulerSolver : public CSolver { vector FluidModel; /*!< \brief fluid model used in the solver */ /*--- Turbomachinery Solver Variables ---*/ - su2double *** AverageFlux, - ***SpanTotalFlux, - ***AverageVelocity, - ***AverageTurboVelocity, - ***OldAverageTurboVelocity, - ***ExtAverageTurboVelocity, - **AveragePressure, - **OldAveragePressure, - **RadialEquilibriumPressure, - **ExtAveragePressure, - **AverageDensity, - **OldAverageDensity, - **ExtAverageDensity, - **AverageNu, - **AverageKine, - **AverageOmega, - **ExtAverageNu, - **ExtAverageKine, - **ExtAverageOmega; - - su2double **DensityIn, - **PressureIn, - ***TurboVelocityIn, - **DensityOut, - **PressureOut, - ***TurboVelocityOut, - **KineIn, - **OmegaIn, - **NuIn, - **KineOut, - **OmegaOut, - **NuOut; - - complex ***CkInflow, - ***CkOutflow1, - ***CkOutflow2; + + su2double ***AverageFlux = nullptr, + ***SpanTotalFlux = nullptr, + ***AverageVelocity = nullptr, + ***AverageTurboVelocity = nullptr, + ***OldAverageTurboVelocity = nullptr, + ***ExtAverageTurboVelocity = nullptr, + **AveragePressure = nullptr, + **OldAveragePressure = nullptr, + **RadialEquilibriumPressure = nullptr, + **ExtAveragePressure = nullptr, + **AverageDensity = nullptr, + **OldAverageDensity = nullptr, + **ExtAverageDensity = nullptr, + **AverageNu = nullptr, + **AverageKine = nullptr, + **AverageOmega = nullptr, + **ExtAverageNu = nullptr, + **ExtAverageKine = nullptr, + **ExtAverageOmega = nullptr; + + su2double **DensityIn = nullptr, + **PressureIn = nullptr, + ***TurboVelocityIn = nullptr, + **DensityOut = nullptr, + **PressureOut = nullptr, + ***TurboVelocityOut = nullptr, + **KineIn = nullptr, + **OmegaIn = nullptr, + **NuIn = nullptr, + **KineOut = nullptr, + **OmegaOut = nullptr, + **NuOut = nullptr; + + complex ***CkInflow = nullptr, + ***CkOutflow1 = nullptr, + ***CkOutflow2 = nullptr; /*--- End of Turbomachinery Solver Variables ---*/ /*--- Sliding meshes variables ---*/ - su2double ****SlidingState; - int **SlidingStateNodes; + su2double ****SlidingState = nullptr; + int **SlidingStateNodes = nullptr; /*--- Shallow copy of grid coloring for OpenMP parallelization. ---*/ @@ -417,7 +352,7 @@ class CEulerSolver : public CSolver { * \brief Get the velocity at the infinity. * \return Value of the velocity at the infinity. */ - inline su2double *GetVelocity_Inf(void) const final { return Velocity_Inf; } + inline su2double *GetVelocity_Inf(void) final { return Velocity_Inf; } /*! * \brief Compute the time step for solving the Euler equations. @@ -1154,224 +1089,224 @@ class CEulerSolver : public CSolver { * \param val_marker Surface where the coefficient is going to be computed. * \return Value of the lift coefficient (inviscid contribution) on the surface val_marker. */ - inline su2double GetCL_Inv(unsigned short val_marker) const final { return CL_Inv[val_marker]; } + inline su2double GetCL_Inv(unsigned short val_marker) const final { return InvCoeff.CL[val_marker]; } + + /*! + * \brief Provide the non dimensional drag coefficient (inviscid contribution). + * \param val_marker Surface where the coeficient is going to be computed. + * \return Value of the drag coefficient (inviscid contribution) on the surface val_marker. + */ + inline su2double GetCD_Inv(unsigned short val_marker) const final { return InvCoeff.CD[val_marker]; } /*! * \brief Provide the non dimensional lift coefficient. * \param[in] val_marker - Surface marker where the coefficient is computed. * \return Value of the lift coefficient on the surface val_marker. */ - inline su2double GetSurface_CL(unsigned short val_marker) const final { return Surface_CL[val_marker]; } + inline su2double GetSurface_CL(unsigned short val_marker) const final { return SurfaceCoeff.CL[val_marker]; } /*! * \brief Provide the non dimensional drag coefficient. * \param[in] val_marker - Surface marker where the coefficient is computed. * \return Value of the drag coefficient on the surface val_marker. */ - inline su2double GetSurface_CD(unsigned short val_marker) const final { return Surface_CD[val_marker]; } + inline su2double GetSurface_CD(unsigned short val_marker) const final { return SurfaceCoeff.CD[val_marker]; } /*! * \brief Provide the non dimensional side-force coefficient. * \param[in] val_marker - Surface marker where the coefficient is computed. * \return Value of the side-force coefficient on the surface val_marker. */ - inline su2double GetSurface_CSF(unsigned short val_marker) const final { return Surface_CSF[val_marker]; } + inline su2double GetSurface_CSF(unsigned short val_marker) const final { return SurfaceCoeff.CSF[val_marker]; } /*! * \brief Provide the non dimensional side-force coefficient. * \param[in] val_marker - Surface marker where the coefficient is computed. * \return Value of the side-force coefficient on the surface val_marker. */ - inline su2double GetSurface_CEff(unsigned short val_marker) const final { return Surface_CEff[val_marker]; } + inline su2double GetSurface_CEff(unsigned short val_marker) const final { return SurfaceCoeff.CEff[val_marker]; } /*! * \brief Provide the non dimensional x force coefficient. * \param[in] val_marker - Surface marker where the coefficient is computed. * \return Value of the x force coefficient on the surface val_marker. */ - inline su2double GetSurface_CFx(unsigned short val_marker) const final { return Surface_CFx[val_marker]; } + inline su2double GetSurface_CFx(unsigned short val_marker) const final { return SurfaceCoeff.CFx[val_marker]; } /*! * \brief Provide the non dimensional y force coefficient. * \param[in] val_marker - Surface marker where the coefficient is computed. * \return Value of the y force coefficient on the surface val_marker. */ - inline su2double GetSurface_CFy(unsigned short val_marker) const final { return Surface_CFy[val_marker]; } + inline su2double GetSurface_CFy(unsigned short val_marker) const final { return SurfaceCoeff.CFy[val_marker]; } /*! * \brief Provide the non dimensional z force coefficient. * \param[in] val_marker - Surface marker where the coefficient is computed. * \return Value of the z force coefficient on the surface val_marker. */ - inline su2double GetSurface_CFz(unsigned short val_marker) const final { return Surface_CFz[val_marker]; } + inline su2double GetSurface_CFz(unsigned short val_marker) const final { return SurfaceCoeff.CFz[val_marker]; } /*! * \brief Provide the non dimensional x moment coefficient. * \param[in] val_marker - Surface marker where the coefficient is computed. * \return Value of the x moment coefficient on the surface val_marker. */ - inline su2double GetSurface_CMx(unsigned short val_marker) const final { return Surface_CMx[val_marker]; } + inline su2double GetSurface_CMx(unsigned short val_marker) const final { return SurfaceCoeff.CMx[val_marker]; } /*! * \brief Provide the non dimensional y moment coefficient. * \param[in] val_marker - Surface marker where the coefficient is computed. * \return Value of the y moment coefficient on the surface val_marker. */ - inline su2double GetSurface_CMy(unsigned short val_marker) const final { return Surface_CMy[val_marker]; } + inline su2double GetSurface_CMy(unsigned short val_marker) const final { return SurfaceCoeff.CMy[val_marker]; } /*! * \brief Provide the non dimensional z moment coefficient. * \param[in] val_marker - Surface marker where the coefficient is computed. * \return Value of the z moment coefficient on the surface val_marker. */ - inline su2double GetSurface_CMz(unsigned short val_marker) const final { return Surface_CMz[val_marker]; } + inline su2double GetSurface_CMz(unsigned short val_marker) const final { return SurfaceCoeff.CMz[val_marker]; } /*! * \brief Provide the non dimensional lift coefficient. * \param[in] val_marker - Surface marker where the coefficient is computed. * \return Value of the lift coefficient on the surface val_marker. */ - inline su2double GetSurface_CL_Inv(unsigned short val_marker) const final { return Surface_CL_Inv[val_marker]; } + inline su2double GetSurface_CL_Inv(unsigned short val_marker) const final { return SurfaceInvCoeff.CL[val_marker]; } /*! * \brief Provide the non dimensional drag coefficient. * \param[in] val_marker - Surface marker where the coefficient is computed. * \return Value of the drag coefficient on the surface val_marker. */ - inline su2double GetSurface_CD_Inv(unsigned short val_marker) const final { return Surface_CD_Inv[val_marker]; } + inline su2double GetSurface_CD_Inv(unsigned short val_marker) const final { return SurfaceInvCoeff.CD[val_marker]; } /*! * \brief Provide the non dimensional side-force coefficient. * \param[in] val_marker - Surface marker where the coefficient is computed. * \return Value of the side-force coefficient on the surface val_marker. */ - inline su2double GetSurface_CSF_Inv(unsigned short val_marker) const final { return Surface_CSF_Inv[val_marker]; } + inline su2double GetSurface_CSF_Inv(unsigned short val_marker) const final { return SurfaceInvCoeff.CSF[val_marker]; } /*! * \brief Provide the non dimensional side-force coefficient. * \param[in] val_marker - Surface marker where the coefficient is computed. * \return Value of the side-force coefficient on the surface val_marker. */ - inline su2double GetSurface_CEff_Inv(unsigned short val_marker) const final { return Surface_CEff_Inv[val_marker]; } + inline su2double GetSurface_CEff_Inv(unsigned short val_marker) const final { return SurfaceInvCoeff.CEff[val_marker]; } /*! * \brief Provide the non dimensional x force coefficient. * \param[in] val_marker - Surface marker where the coefficient is computed. * \return Value of the x force coefficient on the surface val_marker. */ - inline su2double GetSurface_CFx_Inv(unsigned short val_marker) const final { return Surface_CFx_Inv[val_marker]; } + inline su2double GetSurface_CFx_Inv(unsigned short val_marker) const final { return SurfaceInvCoeff.CFx[val_marker]; } /*! * \brief Provide the non dimensional y force coefficient. * \param[in] val_marker - Surface marker where the coefficient is computed. * \return Value of the y force coefficient on the surface val_marker. */ - inline su2double GetSurface_CFy_Inv(unsigned short val_marker) const final { return Surface_CFy_Inv[val_marker]; } + inline su2double GetSurface_CFy_Inv(unsigned short val_marker) const final { return SurfaceInvCoeff.CFy[val_marker]; } /*! * \brief Provide the non dimensional z force coefficient. * \param[in] val_marker - Surface marker where the coefficient is computed. * \return Value of the z force coefficient on the surface val_marker. */ - inline su2double GetSurface_CFz_Inv(unsigned short val_marker) const final { return Surface_CFz_Inv[val_marker]; } + inline su2double GetSurface_CFz_Inv(unsigned short val_marker) const final { return SurfaceInvCoeff.CFz[val_marker]; } /*! * \brief Provide the non dimensional x moment coefficient. * \param[in] val_marker - Surface marker where the coefficient is computed. * \return Value of the x moment coefficient on the surface val_marker. */ - inline su2double GetSurface_CMx_Inv(unsigned short val_marker) const final { return Surface_CMx_Inv[val_marker]; } + inline su2double GetSurface_CMx_Inv(unsigned short val_marker) const final { return SurfaceInvCoeff.CMx[val_marker]; } /*! * \brief Provide the non dimensional y moment coefficient. * \param[in] val_marker - Surface marker where the coefficient is computed. * \return Value of the y moment coefficient on the surface val_marker. */ - inline su2double GetSurface_CMy_Inv(unsigned short val_marker) const final { return Surface_CMy_Inv[val_marker]; } + inline su2double GetSurface_CMy_Inv(unsigned short val_marker) const final { return SurfaceInvCoeff.CMy[val_marker]; } /*! * \brief Provide the non dimensional z moment coefficient. * \param[in] val_marker - Surface marker where the coefficient is computed. * \return Value of the z moment coefficient on the surface val_marker. */ - inline su2double GetSurface_CMz_Inv(unsigned short val_marker) const final { return Surface_CMz_Inv[val_marker]; } + inline su2double GetSurface_CMz_Inv(unsigned short val_marker) const final { return SurfaceInvCoeff.CMz[val_marker]; } /*! * \brief Provide the non dimensional lift coefficient. * \param[in] val_marker - Surface marker where the coefficient is computed. * \return Value of the lift coefficient on the surface val_marker. */ - inline su2double GetSurface_CL_Mnt(unsigned short val_marker) const final { return Surface_CL_Mnt[val_marker]; } + inline su2double GetSurface_CL_Mnt(unsigned short val_marker) const final { return SurfaceMntCoeff.CL[val_marker]; } /*! * \brief Provide the non dimensional drag coefficient. * \param[in] val_marker - Surface marker where the coefficient is computed. * \return Value of the drag coefficient on the surface val_marker. */ - inline su2double GetSurface_CD_Mnt(unsigned short val_marker) const final { return Surface_CD_Mnt[val_marker]; } + inline su2double GetSurface_CD_Mnt(unsigned short val_marker) const final { return SurfaceMntCoeff.CD[val_marker]; } /*! * \brief Provide the non dimensional side-force coefficient. * \param[in] val_marker - Surface marker where the coefficient is computed. * \return Value of the side-force coefficient on the surface val_marker. */ - inline su2double GetSurface_CSF_Mnt(unsigned short val_marker) const final { return Surface_CSF_Mnt[val_marker]; } + inline su2double GetSurface_CSF_Mnt(unsigned short val_marker) const final { return SurfaceMntCoeff.CSF[val_marker]; } /*! * \brief Provide the non dimensional side-force coefficient. * \param[in] val_marker - Surface marker where the coefficient is computed. * \return Value of the side-force coefficient on the surface val_marker. */ - inline su2double GetSurface_CEff_Mnt(unsigned short val_marker) const final { return Surface_CEff_Mnt[val_marker]; } + inline su2double GetSurface_CEff_Mnt(unsigned short val_marker) const final { return SurfaceMntCoeff.CEff[val_marker]; } /*! * \brief Provide the non dimensional x force coefficient. * \param[in] val_marker - Surface marker where the coefficient is computed. * \return Value of the x force coefficient on the surface val_marker. */ - inline su2double GetSurface_CFx_Mnt(unsigned short val_marker) const final { return Surface_CFx_Mnt[val_marker]; } + inline su2double GetSurface_CFx_Mnt(unsigned short val_marker) const final { return SurfaceMntCoeff.CFx[val_marker]; } /*! * \brief Provide the non dimensional y force coefficient. * \param[in] val_marker - Surface marker where the coefficient is computed. * \return Value of the y force coefficient on the surface val_marker. */ - inline su2double GetSurface_CFy_Mnt(unsigned short val_marker) const final { return Surface_CFy_Mnt[val_marker]; } + inline su2double GetSurface_CFy_Mnt(unsigned short val_marker) const final { return SurfaceMntCoeff.CFy[val_marker]; } /*! * \brief Provide the non dimensional z force coefficient. * \param[in] val_marker - Surface marker where the coefficient is computed. * \return Value of the z force coefficient on the surface val_marker. */ - inline su2double GetSurface_CFz_Mnt(unsigned short val_marker) const final { return Surface_CFz_Mnt[val_marker]; } + inline su2double GetSurface_CFz_Mnt(unsigned short val_marker) const final { return SurfaceMntCoeff.CFz[val_marker]; } /*! * \brief Provide the non dimensional x moment coefficient. * \param[in] val_marker - Surface marker where the coefficient is computed. * \return Value of the x moment coefficient on the surface val_marker. */ - inline su2double GetSurface_CMx_Mnt(unsigned short val_marker) const final { return Surface_CMx_Mnt[val_marker]; } + inline su2double GetSurface_CMx_Mnt(unsigned short val_marker) const final { return SurfaceMntCoeff.CMx[val_marker]; } /*! * \brief Provide the non dimensional y moment coefficient. * \param[in] val_marker - Surface marker where the coefficient is computed. * \return Value of the y moment coefficient on the surface val_marker. */ - inline su2double GetSurface_CMy_Mnt(unsigned short val_marker) const final { return Surface_CMy_Mnt[val_marker]; } + inline su2double GetSurface_CMy_Mnt(unsigned short val_marker) const final { return SurfaceMntCoeff.CMy[val_marker]; } /*! * \brief Provide the non dimensional z moment coefficient. * \param[in] val_marker - Surface marker where the coefficient is computed. * \return Value of the z moment coefficient on the surface val_marker. */ - inline su2double GetSurface_CMz_Mnt(unsigned short val_marker) const final { return Surface_CMz_Mnt[val_marker]; } - - /*! - * \brief Provide the non dimensional drag coefficient (inviscid contribution). - * \param val_marker Surface where the coeficient is going to be computed. - * \return Value of the drag coefficient (inviscid contribution) on the surface val_marker. - */ - inline su2double GetCD_Inv(unsigned short val_marker) const final { return CD_Inv[val_marker]; } + inline su2double GetSurface_CMz_Mnt(unsigned short val_marker) const final { return SurfaceMntCoeff.CMz[val_marker]; } /*! * \brief Provide the mass flow rate. @@ -1406,26 +1341,26 @@ class CEulerSolver : public CSolver { * \param val_marker Surface where the coeficient is going to be computed. * \return Value of the sideforce coefficient (inviscid contribution) on the surface val_marker. */ - inline su2double GetCSF_Inv(unsigned short val_marker) const final { return CSF_Inv[val_marker]; } + inline su2double GetCSF_Inv(unsigned short val_marker) const final { return InvCoeff.CSF[val_marker]; } /*! * \brief Provide the non dimensional efficiency coefficient (inviscid contribution). * \param val_marker Surface where the coeficient is going to be computed. * \return Value of the efficiency coefficient (inviscid contribution) on the surface val_marker. */ - inline su2double GetCEff_Inv(unsigned short val_marker) const final { return CEff_Inv[val_marker]; } + inline su2double GetCEff_Inv(unsigned short val_marker) const final { return InvCoeff.CEff[val_marker]; } /*! * \brief Provide the total (inviscid + viscous) non dimensional sideforce coefficient. * \return Value of the sideforce coefficient (inviscid + viscous contribution). */ - inline su2double GetTotal_CSF() const final { return Total_CSF; } + inline su2double GetTotal_CSF() const final { return TotalCoeff.CSF; } /*! * \brief Provide the total (inviscid + viscous) non dimensional efficiency coefficient. * \return Value of the efficiency coefficient (inviscid + viscous contribution). */ - inline su2double GetTotal_CEff() const final { return Total_CEff; } + inline su2double GetTotal_CEff() const final { return TotalCoeff.CEff; } /*! * \brief Provide the total (inviscid + viscous) non dimensional Equivalent Area coefficient. @@ -1512,13 +1447,13 @@ class CEulerSolver : public CSolver { * \brief Provide the total (inviscid + viscous) non dimensional lift coefficient. * \return Value of the lift coefficient (inviscid + viscous contribution). */ - inline su2double GetTotal_CL() const final { return Total_CL; } + inline su2double GetTotal_CL() const final { return TotalCoeff.CL; } /*! * \brief Provide the total (inviscid + viscous) non dimensional drag coefficient. * \return Value of the drag coefficient (inviscid + viscous contribution). */ - inline su2double GetTotal_CD() const final { return Total_CD; } + inline su2double GetTotal_CD() const final { return TotalCoeff.CD; } /*! * \brief Provide the total (inviscid + viscous) non dimensional drag coefficient. @@ -1608,73 +1543,73 @@ class CEulerSolver : public CSolver { * \brief Provide the total (inviscid + viscous) non dimensional x moment coefficient. * \return Value of the moment x coefficient (inviscid + viscous contribution). */ - inline su2double GetTotal_CMx() const final { return Total_CMx; } + inline su2double GetTotal_CMx() const final { return TotalCoeff.CMx; } /*! * \brief Provide the total (inviscid + viscous) non dimensional y moment coefficient. * \return Value of the moment y coefficient (inviscid + viscous contribution). */ - inline su2double GetTotal_CMy() const final { return Total_CMy; } + inline su2double GetTotal_CMy() const final { return TotalCoeff.CMy; } /*! * \brief Provide the total (inviscid + viscous) non dimensional z moment coefficient. * \return Value of the moment z coefficient (inviscid + viscous contribution). */ - inline su2double GetTotal_CMz() const final { return Total_CMz; } + inline su2double GetTotal_CMz() const final { return TotalCoeff.CMz; } /*! * \brief Provide the total (inviscid + viscous) non dimensional x moment coefficient. * \return Value of the moment x coefficient (inviscid + viscous contribution). */ - inline su2double GetTotal_CoPx() const final { return Total_CoPx; } + inline su2double GetTotal_CoPx() const final { return TotalCoeff.CoPx; } /*! * \brief Provide the total (inviscid + viscous) non dimensional y moment coefficient. * \return Value of the moment y coefficient (inviscid + viscous contribution). */ - inline su2double GetTotal_CoPy() const final { return Total_CoPy; } + inline su2double GetTotal_CoPy() const final { return TotalCoeff.CoPy; } /*! * \brief Provide the total (inviscid + viscous) non dimensional z moment coefficient. * \return Value of the moment z coefficient (inviscid + viscous contribution). */ - inline su2double GetTotal_CoPz() const final { return Total_CoPz; } + inline su2double GetTotal_CoPz() const final { return TotalCoeff.CoPz; } /*! * \brief Provide the total (inviscid + viscous) non dimensional x force coefficient. * \return Value of the force x coefficient (inviscid + viscous contribution). */ - inline su2double GetTotal_CFx() const final { return Total_CFx; } + inline su2double GetTotal_CFx() const final { return TotalCoeff.CFx; } /*! * \brief Provide the total (inviscid + viscous) non dimensional y force coefficient. * \return Value of the force y coefficient (inviscid + viscous contribution). */ - inline su2double GetTotal_CFy() const final { return Total_CFy; } + inline su2double GetTotal_CFy() const final { return TotalCoeff.CFy; } /*! * \brief Provide the total (inviscid + viscous) non dimensional z force coefficient. * \return Value of the force z coefficient (inviscid + viscous contribution). */ - inline su2double GetTotal_CFz() const final { return Total_CFz; } + inline su2double GetTotal_CFz() const final { return TotalCoeff.CFz; } /*! * \brief Provide the total (inviscid + viscous) non dimensional thrust coefficient. * \return Value of the rotor efficiency coefficient (inviscid + viscous contribution). */ - inline su2double GetTotal_CT() const final { return Total_CT; } + inline su2double GetTotal_CT() const final { return TotalCoeff.CT; } /*! * \brief Store the total (inviscid + viscous) non dimensional thrust coefficient. * \param[in] val_Total_CT - Value of the total thrust coefficient. */ - inline void SetTotal_CT(su2double val_Total_CT) final { Total_CT = val_Total_CT; } + inline void SetTotal_CT(su2double val_Total_CT) final { TotalCoeff.CT = val_Total_CT; } /*! * \brief Provide the total (inviscid + viscous) non dimensional torque coefficient. * \return Value of the rotor efficiency coefficient (inviscid + viscous contribution). */ - inline su2double GetTotal_CQ() const final { return Total_CQ; } + inline su2double GetTotal_CQ() const final { return TotalCoeff.CQ; } /*! * \brief Provide the total heat load. @@ -1692,7 +1627,7 @@ class CEulerSolver : public CSolver { * \brief Store the total (inviscid + viscous) non dimensional torque coefficient. * \param[in] val_Total_CQ - Value of the total torque coefficient. */ - inline void SetTotal_CQ(su2double val_Total_CQ) final { Total_CQ = val_Total_CQ; } + inline void SetTotal_CQ(su2double val_Total_CQ) final { TotalCoeff.CQ = val_Total_CQ; } /*! * \brief Store the total heat load. @@ -1710,19 +1645,19 @@ class CEulerSolver : public CSolver { * \brief Provide the total (inviscid + viscous) non dimensional rotor Figure of Merit. * \return Value of the rotor efficiency coefficient (inviscid + viscous contribution). */ - inline su2double GetTotal_CMerit() const final { return Total_CMerit; } + inline su2double GetTotal_CMerit() const final { return TotalCoeff.CMerit; } /*! * \brief Store the total (inviscid + viscous) non dimensional drag coefficient. * \param[in] val_Total_CD - Value of the total drag coefficient. */ - inline void SetTotal_CD(su2double val_Total_CD) final { Total_CD = val_Total_CD; } + inline void SetTotal_CD(su2double val_Total_CD) final { TotalCoeff.CD = val_Total_CD; } /*! * \brief Store the total (inviscid + viscous) non dimensional lift coefficient. * \param[in] val_Total_CL - Value of the total lift coefficient. */ - inline void SetTotal_CL(su2double val_Total_CL) final { Total_CL = val_Total_CL; } + inline void SetTotal_CL(su2double val_Total_CL) final { TotalCoeff.CL = val_Total_CL; } /*! * \brief Store the total (inviscid + viscous) non dimensional drag coefficient. @@ -1824,157 +1759,157 @@ class CEulerSolver : public CSolver { * \brief Get the inviscid contribution to the lift coefficient. * \return Value of the lift coefficient (inviscid contribution). */ - inline su2double GetAllBound_CL_Inv() const final { return AllBound_CL_Inv; } + inline su2double GetAllBound_CL_Inv() const final { return AllBoundInvCoeff.CL; } /*! * \brief Get the inviscid contribution to the drag coefficient. * \return Value of the drag coefficient (inviscid contribution). */ - inline su2double GetAllBound_CD_Inv() const final { return AllBound_CD_Inv; } + inline su2double GetAllBound_CD_Inv() const final { return AllBoundInvCoeff.CD; } /*! * \brief Get the inviscid contribution to the sideforce coefficient. * \return Value of the sideforce coefficient (inviscid contribution). */ - inline su2double GetAllBound_CSF_Inv() const final { return AllBound_CSF_Inv; } + inline su2double GetAllBound_CSF_Inv() const final { return AllBoundInvCoeff.CSF; } /*! * \brief Get the inviscid contribution to the efficiency coefficient. * \return Value of the efficiency coefficient (inviscid contribution). */ - inline su2double GetAllBound_CEff_Inv() const final { return AllBound_CEff_Inv; } + inline su2double GetAllBound_CEff_Inv() const final { return AllBoundInvCoeff.CEff; } /*! * \brief Get the inviscid contribution to the efficiency coefficient. * \return Value of the efficiency coefficient (inviscid contribution). */ - inline su2double GetAllBound_CMx_Inv() const final { return AllBound_CMx_Inv; } + inline su2double GetAllBound_CMx_Inv() const final { return AllBoundInvCoeff.CMx; } /*! * \brief Get the inviscid contribution to the efficiency coefficient. * \return Value of the efficiency coefficient (inviscid contribution). */ - inline su2double GetAllBound_CMy_Inv() const final { return AllBound_CMy_Inv; } + inline su2double GetAllBound_CMy_Inv() const final { return AllBoundInvCoeff.CMy; } /*! * \brief Get the inviscid contribution to the efficiency coefficient. * \return Value of the efficiency coefficient (inviscid contribution). */ - inline su2double GetAllBound_CMz_Inv() const final { return AllBound_CMz_Inv; } + inline su2double GetAllBound_CMz_Inv() const final { return AllBoundInvCoeff.CMz; } /*! * \brief Get the inviscid contribution to the efficiency coefficient. * \return Value of the efficiency coefficient (inviscid contribution). */ - inline su2double GetAllBound_CoPx_Inv() const final { return AllBound_CoPx_Inv; } + inline su2double GetAllBound_CoPx_Inv() const final { return AllBoundInvCoeff.CoPx; } /*! * \brief Get the inviscid contribution to the efficiency coefficient. * \return Value of the efficiency coefficient (inviscid contribution). */ - inline su2double GetAllBound_CoPy_Inv() const final { return AllBound_CoPy_Inv; } + inline su2double GetAllBound_CoPy_Inv() const final { return AllBoundInvCoeff.CoPy; } /*! * \brief Get the inviscid contribution to the efficiency coefficient. * \return Value of the efficiency coefficient (inviscid contribution). */ - inline su2double GetAllBound_CoPz_Inv() const final { return AllBound_CoPz_Inv; } + inline su2double GetAllBound_CoPz_Inv() const final { return AllBoundInvCoeff.CoPz; } /*! * \brief Get the inviscid contribution to the efficiency coefficient. * \return Value of the efficiency coefficient (inviscid contribution). */ - inline su2double GetAllBound_CFx_Inv() const final { return AllBound_CFx_Inv; } + inline su2double GetAllBound_CFx_Inv() const final { return AllBoundInvCoeff.CFx; } /*! * \brief Get the inviscid contribution to the efficiency coefficient. * \return Value of the efficiency coefficient (inviscid contribution). */ - inline su2double GetAllBound_CFy_Inv() const final { return AllBound_CFy_Inv; } + inline su2double GetAllBound_CFy_Inv() const final { return AllBoundInvCoeff.CFy; } /*! * \brief Get the inviscid contribution to the efficiency coefficient. * \return Value of the efficiency coefficient (inviscid contribution). */ - inline su2double GetAllBound_CFz_Inv() const final { return AllBound_CFz_Inv; } + inline su2double GetAllBound_CFz_Inv() const final { return AllBoundInvCoeff.CFz; } /*! * \brief Get the inviscid contribution to the lift coefficient. * \return Value of the lift coefficient (inviscid contribution). */ - inline su2double GetAllBound_CL_Mnt() const final { return AllBound_CL_Mnt; } + inline su2double GetAllBound_CL_Mnt() const final { return AllBoundMntCoeff.CL; } /*! * \brief Get the inviscid contribution to the drag coefficient. * \return Value of the drag coefficient (inviscid contribution). */ - inline su2double GetAllBound_CD_Mnt() const final { return AllBound_CD_Mnt; } + inline su2double GetAllBound_CD_Mnt() const final { return AllBoundMntCoeff.CD; } /*! * \brief Get the inviscid contribution to the sideforce coefficient. * \return Value of the sideforce coefficient (inviscid contribution). */ - inline su2double GetAllBound_CSF_Mnt() const final { return AllBound_CSF_Mnt; } + inline su2double GetAllBound_CSF_Mnt() const final { return AllBoundMntCoeff.CSF; } /*! * \brief Get the inviscid contribution to the efficiency coefficient. * \return Value of the efficiency coefficient (inviscid contribution). */ - inline su2double GetAllBound_CEff_Mnt() const final { return AllBound_CEff_Mnt; } + inline su2double GetAllBound_CEff_Mnt() const final { return AllBoundMntCoeff.CEff; } /*! * \brief Get the inviscid contribution to the efficiency coefficient. * \return Value of the efficiency coefficient (inviscid contribution). */ - inline su2double GetAllBound_CMx_Mnt() const final { return AllBound_CMx_Mnt; } + inline su2double GetAllBound_CMx_Mnt() const final { return AllBoundMntCoeff.CMx; } /*! * \brief Get the inviscid contribution to the efficiency coefficient. * \return Value of the efficiency coefficient (inviscid contribution). */ - inline su2double GetAllBound_CMy_Mnt() const final { return AllBound_CMy_Mnt; } + inline su2double GetAllBound_CMy_Mnt() const final { return AllBoundMntCoeff.CMy; } /*! * \brief Get the inviscid contribution to the efficiency coefficient. * \return Value of the efficiency coefficient (inviscid contribution). */ - inline su2double GetAllBound_CMz_Mnt() const final { return AllBound_CMz_Mnt; } + inline su2double GetAllBound_CMz_Mnt() const final { return AllBoundMntCoeff.CMz; } /*! * \brief Get the inviscid contribution to the efficiency coefficient. * \return Value of the efficiency coefficient (inviscid contribution). */ - inline su2double GetAllBound_CoPx_Mnt() const final { return AllBound_CoPx_Mnt; } + inline su2double GetAllBound_CoPx_Mnt() const final { return AllBoundMntCoeff.CoPx; } /*! * \brief Get the inviscid contribution to the efficiency coefficient. * \return Value of the efficiency coefficient (inviscid contribution). */ - inline su2double GetAllBound_CoPy_Mnt() const final { return AllBound_CoPy_Mnt; } + inline su2double GetAllBound_CoPy_Mnt() const final { return AllBoundMntCoeff.CoPy; } /*! * \brief Get the inviscid contribution to the efficiency coefficient. * \return Value of the efficiency coefficient (inviscid contribution). */ - inline su2double GetAllBound_CoPz_Mnt() const final { return AllBound_CoPz_Mnt; } + inline su2double GetAllBound_CoPz_Mnt() const final { return AllBoundMntCoeff.CoPz; } /*! * \brief Get the inviscid contribution to the efficiency coefficient. * \return Value of the efficiency coefficient (inviscid contribution). */ - inline su2double GetAllBound_CFx_Mnt() const final { return AllBound_CFx_Mnt; } + inline su2double GetAllBound_CFx_Mnt() const final { return AllBoundMntCoeff.CFx; } /*! * \brief Get the inviscid contribution to the efficiency coefficient. * \return Value of the efficiency coefficient (inviscid contribution). */ - inline su2double GetAllBound_CFy_Mnt() const final { return AllBound_CFy_Mnt; } + inline su2double GetAllBound_CFy_Mnt() const final { return AllBoundMntCoeff.CFy; } /*! * \brief Get the inviscid contribution to the efficiency coefficient. * \return Value of the efficiency coefficient (inviscid contribution). */ - inline su2double GetAllBound_CFz_Mnt() const final { return AllBound_CFz_Mnt; } + inline su2double GetAllBound_CFz_Mnt() const final { return AllBoundMntCoeff.CFz; } /*! * \brief Provide the Pressure coefficient. diff --git a/SU2_CFD/include/solvers/CFEM_DG_EulerSolver.hpp b/SU2_CFD/include/solvers/CFEM_DG_EulerSolver.hpp index 0646564a5a22..1990d9767301 100644 --- a/SU2_CFD/include/solvers/CFEM_DG_EulerSolver.hpp +++ b/SU2_CFD/include/solvers/CFEM_DG_EulerSolver.hpp @@ -374,7 +374,7 @@ class CFEM_DG_EulerSolver : public CSolver { * \brief Get the velocity at the infinity. * \return Value of the velocity at the infinity. */ - inline su2double *GetVelocity_Inf(void) const final { return Velocity_Inf; } + inline su2double *GetVelocity_Inf(void) final { return Velocity_Inf; } /*! * \brief Set the freestream pressure. diff --git a/SU2_CFD/include/solvers/CIncEulerSolver.hpp b/SU2_CFD/include/solvers/CIncEulerSolver.hpp index a36cb0cde3aa..e9ef8143eb96 100644 --- a/SU2_CFD/include/solvers/CIncEulerSolver.hpp +++ b/SU2_CFD/include/solvers/CIncEulerSolver.hpp @@ -299,7 +299,7 @@ class CIncEulerSolver : public CSolver { * \brief Get the velocity at the infinity. * \return Value of the velocity at the infinity. */ - inline su2double *GetVelocity_Inf(void) const final { return Velocity_Inf; } + inline su2double *GetVelocity_Inf(void) final { return Velocity_Inf; } /*! * \brief Set the velocity at infinity. diff --git a/SU2_CFD/include/solvers/CNSSolver.hpp b/SU2_CFD/include/solvers/CNSSolver.hpp index 1eaf35a70a4e..a37b5a9f41dc 100644 --- a/SU2_CFD/include/solvers/CNSSolver.hpp +++ b/SU2_CFD/include/solvers/CNSSolver.hpp @@ -39,59 +39,22 @@ class CNSSolver final : public CEulerSolver { private: su2double Viscosity_Inf; /*!< \brief Viscosity at the infinity. */ su2double Tke_Inf; /*!< \brief Turbulent kinetic energy at the infinity. */ - su2double *CD_Visc, /*!< \brief Drag coefficient (viscous contribution) for each boundary. */ - *CL_Visc, /*!< \brief Lift coefficient (viscous contribution) for each boundary. */ - *CSF_Visc, /*!< \brief Side force coefficient (viscous contribution) for each boundary. */ - *CMx_Visc, /*!< \brief Moment x coefficient (viscous contribution) for each boundary. */ - *CMy_Visc, /*!< \brief Moment y coefficient (viscous contribution) for each boundary. */ - *CMz_Visc, /*!< \brief Moment z coefficient (viscous contribution) for each boundary. */ - *CoPx_Visc, /*!< \brief Moment x coefficient (viscous contribution) for each boundary. */ - *CoPy_Visc, /*!< \brief Moment y coefficient (viscous contribution) for each boundary. */ - *CoPz_Visc, /*!< \brief Moment z coefficient (viscous contribution) for each boundary. */ - *CFx_Visc, /*!< \brief Force x coefficient (viscous contribution) for each boundary. */ - *CFy_Visc, /*!< \brief Force y coefficient (viscous contribution) for each boundary. */ - *CFz_Visc, /*!< \brief Force z coefficient (viscous contribution) for each boundary. */ - *Surface_CL_Visc, /*!< \brief Lift coefficient (viscous contribution) for each monitoring surface. */ - *Surface_CD_Visc, /*!< \brief Drag coefficient (viscous contribution) for each monitoring surface. */ - *Surface_CSF_Visc, /*!< \brief Side-force coefficient (viscous contribution) for each monitoring surface. */ - *Surface_CEff_Visc, /*!< \brief Side-force coefficient (viscous contribution) for each monitoring surface. */ - *Surface_CFx_Visc, /*!< \brief Force x coefficient (viscous contribution) for each monitoring surface. */ - *Surface_CFy_Visc, /*!< \brief Force y coefficient (viscous contribution) for each monitoring surface. */ - *Surface_CFz_Visc, /*!< \brief Force z coefficient (viscous contribution) for each monitoring surface. */ - *Surface_CMx_Visc, /*!< \brief Moment x coefficient (viscous contribution) for each monitoring surface. */ - *Surface_CMy_Visc, /*!< \brief Moment y coefficient (viscous contribution) for each monitoring surface. */ - *Surface_CMz_Visc, /*!< \brief Moment z coefficient (viscous contribution) for each monitoring surface. */ - *Surface_Buffet_Metric, /*!< \brief Integrated separation sensor for each monitoring surface. */ - *CEff_Visc, /*!< \brief Efficiency (Cl/Cd) (Viscous contribution) for each boundary. */ - *CMerit_Visc, /*!< \brief Rotor Figure of Merit (Viscous contribution) for each boundary. */ - *Buffet_Metric, /*!< \brief Integrated separation sensor for each boundary. */ - *CT_Visc, /*!< \brief Thrust coefficient (viscous contribution) for each boundary. */ - *CQ_Visc, /*!< \brief Torque coefficient (viscous contribution) for each boundary. */ - *HF_Visc, /*!< \brief Heat load (viscous contribution) for each boundary. */ - *MaxHF_Visc, /*!< \brief Maximum heat flux (viscous contribution) for each boundary. */ - ***HeatConjugateVar, /*!< \brief Conjugate heat transfer variables for each boundary and vertex. */ - ***CSkinFriction, /*!< \brief Skin friction coefficient for each boundary and vertex. */ - **Buffet_Sensor; /*!< \brief Separation sensor for each boundary and vertex. */ - su2double Total_Buffet_Metric; /*!< \brief Integrated separation sensor for all the boundaries. */ - su2double *ForceViscous, /*!< \brief Viscous force for each boundary. */ - *MomentViscous; /*!< \brief Inviscid moment for each boundary. */ + + CoefficientsArray ViscCoeff; /*!< \brief Viscous contributions for each boundary. */ + CoefficientsArray SurfaceViscCoeff; /*!< \brief Viscous contributions for each monitoring boundary. */ + Coefficients AllBoundViscCoeff; /*!< \brief Total pressure contribution for all the boundaries. */ + + su2double + *Surface_Buffet_Metric = nullptr, /*!< \brief Integrated separation sensor for each monitoring surface. */ + *Buffet_Metric = nullptr, /*!< \brief Integrated separation sensor for each boundary. */ + *HF_Visc = nullptr, /*!< \brief Heat load (viscous contribution) for each boundary. */ + *MaxHF_Visc = nullptr, /*!< \brief Maximum heat flux (viscous contribution) for each boundary. */ + ***HeatConjugateVar = nullptr, /*!< \brief Conjugate heat transfer variables for each boundary and vertex. */ + ***CSkinFriction = nullptr, /*!< \brief Skin friction coefficient for each boundary and vertex. */ + **Buffet_Sensor = nullptr, /*!< \brief Separation sensor for each boundary and vertex. */ + Total_Buffet_Metric; /*!< \brief Integrated separation sensor for all the boundaries. */ + su2double - AllBound_CD_Visc, /*!< \brief Drag coefficient (viscous contribution) for all the boundaries. */ - AllBound_CL_Visc, /*!< \brief Lift coefficient (viscous contribution) for all the boundaries. */ - AllBound_CSF_Visc, /*!< \brief Sideforce coefficient (viscous contribution) for all the boundaries. */ - AllBound_CMx_Visc, /*!< \brief Moment x coefficient (inviscid contribution) for all the boundaries. */ - AllBound_CMy_Visc, /*!< \brief Moment y coefficient (inviscid contribution) for all the boundaries. */ - AllBound_CMz_Visc, /*!< \brief Moment z coefficient (inviscid contribution) for all the boundaries. */ - AllBound_CoPx_Visc, /*!< \brief Moment x coefficient (inviscid contribution) for all the boundaries. */ - AllBound_CoPy_Visc, /*!< \brief Moment y coefficient (inviscid contribution) for all the boundaries. */ - AllBound_CoPz_Visc, /*!< \brief Moment z coefficient (inviscid contribution) for all the boundaries. */ - AllBound_CEff_Visc, /*!< \brief Efficient coefficient (Viscous contribution) for all the boundaries. */ - AllBound_CFx_Visc, /*!< \brief Force x coefficient (inviscid contribution) for all the boundaries. */ - AllBound_CFy_Visc, /*!< \brief Force y coefficient (inviscid contribution) for all the boundaries. */ - AllBound_CFz_Visc, /*!< \brief Force z coefficient (inviscid contribution) for all the boundaries. */ - AllBound_CMerit_Visc, /*!< \brief Rotor Figure of Merit coefficient (Viscous contribution) for all the boundaries. */ - AllBound_CT_Visc, /*!< \brief Thrust coefficient (viscous contribution) for all the boundaries. */ - AllBound_CQ_Visc, /*!< \brief Torque coefficient (viscous contribution) for all the boundaries. */ AllBound_HF_Visc, /*!< \brief Heat load (viscous contribution) for all the boundaries. */ AllBound_MaxHF_Visc; /*!< \brief Maximum heat flux (viscous contribution) for all boundaries. */ su2double @@ -122,70 +85,70 @@ class CNSSolver final : public CEulerSolver { * \param[in] val_marker - Surface marker where the coefficient is computed. * \return Value of the lift coefficient on the surface val_marker. */ - inline su2double GetSurface_CL_Visc(unsigned short val_marker) const override { return Surface_CL_Visc[val_marker]; } + inline su2double GetSurface_CL_Visc(unsigned short val_marker) const override { return SurfaceViscCoeff.CL[val_marker]; } /*! * \brief Provide the non dimensional drag coefficient. * \param[in] val_marker - Surface marker where the coefficient is computed. * \return Value of the drag coefficient on the surface val_marker. */ - inline su2double GetSurface_CD_Visc(unsigned short val_marker) const override { return Surface_CD_Visc[val_marker]; } + inline su2double GetSurface_CD_Visc(unsigned short val_marker) const override { return SurfaceViscCoeff.CD[val_marker]; } /*! * \brief Provide the non dimensional side-force coefficient. * \param[in] val_marker - Surface marker where the coefficient is computed. * \return Value of the side-force coefficient on the surface val_marker. */ - inline su2double GetSurface_CSF_Visc(unsigned short val_marker) const override { return Surface_CSF_Visc[val_marker]; } + inline su2double GetSurface_CSF_Visc(unsigned short val_marker) const override { return SurfaceViscCoeff.CSF[val_marker]; } /*! * \brief Provide the non dimensional side-force coefficient. * \param[in] val_marker - Surface marker where the coefficient is computed. * \return Value of the side-force coefficient on the surface val_marker. */ - inline su2double GetSurface_CEff_Visc(unsigned short val_marker) const override { return Surface_CEff_Visc[val_marker]; } + inline su2double GetSurface_CEff_Visc(unsigned short val_marker) const override { return SurfaceViscCoeff.CEff[val_marker]; } /*! * \brief Provide the non dimensional x force coefficient. * \param[in] val_marker - Surface marker where the coefficient is computed. * \return Value of the x force coefficient on the surface val_marker. */ - inline su2double GetSurface_CFx_Visc(unsigned short val_marker) const override { return Surface_CFx_Visc[val_marker]; } + inline su2double GetSurface_CFx_Visc(unsigned short val_marker) const override { return SurfaceViscCoeff.CFx[val_marker]; } /*! * \brief Provide the non dimensional y force coefficient. * \param[in] val_marker - Surface marker where the coefficient is computed. * \return Value of the y force coefficient on the surface val_marker. */ - inline su2double GetSurface_CFy_Visc(unsigned short val_marker) const override { return Surface_CFy_Visc[val_marker]; } + inline su2double GetSurface_CFy_Visc(unsigned short val_marker) const override { return SurfaceViscCoeff.CFy[val_marker]; } /*! * \brief Provide the non dimensional z force coefficient. * \param[in] val_marker - Surface marker where the coefficient is computed. * \return Value of the z force coefficient on the surface val_marker. */ - inline su2double GetSurface_CFz_Visc(unsigned short val_marker) const override { return Surface_CFz_Visc[val_marker]; } + inline su2double GetSurface_CFz_Visc(unsigned short val_marker) const override { return SurfaceViscCoeff.CFz[val_marker]; } /*! * \brief Provide the non dimensional x moment coefficient. * \param[in] val_marker - Surface marker where the coefficient is computed. * \return Value of the x moment coefficient on the surface val_marker. */ - inline su2double GetSurface_CMx_Visc(unsigned short val_marker) const override { return Surface_CMx_Visc[val_marker]; } + inline su2double GetSurface_CMx_Visc(unsigned short val_marker) const override { return SurfaceViscCoeff.CMx[val_marker]; } /*! * \brief Provide the non dimensional y moment coefficient. * \param[in] val_marker - Surface marker where the coefficient is computed. * \return Value of the y moment coefficient on the surface val_marker. */ - inline su2double GetSurface_CMy_Visc(unsigned short val_marker) const override { return Surface_CMy_Visc[val_marker]; } + inline su2double GetSurface_CMy_Visc(unsigned short val_marker) const override { return SurfaceViscCoeff.CMy[val_marker]; } /*! * \brief Provide the non dimensional z moment coefficient. * \param[in] val_marker - Surface marker where the coefficient is computed. * \return Value of the z moment coefficient on the surface val_marker. */ - inline su2double GetSurface_CMz_Visc(unsigned short val_marker) const override { return Surface_CMz_Visc[val_marker]; } + inline su2double GetSurface_CMz_Visc(unsigned short val_marker) const override { return SurfaceViscCoeff.CMz[val_marker]; } /*! * \brief Provide the buffet metric. @@ -198,79 +161,79 @@ class CNSSolver final : public CEulerSolver { * \brief Get the inviscid contribution to the lift coefficient. * \return Value of the lift coefficient (inviscid contribution). */ - inline su2double GetAllBound_CL_Visc() const override { return AllBound_CL_Visc; } + inline su2double GetAllBound_CL_Visc() const override { return AllBoundViscCoeff.CL; } /*! * \brief Get the inviscid contribution to the drag coefficient. * \return Value of the drag coefficient (inviscid contribution). */ - inline su2double GetAllBound_CD_Visc() const override { return AllBound_CD_Visc; } + inline su2double GetAllBound_CD_Visc() const override { return AllBoundViscCoeff.CD; } /*! * \brief Get the inviscid contribution to the sideforce coefficient. * \return Value of the sideforce coefficient (inviscid contribution). */ - inline su2double GetAllBound_CSF_Visc() const override { return AllBound_CSF_Visc; } + inline su2double GetAllBound_CSF_Visc() const override { return AllBoundViscCoeff.CSF; } /*! * \brief Get the inviscid contribution to the efficiency coefficient. * \return Value of the efficiency coefficient (inviscid contribution). */ - inline su2double GetAllBound_CEff_Visc() const override { return AllBound_CEff_Visc; } + inline su2double GetAllBound_CEff_Visc() const override { return AllBoundViscCoeff.CEff; } /*! * \brief Get the inviscid contribution to the efficiency coefficient. * \return Value of the efficiency coefficient (inviscid contribution). */ - inline su2double GetAllBound_CMx_Visc() const override { return AllBound_CMx_Visc; } + inline su2double GetAllBound_CMx_Visc() const override { return AllBoundViscCoeff.CMx; } /*! * \brief Get the inviscid contribution to the efficiency coefficient. * \return Value of the efficiency coefficient (inviscid contribution). */ - inline su2double GetAllBound_CMy_Visc() const override { return AllBound_CMy_Visc; } + inline su2double GetAllBound_CMy_Visc() const override { return AllBoundViscCoeff.CMy; } /*! * \brief Get the inviscid contribution to the efficiency coefficient. * \return Value of the efficiency coefficient (inviscid contribution). */ - inline su2double GetAllBound_CMz_Visc() const override { return AllBound_CMz_Visc; } + inline su2double GetAllBound_CMz_Visc() const override { return AllBoundViscCoeff.CMz; } /*! * \brief Get the inviscid contribution to the efficiency coefficient. * \return Value of the efficiency coefficient (inviscid contribution). */ - inline su2double GetAllBound_CoPx_Visc() const override { return AllBound_CoPx_Visc; } + inline su2double GetAllBound_CoPx_Visc() const override { return AllBoundViscCoeff.CoPx; } /*! * \brief Get the inviscid contribution to the efficiency coefficient. * \return Value of the efficiency coefficient (inviscid contribution). */ - inline su2double GetAllBound_CoPy_Visc() const override { return AllBound_CoPy_Visc; } + inline su2double GetAllBound_CoPy_Visc() const override { return AllBoundViscCoeff.CoPy; } /*! * \brief Get the inviscid contribution to the efficiency coefficient. * \return Value of the efficiency coefficient (inviscid contribution). */ - inline su2double GetAllBound_CoPz_Visc() const override { return AllBound_CoPz_Visc; } + inline su2double GetAllBound_CoPz_Visc() const override { return AllBoundViscCoeff.CoPz; } /*! * \brief Get the inviscid contribution to the efficiency coefficient. * \return Value of the efficiency coefficient (inviscid contribution). */ - inline su2double GetAllBound_CFx_Visc() const override { return AllBound_CFx_Visc; } + inline su2double GetAllBound_CFx_Visc() const override { return AllBoundViscCoeff.CFx; } /*! * \brief Get the inviscid contribution to the efficiency coefficient. * \return Value of the efficiency coefficient (inviscid contribution). */ - inline su2double GetAllBound_CFy_Visc() const override { return AllBound_CFy_Visc; } + inline su2double GetAllBound_CFy_Visc() const override { return AllBoundViscCoeff.CFy; } /*! * \brief Get the inviscid contribution to the efficiency coefficient. * \return Value of the efficiency coefficient (inviscid contribution). */ - inline su2double GetAllBound_CFz_Visc() const override { return AllBound_CFz_Visc; } + inline su2double GetAllBound_CFz_Visc() const override { return AllBoundViscCoeff.CFz; } /*! * \brief Get the buffet metric. @@ -432,21 +395,21 @@ class CNSSolver final : public CEulerSolver { * \param[in] val_marker - Surface marker where the coefficient is computed. * \return Value of the lift coefficient (viscous contribution) on the surface val_marker. */ - inline su2double GetCL_Visc(unsigned short val_marker) const override { return CL_Visc[val_marker]; } + inline su2double GetCL_Visc(unsigned short val_marker) const override { return ViscCoeff.CL[val_marker]; } /*! * \brief Get the non dimensional sideforce coefficient (viscous contribution). * \param[in] val_marker - Surface marker where the coefficient is computed. * \return Value of the sideforce coefficient (viscous contribution) on the surface val_marker. */ - inline su2double GetCSF_Visc(unsigned short val_marker) const override { return CSF_Visc[val_marker]; } + inline su2double GetCSF_Visc(unsigned short val_marker) const override { return ViscCoeff.CSF[val_marker]; } /*! * \brief Get the non dimensional drag coefficient (viscous contribution). * \param[in] val_marker - Surface marker where the coefficient is computed. * \return Value of the drag coefficient (viscous contribution) on the surface val_marker. */ - inline su2double GetCD_Visc(unsigned short val_marker) const override { return CD_Visc[val_marker]; } + inline su2double GetCD_Visc(unsigned short val_marker) const override { return ViscCoeff.CD[val_marker]; } /*! * \brief Compute the viscous residuals. diff --git a/SU2_CFD/include/solvers/CSolver.hpp b/SU2_CFD/include/solvers/CSolver.hpp index cfe9379ea60c..5b7732ce17b1 100644 --- a/SU2_CFD/include/solvers/CSolver.hpp +++ b/SU2_CFD/include/solvers/CSolver.hpp @@ -3455,7 +3455,7 @@ class CSolver { * \brief A virtual member. * \return Value of the velocity at the infinity. */ - inline virtual su2double *GetVelocity_Inf(void) const { return 0; } + inline virtual su2double *GetVelocity_Inf(void) { return 0; } /*! * \brief A virtual member. diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index ef928cd6b492..680eef84b04b 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -34,66 +34,6 @@ CEulerSolver::CEulerSolver(void) : CSolver() { - /*--- Basic array initialization ---*/ - - CD_Inv = NULL; CL_Inv = NULL; CSF_Inv = NULL; CEff_Inv = NULL; - CMx_Inv = NULL; CMy_Inv = NULL; CMz_Inv = NULL; - CFx_Inv = NULL; CFy_Inv = NULL; CFz_Inv = NULL; - CoPx_Inv = NULL; CoPy_Inv = NULL; CoPz_Inv = NULL; - - CD_Mnt = NULL; CL_Mnt = NULL; CSF_Mnt = NULL; CEff_Mnt = NULL; - CMx_Mnt = NULL; CMy_Mnt = NULL; CMz_Mnt = NULL; - CFx_Mnt = NULL; CFy_Mnt = NULL; CFz_Mnt = NULL; - CoPx_Mnt = NULL; CoPy_Mnt = NULL; CoPz_Mnt = NULL; - - CPressure = NULL; CPressureTarget = NULL; HeatFlux = NULL; HeatFluxTarget = NULL; YPlus = NULL; - ForceInviscid = NULL; MomentInviscid = NULL; - ForceMomentum = NULL; MomentMomentum = NULL; - - /*--- Surface based array initialization ---*/ - - Surface_CL_Inv = NULL; Surface_CD_Inv = NULL; Surface_CSF_Inv = NULL; Surface_CEff_Inv = NULL; - Surface_CFx_Inv = NULL; Surface_CFy_Inv = NULL; Surface_CFz_Inv = NULL; - Surface_CMx_Inv = NULL; Surface_CMy_Inv = NULL; Surface_CMz_Inv = NULL; - - Surface_CL_Mnt = NULL; Surface_CD_Mnt = NULL; Surface_CSF_Mnt = NULL; Surface_CEff_Mnt = NULL; - Surface_CFx_Mnt = NULL; Surface_CFy_Mnt = NULL; Surface_CFz_Mnt = NULL; - Surface_CMx_Mnt = NULL; Surface_CMy_Mnt = NULL; Surface_CMz_Mnt = NULL; - - Surface_CL = NULL; Surface_CD = NULL; Surface_CSF = NULL; Surface_CEff = NULL; - Surface_CFx = NULL; Surface_CFy = NULL; Surface_CFz = NULL; - Surface_CMx = NULL; Surface_CMy = NULL; Surface_CMz = NULL; - - /*--- Rotorcraft simulation array initialization ---*/ - - CMerit_Inv = NULL; CT_Inv = NULL; CQ_Inv = NULL; - - CMerit_Mnt = NULL; CT_Mnt = NULL; CQ_Mnt = NULL; - - /*--- Supersonic simulation array initialization ---*/ - - CEquivArea_Inv = NULL; - CNearFieldOF_Inv = NULL; - - /*--- Engine simulation array initialization ---*/ - - Inflow_MassFlow = NULL; Inflow_Pressure = NULL; - Inflow_Mach = NULL; Inflow_Area = NULL; - Exhaust_Pressure = NULL; Exhaust_Temperature = NULL; - Exhaust_MassFlow = NULL; Exhaust_Area = NULL; - - /*--- Numerical methods array initialization ---*/ - - CharacPrimVar = NULL; - - DonorPrimVar = NULL; DonorGlobalIndex = NULL; - ActDisk_DeltaP = NULL; ActDisk_DeltaT = NULL; - - Inlet_Ttotal = NULL; Inlet_Ptotal = NULL; Inlet_FlowDir = NULL; - nVertex = NULL; - - Smatrix = NULL; Cvector = NULL; - /*--- Fixed CL mode initialization ---*/ Start_AoA_FD = false; @@ -101,60 +41,11 @@ CEulerSolver::CEulerSolver(void) : CSolver() { Update_AoA = false; Iter_Update_AoA = 0; - SlidingState = NULL; - SlidingStateNodes = NULL; - - /*--- Initialize quantities for the average process for internal flow ---*/ - - AverageVelocity = NULL; - AverageTurboVelocity = NULL; - OldAverageTurboVelocity = NULL; - ExtAverageTurboVelocity = NULL; - AverageFlux = NULL; - SpanTotalFlux = NULL; - AveragePressure = NULL; - OldAveragePressure = NULL; - RadialEquilibriumPressure = NULL; - ExtAveragePressure = NULL; - AverageDensity = NULL; - OldAverageDensity = NULL; - ExtAverageDensity = NULL; - AverageNu = NULL; - AverageKine = NULL; - AverageOmega = NULL; - ExtAverageNu = NULL; - ExtAverageKine = NULL; - ExtAverageOmega = NULL; - - - /*--- Initialize primitive quantities for turboperformace ---*/ - - DensityIn = NULL; - PressureIn = NULL; - TurboVelocityIn = NULL; - DensityOut = NULL; - PressureOut = NULL; - TurboVelocityOut = NULL; - KineIn = NULL; - OmegaIn = NULL; - NuIn = NULL; - KineOut = NULL; - OmegaOut = NULL; - NuOut = NULL; - - - /*--- Initialize quantities for Giles BC---*/ - - CkInflow = NULL; - CkOutflow1 = NULL; - CkOutflow2 = NULL; - - nodes = nullptr; } CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) : CSolver() { - unsigned long iPoint, counter_local = 0, counter_global = 0, iVertex; + unsigned long iPoint, counter_local = 0, counter_global = 0; unsigned short iVar, iDim, iMarker, nLineLets; su2double StaticEnergy, Density, Velocity2, Pressure, Temperature; unsigned short nZone = geometry->GetnZone(); @@ -207,66 +98,6 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short } - /*--- Array initialization ---*/ - - /*--- Basic array initialization ---*/ - - CD_Inv = NULL; CL_Inv = NULL; CSF_Inv = NULL; CEff_Inv = NULL; - CMx_Inv = NULL; CMy_Inv = NULL; CMz_Inv = NULL; - CFx_Inv = NULL; CFy_Inv = NULL; CFz_Inv = NULL; - CoPx_Inv = NULL; CoPy_Inv = NULL; CoPz_Inv = NULL; - - CD_Mnt= NULL; CL_Mnt= NULL; CSF_Mnt= NULL; CEff_Mnt= NULL; - CMx_Mnt= NULL; CMy_Mnt= NULL; CMz_Mnt= NULL; - CFx_Mnt= NULL; CFy_Mnt= NULL; CFz_Mnt= NULL; - CoPx_Mnt= NULL; CoPy_Mnt= NULL; CoPz_Mnt= NULL; - - CPressure = NULL; CPressureTarget = NULL; HeatFlux = NULL; HeatFluxTarget = NULL; YPlus = NULL; - ForceInviscid = NULL; MomentInviscid = NULL; - ForceMomentum = NULL; MomentMomentum = NULL; - - /*--- Surface based array initialization ---*/ - - Surface_CL_Inv = NULL; Surface_CD_Inv = NULL; Surface_CSF_Inv = NULL; Surface_CEff_Inv = NULL; - Surface_CFx_Inv = NULL; Surface_CFy_Inv = NULL; Surface_CFz_Inv = NULL; - Surface_CMx_Inv = NULL; Surface_CMy_Inv = NULL; Surface_CMz_Inv = NULL; - - Surface_CL_Mnt= NULL; Surface_CD_Mnt= NULL; Surface_CSF_Mnt= NULL; Surface_CEff_Mnt= NULL; - Surface_CFx_Mnt= NULL; Surface_CFy_Mnt= NULL; Surface_CFz_Mnt= NULL; - Surface_CMx_Mnt= NULL; Surface_CMy_Mnt= NULL; Surface_CMz_Mnt = NULL; - - Surface_CL = NULL; Surface_CD = NULL; Surface_CSF = NULL; Surface_CEff = NULL; - Surface_CFx = NULL; Surface_CFy = NULL; Surface_CFz = NULL; - Surface_CMx = NULL; Surface_CMy = NULL; Surface_CMz = NULL; - - /*--- Rotorcraft simulation array initialization ---*/ - - CMerit_Inv = NULL; CT_Inv = NULL; CQ_Inv = NULL; - - CMerit_Mnt = NULL; CT_Mnt = NULL; CQ_Mnt = NULL; - - /*--- Supersonic simulation array initialization ---*/ - - CEquivArea_Inv = NULL; - CNearFieldOF_Inv = NULL; - - /*--- Engine simulation array initialization ---*/ - - Inflow_MassFlow = NULL; Inflow_Pressure = NULL; - Inflow_Mach = NULL; Inflow_Area = NULL; - Exhaust_Pressure = NULL; Exhaust_Temperature = NULL; - Exhaust_MassFlow = NULL; Exhaust_Area = NULL; - - /*--- Numerical methods array initialization ---*/ - - iPoint_UndLapl = NULL; - jPoint_UndLapl = NULL; - CharacPrimVar = NULL; - DonorPrimVar = NULL; DonorGlobalIndex = NULL; - ActDisk_DeltaP = NULL; ActDisk_DeltaT = NULL; - - Smatrix = NULL; Cvector = NULL; - /*--- Fixed CL mode initialization ---*/ Start_AoA_FD = false; @@ -274,51 +105,6 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short Update_AoA = false; Iter_Update_AoA = 0; - /*--- Initialize quantities for the average process for internal flow ---*/ - - AverageVelocity = NULL; - AverageTurboVelocity = NULL; - OldAverageTurboVelocity = NULL; - ExtAverageTurboVelocity = NULL; - AverageFlux = NULL; - SpanTotalFlux = NULL; - AveragePressure = NULL; - OldAveragePressure = NULL; - RadialEquilibriumPressure = NULL; - ExtAveragePressure = NULL; - AverageDensity = NULL; - OldAverageDensity = NULL; - ExtAverageDensity = NULL; - AverageNu = NULL; - AverageKine = NULL; - AverageOmega = NULL; - ExtAverageNu = NULL; - ExtAverageKine = NULL; - ExtAverageOmega = NULL; - - - /*--- Initialize primitive quantities for turboperformace ---*/ - - DensityIn = NULL; - PressureIn = NULL; - TurboVelocityIn = NULL; - DensityOut = NULL; - PressureOut = NULL; - TurboVelocityOut = NULL; - KineIn = NULL; - OmegaIn = NULL; - NuIn = NULL; - KineOut = NULL; - OmegaOut = NULL; - NuOut = NULL; - - - /*--- Initialize quantities for Giles BC---*/ - - CkInflow = NULL; - CkOutflow1 = NULL; - CkOutflow2 = NULL; - /*--- Set the gamma value ---*/ Gamma = config->GetGamma(); @@ -446,162 +232,73 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short Cvector[iVar] = new su2double [nDim]; } - /*--- Store the value of the characteristic primitive variables at the boundaries ---*/ + /*--- Allocates a 2D array with variable "outer" sizes and init to 0. ---*/ - CharacPrimVar = new su2double** [nMarker]; - for (iMarker = 0; iMarker < nMarker; iMarker++) { - CharacPrimVar[iMarker] = new su2double* [geometry->nVertex[iMarker]]; - for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { - CharacPrimVar[iMarker][iVertex] = new su2double [nPrimVar](); + auto Alloc2D = [](unsigned long M, const unsigned long* N, su2double**& X) { + X = new su2double* [M]; + for(unsigned long i = 0; i < M; ++i) + X[i] = new su2double [N[i]] (); + }; + + /*--- Allocates a 3D array with variable "middle" sizes and init to 0. ---*/ + + auto Alloc3D = [](unsigned long M, const unsigned long* N, unsigned long P, su2double***& X) { + X = new su2double** [M]; + for(unsigned long i = 0; i < M; ++i) { + X[i] = new su2double* [N[i]]; + for(unsigned long j = 0; j < N[i]; ++j) + X[i][j] = new su2double [P] (); } - } + }; + + /*--- Store the value of the characteristic primitive variables at the boundaries ---*/ + + Alloc3D(nMarker, nVertex, nPrimVar, CharacPrimVar); /*--- Store the value of the primitive variables + 2 turb variables at the boundaries, used for IO with a donor cell ---*/ - DonorPrimVar = new su2double** [nMarker]; - for (iMarker = 0; iMarker < nMarker; iMarker++) { - DonorPrimVar[iMarker] = new su2double* [geometry->nVertex[iMarker]]; - for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { - if (rans) { - DonorPrimVar[iMarker][iVertex] = new su2double [nPrimVar+2](); - } - else { - DonorPrimVar[iMarker][iVertex] = new su2double [nPrimVar](); - } - } - } + Alloc3D(nMarker, nVertex, (rans? nPrimVar+2 : nPrimVar), DonorPrimVar); /*--- Store the value of the characteristic primitive variables index at the boundaries ---*/ DonorGlobalIndex = new unsigned long* [nMarker]; for (iMarker = 0; iMarker < nMarker; iMarker++) { - DonorGlobalIndex[iMarker] = new unsigned long [geometry->nVertex[iMarker]](); + DonorGlobalIndex[iMarker] = new unsigned long [nVertex[iMarker]](); } /*--- Store the value of the Delta P at the Actuator Disk ---*/ - ActDisk_DeltaP = new su2double* [nMarker]; - for (iMarker = 0; iMarker < nMarker; iMarker++) { - ActDisk_DeltaP[iMarker] = new su2double [geometry->nVertex[iMarker]](); - } + Alloc2D(nMarker, nVertex, ActDisk_DeltaP); /*--- Store the value of the Delta T at the Actuator Disk ---*/ - ActDisk_DeltaT = new su2double* [nMarker]; - for (iMarker = 0; iMarker < nMarker; iMarker++) { - ActDisk_DeltaT[iMarker] = new su2double [geometry->nVertex[iMarker]](); - } + Alloc2D(nMarker, nVertex, ActDisk_DeltaT); /*--- Store the value of the Total Pressure at the inlet BC ---*/ - Inlet_Ttotal = new su2double* [nMarker]; - for (iMarker = 0; iMarker < nMarker; iMarker++) { - Inlet_Ttotal[iMarker] = new su2double [geometry->nVertex[iMarker]](); - } + Alloc2D(nMarker, nVertex, Inlet_Ttotal); /*--- Store the value of the Total Temperature at the inlet BC ---*/ - Inlet_Ptotal = new su2double* [nMarker]; - for (iMarker = 0; iMarker < nMarker; iMarker++) { - Inlet_Ptotal[iMarker] = new su2double [geometry->nVertex[iMarker]](); - } + Alloc2D(nMarker, nVertex, Inlet_Ptotal); /*--- Store the value of the Flow direction at the inlet BC ---*/ - Inlet_FlowDir = new su2double** [nMarker]; - for (iMarker = 0; iMarker < nMarker; iMarker++) { - Inlet_FlowDir[iMarker] = new su2double* [geometry->nVertex[iMarker]]; - for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { - Inlet_FlowDir[iMarker][iVertex] = new su2double [nDim](); - } - } + Alloc3D(nMarker, nVertex, nDim, Inlet_FlowDir); /*--- Force definition and coefficient arrays for all of the markers ---*/ - CPressure = new su2double* [nMarker]; - CPressureTarget = new su2double* [nMarker]; - for (iMarker = 0; iMarker < nMarker; iMarker++) { - CPressure[iMarker] = new su2double [geometry->nVertex[iMarker]](); - CPressureTarget[iMarker] = new su2double [geometry->nVertex[iMarker]](); - } - - /*--- Non-dimensional coefficients ---*/ - - ForceInviscid = new su2double[nDim]; - MomentInviscid = new su2double[3]; - CD_Inv = new su2double[nMarker]; - CL_Inv = new su2double[nMarker]; - CSF_Inv = new su2double[nMarker]; - CMx_Inv = new su2double[nMarker]; - CMy_Inv = new su2double[nMarker]; - CMz_Inv = new su2double[nMarker]; - CEff_Inv = new su2double[nMarker]; - CFx_Inv = new su2double[nMarker]; - CFy_Inv = new su2double[nMarker]; - CFz_Inv = new su2double[nMarker]; - CoPx_Inv = new su2double[nMarker]; - CoPy_Inv = new su2double[nMarker]; - CoPz_Inv = new su2double[nMarker]; - - ForceMomentum = new su2double[nDim]; - MomentMomentum = new su2double[3]; - CD_Mnt = new su2double[nMarker]; - CL_Mnt = new su2double[nMarker]; - CSF_Mnt = new su2double[nMarker]; - CMx_Mnt = new su2double[nMarker]; - CMy_Mnt = new su2double[nMarker]; - CMz_Mnt = new su2double[nMarker]; - CEff_Mnt = new su2double[nMarker]; - CFx_Mnt = new su2double[nMarker]; - CFy_Mnt = new su2double[nMarker]; - CFz_Mnt = new su2double[nMarker]; - CoPx_Mnt = new su2double[nMarker]; - CoPy_Mnt = new su2double[nMarker]; - CoPz_Mnt = new su2double[nMarker]; - - Surface_CL_Inv = new su2double[config->GetnMarker_Monitoring()]; - Surface_CD_Inv = new su2double[config->GetnMarker_Monitoring()]; - Surface_CSF_Inv = new su2double[config->GetnMarker_Monitoring()]; - Surface_CEff_Inv = new su2double[config->GetnMarker_Monitoring()]; - Surface_CFx_Inv = new su2double[config->GetnMarker_Monitoring()]; - Surface_CFy_Inv = new su2double[config->GetnMarker_Monitoring()]; - Surface_CFz_Inv = new su2double[config->GetnMarker_Monitoring()]; - Surface_CMx_Inv = new su2double[config->GetnMarker_Monitoring()]; - Surface_CMy_Inv = new su2double[config->GetnMarker_Monitoring()]; - Surface_CMz_Inv = new su2double[config->GetnMarker_Monitoring()]; - - Surface_CL_Mnt = new su2double[config->GetnMarker_Monitoring()]; - Surface_CD_Mnt = new su2double[config->GetnMarker_Monitoring()]; - Surface_CSF_Mnt = new su2double[config->GetnMarker_Monitoring()]; - Surface_CEff_Mnt = new su2double[config->GetnMarker_Monitoring()]; - Surface_CFx_Mnt = new su2double[config->GetnMarker_Monitoring()]; - Surface_CFy_Mnt = new su2double[config->GetnMarker_Monitoring()]; - Surface_CFz_Mnt = new su2double[config->GetnMarker_Monitoring()]; - Surface_CMx_Mnt = new su2double[config->GetnMarker_Monitoring()]; - Surface_CMy_Mnt = new su2double[config->GetnMarker_Monitoring()]; - Surface_CMz_Mnt = new su2double[config->GetnMarker_Monitoring()]; - - Surface_CL = new su2double[config->GetnMarker_Monitoring()]; - Surface_CD = new su2double[config->GetnMarker_Monitoring()]; - Surface_CSF = new su2double[config->GetnMarker_Monitoring()]; - Surface_CEff = new su2double[config->GetnMarker_Monitoring()]; - Surface_CFx = new su2double[config->GetnMarker_Monitoring()]; - Surface_CFy = new su2double[config->GetnMarker_Monitoring()]; - Surface_CFz = new su2double[config->GetnMarker_Monitoring()]; - Surface_CMx = new su2double[config->GetnMarker_Monitoring()]; - Surface_CMy = new su2double[config->GetnMarker_Monitoring()]; - Surface_CMz = new su2double[config->GetnMarker_Monitoring()]; - - /*--- Rotorcraft coefficients ---*/ - - CT_Inv = new su2double[nMarker]; - CQ_Inv = new su2double[nMarker]; - CMerit_Inv = new su2double[nMarker]; - - CT_Mnt = new su2double[nMarker]; - CQ_Mnt = new su2double[nMarker]; - CMerit_Mnt = new su2double[nMarker]; + Alloc2D(nMarker, nVertex, CPressure); + Alloc2D(nMarker, nVertex, CPressureTarget); + + /*--- Non dimensional aerodynamic coefficients ---*/ + + InvCoeff.allocate(nMarker); + MntCoeff.allocate(nMarker); + SurfaceInvCoeff.allocate(config->GetnMarker_Monitoring()); + SurfaceMntCoeff.allocate(config->GetnMarker_Monitoring()); + SurfaceCoeff.allocate(config->GetnMarker_Monitoring()); /*--- Supersonic coefficients ---*/ @@ -620,22 +317,6 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short Exhaust_Temperature = new su2double[nMarker]; Exhaust_Area = new su2double[nMarker]; - /*--- Init total coefficients ---*/ - - Total_CD = 0.0; Total_CL = 0.0; Total_CSF = 0.0; - Total_CMx = 0.0; Total_CMy = 0.0; Total_CMz = 0.0; - Total_CoPx = 0.0; Total_CoPy = 0.0; Total_CoPz = 0.0; - Total_CEff = 0.0; Total_CEquivArea = 0.0; Total_CNearFieldOF = 0.0; - Total_CFx = 0.0; Total_CFy = 0.0; Total_CFz = 0.0; - Total_CT = 0.0; Total_CQ = 0.0; Total_CMerit = 0.0; - Total_MaxHeat = 0.0; Total_Heat = 0.0; Total_ComboObj = 0.0; - Total_CpDiff = 0.0; Total_HeatFluxDiff = 0.0; Total_Custom_ObjFunc = 0.0; - Total_NetThrust = 0.0; - Total_Power = 0.0; AoA_Prev = 0.0; AoA_inc = 0.0; - Total_CL_Prev = 0.0; Total_CD_Prev = 0.0; - Total_CMx_Prev = 0.0; Total_CMy_Prev = 0.0; Total_CMz_Prev = 0.0; - Total_AeroCD = 0.0; Total_SolidCD = 0.0; Total_IDR = 0.0; Total_IDC = 0.0; - /*--- Read farfield conditions ---*/ Density_Inf = config->GetDensity_FreeStreamND(); @@ -669,7 +350,6 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short break; } - /*--- Initialize fan face pressure, fan face mach number, and mass flow rate ---*/ for (iMarker = 0; iMarker < nMarker; iMarker++) { @@ -784,11 +464,9 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short /*--- Warning message about non-physical points ---*/ 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 ((rank == MASTER_NODE) && (counter_global != 0)) cout << "Warning. The original solution contains "<< counter_global << " points that are not physical." << endl; } @@ -844,78 +522,9 @@ CEulerSolver::~CEulerSolver(void) { /*--- Array deallocation ---*/ - delete [] CD_Inv; - delete [] CL_Inv; - delete [] CSF_Inv; - delete [] CMx_Inv; - delete [] CMy_Inv; - delete [] CMz_Inv; - delete [] CFx_Inv; - delete [] CFy_Inv; - delete [] CFz_Inv; - delete [] CoPx_Inv; - delete [] CoPy_Inv; - delete [] CoPz_Inv; - delete[] Surface_CL_Inv; - delete[] Surface_CD_Inv; - delete[] Surface_CSF_Inv; - delete[] Surface_CEff_Inv; - delete [] Surface_CFx_Inv; - delete [] Surface_CFy_Inv; - delete [] Surface_CFz_Inv; - delete [] Surface_CMx_Inv; - delete [] Surface_CMy_Inv; - delete [] Surface_CMz_Inv; - - delete [] CD_Mnt; - delete [] CL_Mnt; - delete [] CSF_Mnt; - delete [] CFx_Mnt; - delete [] CFy_Mnt; - delete [] CFz_Mnt; - delete [] CMx_Mnt; - delete [] CMy_Mnt; - delete [] CMz_Mnt; - delete [] CoPx_Mnt; - delete [] CoPy_Mnt; - delete [] CoPz_Mnt; - delete [] Surface_CL_Mnt; - delete [] Surface_CD_Mnt; - delete [] Surface_CSF_Mnt; - delete [] Surface_CEff_Mnt; - delete [] Surface_CFx_Mnt; - delete [] Surface_CFy_Mnt; - delete [] Surface_CFz_Mnt; - delete [] Surface_CMx_Mnt; - delete [] Surface_CMy_Mnt; - delete [] Surface_CMz_Mnt; - - delete [] Surface_CL; - delete [] Surface_CD; - delete [] Surface_CSF; - delete [] Surface_CEff; - delete [] Surface_CFx; - delete [] Surface_CFy; - delete [] Surface_CFz; - delete [] Surface_CMx; - delete [] Surface_CMy; - delete [] Surface_CMz; - delete [] CEff_Inv; - delete [] CMerit_Inv; - delete [] CT_Inv; - delete [] CQ_Inv; delete [] CEquivArea_Inv; delete [] CNearFieldOF_Inv; - delete [] CEff_Mnt; - delete [] CMerit_Mnt; - delete [] CT_Mnt; - delete [] CQ_Mnt; - - delete [] ForceInviscid; - delete [] MomentInviscid; - delete [] ForceMomentum; - delete [] MomentMomentum; delete [] Inflow_MassFlow; delete [] Exhaust_MassFlow; delete [] Exhaust_Area; @@ -1081,7 +690,6 @@ CEulerSolver::~CEulerSolver(void) { delete [] ExtAverageTurboVelocity; } - if(AverageFlux !=NULL){ for (iMarker = 0; iMarker < nMarker; iMarker++) { for(iSpan = 0; iSpan < nSpanWiseSections + 1; iSpan++) @@ -4213,11 +3821,10 @@ void CEulerSolver::Pressure_Forces(CGeometry *geometry, CConfig *config) { unsigned long iVertex, iPoint; unsigned short iDim, iMarker, Boundary, Monitoring, iMarker_Monitoring; - su2double Pressure = 0.0, MomentDist[3] = {0.0,0.0,0.0}, factor, NFPressOF, RefVel2, - RefTemp, RefDensity, RefPressure, Mach2Vel, Mach_Motion, Force[3] = {0.0,0.0,0.0}; + su2double Pressure = 0.0, factor, NFPressOF, RefVel2, + RefTemp, RefDensity, RefPressure, Mach2Vel, Mach_Motion; const su2double *Normal = nullptr, *Coord = nullptr; string Marker_Tag, Monitoring_Tag; - su2double MomentX_Force[3] = {0.0,0.0,0.0}, MomentY_Force[3] = {0.0,0.0,0.0}, MomentZ_Force[3] = {0.0,0.0,0.0}; su2double AxiFactor; su2double Alpha = config->GetAoA()*PI_NUMBER/180.0; @@ -4254,32 +3861,16 @@ void CEulerSolver::Pressure_Forces(CGeometry *geometry, CConfig *config) { /*-- Variables initialization ---*/ - Total_CD = 0.0; Total_CL = 0.0; Total_CSF = 0.0; Total_CEff = 0.0; - Total_CMx = 0.0; Total_CMy = 0.0; Total_CMz = 0.0; - Total_CoPx = 0.0; Total_CoPy = 0.0; Total_CoPz = 0.0; - Total_CFx = 0.0; Total_CFy = 0.0; Total_CFz = 0.0; - Total_CT = 0.0; Total_CQ = 0.0; Total_CMerit = 0.0; + TotalCoeff.setZero(); + Total_CNearFieldOF = 0.0; Total_Heat = 0.0; Total_MaxHeat = 0.0; - AllBound_CD_Inv = 0.0; AllBound_CL_Inv = 0.0; AllBound_CSF_Inv = 0.0; - AllBound_CMx_Inv = 0.0; AllBound_CMy_Inv = 0.0; AllBound_CMz_Inv = 0.0; - AllBound_CoPx_Inv = 0.0; AllBound_CoPy_Inv = 0.0; AllBound_CoPz_Inv = 0.0; - AllBound_CFx_Inv = 0.0; AllBound_CFy_Inv = 0.0; AllBound_CFz_Inv = 0.0; - AllBound_CT_Inv = 0.0; AllBound_CQ_Inv = 0.0; AllBound_CMerit_Inv = 0.0; - AllBound_CNearFieldOF_Inv = 0.0; AllBound_CEff_Inv = 0.0; + AllBoundInvCoeff.setZero(); - for (iMarker_Monitoring = 0; iMarker_Monitoring < config->GetnMarker_Monitoring(); iMarker_Monitoring++) { - Surface_CL_Inv[iMarker_Monitoring] = 0.0; Surface_CD_Inv[iMarker_Monitoring] = 0.0; - Surface_CSF_Inv[iMarker_Monitoring] = 0.0; Surface_CEff_Inv[iMarker_Monitoring] = 0.0; - Surface_CFx_Inv[iMarker_Monitoring] = 0.0; Surface_CFy_Inv[iMarker_Monitoring] = 0.0; - Surface_CFz_Inv[iMarker_Monitoring] = 0.0; Surface_CMx_Inv[iMarker_Monitoring] = 0.0; - Surface_CMy_Inv[iMarker_Monitoring] = 0.0; Surface_CMz_Inv[iMarker_Monitoring] = 0.0; - Surface_CL[iMarker_Monitoring] = 0.0; Surface_CD[iMarker_Monitoring] = 0.0; - Surface_CSF[iMarker_Monitoring] = 0.0; Surface_CEff[iMarker_Monitoring] = 0.0; - Surface_CFx[iMarker_Monitoring] = 0.0; Surface_CFy[iMarker_Monitoring] = 0.0; - Surface_CFz[iMarker_Monitoring] = 0.0; Surface_CMx[iMarker_Monitoring] = 0.0; - Surface_CMy[iMarker_Monitoring] = 0.0; Surface_CMz[iMarker_Monitoring] = 0.0; - } + AllBound_CNearFieldOF_Inv = 0.0; + + SurfaceInvCoeff.setZero(); + SurfaceCoeff.setZero(); /*--- Loop over the Euler and Navier-Stokes markers ---*/ @@ -4308,18 +3899,12 @@ void CEulerSolver::Pressure_Forces(CGeometry *geometry, CConfig *config) { /*--- Forces initialization at each Marker ---*/ - CD_Inv[iMarker] = 0.0; CL_Inv[iMarker] = 0.0; CSF_Inv[iMarker] = 0.0; - CMx_Inv[iMarker] = 0.0; CMy_Inv[iMarker] = 0.0; CMz_Inv[iMarker] = 0.0; - CoPx_Inv[iMarker] = 0.0; CoPy_Inv[iMarker] = 0.0; CoPz_Inv[iMarker] = 0.0; - CFx_Inv[iMarker] = 0.0; CFy_Inv[iMarker] = 0.0; CFz_Inv[iMarker] = 0.0; - CT_Inv[iMarker] = 0.0; CQ_Inv[iMarker] = 0.0; CMerit_Inv[iMarker] = 0.0; - CNearFieldOF_Inv[iMarker] = 0.0; CEff_Inv[iMarker] = 0.0; + InvCoeff.setZero(iMarker); + + CNearFieldOF_Inv[iMarker] = 0.0; - for (iDim = 0; iDim < nDim; iDim++) ForceInviscid[iDim] = 0.0; - MomentInviscid[0] = 0.0; MomentInviscid[1] = 0.0; MomentInviscid[2] = 0.0; - MomentX_Force[0] = 0.0; MomentX_Force[1] = 0.0; MomentX_Force[2] = 0.0; - MomentY_Force[0] = 0.0; MomentY_Force[1] = 0.0; MomentY_Force[2] = 0.0; - MomentZ_Force[0] = 0.0; MomentZ_Force[1] = 0.0; MomentZ_Force[2] = 0.0; + su2double ForceInviscid[MAXNDIM] = {0.0}, MomentInviscid[MAXNDIM] = {0.0}; + su2double MomentX_Force[MAXNDIM] = {0.0}, MomentY_Force[MAXNDIM] = {0.0}, MomentZ_Force[MAXNDIM] = {0.0}; NFPressOF = 0.0; @@ -4346,6 +3931,7 @@ void CEulerSolver::Pressure_Forces(CGeometry *geometry, CConfig *config) { NFPressOF += 0.5*(Pressure - Pressure_Inf)*(Pressure - Pressure_Inf)*Normal[nDim-1]; + su2double MomentDist[MAXNDIM] = {0.0}; for (iDim = 0; iDim < nDim; iDim++) { MomentDist[iDim] = Coord[iDim] - Origin[iDim]; } @@ -4358,6 +3944,7 @@ void CEulerSolver::Pressure_Forces(CGeometry *geometry, CConfig *config) { /*--- Force computation, note the minus sign due to the orientation of the normal (outward) ---*/ + su2double Force[MAXNDIM] = {0.0}; for (iDim = 0; iDim < nDim; iDim++) { Force[iDim] = -(Pressure - Pressure_Inf) * Normal[iDim] * factor * AxiFactor; ForceInviscid[iDim] += Force[iDim]; @@ -4387,52 +3974,52 @@ void CEulerSolver::Pressure_Forces(CGeometry *geometry, CConfig *config) { if (Boundary != NEARFIELD_BOUNDARY) { if (nDim == 2) { - CD_Inv[iMarker] = ForceInviscid[0]*cos(Alpha) + ForceInviscid[1]*sin(Alpha); - CL_Inv[iMarker] = -ForceInviscid[0]*sin(Alpha) + ForceInviscid[1]*cos(Alpha); - CEff_Inv[iMarker] = CL_Inv[iMarker] / (CD_Inv[iMarker]+EPS); - CMz_Inv[iMarker] = MomentInviscid[2]; - CoPx_Inv[iMarker] = MomentZ_Force[1]; - CoPy_Inv[iMarker] = -MomentZ_Force[0]; - CFx_Inv[iMarker] = ForceInviscid[0]; - CFy_Inv[iMarker] = ForceInviscid[1]; - CT_Inv[iMarker] = -CFx_Inv[iMarker]; - CQ_Inv[iMarker] = -CMz_Inv[iMarker]; - CMerit_Inv[iMarker] = CT_Inv[iMarker] / (CQ_Inv[iMarker] + EPS); + InvCoeff.CD[iMarker] = ForceInviscid[0]*cos(Alpha) + ForceInviscid[1]*sin(Alpha); + InvCoeff.CL[iMarker] = -ForceInviscid[0]*sin(Alpha) + ForceInviscid[1]*cos(Alpha); + InvCoeff.CEff[iMarker] = InvCoeff.CL[iMarker] / (InvCoeff.CD[iMarker]+EPS); + InvCoeff.CMz[iMarker] = MomentInviscid[2]; + InvCoeff.CoPx[iMarker] = MomentZ_Force[1]; + InvCoeff.CoPy[iMarker] = -MomentZ_Force[0]; + InvCoeff.CFx[iMarker] = ForceInviscid[0]; + InvCoeff.CFy[iMarker] = ForceInviscid[1]; + InvCoeff.CT[iMarker] = -InvCoeff.CFx[iMarker]; + InvCoeff.CQ[iMarker] = -InvCoeff.CMz[iMarker]; + InvCoeff.CMerit[iMarker] = InvCoeff.CT[iMarker] / (InvCoeff.CQ[iMarker] + EPS); } if (nDim == 3) { - CD_Inv[iMarker] = ForceInviscid[0]*cos(Alpha)*cos(Beta) + ForceInviscid[1]*sin(Beta) + ForceInviscid[2]*sin(Alpha)*cos(Beta); - CL_Inv[iMarker] = -ForceInviscid[0]*sin(Alpha) + ForceInviscid[2]*cos(Alpha); - CSF_Inv[iMarker] = -ForceInviscid[0]*sin(Beta)*cos(Alpha) + ForceInviscid[1]*cos(Beta) - ForceInviscid[2]*sin(Beta)*sin(Alpha); - CEff_Inv[iMarker] = CL_Inv[iMarker] / (CD_Inv[iMarker] + EPS); - CMx_Inv[iMarker] = MomentInviscid[0]; - CMy_Inv[iMarker] = MomentInviscid[1]; - CMz_Inv[iMarker] = MomentInviscid[2]; - CoPx_Inv[iMarker] = -MomentY_Force[0]; - CoPz_Inv[iMarker] = MomentY_Force[2]; - CFx_Inv[iMarker] = ForceInviscid[0]; - CFy_Inv[iMarker] = ForceInviscid[1]; - CFz_Inv[iMarker] = ForceInviscid[2]; - CT_Inv[iMarker] = -CFz_Inv[iMarker]; - CQ_Inv[iMarker] = -CMz_Inv[iMarker]; - CMerit_Inv[iMarker] = CT_Inv[iMarker] / (CQ_Inv[iMarker] + EPS); + InvCoeff.CD[iMarker] = ForceInviscid[0]*cos(Alpha)*cos(Beta) + ForceInviscid[1]*sin(Beta) + ForceInviscid[2]*sin(Alpha)*cos(Beta); + InvCoeff.CL[iMarker] = -ForceInviscid[0]*sin(Alpha) + ForceInviscid[2]*cos(Alpha); + InvCoeff.CSF[iMarker] = -ForceInviscid[0]*sin(Beta)*cos(Alpha) + ForceInviscid[1]*cos(Beta) - ForceInviscid[2]*sin(Beta)*sin(Alpha); + InvCoeff.CEff[iMarker] = InvCoeff.CL[iMarker] / (InvCoeff.CD[iMarker] + EPS); + InvCoeff.CMx[iMarker] = MomentInviscid[0]; + InvCoeff.CMy[iMarker] = MomentInviscid[1]; + InvCoeff.CMz[iMarker] = MomentInviscid[2]; + InvCoeff.CoPx[iMarker] = -MomentY_Force[0]; + InvCoeff.CoPz[iMarker] = MomentY_Force[2]; + InvCoeff.CFx[iMarker] = ForceInviscid[0]; + InvCoeff.CFy[iMarker] = ForceInviscid[1]; + InvCoeff.CFz[iMarker] = ForceInviscid[2]; + InvCoeff.CT[iMarker] = -InvCoeff.CFz[iMarker]; + InvCoeff.CQ[iMarker] = -InvCoeff.CMz[iMarker]; + InvCoeff.CMerit[iMarker] = InvCoeff.CT[iMarker] / (InvCoeff.CQ[iMarker] + EPS); } - AllBound_CD_Inv += CD_Inv[iMarker]; - AllBound_CL_Inv += CL_Inv[iMarker]; - AllBound_CSF_Inv += CSF_Inv[iMarker]; - AllBound_CEff_Inv = AllBound_CL_Inv / (AllBound_CD_Inv + EPS); - AllBound_CMx_Inv += CMx_Inv[iMarker]; - AllBound_CMy_Inv += CMy_Inv[iMarker]; - AllBound_CMz_Inv += CMz_Inv[iMarker]; - AllBound_CoPx_Inv += CoPx_Inv[iMarker]; - AllBound_CoPy_Inv += CoPy_Inv[iMarker]; - AllBound_CoPz_Inv += CoPz_Inv[iMarker]; - AllBound_CFx_Inv += CFx_Inv[iMarker]; - AllBound_CFy_Inv += CFy_Inv[iMarker]; - AllBound_CFz_Inv += CFz_Inv[iMarker]; - AllBound_CT_Inv += CT_Inv[iMarker]; - AllBound_CQ_Inv += CQ_Inv[iMarker]; - AllBound_CMerit_Inv = AllBound_CT_Inv / (AllBound_CQ_Inv + EPS); + AllBoundInvCoeff.CD += InvCoeff.CD[iMarker]; + AllBoundInvCoeff.CL += InvCoeff.CL[iMarker]; + AllBoundInvCoeff.CSF += InvCoeff.CSF[iMarker]; + AllBoundInvCoeff.CEff = AllBoundInvCoeff.CL / (AllBoundInvCoeff.CD + EPS); + AllBoundInvCoeff.CMx += InvCoeff.CMx[iMarker]; + AllBoundInvCoeff.CMy += InvCoeff.CMy[iMarker]; + AllBoundInvCoeff.CMz += InvCoeff.CMz[iMarker]; + AllBoundInvCoeff.CoPx += InvCoeff.CoPx[iMarker]; + AllBoundInvCoeff.CoPy += InvCoeff.CoPy[iMarker]; + AllBoundInvCoeff.CoPz += InvCoeff.CoPz[iMarker]; + AllBoundInvCoeff.CFx += InvCoeff.CFx[iMarker]; + AllBoundInvCoeff.CFy += InvCoeff.CFy[iMarker]; + AllBoundInvCoeff.CFz += InvCoeff.CFz[iMarker]; + AllBoundInvCoeff.CT += InvCoeff.CT[iMarker]; + AllBoundInvCoeff.CQ += InvCoeff.CQ[iMarker]; + AllBoundInvCoeff.CMerit = AllBoundInvCoeff.CT / (AllBoundInvCoeff.CQ + EPS); /*--- Compute the coefficients per surface ---*/ @@ -4440,16 +4027,16 @@ void CEulerSolver::Pressure_Forces(CGeometry *geometry, CConfig *config) { Monitoring_Tag = config->GetMarker_Monitoring_TagBound(iMarker_Monitoring); Marker_Tag = config->GetMarker_All_TagBound(iMarker); if (Marker_Tag == Monitoring_Tag) { - Surface_CL_Inv[iMarker_Monitoring] += CL_Inv[iMarker]; - Surface_CD_Inv[iMarker_Monitoring] += CD_Inv[iMarker]; - Surface_CSF_Inv[iMarker_Monitoring] += CSF_Inv[iMarker]; - Surface_CEff_Inv[iMarker_Monitoring] = CL_Inv[iMarker] / (CD_Inv[iMarker] + EPS); - Surface_CFx_Inv[iMarker_Monitoring] += CFx_Inv[iMarker]; - Surface_CFy_Inv[iMarker_Monitoring] += CFy_Inv[iMarker]; - Surface_CFz_Inv[iMarker_Monitoring] += CFz_Inv[iMarker]; - Surface_CMx_Inv[iMarker_Monitoring] += CMx_Inv[iMarker]; - Surface_CMy_Inv[iMarker_Monitoring] += CMy_Inv[iMarker]; - Surface_CMz_Inv[iMarker_Monitoring] += CMz_Inv[iMarker]; + SurfaceInvCoeff.CL[iMarker_Monitoring] += InvCoeff.CL[iMarker]; + SurfaceInvCoeff.CD[iMarker_Monitoring] += InvCoeff.CD[iMarker]; + SurfaceInvCoeff.CSF[iMarker_Monitoring] += InvCoeff.CSF[iMarker]; + SurfaceInvCoeff.CEff[iMarker_Monitoring] = InvCoeff.CL[iMarker] / (InvCoeff.CD[iMarker] + EPS); + SurfaceInvCoeff.CFx[iMarker_Monitoring] += InvCoeff.CFx[iMarker]; + SurfaceInvCoeff.CFy[iMarker_Monitoring] += InvCoeff.CFy[iMarker]; + SurfaceInvCoeff.CFz[iMarker_Monitoring] += InvCoeff.CFz[iMarker]; + SurfaceInvCoeff.CMx[iMarker_Monitoring] += InvCoeff.CMx[iMarker]; + SurfaceInvCoeff.CMy[iMarker_Monitoring] += InvCoeff.CMy[iMarker]; + SurfaceInvCoeff.CMz[iMarker_Monitoring] += InvCoeff.CMz[iMarker]; } } @@ -4478,26 +4065,26 @@ void CEulerSolver::Pressure_Forces(CGeometry *geometry, CConfig *config) { SU2_MPI::Allreduce(&tmp, &x, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); return x; }; - AllBound_CD_Inv = Allreduce(AllBound_CD_Inv); - AllBound_CL_Inv = Allreduce(AllBound_CL_Inv); - AllBound_CSF_Inv = Allreduce(AllBound_CSF_Inv); - AllBound_CEff_Inv = AllBound_CL_Inv / (AllBound_CD_Inv + EPS); - - AllBound_CMx_Inv = Allreduce(AllBound_CMx_Inv); - AllBound_CMy_Inv = Allreduce(AllBound_CMy_Inv); - AllBound_CMz_Inv = Allreduce(AllBound_CMz_Inv); - - AllBound_CoPx_Inv = Allreduce(AllBound_CoPx_Inv); - AllBound_CoPy_Inv = Allreduce(AllBound_CoPy_Inv); - AllBound_CoPz_Inv = Allreduce(AllBound_CoPz_Inv); - - AllBound_CFx_Inv = Allreduce(AllBound_CFx_Inv); - AllBound_CFy_Inv = Allreduce(AllBound_CFy_Inv); - AllBound_CFz_Inv = Allreduce(AllBound_CFz_Inv); - - AllBound_CT_Inv = Allreduce(AllBound_CT_Inv); - AllBound_CQ_Inv = Allreduce(AllBound_CQ_Inv); - AllBound_CMerit_Inv = AllBound_CT_Inv / (AllBound_CQ_Inv + EPS); + AllBoundInvCoeff.CD = Allreduce(AllBoundInvCoeff.CD); + AllBoundInvCoeff.CL = Allreduce(AllBoundInvCoeff.CL); + AllBoundInvCoeff.CSF = Allreduce(AllBoundInvCoeff.CSF); + AllBoundInvCoeff.CEff = AllBoundInvCoeff.CL / (AllBoundInvCoeff.CD + EPS); + + AllBoundInvCoeff.CMx = Allreduce(AllBoundInvCoeff.CMx); + AllBoundInvCoeff.CMy = Allreduce(AllBoundInvCoeff.CMy); + AllBoundInvCoeff.CMz = Allreduce(AllBoundInvCoeff.CMz); + + AllBoundInvCoeff.CoPx = Allreduce(AllBoundInvCoeff.CoPx); + AllBoundInvCoeff.CoPy = Allreduce(AllBoundInvCoeff.CoPy); + AllBoundInvCoeff.CoPz = Allreduce(AllBoundInvCoeff.CoPz); + + AllBoundInvCoeff.CFx = Allreduce(AllBoundInvCoeff.CFx); + AllBoundInvCoeff.CFy = Allreduce(AllBoundInvCoeff.CFy); + AllBoundInvCoeff.CFz = Allreduce(AllBoundInvCoeff.CFz); + + AllBoundInvCoeff.CT = Allreduce(AllBoundInvCoeff.CT); + AllBoundInvCoeff.CQ = Allreduce(AllBoundInvCoeff.CQ); + AllBoundInvCoeff.CMerit = AllBoundInvCoeff.CT / (AllBoundInvCoeff.CQ + EPS); AllBound_CNearFieldOF_Inv = Allreduce(AllBound_CNearFieldOF_Inv); } @@ -4518,20 +4105,20 @@ void CEulerSolver::Pressure_Forces(CGeometry *geometry, CConfig *config) { for(int i=0; iGetnMarker_Monitoring(); iMarker_Monitoring++) { - Surface_CL[iMarker_Monitoring] = Surface_CL_Inv[iMarker_Monitoring]; - Surface_CD[iMarker_Monitoring] = Surface_CD_Inv[iMarker_Monitoring]; - Surface_CSF[iMarker_Monitoring] = Surface_CSF_Inv[iMarker_Monitoring]; - Surface_CEff[iMarker_Monitoring] = Surface_CL_Inv[iMarker_Monitoring] / (Surface_CD_Inv[iMarker_Monitoring] + EPS); - Surface_CFx[iMarker_Monitoring] = Surface_CFx_Inv[iMarker_Monitoring]; - Surface_CFy[iMarker_Monitoring] = Surface_CFy_Inv[iMarker_Monitoring]; - Surface_CFz[iMarker_Monitoring] = Surface_CFz_Inv[iMarker_Monitoring]; - Surface_CMx[iMarker_Monitoring] = Surface_CMx_Inv[iMarker_Monitoring]; - Surface_CMy[iMarker_Monitoring] = Surface_CMy_Inv[iMarker_Monitoring]; - Surface_CMz[iMarker_Monitoring] = Surface_CMz_Inv[iMarker_Monitoring]; + SurfaceCoeff.CL[iMarker_Monitoring] = SurfaceInvCoeff.CL[iMarker_Monitoring]; + SurfaceCoeff.CD[iMarker_Monitoring] = SurfaceInvCoeff.CD[iMarker_Monitoring]; + SurfaceCoeff.CSF[iMarker_Monitoring] = SurfaceInvCoeff.CSF[iMarker_Monitoring]; + SurfaceCoeff.CEff[iMarker_Monitoring] = SurfaceInvCoeff.CL[iMarker_Monitoring] / (SurfaceInvCoeff.CD[iMarker_Monitoring] + EPS); + SurfaceCoeff.CFx[iMarker_Monitoring] = SurfaceInvCoeff.CFx[iMarker_Monitoring]; + SurfaceCoeff.CFy[iMarker_Monitoring] = SurfaceInvCoeff.CFy[iMarker_Monitoring]; + SurfaceCoeff.CFz[iMarker_Monitoring] = SurfaceInvCoeff.CFz[iMarker_Monitoring]; + SurfaceCoeff.CMx[iMarker_Monitoring] = SurfaceInvCoeff.CMx[iMarker_Monitoring]; + SurfaceCoeff.CMy[iMarker_Monitoring] = SurfaceInvCoeff.CMy[iMarker_Monitoring]; + SurfaceCoeff.CMz[iMarker_Monitoring] = SurfaceInvCoeff.CMz[iMarker_Monitoring]; } } @@ -4580,12 +4167,9 @@ void CEulerSolver::Momentum_Forces(CGeometry *geometry, CConfig *config) { unsigned long iVertex, iPoint; unsigned short iDim, iMarker, Boundary, Monitoring, iMarker_Monitoring; - su2double MomentDist[3] = {0.0,0.0,0.0}, Area, - factor, RefVel2, RefTemp, RefDensity, Mach2Vel, Mach_Motion, - Force[3] = {0.0,0.0,0.0}, Velocity[3] = {0.0,0.0,0.0}, MassFlow, Density; + su2double Area, factor, RefVel2, RefTemp, RefDensity, Mach2Vel, Mach_Motion, MassFlow, Density; const su2double *Normal = nullptr, *Coord = nullptr; string Marker_Tag, Monitoring_Tag; - su2double MomentX_Force[3] = {0.0,0.0,0.0}, MomentY_Force[3] = {0.0,0.0,0.0}, MomentZ_Force[3] = {0.0,0.0,0.0}; su2double AxiFactor; su2double Alpha = config->GetAoA()*PI_NUMBER/180.0; @@ -4621,19 +4205,8 @@ void CEulerSolver::Momentum_Forces(CGeometry *geometry, CConfig *config) { /*-- Variables initialization ---*/ - AllBound_CD_Mnt = 0.0; AllBound_CL_Mnt = 0.0; AllBound_CSF_Mnt = 0.0; - AllBound_CMx_Mnt = 0.0; AllBound_CMy_Mnt = 0.0; AllBound_CMz_Mnt = 0.0; - AllBound_CoPx_Mnt = 0.0; AllBound_CoPy_Mnt = 0.0; AllBound_CoPz_Mnt = 0.0; - AllBound_CFx_Mnt = 0.0; AllBound_CFy_Mnt = 0.0; AllBound_CFz_Mnt = 0.0; - AllBound_CT_Mnt = 0.0; AllBound_CQ_Mnt = 0.0; AllBound_CMerit_Mnt = 0.0; - AllBound_CEff_Mnt = 0.0; - - for (iMarker_Monitoring = 0; iMarker_Monitoring < config->GetnMarker_Monitoring(); iMarker_Monitoring++) { - Surface_CL_Mnt[iMarker_Monitoring] = 0.0; Surface_CD_Mnt[iMarker_Monitoring] = 0.0; - Surface_CSF_Mnt[iMarker_Monitoring] = 0.0; Surface_CEff_Mnt[iMarker_Monitoring] = 0.0; - Surface_CFx_Mnt[iMarker_Monitoring] = 0.0; Surface_CFy_Mnt[iMarker_Monitoring] = 0.0; Surface_CFz_Mnt[iMarker_Monitoring] = 0.0; - Surface_CMx_Mnt[iMarker_Monitoring] = 0.0; Surface_CMy_Mnt[iMarker_Monitoring] = 0.0; Surface_CMz_Mnt[iMarker_Monitoring] = 0.0; - } + AllBoundMntCoeff.setZero(); + SurfaceMntCoeff.setZero(); /*--- Loop over the Inlet -Outlet Markers ---*/ @@ -4659,18 +4232,10 @@ void CEulerSolver::Momentum_Forces(CGeometry *geometry, CConfig *config) { /*--- Forces initialization at each Marker ---*/ - CD_Mnt[iMarker] = 0.0; CL_Mnt[iMarker] = 0.0; CSF_Mnt[iMarker] = 0.0; - CFx_Mnt[iMarker] = 0.0; CFy_Mnt[iMarker] = 0.0; CFz_Mnt[iMarker] = 0.0; - CMx_Mnt[iMarker] = 0.0; CMy_Mnt[iMarker] = 0.0; CMz_Mnt[iMarker] = 0.0; - CoPx_Mnt[iMarker] = 0.0; CoPy_Mnt[iMarker] = 0.0; CoPz_Mnt[iMarker] = 0.0; - CT_Mnt[iMarker] = 0.0; CQ_Mnt[iMarker] = 0.0; CMerit_Mnt[iMarker] = 0.0; - CEff_Mnt[iMarker] = 0.0; + MntCoeff.setZero(iMarker); - for (iDim = 0; iDim < nDim; iDim++) ForceMomentum[iDim] = 0.0; - MomentMomentum[0] = 0.0; MomentMomentum[1] = 0.0; MomentMomentum[2] = 0.0; - MomentX_Force[0] = 0.0; MomentX_Force[1] = 0.0; MomentX_Force[2] = 0.0; - MomentY_Force[0] = 0.0; MomentY_Force[1] = 0.0; MomentY_Force[2] = 0.0; - MomentZ_Force[0] = 0.0; MomentZ_Force[1] = 0.0; MomentZ_Force[2] = 0.0; + su2double ForceMomentum[MAXNDIM] = {0.0}, MomentMomentum[MAXNDIM] = {0.0}; + su2double MomentX_Force[3] = {0.0}, MomentY_Force[3] = {0.0}, MomentZ_Force[3] = {0.0}; /*--- Loop over the vertices to compute the forces ---*/ @@ -4693,6 +4258,7 @@ void CEulerSolver::Momentum_Forces(CGeometry *geometry, CConfig *config) { Area = 0.0; for (iDim = 0; iDim < nDim; iDim++) Area += Normal[iDim]*Normal[iDim]; Area = sqrt(Area); MassFlow = 0.0; + su2double Velocity[MAXNDIM] = {0.0}, MomentDist[MAXNDIM] = {0.0}; for (iDim = 0; iDim < nDim; iDim++) { Velocity[iDim] = nodes->GetVelocity(iPoint,iDim); MomentDist[iDim] = Coord[iDim] - Origin[iDim]; @@ -4707,6 +4273,7 @@ void CEulerSolver::Momentum_Forces(CGeometry *geometry, CConfig *config) { /*--- Force computation, note the minus sign due to the orientation of the normal (outward) ---*/ + su2double Force[MAXNDIM] = {0.0}; for (iDim = 0; iDim < nDim; iDim++) { Force[iDim] = MassFlow * Velocity[iDim] * factor * AxiFactor; ForceMomentum[iDim] += Force[iDim]; @@ -4736,51 +4303,52 @@ void CEulerSolver::Momentum_Forces(CGeometry *geometry, CConfig *config) { if (Monitoring == YES) { if (nDim == 2) { - CD_Mnt[iMarker] = ForceMomentum[0]*cos(Alpha) + ForceMomentum[1]*sin(Alpha); - CL_Mnt[iMarker] = -ForceMomentum[0]*sin(Alpha) + ForceMomentum[1]*cos(Alpha); - CEff_Mnt[iMarker] = CL_Mnt[iMarker] / (CD_Mnt[iMarker]+EPS); - CFx_Mnt[iMarker] = ForceMomentum[0]; - CFy_Mnt[iMarker] = ForceMomentum[1]; - CMz_Mnt[iMarker] = MomentMomentum[2]; - CoPx_Mnt[iMarker] = MomentZ_Force[1]; - CoPy_Mnt[iMarker] = -MomentZ_Force[0]; - CT_Mnt[iMarker] = -CFx_Mnt[iMarker]; - CQ_Mnt[iMarker] = -CMz_Mnt[iMarker]; - CMerit_Mnt[iMarker] = CT_Mnt[iMarker] / (CQ_Mnt[iMarker] + EPS); + MntCoeff.CD[iMarker] = ForceMomentum[0]*cos(Alpha) + ForceMomentum[1]*sin(Alpha); + MntCoeff.CL[iMarker] = -ForceMomentum[0]*sin(Alpha) + ForceMomentum[1]*cos(Alpha); + MntCoeff.CEff[iMarker] = MntCoeff.CL[iMarker] / (MntCoeff.CD[iMarker]+EPS); + MntCoeff.CFx[iMarker] = ForceMomentum[0]; + MntCoeff.CFy[iMarker] = ForceMomentum[1]; + MntCoeff.CMz[iMarker] = MomentMomentum[2]; + MntCoeff.CoPx[iMarker] = MomentZ_Force[1]; + MntCoeff.CoPy[iMarker] = -MomentZ_Force[0]; + MntCoeff.CT[iMarker] = -MntCoeff.CFx[iMarker]; + MntCoeff.CQ[iMarker] = -MntCoeff.CMz[iMarker]; + MntCoeff.CMerit[iMarker] = MntCoeff.CT[iMarker] / (MntCoeff.CQ[iMarker] + EPS); } if (nDim == 3) { - CD_Mnt[iMarker] = ForceMomentum[0]*cos(Alpha)*cos(Beta) + ForceMomentum[1]*sin(Beta) + ForceMomentum[2]*sin(Alpha)*cos(Beta); - CL_Mnt[iMarker] = -ForceMomentum[0]*sin(Alpha) + ForceMomentum[2]*cos(Alpha); - CSF_Mnt[iMarker] = -ForceMomentum[0]*sin(Beta)*cos(Alpha) + ForceMomentum[1]*cos(Beta) - ForceMomentum[2]*sin(Beta)*sin(Alpha); - CEff_Mnt[iMarker] = CL_Mnt[iMarker] / (CD_Mnt[iMarker] + EPS); - CFx_Mnt[iMarker] = ForceMomentum[0]; - CFy_Mnt[iMarker] = ForceMomentum[1]; - CFz_Mnt[iMarker] = ForceMomentum[2]; - CMx_Mnt[iMarker] = MomentMomentum[0]; - CMy_Mnt[iMarker] = MomentMomentum[1]; - CMz_Mnt[iMarker] = MomentMomentum[2]; - CoPx_Mnt[iMarker] = -MomentY_Force[0]; - CoPz_Mnt[iMarker] = MomentY_Force[2]; - CT_Mnt[iMarker] = -CFz_Mnt[iMarker]; - CQ_Mnt[iMarker] = -CMz_Mnt[iMarker]; - CMerit_Mnt[iMarker] = CT_Mnt[iMarker] / (CQ_Mnt[iMarker] + EPS); + MntCoeff.CD[iMarker] = ForceMomentum[0]*cos(Alpha)*cos(Beta) + ForceMomentum[1]*sin(Beta) + ForceMomentum[2]*sin(Alpha)*cos(Beta); + MntCoeff.CL[iMarker] = -ForceMomentum[0]*sin(Alpha) + ForceMomentum[2]*cos(Alpha); + MntCoeff.CSF[iMarker] = -ForceMomentum[0]*sin(Beta)*cos(Alpha) + ForceMomentum[1]*cos(Beta) - ForceMomentum[2]*sin(Beta)*sin(Alpha); + MntCoeff.CEff[iMarker] = MntCoeff.CL[iMarker] / (MntCoeff.CD[iMarker] + EPS); + MntCoeff.CFx[iMarker] = ForceMomentum[0]; + MntCoeff.CFy[iMarker] = ForceMomentum[1]; + MntCoeff.CFz[iMarker] = ForceMomentum[2]; + MntCoeff.CMx[iMarker] = MomentMomentum[0]; + MntCoeff.CMy[iMarker] = MomentMomentum[1]; + MntCoeff.CMz[iMarker] = MomentMomentum[2]; + MntCoeff.CoPx[iMarker] = -MomentY_Force[0]; + MntCoeff.CoPz[iMarker] = MomentY_Force[2]; + MntCoeff.CT[iMarker] = -MntCoeff.CFz[iMarker]; + MntCoeff.CQ[iMarker] = -MntCoeff.CMz[iMarker]; + MntCoeff.CMerit[iMarker] = MntCoeff.CT[iMarker] / (MntCoeff.CQ[iMarker] + EPS); } - AllBound_CD_Mnt += CD_Mnt[iMarker]; - AllBound_CL_Mnt += CL_Mnt[iMarker]; - AllBound_CSF_Mnt += CSF_Mnt[iMarker]; - AllBound_CEff_Mnt = AllBound_CL_Mnt / (AllBound_CD_Mnt + EPS); - AllBound_CFx_Mnt += CFx_Mnt[iMarker]; - AllBound_CFy_Mnt += CFy_Mnt[iMarker]; - AllBound_CFz_Mnt += CFz_Mnt[iMarker]; - AllBound_CMx_Mnt += CMx_Mnt[iMarker]; - AllBound_CMy_Mnt += CMy_Mnt[iMarker]; - AllBound_CMz_Mnt += CMz_Mnt[iMarker]; - AllBound_CoPy_Mnt += CoPy_Mnt[iMarker]; - AllBound_CoPz_Mnt += CoPz_Mnt[iMarker]; - AllBound_CT_Mnt += CT_Mnt[iMarker]; - AllBound_CQ_Mnt += CQ_Mnt[iMarker]; - AllBound_CMerit_Mnt += AllBound_CT_Mnt / (AllBound_CQ_Mnt + EPS); + AllBoundMntCoeff.CD += MntCoeff.CD[iMarker]; + AllBoundMntCoeff.CL += MntCoeff.CL[iMarker]; + AllBoundMntCoeff.CSF += MntCoeff.CSF[iMarker]; + AllBoundMntCoeff.CEff = AllBoundMntCoeff.CL / (AllBoundMntCoeff.CD + EPS); + AllBoundMntCoeff.CFx += MntCoeff.CFx[iMarker]; + AllBoundMntCoeff.CFy += MntCoeff.CFy[iMarker]; + AllBoundMntCoeff.CFz += MntCoeff.CFz[iMarker]; + AllBoundMntCoeff.CMx += MntCoeff.CMx[iMarker]; + AllBoundMntCoeff.CMy += MntCoeff.CMy[iMarker]; + AllBoundMntCoeff.CMx += MntCoeff.CMz[iMarker]; + AllBoundMntCoeff.CoPx += MntCoeff.CoPx[iMarker]; + AllBoundMntCoeff.CoPy += MntCoeff.CoPy[iMarker]; + AllBoundMntCoeff.CoPz += MntCoeff.CoPz[iMarker]; + AllBoundMntCoeff.CT += MntCoeff.CT[iMarker]; + AllBoundMntCoeff.CQ += MntCoeff.CQ[iMarker]; + AllBoundMntCoeff.CMerit += AllBoundMntCoeff.CT / (AllBoundMntCoeff.CQ + EPS); /*--- Compute the coefficients per surface ---*/ @@ -4788,16 +4356,16 @@ void CEulerSolver::Momentum_Forces(CGeometry *geometry, CConfig *config) { Monitoring_Tag = config->GetMarker_Monitoring_TagBound(iMarker_Monitoring); Marker_Tag = config->GetMarker_All_TagBound(iMarker); if (Marker_Tag == Monitoring_Tag) { - Surface_CL_Mnt[iMarker_Monitoring] += CL_Mnt[iMarker]; - Surface_CD_Mnt[iMarker_Monitoring] += CD_Mnt[iMarker]; - Surface_CSF_Mnt[iMarker_Monitoring] += CSF_Mnt[iMarker]; - Surface_CEff_Mnt[iMarker_Monitoring] = CL_Mnt[iMarker] / (CD_Mnt[iMarker] + EPS); - Surface_CFx_Mnt[iMarker_Monitoring] += CFx_Mnt[iMarker]; - Surface_CFy_Mnt[iMarker_Monitoring] += CFy_Mnt[iMarker]; - Surface_CFz_Mnt[iMarker_Monitoring] += CFz_Mnt[iMarker]; - Surface_CMx_Mnt[iMarker_Monitoring] += CMx_Mnt[iMarker]; - Surface_CMy_Mnt[iMarker_Monitoring] += CMy_Mnt[iMarker]; - Surface_CMz_Mnt[iMarker_Monitoring] += CMz_Mnt[iMarker]; + SurfaceMntCoeff.CL[iMarker_Monitoring] += MntCoeff.CL[iMarker]; + SurfaceMntCoeff.CD[iMarker_Monitoring] += MntCoeff.CD[iMarker]; + SurfaceMntCoeff.CSF[iMarker_Monitoring] += MntCoeff.CSF[iMarker]; + SurfaceMntCoeff.CEff[iMarker_Monitoring] = MntCoeff.CL[iMarker] / (MntCoeff.CD[iMarker] + EPS); + SurfaceMntCoeff.CFx[iMarker_Monitoring] += MntCoeff.CFx[iMarker]; + SurfaceMntCoeff.CFy[iMarker_Monitoring] += MntCoeff.CFy[iMarker]; + SurfaceMntCoeff.CFz[iMarker_Monitoring] += MntCoeff.CFz[iMarker]; + SurfaceMntCoeff.CMx[iMarker_Monitoring] += MntCoeff.CMx[iMarker]; + SurfaceMntCoeff.CMy[iMarker_Monitoring] += MntCoeff.CMy[iMarker]; + SurfaceMntCoeff.CMz[iMarker_Monitoring] += MntCoeff.CMz[iMarker]; } } @@ -4818,26 +4386,26 @@ void CEulerSolver::Momentum_Forces(CGeometry *geometry, CConfig *config) { return x; }; - AllBound_CD_Mnt = Allreduce(AllBound_CD_Mnt); - AllBound_CL_Mnt = Allreduce(AllBound_CL_Mnt); - AllBound_CSF_Mnt = Allreduce(AllBound_CSF_Mnt); - AllBound_CEff_Mnt = AllBound_CL_Mnt / (AllBound_CD_Mnt + EPS); + AllBoundMntCoeff.CD = Allreduce(AllBoundMntCoeff.CD); + AllBoundMntCoeff.CL = Allreduce(AllBoundMntCoeff.CL); + AllBoundMntCoeff.CSF = Allreduce(AllBoundMntCoeff.CSF); + AllBoundMntCoeff.CEff = AllBoundMntCoeff.CL / (AllBoundMntCoeff.CD + EPS); - AllBound_CFx_Mnt = Allreduce(AllBound_CFx_Mnt); - AllBound_CFy_Mnt = Allreduce(AllBound_CFy_Mnt); - AllBound_CFz_Mnt = Allreduce(AllBound_CFz_Mnt); + AllBoundMntCoeff.CFx = Allreduce(AllBoundMntCoeff.CFx); + AllBoundMntCoeff.CFy = Allreduce(AllBoundMntCoeff.CFy); + AllBoundMntCoeff.CFz = Allreduce(AllBoundMntCoeff.CFz); - AllBound_CMx_Mnt = Allreduce(AllBound_CMx_Mnt); - AllBound_CMy_Mnt = Allreduce(AllBound_CMy_Mnt); - AllBound_CMz_Mnt = Allreduce(AllBound_CMz_Mnt); + AllBoundMntCoeff.CMx = Allreduce(AllBoundMntCoeff.CMx); + AllBoundMntCoeff.CMy = Allreduce(AllBoundMntCoeff.CMy); + AllBoundMntCoeff.CMz = Allreduce(AllBoundMntCoeff.CMz); - AllBound_CoPx_Mnt = Allreduce(AllBound_CoPx_Mnt); - AllBound_CoPy_Mnt = Allreduce(AllBound_CoPy_Mnt); - AllBound_CoPz_Mnt = Allreduce(AllBound_CoPz_Mnt); + AllBoundMntCoeff.CoPx = Allreduce(AllBoundMntCoeff.CoPx); + AllBoundMntCoeff.CoPy = Allreduce(AllBoundMntCoeff.CoPy); + AllBoundMntCoeff.CoPz = Allreduce(AllBoundMntCoeff.CoPz); - AllBound_CT_Mnt = Allreduce(AllBound_CT_Mnt); - AllBound_CQ_Mnt = Allreduce(AllBound_CQ_Mnt); - AllBound_CMerit_Mnt = AllBound_CT_Mnt / (AllBound_CQ_Mnt + EPS); + AllBoundMntCoeff.CT = Allreduce(AllBoundMntCoeff.CT); + AllBoundMntCoeff.CQ = Allreduce(AllBoundMntCoeff.CQ); + AllBoundMntCoeff.CMerit = AllBoundMntCoeff.CT / (AllBoundMntCoeff.CQ + EPS); } @@ -4857,20 +4425,20 @@ void CEulerSolver::Momentum_Forces(CGeometry *geometry, CConfig *config) { for(int i=0; iGetnMarker_Monitoring(); iMarker_Monitoring++) { - Surface_CL[iMarker_Monitoring] += Surface_CL_Mnt[iMarker_Monitoring]; - Surface_CD[iMarker_Monitoring] += Surface_CD_Mnt[iMarker_Monitoring]; - Surface_CSF[iMarker_Monitoring] += Surface_CSF_Mnt[iMarker_Monitoring]; - Surface_CEff[iMarker_Monitoring] += Surface_CL_Mnt[iMarker_Monitoring] / (Surface_CD_Mnt[iMarker_Monitoring] + EPS); - Surface_CFx[iMarker_Monitoring] += Surface_CFx_Mnt[iMarker_Monitoring]; - Surface_CFy[iMarker_Monitoring] += Surface_CFy_Mnt[iMarker_Monitoring]; - Surface_CFz[iMarker_Monitoring] += Surface_CFz_Mnt[iMarker_Monitoring]; - Surface_CMx[iMarker_Monitoring] += Surface_CMx_Mnt[iMarker_Monitoring]; - Surface_CMy[iMarker_Monitoring] += Surface_CMy_Mnt[iMarker_Monitoring]; - Surface_CMz[iMarker_Monitoring] += Surface_CMz_Mnt[iMarker_Monitoring]; + SurfaceCoeff.CL[iMarker_Monitoring] += SurfaceMntCoeff.CL[iMarker_Monitoring]; + SurfaceCoeff.CD[iMarker_Monitoring] += SurfaceMntCoeff.CD[iMarker_Monitoring]; + SurfaceCoeff.CSF[iMarker_Monitoring] += SurfaceMntCoeff.CSF[iMarker_Monitoring]; + SurfaceCoeff.CEff[iMarker_Monitoring] += SurfaceMntCoeff.CL[iMarker_Monitoring] / (SurfaceMntCoeff.CD[iMarker_Monitoring] + EPS); + SurfaceCoeff.CFx[iMarker_Monitoring] += SurfaceMntCoeff.CFx[iMarker_Monitoring]; + SurfaceCoeff.CFy[iMarker_Monitoring] += SurfaceMntCoeff.CFy[iMarker_Monitoring]; + SurfaceCoeff.CFz[iMarker_Monitoring] += SurfaceMntCoeff.CFz[iMarker_Monitoring]; + SurfaceCoeff.CMx[iMarker_Monitoring] += SurfaceMntCoeff.CMx[iMarker_Monitoring]; + SurfaceCoeff.CMy[iMarker_Monitoring] += SurfaceMntCoeff.CMy[iMarker_Monitoring]; + SurfaceCoeff.CMz[iMarker_Monitoring] += SurfaceMntCoeff.CMz[iMarker_Monitoring]; } } @@ -6720,11 +6288,11 @@ void CEulerSolver::SetFarfield_AoA(CGeometry *geometry, CSolver **solver_contain SetCoefficient_Gradients(config); - Total_CD_Prev = Total_CD; - Total_CL_Prev = Total_CL; - Total_CMx_Prev = Total_CMx; - Total_CMy_Prev = Total_CMy; - Total_CMz_Prev = Total_CMz; + Total_CD_Prev = TotalCoeff.CD; + Total_CL_Prev = TotalCoeff.CL; + Total_CMx_Prev = TotalCoeff.CMx; + Total_CMy_Prev = TotalCoeff.CMy; + Total_CMz_Prev = TotalCoeff.CMz; AoA_Prev = AoA; /*--- Compute a new value for AoA on the fine mesh only (degrees)---*/ @@ -6793,7 +6361,7 @@ bool CEulerSolver::FixedCL_Convergence(CConfig* config, bool convergence) { /* --- C_L and solution are converged, start finite differencing --- */ - if (fabs(Total_CL-Target_CL) < (config->GetCauchy_Eps()/2)) { + if (fabs(TotalCoeff.CL-Target_CL) < (config->GetCauchy_Eps()/2)) { /* --- If no finite differencing required --- */ @@ -6816,8 +6384,8 @@ bool CEulerSolver::FixedCL_Convergence(CConfig* config, bool convergence) { else if ((curr_iter - Iter_Update_AoA) > config->GetStartConv_Iter()){ Iter_Update_AoA = curr_iter; fixed_cl_conv = false; - if (fabs(Total_CL-Target_CL) > (config->GetCauchy_Eps()/2)) { - AoA_inc = (1.0/dCL_dAlpha)*(Target_CL - Total_CL); + if (fabs(TotalCoeff.CL-Target_CL) > (config->GetCauchy_Eps()/2)) { + AoA_inc = (1.0/dCL_dAlpha)*(Target_CL - TotalCoeff.CL); } } } @@ -6827,8 +6395,8 @@ bool CEulerSolver::FixedCL_Convergence(CConfig* config, bool convergence) { else if ((curr_iter - Iter_Update_AoA) == config->GetUpdate_AoA_Iter_Limit()) { Iter_Update_AoA = curr_iter; fixed_cl_conv = false; - if (fabs(Total_CL-Target_CL) > (config->GetCauchy_Eps()/2)) { - AoA_inc = (1.0/dCL_dAlpha)*(Target_CL - Total_CL); + if (fabs(TotalCoeff.CL-Target_CL) > (config->GetCauchy_Eps()/2)) { + AoA_inc = (1.0/dCL_dAlpha)*(Target_CL - TotalCoeff.CL); } } @@ -6888,11 +6456,11 @@ void CEulerSolver::SetCoefficient_Gradients(CConfig *config){ if (AoA != AoA_Prev) { /* --- Calculate gradients of coefficients w.r.t. CL --- */ - dCL_dAlpha_ = (Total_CL-Total_CL_Prev)/(AoA - AoA_Prev); - dCD_dCL_ = (Total_CD-Total_CD_Prev)/(Total_CL-Total_CL_Prev); - dCMx_dCL_ = (Total_CMx-Total_CMx_Prev)/(Total_CL-Total_CL_Prev); - dCMy_dCL_ = (Total_CMy-Total_CMy_Prev)/(Total_CL-Total_CL_Prev); - dCMz_dCL_ = (Total_CMz-Total_CMz_Prev)/(Total_CL-Total_CL_Prev); + dCL_dAlpha_ = (TotalCoeff.CL-Total_CL_Prev)/(AoA - AoA_Prev); + dCD_dCL_ = (TotalCoeff.CD-Total_CD_Prev)/(TotalCoeff.CL-Total_CL_Prev); + dCMx_dCL_ = (TotalCoeff.CMx-Total_CMx_Prev)/(TotalCoeff.CL-Total_CL_Prev); + dCMy_dCL_ = (TotalCoeff.CMy-Total_CMy_Prev)/(TotalCoeff.CL-Total_CL_Prev); + dCMz_dCL_ = (TotalCoeff.CMz-Total_CMz_Prev)/(TotalCoeff.CL-Total_CL_Prev); /*--- Set the value of the dOF/dCL in the config file ---*/ @@ -7079,39 +6647,39 @@ void CEulerSolver::Evaluate_ObjFunc(CConfig *config) { switch(Kind_ObjFunc) { case DRAG_COEFFICIENT: - Total_ComboObj+=Weight_ObjFunc*(Surface_CD[iMarker_Monitoring]); - if (config->GetFixed_CL_Mode()) Total_ComboObj -= Weight_ObjFunc*config->GetdCD_dCL()*(Surface_CL[iMarker_Monitoring]); - if (config->GetFixed_CM_Mode()) Total_ComboObj -= Weight_ObjFunc*config->GetdCD_dCMy()*(Surface_CMy[iMarker_Monitoring]); + Total_ComboObj+=Weight_ObjFunc*(SurfaceCoeff.CD[iMarker_Monitoring]); + if (config->GetFixed_CL_Mode()) Total_ComboObj -= Weight_ObjFunc*config->GetdCD_dCL()*(SurfaceCoeff.CL[iMarker_Monitoring]); + if (config->GetFixed_CM_Mode()) Total_ComboObj -= Weight_ObjFunc*config->GetdCD_dCMy()*(SurfaceCoeff.CMy[iMarker_Monitoring]); break; case LIFT_COEFFICIENT: - Total_ComboObj+=Weight_ObjFunc*(Surface_CL[iMarker_Monitoring]); + Total_ComboObj+=Weight_ObjFunc*(SurfaceCoeff.CL[iMarker_Monitoring]); break; case SIDEFORCE_COEFFICIENT: - Total_ComboObj+=Weight_ObjFunc*(Surface_CSF[iMarker_Monitoring]); + Total_ComboObj+=Weight_ObjFunc*(SurfaceCoeff.CSF[iMarker_Monitoring]); break; case EFFICIENCY: - Total_ComboObj+=Weight_ObjFunc*(Surface_CEff[iMarker_Monitoring]); + Total_ComboObj+=Weight_ObjFunc*(SurfaceCoeff.CEff[iMarker_Monitoring]); break; case MOMENT_X_COEFFICIENT: - Total_ComboObj+=Weight_ObjFunc*(Surface_CMx[iMarker_Monitoring]); - if (config->GetFixed_CL_Mode()) Total_ComboObj -= Weight_ObjFunc*config->GetdCMx_dCL()*(Surface_CL[iMarker_Monitoring]); + Total_ComboObj+=Weight_ObjFunc*(SurfaceCoeff.CMx[iMarker_Monitoring]); + if (config->GetFixed_CL_Mode()) Total_ComboObj -= Weight_ObjFunc*config->GetdCMx_dCL()*(SurfaceCoeff.CL[iMarker_Monitoring]); break; case MOMENT_Y_COEFFICIENT: - Total_ComboObj+=Weight_ObjFunc*(Surface_CMy[iMarker_Monitoring]); - if (config->GetFixed_CL_Mode()) Total_ComboObj -= Weight_ObjFunc*config->GetdCMy_dCL()*(Surface_CL[iMarker_Monitoring]); + Total_ComboObj+=Weight_ObjFunc*(SurfaceCoeff.CMy[iMarker_Monitoring]); + if (config->GetFixed_CL_Mode()) Total_ComboObj -= Weight_ObjFunc*config->GetdCMy_dCL()*(SurfaceCoeff.CL[iMarker_Monitoring]); break; case MOMENT_Z_COEFFICIENT: - Total_ComboObj+=Weight_ObjFunc*(Surface_CMz[iMarker_Monitoring]); - if (config->GetFixed_CL_Mode()) Total_ComboObj -= Weight_ObjFunc*config->GetdCMz_dCL()*(Surface_CL[iMarker_Monitoring]); + Total_ComboObj+=Weight_ObjFunc*(SurfaceCoeff.CMz[iMarker_Monitoring]); + if (config->GetFixed_CL_Mode()) Total_ComboObj -= Weight_ObjFunc*config->GetdCMz_dCL()*(SurfaceCoeff.CL[iMarker_Monitoring]); break; case FORCE_X_COEFFICIENT: - Total_ComboObj+=Weight_ObjFunc*Surface_CFx[iMarker_Monitoring]; + Total_ComboObj+=Weight_ObjFunc*SurfaceCoeff.CFx[iMarker_Monitoring]; break; case FORCE_Y_COEFFICIENT: - Total_ComboObj+=Weight_ObjFunc*Surface_CFy[iMarker_Monitoring]; + Total_ComboObj+=Weight_ObjFunc*SurfaceCoeff.CFy[iMarker_Monitoring]; break; case FORCE_Z_COEFFICIENT: - Total_ComboObj+=Weight_ObjFunc*Surface_CFz[iMarker_Monitoring]; + Total_ComboObj+=Weight_ObjFunc*SurfaceCoeff.CFz[iMarker_Monitoring]; break; case TOTAL_HEATFLUX: Total_ComboObj+=Weight_ObjFunc*Surface_HF_Visc[iMarker_Monitoring]; @@ -7146,13 +6714,13 @@ void CEulerSolver::Evaluate_ObjFunc(CConfig *config) { Total_ComboObj+=Weight_ObjFunc*Total_HeatFluxDiff; break; case THRUST_COEFFICIENT: - Total_ComboObj+=Weight_ObjFunc*Total_CT; + Total_ComboObj+=Weight_ObjFunc*TotalCoeff.CT; break; case TORQUE_COEFFICIENT: - Total_ComboObj+=Weight_ObjFunc*Total_CQ; + Total_ComboObj+=Weight_ObjFunc*TotalCoeff.CQ; break; case FIGURE_OF_MERIT: - Total_ComboObj+=Weight_ObjFunc*Total_CMerit; + Total_ComboObj+=Weight_ObjFunc*TotalCoeff.CMerit; break; case SURFACE_TOTAL_PRESSURE: Total_ComboObj+=Weight_ObjFunc*config->GetSurface_TotalPressure(0); @@ -12481,7 +12049,6 @@ void CEulerSolver::TurboAverageProcess(CSolver **solver, CGeometry *geometry, CC Omega = 0.0; Kine = 0.0; - for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++){ for (iMarkerTP=1; iMarkerTP < config->GetnMarker_Turbomachinery()+1; iMarkerTP++){ if (config->GetMarker_All_Turbomachinery(iMarker) == iMarkerTP){ @@ -12688,7 +12255,6 @@ void CEulerSolver::TurboAverageProcess(CSolver **solver, CGeometry *geometry, CC #endif - for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++){ for (iMarkerTP=1; iMarkerTP < config->GetnMarker_Turbomachinery()+1; iMarkerTP++){ if (config->GetMarker_All_Turbomachinery(iMarker) == iMarkerTP){ @@ -12698,8 +12264,6 @@ void CEulerSolver::TurboAverageProcess(CSolver **solver, CGeometry *geometry, CC AverageTurboNormal = geometry->GetAverageTurboNormal(iMarker,iSpan); nVert = geometry->GetnTotVertexSpan(iMarker,iSpan); - - /*--- compute normal Mach number as a check for massflow average and mixedout average ---*/ GetFluidModel()->SetTDState_Prho(TotalAreaPressure/TotalArea, TotalAreaDensity / TotalArea); soundSpeed = GetFluidModel()->GetSoundSpeed(); @@ -12938,8 +12502,6 @@ void CEulerSolver::TurboAverageProcess(CSolver **solver, CGeometry *geometry, CC } } - - /*--- Compute Outlet Static Pressure if Radial equilibrium is imposed ---*/ for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++){ @@ -13055,7 +12617,6 @@ void CEulerSolver::MixedOut_Average (CConfig *config, su2double val_init_pressur density_mix = val_Averaged_Flux[0]*val_Averaged_Flux[0]/(val_Averaged_Flux[1] - pressure_mix); - delete [] vel; } diff --git a/SU2_CFD/src/solvers/CNSSolver.cpp b/SU2_CFD/src/solvers/CNSSolver.cpp index dc582e8f96e6..5d023707b2e2 100644 --- a/SU2_CFD/src/solvers/CNSSolver.cpp +++ b/SU2_CFD/src/solvers/CNSSolver.cpp @@ -30,44 +30,7 @@ #include "../../include/variables/CNSVariable.hpp" #include "../../../Common/include/toolboxes/printing_toolbox.hpp" -CNSSolver::CNSSolver(void) : CEulerSolver() { - - /*--- Basic array initialization ---*/ - - CD_Visc = NULL; CL_Visc = NULL; CSF_Visc = NULL; CEff_Visc = NULL; - CFx_Visc = NULL; CFy_Visc = NULL; CFz_Visc = NULL; - CMx_Visc = NULL; CMy_Visc = NULL; CMz_Visc = NULL; - CoPx_Visc = NULL; CoPy_Visc = NULL; CoPz_Visc = NULL; - - ForceViscous = NULL; MomentViscous = NULL; CSkinFriction = NULL; - - Buffet_Sensor = NULL; Buffet_Metric = NULL; - - /*--- Surface based array initialization ---*/ - - Surface_CL_Visc = NULL; Surface_CD_Visc = NULL; Surface_CSF_Visc = NULL; Surface_CEff_Visc = NULL; - Surface_CFx_Visc = NULL; Surface_CFy_Visc = NULL; Surface_CFz_Visc = NULL; - Surface_CMx_Visc = NULL; Surface_CMy_Visc = NULL; Surface_CMz_Visc = NULL; - Surface_HF_Visc = NULL; Surface_MaxHF_Visc = NULL; Surface_Buffet_Metric = NULL; - - /*--- Rotorcraft simulation array initialization ---*/ - - CMerit_Visc = NULL; CT_Visc = NULL; CQ_Visc = NULL; - HF_Visc = NULL; MaxHF_Visc = NULL; - - /*--- Inlet Variables ---*/ - Inlet_Ttotal = NULL; - Inlet_Ptotal = NULL; - Inlet_FlowDir = NULL; - - SlidingState = NULL; - SlidingStateNodes = NULL; - - DonorPrimVar = NULL; DonorGlobalIndex = NULL; - - HeatConjugateVar = NULL; - -} +CNSSolver::CNSSolver(void) : CEulerSolver() { } CNSSolver::CNSSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) : CEulerSolver() { @@ -78,11 +41,11 @@ CNSSolver::CNSSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) unsigned short nZone = geometry->GetnZone(); bool restart = (config->GetRestart() || config->GetRestart_Flow()); int Unst_RestartIter = 0; - bool dual_time = ((config->GetTime_Marching() == DT_STEPPING_1ST) || - (config->GetTime_Marching() == DT_STEPPING_2ND)); - bool time_stepping = config->GetTime_Marching() == TIME_STEPPING; + bool dual_time = (config->GetTime_Marching() == DT_STEPPING_1ST) || + (config->GetTime_Marching() == DT_STEPPING_2ND); + bool time_stepping = (config->GetTime_Marching() == TIME_STEPPING); - /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ + /*--- A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain ---*/ dynamic_grid = config->GetDynamic_Grid(); bool adjoint = (config->GetContinuous_Adjoint()) || (config->GetDiscrete_Adjoint()); @@ -124,67 +87,6 @@ CNSSolver::CNSSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) } - /*--- Array initialization ---*/ - - CD_Visc = NULL; CL_Visc = NULL; CSF_Visc = NULL; CEff_Visc = NULL; - CFx_Visc = NULL; CFy_Visc = NULL; CFz_Visc = NULL; - CMx_Visc = NULL; CMy_Visc = NULL; CMz_Visc = NULL; - CoPx_Visc = NULL; CoPy_Visc = NULL; CoPz_Visc = NULL; - - Buffet_Sensor = NULL; Buffet_Metric = NULL; - - Surface_CL_Visc = NULL; Surface_CD_Visc = NULL; Surface_CSF_Visc = NULL; Surface_CEff_Visc = NULL; - Surface_CFx_Visc = NULL; Surface_CFy_Visc = NULL; Surface_CFz_Visc = NULL; - Surface_CMx_Visc = NULL; Surface_CMy_Visc = NULL; Surface_CMz_Visc = NULL; - Surface_HF_Visc = NULL; Surface_MaxHF_Visc = NULL; - - Surface_Buffet_Metric = NULL; - - CMerit_Visc = NULL; CT_Visc = NULL; CQ_Visc = NULL; - MaxHF_Visc = NULL; ForceViscous = NULL; MomentViscous = NULL; - CSkinFriction = NULL; HF_Visc = NULL; - HeatConjugateVar = NULL; - - /*--- Initialize quantities for the average process for internal flow ---*/ - - AverageVelocity = NULL; - AverageTurboVelocity = NULL; - OldAverageTurboVelocity = NULL; - ExtAverageTurboVelocity = NULL; - AverageFlux = NULL; - SpanTotalFlux = NULL; - AveragePressure = NULL; - OldAveragePressure = NULL; - RadialEquilibriumPressure = NULL; - ExtAveragePressure = NULL; - AverageDensity = NULL; - OldAverageDensity = NULL; - ExtAverageDensity = NULL; - AverageNu = NULL; - AverageKine = NULL; - AverageOmega = NULL; - ExtAverageNu = NULL; - ExtAverageKine = NULL; - ExtAverageOmega = NULL; - - - /*--- Initialize primitive quantities for turboperformace ---*/ - - DensityIn = NULL; - PressureIn = NULL; - TurboVelocityIn = NULL; - DensityOut = NULL; - PressureOut = NULL; - TurboVelocityOut = NULL; - - - /*--- Initialize quantities for Giles BC ---*/ - - CkInflow = NULL; - CkOutflow1 = NULL; - CkOutflow2 = NULL; - - /*--- Set the gamma value ---*/ Gamma = config->GetGamma(); @@ -314,49 +216,39 @@ CNSSolver::CNSSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) Cvector[iVar] = new su2double [nDim]; } - /*--- Store the value of the characteristic primitive variables at the boundaries ---*/ + /*--- Allocates a 2D array with variable "outer" sizes and init to 0. ---*/ - CharacPrimVar = new su2double** [nMarker]; - for (iMarker = 0; iMarker < nMarker; iMarker++) { - CharacPrimVar[iMarker] = new su2double* [geometry->nVertex[iMarker]]; - for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { - CharacPrimVar[iMarker][iVertex] = new su2double [nPrimVar]; - for (iVar = 0; iVar < nPrimVar; iVar++) { - CharacPrimVar[iMarker][iVertex][iVar] = 0.0; - } + auto Alloc2D = [](unsigned long M, const unsigned long* N, su2double**& X) { + X = new su2double* [M]; + for(unsigned long i = 0; i < M; ++i) + X[i] = new su2double [N[i]] (); + }; + + /*--- Allocates a 3D array with variable "middle" sizes and init to 0. ---*/ + + auto Alloc3D = [](unsigned long M, const unsigned long* N, unsigned long P, su2double***& X) { + X = new su2double** [M]; + for(unsigned long i = 0; i < M; ++i) { + X[i] = new su2double* [N[i]]; + for(unsigned long j = 0; j < N[i]; ++j) + X[i][j] = new su2double [P] (); } - } + }; + + /*--- Store the value of the characteristic primitive variables at the boundaries ---*/ + + Alloc3D(nMarker, nVertex, nPrimVar, CharacPrimVar); /*--- Store the value of the primitive variables + 2 turb variables at the boundaries, used for IO with a donor cell ---*/ - DonorPrimVar = new su2double** [nMarker]; - for (iMarker = 0; iMarker < nMarker; iMarker++) { - DonorPrimVar[iMarker] = new su2double* [geometry->nVertex[iMarker]]; - for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { - if (rans) { - DonorPrimVar[iMarker][iVertex] = new su2double [nPrimVar+2]; - for (iVar = 0; iVar < nPrimVar + 2 ; iVar++) { - DonorPrimVar[iMarker][iVertex][iVar] = 0.0; - } - } - else { - DonorPrimVar[iMarker][iVertex] = new su2double [nPrimVar]; - for (iVar = 0; iVar < nPrimVar ; iVar++) { - DonorPrimVar[iMarker][iVertex][iVar] = 0.0; - } - } - } - } + Alloc3D(nMarker, nVertex, (rans? nPrimVar+2 : nPrimVar), DonorPrimVar); /*--- Store the value of the characteristic primitive variables index at the boundaries ---*/ DonorGlobalIndex = new unsigned long* [nMarker]; for (iMarker = 0; iMarker < nMarker; iMarker++) { - DonorGlobalIndex[iMarker] = new unsigned long [geometry->nVertex[iMarker]]; - for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { - DonorGlobalIndex[iMarker][iVertex] = 0; - } + DonorGlobalIndex[iMarker] = new unsigned long [geometry->nVertex[iMarker]](); } /*--- Store the values of the temperature and the heat flux density at the boundaries, @@ -378,92 +270,37 @@ CNSSolver::CNSSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) /*--- Store the value of the Delta P at the Actuator Disk ---*/ - ActDisk_DeltaP = new su2double* [nMarker]; - for (iMarker = 0; iMarker < nMarker; iMarker++) { - ActDisk_DeltaP[iMarker] = new su2double [geometry->nVertex[iMarker]]; - for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { - ActDisk_DeltaP[iMarker][iVertex] = 0; - } - } + Alloc2D(nMarker, nVertex, ActDisk_DeltaP); /*--- Store the value of the Delta T at the Actuator Disk ---*/ - ActDisk_DeltaT = new su2double* [nMarker]; - for (iMarker = 0; iMarker < nMarker; iMarker++) { - ActDisk_DeltaT[iMarker] = new su2double [geometry->nVertex[iMarker]]; - for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { - ActDisk_DeltaT[iMarker][iVertex] = 0; - } - } + Alloc2D(nMarker, nVertex, ActDisk_DeltaT); /*--- Store the value of the Total Pressure at the inlet BC ---*/ - Inlet_Ttotal = new su2double* [nMarker]; - for (iMarker = 0; iMarker < nMarker; iMarker++) { - Inlet_Ttotal[iMarker] = new su2double [geometry->nVertex[iMarker]]; - for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { - Inlet_Ttotal[iMarker][iVertex] = 0; - } - } + Alloc2D(nMarker, nVertex, Inlet_Ttotal); /*--- Store the value of the Total Temperature at the inlet BC ---*/ - Inlet_Ptotal = new su2double* [nMarker]; - for (iMarker = 0; iMarker < nMarker; iMarker++) { - Inlet_Ptotal[iMarker] = new su2double [geometry->nVertex[iMarker]]; - for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { - Inlet_Ptotal[iMarker][iVertex] = 0; - } - } + Alloc2D(nMarker, nVertex, Inlet_Ptotal); /*--- Store the value of the Flow direction at the inlet BC ---*/ - Inlet_FlowDir = new su2double** [nMarker]; - for (iMarker = 0; iMarker < nMarker; iMarker++) { - Inlet_FlowDir[iMarker] = new su2double* [geometry->nVertex[iMarker]]; - for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { - Inlet_FlowDir[iMarker][iVertex] = new su2double [nDim]; - for (iDim = 0; iDim < nDim; iDim++) { - Inlet_FlowDir[iMarker][iVertex][iDim] = 0; - } - } - } + Alloc3D(nMarker, nVertex, nDim, Inlet_FlowDir); /*--- Inviscid force definition and coefficient in all the markers ---*/ - CPressure = new su2double* [nMarker]; - CPressureTarget = new su2double* [nMarker]; - for (iMarker = 0; iMarker < nMarker; iMarker++) { - CPressure[iMarker] = new su2double [geometry->nVertex[iMarker]]; - CPressureTarget[iMarker] = new su2double [geometry->nVertex[iMarker]]; - for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { - CPressure[iMarker][iVertex] = 0.0; - CPressureTarget[iMarker][iVertex] = 0.0; - } - } + Alloc2D(nMarker, nVertex, CPressure); + Alloc2D(nMarker, nVertex, CPressureTarget); /*--- Heat flux in all the markers ---*/ - HeatFlux = new su2double* [nMarker]; - HeatFluxTarget = new su2double* [nMarker]; - for (iMarker = 0; iMarker < nMarker; iMarker++) { - HeatFlux[iMarker] = new su2double [geometry->nVertex[iMarker]]; - HeatFluxTarget[iMarker] = new su2double [geometry->nVertex[iMarker]]; - for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { - HeatFlux[iMarker][iVertex] = 0.0; - HeatFluxTarget[iMarker][iVertex] = 0.0; - } - } + Alloc2D(nMarker, nVertex, HeatFlux); + Alloc2D(nMarker, nVertex, HeatFluxTarget); /*--- Y plus in all the markers ---*/ - YPlus = new su2double* [nMarker]; - for (iMarker = 0; iMarker < nMarker; iMarker++) { - YPlus[iMarker] = new su2double [geometry->nVertex[iMarker]]; - for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { - YPlus[iMarker][iVertex] = 0.0; - } - } + Alloc2D(nMarker, nVertex, YPlus); /*--- Skin friction in all the markers ---*/ @@ -471,147 +308,38 @@ CNSSolver::CNSSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) for (iMarker = 0; iMarker < nMarker; iMarker++) { CSkinFriction[iMarker] = new su2double*[nDim]; for (iDim = 0; iDim < nDim; iDim++) { - CSkinFriction[iMarker][iDim] = new su2double[geometry->nVertex[iMarker]]; - for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { - CSkinFriction[iMarker][iDim][iVertex] = 0.0; - } + CSkinFriction[iMarker][iDim] = new su2double[geometry->nVertex[iMarker]] (); } } - /*--- Buffet sensor in all the markers ---*/ + /*--- Non dimensional aerodynamic coefficients ---*/ - if(config->GetBuffet_Monitoring() || config->GetKind_ObjFunc() == BUFFET_SENSOR){ + InvCoeff.allocate(nMarker); + MntCoeff.allocate(nMarker); + ViscCoeff.allocate(nMarker); + SurfaceInvCoeff.allocate(config->GetnMarker_Monitoring()); + SurfaceMntCoeff.allocate(config->GetnMarker_Monitoring()); + SurfaceViscCoeff.allocate(config->GetnMarker_Monitoring()); + SurfaceCoeff.allocate(config->GetnMarker_Monitoring()); - Buffet_Sensor = new su2double*[nMarker]; - for(iMarker = 0; iMarker < nMarker; iMarker++) { - Buffet_Sensor[iMarker] = new su2double[geometry->nVertex[iMarker]]; - } + /*--- Heat flux and buffet coefficients ---*/ - } + HF_Visc = new su2double[nMarker]; + MaxHF_Visc = new su2double[nMarker]; - /*--- Non dimensional coefficients ---*/ - - ForceInviscid = new su2double[3]; - MomentInviscid = new su2double[3]; - CD_Inv = new su2double[nMarker]; - CL_Inv = new su2double[nMarker]; - CSF_Inv = new su2double[nMarker]; - CEff_Inv = new su2double[nMarker]; - CFx_Inv = new su2double[nMarker]; - CFy_Inv = new su2double[nMarker]; - CFz_Inv = new su2double[nMarker]; - CMx_Inv = new su2double[nMarker]; - CMy_Inv = new su2double[nMarker]; - CMz_Inv = new su2double[nMarker]; - CoPx_Inv = new su2double[nMarker]; - CoPy_Inv = new su2double[nMarker]; - CoPz_Inv = new su2double[nMarker]; - - ForceMomentum = new su2double[3]; - MomentMomentum = new su2double[3]; - CD_Mnt = new su2double[nMarker]; - CL_Mnt = new su2double[nMarker]; - CSF_Mnt = new su2double[nMarker]; - CEff_Mnt = new su2double[nMarker]; - CFx_Mnt = new su2double[nMarker]; - CFy_Mnt = new su2double[nMarker]; - CFz_Mnt = new su2double[nMarker]; - CMx_Mnt = new su2double[nMarker]; - CMy_Mnt = new su2double[nMarker]; - CMz_Mnt = new su2double[nMarker]; - CoPx_Mnt = new su2double[nMarker]; - CoPy_Mnt = new su2double[nMarker]; - CoPz_Mnt = new su2double[nMarker]; - - ForceViscous = new su2double[3]; - MomentViscous = new su2double[3]; - CD_Visc = new su2double[nMarker]; - CL_Visc = new su2double[nMarker]; - CSF_Visc = new su2double[nMarker]; - CEff_Visc = new su2double[nMarker]; - CFx_Visc = new su2double[nMarker]; - CFy_Visc = new su2double[nMarker]; - CFz_Visc = new su2double[nMarker]; - CMx_Visc = new su2double[nMarker]; - CMy_Visc = new su2double[nMarker]; - CMz_Visc = new su2double[nMarker]; - CoPx_Visc = new su2double[nMarker]; - CoPy_Visc = new su2double[nMarker]; - CoPz_Visc = new su2double[nMarker]; - - Surface_CL_Inv = new su2double[config->GetnMarker_Monitoring()]; - Surface_CD_Inv = new su2double[config->GetnMarker_Monitoring()]; - Surface_CSF_Inv = new su2double[config->GetnMarker_Monitoring()]; - Surface_CEff_Inv = new su2double[config->GetnMarker_Monitoring()]; - Surface_CFx_Inv = new su2double[config->GetnMarker_Monitoring()]; - Surface_CFy_Inv = new su2double[config->GetnMarker_Monitoring()]; - Surface_CFz_Inv = new su2double[config->GetnMarker_Monitoring()]; - Surface_CMx_Inv = new su2double[config->GetnMarker_Monitoring()]; - Surface_CMy_Inv = new su2double[config->GetnMarker_Monitoring()]; - Surface_CMz_Inv = new su2double[config->GetnMarker_Monitoring()]; - - Surface_CL_Mnt = new su2double[config->GetnMarker_Monitoring()]; - Surface_CD_Mnt = new su2double[config->GetnMarker_Monitoring()]; - Surface_CSF_Mnt = new su2double[config->GetnMarker_Monitoring()]; - Surface_CEff_Mnt = new su2double[config->GetnMarker_Monitoring()]; - Surface_CFx_Mnt = new su2double[config->GetnMarker_Monitoring()]; - Surface_CFy_Mnt = new su2double[config->GetnMarker_Monitoring()]; - Surface_CFz_Mnt = new su2double[config->GetnMarker_Monitoring()]; - Surface_CMx_Mnt = new su2double[config->GetnMarker_Monitoring()]; - Surface_CMy_Mnt = new su2double[config->GetnMarker_Monitoring()]; - Surface_CMz_Mnt = new su2double[config->GetnMarker_Monitoring()]; - - Surface_CL = new su2double[config->GetnMarker_Monitoring()]; - Surface_CD = new su2double[config->GetnMarker_Monitoring()]; - Surface_CSF = new su2double[config->GetnMarker_Monitoring()]; - Surface_CEff = new su2double[config->GetnMarker_Monitoring()]; - Surface_CFx = new su2double[config->GetnMarker_Monitoring()]; - Surface_CFy = new su2double[config->GetnMarker_Monitoring()]; - Surface_CFz = new su2double[config->GetnMarker_Monitoring()]; - Surface_CMx = new su2double[config->GetnMarker_Monitoring()]; - Surface_CMy = new su2double[config->GetnMarker_Monitoring()]; - Surface_CMz = new su2double[config->GetnMarker_Monitoring()]; - - Surface_CL_Visc = new su2double[config->GetnMarker_Monitoring()]; - Surface_CD_Visc = new su2double[config->GetnMarker_Monitoring()]; - Surface_CSF_Visc = new su2double[config->GetnMarker_Monitoring()]; - Surface_CEff_Visc = new su2double[config->GetnMarker_Monitoring()]; - Surface_CFx_Visc = new su2double[config->GetnMarker_Monitoring()]; - Surface_CFy_Visc = new su2double[config->GetnMarker_Monitoring()]; - Surface_CFz_Visc = new su2double[config->GetnMarker_Monitoring()]; - Surface_CMx_Visc = new su2double[config->GetnMarker_Monitoring()]; - Surface_CMy_Visc = new su2double[config->GetnMarker_Monitoring()]; - Surface_CMz_Visc = new su2double[config->GetnMarker_Monitoring()]; - Surface_HF_Visc = new su2double[config->GetnMarker_Monitoring()]; - Surface_MaxHF_Visc = new su2double[config->GetnMarker_Monitoring()]; + Surface_HF_Visc = new su2double[config->GetnMarker_Monitoring()]; + Surface_MaxHF_Visc = new su2double[config->GetnMarker_Monitoring()]; + + /*--- Buffet sensor in all the markers and coefficients ---*/ if(config->GetBuffet_Monitoring() || config->GetKind_ObjFunc() == BUFFET_SENSOR){ - Buffet_Metric = new su2double[nMarker]; - Surface_Buffet_Metric = new su2double[config->GetnMarker_Monitoring()]; + Alloc2D(nMarker, nVertex, Buffet_Sensor); + Buffet_Metric = new su2double[nMarker]; + Surface_Buffet_Metric = new su2double[config->GetnMarker_Monitoring()]; } - - /*--- Rotational coefficients ---*/ - - CMerit_Inv = new su2double[nMarker]; - CT_Inv = new su2double[nMarker]; - CQ_Inv = new su2double[nMarker]; - - CMerit_Mnt = new su2double[nMarker]; - CT_Mnt = new su2double[nMarker]; - CQ_Mnt = new su2double[nMarker]; - - CMerit_Visc = new su2double[nMarker]; - CT_Visc = new su2double[nMarker]; - CQ_Visc = new su2double[nMarker]; - - /*--- Heat based coefficients ---*/ - - HF_Visc = new su2double[nMarker]; - MaxHF_Visc = new su2double[nMarker]; - /*--- Supersonic coefficients ---*/ CEquivArea_Inv = new su2double[nMarker]; @@ -629,23 +357,6 @@ CNSSolver::CNSSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) Exhaust_Temperature = new su2double[nMarker]; Exhaust_Area = new su2double[nMarker]; - /*--- Init total coefficients ---*/ - - Total_CD = 0.0; Total_CL = 0.0; Total_CSF = 0.0; - Total_CMx = 0.0; Total_CMy = 0.0; Total_CMz = 0.0; - Total_CoPx = 0.0; Total_CoPy = 0.0; Total_CoPz = 0.0; - Total_CEff = 0.0; Total_CEquivArea = 0.0; Total_CNearFieldOF = 0.0; - Total_CFx = 0.0; Total_CFy = 0.0; Total_CFz = 0.0; - Total_CT = 0.0; Total_CQ = 0.0; Total_CMerit = 0.0; - Total_MaxHeat = 0.0; Total_Heat = 0.0; Total_ComboObj = 0.0; - Total_CpDiff = 0.0; Total_HeatFluxDiff = 0.0; - Total_NetThrust = 0.0; Total_Power = 0.0; - Total_CL_Prev = 0.0; Total_CD_Prev = 0.0; Total_CMx_Prev = 0.0; - Total_CMy_Prev = 0.0; Total_CMz_Prev = 0.0; - Total_AeroCD = 0.0; Total_SolidCD = 0.0; Total_IDR = 0.0; - Total_IDC = 0.0; - Total_Custom_ObjFunc = 0.0; - /*--- Read farfield conditions from config ---*/ Density_Inf = config->GetDensity_FreeStreamND(); @@ -711,17 +422,11 @@ CNSSolver::CNSSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) if (config->GetMarker_All_KindBC(iMarker) == FLUID_INTERFACE){ - SlidingState[iMarker] = new su2double**[geometry->GetnVertex(iMarker)]; - SlidingStateNodes[iMarker] = new int [geometry->GetnVertex(iMarker)]; - - for (iPoint = 0; iPoint < geometry->GetnVertex(iMarker); iPoint++){ - SlidingState[iMarker][iPoint] = new su2double*[nPrimVar+1]; - - SlidingStateNodes[iMarker][iPoint] = 0; - for (iVar = 0; iVar < nPrimVar+1; iVar++) - SlidingState[iMarker][iPoint][iVar] = NULL; - } + SlidingState[iMarker] = new su2double**[geometry->GetnVertex(iMarker)](); + SlidingStateNodes[iMarker] = new int [geometry->GetnVertex(iMarker)](); + for (iPoint = 0; iPoint < geometry->GetnVertex(iMarker); iPoint++) + SlidingState[iMarker][iPoint] = new su2double*[nPrimVar+1](); } } @@ -860,41 +565,13 @@ CNSSolver::~CNSSolver(void) { unsigned long iVertex; - if (CD_Visc != NULL) delete [] CD_Visc; - if (CL_Visc != NULL) delete [] CL_Visc; - if (CSF_Visc != NULL) delete [] CSF_Visc; - if (CFx_Visc != NULL) delete [] CFx_Visc; - if (CFy_Visc != NULL) delete [] CFy_Visc; - if (CFz_Visc != NULL) delete [] CFz_Visc; - if (CMx_Visc != NULL) delete [] CMx_Visc; - if (CMy_Visc != NULL) delete [] CMy_Visc; - if (CMz_Visc != NULL) delete [] CMz_Visc; - if (CoPx_Visc != NULL) delete [] CoPx_Visc; - if (CoPy_Visc != NULL) delete [] CoPy_Visc; - if (CoPz_Visc != NULL) delete [] CoPz_Visc; - if (CEff_Visc != NULL) delete [] CEff_Visc; - if (CMerit_Visc != NULL) delete [] CMerit_Visc; - if (Buffet_Metric != NULL) delete [] Buffet_Metric; - if (CT_Visc != NULL) delete [] CT_Visc; - if (CQ_Visc != NULL) delete [] CQ_Visc; - if (HF_Visc != NULL) delete [] HF_Visc; - if (MaxHF_Visc != NULL) delete [] MaxHF_Visc; - if (ForceViscous != NULL) delete [] ForceViscous; - if (MomentViscous != NULL) delete [] MomentViscous; - - if (Surface_CL_Visc != NULL) delete [] Surface_CL_Visc; - if (Surface_CD_Visc != NULL) delete [] Surface_CD_Visc; - if (Surface_CSF_Visc != NULL) delete [] Surface_CSF_Visc; - if (Surface_CEff_Visc != NULL) delete [] Surface_CEff_Visc; - if (Surface_CFx_Visc != NULL) delete [] Surface_CFx_Visc; - if (Surface_CFy_Visc != NULL) delete [] Surface_CFy_Visc; - if (Surface_CFz_Visc != NULL) delete [] Surface_CFz_Visc; - if (Surface_CMx_Visc != NULL) delete [] Surface_CMx_Visc; - if (Surface_CMy_Visc != NULL) delete [] Surface_CMy_Visc; - if (Surface_CMz_Visc != NULL) delete [] Surface_CMz_Visc; - if (Surface_HF_Visc != NULL) delete [] Surface_HF_Visc; - if (Surface_MaxHF_Visc != NULL) delete [] Surface_MaxHF_Visc; - if (Surface_Buffet_Metric != NULL) delete [] Surface_Buffet_Metric; + delete [] Buffet_Metric; + delete [] HF_Visc; + delete [] MaxHF_Visc; + + delete [] Surface_HF_Visc; + delete [] Surface_MaxHF_Visc; + delete [] Surface_Buffet_Metric; if (CSkinFriction != NULL) { for (iMarker = 0; iMarker < nMarker; iMarker++) { @@ -1213,13 +890,12 @@ void CNSSolver::Friction_Forces(CGeometry *geometry, CConfig *config) { unsigned long iVertex, iPoint, iPointNormal; unsigned short Boundary, Monitoring, iMarker, iMarker_Monitoring, iDim, jDim; - su2double Viscosity = 0.0, div_vel, MomentDist[3] = {0.0, 0.0, 0.0}, WallDist[3] = {0.0, 0.0, 0.0}, + su2double Viscosity = 0.0, div_vel, WallDist[3] = {0.0, 0.0, 0.0}, Area, WallShearStress, TauNormal, factor, RefTemp, RefVel2, RefDensity, GradTemperature, Density = 0.0, WallDistMod, FrictionVel, Mach2Vel, Mach_Motion, UnitNormal[3] = {0.0, 0.0, 0.0}, TauElem[3] = {0.0, 0.0, 0.0}, TauTangent[3] = {0.0, 0.0, 0.0}, - Tau[3][3] = {{0.0, 0.0, 0.0},{0.0, 0.0, 0.0},{0.0, 0.0, 0.0}}, Force[3] = {0.0, 0.0, 0.0}, Cp, thermal_conductivity, MaxNorm = 8.0, + Tau[3][3] = {{0.0, 0.0, 0.0},{0.0, 0.0, 0.0},{0.0, 0.0, 0.0}}, Cp, thermal_conductivity, MaxNorm = 8.0, Grad_Vel[3][3] = {{0.0, 0.0, 0.0},{0.0, 0.0, 0.0},{0.0, 0.0, 0.0}}, Grad_Temp[3] = {0.0, 0.0, 0.0}, delta[3][3] = {{1.0, 0.0, 0.0},{0.0,1.0,0.0},{0.0,0.0,1.0}}; - su2double MomentX_Force[3] = {0.0,0.0,0.0}, MomentY_Force[3] = {0.0,0.0,0.0}, MomentZ_Force[3] = {0.0,0.0,0.0}; su2double AxiFactor; const su2double *Coord = nullptr, *Coord_Normal = nullptr, *Normal = nullptr; @@ -1260,19 +936,12 @@ void CNSSolver::Friction_Forces(CGeometry *geometry, CConfig *config) { /*--- Variables initialization ---*/ - AllBound_CD_Visc = 0.0; AllBound_CL_Visc = 0.0; AllBound_CSF_Visc = 0.0; - AllBound_CFx_Visc = 0.0; AllBound_CFy_Visc = 0.0; AllBound_CFz_Visc = 0.0; - AllBound_CMx_Visc = 0.0; AllBound_CMy_Visc = 0.0; AllBound_CMz_Visc = 0.0; - AllBound_CoPx_Visc = 0.0; AllBound_CoPy_Visc = 0.0; AllBound_CoPz_Visc = 0.0; - AllBound_CT_Visc = 0.0; AllBound_CQ_Visc = 0.0; AllBound_CMerit_Visc = 0.0; - AllBound_HF_Visc = 0.0; AllBound_MaxHF_Visc = 0.0; AllBound_CEff_Visc = 0.0; + AllBoundViscCoeff.setZero(); + SurfaceViscCoeff.setZero(); + + AllBound_HF_Visc = 0.0; AllBound_MaxHF_Visc = 0.0; for (iMarker_Monitoring = 0; iMarker_Monitoring < config->GetnMarker_Monitoring(); iMarker_Monitoring++) { - Surface_CL_Visc[iMarker_Monitoring] = 0.0; Surface_CD_Visc[iMarker_Monitoring] = 0.0; - Surface_CSF_Visc[iMarker_Monitoring] = 0.0; Surface_CEff_Visc[iMarker_Monitoring] = 0.0; - Surface_CFx_Visc[iMarker_Monitoring] = 0.0; Surface_CFy_Visc[iMarker_Monitoring] = 0.0; - Surface_CFz_Visc[iMarker_Monitoring] = 0.0; Surface_CMx_Visc[iMarker_Monitoring] = 0.0; - Surface_CMy_Visc[iMarker_Monitoring] = 0.0; Surface_CMz_Visc[iMarker_Monitoring] = 0.0; Surface_HF_Visc[iMarker_Monitoring] = 0.0; Surface_MaxHF_Visc[iMarker_Monitoring] = 0.0; } @@ -1298,18 +967,12 @@ void CNSSolver::Friction_Forces(CGeometry *geometry, CConfig *config) { /*--- Forces initialization at each Marker ---*/ - CD_Visc[iMarker] = 0.0; CL_Visc[iMarker] = 0.0; CSF_Visc[iMarker] = 0.0; - CFx_Visc[iMarker] = 0.0; CFy_Visc[iMarker] = 0.0; CFz_Visc[iMarker] = 0.0; - CMx_Visc[iMarker] = 0.0; CMy_Visc[iMarker] = 0.0; CMz_Visc[iMarker] = 0.0; - CoPx_Visc[iMarker] = 0.0; CoPy_Visc[iMarker] = 0.0; CoPz_Visc[iMarker] = 0.0; - CT_Visc[iMarker] = 0.0; CQ_Visc[iMarker] = 0.0; CMerit_Visc[iMarker] = 0.0; - HF_Visc[iMarker] = 0.0; MaxHF_Visc[iMarker] = 0.0; CEff_Visc[iMarker] = 0.0; + ViscCoeff.setZero(iMarker); + + HF_Visc[iMarker] = 0.0; MaxHF_Visc[iMarker] = 0.0; - for (iDim = 0; iDim < nDim; iDim++) ForceViscous[iDim] = 0.0; - MomentViscous[0] = 0.0; MomentViscous[1] = 0.0; MomentViscous[2] = 0.0; - MomentX_Force[0] = 0.0; MomentX_Force[1] = 0.0; MomentX_Force[2] = 0.0; - MomentY_Force[0] = 0.0; MomentY_Force[1] = 0.0; MomentY_Force[2] = 0.0; - MomentZ_Force[0] = 0.0; MomentZ_Force[1] = 0.0; MomentZ_Force[2] = 0.0; + su2double ForceViscous[MAXNDIM] = {0.0}, MomentViscous[MAXNDIM] = {0.0}; + su2double MomentX_Force[MAXNDIM] = {0.0}, MomentY_Force[MAXNDIM] = {0.0}, MomentZ_Force[MAXNDIM] = {0.0}; /*--- Loop over the vertices to compute the forces ---*/ @@ -1352,30 +1015,29 @@ void CNSSolver::Friction_Forces(CGeometry *geometry, CConfig *config) { /*--- If necessary evaluate the QCR contribution to Tau ---*/ - if (QCR){ - su2double den_aux, c_cr1=0.3, O_ik, O_jk; - unsigned short kDim; + if (QCR) { + su2double den_aux, c_cr1=0.3, O_ik, O_jk; + unsigned short kDim; - /*--- Denominator Antisymmetric normalized rotation tensor ---*/ + /*--- Denominator Antisymmetric normalized rotation tensor ---*/ - den_aux = 0.0; - for (iDim = 0 ; iDim < nDim; iDim++) - for (jDim = 0 ; jDim < nDim; jDim++) - den_aux += Grad_Vel[iDim][jDim] * Grad_Vel[iDim][jDim]; - den_aux = sqrt(max(den_aux,1E-10)); + den_aux = 0.0; + for (iDim = 0 ; iDim < nDim; iDim++) + for (jDim = 0 ; jDim < nDim; jDim++) + den_aux += Grad_Vel[iDim][jDim] * Grad_Vel[iDim][jDim]; + den_aux = sqrt(max(den_aux,1E-10)); - /*--- Adding the QCR contribution ---*/ + /*--- Adding the QCR contribution ---*/ - for (iDim = 0 ; iDim < nDim; iDim++){ - for (jDim = 0 ; jDim < nDim; jDim++){ - for (kDim = 0 ; kDim < nDim; kDim++){ - O_ik = (Grad_Vel[iDim][kDim] - Grad_Vel[kDim][iDim])/ den_aux; - O_jk = (Grad_Vel[jDim][kDim] - Grad_Vel[kDim][jDim])/ den_aux; - Tau[iDim][jDim] -= c_cr1 * (O_ik * Tau[jDim][kDim] + O_jk * Tau[iDim][kDim]); - } - } + for (iDim = 0 ; iDim < nDim; iDim++){ + for (jDim = 0 ; jDim < nDim; jDim++){ + for (kDim = 0 ; kDim < nDim; kDim++){ + O_ik = (Grad_Vel[iDim][kDim] - Grad_Vel[kDim][iDim])/ den_aux; + O_jk = (Grad_Vel[jDim][kDim] - Grad_Vel[kDim][jDim])/ den_aux; + Tau[iDim][jDim] -= c_cr1 * (O_ik * Tau[jDim][kDim] + O_jk * Tau[iDim][kDim]); + } } - + } } /*--- Project Tau in each surface element ---*/ @@ -1429,6 +1091,7 @@ void CNSSolver::Friction_Forces(CGeometry *geometry, CConfig *config) { /*--- Force computation ---*/ + su2double Force[MAXNDIM] = {0.0}, MomentDist[MAXNDIM] = {0.0}; for (iDim = 0; iDim < nDim; iDim++) { Force[iDim] = TauElem[iDim] * Area * factor * AxiFactor; ForceViscous[iDim] += Force[iDim]; @@ -1461,54 +1124,54 @@ void CNSSolver::Friction_Forces(CGeometry *geometry, CConfig *config) { if (Monitoring == YES) { if (nDim == 2) { - CD_Visc[iMarker] = ForceViscous[0]*cos(Alpha) + ForceViscous[1]*sin(Alpha); - CL_Visc[iMarker] = -ForceViscous[0]*sin(Alpha) + ForceViscous[1]*cos(Alpha); - CEff_Visc[iMarker] = CL_Visc[iMarker] / (CD_Visc[iMarker]+EPS); - CFx_Visc[iMarker] = ForceViscous[0]; - CFy_Visc[iMarker] = ForceViscous[1]; - CMz_Visc[iMarker] = MomentViscous[2]; - CoPx_Visc[iMarker] = MomentZ_Force[1]; - CoPy_Visc[iMarker] = -MomentZ_Force[0]; - CT_Visc[iMarker] = -CFx_Visc[iMarker]; - CQ_Visc[iMarker] = -CMz_Visc[iMarker]; - CMerit_Visc[iMarker] = CT_Visc[iMarker] / (CQ_Visc[iMarker]+EPS); - MaxHF_Visc[iMarker] = pow(MaxHF_Visc[iMarker], 1.0/MaxNorm); + ViscCoeff.CD[iMarker] = ForceViscous[0]*cos(Alpha) + ForceViscous[1]*sin(Alpha); + ViscCoeff.CL[iMarker] = -ForceViscous[0]*sin(Alpha) + ForceViscous[1]*cos(Alpha); + ViscCoeff.CEff[iMarker] = ViscCoeff.CL[iMarker] / (ViscCoeff.CD[iMarker]+EPS); + ViscCoeff.CFx[iMarker] = ForceViscous[0]; + ViscCoeff.CFy[iMarker] = ForceViscous[1]; + ViscCoeff.CMz[iMarker] = MomentViscous[2]; + ViscCoeff.CoPx[iMarker] = MomentZ_Force[1]; + ViscCoeff.CoPy[iMarker] = -MomentZ_Force[0]; + ViscCoeff.CT[iMarker] = -ViscCoeff.CFx[iMarker]; + ViscCoeff.CQ[iMarker] = -ViscCoeff.CMz[iMarker]; + ViscCoeff.CMerit[iMarker] = ViscCoeff.CT[iMarker] / (ViscCoeff.CQ[iMarker]+EPS); + MaxHF_Visc[iMarker] = pow(MaxHF_Visc[iMarker], 1.0/MaxNorm); } if (nDim == 3) { - CD_Visc[iMarker] = ForceViscous[0]*cos(Alpha)*cos(Beta) + ForceViscous[1]*sin(Beta) + ForceViscous[2]*sin(Alpha)*cos(Beta); - CL_Visc[iMarker] = -ForceViscous[0]*sin(Alpha) + ForceViscous[2]*cos(Alpha); - CSF_Visc[iMarker] = -ForceViscous[0]*sin(Beta)*cos(Alpha) + ForceViscous[1]*cos(Beta) - ForceViscous[2]*sin(Beta)*sin(Alpha); - CEff_Visc[iMarker] = CL_Visc[iMarker]/(CD_Visc[iMarker] + EPS); - CFx_Visc[iMarker] = ForceViscous[0]; - CFy_Visc[iMarker] = ForceViscous[1]; - CFz_Visc[iMarker] = ForceViscous[2]; - CMx_Visc[iMarker] = MomentViscous[0]; - CMy_Visc[iMarker] = MomentViscous[1]; - CMz_Visc[iMarker] = MomentViscous[2]; - CoPx_Visc[iMarker] = -MomentY_Force[0]; - CoPz_Visc[iMarker] = MomentY_Force[2]; - CT_Visc[iMarker] = -CFz_Visc[iMarker]; - CQ_Visc[iMarker] = -CMz_Visc[iMarker]; - CMerit_Visc[iMarker] = CT_Visc[iMarker] / (CQ_Visc[iMarker] + EPS); - MaxHF_Visc[iMarker] = pow(MaxHF_Visc[iMarker], 1.0/MaxNorm); + ViscCoeff.CD[iMarker] = ForceViscous[0]*cos(Alpha)*cos(Beta) + ForceViscous[1]*sin(Beta) + ForceViscous[2]*sin(Alpha)*cos(Beta); + ViscCoeff.CL[iMarker] = -ForceViscous[0]*sin(Alpha) + ForceViscous[2]*cos(Alpha); + ViscCoeff.CSF[iMarker] = -ForceViscous[0]*sin(Beta)*cos(Alpha) + ForceViscous[1]*cos(Beta) - ForceViscous[2]*sin(Beta)*sin(Alpha); + ViscCoeff.CEff[iMarker] = ViscCoeff.CL[iMarker]/(ViscCoeff.CD[iMarker] + EPS); + ViscCoeff.CFx[iMarker] = ForceViscous[0]; + ViscCoeff.CFy[iMarker] = ForceViscous[1]; + ViscCoeff.CFz[iMarker] = ForceViscous[2]; + ViscCoeff.CMx[iMarker] = MomentViscous[0]; + ViscCoeff.CMy[iMarker] = MomentViscous[1]; + ViscCoeff.CMz[iMarker] = MomentViscous[2]; + ViscCoeff.CoPx[iMarker] = -MomentY_Force[0]; + ViscCoeff.CoPz[iMarker] = MomentY_Force[2]; + ViscCoeff.CT[iMarker] = -ViscCoeff.CFz[iMarker]; + ViscCoeff.CQ[iMarker] = -ViscCoeff.CMz[iMarker]; + ViscCoeff.CMerit[iMarker] = ViscCoeff.CT[iMarker] / (ViscCoeff.CQ[iMarker] + EPS); + MaxHF_Visc[iMarker] = pow(MaxHF_Visc[iMarker], 1.0/MaxNorm); } - AllBound_CD_Visc += CD_Visc[iMarker]; - AllBound_CL_Visc += CL_Visc[iMarker]; - AllBound_CSF_Visc += CSF_Visc[iMarker]; - AllBound_CFx_Visc += CFx_Visc[iMarker]; - AllBound_CFy_Visc += CFy_Visc[iMarker]; - AllBound_CFz_Visc += CFz_Visc[iMarker]; - AllBound_CMx_Visc += CMx_Visc[iMarker]; - AllBound_CMy_Visc += CMy_Visc[iMarker]; - AllBound_CMz_Visc += CMz_Visc[iMarker]; - AllBound_CoPx_Visc += CoPx_Visc[iMarker]; - AllBound_CoPy_Visc += CoPy_Visc[iMarker]; - AllBound_CoPz_Visc += CoPz_Visc[iMarker]; - AllBound_CT_Visc += CT_Visc[iMarker]; - AllBound_CQ_Visc += CQ_Visc[iMarker]; - AllBound_HF_Visc += HF_Visc[iMarker]; - AllBound_MaxHF_Visc += pow(MaxHF_Visc[iMarker], MaxNorm); + AllBoundViscCoeff.CD += ViscCoeff.CD[iMarker]; + AllBoundViscCoeff.CL += ViscCoeff.CL[iMarker]; + AllBoundViscCoeff.CSF += ViscCoeff.CSF[iMarker]; + AllBoundViscCoeff.CFx += ViscCoeff.CFx[iMarker]; + AllBoundViscCoeff.CFy += ViscCoeff.CFy[iMarker]; + AllBoundViscCoeff.CFz += ViscCoeff.CFz[iMarker]; + AllBoundViscCoeff.CMx += ViscCoeff.CMx[iMarker]; + AllBoundViscCoeff.CMy += ViscCoeff.CMy[iMarker]; + AllBoundViscCoeff.CMz += ViscCoeff.CMz[iMarker]; + AllBoundViscCoeff.CoPx += ViscCoeff.CoPx[iMarker]; + AllBoundViscCoeff.CoPy += ViscCoeff.CoPy[iMarker]; + AllBoundViscCoeff.CoPz += ViscCoeff.CoPz[iMarker]; + AllBoundViscCoeff.CT += ViscCoeff.CT[iMarker]; + AllBoundViscCoeff.CQ += ViscCoeff.CQ[iMarker]; + AllBound_HF_Visc += HF_Visc[iMarker]; + AllBound_MaxHF_Visc += pow(MaxHF_Visc[iMarker], MaxNorm); /*--- Compute the coefficients per surface ---*/ @@ -1516,18 +1179,18 @@ void CNSSolver::Friction_Forces(CGeometry *geometry, CConfig *config) { Monitoring_Tag = config->GetMarker_Monitoring_TagBound(iMarker_Monitoring); Marker_Tag = config->GetMarker_All_TagBound(iMarker); if (Marker_Tag == Monitoring_Tag) { - Surface_CL_Visc[iMarker_Monitoring] += CL_Visc[iMarker]; - Surface_CD_Visc[iMarker_Monitoring] += CD_Visc[iMarker]; - Surface_CSF_Visc[iMarker_Monitoring] += CSF_Visc[iMarker]; - Surface_CEff_Visc[iMarker_Monitoring] += CEff_Visc[iMarker]; - Surface_CFx_Visc[iMarker_Monitoring] += CFx_Visc[iMarker]; - Surface_CFy_Visc[iMarker_Monitoring] += CFy_Visc[iMarker]; - Surface_CFz_Visc[iMarker_Monitoring] += CFz_Visc[iMarker]; - Surface_CMx_Visc[iMarker_Monitoring] += CMx_Visc[iMarker]; - Surface_CMy_Visc[iMarker_Monitoring] += CMy_Visc[iMarker]; - Surface_CMz_Visc[iMarker_Monitoring] += CMz_Visc[iMarker]; - Surface_HF_Visc[iMarker_Monitoring] += HF_Visc[iMarker]; - Surface_MaxHF_Visc[iMarker_Monitoring] += pow(MaxHF_Visc[iMarker],MaxNorm); + SurfaceViscCoeff.CL[iMarker_Monitoring] += ViscCoeff.CL[iMarker]; + SurfaceViscCoeff.CD[iMarker_Monitoring] += ViscCoeff.CD[iMarker]; + SurfaceViscCoeff.CSF[iMarker_Monitoring] += ViscCoeff.CSF[iMarker]; + SurfaceViscCoeff.CEff[iMarker_Monitoring] += ViscCoeff.CEff[iMarker]; + SurfaceViscCoeff.CFx[iMarker_Monitoring] += ViscCoeff.CFx[iMarker]; + SurfaceViscCoeff.CFy[iMarker_Monitoring] += ViscCoeff.CFy[iMarker]; + SurfaceViscCoeff.CFz[iMarker_Monitoring] += ViscCoeff.CFz[iMarker]; + SurfaceViscCoeff.CMx[iMarker_Monitoring] += ViscCoeff.CMx[iMarker]; + SurfaceViscCoeff.CMy[iMarker_Monitoring] += ViscCoeff.CMy[iMarker]; + SurfaceViscCoeff.CMz[iMarker_Monitoring] += ViscCoeff.CMz[iMarker]; + Surface_HF_Visc[iMarker_Monitoring] += HF_Visc[iMarker]; + Surface_MaxHF_Visc[iMarker_Monitoring] += pow(MaxHF_Visc[iMarker],MaxNorm); } } @@ -1538,8 +1201,8 @@ void CNSSolver::Friction_Forces(CGeometry *geometry, CConfig *config) { /*--- Update some global coeffients ---*/ - AllBound_CEff_Visc = AllBound_CL_Visc / (AllBound_CD_Visc + EPS); - AllBound_CMerit_Visc = AllBound_CT_Visc / (AllBound_CQ_Visc + EPS); + AllBoundViscCoeff.CEff = AllBoundViscCoeff.CL / (AllBoundViscCoeff.CD + EPS); + AllBoundViscCoeff.CMerit = AllBoundViscCoeff.CT / (AllBoundViscCoeff.CQ + EPS); AllBound_MaxHF_Visc = pow(AllBound_MaxHF_Visc, 1.0/MaxNorm); @@ -1554,28 +1217,28 @@ void CNSSolver::Friction_Forces(CGeometry *geometry, CConfig *config) { SU2_MPI::Allreduce(&tmp, &x, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); return x; }; - AllBound_CD_Visc = Allreduce(AllBound_CD_Visc); - AllBound_CL_Visc = Allreduce(AllBound_CL_Visc); - AllBound_CSF_Visc = Allreduce(AllBound_CSF_Visc); - AllBound_CEff_Visc = AllBound_CL_Visc / (AllBound_CD_Visc + EPS); + AllBoundViscCoeff.CD = Allreduce(AllBoundViscCoeff.CD); + AllBoundViscCoeff.CL = Allreduce(AllBoundViscCoeff.CL); + AllBoundViscCoeff.CSF = Allreduce(AllBoundViscCoeff.CSF); + AllBoundViscCoeff.CEff = AllBoundViscCoeff.CL / (AllBoundViscCoeff.CD + EPS); - AllBound_CMx_Visc = Allreduce(AllBound_CMx_Visc); - AllBound_CMy_Visc = Allreduce(AllBound_CMy_Visc); - AllBound_CMz_Visc = Allreduce(AllBound_CMz_Visc); + AllBoundViscCoeff.CMx = Allreduce(AllBoundViscCoeff.CMx); + AllBoundViscCoeff.CMy = Allreduce(AllBoundViscCoeff.CMy); + AllBoundViscCoeff.CMz = Allreduce(AllBoundViscCoeff.CMz); - AllBound_CFx_Visc = Allreduce(AllBound_CFx_Visc); - AllBound_CFy_Visc = Allreduce(AllBound_CFy_Visc); - AllBound_CFz_Visc = Allreduce(AllBound_CFz_Visc); + AllBoundViscCoeff.CFx = Allreduce(AllBoundViscCoeff.CFx); + AllBoundViscCoeff.CFy = Allreduce(AllBoundViscCoeff.CFy); + AllBoundViscCoeff.CFz = Allreduce(AllBoundViscCoeff.CFz); - AllBound_CoPx_Visc = Allreduce(AllBound_CoPx_Visc); - AllBound_CoPy_Visc = Allreduce(AllBound_CoPy_Visc); - AllBound_CoPz_Visc = Allreduce(AllBound_CoPz_Visc); + AllBoundViscCoeff.CoPx = Allreduce(AllBoundViscCoeff.CoPx); + AllBoundViscCoeff.CoPy = Allreduce(AllBoundViscCoeff.CoPy); + AllBoundViscCoeff.CoPz = Allreduce(AllBoundViscCoeff.CoPz); - AllBound_CT_Visc = Allreduce(AllBound_CT_Visc); - AllBound_CQ_Visc = Allreduce(AllBound_CQ_Visc); - AllBound_HF_Visc = Allreduce(AllBound_HF_Visc); - AllBound_CMerit_Visc = AllBound_CT_Visc / (AllBound_CQ_Visc + EPS); + AllBoundViscCoeff.CT = Allreduce(AllBoundViscCoeff.CT); + AllBoundViscCoeff.CQ = Allreduce(AllBoundViscCoeff.CQ); + AllBoundViscCoeff.CMerit = AllBoundViscCoeff.CT / (AllBoundViscCoeff.CQ + EPS); + AllBound_HF_Visc = Allreduce(AllBound_HF_Visc); AllBound_MaxHF_Visc = pow(Allreduce(pow(AllBound_MaxHF_Visc, MaxNorm)), 1.0/MaxNorm); } @@ -1596,20 +1259,21 @@ void CNSSolver::Friction_Forces(CGeometry *geometry, CConfig *config) { for(int i=0; iGetnMarker_Monitoring(); iMarker_Monitoring++) { - Surface_CL[iMarker_Monitoring] += Surface_CL_Visc[iMarker_Monitoring]; - Surface_CD[iMarker_Monitoring] += Surface_CD_Visc[iMarker_Monitoring]; - Surface_CSF[iMarker_Monitoring] += Surface_CSF_Visc[iMarker_Monitoring]; - Surface_CEff[iMarker_Monitoring] = Surface_CL[iMarker_Monitoring] / (Surface_CD[iMarker_Monitoring] + EPS); - Surface_CFx[iMarker_Monitoring] += Surface_CFx_Visc[iMarker_Monitoring]; - Surface_CFy[iMarker_Monitoring] += Surface_CFy_Visc[iMarker_Monitoring]; - Surface_CFz[iMarker_Monitoring] += Surface_CFz_Visc[iMarker_Monitoring]; - Surface_CMx[iMarker_Monitoring] += Surface_CMx_Visc[iMarker_Monitoring]; - Surface_CMy[iMarker_Monitoring] += Surface_CMy_Visc[iMarker_Monitoring]; - Surface_CMz[iMarker_Monitoring] += Surface_CMz_Visc[iMarker_Monitoring]; + SurfaceCoeff.CL[iMarker_Monitoring] += SurfaceViscCoeff.CL[iMarker_Monitoring]; + SurfaceCoeff.CD[iMarker_Monitoring] += SurfaceViscCoeff.CD[iMarker_Monitoring]; + SurfaceCoeff.CSF[iMarker_Monitoring] += SurfaceViscCoeff.CSF[iMarker_Monitoring]; + SurfaceCoeff.CEff[iMarker_Monitoring] = SurfaceViscCoeff.CL[iMarker_Monitoring] / (SurfaceCoeff.CD[iMarker_Monitoring] + EPS); + SurfaceCoeff.CFx[iMarker_Monitoring] += SurfaceViscCoeff.CFx[iMarker_Monitoring]; + SurfaceCoeff.CFy[iMarker_Monitoring] += SurfaceViscCoeff.CFy[iMarker_Monitoring]; + SurfaceCoeff.CFz[iMarker_Monitoring] += SurfaceViscCoeff.CFz[iMarker_Monitoring]; + SurfaceCoeff.CMx[iMarker_Monitoring] += SurfaceViscCoeff.CMx[iMarker_Monitoring]; + SurfaceCoeff.CMy[iMarker_Monitoring] += SurfaceViscCoeff.CMy[iMarker_Monitoring]; + SurfaceCoeff.CMz[iMarker_Monitoring] += SurfaceViscCoeff.CMz[iMarker_Monitoring]; } } From 3a843051bd2fa2f071f621edc3d6326bd16d53d4 Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Fri, 31 Jan 2020 20:01:27 +0000 Subject: [PATCH 069/118] complete the aero coefficients auxilary type --- SU2_CFD/include/solvers/CEulerSolver.hpp | 93 +++++++++++++----------- SU2_CFD/include/solvers/CNSSolver.hpp | 6 +- SU2_CFD/src/solvers/CEulerSolver.cpp | 23 ++++++ 3 files changed, 77 insertions(+), 45 deletions(-) diff --git a/SU2_CFD/include/solvers/CEulerSolver.hpp b/SU2_CFD/include/solvers/CEulerSolver.hpp index 7a277f588183..9e80ebb20409 100644 --- a/SU2_CFD/include/solvers/CEulerSolver.hpp +++ b/SU2_CFD/include/solvers/CEulerSolver.hpp @@ -60,52 +60,61 @@ class CEulerSolver : public CSolver { Prandtl_Turb = 0.0; /*!< \brief Turbulent Prandtl number. */ /*! - * \brief Auxilary type to store common aero coefficients (avoids repeating oneself so much). - * \tparam The type can be used to store scalars (Type = su2double) or arrays - * (Type = su2double*) e.g. for when the coeffs are computed over surfaces. - */ - template - struct AerodynamicCoefficients { - Type CD = 0; /*!< \brief Drag coefficient. */ - Type CL = 0; /*!< \brief Lift coefficient. */ - Type CSF = 0; /*!< \brief Sideforce coefficient. */ - Type CEff = 0; /*!< \brief Efficiency (Cl/Cd). */ - Type CFx = 0; /*!< \brief x Force coefficient. */ - Type CFy = 0; /*!< \brief y Force coefficient. */ - Type CFz = 0; /*!< \brief z Force coefficient. */ - Type CMx = 0; /*!< \brief x Moment coefficient. */ - Type CMy = 0; /*!< \brief y Moment coefficient. */ - Type CMz = 0; /*!< \brief z Moment coefficient. */ - Type CoPx = 0; /*!< \brief x Moment coefficient. */ - Type CoPy = 0; /*!< \brief y Moment coefficient. */ - Type CoPz = 0; /*!< \brief z Moment coefficient. */ - Type CT = 0; /*!< \brief Thrust coefficient. */ - Type CQ = 0; /*!< \brief Torque coefficient. */ - Type CMerit = 0; /*!< \brief Rotor Figure of Merit. */ - int _size; - - void allocate(int size); /*!< \brief Allocates arrays (for Type = su2double*). */ - - void setZero(); /*!< \brief Sets all values to zero for all indices. */ - void setZero(int i); /*!< \brief Sets all values to zero at a particular index. */ - - AerodynamicCoefficients(int size = 0) : _size(size) { allocate(size); } - - ~AerodynamicCoefficients(); + * \brief Auxilary types to store common aero coefficients (avoids repeating oneself so much). + */ + struct AeroCoeffsArray { + su2double* CD = nullptr; /*!< \brief Drag coefficient. */ + su2double* CL = nullptr; /*!< \brief Lift coefficient. */ + su2double* CSF = nullptr; /*!< \brief Sideforce coefficient. */ + su2double* CEff = nullptr; /*!< \brief Efficiency (Cl/Cd). */ + su2double* CFx = nullptr; /*!< \brief x Force coefficient. */ + su2double* CFy = nullptr; /*!< \brief y Force coefficient. */ + su2double* CFz = nullptr; /*!< \brief z Force coefficient. */ + su2double* CMx = nullptr; /*!< \brief x Moment coefficient. */ + su2double* CMy = nullptr; /*!< \brief y Moment coefficient. */ + su2double* CMz = nullptr; /*!< \brief z Moment coefficient. */ + su2double* CoPx = nullptr; /*!< \brief x Moment coefficient. */ + su2double* CoPy = nullptr; /*!< \brief y Moment coefficient. */ + su2double* CoPz = nullptr; /*!< \brief z Moment coefficient. */ + su2double* CT = nullptr; /*!< \brief Thrust coefficient. */ + su2double* CQ = nullptr; /*!< \brief Torque coefficient. */ + su2double* CMerit = nullptr; /*!< \brief Rotor Figure of Merit. */ + int _size = 0; /*!< \brief Array size. */ + + void allocate(int size); /*!< \brief Allocates arrays. */ + + void setZero(int i); /*!< \brief Sets all values to zero at a particular index. */ + void setZero() { /*!< \brief Sets all values to zero for all indices. */ + for(int i=0; i<_size; ++i) setZero(i); + } + + AeroCoeffsArray(int size = 0) : _size(size) { if(size) allocate(size); } + + ~AeroCoeffsArray(); + }; + /*! + * \brief Scalar version of the coefficients type. + */ + struct AeroCoeffs { + su2double CD,CL,CSF,CEff,CFx,CFy,CFz,CMx,CMy,CMz,CoPx,CoPy,CoPz,CT,CQ,CMerit; + + void setZero() { + CD=CL=CSF=CEff=CFx=CFy=CFz=CMx=CMy=CMz=CoPx=CoPy=CoPz=CT=CQ=CMerit=0.0; + } + + AeroCoeffs() { setZero(); } }; - using Coefficients = AerodynamicCoefficients; - using CoefficientsArray = AerodynamicCoefficients; - CoefficientsArray InvCoeff; /*!< \brief Inviscid pressure contributions for each boundary. */ - CoefficientsArray SurfaceInvCoeff; /*!< \brief Inviscid pressure contributions for each monitoring boundary. */ - Coefficients AllBoundInvCoeff; /*!< \brief Total pressure contribution for all the boundaries. */ + AeroCoeffsArray InvCoeff; /*!< \brief Inviscid pressure contributions for each boundary. */ + AeroCoeffsArray SurfaceInvCoeff; /*!< \brief Inviscid pressure contributions for each monitoring boundary. */ + AeroCoeffs AllBoundInvCoeff; /*!< \brief Total pressure contribution for all the boundaries. */ - CoefficientsArray MntCoeff; /*!< \brief Inviscid momentum contributions for each boundary. */ - CoefficientsArray SurfaceMntCoeff; /*!< \brief Inviscid momentum contributions for each monitoring boundary. */ - Coefficients AllBoundMntCoeff; /*!< \brief Total momentum contribution for all the boundaries. */ + AeroCoeffsArray MntCoeff; /*!< \brief Inviscid momentum contributions for each boundary. */ + AeroCoeffsArray SurfaceMntCoeff; /*!< \brief Inviscid momentum contributions for each monitoring boundary. */ + AeroCoeffs AllBoundMntCoeff; /*!< \brief Total momentum contribution for all the boundaries. */ - CoefficientsArray SurfaceCoeff; /*!< \brief Totals for each monitoring surface. */ - Coefficients TotalCoeff; /*!< \brief Totals for all boundaries. */ + AeroCoeffsArray SurfaceCoeff; /*!< \brief Totals for each monitoring surface. */ + AeroCoeffs TotalCoeff; /*!< \brief Totals for all boundaries. */ su2double AllBound_CEquivArea_Inv = 0.0, /*!< \brief equivalent area coefficient (inviscid contribution) for all the boundaries. */ diff --git a/SU2_CFD/include/solvers/CNSSolver.hpp b/SU2_CFD/include/solvers/CNSSolver.hpp index a37b5a9f41dc..64a97fb0ac3a 100644 --- a/SU2_CFD/include/solvers/CNSSolver.hpp +++ b/SU2_CFD/include/solvers/CNSSolver.hpp @@ -40,9 +40,9 @@ class CNSSolver final : public CEulerSolver { su2double Viscosity_Inf; /*!< \brief Viscosity at the infinity. */ su2double Tke_Inf; /*!< \brief Turbulent kinetic energy at the infinity. */ - CoefficientsArray ViscCoeff; /*!< \brief Viscous contributions for each boundary. */ - CoefficientsArray SurfaceViscCoeff; /*!< \brief Viscous contributions for each monitoring boundary. */ - Coefficients AllBoundViscCoeff; /*!< \brief Total pressure contribution for all the boundaries. */ + AeroCoeffsArray ViscCoeff; /*!< \brief Viscous contributions for each boundary. */ + AeroCoeffsArray SurfaceViscCoeff; /*!< \brief Viscous contributions for each monitoring boundary. */ + AeroCoeffs AllBoundViscCoeff; /*!< \brief Total pressure contribution for all the boundaries. */ su2double *Surface_Buffet_Metric = nullptr, /*!< \brief Integrated separation sensor for each monitoring surface. */ diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 680eef84b04b..574ce8f8fd6a 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -32,6 +32,29 @@ #include "../../include/gradients/computeGradientsLeastSquares.hpp" #include "../../include/limiters/computeLimiters.hpp" +void CEulerSolver::AeroCoeffsArray::allocate(int size) { + _size = size; + CD = new su2double[size]; CL = new su2double[size]; CSF = new su2double[size]; CEff = new su2double[size]; + CFx = new su2double[size]; CFy = new su2double[size]; CFz = new su2double[size]; CMx = new su2double[size]; + CMy = new su2double[size]; CMz = new su2double[size]; CoPx = new su2double[size]; CoPy = new su2double[size]; + CoPz = new su2double[size]; CT = new su2double[size]; CQ = new su2double[size]; CMerit = new su2double[size]; + setZero(); +} + +CEulerSolver::AeroCoeffsArray::~AeroCoeffsArray() { + delete [] CD; delete [] CL; delete [] CSF; delete [] CEff; + delete [] CFx; delete [] CFy; delete [] CFz; delete [] CMx; + delete [] CMy; delete [] CMz; delete [] CoPx; delete [] CoPy; + delete [] CoPz; delete [] CT; delete [] CQ; delete [] CMerit; +} + +void CEulerSolver::AeroCoeffsArray::setZero(int i) { + CD[i] = CL[i] = CSF[i] = CEff[i] = 0.0; + CFx[i] = CFy[i] = CFz[i] = CMx[i] = 0.0; + CMy[i] = CMz[i] = CoPx[i] = CoPy[i] = 0.0; + CoPz[i] = CT[i] = CQ[i] = CMerit[i] = 0.0; +} + CEulerSolver::CEulerSolver(void) : CSolver() { /*--- Fixed CL mode initialization ---*/ From 46fddd8377a91090e551905cba566f9c8a889679 Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Fri, 31 Jan 2020 20:14:20 +0000 Subject: [PATCH 070/118] merge still not ok, files left behind --- .../elasticity/CFEAMeshElasticity.hpp | 80 ------------ .../elasticity/CFEM_DielectricElastomer.hpp | 78 ------------ .../numerics/elasticity/CFEM_IdealDE.hpp | 79 ------------ .../elasticity/CFEM_Knowles_NearInc.hpp | 82 ------------ .../elasticity/CFEM_NeoHookean_Comp.hpp | 79 ------------ .../elasticity/CFEAMeshElasticity.cpp | 92 -------------- .../elasticity/CFEM_DielectricElastomer.cpp | 86 ------------- .../src/numerics/elasticity/CFEM_IdealDE.cpp | 112 ---------------- .../elasticity/CFEM_Knowles_NearInc.cpp | 120 ------------------ .../elasticity/CFEM_NeoHookean_Comp.cpp | 120 ------------------ 10 files changed, 928 deletions(-) delete mode 100644 SU2_CFD/include/numerics/elasticity/CFEAMeshElasticity.hpp delete mode 100644 SU2_CFD/include/numerics/elasticity/CFEM_DielectricElastomer.hpp delete mode 100644 SU2_CFD/include/numerics/elasticity/CFEM_IdealDE.hpp delete mode 100644 SU2_CFD/include/numerics/elasticity/CFEM_Knowles_NearInc.hpp delete mode 100644 SU2_CFD/include/numerics/elasticity/CFEM_NeoHookean_Comp.hpp delete mode 100644 SU2_CFD/src/numerics/elasticity/CFEAMeshElasticity.cpp delete mode 100644 SU2_CFD/src/numerics/elasticity/CFEM_DielectricElastomer.cpp delete mode 100644 SU2_CFD/src/numerics/elasticity/CFEM_IdealDE.cpp delete mode 100644 SU2_CFD/src/numerics/elasticity/CFEM_Knowles_NearInc.cpp delete mode 100644 SU2_CFD/src/numerics/elasticity/CFEM_NeoHookean_Comp.cpp diff --git a/SU2_CFD/include/numerics/elasticity/CFEAMeshElasticity.hpp b/SU2_CFD/include/numerics/elasticity/CFEAMeshElasticity.hpp deleted file mode 100644 index e60caac7f9ff..000000000000 --- a/SU2_CFD/include/numerics/elasticity/CFEAMeshElasticity.hpp +++ /dev/null @@ -1,80 +0,0 @@ -/*! - * \file CFEAMeshNumerics.hpp - * \brief Declaration and inlines of the class to compute - * the stiffness matrix of a linear, pseudo-elastic mesh problem. - * \author Ruben Sanchez - * \version 7.0.1 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "CFEALinearElasticity.hpp" - - -class CFEAMeshElasticity final : public CFEALinearElasticity { - - bool element_based; - bool stiffness_set; - -public: - /*! - * \brief Default constructor deleted as instantiation with no argument would not allocate fields. - */ - CFEAMeshElasticity() = delete; - - /*! - * \brief Constructor of the class. - * \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. - */ - CFEAMeshElasticity(unsigned short val_nDim, unsigned short val_nVar, unsigned long val_nElem, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CFEAMeshElasticity(void) = default; - - /*! - * \brief Set the element-based local Young's modulus in mesh problems - * \param[in] iElem - Element index. - * \param[in] val_E - Value of elasticity modulus. - */ - inline void SetMeshElasticProperties(unsigned long iElem, su2double val_E) override { - if (element_based) E_i[iElem] = val_E; - } - -private: - /*! - * \brief Set element material properties. - * \param[in] element_container - Element defining the properties. - * \param[in] config - Definition of the problem. - */ - inline void SetElement_Properties(const CElement *element, CConfig *config) override { - if (element_based) { - E = E_i[element->Get_iProp()]; - Compute_Lame_Parameters(); - } - } - -}; diff --git a/SU2_CFD/include/numerics/elasticity/CFEM_DielectricElastomer.hpp b/SU2_CFD/include/numerics/elasticity/CFEM_DielectricElastomer.hpp deleted file mode 100644 index 9e9308ebe97d..000000000000 --- a/SU2_CFD/include/numerics/elasticity/CFEM_DielectricElastomer.hpp +++ /dev/null @@ -1,78 +0,0 @@ -/*! - * \file CFEM_DielectricElastomer.hpp - * \brief Class for computing the constitutive and stress tensors for a dielectric elastomer. - * \author Ruben Sanchez - * \version 7.0.1 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "CFEANonlinearElasticity.hpp" - - -/*! - * \class CFEM_DielectricElastomer - * \brief Class for computing the constitutive and stress tensors for a dielectric elastomer. - * \ingroup FEM_Discr - * \author R.Sanchez - * \version 7.0.1 "Blackbird" - */ -class CFEM_DielectricElastomer final : public CFEANonlinearElasticity { - -public: - /*! - * \brief Constructor of the class. - * \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. - */ - CFEM_DielectricElastomer(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CFEM_DielectricElastomer(void) = default; - -private: - /*! - * \brief Compute the plane stress term. - * \param[in,out] element_container - The finite element. - * \param[in] config - Definition of the problem. - */ - inline void Compute_Plane_Stress_Term(CElement *element_container, CConfig *config) override { }; - - /*! - * \brief Compute the constitutive matrix. - * \param[in,out] element_container - The finite element. - * \param[in] config - Definition of the problem. - */ - void Compute_Constitutive_Matrix(CElement *element_container, CConfig *config) override; - - /*! - * \brief Compute the stress tensor. - * \param[in,out] element_container - The finite element. - * \param[in] config - Definition of the problem. - */ - void Compute_Stress_Tensor(CElement *element_container, CConfig *config) override; - -}; diff --git a/SU2_CFD/include/numerics/elasticity/CFEM_IdealDE.hpp b/SU2_CFD/include/numerics/elasticity/CFEM_IdealDE.hpp deleted file mode 100644 index 7d040cac41dc..000000000000 --- a/SU2_CFD/include/numerics/elasticity/CFEM_IdealDE.hpp +++ /dev/null @@ -1,79 +0,0 @@ -/*! - * \file CFEM_IdealDE.hpp - * \brief Class for computing the constitutive and stress tensors for a nearly-incompressible ideal DE. - * \author Ruben Sanchez - * \version 7.0.1 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "CFEANonlinearElasticity.hpp" - -/*! - * \class CFEM_IdealDE - * \brief Class for computing the constitutive and stress tensors for a nearly-incompressible ideal DE. - * \ingroup FEM_Discr - * \author R.Sanchez - * \version 7.0.1 "Blackbird" - */ -class CFEM_IdealDE final : public CFEANonlinearElasticity { - - su2double trbbar, Eg, Eg23, Ek, Pr; /*!< \brief Variables of the model calculation. */ - -public: - /*! - * \brief Constructor of the class. - * \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. - */ - CFEM_IdealDE(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CFEM_IdealDE(void) = default; - -private: - /*! - * \brief Compute the plane stress term. - * \param[in,out] element_container - The finite element. - * \param[in] config - Definition of the problem. - */ - void Compute_Plane_Stress_Term(CElement *element_container, CConfig *config) override; - - /*! - * \brief Compute the constitutive matrix. - * \param[in,out] element_container - The finite element. - * \param[in] config - Definition of the problem. - */ - void Compute_Constitutive_Matrix(CElement *element_container, CConfig *config) override; - - /*! - * \brief Compute the stress tensor. - * \param[in,out] element_container - The finite element. - * \param[in] config - Definition of the problem. - */ - void Compute_Stress_Tensor(CElement *element_container, CConfig *config) override; - -}; diff --git a/SU2_CFD/include/numerics/elasticity/CFEM_Knowles_NearInc.hpp b/SU2_CFD/include/numerics/elasticity/CFEM_Knowles_NearInc.hpp deleted file mode 100644 index ac991d586074..000000000000 --- a/SU2_CFD/include/numerics/elasticity/CFEM_Knowles_NearInc.hpp +++ /dev/null @@ -1,82 +0,0 @@ -/*! - * \file CFEM_Knowles_NearInc.hpp - * \brief Class for computing the constitutive and stress tensors - * for the Knowles nearly-incompressible material. - * \author Ruben Sanchez - * \version 7.0.1 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "CFEANonlinearElasticity.hpp" - - -/*! - * \class CFEM_NeoHookean_Comp - * \brief Constitutive and stress tensors for a Knowles stored-energy function, nearly incompressible. - * \ingroup FEM_Discr - * \author R.Sanchez - * \version 7.0.1 "Blackbird" - */ -class CFEM_Knowles_NearInc final : public CFEANonlinearElasticity { - - su2double trbbar, term1, term2, Ek, Pr; /*!< \brief Variables of the model calculation. */ - su2double Bk, Nk; /*!< \brief Parameters b and n of the model. */ - -public: - /*! - * \brief Constructor of the class. - * \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. - */ - CFEM_Knowles_NearInc(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CFEM_Knowles_NearInc(void) = default; - -private: - /*! - * \brief Compute the plane stress term. - * \param[in,out] element_container - The finite element. - * \param[in] config - Definition of the problem. - */ - void Compute_Plane_Stress_Term(CElement *element_container, CConfig *config) override; - - /*! - * \brief Compute the constitutive matrix. - * \param[in,out] element_container - The finite element. - * \param[in] config - Definition of the problem. - */ - void Compute_Constitutive_Matrix(CElement *element_container, CConfig *config) override; - - /*! - * \brief Compute the stress tensor. - * \param[in,out] element_container - The finite element. - * \param[in] config - Definition of the problem. - */ - void Compute_Stress_Tensor(CElement *element_container, CConfig *config) override; - -}; diff --git a/SU2_CFD/include/numerics/elasticity/CFEM_NeoHookean_Comp.hpp b/SU2_CFD/include/numerics/elasticity/CFEM_NeoHookean_Comp.hpp deleted file mode 100644 index 548abf84ae68..000000000000 --- a/SU2_CFD/include/numerics/elasticity/CFEM_NeoHookean_Comp.hpp +++ /dev/null @@ -1,79 +0,0 @@ -/*! - * \file CFEM_NeoHookean_Comp.hpp - * \brief Compressible Neo-Hookean FE numerics class. - * \author Ruben Sanchez - * \version 7.0.1 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "CFEANonlinearElasticity.hpp" - - -/*! - * \class CFEM_NeoHookean_Comp - * \brief Class for computing the constitutive and stress tensors for a neo-Hookean material model, compressible. - * \ingroup FEM_Discr - * \author R.Sanchez - * \version 7.0.1 "Blackbird" - */ -class CFEM_NeoHookean_Comp final : public CFEANonlinearElasticity { - -public: - /*! - * \brief Constructor of the class. - * \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. - */ - CFEM_NeoHookean_Comp(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CFEM_NeoHookean_Comp(void) = default; - -private: - /*! - * \brief Compute the plane stress term. - * \param[in,out] element_container - The finite element. - * \param[in] config - Definition of the problem. - */ - void Compute_Plane_Stress_Term(CElement *element_container, CConfig *config) override; - - /*! - * \brief Compute the constitutive matrix. - * \param[in,out] element_container - The finite element. - * \param[in] config - Definition of the problem. - */ - void Compute_Constitutive_Matrix(CElement *element_container, CConfig *config) override; - - /*! - * \brief Compute the stress tensor. - * \param[in,out] element_container - The finite element. - * \param[in] config - Definition of the problem. - */ - void Compute_Stress_Tensor(CElement *element_container, CConfig *config) override; - -}; - diff --git a/SU2_CFD/src/numerics/elasticity/CFEAMeshElasticity.cpp b/SU2_CFD/src/numerics/elasticity/CFEAMeshElasticity.cpp deleted file mode 100644 index c88af379a8d1..000000000000 --- a/SU2_CFD/src/numerics/elasticity/CFEAMeshElasticity.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/*! - * \file CFEAMeshElasticity.cpp - * \brief This file contains the routines for setting the mesh pseudo-elastic problem. - * \author Ruben Sanchez - * \version 7.0.1 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../include/numerics/elasticity/CFEAMeshElasticity.hpp" - - -CFEAMeshElasticity::CFEAMeshElasticity(unsigned short val_nDim, unsigned short val_nVar, - unsigned long val_nElem, CConfig *config) : - CFEALinearElasticity() { - DV_Val = NULL; - FAux_Dead_Load = NULL; - Rho_s_i = NULL; - Rho_s_DL_i = NULL; - Nu_i = NULL; - - nDim = val_nDim; - nVar = val_nVar; - - unsigned long iVar; - - E = config->GetDeform_ElasticityMod(); - Nu = config->GetDeform_PoissonRatio(); - Compute_Lame_Parameters(); - - switch (config->GetDeform_Stiffness_Type()) { - case INVERSE_VOLUME: - case SOLID_WALL_DISTANCE: - element_based = true; - Nu = config->GetDeform_Coeff(); - break; - case CONSTANT_STIFFNESS: - element_based = false; - break; - } - - E_i = NULL; - if (element_based){ - E_i = new su2double[val_nElem]; - for (iVar = 0; iVar < val_nElem; iVar++){ - E_i[iVar] = E; - } - } - - KAux_ab = new su2double* [nDim]; - for (iVar = 0; iVar < nDim; iVar++) { - KAux_ab[iVar] = new su2double[nDim]; - } - - unsigned short nStrain = (nDim==2) ? DIM_STRAIN_2D : DIM_STRAIN_3D; - unsigned short nNodes = (nDim==2) ? NNODES_2D : NNODES_3D; - - Ba_Mat = new su2double* [nStrain]; - Bb_Mat = new su2double* [nStrain]; - D_Mat = new su2double* [nStrain]; - Ni_Vec = new su2double [nNodes]; - GradNi_Ref_Mat = new su2double* [nNodes]; - GradNi_Curr_Mat = new su2double* [nNodes]; - for (iVar = 0; iVar < nStrain; iVar++) { - Ba_Mat[iVar] = new su2double[nDim]; - Bb_Mat[iVar] = new su2double[nDim]; - D_Mat[iVar] = new su2double[nStrain]; - } - for (iVar = 0; iVar < nNodes; iVar++) { - GradNi_Ref_Mat[iVar] = new su2double[nDim]; - GradNi_Curr_Mat[iVar] = new su2double[nDim]; - } - -} diff --git a/SU2_CFD/src/numerics/elasticity/CFEM_DielectricElastomer.cpp b/SU2_CFD/src/numerics/elasticity/CFEM_DielectricElastomer.cpp deleted file mode 100644 index 3af19ccf2b8f..000000000000 --- a/SU2_CFD/src/numerics/elasticity/CFEM_DielectricElastomer.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/*! - * \file CFEM_DielectricElastomer.cpp - * \brief This file contains the routines for setting the tangent matrix and residual - * of a FEM nonlinear elastic structural problem. - * \author R. Sanchez - * \version 7.0.1 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../include/numerics/elasticity/CFEM_DielectricElastomer.hpp" - - -CFEM_DielectricElastomer::CFEM_DielectricElastomer(unsigned short val_nDim, unsigned short val_nVar, - CConfig *config) : CFEANonlinearElasticity(val_nDim, val_nVar, config) {} - - -void CFEM_DielectricElastomer::Compute_Constitutive_Matrix(CElement *element, CConfig *config) { - - /*--- This reduces performance by now, but it is temporal ---*/ - - if (nDim == 2){ - D_Mat[0][0] = 0.0; D_Mat[0][1] = 0.0; D_Mat[0][2] = 0.0; - D_Mat[1][0] = 0.0; D_Mat[1][1] = 0.0; D_Mat[1][2] = 0.0; - D_Mat[2][0] = 0.0; D_Mat[2][1] = 0.0; D_Mat[2][2] = 0.0; - } - else { - D_Mat[0][0] = 0.0; D_Mat[0][1] = 0.0; D_Mat[0][2] = 0.0; D_Mat[0][3] = 0.0; D_Mat[0][4] = 0.0; D_Mat[0][5] = 0.0; - D_Mat[1][0] = 0.0; D_Mat[1][1] = 0.0; D_Mat[1][2] = 0.0; D_Mat[1][3] = 0.0; D_Mat[1][4] = 0.0; D_Mat[1][5] = 0.0; - D_Mat[2][0] = 0.0; D_Mat[2][1] = 0.0; D_Mat[2][2] = 0.0; D_Mat[2][3] = 0.0; D_Mat[2][4] = 0.0; D_Mat[2][5] = 0.0; - D_Mat[3][0] = 0.0; D_Mat[3][1] = 0.0; D_Mat[3][2] = 0.0; D_Mat[3][3] = 0.0; D_Mat[3][4] = 0.0; D_Mat[3][5] = 0.0; - D_Mat[4][0] = 0.0; D_Mat[4][1] = 0.0; D_Mat[4][2] = 0.0; D_Mat[4][3] = 0.0; D_Mat[4][4] = 0.0; D_Mat[4][5] = 0.0; - D_Mat[5][0] = 0.0; D_Mat[5][1] = 0.0; D_Mat[5][2] = 0.0; D_Mat[5][3] = 0.0; D_Mat[5][4] = 0.0; D_Mat[5][5] = 0.0; - } - - -} - -void CFEM_DielectricElastomer::Compute_Stress_Tensor(CElement *element, CConfig *config) { - - unsigned short iDim, jDim; - - su2double E0 = 0.0, E1 = 0.0, E2 = 0.0; - su2double E0_2 = 0.0, E1_2 = 0.0, E2_2 = 0.0; - su2double E_2 = 0.0; - - Compute_FmT_Mat(); - - for (iDim = 0; iDim < nDim; iDim++){ - EField_Curr_Unit[iDim] = 0.0; - for (jDim = 0; jDim < nDim; jDim++){ - EField_Curr_Unit[iDim] += FmT_Mat[iDim][jDim] * EField_Ref_Unit[jDim]; - } - } - - E0 = EFieldMod_Ref*EField_Curr_Unit[0]; E0_2 = pow(E0,2); - E1 = EFieldMod_Ref*EField_Curr_Unit[1]; E1_2 = pow(E1,2); - if (nDim == 3) {E2 = EFieldMod_Ref*EField_Curr_Unit[2]; E2_2 = pow(E2,2);} - - E_2 = E0_2+E1_2+E2_2; - - Stress_Tensor[0][0] = ke_DE*(E0_2-0.5*E_2); Stress_Tensor[0][1] = ke_DE*E0*E1; Stress_Tensor[0][2] = ke_DE*E0*E2; - Stress_Tensor[1][0] = ke_DE*E1*E0; Stress_Tensor[1][1] = ke_DE*(E1_2-0.5*E_2); Stress_Tensor[1][2] = ke_DE*E1*E2; - Stress_Tensor[2][0] = ke_DE*E2*E0; Stress_Tensor[2][1] = ke_DE*E2*E1; Stress_Tensor[2][2] = ke_DE*(E2_2-0.5*E_2); - - -} - diff --git a/SU2_CFD/src/numerics/elasticity/CFEM_IdealDE.cpp b/SU2_CFD/src/numerics/elasticity/CFEM_IdealDE.cpp deleted file mode 100644 index 721a488798bd..000000000000 --- a/SU2_CFD/src/numerics/elasticity/CFEM_IdealDE.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/*! - * \file CFEM_IdealDE.cpp - * \brief Definition of ideal dielectric elastomer. - * \author R. Sanchez - * \version 7.0.1 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../include/numerics/elasticity/CFEM_IdealDE.hpp" - - -CFEM_IdealDE::CFEM_IdealDE(unsigned short val_nDim, unsigned short val_nVar, - CConfig *config) : CFEANonlinearElasticity(val_nDim, val_nVar, config) { - - /* -- The formulation adopted for this material model has been described by: - * -- - * -- Zhao, X. and Suo, Z., Method to analyze programmable deformation of - * -- dielectric elastomer layers, Applied Physics Letters 93, 251902 (2008). - * -- - * -- http://imechanica.org/node/4234 - */ - - trbbar = 0.0; - Eg = 0.0; - Eg23 = 0.0; - Ek = 0.0; - Pr = 0.0; - -} - -void CFEM_IdealDE::Compute_Plane_Stress_Term(CElement *element, CConfig *config) { - - SU2_MPI::Error("This material model cannot (yet) be used for plane stress.", CURRENT_FUNCTION); - -} - -void CFEM_IdealDE::Compute_Constitutive_Matrix(CElement *element, CConfig *config) { - - /* -- Zhao, X. and Suo, Z. (2008) (full reference in class constructor). ---*/ - - if (nDim == 2){ - - D_Mat[0][0] = Eg23*(b_Mat_Iso[0][0]+trbbar)+Ek; - D_Mat[1][1] = Eg23*(b_Mat_Iso[1][1]+trbbar)+Ek; - - D_Mat[0][1] = -Eg23*(b_Mat_Iso[0][0]+b_Mat_Iso[1][1]-trbbar)+Ek; - D_Mat[1][0] = -Eg23*(b_Mat_Iso[0][0]+b_Mat_Iso[1][1]-trbbar)+Ek; - - D_Mat[0][2] = Eg23*b_Mat_Iso[0][1]/2.0; - D_Mat[2][0] = Eg23*b_Mat_Iso[0][1]/2.0; - - D_Mat[1][2] = Eg23*b_Mat_Iso[0][1]/2.0; - D_Mat[2][1] = Eg23*b_Mat_Iso[0][1]/2.0; - - D_Mat[2][2] = Eg*(b_Mat_Iso[0][0]+b_Mat_Iso[1][1])/2.0; - - } - else { - SU2_MPI::Error("This material model cannot be used for 3D yet.", CURRENT_FUNCTION); - } - -} - -void CFEM_IdealDE::Compute_Stress_Tensor(CElement *element, CConfig *config) { - - /* -- Zhao, X. and Suo, Z. (2008) (full reference in class constructor). ---*/ - - unsigned short iVar, jVar; - su2double dij = 0.0; - - /*--- Compute the isochoric deformation gradient Fbar and left Cauchy-Green tensor bbar ---*/ - Compute_Isochoric_F_b(); - - // Stress terms - - trbbar = (b_Mat_Iso[0][0] + b_Mat_Iso[1][1] + b_Mat_Iso[2][2]) / 3.0; - Eg = Mu / J_F; - Ek = Kappa * (2.0 * J_F - 1.0); - Pr = Kappa * (J_F - 1.0); - Eg23 = 2.0 * Eg / 3.0; - - // Stress tensor - - for (iVar = 0; iVar < 3; iVar++){ - for (jVar = 0; jVar < 3; jVar++){ - if (iVar == jVar) dij = 1.0; - else if (iVar != jVar) dij = 0.0; - Stress_Tensor[iVar][jVar] = Eg * ( b_Mat_Iso[iVar][jVar] - dij * trbbar) + dij * Pr ; - } - } - -} - diff --git a/SU2_CFD/src/numerics/elasticity/CFEM_Knowles_NearInc.cpp b/SU2_CFD/src/numerics/elasticity/CFEM_Knowles_NearInc.cpp deleted file mode 100644 index aeb6ec365219..000000000000 --- a/SU2_CFD/src/numerics/elasticity/CFEM_Knowles_NearInc.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/*! - * \file CFEM_Knowles_NearInc.cpp - * \brief FE numerics for nearly incompressible Knowles material model. - * \author R. Sanchez - * \version 7.0.1 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../include/numerics/elasticity/CFEM_Knowles_NearInc.hpp" - - -CFEM_Knowles_NearInc::CFEM_Knowles_NearInc(unsigned short val_nDim, unsigned short val_nVar, - CConfig *config) : CFEANonlinearElasticity(val_nDim, val_nVar, config) { - - /* -- The formulation adopted for this material model has been described by: - * -- - * -- Suchocki, C., A Finite Element Implementation of Knowles stored-energy function: - * -- theory, coding and applications, Archive of Mechanical Engineering, Vol. 58, pp. 319-346 (2011). - * -- - * -- DOI: 10.2478/v10180-011-0021-7 - */ - - Bk = config->GetKnowles_B(); - Nk = config->GetKnowles_N(); - - trbbar = 0.0; - Ek = 0.0; - Pr = 0.0; - -} - -void CFEM_Knowles_NearInc::Compute_Plane_Stress_Term(CElement *element, CConfig *config) { - - SU2_MPI::Error("This material model cannot (yet) be used for plane stress.",CURRENT_FUNCTION); - -} - -void CFEM_Knowles_NearInc::Compute_Constitutive_Matrix(CElement *element, CConfig *config) { - - /* -- Suchocki (2011) (full reference in class constructor). ---*/ - - /*--- Computation of the tensor cijkl ---*/ - - unsigned short iVar, jVar, kVar, lVar; - - for (iVar = 0; iVar < 3; iVar++){ - for (jVar = 0; jVar < 3; jVar++){ - for (kVar = 0; kVar < 3; kVar++){ - for (lVar = 0; lVar < 3; lVar++){ - cijkl[iVar][jVar][kVar][lVar] = - term1 * ((1.0/2.0)*( deltaij(iVar,kVar)*b_Mat_Iso[jVar][lVar] - +deltaij(jVar,lVar)*b_Mat_Iso[iVar][kVar] - +deltaij(iVar,lVar)*b_Mat_Iso[jVar][kVar] - +deltaij(jVar,kVar)*b_Mat_Iso[iVar][lVar]) - +(2.0/3.0)*(trbbar*deltaij(iVar,jVar)*deltaij(kVar,lVar) - -b_Mat_Iso[iVar][jVar]*deltaij(kVar,lVar) - -deltaij(iVar,jVar)*b_Mat_Iso[kVar][lVar])) - +term2 * ( b_Mat_Iso[iVar][jVar]*b_Mat_Iso[kVar][lVar] - - trbbar*(b_Mat_Iso[iVar][jVar]*deltaij(kVar,lVar) - +deltaij(iVar,jVar)*b_Mat_Iso[kVar][lVar]) - + pow(trbbar,2.0) * deltaij(iVar,jVar) * deltaij(kVar,lVar)) - +Kappa * (2.0 * J_F - 1.0) * deltaij(iVar,jVar) * deltaij(kVar,lVar); - - } - } - } - } - - /*--- Reorganizing the tensor into the matrix D ---*/ - - Assign_cijkl_D_Mat(); - - -} - -void CFEM_Knowles_NearInc::Compute_Stress_Tensor(CElement *element, CConfig *config) { - - /* -- Suchocki (2011) (full reference in class constructor). ---*/ - - unsigned short iVar, jVar; - - /*--- Compute the isochoric deformation gradient Fbar and left Cauchy-Green tensor bbar ---*/ - Compute_Isochoric_F_b(); - - trbbar = (b_Mat_Iso[0][0] + b_Mat_Iso[1][1] + b_Mat_Iso[2][2]) / 3.0; - term1 = (Mu / J_F) * pow((1 + (Bk / Nk) * (3.0 * trbbar - 3.0)), (Nk-1.0)); - term2 = 2.0 * (Mu / J_F) * (Bk * (Nk - 1.0) / Nk) * - pow((1.0 + (Bk / Nk) * (3.0 * trbbar - 3.0)), (Nk-2.0)); - - Ek = Kappa * (2.0 * J_F - 1.0); - Pr = Kappa * (J_F - 1.0); - - for (iVar = 0; iVar < 3; iVar++){ - for (jVar = 0; jVar < 3; jVar++){ - Stress_Tensor[iVar][jVar] = term1 * (b_Mat_Iso[iVar][jVar] - deltaij(iVar,jVar)*trbbar) + - deltaij(iVar,jVar) * Pr; - } - } - -} - diff --git a/SU2_CFD/src/numerics/elasticity/CFEM_NeoHookean_Comp.cpp b/SU2_CFD/src/numerics/elasticity/CFEM_NeoHookean_Comp.cpp deleted file mode 100644 index 18de92c0de0f..000000000000 --- a/SU2_CFD/src/numerics/elasticity/CFEM_NeoHookean_Comp.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/*! - * \file CFEM_NeoHookean_Comp.cpp - * \brief Definition of Neo-Hookean compressible material. - * \author R. Sanchez - * \version 7.0.1 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../../include/numerics/elasticity/CFEM_NeoHookean_Comp.hpp" - - -CFEM_NeoHookean_Comp::CFEM_NeoHookean_Comp(unsigned short val_nDim, - unsigned short val_nVar, - CConfig *config) : - CFEANonlinearElasticity(val_nDim, val_nVar, config) { -} - -void CFEM_NeoHookean_Comp::Compute_Plane_Stress_Term(CElement *element, CConfig *config) { - - su2double j_red = 1.0; - su2double fx = 0.0, fpx = 1.0; - su2double xkm1 = 1.0, xk = 1.0; - su2double cte = 0.0; - - unsigned short iNR, nNR; - su2double NRTOL; - - // Maximum number of iterations and tolerance (relative) - nNR = 10; - NRTOL = 1E-25; - - // j_red: reduced jacobian, for the 2x2 submatrix of F - j_red = F_Mat[0][0] * F_Mat[1][1] - F_Mat[1][0] * F_Mat[0][1]; - // cte: constant term in the NR method - cte = Lambda*log(j_red) - Mu; - - // f(f33) = mu*f33^2 + lambda*ln(f33) + (lambda*ln(j_red)-mu) = 0 - // f'(f33) = 2*mu*f33 + lambda/f33 - - for (iNR = 0; iNR < nNR; iNR++) { - fx = Mu*pow(xk,2.0) + Lambda*log(xk) + cte; - fpx = 2*Mu*xk + (Lambda / xk); - xkm1 = xk - fx / fpx; - if (((xkm1 - xk) / xk) < NRTOL) break; - xk = xkm1; - } - - f33 = xkm1; - -} - -void CFEM_NeoHookean_Comp::Compute_Constitutive_Matrix(CElement *element, CConfig *config) { - - su2double Mu_p = 0.0, Lambda_p = 0.0; - - /*--- This can be done in a better way ---*/ - if (J_F != 0.0) { - Mu_p = (Mu - Lambda*log(J_F))/J_F; - Lambda_p = Lambda/J_F; - } - - /*--- Assuming plane strain ---*/ - - su2double Lbd_2Mu = Lambda_p + 2.0 * Mu_p; - - if (nDim == 2) { - D_Mat[0][0] = Lbd_2Mu; D_Mat[0][1] = Lambda_p; D_Mat[0][2] = 0.0; - D_Mat[1][0] = Lambda_p; D_Mat[1][1] = Lbd_2Mu; D_Mat[1][2] = 0.0; - D_Mat[2][0] = 0.0; D_Mat[2][1] = 0.0; D_Mat[2][2] = Mu_p; - } - else { - D_Mat[0][0] = Lbd_2Mu; D_Mat[0][1] = Lambda_p; D_Mat[0][2] = Lambda_p; D_Mat[0][3] = 0.0; D_Mat[0][4] = 0.0; D_Mat[0][5] = 0.0; - D_Mat[1][0] = Lambda_p; D_Mat[1][1] = Lbd_2Mu; D_Mat[1][2] = Lambda_p; D_Mat[1][3] = 0.0; D_Mat[1][4] = 0.0; D_Mat[1][5] = 0.0; - D_Mat[2][0] = Lambda_p; D_Mat[2][1] = Lambda_p; D_Mat[2][2] = Lbd_2Mu; D_Mat[2][3] = 0.0; D_Mat[2][4] = 0.0; D_Mat[2][5] = 0.0; - D_Mat[3][0] = 0.0; D_Mat[3][1] = 0.0; D_Mat[3][2] = 0.0; D_Mat[3][3] = Mu_p; D_Mat[3][4] = 0.0; D_Mat[3][5] = 0.0; - D_Mat[4][0] = 0.0; D_Mat[4][1] = 0.0; D_Mat[4][2] = 0.0; D_Mat[4][3] = 0.0; D_Mat[4][4] = Mu_p; D_Mat[4][5] = 0.0; - D_Mat[5][0] = 0.0; D_Mat[5][1] = 0.0; D_Mat[5][2] = 0.0; D_Mat[5][3] = 0.0; D_Mat[5][4] = 0.0; D_Mat[5][5] = Mu_p; - } - -} - -void CFEM_NeoHookean_Comp::Compute_Stress_Tensor(CElement *element, CConfig *config) { - - unsigned short iVar,jVar; - su2double Mu_J = 0.0, Lambda_J = 0.0; - - /*--- This can be done in a better way ---*/ - if (J_F != 0.0) { - Mu_J = Mu/J_F; - Lambda_J = Lambda/J_F; - } - - for (iVar = 0; iVar < 3; iVar++) { - for (jVar = 0; jVar < 3; jVar++) { - su2double dij = deltaij(iVar,jVar); - Stress_Tensor[iVar][jVar] = Mu_J * (b_Mat[iVar][jVar] - dij) + Lambda_J * log(J_F) * dij; - } - } - -} - From 7d0bb9b10b5e2e4e1a7b21e346dc936112cfba6b Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Fri, 31 Jan 2020 20:22:34 +0000 Subject: [PATCH 071/118] make OpenMP parallel sections easier to find by using allways a version of SU2_OMP_PARALLEL_XX for them --- Common/src/geometry/CGeometry.cpp | 2 +- SU2_CFD/src/solvers/CFEASolver.cpp | 20 ++++++++++---------- SU2_CFD/src/solvers/CMeshSolver.cpp | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index a1f31f466db3..dac9c80db61c 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -3357,7 +3357,7 @@ void CGeometry::FilterValuesAtElementCG(const vector &filter_radius, the recursion limit is reached and the full neighborhood is not considered. ---*/ unsigned long limited_searches = 0; - SU2_OMP(parallel reduction(+:limited_searches)) + SU2_OMP_PARALLEL_(reduction(+:limited_searches)) { /*--- Initialize ---*/ diff --git a/SU2_CFD/src/solvers/CFEASolver.cpp b/SU2_CFD/src/solvers/CFEASolver.cpp index cb5526a46ba9..e4b102f81ff3 100644 --- a/SU2_CFD/src/solvers/CFEASolver.cpp +++ b/SU2_CFD/src/solvers/CFEASolver.cpp @@ -2688,7 +2688,7 @@ void CFEASolver::GeneralizedAlpha_UpdateDisp(CGeometry *geometry, CSolver **solv /*--- Update displacement components of the solution. ---*/ - SU2_OMP(parallel for schedule(static,omp_chunk_size)) + SU2_OMP_PARALLEL_(for schedule(static,omp_chunk_size)) for (unsigned long iPoint = 0; iPoint < nPointDomain; iPoint++) for (unsigned short iVar = 0; iVar < nVar; iVar++) nodes->Add_DeltaSolution(iPoint, iVar, LinSysSol[iPoint*nVar+iVar]); @@ -2707,7 +2707,7 @@ void CFEASolver::GeneralizedAlpha_UpdateSolution(CGeometry *geometry, CSolver ** /*--- Compute solution at t_n+1, and update velocities and accelerations ---*/ - SU2_OMP(parallel for schedule(static,omp_chunk_size)) + SU2_OMP_PARALLEL_(for schedule(static,omp_chunk_size)) for (unsigned long iPoint = 0; iPoint < nPointDomain; iPoint++) { unsigned short iVar; @@ -2802,7 +2802,7 @@ void CFEASolver::PredictStruct_Displacement(CGeometry **fea_geometry, cout << "Higher order predictor not implemented. Solving with order 0." << endl; /*--- To nPointDomain: we need to communicate the predicted solution after setting it. ---*/ - SU2_OMP(parallel for schedule(static,omp_chunk_size)) + SU2_OMP_PARALLEL_(for schedule(static,omp_chunk_size)) for (unsigned long iPoint=0; iPoint < nPointDomain; iPoint++) { unsigned short iDim; @@ -2937,7 +2937,7 @@ void CFEASolver::SetAitken_Relaxation(CGeometry **fea_geometry, const su2double WAitken = GetWAitken_Dyn(); // To nPointDomain; we need to communicate the solutions (predicted, old and old predicted) after this routine - SU2_OMP(parallel for schedule(static,omp_chunk_size)) + SU2_OMP_PARALLEL_(for schedule(static,omp_chunk_size)) for (unsigned long iPoint=0; iPoint < nPointDomain; iPoint++) { /*--- Retrieve pointers to the predicted and calculated solutions ---*/ @@ -2962,7 +2962,7 @@ void CFEASolver::Update_StructSolution(CGeometry **fea_geometry, CConfig *fea_config, CSolver ***fea_solution) { - SU2_OMP(parallel for schedule(static,omp_chunk_size)) + SU2_OMP_PARALLEL_(for schedule(static,omp_chunk_size)) for (unsigned long iPoint=0; iPoint < nPointDomain; iPoint++) { auto valSolutionPred = fea_solution[MESH_0][FEA_SOL]->GetNodes()->GetSolution_Pred(iPoint); @@ -3055,7 +3055,7 @@ void CFEASolver::Compute_OFRefGeom(CGeometry *geometry, CSolver **solver_contain su2double objective_function = 0.0; - SU2_OMP(parallel for schedule(static,omp_chunk_size) reduction(+:objective_function)) + SU2_OMP_PARALLEL_(for schedule(static,omp_chunk_size) reduction(+:objective_function)) for (unsigned long iPoint = 0; iPoint < nPointDomain; iPoint++) { for (unsigned short iVar = 0; iVar < nVar; iVar++) { @@ -3192,7 +3192,7 @@ void CFEASolver::Compute_OFVolFrac(CGeometry *geometry, CSolver **solver_contain su2double total_volume = 0.0, integral = 0.0, discreteness = 0.0; - SU2_OMP(parallel for schedule(static,omp_chunk_size) reduction(+:total_volume,integral,discreteness)) + SU2_OMP_PARALLEL_(for schedule(static,omp_chunk_size) reduction(+:total_volume,integral,discreteness)) for (unsigned long iElem = 0; iElem < nElement; ++iElem) { /*--- count only elements that belong to the partition ---*/ if ( geometry->node[geometry->elem[iElem]->GetNode(0)]->GetDomain() ){ @@ -3247,7 +3247,7 @@ void CFEASolver::Compute_OFCompliance(CGeometry *geometry, CSolver **solver_cont su2double compliance = 0.0; - SU2_OMP(parallel for schedule(static,omp_chunk_size) reduction(+:compliance)) + SU2_OMP_PARALLEL_(for schedule(static,omp_chunk_size) reduction(+:compliance)) for (unsigned long iPoint = 0; iPoint < nPointDomain; iPoint++) { unsigned short iVar; @@ -3299,7 +3299,7 @@ void CFEASolver::Stiffness_Penalty(CGeometry *geometry, CSolver **solver, CNumer su2double totalVolume_reduce = 0.0; /*--- Loop over the elements in the domain. ---*/ - SU2_OMP(parallel for schedule(dynamic,omp_chunk_size) reduction(+:weightedValue,totalVolume)) + SU2_OMP_PARALLEL_(for schedule(dynamic,omp_chunk_size) reduction(+:weightedValue,totalVolume)) for (unsigned long iElem = 0; iElem < nElement; iElem++) { int thread = omp_get_thread_num(); @@ -3531,7 +3531,7 @@ void CFEASolver::FilterElementDensities(CGeometry *geometry, CConfig *config) /*--- "Rectify" the input, initialize the physical density with the design density (the filter function works in-place). ---*/ - SU2_OMP(parallel for schedule(static,omp_chunk_size)) + SU2_OMP_PARALLEL_(for schedule(static,omp_chunk_size)) for (auto iElem=0ul; iElemGetDesignDensity(); if (rho > 1.0) physical_rho[iElem] = 1.0; diff --git a/SU2_CFD/src/solvers/CMeshSolver.cpp b/SU2_CFD/src/solvers/CMeshSolver.cpp index f7b284db65c5..de40dcc9f607 100644 --- a/SU2_CFD/src/solvers/CMeshSolver.cpp +++ b/SU2_CFD/src/solvers/CMeshSolver.cpp @@ -483,7 +483,7 @@ void CMeshSolver::UpdateGridCoord(CGeometry *geometry, CConfig *config){ /*--- Update the grid coordinates using the solution of the linear system ---*/ /*--- LinSysSol contains the absolute x, y, z displacements. ---*/ - SU2_OMP(parallel for schedule(static,omp_chunk_size)) + SU2_OMP_PARALLEL_(for schedule(static,omp_chunk_size)) for (unsigned long iPoint = 0; iPoint < nPoint; iPoint++){ for (unsigned short iDim = 0; iDim < nDim; iDim++) { auto total_index = iPoint*nDim + iDim; @@ -528,7 +528,7 @@ void CMeshSolver::ComputeGridVelocity(CGeometry *geometry, CConfig *config){ /*--- Compute the velocity of each node in the domain of the current rank (halo nodes are not computed as the grid velocity is later communicated). ---*/ - SU2_OMP(parallel for schedule(static,omp_chunk_size)) + SU2_OMP_PARALLEL_(for schedule(static,omp_chunk_size)) for (unsigned long iPoint = 0; iPoint < nPointDomain; iPoint++) { /*--- Coordinates of the current point at n+1, n, & n-1 time levels. ---*/ From 594bfda4a994554e9a2ba3eaa9fc6b538858b3b2 Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Fri, 31 Jan 2020 20:43:27 +0000 Subject: [PATCH 072/118] cleaner handling of AD-compatible dot-product --- Common/src/linear_algebra/CSysVector.cpp | 35 ++++++++---------------- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/Common/src/linear_algebra/CSysVector.cpp b/Common/src/linear_algebra/CSysVector.cpp index eb30b02e9a2c..709e7b4d0b3d 100644 --- a/Common/src/linear_algebra/CSysVector.cpp +++ b/Common/src/linear_algebra/CSysVector.cpp @@ -207,53 +207,42 @@ void CSysVector::CopyToArray(ScalarType* u_array) const { template ScalarType CSysVector::dot(const CSysVector & u) const { -#if !defined(CODI_FORWARD_TYPE) && !defined(CODI_REVERSE_TYPE) /*--- All threads get the same "view" of the vectors and shared variable. ---*/ SU2_OMP_BARRIER dotRes = 0.0; SU2_OMP_BARRIER - /*--- Reduction over all threads in this mpi rank using the shared variable. ---*/ + /*--- Local dot product for each thread. ---*/ ScalarType sum = 0.0; PARALLEL_FOR for(auto i=0ul; i::W::Allreduce(&sum, &dotRes, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); } +#endif /*--- Make view of result consistent across threads. ---*/ SU2_OMP_BARRIER -#endif // MPI -#else // CODI_TYPE - /*--- Compatible version, no OMP reductions, no atomics, master does everything. ---*/ - SU2_OMP_BARRIER - SU2_OMP_MASTER - { - ScalarType sum = 0.0; - for(auto i=0ul; i::W::Allreduce(&sum, &dotRes, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); -#else - dotRes = sum; -#endif // MPI - } - SU2_OMP_BARRIER -#endif // CODI + return dotRes; } From 3910f3d0de1873a32cbbcb435de81dcf3754247e Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Sat, 1 Feb 2020 10:23:08 +0000 Subject: [PATCH 073/118] update version of new files to 7.0.1 --- SU2_CFD/include/numerics/CNumerics.hpp | 2 +- .../numerics/continuous_adjoint/adj_convection.hpp | 2 +- .../numerics/continuous_adjoint/adj_diffusion.hpp | 2 +- .../numerics/continuous_adjoint/adj_sources.hpp | 2 +- .../numerics/elasticity/CFEALinearElasticity.hpp | 2 +- .../include/numerics/elasticity/nonlinear_models.hpp | 10 +++++----- SU2_CFD/include/numerics/flow/convection/ausm_slau.hpp | 2 +- SU2_CFD/include/numerics/flow/convection/centered.hpp | 2 +- SU2_CFD/include/numerics/flow/convection/cusp.hpp | 2 +- SU2_CFD/include/numerics/flow/convection/fds.hpp | 2 +- SU2_CFD/include/numerics/flow/convection/fvs.hpp | 2 +- SU2_CFD/include/numerics/flow/convection/hllc.hpp | 6 +++--- SU2_CFD/include/numerics/flow/convection/roe.hpp | 6 +++--- SU2_CFD/include/numerics/flow/flow_diffusion.hpp | 2 +- SU2_CFD/include/numerics/flow/flow_sources.hpp | 6 +++--- SU2_CFD/include/numerics/heat.hpp | 10 +++++----- SU2_CFD/include/numerics/template.hpp | 2 +- SU2_CFD/include/numerics/transition.hpp | 2 +- SU2_CFD/include/numerics/turbulent/turb_convection.hpp | 2 +- SU2_CFD/include/numerics/turbulent/turb_diffusion.hpp | 2 +- SU2_CFD/include/numerics/turbulent/turb_sources.hpp | 8 ++++---- .../src/numerics/continuous_adjoint/adj_convection.cpp | 2 +- .../src/numerics/continuous_adjoint/adj_diffusion.cpp | 2 +- .../src/numerics/continuous_adjoint/adj_sources.cpp | 2 +- SU2_CFD/src/numerics/elasticity/nonlinear_models.cpp | 2 +- SU2_CFD/src/numerics/flow/convection/ausm_slau.cpp | 2 +- SU2_CFD/src/numerics/flow/convection/centered.cpp | 2 +- SU2_CFD/src/numerics/flow/convection/cusp.cpp | 2 +- SU2_CFD/src/numerics/flow/convection/fds.cpp | 2 +- SU2_CFD/src/numerics/flow/convection/fvs.cpp | 2 +- SU2_CFD/src/numerics/flow/convection/hllc.cpp | 2 +- SU2_CFD/src/numerics/flow/convection/roe.cpp | 2 +- SU2_CFD/src/numerics/flow/flow_diffusion.cpp | 2 +- SU2_CFD/src/numerics/flow/flow_sources.cpp | 2 +- SU2_CFD/src/numerics/template.cpp | 2 +- SU2_CFD/src/numerics/transition.cpp | 2 +- SU2_CFD/src/numerics/turbulent/turb_convection.cpp | 2 +- SU2_CFD/src/numerics/turbulent/turb_diffusion.cpp | 2 +- SU2_CFD/src/numerics/turbulent/turb_sources.cpp | 2 +- 39 files changed, 56 insertions(+), 56 deletions(-) diff --git a/SU2_CFD/include/numerics/CNumerics.hpp b/SU2_CFD/include/numerics/CNumerics.hpp index e4d162676d3c..43e13d5e1b81 100644 --- a/SU2_CFD/include/numerics/CNumerics.hpp +++ b/SU2_CFD/include/numerics/CNumerics.hpp @@ -3,7 +3,7 @@ * \brief Delaration of the base numerics class, the * implementation is in the CNumerics.cpp file. * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" * * SU2 Project Website: https://su2code.github.io * diff --git a/SU2_CFD/include/numerics/continuous_adjoint/adj_convection.hpp b/SU2_CFD/include/numerics/continuous_adjoint/adj_convection.hpp index 552be04ba394..b352031fff8a 100644 --- a/SU2_CFD/include/numerics/continuous_adjoint/adj_convection.hpp +++ b/SU2_CFD/include/numerics/continuous_adjoint/adj_convection.hpp @@ -3,7 +3,7 @@ * \brief Delarations of numerics classes for continuous adjoint * convective discretization. Implemented in adj_convection.cpp. * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" * * SU2 Project Website: https://su2code.github.io * diff --git a/SU2_CFD/include/numerics/continuous_adjoint/adj_diffusion.hpp b/SU2_CFD/include/numerics/continuous_adjoint/adj_diffusion.hpp index 8612c52223a3..e819365c8e98 100644 --- a/SU2_CFD/include/numerics/continuous_adjoint/adj_diffusion.hpp +++ b/SU2_CFD/include/numerics/continuous_adjoint/adj_diffusion.hpp @@ -3,7 +3,7 @@ * \brief Delarations of numerics classes for continuous adjoint * diffusion discretization. Implemented in adj_diffusion.cpp. * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" * * SU2 Project Website: https://su2code.github.io * diff --git a/SU2_CFD/include/numerics/continuous_adjoint/adj_sources.hpp b/SU2_CFD/include/numerics/continuous_adjoint/adj_sources.hpp index 95ce9a1fefe1..ddafd2864007 100644 --- a/SU2_CFD/include/numerics/continuous_adjoint/adj_sources.hpp +++ b/SU2_CFD/include/numerics/continuous_adjoint/adj_sources.hpp @@ -3,7 +3,7 @@ * \brief Delarations of numerics classes for continuous adjoint * source term integration. Implemented in adj_sources.cpp. * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" * * SU2 Project Website: https://su2code.github.io * diff --git a/SU2_CFD/include/numerics/elasticity/CFEALinearElasticity.hpp b/SU2_CFD/include/numerics/elasticity/CFEALinearElasticity.hpp index 7b1162c1a466..df0fd227a447 100644 --- a/SU2_CFD/include/numerics/elasticity/CFEALinearElasticity.hpp +++ b/SU2_CFD/include/numerics/elasticity/CFEALinearElasticity.hpp @@ -90,7 +90,7 @@ class CFEALinearElasticity : public CFEAElasticity { * \brief Particular case of linear elasticity used for mesh deformation. * \ingroup FEM_Discr * \author R.Sanchez - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" */ class CFEAMeshElasticity final : public CFEALinearElasticity { diff --git a/SU2_CFD/include/numerics/elasticity/nonlinear_models.hpp b/SU2_CFD/include/numerics/elasticity/nonlinear_models.hpp index bf8f12071723..e51c9b50bb11 100644 --- a/SU2_CFD/include/numerics/elasticity/nonlinear_models.hpp +++ b/SU2_CFD/include/numerics/elasticity/nonlinear_models.hpp @@ -2,7 +2,7 @@ * \file nonlinear_models.hpp * \brief Declarations of nonlinear constitutive models. * \author Ruben Sanchez - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" * * SU2 Project Website: https://su2code.github.io * @@ -35,7 +35,7 @@ * \brief Class for computing the constitutive and stress tensors for a neo-Hookean material model, compressible. * \ingroup FEM_Discr * \author R.Sanchez - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" */ class CFEM_NeoHookean_Comp final : public CFEANonlinearElasticity { @@ -83,7 +83,7 @@ class CFEM_NeoHookean_Comp final : public CFEANonlinearElasticity { * \brief Constitutive and stress tensors for a Knowles stored-energy function, nearly incompressible. * \ingroup FEM_Discr * \author R.Sanchez - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" */ class CFEM_Knowles_NearInc final : public CFEANonlinearElasticity { @@ -134,7 +134,7 @@ class CFEM_Knowles_NearInc final : public CFEANonlinearElasticity { * \brief Class for computing the constitutive and stress tensors for a dielectric elastomer. * \ingroup FEM_Discr * \author R.Sanchez - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" */ class CFEM_DielectricElastomer final : public CFEANonlinearElasticity { @@ -182,7 +182,7 @@ class CFEM_DielectricElastomer final : public CFEANonlinearElasticity { * \brief Class for computing the constitutive and stress tensors for a nearly-incompressible ideal DE. * \ingroup FEM_Discr * \author R.Sanchez - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" */ class CFEM_IdealDE final : public CFEANonlinearElasticity { diff --git a/SU2_CFD/include/numerics/flow/convection/ausm_slau.hpp b/SU2_CFD/include/numerics/flow/convection/ausm_slau.hpp index 384d107e6f0c..3139fea00425 100644 --- a/SU2_CFD/include/numerics/flow/convection/ausm_slau.hpp +++ b/SU2_CFD/include/numerics/flow/convection/ausm_slau.hpp @@ -3,7 +3,7 @@ * \brief Declaration of numerics classes for the AUSM family of schemes, * including SLAU. The implementation is in ausm.cpp. * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" * * SU2 Project Website: https://su2code.github.io * diff --git a/SU2_CFD/include/numerics/flow/convection/centered.hpp b/SU2_CFD/include/numerics/flow/convection/centered.hpp index 82d306fc7286..d093e3e6d353 100644 --- a/SU2_CFD/include/numerics/flow/convection/centered.hpp +++ b/SU2_CFD/include/numerics/flow/convection/centered.hpp @@ -3,7 +3,7 @@ * \brief Delaration of numerics classes for centered schemes, * the implementation is in centered.cpp. * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" * * SU2 Project Website: https://su2code.github.io * diff --git a/SU2_CFD/include/numerics/flow/convection/cusp.hpp b/SU2_CFD/include/numerics/flow/convection/cusp.hpp index 6e22a217244b..e62f9c453075 100644 --- a/SU2_CFD/include/numerics/flow/convection/cusp.hpp +++ b/SU2_CFD/include/numerics/flow/convection/cusp.hpp @@ -2,7 +2,7 @@ * \file cusp.hpp * \brief Declaration of the CUSP numerics class. * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" * * SU2 Project Website: https://su2code.github.io * diff --git a/SU2_CFD/include/numerics/flow/convection/fds.hpp b/SU2_CFD/include/numerics/flow/convection/fds.hpp index 4a36fc4b404c..7e962ef88d27 100644 --- a/SU2_CFD/include/numerics/flow/convection/fds.hpp +++ b/SU2_CFD/include/numerics/flow/convection/fds.hpp @@ -3,7 +3,7 @@ * \brief Declarations of classes for Flux-Difference-Spliting schemes, * the implementations are in fds.cpp * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" * * SU2 Project Website: https://su2code.github.io * diff --git a/SU2_CFD/include/numerics/flow/convection/fvs.hpp b/SU2_CFD/include/numerics/flow/convection/fvs.hpp index 748ff0f96f2e..9eedb36749c9 100644 --- a/SU2_CFD/include/numerics/flow/convection/fvs.hpp +++ b/SU2_CFD/include/numerics/flow/convection/fvs.hpp @@ -3,7 +3,7 @@ * \brief Delarations of classes for Flux-Vector-Spliting schemes, * the implementations are in fvs.cpp. * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" * * SU2 Project Website: https://su2code.github.io * diff --git a/SU2_CFD/include/numerics/flow/convection/hllc.hpp b/SU2_CFD/include/numerics/flow/convection/hllc.hpp index d57779674b65..b148bcde5224 100644 --- a/SU2_CFD/include/numerics/flow/convection/hllc.hpp +++ b/SU2_CFD/include/numerics/flow/convection/hllc.hpp @@ -2,7 +2,7 @@ * \file hllc.hpp * \brief Declaration of HLLC numerics classes, implemented in hllc.cpp. * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" * * SU2 Project Website: https://su2code.github.io * @@ -34,7 +34,7 @@ * \brief Class for solving an approximate Riemann HLLC. * \ingroup ConvDiscr * \author G. Gori, Politecnico di Milano - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" */ class CUpwHLLC_Flow final : public CNumerics { private: @@ -86,7 +86,7 @@ class CUpwHLLC_Flow final : public CNumerics { * \brief Class for solving an approximate Riemann HLLC. * \ingroup ConvDiscr * \author G. Gori, Politecnico di Milano - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" */ class CUpwGeneralHLLC_Flow final : public CNumerics { private: diff --git a/SU2_CFD/include/numerics/flow/convection/roe.hpp b/SU2_CFD/include/numerics/flow/convection/roe.hpp index ade2d66b5207..9fbb697b4f41 100644 --- a/SU2_CFD/include/numerics/flow/convection/roe.hpp +++ b/SU2_CFD/include/numerics/flow/convection/roe.hpp @@ -3,7 +3,7 @@ * \brief Delarations of numerics classes for Roe-type schemes, * implemented in roe.cpp. * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" * * SU2 Project Website: https://su2code.github.io * @@ -119,7 +119,7 @@ class CUpwRoe_Flow final : public CUpwRoeBase_Flow { * \brief Class for solving an approximate Riemann solver of L2Roe for the flow equations. * \ingroup ConvDiscr * \author E. Molina, A. Bueno, F. Palacios, P. Gomes - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" */ class CUpwL2Roe_Flow final : public CUpwRoeBase_Flow { private: @@ -149,7 +149,7 @@ class CUpwL2Roe_Flow final : public CUpwRoeBase_Flow { * \brief Class for solving an approximate Riemann solver of LMRoe for the flow equations. * \ingroup ConvDiscr * \author E. Molina, A. Bueno, F. Palacios, P. Gomes - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" */ class CUpwLMRoe_Flow final : public CUpwRoeBase_Flow { private: diff --git a/SU2_CFD/include/numerics/flow/flow_diffusion.hpp b/SU2_CFD/include/numerics/flow/flow_diffusion.hpp index 688fe8d79225..e50eb3a59d58 100644 --- a/SU2_CFD/include/numerics/flow/flow_diffusion.hpp +++ b/SU2_CFD/include/numerics/flow/flow_diffusion.hpp @@ -2,7 +2,7 @@ * \file flow_diffusion.hpp * \brief Delarations of numerics classes for viscous flux computation. * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" * * SU2 Project Website: https://su2code.github.io * diff --git a/SU2_CFD/include/numerics/flow/flow_sources.hpp b/SU2_CFD/include/numerics/flow/flow_sources.hpp index 89a4a7a8cb7a..1872a9c60325 100644 --- a/SU2_CFD/include/numerics/flow/flow_sources.hpp +++ b/SU2_CFD/include/numerics/flow/flow_sources.hpp @@ -2,7 +2,7 @@ * \file flow_sources.hpp * \brief Delarations of numerics classes for source-term integration. * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" * * SU2 Project Website: https://su2code.github.io * @@ -142,7 +142,7 @@ class CSourceBodyForce final : public CSourceBase_Flow { * \brief Class for the source term integration of a body force in the incompressible solver. * \ingroup SourceDiscr * \author T. Economon - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" */ class CSourceIncBodyForce final : public CSourceBase_Flow { su2double Body_Force_Vector[3]; @@ -169,7 +169,7 @@ class CSourceIncBodyForce final : public CSourceBase_Flow { * \brief Class for the source term integration of the Boussinesq approximation for incompressible flow. * \ingroup SourceDiscr * \author T. Economon - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" */ class CSourceBoussinesq final : public CSourceBase_Flow { su2double Gravity_Vector[3]; diff --git a/SU2_CFD/include/numerics/heat.hpp b/SU2_CFD/include/numerics/heat.hpp index 3331403e9e59..88bf8ed3641f 100644 --- a/SU2_CFD/include/numerics/heat.hpp +++ b/SU2_CFD/include/numerics/heat.hpp @@ -2,7 +2,7 @@ * \file heat.hpp * \brief Delarations of numerics classes for heat transfer problems. * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" * * SU2 Project Website: https://su2code.github.io * @@ -34,7 +34,7 @@ * \brief Class for scalar centered scheme. * \ingroup ConvDiscr * \author O. Burghardt - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" */ class CCentSca_Heat : public CNumerics { @@ -81,7 +81,7 @@ class CCentSca_Heat : public CNumerics { * \brief Class for doing a scalar upwind solver for the heat convection equation. * \ingroup ConvDiscr * \author O. Burghardt. - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" */ class CUpwSca_Heat : public CNumerics { private: @@ -119,7 +119,7 @@ class CUpwSca_Heat : public CNumerics { * \brief Class for computing viscous term using average of gradients without correction (heat equation). * \ingroup ViscDiscr * \author O. Burghardt. - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" */ class CAvgGrad_Heat : public CNumerics { private: @@ -160,7 +160,7 @@ class CAvgGrad_Heat : public CNumerics { * \brief Class for computing viscous term using average of gradients with correction (heat equation). * \ingroup ViscDiscr * \author O. Burghardt. - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" */ class CAvgGradCorrected_Heat : public CNumerics { private: diff --git a/SU2_CFD/include/numerics/template.hpp b/SU2_CFD/include/numerics/template.hpp index 638fc38a5e01..c9bdd3659cd3 100644 --- a/SU2_CFD/include/numerics/template.hpp +++ b/SU2_CFD/include/numerics/template.hpp @@ -5,7 +5,7 @@ * new schemes in SU2, in practice you should look for a similar * scheme and try to re-use functionality (not by copy-paste). * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" * * SU2 Project Website: https://su2code.github.io * diff --git a/SU2_CFD/include/numerics/transition.hpp b/SU2_CFD/include/numerics/transition.hpp index 40f207b3c622..2806fdd07c63 100644 --- a/SU2_CFD/include/numerics/transition.hpp +++ b/SU2_CFD/include/numerics/transition.hpp @@ -2,7 +2,7 @@ * \file transition.hpp * \brief Delarations of numerics classes for transition problems. * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" * * SU2 Project Website: https://su2code.github.io * diff --git a/SU2_CFD/include/numerics/turbulent/turb_convection.hpp b/SU2_CFD/include/numerics/turbulent/turb_convection.hpp index 2d5af1de17f1..f8a1d3fcbf1a 100644 --- a/SU2_CFD/include/numerics/turbulent/turb_convection.hpp +++ b/SU2_CFD/include/numerics/turbulent/turb_convection.hpp @@ -3,7 +3,7 @@ * \brief Delarations of numerics classes for discretization of * convective fluxes in turbulence problems. * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" * * SU2 Project Website: https://su2code.github.io * diff --git a/SU2_CFD/include/numerics/turbulent/turb_diffusion.hpp b/SU2_CFD/include/numerics/turbulent/turb_diffusion.hpp index 9ad7111d15d0..500cbc4f3426 100644 --- a/SU2_CFD/include/numerics/turbulent/turb_diffusion.hpp +++ b/SU2_CFD/include/numerics/turbulent/turb_diffusion.hpp @@ -3,7 +3,7 @@ * \brief Declarations of numerics classes for discretization of * viscous fluxes in turbulence problems. * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" * * SU2 Project Website: https://su2code.github.io * diff --git a/SU2_CFD/include/numerics/turbulent/turb_sources.hpp b/SU2_CFD/include/numerics/turbulent/turb_sources.hpp index 31ec53f88ab3..589784f8dcfa 100644 --- a/SU2_CFD/include/numerics/turbulent/turb_sources.hpp +++ b/SU2_CFD/include/numerics/turbulent/turb_sources.hpp @@ -3,7 +3,7 @@ * \brief Delarations of numerics classes for integration of source * terms in turbulence problems. * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" * * SU2 Project Website: https://su2code.github.io * @@ -137,7 +137,7 @@ class CSourcePieceWise_TurbSA : public CNumerics { * \brief Class for integrating the source terms of the Spalart-Allmaras CC modification turbulence model equation. * \ingroup SourceDiscr * \author E.Molina, A. Bueno. - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" */ class CSourcePieceWise_TurbSA_COMP : public CNumerics { private: @@ -234,7 +234,7 @@ class CSourcePieceWise_TurbSA_COMP : public CNumerics { * \brief Class for integrating the source terms of the Spalart-Allmaras Edwards modification turbulence model equation. * \ingroup SourceDiscr * \author E.Molina, A. Bueno. - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" */ class CSourcePieceWise_TurbSA_E : public CNumerics { private: @@ -331,7 +331,7 @@ class CSourcePieceWise_TurbSA_E : public CNumerics { * \brief Class for integrating the source terms of the Spalart-Allmaras Edwards modification with CC turbulence model equation. * \ingroup SourceDiscr * \author E.Molina, A. Bueno. - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" */ class CSourcePieceWise_TurbSA_E_COMP : public CNumerics { private: diff --git a/SU2_CFD/src/numerics/continuous_adjoint/adj_convection.cpp b/SU2_CFD/src/numerics/continuous_adjoint/adj_convection.cpp index b1318c3f8614..14d2d7f40346 100644 --- a/SU2_CFD/src/numerics/continuous_adjoint/adj_convection.cpp +++ b/SU2_CFD/src/numerics/continuous_adjoint/adj_convection.cpp @@ -2,7 +2,7 @@ * \file adj_convection.cpp * \brief Implementation of adjoint convection numerics classes. * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" * * SU2 Project Website: https://su2code.github.io * diff --git a/SU2_CFD/src/numerics/continuous_adjoint/adj_diffusion.cpp b/SU2_CFD/src/numerics/continuous_adjoint/adj_diffusion.cpp index 65beaad8f6f6..8467f8181f1b 100644 --- a/SU2_CFD/src/numerics/continuous_adjoint/adj_diffusion.cpp +++ b/SU2_CFD/src/numerics/continuous_adjoint/adj_diffusion.cpp @@ -2,7 +2,7 @@ * \file adj_diffusion.cpp * \brief Implementation of adjoint diffusion numerics classes. * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" * * SU2 Project Website: https://su2code.github.io * diff --git a/SU2_CFD/src/numerics/continuous_adjoint/adj_sources.cpp b/SU2_CFD/src/numerics/continuous_adjoint/adj_sources.cpp index 60a75b5f1838..8c0b67dcb354 100644 --- a/SU2_CFD/src/numerics/continuous_adjoint/adj_sources.cpp +++ b/SU2_CFD/src/numerics/continuous_adjoint/adj_sources.cpp @@ -2,7 +2,7 @@ * \file adj_sources.cpp * \brief Implementation of adjoint source numerics classes. * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" * * SU2 Project Website: https://su2code.github.io * diff --git a/SU2_CFD/src/numerics/elasticity/nonlinear_models.cpp b/SU2_CFD/src/numerics/elasticity/nonlinear_models.cpp index e904d65546aa..c526ff8f71b6 100644 --- a/SU2_CFD/src/numerics/elasticity/nonlinear_models.cpp +++ b/SU2_CFD/src/numerics/elasticity/nonlinear_models.cpp @@ -2,7 +2,7 @@ * \file nonlinear_models.cpp * \brief Definition of nonlinear constitutive models. * \author R. Sanchez - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" * * SU2 Project Website: https://su2code.github.io * diff --git a/SU2_CFD/src/numerics/flow/convection/ausm_slau.cpp b/SU2_CFD/src/numerics/flow/convection/ausm_slau.cpp index 969b9de9bb72..0e168597fdd0 100644 --- a/SU2_CFD/src/numerics/flow/convection/ausm_slau.cpp +++ b/SU2_CFD/src/numerics/flow/convection/ausm_slau.cpp @@ -2,7 +2,7 @@ * \file ausm_slau.cpp * \brief Implementations of the AUSM-family of schemes. * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" * * SU2 Project Website: https://su2code.github.io * diff --git a/SU2_CFD/src/numerics/flow/convection/centered.cpp b/SU2_CFD/src/numerics/flow/convection/centered.cpp index 888920527321..50e396e2fa8c 100644 --- a/SU2_CFD/src/numerics/flow/convection/centered.cpp +++ b/SU2_CFD/src/numerics/flow/convection/centered.cpp @@ -2,7 +2,7 @@ * \file centered.cpp * \brief Implementations of centered schemes. * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" * * SU2 Project Website: https://su2code.github.io * diff --git a/SU2_CFD/src/numerics/flow/convection/cusp.cpp b/SU2_CFD/src/numerics/flow/convection/cusp.cpp index 688fa827f161..b60bb7b83135 100644 --- a/SU2_CFD/src/numerics/flow/convection/cusp.cpp +++ b/SU2_CFD/src/numerics/flow/convection/cusp.cpp @@ -2,7 +2,7 @@ * \file cusp.cpp * \brief Implementation of the CUSP scheme. * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" * * SU2 Project Website: https://su2code.github.io * diff --git a/SU2_CFD/src/numerics/flow/convection/fds.cpp b/SU2_CFD/src/numerics/flow/convection/fds.cpp index 02cd8c7b834f..ee6487320340 100644 --- a/SU2_CFD/src/numerics/flow/convection/fds.cpp +++ b/SU2_CFD/src/numerics/flow/convection/fds.cpp @@ -2,7 +2,7 @@ * \file fds.cpp * \brief Implementation of Flux-Difference-Splitting schemes. * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" * * SU2 Project Website: https://su2code.github.io * diff --git a/SU2_CFD/src/numerics/flow/convection/fvs.cpp b/SU2_CFD/src/numerics/flow/convection/fvs.cpp index 84b57b3e41cf..3fcf5c363f2f 100644 --- a/SU2_CFD/src/numerics/flow/convection/fvs.cpp +++ b/SU2_CFD/src/numerics/flow/convection/fvs.cpp @@ -2,7 +2,7 @@ * \file fvs.cpp * \brief Implementations of Flux-Vector-Splitting schemes. * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" * * SU2 Project Website: https://su2code.github.io * diff --git a/SU2_CFD/src/numerics/flow/convection/hllc.cpp b/SU2_CFD/src/numerics/flow/convection/hllc.cpp index fe74a029b92e..c50d8d178ed5 100644 --- a/SU2_CFD/src/numerics/flow/convection/hllc.cpp +++ b/SU2_CFD/src/numerics/flow/convection/hllc.cpp @@ -2,7 +2,7 @@ * \file hllc.cpp * \brief Implementations of HLLC schemes. * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" * * SU2 Project Website: https://su2code.github.io * diff --git a/SU2_CFD/src/numerics/flow/convection/roe.cpp b/SU2_CFD/src/numerics/flow/convection/roe.cpp index 2fdb15ece5e7..850adc958ffc 100644 --- a/SU2_CFD/src/numerics/flow/convection/roe.cpp +++ b/SU2_CFD/src/numerics/flow/convection/roe.cpp @@ -2,7 +2,7 @@ * \file roe.cpp * \brief Implementations of Roe-type schemes. * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" * * SU2 Project Website: https://su2code.github.io * diff --git a/SU2_CFD/src/numerics/flow/flow_diffusion.cpp b/SU2_CFD/src/numerics/flow/flow_diffusion.cpp index 229fece2d824..2587155c0ab4 100644 --- a/SU2_CFD/src/numerics/flow/flow_diffusion.cpp +++ b/SU2_CFD/src/numerics/flow/flow_diffusion.cpp @@ -3,7 +3,7 @@ * \brief Implementation of numerics classes for discretization * of viscous fluxes in fluid flow problems. * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" * * SU2 Project Website: https://su2code.github.io * diff --git a/SU2_CFD/src/numerics/flow/flow_sources.cpp b/SU2_CFD/src/numerics/flow/flow_sources.cpp index 6c813ab79f22..1744b9852efa 100644 --- a/SU2_CFD/src/numerics/flow/flow_sources.cpp +++ b/SU2_CFD/src/numerics/flow/flow_sources.cpp @@ -3,7 +3,7 @@ * \brief Implementation of numerics classes for integration * of source terms in fluid flow problems. * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" * * SU2 Project Website: https://su2code.github.io * diff --git a/SU2_CFD/src/numerics/template.cpp b/SU2_CFD/src/numerics/template.cpp index 53077ffe9545..f21b2162206b 100644 --- a/SU2_CFD/src/numerics/template.cpp +++ b/SU2_CFD/src/numerics/template.cpp @@ -2,7 +2,7 @@ * \file template.cpp * \brief Empty implementation of numerics templates, see .hpp file. * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" * * SU2 Project Website: https://su2code.github.io * diff --git a/SU2_CFD/src/numerics/transition.cpp b/SU2_CFD/src/numerics/transition.cpp index 4accc7b2b94d..efbb12ab7053 100644 --- a/SU2_CFD/src/numerics/transition.cpp +++ b/SU2_CFD/src/numerics/transition.cpp @@ -2,7 +2,7 @@ * \file transition.cpp * \brief Implementation of numerics classes for transition problems. * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" * * SU2 Project Website: https://su2code.github.io * diff --git a/SU2_CFD/src/numerics/turbulent/turb_convection.cpp b/SU2_CFD/src/numerics/turbulent/turb_convection.cpp index 6b69d5bdcbee..b627519c5e27 100644 --- a/SU2_CFD/src/numerics/turbulent/turb_convection.cpp +++ b/SU2_CFD/src/numerics/turbulent/turb_convection.cpp @@ -3,7 +3,7 @@ * \brief Implementation of numerics classes to compute convective * fluxes in turbulence problems. * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" * * SU2 Project Website: https://su2code.github.io * diff --git a/SU2_CFD/src/numerics/turbulent/turb_diffusion.cpp b/SU2_CFD/src/numerics/turbulent/turb_diffusion.cpp index 5c6bb8fe952e..2625021984c9 100644 --- a/SU2_CFD/src/numerics/turbulent/turb_diffusion.cpp +++ b/SU2_CFD/src/numerics/turbulent/turb_diffusion.cpp @@ -3,7 +3,7 @@ * \brief Implementation of numerics classes to compute viscous * fluxes in turbulence problems. * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" * * SU2 Project Website: https://su2code.github.io * diff --git a/SU2_CFD/src/numerics/turbulent/turb_sources.cpp b/SU2_CFD/src/numerics/turbulent/turb_sources.cpp index 75ca147f8ad5..8298f5a46fcb 100644 --- a/SU2_CFD/src/numerics/turbulent/turb_sources.cpp +++ b/SU2_CFD/src/numerics/turbulent/turb_sources.cpp @@ -3,7 +3,7 @@ * \brief Implementation of numerics classes for integration of * turbulence source-terms. * \author F. Palacios, T. Economon - * \version 7.0.0 "Blackbird" + * \version 7.0.1 "Blackbird" * * SU2 Project Website: https://su2code.github.io * From 3cb4ad77867c6711bd2a509f64ec491a5b8cb723 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Sat, 1 Feb 2020 11:16:47 +0000 Subject: [PATCH 074/118] simplify some OpenMP reductions --- Common/include/omp_structure.hpp | 1 + Common/src/linear_algebra/CSysVector.cpp | 26 +++++++++++++++--------- SU2_CFD/src/solvers/CFEASolver.cpp | 25 ++++++++--------------- SU2_CFD/src/solvers/CMeshSolver.cpp | 23 +++++++++++++-------- 4 files changed, 40 insertions(+), 35 deletions(-) diff --git a/Common/include/omp_structure.hpp b/Common/include/omp_structure.hpp index c19ab3260c74..3f0c85419bc5 100644 --- a/Common/include/omp_structure.hpp +++ b/Common/include/omp_structure.hpp @@ -84,6 +84,7 @@ inline constexpr int omp_get_thread_num(void) {return 0;} #define SU2_OMP_SIMD SU2_OMP(simd) #define SU2_OMP_MASTER SU2_OMP(master) +#define SU2_OMP_ATOMIC SU2_OMP(atomic) #define SU2_OMP_BARRIER SU2_OMP(barrier) #define SU2_OMP_CRITICAL SU2_OMP(critical) diff --git a/Common/src/linear_algebra/CSysVector.cpp b/Common/src/linear_algebra/CSysVector.cpp index 709e7b4d0b3d..ee9dff71a218 100644 --- a/Common/src/linear_algebra/CSysVector.cpp +++ b/Common/src/linear_algebra/CSysVector.cpp @@ -205,6 +205,20 @@ void CSysVector::CopyToArray(ScalarType* u_array) const { for(auto i=0ul; i +inline void reduce(ScalarType local, ScalarType& shared) { + SU2_OMP_CRITICAL + shared += local; +} +template<> +inline void reduce(passivedouble local, passivedouble& shared) { + SU2_OMP_ATOMIC + shared += local; +} + template ScalarType CSysVector::dot(const CSysVector & u) const { @@ -220,16 +234,8 @@ ScalarType CSysVector::dot(const CSysVector & u) const { for(auto i=0ul; iComputeArea(); else ElemVolume = fea_elem->ComputeVolume(); - MaxVolume = max(MaxVolume, ElemVolume); - MinVolume = max(MinVolume, -1.0*ElemVolume); + maxVol = max(maxVol, ElemVolume); + minVol = min(minVol, ElemVolume); if (updated) element[iElem].SetCurr_Volume(ElemVolume); else element[iElem].SetRef_Volume(ElemVolume); /*--- Count distorted elements. ---*/ - if (ElemVolume <= 0.0) { - SU2_OMP(atomic) - ElemCounter++; - } + if (ElemVolume <= 0.0) ElemCounter++; } - MinVolume *= -1.0; + SU2_OMP_CRITICAL + { + MaxVolume = max(MaxVolume, maxVol); + MinVolume = min(MinVolume, minVol); + } + SU2_OMP_BARRIER SU2_OMP_MASTER { From 253580a75f241ae04c108455ea91aec4c42b28fe Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Sat, 1 Feb 2020 14:15:43 +0000 Subject: [PATCH 075/118] parallel upwind and viscous loops of CTurbSolver --- SU2_CFD/include/solvers/CSolver.hpp | 2 +- SU2_CFD/include/solvers/CTurbSSTSolver.hpp | 6 +- SU2_CFD/include/solvers/CTurbSolver.hpp | 40 +++- SU2_CFD/src/solvers/CEulerSolver.cpp | 43 ++-- SU2_CFD/src/solvers/CTurbSASolver.cpp | 86 +++----- SU2_CFD/src/solvers/CTurbSSTSolver.cpp | 92 +++----- SU2_CFD/src/solvers/CTurbSolver.cpp | 236 +++++++++++++-------- 7 files changed, 260 insertions(+), 245 deletions(-) diff --git a/SU2_CFD/include/solvers/CSolver.hpp b/SU2_CFD/include/solvers/CSolver.hpp index 5b7732ce17b1..b3af35bfee98 100644 --- a/SU2_CFD/include/solvers/CSolver.hpp +++ b/SU2_CFD/include/solvers/CSolver.hpp @@ -3621,7 +3621,7 @@ class CSolver { * \brief A virtual member. * \return A pointer to an array containing a set of constants */ - inline virtual su2double* GetConstants() const { return NULL; } + inline virtual const su2double* GetConstants() const { return nullptr; } /*! * \brief A virtual member. diff --git a/SU2_CFD/include/solvers/CTurbSSTSolver.hpp b/SU2_CFD/include/solvers/CTurbSSTSolver.hpp index 1aa513bf7589..c296f098a653 100644 --- a/SU2_CFD/include/solvers/CTurbSSTSolver.hpp +++ b/SU2_CFD/include/solvers/CTurbSSTSolver.hpp @@ -35,10 +35,10 @@ * \ingroup Turbulence_Model * \author A. Campos, F. Palacios, T. Economon */ - class CTurbSSTSolver final : public CTurbSolver { private: - su2double *constants, /*!< \brief Constants for the model. */ + su2double + constants[10] = {0.0}, /*!< \brief Constants for the model. */ kine_Inf, /*!< \brief Free-stream turbulent kinetic energy. */ omega_Inf; /*!< \brief Free-stream specific dissipation. */ @@ -246,7 +246,7 @@ class CTurbSSTSolver final : public CTurbSolver { * \brief Get the constants for the SST model. * \return A pointer to an array containing a set of constants */ - inline su2double* GetConstants() const override { return constants; } + inline const su2double* GetConstants() const override { return constants; } /*! * \brief Set the solution using the Freestream values. diff --git a/SU2_CFD/include/solvers/CTurbSolver.hpp b/SU2_CFD/include/solvers/CTurbSolver.hpp index 09286e40499c..58f8e1256611 100644 --- a/SU2_CFD/include/solvers/CTurbSolver.hpp +++ b/SU2_CFD/include/solvers/CTurbSolver.hpp @@ -38,22 +38,40 @@ */ class CTurbSolver : public CSolver { protected: - su2double *FlowPrimVar_i, /*!< \brief Store the flow solution at point i. */ - *FlowPrimVar_j, /*!< \brief Store the flow solution at point j. */ - *lowerlimit, /*!< \brief contains lower limits for turbulence variables. */ - *upperlimit; /*!< \brief contains upper limits for turbulence variables. */ - 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 */ + enum : size_t {MAXNDIM = 3}; /*!< \brief Max number of space dimensions, used in some static arrays. */ + enum : size_t {MAXNVAR = 2}; /*!< \brief Max number of variables, used in some static arrays. */ + enum : size_t {MAXNVARFLOW = 12}; /*!< \brief Max number of flow variables, used in some static arrays. */ - CTurbVariable* snode; /*!< \brief The highest level in the variable hierarchy this solver can safely use. */ + enum : size_t {OMP_MAX_SIZE = 512}; /*!< \brief Max chunk size for light point loops. */ + enum : size_t {OMP_MIN_SIZE = 128}; /*!< \brief Min chunk size for edge loops (max is color group size). */ + + unsigned long omp_chunk_size; /*!< \brief Chunk size used in light point loops. */ + + su2double + lowerlimit[MAXNVAR] = {0.0}, /*!< \brief contains lower limits for turbulence variables. */ + upperlimit[MAXNVAR] = {0.0}, /*!< \brief contains upper limits for turbulence variables. */ + Gamma, /*!< \brief Fluid's Gamma constant (ratio of specific heats). */ + Gamma_Minus_One, /*!< \brief Fluids's Gamma - 1.0 . */ + ***Inlet_TurbVars = nullptr; /*!< \brief Turbulence variables at inlet profiles */ /* Sliding meshes variables */ - su2double ****SlidingState; - int **SlidingStateNodes; + su2double ****SlidingState = nullptr; + int **SlidingStateNodes = nullptr; + + /*--- Shallow copy of grid coloring for OpenMP parallelization. ---*/ - CTurbVariable* nodes = nullptr; /*!< \brief The highest level in the variable hierarchy this solver can safely use. */ + struct EdgeColor { + unsigned long size; /*!< \brief Number of edges with a given color. */ + const unsigned long* indices; /*!< \brief Array of edge indices for a given color. */ + }; + vector EdgeColoring; /*!< \brief Edge colors. */ + unsigned long ColorGroupSize; /*!< \brief Group size used for coloring, chunk size in edge loops must be a multiple of this. */ + + /*! + * \brief The highest level in the variable hierarchy this solver can safely use. + */ + CTurbVariable* nodes = nullptr; /*! * \brief Return nodes to allow CSolver::base_nodes to be set. diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 574ce8f8fd6a..57c25541a6fb 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -172,35 +172,34 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short /*--- 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; - Residual_Max = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) Residual_Max[iVar] = 0.0; - Residual_i = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) Residual_i[iVar] = 0.0; - Residual_j = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) Residual_j[iVar] = 0.0; - Res_Conv = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) Res_Conv[iVar] = 0.0; - Res_Visc = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) Res_Visc[iVar] = 0.0; - Res_Sour = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) Res_Sour[iVar] = 0.0; + Residual = new su2double[nVar](); + Residual_RMS = new su2double[nVar](); + Residual_Max = new su2double[nVar](); + Residual_i = new su2double[nVar](); + Residual_j = new su2double[nVar](); + Res_Conv = new su2double[nVar](); + Res_Visc = new su2double[nVar](); + Res_Sour = new su2double[nVar](); /*--- Define some structures for locating max residuals ---*/ - Point_Max = new unsigned long[nVar]; for (iVar = 0; iVar < nVar; iVar++) Point_Max[iVar] = 0; + Point_Max = new unsigned long[nVar](); Point_Max_Coord = new su2double*[nVar]; for (iVar = 0; iVar < nVar; iVar++) { - Point_Max_Coord[iVar] = new su2double[nDim]; - for (iDim = 0; iDim < nDim; iDim++) Point_Max_Coord[iVar][iDim] = 0.0; + Point_Max_Coord[iVar] = new su2double[nDim](); } /*--- Define some auxiliary vectors related to the solution ---*/ - Solution = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) Solution[iVar] = 0.0; - Solution_i = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) Solution_i[iVar] = 0.0; - Solution_j = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) Solution_j[iVar] = 0.0; + Solution = new su2double[nVar](); + Solution_i = new su2double[nVar](); + Solution_j = new su2double[nVar](); /*--- Define some auxiliary vectors related to the geometry ---*/ - Vector = new su2double[nDim]; for (iDim = 0; iDim < nDim; iDim++) Vector[iDim] = 0.0; - Vector_i = new su2double[nDim]; for (iDim = 0; iDim < nDim; iDim++) Vector_i[iDim] = 0.0; - Vector_j = new su2double[nDim]; for (iDim = 0; iDim < nDim; iDim++) Vector_j[iDim] = 0.0; + Vector = new su2double[nDim](); + Vector_i = new su2double[nDim](); + Vector_j = new su2double[nDim](); /*--- Define some auxiliary vectors related to the undivided lapalacian ---*/ @@ -3082,6 +3081,13 @@ void CEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_contain auto Gradient_i = nodes->GetGradient_Reconstruction(iPoint); auto Gradient_j = nodes->GetGradient_Reconstruction(jPoint); + su2double *Limiter_i = nullptr, *Limiter_j = nullptr; + + if (limiter) { + Limiter_i = nodes->GetLimiter_Primitive(iPoint); + Limiter_j = nodes->GetLimiter_Primitive(jPoint); + } + for (iVar = 0; iVar < nPrimVarGrad; iVar++) { su2double Project_Grad_i = 0.0; @@ -3093,9 +3099,6 @@ void CEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_contain } if (limiter) { - auto Limiter_i = nodes->GetLimiter_Primitive(iPoint); - auto Limiter_j = nodes->GetLimiter_Primitive(jPoint); - if (van_albada) { su2double V_ij = V_j[iVar] - V_i[iVar]; Limiter_i[iVar] = V_ij*( 2.0*Project_Grad_i + V_ij) / (4*pow(Project_Grad_i, 2) + pow(V_ij, 2) + EPS); diff --git a/SU2_CFD/src/solvers/CTurbSASolver.cpp b/SU2_CFD/src/solvers/CTurbSASolver.cpp index bc70b8cfca4f..4cb1faa5adfb 100644 --- a/SU2_CFD/src/solvers/CTurbSASolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSASolver.cpp @@ -29,14 +29,11 @@ #include "../../include/solvers/CTurbSASolver.hpp" #include "../../include/variables/CTurbSAVariable.hpp" -CTurbSASolver::CTurbSASolver(void) : CTurbSolver() { - - Inlet_TurbVars = NULL; - -} +CTurbSASolver::CTurbSASolver(void) : CTurbSolver() { } CTurbSASolver::CTurbSASolver(CGeometry *geometry, CConfig *config, unsigned short iMesh, CFluidModel* FluidModel) - : CTurbSolver(geometry, config) { + : CTurbSolver(geometry, config) { + unsigned short iVar, iDim, nLineLets; unsigned long iPoint; su2double Density_Inf, Viscosity_Inf, Factor_nu_Inf, Factor_nu_Engine, Factor_nu_ActDisk; @@ -67,20 +64,18 @@ CTurbSASolver::CTurbSASolver(CGeometry *geometry, CConfig *config, unsigned shor /*--- Define some auxiliar vector related with 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; - Residual_i = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) Residual_i[iVar] = 0.0; - Residual_j = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) Residual_j[iVar] = 0.0; - Residual_Max = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) Residual_Max[iVar] = 0.0; + Residual = new su2double[nVar](); + Residual_RMS = new su2double[nVar](); + Residual_i = new su2double[nVar](); + Residual_j = new su2double[nVar](); + Residual_Max = new su2double[nVar](); /*--- Define some structures for locating max residuals ---*/ - Point_Max = new unsigned long[nVar]; - for (iVar = 0; iVar < nVar; iVar++) Point_Max[iVar] = 0; + Point_Max = new unsigned long[nVar](); Point_Max_Coord = new su2double*[nVar]; for (iVar = 0; iVar < nVar; iVar++) { - Point_Max_Coord[iVar] = new su2double[nDim]; - for (iDim = 0; iDim < nDim; iDim++) Point_Max_Coord[iVar][iDim] = 0.0; + Point_Max_Coord[iVar] = new su2double[nDim](); } /*--- Define some auxiliar vector related with the solution ---*/ @@ -88,14 +83,6 @@ CTurbSASolver::CTurbSASolver(CGeometry *geometry, CConfig *config, unsigned shor Solution = new su2double[nVar]; Solution_i = new su2double[nVar]; Solution_j = new su2double[nVar]; - /*--- Define some auxiliar vector related with the geometry ---*/ - - Vector_i = new su2double[nDim]; Vector_j = new su2double[nDim]; - - /*--- Define some auxiliar vector related with the flow solution ---*/ - - FlowPrimVar_i = new su2double [nDim+9]; FlowPrimVar_j = new su2double [nDim+9]; - /*--- Jacobians and vector structures for implicit computations ---*/ Jacobian_i = new su2double* [nVar]; @@ -141,16 +128,15 @@ CTurbSASolver::CTurbSASolver(CGeometry *geometry, CConfig *config, unsigned shor /*--- Initialize the BGS residuals in multizone problems. ---*/ if (multizone){ - Residual_BGS = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) Residual_BGS[iVar] = 0.0; - Residual_Max_BGS = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) Residual_Max_BGS[iVar] = 0.0; + Residual_BGS = new su2double[nVar](); + Residual_Max_BGS = new su2double[nVar](); /*--- Define some structures for locating max residuals ---*/ - Point_Max_BGS = new unsigned long[nVar]; for (iVar = 0; iVar < nVar; iVar++) Point_Max_BGS[iVar] = 0; + Point_Max_BGS = new unsigned long[nVar](); Point_Max_Coord_BGS = new su2double*[nVar]; for (iVar = 0; iVar < nVar; iVar++) { - Point_Max_Coord_BGS[iVar] = new su2double[nDim]; - for (iDim = 0; iDim < nDim; iDim++) Point_Max_Coord_BGS[iVar][iDim] = 0.0; + Point_Max_Coord_BGS[iVar] = new su2double[nDim] (); } } @@ -202,28 +188,20 @@ CTurbSASolver::CTurbSASolver(CGeometry *geometry, CConfig *config, unsigned shor unsigned long iMarker; - SlidingState = new su2double*** [nMarker]; - SlidingStateNodes = new int* [nMarker]; + SlidingState = new su2double*** [nMarker] (); + SlidingStateNodes = new int* [nMarker] (); for (iMarker = 0; iMarker < nMarker; iMarker++){ - SlidingState[iMarker] = NULL; - SlidingStateNodes[iMarker] = NULL; - if (config->GetMarker_All_KindBC(iMarker) == FLUID_INTERFACE){ - SlidingState[iMarker] = new su2double**[geometry->GetnVertex(iMarker)]; - SlidingStateNodes[iMarker] = new int [geometry->GetnVertex(iMarker)]; - - for (iPoint = 0; iPoint < geometry->GetnVertex(iMarker); iPoint++){ - SlidingState[iMarker][iPoint] = new su2double*[nPrimVar+1]; - - SlidingStateNodes[iMarker][iPoint] = 0; - for (iVar = 0; iVar < nPrimVar+1; iVar++) - SlidingState[iMarker][iPoint][iVar] = NULL; - } + SlidingState[iMarker] = new su2double**[geometry->GetnVertex(iMarker)] (); + SlidingStateNodes[iMarker] = new int [geometry->GetnVertex(iMarker)] (); + for (iPoint = 0; iPoint < geometry->GetnVertex(iMarker); iPoint++) + SlidingState[iMarker][iPoint] = new su2double*[nPrimVar+1] (); } + } /*-- Allocation of inlets has to happen in derived classes (not CTurbSolver), @@ -231,11 +209,11 @@ CTurbSASolver::CTurbSASolver(CGeometry *geometry, CConfig *config, unsigned shor Inlet_TurbVars = new su2double**[nMarker]; for (unsigned long iMarker = 0; iMarker < nMarker; iMarker++) { - Inlet_TurbVars[iMarker] = new su2double*[nVertex[iMarker]]; - for(unsigned long iVertex=0; iVertex < nVertex[iMarker]; iVertex++){ - Inlet_TurbVars[iMarker][iVertex] = new su2double[nVar]; - Inlet_TurbVars[iMarker][iVertex][0] = nu_tilde_Inf; - } + Inlet_TurbVars[iMarker] = new su2double*[nVertex[iMarker]]; + for(unsigned long iVertex=0; iVertex < nVertex[iMarker]; iVertex++){ + Inlet_TurbVars[iMarker][iVertex] = new su2double[nVar] (); + Inlet_TurbVars[iMarker][iVertex][0] = nu_tilde_Inf; + } } /*--- The turbulence models are always solved implicitly, so set the @@ -263,11 +241,11 @@ CTurbSASolver::~CTurbSASolver(void) { unsigned long iMarker, iVertex; unsigned short iVar; - if ( SlidingState != NULL ) { + if ( SlidingState != nullptr ) { for (iMarker = 0; iMarker < nMarker; iMarker++) { - if ( SlidingState[iMarker] != NULL ) { + if ( SlidingState[iMarker] != nullptr ) { for (iVertex = 0; iVertex < nVertex[iMarker]; iVertex++) - if ( SlidingState[iMarker][iVertex] != NULL ){ + if ( SlidingState[iMarker][iVertex] != nullptr ){ for (iVar = 0; iVar < nPrimVar+1; iVar++) delete [] SlidingState[iMarker][iVertex][iVar]; delete [] SlidingState[iMarker][iVertex]; @@ -278,10 +256,10 @@ CTurbSASolver::~CTurbSASolver(void) { delete [] SlidingState; } - if ( SlidingStateNodes != NULL ){ + if ( SlidingStateNodes != nullptr ){ for (iMarker = 0; iMarker < nMarker; iMarker++){ - if (SlidingStateNodes[iMarker] != NULL) - delete [] SlidingStateNodes[iMarker]; + if (SlidingStateNodes[iMarker] != nullptr) + delete [] SlidingStateNodes[iMarker]; } delete [] SlidingStateNodes; } diff --git a/SU2_CFD/src/solvers/CTurbSSTSolver.cpp b/SU2_CFD/src/solvers/CTurbSSTSolver.cpp index 1dbbc3e97846..1bb05905a214 100644 --- a/SU2_CFD/src/solvers/CTurbSSTSolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSSTSolver.cpp @@ -29,13 +29,7 @@ #include "../../include/solvers/CTurbSSTSolver.hpp" #include "../../include/variables/CTurbSSTVariable.hpp" -CTurbSSTSolver::CTurbSSTSolver(void) : CTurbSolver() { - - /*--- Array initialization ---*/ - constants = NULL; - Inlet_TurbVars = NULL; - -} +CTurbSSTSolver::CTurbSSTSolver(void) : CTurbSolver() { } CTurbSSTSolver::CTurbSSTSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) : CTurbSolver(geometry, config) { @@ -48,8 +42,6 @@ CTurbSSTSolver::CTurbSSTSolver(CGeometry *geometry, CConfig *config, unsigned sh /*--- Array initialization ---*/ - constants = NULL; - Gamma = config->GetGamma(); Gamma_Minus_One = Gamma - 1.0; @@ -74,20 +66,18 @@ CTurbSSTSolver::CTurbSSTSolver(CGeometry *geometry, CConfig *config, unsigned sh /*--- Define some auxiliary vector related with 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; - Residual_i = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) Residual_i[iVar] = 0.0; - Residual_j = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) Residual_j[iVar] = 0.0; - Residual_Max = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) Residual_Max[iVar] = 0.0; + Residual = new su2double[nVar](); + Residual_RMS = new su2double[nVar](); + Residual_i = new su2double[nVar](); + Residual_j = new su2double[nVar](); + Residual_Max = new su2double[nVar](); /*--- Define some structures for locating max residuals ---*/ - Point_Max = new unsigned long[nVar]; - for (iVar = 0; iVar < nVar; iVar++) Point_Max[iVar] = 0; + Point_Max = new unsigned long[nVar](); Point_Max_Coord = new su2double*[nVar]; for (iVar = 0; iVar < nVar; iVar++) { - Point_Max_Coord[iVar] = new su2double[nDim]; - for (iDim = 0; iDim < nDim; iDim++) Point_Max_Coord[iVar][iDim] = 0.0; + Point_Max_Coord[iVar] = new su2double[nDim](); } /*--- Define some auxiliary vector related with the solution ---*/ @@ -95,14 +85,6 @@ CTurbSSTSolver::CTurbSSTSolver(CGeometry *geometry, CConfig *config, unsigned sh Solution = new su2double[nVar]; Solution_i = new su2double[nVar]; Solution_j = new su2double[nVar]; - /*--- Define some auxiliary vector related with the geometry ---*/ - - Vector_i = new su2double[nDim]; Vector_j = new su2double[nDim]; - - /*--- Define some auxiliary vector related with the flow solution ---*/ - - FlowPrimVar_i = new su2double [nDim+9]; FlowPrimVar_j = new su2double [nDim+9]; - /*--- Jacobians and vector structures for implicit computations ---*/ Jacobian_i = new su2double* [nVar]; @@ -127,16 +109,15 @@ CTurbSSTSolver::CTurbSSTSolver(CGeometry *geometry, CConfig *config, unsigned sh /*--- Initialize the BGS residuals in multizone problems. ---*/ if (multizone){ - Residual_BGS = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) Residual_BGS[iVar] = 0.0; - Residual_Max_BGS = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) Residual_Max_BGS[iVar] = 0.0; + Residual_BGS = new su2double[nVar](); + Residual_Max_BGS = new su2double[nVar](); /*--- Define some structures for locating max residuals ---*/ - Point_Max_BGS = new unsigned long[nVar]; for (iVar = 0; iVar < nVar; iVar++) Point_Max_BGS[iVar] = 0; + Point_Max_BGS = new unsigned long[nVar](); Point_Max_Coord_BGS = new su2double*[nVar]; for (iVar = 0; iVar < nVar; iVar++) { - Point_Max_Coord_BGS[iVar] = new su2double[nDim]; - for (iDim = 0; iDim < nDim; iDim++) Point_Max_Coord_BGS[iVar][iDim] = 0.0; + Point_Max_Coord_BGS[iVar] = new su2double[nDim](); } } @@ -148,15 +129,14 @@ CTurbSSTSolver::CTurbSSTSolver(CGeometry *geometry, CConfig *config, unsigned sh /*--- S matrix := inv(R)*traspose(inv(R)) ---*/ Smatrix = new su2double* [nDim]; for (iDim = 0; iDim < nDim; iDim++) - Smatrix[iDim] = new su2double [nDim]; + 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]; + Cvector[iVar] = new su2double [nDim]; } /*--- Initialize value for model constants ---*/ - constants = new su2double[10]; constants[0] = 0.85; //sigma_k1 constants[1] = 1.0; //sigma_k2 constants[2] = 0.5; //sigma_om1 @@ -169,9 +149,6 @@ CTurbSSTSolver::CTurbSSTSolver(CGeometry *geometry, CConfig *config, unsigned sh constants[9] = constants[5]/constants[6] - constants[3]*0.41*0.41/sqrt(constants[6]); //alfa_2 /*--- Initialize lower and upper limits---*/ - lowerlimit = new su2double[nVar]; - upperlimit = new su2double[nVar]; - lowerlimit[0] = 1.0e-10; upperlimit[0] = 1.0e10; @@ -212,42 +189,33 @@ CTurbSSTSolver::CTurbSSTSolver(CGeometry *geometry, CConfig *config, unsigned sh unsigned long iMarker; - SlidingState = new su2double*** [nMarker]; - SlidingStateNodes = new int* [nMarker]; + SlidingState = new su2double*** [nMarker](); + SlidingStateNodes = new int* [nMarker](); for (iMarker = 0; iMarker < nMarker; iMarker++){ - SlidingState[iMarker] = NULL; - SlidingStateNodes[iMarker] = NULL; - if (config->GetMarker_All_KindBC(iMarker) == FLUID_INTERFACE){ - SlidingState[iMarker] = new su2double**[geometry->GetnVertex(iMarker)]; - SlidingStateNodes[iMarker] = new int [geometry->GetnVertex(iMarker)]; - - for (iPoint = 0; iPoint < geometry->GetnVertex(iMarker); iPoint++){ - SlidingState[iMarker][iPoint] = new su2double*[nPrimVar+1]; - - SlidingStateNodes[iMarker][iPoint] = 0; - for (iVar = 0; iVar < nPrimVar+1; iVar++) - SlidingState[iMarker][iPoint][iVar] = NULL; - } + SlidingState[iMarker] = new su2double**[geometry->GetnVertex(iMarker)](); + SlidingStateNodes[iMarker] = new int [geometry->GetnVertex(iMarker)](); + for (iPoint = 0; iPoint < geometry->GetnVertex(iMarker); iPoint++) + SlidingState[iMarker][iPoint] = new su2double*[nPrimVar+1](); } } /*-- Allocation of inlets has to happen in derived classes (not CTurbSolver), due to arbitrary number of turbulence variables ---*/ - Inlet_TurbVars = new su2double**[nMarker]; - for (unsigned long iMarker = 0; iMarker < nMarker; iMarker++) { - Inlet_TurbVars[iMarker] = new su2double*[nVertex[iMarker]]; - for(unsigned long iVertex=0; iVertex < nVertex[iMarker]; iVertex++){ - Inlet_TurbVars[iMarker][iVertex] = new su2double[nVar]; - Inlet_TurbVars[iMarker][iVertex][0] = kine_Inf; - Inlet_TurbVars[iMarker][iVertex][1] = omega_Inf; - } - } + Inlet_TurbVars = new su2double**[nMarker]; + for (unsigned long iMarker = 0; iMarker < nMarker; iMarker++) { + Inlet_TurbVars[iMarker] = new su2double*[nVertex[iMarker]]; + for(unsigned long iVertex=0; iVertex < nVertex[iMarker]; iVertex++){ + Inlet_TurbVars[iMarker][iVertex] = new su2double[nVar]; + Inlet_TurbVars[iMarker][iVertex][0] = kine_Inf; + Inlet_TurbVars[iMarker][iVertex][1] = omega_Inf; + } + } /*--- The turbulence models are always solved implicitly, so set the implicit flag in case we have periodic BCs. ---*/ @@ -271,8 +239,6 @@ CTurbSSTSolver::CTurbSSTSolver(CGeometry *geometry, CConfig *config, unsigned sh CTurbSSTSolver::~CTurbSSTSolver(void) { - if (constants != NULL) delete [] constants; - unsigned long iMarker, iVertex; unsigned short iVar; diff --git a/SU2_CFD/src/solvers/CTurbSolver.cpp b/SU2_CFD/src/solvers/CTurbSolver.cpp index 152330c85b32..38a5391da8bf 100644 --- a/SU2_CFD/src/solvers/CTurbSolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSolver.cpp @@ -27,30 +27,17 @@ #include "../../include/solvers/CTurbSolver.hpp" +#include "../../../Common/include/omp_structure.hpp" -CTurbSolver::CTurbSolver(void) : CSolver() { - - FlowPrimVar_i = NULL; - FlowPrimVar_j = NULL; - lowerlimit = NULL; - upperlimit = NULL; - nVertex = NULL; - nMarker = 0; - Inlet_TurbVars = NULL; - snode = nullptr; -} +CTurbSolver::CTurbSolver(void) : CSolver() { } CTurbSolver::CTurbSolver(CGeometry* geometry, CConfig *config) : CSolver() { Gamma = config->GetGamma(); Gamma_Minus_One = Gamma - 1.0; - FlowPrimVar_i = NULL; - FlowPrimVar_j = NULL; - lowerlimit = NULL; - upperlimit = NULL; - nMarker = config->GetnMarker_All(); + nMarker = config->GetnMarker_All(); /*--- Store the number of vertices on each marker for deallocation later ---*/ nVertex = new unsigned long[nMarker]; @@ -60,13 +47,31 @@ CTurbSolver::CTurbSolver(CGeometry* geometry, CConfig *config) : CSolver() { /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ dynamic_grid = config->GetDynamic_Grid(); +#ifdef HAVE_OMP + /*--- Get the edge coloring. ---*/ + + const auto& coloring = geometry->GetEdgeColoring(); + + auto nColor = coloring.getOuterSize(); + EdgeColoring.resize(nColor); + + for(auto iColor = 0ul; iColor < nColor; ++iColor) { + EdgeColoring[iColor].size = coloring.getNumNonZeros(iColor); + EdgeColoring[iColor].indices = coloring.innerIdx(iColor); + } + + ColorGroupSize = geometry->GetEdgeColorGroupSize(); + + nPoint = geometry->GetnPoint(); + omp_chunk_size = computeStaticChunkSize(nPoint, omp_get_max_threads(), OMP_MAX_SIZE); +#endif } CTurbSolver::~CTurbSolver(void) { - if (Inlet_TurbVars != NULL) { + if (Inlet_TurbVars != nullptr) { for (unsigned short iMarker = 0; iMarker < nMarker; iMarker++) { - if (Inlet_TurbVars[iMarker] != NULL) { + if (Inlet_TurbVars[iMarker] != nullptr) { for (unsigned long iVertex = 0; iVertex < nVertex[iMarker]; iVertex++) { delete [] Inlet_TurbVars[iMarker][iVertex]; } @@ -76,87 +81,115 @@ CTurbSolver::~CTurbSolver(void) { delete [] Inlet_TurbVars; } - if (FlowPrimVar_i != NULL) delete [] FlowPrimVar_i; - if (FlowPrimVar_j != NULL) delete [] FlowPrimVar_j; - if (lowerlimit != NULL) delete [] lowerlimit; - if (upperlimit != NULL) delete [] upperlimit; - - if (nodes != nullptr) delete nodes; + delete nodes; } void CTurbSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics_container, CConfig *config, unsigned short iMesh) { - CNumerics* numerics = numerics_container[CONV_TERM]; + const bool muscl = config->GetMUSCL_Turb(); + const bool limiter = (config->GetKind_SlopeLimit_Turb() != NO_LIMITER); + + CVariable* flowNodes = solver_container[FLOW_SOL]->GetNodes(); + + /*--- Start OpenMP parallel section. ---*/ + + SU2_OMP_PARALLEL + { + /*--- Pick one numerics object per thread. ---*/ + CNumerics* numerics = numerics_container[CONV_TERM + omp_get_thread_num()*MAX_TERMS]; - su2double *Turb_i, *Turb_j, *Limiter_i = NULL, *Limiter_j = NULL, *V_i, *V_j, **Gradient_i, **Gradient_j, Project_Grad_i, Project_Grad_j; - unsigned long iEdge, iPoint, jPoint; - unsigned short iDim, iVar; + /*--- Static arrays of MUSCL-reconstructed flow primitives and turbulence variables (thread safety). ---*/ + su2double solution_i[MAXNVAR] = {0.0}, flowPrimVar_i[MAXNVARFLOW] = {0.0}; + su2double solution_j[MAXNVAR] = {0.0}, flowPrimVar_j[MAXNVARFLOW] = {0.0}; - bool muscl = config->GetMUSCL_Turb(); - bool limiter = (config->GetKind_SlopeLimit_Turb() != NO_LIMITER); + /*--- Loop over all the edges ---*/ - for (iEdge = 0; iEdge < geometry->GetnEdge(); iEdge++) { +#ifdef HAVE_OMP + /*--- Chunk size is at least OMP_MIN_SIZE and a multiple of the color group size. ---*/ + auto chunkSize = roundUpDiv(OMP_MIN_SIZE, ColorGroupSize)*ColorGroupSize; + + /*--- Loop over edge colors. ---*/ + for (auto color : EdgeColoring) + { + SU2_OMP_FOR_DYN(chunkSize) + for(auto k = 0ul; k < color.size; ++k) { + + auto iEdge = color.indices[k]; +#else + /*--- Natural coloring. ---*/ + { + for (auto iEdge = 0ul; iEdge < geometry->GetnEdge(); iEdge++) { +#endif + unsigned short iDim, iVar; /*--- Points in edge and normal vectors ---*/ - iPoint = geometry->edge[iEdge]->GetNode(0); - jPoint = geometry->edge[iEdge]->GetNode(1); + auto iPoint = geometry->edge[iEdge]->GetNode(0); + auto jPoint = geometry->edge[iEdge]->GetNode(1); + numerics->SetNormal(geometry->edge[iEdge]->GetNormal()); /*--- Primitive variables w/o reconstruction ---*/ - V_i = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint); - V_j = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(jPoint); + auto V_i = flowNodes->GetPrimitive(iPoint); + auto V_j = flowNodes->GetPrimitive(jPoint); numerics->SetPrimitive(V_i, V_j); /*--- Turbulent variables w/o reconstruction ---*/ - Turb_i = nodes->GetSolution(iPoint); - Turb_j = nodes->GetSolution(jPoint); + auto Turb_i = nodes->GetSolution(iPoint); + auto Turb_j = nodes->GetSolution(jPoint); numerics->SetTurbVar(Turb_i, Turb_j); /*--- Grid Movement ---*/ if (dynamic_grid) - numerics->SetGridVel(geometry->node[iPoint]->GetGridVel(), geometry->node[jPoint]->GetGridVel()); + numerics->SetGridVel(geometry->node[iPoint]->GetGridVel(), + geometry->node[jPoint]->GetGridVel()); if (muscl) { + su2double *Limiter_i = nullptr, *Limiter_j = nullptr; + + auto Coord_i = geometry->node[iPoint]->GetCoord(); + auto Coord_j = geometry->node[jPoint]->GetCoord(); + + /*--- Reconstruct flow variables. ---*/ + su2double Vector_ij[MAXNDIM] = {0.0}; 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)); + Vector_ij[iDim] = 0.5*(Coord_j[iDim] - Coord_i[iDim]); } /*--- Mean flow primitive variables using gradient reconstruction and limiters ---*/ - Gradient_i = solver_container[FLOW_SOL]->GetNodes()->GetGradient_Reconstruction(iPoint); - Gradient_j = solver_container[FLOW_SOL]->GetNodes()->GetGradient_Reconstruction(jPoint); + auto Gradient_i = flowNodes->GetGradient_Reconstruction(iPoint); + auto Gradient_j = flowNodes->GetGradient_Reconstruction(jPoint); if (limiter) { - Limiter_i = solver_container[FLOW_SOL]->GetNodes()->GetLimiter_Primitive(iPoint); - Limiter_j = solver_container[FLOW_SOL]->GetNodes()->GetLimiter_Primitive(jPoint); + Limiter_i = flowNodes->GetLimiter_Primitive(iPoint); + Limiter_j = flowNodes->GetLimiter_Primitive(jPoint); } for (iVar = 0; iVar < solver_container[FLOW_SOL]->GetnPrimVarGrad(); iVar++) { - Project_Grad_i = 0.0; Project_Grad_j = 0.0; + su2double 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]; - Project_Grad_j += Vector_j[iDim]*Gradient_j[iVar][iDim]; + Project_Grad_i += Vector_ij[iDim]*Gradient_i[iVar][iDim]; + Project_Grad_j -= Vector_ij[iDim]*Gradient_j[iVar][iDim]; } if (limiter) { - FlowPrimVar_i[iVar] = V_i[iVar] + Limiter_i[iVar]*Project_Grad_i; - FlowPrimVar_j[iVar] = V_j[iVar] + Limiter_j[iVar]*Project_Grad_j; + flowPrimVar_i[iVar] = V_i[iVar] + Limiter_i[iVar]*Project_Grad_i; + flowPrimVar_j[iVar] = V_j[iVar] + Limiter_j[iVar]*Project_Grad_j; } else { - FlowPrimVar_i[iVar] = V_i[iVar] + Project_Grad_i; - FlowPrimVar_j[iVar] = V_j[iVar] + Project_Grad_j; + flowPrimVar_i[iVar] = V_i[iVar] + Project_Grad_i; + flowPrimVar_j[iVar] = V_j[iVar] + Project_Grad_j; } } - numerics->SetPrimitive(FlowPrimVar_i, FlowPrimVar_j); + numerics->SetPrimitive(flowPrimVar_i, flowPrimVar_j); - /*--- Turbulent variables using gradient reconstruction and limiters ---*/ + /*--- Reconstruct turbulence variables. ---*/ Gradient_i = nodes->GetGradient_Reconstruction(iPoint); Gradient_j = nodes->GetGradient_Reconstruction(jPoint); @@ -167,53 +200,75 @@ void CTurbSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_containe } for (iVar = 0; iVar < nVar; iVar++) { - Project_Grad_i = 0.0; Project_Grad_j = 0.0; + su2double 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]; - Project_Grad_j += Vector_j[iDim]*Gradient_j[iVar][iDim]; + Project_Grad_i += Vector_ij[iDim]*Gradient_i[iVar][iDim]; + Project_Grad_j -= Vector_ij[iDim]*Gradient_j[iVar][iDim]; } if (limiter) { - Solution_i[iVar] = Turb_i[iVar] + Limiter_i[iVar]*Project_Grad_i; - Solution_j[iVar] = Turb_j[iVar] + Limiter_j[iVar]*Project_Grad_j; + solution_i[iVar] = Turb_i[iVar] + Limiter_i[iVar]*Project_Grad_i; + solution_j[iVar] = Turb_j[iVar] + Limiter_j[iVar]*Project_Grad_j; } else { - Solution_i[iVar] = Turb_i[iVar] + Project_Grad_i; - Solution_j[iVar] = Turb_j[iVar] + Project_Grad_j; + solution_i[iVar] = Turb_i[iVar] + Project_Grad_i; + solution_j[iVar] = Turb_j[iVar] + Project_Grad_j; } } - numerics->SetTurbVar(Solution_i, Solution_j); + numerics->SetTurbVar(solution_i, solution_j); } /*--- Add and subtract residual ---*/ - numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); + auto residual = numerics->ComputeResidual(config); - LinSysRes.AddBlock(iPoint, Residual); - LinSysRes.SubtractBlock(jPoint, Residual); + LinSysRes.AddBlock(iPoint, residual); + LinSysRes.SubtractBlock(jPoint, residual); /*--- Implicit part ---*/ - Jacobian.UpdateBlocks(iEdge, iPoint, jPoint, Jacobian_i, Jacobian_j); + Jacobian.UpdateBlocks(iEdge, iPoint, jPoint, residual.jacobian_i, residual.jacobian_j); } - + } // end color loop + } // end SU2_OMP_PARALLEL } void CTurbSolver::Viscous_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics_container, CConfig *config, unsigned short iMesh, unsigned short iRKStep) { - CNumerics* numerics = numerics_container[VISC_TERM]; + CVariable* flowNodes = solver_container[FLOW_SOL]->GetNodes(); + + /*--- Start OpenMP parallel section. ---*/ + + SU2_OMP_PARALLEL + { + /*--- Pick one numerics object per thread. ---*/ + CNumerics* numerics = numerics_container[VISC_TERM + omp_get_thread_num()*MAX_TERMS]; + + /*--- Loop over all the edges ---*/ - unsigned long iEdge, iPoint, jPoint; +#ifdef HAVE_OMP + /*--- Chunk size is at least OMP_MIN_SIZE and a multiple of the color group size. ---*/ + auto chunkSize = roundUpDiv(OMP_MIN_SIZE, ColorGroupSize)*ColorGroupSize; - for (iEdge = 0; iEdge < geometry->GetnEdge(); iEdge++) { + /*--- Loop over edge colors. ---*/ + for (auto color : EdgeColoring) + { + SU2_OMP_FOR_DYN(chunkSize) + for(auto k = 0ul; k < color.size; ++k) { + auto iEdge = color.indices[k]; +#else + /*--- Natural coloring. ---*/ + { + for (auto iEdge = 0ul; iEdge < geometry->GetnEdge(); iEdge++) { +#endif /*--- Points in edge ---*/ - iPoint = geometry->edge[iEdge]->GetNode(0); - jPoint = geometry->edge[iEdge]->GetNode(1); + auto iPoint = geometry->edge[iEdge]->GetNode(0); + auto jPoint = geometry->edge[iEdge]->GetNode(1); /*--- Points coordinates, and normal vector ---*/ @@ -223,31 +278,35 @@ void CTurbSolver::Viscous_Residual(CGeometry *geometry, CSolver **solver_contain /*--- Conservative variables w/o reconstruction ---*/ - numerics->SetPrimitive(solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint), - solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(jPoint)); + numerics->SetPrimitive(flowNodes->GetPrimitive(iPoint), + flowNodes->GetPrimitive(jPoint)); /*--- Turbulent variables w/o reconstruction, and its gradients ---*/ - numerics->SetTurbVar(nodes->GetSolution(iPoint), nodes->GetSolution(jPoint)); - numerics->SetTurbVarGradient(nodes->GetGradient(iPoint), nodes->GetGradient(jPoint)); + 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(nodes->GetF1blending(iPoint), nodes->GetF1blending(jPoint)); + numerics->SetF1blending(nodes->GetF1blending(iPoint), + nodes->GetF1blending(jPoint)); /*--- Compute residual, and Jacobians ---*/ - numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); + auto residual = numerics->ComputeResidual(config); /*--- Add and subtract residual, and update Jacobians ---*/ - LinSysRes.SubtractBlock(iPoint, Residual); - LinSysRes.AddBlock(jPoint, Residual); + LinSysRes.SubtractBlock(iPoint, residual); + LinSysRes.AddBlock(jPoint, residual); - Jacobian.UpdateBlocksSub(iEdge, iPoint, jPoint, Jacobian_i, Jacobian_j); + Jacobian.UpdateBlocksSub(iEdge, iPoint, jPoint, residual.jacobian_i, residual.jacobian_j); } - + } // end color loop + } // end SU2_OMP_PARALLEL } void CTurbSolver::BC_Sym_Plane(CGeometry *geometry, @@ -830,7 +889,6 @@ void CTurbSolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConfig * int counter = 0; long iPoint_Local = 0; unsigned long iPoint_Global = 0; unsigned long iPoint_Global_Local = 0; - unsigned short rbuf_NotMatching = 0, sbuf_NotMatching = 0; /*--- Skip flow variables ---*/ @@ -880,14 +938,7 @@ void CTurbSolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConfig * /*--- Detect a wrong solution file ---*/ - if (iPoint_Global_Local < nPointDomain) { sbuf_NotMatching = 1; } - -#ifndef HAVE_MPI - rbuf_NotMatching = sbuf_NotMatching; -#else - SU2_MPI::Allreduce(&sbuf_NotMatching, &rbuf_NotMatching, 1, MPI_UNSIGNED_SHORT, MPI_SUM, MPI_COMM_WORLD); -#endif - if (rbuf_NotMatching != 0) { + if (iPoint_Global_Local < nPointDomain) { SU2_MPI::Error(string("The solution file ") + restart_filename + string(" doesn't match with the mesh file!\n") + string("It could be empty lines at the end of the file."), CURRENT_FUNCTION); } @@ -924,8 +975,7 @@ void CTurbSolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConfig * /*--- Delete the class memory that is used to load the restart. ---*/ - if (Restart_Vars != NULL) delete [] Restart_Vars; - if (Restart_Data != NULL) delete [] Restart_Data; - Restart_Vars = NULL; Restart_Data = NULL; + delete [] Restart_Vars; Restart_Vars = nullptr; + delete [] Restart_Data; Restart_Data = nullptr; } From f53aec3bfd531a1d7c25abe92ffa51cc063fb121 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Sat, 1 Feb 2020 19:10:34 +0000 Subject: [PATCH 076/118] thread-safe convection and diffusion turbulence numerics --- .../numerics/turbulent/turb_convection.hpp | 77 +++----- .../numerics/turbulent/turb_diffusion.hpp | 133 +++++-------- .../src/numerics/flow/convection/centered.cpp | 13 +- .../numerics/turbulent/turb_convection.cpp | 106 +++++------ .../src/numerics/turbulent/turb_diffusion.cpp | 169 ++++++++--------- SU2_CFD/src/solvers/CTurbSASolver.cpp | 176 +++++++++--------- SU2_CFD/src/solvers/CTurbSSTSolver.cpp | 120 ++++++------ 7 files changed, 365 insertions(+), 429 deletions(-) diff --git a/SU2_CFD/include/numerics/turbulent/turb_convection.hpp b/SU2_CFD/include/numerics/turbulent/turb_convection.hpp index f8a1d3fcbf1a..a63f16f890ad 100644 --- a/SU2_CFD/include/numerics/turbulent/turb_convection.hpp +++ b/SU2_CFD/include/numerics/turbulent/turb_convection.hpp @@ -45,7 +45,16 @@ * \author C. Pederson, A. Bueno., and A. Campos. */ class CUpwScalar : public CNumerics { -private: +protected: + su2double + q_ij = 0.0, /*!< \brief Projected velocity at the face. */ + a0 = 0.0, /*!< \brief The maximum of the face-normal velocity and 0 */ + a1 = 0.0, /*!< \brief The minimum of the face-normal velocity and 0 */ + *Flux = nullptr, /*!< \brief Final result, diffusive flux/residual. */ + **Jacobian_i = nullptr, /*!< \brief Flux Jacobian w.r.t. node i. */ + **Jacobian_j = nullptr; /*!< \brief Flux Jacobian w.r.t. node j. */ + + const bool implicit = false, incompressible = false, dynamic_grid = false; /*! * \brief A pure virtual function; Adds any extra variables to AD @@ -53,35 +62,20 @@ class CUpwScalar : public CNumerics { virtual void ExtraADPreaccIn() = 0; /*! - * \brief Model-specific steps in the ComputeResidual method - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \brief Model-specific steps in the ComputeResidual method, derived classes + * compute the Flux and its Jacobians via this method. * \param[in] config - Definition of the particular problem. */ - virtual void FinishResidualCalc(su2double *val_residual, - su2double **Jacobian_i, - su2double **Jacobian_j, - CConfig *config) = 0; - -protected: - su2double *Velocity_i, *Velocity_j; /*!< \brief Velocity, minus any grid movement. */ - su2double Density_i, Density_j; - bool implicit, dynamic_grid, incompressible; - su2double q_ij, /*!< \brief Projected velocity at the face. */ - a0, /*!< \brief The maximum of the face-normal velocity and 0 */ - a1; /*!< \brief The minimum of the face-normal velocity and 0 */ - unsigned short iDim; + virtual void FinishResidualCalc(const CConfig* config) = 0; public: - /*! * \brief Constructor of the class. * \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. */ - CUpwScalar(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + CUpwScalar(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config); /*! * \brief Destructor of the class. @@ -90,12 +84,11 @@ class CUpwScalar : public CNumerics { /*! * \brief Compute the scalar upwind flux between two nodes i and j. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). * \param[in] config - Definition of the particular problem. + * \return A lightweight const-view (read-only) of the residual/flux and Jacobians. */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + ResidualType<> ComputeResidual(const CConfig* config); + }; /*! @@ -104,38 +97,28 @@ class CUpwScalar : public CNumerics { * \ingroup ConvDiscr * \author A. Bueno. */ -class CUpwSca_TurbSA : public CUpwScalar { +class CUpwSca_TurbSA final : public CUpwScalar { private: - /*! * \brief Adds any extra variables to AD */ - void ExtraADPreaccIn(); + void ExtraADPreaccIn() override; /*! * \brief SA specific steps in the ComputeResidual method - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). * \param[in] config - Definition of the particular problem. */ - void FinishResidualCalc(su2double *val_residual, su2double **Jacobian_i, - su2double **Jacobian_j, CConfig *config); + void FinishResidualCalc(const CConfig* config) override; public: - /*! * \brief Constructor of the class. * \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. */ - CUpwSca_TurbSA(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + CUpwSca_TurbSA(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config); - /*! - * \brief Destructor of the class. - */ - ~CUpwSca_TurbSA(void); }; /*! @@ -144,36 +127,26 @@ class CUpwSca_TurbSA : public CUpwScalar { * \ingroup ConvDiscr * \author A. Campos. */ -class CUpwSca_TurbSST : public CUpwScalar { +class CUpwSca_TurbSST final : public CUpwScalar { private: - /*! * \brief Adds any extra variables to AD */ - void ExtraADPreaccIn(); + void ExtraADPreaccIn() override; /*! * \brief SST specific steps in the ComputeResidual method - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). * \param[in] config - Definition of the particular problem. */ - void FinishResidualCalc(su2double *val_residual, su2double **Jacobian_i, - su2double **Jacobian_j, CConfig *config); + void FinishResidualCalc(const CConfig* config) override; public: - /*! * \brief Constructor of the class. * \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. */ - CUpwSca_TurbSST(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + CUpwSca_TurbSST(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config); - /*! - * \brief Destructor of the class. - */ - ~CUpwSca_TurbSST(void); }; diff --git a/SU2_CFD/include/numerics/turbulent/turb_diffusion.hpp b/SU2_CFD/include/numerics/turbulent/turb_diffusion.hpp index 500cbc4f3426..00b1738b4763 100644 --- a/SU2_CFD/include/numerics/turbulent/turb_diffusion.hpp +++ b/SU2_CFD/include/numerics/turbulent/turb_diffusion.hpp @@ -45,7 +45,19 @@ * \author C. Pederson, A. Bueno, and F. Palacios */ class CAvgGrad_Scalar : public CNumerics { - private: +protected: + su2double + Edge_Vector[MAXNDIM] = {0.0}, /*!< \brief Vector from node i to node j. */ + *Proj_Mean_GradTurbVar_Normal = nullptr, /*!< \brief Mean_gradTurbVar DOT normal. */ + *Proj_Mean_GradTurbVar_Edge = nullptr, /*!< \brief Mean_gradTurbVar DOT Edge_Vector. */ + *Proj_Mean_GradTurbVar = nullptr, /*!< \brief Mean_gradTurbVar DOT normal, corrected if required. */ + dist_ij_2 = 0.0, /*!< \brief |Edge_Vector|^2 */ + proj_vector_ij = 0.0, /*!< \brief (Edge_Vector DOT normal)/|Edge_Vector|^2 */ + *Flux = nullptr, /*!< \brief Final result, diffusive flux/residual. */ + **Jacobian_i = nullptr, /*!< \brief Flux Jacobian w.r.t. node i. */ + **Jacobian_j = nullptr; /*!< \brief Flux Jacobian w.r.t. node j. */ + + const bool correct_gradient = false, implicit = false, incompressible = false; /*! * \brief A pure virtual function; Adds any extra variables to AD @@ -53,38 +65,22 @@ class CAvgGrad_Scalar : public CNumerics { virtual void ExtraADPreaccIn() = 0; /*! - * \brief Model-specific steps in the ComputeResidual method - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). + * \brief Model-specific steps in the ComputeResidual method, derived classes + * should compute the Flux and Jacobians (i/j) inside this method. * \param[in] config - Definition of the particular problem. */ - virtual void FinishResidualCalc(su2double *val_residual, - su2double **Jacobian_i, - su2double **Jacobian_j, - CConfig *config) = 0; - - protected: - bool implicit, incompressible; - bool correct_gradient; - unsigned short iVar, iDim; - su2double **Mean_GradTurbVar; /*!< \brief Average of gradients at cell face */ - su2double *Edge_Vector, /*!< \brief Vector from node i to node j. */ - *Proj_Mean_GradTurbVar_Normal, /*!< \brief Mean_gradTurbVar DOT normal */ - *Proj_Mean_GradTurbVar_Edge, /*!< \brief Mean_gradTurbVar DOT Edge_Vector */ - *Proj_Mean_GradTurbVar; /*!< \brief Mean_gradTurbVar DOT normal, corrected if required*/ - su2double dist_ij_2, /*!< \brief |Edge_Vector|^2 */ - proj_vector_ij; /*!< \brief (Edge_Vector DOT normal)/|Edge_Vector|^2 */ - - public: + virtual void FinishResidualCalc(const CConfig* config) = 0; + +public: /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. * \param[in] val_nVar - Number of variables of the problem. + * \param[in] correct_gradient - Whether to correct gradient for skewness. * \param[in] config - Definition of the particular problem. */ CAvgGrad_Scalar(unsigned short val_nDim, unsigned short val_nVar, - bool correct_gradient, CConfig *config); + bool correct_gradient, const CConfig* config); /*! * \brief Destructor of the class. @@ -93,13 +89,11 @@ class CAvgGrad_Scalar : public CNumerics { /*! * \brief Compute the viscous residual using an average of gradients without correction. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] Jacobian_j - Jacobian of the numerical method at node j (implicit computation). * \param[in] config - Definition of the particular problem. + * \return A lightweight const-view (read-only) of the residual/flux and Jacobians. */ - void ComputeResidual(su2double *val_residual, su2double **Jacobian_i, - su2double **Jacobian_j, CConfig *config); + ResidualType<> ComputeResidual(const CConfig* config); + }; /*! @@ -108,42 +102,31 @@ class CAvgGrad_Scalar : public CNumerics { * \ingroup ViscDiscr * \author A. Bueno. */ -class CAvgGrad_TurbSA : public CAvgGrad_Scalar { +class CAvgGrad_TurbSA final : public CAvgGrad_Scalar { private: - - const su2double sigma; - su2double nu_i, nu_j, nu_e; + const su2double sigma = 2.0/3.0; /*! * \brief Adds any extra variables to AD */ - void ExtraADPreaccIn(void); + void ExtraADPreaccIn(void) override; /*! * \brief SA specific steps in the ComputeResidual method - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). * \param[in] config - Definition of the particular problem. */ - void FinishResidualCalc(su2double *val_residual, su2double **Jacobian_i, - su2double **Jacobian_j, CConfig *config); + void FinishResidualCalc(const CConfig* config) override; public: - /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. * \param[in] val_nVar - Number of variables of the problem. + * \param[in] correct_grad - Whether to correct gradient for skewness. * \param[in] config - Definition of the particular problem. */ CAvgGrad_TurbSA(unsigned short val_nDim, unsigned short val_nVar, - bool correct_grad, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CAvgGrad_TurbSA(void); + bool correct_grad, const CConfig* config); }; /*! @@ -152,44 +135,32 @@ class CAvgGrad_TurbSA : public CAvgGrad_Scalar { * \ingroup ViscDiscr * \author F. Palacios */ -class CAvgGrad_TurbSA_Neg : public CAvgGrad_Scalar { +class CAvgGrad_TurbSA_Neg final : public CAvgGrad_Scalar { private: - - const su2double sigma; - const su2double cn1; - su2double fn, Xi; - su2double nu_i, nu_j, nu_ij, nu_tilde_ij, nu_e; + const su2double sigma = 2.0/3.0; + const su2double cn1 = 16.0; /*! * \brief Adds any extra variables to AD */ - void ExtraADPreaccIn(void); + void ExtraADPreaccIn(void) override; /*! * \brief SA specific steps in the ComputeResidual method - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). * \param[in] config - Definition of the particular problem. */ - void FinishResidualCalc(su2double *val_residual, su2double **Jacobian_i, - su2double **Jacobian_j, CConfig *config); + void FinishResidualCalc(const CConfig* config) override; public: - /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. * \param[in] val_nVar - Number of variables of the problem. + * \param[in] correct_grad - Whether to correct gradient for skewness. * \param[in] config - Definition of the particular problem. */ CAvgGrad_TurbSA_Neg(unsigned short val_nDim, unsigned short val_nVar, - bool correct_grad, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CAvgGrad_TurbSA_Neg(void); + bool correct_grad, const CConfig* config); }; /*! @@ -198,48 +169,38 @@ class CAvgGrad_TurbSA_Neg : public CAvgGrad_Scalar { * \ingroup ViscDiscr * \author A. Bueno. */ -class CAvgGrad_TurbSST : public CAvgGrad_Scalar { +class CAvgGrad_TurbSST final : public CAvgGrad_Scalar { private: - su2double sigma_k1, /*!< \brief Constants for the viscous terms, k-w (1), k-eps (2)*/ - sigma_k2, - sigma_om1, - sigma_om2; - - su2double diff_kine, /*!< \brief Diffusivity for viscous terms of tke eq */ - diff_omega; /*!< \brief Diffusivity for viscous terms of omega eq */ + const su2double + sigma_k1 = 0.0, /*!< \brief Constants for the viscous terms, k-w (1), k-eps (2)*/ + sigma_k2 = 0.0, + sigma_om1 = 0.0, + sigma_om2 = 0.0; su2double F1_i, F1_j; /*!< \brief Menter's first blending function */ /*! * \brief Adds any extra variables to AD */ - void ExtraADPreaccIn(void); + void ExtraADPreaccIn(void) override; /*! * \brief SST specific steps in the ComputeResidual method - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). * \param[in] config - Definition of the particular problem. */ - void FinishResidualCalc(su2double *val_residual, su2double **Jacobian_i, - su2double **Jacobian_j, CConfig *config); + void FinishResidualCalc(const CConfig* config) override; public: - /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. * \param[in] val_nVar - Number of variables of the problem. + * \param[in] constants - Constants of the model. + * \param[in] correct_grad - Whether to correct gradient for skewness. * \param[in] config - Definition of the particular problem. */ CAvgGrad_TurbSST(unsigned short val_nDim, unsigned short val_nVar, - const su2double* constants, bool correct_grad, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CAvgGrad_TurbSST(void); + const su2double* constants, bool correct_grad, const CConfig* config); /*! * \brief Sets value of first blending function. diff --git a/SU2_CFD/src/numerics/flow/convection/centered.cpp b/SU2_CFD/src/numerics/flow/convection/centered.cpp index 50e396e2fa8c..1b1ab3d0af07 100644 --- a/SU2_CFD/src/numerics/flow/convection/centered.cpp +++ b/SU2_CFD/src/numerics/flow/convection/centered.cpp @@ -54,12 +54,15 @@ CCentBase_Flow::~CCentBase_Flow(void) { delete [] Diff_U; delete [] Diff_Lapl; delete [] ProjFlux; - for (iVar = 0; iVar < nVar; iVar++) { - delete [] Jacobian_i[iVar]; - delete [] Jacobian_j[iVar]; + + if (Jacobian_i != nullptr) { + for (iVar = 0; iVar < nVar; iVar++) { + delete [] Jacobian_i[iVar]; + delete [] Jacobian_j[iVar]; + } + delete [] Jacobian_i; + delete [] Jacobian_j; } - delete [] Jacobian_i; - delete [] Jacobian_j; } CNumerics::ResidualType<> CCentBase_Flow::ComputeResidual(const CConfig* config) { diff --git a/SU2_CFD/src/numerics/turbulent/turb_convection.cpp b/SU2_CFD/src/numerics/turbulent/turb_convection.cpp index b627519c5e27..09016b3b475c 100644 --- a/SU2_CFD/src/numerics/turbulent/turb_convection.cpp +++ b/SU2_CFD/src/numerics/turbulent/turb_convection.cpp @@ -30,30 +30,37 @@ CUpwScalar::CUpwScalar(unsigned short val_nDim, unsigned short val_nVar, - CConfig *config) : - CNumerics(val_nDim, val_nVar, config) { - - implicit = (config->GetKind_TimeIntScheme_Turb() == EULER_IMPLICIT); - incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); - /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ - dynamic_grid = config->GetDynamic_Grid(); - - Velocity_i = new su2double [nDim]; - Velocity_j = new su2double [nDim]; - + const CConfig* config) : + CNumerics(val_nDim, val_nVar, config), + implicit(config->GetKind_TimeIntScheme_Turb() == EULER_IMPLICIT), + incompressible(config->GetKind_Regime() == INCOMPRESSIBLE), + dynamic_grid(config->GetDynamic_Grid()) +{ + Flux = new su2double [nVar]; + Jacobian_i = new su2double* [nVar]; + Jacobian_j = new su2double* [nVar]; + for (unsigned short iVar = 0; iVar < nVar; iVar++) { + Jacobian_i[iVar] = new su2double [nVar]; + Jacobian_j[iVar] = new su2double [nVar]; + } } CUpwScalar::~CUpwScalar(void) { - delete [] Velocity_i; - delete [] Velocity_j; - + delete [] Flux; + if (Jacobian_i != nullptr) { + for (unsigned short iVar = 0; iVar < nVar; iVar++) { + delete [] Jacobian_i[iVar]; + delete [] Jacobian_j[iVar]; + } + delete [] Jacobian_i; + delete [] Jacobian_j; + } } -void CUpwScalar::ComputeResidual(su2double *val_residual, - su2double **val_Jacobian_i, - su2double **val_Jacobian_j, - CConfig *config) { +CNumerics::ResidualType<> CUpwScalar::ComputeResidual(const CConfig* config) { + + unsigned short iDim; AD::StartPreacc(); AD::SetPreaccIn(Normal, nDim); @@ -70,82 +77,69 @@ void CUpwScalar::ComputeResidual(su2double *val_residual, q_ij = 0.0; if (dynamic_grid) { for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = V_i[iDim+1] - GridVel_i[iDim]; - Velocity_j[iDim] = V_j[iDim+1] - GridVel_j[iDim]; - q_ij += 0.5*(Velocity_i[iDim]+Velocity_j[iDim])*Normal[iDim]; + su2double Velocity_i = V_i[iDim+1] - GridVel_i[iDim]; + su2double Velocity_j = V_j[iDim+1] - GridVel_j[iDim]; + q_ij += 0.5*(Velocity_i+Velocity_j)*Normal[iDim]; } } else { for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = V_i[iDim+1]; - Velocity_j[iDim] = V_j[iDim+1]; - q_ij += 0.5*(Velocity_i[iDim]+Velocity_j[iDim])*Normal[iDim]; + q_ij += 0.5*(V_i[iDim+1]+V_j[iDim+1])*Normal[iDim]; } } a0 = 0.5*(q_ij+fabs(q_ij)); a1 = 0.5*(q_ij-fabs(q_ij)); - FinishResidualCalc(val_residual, val_Jacobian_i, val_Jacobian_j, config); - + FinishResidualCalc(config); - AD::SetPreaccOut(val_residual, nVar); + AD::SetPreaccOut(Flux, nVar); AD::EndPreacc(); + return ResidualType<>(Flux, Jacobian_i, Jacobian_j); + } CUpwSca_TurbSA::CUpwSca_TurbSA(unsigned short val_nDim, unsigned short val_nVar, - CConfig *config) - : CUpwScalar(val_nDim, val_nVar, config) { -} - -CUpwSca_TurbSA::~CUpwSca_TurbSA(void) { -} + const CConfig* config) : + CUpwScalar(val_nDim, val_nVar, config) { } void CUpwSca_TurbSA::ExtraADPreaccIn() { - AD::SetPreaccIn(V_i, nDim+1); AD::SetPreaccIn(V_j, nDim+1); + AD::SetPreaccIn(V_i, nDim+1); + AD::SetPreaccIn(V_j, nDim+1); } -void CUpwSca_TurbSA::FinishResidualCalc(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { +void CUpwSca_TurbSA::FinishResidualCalc(const CConfig* config) { - val_residual[0] = a0*TurbVar_i[0]+a1*TurbVar_j[0]; + Flux[0] = a0*TurbVar_i[0]+a1*TurbVar_j[0]; if (implicit) { - val_Jacobian_i[0][0] = a0; - val_Jacobian_j[0][0] = a1; + Jacobian_i[0][0] = a0; + Jacobian_j[0][0] = a1; } } CUpwSca_TurbSST::CUpwSca_TurbSST(unsigned short val_nDim, unsigned short val_nVar, - CConfig *config) - : CUpwScalar(val_nDim, val_nVar, config) { -} - -CUpwSca_TurbSST::~CUpwSca_TurbSST(void) { -} + const CConfig* config) : + CUpwScalar(val_nDim, val_nVar, config) { } void CUpwSca_TurbSST::ExtraADPreaccIn() { - AD::SetPreaccIn(V_i, nDim+3); AD::SetPreaccIn(V_j, nDim+3); - } -void CUpwSca_TurbSST::FinishResidualCalc(su2double *val_residual, - su2double **val_Jacobian_i, - su2double **val_Jacobian_j, - CConfig *config) { +void CUpwSca_TurbSST::FinishResidualCalc(const CConfig* config) { - val_residual[0] = a0*Density_i*TurbVar_i[0]+a1*Density_j*TurbVar_j[0]; - val_residual[1] = a0*Density_i*TurbVar_i[1]+a1*Density_j*TurbVar_j[1]; + Flux[0] = a0*Density_i*TurbVar_i[0]+a1*Density_j*TurbVar_j[0]; + Flux[1] = a0*Density_i*TurbVar_i[1]+a1*Density_j*TurbVar_j[1]; if (implicit) { - val_Jacobian_i[0][0] = a0; val_Jacobian_i[0][1] = 0.0; - val_Jacobian_i[1][0] = 0.0; val_Jacobian_i[1][1] = a0; + Jacobian_i[0][0] = a0; Jacobian_i[0][1] = 0.0; + Jacobian_i[1][0] = 0.0; Jacobian_i[1][1] = a0; - val_Jacobian_j[0][0] = a1; val_Jacobian_j[0][1] = 0.0; - val_Jacobian_j[1][0] = 0.0; val_Jacobian_j[1][1] = a1; + Jacobian_j[0][0] = a1; Jacobian_j[0][1] = 0.0; + Jacobian_j[1][0] = 0.0; Jacobian_j[1][1] = a1; } } diff --git a/SU2_CFD/src/numerics/turbulent/turb_diffusion.cpp b/SU2_CFD/src/numerics/turbulent/turb_diffusion.cpp index 2625021984c9..c6f67ce28fc0 100644 --- a/SU2_CFD/src/numerics/turbulent/turb_diffusion.cpp +++ b/SU2_CFD/src/numerics/turbulent/turb_diffusion.cpp @@ -29,40 +29,47 @@ #include "../../../include/numerics/turbulent/turb_diffusion.hpp" CAvgGrad_Scalar::CAvgGrad_Scalar(unsigned short val_nDim, - unsigned short val_nVar, - bool correct_grad, - CConfig *config) - : CNumerics(val_nDim, val_nVar, config), correct_gradient(correct_grad) { - - implicit = (config->GetKind_TimeIntScheme_Turb() == EULER_IMPLICIT); - incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); - - Edge_Vector = new su2double [nDim]; + unsigned short val_nVar, + bool correct_grad, + const CConfig* config) : + CNumerics(val_nDim, val_nVar, config), + correct_gradient(correct_grad), + implicit(config->GetKind_TimeIntScheme_Turb() == EULER_IMPLICIT), + incompressible(config->GetKind_Regime() == INCOMPRESSIBLE) +{ Proj_Mean_GradTurbVar_Normal = new su2double [nVar]; Proj_Mean_GradTurbVar_Edge = new su2double [nVar]; Proj_Mean_GradTurbVar = new su2double [nVar]; - Mean_GradTurbVar = new su2double* [nVar]; - for (iVar = 0; iVar < nVar; iVar++) - Mean_GradTurbVar[iVar] = new su2double [nDim]; + Flux = new su2double [nVar]; + Jacobian_i = new su2double* [nVar]; + Jacobian_j = new su2double* [nVar]; + for (unsigned short iVar = 0; iVar < nVar; iVar++) { + Jacobian_i[iVar] = new su2double [nVar]; + Jacobian_j[iVar] = new su2double [nVar]; + } } CAvgGrad_Scalar::~CAvgGrad_Scalar(void) { - delete [] Edge_Vector; delete [] Proj_Mean_GradTurbVar_Normal; delete [] Proj_Mean_GradTurbVar_Edge; delete [] Proj_Mean_GradTurbVar; - for (iVar = 0; iVar < nVar; iVar++) - delete [] Mean_GradTurbVar[iVar]; - delete [] Mean_GradTurbVar; + delete [] Flux; + if (Jacobian_i != nullptr) { + for (unsigned short iVar = 0; iVar < nVar; iVar++) { + delete [] Jacobian_i[iVar]; + delete [] Jacobian_j[iVar]; + } + delete [] Jacobian_i; + delete [] Jacobian_j; + } } -void CAvgGrad_Scalar::ComputeResidual(su2double *val_residual, - su2double **Jacobian_i, - su2double **Jacobian_j, - CConfig *config) { +CNumerics::ResidualType<> CAvgGrad_Scalar::ComputeResidual(const CConfig* config) { + + unsigned short iVar, iDim; AD::StartPreacc(); AD::SetPreaccIn(Coord_i, nDim); AD::SetPreaccIn(Coord_j, nDim); @@ -105,12 +112,13 @@ void CAvgGrad_Scalar::ComputeResidual(su2double *val_residual, Proj_Mean_GradTurbVar_Normal[iVar] = 0.0; Proj_Mean_GradTurbVar_Edge[iVar] = 0.0; for (iDim = 0; iDim < nDim; iDim++) { - Mean_GradTurbVar[iVar][iDim] = 0.5*(TurbVar_Grad_i[iVar][iDim] + - TurbVar_Grad_j[iVar][iDim]); - Proj_Mean_GradTurbVar_Normal[iVar] += Mean_GradTurbVar[iVar][iDim] * - Normal[iDim]; + su2double Mean_GradTurbVar = 0.5*(TurbVar_Grad_i[iVar][iDim] + + TurbVar_Grad_j[iVar][iDim]); + + Proj_Mean_GradTurbVar_Normal[iVar] += Mean_GradTurbVar * Normal[iDim]; + if (correct_gradient) - Proj_Mean_GradTurbVar_Edge[iVar] += Mean_GradTurbVar[iVar][iDim]*Edge_Vector[iDim]; + Proj_Mean_GradTurbVar_Edge[iVar] += Mean_GradTurbVar * Edge_Vector[iDim]; } Proj_Mean_GradTurbVar[iVar] = Proj_Mean_GradTurbVar_Normal[iVar]; if (correct_gradient) { @@ -119,34 +127,30 @@ void CAvgGrad_Scalar::ComputeResidual(su2double *val_residual, } } - FinishResidualCalc(val_residual, Jacobian_i, Jacobian_j, config); + FinishResidualCalc(config); - AD::SetPreaccOut(val_residual, nVar); + AD::SetPreaccOut(Flux, nVar); AD::EndPreacc(); -} + return ResidualType<>(Flux, Jacobian_i, Jacobian_j); -CAvgGrad_TurbSA::CAvgGrad_TurbSA(unsigned short val_nDim, - unsigned short val_nVar, bool correct_grad, - CConfig *config) - : CAvgGrad_Scalar(val_nDim, val_nVar, correct_grad, config), sigma(2./3.) { } -CAvgGrad_TurbSA::~CAvgGrad_TurbSA(void) { -} +CAvgGrad_TurbSA::CAvgGrad_TurbSA(unsigned short val_nDim, unsigned short val_nVar, + bool correct_grad, const CConfig* config) : + CAvgGrad_Scalar(val_nDim, val_nVar, correct_grad, config) { } -void CAvgGrad_TurbSA::ExtraADPreaccIn() { -} +void CAvgGrad_TurbSA::ExtraADPreaccIn() { } -void CAvgGrad_TurbSA::FinishResidualCalc(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config) { +void CAvgGrad_TurbSA::FinishResidualCalc(const CConfig* config) { /*--- Compute mean effective viscosity ---*/ - nu_i = Laminar_Viscosity_i/Density_i; - nu_j = Laminar_Viscosity_j/Density_j; - nu_e = 0.5*(nu_i+nu_j+TurbVar_i[0]+TurbVar_j[0]); + su2double nu_i = Laminar_Viscosity_i/Density_i; + su2double nu_j = Laminar_Viscosity_j/Density_j; + su2double nu_e = 0.5*(nu_i+nu_j+TurbVar_i[0]+TurbVar_j[0]); - val_residual[0] = nu_e*Proj_Mean_GradTurbVar[0]/sigma; + Flux[0] = nu_e*Proj_Mean_GradTurbVar[0]/sigma; /*--- For Jacobians -> Use of TSL approx. to compute derivatives of the gradients ---*/ @@ -157,45 +161,36 @@ void CAvgGrad_TurbSA::FinishResidualCalc(su2double *val_residual, su2double **Ja } - CAvgGrad_TurbSA_Neg::CAvgGrad_TurbSA_Neg(unsigned short val_nDim, unsigned short val_nVar, bool correct_grad, - CConfig *config) - : CAvgGrad_Scalar(val_nDim, val_nVar, correct_grad, config), - sigma(2./3.), cn1(16.0), fn(0.0) { -} - -CAvgGrad_TurbSA_Neg::~CAvgGrad_TurbSA_Neg(void) { -} + const CConfig* config) : + CAvgGrad_Scalar(val_nDim, val_nVar, correct_grad, config) { } -void CAvgGrad_TurbSA_Neg::ExtraADPreaccIn() { -} +void CAvgGrad_TurbSA_Neg::ExtraADPreaccIn() { } -void CAvgGrad_TurbSA_Neg::FinishResidualCalc(su2double *val_residual, - su2double **Jacobian_i, - su2double **Jacobian_j, - CConfig *config) { +void CAvgGrad_TurbSA_Neg::FinishResidualCalc(const CConfig* config) { /*--- Compute mean effective viscosity ---*/ - nu_i = Laminar_Viscosity_i/Density_i; - nu_j = Laminar_Viscosity_j/Density_j; + su2double nu_i = Laminar_Viscosity_i/Density_i; + su2double nu_j = Laminar_Viscosity_j/Density_j; - nu_ij = 0.5*(nu_i+nu_j); - nu_tilde_ij = 0.5*(TurbVar_i[0]+TurbVar_j[0]); + su2double nu_ij = 0.5*(nu_i+nu_j); + su2double nu_tilde_ij = 0.5*(TurbVar_i[0]+TurbVar_j[0]); - Xi = nu_tilde_ij/nu_ij; + su2double nu_e; if (nu_tilde_ij > 0.0) { nu_e = nu_ij + nu_tilde_ij; } else { - fn = (cn1 + Xi*Xi*Xi)/(cn1 - Xi*Xi*Xi); + su2double Xi = nu_tilde_ij/nu_ij; + su2double fn = (cn1 + Xi*Xi*Xi)/(cn1 - Xi*Xi*Xi); nu_e = nu_ij + fn*nu_tilde_ij; } - val_residual[0] = nu_e*Proj_Mean_GradTurbVar_Normal[0]/sigma; + Flux[0] = nu_e*Proj_Mean_GradTurbVar_Normal[0]/sigma; /*--- For Jacobians -> Use of TSL approx. to compute derivatives of the gradients ---*/ @@ -210,57 +205,53 @@ CAvgGrad_TurbSST::CAvgGrad_TurbSST(unsigned short val_nDim, unsigned short val_nVar, const su2double *constants, bool correct_grad, - CConfig *config) - : CAvgGrad_Scalar(val_nDim, val_nVar, correct_grad, config) { - - sigma_k1 = constants[0]; - sigma_om1 = constants[2]; - sigma_k2 = constants[1]; - sigma_om2 = constants[3]; + const CConfig* config) : + CAvgGrad_Scalar(val_nDim, val_nVar, correct_grad, config), + sigma_k1(constants[0]), + sigma_k2(constants[1]), + sigma_om1(constants[2]), + sigma_om2(constants[3]) { - F1_i = 0.0; F1_j = 0.0; - diff_kine = 0.0; - diff_omega = 0.0; - -} - -CAvgGrad_TurbSST::~CAvgGrad_TurbSST(void) { } void CAvgGrad_TurbSST::ExtraADPreaccIn() { AD::SetPreaccIn(F1_i); AD::SetPreaccIn(F1_j); } -void CAvgGrad_TurbSST::FinishResidualCalc(su2double *val_residual, su2double **Jacobian_i, su2double **Jacobian_j, CConfig *config) { +void CAvgGrad_TurbSST::FinishResidualCalc(const CConfig* config) { su2double sigma_kine_i, sigma_kine_j, sigma_omega_i, sigma_omega_j; su2double diff_i_kine, diff_i_omega, diff_j_kine, diff_j_omega; /*--- Compute the blended constant for the viscous terms ---*/ - sigma_kine_i = F1_i*sigma_k1 + (1.0 - F1_i)*sigma_k2; - sigma_kine_j = F1_j*sigma_k1 + (1.0 - F1_j)*sigma_k2; + sigma_kine_i = F1_i*sigma_k1 + (1.0 - F1_i)*sigma_k2; + sigma_kine_j = F1_j*sigma_k1 + (1.0 - F1_j)*sigma_k2; sigma_omega_i = F1_i*sigma_om1 + (1.0 - F1_i)*sigma_om2; sigma_omega_j = F1_j*sigma_om1 + (1.0 - F1_j)*sigma_om2; /*--- Compute mean effective viscosity ---*/ - diff_i_kine = Laminar_Viscosity_i + sigma_kine_i*Eddy_Viscosity_i; - diff_j_kine = Laminar_Viscosity_j + sigma_kine_j*Eddy_Viscosity_j; + diff_i_kine = Laminar_Viscosity_i + sigma_kine_i*Eddy_Viscosity_i; + diff_j_kine = Laminar_Viscosity_j + sigma_kine_j*Eddy_Viscosity_j; diff_i_omega = Laminar_Viscosity_i + sigma_omega_i*Eddy_Viscosity_i; diff_j_omega = Laminar_Viscosity_j + sigma_omega_j*Eddy_Viscosity_j; - diff_kine = 0.5*(diff_i_kine + diff_j_kine); - diff_omega = 0.5*(diff_i_omega + diff_j_omega); + su2double diff_kine = 0.5*(diff_i_kine + diff_j_kine); + su2double diff_omega = 0.5*(diff_i_omega + diff_j_omega); - val_residual[0] = diff_kine*Proj_Mean_GradTurbVar[0]; - val_residual[1] = diff_omega*Proj_Mean_GradTurbVar[1]; + Flux[0] = diff_kine*Proj_Mean_GradTurbVar[0]; + Flux[1] = diff_omega*Proj_Mean_GradTurbVar[1]; /*--- For Jacobians -> Use of TSL approx. to compute derivatives of the gradients ---*/ if (implicit) { - Jacobian_i[0][0] = -diff_kine*proj_vector_ij/Density_i; Jacobian_i[0][1] = 0.0; - Jacobian_i[1][0] = 0.0; Jacobian_i[1][1] = -diff_omega*proj_vector_ij/Density_i; + su2double proj_on_rho = proj_vector_ij/Density_i; + + Jacobian_i[0][0] = -diff_kine*proj_on_rho; Jacobian_i[0][1] = 0.0; + Jacobian_i[1][0] = 0.0; Jacobian_i[1][1] = -diff_omega*proj_on_rho; + + proj_on_rho = proj_vector_ij/Density_j; - Jacobian_j[0][0] = diff_kine*proj_vector_ij/Density_j; Jacobian_j[0][1] = 0.0; - Jacobian_j[1][0] = 0.0; Jacobian_j[1][1] = diff_omega*proj_vector_ij/Density_j; + Jacobian_j[0][0] = diff_kine*proj_on_rho; Jacobian_j[0][1] = 0.0; + Jacobian_j[1][0] = 0.0; Jacobian_j[1][1] = diff_omega*proj_on_rho; } } diff --git a/SU2_CFD/src/solvers/CTurbSASolver.cpp b/SU2_CFD/src/solvers/CTurbSASolver.cpp index 4cb1faa5adfb..f28b10915683 100644 --- a/SU2_CFD/src/solvers/CTurbSASolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSASolver.cpp @@ -266,10 +266,12 @@ CTurbSASolver::~CTurbSASolver(void) { } -void CTurbSASolver::Preprocessing(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh, unsigned short iRKStep, unsigned short RunTime_EqSystem, bool Output) { +void CTurbSASolver::Preprocessing(CGeometry *geometry, CSolver **solver_container, CConfig *config, + unsigned short iMesh, unsigned short iRKStep, unsigned short RunTime_EqSystem, bool Output) { unsigned long iPoint; - bool limiter_turb = (config->GetKind_SlopeLimit_Turb() != NO_LIMITER) && (config->GetInnerIter() <= config->GetLimiterIter()); + bool limiter_turb = (config->GetKind_SlopeLimit_Turb() != NO_LIMITER) && + (config->GetInnerIter() <= config->GetLimiterIter()); unsigned short kind_hybridRANSLES = config->GetKind_HybridRANSLES(); su2double** PrimGrad_Flow = NULL; su2double* Vorticity = NULL; @@ -461,10 +463,10 @@ void CTurbSASolver::Source_Residual(CGeometry *geometry, CSolver **solver_contai void CTurbSASolver::Source_Template(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, CConfig *config, unsigned short iMesh) { - } -void CTurbSASolver::BC_HeatFlux_Wall(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { +void CTurbSASolver::BC_HeatFlux_Wall(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, + CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { unsigned long iPoint, iVertex; unsigned short iVar; @@ -505,8 +507,8 @@ void CTurbSASolver::BC_HeatFlux_Wall(CGeometry *geometry, CSolver **solver_conta } -void CTurbSASolver::BC_Isothermal_Wall(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, - unsigned short val_marker) { +void CTurbSASolver::BC_Isothermal_Wall(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, + CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { unsigned long iPoint, iVertex; unsigned short iVar; @@ -532,7 +534,8 @@ void CTurbSASolver::BC_Isothermal_Wall(CGeometry *geometry, CSolver **solver_con } -void CTurbSASolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { +void CTurbSASolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, + CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { unsigned long iPoint, iVertex; unsigned short iVar, iDim; @@ -579,12 +582,12 @@ void CTurbSASolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_container /*--- Compute residuals and Jacobians ---*/ - conv_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); + auto residual = conv_numerics->ComputeResidual(config); /*--- Add residuals and Jacobians ---*/ - LinSysRes.AddBlock(iPoint, Residual); - Jacobian.AddBlock2Diag(iPoint, Jacobian_i); + LinSysRes.AddBlock(iPoint, residual); + Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); } } @@ -593,7 +596,8 @@ void CTurbSASolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_container } -void CTurbSASolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { +void CTurbSASolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, + CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { unsigned short iDim; unsigned long iVertex, iPoint; @@ -650,12 +654,12 @@ void CTurbSASolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, CN /*--- Compute the residual using an upwind scheme ---*/ - conv_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); - LinSysRes.AddBlock(iPoint, Residual); + auto residual = conv_numerics->ComputeResidual(config); + LinSysRes.AddBlock(iPoint, residual); /*--- Jacobian contribution for implicit integration ---*/ - Jacobian.AddBlock2Diag(iPoint, Jacobian_i); + Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); // /*--- Viscous contribution, commented out because serious convergence problems ---*/ // @@ -673,12 +677,12 @@ void CTurbSASolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, CN // // /*--- Compute residual, and Jacobians ---*/ // -// visc_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); +// auto residual = visc_numerics->ComputeResidual(config); // // /*--- Subtract residual, and update Jacobians ---*/ // -// LinSysRes.SubtractBlock(iPoint, Residual); -// Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); +// LinSysRes.SubtractBlock(iPoint, residual); +// Jacobian.SubtractBlock2Diag(iPoint, residual.jacobian_i); } } @@ -688,8 +692,9 @@ void CTurbSASolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, CN } -void CTurbSASolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CNumerics *visc_numerics, - CConfig *config, unsigned short val_marker) { +void CTurbSASolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, + CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { + unsigned long iPoint, iVertex; unsigned short iVar, iDim; su2double *V_outlet, *V_domain, *Normal; @@ -742,12 +747,12 @@ void CTurbSASolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, C /*--- Compute the residual using an upwind scheme ---*/ - conv_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); - LinSysRes.AddBlock(iPoint, Residual); + auto residual = conv_numerics->ComputeResidual(config); + LinSysRes.AddBlock(iPoint, residual); /*--- Jacobian contribution for implicit integration ---*/ - Jacobian.AddBlock2Diag(iPoint, Jacobian_i); + Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); // /*--- Viscous contribution, commented out because serious convergence problems ---*/ // @@ -765,12 +770,12 @@ void CTurbSASolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, C // // /*--- Compute residual, and Jacobians ---*/ // -// visc_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); +// auto residual = visc_numerics->ComputeResidual(config); // // /*--- Subtract residual, and update Jacobians ---*/ // -// LinSysRes.SubtractBlock(iPoint, Residual); -// Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); +// LinSysRes.SubtractBlock(iPoint, residual); +// Jacobian.SubtractBlock2Diag(iPoint, residual.jacobian_i); } } @@ -781,8 +786,8 @@ void CTurbSASolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, C } -void CTurbSASolver::BC_Engine_Inflow(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { - +void CTurbSASolver::BC_Engine_Inflow(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, + CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { unsigned long iPoint, iVertex; unsigned short iDim; su2double *V_inflow, *V_domain, *Normal; @@ -832,12 +837,12 @@ void CTurbSASolver::BC_Engine_Inflow(CGeometry *geometry, CSolver **solver_conta /*--- Compute the residual using an upwind scheme ---*/ - conv_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); - LinSysRes.AddBlock(iPoint, Residual); + auto residual = conv_numerics->ComputeResidual(config); + LinSysRes.AddBlock(iPoint, residual); /*--- Jacobian contribution for implicit integration ---*/ - Jacobian.AddBlock2Diag(iPoint, Jacobian_i); + Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); // /*--- Viscous contribution, commented out because serious convergence problems ---*/ // @@ -855,12 +860,12 @@ void CTurbSASolver::BC_Engine_Inflow(CGeometry *geometry, CSolver **solver_conta // // /*--- Compute residual, and Jacobians ---*/ // -// visc_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); +// auto residual = visc_numerics->ComputeResidual(config); // // /*--- Subtract residual, and update Jacobians ---*/ // -// LinSysRes.SubtractBlock(iPoint, Residual); -// Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); +// LinSysRes.SubtractBlock(iPoint, residual); +// Jacobian.SubtractBlock2Diag(iPoint, residual.jacobian_i); } @@ -872,7 +877,8 @@ void CTurbSASolver::BC_Engine_Inflow(CGeometry *geometry, CSolver **solver_conta } -void CTurbSASolver::BC_Engine_Exhaust(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { +void CTurbSASolver::BC_Engine_Exhaust(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, + CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { unsigned short iDim; unsigned long iVertex, iPoint; @@ -928,12 +934,12 @@ void CTurbSASolver::BC_Engine_Exhaust(CGeometry *geometry, CSolver **solver_cont /*--- Compute the residual using an upwind scheme ---*/ - conv_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); - LinSysRes.AddBlock(iPoint, Residual); + auto residual = conv_numerics->ComputeResidual(config); + LinSysRes.AddBlock(iPoint, residual); /*--- Jacobian contribution for implicit integration ---*/ - Jacobian.AddBlock2Diag(iPoint, Jacobian_i); + Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); // /*--- Viscous contribution, commented out because serious convergence problems ---*/ // @@ -951,12 +957,12 @@ void CTurbSASolver::BC_Engine_Exhaust(CGeometry *geometry, CSolver **solver_cont // // /*--- Compute residual, and Jacobians ---*/ // -// visc_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); +// auto residual = visc_numerics->ComputeResidual(config); // // /*--- Subtract residual, and update Jacobians ---*/ // -// LinSysRes.SubtractBlock(iPoint, Residual); -// Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); +// LinSysRes.SubtractBlock(iPoint, residual); +// Jacobian.SubtractBlock2Diag(iPoint, residual.jacobian_i); } } @@ -970,20 +976,17 @@ void CTurbSASolver::BC_Engine_Exhaust(CGeometry *geometry, CSolver **solver_cont void CTurbSASolver::BC_ActDisk_Inlet(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { - BC_ActDisk(geometry, solver_container, conv_numerics, visc_numerics, - config, val_marker, true); - + BC_ActDisk(geometry, solver_container, conv_numerics, visc_numerics, config, val_marker, true); } void CTurbSASolver::BC_ActDisk_Outlet(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { - BC_ActDisk(geometry, solver_container, conv_numerics, visc_numerics, - config, val_marker, false); - + BC_ActDisk(geometry, solver_container, conv_numerics, visc_numerics, config, val_marker, false); } -void CTurbSASolver::BC_ActDisk(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CNumerics *visc_numerics, +void CTurbSASolver::BC_ActDisk(CGeometry *geometry, CSolver **solver_container, + CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, unsigned short val_marker, bool val_inlet_surface) { unsigned long iPoint, iVertex, GlobalIndex_donor, GlobalIndex; @@ -1090,12 +1093,12 @@ void CTurbSASolver::BC_ActDisk(CGeometry *geometry, CSolver **solver_container, /*--- Compute the residual using an upwind scheme ---*/ - conv_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); - LinSysRes.AddBlock(iPoint, Residual); + auto residual = conv_numerics->ComputeResidual(config); + LinSysRes.AddBlock(iPoint, residual); /*--- Jacobian contribution for implicit integration ---*/ - Jacobian.AddBlock2Diag(iPoint, Jacobian_i); + Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); // /*--- Viscous contribution, commented out because serious convergence problems ---*/ // @@ -1115,12 +1118,12 @@ void CTurbSASolver::BC_ActDisk(CGeometry *geometry, CSolver **solver_container, // // /*--- Compute residual, and Jacobians ---*/ // -// visc_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); +// auto residual = visc_numerics->ComputeResidual(config); // // /*--- Subtract residual, and update Jacobians ---*/ // -// LinSysRes.SubtractBlock(iPoint, Residual); -// Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); +// LinSysRes.SubtractBlock(iPoint, residual); +// Jacobian.SubtractBlock2Diag(iPoint, residual.jacobian_i); } } @@ -1133,7 +1136,8 @@ void CTurbSASolver::BC_ActDisk(CGeometry *geometry, CSolver **solver_container, } -void CTurbSASolver::BC_Inlet_MixingPlane(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { +void CTurbSASolver::BC_Inlet_MixingPlane(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, + CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { unsigned short iDim, iSpan; unsigned long oldVertex, iPoint, Point_Normal, iVertex; @@ -1200,12 +1204,12 @@ void CTurbSASolver::BC_Inlet_MixingPlane(CGeometry *geometry, CSolver **solver_c /*--- Compute the residual using an upwind scheme ---*/ - conv_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); - LinSysRes.AddBlock(iPoint, Residual); + auto conv_residual = conv_numerics->ComputeResidual(config); /*--- Jacobian contribution for implicit integration ---*/ - Jacobian.AddBlock2Diag(iPoint, Jacobian_i); + LinSysRes.AddBlock(iPoint, conv_residual); + Jacobian.AddBlock2Diag(iPoint, conv_residual.jacobian_i); /*--- Viscous contribution ---*/ @@ -1223,12 +1227,12 @@ void CTurbSASolver::BC_Inlet_MixingPlane(CGeometry *geometry, CSolver **solver_c /*--- Compute residual, and Jacobians ---*/ - visc_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); + auto visc_residual = visc_numerics->ComputeResidual(config); /*--- Subtract residual, and update Jacobians ---*/ - LinSysRes.SubtractBlock(iPoint, Residual); - Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); + LinSysRes.SubtractBlock(iPoint, visc_residual); + Jacobian.SubtractBlock2Diag(iPoint, visc_residual.jacobian_i); } } @@ -1238,8 +1242,8 @@ void CTurbSASolver::BC_Inlet_MixingPlane(CGeometry *geometry, CSolver **solver_c } -void CTurbSASolver::BC_Inlet_Turbo(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { - +void CTurbSASolver::BC_Inlet_Turbo(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, + CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { unsigned short iDim, iSpan; unsigned long oldVertex, iPoint, Point_Normal, iVertex; su2double *V_inlet, *V_domain, *Normal; @@ -1316,12 +1320,12 @@ void CTurbSASolver::BC_Inlet_Turbo(CGeometry *geometry, CSolver **solver_contain /*--- Compute the residual using an upwind scheme ---*/ - conv_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); - LinSysRes.AddBlock(iPoint, Residual); + auto conv_residual = conv_numerics->ComputeResidual(config); /*--- Jacobian contribution for implicit integration ---*/ - Jacobian.AddBlock2Diag(iPoint, Jacobian_i); + LinSysRes.AddBlock(iPoint, conv_residual); + Jacobian.AddBlock2Diag(iPoint, conv_residual.jacobian_i); /*--- Viscous contribution ---*/ @@ -1339,12 +1343,12 @@ void CTurbSASolver::BC_Inlet_Turbo(CGeometry *geometry, CSolver **solver_contain /*--- Compute residual, and Jacobians ---*/ - visc_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); + auto visc_residual = visc_numerics->ComputeResidual(config); /*--- Subtract residual, and update Jacobians ---*/ - LinSysRes.SubtractBlock(iPoint, Residual); - Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); + LinSysRes.SubtractBlock(iPoint, visc_residual); + Jacobian.SubtractBlock2Diag(iPoint, visc_residual.jacobian_i); } } @@ -1517,17 +1521,16 @@ void CTurbSASolver::BC_Interface_Boundary(CGeometry *geometry, CSolver **solver_ // } -void CTurbSASolver::BC_Fluid_Interface(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, - CNumerics *visc_numerics, CConfig *config){ +void CTurbSASolver::BC_Fluid_Interface(CGeometry *geometry, CSolver **solver_container, + CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config){ unsigned long iVertex, jVertex, iPoint, Point_Normal = 0; - unsigned short iDim, iVar, iMarker; + unsigned short iDim, iVar, jVar, iMarker; unsigned short nPrimVar = solver_container[FLOW_SOL]->GetnPrimVar(); - su2double *Normal = new su2double[nDim]; + su2double Normal[MAXNDIM] = {0.0}; su2double *PrimVar_i = new su2double[nPrimVar]; su2double *PrimVar_j = new su2double[nPrimVar]; - su2double *tmp_residual = new su2double[nVar]; unsigned long nDonorVertex; su2double weight; @@ -1547,12 +1550,15 @@ void CTurbSASolver::BC_Fluid_Interface(CGeometry *geometry, CSolver **solver_con /*--- Initialize Residual, this will serve to accumulate the average ---*/ - for (iVar = 0; iVar < nVar; iVar++) + for (iVar = 0; iVar < nVar; iVar++) { Residual[iVar] = 0.0; + for (jVar = 0; jVar < nVar; jVar++) + Jacobian_i[iVar][jVar] = 0.0; + } /*--- Loop over the nDonorVertexes and compute the averaged flux ---*/ - for (jVertex = 0; jVertex < nDonorVertex; jVertex++){ + for (jVertex = 0; jVertex < nDonorVertex; jVertex++) { geometry->vertex[iMarker][iVertex]->GetNormal(Normal); for (iDim = 0; iDim < nDim; iDim++) Normal[iDim] = -Normal[iDim]; @@ -1584,13 +1590,15 @@ void CTurbSASolver::BC_Fluid_Interface(CGeometry *geometry, CSolver **solver_con /*--- Compute the convective residual using an upwind scheme ---*/ - conv_numerics->ComputeResidual(tmp_residual, Jacobian_i, Jacobian_j, config); + auto residual = conv_numerics->ComputeResidual(config); /*--- Accumulate the residuals to compute the average ---*/ - for (iVar = 0; iVar < nVar; iVar++) - Residual[iVar] += weight*tmp_residual[iVar]; - + for (iVar = 0; iVar < nVar; iVar++) { + Residual[iVar] += weight*residual.residual[iVar]; + for (jVar = 0; jVar < nVar; jVar++) + Jacobian_i[iVar][jVar] += weight*residual.jacobian_i[iVar][jVar]; + } } /*--- Add Residuals and Jacobians ---*/ @@ -1616,13 +1624,13 @@ void CTurbSASolver::BC_Fluid_Interface(CGeometry *geometry, CSolver **solver_con /*--- Compute and update residual ---*/ - visc_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); + auto residual = visc_numerics->ComputeResidual(config); - LinSysRes.SubtractBlock(iPoint, Residual); + LinSysRes.SubtractBlock(iPoint, residual); /*--- Jacobian contribution for implicit integration ---*/ - Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); + Jacobian.SubtractBlock2Diag(iPoint, residual.jacobian_i); } } @@ -1631,8 +1639,6 @@ void CTurbSASolver::BC_Fluid_Interface(CGeometry *geometry, CSolver **solver_con /*--- Free locally allocated memory ---*/ - delete [] tmp_residual; - delete [] Normal; delete [] PrimVar_i; delete [] PrimVar_j; @@ -1802,7 +1808,7 @@ void CTurbSASolver::BC_NearField_Boundary(CGeometry *geometry, CSolver **solver_ } void CTurbSASolver::SetNuTilde_WF(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, - CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { + CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { /*--- Local variables ---*/ diff --git a/SU2_CFD/src/solvers/CTurbSSTSolver.cpp b/SU2_CFD/src/solvers/CTurbSSTSolver.cpp index 1bb05905a214..5c63d317963b 100644 --- a/SU2_CFD/src/solvers/CTurbSSTSolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSSTSolver.cpp @@ -267,7 +267,8 @@ CTurbSSTSolver::~CTurbSSTSolver(void) { } -void CTurbSSTSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh, unsigned short iRKStep, unsigned short RunTime_EqSystem, bool Output) { +void CTurbSSTSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container, CConfig *config, + unsigned short iMesh, unsigned short iRKStep, unsigned short RunTime_EqSystem, bool Output) { unsigned long iPoint; @@ -303,7 +304,9 @@ void CTurbSSTSolver::Preprocessing(CGeometry *geometry, CSolver **solver_contain } -void CTurbSSTSolver::Postprocessing(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh) { +void CTurbSSTSolver::Postprocessing(CGeometry *geometry, CSolver **solver_container, + CConfig *config, unsigned short iMesh) { + su2double rho = 0.0, mu = 0.0, dist, omega, kine, F2, muT, zeta; su2double a1 = constants[7]; unsigned long iPoint; @@ -410,10 +413,10 @@ void CTurbSSTSolver::Source_Residual(CGeometry *geometry, CSolver **solver_conta void CTurbSSTSolver::Source_Template(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, CConfig *config, unsigned short iMesh) { - } -void CTurbSSTSolver::BC_HeatFlux_Wall(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { +void CTurbSSTSolver::BC_HeatFlux_Wall(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, + CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { unsigned long iPoint, jPoint, iVertex, total_index; unsigned short iDim, iVar; @@ -429,8 +432,8 @@ void CTurbSSTSolver::BC_HeatFlux_Wall(CGeometry *geometry, CSolver **solver_cont jPoint = geometry->vertex[val_marker][iVertex]->GetNormal_Neighbor(); distance = 0.0; for (iDim = 0; iDim < nDim; iDim++) { - distance += (geometry->node[iPoint]->GetCoord(iDim) - geometry->node[jPoint]->GetCoord(iDim))* - (geometry->node[iPoint]->GetCoord(iDim) - geometry->node[jPoint]->GetCoord(iDim)); + distance += pow(geometry->node[iPoint]->GetCoord(iDim)- + geometry->node[jPoint]->GetCoord(iDim), 2); } distance = sqrt(distance); @@ -460,8 +463,8 @@ void CTurbSSTSolver::BC_HeatFlux_Wall(CGeometry *geometry, CSolver **solver_cont } -void CTurbSSTSolver::BC_Isothermal_Wall(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, - unsigned short val_marker) { +void CTurbSSTSolver::BC_Isothermal_Wall(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, + CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { unsigned long iPoint, jPoint, iVertex, total_index; unsigned short iDim, iVar; @@ -508,7 +511,8 @@ void CTurbSSTSolver::BC_Isothermal_Wall(CGeometry *geometry, CSolver **solver_co } -void CTurbSSTSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { +void CTurbSSTSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, + CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { unsigned long iPoint, iVertex; su2double *Normal, *V_infty, *V_domain; @@ -558,12 +562,12 @@ void CTurbSSTSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_containe /*--- Compute residuals and Jacobians ---*/ - conv_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); + auto residual = conv_numerics->ComputeResidual(config); /*--- Add residuals and Jacobians ---*/ - LinSysRes.AddBlock(iPoint, Residual); - Jacobian.AddBlock2Diag(iPoint, Jacobian_i); + LinSysRes.AddBlock(iPoint, residual); + Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); } } @@ -572,8 +576,8 @@ void CTurbSSTSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_containe } -void CTurbSSTSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, - unsigned short val_marker) { +void CTurbSSTSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, + CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { unsigned short iVar, iDim; unsigned long iVertex, iPoint; @@ -633,12 +637,12 @@ void CTurbSSTSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, C /*--- Compute the residual using an upwind scheme ---*/ - conv_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); - LinSysRes.AddBlock(iPoint, Residual); + auto residual = conv_numerics->ComputeResidual(config); + LinSysRes.AddBlock(iPoint, residual); /*--- Jacobian contribution for implicit integration ---*/ - Jacobian.AddBlock2Diag(iPoint, Jacobian_i); + Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); // /*--- Viscous contribution, commented out because serious convergence problems ---*/ // @@ -660,12 +664,12 @@ void CTurbSSTSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, C // // /*--- Compute residual, and Jacobians ---*/ // - // visc_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); + // auto residual = visc_numerics->ComputeResidual(config); // // /*--- Subtract residual, and update Jacobians ---*/ // - // LinSysRes.SubtractBlock(iPoint, Residual); - // Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); + // LinSysRes.SubtractBlock(iPoint, residual); + // Jacobian.SubtractBlock2Diag(iPoint, residual.jacobian_i); } @@ -677,7 +681,8 @@ void CTurbSSTSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, C } -void CTurbSSTSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { +void CTurbSSTSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, + CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { unsigned long iPoint, iVertex; unsigned short iVar, iDim; @@ -731,12 +736,12 @@ void CTurbSSTSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, /*--- Compute the residual using an upwind scheme ---*/ - conv_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); - LinSysRes.AddBlock(iPoint, Residual); + auto residual = conv_numerics->ComputeResidual(config); + LinSysRes.AddBlock(iPoint, residual); /*--- Jacobian contribution for implicit integration ---*/ - Jacobian.AddBlock2Diag(iPoint, Jacobian_i); + Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); // /*--- Viscous contribution, commented out because serious convergence problems ---*/ // @@ -758,12 +763,12 @@ void CTurbSSTSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, // // /*--- Compute residual, and Jacobians ---*/ // -// visc_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); +// auto residual = visc_numerics->ComputeResidual(config); // // /*--- Subtract residual, and update Jacobians ---*/ // -// LinSysRes.SubtractBlock(iPoint, Residual); -// Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); +// LinSysRes.SubtractBlock(iPoint, residual); +// Jacobian.SubtractBlock2Diag(iPoint, residual.jacobian_i); } } @@ -774,8 +779,8 @@ void CTurbSSTSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, } -void CTurbSSTSolver::BC_Inlet_MixingPlane(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, - unsigned short val_marker) { +void CTurbSSTSolver::BC_Inlet_MixingPlane(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, + CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { unsigned short iVar, iSpan, iDim; unsigned long oldVertex, iPoint, Point_Normal, iVertex; @@ -840,11 +845,11 @@ void CTurbSSTSolver::BC_Inlet_MixingPlane(CGeometry *geometry, CSolver **solver_ geometry->node[iPoint]->GetGridVel()); /*--- Compute the residual using an upwind scheme ---*/ - conv_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); - LinSysRes.AddBlock(iPoint, Residual); + auto conv_residual = conv_numerics->ComputeResidual(config); /*--- Jacobian contribution for implicit integration ---*/ - Jacobian.AddBlock2Diag(iPoint, Jacobian_i); + LinSysRes.AddBlock(iPoint, conv_residual); + Jacobian.AddBlock2Diag(iPoint, conv_residual.jacobian_i); /*--- Viscous contribution ---*/ visc_numerics->SetCoord(geometry->node[iPoint]->GetCoord(), geometry->node[Point_Normal]->GetCoord()); @@ -861,11 +866,11 @@ void CTurbSSTSolver::BC_Inlet_MixingPlane(CGeometry *geometry, CSolver **solver_ visc_numerics->SetF1blending(nodes->GetF1blending(iPoint), nodes->GetF1blending(iPoint)); /*--- Compute residual, and Jacobians ---*/ - visc_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); + auto visc_residual = visc_numerics->ComputeResidual(config); /*--- Subtract residual, and update Jacobians ---*/ - LinSysRes.SubtractBlock(iPoint, Residual); - Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); + LinSysRes.SubtractBlock(iPoint, visc_residual); + Jacobian.SubtractBlock2Diag(iPoint, visc_residual.jacobian_i); } } @@ -875,8 +880,8 @@ void CTurbSSTSolver::BC_Inlet_MixingPlane(CGeometry *geometry, CSolver **solver_ } -void CTurbSSTSolver::BC_Inlet_Turbo(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, - unsigned short val_marker) { +void CTurbSSTSolver::BC_Inlet_Turbo(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, + CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { unsigned short iVar, iSpan, iDim; unsigned long oldVertex, iPoint, Point_Normal, iVertex; @@ -962,14 +967,14 @@ void CTurbSSTSolver::BC_Inlet_Turbo(CGeometry *geometry, CSolver **solver_contai if (dynamic_grid) conv_numerics->SetGridVel(geometry->node[iPoint]->GetGridVel(), - geometry->node[iPoint]->GetGridVel()); + geometry->node[iPoint]->GetGridVel()); /*--- Compute the residual using an upwind scheme ---*/ - conv_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); - LinSysRes.AddBlock(iPoint, Residual); + auto conv_residual = conv_numerics->ComputeResidual(config); /*--- Jacobian contribution for implicit integration ---*/ - Jacobian.AddBlock2Diag(iPoint, Jacobian_i); + LinSysRes.AddBlock(iPoint, conv_residual); + Jacobian.AddBlock2Diag(iPoint, conv_residual.jacobian_i); /*--- Viscous contribution ---*/ visc_numerics->SetCoord(geometry->node[iPoint]->GetCoord(), geometry->node[Point_Normal]->GetCoord()); @@ -986,11 +991,11 @@ void CTurbSSTSolver::BC_Inlet_Turbo(CGeometry *geometry, CSolver **solver_contai visc_numerics->SetF1blending(nodes->GetF1blending(iPoint), nodes->GetF1blending(iPoint)); /*--- Compute residual, and Jacobians ---*/ - visc_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); + auto visc_residual = visc_numerics->ComputeResidual(config); /*--- Subtract residual, and update Jacobians ---*/ - LinSysRes.SubtractBlock(iPoint, Residual); - Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); + LinSysRes.SubtractBlock(iPoint, visc_residual); + Jacobian.SubtractBlock2Diag(iPoint, visc_residual.jacobian_i); } } @@ -1001,18 +1006,16 @@ void CTurbSSTSolver::BC_Inlet_Turbo(CGeometry *geometry, CSolver **solver_contai } - void CTurbSSTSolver::BC_Fluid_Interface(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, - CNumerics *visc_numerics, CConfig *config){ + CNumerics *visc_numerics, CConfig *config){ unsigned long iVertex, jVertex, iPoint, Point_Normal = 0; - unsigned short iDim, iVar, iMarker; + unsigned short iDim, iVar, jVar, iMarker; unsigned short nPrimVar = solver_container[FLOW_SOL]->GetnPrimVar(); su2double *Normal = new su2double[nDim]; su2double *PrimVar_i = new su2double[nPrimVar]; su2double *PrimVar_j = new su2double[nPrimVar]; - su2double *tmp_residual = new su2double[nVar]; unsigned long nDonorVertex; su2double weight; @@ -1032,8 +1035,11 @@ void CTurbSSTSolver::BC_Fluid_Interface(CGeometry *geometry, CSolver **solver_co /*--- Initialize Residual, this will serve to accumulate the average ---*/ - for (iVar = 0; iVar < nVar; iVar++) + for (iVar = 0; iVar < nVar; iVar++) { Residual[iVar] = 0.0; + for (jVar = 0; jVar < nVar; jVar++) + Jacobian_i[iVar][jVar] = 0.0; + } /*--- Loop over the nDonorVertexes and compute the averaged flux ---*/ @@ -1071,12 +1077,15 @@ void CTurbSSTSolver::BC_Fluid_Interface(CGeometry *geometry, CSolver **solver_co if (dynamic_grid) conv_numerics->SetGridVel(geometry->node[iPoint]->GetGridVel(), geometry->node[iPoint]->GetGridVel()); - conv_numerics->ComputeResidual(tmp_residual, Jacobian_i, Jacobian_j, config); + auto residual = conv_numerics->ComputeResidual(config); /*--- Accumulate the residuals to compute the average ---*/ - for (iVar = 0; iVar < nVar; iVar++) - Residual[iVar] += weight*tmp_residual[iVar]; + for (iVar = 0; iVar < nVar; iVar++) { + Residual[iVar] += weight*residual.residual[iVar]; + for (jVar = 0; jVar < nVar; jVar++) + Jacobian_i[iVar][jVar] += weight*residual.jacobian_i[iVar][jVar]; + } } /*--- Add Residuals and Jacobians ---*/ @@ -1102,13 +1111,13 @@ void CTurbSSTSolver::BC_Fluid_Interface(CGeometry *geometry, CSolver **solver_co /*--- Compute and update residual ---*/ - visc_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); + auto residual = visc_numerics->ComputeResidual(config); - LinSysRes.SubtractBlock(iPoint, Residual); + LinSysRes.SubtractBlock(iPoint, residual); /*--- Jacobian contribution for implicit integration ---*/ - Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); + Jacobian.SubtractBlock2Diag(iPoint, residual.jacobian_i); } } @@ -1117,7 +1126,6 @@ void CTurbSSTSolver::BC_Fluid_Interface(CGeometry *geometry, CSolver **solver_co /*--- Free locally allocated memory ---*/ - delete [] tmp_residual; delete [] Normal; delete [] PrimVar_i; delete [] PrimVar_j; From 1061736438d881bb5ecf1bfcf91fa0dc97b35083 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Sat, 1 Feb 2020 19:32:34 +0000 Subject: [PATCH 077/118] parallel implicit euler of CTurbSolver --- SU2_CFD/src/solvers/CEulerSolver.cpp | 4 +- SU2_CFD/src/solvers/CTurbSolver.cpp | 129 +++++++++++++++++---------- 2 files changed, 82 insertions(+), 51 deletions(-) diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 57c25541a6fb..47cd4e1ea8fb 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -4720,8 +4720,8 @@ void CEulerSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver su2double Res = fabs(LinSysRes[total_index]); resRMS[iVar] += Res*Res; - if (fabs(Res) > resMax[iVar]) { - resMax[iVar] = fabs(Res); + if (Res > resMax[iVar]) { + resMax[iVar] = Res; idxMax[iVar] = iPoint; coordMax[iVar] = geometry->node[iPoint]->GetCoord(); } diff --git a/SU2_CFD/src/solvers/CTurbSolver.cpp b/SU2_CFD/src/solvers/CTurbSolver.cpp index 38a5391da8bf..73f712f6f104 100644 --- a/SU2_CFD/src/solvers/CTurbSolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSolver.cpp @@ -404,64 +404,92 @@ void CTurbSolver::BC_Periodic(CGeometry *geometry, CSolver **solver_container, void CTurbSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver_container, CConfig *config) { - unsigned short iVar; - unsigned long iPoint, total_index; - su2double Delta, Vol, density_old = 0.0, density = 0.0; + const bool adjoint = config->GetContinuous_Adjoint() || (config->GetDiscrete_Adjoint() && config->GetFrozen_Visc_Disc()); + const bool compressible = (config->GetKind_Regime() == COMPRESSIBLE); - bool adjoint = config->GetContinuous_Adjoint() || (config->GetDiscrete_Adjoint() && config->GetFrozen_Visc_Disc()); - bool compressible = (config->GetKind_Regime() == COMPRESSIBLE); - bool incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); + CVariable* flowNodes = solver_container[FLOW_SOL]->GetNodes(); - /*--- Set maximum residual to zero ---*/ + /*--- Start OpenMP parallel section. ---*/ - for (iVar = 0; iVar < nVar; iVar++) { + SU2_OMP_PARALLEL + { + /*--- Set shared residual variables to 0 and declare + * local ones for current thread to work on. ---*/ + + SU2_OMP_MASTER + for (unsigned short iVar = 0; iVar < nVar; iVar++) { SetRes_RMS(iVar, 0.0); SetRes_Max(iVar, 0.0, 0); } + SU2_OMP_BARRIER + + su2double resMax[MAXNVAR] = {0.0}, resRMS[MAXNVAR] = {0.0}; + const su2double* coordMax[MAXNVAR] = {nullptr}; + unsigned long idxMax[MAXNVAR] = {0}; /*--- Build implicit system ---*/ - for (iPoint = 0; iPoint < nPointDomain; iPoint++) { + SU2_OMP(for schedule(static,omp_chunk_size) nowait) + for (unsigned long iPoint = 0; iPoint < nPointDomain; iPoint++) { /*--- Read the volume ---*/ - Vol = (geometry->node[iPoint]->GetVolume() + - geometry->node[iPoint]->GetPeriodicVolume()); + su2double Vol = (geometry->node[iPoint]->GetVolume() + geometry->node[iPoint]->GetPeriodicVolume()); /*--- Modify matrix diagonal to assure diagonal dominance ---*/ - Delta = Vol / ((nodes->GetLocalCFL(iPoint)/solver_container[FLOW_SOL]->GetNodes()->GetLocalCFL(iPoint))*solver_container[FLOW_SOL]->GetNodes()->GetDelta_Time(iPoint)); + su2double Delta = Vol / ((nodes->GetLocalCFL(iPoint)/flowNodes->GetLocalCFL(iPoint))*flowNodes->GetDelta_Time(iPoint)); Jacobian.AddVal2Diag(iPoint, Delta); /*--- Right hand side of the system (-Residual) and initial guess (x = 0) ---*/ - for (iVar = 0; iVar < nVar; iVar++) { - total_index = iPoint*nVar+iVar; - LinSysRes[total_index] = - LinSysRes[total_index]; + for (unsigned short iVar = 0; iVar < nVar; iVar++) { + unsigned long total_index = iPoint*nVar + iVar; + LinSysRes[total_index] = -LinSysRes[total_index]; LinSysSol[total_index] = 0.0; - AddRes_RMS(iVar, LinSysRes[total_index]*LinSysRes[total_index]); - AddRes_Max(iVar, fabs(LinSysRes[total_index]), geometry->node[iPoint]->GetGlobalIndex(), geometry->node[iPoint]->GetCoord()); + + su2double Res = fabs(LinSysRes[total_index]); + resRMS[iVar] += Res*Res; + if (Res > resMax[iVar]) { + resMax[iVar] = Res; + idxMax[iVar] = iPoint; + coordMax[iVar] = geometry->node[iPoint]->GetCoord(); + } } } + SU2_OMP_CRITICAL + for (unsigned short iVar = 0; iVar < nVar; iVar++) { + AddRes_RMS(iVar, resRMS[iVar]); + AddRes_Max(iVar, resMax[iVar], geometry->node[idxMax[iVar]]->GetGlobalIndex(), coordMax[iVar]); + } /*--- Initialize residual and solution at the ghost points ---*/ - for (iPoint = nPointDomain; iPoint < nPoint; iPoint++) { - for (iVar = 0; iVar < nVar; iVar++) { - total_index = iPoint*nVar + iVar; - LinSysRes[total_index] = 0.0; - LinSysSol[total_index] = 0.0; - } + SU2_OMP(sections nowait) + { + SU2_OMP(section) + for (unsigned long iPoint = nPointDomain; iPoint < nPoint; iPoint++) + LinSysRes.SetBlock_Zero(iPoint); + + SU2_OMP(section) + for (unsigned long iPoint = nPointDomain; iPoint < nPoint; iPoint++) + LinSysSol.SetBlock_Zero(iPoint); } + } // end SU2_OMP_PARALLEL + + /// TODO: We should be able to call the linear solver inside the parallel region. + /*--- Solve or smooth the linear system ---*/ unsigned long IterLinSol = System.Solve(Jacobian, LinSysRes, LinSysSol, geometry, config); SetIterLinSolver(IterLinSol); + SetResLinSolver(System.GetResidual()); - /*--- Store the value of the residual. ---*/ + /*--- Go back to parallel. ---*/ - SetResLinSolver(System.GetResidual()); + SU2_OMP_PARALLEL + { ComputeUnderRelaxationFactor(solver_container, config); @@ -475,50 +503,52 @@ 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++) { + SU2_OMP_FOR_STAT(omp_chunk_size) + for (unsigned long iPoint = 0; iPoint < nPointDomain; iPoint++) { nodes->AddSolution(iPoint, 0, nodes->GetUnderRelaxation(iPoint)*LinSysSol[iPoint]); } - break; case SST: case SST_SUST: - for (iPoint = 0; iPoint < nPointDomain; iPoint++) { + SU2_OMP_FOR_STAT(omp_chunk_size) + for (unsigned long iPoint = 0; iPoint < nPointDomain; iPoint++) { - if (compressible) { - 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]->GetNodes()->GetDensity(iPoint); - density = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); - } + su2double density = flowNodes->GetDensity(iPoint); + su2double density_old = density; - for (iVar = 0; iVar < nVar; iVar++) { - nodes->AddConservativeSolution(iPoint, iVar, nodes->GetUnderRelaxation(iPoint)*LinSysSol[iPoint*nVar+iVar], density, density_old, lowerlimit[iVar], upperlimit[iVar]); - } + if (compressible) + density_old = flowNodes->GetSolution_Old(iPoint,0); + for (unsigned short iVar = 0; iVar < nVar; iVar++) { + nodes->AddConservativeSolution(iPoint, iVar, + nodes->GetUnderRelaxation(iPoint)*LinSysSol[iPoint*nVar+iVar], + density, density_old, lowerlimit[iVar], upperlimit[iVar]); + } } - break; } } - for (unsigned short iPeriodic = 1; iPeriodic <= config->GetnMarker_Periodic()/2; iPeriodic++) { - InitiatePeriodicComms(geometry, config, iPeriodic, PERIODIC_IMPLICIT); - CompletePeriodicComms(geometry, config, iPeriodic, PERIODIC_IMPLICIT); - } + SU2_OMP_MASTER + { + for (unsigned short iPeriodic = 1; iPeriodic <= config->GetnMarker_Periodic()/2; iPeriodic++) { + InitiatePeriodicComms(geometry, config, iPeriodic, PERIODIC_IMPLICIT); + CompletePeriodicComms(geometry, config, iPeriodic, PERIODIC_IMPLICIT); + } - /*--- MPI solution ---*/ + /*--- MPI solution ---*/ - InitiateComms(geometry, config, SOLUTION_EDDY); - CompleteComms(geometry, config, SOLUTION_EDDY); + InitiateComms(geometry, config, SOLUTION_EDDY); + CompleteComms(geometry, config, SOLUTION_EDDY); - /*--- Compute the root mean square residual ---*/ + /*--- Compute the root mean square residual ---*/ - SetResidual_RMS(geometry, config); + SetResidual_RMS(geometry, config); + } + } // end SU2_OMP_PARALLEL } void CTurbSolver::ComputeUnderRelaxationFactor(CSolver **solver_container, CConfig *config) { @@ -539,6 +569,7 @@ void CTurbSolver::ComputeUnderRelaxationFactor(CSolver **solver_container, CConf const su2double allowableDecrease = -0.99; const su2double allowableIncrease = 0.99; + SU2_OMP_FOR_STAT(omp_chunk_size) for (unsigned long iPoint = 0; iPoint < nPointDomain; iPoint++) { localUnderRelaxation = 1.0; From 7c6a91f27c2500edbaae832bebf3807e89cd6bc0 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Sat, 1 Feb 2020 21:28:15 +0000 Subject: [PATCH 078/118] parallel pre and postprocessing SA and SST --- SU2_CFD/src/solvers/CTurbSASolver.cpp | 45 ++++++++++----------- SU2_CFD/src/solvers/CTurbSSTSolver.cpp | 54 ++++++++++++-------------- 2 files changed, 46 insertions(+), 53 deletions(-) diff --git a/SU2_CFD/src/solvers/CTurbSASolver.cpp b/SU2_CFD/src/solvers/CTurbSASolver.cpp index f28b10915683..2eea771a0488 100644 --- a/SU2_CFD/src/solvers/CTurbSASolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSASolver.cpp @@ -25,9 +25,10 @@ * License along with SU2. If not, see . */ - #include "../../include/solvers/CTurbSASolver.hpp" #include "../../include/variables/CTurbSAVariable.hpp" +#include "../../../Common/include/omp_structure.hpp" + CTurbSASolver::CTurbSASolver(void) : CTurbSolver() { } @@ -269,6 +270,8 @@ CTurbSASolver::~CTurbSASolver(void) { void CTurbSASolver::Preprocessing(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh, unsigned short iRKStep, unsigned short RunTime_EqSystem, bool Output) { + /// TODO: Try to start a parallel section here encompassing all "heavy" methods. + unsigned long iPoint; bool limiter_turb = (config->GetKind_SlopeLimit_Turb() != NO_LIMITER) && (config->GetInnerIter() <= config->GetLimiterIter()); @@ -277,17 +280,12 @@ void CTurbSASolver::Preprocessing(CGeometry *geometry, CSolver **solver_containe su2double* Vorticity = NULL; su2double Laminar_Viscosity = 0; - for (iPoint = 0; iPoint < nPoint; iPoint ++) { - - /*--- Initialize the residual vector ---*/ - - LinSysRes.SetBlock_Zero(iPoint); - - } - - /*--- Initialize the Jacobian matrices ---*/ - + SU2_OMP_PARALLEL + { + /*--- Clear residual and system matrix. ---*/ + LinSysRes.SetValZero(); Jacobian.SetValZero(); + } /*--- Upwind second order reconstruction and gradients ---*/ @@ -326,27 +324,26 @@ void CTurbSASolver::Preprocessing(CGeometry *geometry, CSolver **solver_containe void CTurbSASolver::Postprocessing(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh) { - su2double rho = 0.0, mu = 0.0, nu, *nu_hat, muT, Ji, Ji_3, fv1; - su2double cv1_3 = 7.1*7.1*7.1; - unsigned long iPoint; + const su2double cv1_3 = 7.1*7.1*7.1; - bool neg_spalart_allmaras = (config->GetKind_Turb_Model() == SA_NEG); + const bool neg_spalart_allmaras = (config->GetKind_Turb_Model() == SA_NEG); /*--- Compute eddy viscosity ---*/ - for (iPoint = 0; iPoint < nPoint; iPoint ++) { + SU2_OMP_PARALLEL_(for schedule(static,omp_chunk_size)) + for (unsigned long iPoint = 0; iPoint < nPoint; iPoint ++) { - rho = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); - mu = solver_container[FLOW_SOL]->GetNodes()->GetLaminarViscosity(iPoint); + su2double rho = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); + su2double mu = solver_container[FLOW_SOL]->GetNodes()->GetLaminarViscosity(iPoint); - nu = mu/rho; - nu_hat = nodes->GetSolution(iPoint); + su2double nu = mu/rho; + su2double nu_hat = nodes->GetSolution(iPoint,0); - Ji = nu_hat[0]/nu; - Ji_3 = Ji*Ji*Ji; - fv1 = Ji_3/(Ji_3+cv1_3); + su2double Ji = nu_hat/nu; + su2double Ji_3 = Ji*Ji*Ji; + su2double fv1 = Ji_3/(Ji_3+cv1_3); - muT = rho*fv1*nu_hat[0]; + su2double muT = rho*fv1*nu_hat; if (neg_spalart_allmaras && (muT < 0.0)) muT = 0.0; diff --git a/SU2_CFD/src/solvers/CTurbSSTSolver.cpp b/SU2_CFD/src/solvers/CTurbSSTSolver.cpp index 5c63d317963b..442caa0873c3 100644 --- a/SU2_CFD/src/solvers/CTurbSSTSolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSSTSolver.cpp @@ -25,9 +25,10 @@ * License along with SU2. If not, see . */ - #include "../../include/solvers/CTurbSSTSolver.hpp" #include "../../include/variables/CTurbSSTVariable.hpp" +#include "../../../Common/include/omp_structure.hpp" + CTurbSSTSolver::CTurbSSTSolver(void) : CTurbSolver() { } @@ -270,22 +271,17 @@ CTurbSSTSolver::~CTurbSSTSolver(void) { void CTurbSSTSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh, unsigned short iRKStep, unsigned short RunTime_EqSystem, bool Output) { - unsigned long iPoint; - - bool limiter_turb = (config->GetKind_SlopeLimit_Turb() != NO_LIMITER) && (config->GetInnerIter() <= config->GetLimiterIter()); - - - for (iPoint = 0; iPoint < nPoint; iPoint ++) { - - /*--- Initialize the residual vector ---*/ + /// TODO: Try to start a parallel section here encompassing all "heavy" methods. - LinSysRes.SetBlock_Zero(iPoint); - - } - - /*--- Initialize the Jacobian matrices ---*/ + const bool limiter_turb = (config->GetKind_SlopeLimit_Turb() != NO_LIMITER) && + (config->GetInnerIter() <= config->GetLimiterIter()); + SU2_OMP_PARALLEL + { + /*--- Clear residual and system matrix. ---*/ + LinSysRes.SetValZero(); Jacobian.SetValZero(); + } /*--- Upwind second order reconstruction and gradients ---*/ @@ -307,11 +303,9 @@ 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, F2, muT, zeta; - su2double a1 = constants[7]; - unsigned long iPoint; + const su2double a1 = constants[7]; - /*--- Compute mean flow and turbulence gradients ---*/ + /*--- Compute turbulence gradients. ---*/ if (config->GetKind_Gradient_Method() == GREEN_GAUSS) { SetSolution_Gradient_GG(geometry, config); @@ -320,30 +314,32 @@ void CTurbSSTSolver::Postprocessing(CGeometry *geometry, CSolver **solver_contai SetSolution_Gradient_LS(geometry, config); } - for (iPoint = 0; iPoint < nPoint; iPoint ++) { + SU2_OMP_PARALLEL_(for schedule(static,omp_chunk_size)) + for (unsigned long iPoint = 0; iPoint < nPoint; iPoint ++) { /*--- Compute blending functions and cross diffusion ---*/ - rho = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); - mu = solver_container[FLOW_SOL]->GetNodes()->GetLaminarViscosity(iPoint); + su2double rho = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); + su2double mu = solver_container[FLOW_SOL]->GetNodes()->GetLaminarViscosity(iPoint); - dist = geometry->node[iPoint]->GetWall_Distance(); + su2double dist = geometry->node[iPoint]->GetWall_Distance(); - su2double *Vorticity = solver_container[FLOW_SOL]->GetNodes()->GetVorticity(iPoint); + const su2double *Vorticity = solver_container[FLOW_SOL]->GetNodes()->GetVorticity(iPoint); su2double VorticityMag = sqrt(Vorticity[0]*Vorticity[0] + Vorticity[1]*Vorticity[1] + Vorticity[2]*Vorticity[2]); - nodes->SetBlendingFunc(iPoint,mu, dist, rho); + nodes->SetBlendingFunc(iPoint, mu, dist, rho); - F2 = nodes->GetF2blending(iPoint); + su2double F2 = nodes->GetF2blending(iPoint); /*--- Compute the eddy viscosity ---*/ - kine = nodes->GetSolution(iPoint,0); - omega = nodes->GetSolution(iPoint,1); - zeta = min(1.0/omega, a1/(VorticityMag*F2)); - muT = max(rho*kine*zeta,0.0); + su2double kine = nodes->GetSolution(iPoint,0); + su2double omega = nodes->GetSolution(iPoint,1); + su2double zeta = min(1.0/omega, a1/(VorticityMag*F2)); + su2double muT = max(rho*kine*zeta,0.0); + nodes->SetmuT(iPoint,muT); } From 9ea05ef11d95e97a485183a77a328c866d6691b5 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Sat, 1 Feb 2020 21:38:26 +0000 Subject: [PATCH 079/118] parallel source loops SA and SST --- SU2_CFD/src/solvers/CTurbSASolver.cpp | 62 +++++++++++++------------- SU2_CFD/src/solvers/CTurbSSTSolver.cpp | 33 +++++++++----- 2 files changed, 51 insertions(+), 44 deletions(-) diff --git a/SU2_CFD/src/solvers/CTurbSASolver.cpp b/SU2_CFD/src/solvers/CTurbSASolver.cpp index 2eea771a0488..5f185bc0fc4c 100644 --- a/SU2_CFD/src/solvers/CTurbSASolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSASolver.cpp @@ -356,29 +356,37 @@ void CTurbSASolver::Postprocessing(CGeometry *geometry, CSolver **solver_contain void CTurbSASolver::Source_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics_container, CConfig *config, unsigned short iMesh) { - CNumerics* numerics = numerics_container[SOURCE_FIRST_TERM]; + const bool harmonic_balance = (config->GetTime_Marching() == HARMONIC_BALANCE); + const bool transition = (config->GetKind_Trans_Model() == LM); + const bool transition_BC = (config->GetKind_Trans_Model() == BC); - unsigned long iPoint; + CVariable* flowNodes = solver_container[FLOW_SOL]->GetNodes(); + + /*--- Start OpenMP parallel section. ---*/ + + SU2_OMP_PARALLEL + { + /*--- Pick one numerics object per thread. ---*/ + CNumerics* numerics = numerics_container[SOURCE_FIRST_TERM + omp_get_thread_num()*MAX_TERMS]; - bool harmonic_balance = (config->GetTime_Marching() == HARMONIC_BALANCE); - bool transition = (config->GetKind_Trans_Model() == LM); - bool transition_BC = (config->GetKind_Trans_Model() == BC); + /*--- Loop over all points. ---*/ - for (iPoint = 0; iPoint < nPointDomain; iPoint++) { + SU2_OMP_FOR_DYN(omp_chunk_size) + for (unsigned long iPoint = 0; iPoint < nPointDomain; iPoint++) { /*--- Conservative variables w/o reconstruction ---*/ - numerics->SetPrimitive(solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint), NULL); + numerics->SetPrimitive(flowNodes->GetPrimitive(iPoint), nullptr); /*--- Gradient of the primitive and conservative variables ---*/ - numerics->SetPrimVarGradient(solver_container[FLOW_SOL]->GetNodes()->GetGradient_Primitive(iPoint), NULL); + numerics->SetPrimVarGradient(flowNodes->GetGradient_Primitive(iPoint), nullptr); /*--- Set vorticity and strain rate magnitude ---*/ - numerics->SetVorticity(solver_container[FLOW_SOL]->GetNodes()->GetVorticity(iPoint), NULL); + numerics->SetVorticity(flowNodes->GetVorticity(iPoint), nullptr); - numerics->SetStrainMag(solver_container[FLOW_SOL]->GetNodes()->GetStrainMag(iPoint), 0.0); + numerics->SetStrainMag(flowNodes->GetStrainMag(iPoint), 0.0); /*--- Set intermittency ---*/ @@ -388,8 +396,8 @@ void CTurbSASolver::Source_Residual(CGeometry *geometry, CSolver **solver_contai /*--- Turbulent variables w/o reconstruction, and its gradient ---*/ - numerics->SetTurbVar(nodes->GetSolution(iPoint), NULL); - numerics->SetTurbVarGradient(nodes->GetGradient(iPoint), NULL); + numerics->SetTurbVar(nodes->GetSolution(iPoint), nullptr); + numerics->SetTurbVarGradient(nodes->GetGradient(iPoint), nullptr); /*--- Set volume ---*/ @@ -413,7 +421,7 @@ void CTurbSASolver::Source_Residual(CGeometry *geometry, CSolver **solver_contai /*--- Compute the source term ---*/ - numerics->ComputeResidual(Residual, Jacobian_i, NULL, config); + auto residual = numerics->ComputeResidual(config); /*--- Store the intermittency ---*/ @@ -423,39 +431,29 @@ void CTurbSASolver::Source_Residual(CGeometry *geometry, CSolver **solver_contai /*--- Subtract residual and the Jacobian ---*/ - LinSysRes.SubtractBlock(iPoint, Residual); + LinSysRes.SubtractBlock(iPoint, residual); - Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); + Jacobian.SubtractBlock2Diag(iPoint, residual.jacobian_i); } if (harmonic_balance) { - su2double Volume, Source; - unsigned short nVar_Turb = solver_container[TURB_SOL]->GetnVar(); - - /*--- Loop over points ---*/ + SU2_OMP_FOR_STAT(omp_chunk_size) + for (unsigned long iPoint = 0; iPoint < nPointDomain; iPoint++) { - for (iPoint = 0; iPoint < nPointDomain; iPoint++) { - - /*--- Get control volume ---*/ - - Volume = geometry->node[iPoint]->GetVolume(); + su2double Volume = geometry->node[iPoint]->GetVolume(); /*--- Access stored harmonic balance source term ---*/ - for (unsigned short iVar = 0; iVar < nVar_Turb; iVar++) { - Source = nodes->GetHarmonicBalance_Source(iPoint,iVar); - Residual[iVar] = Source*Volume; + for (unsigned short iVar = 0; iVar < nVar; iVar++) { + su2double Source = nodes->GetHarmonicBalance_Source(iPoint,iVar); + LinSysRes[iPoint*nVar+iVar] += Source*Volume; } - - /*--- Add Residual ---*/ - - LinSysRes.AddBlock(iPoint, Residual); - } } + } // end SU2_OMP_PARALLEL } void CTurbSASolver::Source_Template(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, diff --git a/SU2_CFD/src/solvers/CTurbSSTSolver.cpp b/SU2_CFD/src/solvers/CTurbSSTSolver.cpp index 442caa0873c3..3259a33892ee 100644 --- a/SU2_CFD/src/solvers/CTurbSSTSolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSSTSolver.cpp @@ -349,24 +349,32 @@ void CTurbSSTSolver::Postprocessing(CGeometry *geometry, CSolver **solver_contai void CTurbSSTSolver::Source_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics_container, CConfig *config, unsigned short iMesh) { - CNumerics* numerics = numerics_container[SOURCE_FIRST_TERM]; + CVariable* flowNodes = solver_container[FLOW_SOL]->GetNodes(); - unsigned long iPoint; + /*--- Start OpenMP parallel section. ---*/ + + SU2_OMP_PARALLEL + { + /*--- Pick one numerics object per thread. ---*/ + CNumerics* numerics = numerics_container[SOURCE_FIRST_TERM + omp_get_thread_num()*MAX_TERMS]; + + /*--- Loop over all points. ---*/ - for (iPoint = 0; iPoint < nPointDomain; iPoint++) { + SU2_OMP_FOR_DYN(omp_chunk_size) + for (unsigned long iPoint = 0; iPoint < nPointDomain; iPoint++) { /*--- Conservative variables w/o reconstruction ---*/ - numerics->SetPrimitive(solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint), NULL); + numerics->SetPrimitive(flowNodes->GetPrimitive(iPoint), nullptr); /*--- Gradient of the primitive and conservative variables ---*/ - numerics->SetPrimVarGradient(solver_container[FLOW_SOL]->GetNodes()->GetGradient_Primitive(iPoint), NULL); + numerics->SetPrimVarGradient(flowNodes->GetGradient_Primitive(iPoint), nullptr); /*--- Turbulent variables w/o reconstruction, and its gradient ---*/ - numerics->SetTurbVar(nodes->GetSolution(iPoint), NULL); - numerics->SetTurbVarGradient(nodes->GetGradient(iPoint), NULL); + numerics->SetTurbVar(nodes->GetSolution(iPoint), nullptr); + numerics->SetTurbVarGradient(nodes->GetGradient(iPoint), nullptr); /*--- Set volume ---*/ @@ -386,9 +394,9 @@ void CTurbSSTSolver::Source_Residual(CGeometry *geometry, CSolver **solver_conta /*--- Set vorticity and strain rate magnitude ---*/ - numerics->SetVorticity(solver_container[FLOW_SOL]->GetNodes()->GetVorticity(iPoint), NULL); + numerics->SetVorticity(flowNodes->GetVorticity(iPoint), nullptr); - numerics->SetStrainMag(solver_container[FLOW_SOL]->GetNodes()->GetStrainMag(iPoint), 0.0); + numerics->SetStrainMag(flowNodes->GetStrainMag(iPoint), 0.0); /*--- Cross diffusion ---*/ @@ -396,15 +404,16 @@ void CTurbSSTSolver::Source_Residual(CGeometry *geometry, CSolver **solver_conta /*--- Compute the source term ---*/ - numerics->ComputeResidual(Residual, Jacobian_i, NULL, config); + auto residual = numerics->ComputeResidual(config); /*--- Subtract residual and the Jacobian ---*/ - LinSysRes.SubtractBlock(iPoint, Residual); - Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); + LinSysRes.SubtractBlock(iPoint, residual); + Jacobian.SubtractBlock2Diag(iPoint, residual.jacobian_i); } + } // end SU2_OMP_PARALLEL } void CTurbSSTSolver::Source_Template(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, From 080f0e0a5a2411a3d90256226fd71711092d96b1 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Sat, 1 Feb 2020 22:51:02 +0000 Subject: [PATCH 080/118] thread safe turbulence sources --- SU2_CFD/include/numerics/CNumerics.hpp | 8 +- .../numerics/turbulent/turb_sources.hpp | 441 ++++-------------- .../src/numerics/turbulent/turb_sources.cpp | 297 +++++------- 3 files changed, 232 insertions(+), 514 deletions(-) diff --git a/SU2_CFD/include/numerics/CNumerics.hpp b/SU2_CFD/include/numerics/CNumerics.hpp index 43e13d5e1b81..c05fef7cee57 100644 --- a/SU2_CFD/include/numerics/CNumerics.hpp +++ b/SU2_CFD/include/numerics/CNumerics.hpp @@ -1136,24 +1136,24 @@ class CNumerics { * \brief Residual for source term integration. * \param[in] val_production - Value of the Production. */ - inline virtual su2double GetProduction(void) { return 0; } + inline virtual su2double GetProduction(void) const { return 0; } /*! * \brief Residual for source term integration. * \param[in] val_destruction - Value of the Destruction. */ - inline virtual su2double GetDestruction(void) { return 0; } + inline virtual su2double GetDestruction(void) const { return 0; } /*! * \brief Residual for source term integration. * \param[in] val_crossproduction - Value of the CrossProduction. */ - inline virtual su2double GetCrossProduction(void) { return 0; } + inline virtual su2double GetCrossProduction(void) const { return 0; } /*! * \brief A virtual member. */ - inline virtual su2double GetGammaBC(void) { return 0.0; } + inline virtual su2double GetGammaBC(void) const { return 0.0; } /*! * \brief A virtual member to compute the tangent matrix in structural problems diff --git a/SU2_CFD/include/numerics/turbulent/turb_sources.hpp b/SU2_CFD/include/numerics/turbulent/turb_sources.hpp index 589784f8dcfa..9ec52d2f2ce5 100644 --- a/SU2_CFD/include/numerics/turbulent/turb_sources.hpp +++ b/SU2_CFD/include/numerics/turbulent/turb_sources.hpp @@ -36,8 +36,8 @@ * \ingroup SourceDiscr * \author A. Bueno. */ -class CSourcePieceWise_TurbSA : public CNumerics { -private: +class CSourceBase_TurbSA : public CNumerics { +protected: su2double cv1_3; su2double k2; su2double cb1; @@ -49,184 +49,141 @@ class CSourcePieceWise_TurbSA : public CNumerics { su2double sigma; su2double cb2; su2double cw1; - unsigned short iDim; - su2double nu, Ji, fv1, fv2, ft2, Omega, S, Shat, inv_Shat, dist_i_2, Ji_2, Ji_3, inv_k2_d2; - su2double r, g, g_6, glim, fw; - su2double norm2_Grad; - su2double dfv1, dfv2, dShat; - su2double dr, dg, dfw; - bool incompressible; - bool rotating_frame; - bool transition; + su2double gamma_BC; su2double intermittency; su2double Production, Destruction, CrossProduction; -public: + su2double Residual, *Jacobian_i; +private: + su2double Jacobian_Buffer; /// Static storage for the Jacobian (which needs to be pointer for return type). + +protected: + const bool incompressible = false, rotating_frame = false; +public: /*! * \brief Constructor of the class. * \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. */ - CSourcePieceWise_TurbSA(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourcePieceWise_TurbSA(void); - - /*! - * \brief Residual for source term integration. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). - * \param[in] config - Definition of the particular problem. - */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + CSourceBase_TurbSA(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config); /*! * \brief Residual for source term integration. * \param[in] intermittency_in - Value of the intermittency. */ - inline void SetIntermittency(su2double intermittency_in) { intermittency = intermittency_in; } + inline void SetIntermittency(su2double intermittency_in) final { intermittency = intermittency_in; } /*! * \brief Residual for source term integration. * \param[in] val_production - Value of the Production. */ - inline void SetProduction(su2double val_production) { Production = val_production; } + inline void SetProduction(su2double val_production) final { Production = val_production; } /*! * \brief Residual for source term integration. * \param[in] val_destruction - Value of the Destruction. */ - inline void SetDestruction(su2double val_destruction) { Destruction = val_destruction; } + inline void SetDestruction(su2double val_destruction) final { Destruction = val_destruction; } /*! * \brief Residual for source term integration. * \param[in] val_crossproduction - Value of the CrossProduction. */ - inline void SetCrossProduction(su2double val_crossproduction) { CrossProduction = val_crossproduction; } + inline void SetCrossProduction(su2double val_crossproduction) final { CrossProduction = val_crossproduction; } /*! * \brief ______________. */ - inline su2double GetProduction(void) { return Production; } + inline su2double GetProduction(void) const final { return Production; } /*! * \brief Get the intermittency for the BC trans. model. * \return Value of the intermittency. */ - inline su2double GetGammaBC(void) { return gamma_BC; } + inline su2double GetGammaBC(void) const final { return gamma_BC; } /*! * \brief ______________. */ - inline su2double GetDestruction(void) { return Destruction; } + inline su2double GetDestruction(void) const final { return Destruction; } /*! * \brief ______________. */ - inline su2double GetCrossProduction(void) { return CrossProduction; } + inline su2double GetCrossProduction(void) const final { return CrossProduction; } }; + /*! - * \class CSourcePieceWise_TurbSA_COMP - * \brief Class for integrating the source terms of the Spalart-Allmaras CC modification turbulence model equation. + * \class CSourcePieceWise_TurbSA + * \brief Class for integrating the source terms of the Spalart-Allmaras turbulence model equation. * \ingroup SourceDiscr - * \author E.Molina, A. Bueno. - * \version 7.0.1 "Blackbird" + * \author A. Bueno. */ -class CSourcePieceWise_TurbSA_COMP : public CNumerics { +class CSourcePieceWise_TurbSA final : public CSourceBase_TurbSA { private: - su2double cv1_3; - su2double k2; - su2double cb1; - su2double cw2; - su2double ct3; - su2double ct4; - su2double cw3_6; - su2double cb2_sigma; - su2double sigma; - su2double cb2; - su2double cw1; - unsigned short iDim; su2double nu, Ji, fv1, fv2, ft2, Omega, S, Shat, inv_Shat, dist_i_2, Ji_2, Ji_3, inv_k2_d2; su2double r, g, g_6, glim, fw; su2double norm2_Grad; su2double dfv1, dfv2, dShat; su2double dr, dg, dfw; - bool incompressible; - bool rotating_frame; - su2double intermittency; - su2double Production, Destruction, CrossProduction; - su2double aux_cc, CompCorrection, c5; - unsigned short jDim; + unsigned short iDim; + bool transition; public: - /*! * \brief Constructor of the class. * \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. */ - CSourcePieceWise_TurbSA_COMP(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourcePieceWise_TurbSA_COMP(void); + CSourcePieceWise_TurbSA(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config); /*! * \brief Residual for source term integration. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). * \param[in] config - Definition of the particular problem. + * \return A lightweight const-view (read-only) of the residual/flux and Jacobians. */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + ResidualType<> ComputeResidual(const CConfig* config) override; - /*! - * \brief Residual for source term integration. - * \param[in] intermittency_in - Value of the intermittency. - */ - inline void SetIntermittency(su2double intermittency_in) { intermittency = intermittency_in; } +}; - /*! - * \brief Residual for source term integration. - * \param[in] val_production - Value of the Production. - */ - inline void SetProduction(su2double val_production) { Production = val_production; } +/*! + * \class CSourcePieceWise_TurbSA_COMP + * \brief Class for integrating the source terms of the Spalart-Allmaras CC modification turbulence model equation. + * \ingroup SourceDiscr + * \author E.Molina, A. Bueno. + * \version 7.0.1 "Blackbird" + */ +class CSourcePieceWise_TurbSA_COMP final : public CSourceBase_TurbSA { +private: + su2double nu, Ji, fv1, fv2, ft2, Omega, S, Shat, inv_Shat, dist_i_2, Ji_2, Ji_3, inv_k2_d2; + su2double r, g, g_6, glim, fw; + su2double norm2_Grad; + su2double dfv1, dfv2, dShat; + su2double dr, dg, dfw; + su2double aux_cc, CompCorrection, c5; + unsigned short iDim, jDim; +public: /*! - * \brief Residual for source term integration. - * \param[in] val_destruction - Value of the Destruction. + * \brief Constructor of the class. + * \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. */ - inline void SetDestruction(su2double val_destruction) { Destruction = val_destruction; } + CSourcePieceWise_TurbSA_COMP(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config); /*! * \brief Residual for source term integration. - * \param[in] val_crossproduction - Value of the CrossProduction. - */ - inline void SetCrossProduction(su2double val_crossproduction) { CrossProduction = val_crossproduction; } - - /*! - * \brief ______________. - */ - inline su2double GetProduction(void) { return Production; } - - /*! - * \brief ______________. + * \param[in] config - Definition of the particular problem. + * \return A lightweight const-view (read-only) of the residual/flux and Jacobians. */ - inline su2double GetDestruction(void) { return Destruction; } + ResidualType<> ComputeResidual(const CConfig* config) override; - /*! - * \brief ______________. - */ - inline su2double GetCrossProduction(void) { return CrossProduction; } }; /*! @@ -236,94 +193,31 @@ class CSourcePieceWise_TurbSA_COMP : public CNumerics { * \author E.Molina, A. Bueno. * \version 7.0.1 "Blackbird" */ -class CSourcePieceWise_TurbSA_E : public CNumerics { +class CSourcePieceWise_TurbSA_E final : public CSourceBase_TurbSA { private: - su2double cv1_3; - su2double k2; - su2double cb1; - su2double cw2; - su2double ct3; - su2double ct4; - su2double cw3_6; - su2double cb2_sigma; - su2double sigma; - su2double cb2; - su2double cw1; - unsigned short iDim; su2double nu, Ji, fv1, fv2, ft2, Omega, S, Shat, inv_Shat, dist_i_2, Ji_2, Ji_3, inv_k2_d2; su2double r, g, g_6, glim, fw; su2double norm2_Grad; su2double dfv1, dfv2, dShat; su2double dr, dg, dfw; - bool incompressible; - bool rotating_frame; - su2double intermittency; - su2double Production, Destruction, CrossProduction; su2double Sbar; - unsigned short jDim; + unsigned short iDim, jDim; public: - /*! * \brief Constructor of the class. * \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. */ - CSourcePieceWise_TurbSA_E(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourcePieceWise_TurbSA_E(void); + CSourcePieceWise_TurbSA_E(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config); /*! * \brief Residual for source term integration. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). * \param[in] config - Definition of the particular problem. + * \return A lightweight const-view (read-only) of the residual/flux and Jacobians. */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - - /*! - * \brief Residual for source term integration. - * \param[in] intermittency_in - Value of the intermittency. - */ - inline void SetIntermittency(su2double intermittency_in) { intermittency = intermittency_in; } - - /*! - * \brief Residual for source term integration. - * \param[in] val_production - Value of the Production. - */ - inline void SetProduction(su2double val_production) { Production = val_production; } - - /*! - * \brief Residual for source term integration. - * \param[in] val_destruction - Value of the Destruction. - */ - inline void SetDestruction(su2double val_destruction) { Destruction = val_destruction; } - - /*! - * \brief Residual for source term integration. - * \param[in] val_crossproduction - Value of the CrossProduction. - */ - inline void SetCrossProduction(su2double val_crossproduction) { CrossProduction = val_crossproduction; } - - /*! - * \brief ______________. - */ - inline su2double GetProduction(void) { return Production; } - - /*! - * \brief ______________. - */ - inline su2double GetDestruction(void) { return Destruction; } - - /*! - * \brief ______________. - */ - inline su2double GetCrossProduction(void) { return CrossProduction; } + ResidualType<> ComputeResidual(const CConfig* config) override; }; /*! @@ -333,95 +227,32 @@ class CSourcePieceWise_TurbSA_E : public CNumerics { * \author E.Molina, A. Bueno. * \version 7.0.1 "Blackbird" */ -class CSourcePieceWise_TurbSA_E_COMP : public CNumerics { +class CSourcePieceWise_TurbSA_E_COMP : public CSourceBase_TurbSA { private: - su2double cv1_3; - su2double k2; - su2double cb1; - su2double cw2; - su2double ct3; - su2double ct4; - su2double cw3_6; - su2double cb2_sigma; - su2double sigma; - su2double cb2; - su2double cw1; - unsigned short iDim; su2double nu, Ji, fv1, fv2, ft2, Omega, S, Shat, inv_Shat, dist_i_2, Ji_2, Ji_3, inv_k2_d2; su2double r, g, g_6, glim, fw; su2double norm2_Grad; su2double dfv1, dfv2, dShat; su2double dr, dg, dfw; - bool incompressible; - bool rotating_frame; - su2double intermittency; - su2double Production, Destruction, CrossProduction; su2double Sbar; - unsigned short jDim; su2double aux_cc, CompCorrection, c5; + unsigned short iDim, jDim; public: - /*! * \brief Constructor of the class. * \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. */ - CSourcePieceWise_TurbSA_E_COMP(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourcePieceWise_TurbSA_E_COMP(void); + CSourcePieceWise_TurbSA_E_COMP(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config); /*! * \brief Residual for source term integration. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). * \param[in] config - Definition of the particular problem. + * \return A lightweight const-view (read-only) of the residual/flux and Jacobians. */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - - /*! - * \brief Residual for source term integration. - * \param[in] intermittency_in - Value of the intermittency. - */ - inline void SetIntermittency(su2double intermittency_in) { intermittency = intermittency_in; } - - /*! - * \brief Residual for source term integration. - * \param[in] val_production - Value of the Production. - */ - inline void SetProduction(su2double val_production) { Production = val_production; } - - /*! - * \brief Residual for source term integration. - * \param[in] val_destruction - Value of the Destruction. - */ - inline void SetDestruction(su2double val_destruction) { Destruction = val_destruction; } - - /*! - * \brief Residual for source term integration. - * \param[in] val_crossproduction - Value of the CrossProduction. - */ - inline void SetCrossProduction(su2double val_crossproduction) { CrossProduction = val_crossproduction; } - - /*! - * \brief ______________. - */ - inline su2double GetProduction(void) { return Production; } - - /*! - * \brief ______________. - */ - inline su2double GetDestruction(void) { return Destruction; } - - /*! - * \brief ______________. - */ - inline su2double GetCrossProduction(void) { return CrossProduction; } + ResidualType<> ComputeResidual(const CConfig* config) override; }; /*! @@ -430,92 +261,30 @@ class CSourcePieceWise_TurbSA_E_COMP : public CNumerics { * \ingroup SourceDiscr * \author F. Palacios */ -class CSourcePieceWise_TurbSA_Neg : public CNumerics { +class CSourcePieceWise_TurbSA_Neg : public CSourceBase_TurbSA { private: - su2double cv1_3; - su2double k2; - su2double cb1; - su2double cw2; - su2double ct3; - su2double ct4; - su2double cw3_6; - su2double cb2_sigma; - su2double sigma; - su2double cb2; - su2double cw1; - unsigned short iDim; su2double nu, Ji, fv1, fv2, ft2, Omega, S, Shat, inv_Shat, dist_i_2, Ji_2, Ji_3, inv_k2_d2; su2double r, g, g_6, glim, fw; su2double norm2_Grad; su2double dfv1, dfv2, dShat; su2double dr, dg, dfw; - bool incompressible; - bool rotating_frame; - su2double intermittency; - su2double Production, Destruction, CrossProduction; public: - /*! * \brief Constructor of the class. * \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. */ - CSourcePieceWise_TurbSA_Neg(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourcePieceWise_TurbSA_Neg(void); + CSourcePieceWise_TurbSA_Neg(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config); /*! * \brief Residual for source term integration. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). * \param[in] config - Definition of the particular problem. + * \return A lightweight const-view (read-only) of the residual/flux and Jacobians. */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); + ResidualType<> ComputeResidual(const CConfig* config) override; - /*! - * \brief Residual for source term integration. - * \param[in] intermittency_in - Value of the intermittency. - */ - inline void SetIntermittency(su2double intermittency_in) { intermittency = intermittency_in; } - - /*! - * \brief Residual for source term integration. - * \param[in] val_production - Value of the Production. - */ - inline void SetProduction(su2double val_production) { Production = val_production; } - - /*! - * \brief Residual for source term integration. - * \param[in] val_destruction - Value of the Destruction. - */ - inline void SetDestruction(su2double val_destruction) { Destruction = val_destruction; } - - /*! - * \brief Residual for source term integration. - * \param[in] val_crossproduction - Value of the CrossProduction. - */ - inline void SetCrossProduction(su2double val_crossproduction) { CrossProduction = val_crossproduction; } - - /*! - * \brief ______________. - */ - inline su2double GetProduction(void) { return Production; } - - /*! - * \brief ______________. - */ - inline su2double GetDestruction(void) { return Destruction; } - - /*! - * \brief ______________. - */ - inline su2double GetCrossProduction(void) { return CrossProduction; } }; /*! @@ -524,7 +293,7 @@ class CSourcePieceWise_TurbSA_Neg : public CNumerics { * \ingroup SourceDiscr * \author A. Campos. */ -class CSourcePieceWise_TurbSST : public CNumerics { +class CSourcePieceWise_TurbSST final : public CNumerics { private: su2double F1_i, F1_j, @@ -544,11 +313,38 @@ class CSourcePieceWise_TurbSST : public CNumerics { su2double kAmb, omegaAmb; + su2double Residual[2], + *Jacobian_i[2] = {nullptr}, + Jacobian_Buffer[4] = {0.0}; /// Static storage for the Jacobian (which needs to be pointer for return type). + bool incompressible; bool sustaining_terms; -public: + /*! + * \brief Initialize the Reynolds Stress Matrix + * \param[in] turb_ke turbulent kinetic energy of node + */ + void SetReynoldsStressMatrix(su2double turb_ke); + + /*! + * \brief Perturb the Reynolds stress tensor based on parameters + * \param[in] turb_ke: turbulent kinetic energy of the noce + * \param[in] config: config file + */ + void SetPerturbedRSM(su2double turb_ke, const CConfig* config); + /*! + * \brief A virtual member. Get strain magnitude based on perturbed reynolds stress matrix + * \param[in] turb_ke: turbulent kinetic energy of the node + */ + void SetPerturbedStrainMag(su2double turb_ke); + /*! + * \brief Get the mean rate of strain matrix based on velocity gradients + * \param[in] S_ij + */ + void GetMeanRateOfStrainMatrix(su2double **S_ij); + +public: /*! * \brief Constructor of the class. * \param[in] val_nDim - Number of dimensions of the problem. @@ -556,19 +352,14 @@ class CSourcePieceWise_TurbSST : public CNumerics { * \param[in] config - Definition of the particular problem. */ CSourcePieceWise_TurbSST(unsigned short val_nDim, unsigned short val_nVar, const su2double* constants, - su2double val_kine_Inf, su2double val_omega_Inf, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSourcePieceWise_TurbSST(void); + su2double val_kine_Inf, su2double val_omega_Inf, const CConfig* config); /*! * \brief Set the value of the first blending function. * \param[in] val_F1_i - Value of the first blending function at point i. * \param[in] val_F1_j - Value of the first blending function at point j. */ - inline void SetF1blending(su2double val_F1_i, su2double val_F1_j) { + inline void SetF1blending(su2double val_F1_i, su2double val_F1_j) override { F1_i = val_F1_i; F1_j = val_F1_j; } @@ -578,7 +369,7 @@ class CSourcePieceWise_TurbSST : public CNumerics { * \param[in] val_F2_i - Value of the second blending function at point i. * \param[in] val_F2_j - Value of the second blending function at point j. */ - inline void SetF2blending(su2double val_F2_i, su2double val_F2_j) { + inline void SetF2blending(su2double val_F2_i, su2double val_F2_j) override { F2_i = val_F2_i; F2_j = val_F2_j; } @@ -595,35 +386,9 @@ class CSourcePieceWise_TurbSST : public CNumerics { /*! * \brief Residual for source term integration. - * \param[out] val_residual - Pointer to the total residual. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). * \param[in] config - Definition of the particular problem. + * \return A lightweight const-view (read-only) of the residual/flux and Jacobians. */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - - /*! - * \brief Initialize the Reynolds Stress Matrix - * \param[in] turb_ke turbulent kinetic energy of node - */ - void SetReynoldsStressMatrix(su2double turb_ke); - - /*! - * \brief Perturb the Reynolds stress tensor based on parameters - * \param[in] turb_ke: turbulent kinetic energy of the noce - * \param[in] config: config file - */ - void SetPerturbedRSM(su2double turb_ke, CConfig *config); - /*! - * \brief A virtual member. Get strain magnitude based on perturbed reynolds stress matrix - * \param[in] turb_ke: turbulent kinetic energy of the node - */ - void SetPerturbedStrainMag(su2double turb_ke); - - /*! - * \brief Get the mean rate of strain matrix based on velocity gradients - * \param[in] S_ij - */ - void GetMeanRateOfStrainMatrix(su2double **S_ij); + ResidualType<> ComputeResidual(const CConfig* config) override; }; diff --git a/SU2_CFD/src/numerics/turbulent/turb_sources.cpp b/SU2_CFD/src/numerics/turbulent/turb_sources.cpp index 8298f5a46fcb..1210caecef87 100644 --- a/SU2_CFD/src/numerics/turbulent/turb_sources.cpp +++ b/SU2_CFD/src/numerics/turbulent/turb_sources.cpp @@ -28,13 +28,13 @@ #include "../../../include/numerics/turbulent/turb_sources.hpp" -CSourcePieceWise_TurbSA::CSourcePieceWise_TurbSA(unsigned short val_nDim, unsigned short val_nVar, - CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); - rotating_frame = config->GetRotating_Frame(); - transition = (config->GetKind_Trans_Model() == BC); - +CSourceBase_TurbSA::CSourceBase_TurbSA(unsigned short val_nDim, + unsigned short val_nVar, + const CConfig* config) : + CNumerics(val_nDim, val_nVar, config), + incompressible(config->GetKind_Regime() == INCOMPRESSIBLE), + rotating_frame(config->GetRotating_Frame()) +{ /*--- Spalart-Allmaras closure constants ---*/ cv1_3 = pow(7.1, 3.0); @@ -49,12 +49,23 @@ CSourcePieceWise_TurbSA::CSourcePieceWise_TurbSA(unsigned short val_nDim, unsign cb2_sigma = cb2/sigma; cw1 = cb1/k2+(1.0+cb2)/sigma; + /*--- Setup the Jacobian pointer, we need to return su2double** but + * we know the Jacobian is 1x1 so we use this "trick" to avoid + * having to dynamically allocate. ---*/ + + Jacobian_i = &Jacobian_Buffer; + } -CSourcePieceWise_TurbSA::~CSourcePieceWise_TurbSA(void) { } +CSourcePieceWise_TurbSA::CSourcePieceWise_TurbSA(unsigned short val_nDim, + unsigned short val_nVar, + const CConfig* config) : + CSourceBase_TurbSA(val_nDim, val_nVar, config) { -void CSourcePieceWise_TurbSA::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, - su2double **val_Jacobian_j, CConfig *config) { + transition = (config->GetKind_Trans_Model() == BC); +} + +CNumerics::ResidualType<> CSourcePieceWise_TurbSA::ComputeResidual(const CConfig* config) { // AD::StartPreacc(); // AD::SetPreaccIn(V_i, nDim+6); @@ -77,11 +88,11 @@ void CSourcePieceWise_TurbSA::ComputeResidual(su2double *val_residual, su2double Laminar_Viscosity_i = V_i[nDim+5]; } - val_residual[0] = 0.0; + Residual = 0.0; Production = 0.0; Destruction = 0.0; CrossProduction = 0.0; - val_Jacobian_i[0][0] = 0.0; + Jacobian_i[0] = 0.0; gamma_BC = 0.0; vmag = 0.0; @@ -91,7 +102,7 @@ void CSourcePieceWise_TurbSA::ComputeResidual(su2double *val_residual, su2double if (nDim==2) { vmag = sqrt(V_i[1]*V_i[1]+V_i[2]*V_i[2]); } - else if (nDim==3) { + else { vmag = sqrt(V_i[1]*V_i[1]+V_i[2]*V_i[2]+V_i[3]*V_i[3]); } @@ -172,7 +183,7 @@ void CSourcePieceWise_TurbSA::ComputeResidual(su2double *val_residual, su2double CrossProduction = cb2_sigma*norm2_Grad*Volume; - val_residual[0] = Production - Destruction + CrossProduction; + Residual = Production - Destruction + CrossProduction; /*--- Implicit part, production term ---*/ @@ -182,10 +193,10 @@ void CSourcePieceWise_TurbSA::ComputeResidual(su2double *val_residual, su2double else dShat = (fv2+TurbVar_i[0]*dfv2)*inv_k2_d2; if (transition) { - val_Jacobian_i[0][0] += gamma_BC*cb1*(TurbVar_i[0]*dShat+Shat)*Volume; + Jacobian_i[0] += gamma_BC*cb1*(TurbVar_i[0]*dShat+Shat)*Volume; } else { - val_Jacobian_i[0][0] += cb1*(TurbVar_i[0]*dShat+Shat)*Volume; + Jacobian_i[0] += cb1*(TurbVar_i[0]*dShat+Shat)*Volume; } /*--- Implicit part, destruction term ---*/ @@ -194,42 +205,23 @@ void CSourcePieceWise_TurbSA::ComputeResidual(su2double *val_residual, su2double if (r == 10.0) dr = 0.0; dg = dr*(1.+cw2*(6.0*pow(r,5.0)-1.0)); dfw = dg*glim*(1.-g_6/(g_6+cw3_6)); - val_Jacobian_i[0][0] -= cw1*(dfw*TurbVar_i[0] + 2.0*fw)*TurbVar_i[0]/dist_i_2*Volume; + Jacobian_i[0] -= cw1*(dfw*TurbVar_i[0] + 2.0*fw)*TurbVar_i[0]/dist_i_2*Volume; } -// AD::SetPreaccOut(val_residual[0]); +// AD::SetPreaccOut(Residual); // AD::EndPreacc(); -} - -CSourcePieceWise_TurbSA_COMP::CSourcePieceWise_TurbSA_COMP(unsigned short val_nDim, unsigned short val_nVar, - CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); - rotating_frame = config->GetRotating_Frame(); - - /*--- Spalart-Allmaras closure constants ---*/ - - cv1_3 = pow(7.1, 3.0); - k2 = pow(0.41, 2.0); - cb1 = 0.1355; - cw2 = 0.3; - ct3 = 1.2; - ct4 = 0.5; - cw3_6 = pow(2.0, 6.0); - sigma = 2./3.; - cb2 = 0.622; - cb2_sigma = cb2/sigma; - cw1 = cb1/k2+(1.0+cb2)/sigma; - c5 = 3.5; + return ResidualType<>(&Residual, &Jacobian_i, nullptr); } -CSourcePieceWise_TurbSA_COMP::~CSourcePieceWise_TurbSA_COMP(void) { } +CSourcePieceWise_TurbSA_COMP::CSourcePieceWise_TurbSA_COMP(unsigned short val_nDim, + unsigned short val_nVar, + const CConfig* config) : + CSourceBase_TurbSA(val_nDim, val_nVar, config), c5(3.5) { } -void CSourcePieceWise_TurbSA_COMP::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, - su2double **val_Jacobian_j, CConfig *config) { +CNumerics::ResidualType<> CSourcePieceWise_TurbSA_COMP::ComputeResidual(const CConfig* config) { // AD::StartPreacc(); // AD::SetPreaccIn(V_i, nDim+6); @@ -248,11 +240,11 @@ void CSourcePieceWise_TurbSA_COMP::ComputeResidual(su2double *val_residual, su2d Laminar_Viscosity_i = V_i[nDim+5]; } - val_residual[0] = 0.0; + Residual = 0.0; Production = 0.0; Destruction = 0.0; CrossProduction = 0.0; - val_Jacobian_i[0][0] = 0.0; + Jacobian_i[0] = 0.0; /*--- Evaluate Omega ---*/ @@ -303,7 +295,7 @@ void CSourcePieceWise_TurbSA_COMP::ComputeResidual(su2double *val_residual, su2d CrossProduction = cb2_sigma*norm2_Grad*Volume; - val_residual[0] = Production - Destruction + CrossProduction; + Residual = Production - Destruction + CrossProduction; /*--- Compressibility Correction term ---*/ Pressure_i = V_i[nDim+1]; @@ -314,7 +306,7 @@ void CSourcePieceWise_TurbSA_COMP::ComputeResidual(su2double *val_residual, su2d aux_cc+=PrimVar_Grad_i[1+iDim][jDim]*PrimVar_Grad_i[1+iDim][jDim];}} CompCorrection=c5*(TurbVar_i[0]*TurbVar_i[0]/(SoundSpeed_i*SoundSpeed_i))*aux_cc*Volume; - val_residual[0]-=CompCorrection; + Residual -= CompCorrection; /*--- Implicit part, production term ---*/ @@ -322,7 +314,7 @@ void CSourcePieceWise_TurbSA_COMP::ComputeResidual(su2double *val_residual, su2d dfv2 = -(1/nu-Ji_2*dfv1)/pow(1.+Ji*fv1,2.); if ( Shat <= 1.0e-10 ) dShat = 0.0; else dShat = (fv2+TurbVar_i[0]*dfv2)*inv_k2_d2; - val_Jacobian_i[0][0] += cb1*(TurbVar_i[0]*dShat+Shat)*Volume; + Jacobian_i[0] += cb1*(TurbVar_i[0]*dShat+Shat)*Volume; /*--- Implicit part, destruction term ---*/ @@ -330,44 +322,28 @@ void CSourcePieceWise_TurbSA_COMP::ComputeResidual(su2double *val_residual, su2d if (r == 10.0) dr = 0.0; dg = dr*(1.+cw2*(6.0*pow(r,5.0)-1.0)); dfw = dg*glim*(1.-g_6/(g_6+cw3_6)); - val_Jacobian_i[0][0] -= cw1*(dfw*TurbVar_i[0] + 2.0*fw)*TurbVar_i[0]/dist_i_2*Volume; + Jacobian_i[0] -= cw1*(dfw*TurbVar_i[0] + 2.0*fw)*TurbVar_i[0]/dist_i_2*Volume; /* Compressibility Correction */ - val_Jacobian_i[0][0] -= 2.0*c5*(TurbVar_i[0]/(SoundSpeed_i*SoundSpeed_i))*aux_cc*Volume; + Jacobian_i[0] -= 2.0*c5*(TurbVar_i[0]/(SoundSpeed_i*SoundSpeed_i))*aux_cc*Volume; } - // AD::SetPreaccOut(val_residual[0]); + // AD::SetPreaccOut(Residual); // AD::EndPreacc(); -} - -CSourcePieceWise_TurbSA_E::CSourcePieceWise_TurbSA_E(unsigned short val_nDim, unsigned short val_nVar, - CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); - rotating_frame = config->GetRotating_Frame(); - - /*--- Spalart-Allmaras closure constants ---*/ - - cv1_3 = pow(7.1, 3.0); - k2 = pow(0.41, 2.0); - cb1 = 0.1355; - cw2 = 0.3; - ct3 = 1.2; - ct4 = 0.5; - cw3_6 = pow(2.0, 6.0); - sigma = 2./3.; - cb2 = 0.622; - cb2_sigma = cb2/sigma; - cw1 = cb1/k2+(1.0+cb2)/sigma; + return ResidualType<>(&Residual, &Jacobian_i, nullptr); } -CSourcePieceWise_TurbSA_E::~CSourcePieceWise_TurbSA_E(void) { } +CSourcePieceWise_TurbSA_E::CSourcePieceWise_TurbSA_E(unsigned short val_nDim, + unsigned short val_nVar, + const CConfig* config) : + CSourceBase_TurbSA(val_nDim, val_nVar, config) { } + +CNumerics::ResidualType<> CSourcePieceWise_TurbSA_E::ComputeResidual(const CConfig* config) { -void CSourcePieceWise_TurbSA_E::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, - su2double **val_Jacobian_j, CConfig *config) { + unsigned short iDim, jDim; // AD::StartPreacc(); // AD::SetPreaccIn(V_i, nDim+6); @@ -382,15 +358,15 @@ void CSourcePieceWise_TurbSA_E::ComputeResidual(su2double *val_residual, su2doub Laminar_Viscosity_i = V_i[nDim+4]; } else { - Density_i = V_i[nDim+2]; - Laminar_Viscosity_i = V_i[nDim+5]; + Density_i = V_i[nDim+2]; + Laminar_Viscosity_i = V_i[nDim+5]; } - val_residual[0] = 0.0; + Residual = 0.0; Production = 0.0; Destruction = 0.0; CrossProduction = 0.0; - val_Jacobian_i[0][0] = 0.0; + Jacobian_i[0] = 0.0; /* From NASA Turbulence model site. http://turbmodels.larc.nasa.gov/spalart.html @@ -459,7 +435,7 @@ void CSourcePieceWise_TurbSA_E::ComputeResidual(su2double *val_residual, su2doub CrossProduction = cb2_sigma*norm2_Grad*Volume; - val_residual[0] = Production - Destruction + CrossProduction; + Residual = Production - Destruction + CrossProduction; /*--- Implicit part, production term ---*/ @@ -468,7 +444,7 @@ void CSourcePieceWise_TurbSA_E::ComputeResidual(su2double *val_residual, su2doub if ( Shat <= 1.0e-10 ) dShat = 0.0; else dShat = -S*pow(Ji,-2.0)/nu + S*dfv1; - val_Jacobian_i[0][0] += cb1*(TurbVar_i[0]*dShat+Shat)*Volume; + Jacobian_i[0] += cb1*(TurbVar_i[0]*dShat+Shat)*Volume; /*--- Implicit part, destruction term ---*/ @@ -476,41 +452,25 @@ void CSourcePieceWise_TurbSA_E::ComputeResidual(su2double *val_residual, su2doub dr=(1-pow(tanh(r),2.0))*(dr)/tanh(1.0); dg = dr*(1.+cw2*(6.0*pow(r,5.0)-1.0)); dfw = dg*glim*(1.-g_6/(g_6+cw3_6)); - val_Jacobian_i[0][0] -= cw1*(dfw*TurbVar_i[0] + 2.0*fw)*TurbVar_i[0]/dist_i_2*Volume; + Jacobian_i[0] -= cw1*(dfw*TurbVar_i[0] + 2.0*fw)*TurbVar_i[0]/dist_i_2*Volume; } - // AD::SetPreaccOut(val_residual[0]); + // AD::SetPreaccOut(Residual); // AD::EndPreacc(); -} - -CSourcePieceWise_TurbSA_E_COMP::CSourcePieceWise_TurbSA_E_COMP(unsigned short val_nDim, unsigned short val_nVar, - CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); - rotating_frame = config->GetRotating_Frame(); - - /*--- Spalart-Allmaras closure constants ---*/ - - cv1_3 = pow(7.1, 3.0); - k2 = pow(0.41, 2.0); - cb1 = 0.1355; - cw2 = 0.3; - ct3 = 1.2; - ct4 = 0.5; - cw3_6 = pow(2.0, 6.0); - sigma = 2./3.; - cb2 = 0.622; - cb2_sigma = cb2/sigma; - cw1 = cb1/k2+(1.0+cb2)/sigma; + return ResidualType<>(&Residual, &Jacobian_i, nullptr); } -CSourcePieceWise_TurbSA_E_COMP::~CSourcePieceWise_TurbSA_E_COMP(void) { } +CSourcePieceWise_TurbSA_E_COMP::CSourcePieceWise_TurbSA_E_COMP(unsigned short val_nDim, + unsigned short val_nVar, + const CConfig* config) : + CSourceBase_TurbSA(val_nDim, val_nVar, config) { } + +CNumerics::ResidualType<> CSourcePieceWise_TurbSA_E_COMP::ComputeResidual(const CConfig* config) { -void CSourcePieceWise_TurbSA_E_COMP::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, - su2double **val_Jacobian_j, CConfig *config) { + unsigned short iDim; // AD::StartPreacc(); // AD::SetPreaccIn(V_i, nDim+6); @@ -529,11 +489,11 @@ void CSourcePieceWise_TurbSA_E_COMP::ComputeResidual(su2double *val_residual, su Laminar_Viscosity_i = V_i[nDim+5]; } - val_residual[0] = 0.0; + Residual = 0.0; Production = 0.0; Destruction = 0.0; CrossProduction = 0.0; - val_Jacobian_i[0][0] = 0.0; + Jacobian_i[0] = 0.0; /* From NASA Turbulence model site. http://turbmodels.larc.nasa.gov/spalart.html @@ -601,7 +561,7 @@ void CSourcePieceWise_TurbSA_E_COMP::ComputeResidual(su2double *val_residual, su CrossProduction = cb2_sigma*norm2_Grad*Volume; - val_residual[0] = Production - Destruction + CrossProduction; + Residual = Production - Destruction + CrossProduction; /*--- Compressibility Correction term ---*/ Pressure_i = V_i[nDim+1]; @@ -612,7 +572,7 @@ void CSourcePieceWise_TurbSA_E_COMP::ComputeResidual(su2double *val_residual, su aux_cc+=PrimVar_Grad_i[1+iDim][jDim]*PrimVar_Grad_i[1+iDim][jDim];}} CompCorrection=c5*(TurbVar_i[0]*TurbVar_i[0]/(SoundSpeed_i*SoundSpeed_i))*aux_cc*Volume; - val_residual[0]-=CompCorrection; + Residual -= CompCorrection; /*--- Implicit part, production term ---*/ @@ -621,7 +581,7 @@ void CSourcePieceWise_TurbSA_E_COMP::ComputeResidual(su2double *val_residual, su if ( Shat <= 1.0e-10 ) dShat = 0.0; else dShat = -S*pow(Ji,-2.0)/nu + S*dfv1; - val_Jacobian_i[0][0] += cb1*(TurbVar_i[0]*dShat+Shat)*Volume; + Jacobian_i[0] += cb1*(TurbVar_i[0]*dShat+Shat)*Volume; /*--- Implicit part, destruction term ---*/ @@ -629,46 +589,28 @@ void CSourcePieceWise_TurbSA_E_COMP::ComputeResidual(su2double *val_residual, su dr=(1-pow(tanh(r),2.0))*(dr)/tanh(1.0); dg = dr*(1.+cw2*(6.0*pow(r,5.0)-1.0)); dfw = dg*glim*(1.-g_6/(g_6+cw3_6)); - val_Jacobian_i[0][0] -= cw1*(dfw*TurbVar_i[0] + 2.0*fw)*TurbVar_i[0]/dist_i_2*Volume; + Jacobian_i[0] -= cw1*(dfw*TurbVar_i[0] + 2.0*fw)*TurbVar_i[0]/dist_i_2*Volume; /* Compressibility Correction */ - val_Jacobian_i[0][0] -= 2.0*c5*(TurbVar_i[0]/(SoundSpeed_i*SoundSpeed_i))*aux_cc*Volume; + Jacobian_i[0] -= 2.0*c5*(TurbVar_i[0]/(SoundSpeed_i*SoundSpeed_i))*aux_cc*Volume; } - // AD::SetPreaccOut(val_residual[0]); + // AD::SetPreaccOut(Residual); // AD::EndPreacc(); -} - -CSourcePieceWise_TurbSA_Neg::CSourcePieceWise_TurbSA_Neg(unsigned short val_nDim, unsigned short val_nVar, - CConfig *config) : CNumerics(val_nDim, val_nVar, config) { - - incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); - rotating_frame = config->GetRotating_Frame(); - - /*--- Negative Spalart-Allmaras closure constants ---*/ - - cv1_3 = pow(7.1, 3.0); - k2 = pow(0.41, 2.0); - cb1 = 0.1355; - cw2 = 0.3; - ct3 = 1.2; - ct4 = 0.5; - cw3_6 = pow(2.0, 6.0); - sigma = 2./3.; - cb2 = 0.622; - cb2_sigma = cb2/sigma; - cw1 = cb1/k2+(1.0+cb2)/sigma; + return ResidualType<>(&Residual, &Jacobian_i, nullptr); } -CSourcePieceWise_TurbSA_Neg::~CSourcePieceWise_TurbSA_Neg(void) { +CSourcePieceWise_TurbSA_Neg::CSourcePieceWise_TurbSA_Neg(unsigned short val_nDim, + unsigned short val_nVar, + const CConfig* config) : + CSourceBase_TurbSA(val_nDim, val_nVar, config) { } -} +CNumerics::ResidualType<> CSourcePieceWise_TurbSA_Neg::ComputeResidual(const CConfig* config) { -void CSourcePieceWise_TurbSA_Neg::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, - su2double **val_Jacobian_j, CConfig *config) { + unsigned short iDim; // AD::StartPreacc(); // AD::SetPreaccIn(V_i, nDim+6); @@ -687,11 +629,11 @@ void CSourcePieceWise_TurbSA_Neg::ComputeResidual(su2double *val_residual, su2do Laminar_Viscosity_i = V_i[nDim+5]; } - val_residual[0] = 0.0; + Residual = 0.0; Production = 0.0; Destruction = 0.0; CrossProduction = 0.0; - val_Jacobian_i[0][0] = 0.0; + Jacobian_i[0] = 0.0; /*--- Evaluate Omega ---*/ @@ -747,7 +689,7 @@ void CSourcePieceWise_TurbSA_Neg::ComputeResidual(su2double *val_residual, su2do CrossProduction = cb2_sigma*norm2_Grad*Volume; - val_residual[0] = Production - Destruction + CrossProduction; + Residual = Production - Destruction + CrossProduction; /*--- Implicit part, production term ---*/ @@ -755,7 +697,7 @@ void CSourcePieceWise_TurbSA_Neg::ComputeResidual(su2double *val_residual, su2do dfv2 = -(1/nu-Ji_2*dfv1)/pow(1.+Ji*fv1,2.); if ( Shat <= 1.0e-10 ) dShat = 0.0; else dShat = (fv2+TurbVar_i[0]*dfv2)*inv_k2_d2; - val_Jacobian_i[0][0] += cb1*(TurbVar_i[0]*dShat+Shat)*Volume; + Jacobian_i[0] += cb1*(TurbVar_i[0]*dShat+Shat)*Volume; /*--- Implicit part, destruction term ---*/ @@ -763,7 +705,7 @@ void CSourcePieceWise_TurbSA_Neg::ComputeResidual(su2double *val_residual, su2do if (r == 10.0) dr = 0.0; dg = dr*(1.+cw2*(6.0*pow(r,5.0)-1.0)); dfw = dg*glim*(1.-g_6/(g_6+cw3_6)); - val_Jacobian_i[0][0] -= cw1*(dfw*TurbVar_i[0] + 2.0*fw)*TurbVar_i[0]/dist_i_2*Volume; + Jacobian_i[0] -= cw1*(dfw*TurbVar_i[0] + 2.0*fw)*TurbVar_i[0]/dist_i_2*Volume; } @@ -789,29 +731,36 @@ void CSourcePieceWise_TurbSA_Neg::ComputeResidual(su2double *val_residual, su2do CrossProduction = cb2_sigma*norm2_Grad*Volume; - val_residual[0] = Production + Destruction + CrossProduction; + Residual = Production + Destruction + CrossProduction; /*--- Implicit part, production term ---*/ - val_Jacobian_i[0][0] += cb1*(1.0-ct3)*Omega*Volume; + Jacobian_i[0] += cb1*(1.0-ct3)*Omega*Volume; /*--- Implicit part, destruction term ---*/ - val_Jacobian_i[0][0] += 2.0*cw1*TurbVar_i[0]/dist_i_2*Volume; + Jacobian_i[0] += 2.0*cw1*TurbVar_i[0]/dist_i_2*Volume; } } -// AD::SetPreaccOut(val_residual, nVar); +// AD::SetPreaccOut(Residual); // AD::EndPreacc(); + + return ResidualType<>(&Residual, &Jacobian_i, nullptr); + } -CSourcePieceWise_TurbSST::CSourcePieceWise_TurbSST(unsigned short val_nDim, unsigned short val_nVar, const su2double *constants, - su2double val_kine_Inf, su2double val_omega_Inf, CConfig *config) - : CNumerics(val_nDim, val_nVar, config) { +CSourcePieceWise_TurbSST::CSourcePieceWise_TurbSST(unsigned short val_nDim, + unsigned short val_nVar, + const su2double *constants, + su2double val_kine_Inf, + su2double val_omega_Inf, + const CConfig* config) : + CNumerics(val_nDim, val_nVar, config) { - incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); + incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); sustaining_terms = (config->GetKind_Turb_Model() == SST_SUST); /*--- Closure constants ---*/ @@ -827,12 +776,14 @@ CSourcePieceWise_TurbSST::CSourcePieceWise_TurbSST(unsigned short val_nDim, unsi /*--- Set the ambient values of k and omega to the free stream values. ---*/ kAmb = val_kine_Inf; omegaAmb = val_omega_Inf; -} -CSourcePieceWise_TurbSST::~CSourcePieceWise_TurbSST(void) { } + /*--- "Allocate" the Jacobian using the static buffer. ---*/ + Jacobian_i[0] = Jacobian_Buffer; + Jacobian_i[1] = Jacobian_Buffer+2; -void CSourcePieceWise_TurbSST::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, - su2double **val_Jacobian_j, CConfig *config) { +} + +CNumerics::ResidualType<> CSourcePieceWise_TurbSST::ComputeResidual(const CConfig* config) { AD::StartPreacc(); AD::SetPreaccIn(StrainMag_i); @@ -861,9 +812,9 @@ void CSourcePieceWise_TurbSST::ComputeResidual(su2double *val_residual, su2doubl Eddy_Viscosity_i = V_i[nDim+6]; } - val_residual[0] = 0.0; val_residual[1] = 0.0; - val_Jacobian_i[0][0] = 0.0; val_Jacobian_i[0][1] = 0.0; - val_Jacobian_i[1][0] = 0.0; val_Jacobian_i[1][1] = 0.0; + Residual[0] = 0.0; Residual[1] = 0.0; + Jacobian_i[0][0] = 0.0; Jacobian_i[0][1] = 0.0; + Jacobian_i[1][0] = 0.0; Jacobian_i[1][1] = 0.0; /*--- Computation of blended constants for the source terms---*/ @@ -885,7 +836,7 @@ void CSourcePieceWise_TurbSST::ComputeResidual(su2double *val_residual, su2doubl SetPerturbedRSM(TurbVar_i[0], config); SetPerturbedStrainMag(TurbVar_i[0]); pk = Eddy_Viscosity_i*PerturbedStrainMag*PerturbedStrainMag - - 2.0/3.0*Density_i*TurbVar_i[0]*diverg; + - 2.0/3.0*Density_i*TurbVar_i[0]*diverg; } else { pk = Eddy_Viscosity_i*StrainMag_i*StrainMag_i - 2.0/3.0*Density_i*TurbVar_i[0]*diverg; @@ -924,29 +875,31 @@ void CSourcePieceWise_TurbSST::ComputeResidual(su2double *val_residual, su2doubl /*--- Add the production terms to the residuals. ---*/ - val_residual[0] += pk*Volume; - val_residual[1] += pw*Volume; + Residual[0] += pk*Volume; + Residual[1] += pw*Volume; /*--- Dissipation ---*/ - val_residual[0] -= beta_star*Density_i*TurbVar_i[1]*TurbVar_i[0]*Volume; - val_residual[1] -= beta_blended*Density_i*TurbVar_i[1]*TurbVar_i[1]*Volume; + Residual[0] -= beta_star*Density_i*TurbVar_i[1]*TurbVar_i[0]*Volume; + Residual[1] -= beta_blended*Density_i*TurbVar_i[1]*TurbVar_i[1]*Volume; /*--- Cross diffusion ---*/ - val_residual[1] += (1.0 - F1_i)*CDkw_i*Volume; + Residual[1] += (1.0 - F1_i)*CDkw_i*Volume; /*--- Implicit part ---*/ - val_Jacobian_i[0][0] = -beta_star*TurbVar_i[1]*Volume; - val_Jacobian_i[0][1] = -beta_star*TurbVar_i[0]*Volume; - val_Jacobian_i[1][0] = 0.0; - val_Jacobian_i[1][1] = -2.0*beta_blended*TurbVar_i[1]*Volume; + Jacobian_i[0][0] = -beta_star*TurbVar_i[1]*Volume; + Jacobian_i[0][1] = -beta_star*TurbVar_i[0]*Volume; + Jacobian_i[1][0] = 0.0; + Jacobian_i[1][1] = -2.0*beta_blended*TurbVar_i[1]*Volume; } - AD::SetPreaccOut(val_residual, nVar); + AD::SetPreaccOut(Residual, nVar); AD::EndPreacc(); + return ResidualType<>(Residual, Jacobian_i, nullptr); + } void CSourcePieceWise_TurbSST::GetMeanRateOfStrainMatrix(su2double **S_ij) @@ -1010,7 +963,7 @@ void CSourcePieceWise_TurbSST::SetReynoldsStressMatrix(su2double turb_ke){ delete [] S_ij; } -void CSourcePieceWise_TurbSST::SetPerturbedRSM(su2double turb_ke, CConfig *config){ +void CSourcePieceWise_TurbSST::SetPerturbedRSM(su2double turb_ke, const CConfig* config){ unsigned short iDim,jDim; From 4d048a0649d17297ee7a0ff6644bf236ee9a46af Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Mon, 3 Feb 2020 16:50:54 +0000 Subject: [PATCH 081/118] color balancing on coarse grids, config options for edge coloring group size --- Common/include/CConfig.hpp | 7 ++++ Common/include/toolboxes/graph_toolbox.hpp | 39 +++++++++++++++++----- Common/src/CConfig.cpp | 3 ++ Common/src/geometry/CGeometry.cpp | 12 ++----- Common/src/geometry/CPhysicalGeometry.cpp | 16 +++++---- SU2_CFD/include/solvers/CEulerSolver.hpp | 2 +- SU2_CFD/include/solvers/CFEASolver.hpp | 2 +- SU2_CFD/include/solvers/CTurbSolver.hpp | 2 +- SU2_CFD/src/integration_time.cpp | 6 ++-- 9 files changed, 60 insertions(+), 29 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index abebbb85161e..ec4d73deb74a 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -1124,6 +1124,8 @@ class CConfig { string caseName; /*!< \brief Name of the current case */ + unsigned long edgeColorGroupSize; /*!< \brief Size of the edge groups colored for OpenMP parallelization of edge loops. */ + /*! * \brief Set the default values of config options not set in the config file using another config object. * \param config - Config object to use the default values from. @@ -9194,4 +9196,9 @@ class CConfig { */ unsigned long GetLinear_Solver_Prec_Threads(void) const { return Linear_Solver_Prec_Threads; } + /*! + * \brief Get the size of the edge groups colored for OpenMP parallelization of edge loops. + */ + unsigned long GetEdgeColoringGroupSize(void) const { return edgeColorGroupSize; } + }; diff --git a/Common/include/toolboxes/graph_toolbox.hpp b/Common/include/toolboxes/graph_toolbox.hpp index 76dffc1f39ab..2b9adda6ec34 100644 --- a/Common/include/toolboxes/graph_toolbox.hpp +++ b/Common/include/toolboxes/graph_toolbox.hpp @@ -34,6 +34,7 @@ #include #include #include +#include /*! * \enum ConnectivityType @@ -398,11 +399,13 @@ CEdgeToNonZeroMap mapEdgesToSparsePattern(Geometry_t& geometry, * pattern is returned. * \param[in] pattern - Sparse pattern to be colored. * \param[in] groupSize - Size of the outer index groups, default 1. + * \param[in] balanceColors - Try to balance number of indexes per color, + * tends to result in worse locality (thus false by default). * \param[out] indexColor - Optional, vector with colors given to the outer indices. * \return Coloring in the same type of the input pattern. */ template -T colorSparsePattern(const T& pattern, size_t groupSize = 1, +T colorSparsePattern(const T& pattern, size_t groupSize = 1, bool balanceColors = false, std::vector* indexColor = nullptr) { static_assert(std::is_integral::value,""); @@ -423,13 +426,16 @@ T colorSparsePattern(const T& pattern, size_t groupSize = 1, /*--- Start with one color, with no indices assigned. ---*/ std::vector colorSize(1,0); - Color_t color, nColor = 1; + Color_t nColor = 1; { /*--- For each color keep track of the inner indices that are in it. ---*/ std::vector > innerInColor; innerInColor.emplace_back(nInner, false); + /*--- Order in which we look for space in the colors to insert a new group. ---*/ + std::vector searchOrder(MaxColors); + auto outerPtr = pattern.outerPtr(); auto innerIdx = pattern.innerIdx(); @@ -437,23 +443,40 @@ T colorSparsePattern(const T& pattern, size_t groupSize = 1, { Index_t grpEnd = std::min(iOuter+grpSz, nOuter); - for(color = 0; color < nColor; ++color) + searchOrder.resize(nColor); + std::iota(searchOrder.begin(), searchOrder.end(), 0); + + /*--- Balance sizes by looking for space in smaller colors first. ---*/ + if(balanceColors) { + std::sort(searchOrder.begin(), searchOrder.end(), + [&colorSize](Color_t a, Color_t b){return colorSize[a] < colorSize[b];}); + } + + auto it = searchOrder.begin(); + + for(; it != searchOrder.end(); ++it) { bool free = true; /*--- Traverse entire group as a large outer index. ---*/ for(Index_t k = outerPtr[iOuter]; k < outerPtr[grpEnd] && free; ++k) { - free = !innerInColor[color][innerIdx[k]-minIdx]; + free = !innerInColor[*it][innerIdx[k]-minIdx]; } /*--- If none of the inner indices in the group appears in * this color yet, it is assigned to the group. ---*/ if(free) break; } - /*--- No color was free, make space for a new one. ---*/ - if(color == nColor) + Color_t color; + + if(it != searchOrder.end()) { - ++nColor; + /*--- Found a free color. ---*/ + color = *it; + } + else { + /*--- No color was free, make space for a new one. ---*/ + color = nColor++; if(nColor == MaxColors) return T(); colorSize.push_back(0); innerInColor.emplace_back(nInner, false); @@ -480,7 +503,7 @@ T colorSparsePattern(const T& pattern, size_t groupSize = 1, su2vector outerIdx(nOuter); Index_t k = 0; - for(color = 0; color < nColor; ++color) + for(Color_t color = 0; color < nColor; ++color) { colorPtr(color+1) = colorPtr(color)+colorSize[color]; diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index 6c6650d78f2e..d43f29d9c3d6 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -2798,6 +2798,9 @@ void CConfig::SetConfig_Options() { /* DESCRIPTION: Level of fill for PaStiX incomplete LU factorization. */ addUnsignedShortOption("PASTIX_FILL_LEVEL", pastix_fill_lvl, 1); + /* DESCRIPTION: Size of the edge groups colored for OpenMP parallelization of edge loops. */ + addUnsignedLongOption("EDGE_COLORING_GROUP_SIZE", edgeColorGroupSize, 512); + /* END_CONFIG_OPTIONS */ } diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index dac9c80db61c..2afdf84313f2 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -70,13 +70,6 @@ CGeometry::CGeometry(void) { nNewElem_Bound = NULL; Marker_All_SendRecv = NULL; - XCoordList.clear(); - Xcoord_plane.clear(); - Ycoord_plane.clear(); - Zcoord_plane.clear(); - FaceArea_plane.clear(); - Plane_points.clear(); - /*--- Arrays for defining the linear partitioning ---*/ beg_node = NULL; @@ -4057,8 +4050,9 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(void) CCompressedSparsePatternUL pattern(move(outerPtr), move(innerIdx)); - /*--- Color the edges. ---*/ - edgeColoring = colorSparsePattern(pattern, edgeColorGroupSize); + /*--- Color the edges, only balance sizes on coarse levels. ---*/ + bool balanceColors = (MGLevel != MESH_0); + edgeColoring = colorSparsePattern(pattern, edgeColorGroupSize, balanceColors); if(edgeColoring.empty()) SU2_MPI::Error("Edge coloring failed.", CURRENT_FUNCTION); diff --git a/Common/src/geometry/CPhysicalGeometry.cpp b/Common/src/geometry/CPhysicalGeometry.cpp index ad15b62ee425..8d074e63b2b4 100644 --- a/Common/src/geometry/CPhysicalGeometry.cpp +++ b/Common/src/geometry/CPhysicalGeometry.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -124,6 +124,8 @@ CPhysicalGeometry::CPhysicalGeometry(CConfig *config, unsigned short val_iZone, #endif #endif + edgeColorGroupSize = config->GetEdgeColoringGroupSize(); + /*--- Arrays for defining the turbomachinery structure ---*/ nSpanWiseSections = NULL; @@ -311,6 +313,8 @@ CPhysicalGeometry::CPhysicalGeometry(CGeometry *geometry, #endif #endif + edgeColorGroupSize = config->GetEdgeColoringGroupSize(); + /*--- Arrays for defining the turbomachinery structure ---*/ nSpanWiseSections = NULL; @@ -7985,11 +7989,11 @@ void CPhysicalGeometry::MatchPeriodic(CConfig *config, su2double rotMatrix[3][3] = {{1.0,0.0,0.0},{0.0,1.0,0.0},{0.0,0.0,1.0}}; su2double Theta, Phi, Psi, cosTheta, sinTheta, cosPhi, sinPhi, cosPsi, sinPsi; su2double rotCoord[3] = {0.0, 0.0, 0.0}; - + bool pointOnAxis = false; - + bool chkSamePoint = false; - + su2double distToAxis = 0.0; /*--- Tolerance for distance-based match to report warning. ---*/ @@ -8199,7 +8203,7 @@ void CPhysicalGeometry::MatchPeriodic(CConfig *config, rotMatrix[2][1]*dy + rotMatrix[2][2]*dz + translation[2]); - /*--- Check if the point lies on the axis of rotation. If it does, + /*--- Check if the point lies on the axis of rotation. If it does, the rotated coordinate and the original coordinate are the same. ---*/ pointOnAxis = false; @@ -8254,7 +8258,7 @@ void CPhysicalGeometry::MatchPeriodic(CConfig *config, and also perform checks just to be sure that this is an independent periodic point (even if on the same rank), unless it lies on the axis of rotation. ---*/ - + chkSamePoint = false; chkSamePoint = (((dist < mindist) && (iProcessor != rank)) || ((dist < mindist) && (iProcessor == rank) && diff --git a/SU2_CFD/include/solvers/CEulerSolver.hpp b/SU2_CFD/include/solvers/CEulerSolver.hpp index 9e80ebb20409..86fd772ff096 100644 --- a/SU2_CFD/include/solvers/CEulerSolver.hpp +++ b/SU2_CFD/include/solvers/CEulerSolver.hpp @@ -43,7 +43,7 @@ class CEulerSolver : public CSolver { enum : size_t {MAXNVAR = 12}; /*!< \brief Max number of variables, used in some static arrays. */ enum : size_t {OMP_MAX_SIZE = 512}; /*!< \brief Max chunk size for light point loops. */ - enum : size_t {OMP_MIN_SIZE = 128}; /*!< \brief Min chunk size for edge loops (max is color group size). */ + enum : size_t {OMP_MIN_SIZE = 32}; /*!< \brief Min chunk size for edge loops (max is color group size). */ unsigned long omp_chunk_size; /*!< \brief Chunk size used in light point loops. */ diff --git a/SU2_CFD/include/solvers/CFEASolver.hpp b/SU2_CFD/include/solvers/CFEASolver.hpp index 742573eb56d4..da76e495bb91 100644 --- a/SU2_CFD/include/solvers/CFEASolver.hpp +++ b/SU2_CFD/include/solvers/CFEASolver.hpp @@ -38,7 +38,7 @@ class CFEASolver : public CSolver { protected: enum : size_t {MAXNNODE = 8}; enum : size_t {MAXNVAR = 3}; - enum : size_t {OMP_MIN_SIZE = 64}; + enum : size_t {OMP_MIN_SIZE = 32}; enum : size_t {OMP_MAX_SIZE = 512}; unsigned long omp_chunk_size; /*!< \brief Chunk size used in light point loops. */ diff --git a/SU2_CFD/include/solvers/CTurbSolver.hpp b/SU2_CFD/include/solvers/CTurbSolver.hpp index 58f8e1256611..e2117c1d0269 100644 --- a/SU2_CFD/include/solvers/CTurbSolver.hpp +++ b/SU2_CFD/include/solvers/CTurbSolver.hpp @@ -43,7 +43,7 @@ class CTurbSolver : public CSolver { enum : size_t {MAXNVARFLOW = 12}; /*!< \brief Max number of flow variables, used in some static arrays. */ enum : size_t {OMP_MAX_SIZE = 512}; /*!< \brief Max chunk size for light point loops. */ - enum : size_t {OMP_MIN_SIZE = 128}; /*!< \brief Min chunk size for edge loops (max is color group size). */ + enum : size_t {OMP_MIN_SIZE = 32}; /*!< \brief Min chunk size for edge loops (max is color group size). */ unsigned long omp_chunk_size; /*!< \brief Chunk size used in light point loops. */ diff --git a/SU2_CFD/src/integration_time.cpp b/SU2_CFD/src/integration_time.cpp index 40058283a689..f4a7a87fdab4 100644 --- a/SU2_CFD/src/integration_time.cpp +++ b/SU2_CFD/src/integration_time.cpp @@ -85,9 +85,9 @@ void CMultiGridIntegration::MultiGrid_Iteration(CGeometry ****geometry, /*--- Computes primitive variables and gradients in the finest mesh (useful for the next solver (turbulence) and output ---*/ - solver_container[iZone][iInst][MESH_0][SolContainer_Position]->Preprocessing(geometry[iZone][iInst][MESH_0], - solver_container[iZone][iInst][MESH_0], config[iZone], - MESH_0, NO_RK_ITER, RunTime_EqSystem, true); + solver_container[iZone][iInst][MESH_0][SolContainer_Position]->Preprocessing(geometry[iZone][iInst][MESH_0], + solver_container[iZone][iInst][MESH_0], config[iZone], + MESH_0, NO_RK_ITER, RunTime_EqSystem, true); /*--- Compute non-dimensional parameters and the convergence monitor ---*/ From d3c016fc9dfefd37c4c52e1fcb1555bdb318847a Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Mon, 3 Feb 2020 17:04:59 +0000 Subject: [PATCH 082/118] more ctor cleanup --- SU2_CFD/src/solvers/CEulerSolver.cpp | 8 ++---- SU2_CFD/src/solvers/CNSSolver.cpp | 38 ++++++++++++---------------- 2 files changed, 18 insertions(+), 28 deletions(-) diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 47cd4e1ea8fb..32bede1c66e4 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -191,15 +191,11 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short /*--- Define some auxiliary vectors related to the solution ---*/ - Solution = new su2double[nVar](); - Solution_i = new su2double[nVar](); - Solution_j = new su2double[nVar](); + Solution = new su2double[nVar](); /*--- Define some auxiliary vectors related to the geometry ---*/ - Vector = new su2double[nDim](); - Vector_i = new su2double[nDim](); - Vector_j = new su2double[nDim](); + Vector = new su2double[nDim](); /*--- Define some auxiliary vectors related to the undivided lapalacian ---*/ diff --git a/SU2_CFD/src/solvers/CNSSolver.cpp b/SU2_CFD/src/solvers/CNSSolver.cpp index 5d023707b2e2..e7cc96e80d63 100644 --- a/SU2_CFD/src/solvers/CNSSolver.cpp +++ b/SU2_CFD/src/solvers/CNSSolver.cpp @@ -132,35 +132,30 @@ CNSSolver::CNSSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) /*--- Define some auxiliar vector related with 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; - Residual_Max = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) Residual_Max[iVar] = 0.0; - Residual_i = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) Residual_i[iVar] = 0.0; - Residual_j = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) Residual_j[iVar] = 0.0; - Res_Conv = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) Res_Conv[iVar] = 0.0; - Res_Visc = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) Res_Visc[iVar] = 0.0; - Res_Sour = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) Res_Sour[iVar] = 0.0; + Residual = new su2double[nVar](); + Residual_RMS = new su2double[nVar](); + Residual_Max = new su2double[nVar](); + Residual_i = new su2double[nVar](); + Residual_j = new su2double[nVar](); + Res_Conv = new su2double[nVar](); + Res_Visc = new su2double[nVar](); + Res_Sour = new su2double[nVar](); /*--- Define some structures for locating max residuals ---*/ - Point_Max = new unsigned long[nVar]; for (iVar = 0; iVar < nVar; iVar++) Point_Max[iVar] = 0; + Point_Max = new unsigned long[nVar]; Point_Max_Coord = new su2double*[nVar]; for (iVar = 0; iVar < nVar; iVar++) { - Point_Max_Coord[iVar] = new su2double[nDim]; - for (iDim = 0; iDim < nDim; iDim++) Point_Max_Coord[iVar][iDim] = 0.0; + Point_Max_Coord[iVar] = new su2double[nDim](); } /*--- Define some auxiliary vectors related to the solution ---*/ - Solution = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) Solution[iVar] = 0.0; - Solution_i = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) Solution_i[iVar] = 0.0; - Solution_j = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) Solution_j[iVar] = 0.0; + Solution = new su2double[nVar](); /*--- Define some auxiliary vectors related to the geometry ---*/ - Vector = new su2double[nDim]; for (iDim = 0; iDim < nDim; iDim++) Vector[iDim] = 0.0; - Vector_i = new su2double[nDim]; for (iDim = 0; iDim < nDim; iDim++) Vector_i[iDim] = 0.0; - Vector_j = new su2double[nDim]; for (iDim = 0; iDim < nDim; iDim++) Vector_j[iDim] = 0.0; + Vector = new su2double[nDim](); /*--- Define some auxiliar vector related with the undivided lapalacian computation ---*/ @@ -508,16 +503,15 @@ CNSSolver::CNSSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) /*--- Initialize the BGS residuals in FSI problems. ---*/ if (config->GetMultizone_Residual()){ - Residual_BGS = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) Residual_BGS[iVar] = 1.0; - Residual_Max_BGS = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) Residual_Max_BGS[iVar] = 1.0; + Residual_BGS = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) Residual_BGS[iVar] = 1.0; + Residual_Max_BGS = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) Residual_Max_BGS[iVar] = 1.0; /*--- Define some structures for locating max residuals ---*/ - Point_Max_BGS = new unsigned long[nVar]; for (iVar = 0; iVar < nVar; iVar++) Point_Max_BGS[iVar] = 0; + Point_Max_BGS = new unsigned long[nVar](); Point_Max_Coord_BGS = new su2double*[nVar]; for (iVar = 0; iVar < nVar; iVar++) { - Point_Max_Coord_BGS[iVar] = new su2double[nDim]; - for (iDim = 0; iDim < nDim; iDim++) Point_Max_Coord_BGS[iVar][iDim] = 0.0; + Point_Max_Coord_BGS[iVar] = new su2double[nDim](); } } From ded9c08e90496634a38b4998d9fe7aa5b72cdcc3 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Mon, 3 Feb 2020 17:37:36 +0000 Subject: [PATCH 083/118] fix #857 --- Common/include/omp_structure.hpp | 1 + Common/src/geometry/CGeometry.cpp | 4 ++-- SU2_CFD/src/solvers/CEulerSolver.cpp | 13 +++++++------ SU2_CFD/src/solvers/CFEASolver.cpp | 13 +++++++------ SU2_CFD/src/solvers/CMeshSolver.cpp | 13 +++++++------ SU2_CFD/src/solvers/CNSSolver.cpp | 13 +++++++------ SU2_CFD/src/solvers/CTurbSolver.cpp | 13 +++++++------ 7 files changed, 38 insertions(+), 32 deletions(-) diff --git a/Common/include/omp_structure.hpp b/Common/include/omp_structure.hpp index 3f0c85419bc5..c9ba9976bcf1 100644 --- a/Common/include/omp_structure.hpp +++ b/Common/include/omp_structure.hpp @@ -118,6 +118,7 @@ inline size_t computeStaticChunkSize(size_t totalWork, size_t numThreads, size_t maxChunkSize) { + if(!totalWork) return maxChunkSize; size_t workPerThread = roundUpDiv(totalWork, numThreads); size_t chunksPerThread = roundUpDiv(workPerThread, maxChunkSize); return roundUpDiv(workPerThread, chunksPerThread); diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index 2afdf84313f2..fa7c1a252bfa 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -4035,7 +4035,7 @@ const CEdgeToNonZeroMapUL& CGeometry::GetEdgeToSparsePatternMap(void) const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(void) { - if (edgeColoring.empty()) { + if (edgeColoring.empty() && nEdge) { /*--- Create a temporary sparse pattern from the edges. ---*/ /// TODO: Try to avoid temporary once grid information is made contiguous. su2vector outerPtr(nEdge+1); @@ -4062,7 +4062,7 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(void) const CCompressedSparsePatternUL& CGeometry::GetElementColoring(void) { - if (elemColoring.empty()) { + if (elemColoring.empty() && nElem) { /*--- Create a temporary sparse pattern from the elements. ---*/ /// TODO: Try to avoid temporary once grid information is made contiguous. vector outerPtr(nElem+1); diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 32bede1c66e4..26d4a5fa8293 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -420,14 +420,15 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short const auto& coloring = geometry->GetEdgeColoring(); - auto nColor = coloring.getOuterSize(); - EdgeColoring.resize(nColor); + if (!coloring.empty()) { + auto nColor = coloring.getOuterSize(); + EdgeColoring.resize(nColor); - for(auto iColor = 0ul; iColor < nColor; ++iColor) { - EdgeColoring[iColor].size = coloring.getNumNonZeros(iColor); - EdgeColoring[iColor].indices = coloring.innerIdx(iColor); + for(auto iColor = 0ul; iColor < nColor; ++iColor) { + EdgeColoring[iColor].size = coloring.getNumNonZeros(iColor); + EdgeColoring[iColor].indices = coloring.innerIdx(iColor); + } } - ColorGroupSize = geometry->GetEdgeColorGroupSize(); omp_chunk_size = computeStaticChunkSize(nPoint, omp_get_max_threads(), OMP_MAX_SIZE); diff --git a/SU2_CFD/src/solvers/CFEASolver.cpp b/SU2_CFD/src/solvers/CFEASolver.cpp index 259f7bfa01fa..673f85e3e04a 100644 --- a/SU2_CFD/src/solvers/CFEASolver.cpp +++ b/SU2_CFD/src/solvers/CFEASolver.cpp @@ -246,14 +246,15 @@ CFEASolver::CFEASolver(CGeometry *geometry, CConfig *config) : CSolver() { const auto& coloring = geometry->GetElementColoring(); - auto nColor = coloring.getOuterSize(); - ElemColoring.resize(nColor); + if (!coloring.empty()) { + auto nColor = coloring.getOuterSize(); + ElemColoring.resize(nColor); - for(auto iColor = 0ul; iColor < nColor; ++iColor) { - ElemColoring[iColor].size = coloring.getNumNonZeros(iColor); - ElemColoring[iColor].indices = coloring.innerIdx(iColor); + for(auto iColor = 0ul; iColor < nColor; ++iColor) { + ElemColoring[iColor].size = coloring.getNumNonZeros(iColor); + ElemColoring[iColor].indices = coloring.innerIdx(iColor); + } } - ColorGroupSize = geometry->GetElementColorGroupSize(); omp_chunk_size = computeStaticChunkSize(nPointDomain, omp_get_max_threads(), OMP_MAX_SIZE); diff --git a/SU2_CFD/src/solvers/CMeshSolver.cpp b/SU2_CFD/src/solvers/CMeshSolver.cpp index 5e95a649e564..7cde555d4ac7 100644 --- a/SU2_CFD/src/solvers/CMeshSolver.cpp +++ b/SU2_CFD/src/solvers/CMeshSolver.cpp @@ -105,14 +105,15 @@ CMeshSolver::CMeshSolver(CGeometry *geometry, CConfig *config) : CFEASolver(true const auto& coloring = geometry->GetElementColoring(); - auto nColor = coloring.getOuterSize(); - ElemColoring.resize(nColor); + if (!coloring.empty()) { + auto nColor = coloring.getOuterSize(); + ElemColoring.resize(nColor); - for(auto iColor = 0ul; iColor < nColor; ++iColor) { - ElemColoring[iColor].size = coloring.getNumNonZeros(iColor); - ElemColoring[iColor].indices = coloring.innerIdx(iColor); + for(auto iColor = 0ul; iColor < nColor; ++iColor) { + ElemColoring[iColor].size = coloring.getNumNonZeros(iColor); + ElemColoring[iColor].indices = coloring.innerIdx(iColor); + } } - ColorGroupSize = geometry->GetElementColorGroupSize(); omp_chunk_size = computeStaticChunkSize(nPointDomain, omp_get_max_threads(), OMP_MAX_SIZE); diff --git a/SU2_CFD/src/solvers/CNSSolver.cpp b/SU2_CFD/src/solvers/CNSSolver.cpp index e7cc96e80d63..c5fcf5c0e021 100644 --- a/SU2_CFD/src/solvers/CNSSolver.cpp +++ b/SU2_CFD/src/solvers/CNSSolver.cpp @@ -446,14 +446,15 @@ CNSSolver::CNSSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) const auto& coloring = geometry->GetEdgeColoring(); - auto nColor = coloring.getOuterSize(); - EdgeColoring.resize(nColor); + if (!coloring.empty()) { + auto nColor = coloring.getOuterSize(); + EdgeColoring.resize(nColor); - for(auto iColor = 0ul; iColor < nColor; ++iColor) { - EdgeColoring[iColor].size = coloring.getNumNonZeros(iColor); - EdgeColoring[iColor].indices = coloring.innerIdx(iColor); + for(auto iColor = 0ul; iColor < nColor; ++iColor) { + EdgeColoring[iColor].size = coloring.getNumNonZeros(iColor); + EdgeColoring[iColor].indices = coloring.innerIdx(iColor); + } } - ColorGroupSize = geometry->GetEdgeColorGroupSize(); omp_chunk_size = computeStaticChunkSize(nPoint, omp_get_max_threads(), OMP_MAX_SIZE); diff --git a/SU2_CFD/src/solvers/CTurbSolver.cpp b/SU2_CFD/src/solvers/CTurbSolver.cpp index 73f712f6f104..c096c7051c73 100644 --- a/SU2_CFD/src/solvers/CTurbSolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSolver.cpp @@ -52,14 +52,15 @@ CTurbSolver::CTurbSolver(CGeometry* geometry, CConfig *config) : CSolver() { const auto& coloring = geometry->GetEdgeColoring(); - auto nColor = coloring.getOuterSize(); - EdgeColoring.resize(nColor); + if (!coloring.empty()) { + auto nColor = coloring.getOuterSize(); + EdgeColoring.resize(nColor); - for(auto iColor = 0ul; iColor < nColor; ++iColor) { - EdgeColoring[iColor].size = coloring.getNumNonZeros(iColor); - EdgeColoring[iColor].indices = coloring.innerIdx(iColor); + for(auto iColor = 0ul; iColor < nColor; ++iColor) { + EdgeColoring[iColor].size = coloring.getNumNonZeros(iColor); + EdgeColoring[iColor].indices = coloring.innerIdx(iColor); + } } - ColorGroupSize = geometry->GetEdgeColorGroupSize(); nPoint = geometry->GetnPoint(); From f14ba270b1f3766db68774668ba4315ed239d29b Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Tue, 4 Feb 2020 10:55:01 +0000 Subject: [PATCH 084/118] natural coloring when running single threaded --- Common/include/toolboxes/graph_toolbox.hpp | 24 ++++++++++++++++++++++ Common/src/geometry/CGeometry.cpp | 14 +++++++++++++ 2 files changed, 38 insertions(+) diff --git a/Common/include/toolboxes/graph_toolbox.hpp b/Common/include/toolboxes/graph_toolbox.hpp index 2b9adda6ec34..a18848991716 100644 --- a/Common/include/toolboxes/graph_toolbox.hpp +++ b/Common/include/toolboxes/graph_toolbox.hpp @@ -518,3 +518,27 @@ T colorSparsePattern(const T& pattern, size_t groupSize = 1, bool balanceColors /*--- Move compressed coloring into result pattern instance. ---*/ return T(std::move(colorPtr), std::move(outerIdx)); } + + +/*! + * \brief Create the natural coloring (equivalent to the normal sequential loop + * order) for a given number of inner indexes. + * \note This is to reduce overhead in "OpenMP-ready" code when only 1 thread is used. + * \param[in] numInnerIndexes - Number of indexes that are to be colored. + * \return Natural (sequential) coloring of the inner indices. + */ +template +T createNaturalColoring(Index_t numInnerIndexes) +{ + /*--- One color. ---*/ + su2vector outerPtr(2); + outerPtr(0) = 0; + outerPtr(1) = numInnerIndexes; + + /*--- Containing all indexes in ascending order. ---*/ + su2vector innerIdx(numInnerIndexes); + std::iota(innerIdx.data(), innerIdx.data()+numInnerIndexes, 0); + + return T(std::move(outerPtr), std::move(innerIdx)); +} diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index fa7c1a252bfa..77cc01e9d33f 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -4036,6 +4036,13 @@ const CEdgeToNonZeroMapUL& CGeometry::GetEdgeToSparsePatternMap(void) const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(void) { if (edgeColoring.empty() && nEdge) { + + /*--- When not using threading use the natural coloring. ---*/ + if (omp_get_max_threads() == 1) { + edgeColoring = createNaturalColoring(nEdge); + return edgeColoring; + } + /*--- Create a temporary sparse pattern from the edges. ---*/ /// TODO: Try to avoid temporary once grid information is made contiguous. su2vector outerPtr(nEdge+1); @@ -4063,6 +4070,13 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(void) const CCompressedSparsePatternUL& CGeometry::GetElementColoring(void) { if (elemColoring.empty() && nElem) { + + /*--- When not using threading use the natural coloring. ---*/ + if (omp_get_max_threads() == 1) { + elemColoring = createNaturalColoring(nElem); + return elemColoring; + } + /*--- Create a temporary sparse pattern from the elements. ---*/ /// TODO: Try to avoid temporary once grid information is made contiguous. vector outerPtr(nElem+1); From 810f8b481b4f09c18a83e66bd92220b86cd22096 Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Tue, 4 Feb 2020 11:25:01 +0000 Subject: [PATCH 085/118] transform the edge loop in SetTimeStep to point loop --- SU2_CFD/src/integration_time.cpp | 2 +- SU2_CFD/src/solvers/CEulerSolver.cpp | 98 ++++++++++++---------------- 2 files changed, 43 insertions(+), 57 deletions(-) diff --git a/SU2_CFD/src/integration_time.cpp b/SU2_CFD/src/integration_time.cpp index f4a7a87fdab4..1272674eed47 100644 --- a/SU2_CFD/src/integration_time.cpp +++ b/SU2_CFD/src/integration_time.cpp @@ -108,7 +108,7 @@ void CMultiGridIntegration::MultiGrid_Cycle(CGeometry ****geometry, unsigned short iInst) { unsigned short iPreSmooth, iPostSmooth, iRKStep, iRKLimit = 1; - unsigned short SolContainer_Position = config[iZone]->GetContainerPosition(RunTime_EqSystem); + unsigned short SolContainer_Position = config[iZone]->GetContainerPosition(RunTime_EqSystem); /*--- Do a presmoothing on the grid iMesh to be restricted to the grid iMesh+1 ---*/ diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 26d4a5fa8293..2f5c6124f3c3 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -2642,84 +2642,69 @@ void CEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, unsigned long iEdge, iVertex, iPoint, jPoint; unsigned short iDim, iMarker; - /*--- Set maximum eigenvalues to zero. ---*/ + /*--- Loop domain points. ---*/ - SU2_OMP(for schedule(static,omp_chunk_size) nowait) - for (iPoint = 0; iPoint < nPointDomain; iPoint++) - nodes->SetMax_Lambda_Inv(iPoint,0.0); + SU2_OMP_FOR_DYN(omp_chunk_size) + for (iPoint = 0; iPoint < nPointDomain; ++iPoint) { - if (viscous) { - SU2_OMP(for schedule(static,omp_chunk_size) nowait) - for (iPoint = 0; iPoint < nPointDomain; iPoint++) - nodes->SetMax_Lambda_Visc(iPoint,0.0); - } - SU2_OMP_BARRIER + auto node_i = geometry->node[iPoint]; - /*--- Loop interior edges ---*/ + /*--- Set maximum eigenvalues to zero. ---*/ -#ifdef HAVE_OMP - /*--- Chunk size is at least OMP_MIN_SIZE and a multiple of the color group size. ---*/ - auto chunkSize = roundUpDiv(OMP_MIN_SIZE, ColorGroupSize)*ColorGroupSize; + nodes->SetMax_Lambda_Inv(iPoint,0.0); - /*--- Loop over edge colors. ---*/ - for (auto color : EdgeColoring) - { - SU2_OMP_FOR_DYN(chunkSize) - for(auto k = 0ul; k < color.size; ++k) { + if (viscous) + nodes->SetMax_Lambda_Visc(iPoint,0.0); - iEdge = color.indices[k]; -#else - /*--- Natural coloring. ---*/ - { - for (iEdge = 0; iEdge < geometry->GetnEdge(); iEdge++) { -#endif - /*--- Point identification, Normal vector and area ---*/ + /*--- Loop over the neighbors of point i. ---*/ - iPoint = geometry->edge[iEdge]->GetNode(0); - jPoint = geometry->edge[iEdge]->GetNode(1); + for (unsigned short iNeigh = 0; iNeigh < node_i->GetnPoint(); ++iNeigh) + { + jPoint = node_i->GetPoint(iNeigh); + auto node_j = geometry->node[jPoint]; - Normal = geometry->edge[iEdge]->GetNormal(); - Area = 0.0; for (iDim = 0; iDim < nDim; iDim++) Area += pow(Normal[iDim],2); Area = sqrt(Area); + iEdge = node_i->GetEdge(iNeigh); + Normal = geometry->edge[iEdge]->GetNormal(); + Area = 0.0; for (iDim = 0; iDim < nDim; iDim++) Area += pow(Normal[iDim],2); Area = sqrt(Area); - /*--- Mean Values ---*/ + /*--- Mean Values ---*/ - Mean_ProjVel = 0.5 * (nodes->GetProjVel(iPoint,Normal) + nodes->GetProjVel(jPoint,Normal)); - Mean_SoundSpeed = 0.5 * (nodes->GetSoundSpeed(iPoint) + nodes->GetSoundSpeed(jPoint)) * 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 ---*/ + /*--- Adjustment for grid movement ---*/ - if (dynamic_grid) { - const su2double *GridVel_i = geometry->node[iPoint]->GetGridVel(); - const su2double *GridVel_j = geometry->node[jPoint]->GetGridVel(); + if (dynamic_grid) { + const su2double *GridVel_i = node_i->GetGridVel(); + const su2double *GridVel_j = node_j->GetGridVel(); - for (iDim = 0; iDim < nDim; iDim++) - Mean_ProjVel -= 0.5 * (GridVel_i[iDim] + GridVel_j[iDim]) * Normal[iDim]; - } + for (iDim = 0; iDim < nDim; iDim++) + Mean_ProjVel -= 0.5 * (GridVel_i[iDim] + GridVel_j[iDim]) * Normal[iDim]; + } - /*--- Inviscid contribution ---*/ + /*--- Inviscid contribution ---*/ - Lambda = fabs(Mean_ProjVel) + Mean_SoundSpeed ; - if (geometry->node[iPoint]->GetDomain()) nodes->AddMax_Lambda_Inv(iPoint,Lambda); - if (geometry->node[jPoint]->GetDomain()) nodes->AddMax_Lambda_Inv(jPoint,Lambda); + Lambda = fabs(Mean_ProjVel) + Mean_SoundSpeed ; + nodes->AddMax_Lambda_Inv(iPoint,Lambda); - /*--- Viscous contribution ---*/ + /*--- Viscous contribution ---*/ + + if (!viscous) continue; - if (!viscous) continue; + 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_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_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; + Lambda = (Lambda_1 + Lambda_2)*Area*Area/Mean_Density; + nodes->AddMax_Lambda_Visc(iPoint, Lambda); - if (geometry->node[iPoint]->GetDomain()) nodes->AddMax_Lambda_Visc(iPoint, Lambda); - if (geometry->node[jPoint]->GetDomain()) nodes->AddMax_Lambda_Visc(jPoint, Lambda); + } } - } // end color loop /*--- Loop boundary edges ---*/ @@ -3621,6 +3606,7 @@ void CEulerSolver::SetUndivided_Laplacian(CGeometry *geometry, CConfig *config) /// TODO: Add worksharing to SetUnd_LaplZero and co. SU2_OMP_MASTER nodes->SetUnd_LaplZero(); + SU2_OMP_BARRIER /*--- Loop interior edges ---*/ From 93eb726686587a9bfe6a87364492c4781d534713 Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Tue, 4 Feb 2020 11:30:53 +0000 Subject: [PATCH 086/118] make SetMax_Eigenvalue a point loop --- SU2_CFD/src/solvers/CEulerSolver.cpp | 72 +++++++++++----------------- 1 file changed, 27 insertions(+), 45 deletions(-) diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 2f5c6124f3c3..84aaa7688741 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -2701,7 +2701,6 @@ void CEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, Lambda = (Lambda_1 + Lambda_2)*Area*Area/Mean_Density; nodes->AddMax_Lambda_Visc(iPoint, Lambda); - } } @@ -3478,65 +3477,48 @@ void CEulerSolver::SetMax_Eigenvalue(CGeometry *geometry, CConfig *config) { SU2_OMP_PARALLEL { - /*--- Set maximum inviscid eigenvalue to zero, and compute sound speed ---*/ - - SU2_OMP_FOR_STAT(omp_chunk_size) - for (unsigned long iPoint = 0; iPoint < nPointDomain; iPoint++) { - nodes->SetLambda(iPoint,0.0); - } - /*--- Loop interior edges ---*/ + /*--- Loop domain points. ---*/ -#ifdef HAVE_OMP - /*--- Chunk size is at least OMP_MIN_SIZE and a multiple of the color group size. ---*/ - auto chunkSize = roundUpDiv(OMP_MIN_SIZE, ColorGroupSize)*ColorGroupSize; + SU2_OMP_FOR_DYN(omp_chunk_size) + for (unsigned long iPoint = 0; iPoint < nPointDomain; ++iPoint) { - /*--- Loop over edge colors. ---*/ - for (auto color : EdgeColoring) - { - SU2_OMP_FOR_STAT(chunkSize) - for(auto k = 0ul; k < color.size; ++k) { + /*--- Set eigenvalues to zero. ---*/ + nodes->SetLambda(iPoint,0.0); - auto iEdge = color.indices[k]; -#else - /*--- Natural coloring. ---*/ - { - for (auto iEdge = 0ul; iEdge < geometry->GetnEdge(); iEdge++) { -#endif - /*--- Point identification, Normal vector and area ---*/ + /*--- Loop over the neighbors of point i. ---*/ + for (unsigned short iNeigh = 0; iNeigh < geometry->node[iPoint]->GetnPoint(); ++iNeigh) + { + auto jPoint = geometry->node[iPoint]->GetPoint(iNeigh); - auto iPoint = geometry->edge[iEdge]->GetNode(0); - auto jPoint = geometry->edge[iEdge]->GetNode(1); + auto iEdge = geometry->node[iPoint]->GetEdge(iNeigh); + auto Normal = geometry->edge[iEdge]->GetNormal(); + su2double Area = 0.0; + for (unsigned short iDim = 0; iDim < nDim; iDim++) Area += pow(Normal[iDim],2); + Area = sqrt(Area); - auto Normal = geometry->edge[iEdge]->GetNormal(); - su2double Area = 0.0; - for (unsigned short iDim = 0; iDim < nDim; iDim++) - Area += pow(Normal[iDim],2); - Area = sqrt(Area); + /*--- Mean Values ---*/ - /*--- Mean Values ---*/ + su2double Mean_ProjVel = 0.5 * (nodes->GetProjVel(iPoint,Normal) + nodes->GetProjVel(jPoint,Normal)); + su2double Mean_SoundSpeed = 0.5 * (nodes->GetSoundSpeed(iPoint) + nodes->GetSoundSpeed(jPoint)) * Area; - su2double Mean_ProjVel = 0.5 * (nodes->GetProjVel(iPoint,Normal) + nodes->GetProjVel(jPoint,Normal)); - su2double Mean_SoundSpeed = 0.5 * (nodes->GetSoundSpeed(iPoint) + nodes->GetSoundSpeed(jPoint)) * Area; + /*--- Adjustment for grid movement ---*/ - /*--- Adjustment for grid movement ---*/ + if (dynamic_grid) { + const su2double *GridVel_i = geometry->node[iPoint]->GetGridVel(); + const su2double *GridVel_j = geometry->node[jPoint]->GetGridVel(); - if (dynamic_grid) { - auto GridVel_i = geometry->node[iPoint]->GetGridVel(); - auto GridVel_j = geometry->node[jPoint]->GetGridVel(); - for (unsigned short iDim = 0; iDim < nDim; iDim++) { - Mean_ProjVel -= 0.5 * (GridVel_i[iDim] + GridVel_j[iDim])*Normal[iDim]; + for (unsigned short iDim = 0; iDim < nDim; iDim++) + Mean_ProjVel -= 0.5 * (GridVel_i[iDim] + GridVel_j[iDim]) * Normal[iDim]; } - } - /*--- Inviscid contribution ---*/ + /*--- Inviscid contribution ---*/ - su2double Lambda = fabs(Mean_ProjVel) + Mean_SoundSpeed; - if (geometry->node[iPoint]->GetDomain()) nodes->AddLambda(iPoint, Lambda); - if (geometry->node[jPoint]->GetDomain()) nodes->AddLambda(jPoint, Lambda); + su2double Lambda = fabs(Mean_ProjVel) + Mean_SoundSpeed ; + nodes->AddLambda(iPoint, Lambda); + } } - } // end color loop /*--- Loop boundary edges ---*/ From 3fd3d241becd64b171962301add3beef9821c9a5 Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Tue, 4 Feb 2020 14:16:33 +0000 Subject: [PATCH 087/118] reducer strategy on coarse grids (coloring fails too often) --- Common/include/linear_algebra/CSysMatrix.hpp | 39 +++++++ Common/src/geometry/CGeometry.cpp | 2 +- Common/src/linear_algebra/CSysMatrix.cpp | 30 +++++ SU2_CFD/include/solvers/CEulerSolver.hpp | 8 ++ SU2_CFD/include/solvers/CNSSolver.hpp | 14 ++- SU2_CFD/src/solvers/CEulerSolver.cpp | 113 ++++++++++++++++--- SU2_CFD/src/solvers/CNSSolver.cpp | 98 +++++++--------- 7 files changed, 225 insertions(+), 79 deletions(-) diff --git a/Common/include/linear_algebra/CSysMatrix.hpp b/Common/include/linear_algebra/CSysMatrix.hpp index 88dedb0b9e75..e9c3099df766 100644 --- a/Common/include/linear_algebra/CSysMatrix.hpp +++ b/Common/include/linear_algebra/CSysMatrix.hpp @@ -95,6 +95,7 @@ class CSysMatrix { const unsigned long *row_ptr; /*!< \brief Pointers to the first element in each row. */ const unsigned long *dia_ptr; /*!< \brief Pointers to the diagonal element in each row. */ const unsigned long *col_ind; /*!< \brief Column index for each of the elements in val(). */ + vector col_ptr; /*!< \brief The transpose of col_ind, pointer to blocks with the same column index. */ ScalarType *ILU_matrix; /*!< \brief Entries of the ILU sparse matrix. */ unsigned long nnz_ilu; /*!< \brief Number of possible nonzero entries in the matrix (ILU). */ @@ -579,6 +580,39 @@ class CSysMatrix { UpdateBlocks(iEdge, iPoint, jPoint, block_i, block_j); } + /*! + * \brief Update 2 blocks ij and ji (add to i* sub from j*). + * \note The template parameter Sign, can be used create a "subtractive" + * update i.e. subtract from row i and add to row j instead. + * \param[in] edge - Index of edge that connects iPoint and jPoint. + * \param[in] block_i - Subs from ji. + * \param[in] block_j - Adds to ij. + */ + template + inline void UpdateBlocks(unsigned long iEdge, const OtherType* const* block_i, const OtherType* const* block_j) { + + ScalarType *bij = &matrix[edge_ptr(iEdge,0)*nVar*nEqn]; + ScalarType *bji = &matrix[edge_ptr(iEdge,1)*nVar*nEqn]; + + unsigned long iVar, jVar, offset = 0; + + for (iVar = 0; iVar < nVar; iVar++) { + for (jVar = 0; jVar < nEqn; jVar++) { + bij[offset] += PassiveAssign(block_j[iVar][jVar]) * Sign; + bji[offset] -= PassiveAssign(block_i[iVar][jVar]) * Sign; + ++offset; + } + } + } + + /*! + * \brief Short-hand for the "subtractive" version (sub from i* add to j*) of UpdateBlocks. + */ + template + inline void UpdateBlocksSub(unsigned long iEdge, const OtherType* const* block_i, const OtherType* const* block_j) { + UpdateBlocks(iEdge, block_i, block_j); + } + /*! * \brief Adds the specified block to the (i, i) subblock of the matrix-by-blocks structure. * \param[in] block_i - Diagonal index. @@ -661,6 +695,11 @@ class CSysMatrix { template void EnforceSolutionAtNode(const unsigned long node_i, const OtherType *x_i, CSysVector & b); + /*! + * \brief Sets the diagonal entries of the matrix as the sum of the blocks in the corresponding column. + */ + void SetDiagonalAsColumnSum(); + /*! * \brief Add a scaled sparse matrix to "this" (axpy-type operation, A = A+alpha*B). * \note Matrices must have the same sparse pattern. diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index 77cc01e9d33f..369dff426783 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -4038,7 +4038,7 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(void) if (edgeColoring.empty() && nEdge) { /*--- When not using threading use the natural coloring. ---*/ - if (omp_get_max_threads() == 1) { + if ((omp_get_max_threads() == 1) || (MGLevel != MESH_0)) { edgeColoring = createNaturalColoring(nEdge); return edgeColoring; } diff --git a/Common/src/linear_algebra/CSysMatrix.cpp b/Common/src/linear_algebra/CSysMatrix.cpp index 5755dbdef576..bf1ccab74dd6 100644 --- a/Common/src/linear_algebra/CSysMatrix.cpp +++ b/Common/src/linear_algebra/CSysMatrix.cpp @@ -189,6 +189,21 @@ void CSysMatrix::Initialize(unsigned long npoint, unsigned long npoi omp_partitions[part] = part * pts_per_part; omp_partitions[omp_num_parts] = nPointDomain; + /*--- For coarse grid levels setup a structure that allows doing a column sum efficiently, + * essentially the transpose of the col_ind, this allows populating the matrix by setting + * the off-diagonal entries and then setting the diagonal ones as the sum of column + * (excluding the diagonal itself). We use the fact that the pattern is symmetric. ---*/ + + col_ptr.resize(nnz, nullptr); + + SU2_OMP_PARALLEL_(for schedule(static,omp_heavy_size)) + for (auto iPoint = 0ul; iPoint < nPoint; ++iPoint) { + for (auto k = row_ptr[iPoint]; k < row_ptr[iPoint+1]; ++k) { + auto jPoint = col_ind[k]; + col_ptr[k] = GetBlock(jPoint, iPoint); + } + } + /*--- Generate MKL Kernels ---*/ #ifdef USE_MKL @@ -1307,6 +1322,21 @@ void CSysMatrix::EnforceSolutionAtNode(const unsigned long node_i, c } +template +void CSysMatrix::SetDiagonalAsColumnSum() { + + SU2_OMP_FOR_DYN(omp_heavy_size) + for (auto iPoint = 0ul; iPoint < nPoint; ++iPoint) { + + su2double* block_ii = &matrix[dia_ptr[iPoint]*nVar*nEqn]; + + for (auto k = row_ptr[iPoint]; k < row_ptr[iPoint+1]; ++k) { + auto block_ji = col_ptr[k]; + if (block_ji != block_ii) MatrixSubtraction(block_ii, block_ji, block_ii); + } + } +} + template template void CSysMatrix::MatrixMatrixAddition(OtherType alpha, const CSysMatrix& B) { diff --git a/SU2_CFD/include/solvers/CEulerSolver.hpp b/SU2_CFD/include/solvers/CEulerSolver.hpp index 86fd772ff096..8a5adaeb7b13 100644 --- a/SU2_CFD/include/solvers/CEulerSolver.hpp +++ b/SU2_CFD/include/solvers/CEulerSolver.hpp @@ -264,6 +264,11 @@ class CEulerSolver : public CSolver { vector EdgeColoring; /*!< \brief Edge colors. */ unsigned long ColorGroupSize; /*!< \brief Group size used for coloring, chunk size in edge loops must be a multiple of this. */ + /*--- Edge fluxes, for OpenMP parallelization on coarse grids. As it is difficult to + * color them, we first store the fluxes and then compute the sum for each cell. ---*/ + + CSysVector EdgeFluxes; /*!< \brief Flux across each edge. */ + /*! * \brief The highest level in the variable hierarchy this solver can safely use. */ @@ -407,6 +412,9 @@ class CEulerSolver : public CSolver { CConfig *config, unsigned short iMesh) final; + virtual void Viscous_Residual(unsigned long iEdge, CGeometry *geometry, CSolver **solver_container, + CNumerics *numerics, CConfig *config) {} + /*! * \brief Recompute the extrapolated quantities, after MUSCL reconstruction, * in a more thermodynamically consistent way. diff --git a/SU2_CFD/include/solvers/CNSSolver.hpp b/SU2_CFD/include/solvers/CNSSolver.hpp index 64a97fb0ac3a..887b4ca8971c 100644 --- a/SU2_CFD/include/solvers/CNSSolver.hpp +++ b/SU2_CFD/include/solvers/CNSSolver.hpp @@ -420,12 +420,14 @@ class CNSSolver final : public CEulerSolver { * \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_container, - CConfig *config, - unsigned short iMesh, - unsigned short iRKStep) override; +// void Viscous_Residual(CGeometry *geometry, +// CSolver **solver_container, +// CNumerics **numerics_container, +// CConfig *config, +// unsigned short iMesh, +// unsigned short iRKStep) override; + void Viscous_Residual(unsigned long iEdge, CGeometry *geometry, CSolver **solver_container, + CNumerics *numerics, CConfig *config) override; /*! * \brief Get the skin friction coefficient. diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 84aaa7688741..a69211bccdbb 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -416,7 +416,9 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short SetBaseClassPointerToNodes(); #ifdef HAVE_OMP - /*--- Get the edge coloring. ---*/ + /*--- On the fine grid get the edge coloring, on coarse grids (which are difficult to color) + * setup the reducer strategy, i.e. one loop over edges followed by a point loop to sum + * the fluxes for each cell and set the diagonal of the system matrix. ---*/ const auto& coloring = geometry->GetEdgeColoring(); @@ -431,6 +433,10 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short } ColorGroupSize = geometry->GetEdgeColorGroupSize(); + if (MGLevel != MESH_0) { + EdgeFluxes.Initialize(geometry->GetnEdge(), geometry->GetnEdge(), nVar, nullptr); + } + omp_chunk_size = computeStaticChunkSize(nPoint, omp_get_max_threads(), OMP_MAX_SIZE); #endif @@ -2945,15 +2951,52 @@ void CEulerSolver::Centered_Residual(CGeometry *geometry, CSolver **solver_conta /*--- Update convective and artificial dissipation residuals ---*/ - LinSysRes.AddBlock(iPoint, residual); - LinSysRes.SubtractBlock(jPoint, residual); +#ifdef HAVE_OMP + if (MGLevel != MESH_0) { + EdgeFluxes.SetBlock(iEdge, residual); + if (implicit) + Jacobian.UpdateBlocks(iEdge, residual.jacobian_i, residual.jacobian_j); + } + else { +#else + { +#endif + LinSysRes.AddBlock(iPoint, residual); + LinSysRes.SubtractBlock(jPoint, residual); - /*--- Set implicit computation ---*/ - if (implicit) { - Jacobian.UpdateBlocks(iEdge, iPoint, jPoint, residual.jacobian_i, residual.jacobian_j); + /*--- Set implicit computation ---*/ + if (implicit) + Jacobian.UpdateBlocks(iEdge, iPoint, jPoint, residual.jacobian_i, residual.jacobian_j); } + + /*--- Viscous contribution. ---*/ + + Viscous_Residual(iEdge, geometry, solver_container, + numerics_container[VISC_TERM + omp_get_thread_num()*MAX_TERMS], config); } } // end color loop + +#ifdef HAVE_OMP + if (MGLevel != MESH_0) { + + SU2_OMP_FOR_STAT(omp_chunk_size) + for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) { + + for (unsigned short iNeigh = 0; iNeigh < geometry->node[iPoint]->GetnPoint(); ++iNeigh) { + + auto iEdge = geometry->node[iPoint]->GetEdge(iNeigh); + + if (iPoint == geometry->edge[iEdge]->GetNode(0)) + LinSysRes.AddBlock(iPoint, EdgeFluxes.GetBlock(iEdge)); + else + LinSysRes.SubtractBlock(iPoint, EdgeFluxes.GetBlock(iEdge)); + } + } + + if (implicit) Jacobian.SetDiagonalAsColumnSum(); + } +#endif + } // end SU2_OMP_PARALLEL } @@ -3162,25 +3205,61 @@ void CEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_contain auto residual = numerics->ComputeResidual(config); - /*--- Update residual value ---*/ - - LinSysRes.AddBlock(iPoint, residual); - LinSysRes.SubtractBlock(jPoint, residual); - - /*--- Set implicit Jacobians ---*/ - - if (implicit) { - Jacobian.UpdateBlocks(iEdge, iPoint, jPoint, residual.jacobian_i, residual.jacobian_j); - } - /*--- Set the final value of the Roe dissipation coefficient ---*/ if (kind_dissipation != NO_ROELOWDISS) { nodes->SetRoe_Dissipation(iPoint,numerics->GetDissipation()); nodes->SetRoe_Dissipation(jPoint,numerics->GetDissipation()); } + + /*--- Update residual value ---*/ + +#ifdef HAVE_OMP + if (MGLevel != MESH_0) { + EdgeFluxes.SetBlock(iEdge, residual); + if (implicit) + Jacobian.UpdateBlocks(iEdge, residual.jacobian_i, residual.jacobian_j); + } + else { +#else + { +#endif + LinSysRes.AddBlock(iPoint, residual); + LinSysRes.SubtractBlock(jPoint, residual); + + /*--- Set implicit computation ---*/ + if (implicit) + Jacobian.UpdateBlocks(iEdge, iPoint, jPoint, residual.jacobian_i, residual.jacobian_j); + } + + /*--- Viscous contribution. ---*/ + + Viscous_Residual(iEdge, geometry, solver_container, + numerics_container[VISC_TERM + omp_get_thread_num()*MAX_TERMS], config); } } // end color loop + +#ifdef HAVE_OMP + if (MGLevel != MESH_0) { + + SU2_OMP_FOR_STAT(omp_chunk_size) + for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) { + + for (unsigned short iNeigh = 0; iNeigh < geometry->node[iPoint]->GetnPoint(); ++iNeigh) { + + auto iEdge = geometry->node[iPoint]->GetEdge(iNeigh); + + if (iPoint == geometry->edge[iEdge]->GetNode(0)) + LinSysRes.AddBlock(iPoint, EdgeFluxes.GetBlock(iEdge)); + else + LinSysRes.SubtractBlock(iPoint, EdgeFluxes.GetBlock(iEdge)); + } + } + + if (implicit) Jacobian.SetDiagonalAsColumnSum(); + } +#endif + } // end SU2_OMP_PARALLEL /*--- Warning message about non-physical reconstructions. ---*/ diff --git a/SU2_CFD/src/solvers/CNSSolver.cpp b/SU2_CFD/src/solvers/CNSSolver.cpp index c5fcf5c0e021..bad3c122b878 100644 --- a/SU2_CFD/src/solvers/CNSSolver.cpp +++ b/SU2_CFD/src/solvers/CNSSolver.cpp @@ -442,7 +442,9 @@ CNSSolver::CNSSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) SetBaseClassPointerToNodes(); #ifdef HAVE_OMP - /*--- Get the edge coloring. ---*/ + /*--- On the fine grid get the edge coloring, on coarse grids (which are difficult to color) + * setup the reducer strategy, i.e. one loop over edges followed by a point loop to sum + * the fluxes for each cell and set the diagonal of the system matrix. ---*/ const auto& coloring = geometry->GetEdgeColoring(); @@ -457,6 +459,10 @@ CNSSolver::CNSSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) } ColorGroupSize = geometry->GetEdgeColorGroupSize(); + if (MGLevel != MESH_0) { + EdgeFluxes.Initialize(geometry->GetnEdge(), geometry->GetnEdge(), nVar, nullptr); + } + omp_chunk_size = computeStaticChunkSize(nPoint, omp_get_max_threads(), OMP_MAX_SIZE); #endif @@ -796,8 +802,8 @@ unsigned long CNSSolver::SetPrimitive_Variables(CSolver **solver_container, CCon return nonPhysicalPoints; } -void CNSSolver::Viscous_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics_container, - CConfig *config, unsigned short iMesh, unsigned short iRKStep) { +void CNSSolver::Viscous_Residual(unsigned long iEdge, CGeometry *geometry, CSolver **solver_container, + CNumerics *numerics, CConfig *config) { const bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); const bool tkeNeeded = (config->GetKind_Turb_Model() == SST) || @@ -806,79 +812,61 @@ void CNSSolver::Viscous_Residual(CGeometry *geometry, CSolver **solver_container CVariable* turbNodes = nullptr; if (tkeNeeded) turbNodes = solver_container[TURB_SOL]->GetNodes(); - /*--- Start OpenMP parallel section. ---*/ - - SU2_OMP_PARALLEL - { - /*--- Pick one numerics object per thread. ---*/ - CNumerics* numerics = numerics_container[VISC_TERM + omp_get_thread_num()*MAX_TERMS]; - - /*--- Loop over all the edges ---*/ - -#ifdef HAVE_OMP - /*--- Chunk size is at least OMP_MIN_SIZE and a multiple of the color group size. ---*/ - auto chunkSize = roundUpDiv(OMP_MIN_SIZE, ColorGroupSize)*ColorGroupSize; - - /*--- Loop over edge colors. ---*/ - for (auto color : EdgeColoring) - { - SU2_OMP_FOR_DYN(chunkSize) - for(auto k = 0ul; k < color.size; ++k) { - - auto iEdge = color.indices[k]; -#else - /*--- Natural coloring. ---*/ - { - for (auto iEdge = 0ul; iEdge < geometry->GetnEdge(); iEdge++) { -#endif - /*--- Points, coordinates and normal vector in edge ---*/ + /*--- Points, coordinates and normal vector in edge ---*/ - auto iPoint = geometry->edge[iEdge]->GetNode(0); - auto jPoint = geometry->edge[iEdge]->GetNode(1); + auto iPoint = geometry->edge[iEdge]->GetNode(0); + auto jPoint = geometry->edge[iEdge]->GetNode(1); - numerics->SetCoord(geometry->node[iPoint]->GetCoord(), - geometry->node[jPoint]->GetCoord()); + numerics->SetCoord(geometry->node[iPoint]->GetCoord(), + geometry->node[jPoint]->GetCoord()); - numerics->SetNormal(geometry->edge[iEdge]->GetNormal()); + numerics->SetNormal(geometry->edge[iEdge]->GetNormal()); - /*--- Primitive and secondary variables. ---*/ + /*--- Primitive and secondary variables. ---*/ - numerics->SetPrimitive(nodes->GetPrimitive(iPoint), - nodes->GetPrimitive(jPoint)); + numerics->SetPrimitive(nodes->GetPrimitive(iPoint), + nodes->GetPrimitive(jPoint)); - numerics->SetSecondary(nodes->GetSecondary(iPoint), - nodes->GetSecondary(jPoint)); + numerics->SetSecondary(nodes->GetSecondary(iPoint), + nodes->GetSecondary(jPoint)); - /*--- Gradients. ---*/ + /*--- Gradients. ---*/ - numerics->SetPrimVarGradient(nodes->GetGradient_Primitive(iPoint), - nodes->GetGradient_Primitive(jPoint)); + numerics->SetPrimVarGradient(nodes->GetGradient_Primitive(iPoint), + nodes->GetGradient_Primitive(jPoint)); - /*--- Turbulent kinetic energy. ---*/ + /*--- Turbulent kinetic energy. ---*/ - if (tkeNeeded) - numerics->SetTurbKineticEnergy(turbNodes->GetSolution(iPoint,0), - turbNodes->GetSolution(jPoint,0)); + if (tkeNeeded) + numerics->SetTurbKineticEnergy(turbNodes->GetSolution(iPoint,0), + turbNodes->GetSolution(jPoint,0)); - /*--- Wall shear stress values (wall functions) ---*/ + /*--- Wall shear stress values (wall functions) ---*/ - numerics->SetTauWall(nodes->GetTauWall(iPoint), - nodes->GetTauWall(iPoint)); + numerics->SetTauWall(nodes->GetTauWall(iPoint), + nodes->GetTauWall(iPoint)); - /*--- Compute and update residual ---*/ + /*--- Compute and update residual ---*/ - auto residual = numerics->ComputeResidual(config); + auto residual = numerics->ComputeResidual(config); +#ifdef HAVE_OMP + if (MGLevel != MESH_0) { + EdgeFluxes.SubtractBlock(iEdge, residual); + if (implicit) + Jacobian.UpdateBlocksSub(iEdge, residual.jacobian_i, residual.jacobian_j); + } + else { +#else + { +#endif LinSysRes.SubtractBlock(iPoint, residual); LinSysRes.AddBlock(jPoint, residual); - /*--- Implicit part ---*/ - if (implicit) Jacobian.UpdateBlocksSub(iEdge, iPoint, jPoint, residual.jacobian_i, residual.jacobian_j); } - } // end color loop - } // end SU2_OMP_PARALLEL + } void CNSSolver::Friction_Forces(CGeometry *geometry, CConfig *config) { From caa4d7b1a387ad0139d99e639b359a69e2369c8e Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Tue, 4 Feb 2020 16:31:35 +0000 Subject: [PATCH 088/118] fix AD compilation --- Common/include/linear_algebra/CSysMatrix.hpp | 2 +- Common/src/linear_algebra/CSysMatrix.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Common/include/linear_algebra/CSysMatrix.hpp b/Common/include/linear_algebra/CSysMatrix.hpp index e9c3099df766..be91dcab6865 100644 --- a/Common/include/linear_algebra/CSysMatrix.hpp +++ b/Common/include/linear_algebra/CSysMatrix.hpp @@ -95,7 +95,7 @@ class CSysMatrix { const unsigned long *row_ptr; /*!< \brief Pointers to the first element in each row. */ const unsigned long *dia_ptr; /*!< \brief Pointers to the diagonal element in each row. */ const unsigned long *col_ind; /*!< \brief Column index for each of the elements in val(). */ - vector col_ptr; /*!< \brief The transpose of col_ind, pointer to blocks with the same column index. */ + vector col_ptr;/*!< \brief The transpose of col_ind, pointer to blocks with the same column index. */ ScalarType *ILU_matrix; /*!< \brief Entries of the ILU sparse matrix. */ unsigned long nnz_ilu; /*!< \brief Number of possible nonzero entries in the matrix (ILU). */ diff --git a/Common/src/linear_algebra/CSysMatrix.cpp b/Common/src/linear_algebra/CSysMatrix.cpp index bf1ccab74dd6..ec18c78e3fa8 100644 --- a/Common/src/linear_algebra/CSysMatrix.cpp +++ b/Common/src/linear_algebra/CSysMatrix.cpp @@ -1328,7 +1328,7 @@ void CSysMatrix::SetDiagonalAsColumnSum() { SU2_OMP_FOR_DYN(omp_heavy_size) for (auto iPoint = 0ul; iPoint < nPoint; ++iPoint) { - su2double* block_ii = &matrix[dia_ptr[iPoint]*nVar*nEqn]; + auto block_ii = &matrix[dia_ptr[iPoint]*nVar*nEqn]; for (auto k = row_ptr[iPoint]; k < row_ptr[iPoint+1]; ++k) { auto block_ji = col_ptr[k]; From e9ad0d57a6156eb276066be2b25530ee3ac584b7 Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Tue, 4 Feb 2020 18:20:33 +0000 Subject: [PATCH 089/118] more ctor cleanup --- SU2_CFD/include/solvers/CEulerSolver.hpp | 18 +- SU2_CFD/src/solvers/CEulerSolver.cpp | 106 ++--- SU2_CFD/src/solvers/CNSSolver.cpp | 473 +---------------------- 3 files changed, 81 insertions(+), 516 deletions(-) diff --git a/SU2_CFD/include/solvers/CEulerSolver.hpp b/SU2_CFD/include/solvers/CEulerSolver.hpp index 8a5adaeb7b13..dde6647b7009 100644 --- a/SU2_CFD/include/solvers/CEulerSolver.hpp +++ b/SU2_CFD/include/solvers/CEulerSolver.hpp @@ -195,19 +195,19 @@ class CEulerSolver : public CSolver { su2double Gamma; /*!< \brief Fluid's Gamma constant (ratio of specific heats). */ su2double Gamma_Minus_One; /*!< \brief Fluids's Gamma - 1.0 . */ - su2double AoA_Prev, /*!< \brief Old value of the angle of attack (monitored). */ + su2double AoA_Prev, /*!< \brief Old value of the angle of attack (monitored). */ AoA_inc; - bool Start_AoA_FD, /*!< \brief Boolean for start of finite differencing for FixedCL mode */ - End_AoA_FD, /*!< \brief Boolean for end of finite differencing for FixedCL mode */ - Update_AoA; /*!< \brief Boolean to signal Angle of Attack Update */ - unsigned long Iter_Update_AoA; /*!< \brief Iteration at which AoA was updated last */ - su2double dCL_dAlpha; /*!< \brief Value of dCL_dAlpha used to control CL in fixed CL mode */ + bool Start_AoA_FD = false, /*!< \brief Boolean for start of finite differencing for FixedCL mode */ + End_AoA_FD = false, /*!< \brief Boolean for end of finite differencing for FixedCL mode */ + Update_AoA = false; /*!< \brief Boolean to signal Angle of Attack Update */ + unsigned long Iter_Update_AoA = 0; /*!< \brief Iteration at which AoA was updated last */ + su2double dCL_dAlpha; /*!< \brief Value of dCL_dAlpha used to control CL in fixed CL mode */ unsigned long BCThrust_Counter; unsigned short nSpanWiseSections; /*!< \brief Number of span-wise sections. */ unsigned short nSpanMax; /*!< \brief Max number of maximum span-wise sections for all zones */ unsigned short nMarkerTurboPerf; /*!< \brief Number of turbo performance. */ - vector FluidModel; /*!< \brief fluid model used in the solver */ + vector FluidModel; /*!< \brief fluid model used in the solver */ /*--- Turbomachinery Solver Variables ---*/ @@ -297,8 +297,10 @@ class CEulerSolver : public CSolver { * \overload * \param[in] geometry - Geometrical definition of the problem. * \param[in] config - Definition of the particular problem. + * \param[in] iMesh - Grid level. + * \param[in] navier_stokes - True when the constructor is called by the derived class CNSSolver. */ - CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh); + CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh, const bool navier_stokes = false); /*! * \brief Destructor of the class. diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index a69211bccdbb..fe6cf2da8ebe 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -27,6 +27,7 @@ #include "../../include/solvers/CEulerSolver.hpp" +#include "../../include/variables/CNSVariable.hpp" #include "../../../Common/include/toolboxes/printing_toolbox.hpp" #include "../../include/gradients/computeGradientsGreenGauss.hpp" #include "../../include/gradients/computeGradientsLeastSquares.hpp" @@ -55,37 +56,40 @@ void CEulerSolver::AeroCoeffsArray::setZero(int i) { CoPz[i] = CT[i] = CQ[i] = CMerit[i] = 0.0; } -CEulerSolver::CEulerSolver(void) : CSolver() { +CEulerSolver::CEulerSolver(void) : CSolver() { } - /*--- Fixed CL mode initialization ---*/ +CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, + unsigned short iMesh, const bool navier_stokes) : CSolver() { - Start_AoA_FD = false; - End_AoA_FD = false; - Update_AoA = false; - Iter_Update_AoA = 0; - -} - -CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) : CSolver() { + /*--- Based on the navier_stokes boolean, determine if this constructor is + * being called by itself, or by its derived class CNSSolver. ---*/ + string description; + unsigned short nSecVar; + if (navier_stokes) { + description = "Navier-Stokes"; + nSecVar = 8; + } + else { + description = "Euler"; + nSecVar = 2; + } unsigned long iPoint, counter_local = 0, counter_global = 0; unsigned short iVar, iDim, iMarker, nLineLets; su2double StaticEnergy, Density, Velocity2, Pressure, Temperature; unsigned short nZone = geometry->GetnZone(); - bool restart = (config->GetRestart() || config->GetRestart_Flow()); + bool restart = (config->GetRestart() || config->GetRestart_Flow()); bool rans = (config->GetKind_Turb_Model() != NONE); unsigned short direct_diff = config->GetDirectDiff(); int Unst_RestartIter = 0; - bool dual_time = ((config->GetTime_Marching() == DT_STEPPING_1ST) || - (config->GetTime_Marching() == DT_STEPPING_2ND)); - bool time_stepping = config->GetTime_Marching() == TIME_STEPPING; + bool dual_time = (config->GetTime_Marching() == DT_STEPPING_1ST) || + (config->GetTime_Marching() == DT_STEPPING_2ND); + bool time_stepping = (config->GetTime_Marching() == TIME_STEPPING); - /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ + /*--- A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain ---*/ dynamic_grid = config->GetDynamic_Grid(); bool adjoint = (config->GetContinuous_Adjoint()) || (config->GetDiscrete_Adjoint()); - bool fsi = config->GetFSI_Simulation(); - bool multizone = config->GetMultizone_Problem(); string filename_ = "flow"; /*--- Store the multigrid level. ---*/ @@ -121,13 +125,6 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short } - /*--- Fixed CL mode initialization ---*/ - - Start_AoA_FD = false; - End_AoA_FD = false; - Update_AoA = false; - Iter_Update_AoA = 0; - /*--- Set the gamma value ---*/ Gamma = config->GetGamma(); @@ -141,7 +138,7 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short nVar = nDim+2; nPrimVar = nDim+9; nPrimVarGrad = nDim+4; - nSecondaryVar = 2; nSecondaryVarGrad = 2; + nSecondaryVar = nSecVar; nSecondaryVarGrad = 2; /*--- Initialize nVarGrad for deallocation ---*/ @@ -170,7 +167,7 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short SetVerificationSolution(nDim, nVar, config); - /*--- Define some auxiliary vectors related to the residual ---*/ + /*--- Define some auxiliar vector related with the residual ---*/ Residual = new su2double[nVar](); Residual_RMS = new su2double[nVar](); @@ -197,7 +194,7 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short Vector = new su2double[nDim](); - /*--- Define some auxiliary vectors related to the undivided lapalacian ---*/ + /*--- Define some auxiliar vector related with the undivided lapalacian computation ---*/ if (config->GetKind_ConvNumScheme_Flow() == SPACE_CENTERED) { iPoint_UndLapl = new su2double [nPoint]; @@ -222,18 +219,22 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short Jacobian_j[iVar] = new su2double [nVar]; } - if (rank == MASTER_NODE) cout << "Initialize Jacobian structure (Euler). MG level: " << iMesh <<"." << endl; + if (rank == MASTER_NODE) + cout << "Initialize Jacobian structure (" << description << "). MG level: " << iMesh <<"." << endl; + Jacobian.Initialize(nPoint, nPointDomain, nVar, nVar, true, geometry, config); if (config->GetKind_Linear_Solver_Prec() == LINELET) { nLineLets = Jacobian.BuildLineletPreconditioner(geometry, config); - if (rank == MASTER_NODE) cout << "Compute linelet structure. " << nLineLets << " elements in each line (average)." << endl; + if (rank == MASTER_NODE) + cout << "Compute linelet structure. " << nLineLets << " elements in each line (average)." << endl; } } else { - if (rank == MASTER_NODE) cout << "Explicit scheme. No Jacobian structure (Euler). MG level: " << iMesh <<"." << endl; + if (rank == MASTER_NODE) + cout << "Explicit scheme. No Jacobian structure (" << description << "). MG level: " << iMesh <<"." << endl; } /*--- Define some auxiliary vectors for computing flow variable @@ -335,7 +336,7 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short Exhaust_Temperature = new su2double[nMarker]; Exhaust_Area = new su2double[nMarker]; - /*--- Read farfield conditions ---*/ + /*--- Read farfield conditions from config ---*/ Density_Inf = config->GetDensity_FreeStreamND(); Pressure_Inf = config->GetPressure_FreeStreamND(); @@ -412,7 +413,11 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short /*--- Initialize the solution to the far-field state everywhere. ---*/ - nodes = new CEulerVariable(Density_Inf, Velocity_Inf, Energy_Inf, nPoint, nDim, nVar, config); + if (navier_stokes) { + nodes = new CNSVariable(Density_Inf, Velocity_Inf, Energy_Inf, nPoint, nDim, nVar, config); + } else { + nodes = new CEulerVariable(Density_Inf, Velocity_Inf, Energy_Inf, nPoint, nDim, nVar, config); + } SetBaseClassPointerToNodes(); #ifdef HAVE_OMP @@ -472,20 +477,6 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short } - /*--- Initialize the BGS residuals in FSI problems. ---*/ - if (fsi || multizone){ - Residual_BGS = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) Residual_BGS[iVar] = 1.0; - Residual_Max_BGS = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) Residual_Max_BGS[iVar] = 1.0; - - /*--- Define some structures for locating max residuals ---*/ - - Point_Max_BGS = new unsigned long[nVar](); - Point_Max_Coord_BGS = new su2double*[nVar](); - for (iVar = 0; iVar < nVar; iVar++) { - Point_Max_Coord_BGS[iVar] = new su2double[nDim](); - } - } - /*--- Warning message about non-physical points ---*/ if (config->GetComm_Level() == COMM_FULL) { @@ -496,16 +487,25 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short cout << "Warning. The original solution contains "<< counter_global << " points that are not physical." << endl; } - /*--- Define solver parameters needed for execution of destructor ---*/ + /*--- Initialize the BGS residuals in FSI problems. ---*/ + if (config->GetMultizone_Residual()){ + Residual_BGS = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) Residual_BGS[iVar] = 1.0; + Residual_Max_BGS = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) Residual_Max_BGS[iVar] = 1.0; - if (config->GetKind_ConvNumScheme_Flow() == SPACE_CENTERED ) space_centered = true; - else space_centered = false; + /*--- Define some structures for locating max residuals ---*/ - if (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT) euler_implicit = true; - else euler_implicit = false; + Point_Max_BGS = new unsigned long[nVar](); + Point_Max_Coord_BGS = new su2double*[nVar]; + for (iVar = 0; iVar < nVar; iVar++) { + Point_Max_Coord_BGS[iVar] = new su2double[nDim](); + } + } + + /*--- Define solver parameters needed for execution of destructor ---*/ - if (config->GetKind_Gradient_Method() == WEIGHTED_LEAST_SQUARES) least_squares = true; - else least_squares = false; + space_centered = (config->GetKind_ConvNumScheme_Flow() == SPACE_CENTERED); + euler_implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + least_squares = (config->GetKind_Gradient_Method() == WEIGHTED_LEAST_SQUARES); /*--- Communicate and store volume and the number of neighbors for any dual CVs that lie on on periodic markers. ---*/ diff --git a/SU2_CFD/src/solvers/CNSSolver.cpp b/SU2_CFD/src/solvers/CNSSolver.cpp index bad3c122b878..241af41cba69 100644 --- a/SU2_CFD/src/solvers/CNSSolver.cpp +++ b/SU2_CFD/src/solvers/CNSSolver.cpp @@ -32,219 +32,13 @@ CNSSolver::CNSSolver(void) : CEulerSolver() { } -CNSSolver::CNSSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) : CEulerSolver() { +CNSSolver::CNSSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) : + CEulerSolver(geometry, config, iMesh, true) { - unsigned long iPoint, counter_local = 0, counter_global = 0, iVertex; - unsigned short iVar, iDim, iMarker, nLineLets; - su2double Density, Velocity2, Pressure, Temperature, StaticEnergy; - ifstream restart_file; - unsigned short nZone = geometry->GetnZone(); - bool restart = (config->GetRestart() || config->GetRestart_Flow()); - int Unst_RestartIter = 0; - bool dual_time = (config->GetTime_Marching() == DT_STEPPING_1ST) || - (config->GetTime_Marching() == DT_STEPPING_2ND); - bool time_stepping = (config->GetTime_Marching() == TIME_STEPPING); + /*--- This constructor only allocates/inits what is extra to CEulerSolver. ---*/ - /*--- A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain ---*/ - dynamic_grid = config->GetDynamic_Grid(); - - bool adjoint = (config->GetContinuous_Adjoint()) || (config->GetDiscrete_Adjoint()); - string filename_ = "flow"; - - unsigned short direct_diff = config->GetDirectDiff(); - bool rans = (config->GetKind_Turb_Model() != NONE); - - /*--- Store the multigrid level. ---*/ - MGLevel = iMesh; - - /*--- Check for a restart file to evaluate if there is a change in the angle of attack - before computing all the non-dimesional quantities. ---*/ - - if (!(!restart || (iMesh != MESH_0) || nZone > 1) && - (config->GetFixed_CL_Mode() || config->GetFixed_CM_Mode())) { - - /*--- Modify file name for a dual-time unsteady restart ---*/ - - if (dual_time) { - if (adjoint) Unst_RestartIter = SU2_TYPE::Int(config->GetUnst_AdjointIter())-1; - else if (config->GetTime_Marching() == DT_STEPPING_1ST) - Unst_RestartIter = SU2_TYPE::Int(config->GetRestart_Iter())-1; - else Unst_RestartIter = SU2_TYPE::Int(config->GetRestart_Iter())-2; - } - - /*--- Modify file name for a time stepping unsteady restart ---*/ - - if (time_stepping) { - if (adjoint) Unst_RestartIter = SU2_TYPE::Int(config->GetUnst_AdjointIter())-1; - else Unst_RestartIter = SU2_TYPE::Int(config->GetRestart_Iter())-1; - } - - filename_ = config->GetFilename(filename_, ".meta", Unst_RestartIter); - - /*--- Read and store the restart metadata. ---*/ - - Read_SU2_Restart_Metadata(geometry, config, adjoint, filename_); - - } - - /*--- Set the gamma value ---*/ - - Gamma = config->GetGamma(); - Gamma_Minus_One = Gamma - 1.0; - - /*--- Define geometry constants in the solver structure - Compressible flow, primitive variables (T, vx, vy, vz, P, rho, h, c, lamMu, EddyMu, ThCond, Cp). - ---*/ - - nDim = geometry->GetnDim(); - - nVar = nDim+2; - nPrimVar = nDim+9; nPrimVarGrad = nDim+4; - nSecondaryVar = 8; nSecondaryVarGrad = 2; - - - /*--- Initialize nVarGrad for deallocation ---*/ - - nVarGrad = nPrimVarGrad; - - nMarker = config->GetnMarker_All(); - nPoint = geometry->GetnPoint(); - nPointDomain = geometry->GetnPointDomain(); - - /*--- Store the number of vertices on each marker for deallocation later ---*/ - - nVertex = new unsigned long[nMarker]; - for (iMarker = 0; iMarker < nMarker; iMarker++) - nVertex[iMarker] = geometry->nVertex[iMarker]; - - /*--- Perform the non-dimensionalization for the flow equations using the - specified reference values. ---*/ - - SetNondimensionalization(config, iMesh); - - /*--- Check if we are executing a verification case. If so, the - VerificationSolution object will be instantiated for a particular - option from the available library of verification solutions. Note - that this is done after SetNondim(), as problem-specific initial - parameters are needed by the solution constructors. ---*/ - - SetVerificationSolution(nDim, nVar, config); - - /*--- Define some auxiliar vector related with the residual ---*/ - - Residual = new su2double[nVar](); - Residual_RMS = new su2double[nVar](); - Residual_Max = new su2double[nVar](); - Residual_i = new su2double[nVar](); - Residual_j = new su2double[nVar](); - Res_Conv = new su2double[nVar](); - Res_Visc = new su2double[nVar](); - Res_Sour = new su2double[nVar](); - - /*--- Define some structures for locating max residuals ---*/ - - Point_Max = new unsigned long[nVar]; - Point_Max_Coord = new su2double*[nVar]; - for (iVar = 0; iVar < nVar; iVar++) { - Point_Max_Coord[iVar] = new su2double[nDim](); - } - - /*--- Define some auxiliary vectors related to the solution ---*/ - - Solution = new su2double[nVar](); - - /*--- Define some auxiliary vectors related to the geometry ---*/ - - Vector = new su2double[nDim](); - - /*--- Define some auxiliar vector related with the undivided lapalacian computation ---*/ - - if (config->GetKind_ConvNumScheme_Flow() == SPACE_CENTERED) { - iPoint_UndLapl = new su2double [nPoint]; - jPoint_UndLapl = new su2double [nPoint]; - } - - /*--- Initialize the solution and right hand side vectors for storing - the residuals and updating the solution (always needed even for - explicit schemes). ---*/ - - LinSysSol.Initialize(nPoint, nPointDomain, nVar, 0.0); - LinSysRes.Initialize(nPoint, nPointDomain, nVar, 0.0); - - /*--- Jacobians and vector structures for implicit computations ---*/ - - if (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT) { - - Jacobian_i = new su2double* [nVar]; - Jacobian_j = new su2double* [nVar]; - for (iVar = 0; iVar < nVar; iVar++) { - Jacobian_i[iVar] = new su2double [nVar]; - Jacobian_j[iVar] = new su2double [nVar]; - } - - if (rank == MASTER_NODE) cout << "Initialize Jacobian structure (Navier-Stokes). MG level: " << iMesh <<"." << endl; - Jacobian.Initialize(nPoint, nPointDomain, nVar, nVar, true, geometry, config); - - if (config->GetKind_Linear_Solver_Prec() == LINELET) { - nLineLets = Jacobian.BuildLineletPreconditioner(geometry, config); - if (rank == MASTER_NODE) cout << "Compute linelet structure. " << nLineLets << " elements in each line (average)." << endl; - } - - } - - else { - if (rank == MASTER_NODE) - cout << "Explicit scheme. No Jacobian structure (Navier-Stokes). MG level: " << iMesh <<"." << endl; - } - - /*--- Define some auxiliary vectors for computing flow variable - gradients by least squares, S matrix := inv(R)*traspose(inv(R)), - c vector := transpose(WA)*(Wb) ---*/ - - 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]; - } - - /*--- Allocates a 2D array with variable "outer" sizes and init to 0. ---*/ - - auto Alloc2D = [](unsigned long M, const unsigned long* N, su2double**& X) { - X = new su2double* [M]; - for(unsigned long i = 0; i < M; ++i) - X[i] = new su2double [N[i]] (); - }; - - /*--- Allocates a 3D array with variable "middle" sizes and init to 0. ---*/ - - auto Alloc3D = [](unsigned long M, const unsigned long* N, unsigned long P, su2double***& X) { - X = new su2double** [M]; - for(unsigned long i = 0; i < M; ++i) { - X[i] = new su2double* [N[i]]; - for(unsigned long j = 0; j < N[i]; ++j) - X[i][j] = new su2double [P] (); - } - }; - - /*--- Store the value of the characteristic primitive variables at the boundaries ---*/ - - Alloc3D(nMarker, nVertex, nPrimVar, CharacPrimVar); - - /*--- Store the value of the primitive variables + 2 turb variables at the boundaries, - used for IO with a donor cell ---*/ - - Alloc3D(nMarker, nVertex, (rans? nPrimVar+2 : nPrimVar), DonorPrimVar); - - /*--- Store the value of the characteristic primitive variables index at the boundaries ---*/ - - DonorGlobalIndex = new unsigned long* [nMarker]; - for (iMarker = 0; iMarker < nMarker; iMarker++) { - DonorGlobalIndex[iMarker] = new unsigned long [geometry->nVertex[iMarker]](); - } + unsigned short iMarker, iDim; + unsigned long iVertex; /*--- Store the values of the temperature and the heat flux density at the boundaries, used for coupling with a solid donor cell ---*/ @@ -252,41 +46,20 @@ CNSSolver::CNSSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) HeatConjugateVar = new su2double** [nMarker]; for (iMarker = 0; iMarker < nMarker; iMarker++) { - HeatConjugateVar[iMarker] = new su2double* [geometry->nVertex[iMarker]]; - for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { - - HeatConjugateVar[iMarker][iVertex] = new su2double [nHeatConjugateVar]; - for (iVar = 1; iVar < nHeatConjugateVar ; iVar++) { - HeatConjugateVar[iMarker][iVertex][iVar] = 0.0; - } + HeatConjugateVar[iMarker] = new su2double* [nVertex[iMarker]]; + for (iVertex = 0; iVertex < nVertex[iMarker]; iVertex++) { + HeatConjugateVar[iMarker][iVertex] = new su2double [nHeatConjugateVar](); HeatConjugateVar[iMarker][iVertex][0] = config->GetTemperature_FreeStreamND(); } } - /*--- Store the value of the Delta P at the Actuator Disk ---*/ - - Alloc2D(nMarker, nVertex, ActDisk_DeltaP); - - /*--- Store the value of the Delta T at the Actuator Disk ---*/ - - Alloc2D(nMarker, nVertex, ActDisk_DeltaT); - - /*--- Store the value of the Total Pressure at the inlet BC ---*/ - - Alloc2D(nMarker, nVertex, Inlet_Ttotal); - - /*--- Store the value of the Total Temperature at the inlet BC ---*/ - - Alloc2D(nMarker, nVertex, Inlet_Ptotal); - - /*--- Store the value of the Flow direction at the inlet BC ---*/ - - Alloc3D(nMarker, nVertex, nDim, Inlet_FlowDir); - - /*--- Inviscid force definition and coefficient in all the markers ---*/ + /*--- Allocates a 2D array with variable "outer" sizes and init to 0. ---*/ - Alloc2D(nMarker, nVertex, CPressure); - Alloc2D(nMarker, nVertex, CPressureTarget); + auto Alloc2D = [](unsigned long M, const unsigned long* N, su2double**& X) { + X = new su2double* [M]; + for(unsigned long i = 0; i < M; ++i) + X[i] = new su2double [N[i]] (); + }; /*--- Heat flux in all the markers ---*/ @@ -303,19 +76,14 @@ CNSSolver::CNSSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) for (iMarker = 0; iMarker < nMarker; iMarker++) { CSkinFriction[iMarker] = new su2double*[nDim]; for (iDim = 0; iDim < nDim; iDim++) { - CSkinFriction[iMarker][iDim] = new su2double[geometry->nVertex[iMarker]] (); + CSkinFriction[iMarker][iDim] = new su2double[nVertex[iMarker]] (); } } /*--- Non dimensional aerodynamic coefficients ---*/ - InvCoeff.allocate(nMarker); - MntCoeff.allocate(nMarker); ViscCoeff.allocate(nMarker); - SurfaceInvCoeff.allocate(config->GetnMarker_Monitoring()); - SurfaceMntCoeff.allocate(config->GetnMarker_Monitoring()); SurfaceViscCoeff.allocate(config->GetnMarker_Monitoring()); - SurfaceCoeff.allocate(config->GetnMarker_Monitoring()); /*--- Heat flux and buffet coefficients ---*/ @@ -335,229 +103,24 @@ CNSSolver::CNSSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) } - /*--- Supersonic coefficients ---*/ - - CEquivArea_Inv = new su2double[nMarker]; - CNearFieldOF_Inv = new su2double[nMarker]; - - /*--- Engine simulation ---*/ - - Inflow_MassFlow = new su2double[nMarker]; - Inflow_Pressure = new su2double[nMarker]; - Inflow_Mach = new su2double[nMarker]; - Inflow_Area = new su2double[nMarker]; - - Exhaust_MassFlow = new su2double[nMarker]; - Exhaust_Pressure = new su2double[nMarker]; - Exhaust_Temperature = new su2double[nMarker]; - Exhaust_Area = new su2double[nMarker]; - /*--- Read farfield conditions from config ---*/ - Density_Inf = config->GetDensity_FreeStreamND(); - Pressure_Inf = config->GetPressure_FreeStreamND(); - Velocity_Inf = config->GetVelocity_FreeStreamND(); - Energy_Inf = config->GetEnergy_FreeStreamND(); - Temperature_Inf = config->GetTemperature_FreeStreamND(); Viscosity_Inf = config->GetViscosity_FreeStreamND(); - Mach_Inf = config->GetMach(); Prandtl_Lam = config->GetPrandtl_Lam(); Prandtl_Turb = config->GetPrandtl_Turb(); Tke_Inf = config->GetTke_FreeStreamND(); - /*--- Initialize the secondary values for direct derivative approxiations ---*/ + /*--- Initialize the seed values for forward mode differentiation. ---*/ - switch(direct_diff) { - case NO_DERIVATIVE: - break; - case D_DENSITY: - SU2_TYPE::SetDerivative(Density_Inf, 1.0); - break; - case D_PRESSURE: - SU2_TYPE::SetDerivative(Pressure_Inf, 1.0); - break; - case D_TEMPERATURE: - SU2_TYPE::SetDerivative(Temperature_Inf, 1.0); - break; + switch(config->GetDirectDiff()) { case D_VISCOSITY: SU2_TYPE::SetDerivative(Viscosity_Inf, 1.0); break; - case D_MACH: case D_AOA: - case D_SIDESLIP: case D_REYNOLDS: - case D_TURB2LAM: case D_DESIGN: - /*--- Already done in postprocessing of config ---*/ - break; default: + /*--- Already done upstream. ---*/ break; } - /*--- Initialize fan face pressure, fan face mach number, and mass flow rate ---*/ - - for (iMarker = 0; iMarker < nMarker; iMarker++) { - Inflow_MassFlow[iMarker] = 0.0; - Inflow_Mach[iMarker] = Mach_Inf; - Inflow_Pressure[iMarker] = Pressure_Inf; - Inflow_Area[iMarker] = 0.0; - - Exhaust_MassFlow[iMarker] = 0.0; - Exhaust_Temperature[iMarker] = Temperature_Inf; - Exhaust_Pressure[iMarker] = Pressure_Inf; - Exhaust_Area[iMarker] = 0.0; - - } - /*--- Initializate quantities for SlidingMesh Interface ---*/ - - SlidingState = new su2double*** [nMarker]; - SlidingStateNodes = new int* [nMarker]; - - for (iMarker = 0; iMarker < nMarker; iMarker++){ - - SlidingState[iMarker] = NULL; - SlidingStateNodes[iMarker] = NULL; - - if (config->GetMarker_All_KindBC(iMarker) == FLUID_INTERFACE){ - - SlidingState[iMarker] = new su2double**[geometry->GetnVertex(iMarker)](); - SlidingStateNodes[iMarker] = new int [geometry->GetnVertex(iMarker)](); - - for (iPoint = 0; iPoint < geometry->GetnVertex(iMarker); iPoint++) - SlidingState[iMarker][iPoint] = new su2double*[nPrimVar+1](); - } - } - - /*--- Only initialize when there is a Marker_Fluid_Load - *--- (this avoids overhead in all other cases while a more permanent structure is being developed) ---*/ - if((config->GetnMarker_Fluid_Load() > 0) && (MGLevel == MESH_0)){ - - InitVertexTractionContainer(geometry, config); - - if (config->GetDiscrete_Adjoint()) - InitVertexTractionAdjointContainer(geometry, config); - - } - - /*--- Initialize the solution to the far-field state everywhere. ---*/ - - nodes = new CNSVariable(Density_Inf, Velocity_Inf, Energy_Inf, nPoint, nDim, nVar, config); - SetBaseClassPointerToNodes(); - -#ifdef HAVE_OMP - /*--- On the fine grid get the edge coloring, on coarse grids (which are difficult to color) - * setup the reducer strategy, i.e. one loop over edges followed by a point loop to sum - * the fluxes for each cell and set the diagonal of the system matrix. ---*/ - - const auto& coloring = geometry->GetEdgeColoring(); - - if (!coloring.empty()) { - auto nColor = coloring.getOuterSize(); - EdgeColoring.resize(nColor); - - for(auto iColor = 0ul; iColor < nColor; ++iColor) { - EdgeColoring[iColor].size = coloring.getNumNonZeros(iColor); - EdgeColoring[iColor].indices = coloring.innerIdx(iColor); - } - } - ColorGroupSize = geometry->GetEdgeColorGroupSize(); - - if (MGLevel != MESH_0) { - EdgeFluxes.Initialize(geometry->GetnEdge(), geometry->GetnEdge(), nVar, nullptr); - } - - omp_chunk_size = computeStaticChunkSize(nPoint, omp_get_max_threads(), OMP_MAX_SIZE); -#endif - - /*--- Check that the initial solution is physical, report any non-physical nodes ---*/ - - counter_local = 0; - - for (iPoint = 0; iPoint < nPoint; iPoint++) { - - Density = nodes->GetDensity(iPoint); - - Velocity2 = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - Velocity2 += pow(nodes->GetSolution(iPoint,iDim+1)/Density,2); - - StaticEnergy= nodes->GetEnergy(iPoint) - 0.5*Velocity2; - - GetFluidModel()->SetTDState_rhoe(Density, StaticEnergy); - Pressure= GetFluidModel()->GetPressure(); - Temperature= GetFluidModel()->GetTemperature(); - - /*--- Use the values at the infinity ---*/ - - if ((Pressure < 0.0) || (Density < 0.0) || (Temperature < 0.0)) { - Solution[0] = Density_Inf; - for (iDim = 0; iDim < nDim; iDim++) - Solution[iDim+1] = Velocity_Inf[iDim]*Density_Inf; - Solution[nDim+1] = Energy_Inf*Density_Inf; - nodes->SetSolution(iPoint,Solution); - nodes->SetSolution_Old(iPoint,Solution); - counter_local++; - } - - } - - /*--- Warning message about non-physical points ---*/ - - if (config->GetComm_Level() == COMM_FULL) { - - SU2_MPI::Reduce(&counter_local, &counter_global, 1, MPI_UNSIGNED_LONG, MPI_SUM, MASTER_NODE, MPI_COMM_WORLD); - - if ((rank == MASTER_NODE) && (counter_global != 0)) - cout << "Warning. The original solution contains "<< counter_global << " points that are not physical." << endl; - } - - /*--- Initialize the BGS residuals in FSI problems. ---*/ - if (config->GetMultizone_Residual()){ - Residual_BGS = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) Residual_BGS[iVar] = 1.0; - Residual_Max_BGS = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) Residual_Max_BGS[iVar] = 1.0; - - /*--- Define some structures for locating max residuals ---*/ - - Point_Max_BGS = new unsigned long[nVar](); - Point_Max_Coord_BGS = new su2double*[nVar]; - for (iVar = 0; iVar < nVar; iVar++) { - Point_Max_Coord_BGS[iVar] = new su2double[nDim](); - } - } - - /*--- Define solver parameters needed for execution of destructor ---*/ - - space_centered = (config->GetKind_ConvNumScheme_Flow() == SPACE_CENTERED); - euler_implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - least_squares = (config->GetKind_Gradient_Method() == WEIGHTED_LEAST_SQUARES); - - /*--- Communicate and store volume and the number of neighbors for - any dual CVs that lie on on periodic markers. ---*/ - - for (unsigned short iPeriodic = 1; iPeriodic <= config->GetnMarker_Periodic()/2; iPeriodic++) { - InitiatePeriodicComms(geometry, config, iPeriodic, PERIODIC_VOLUME); - CompletePeriodicComms(geometry, config, iPeriodic, PERIODIC_VOLUME); - InitiatePeriodicComms(geometry, config, iPeriodic, PERIODIC_NEIGHBORS); - CompletePeriodicComms(geometry, config, iPeriodic, PERIODIC_NEIGHBORS); - } - SetImplicitPeriodic(euler_implicit); - if (iMesh == MESH_0) SetRotatePeriodic(true); - - /*--- Perform the MPI communication of the solution ---*/ - - InitiateComms(geometry, config, SOLUTION); - CompleteComms(geometry, config, SOLUTION); - - /* Store the initial CFL number for all grid points. */ - - const su2double CFL = config->GetCFL(MGLevel); - for (iPoint = 0; iPoint < nPoint; iPoint++) { - nodes->SetLocalCFL(iPoint, CFL); - } - Min_CFL_Local = CFL; - Max_CFL_Local = CFL; - Avg_CFL_Local = CFL; - - /*--- Add the solver name (max 8 characters) ---*/ - SolverName = "C.FLOW"; - } CNSSolver::~CNSSolver(void) { From 10aa2cecdae75dd5f9c624433bef78ffdf7578cb Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Tue, 4 Feb 2020 20:29:31 +0000 Subject: [PATCH 090/118] document and cleanup reducer strategy --- Common/src/geometry/CGeometry.cpp | 2 +- Common/src/linear_algebra/CSysMatrix.cpp | 15 ++-- SU2_CFD/include/solvers/CEulerSolver.hpp | 28 ++++++-- SU2_CFD/include/solvers/CNSSolver.hpp | 13 +--- SU2_CFD/src/solvers/CEulerSolver.cpp | 92 ++++++++++-------------- SU2_CFD/src/solvers/CNSSolver.cpp | 6 +- 6 files changed, 76 insertions(+), 80 deletions(-) diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index 369dff426783..1c5e48ff6fb5 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -4037,7 +4037,7 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(void) { if (edgeColoring.empty() && nEdge) { - /*--- When not using threading use the natural coloring. ---*/ + /*--- When not using threading, and for coarse grids, use the natural coloring. ---*/ if ((omp_get_max_threads() == 1) || (MGLevel != MESH_0)) { edgeColoring = createNaturalColoring(nEdge); return edgeColoring; diff --git a/Common/src/linear_algebra/CSysMatrix.cpp b/Common/src/linear_algebra/CSysMatrix.cpp index ec18c78e3fa8..af3635438a3d 100644 --- a/Common/src/linear_algebra/CSysMatrix.cpp +++ b/Common/src/linear_algebra/CSysMatrix.cpp @@ -194,13 +194,16 @@ void CSysMatrix::Initialize(unsigned long npoint, unsigned long npoi * the off-diagonal entries and then setting the diagonal ones as the sum of column * (excluding the diagonal itself). We use the fact that the pattern is symmetric. ---*/ - col_ptr.resize(nnz, nullptr); + if ((geometry->GetMGLevel() != MESH_0) && (omp_get_max_threads() > 1)) { - SU2_OMP_PARALLEL_(for schedule(static,omp_heavy_size)) - for (auto iPoint = 0ul; iPoint < nPoint; ++iPoint) { - for (auto k = row_ptr[iPoint]; k < row_ptr[iPoint+1]; ++k) { - auto jPoint = col_ind[k]; - col_ptr[k] = GetBlock(jPoint, iPoint); + col_ptr.resize(nnz, nullptr); + + SU2_OMP_PARALLEL_(for schedule(static,omp_heavy_size)) + for (auto iPoint = 0ul; iPoint < nPoint; ++iPoint) { + for (auto k = row_ptr[iPoint]; k < row_ptr[iPoint+1]; ++k) { + auto jPoint = col_ind[k]; + col_ptr[k] = GetBlock(jPoint, iPoint); + } } } diff --git a/SU2_CFD/include/solvers/CEulerSolver.hpp b/SU2_CFD/include/solvers/CEulerSolver.hpp index dde6647b7009..715a19efa74f 100644 --- a/SU2_CFD/include/solvers/CEulerSolver.hpp +++ b/SU2_CFD/include/solvers/CEulerSolver.hpp @@ -265,7 +265,10 @@ class CEulerSolver : public CSolver { unsigned long ColorGroupSize; /*!< \brief Group size used for coloring, chunk size in edge loops must be a multiple of this. */ /*--- Edge fluxes, for OpenMP parallelization on coarse grids. As it is difficult to - * color them, we first store the fluxes and then compute the sum for each cell. ---*/ + * color them, we first store the fluxes and then compute the sum for each cell. + * This strategy is thread-safe but lower performance than writting to both end + * points of each edge, so we only use it when necessary, i.e. coarse grids and + * with more than one thread per MPI rank. ---*/ CSysVector EdgeFluxes; /*!< \brief Flux across each edge. */ @@ -285,8 +288,13 @@ class CEulerSolver : public CSolver { template void Explicit_Iteration(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iRKStep); -public: + /*! + * \brief Sum the edge fluxes for each cell to populate the residual vector, only used on coarse grids. + * \param[in] geometry - Geometrical definition of the problem. + */ + void SumEdgeFluxes(CGeometry* geometry); +public: /*! * \brief Constructor of the class. @@ -294,7 +302,7 @@ class CEulerSolver : public CSolver { CEulerSolver(void); /*! - * \overload + * \overload Main constructor of this class. * \param[in] geometry - Geometrical definition of the problem. * \param[in] config - Definition of the particular problem. * \param[in] iMesh - Grid level. @@ -414,8 +422,18 @@ class CEulerSolver : public CSolver { CConfig *config, unsigned short iMesh) final; - virtual void Viscous_Residual(unsigned long iEdge, CGeometry *geometry, CSolver **solver_container, - CNumerics *numerics, CConfig *config) {} + /*! + * \brief Compute the viscous contribution for a particular edge. + * \note The convective residual methods include a call to this for each edge, + * this allows convective and viscous loops to be "fused". + * \param[in] iEdge - Edge for which the flux and Jacobians are to be computed. + * \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. + */ + inline virtual void Viscous_Residual(unsigned long iEdge, CGeometry *geometry, CSolver **solver_container, + CNumerics *numerics, CConfig *config) { } /*! * \brief Recompute the extrapolated quantities, after MUSCL reconstruction, diff --git a/SU2_CFD/include/solvers/CNSSolver.hpp b/SU2_CFD/include/solvers/CNSSolver.hpp index 887b4ca8971c..8d49125a132f 100644 --- a/SU2_CFD/include/solvers/CNSSolver.hpp +++ b/SU2_CFD/include/solvers/CNSSolver.hpp @@ -412,20 +412,13 @@ class CNSSolver final : public CEulerSolver { inline su2double GetCD_Visc(unsigned short val_marker) const override { return ViscCoeff.CD[val_marker]; } /*! - * \brief Compute the viscous residuals. + * \brief Compute the viscous contribution for a particular edge. + * \param[in] iEdge - Edge for which the flux and Jacobians are to be computed. * \param[in] geometry - Geometrical definition of the problem. * \param[in] solver_container - Container vector with all the solutions. - * \param[in] numerics_container - Description of the numerical method. + * \param[in] 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_container, -// CConfig *config, -// unsigned short iMesh, -// unsigned short iRKStep) override; void Viscous_Residual(unsigned long iEdge, CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, CConfig *config) override; diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index fe6cf2da8ebe..3149759398cf 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -421,8 +421,8 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, SetBaseClassPointerToNodes(); #ifdef HAVE_OMP - /*--- On the fine grid get the edge coloring, on coarse grids (which are difficult to color) - * setup the reducer strategy, i.e. one loop over edges followed by a point loop to sum + /*--- Get the edge coloring, on coarse grids (which are difficult to color) setup the reducer strategy, + * if required (i.e. in parallel). One loop is performed over edges followed by a point loop to sum * the fluxes for each cell and set the diagonal of the system matrix. ---*/ const auto& coloring = geometry->GetEdgeColoring(); @@ -438,7 +438,7 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, } ColorGroupSize = geometry->GetEdgeColorGroupSize(); - if (MGLevel != MESH_0) { + if ((MGLevel != MESH_0) && (omp_get_max_threads() > 1)) { EdgeFluxes.Initialize(geometry->GetnEdge(), geometry->GetnEdge(), nVar, nullptr); } @@ -2898,6 +2898,9 @@ void CEulerSolver::Centered_Residual(CGeometry *geometry, CSolver **solver_conta /*--- Pick one numerics object per thread. ---*/ CNumerics* numerics = numerics_container[CONV_TERM + omp_get_thread_num()*MAX_TERMS]; + /*--- Determine if using the reducer strategy is necessary, see CEulerSolver::SumEdgeFluxes(). ---*/ + const bool reducer_strategy = (MGLevel != MESH_0) && (omp_get_num_threads() > 1); + #ifdef HAVE_OMP /*--- Chunk size is at least OMP_MIN_SIZE and a multiple of the color group size. ---*/ auto chunkSize = roundUpDiv(OMP_MIN_SIZE, ColorGroupSize)*ColorGroupSize; @@ -2949,18 +2952,14 @@ void CEulerSolver::Centered_Residual(CGeometry *geometry, CSolver **solver_conta auto residual = numerics->ComputeResidual(config); - /*--- Update convective and artificial dissipation residuals ---*/ + /*--- Update convective and artificial dissipation residuals. ---*/ -#ifdef HAVE_OMP - if (MGLevel != MESH_0) { + if (reducer_strategy) { EdgeFluxes.SetBlock(iEdge, residual); if (implicit) Jacobian.UpdateBlocks(iEdge, residual.jacobian_i, residual.jacobian_j); } else { -#else - { -#endif LinSysRes.AddBlock(iPoint, residual); LinSysRes.SubtractBlock(jPoint, residual); @@ -2976,26 +2975,11 @@ void CEulerSolver::Centered_Residual(CGeometry *geometry, CSolver **solver_conta } } // end color loop -#ifdef HAVE_OMP - if (MGLevel != MESH_0) { - - SU2_OMP_FOR_STAT(omp_chunk_size) - for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) { - - for (unsigned short iNeigh = 0; iNeigh < geometry->node[iPoint]->GetnPoint(); ++iNeigh) { - - auto iEdge = geometry->node[iPoint]->GetEdge(iNeigh); - - if (iPoint == geometry->edge[iEdge]->GetNode(0)) - LinSysRes.AddBlock(iPoint, EdgeFluxes.GetBlock(iEdge)); - else - LinSysRes.SubtractBlock(iPoint, EdgeFluxes.GetBlock(iEdge)); - } - } - - if (implicit) Jacobian.SetDiagonalAsColumnSum(); + if (reducer_strategy) { + SumEdgeFluxes(geometry); + if (implicit) + Jacobian.SetDiagonalAsColumnSum(); } -#endif } // end SU2_OMP_PARALLEL @@ -3035,6 +3019,9 @@ void CEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_contain su2double Primitive_i[MAXNVAR] = {0.0}, Primitive_j[MAXNVAR] = {0.0}; su2double Secondary_i[MAXNVAR] = {0.0}, Secondary_j[MAXNVAR] = {0.0}; + /*--- Determine if using the reducer strategy is necessary, see CEulerSolver::SumEdgeFluxes(). ---*/ + const bool reducer_strategy = (MGLevel != MESH_0) && (omp_get_num_threads() > 1); + /*--- Loop over all the edges ---*/ #ifdef HAVE_OMP @@ -3207,23 +3194,19 @@ void CEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_contain /*--- Set the final value of the Roe dissipation coefficient ---*/ - if (kind_dissipation != NO_ROELOWDISS) { + if ((kind_dissipation != NO_ROELOWDISS) && (MGLevel != MESH_0)) { nodes->SetRoe_Dissipation(iPoint,numerics->GetDissipation()); nodes->SetRoe_Dissipation(jPoint,numerics->GetDissipation()); } /*--- Update residual value ---*/ -#ifdef HAVE_OMP - if (MGLevel != MESH_0) { + if (reducer_strategy) { EdgeFluxes.SetBlock(iEdge, residual); if (implicit) Jacobian.UpdateBlocks(iEdge, residual.jacobian_i, residual.jacobian_j); } else { -#else - { -#endif LinSysRes.AddBlock(iPoint, residual); LinSysRes.SubtractBlock(jPoint, residual); @@ -3239,26 +3222,11 @@ void CEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_contain } } // end color loop -#ifdef HAVE_OMP - if (MGLevel != MESH_0) { - - SU2_OMP_FOR_STAT(omp_chunk_size) - for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) { - - for (unsigned short iNeigh = 0; iNeigh < geometry->node[iPoint]->GetnPoint(); ++iNeigh) { - - auto iEdge = geometry->node[iPoint]->GetEdge(iNeigh); - - if (iPoint == geometry->edge[iEdge]->GetNode(0)) - LinSysRes.AddBlock(iPoint, EdgeFluxes.GetBlock(iEdge)); - else - LinSysRes.SubtractBlock(iPoint, EdgeFluxes.GetBlock(iEdge)); - } - } - - if (implicit) Jacobian.SetDiagonalAsColumnSum(); + if (reducer_strategy) { + SumEdgeFluxes(geometry); + if (implicit) + Jacobian.SetDiagonalAsColumnSum(); } -#endif } // end SU2_OMP_PARALLEL @@ -3273,6 +3241,24 @@ void CEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_contain } } +void CEulerSolver::SumEdgeFluxes(CGeometry* geometry) { + + SU2_OMP_FOR_STAT(omp_chunk_size) + for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) { + + for (unsigned short iNeigh = 0; iNeigh < geometry->node[iPoint]->GetnPoint(); ++iNeigh) { + + auto iEdge = geometry->node[iPoint]->GetEdge(iNeigh); + + if (iPoint == geometry->edge[iEdge]->GetNode(0)) + LinSysRes.AddBlock(iPoint, EdgeFluxes.GetBlock(iEdge)); + else + LinSysRes.SubtractBlock(iPoint, EdgeFluxes.GetBlock(iEdge)); + } + } + +} + void CEulerSolver::ComputeConsistentExtrapolation(CFluidModel *fluidModel, unsigned short nDim, su2double *primitive, su2double *secondary) { diff --git a/SU2_CFD/src/solvers/CNSSolver.cpp b/SU2_CFD/src/solvers/CNSSolver.cpp index 241af41cba69..1c3e89c5cd1d 100644 --- a/SU2_CFD/src/solvers/CNSSolver.cpp +++ b/SU2_CFD/src/solvers/CNSSolver.cpp @@ -413,16 +413,12 @@ void CNSSolver::Viscous_Residual(unsigned long iEdge, CGeometry *geometry, CSolv auto residual = numerics->ComputeResidual(config); -#ifdef HAVE_OMP - if (MGLevel != MESH_0) { + if ((MGLevel != MESH_0) && (omp_get_num_threads() > 1)) { EdgeFluxes.SubtractBlock(iEdge, residual); if (implicit) Jacobian.UpdateBlocksSub(iEdge, residual.jacobian_i, residual.jacobian_j); } else { -#else - { -#endif LinSysRes.SubtractBlock(iPoint, residual); LinSysRes.AddBlock(jPoint, residual); From 7ef421a888eedf4f656e36cdc554a63561a32d3c Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Thu, 6 Feb 2020 19:44:15 +0000 Subject: [PATCH 091/118] move incompressible convective numerics to new return type --- .../numerics/flow/convection/centered.hpp | 24 ++-- .../include/numerics/flow/convection/fds.hpp | 16 +-- .../src/numerics/flow/convection/centered.cpp | 114 +++++++++++------- SU2_CFD/src/numerics/flow/convection/fds.cpp | 57 ++++++--- SU2_CFD/src/solvers/CIncEulerSolver.cpp | 66 +++++----- 5 files changed, 163 insertions(+), 114 deletions(-) diff --git a/SU2_CFD/include/numerics/flow/convection/centered.hpp b/SU2_CFD/include/numerics/flow/convection/centered.hpp index d093e3e6d353..18a682aa23aa 100644 --- a/SU2_CFD/include/numerics/flow/convection/centered.hpp +++ b/SU2_CFD/include/numerics/flow/convection/centered.hpp @@ -226,7 +226,7 @@ class CCentJST_Flow final : public CCentBase_Flow { * \ingroup ConvDiscr * \author F. Palacios, T. Economon */ -class CCentLaxInc_Flow : public CNumerics { +class CCentLaxInc_Flow final : public CNumerics { private: unsigned short iDim, iVar, jVar; /*!< \brief Iteration on dimension and variables. */ su2double *Diff_V, /*!< \brief Difference of primitive variables. */ @@ -252,6 +252,9 @@ class CCentLaxInc_Flow : public CNumerics { variable_density, /*!< \brief Variable density incompressible flows. */ energy; /*!< \brief computation with the energy equation. */ + su2double** Jacobian_i = nullptr; /*!< \brief The Jacobian w.r.t. point i after computation. */ + su2double** Jacobian_j = nullptr; /*!< \brief The Jacobian w.r.t. point j after computation. */ + public: /*! * \brief Constructor of the class. @@ -268,12 +271,11 @@ class CCentLaxInc_Flow : public CNumerics { /*! * \brief Compute the flow residual using a Lax method. - * \param[out] val_residual - Pointer to the residual array. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). * \param[in] config - Definition of the particular problem. + * \return A lightweight const-view (read-only) of the residual/flux and Jacobians. */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, const CConfig* config); + ResidualType<> ComputeResidual(const CConfig* config) override; + }; /*! @@ -282,7 +284,7 @@ class CCentLaxInc_Flow : public CNumerics { * \ingroup ConvDiscr * \author F. Palacios, T. Economon */ -class CCentJSTInc_Flow : public CNumerics { +class CCentJSTInc_Flow final : public CNumerics { private: unsigned short iDim, iVar, jVar; /*!< \brief Iteration on dimension and variables. */ @@ -310,6 +312,9 @@ class CCentJSTInc_Flow : public CNumerics { variable_density, /*!< \brief Variable density incompressible flows. */ energy; /*!< \brief computation with the energy equation. */ + su2double** Jacobian_i = nullptr; /*!< \brief The Jacobian w.r.t. point i after computation. */ + su2double** Jacobian_j = nullptr; /*!< \brief The Jacobian w.r.t. point j after computation. */ + public: /*! * \brief Constructor of the class. @@ -326,10 +331,9 @@ class CCentJSTInc_Flow : public CNumerics { /*! * \brief Compute the flow residual using a JST method. - * \param[out] val_residual - Pointer to the residual array. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). * \param[in] config - Definition of the particular problem. + * \return A lightweight const-view (read-only) of the residual/flux and Jacobians. */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, const CConfig* config); + ResidualType<> ComputeResidual(const CConfig* config) override; + }; diff --git a/SU2_CFD/include/numerics/flow/convection/fds.hpp b/SU2_CFD/include/numerics/flow/convection/fds.hpp index 7e962ef88d27..6747ffd5028e 100644 --- a/SU2_CFD/include/numerics/flow/convection/fds.hpp +++ b/SU2_CFD/include/numerics/flow/convection/fds.hpp @@ -36,7 +36,7 @@ * \ingroup ConvDiscr * \author F. Palacios, T. Economon */ -class CUpwFDSInc_Flow : public CNumerics { +class CUpwFDSInc_Flow final : public CNumerics { private: bool implicit, /*!< \brief Implicit calculation. */ dynamic_grid, /*!< \brief Modification for grid movement. */ @@ -54,6 +54,10 @@ class CUpwFDSInc_Flow : public CNumerics { MeanDensity, MeanPressure, MeanSoundSpeed, MeanBetaInc2, MeanEnthalpy, MeanCp, MeanTemperature; /*!< \brief Mean values of primitive variables. */ unsigned short iDim, iVar, jVar, kVar; + su2double* Flux = nullptr; /*!< \brief The flux / residual across the edge. */ + su2double** Jacobian_i = nullptr; /*!< \brief The Jacobian w.r.t. point i after computation. */ + su2double** Jacobian_j = nullptr; /*!< \brief The Jacobian w.r.t. point j after computation. */ + public: /*! @@ -62,7 +66,7 @@ class CUpwFDSInc_Flow : public CNumerics { * \param[in] val_nVar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CUpwFDSInc_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config); + CUpwFDSInc_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig *config); /*! * \brief Destructor of the class. @@ -71,11 +75,9 @@ class CUpwFDSInc_Flow : public CNumerics { /*! * \brief Compute the upwind flux between two nodes i and j. - * \param[out] val_residual - Pointer to the residual array. - * \param[out] val_Jacobian_i - Jacobian of the numerical method at node i (implicit computation). - * \param[out] val_Jacobian_j - Jacobian of the numerical method at node j (implicit computation). * \param[in] config - Definition of the particular problem. + * \return A lightweight const-view (read-only) of the residual/flux and Jacobians. */ - void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, - CConfig *config); + ResidualType<> ComputeResidual(const CConfig* config) override; + }; diff --git a/SU2_CFD/src/numerics/flow/convection/centered.cpp b/SU2_CFD/src/numerics/flow/convection/centered.cpp index 1b1ab3d0af07..0c52f2f9ae8a 100644 --- a/SU2_CFD/src/numerics/flow/convection/centered.cpp +++ b/SU2_CFD/src/numerics/flow/convection/centered.cpp @@ -357,9 +357,13 @@ CCentLaxInc_Flow::CCentLaxInc_Flow(unsigned short val_nDim, unsigned short val_n MeanVelocity = new su2double[nDim]; ProjFlux = new su2double[nVar]; Precon = new su2double*[nVar]; - - for (iVar = 0; iVar < nVar; iVar++) + Jacobian_i = new su2double* [nVar]; + Jacobian_j = new su2double* [nVar]; + for (iVar = 0; iVar < nVar; iVar++) { Precon[iVar] = new su2double[nVar]; + Jacobian_i[iVar] = new su2double [nVar]; + Jacobian_j[iVar] = new su2double [nVar]; + } } @@ -375,9 +379,18 @@ CCentLaxInc_Flow::~CCentLaxInc_Flow(void) { delete [] Precon[iVar]; delete [] Precon; + if (Jacobian_i != nullptr) { + for (iVar = 0; iVar < nVar; iVar++) { + delete [] Jacobian_i[iVar]; + delete [] Jacobian_j[iVar]; + } + delete [] Jacobian_i; + delete [] Jacobian_j; + } + } -void CCentLaxInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, const CConfig* config) { +CNumerics::ResidualType<> CCentLaxInc_Flow::ComputeResidual(const CConfig* config) { su2double U_i[5] = {0.0}, U_j[5] = {0.0}; su2double ProjGridVel = 0.0, ProjVelocity = 0.0; @@ -427,19 +440,13 @@ void CCentLaxInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_ GetInviscidIncProjFlux(&MeanDensity, MeanVelocity, &MeanPressure, &MeanBetaInc2, &MeanEnthalpy, Normal, ProjFlux); - /*--- Compute inviscid residual ---*/ - - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] = ProjFlux[iVar]; - } - /*--- Jacobians of the inviscid flux ---*/ if (implicit) { - GetInviscidIncProjJac(&MeanDensity, MeanVelocity, &MeanBetaInc2, &MeanCp, &MeanTemperature, &MeandRhodT, Normal, 0.5, val_Jacobian_i); + GetInviscidIncProjJac(&MeanDensity, MeanVelocity, &MeanBetaInc2, &MeanCp, &MeanTemperature, &MeandRhodT, Normal, 0.5, Jacobian_i); for (iVar = 0; iVar < nVar; iVar++) { for (jVar = 0; jVar < nVar; jVar++) { - val_Jacobian_j[iVar][jVar] = val_Jacobian_i[iVar][jVar]; + Jacobian_j[iVar][jVar] = Jacobian_i[iVar][jVar]; } } } @@ -460,17 +467,17 @@ void CCentLaxInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_ /*--- Residual contributions ---*/ for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] -= ProjVelocity * 0.5*(U_i[iVar]+U_j[iVar]); + ProjFlux[iVar] -= ProjVelocity * 0.5*(U_i[iVar]+U_j[iVar]); /*--- Jacobian contributions ---*/ /*--- Implicit terms ---*/ if (implicit) { for (iDim = 0; iDim < nDim; iDim++){ - val_Jacobian_i[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_i; - val_Jacobian_j[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_j; + Jacobian_i[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_i; + Jacobian_j[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_j; } - val_Jacobian_i[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_i*Cp_i; - val_Jacobian_j[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_j*Cp_j; + Jacobian_i[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_i*Cp_i; + Jacobian_j[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_j*Cp_j; } } } @@ -518,10 +525,10 @@ void CCentLaxInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_ for (iVar = 0; iVar < nVar; iVar++) { for (jVar = 0; jVar < nVar; jVar++) { - val_residual[iVar] += Precon[iVar][jVar]*Epsilon_0*Diff_V[jVar]*StretchingFactor*MeanLambda; + ProjFlux[iVar] += Precon[iVar][jVar]*Epsilon_0*Diff_V[jVar]*StretchingFactor*MeanLambda; if (implicit) { - val_Jacobian_i[iVar][jVar] += Precon[iVar][jVar]*Epsilon_0*StretchingFactor*MeanLambda; - val_Jacobian_j[iVar][jVar] -= Precon[iVar][jVar]*Epsilon_0*StretchingFactor*MeanLambda; + Jacobian_i[iVar][jVar] += Precon[iVar][jVar]*Epsilon_0*StretchingFactor*MeanLambda; + Jacobian_j[iVar][jVar] -= Precon[iVar][jVar]*Epsilon_0*StretchingFactor*MeanLambda; } } } @@ -529,17 +536,20 @@ void CCentLaxInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_ /*--- Remove energy contributions if we aren't solving the energy equation. ---*/ if (!energy) { - val_residual[nDim+1] = 0.0; + ProjFlux[nDim+1] = 0.0; if (implicit) { for (iVar = 0; iVar < nVar; iVar++) { - val_Jacobian_i[iVar][nDim+1] = 0.0; - val_Jacobian_j[iVar][nDim+1] = 0.0; + Jacobian_i[iVar][nDim+1] = 0.0; + Jacobian_j[iVar][nDim+1] = 0.0; - val_Jacobian_i[nDim+1][iVar] = 0.0; - val_Jacobian_j[nDim+1][iVar] = 0.0; + Jacobian_i[nDim+1][iVar] = 0.0; + Jacobian_j[nDim+1][iVar] = 0.0; } } } + + return ResidualType<>(ProjFlux, Jacobian_i, Jacobian_j); + } @@ -566,9 +576,13 @@ CCentJSTInc_Flow::CCentJSTInc_Flow(unsigned short val_nDim, unsigned short val_n MeanVelocity = new su2double [nDim]; ProjFlux = new su2double [nVar]; Precon = new su2double*[nVar]; - - for (iVar = 0; iVar < nVar; iVar++) + Jacobian_i = new su2double* [nVar]; + Jacobian_j = new su2double* [nVar]; + for (iVar = 0; iVar < nVar; iVar++) { Precon[iVar] = new su2double[nVar]; + Jacobian_i[iVar] = new su2double [nVar]; + Jacobian_j[iVar] = new su2double [nVar]; + } } @@ -585,9 +599,18 @@ CCentJSTInc_Flow::~CCentJSTInc_Flow(void) { delete [] Precon[iVar]; delete [] Precon; + if (Jacobian_i != nullptr) { + for (iVar = 0; iVar < nVar; iVar++) { + delete [] Jacobian_i[iVar]; + delete [] Jacobian_j[iVar]; + } + delete [] Jacobian_i; + delete [] Jacobian_j; + } + } -void CCentJSTInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, const CConfig* config) { +CNumerics::ResidualType<> CCentJSTInc_Flow::ComputeResidual(const CConfig* config) { su2double U_i[5] = {0.0}, U_j[5] = {0.0}; su2double ProjGridVel = 0.0; @@ -637,17 +660,13 @@ void CCentJSTInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_ GetInviscidIncProjFlux(&MeanDensity, MeanVelocity, &MeanPressure, &MeanBetaInc2, &MeanEnthalpy, Normal, ProjFlux); - for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] = ProjFlux[iVar]; - } - /*--- Jacobians of the inviscid flux ---*/ if (implicit) { - GetInviscidIncProjJac(&MeanDensity, MeanVelocity, &MeanBetaInc2, &MeanCp, &MeanTemperature, &MeandRhodT, Normal, 0.5, val_Jacobian_i); + GetInviscidIncProjJac(&MeanDensity, MeanVelocity, &MeanBetaInc2, &MeanCp, &MeanTemperature, &MeandRhodT, Normal, 0.5, Jacobian_i); for (iVar = 0; iVar < nVar; iVar++) { for (jVar = 0; jVar < nVar; jVar++) { - val_Jacobian_j[iVar][jVar] = val_Jacobian_i[iVar][jVar]; + Jacobian_j[iVar][jVar] = Jacobian_i[iVar][jVar]; } } } @@ -669,17 +688,17 @@ void CCentJSTInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_ /*--- Residual contributions ---*/ for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] -= ProjVelocity * 0.5*(U_i[iVar]+U_j[iVar]); + ProjFlux[iVar] -= ProjVelocity * 0.5*(U_i[iVar]+U_j[iVar]); /*--- Jacobian contributions ---*/ /*--- Implicit terms ---*/ if (implicit) { for (iDim = 0; iDim < nDim; iDim++){ - val_Jacobian_i[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_i; - val_Jacobian_j[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_j; + Jacobian_i[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_i; + Jacobian_j[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_j; } - val_Jacobian_i[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_i*Cp_i; - val_Jacobian_j[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_j*Cp_j; + Jacobian_i[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_i*Cp_i; + Jacobian_j[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_j*Cp_j; } } } @@ -732,10 +751,10 @@ void CCentJSTInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_ for (iVar = 0; iVar < nVar; iVar++) { for (jVar = 0; jVar < nVar; jVar++) { - val_residual[iVar] += Precon[iVar][jVar]*(Epsilon_2*Diff_V[jVar] - Epsilon_4*Diff_Lapl[jVar])*StretchingFactor*MeanLambda; + ProjFlux[iVar] += Precon[iVar][jVar]*(Epsilon_2*Diff_V[jVar] - Epsilon_4*Diff_Lapl[jVar])*StretchingFactor*MeanLambda; if (implicit) { - val_Jacobian_i[iVar][jVar] += Precon[iVar][jVar]*(Epsilon_2 + Epsilon_4*su2double(Neighbor_i+1))*StretchingFactor*MeanLambda; - val_Jacobian_j[iVar][jVar] -= Precon[iVar][jVar]*(Epsilon_2 + Epsilon_4*su2double(Neighbor_j+1))*StretchingFactor*MeanLambda; + Jacobian_i[iVar][jVar] += Precon[iVar][jVar]*(Epsilon_2 + Epsilon_4*su2double(Neighbor_i+1))*StretchingFactor*MeanLambda; + Jacobian_j[iVar][jVar] -= Precon[iVar][jVar]*(Epsilon_2 + Epsilon_4*su2double(Neighbor_j+1))*StretchingFactor*MeanLambda; } } } @@ -743,15 +762,18 @@ void CCentJSTInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_ /*--- Remove energy contributions if not solving the energy equation. ---*/ if (!energy) { - val_residual[nDim+1] = 0.0; + ProjFlux[nDim+1] = 0.0; if (implicit) { for (iVar = 0; iVar < nVar; iVar++) { - val_Jacobian_i[iVar][nDim+1] = 0.0; - val_Jacobian_j[iVar][nDim+1] = 0.0; + Jacobian_i[iVar][nDim+1] = 0.0; + Jacobian_j[iVar][nDim+1] = 0.0; - val_Jacobian_i[nDim+1][iVar] = 0.0; - val_Jacobian_j[nDim+1][iVar] = 0.0; + Jacobian_i[nDim+1][iVar] = 0.0; + Jacobian_j[nDim+1][iVar] = 0.0; } } } + + return ResidualType<>(ProjFlux, Jacobian_i, Jacobian_j); + } diff --git a/SU2_CFD/src/numerics/flow/convection/fds.cpp b/SU2_CFD/src/numerics/flow/convection/fds.cpp index ee6487320340..943e24530a02 100644 --- a/SU2_CFD/src/numerics/flow/convection/fds.cpp +++ b/SU2_CFD/src/numerics/flow/convection/fds.cpp @@ -27,7 +27,7 @@ #include "../../../../include/numerics/flow/convection/fds.hpp" -CUpwFDSInc_Flow::CUpwFDSInc_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { +CUpwFDSInc_Flow::CUpwFDSInc_Flow(unsigned short val_nDim, unsigned short val_nVar, const CConfig *config) : CNumerics(val_nDim, val_nVar, config) { implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); variable_density = (config->GetKind_DensityModel() == VARIABLE); @@ -35,6 +35,7 @@ CUpwFDSInc_Flow::CUpwFDSInc_Flow(unsigned short val_nDim, unsigned short val_nVa /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ dynamic_grid = config->GetDynamic_Grid(); + Flux = new su2double[nVar]; Diff_V = new su2double[nVar]; Velocity_i = new su2double[nDim]; Velocity_j = new su2double[nDim]; @@ -45,16 +46,20 @@ CUpwFDSInc_Flow::CUpwFDSInc_Flow(unsigned short val_nDim, unsigned short val_nVa Epsilon = new su2double[nVar]; Precon = new su2double*[nVar]; invPrecon_A = new su2double*[nVar]; - + Jacobian_i = new su2double*[nVar]; + Jacobian_j = new su2double*[nVar]; for (iVar = 0; iVar < nVar; iVar++) { Precon[iVar] = new su2double[nVar]; invPrecon_A[iVar] = new su2double[nVar]; + Jacobian_i[iVar] = new su2double[nVar]; + Jacobian_j[iVar] = new su2double[nVar]; } } CUpwFDSInc_Flow::~CUpwFDSInc_Flow(void) { + delete [] Flux; delete [] Diff_V; delete [] Velocity_i; delete [] Velocity_j; @@ -71,9 +76,18 @@ CUpwFDSInc_Flow::~CUpwFDSInc_Flow(void) { delete [] Precon; delete [] invPrecon_A; + if (Jacobian_i != nullptr) { + for (iVar = 0; iVar < nVar; iVar++) { + delete [] Jacobian_i[iVar]; + delete [] Jacobian_j[iVar]; + } + delete [] Jacobian_i; + delete [] Jacobian_j; + } + } -void CUpwFDSInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { +CNumerics::ResidualType<> CUpwFDSInc_Flow::ComputeResidual(const CConfig *config) { su2double U_i[5] = {0.0,0.0,0.0,0.0,0.0}, U_j[5] = {0.0,0.0,0.0,0.0,0.0}; su2double ProjGridVel = 0.0; @@ -199,23 +213,23 @@ void CUpwFDSInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_J /*--- Build the inviscid Jacobian w.r.t. the primitive variables ---*/ if (implicit) { - GetInviscidIncProjJac(&DensityInc_i, Velocity_i, &BetaInc2_i, &Cp_i, &Temperature_i, &dRhodT_i, Normal, 0.5, val_Jacobian_i); - GetInviscidIncProjJac(&DensityInc_j, Velocity_j, &BetaInc2_j, &Cp_j, &Temperature_j, &dRhodT_j, Normal, 0.5, val_Jacobian_j); + GetInviscidIncProjJac(&DensityInc_i, Velocity_i, &BetaInc2_i, &Cp_i, &Temperature_i, &dRhodT_i, Normal, 0.5, Jacobian_i); + GetInviscidIncProjJac(&DensityInc_j, Velocity_j, &BetaInc2_j, &Cp_j, &Temperature_j, &dRhodT_j, Normal, 0.5, Jacobian_j); } /*--- Compute dissipation as Precon x |A_precon| x dV. If implicit, store Precon x |A_precon| from dissipation term. ---*/ for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] = 0.5*(ProjFlux_i[iVar]+ProjFlux_j[iVar]); + Flux[iVar] = 0.5*(ProjFlux_i[iVar]+ProjFlux_j[iVar]); for (jVar = 0; jVar < nVar; jVar++) { Proj_ModJac_Tensor_ij = 0.0; for (kVar = 0; kVar < nVar; kVar++) Proj_ModJac_Tensor_ij += Precon[iVar][kVar]*invPrecon_A[kVar][jVar]; - val_residual[iVar] -= 0.5*Proj_ModJac_Tensor_ij*Diff_V[jVar]; + Flux[iVar] -= 0.5*Proj_ModJac_Tensor_ij*Diff_V[jVar]; if (implicit) { - val_Jacobian_i[iVar][jVar] += 0.5*Proj_ModJac_Tensor_ij; - val_Jacobian_j[iVar][jVar] -= 0.5*Proj_ModJac_Tensor_ij; + Jacobian_i[iVar][jVar] += 0.5*Proj_ModJac_Tensor_ij; + Jacobian_j[iVar][jVar] -= 0.5*Proj_ModJac_Tensor_ij; } } } @@ -237,34 +251,37 @@ void CUpwFDSInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_J /*--- Residual contributions ---*/ for (iVar = 0; iVar < nVar; iVar++) { - val_residual[iVar] -= ProjVelocity * 0.5*(U_i[iVar]+U_j[iVar]); + Flux[iVar] -= ProjVelocity * 0.5*(U_i[iVar]+U_j[iVar]); /*--- Jacobian contributions ---*/ /*--- Implicit terms ---*/ if (implicit) { for (iDim = 0; iDim < nDim; iDim++){ - val_Jacobian_i[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_i; - val_Jacobian_j[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_j; + Jacobian_i[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_i; + Jacobian_j[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_j; } - val_Jacobian_i[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_i*Cp_i; - val_Jacobian_j[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_j*Cp_j; + Jacobian_i[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_i*Cp_i; + Jacobian_j[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_j*Cp_j; } } } if (!energy) { - val_residual[nDim+1] = 0.0; + Flux[nDim+1] = 0.0; if (implicit) { for (iVar = 0; iVar < nVar; iVar++) { - val_Jacobian_i[iVar][nDim+1] = 0.0; - val_Jacobian_j[iVar][nDim+1] = 0.0; + Jacobian_i[iVar][nDim+1] = 0.0; + Jacobian_j[iVar][nDim+1] = 0.0; - val_Jacobian_i[nDim+1][iVar] = 0.0; - val_Jacobian_j[nDim+1][iVar] = 0.0; + Jacobian_i[nDim+1][iVar] = 0.0; + Jacobian_j[nDim+1][iVar] = 0.0; } } } - AD::SetPreaccOut(val_residual, nVar); + AD::SetPreaccOut(Flux, nVar); AD::EndPreacc(); + + return ResidualType<>(Flux, Jacobian_i, Jacobian_j); + } diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index defec02c9bab..275e296a7523 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -1853,17 +1853,17 @@ void CIncEulerSolver::Centered_Residual(CGeometry *geometry, CSolver **solver_co /*--- Compute residuals, and Jacobians ---*/ - numerics->ComputeResidual(Res_Conv, Jacobian_i, Jacobian_j, config); + auto residual = numerics->ComputeResidual(config); /*--- Update convective and artificial dissipation residuals ---*/ - LinSysRes.AddBlock(iPoint, Res_Conv); - LinSysRes.SubtractBlock(jPoint, Res_Conv); + LinSysRes.AddBlock(iPoint, residual); + LinSysRes.SubtractBlock(jPoint, residual); /*--- Store implicit contributions from the residual calculation. ---*/ if (implicit) { - Jacobian.UpdateBlocks(iEdge, iPoint, jPoint, Jacobian_i, Jacobian_j); + Jacobian.UpdateBlocks(iEdge, iPoint, jPoint, residual.jacobian_i, residual.jacobian_j); } } @@ -2001,29 +2001,27 @@ void CIncEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_cont /*--- Compute the residual ---*/ - numerics->ComputeResidual(Res_Conv, Jacobian_i, Jacobian_j, config); + auto residual = numerics->ComputeResidual(config); /*--- Update residual value ---*/ - LinSysRes.AddBlock(iPoint, Res_Conv); - LinSysRes.SubtractBlock(jPoint, Res_Conv); + LinSysRes.AddBlock(iPoint, residual); + LinSysRes.SubtractBlock(jPoint, residual); /*--- Set implicit Jacobians ---*/ if (implicit) { - Jacobian.UpdateBlocks(iEdge, iPoint, jPoint, Jacobian_i, Jacobian_j); + Jacobian.UpdateBlocks(iEdge, iPoint, jPoint, residual.jacobian_i, residual.jacobian_j); } } /*--- 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); + if (iMesh == MESH_0) { + SU2_MPI::Reduce(&counter_local, &counter_global, 1, MPI_UNSIGNED_LONG, MPI_SUM, MASTER_NODE, MPI_COMM_WORLD); + config->SetNonphysical_Reconstr(counter_global); + } } } @@ -4066,16 +4064,16 @@ void CIncEulerSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_contain /*--- Compute the convective residual using an upwind scheme ---*/ - conv_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); + auto residual = conv_numerics->ComputeResidual(config); /*--- Update residual value ---*/ - LinSysRes.AddBlock(iPoint, Residual); + LinSysRes.AddBlock(iPoint, residual); /*--- Convective Jacobian contribution for implicit integration ---*/ if (implicit) - Jacobian.AddBlock2Diag(iPoint, Jacobian_i); + Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); /*--- Viscous residual contribution ---*/ @@ -4318,16 +4316,16 @@ void CIncEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, /*--- Compute the residual using an upwind scheme ---*/ - conv_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); + auto residual = conv_numerics->ComputeResidual(config); /*--- Update residual value ---*/ - LinSysRes.AddBlock(iPoint, Residual); + LinSysRes.AddBlock(iPoint, residual); /*--- Jacobian contribution for implicit integration ---*/ if (implicit) - Jacobian.AddBlock2Diag(iPoint, Jacobian_i); + Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); /*--- Viscous contribution, commented out because serious convergence problems ---*/ @@ -4526,16 +4524,16 @@ void CIncEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, /*--- Compute the residual using an upwind scheme ---*/ - conv_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); + auto residual = conv_numerics->ComputeResidual(config); /*--- Update residual value ---*/ - LinSysRes.AddBlock(iPoint, Residual); + LinSysRes.AddBlock(iPoint, residual); /*--- Jacobian contribution for implicit integration ---*/ if (implicit) { - Jacobian.AddBlock2Diag(iPoint, Jacobian_i); + Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); } /*--- Viscous contribution, commented out because serious convergence problems ---*/ @@ -4744,14 +4742,14 @@ void CIncEulerSolver::BC_Sym_Plane(CGeometry *geometry, 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); + auto residual = conv_numerics->ComputeResidual(config); /*--- Update residual value ---*/ - LinSysRes.AddBlock(iPoint, Residual); + LinSysRes.AddBlock(iPoint, residual); /*--- Jacobian contribution for implicit integration. ---*/ if (implicit) { - Jacobian.AddBlock2Diag(iPoint, Jacobian_i); + Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); } if (viscous) { @@ -4900,12 +4898,15 @@ void CIncEulerSolver::BC_Fluid_Interface(CGeometry *geometry, CSolver **solver_c /*--- Initialize Residual, this will serve to accumulate the average ---*/ - for (iVar = 0; iVar < nVar; iVar++) + for (iVar = 0; iVar < nVar; iVar++) { Residual[iVar] = 0.0; + for (jVar = 0; jVar < nVar; jVar++) + Jacobian_i[iVar][jVar] = 0.0; + } /*--- Loop over the nDonorVertexes and compute the averaged flux ---*/ - for (jVertex = 0; jVertex < nDonorVertex; jVertex++){ + for (jVertex = 0; jVertex < nDonorVertex; jVertex++) { Point_Normal = geometry->vertex[iMarker][iVertex]->GetNormal_Neighbor(); @@ -4935,12 +4936,15 @@ void CIncEulerSolver::BC_Fluid_Interface(CGeometry *geometry, CSolver **solver_c /*--- Compute the convective residual using an upwind scheme ---*/ - conv_numerics->ComputeResidual(tmp_residual, Jacobian_i, Jacobian_j, config); + auto residual = conv_numerics->ComputeResidual(config); /*--- Accumulate the residuals to compute the average ---*/ - for (iVar = 0; iVar < nVar; iVar++) - Residual[iVar] += weight*tmp_residual[iVar]; + for (iVar = 0; iVar < nVar; iVar++) { + Residual[iVar] += weight*residual.residual[iVar]; + for (jVar = 0; jVar < nVar; jVar++) + Jacobian_i[iVar][jVar] += weight*residual.jacobian_i[iVar][jVar]; + } } From 2620ac67bac44cf177ad4467396573024855a412 Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Thu, 6 Feb 2020 20:12:24 +0000 Subject: [PATCH 092/118] parallel CTurbSolver::SetResidual_DualTime --- SU2_CFD/src/solvers/CTurbSolver.cpp | 209 ++++++++++++++++------------ 1 file changed, 120 insertions(+), 89 deletions(-) diff --git a/SU2_CFD/src/solvers/CTurbSolver.cpp b/SU2_CFD/src/solvers/CTurbSolver.cpp index c096c7051c73..b19d24983769 100644 --- a/SU2_CFD/src/solvers/CTurbSolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSolver.cpp @@ -612,24 +612,35 @@ void CTurbSolver::ComputeUnderRelaxationFactor(CSolver **solver_container, CConf void CTurbSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iRKStep, unsigned short iMesh, unsigned short RunTime_EqSystem) { + const bool implicit = (config->GetKind_TimeIntScheme_Turb() == EULER_IMPLICIT); + const bool incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); + const bool first_order = (config->GetTime_Marching() == DT_STEPPING_1ST); + const bool second_order = (config->GetTime_Marching() == DT_STEPPING_2ND); + const unsigned short turbModel = config->GetKind_Turb_Model(); + + /*--- Store the physical time step ---*/ + + const su2double TimeStep = config->GetDelta_UnstTimeND(); + + /*--- Start OpenMP parallel section. ---*/ + + SU2_OMP_PARALLEL + { + /*--- Local variables ---*/ - unsigned short iVar, jVar, iMarker, iDim; + unsigned short iVar, iMarker, iDim; unsigned long iPoint, jPoint, iEdge, iVertex; - su2double *U_time_nM1, *U_time_n, *U_time_nP1; - su2double Volume_nM1, Volume_nP1, TimeStep; + const su2double *U_time_nM1, *U_time_n, *U_time_nP1; + su2double Volume_nM1, Volume_nP1; su2double Density_nM1, Density_n, Density_nP1; - su2double *Normal = NULL, *GridVel_i = NULL, *GridVel_j = NULL, Residual_GCL; - - bool implicit = (config->GetKind_TimeIntScheme_Turb() == EULER_IMPLICIT); + const su2double *Normal = NULL, *GridVel_i = NULL, *GridVel_j = NULL; + su2double Residual_GCL; - bool incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); - unsigned short turbModel = config->GetKind_Turb_Model(); + /*--- "Allocate" local (to the thread) Residual to then write to CSysVector. ---*/ + su2double Res_Time[MAXNVAR] = {0.0}; - /*--- Store the physical time step ---*/ - - TimeStep = config->GetDelta_UnstTimeND(); /*--- Compute the dual time-stepping source term for static meshes ---*/ @@ -637,6 +648,7 @@ void CTurbSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_con /*--- Loop over all nodes (excluding halos) ---*/ + SU2_OMP_FOR_STAT(omp_chunk_size) for (iPoint = 0; iPoint < nPointDomain; iPoint++) { /*--- Retrieve the solution at time levels n-1, n, and n+1. Note that @@ -675,38 +687,32 @@ void CTurbSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_con } for (iVar = 0; iVar < nVar; iVar++) { - if (config->GetTime_Marching() == DT_STEPPING_1ST) - Residual[iVar] = ( Density_nP1*U_time_nP1[iVar] - Density_n*U_time_n[iVar])*Volume_nP1 / TimeStep; - if (config->GetTime_Marching() == DT_STEPPING_2ND) - Residual[iVar] = ( 3.0*Density_nP1*U_time_nP1[iVar] - 4.0*Density_n*U_time_n[iVar] + if (first_order) + Res_Time[iVar] = ( Density_nP1*U_time_nP1[iVar] - Density_n*U_time_n[iVar])*Volume_nP1 / TimeStep; + if (second_order) + Res_Time[iVar] = ( 3.0*Density_nP1*U_time_nP1[iVar] - 4.0*Density_n*U_time_n[iVar] +1.0*Density_nM1*U_time_nM1[iVar])*Volume_nP1 / (2.0*TimeStep); } } else { for (iVar = 0; iVar < nVar; iVar++) { - if (config->GetTime_Marching() == DT_STEPPING_1ST) - Residual[iVar] = (U_time_nP1[iVar] - U_time_n[iVar])*Volume_nP1 / TimeStep; - if (config->GetTime_Marching() == DT_STEPPING_2ND) - Residual[iVar] = ( 3.0*U_time_nP1[iVar] - 4.0*U_time_n[iVar] + if (first_order) + Res_Time[iVar] = (U_time_nP1[iVar] - U_time_n[iVar])*Volume_nP1 / TimeStep; + if (second_order) + Res_Time[iVar] = ( 3.0*U_time_nP1[iVar] - 4.0*U_time_n[iVar] +1.0*U_time_nM1[iVar])*Volume_nP1 / (2.0*TimeStep); } } - /*--- Store the residual and compute the Jacobian contribution due - to the dual time source term. ---*/ + /*--- Store the residual and compute the Jacobian contribution due to the dual time source term. ---*/ - LinSysRes.AddBlock(iPoint, Residual); + LinSysRes.AddBlock(iPoint, Res_Time); if (implicit) { - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) Jacobian_i[iVar][jVar] = 0.0; - if (config->GetTime_Marching() == DT_STEPPING_1ST) - Jacobian_i[iVar][iVar] = Volume_nP1 / TimeStep; - if (config->GetTime_Marching() == DT_STEPPING_2ND) - Jacobian_i[iVar][iVar] = (Volume_nP1*3.0)/(2.0*TimeStep); - } - Jacobian.AddBlock2Diag(iPoint, Jacobian_i); + if (first_order) Jacobian.AddVal2Diag(iPoint, Volume_nP1/TimeStep); + if (second_order) Jacobian.AddVal2Diag(iPoint, (Volume_nP1*3.0)/(2.0*TimeStep)); } + } } else { @@ -719,8 +725,22 @@ void CTurbSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_con we will loop over the edges and boundaries to compute the GCL component of the dual time source term that depends on grid velocities. ---*/ - for (iEdge = 0; iEdge < geometry->GetnEdge(); iEdge++) { +#ifdef HAVE_OMP + /*--- Chunk size is at least OMP_MIN_SIZE and a multiple of the color group size. ---*/ + auto chunkSize = roundUpDiv(OMP_MIN_SIZE, ColorGroupSize)*ColorGroupSize; + + /*--- Loop over edge colors. ---*/ + for (auto color : EdgeColoring) + { + SU2_OMP_FOR_DYN(chunkSize) + for(auto k = 0ul; k < color.size; ++k) { + iEdge = color.indices[k]; +#else + /*--- Natural coloring. ---*/ + { + for (iEdge = 0ul; iEdge < geometry->GetnEdge(); iEdge++) { +#endif /*--- Get indices for nodes i & j plus the face normal ---*/ iPoint = geometry->edge[iEdge]->GetNode(0); @@ -746,15 +766,19 @@ void CTurbSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_con /*--- Multiply by density at node i for the SST model ---*/ if ((turbModel == SST) || (turbModel == SST_SUST)) { - 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); + 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 { + Res_Time[iVar] = Density_n*U_time_n[iVar]*Residual_GCL; + } + else { for (iVar = 0; iVar < nVar; iVar++) - Residual[iVar] = U_time_n[iVar]*Residual_GCL; + Res_Time[iVar] = U_time_n[iVar]*Residual_GCL; } - LinSysRes.AddBlock(iPoint, Residual); + LinSysRes.AddBlock(iPoint, Res_Time); /*--- Compute the GCL component of the source term for node j ---*/ @@ -763,65 +787,77 @@ void CTurbSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_con /*--- Multiply by density at node j for the SST model ---*/ if ((turbModel == SST) || (turbModel == SST_SUST)) { - 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]; + 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 { + Res_Time[iVar] = Density_n*U_time_n[iVar]*Residual_GCL; + } + else { for (iVar = 0; iVar < nVar; iVar++) - Residual[iVar] = U_time_n[iVar]*Residual_GCL; + Res_Time[iVar] = U_time_n[iVar]*Residual_GCL; } - LinSysRes.SubtractBlock(jPoint, Residual); + LinSysRes.SubtractBlock(jPoint, Res_Time); } + } // end color loop /*--- Loop over the boundary edges ---*/ for (iMarker = 0; iMarker < geometry->GetnMarker(); iMarker++) { if ((config->GetMarker_All_KindBC(iMarker) != INTERNAL_BOUNDARY) && (config->GetMarker_All_KindBC(iMarker) != PERIODIC_BOUNDARY)) { - for (iVertex = 0; iVertex < geometry->GetnVertex(iMarker); iVertex++) { - /*--- Get the index for node i plus the boundary face normal ---*/ + SU2_OMP_FOR_STAT(OMP_MIN_SIZE) + for (iVertex = 0; iVertex < geometry->GetnVertex(iMarker); iVertex++) { - iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); - Normal = geometry->vertex[iMarker][iVertex]->GetNormal(); + /*--- Get the index for node i plus the boundary face normal ---*/ - /*--- Grid velocities stored at boundary node i ---*/ + iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); + Normal = geometry->vertex[iMarker][iVertex]->GetNormal(); - GridVel_i = geometry->node[iPoint]->GetGridVel(); + /*--- Grid velocities stored at boundary node i ---*/ - /*--- Compute the GCL term by dotting the grid velocity with the face - normal. The normal is negated to match the boundary convention. ---*/ + GridVel_i = geometry->node[iPoint]->GetGridVel(); - Residual_GCL = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - Residual_GCL -= 0.5*(GridVel_i[iDim]+GridVel_i[iDim])*Normal[iDim]; + /*--- Compute the GCL term by dotting the grid velocity with the face + normal. The normal is negated to match the boundary convention. ---*/ - /*--- Compute the GCL component of the source term for node i ---*/ + Residual_GCL = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + Residual_GCL -= 0.5*(GridVel_i[iDim]+GridVel_i[iDim])*Normal[iDim]; - U_time_n = nodes->GetSolution_time_n(iPoint); + /*--- Compute the GCL component of the source term for node i ---*/ - /*--- Multiply by density at node i for the SST model ---*/ + U_time_n = nodes->GetSolution_time_n(iPoint); - if ((turbModel == SST) || (turbModel == SST_SUST)) { - 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 { - for (iVar = 0; iVar < nVar; iVar++) - Residual[iVar] = U_time_n[iVar]*Residual_GCL; - } - LinSysRes.AddBlock(iPoint, Residual); + /*--- Multiply by density at node i for the SST model ---*/ - } + if ((turbModel == SST) || (turbModel == SST_SUST)) { + 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++) + Res_Time[iVar] = Density_n*U_time_n[iVar]*Residual_GCL; + } + else { + for (iVar = 0; iVar < nVar; iVar++) + Res_Time[iVar] = U_time_n[iVar]*Residual_GCL; + } + LinSysRes.AddBlock(iPoint, Res_Time); + + } } } /*--- Loop over all nodes (excluding halos) to compute the remainder of the dual time-stepping source term. ---*/ + SU2_OMP_FOR_STAT(omp_chunk_size) for (iPoint = 0; iPoint < nPointDomain; iPoint++) { /*--- Retrieve the solution at time levels n-1, n, and n+1. Note that @@ -847,7 +883,7 @@ void CTurbSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_con /*--- If this is the SST model, we need to multiply by the density in order to get the conservative variables ---*/ - if (incompressible){ + if (incompressible) { /*--- This is temporary and only valid for constant-density problems: 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 @@ -856,48 +892,43 @@ void CTurbSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_con Density_n = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); Density_nP1 = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); } - else{ + else { 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++) { - if (config->GetTime_Marching() == DT_STEPPING_1ST) - Residual[iVar] = (Density_nP1*U_time_nP1[iVar] - Density_n*U_time_n[iVar])*(Volume_nP1/TimeStep); - if (config->GetTime_Marching() == DT_STEPPING_2ND) - Residual[iVar] = (Density_nP1*U_time_nP1[iVar] - Density_n*U_time_n[iVar])*(3.0*Volume_nP1/(2.0*TimeStep)) + if (first_order) + Res_Time[iVar] = (Density_nP1*U_time_nP1[iVar] - Density_n*U_time_n[iVar])*(Volume_nP1/TimeStep); + if (second_order) + Res_Time[iVar] = (Density_nP1*U_time_nP1[iVar] - Density_n*U_time_n[iVar])*(3.0*Volume_nP1/(2.0*TimeStep)) + (Density_nM1*U_time_nM1[iVar] - Density_n*U_time_n[iVar])*(Volume_nM1/(2.0*TimeStep)); } } else { for (iVar = 0; iVar < nVar; iVar++) { - if (config->GetTime_Marching() == DT_STEPPING_1ST) - Residual[iVar] = (U_time_nP1[iVar] - U_time_n[iVar])*(Volume_nP1/TimeStep); - if (config->GetTime_Marching() == DT_STEPPING_2ND) - Residual[iVar] = (U_time_nP1[iVar] - U_time_n[iVar])*(3.0*Volume_nP1/(2.0*TimeStep)) + if (first_order) + Res_Time[iVar] = (U_time_nP1[iVar] - U_time_n[iVar])*(Volume_nP1/TimeStep); + if (second_order) + Res_Time[iVar] = (U_time_nP1[iVar] - U_time_n[iVar])*(3.0*Volume_nP1/(2.0*TimeStep)) + (U_time_nM1[iVar] - U_time_n[iVar])*(Volume_nM1/(2.0*TimeStep)); } } - /*--- Store the residual and compute the Jacobian contribution due - to the dual time source term. ---*/ + /*--- Store the residual and compute the Jacobian contribution due to the dual time source term. ---*/ - LinSysRes.AddBlock(iPoint, Residual); + LinSysRes.AddBlock(iPoint, Res_Time); if (implicit) { - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) Jacobian_i[iVar][jVar] = 0.0; - if (config->GetTime_Marching() == DT_STEPPING_1ST) - Jacobian_i[iVar][iVar] = Volume_nP1/TimeStep; - if (config->GetTime_Marching() == DT_STEPPING_2ND) - Jacobian_i[iVar][iVar] = (3.0*Volume_nP1)/(2.0*TimeStep); - } - Jacobian.AddBlock2Diag(iPoint, Jacobian_i); + if (first_order) Jacobian.AddVal2Diag(iPoint, Volume_nP1/TimeStep); + if (second_order) Jacobian.AddVal2Diag(iPoint, (Volume_nP1*3.0)/(2.0*TimeStep)); } } } + } // end SU2_OMP_PARALLEL + } From d3dbfd00097039092d6f36a764d7a293c3d24327 Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Fri, 7 Feb 2020 11:38:26 +0000 Subject: [PATCH 093/118] fix automake --- SU2_CFD/obj/Makefile.am | 1 - 1 file changed, 1 deletion(-) diff --git a/SU2_CFD/obj/Makefile.am b/SU2_CFD/obj/Makefile.am index 2db018d1bc48..219ceb7a94b7 100644 --- a/SU2_CFD/obj/Makefile.am +++ b/SU2_CFD/obj/Makefile.am @@ -181,7 +181,6 @@ libSU2Core_sources = ../src/definition_structure.cpp \ ../src/variables/CEulerVariable.cpp su2_cfd_sources = \ - ../include/SU2_CFD.cpp \ ../src/SU2_CFD.cpp libSU2Core_cxx_flags = -fPIC -std=c++11 From 9ba1988692e98c178ae97c966d76e15c55957dc7 Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Fri, 7 Feb 2020 12:14:44 +0000 Subject: [PATCH 094/118] cleanup of CSysVector access --- Common/include/linear_algebra/CSysVector.hpp | 8 +- SU2_CFD/src/output/CFlowCompOutput.cpp | 18 +- SU2_CFD/src/output/CFlowIncOutput.cpp | 18 +- SU2_CFD/src/output/CHeatOutput.cpp | 2 +- .../src/output/output_structure_legacy.cpp | 6326 ++++++++--------- SU2_CFD/src/solvers/CEulerSolver.cpp | 6 +- SU2_CFD/src/solvers/CFEASolver.cpp | 50 +- SU2_CFD/src/solvers/CSolver.cpp | 28 +- SU2_CFD/src/solvers/CTurbSASolver.cpp | 2 +- SU2_CFD/src/solvers/CTurbSolver.cpp | 74 +- 10 files changed, 3263 insertions(+), 3269 deletions(-) diff --git a/Common/include/linear_algebra/CSysVector.hpp b/Common/include/linear_algebra/CSysVector.hpp index 7f59b23055f4..d55759d67244 100644 --- a/Common/include/linear_algebra/CSysVector.hpp +++ b/Common/include/linear_algebra/CSysVector.hpp @@ -59,7 +59,7 @@ class CSysVector { * \brief Generic initialization from a scalar or array. * \note If val==nullptr vec_val is not initialized, only allocated. * \param[in] numBlk - number of blocks locally - * \param[in] numBlkDomain - number of blocks locally (without g cells) + * \param[in] numBlkDomain - number of blocks locally (without ghost cells) * \param[in] numVar - number of variables in each block * \param[in] val - default value for elements * \param[in] valIsArray - if true val is treated as array @@ -360,7 +360,11 @@ class CSysVector { * \param[in] val_var - inde of the residual to be set. * \return Value of the residual. */ - inline ScalarType GetBlock(unsigned long val_ipoint, unsigned long val_var) const { + inline const ScalarType& operator() (unsigned long val_ipoint, unsigned long val_var) const { + return vec_val[val_ipoint*nVar+val_var]; + } + inline ScalarType& operator() (unsigned long val_ipoint, unsigned long val_var) { return vec_val[val_ipoint*nVar+val_var]; } + }; diff --git a/SU2_CFD/src/output/CFlowCompOutput.cpp b/SU2_CFD/src/output/CFlowCompOutput.cpp index 73fe45157faa..3adb4f7b8f1c 100644 --- a/SU2_CFD/src/output/CFlowCompOutput.cpp +++ b/SU2_CFD/src/output/CFlowCompOutput.cpp @@ -484,24 +484,24 @@ void CFlowCompOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolv SetVolumeOutputValue("INTERMITTENCY", iPoint, Node_Turb->GetGammaBC(iPoint)); } - SetVolumeOutputValue("RES_DENSITY", iPoint, solver[FLOW_SOL]->LinSysRes.GetBlock(iPoint, 0)); - SetVolumeOutputValue("RES_MOMENTUM-X", iPoint, solver[FLOW_SOL]->LinSysRes.GetBlock(iPoint, 1)); - SetVolumeOutputValue("RES_MOMENTUM-Y", iPoint, solver[FLOW_SOL]->LinSysRes.GetBlock(iPoint, 2)); + SetVolumeOutputValue("RES_DENSITY", iPoint, solver[FLOW_SOL]->LinSysRes(iPoint, 0)); + SetVolumeOutputValue("RES_MOMENTUM-X", iPoint, solver[FLOW_SOL]->LinSysRes(iPoint, 1)); + SetVolumeOutputValue("RES_MOMENTUM-Y", iPoint, solver[FLOW_SOL]->LinSysRes(iPoint, 2)); if (nDim == 3){ - SetVolumeOutputValue("RES_MOMENTUM-Z", iPoint, solver[FLOW_SOL]->LinSysRes.GetBlock(iPoint, 3)); - SetVolumeOutputValue("RES_ENERGY", iPoint, solver[FLOW_SOL]->LinSysRes.GetBlock(iPoint, 4)); + SetVolumeOutputValue("RES_MOMENTUM-Z", iPoint, solver[FLOW_SOL]->LinSysRes(iPoint, 3)); + SetVolumeOutputValue("RES_ENERGY", iPoint, solver[FLOW_SOL]->LinSysRes(iPoint, 4)); } else { - SetVolumeOutputValue("RES_ENERGY", iPoint, solver[FLOW_SOL]->LinSysRes.GetBlock(iPoint, 3)); + SetVolumeOutputValue("RES_ENERGY", iPoint, solver[FLOW_SOL]->LinSysRes(iPoint, 3)); } switch(config->GetKind_Turb_Model()){ case SST: case SST_SUST: - SetVolumeOutputValue("RES_TKE", iPoint, solver[TURB_SOL]->LinSysRes.GetBlock(iPoint, 0)); - SetVolumeOutputValue("RES_DISSIPATION", iPoint, solver[TURB_SOL]->LinSysRes.GetBlock(iPoint, 1)); + SetVolumeOutputValue("RES_TKE", iPoint, solver[TURB_SOL]->LinSysRes(iPoint, 0)); + SetVolumeOutputValue("RES_DISSIPATION", iPoint, solver[TURB_SOL]->LinSysRes(iPoint, 1)); break; case SA: case SA_COMP: case SA_E: case SA_E_COMP: case SA_NEG: - SetVolumeOutputValue("RES_NU_TILDE", iPoint, solver[TURB_SOL]->LinSysRes.GetBlock(iPoint, 0)); + SetVolumeOutputValue("RES_NU_TILDE", iPoint, solver[TURB_SOL]->LinSysRes(iPoint, 0)); break; case NONE: break; diff --git a/SU2_CFD/src/output/CFlowIncOutput.cpp b/SU2_CFD/src/output/CFlowIncOutput.cpp index 016ea7c5cf6d..9c1581e326e9 100644 --- a/SU2_CFD/src/output/CFlowIncOutput.cpp +++ b/SU2_CFD/src/output/CFlowIncOutput.cpp @@ -518,24 +518,24 @@ void CFlowIncOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolve SetVolumeOutputValue("INTERMITTENCY", iPoint, Node_Turb->GetGammaBC(iPoint)); } - SetVolumeOutputValue("RES_PRESSURE", iPoint, solver[FLOW_SOL]->LinSysRes.GetBlock(iPoint, 0)); - SetVolumeOutputValue("RES_VELOCITY-X", iPoint, solver[FLOW_SOL]->LinSysRes.GetBlock(iPoint, 1)); - SetVolumeOutputValue("RES_VELOCITY-Y", iPoint, solver[FLOW_SOL]->LinSysRes.GetBlock(iPoint, 2)); + SetVolumeOutputValue("RES_PRESSURE", iPoint, solver[FLOW_SOL]->LinSysRes(iPoint, 0)); + SetVolumeOutputValue("RES_VELOCITY-X", iPoint, solver[FLOW_SOL]->LinSysRes(iPoint, 1)); + SetVolumeOutputValue("RES_VELOCITY-Y", iPoint, solver[FLOW_SOL]->LinSysRes(iPoint, 2)); if (nDim == 3){ - SetVolumeOutputValue("RES_VELOCITY-Z", iPoint, solver[FLOW_SOL]->LinSysRes.GetBlock(iPoint, 3)); - SetVolumeOutputValue("RES_TEMPERATURE", iPoint, solver[FLOW_SOL]->LinSysRes.GetBlock(iPoint, 4)); + SetVolumeOutputValue("RES_VELOCITY-Z", iPoint, solver[FLOW_SOL]->LinSysRes(iPoint, 3)); + SetVolumeOutputValue("RES_TEMPERATURE", iPoint, solver[FLOW_SOL]->LinSysRes(iPoint, 4)); } else { - SetVolumeOutputValue("RES_TEMPERATURE", iPoint, solver[FLOW_SOL]->LinSysRes.GetBlock(iPoint, 3)); + SetVolumeOutputValue("RES_TEMPERATURE", iPoint, solver[FLOW_SOL]->LinSysRes(iPoint, 3)); } switch(config->GetKind_Turb_Model()){ case SST: case SST_SUST: - SetVolumeOutputValue("RES_TKE", iPoint, solver[TURB_SOL]->LinSysRes.GetBlock(iPoint, 0)); - SetVolumeOutputValue("RES_DISSIPATION", iPoint, solver[TURB_SOL]->LinSysRes.GetBlock(iPoint, 1)); + SetVolumeOutputValue("RES_TKE", iPoint, solver[TURB_SOL]->LinSysRes(iPoint, 0)); + SetVolumeOutputValue("RES_DISSIPATION", iPoint, solver[TURB_SOL]->LinSysRes(iPoint, 1)); break; case SA: case SA_COMP: case SA_E: case SA_E_COMP: case SA_NEG: - SetVolumeOutputValue("RES_NU_TILDE", iPoint, solver[TURB_SOL]->LinSysRes.GetBlock(iPoint, 0)); + SetVolumeOutputValue("RES_NU_TILDE", iPoint, solver[TURB_SOL]->LinSysRes(iPoint, 0)); break; case NONE: break; diff --git a/SU2_CFD/src/output/CHeatOutput.cpp b/SU2_CFD/src/output/CHeatOutput.cpp index c384d3e108b7..106791abbc76 100644 --- a/SU2_CFD/src/output/CHeatOutput.cpp +++ b/SU2_CFD/src/output/CHeatOutput.cpp @@ -147,7 +147,7 @@ void CHeatOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolver * SetVolumeOutputValue("TEMPERATURE", iPoint, Node_Heat->GetSolution(iPoint, 0)); // Residuals - SetVolumeOutputValue("RES_TEMPERATURE", iPoint, solver[HEAT_SOL]->LinSysRes.GetBlock(iPoint, 0)); + SetVolumeOutputValue("RES_TEMPERATURE", iPoint, solver[HEAT_SOL]->LinSysRes(iPoint, 0)); } diff --git a/SU2_CFD/src/output/output_structure_legacy.cpp b/SU2_CFD/src/output/output_structure_legacy.cpp index 86d19cb4f708..d2d0a430ca8c 100644 --- a/SU2_CFD/src/output/output_structure_legacy.cpp +++ b/SU2_CFD/src/output/output_structure_legacy.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -37,9 +37,9 @@ COutputLegacy::COutputLegacy(CConfig *config) { size = SU2_MPI::GetSize(); unsigned short iDim, iZone, iSpan, iMarker; - + /*--- Initialize point and connectivity counters to zero. ---*/ - + nGlobal_Poin = 0; nSurf_Poin = 0; nGlobal_Elem = 0; @@ -55,15 +55,15 @@ COutputLegacy::COutputLegacy(CConfig *config) { nGlobal_BoundQuad = 0; /*--- Initialize pointers to NULL ---*/ - + Coords = NULL; Conn_Line = NULL; Conn_BoundTria = NULL; Conn_BoundQuad = NULL; Conn_Tria = NULL; Conn_Quad = NULL; Conn_Tetr = NULL; Conn_Hexa = NULL; Conn_Pris = NULL; Conn_Pyra = NULL; Data = NULL; - + /*--- Initialize parallel pointers to NULL ---*/ - + nGlobal_Poin_Par = 0; nGlobal_Elem_Par = 0; nGlobal_Surf_Poin = 0; @@ -79,13 +79,13 @@ COutputLegacy::COutputLegacy(CConfig *config) { nParallel_Line = 0; nParallel_BoundTria = 0; nParallel_BoundQuad = 0; - + /*--- Initialize pointers to NULL ---*/ - + Conn_BoundLine_Par = NULL; Conn_BoundTria_Par = NULL; Conn_BoundQuad_Par = NULL; Conn_Tria_Par = NULL; Conn_Quad_Par = NULL; Conn_Tetr_Par = NULL; Conn_Hexa_Par = NULL; Conn_Pris_Par = NULL; Conn_Pyra_Par = NULL; - + Local_Data = NULL; Local_Data_Copy = NULL; Parallel_Data = NULL; @@ -106,27 +106,27 @@ COutputLegacy::COutputLegacy(CConfig *config) { nPointCumulative = NULL; /*--- Initialize CGNS write flag ---*/ - + wrote_base_file = false; - + /*--- Initialize CGNS write flag ---*/ - + wrote_CGNS_base = false; - + /*--- Initialize Tecplot surface flag ---*/ - + wrote_surf_file = false; - + /*--- Initialize Paraview write flag ---*/ - + wrote_Paraview_base = false; - + /*--- Initialize residual ---*/ - + RhoRes_New = EPS; RhoRes_Old = new su2double[config->GetnZone()]; for (iZone = 0; iZone < config->GetnZone(); iZone++) RhoRes_Old[iZone] = EPS; - + wrote_Paraview_base = false; /*--- Initialize turbo flag ---*/ @@ -433,25 +433,25 @@ COutputLegacy::~COutputLegacy(void) { void COutputLegacy::SetSurfaceCSV_Flow(CConfig *config, CGeometry *geometry, CSolver *FlowSolver, unsigned long iExtIter, unsigned short val_iZone, unsigned short val_iInst) { - + unsigned short iMarker; unsigned long iPoint, iVertex, Global_Index; su2double PressCoeff = 0.0, SkinFrictionCoeff[3], HeatFlux; su2double xCoord = 0.0, yCoord = 0.0, zCoord = 0.0, Mach, Pressure; char cstr[200]; - + unsigned short solver = config->GetKind_Solver(); unsigned short nDim = geometry->GetnDim(); - + #ifndef HAVE_MPI - + unsigned short iDim; char buffer [50]; ofstream SurfFlow_file; - + /*--- Write file name with extension if unsteady ---*/ strcpy (cstr, config->GetSurfCoeff_FileName().c_str()); - + if (config->GetTime_Marching() == HARMONIC_BALANCE) { SPRINTF (buffer, "_%d.csv", SU2_TYPE::Int(val_iInst)); @@ -464,15 +464,15 @@ void COutputLegacy::SetSurfaceCSV_Flow(CConfig *config, CGeometry *geometry, } else SPRINTF (buffer, ".csv"); - + strcat (cstr, buffer); SurfFlow_file.precision(15); SurfFlow_file.open(cstr, ios::out); - + SurfFlow_file << "\"Global_Index\", \"x_coord\", \"y_coord\", "; if (nDim == 3) SurfFlow_file << "\"z_coord\", "; SurfFlow_file << "\"Pressure\", \"Pressure_Coefficient\", "; - + switch (solver) { case EULER : case INC_EULER: SurfFlow_file << "\"Mach_Number\"" << "\n"; break; case NAVIER_STOKES: case RANS: case INC_NAVIER_STOKES: case INC_RANS: @@ -480,7 +480,7 @@ void COutputLegacy::SetSurfaceCSV_Flow(CConfig *config, CGeometry *geometry, if (nDim == 3) SurfFlow_file << "\"Skin_Friction_Coefficient_X\", \"Skin_Friction_Coefficient_Y\", \"Skin_Friction_Coefficient_Z\", \"Heat_Flux\"" << "\n"; break; } - + for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { if (config->GetMarker_All_Plotting(iMarker) == YES) { for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { @@ -489,14 +489,14 @@ void COutputLegacy::SetSurfaceCSV_Flow(CConfig *config, CGeometry *geometry, xCoord = geometry->node[iPoint]->GetCoord(0); yCoord = geometry->node[iPoint]->GetCoord(1); if (nDim == 3) zCoord = geometry->node[iPoint]->GetCoord(2); - + /*--- The output should be in inches ---*/ - + if (config->GetSystemMeasurements() == US) { xCoord *= 12.0; yCoord *= 12.0; if (nDim == 3) zCoord *= 12.0; } - + Pressure = FlowSolver->GetNodes()->GetPressure(iPoint); PressCoeff = FlowSolver->GetCPressure(iMarker, iVertex); SurfFlow_file << scientific << Global_Index << ", " << xCoord << ", " << yCoord << ", "; @@ -507,35 +507,35 @@ void COutputLegacy::SetSurfaceCSV_Flow(CConfig *config, CGeometry *geometry, 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: + case NAVIER_STOKES: case RANS: case FEM_NAVIER_STOKES: case FEM_RANS: case FEM_LES: case INC_NAVIER_STOKES: case INC_RANS: for (iDim = 0; iDim < nDim; iDim++) SkinFrictionCoeff[iDim] = FlowSolver->GetCSkinFriction(iMarker, iVertex, iDim); HeatFlux = FlowSolver->GetHeatFlux(iMarker, iVertex); - + if (nDim == 2) SurfFlow_file << scientific << SkinFrictionCoeff[0] << ", " << SkinFrictionCoeff[1] << ", " << HeatFlux << "\n"; if (nDim == 3) SurfFlow_file << scientific << SkinFrictionCoeff[0] << ", " << SkinFrictionCoeff[1] << ", " << SkinFrictionCoeff[2] << ", " << HeatFlux << "\n"; - + break; } } } } - + SurfFlow_file.close(); - + #else - + int iProcessor, nProcessor = size; unsigned long Buffer_Send_nVertex[1], *Buffer_Recv_nVertex = NULL; unsigned long nVertex_Surface = 0, nLocalVertex_Surface = 0; unsigned long MaxLocalVertex_Surface = 0; - + /*--- Find the max number of surface vertices among all partitions and set up buffers. The master node will handle the writing of the CSV file after gathering all of the data. ---*/ - + nLocalVertex_Surface = 0; for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) if (config->GetMarker_All_Plotting(iMarker) == YES) @@ -543,53 +543,53 @@ void COutputLegacy::SetSurfaceCSV_Flow(CConfig *config, CGeometry *geometry, iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); if (geometry->node[iPoint]->GetDomain()) nLocalVertex_Surface++; } - + /*--- Communicate the number of local vertices on each partition to the master node ---*/ - + Buffer_Send_nVertex[0] = nLocalVertex_Surface; if (rank == MASTER_NODE) Buffer_Recv_nVertex = new unsigned long [nProcessor]; - + SU2_MPI::Allreduce(&nLocalVertex_Surface, &MaxLocalVertex_Surface, 1, MPI_UNSIGNED_LONG, MPI_MAX, MPI_COMM_WORLD); SU2_MPI::Gather(&Buffer_Send_nVertex, 1, MPI_UNSIGNED_LONG, Buffer_Recv_nVertex, 1, MPI_UNSIGNED_LONG, MASTER_NODE, MPI_COMM_WORLD); - + /*--- Send and Recv buffers ---*/ - + su2double *Buffer_Send_Coord_x = new su2double [MaxLocalVertex_Surface]; su2double *Buffer_Recv_Coord_x = NULL; - + su2double *Buffer_Send_Coord_y = new su2double [MaxLocalVertex_Surface]; su2double *Buffer_Recv_Coord_y = NULL; - + su2double *Buffer_Send_Coord_z = new su2double [MaxLocalVertex_Surface]; su2double *Buffer_Recv_Coord_z = NULL; - + su2double *Buffer_Send_Press = new su2double [MaxLocalVertex_Surface]; su2double *Buffer_Recv_Press = NULL; - + su2double *Buffer_Send_CPress = new su2double [MaxLocalVertex_Surface]; su2double *Buffer_Recv_CPress = NULL; - + su2double *Buffer_Send_Mach = new su2double [MaxLocalVertex_Surface]; su2double *Buffer_Recv_Mach = NULL; - + su2double *Buffer_Send_SkinFriction_x = new su2double [MaxLocalVertex_Surface]; su2double *Buffer_Recv_SkinFriction_x = NULL; - + su2double *Buffer_Send_SkinFriction_y = new su2double [MaxLocalVertex_Surface]; su2double *Buffer_Recv_SkinFriction_y = NULL; - + su2double *Buffer_Send_SkinFriction_z = new su2double [MaxLocalVertex_Surface]; su2double *Buffer_Recv_SkinFriction_z = NULL; - + su2double *Buffer_Send_HeatTransfer = new su2double [MaxLocalVertex_Surface]; su2double *Buffer_Recv_HeatTransfer = NULL; - + unsigned long *Buffer_Send_GlobalIndex = new unsigned long [MaxLocalVertex_Surface]; unsigned long *Buffer_Recv_GlobalIndex = NULL; - + /*--- Prepare the receive buffers on the master node only. ---*/ - + if (rank == MASTER_NODE) { Buffer_Recv_Coord_x = new su2double [nProcessor*MaxLocalVertex_Surface]; Buffer_Recv_Coord_y = new su2double [nProcessor*MaxLocalVertex_Surface]; @@ -603,11 +603,11 @@ void COutputLegacy::SetSurfaceCSV_Flow(CConfig *config, CGeometry *geometry, Buffer_Recv_HeatTransfer = new su2double [nProcessor*MaxLocalVertex_Surface]; Buffer_Recv_GlobalIndex = new unsigned long [nProcessor*MaxLocalVertex_Surface]; } - + /*--- Loop over all vertices in this partition and load the data of the specified type into the buffer to be sent to the master node. ---*/ - + nVertex_Surface = 0; for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) if (config->GetMarker_All_Plotting(iMarker) == YES) @@ -619,18 +619,18 @@ void COutputLegacy::SetSurfaceCSV_Flow(CConfig *config, CGeometry *geometry, Buffer_Send_Coord_x[nVertex_Surface] = geometry->node[iPoint]->GetCoord(0); 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); } - + /*--- If US system, the output should be in inches ---*/ - + if (config->GetSystemMeasurements() == US) { Buffer_Send_Coord_x[nVertex_Surface] *= 12.0; Buffer_Send_Coord_y[nVertex_Surface] *= 12.0; if (nDim == 3) Buffer_Send_Coord_z[nVertex_Surface] *= 12.0; } - + Buffer_Send_GlobalIndex[nVertex_Surface] = geometry->node[iPoint]->GetGlobalIndex(); - - if (solver == EULER || solver == FEM_EULER || solver == INC_EULER) + + if (solver == EULER || solver == FEM_EULER || solver == INC_EULER) 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 || @@ -643,9 +643,9 @@ void COutputLegacy::SetSurfaceCSV_Flow(CConfig *config, CGeometry *geometry, nVertex_Surface++; } } - + /*--- Send the information to the master node ---*/ - + SU2_MPI::Gather(Buffer_Send_Coord_x, MaxLocalVertex_Surface, MPI_DOUBLE, Buffer_Recv_Coord_x, MaxLocalVertex_Surface, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); SU2_MPI::Gather(Buffer_Send_Coord_y, MaxLocalVertex_Surface, MPI_DOUBLE, Buffer_Recv_Coord_y, MaxLocalVertex_Surface, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); if (nDim == 3) SU2_MPI::Gather(Buffer_Send_Coord_z, MaxLocalVertex_Surface, MPI_DOUBLE, Buffer_Recv_Coord_z, MaxLocalVertex_Surface, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); @@ -659,21 +659,21 @@ void COutputLegacy::SetSurfaceCSV_Flow(CConfig *config, CGeometry *geometry, SU2_MPI::Gather(Buffer_Send_HeatTransfer, MaxLocalVertex_Surface, MPI_DOUBLE, Buffer_Recv_HeatTransfer, MaxLocalVertex_Surface, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); } SU2_MPI::Gather(Buffer_Send_GlobalIndex, MaxLocalVertex_Surface, MPI_UNSIGNED_LONG, Buffer_Recv_GlobalIndex, MaxLocalVertex_Surface, MPI_UNSIGNED_LONG, MASTER_NODE, MPI_COMM_WORLD); - + /*--- The master node unpacks the data and writes the surface CSV file ---*/ - + if (rank == MASTER_NODE) { - + /*--- Write file name with extension if unsteady ---*/ char buffer[50]; string filename = config->GetSurfCoeff_FileName(); ofstream SurfFlow_file; - + /*--- Write file name with extension if unsteady ---*/ strcpy (cstr, filename.c_str()); if (config->GetTime_Marching() == HARMONIC_BALANCE) { SPRINTF (buffer, "_%d.csv", SU2_TYPE::Int(val_iInst)); - + } else if (config->GetTime_Marching() && config->GetTime_Domain()) { if ((SU2_TYPE::Int(iExtIter) >= 0) && (SU2_TYPE::Int(iExtIter) < 10)) SPRINTF (buffer, "_0000%d.csv", SU2_TYPE::Int(iExtIter)); if ((SU2_TYPE::Int(iExtIter) >= 10) && (SU2_TYPE::Int(iExtIter) < 100)) SPRINTF (buffer, "_000%d.csv", SU2_TYPE::Int(iExtIter)); @@ -683,15 +683,15 @@ void COutputLegacy::SetSurfaceCSV_Flow(CConfig *config, CGeometry *geometry, } else SPRINTF (buffer, ".csv"); - + strcat (cstr, buffer); SurfFlow_file.precision(15); SurfFlow_file.open(cstr, ios::out); - + SurfFlow_file << "\"Global_Index\", \"x_coord\", \"y_coord\", "; if (nDim == 3) SurfFlow_file << "\"z_coord\", "; SurfFlow_file << "\"Pressure\", \"Pressure_Coefficient\", "; - + switch (solver) { case EULER : case FEM_EULER: case INC_EULER: SurfFlow_file << "\"Mach_Number\"" << "\n"; break; case NAVIER_STOKES: case RANS: case FEM_NAVIER_STOKES: case FEM_RANS: case FEM_LES: case INC_NAVIER_STOKES: case INC_RANS: @@ -699,29 +699,29 @@ void COutputLegacy::SetSurfaceCSV_Flow(CConfig *config, CGeometry *geometry, if (nDim == 3) SurfFlow_file << "\"Skin_Friction_Coefficient_X\", \"Skin_Friction_Coefficient_Y\", \"Skin_Friction_Coefficient_Z\", \"Heat_Flux\"" << "\n"; break; } - + /*--- Loop through all of the collected data and write each node's values ---*/ - + unsigned long Total_Index; for (iProcessor = 0; iProcessor < nProcessor; iProcessor++) { for (iVertex = 0; iVertex < Buffer_Recv_nVertex[iProcessor]; iVertex++) { - + /*--- Current index position and global index ---*/ Total_Index = iProcessor*MaxLocalVertex_Surface+iVertex; Global_Index = Buffer_Recv_GlobalIndex[Total_Index]; - + /*--- Retrieve the merged data for this node ---*/ xCoord = Buffer_Recv_Coord_x[Total_Index]; yCoord = Buffer_Recv_Coord_y[Total_Index]; if (nDim == 3) zCoord = Buffer_Recv_Coord_z[Total_Index]; Pressure = Buffer_Recv_Press[Total_Index]; PressCoeff = Buffer_Recv_CPress[Total_Index]; - + /*--- Write the first part of the data ---*/ SurfFlow_file << scientific << Global_Index << ", " << xCoord << ", " << yCoord << ", "; if (nDim == 3) SurfFlow_file << scientific << zCoord << ", "; SurfFlow_file << scientific << Pressure << ", " << PressCoeff << ", "; - + /*--- Write the solver-dependent part of the data ---*/ switch (solver) { case EULER : @@ -743,12 +743,12 @@ void COutputLegacy::SetSurfaceCSV_Flow(CConfig *config, CGeometry *geometry, } } } - + /*--- Close the CSV file ---*/ SurfFlow_file.close(); - + /*--- Release the recv buffers on the master node ---*/ - + delete [] Buffer_Recv_Coord_x; delete [] Buffer_Recv_Coord_y; if (nDim == 3) delete [] Buffer_Recv_Coord_z; @@ -760,13 +760,13 @@ void COutputLegacy::SetSurfaceCSV_Flow(CConfig *config, CGeometry *geometry, if (nDim == 3) delete [] Buffer_Recv_SkinFriction_z; delete [] Buffer_Recv_HeatTransfer; delete [] Buffer_Recv_GlobalIndex; - + delete [] Buffer_Recv_nVertex; - + } - + /*--- Release the memory for the remaining buffers and exit ---*/ - + delete [] Buffer_Send_Coord_x; delete [] Buffer_Send_Coord_y; delete [] Buffer_Send_Coord_z; @@ -778,28 +778,28 @@ void COutputLegacy::SetSurfaceCSV_Flow(CConfig *config, CGeometry *geometry, delete [] Buffer_Send_SkinFriction_z; delete [] Buffer_Send_HeatTransfer; delete [] Buffer_Send_GlobalIndex; - + #endif - + } void COutputLegacy::SetSurfaceCSV_Adjoint(CConfig *config, CGeometry *geometry, CSolver *AdjSolver, CSolver *FlowSolution, unsigned long iExtIter, unsigned short val_iZone, unsigned short val_iInst) { - + #ifndef HAVE_MPI - + unsigned long iPoint, iVertex, Global_Index; su2double *Solution, xCoord, yCoord, zCoord; unsigned short iMarker; char cstr[200], buffer[50]; ofstream SurfAdj_file; - + /*--- Write file name with extension if unsteady ---*/ - + strcpy (cstr, config->GetSurfAdjCoeff_FileName().c_str()); - + if (config->GetTime_Marching() == HARMONIC_BALANCE) { SPRINTF (buffer, "_%d.csv", SU2_TYPE::Int(val_iInst)); - + } else if (config->GetTime_Marching() && config->GetTime_Domain()) { if ((SU2_TYPE::Int(iExtIter) >= 0) && (SU2_TYPE::Int(iExtIter) < 10)) SPRINTF (buffer, "_0000%d.csv", SU2_TYPE::Int(iExtIter)); if ((SU2_TYPE::Int(iExtIter) >= 10) && (SU2_TYPE::Int(iExtIter) < 100)) SPRINTF (buffer, "_000%d.csv", SU2_TYPE::Int(iExtIter)); @@ -809,11 +809,11 @@ void COutputLegacy::SetSurfaceCSV_Adjoint(CConfig *config, CGeometry *geometry, } else SPRINTF (buffer, ".csv"); - + strcat(cstr, buffer); SurfAdj_file.precision(15); SurfAdj_file.open(cstr, ios::out); - + SurfAdj_file << "SENS_AOA=" << AdjSolver->GetTotal_Sens_AoA() * PI_NUMBER / 180.0 << endl; if (geometry->GetnDim() == 2) { @@ -826,7 +826,7 @@ void COutputLegacy::SetSurfaceCSV_Adjoint(CConfig *config, CGeometry *geometry, SurfAdj_file << ",\"x_Sens\",\"y_Sens\""; } SurfAdj_file << "\n"; - + for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { if (config->GetMarker_All_Plotting(iMarker) == YES) for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { @@ -835,9 +835,9 @@ void COutputLegacy::SetSurfaceCSV_Adjoint(CConfig *config, CGeometry *geometry, Solution = AdjSolver->GetNodes()->GetSolution(iPoint); xCoord = geometry->node[iPoint]->GetCoord(0); yCoord = geometry->node[iPoint]->GetCoord(1); - + /*--- If US system, the output should be in inches ---*/ - + if (config->GetSystemMeasurements() == US) { xCoord *= 12.0; yCoord *= 12.0; @@ -855,7 +855,7 @@ void COutputLegacy::SetSurfaceCSV_Adjoint(CConfig *config, CGeometry *geometry, } } } - + if (geometry->GetnDim() == 3) { if (config ->GetKind_Regime() == COMPRESSIBLE) SurfAdj_file << "\"Point\",\"Sensitivity\",\"PsiRho\",\"Phi_x\",\"Phi_y\",\"Phi_z\",\"PsiE\",\"x_coord\",\"y_coord\",\"z_coord\""; @@ -872,13 +872,13 @@ void COutputLegacy::SetSurfaceCSV_Adjoint(CConfig *config, CGeometry *geometry, iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); Global_Index = geometry->node[iPoint]->GetGlobalIndex(); Solution = AdjSolver->GetNodes()->GetSolution(iPoint); - + xCoord = geometry->node[iPoint]->GetCoord(0); yCoord = geometry->node[iPoint]->GetCoord(1); zCoord = geometry->node[iPoint]->GetCoord(2); - + /*--- If US system, the output should be in inches ---*/ - + if (config->GetSystemMeasurements() == US) { xCoord *= 12.0; yCoord *= 12.0; @@ -898,9 +898,9 @@ void COutputLegacy::SetSurfaceCSV_Adjoint(CConfig *config, CGeometry *geometry, } } } - + SurfAdj_file.close(); - + #else int iProcessor, nProcessor = size; @@ -910,7 +910,7 @@ void COutputLegacy::SetSurfaceCSV_Adjoint(CConfig *config, CGeometry *geometry, MaxLocalVertex_Surface = 0, nBuffer_Scalar; unsigned long *Buffer_Receive_nVertex = NULL; ofstream SurfAdj_file; - + /*--- Write the surface .csv file ---*/ nLocalVertex_Surface = 0; for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) @@ -919,15 +919,15 @@ void COutputLegacy::SetSurfaceCSV_Adjoint(CConfig *config, CGeometry *geometry, iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); if (geometry->node[iPoint]->GetDomain()) nLocalVertex_Surface ++; } - + if (rank == MASTER_NODE) Buffer_Receive_nVertex = new unsigned long [nProcessor]; - + Buffer_Send_nVertex[0] = nLocalVertex_Surface; - + SU2_MPI::Allreduce(&nLocalVertex_Surface, &MaxLocalVertex_Surface, 1, MPI_UNSIGNED_LONG, MPI_MAX, MPI_COMM_WORLD); SU2_MPI::Gather(&Buffer_Send_nVertex, 1, MPI_UNSIGNED_LONG, Buffer_Receive_nVertex, 1, MPI_UNSIGNED_LONG, MASTER_NODE, MPI_COMM_WORLD); - + su2double *Buffer_Send_Coord_x = new su2double[MaxLocalVertex_Surface]; su2double *Buffer_Send_Coord_y= new su2double[MaxLocalVertex_Surface]; su2double *Buffer_Send_Coord_z= new su2double[MaxLocalVertex_Surface]; @@ -943,7 +943,7 @@ void COutputLegacy::SetSurfaceCSV_Adjoint(CConfig *config, CGeometry *geometry, Buffer_Send_PsiE = new su2double[MaxLocalVertex_Surface]; su2double *Buffer_Send_Sens_x = NULL, *Buffer_Send_Sens_y = NULL, *Buffer_Send_Sens_z = NULL; - + if (config->GetDiscrete_Adjoint()) { Buffer_Send_Sens_x = new su2double[MaxLocalVertex_Surface]; Buffer_Send_Sens_y = new su2double[MaxLocalVertex_Surface]; @@ -951,7 +951,7 @@ void COutputLegacy::SetSurfaceCSV_Adjoint(CConfig *config, CGeometry *geometry, Buffer_Send_Sens_z = new su2double[MaxLocalVertex_Surface]; } } - + nVertex_Surface = 0; for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) if (config->GetMarker_All_Plotting(iMarker) == YES) @@ -982,24 +982,24 @@ void COutputLegacy::SetSurfaceCSV_Adjoint(CConfig *config, CGeometry *geometry, Buffer_Send_Sens_z[nVertex_Surface] = AdjSolver->GetNodes()->GetSensitivity(iPoint, 2); } } - + /*--- If US system, the output should be in inches ---*/ - + if (config->GetSystemMeasurements() == US) { Buffer_Send_Coord_x[nVertex_Surface] *= 12.0; Buffer_Send_Coord_y[nVertex_Surface] *= 12.0; if (nDim == 3) Buffer_Send_Coord_z[nVertex_Surface] *= 12.0; } - + nVertex_Surface++; } } - + su2double *Buffer_Receive_Coord_x = NULL, *Buffer_Receive_Coord_y = NULL, *Buffer_Receive_Coord_z = NULL, *Buffer_Receive_Sensitivity = NULL, *Buffer_Receive_PsiRho = NULL, *Buffer_Receive_Phi_x = NULL, *Buffer_Receive_Phi_y = NULL, *Buffer_Receive_Phi_z = NULL, *Buffer_Receive_PsiE = NULL, *Buffer_Receive_Sens_x = NULL, *Buffer_Receive_Sens_y = NULL, *Buffer_Receive_Sens_z = NULL; unsigned long *Buffer_Receive_GlobalPoint = NULL; - + if (rank == MASTER_NODE) { Buffer_Receive_Coord_x = new su2double [nProcessor*MaxLocalVertex_Surface]; Buffer_Receive_Coord_y = new su2double [nProcessor*MaxLocalVertex_Surface]; @@ -1020,9 +1020,9 @@ void COutputLegacy::SetSurfaceCSV_Adjoint(CConfig *config, CGeometry *geometry, } } } - + nBuffer_Scalar = MaxLocalVertex_Surface; - + /*--- Send the information to the Master node ---*/ SU2_MPI::Gather(Buffer_Send_Coord_x, nBuffer_Scalar, MPI_DOUBLE, Buffer_Receive_Coord_x, nBuffer_Scalar, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); SU2_MPI::Gather(Buffer_Send_Coord_y, nBuffer_Scalar, MPI_DOUBLE, Buffer_Receive_Coord_y, nBuffer_Scalar, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); @@ -1042,20 +1042,20 @@ void COutputLegacy::SetSurfaceCSV_Adjoint(CConfig *config, CGeometry *geometry, SU2_MPI::Gather(Buffer_Send_Sens_z, nBuffer_Scalar, MPI_DOUBLE, Buffer_Receive_Sens_z, nBuffer_Scalar, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); } } - + /*--- The master node is the one who writes the surface files ---*/ if (rank == MASTER_NODE) { unsigned long iVertex, GlobalPoint, position; char cstr[200], buffer[50]; ofstream SurfAdj_file; string filename = config->GetSurfAdjCoeff_FileName(); - + /*--- Write file name with extension if unsteady ---*/ strcpy (cstr, filename.c_str()); - + if (config->GetTime_Marching() == HARMONIC_BALANCE) { SPRINTF (buffer, "_%d.csv", SU2_TYPE::Int(val_iInst)); - + } else if (config->GetTime_Marching() && config->GetTime_Domain()) { if ((SU2_TYPE::Int(iExtIter) >= 0) && (SU2_TYPE::Int(iExtIter) < 10)) SPRINTF (buffer, "_0000%d.csv", SU2_TYPE::Int(iExtIter)); if ((SU2_TYPE::Int(iExtIter) >= 10) && (SU2_TYPE::Int(iExtIter) < 100)) SPRINTF (buffer, "_000%d.csv", SU2_TYPE::Int(iExtIter)); @@ -1065,11 +1065,11 @@ void COutputLegacy::SetSurfaceCSV_Adjoint(CConfig *config, CGeometry *geometry, } else SPRINTF (buffer, ".csv"); - + strcat (cstr, buffer); SurfAdj_file.open(cstr, ios::out); SurfAdj_file.precision(15); - + SurfAdj_file << "SENS_AOA=" << AdjSolver->GetTotal_Sens_AoA() * PI_NUMBER / 180.0 << endl; /*--- Write the 2D surface flow coefficient file ---*/ @@ -1083,10 +1083,10 @@ void COutputLegacy::SetSurfaceCSV_Adjoint(CConfig *config, CGeometry *geometry, SurfAdj_file << ",\" x_Sens\",\"y_Sens\""; } SurfAdj_file << "\n"; - + for (iProcessor = 0; iProcessor < nProcessor; iProcessor++) for (iVertex = 0; iVertex < Buffer_Receive_nVertex[iProcessor]; iVertex++) { - + position = iProcessor*MaxLocalVertex_Surface+iVertex; GlobalPoint = Buffer_Receive_GlobalPoint[position]; @@ -1108,7 +1108,7 @@ void COutputLegacy::SetSurfaceCSV_Adjoint(CConfig *config, CGeometry *geometry, SurfAdj_file << "\n"; } } - + /*--- Write the 3D surface flow coefficient file ---*/ if (geometry->GetnDim() == 3) { if (config->GetKind_Regime() == COMPRESSIBLE) @@ -1120,12 +1120,12 @@ void COutputLegacy::SetSurfaceCSV_Adjoint(CConfig *config, CGeometry *geometry, SurfAdj_file << ",\"x_Sens\",\"y_Sens\",\"z_Sens\""; } SurfAdj_file << "\n"; - + for (iProcessor = 0; iProcessor < nProcessor; iProcessor++) for (iVertex = 0; iVertex < Buffer_Receive_nVertex[iProcessor]; iVertex++) { position = iProcessor*MaxLocalVertex_Surface+iVertex; GlobalPoint = Buffer_Receive_GlobalPoint[position]; - + if (config->GetKind_Regime() == COMPRESSIBLE) SurfAdj_file << scientific << GlobalPoint << ", " << Buffer_Receive_Sensitivity[position] << ", " << Buffer_Receive_PsiRho[position] << @@ -1145,9 +1145,9 @@ void COutputLegacy::SetSurfaceCSV_Adjoint(CConfig *config, CGeometry *geometry, SurfAdj_file << "\n"; } } - + } - + if (rank == MASTER_NODE) { delete [] Buffer_Receive_nVertex; delete [] Buffer_Receive_Coord_x; @@ -1169,7 +1169,7 @@ void COutputLegacy::SetSurfaceCSV_Adjoint(CConfig *config, CGeometry *geometry, } } } - + delete [] Buffer_Send_Coord_x; delete [] Buffer_Send_Coord_y; delete [] Buffer_Send_Coord_z; @@ -1183,107 +1183,107 @@ void COutputLegacy::SetSurfaceCSV_Adjoint(CConfig *config, CGeometry *geometry, if (Buffer_Send_Sens_x != NULL) delete [] Buffer_Send_Sens_x; if (Buffer_Send_Sens_y != NULL) delete [] Buffer_Send_Sens_y; if (Buffer_Send_Sens_z != NULL) delete [] Buffer_Send_Sens_z; - + SurfAdj_file.close(); - + #endif } void COutputLegacy::MergeConnectivity(CConfig *config, CGeometry *geometry, unsigned short val_iZone) { - + /*--- Flags identifying the types of files to be written. ---*/ - + bool Wrt_Vol = config->GetWrt_Vol_Sol(); bool Wrt_Srf = config->GetWrt_Srf_Sol(); - + /*--- Merge connectivity for each type of element (excluding halos). Note that we only need to merge the connectivity once, as it does not change during computation. Check whether the base file has been written. ---*/ - + /*--- Merge volumetric grid. ---*/ - + if (Wrt_Vol) { - + if ((rank == MASTER_NODE) && (size != SINGLE_NODE) && (nGlobal_Tria != 0)) cout <<"Merging volumetric triangle grid connectivity." << endl; MergeVolumetricConnectivity(config, geometry, TRIANGLE ); - + if ((rank == MASTER_NODE) && (size != SINGLE_NODE) && (nGlobal_Quad != 0)) cout <<"Merging volumetric quadrilateral grid connectivity." << endl; MergeVolumetricConnectivity(config, geometry, QUADRILATERAL ); - + if ((rank == MASTER_NODE) && (size != SINGLE_NODE) && (nGlobal_Tetr != 0)) cout <<"Merging volumetric tetrahedron grid connectivity." << endl; MergeVolumetricConnectivity(config, geometry, TETRAHEDRON ); - + if ((rank == MASTER_NODE) && (size != SINGLE_NODE) && (nGlobal_Hexa != 0)) cout <<"Merging volumetric hexahedron grid connectivity." << endl; MergeVolumetricConnectivity(config, geometry, HEXAHEDRON ); - + if ((rank == MASTER_NODE) && (size != SINGLE_NODE) && (nGlobal_Pris != 0)) cout <<"Merging volumetric prism grid connectivity." << endl; MergeVolumetricConnectivity(config, geometry, PRISM ); - + if ((rank == MASTER_NODE) && (size != SINGLE_NODE) && (nGlobal_Pyra != 0)) cout <<"Merging volumetric pyramid grid connectivity." << endl; MergeVolumetricConnectivity(config, geometry, PYRAMID ); - + } - + /*--- Merge surface grid. ---*/ - + if (Wrt_Srf) { - + if ((rank == MASTER_NODE) && (size != SINGLE_NODE) && (nGlobal_Line != 0)) cout <<"Merging surface line grid connectivity." << endl; MergeSurfaceConnectivity(config, geometry, LINE); - + if ((rank == MASTER_NODE) && (size != SINGLE_NODE) && (nGlobal_BoundTria != 0)) cout <<"Merging surface triangle grid connectivity." << endl; MergeSurfaceConnectivity(config, geometry, TRIANGLE); - + if ((rank == MASTER_NODE) && (size != SINGLE_NODE) && (nGlobal_BoundQuad != 0)) cout <<"Merging surface quadrilateral grid connectivity." << endl; MergeSurfaceConnectivity(config, geometry, QUADRILATERAL); - + } - + /*--- Update total number of volume elements after merge. ---*/ - + nGlobal_Elem = nGlobal_Tria + nGlobal_Quad + nGlobal_Tetr + nGlobal_Hexa + nGlobal_Pyra + nGlobal_Pris; - + /*--- Update total number of surface elements after merge. ---*/ - + nSurf_Elem = nGlobal_Line + nGlobal_BoundTria + nGlobal_BoundQuad; - + } void COutputLegacy::MergeCoordinates(CConfig *config, CGeometry *geometry) { - + /*--- Local variables needed on all processors ---*/ - + unsigned short iDim, nDim = geometry->GetnDim(); unsigned long iPoint; - + unsigned short kind_SU2 = config->GetKind_SU2(); - + #ifndef HAVE_MPI - + /*--- In serial, the single process has access to all geometry, so simply load the coordinates into the data structure. ---*/ - + unsigned short iMarker; unsigned long iVertex, nTotalPoints = 0; int SendRecv; - + bool isPeriodic; - + /*--- First, create a structure to locate any periodic halo nodes ---*/ int *Local_Halo = new int[geometry->GetnPoint()]; for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) Local_Halo[iPoint] = !geometry->node[iPoint]->GetDomain(); - + for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { if (config->GetMarker_All_KindBC(iMarker) == SEND_RECEIVE) { SendRecv = config->GetMarker_All_SendRecv(iMarker); @@ -1305,88 +1305,88 @@ void COutputLegacy::MergeCoordinates(CConfig *config, CGeometry *geometry) { Local_Halo[iPoint] = false; } } - + } } - + /*--- Total number of points in the mesh (this might include periodic points). ---*/ for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) if (!Local_Halo[iPoint]) nTotalPoints++; - + nGlobal_Poin = nTotalPoints; nGlobal_Doma = geometry->GetnPointDomain(); - + /*--- Allocate the coordinates data structure. ---*/ - + Coords = new su2double*[nDim]; for (iDim = 0; iDim < nDim; iDim++) { Coords[iDim] = new su2double[nGlobal_Poin]; } - + /*--- Loop over the mesh to collect the coords of the local points ---*/ - + for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { - + /*--- Check if the node belongs to the domain (i.e, not a halo node). Sort by the global index, even in serial there is a renumbering (e.g. RCM). ---*/ - + if (!Local_Halo[iPoint]) { - + /*--- Retrieve the current coordinates at this node. ---*/ - + unsigned long iGlobal_Index = geometry->node[iPoint]->GetGlobalIndex(); - + for (iDim = 0; iDim < nDim; iDim++) { Coords[iDim][iGlobal_Index] = geometry->node[iPoint]->GetCoord(iDim); - + /*--- If US system, the output should be in inches ---*/ - + if ((config->GetSystemMeasurements() == US) && (config->GetKind_SU2() != SU2_DEF)) { Coords[iDim][iGlobal_Index] *= 12.0; } - + } - + } } - - + + delete [] Local_Halo; - + #else - + /*--- MPI preprocessing ---*/ int iProcessor, nProcessor = size; unsigned long jPoint; bool Wrt_Halo = config->GetWrt_Halo(), isPeriodic; - + /*--- Local variables needed for merging the geometry with MPI. ---*/ - + unsigned long iVertex, iMarker; unsigned long Buffer_Send_nPoin[1], *Buffer_Recv_nPoin = NULL; unsigned long nLocalPoint = 0, MaxLocalPoint = 0; unsigned long iGlobal_Index = 0, nBuffer_Scalar = 0; - + if (rank == MASTER_NODE) Buffer_Recv_nPoin = new unsigned long[nProcessor]; - + int *Local_Halo = new int[geometry->GetnPoint()]; for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) Local_Halo[iPoint] = !geometry->node[iPoint]->GetDomain(); - + /*--- Search all send/recv boundaries on this partition for any periodic nodes that were part of the original domain. We want to recover these for visualization purposes. ---*/ - + if (Wrt_Halo) { nLocalPoint = geometry->GetnPoint(); } else { for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { if (config->GetMarker_All_KindBC(iMarker) == SEND_RECEIVE) { - + /*--- Checking for less than or equal to the rank, because there may be some periodic halo nodes that send info to the same rank. ---*/ - + for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); @@ -1406,21 +1406,21 @@ void COutputLegacy::MergeCoordinates(CConfig *config, CGeometry *geometry) { } } } - + /*--- Sum total number of nodes that belong to the domain ---*/ - + for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) if (Local_Halo[iPoint] == false) 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); - + if (rank == MASTER_NODE) { nGlobal_Doma = 0; for (iProcessor = 0; iProcessor < nProcessor; iProcessor++) { @@ -1428,30 +1428,30 @@ void COutputLegacy::MergeCoordinates(CConfig *config, CGeometry *geometry) { } } nBuffer_Scalar = MaxLocalPoint; - + /*--- 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]; - + unsigned long *Buffer_Send_GlobalIndex = new unsigned long[MaxLocalPoint]; unsigned long *Buffer_Recv_GlobalIndex = 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_GlobalIndex = new unsigned long[nProcessor*MaxLocalPoint]; - + /*--- Sum total number of nodes to be written and allocate arrays ---*/ nGlobal_Poin = 0; for (iProcessor = 0; iProcessor < nProcessor; iProcessor++) { @@ -1462,55 +1462,55 @@ void COutputLegacy::MergeCoordinates(CConfig *config, CGeometry *geometry) { Coords[iDim] = new su2double[nGlobal_Poin]; } } - + /*--- 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 global index in one large n-dim. array. ---*/ - + /*--- Loop over this partition to collect the coords of the local points. ---*/ su2double *Coords_Local; jPoint = 0; for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { - + /*--- Check for halos and write only if requested ---*/ if (!Local_Halo[iPoint] || Wrt_Halo) { - + /*--- 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) && (config->GetKind_SU2() != SU2_DEF)) { Buffer_Send_X[jPoint] *= 12.0; Buffer_Send_Y[jPoint] *= 12.0; if (nDim == 3) Buffer_Send_Z[jPoint] *= 12.0; } - + /*--- Store the global index for this local node. ---*/ Buffer_Send_GlobalIndex[jPoint] = geometry->node[iPoint]->GetGlobalIndex(); - + /*--- 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, nBuffer_Scalar, MPI_DOUBLE, Buffer_Recv_X, nBuffer_Scalar, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); SU2_MPI::Gather(Buffer_Send_Y, nBuffer_Scalar, MPI_DOUBLE, Buffer_Recv_Y, nBuffer_Scalar, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); if (nDim == 3) { SU2_MPI::Gather(Buffer_Send_Z, nBuffer_Scalar, MPI_DOUBLE, Buffer_Recv_Z, nBuffer_Scalar, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); } SU2_MPI::Gather(Buffer_Send_GlobalIndex, nBuffer_Scalar, MPI_UNSIGNED_LONG, Buffer_Recv_GlobalIndex, nBuffer_Scalar, MPI_UNSIGNED_LONG, MASTER_NODE, MPI_COMM_WORLD); - + /*--- The master node unpacks and sorts this variable by global index ---*/ - + if (rank == MASTER_NODE) { jPoint = 0; for (iProcessor = 0; iProcessor < nProcessor; iProcessor++) { @@ -1529,9 +1529,9 @@ void COutputLegacy::MergeCoordinates(CConfig *config, CGeometry *geometry) { jPoint = (iProcessor+1)*nBuffer_Scalar; } } - + /*--- Immediately release the temporary data buffers. ---*/ - + delete [] Local_Halo; delete [] Buffer_Send_X; delete [] Buffer_Send_Y; @@ -1544,40 +1544,40 @@ void COutputLegacy::MergeCoordinates(CConfig *config, CGeometry *geometry) { delete [] Buffer_Recv_GlobalIndex; delete [] Buffer_Recv_nPoin; } - + #endif - + } void COutputLegacy::MergeVolumetricConnectivity(CConfig *config, CGeometry *geometry, unsigned short Elem_Type) { - + int iProcessor; unsigned short NODES_PER_ELEMENT = 0; unsigned long iPoint, iNode, jNode; unsigned long iElem = 0; unsigned long nLocalElem = 0, nElem_Total = 0; - + unsigned long iVertex, iMarker; unsigned long jElem; int SendRecv, RecvFrom; - + unsigned long Buffer_Send_nElem[1], *Buffer_Recv_nElem = NULL; unsigned long nBuffer_Scalar = 0; unsigned long kNode = 0, kElem = 0; unsigned long MaxLocalElem = 0, iGlobal_Index, jPoint, kPoint; - + bool Wrt_Halo = config->GetWrt_Halo(); bool *Write_Elem = NULL, notPeriodic, notHalo, addedPeriodic, isPeriodic; - + unsigned short kind_SU2 = config->GetKind_SU2(); - + int *Conn_Elem = NULL; - + /*--- Store the local number of this element type and the number of nodes per this element type. In serial, this will be the total number of this element type in the entire mesh. In parallel, it is the number on only the current partition. ---*/ - + switch (Elem_Type) { case TRIANGLE: nLocalElem = geometry->GetnElemTria(); @@ -1606,13 +1606,13 @@ void COutputLegacy::MergeVolumetricConnectivity(CConfig *config, CGeometry *geom default: SU2_MPI::Error("Unrecognized element type", CURRENT_FUNCTION); } - + /*--- Find the max number of this element type among all partitions and set up buffers. ---*/ - + Buffer_Send_nElem[0] = nLocalElem; if (rank == MASTER_NODE) Buffer_Recv_nElem = new unsigned long[size]; - + #ifdef HAVE_MPI SU2_MPI::Allreduce(&nLocalElem, &MaxLocalElem, 1, MPI_UNSIGNED_LONG, MPI_MAX, MPI_COMM_WORLD); SU2_MPI::Gather(&Buffer_Send_nElem, 1, MPI_UNSIGNED_LONG, Buffer_Recv_nElem, 1, MPI_UNSIGNED_LONG, MASTER_NODE, MPI_COMM_WORLD); @@ -1620,40 +1620,40 @@ void COutputLegacy::MergeVolumetricConnectivity(CConfig *config, CGeometry *geom MaxLocalElem = nLocalElem; Buffer_Recv_nElem[0] = Buffer_Send_nElem[0]; #endif - + nBuffer_Scalar = MaxLocalElem*NODES_PER_ELEMENT; - + /*--- Send and Recv buffers ---*/ - + unsigned long *Buffer_Send_Elem = new unsigned long[nBuffer_Scalar]; unsigned long *Buffer_Recv_Elem = NULL; - + unsigned short *Buffer_Send_Halo = new unsigned short[MaxLocalElem]; unsigned short *Buffer_Recv_Halo = NULL; - + /*--- Prepare the receive buffers on the master node only. ---*/ - + if (rank == MASTER_NODE) { Buffer_Recv_Elem = new unsigned long[size*nBuffer_Scalar]; Buffer_Recv_Halo = new unsigned short[size*MaxLocalElem]; if (MaxLocalElem > 0) Conn_Elem = new int[size*MaxLocalElem*NODES_PER_ELEMENT]; } - + /*--- Force the removal of all added periodic elements (use global index). First, we isolate and create a list of all added periodic points, excluding those that we part of the original domain (we want these to be in the output files). ---*/ - + vector Added_Periodic; Added_Periodic.clear(); - + if (kind_SU2 != SU2_DEF) { for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { if (config->GetMarker_All_KindBC(iMarker) == SEND_RECEIVE) { SendRecv = config->GetMarker_All_SendRecv(iMarker); for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); - + if ((geometry->vertex[iMarker][iVertex]->GetRotation_Type() > 0) && (geometry->vertex[iMarker][iVertex]->GetRotation_Type() % 2 == 0) && (SendRecv < 0)) { @@ -1663,20 +1663,20 @@ void COutputLegacy::MergeVolumetricConnectivity(CConfig *config, CGeometry *geom } } } - + /*--- Now we communicate this information to all processors, so that they can force the removal of these particular nodes by flagging them as halo points. In general, this should be a small percentage of the total mesh, so the communication/storage costs here shouldn't be prohibitive. ---*/ - + /*--- First communicate the number of points that each rank has found ---*/ unsigned long nAddedPeriodic = 0, maxAddedPeriodic = 0; unsigned long Buffer_Send_nAddedPeriodic[1], *Buffer_Recv_nAddedPeriodic = NULL; Buffer_Recv_nAddedPeriodic = new unsigned long[size]; - + nAddedPeriodic = Added_Periodic.size(); Buffer_Send_nAddedPeriodic[0] = nAddedPeriodic; - + #ifdef HAVE_MPI SU2_MPI::Allreduce(&nAddedPeriodic, &maxAddedPeriodic, 1, MPI_UNSIGNED_LONG, MPI_MAX, MPI_COMM_WORLD); @@ -1686,18 +1686,18 @@ void COutputLegacy::MergeVolumetricConnectivity(CConfig *config, CGeometry *geom maxAddedPeriodic = nAddedPeriodic; Buffer_Recv_nAddedPeriodic[0] = Buffer_Send_nAddedPeriodic[0]; #endif - + /*--- Communicate the global index values of all added periodic nodes. ---*/ unsigned long *Buffer_Send_AddedPeriodic = new unsigned long[maxAddedPeriodic]; unsigned long *Buffer_Recv_AddedPeriodic = new unsigned long[size*maxAddedPeriodic]; - + for (iPoint = 0; iPoint < Added_Periodic.size(); iPoint++) { Buffer_Send_AddedPeriodic[iPoint] = Added_Periodic[iPoint]; } - + /*--- Gather the element connectivity information. All processors will now have a copy of the global index values for all added periodic points. ---*/ - + #ifdef HAVE_MPI SU2_MPI::Allgather(Buffer_Send_AddedPeriodic, maxAddedPeriodic, MPI_UNSIGNED_LONG, Buffer_Recv_AddedPeriodic, maxAddedPeriodic, MPI_UNSIGNED_LONG, @@ -1705,43 +1705,43 @@ void COutputLegacy::MergeVolumetricConnectivity(CConfig *config, CGeometry *geom #else for (iPoint = 0; iPoint < maxAddedPeriodic; iPoint++) Buffer_Recv_AddedPeriodic[iPoint] = Buffer_Send_AddedPeriodic[iPoint]; #endif - + /*--- Search all send/recv boundaries on this partition for halo cells. In particular, consider only the recv conditions (these are the true halo nodes). Check the ranks of the processors that are communicating and choose to keep only the halo cells from the higher rank processor. Here, we are also choosing to keep periodic nodes that were part of the original domain. We will check the communicated list of added periodic points. ---*/ - + int *Local_Halo = new int[geometry->GetnPoint()]; for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) Local_Halo[iPoint] = !geometry->node[iPoint]->GetDomain(); - + for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { if (config->GetMarker_All_KindBC(iMarker) == SEND_RECEIVE) { SendRecv = config->GetMarker_All_SendRecv(iMarker); RecvFrom = abs(SendRecv)-1; - + for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); iGlobal_Index = geometry->node[iPoint]->GetGlobalIndex(); - + /*--- We need to keep one copy of overlapping halo cells. ---*/ notHalo = ((geometry->vertex[iMarker][iVertex]->GetRotation_Type() == 0) && (SendRecv < 0) && (rank > RecvFrom)); - + /*--- We want to keep the periodic nodes that were part of the original domain. For SU2_DEF we want to keep all periodic nodes. ---*/ - + if (kind_SU2 == SU2_DEF) { isPeriodic = ((geometry->vertex[iMarker][iVertex]->GetRotation_Type() > 0)); }else { isPeriodic = ((geometry->vertex[iMarker][iVertex]->GetRotation_Type() > 0) && (geometry->vertex[iMarker][iVertex]->GetRotation_Type() % 2 == 1)); } - + notPeriodic = (isPeriodic && (SendRecv < 0)); - + /*--- Lastly, check that this isn't an added periodic point that we will forcibly remove. Use the communicated list of these points. ---*/ addedPeriodic = false; kPoint = 0; @@ -1753,7 +1753,7 @@ void COutputLegacy::MergeVolumetricConnectivity(CConfig *config, CGeometry *geom /*--- Adjust jNode to index of next proc's data in the buffers. ---*/ kPoint = (iProcessor+1)*maxAddedPeriodic; } - + /*--- If we found either of these types of nodes, flag them to be kept. ---*/ if ((notHalo || notPeriodic) && !addedPeriodic) { Local_Halo[iPoint] = false; @@ -1761,45 +1761,45 @@ void COutputLegacy::MergeVolumetricConnectivity(CConfig *config, CGeometry *geom } } } - + /*--- Loop over all elements in this partition and load the elements of the current type into the buffer to be sent to the master node. ---*/ - + jNode = 0; jElem = 0; for (iElem = 0; iElem < geometry->GetnElem(); iElem++) { if (geometry->elem[iElem]->GetVTK_Type() == Elem_Type) { - + /*--- Loop over all nodes in this element and load the connectivity into the send buffer. ---*/ - + Buffer_Send_Halo[jElem] = false; for (iNode = 0; iNode < NODES_PER_ELEMENT; iNode++) { - + /*--- Store the global index values directly. ---*/ - + iPoint = geometry->elem[iElem]->GetNode(iNode); Buffer_Send_Elem[jNode] = geometry->node[iPoint]->GetGlobalIndex(); - + /*--- Check if this is a halo node. If so, flag this element as a halo cell. We will use this later to sort and remove any duplicates from the connectivity list. ---*/ - + if (Local_Halo[iPoint]) { Buffer_Send_Halo[jElem] = true; } - + /*--- Increment jNode as the counter. We need this because iElem may include other elements that we skip over during this loop. ---*/ - + jNode++; } jElem++; } } - + /*--- Gather the element connectivity information. ---*/ - + #ifdef HAVE_MPI SU2_MPI::Gather(Buffer_Send_Elem, nBuffer_Scalar, MPI_UNSIGNED_LONG, Buffer_Recv_Elem, nBuffer_Scalar, MPI_UNSIGNED_LONG, MASTER_NODE, MPI_COMM_WORLD); SU2_MPI::Gather(Buffer_Send_Halo, MaxLocalElem, MPI_UNSIGNED_SHORT, Buffer_Recv_Halo, MaxLocalElem, MPI_UNSIGNED_SHORT, MASTER_NODE, MPI_COMM_WORLD); @@ -1807,56 +1807,56 @@ void COutputLegacy::MergeVolumetricConnectivity(CConfig *config, CGeometry *geom for (iPoint = 0; iPoint < nBuffer_Scalar; iPoint++) Buffer_Recv_Elem[iPoint] = Buffer_Send_Elem[iPoint]; for (iPoint = 0; iPoint < MaxLocalElem; iPoint++) Buffer_Recv_Halo[iPoint] = Buffer_Send_Halo[iPoint]; #endif - + /*--- The master node unpacks and sorts the connectivity. ---*/ - + if (rank == MASTER_NODE) { - + /*--- We need to remove any duplicate elements (halo cells) that exist on multiple partitions. Start by initializing all elements to the "write" state by using a boolean array. ---*/ - + Write_Elem = new bool[size*MaxLocalElem]; for (iElem = 0; iElem < size*MaxLocalElem; iElem++) { Write_Elem[iElem] = true; } - + /*--- Remove the rind layer from the solution only if requested ---*/ - + if (!Wrt_Halo) { - + /*--- Loop for flagging duplicate elements so that they are not included in the final connectivity list. ---*/ - + kElem = 0; for (iProcessor = 0; iProcessor < size; iProcessor++) { for (iElem = 0; iElem < Buffer_Recv_nElem[iProcessor]; iElem++) { - + /*--- Check if this element was marked as a halo. ---*/ if (Buffer_Recv_Halo[kElem+iElem]) Write_Elem[kElem+iElem] = false; - + } kElem = (iProcessor+1)*MaxLocalElem; } } - + /*--- Store the unique connectivity list for this element type. ---*/ - + jNode = 0; kNode = 0; jElem = 0; nElem_Total = 0; for (iProcessor = 0; iProcessor < size; iProcessor++) { for (iElem = 0; iElem < Buffer_Recv_nElem[iProcessor]; iElem++) { - + /*--- Only write the elements that were flagged for it. ---*/ if (Write_Elem[jElem+iElem]) { - + /*--- Increment total count for this element type ---*/ nElem_Total++; - + /*--- Get global index, then loop over each variable and store. Note that we are adding one to the index value because CGNS/Tecplot use 1-based indexing.---*/ - + for (iNode = 0; iNode < NODES_PER_ELEMENT; iNode++) { Conn_Elem[kNode] = (int)Buffer_Recv_Elem[jNode+iElem*NODES_PER_ELEMENT+iNode] + 1; kNode++; @@ -1868,7 +1868,7 @@ void COutputLegacy::MergeVolumetricConnectivity(CConfig *config, CGeometry *geom jNode = (iProcessor+1)*nBuffer_Scalar; } } - + /*--- Immediately release the temporary buffers. ---*/ delete [] Buffer_Send_Elem; delete [] Buffer_Send_Halo; @@ -1882,10 +1882,10 @@ void COutputLegacy::MergeVolumetricConnectivity(CConfig *config, CGeometry *geom delete [] Buffer_Recv_Halo; delete [] Write_Elem; } - + /*--- Store the particular global element count in the class data, and set the class data pointer to the connectivity array. ---*/ - + if (rank == MASTER_NODE) { switch (Elem_Type) { case TRIANGLE: @@ -1917,43 +1917,43 @@ void COutputLegacy::MergeVolumetricConnectivity(CConfig *config, CGeometry *geom break; } } - + } void COutputLegacy::MergeSurfaceConnectivity(CConfig *config, CGeometry *geometry, unsigned short Elem_Type) { - + unsigned short NODES_PER_ELEMENT; - + unsigned short iMarker; unsigned long iPoint, iNode, jNode; unsigned long iElem = 0; unsigned long nLocalElem = 0, nElem_Total = 0; - + int iProcessor; unsigned long jElem; - + unsigned long iVertex; - + int SendRecv, RecvFrom; - + unsigned long Buffer_Send_nElem[1], *Buffer_Recv_nElem = NULL; unsigned long nBuffer_Scalar = 0; unsigned long kNode = 0, kElem = 0; unsigned long MaxLocalElem = 0, iGlobal_Index, jPoint, kPoint; - + bool Wrt_Halo = config->GetWrt_Halo(); bool *Write_Elem = NULL, notPeriodic, notHalo, addedPeriodic; - - + + int *Conn_Elem = NULL; - + /*--- Store the local number of this element type and the number of nodes per this element type. In serial, this will be the total number of this element type in the entire mesh. In parallel, it is the number on only the current partition. ---*/ - + nLocalElem = 0; - + for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { if (config->GetMarker_All_Plotting(iMarker) == YES) { for (iElem = 0; iElem < geometry->GetnElem_Bound(iMarker); iElem++) { @@ -1963,7 +1963,7 @@ void COutputLegacy::MergeSurfaceConnectivity(CConfig *config, CGeometry *geometr } } } - + switch (Elem_Type) { case LINE: NODES_PER_ELEMENT = N_POINTS_LINE; @@ -1979,13 +1979,13 @@ void COutputLegacy::MergeSurfaceConnectivity(CConfig *config, CGeometry *geometr NODES_PER_ELEMENT = 0; break; } - + /*--- Find the max number of this element type among all partitions and set up buffers. ---*/ - + Buffer_Send_nElem[0] = nLocalElem; if (rank == MASTER_NODE) Buffer_Recv_nElem = new unsigned long[size]; - + #ifdef HAVE_MPI SU2_MPI::Allreduce(&nLocalElem, &MaxLocalElem, 1, MPI_UNSIGNED_LONG, MPI_MAX, MPI_COMM_WORLD); SU2_MPI::Gather(&Buffer_Send_nElem, 1, MPI_UNSIGNED_LONG, Buffer_Recv_nElem, 1, MPI_UNSIGNED_LONG, MASTER_NODE, MPI_COMM_WORLD); @@ -1993,30 +1993,30 @@ void COutputLegacy::MergeSurfaceConnectivity(CConfig *config, CGeometry *geometr MaxLocalElem = nLocalElem; Buffer_Recv_nElem[0] = Buffer_Send_nElem[0]; #endif - + nBuffer_Scalar = MaxLocalElem*NODES_PER_ELEMENT; - + /*--- Send and Recv buffers ---*/ - + unsigned long *Buffer_Send_Elem = new unsigned long[nBuffer_Scalar]; unsigned long *Buffer_Recv_Elem = NULL; - + unsigned short *Buffer_Send_Halo = new unsigned short[MaxLocalElem]; unsigned short *Buffer_Recv_Halo = NULL; - + /*--- Prepare the receive buffers on the master node only. ---*/ - + if (rank == MASTER_NODE) { Buffer_Recv_Elem = new unsigned long[size*nBuffer_Scalar]; Buffer_Recv_Halo = new unsigned short[size*MaxLocalElem]; if (MaxLocalElem > 0) Conn_Elem = new int[size*MaxLocalElem*NODES_PER_ELEMENT]; } - + /*--- Force the removal of all added periodic elements (use global index). First, we isolate and create a list of all added periodic points, excluding those that we part of the original domain (we want these to be in the output files). ---*/ - + vector Added_Periodic; Added_Periodic.clear(); for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { @@ -2032,20 +2032,20 @@ void COutputLegacy::MergeSurfaceConnectivity(CConfig *config, CGeometry *geometr } } } - + /*--- Now we communicate this information to all processors, so that they can force the removal of these particular nodes by flagging them as halo points. In general, this should be a small percentage of the total mesh, so the communication/storage costs here shouldn't be prohibitive. ---*/ - + /*--- First communicate the number of points that each rank has found ---*/ unsigned long nAddedPeriodic = 0, maxAddedPeriodic = 0; unsigned long Buffer_Send_nAddedPeriodic[1], *Buffer_Recv_nAddedPeriodic = NULL; Buffer_Recv_nAddedPeriodic = new unsigned long[size]; - + nAddedPeriodic = Added_Periodic.size(); Buffer_Send_nAddedPeriodic[0] = nAddedPeriodic; - + #ifdef HAVE_MPI SU2_MPI::Allreduce(&nAddedPeriodic, &maxAddedPeriodic, 1, MPI_UNSIGNED_LONG, MPI_MAX, MPI_COMM_WORLD); @@ -2055,18 +2055,18 @@ void COutputLegacy::MergeSurfaceConnectivity(CConfig *config, CGeometry *geometr maxAddedPeriodic = nAddedPeriodic; Buffer_Recv_nAddedPeriodic[0] = Buffer_Send_nAddedPeriodic[0]; #endif - + /*--- Communicate the global index values of all added periodic nodes. ---*/ unsigned long *Buffer_Send_AddedPeriodic = new unsigned long[maxAddedPeriodic]; unsigned long *Buffer_Recv_AddedPeriodic = new unsigned long[size*maxAddedPeriodic]; - + for (iPoint = 0; iPoint < Added_Periodic.size(); iPoint++) { Buffer_Send_AddedPeriodic[iPoint] = Added_Periodic[iPoint]; } - + /*--- Gather the element connectivity information. All processors will now have a copy of the global index values for all added periodic points. ---*/ - + #ifdef HAVE_MPI SU2_MPI::Allgather(Buffer_Send_AddedPeriodic, maxAddedPeriodic, MPI_UNSIGNED_LONG, Buffer_Recv_AddedPeriodic, maxAddedPeriodic, MPI_UNSIGNED_LONG, @@ -2074,36 +2074,36 @@ void COutputLegacy::MergeSurfaceConnectivity(CConfig *config, CGeometry *geometr #else for (iPoint = 0; iPoint < maxAddedPeriodic; iPoint++) Buffer_Recv_AddedPeriodic[iPoint] = Buffer_Send_AddedPeriodic[iPoint]; #endif - + /*--- Search all send/recv boundaries on this partition for halo cells. In particular, consider only the recv conditions (these are the true halo nodes). Check the ranks of the processors that are communicating and choose to keep only the halo cells from the higher rank processor. Here, we are also choosing to keep periodic nodes that were part of the original domain. We will check the communicated list of added periodic points. ---*/ - + int *Local_Halo = new int[geometry->GetnPoint()]; for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) Local_Halo[iPoint] = !geometry->node[iPoint]->GetDomain(); - + for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { if (config->GetMarker_All_KindBC(iMarker) == SEND_RECEIVE) { SendRecv = config->GetMarker_All_SendRecv(iMarker); RecvFrom = abs(SendRecv)-1; - + for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); iGlobal_Index = geometry->node[iPoint]->GetGlobalIndex(); - + /*--- We need to keep one copy of overlapping halo cells. ---*/ notHalo = ((geometry->vertex[iMarker][iVertex]->GetRotation_Type() == 0) && (SendRecv < 0) && (rank > RecvFrom)); - + /*--- We want to keep the periodic nodes that were part of the original domain ---*/ notPeriodic = ((geometry->vertex[iMarker][iVertex]->GetRotation_Type() > 0) && (geometry->vertex[iMarker][iVertex]->GetRotation_Type() % 2 == 1) && (SendRecv < 0)); - + /*--- Lastly, check that this isn't an added periodic point that we will forcibly remove. Use the communicated list of these points. ---*/ addedPeriodic = false; kPoint = 0; @@ -2115,7 +2115,7 @@ void COutputLegacy::MergeSurfaceConnectivity(CConfig *config, CGeometry *geometr /*--- Adjust jNode to index of next proc's data in the buffers. ---*/ kPoint = (iProcessor+1)*maxAddedPeriodic; } - + /*--- If we found either of these types of nodes, flag them to be kept. ---*/ if ((notHalo || notPeriodic) && !addedPeriodic) { Local_Halo[iPoint] = false; @@ -2123,7 +2123,7 @@ void COutputLegacy::MergeSurfaceConnectivity(CConfig *config, CGeometry *geometr } } } - + /*--- Loop over all elements in this partition and load the elements of the current type into the buffer to be sent to the master node. ---*/ @@ -2131,38 +2131,38 @@ void COutputLegacy::MergeSurfaceConnectivity(CConfig *config, CGeometry *geometr for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) if (config->GetMarker_All_Plotting(iMarker) == YES) for (iElem = 0; iElem < geometry->GetnElem_Bound(iMarker); iElem++) { - + if (geometry->bound[iMarker][iElem]->GetVTK_Type() == Elem_Type) { - + /*--- Loop over all nodes in this element and load the connectivity into the send buffer. ---*/ - + Buffer_Send_Halo[jElem] = false; for (iNode = 0; iNode < NODES_PER_ELEMENT; iNode++) { - + /*--- Store the global index values directly. ---*/ - + iPoint = geometry->bound[iMarker][iElem]->GetNode(iNode); Buffer_Send_Elem[jNode] = geometry->node[iPoint]->GetGlobalIndex(); - + /*--- Check if this is a halo node. If so, flag this element as a halo cell. We will use this later to sort and remove any duplicates from the connectivity list. ---*/ - + if (Local_Halo[iPoint]) Buffer_Send_Halo[jElem] = true; - + /*--- Increment jNode as the counter. We need this because iElem may include other elements that we skip over during this loop. ---*/ - + jNode++; } jElem++; } } - + /*--- Gather the element connectivity information. ---*/ - + #ifdef HAVE_MPI SU2_MPI::Gather(Buffer_Send_Elem, nBuffer_Scalar, MPI_UNSIGNED_LONG, Buffer_Recv_Elem, nBuffer_Scalar, MPI_UNSIGNED_LONG, MASTER_NODE, MPI_COMM_WORLD); SU2_MPI::Gather(Buffer_Send_Halo, MaxLocalElem, MPI_UNSIGNED_SHORT, Buffer_Recv_Halo, MaxLocalElem, MPI_UNSIGNED_SHORT, MASTER_NODE, MPI_COMM_WORLD); @@ -2170,56 +2170,56 @@ void COutputLegacy::MergeSurfaceConnectivity(CConfig *config, CGeometry *geometr for (iPoint = 0; iPoint < nBuffer_Scalar; iPoint++) Buffer_Recv_Elem[iPoint] = Buffer_Send_Elem[iPoint]; for (iPoint = 0; iPoint < MaxLocalElem; iPoint++) Buffer_Recv_Halo[iPoint] = Buffer_Send_Halo[iPoint]; #endif - + /*--- The master node unpacks and sorts the connectivity. ---*/ - + if (rank == MASTER_NODE) { - + /*--- We need to remove any duplicate elements (halo cells) that exist on multiple partitions. Start by initializing all elements to the "write" state by using a boolean array. ---*/ - + Write_Elem = new bool[size*MaxLocalElem]; for (iElem = 0; iElem < size*MaxLocalElem; iElem++) { Write_Elem[iElem] = true; } - + /*--- Remove the rind layer from the solution only if requested ---*/ - + if (!Wrt_Halo) { - + /*--- Loop for flagging duplicate elements so that they are not included in the final connectivity list. ---*/ - + kElem = 0; for (iProcessor = 0; iProcessor < size; iProcessor++) { for (iElem = 0; iElem < Buffer_Recv_nElem[iProcessor]; iElem++) { - + /*--- Check if this element was marked as a halo. ---*/ if (Buffer_Recv_Halo[kElem+iElem]) Write_Elem[kElem+iElem] = false; - + } kElem = (iProcessor+1)*MaxLocalElem; } } - + /*--- Store the unique connectivity list for this element type. ---*/ - + jNode = 0; kNode = 0; jElem = 0; nElem_Total = 0; for (iProcessor = 0; iProcessor < size; iProcessor++) { for (iElem = 0; iElem < Buffer_Recv_nElem[iProcessor]; iElem++) { - + /*--- Only write the elements that were flagged for it. ---*/ if (Write_Elem[jElem+iElem]) { - + /*--- Increment total count for this element type ---*/ nElem_Total++; - + /*--- Get global index, then loop over each variable and store. Note that we are adding one to the index value because CGNS/Tecplot use 1-based indexing.---*/ - + for (iNode = 0; iNode < NODES_PER_ELEMENT; iNode++) { Conn_Elem[kNode] = (int)Buffer_Recv_Elem[jNode+iElem*NODES_PER_ELEMENT+iNode] + 1; kNode++; @@ -2231,7 +2231,7 @@ void COutputLegacy::MergeSurfaceConnectivity(CConfig *config, CGeometry *geometr jNode = (iProcessor+1)*nBuffer_Scalar; } } - + /*--- Immediately release the temporary buffers. ---*/ delete [] Buffer_Send_Elem; delete [] Buffer_Send_Halo; @@ -2245,10 +2245,10 @@ void COutputLegacy::MergeSurfaceConnectivity(CConfig *config, CGeometry *geometr delete [] Buffer_Recv_Halo; delete [] Write_Elem; } - + /*--- Store the particular global element count in the class data, and set the class data pointer to the connectivity array. ---*/ - + if (rank == MASTER_NODE) { switch (Elem_Type) { case LINE: @@ -2268,11 +2268,11 @@ void COutputLegacy::MergeSurfaceConnectivity(CConfig *config, CGeometry *geometr break; } } - + } void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver **solver, unsigned short val_iZone) { - + unsigned short Kind_Solver = config->GetKind_Solver(); unsigned short iVar = 0, jVar = 0, FirstIndex = NONE, SecondIndex = NONE, ThirdIndex = NONE; unsigned short nVar_First = 0, nVar_Second = 0, nVar_Third = 0; @@ -2282,18 +2282,18 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver iVar_FEA_Extra = 0, iVar_SensDim = 0; unsigned long iPoint = 0, jPoint = 0, iVertex = 0, iMarker = 0; su2double Gas_Constant, Mach2Vel, Mach_Motion, RefDensity, RefPressure = 0.0, factor = 0.0; - + su2double *Aux_Frict_x = NULL, *Aux_Frict_y = NULL, *Aux_Frict_z = NULL, *Aux_Heat = NULL, *Aux_yPlus = NULL, *Aux_Sens = NULL; - + unsigned short CurrentIndex; int *Local_Halo; unsigned long Buffer_Send_nPoint[1], *Buffer_Recv_nPoint = NULL; unsigned long nLocalPoint = 0, MaxLocalPoint = 0; unsigned long iGlobal_Index = 0, nBuffer_Scalar = 0; bool Wrt_Halo = config->GetWrt_Halo(), isPeriodic; - + int iProcessor; - + bool dynamic_grid = config->GetDynamic_Grid(); bool compressible = (config->GetKind_Regime() == COMPRESSIBLE); bool incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); @@ -2312,13 +2312,13 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver ( config->GetKind_Solver() == ADJ_NAVIER_STOKES ) || ( config->GetKind_Solver() == ADJ_RANS ) ); bool fem = (config->GetKind_Solver() == FEM_ELASTICITY); - + unsigned short iDim; unsigned short nDim = geometry->GetnDim(); su2double RefArea = config->GetRefArea(); su2double Gamma = config->GetGamma(); su2double RefVel2, *Normal, Area; - + /*--- Set the non-dimensionalization ---*/ if (flow) { if (dynamic_grid) { @@ -2336,11 +2336,11 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver RefPressure = solver[FLOW_SOL]->GetPressure_Inf(); factor = 1.0 / (0.5*RefDensity*RefArea*RefVel2); } - + /*--- Prepare send buffers for the conservative variables. Need to find the total number of conservative variables and also the index for their particular solution container. ---*/ - + switch (Kind_Solver) { case EULER : case NAVIER_STOKES: case INC_EULER: case INC_NAVIER_STOKES: FirstIndex = FLOW_SOL; if(config->GetWeakly_Coupled_Heat()) SecondIndex = HEAT_SOL; else SecondIndex = NONE; ThirdIndex = NONE; break; case RANS : case INC_RANS: FirstIndex = FLOW_SOL; SecondIndex = TURB_SOL; if (transition) ThirdIndex=TRANS_SOL; else ThirdIndex = NONE; if(config->GetWeakly_Coupled_Heat()) ThirdIndex = HEAT_SOL; else ThirdIndex = NONE; break; @@ -2354,32 +2354,32 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver case DISC_ADJ_FEM: FirstIndex = ADJFEA_SOL; SecondIndex = NONE; ThirdIndex = NONE; break; default: SecondIndex = NONE; ThirdIndex = NONE; break; } - + nVar_First = solver[FirstIndex]->GetnVar(); if (SecondIndex != NONE) nVar_Second = solver[SecondIndex]->GetnVar(); if (ThirdIndex != NONE) nVar_Third = solver[ThirdIndex]->GetnVar(); nVar_Consv = nVar_First + nVar_Second + nVar_Third; nVar_Total = nVar_Consv; - - + + /*--- Add the limiters ---*/ - + if (config->GetWrt_Limiters()) nVar_Total += nVar_Consv; - + /*--- Add the residuals ---*/ - + if (config->GetWrt_Residuals()) nVar_Total += nVar_Consv; - + /*--- Add the grid velocity to the restart file for the unsteady adjoint ---*/ - + if (dynamic_grid && !fem) { iVar_GridVel = nVar_Total; if (geometry->GetnDim() == 2) nVar_Total += 2; else if (geometry->GetnDim() == 3) nVar_Total += 3; } - + /*--- Add Pressure, Temperature, Cp, Mach to the restart file ---*/ - + if (Kind_Solver == EULER || Kind_Solver == NAVIER_STOKES || Kind_Solver == RANS || Kind_Solver == INC_EULER || Kind_Solver == INC_NAVIER_STOKES || Kind_Solver == INC_RANS || Kind_Solver == FEM_EULER || Kind_Solver == FEM_NAVIER_STOKES || Kind_Solver == FEM_RANS || @@ -2387,9 +2387,9 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver iVar_PressCp = nVar_Total; nVar_Total += 3; iVar_MachMean = nVar_Total; nVar_Total += 1; } - + /*--- Add Laminar Viscosity, Skin Friction, Heat Flux, & yPlus to the restart file ---*/ - + if (Kind_Solver == NAVIER_STOKES || Kind_Solver == RANS || Kind_Solver == INC_NAVIER_STOKES || Kind_Solver == INC_RANS || Kind_Solver == FEM_NAVIER_STOKES || Kind_Solver == FEM_RANS || Kind_Solver == FEM_LES) { @@ -2401,15 +2401,15 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver iVar_HeatCoeffs = nVar_Total; nVar_Total += 2; } - + /*--- Add Eddy Viscosity to the restart file ---*/ - + if (Kind_Solver == RANS || Kind_Solver == FEM_RANS || Kind_Solver == FEM_LES || Kind_Solver == INC_RANS) { iVar_Eddy = nVar_Total; nVar_Total += 1; } - + /*--- Add Sharp edges to the restart file ---*/ - + if (config->GetWrt_SharpEdges()) { if (((Kind_Solver == EULER) || (Kind_Solver == NAVIER_STOKES) || (Kind_Solver == RANS)) || ((Kind_Solver == INC_EULER) || (Kind_Solver == INC_NAVIER_STOKES) || (Kind_Solver == INC_RANS)) || @@ -2417,14 +2417,14 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver iVar_Sharp = nVar_Total; nVar_Total += 1; } } - - + + if (( Kind_Solver == ADJ_EULER ) || ( Kind_Solver == ADJ_NAVIER_STOKES ) || ( Kind_Solver == ADJ_RANS )) { iVar_Sens = nVar_Total; nVar_Total += 2; } - + if (Kind_Solver == FEM_ELASTICITY) { /*--- If the analysis is dynamic... ---*/ if (config->GetTime_Domain()) { @@ -2441,7 +2441,7 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver if (geometry->GetnDim() == 3) {iVar_FEA_Stress_3D = nVar_Total; nVar_Total += 3;} iVar_FEA_Extra = nVar_Total; nVar_Total += 1; } - + if ((Kind_Solver == DISC_ADJ_EULER) || (Kind_Solver == DISC_ADJ_NAVIER_STOKES) || (Kind_Solver == DISC_ADJ_RANS) || @@ -2451,36 +2451,36 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver iVar_Sens = nVar_Total; nVar_Total += 1; iVar_SensDim = nVar_Total; nVar_Total += nDim; } - + if ((Kind_Solver == DISC_ADJ_FEM) && (config->GetFSI_Simulation())){ iVar_FEA_Extra = nVar_Total; nVar_Total += 2; } - + if (config->GetExtraOutput()) { if (Kind_Solver == RANS || Kind_Solver == INC_RANS) { iVar_Extra = nVar_Total; nVar_Extra = solver[TURB_SOL]->GetnOutputVariables(); nVar_Total += nVar_Extra; } } - - - + + + Local_Halo = new int[geometry->GetnPoint()]; for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) Local_Halo[iPoint] = !geometry->node[iPoint]->GetDomain(); - + /*--- Search all send/recv boundaries on this partition for any periodic nodes that were part of the original domain. We want to recover these for visualization purposes. ---*/ - + if (Wrt_Halo) { nLocalPoint = geometry->GetnPoint(); } else { for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { if (config->GetMarker_All_KindBC(iMarker) == SEND_RECEIVE) { - + /*--- Checking for less than or equal to the rank, because there may be some periodic halo nodes that send info to the same rank. ---*/ - + for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); isPeriodic = ((geometry->vertex[iMarker][iVertex]->GetRotation_Type() > 0) && @@ -2489,20 +2489,20 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver } } } - + /*--- Sum total number of nodes that belong to the domain ---*/ - + for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) if (Local_Halo[iPoint] == false) nLocalPoint++; - + } Buffer_Send_nPoint[0] = nLocalPoint; - + /*--- Each processor sends its local number of nodes to the master. ---*/ - + if (rank == MASTER_NODE) Buffer_Recv_nPoint = new unsigned long[size]; - + #ifdef HAVE_MPI SU2_MPI::Allreduce(&nLocalPoint, &MaxLocalPoint, 1, MPI_UNSIGNED_LONG, MPI_MAX, MPI_COMM_WORLD); SU2_MPI::Gather(&Buffer_Send_nPoint, 1, MPI_UNSIGNED_LONG, Buffer_Recv_nPoint, 1, MPI_UNSIGNED_LONG, MASTER_NODE, MPI_COMM_WORLD); @@ -2510,25 +2510,25 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver MaxLocalPoint = nLocalPoint; Buffer_Recv_nPoint[0] = Buffer_Send_nPoint[0]; #endif - + nBuffer_Scalar = MaxLocalPoint; - + /*--- Send and Recv buffers. ---*/ - + su2double *Buffer_Send_Var = new su2double[MaxLocalPoint]; su2double *Buffer_Recv_Var = NULL; - + su2double *Buffer_Send_Res = new su2double[MaxLocalPoint]; su2double *Buffer_Recv_Res = NULL; - + su2double *Buffer_Send_Vol = new su2double[MaxLocalPoint]; su2double *Buffer_Recv_Vol = NULL; - + unsigned long *Buffer_Send_GlobalIndex = new unsigned long[MaxLocalPoint]; unsigned long *Buffer_Recv_GlobalIndex = NULL; - + /*--- Auxiliary vectors for surface coefficients ---*/ - + if (((Kind_Solver == NAVIER_STOKES) || (Kind_Solver == RANS)) || ((Kind_Solver == INC_NAVIER_STOKES) || (Kind_Solver == INC_RANS)) || ((Kind_Solver == FEM_NAVIER_STOKES) || (Kind_Solver == FEM_RANS) || (Kind_Solver == FEM_LES))) { @@ -2538,7 +2538,7 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver Aux_Heat = new su2double[geometry->GetnPoint()]; Aux_yPlus = new su2double[geometry->GetnPoint()]; } - + if ((Kind_Solver == ADJ_EULER) || (Kind_Solver == ADJ_NAVIER_STOKES) || (Kind_Solver == ADJ_RANS) || @@ -2550,16 +2550,16 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver (Kind_Solver == DISC_ADJ_INC_RANS)) { Aux_Sens = new su2double[geometry->GetnPoint()]; } - + /*--- Prepare the receive buffers in the master node only. ---*/ - + if (rank == MASTER_NODE) { - + Buffer_Recv_Var = new su2double[size*MaxLocalPoint]; Buffer_Recv_Res = new su2double[size*MaxLocalPoint]; Buffer_Recv_Vol = new su2double[size*MaxLocalPoint]; Buffer_Recv_GlobalIndex = new unsigned long[size*MaxLocalPoint]; - + /*--- Sum total number of nodes to be written and allocate arrays ---*/ nGlobal_Poin = 0; for (iProcessor = 0; iProcessor < size; iProcessor++) { @@ -2570,17 +2570,17 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver Data[iVar] = new su2double[nGlobal_Poin]; } } - + /*--- Main communication routine. Loop over each variable that has been requested by the user and perform the MPI comm. Temporary 1-D buffers are used to send the solution for each variable at all nodes on each partition to the master node. These are then unpacked by the master and sorted by global index in one large n-dim. array. ---*/ - + for (iVar = 0; iVar < nVar_Consv; iVar++) { - + /*--- Logic for which solution class to draw from. ---*/ - + jVar = iVar; CurrentIndex = FirstIndex; if ((SecondIndex != NONE) && (iVar > nVar_First-1)) { @@ -2591,54 +2591,54 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver jVar = iVar - nVar_First - nVar_Second; CurrentIndex = ThirdIndex; } - + /*--- Loop over this partition to collect the current variable ---*/ - + jPoint = 0; for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { - + /*--- Check for halos & write only if requested ---*/ - + if (!Local_Halo[iPoint] || Wrt_Halo) { - + /*--- Get this variable into the temporary send buffer. ---*/ - + Buffer_Send_Var[jPoint] = solver[CurrentIndex]->GetNodes()->GetSolution(iPoint, jVar); if (config->GetWrt_Limiters()) { 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); + Buffer_Send_Res[jPoint] = solver[CurrentIndex]->LinSysRes(iPoint, jVar); } else { 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) { Buffer_Send_GlobalIndex[jPoint] = geometry->node[iPoint]->GetGlobalIndex(); } - + jPoint++; - + } } - + /*--- Gather the data on the master node. ---*/ - + #ifdef HAVE_MPI SU2_MPI::Gather(Buffer_Send_Var, nBuffer_Scalar, MPI_DOUBLE, Buffer_Recv_Var, nBuffer_Scalar, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); #else for (iPoint = 0; iPoint < nBuffer_Scalar; iPoint++) Buffer_Recv_Var[iPoint] = Buffer_Send_Var[iPoint]; #endif - + if (config->GetWrt_Limiters()) { #ifdef HAVE_MPI SU2_MPI::Gather(Buffer_Send_Vol, nBuffer_Scalar, MPI_DOUBLE, Buffer_Recv_Vol, nBuffer_Scalar, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); @@ -2646,7 +2646,7 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver for (iPoint = 0; iPoint < nBuffer_Scalar; iPoint++) Buffer_Recv_Vol[iPoint] = Buffer_Send_Vol[iPoint]; #endif } - + if (config->GetWrt_Residuals()) { #ifdef HAVE_MPI SU2_MPI::Gather(Buffer_Send_Res, nBuffer_Scalar, MPI_DOUBLE, Buffer_Recv_Res, nBuffer_Scalar, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); @@ -2654,9 +2654,9 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver for (iPoint = 0; iPoint < nBuffer_Scalar; iPoint++) Buffer_Recv_Res[iPoint] = Buffer_Send_Res[iPoint]; #endif } - - - + + + if (iVar == 0) { #ifdef HAVE_MPI SU2_MPI::Gather(Buffer_Send_GlobalIndex, nBuffer_Scalar, MPI_UNSIGNED_LONG, Buffer_Recv_GlobalIndex, nBuffer_Scalar, MPI_UNSIGNED_LONG, MASTER_NODE, MPI_COMM_WORLD); @@ -2664,61 +2664,61 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver for (iPoint = 0; iPoint < nBuffer_Scalar; iPoint++) Buffer_Recv_GlobalIndex[iPoint] = Buffer_Send_GlobalIndex[iPoint]; #endif } - + /*--- The master node unpacks and sorts this variable by global index ---*/ - + if (rank == MASTER_NODE) { jPoint = 0; for (iProcessor = 0; iProcessor < size; iProcessor++) { for (iPoint = 0; iPoint < Buffer_Recv_nPoint[iProcessor]; iPoint++) { - + /*--- Get global index, then loop over each variable and store ---*/ - + iGlobal_Index = Buffer_Recv_GlobalIndex[jPoint]; - + Data[iVar][iGlobal_Index] = Buffer_Recv_Var[jPoint]; - - + + if (config->GetWrt_Limiters()) { Data[iVar+nVar_Consv][iGlobal_Index] = Buffer_Recv_Vol[jPoint]; } - + if (config->GetWrt_Residuals()) { unsigned short ExtraIndex; ExtraIndex = nVar_Consv; if (config->GetWrt_Limiters()) ExtraIndex = 2*nVar_Consv; Data[iVar+ExtraIndex][iGlobal_Index] = Buffer_Recv_Res[jPoint]; } - - - + + + jPoint++; } /*--- Adjust jPoint to index of next proc's data in the buffers. ---*/ jPoint = (iProcessor+1)*nBuffer_Scalar; } } - + } - + /*--- Additional communication routine for the grid velocity. Note that we are reusing the same temporary buffers from above for efficiency. Also, in the future more routines like this could be used to write an arbitrary number of additional variables to the file. ---*/ - + if (dynamic_grid && !fem) { - + /*--- Loop over this partition to collect the current variable ---*/ - + jPoint = 0; su2double *Grid_Vel; for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { - + /*--- Check for halos & write only if requested ---*/ - + if (!Local_Halo[iPoint] || Wrt_Halo) { - + /*--- Load buffers with the three grid velocity components. ---*/ - + Grid_Vel = geometry->node[iPoint]->GetGridVel(); Buffer_Send_Var[jPoint] = Grid_Vel[0]; Buffer_Send_Res[jPoint] = Grid_Vel[1]; @@ -2726,9 +2726,9 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver jPoint++; } } - + /*--- Gather the data on the master node. ---*/ - + #ifdef HAVE_MPI SU2_MPI::Gather(Buffer_Send_Var, nBuffer_Scalar, MPI_DOUBLE, Buffer_Recv_Var, nBuffer_Scalar, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); SU2_MPI::Gather(Buffer_Send_Res, nBuffer_Scalar, MPI_DOUBLE, Buffer_Recv_Res, nBuffer_Scalar, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); @@ -2742,16 +2742,16 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver for (iPoint = 0; iPoint < nBuffer_Scalar; iPoint++) Buffer_Recv_Vol[iPoint] = Buffer_Send_Vol[iPoint]; } #endif - + /*--- The master node unpacks and sorts this variable by global index ---*/ - + if (rank == MASTER_NODE) { jPoint = 0; iVar = iVar_GridVel; for (iProcessor = 0; iProcessor < size; iProcessor++) { for (iPoint = 0; iPoint < Buffer_Recv_nPoint[iProcessor]; iPoint++) { - + /*--- Get global index, then loop over each variable and store ---*/ - + iGlobal_Index = Buffer_Recv_GlobalIndex[jPoint]; Data[iVar][iGlobal_Index] = Buffer_Recv_Var[jPoint]; Data[iVar+1][iGlobal_Index] = Buffer_Recv_Res[jPoint]; @@ -2759,34 +2759,34 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver Data[iVar+2][iGlobal_Index] = Buffer_Recv_Vol[jPoint]; jPoint++; } - + /*--- Adjust jPoint to index of next proc's data in the buffers. ---*/ - + jPoint = (iProcessor+1)*nBuffer_Scalar; } } } - + /*--- Communicate Pressure, Cp, and Mach ---*/ - + if (((Kind_Solver == EULER) || (Kind_Solver == NAVIER_STOKES) || (Kind_Solver == RANS)) || ((Kind_Solver == INC_EULER) || (Kind_Solver == INC_NAVIER_STOKES) || (Kind_Solver == INC_RANS)) || ((Kind_Solver == FEM_EULER) || (Kind_Solver == FEM_NAVIER_STOKES) || (Kind_Solver == FEM_RANS) || (Kind_Solver == FEM_LES))) { - + /*--- First, loop through the mesh in order to find and store the value of the coefficient of pressure at any surface nodes. They will be placed in an auxiliary vector and then communicated like all other volumetric variables. ---*/ - + /*--- Loop over this partition to collect the current variable ---*/ - + jPoint = 0; for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { - + /*--- Check for halos & write only if requested ---*/ - + if (!Local_Halo[iPoint] || Wrt_Halo) { - + /*--- Load buffers with the pressure, Cp, and mach variables. ---*/ Buffer_Send_Var[jPoint] = solver[FLOW_SOL]->GetNodes()->GetPressure(iPoint); @@ -2800,9 +2800,9 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver jPoint++; } } - + /*--- Gather the data on the master node. ---*/ - + #ifdef HAVE_MPI SU2_MPI::Gather(Buffer_Send_Var, nBuffer_Scalar, MPI_DOUBLE, Buffer_Recv_Var, nBuffer_Scalar, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); SU2_MPI::Gather(Buffer_Send_Res, nBuffer_Scalar, MPI_DOUBLE, Buffer_Recv_Res, nBuffer_Scalar, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); @@ -2812,47 +2812,47 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver for (iPoint = 0; iPoint < nBuffer_Scalar; iPoint++) Buffer_Recv_Res[iPoint] = Buffer_Send_Res[iPoint]; for (iPoint = 0; iPoint < nBuffer_Scalar; iPoint++) Buffer_Recv_Vol[iPoint] = Buffer_Send_Vol[iPoint]; #endif - + /*--- The master node unpacks and sorts this variable by global index ---*/ - + if (rank == MASTER_NODE) { jPoint = 0; iVar = iVar_PressCp; for (iProcessor = 0; iProcessor < size; iProcessor++) { for (iPoint = 0; iPoint < Buffer_Recv_nPoint[iProcessor]; iPoint++) { - + /*--- Get global index, then loop over each variable and store ---*/ - + iGlobal_Index = Buffer_Recv_GlobalIndex[jPoint]; Data[iVar][iGlobal_Index] = Buffer_Recv_Var[jPoint]; Data[iVar+1][iGlobal_Index] = Buffer_Recv_Res[jPoint]; Data[iVar+2][iGlobal_Index] = Buffer_Recv_Vol[jPoint]; jPoint++; } - + /*--- Adjust jPoint to index of next proc's data in the buffers. ---*/ - + jPoint = (iProcessor+1)*nBuffer_Scalar; } } } - + /*--- Communicate Mach---*/ - + if (((Kind_Solver == EULER) || (Kind_Solver == NAVIER_STOKES) || (Kind_Solver == RANS)) || - ((Kind_Solver == INC_EULER) || (Kind_Solver == INC_NAVIER_STOKES) || (Kind_Solver == INC_RANS)) || + ((Kind_Solver == INC_EULER) || (Kind_Solver == INC_NAVIER_STOKES) || (Kind_Solver == INC_RANS)) || ((Kind_Solver == FEM_EULER) || (Kind_Solver == FEM_NAVIER_STOKES) || (Kind_Solver == FEM_RANS) || (Kind_Solver == FEM_LES))) { - + /*--- Loop over this partition to collect the current variable ---*/ - + jPoint = 0; for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { - + /*--- Check for halos & write only if requested ---*/ - + if (!Local_Halo[iPoint] || Wrt_Halo) { - + /*--- Load buffers with the temperature and laminar viscosity variables. ---*/ - + if (compressible) { Buffer_Send_Var[jPoint] = sqrt(solver[FLOW_SOL]->GetNodes()->GetVelocity2(iPoint))/ solver[FLOW_SOL]->GetNodes()->GetSoundSpeed(iPoint); @@ -2864,94 +2864,94 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver jPoint++; } } - + /*--- Gather the data on the master node. ---*/ - + #ifdef HAVE_MPI SU2_MPI::Gather(Buffer_Send_Var, nBuffer_Scalar, MPI_DOUBLE, Buffer_Recv_Var, nBuffer_Scalar, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); #else for (iPoint = 0; iPoint < nBuffer_Scalar; iPoint++) Buffer_Recv_Var[iPoint] = Buffer_Send_Var[iPoint]; #endif - + /*--- The master node unpacks and sorts this variable by global index ---*/ - + if (rank == MASTER_NODE) { jPoint = 0; iVar = iVar_MachMean; for (iProcessor = 0; iProcessor < size; iProcessor++) { for (iPoint = 0; iPoint < Buffer_Recv_nPoint[iProcessor]; iPoint++) { - + /*--- Get global index, then loop over each variable and store ---*/ - + iGlobal_Index = Buffer_Recv_GlobalIndex[jPoint]; Data[iVar][iGlobal_Index] = Buffer_Recv_Var[jPoint]; jPoint++; } - + /*--- Adjust jPoint to index of next proc's data in the buffers. ---*/ - + jPoint = (iProcessor+1)*nBuffer_Scalar; } } } - + /*--- Laminar Viscosity ---*/ - + if (((Kind_Solver == NAVIER_STOKES) || (Kind_Solver == RANS)) || - ((Kind_Solver == INC_NAVIER_STOKES) || (Kind_Solver == INC_RANS)) || + ((Kind_Solver == INC_NAVIER_STOKES) || (Kind_Solver == INC_RANS)) || ((Kind_Solver == FEM_NAVIER_STOKES) || (Kind_Solver == FEM_RANS) || (Kind_Solver == FEM_LES))) { - + /*--- Loop over this partition to collect the current variable ---*/ - + jPoint = 0; for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { - + /*--- Check for halos & write only if requested ---*/ - + if (!Local_Halo[iPoint] || Wrt_Halo) { - + /*--- Load buffers with the temperature and laminar viscosity variables. ---*/ - + Buffer_Send_Res[jPoint] = solver[FLOW_SOL]->GetNodes()->GetLaminarViscosity(iPoint); jPoint++; } } - + /*--- Gather the data on the master node. ---*/ - + #ifdef HAVE_MPI SU2_MPI::Gather(Buffer_Send_Res, nBuffer_Scalar, MPI_DOUBLE, Buffer_Recv_Res, nBuffer_Scalar, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); #else for (iPoint = 0; iPoint < nBuffer_Scalar; iPoint++) Buffer_Recv_Res[iPoint] = Buffer_Send_Res[iPoint]; #endif - + /*--- The master node unpacks and sorts this variable by global index ---*/ - + if (rank == MASTER_NODE) { jPoint = 0; iVar = iVar_Lam; for (iProcessor = 0; iProcessor < size; iProcessor++) { for (iPoint = 0; iPoint < Buffer_Recv_nPoint[iProcessor]; iPoint++) { - + /*--- Get global index, then loop over each variable and store ---*/ - + iGlobal_Index = Buffer_Recv_GlobalIndex[jPoint]; Data[iVar][iGlobal_Index] = Buffer_Recv_Res[jPoint]; jPoint++; } - + /*--- Adjust jPoint to index of next proc's data in the buffers. ---*/ - + jPoint = (iProcessor+1)*nBuffer_Scalar; } } - + /*--- Communicate skin friction ---*/ - + /*--- First, loop through the mesh in order to find and store the value of the viscous coefficients at any surface nodes. They will be placed in an auxiliary vector and then communicated like all other volumetric variables. ---*/ - + for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { Aux_Frict_x[iPoint] = 0.0; Aux_Frict_y[iPoint] = 0.0; @@ -2966,18 +2966,18 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver if (geometry->GetnDim() == 3) Aux_Frict_z[iPoint] = solver[FLOW_SOL]->GetCSkinFriction(iMarker, iVertex, 2); } } - + /*--- Loop over this partition to collect the current variable ---*/ - + jPoint = 0; for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { - + /*--- Check for halos & write only if requested ---*/ - + if (!Local_Halo[iPoint] || Wrt_Halo) { - + /*--- Load buffers with the three grid velocity components. ---*/ - + Buffer_Send_Var[jPoint] = Aux_Frict_x[iPoint]; Buffer_Send_Res[jPoint] = Aux_Frict_y[iPoint]; if (geometry->GetnDim() == 3) @@ -2985,9 +2985,9 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver jPoint++; } } - + /*--- Gather the data on the master node. ---*/ - + #ifdef HAVE_MPI SU2_MPI::Gather(Buffer_Send_Var, nBuffer_Scalar, MPI_DOUBLE, Buffer_Recv_Var, nBuffer_Scalar, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); SU2_MPI::Gather(Buffer_Send_Res, nBuffer_Scalar, MPI_DOUBLE, Buffer_Recv_Res, nBuffer_Scalar, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); @@ -3004,17 +3004,17 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver Buffer_Recv_Vol[iPoint] = Buffer_Send_Vol[iPoint]; } #endif - + /*--- The master node unpacks and sorts this variable by global index ---*/ - + if (rank == MASTER_NODE) { jPoint = 0; iVar = iVar_ViscCoeffs; for (iProcessor = 0; iProcessor < size; iProcessor++) { for (iPoint = 0; iPoint < Buffer_Recv_nPoint[iProcessor]; iPoint++) { - + /*--- Get global index, then loop over each variable and store ---*/ - + iGlobal_Index = Buffer_Recv_GlobalIndex[jPoint]; Data[iVar][iGlobal_Index] = Buffer_Recv_Var[jPoint]; Data[iVar + 1][iGlobal_Index] = Buffer_Recv_Res[jPoint]; @@ -3022,20 +3022,20 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver Data[iVar + 2][iGlobal_Index] = Buffer_Recv_Vol[jPoint]; jPoint++; } - + /*--- Adjust jPoint to index of next proc's data in the buffers. ---*/ - + jPoint = (iProcessor + 1) * nBuffer_Scalar; } } - + /*--- Communicate heat transfer, y+ ---*/ - + /*--- First, loop through the mesh in order to find and store the value of the viscous coefficients at any surface nodes. They will be placed in an auxiliary vector and then communicated like all other volumetric variables. ---*/ - + for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { Aux_Heat[iPoint] = 0.0; Aux_yPlus[iPoint] = 0.0; @@ -3048,18 +3048,18 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver Aux_yPlus[iPoint] = solver[FLOW_SOL]->GetYPlus(iMarker, iVertex); } } - + /*--- Loop over this partition to collect the current variable ---*/ - + jPoint = 0; for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { - + /*--- Check for halos & write only if requested ---*/ - + if (!Local_Halo[iPoint] || Wrt_Halo) { - + /*--- Load buffers with the skin friction, heat transfer, y+ variables. ---*/ - + if (compressible) { Buffer_Send_Res[jPoint] = Aux_Heat[iPoint]; Buffer_Send_Vol[jPoint] = Aux_yPlus[iPoint]; @@ -3071,9 +3071,9 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver jPoint++; } } - + /*--- Gather the data on the master node. ---*/ - + #ifdef HAVE_MPI SU2_MPI::Gather(Buffer_Send_Res, nBuffer_Scalar, MPI_DOUBLE, Buffer_Recv_Res, nBuffer_Scalar, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); SU2_MPI::Gather(Buffer_Send_Vol, nBuffer_Scalar, MPI_DOUBLE, Buffer_Recv_Vol, nBuffer_Scalar, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); @@ -3083,138 +3083,138 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver for (iPoint = 0; iPoint < nBuffer_Scalar; iPoint++) Buffer_Recv_Vol[iPoint] = Buffer_Send_Vol[iPoint]; #endif - + /*--- The master node unpacks and sorts this variable by global index ---*/ - + if (rank == MASTER_NODE) { jPoint = 0; iVar = iVar_HeatCoeffs; for (iProcessor = 0; iProcessor < size; iProcessor++) { for (iPoint = 0; iPoint < Buffer_Recv_nPoint[iProcessor]; iPoint++) { - + /*--- Get global index, then loop over each variable and store ---*/ - + iGlobal_Index = Buffer_Recv_GlobalIndex[jPoint]; Data[iVar + 0][iGlobal_Index] = Buffer_Recv_Res[jPoint]; Data[iVar + 1][iGlobal_Index] = Buffer_Recv_Vol[jPoint]; jPoint++; } - + /*--- Adjust jPoint to index of next proc's data in the buffers. ---*/ - + jPoint = (iProcessor + 1) * nBuffer_Scalar; } } } - - + + /*--- Communicate the Eddy Viscosity ---*/ - + if (Kind_Solver == RANS || Kind_Solver == FEM_RANS || Kind_Solver == FEM_LES || Kind_Solver == INC_RANS) { - + /*--- Loop over this partition to collect the current variable ---*/ - + jPoint = 0; for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { - + /*--- Check for halos & write only if requested ---*/ - + if (!Local_Halo[iPoint] || Wrt_Halo) { - + /*--- Load buffers with the pressure and mach variables. ---*/ - + Buffer_Send_Var[jPoint] = solver[FLOW_SOL]->GetNodes()->GetEddyViscosity(iPoint); jPoint++; } } - + /*--- Gather the data on the master node. ---*/ - + #ifdef HAVE_MPI SU2_MPI::Gather(Buffer_Send_Var, nBuffer_Scalar, MPI_DOUBLE, Buffer_Recv_Var, nBuffer_Scalar, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); #else for (iPoint = 0; iPoint < nBuffer_Scalar; iPoint++) Buffer_Recv_Var[iPoint] = Buffer_Send_Var[iPoint]; #endif - + /*--- The master node unpacks and sorts this variable by global index ---*/ - + if (rank == MASTER_NODE) { jPoint = 0; iVar = iVar_Eddy; for (iProcessor = 0; iProcessor < size; iProcessor++) { for (iPoint = 0; iPoint < Buffer_Recv_nPoint[iProcessor]; iPoint++) { - + /*--- Get global index, then loop over each variable and store ---*/ - + iGlobal_Index = Buffer_Recv_GlobalIndex[jPoint]; Data[iVar][iGlobal_Index] = Buffer_Recv_Var[jPoint]; jPoint++; } - + /*--- Adjust jPoint to index of next proc's data in the buffers. ---*/ - + jPoint = (iProcessor+1)*nBuffer_Scalar; } } - + } - + /*--- Communicate the Sharp Edges ---*/ - + if (config->GetWrt_SharpEdges()) { - + if (((Kind_Solver == EULER) || (Kind_Solver == NAVIER_STOKES) || (Kind_Solver == RANS)) || ((Kind_Solver == INC_EULER) || (Kind_Solver == INC_NAVIER_STOKES) || (Kind_Solver == INC_RANS)) || ((Kind_Solver == FEM_EULER) || (Kind_Solver == FEM_NAVIER_STOKES) || (Kind_Solver == FEM_RANS) || (Kind_Solver == FEM_LES))) { - + /*--- Loop over this partition to collect the current variable ---*/ jPoint = 0; for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { - + /*--- Check for halos & write only if requested ---*/ - + if (!Local_Halo[iPoint] || Wrt_Halo) { - + /*--- Load buffers with the pressure and mach variables. ---*/ - + Buffer_Send_Var[jPoint] = geometry->node[iPoint]->GetSharpEdge_Distance(); jPoint++; } } - + /*--- Gather the data on the master node. ---*/ - + #ifdef HAVE_MPI SU2_MPI::Gather(Buffer_Send_Var, nBuffer_Scalar, MPI_DOUBLE, Buffer_Recv_Var, nBuffer_Scalar, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); #else for (iPoint = 0; iPoint < nBuffer_Scalar; iPoint++) Buffer_Recv_Var[iPoint] = Buffer_Send_Var[iPoint]; #endif - + /*--- The master node unpacks and sorts this variable by global index ---*/ - + if (rank == MASTER_NODE) { jPoint = 0; iVar = iVar_Sharp; for (iProcessor = 0; iProcessor < size; iProcessor++) { for (iPoint = 0; iPoint < Buffer_Recv_nPoint[iProcessor]; iPoint++) { - + /*--- Get global index, then loop over each variable and store ---*/ - + iGlobal_Index = Buffer_Recv_GlobalIndex[jPoint]; Data[iVar][iGlobal_Index] = Buffer_Recv_Var[jPoint]; jPoint++; } - + /*--- Adjust jPoint to index of next proc's data in the buffers. ---*/ - + jPoint = (iProcessor+1)*nBuffer_Scalar; } } } } - + /*--- Communicate the surface sensitivity ---*/ - + if ((Kind_Solver == ADJ_EULER) || (Kind_Solver == ADJ_NAVIER_STOKES) || (Kind_Solver == ADJ_RANS) || @@ -3224,12 +3224,12 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver (Kind_Solver == DISC_ADJ_INC_EULER) || (Kind_Solver == DISC_ADJ_INC_NAVIER_STOKES) || (Kind_Solver == DISC_ADJ_INC_RANS)) { - + /*--- First, loop through the mesh in order to find and store the value of the surface sensitivity at any surface nodes. They will be placed in an auxiliary vector and then communicated like all other volumetric variables. ---*/ - + for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) Aux_Sens[iPoint] = 0.0; for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) if (config->GetMarker_All_Plotting(iMarker) == YES) { @@ -3242,30 +3242,30 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver Aux_Sens[iPoint] = solver[ADJFLOW_SOL]->GetCSensitivity(iMarker, iVertex)/Area; } } - + /*--- Loop over this partition to collect the current variable ---*/ - + jPoint = 0; for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { - + /*--- Check for halos & write only if requested ---*/ - + if (!Local_Halo[iPoint] || Wrt_Halo) { - + /*--- Load buffers with the skin friction, heat transfer, y+ variables. ---*/ - + Buffer_Send_Var[jPoint] = Aux_Sens[iPoint]; if ((config->GetKind_ConvNumScheme() == SPACE_CENTERED) && (!config->GetDiscrete_Adjoint())) 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]->GetNodes()->GetLimiter(iPoint, 0); - + jPoint++; } } - + /*--- Gather the data on the master node. ---*/ - + #ifdef HAVE_MPI SU2_MPI::Gather(Buffer_Send_Var, nBuffer_Scalar, MPI_DOUBLE, Buffer_Recv_Var, nBuffer_Scalar, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); if (!config->GetDiscrete_Adjoint()) @@ -3275,30 +3275,30 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver if (!config->GetDiscrete_Adjoint()) for (iPoint = 0; iPoint < nBuffer_Scalar; iPoint++) Buffer_Recv_Res[iPoint] = Buffer_Send_Res[iPoint]; #endif - + /*--- The master node unpacks and sorts this variable by global index ---*/ - + if (rank == MASTER_NODE) { jPoint = 0; iVar = iVar_Sens; for (iProcessor = 0; iProcessor < size; iProcessor++) { for (iPoint = 0; iPoint < Buffer_Recv_nPoint[iProcessor]; iPoint++) { - + /*--- Get global index, then loop over each variable and store ---*/ - + iGlobal_Index = Buffer_Recv_GlobalIndex[jPoint]; Data[iVar+0][iGlobal_Index] = Buffer_Recv_Var[jPoint]; if (!config->GetDiscrete_Adjoint()) Data[iVar+1][iGlobal_Index] = Buffer_Recv_Res[jPoint]; jPoint++; } - + /*--- Adjust jPoint to index of next proc's data in the buffers. ---*/ - + jPoint = (iProcessor+1)*nBuffer_Scalar; } } } - + if ((Kind_Solver == DISC_ADJ_EULER) || (Kind_Solver == DISC_ADJ_NAVIER_STOKES) || (Kind_Solver == DISC_ADJ_RANS) || @@ -3306,16 +3306,16 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver (Kind_Solver == DISC_ADJ_INC_NAVIER_STOKES) || (Kind_Solver == DISC_ADJ_INC_RANS)) { /*--- Loop over this partition to collect the current variable ---*/ - + jPoint = 0; for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { - + /*--- Check for halos & write only if requested ---*/ - + if (!Local_Halo[iPoint] || Wrt_Halo) { - + /*--- Load buffers with the skin friction, heat transfer, y+ variables. ---*/ - + 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) @@ -3323,9 +3323,9 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver jPoint++; } } - + /*--- Gather the data on the master node. ---*/ - + #ifdef HAVE_MPI SU2_MPI::Gather(Buffer_Send_Var, nBuffer_Scalar, MPI_DOUBLE, Buffer_Recv_Var, nBuffer_Scalar, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); SU2_MPI::Gather(Buffer_Send_Res, nBuffer_Scalar, MPI_DOUBLE, Buffer_Recv_Res, nBuffer_Scalar, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); @@ -3337,16 +3337,16 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver if (nDim == 3) for (iPoint = 0; iPoint < nBuffer_Scalar; iPoint++) Buffer_Recv_Vol[iPoint] = Buffer_Send_Vol[iPoint]; #endif - + /*--- The master node unpacks and sorts this variable by global index ---*/ - + if (rank == MASTER_NODE) { jPoint = 0; iVar = iVar_SensDim; for (iProcessor = 0; iProcessor < size; iProcessor++) { for (iPoint = 0; iPoint < Buffer_Recv_nPoint[iProcessor]; iPoint++) { - + /*--- Get global index, then loop over each variable and store ---*/ - + iGlobal_Index = Buffer_Recv_GlobalIndex[jPoint]; Data[iVar+0][iGlobal_Index] = Buffer_Recv_Var[jPoint]; Data[iVar+1][iGlobal_Index] = Buffer_Recv_Res[jPoint]; @@ -3354,30 +3354,30 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver Data[iVar+2][iGlobal_Index] = Buffer_Recv_Vol[jPoint]; jPoint++; } - + /*--- Adjust jPoint to index of next proc's data in the buffers. ---*/ - + jPoint = (iProcessor+1)*nBuffer_Scalar; } } } - - + + /*--- Communicate the Velocities for dynamic FEM problem ---*/ - + if ((Kind_Solver == FEM_ELASTICITY) && (config->GetTime_Domain())) { - + /*--- Loop over this partition to collect the current variable ---*/ - + jPoint = 0; su2double *Node_Vel; for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { - + /*--- Check for halos & write only if requested ---*/ - + if (!Local_Halo[iPoint] || Wrt_Halo) { - + /*--- Load buffers with the three grid velocity components. ---*/ - + Node_Vel = solver[FEA_SOL]->GetNodes()->GetSolution_Vel(iPoint); Buffer_Send_Var[jPoint] = Node_Vel[0]; Buffer_Send_Res[jPoint] = Node_Vel[1]; @@ -3385,9 +3385,9 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver jPoint++; } } - + /*--- Gather the data on the master node. ---*/ - + #ifdef HAVE_MPI SU2_MPI::Gather(Buffer_Send_Var, nBuffer_Scalar, MPI_DOUBLE, Buffer_Recv_Var, nBuffer_Scalar, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); SU2_MPI::Gather(Buffer_Send_Res, nBuffer_Scalar, MPI_DOUBLE, Buffer_Recv_Res, nBuffer_Scalar, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); @@ -3401,16 +3401,16 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver for (iPoint = 0; iPoint < nBuffer_Scalar; iPoint++) Buffer_Recv_Vol[iPoint] = Buffer_Send_Vol[iPoint]; } #endif - + /*--- The master node unpacks and sorts this variable by global index ---*/ - + if (rank == MASTER_NODE) { jPoint = 0; iVar = iVar_FEA_Vel; for (iProcessor = 0; iProcessor < size; iProcessor++) { for (iPoint = 0; iPoint < Buffer_Recv_nPoint[iProcessor]; iPoint++) { - + /*--- Get global index, then loop over each variable and store ---*/ - + iGlobal_Index = Buffer_Recv_GlobalIndex[jPoint]; Data[iVar][iGlobal_Index] = Buffer_Recv_Var[jPoint]; Data[iVar+1][iGlobal_Index] = Buffer_Recv_Res[jPoint]; @@ -3418,29 +3418,29 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver Data[iVar+2][iGlobal_Index] = Buffer_Recv_Vol[jPoint]; jPoint++; } - + /*--- Adjust jPoint to index of next proc's data in the buffers. ---*/ - + jPoint = (iProcessor+1)*nBuffer_Scalar; } } } - + /*--- Communicate the Accelerations for dynamic FEM problem ---*/ - + if ((Kind_Solver == FEM_ELASTICITY) && (config->GetTime_Domain())) { - + /*--- Loop over this partition to collect the current variable ---*/ - + jPoint = 0; su2double *Node_Accel; for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { - + /*--- Check for halos & write only if requested ---*/ - + if (!Local_Halo[iPoint] || Wrt_Halo) { - + /*--- Load buffers with the three grid velocity components. ---*/ - + Node_Accel = solver[FEA_SOL]->GetNodes()->GetSolution_Accel(iPoint); Buffer_Send_Var[jPoint] = Node_Accel[0]; Buffer_Send_Res[jPoint] = Node_Accel[1]; @@ -3448,9 +3448,9 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver jPoint++; } } - + /*--- Gather the data on the master node. ---*/ - + #ifdef HAVE_MPI SU2_MPI::Gather(Buffer_Send_Var, nBuffer_Scalar, MPI_DOUBLE, Buffer_Recv_Var, nBuffer_Scalar, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); SU2_MPI::Gather(Buffer_Send_Res, nBuffer_Scalar, MPI_DOUBLE, Buffer_Recv_Res, nBuffer_Scalar, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); @@ -3464,16 +3464,16 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver for (iPoint = 0; iPoint < nBuffer_Scalar; iPoint++) Buffer_Recv_Vol[iPoint] = Buffer_Send_Vol[iPoint]; } #endif - + /*--- The master node unpacks and sorts this variable by global index ---*/ - + if (rank == MASTER_NODE) { jPoint = 0; iVar = iVar_FEA_Accel; for (iProcessor = 0; iProcessor < size; iProcessor++) { for (iPoint = 0; iPoint < Buffer_Recv_nPoint[iProcessor]; iPoint++) { - + /*--- Get global index, then loop over each variable and store ---*/ - + iGlobal_Index = Buffer_Recv_GlobalIndex[jPoint]; Data[iVar][iGlobal_Index] = Buffer_Recv_Var[jPoint]; Data[iVar+1][iGlobal_Index] = Buffer_Recv_Res[jPoint]; @@ -3481,29 +3481,29 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver Data[iVar+2][iGlobal_Index] = Buffer_Recv_Vol[jPoint]; jPoint++; } - + /*--- Adjust jPoint to index of next proc's data in the buffers. ---*/ - + jPoint = (iProcessor+1)*nBuffer_Scalar; } } } /*--- Communicate the FEM elasticity stresses (2D) - New elasticity solver---*/ - + if (Kind_Solver == FEM_ELASTICITY) { - + /*--- Loop over this partition to collect the current variable ---*/ - + jPoint = 0; const su2double *Stress; for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { - + /*--- Check for halos & write only if requested ---*/ - + if (!Local_Halo[iPoint] || Wrt_Halo) { - + /*--- Load buffers with the three grid velocity components. ---*/ - + Stress = solver[FEA_SOL]->GetNodes()->GetStress_FEM(iPoint); /*--- Sigma xx ---*/ Buffer_Send_Var[jPoint] = Stress[0]; @@ -3514,9 +3514,9 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver jPoint++; } } - + /*--- Gather the data on the master node. ---*/ - + #ifdef HAVE_MPI SU2_MPI::Gather(Buffer_Send_Var, nBuffer_Scalar, MPI_DOUBLE, Buffer_Recv_Var, nBuffer_Scalar, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); SU2_MPI::Gather(Buffer_Send_Res, nBuffer_Scalar, MPI_DOUBLE, Buffer_Recv_Res, nBuffer_Scalar, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); @@ -3526,45 +3526,45 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver for (iPoint = 0; iPoint < nBuffer_Scalar; iPoint++) Buffer_Recv_Res[iPoint] = Buffer_Send_Res[iPoint]; for (iPoint = 0; iPoint < nBuffer_Scalar; iPoint++) Buffer_Recv_Vol[iPoint] = Buffer_Send_Vol[iPoint]; #endif - + /*--- The master node unpacks and sorts this variable by global index ---*/ - + if (rank == MASTER_NODE) { jPoint = 0; iVar = iVar_FEA_Stress; for (iProcessor = 0; iProcessor < size; iProcessor++) { for (iPoint = 0; iPoint < Buffer_Recv_nPoint[iProcessor]; iPoint++) { - + /*--- Get global index, then loop over each variable and store ---*/ - + iGlobal_Index = Buffer_Recv_GlobalIndex[jPoint]; Data[iVar][iGlobal_Index] = Buffer_Recv_Var[jPoint]; Data[iVar+1][iGlobal_Index] = Buffer_Recv_Res[jPoint]; Data[iVar+2][iGlobal_Index] = Buffer_Recv_Vol[jPoint]; jPoint++; } - + /*--- Adjust jPoint to index of next proc's data in the buffers. ---*/ - + jPoint = (iProcessor+1)*nBuffer_Scalar; } } } - + /*--- Communicate the FEM elasticity stresses (3D) - New elasticity solver---*/ - + if ((Kind_Solver == FEM_ELASTICITY) && (geometry->GetnDim() == 3)) { - + /*--- Loop over this partition to collect the current variable ---*/ - + jPoint = 0; const su2double *Stress; for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { - + /*--- Check for halos & write only if requested ---*/ - + if (!Local_Halo[iPoint] || Wrt_Halo) { - + /*--- Load buffers with the three grid velocity components. ---*/ - + Stress = solver[FEA_SOL]->GetNodes()->GetStress_FEM(iPoint); /*--- Sigma zz ---*/ Buffer_Send_Var[jPoint] = Stress[3]; @@ -3575,9 +3575,9 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver jPoint++; } } - + /*--- Gather the data on the master node. ---*/ - + #ifdef HAVE_MPI SU2_MPI::Gather(Buffer_Send_Var, nBuffer_Scalar, MPI_DOUBLE, Buffer_Recv_Var, nBuffer_Scalar, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); SU2_MPI::Gather(Buffer_Send_Res, nBuffer_Scalar, MPI_DOUBLE, Buffer_Recv_Res, nBuffer_Scalar, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); @@ -3586,81 +3586,81 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver for (iPoint = 0; iPoint < nBuffer_Scalar; iPoint++) Buffer_Recv_Var[iPoint] = Buffer_Send_Var[iPoint]; for (iPoint = 0; iPoint < nBuffer_Scalar; iPoint++) Buffer_Recv_Res[iPoint] = Buffer_Send_Res[iPoint]; for (iPoint = 0; iPoint < nBuffer_Scalar; iPoint++) Buffer_Recv_Vol[iPoint] = Buffer_Send_Vol[iPoint]; - + #endif - + /*--- The master node unpacks and sorts this variable by global index ---*/ - + if (rank == MASTER_NODE) { jPoint = 0; iVar = iVar_FEA_Stress_3D; for (iProcessor = 0; iProcessor < size; iProcessor++) { for (iPoint = 0; iPoint < Buffer_Recv_nPoint[iProcessor]; iPoint++) { - + /*--- Get global index, then loop over each variable and store ---*/ - + iGlobal_Index = Buffer_Recv_GlobalIndex[jPoint]; Data[iVar][iGlobal_Index] = Buffer_Recv_Var[jPoint]; Data[iVar+1][iGlobal_Index] = Buffer_Recv_Res[jPoint]; Data[iVar+2][iGlobal_Index] = Buffer_Recv_Vol[jPoint]; jPoint++; } - + /*--- Adjust jPoint to index of next proc's data in the buffers. ---*/ - + jPoint = (iProcessor+1)*nBuffer_Scalar; } } } - - + + /*--- Communicate the Linear elasticity ---*/ - + if ( Kind_Solver == FEM_ELASTICITY ) { - + /*--- Loop over this partition to collect the current variable ---*/ jPoint = 0; for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { - + /*--- Check for halos & write only if requested ---*/ - + if (!Local_Halo[iPoint] || Wrt_Halo) { - + /*--- Load buffers with the temperature and laminar viscosity variables. ---*/ - + Buffer_Send_Var[jPoint] = solver[FEA_SOL]->GetNodes()->GetVonMises_Stress(iPoint); jPoint++; } } - + /*--- Gather the data on the master node. ---*/ - + #ifdef HAVE_MPI SU2_MPI::Gather(Buffer_Send_Var, nBuffer_Scalar, MPI_DOUBLE, Buffer_Recv_Var, nBuffer_Scalar, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); #else for (iPoint = 0; iPoint < nBuffer_Scalar; iPoint++) Buffer_Recv_Var[iPoint] = Buffer_Send_Var[iPoint]; #endif - + /*--- The master node unpacks and sorts this variable by global index ---*/ - + if (rank == MASTER_NODE) { jPoint = 0; iVar = iVar_FEA_Extra; for (iProcessor = 0; iProcessor < size; iProcessor++) { for (iPoint = 0; iPoint < Buffer_Recv_nPoint[iProcessor]; iPoint++) { - + /*--- Get global index, then loop over each variable and store ---*/ - + iGlobal_Index = Buffer_Recv_GlobalIndex[jPoint]; Data[iVar][iGlobal_Index] = Buffer_Recv_Var[jPoint]; jPoint++; } - + /*--- Adjust jPoint to index of next proc's data in the buffers. ---*/ - + jPoint = (iProcessor+1)*nBuffer_Scalar; } } } - + if ((Kind_Solver == DISC_ADJ_FEM) && (config->GetFSI_Simulation())) { /*--- Loop over this partition to collect the current variable ---*/ @@ -3720,62 +3720,62 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver } if (config->GetExtraOutput()) { - + for (jVar = 0; jVar < nVar_Extra; jVar++) { - + /*--- Loop over this partition to collect the current variable ---*/ - + jPoint = 0; for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { - + /*--- Check for halos & write only if requested ---*/ - + if (!Local_Halo[iPoint] || Wrt_Halo) { - + /*--- Get this variable into the temporary send buffer. ---*/ - + if (Kind_Solver == RANS) { Buffer_Send_Var[jPoint] = solver[TURB_SOL]->OutputVariables[iPoint*nVar_Extra+jVar]; } jPoint++; - + } } - + /*--- Gather the data on the master node. ---*/ - + #ifdef HAVE_MPI SU2_MPI::Gather(Buffer_Send_Var, nBuffer_Scalar, MPI_DOUBLE, Buffer_Recv_Var, nBuffer_Scalar, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); #else for (iPoint = 0; iPoint < nBuffer_Scalar; iPoint++) Buffer_Recv_Var[iPoint] = Buffer_Send_Var[iPoint]; #endif - + /*--- The master node unpacks and sorts this variable by global index ---*/ - + if (rank == MASTER_NODE) { jPoint = 0; iVar = iVar_Extra; for (iProcessor = 0; iProcessor < size; iProcessor++) { for (iPoint = 0; iPoint < Buffer_Recv_nPoint[iProcessor]; iPoint++) { - + /*--- Get global index, then loop over each variable and store ---*/ - + iGlobal_Index = Buffer_Recv_GlobalIndex[jPoint]; Data[iVar+jVar][iGlobal_Index] = Buffer_Recv_Var[jPoint]; jPoint++; } - + /*--- Adjust jPoint to index of next proc's data in the buffers. ---*/ - + jPoint = (iProcessor+1)*nBuffer_Scalar; } } } } - - - + + + /*--- Immediately release the temporary buffers. ---*/ - + delete [] Buffer_Send_Var; delete [] Buffer_Send_Res; delete [] Buffer_Send_Vol; @@ -3787,11 +3787,11 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver delete [] Buffer_Recv_Vol; delete [] Buffer_Recv_GlobalIndex; } - + /*--- Release memory needed for surface coefficients ---*/ - + delete [] Local_Halo; - + if (((Kind_Solver == NAVIER_STOKES) || (Kind_Solver == RANS)) || ((Kind_Solver == INC_NAVIER_STOKES) || (Kind_Solver == INC_RANS)) || ((Kind_Solver == FEM_NAVIER_STOKES) || (Kind_Solver == FEM_RANS) || (Kind_Solver == FEM_LES))) { @@ -3809,33 +3809,33 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver ( Kind_Solver == DISC_ADJ_INC_RANS )) { delete [] Aux_Sens; } - + } void COutputLegacy::MergeBaselineSolution(CConfig *config, CGeometry *geometry, CSolver *solver, unsigned short val_iZone) { - + /*--- Local variables needed on all processors ---*/ unsigned short iVar; unsigned long iPoint = 0, jPoint = 0; - + nVar_Total = config->fields.size() - 1; - + /*--- Merge the solution either in serial or parallel. ---*/ - + #ifndef HAVE_MPI - + /*--- In serial, the single process has access to all solution data, so it is simple to retrieve and store inside Solution_Data. ---*/ - + unsigned short iMarker; unsigned long iVertex, nTotalPoints = 0; int SendRecv; - + /*--- First, create a structure to locate any periodic halo nodes ---*/ int *Local_Halo = new int[geometry->GetnPoint()]; for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) Local_Halo[iPoint] = !geometry->node[iPoint]->GetDomain(); - + for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { if (config->GetMarker_All_KindBC(iMarker) == SEND_RECEIVE) { SendRecv = config->GetMarker_All_SendRecv(iMarker); @@ -3847,76 +3847,76 @@ void COutputLegacy::MergeBaselineSolution(CConfig *config, CGeometry *geometry, Local_Halo[iPoint] = false; } } - + } } - + /*--- Total number of points in the mesh (this might include periodic points). ---*/ - + for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) if (!Local_Halo[iPoint]) nTotalPoints++; - + nGlobal_Poin = nTotalPoints; Data = new su2double*[nVar_Total]; for (iVar = 0; iVar < nVar_Total; iVar++) { Data[iVar] = new su2double[nGlobal_Poin]; } - + /*--- Loop over all points in the mesh, but only write data for nodes in the domain (ignore periodic halo nodes). ---*/ - + jPoint = 0; for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { if (!Local_Halo[iPoint]) { - + /*--- Solution (first, and second system of equations) ---*/ - + unsigned short jVar = 0; for (iVar = 0; iVar < nVar_Total; iVar++) { Data[jVar][jPoint] = solver->GetNodes()->GetSolution(iPoint,iVar); jVar++; } } - + /*--- Increment jPoint as the counter. We need this because iPoint may include halo nodes that we skip over during this loop. ---*/ - + jPoint++; - + } - + #else - + /*--- MPI preprocessing ---*/ - + int nProcessor = size, iProcessor; - + /*--- Local variables needed for merging with MPI ---*/ - + unsigned long iVertex, iMarker; unsigned long Buffer_Send_nPoint[1], *Buffer_Recv_nPoint = NULL; unsigned long nLocalPoint = 0, MaxLocalPoint = 0; unsigned long iGlobal_Index = 0, nBuffer_Scalar = 0; - + int *Local_Halo = new int[geometry->GetnPoint()]; for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) Local_Halo[iPoint] = !geometry->node[iPoint]->GetDomain(); - + bool Wrt_Halo = config->GetWrt_Halo(), isPeriodic; - + /*--- Search all send/recv boundaries on this partition for any periodic nodes that were part of the original domain. We want to recover these for visualization purposes. ---*/ - + if (Wrt_Halo) { nLocalPoint = geometry->GetnPoint(); } else { for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { if (config->GetMarker_All_KindBC(iMarker) == SEND_RECEIVE) { - + /*--- Checking for less than or equal to the rank, because there may be some periodic halo nodes that send info to the same rank. ---*/ - + for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); isPeriodic = ((geometry->vertex[iMarker][iVertex]->GetRotation_Type() > 0) && @@ -3925,37 +3925,37 @@ void COutputLegacy::MergeBaselineSolution(CConfig *config, CGeometry *geometry, } } } - + /*--- Sum total number of nodes that belong to the domain ---*/ - + for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) if (Local_Halo[iPoint] == false) nLocalPoint++; - + } Buffer_Send_nPoint[0] = nLocalPoint; - + if (rank == MASTER_NODE) Buffer_Recv_nPoint = new unsigned long[nProcessor]; - + SU2_MPI::Allreduce(&nLocalPoint, &MaxLocalPoint, 1, MPI_UNSIGNED_LONG, MPI_MAX, MPI_COMM_WORLD); SU2_MPI::Gather(&Buffer_Send_nPoint, 1, MPI_UNSIGNED_LONG, Buffer_Recv_nPoint, 1, MPI_UNSIGNED_LONG, MASTER_NODE, MPI_COMM_WORLD); - + nBuffer_Scalar = MaxLocalPoint; - + /*--- Send and Recv buffers. ---*/ - + su2double *Buffer_Send_Var = new su2double[MaxLocalPoint]; su2double *Buffer_Recv_Var = NULL; - + unsigned long *Buffer_Send_GlobalIndex = new unsigned long[MaxLocalPoint]; unsigned long *Buffer_Recv_GlobalIndex = NULL; - + /*--- Prepare the receive buffers in the master node only. ---*/ if (rank == MASTER_NODE) { - + Buffer_Recv_Var = new su2double[nProcessor*MaxLocalPoint]; Buffer_Recv_GlobalIndex = new unsigned long[nProcessor*MaxLocalPoint]; - + /*--- Sum total number of nodes to be written and allocate arrays ---*/ nGlobal_Poin = 0; for (iProcessor = 0; iProcessor < nProcessor; iProcessor++) { @@ -3965,27 +3965,27 @@ void COutputLegacy::MergeBaselineSolution(CConfig *config, CGeometry *geometry, for (iVar = 0; iVar < nVar_Total; iVar++) { Data[iVar] = new su2double[nGlobal_Poin]; } - + } - + /*--- Main communication routine. Loop over each variable that has been requested by the user and perform the MPI comm. Temporary 1-D buffers are used to send the solution for each variable at all nodes on each partition to the master node. These are then unpacked by the master and sorted by global index in one large n-dim. array. ---*/ - + for (iVar = 0; iVar < nVar_Total; iVar++) { - + /*--- Loop over this partition to collect the current variable ---*/ jPoint = 0; for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { - + /*--- Check for halos and write only if requested ---*/ if (!Local_Halo[iPoint] || Wrt_Halo) { - + /*--- Get this variable into the temporary send buffer. ---*/ Buffer_Send_Var[jPoint] = solver->GetNodes()->GetSolution(iPoint,iVar); - + /*--- Only send/recv the volumes & global indices during the first loop ---*/ if (iVar == 0) { Buffer_Send_GlobalIndex[jPoint] = geometry->node[iPoint]->GetGlobalIndex(); @@ -3993,20 +3993,20 @@ void COutputLegacy::MergeBaselineSolution(CConfig *config, CGeometry *geometry, jPoint++; } } - + /*--- Gather the data on the master node. ---*/ - + SU2_MPI::Gather(Buffer_Send_Var, nBuffer_Scalar, MPI_DOUBLE, Buffer_Recv_Var, nBuffer_Scalar, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); if (iVar == 0) { SU2_MPI::Gather(Buffer_Send_GlobalIndex, nBuffer_Scalar, MPI_UNSIGNED_LONG, Buffer_Recv_GlobalIndex, nBuffer_Scalar, MPI_UNSIGNED_LONG, MASTER_NODE, MPI_COMM_WORLD); } - + /*--- The master node unpacks and sorts this variable by global index ---*/ if (rank == MASTER_NODE) { jPoint = 0; for (iProcessor = 0; iProcessor < nProcessor; iProcessor++) { for (iPoint = 0; iPoint < Buffer_Recv_nPoint[iProcessor]; iPoint++) { - + /*--- Get global index, then loop over each variable and store ---*/ iGlobal_Index = Buffer_Recv_GlobalIndex[jPoint]; Data[iVar][iGlobal_Index] = Buffer_Recv_Var[jPoint]; @@ -4017,26 +4017,26 @@ void COutputLegacy::MergeBaselineSolution(CConfig *config, CGeometry *geometry, } } } - + /*--- Immediately release the temporary buffers. ---*/ - + delete [] Buffer_Send_Var; delete [] Buffer_Send_GlobalIndex; if (rank == MASTER_NODE) { delete [] Buffer_Recv_Var; delete [] Buffer_Recv_GlobalIndex; } - + #endif - + delete [] Local_Halo; - + } void COutputLegacy::SetRestart(CConfig *config, CGeometry *geometry, CSolver **solver, unsigned short val_iZone) { - + /*--- Local variables ---*/ - + unsigned short nZone = geometry->GetnZone(); unsigned short Kind_Solver = config->GetKind_Solver(); unsigned short iVar, iDim, nDim = geometry->GetnDim(); @@ -4049,9 +4049,9 @@ void COutputLegacy::SetRestart(CConfig *config, CGeometry *geometry, CSolver **s ofstream meta_file; string filename, meta_filename; bool adjoint = config->GetContinuous_Adjoint() || config->GetDiscrete_Adjoint(); - + /*--- Retrieve filename from config ---*/ - + // if (((config->GetContinuous_Adjoint()) || (config->GetDiscrete_Adjoint())) && ((config->GetKind_Solver() != DISC_ADJ_FEM))) { // filename = config->GetRestart_AdjFileName(); // filename = config->GetObjFunc_Extension(filename); @@ -4062,11 +4062,11 @@ void COutputLegacy::SetRestart(CConfig *config, CGeometry *geometry, CSolver **s // } else { // filename = config->GetRestart_FileName(); // } - + /*--- Append the zone number if multizone problems ---*/ if (nZone > 1) filename= config->GetMultizone_FileName(filename, val_iZone, ".dat"); - + /*--- Unsteady problems require an iteration number to be appended. ---*/ if (config->GetTime_Marching() == HARMONIC_BALANCE) { filename = config->GetUnsteady_FileName(filename, SU2_TYPE::Int(config->GetiInst()), ".dat"); @@ -4075,31 +4075,31 @@ void COutputLegacy::SetRestart(CConfig *config, CGeometry *geometry, CSolver **s } else if ((fem || disc_adj_fem) && (config->GetWrt_Dynamic())) { filename = config->GetUnsteady_FileName(filename, SU2_TYPE::Int(iExtIter), ".dat"); } - + /*--- Open the restart file and write the solution. ---*/ - + restart_file.open(filename.c_str(), ios::out); restart_file.precision(15); - + /*--- Write the header line based on the particular solver ----*/ - + restart_file << "\"PointID\""; - + /*--- Mesh coordinates are always written to the restart first ---*/ - + if (nDim == 2) { restart_file << "\t\"x\"\t\"y\""; } else { restart_file << "\t\"x\"\t\"y\"\t\"z\""; } - + for (iVar = 0; iVar < nVar_Consv; iVar++) { if (( Kind_Solver == FEM_ELASTICITY ) || ( Kind_Solver == DISC_ADJ_FEM)) restart_file << "\t\"Displacement_" << iVar+1<<"\""; else restart_file << "\t\"Conservative_" << iVar+1<<"\""; } - + if (config->GetWrt_Limiters()) { for (iVar = 0; iVar < nVar_Consv; iVar++) { restart_file << "\t\"Limiter_" << iVar+1<<"\""; @@ -4110,9 +4110,9 @@ void COutputLegacy::SetRestart(CConfig *config, CGeometry *geometry, CSolver **s restart_file << "\t\"Residual_" << iVar+1<<"\""; } } - + /*--- Mesh velocities for dynamic mesh cases ---*/ - + if (dynamic_grid && !fem) { if (nDim == 2) { restart_file << "\t\"Grid_Velx\"\t\"Grid_Vely\""; @@ -4120,7 +4120,7 @@ void COutputLegacy::SetRestart(CConfig *config, CGeometry *geometry, CSolver **s restart_file << "\t\"Grid_Velx\"\t\"Grid_Vely\"\t\"Grid_Velz\""; } } - + if ((Kind_Solver == EULER) || (Kind_Solver == NAVIER_STOKES) || (Kind_Solver == RANS) || (Kind_Solver == INC_EULER) || (Kind_Solver == INC_NAVIER_STOKES) || (Kind_Solver == INC_RANS)) { if (config->GetTabular_FileFormat() == TAB_CSV) { @@ -4128,7 +4128,7 @@ void COutputLegacy::SetRestart(CConfig *config, CGeometry *geometry, CSolver **s } else restart_file << "\t\"Pressure\"\t\"Temperature\"\t\"Cp\"\t\"Mach\""; } - + if ((Kind_Solver == NAVIER_STOKES) || (Kind_Solver == RANS) || (Kind_Solver == INC_NAVIER_STOKES) || (Kind_Solver == INC_RANS)) { if (config->GetTabular_FileFormat() == TAB_CSV) { @@ -4139,21 +4139,21 @@ void COutputLegacy::SetRestart(CConfig *config, CGeometry *geometry, CSolver **s if (nDim == 3) restart_file << "\t\"m\"\t\"Cf_x\"\t\"Cf_y\"\t\"Cf_z\"\t\"h\"\t\"y+\""; } } - + if (Kind_Solver == RANS || Kind_Solver == INC_RANS) { if ((config->GetTabular_FileFormat() == TAB_CSV)) { restart_file << "\t\"Eddy_Viscosity\""; } else restart_file << "\t\"mt\""; } - + if (config->GetWrt_SharpEdges()) { if (((Kind_Solver == EULER) || (Kind_Solver == NAVIER_STOKES) || (Kind_Solver == RANS)) || ((Kind_Solver == INC_EULER) || (Kind_Solver == INC_NAVIER_STOKES) || (Kind_Solver == INC_RANS))) { restart_file << "\t\"Sharp_Edge_Dist\""; } } - + if ((Kind_Solver == ADJ_EULER ) || (Kind_Solver == ADJ_NAVIER_STOKES ) || (Kind_Solver == ADJ_RANS ) ) { @@ -4170,7 +4170,7 @@ void COutputLegacy::SetRestart(CConfig *config, CGeometry *geometry, CSolver **s restart_file << "\t\"Sensitivity_z\""; } } - + if (Kind_Solver == FEM_ELASTICITY) { if (!dynamic_fem) { if (geometry->GetnDim() == 2) @@ -4189,21 +4189,21 @@ void COutputLegacy::SetRestart(CConfig *config, CGeometry *geometry, CSolver **s } } } - + if ((Kind_Solver == DISC_ADJ_FEM) && (config->GetFSI_Simulation())){ if (geometry->GetnDim() == 2) restart_file << "\t\"CrossTerm_1\"\t\"CrossTerm_2\""; if (geometry->GetnDim() == 3) restart_file << "\t\"CrossTerm_1\"\t\"CrossTerm_2\"\t\"CrossTerm_3\""; } - - + + if (config->GetExtraOutput()) { string *headings = NULL; //if (Kind_Solver == RANS) { headings = solver[TURB_SOL]->OutputHeadingNames; //} - + for (iVar = 0; iVar < nVar_Extra; iVar++) { if (headings == NULL) { restart_file << "\t\"ExtraOutput_" << iVar+1<<"\""; @@ -4212,36 +4212,36 @@ void COutputLegacy::SetRestart(CConfig *config, CGeometry *geometry, CSolver **s } } } - - + + restart_file << "\n"; - + /*--- Write the restart file ---*/ - + /*--- Determine whether or not the FEM solver is used, which decides the type of geometry classes that are instantiated. ---*/ bool fem_solver = ((config->GetKind_Solver() == FEM_EULER) || (config->GetKind_Solver() == FEM_NAVIER_STOKES) || (config->GetKind_Solver() == FEM_RANS) || (config->GetKind_Solver() == FEM_LES)); - + unsigned long nPointTotal = 0; if ( fem_solver ) { nPointTotal = solver[FLOW_SOL]->GetnDOFsGlobal(); } else { nPointTotal = geometry->GetGlobal_nPointDomain(); } - + for (iPoint = 0; iPoint < nPointTotal; iPoint++) { - + /*--- Index of the point ---*/ restart_file << iPoint << "\t"; - + /*--- Write the grid coordinates first ---*/ for (iDim = 0; iDim < nDim; iDim++) { restart_file << scientific << Coords[iDim][iPoint] << "\t"; } - + /*--- Loop over the variables and write the values to file ---*/ for (iVar = 0; iVar < nVar_Total; iVar++) { restart_file << scientific << Data[iVar][iPoint] << "\t"; @@ -4271,15 +4271,15 @@ void COutputLegacy::SetRestart(CConfig *config, CGeometry *geometry, CSolver **s } void COutputLegacy::DeallocateCoordinates(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 coordinate data ---*/ - + for (iDim = 0; iDim < nDim; iDim++) { delete [] Coords[iDim]; } @@ -4291,7 +4291,7 @@ void COutputLegacy::DeallocateConnectivity(CConfig *config, CGeometry *geometry, /*--- The master node alone owns all data found in this routine. ---*/ if (rank == MASTER_NODE) { - + /*--- Deallocate memory for connectivity data ---*/ if (surf_sol) { if (nGlobal_Line > 0 && Conn_Line != NULL) delete [] Conn_Line; @@ -4305,9 +4305,9 @@ void COutputLegacy::DeallocateConnectivity(CConfig *config, CGeometry *geometry, if (nGlobal_Hexa > 0 && Conn_Hexa != NULL) delete [] Conn_Hexa; if (nGlobal_Pris > 0 && Conn_Pris != NULL) delete [] Conn_Pris; if (nGlobal_Pyra > 0 && Conn_Pyra != NULL) delete [] Conn_Pyra; - + } - + } } @@ -4315,13 +4315,13 @@ void COutputLegacy::DeallocateSolution(CConfig *config, CGeometry *geometry) { /*--- The master node alone owns all data found in this routine. ---*/ if (rank == MASTER_NODE) { - + /*--- Deallocate memory for solution data ---*/ for (unsigned short iVar = 0; iVar < nVar_Total; iVar++) { delete [] Data[iVar]; } delete [] Data; - + } } @@ -4329,7 +4329,7 @@ void COutputLegacy::SetConvHistory_Header(ofstream *ConvHist_file, CConfig *conf char cstr[200], turb_resid[1000], adj_turb_resid[1000]; unsigned short iMarker_Monitoring; string Monitoring_Tag, monitoring_coeff, aeroelastic_coeff, turbo_coeff; - + bool rotating_frame = config->GetRotating_Frame(); bool aeroelastic = config->GetAeroelastic_Simulation(); bool equiv_area = config->GetEquivArea(); @@ -4343,7 +4343,7 @@ void COutputLegacy::SetConvHistory_Header(ofstream *ConvHist_file, CConfig *conf bool disc_adj = config->GetDiscrete_Adjoint(); bool frozen_visc = (cont_adj && config->GetFrozen_Visc_Cont()) ||( disc_adj && config->GetFrozen_Visc_Disc()); bool inv_design = (config->GetInvDesign_Cp() || config->GetInvDesign_HeatFlux()); - + bool output_surface = (config->GetnMarker_Analyze() != 0); bool output_comboObj = (config->GetnObj() > 1); bool output_per_surface = config->GetWrt_Surface(); @@ -4361,34 +4361,34 @@ void COutputLegacy::SetConvHistory_Header(ofstream *ConvHist_file, CConfig *conf config->GetKind_Solver() == INC_RANS || config->GetKind_Solver() == INC_NAVIER_STOKES) { thermal = true; } - + /*--- Write file name with extension ---*/ string filename = config->GetConv_FileName(); string hist_ext = ".csv"; if (config->GetTabular_FileFormat() == TAB_TECPLOT) hist_ext = ".dat"; - + if(config->GetnZone() > 1){ filename = config->GetMultizone_HistoryFileName(filename, val_iZone, hist_ext); } if(config->GetnTimeInstances() > 1){ filename = config->GetMultiInstance_HistoryFileName(filename, val_iInst); } - + if (config->GetTime_Domain() && config->GetRestart()) { filename = config->GetUnsteady_FileName(filename, config->GetRestart_Iter(), hist_ext); } - + strcpy (cstr, filename.data()); ConvHist_file->open(cstr, ios::out); ConvHist_file->precision(15); - + /*--- Begin of the header ---*/ - + char begin[]= "\"Iteration\""; - + /*--- Header for the coefficients ---*/ - + char flow_coeff[]= ",\"CL\",\"CD\",\"CSF\",\"CMx\",\"CMy\",\"CMz\",\"CFx\",\"CFy\",\"CFz\",\"CL/CD\",\"AoA\",\"Custom_ObjFunc\""; char heat_coeff[]= ",\"HeatFlux_Total\",\"HeatFlux_Maximum\",\"Temperature_Total\""; char equivalent_area_coeff[]= ",\"CEquivArea\",\"CNearFieldOF\""; @@ -4410,7 +4410,7 @@ void COutputLegacy::SetConvHistory_Header(ofstream *ConvHist_file, CConfig *conf char d_surface_outputs[]= ",\"D(Uniformity)\",\"D(Secondary_Strength)\",\"D(Momentum_Distortion)\",\"D(Secondary_Over_Uniformity)\",\"D(Pressure_Drop)\""; /*--- Find the markers being monitored and create a header for them ---*/ - + for (iMarker_Monitoring = 0; iMarker_Monitoring < config->GetnMarker_Monitoring(); iMarker_Monitoring++) { Monitoring_Tag = config->GetMarker_Monitoring_TagBound(iMarker_Monitoring); monitoring_coeff += ",\"CL_" + Monitoring_Tag + "\""; @@ -4455,13 +4455,13 @@ void COutputLegacy::SetConvHistory_Header(ofstream *ConvHist_file, CConfig *conf } char combo_obj[] = ",\"ComboObj\""; - + /*--- Header for the residuals ---*/ - + char flow_resid[]= ",\"Res_Flow[0]\",\"Res_Flow[1]\",\"Res_Flow[2]\",\"Res_Flow[3]\",\"Res_Flow[4]\""; char adj_flow_resid[]= ",\"Res_AdjFlow[0]\",\"Res_AdjFlow[1]\",\"Res_AdjFlow[2]\",\"Res_AdjFlow[3]\",\"Res_AdjFlow[4]\""; switch (config->GetKind_Turb_Model()) { - case SA:case SA_NEG:case SA_E: case SA_COMP: case SA_E_COMP: + case SA:case SA_NEG:case SA_E: case SA_COMP: case SA_E_COMP: SPRINTF (turb_resid, ",\"Res_Turb[0]\""); break; case SST:case SST_SUST: @@ -4478,22 +4478,22 @@ void COutputLegacy::SetConvHistory_Header(ofstream *ConvHist_file, CConfig *conf } char fem_resid[]= ",\"Res_FEM[0]\",\"Res_FEM[1]\",\"Res_FEM[2]\""; char heat_resid[]= ",\"Res_Heat\""; - + /*--- End of the header ---*/ - + char end[]= ",\"Linear_Solver_Iterations\",\"CFL_Number\",\"Time(min)\"\n"; char endfea[]= ",\"Linear_Solver_Iterations\",\"Time(min)\"\n"; - + if ((config->GetTabular_FileFormat() == TECPLOT) || (config->GetTabular_FileFormat() == TECPLOT_BINARY)) { ConvHist_file[0] << "TITLE = \"SU2 Simulation\"" << endl; ConvHist_file[0] << "VARIABLES = "; } - + /*--- Write the header, case depending ---*/ - + switch (config->GetKind_Solver()) { - + case EULER : case NAVIER_STOKES: case RANS : case INC_EULER : case INC_NAVIER_STOKES: case INC_RANS : case FEM_EULER : case FEM_NAVIER_STOKES: case FEM_RANS : case FEM_LES: @@ -4525,9 +4525,9 @@ void COutputLegacy::SetConvHistory_Header(ofstream *ConvHist_file, CConfig *conf } if (output_comboObj) ConvHist_file[0] << combo_obj; ConvHist_file[0] << end; - + break; - + case ADJ_EULER : case ADJ_NAVIER_STOKES : case ADJ_RANS: 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: @@ -4543,18 +4543,18 @@ void COutputLegacy::SetConvHistory_Header(ofstream *ConvHist_file, CConfig *conf if ((turbulent) && (!frozen_visc)) ConvHist_file[0] << adj_turb_resid; ConvHist_file[0] << end; break; - + case HEAT_EQUATION_FVM: ConvHist_file[0] << begin << heat_coeff; ConvHist_file[0] << heat_resid << end; break; - + case FEM_ELASTICITY: ConvHist_file[0] << begin << fem_coeff; if (incload) ConvHist_file[0] << fem_incload; ConvHist_file[0] << fem_resid << endfea; break; - + case DISC_ADJ_FEM: ConvHist_file[0] << begin << fem_coeff; ConvHist_file[0] << fem_resid << endfea; @@ -4566,7 +4566,7 @@ void COutputLegacy::SetConvHistory_Header(ofstream *ConvHist_file, CConfig *conf config->GetTabular_FileFormat() == TECPLOT_BINARY) { ConvHist_file[0] << "ZONE T= \"Convergence history\"" << endl; } - + } @@ -4579,7 +4579,7 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, su2double timeused, unsigned short val_iZone, unsigned short val_iInst) { - + bool output_surface = (config[val_iZone]->GetnMarker_Analyze() != 0); bool output_comboObj = (config[val_iZone]->GetnObj() > 1); bool fluid_structure = (config[val_iZone]->GetFSI_Simulation()); @@ -4600,27 +4600,27 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, bool incompressible = (config[val_iZone]->GetKind_Regime() == INCOMPRESSIBLE); if (!disc_adj && !cont_adj && !DualTime_Iteration) { - + if (fixed_cl && - (solver_container[val_iZone][val_iInst][MESH_0][FLOW_SOL]->GetStart_AoA_FD()) && + (solver_container[val_iZone][val_iInst][MESH_0][FLOW_SOL]->GetStart_AoA_FD()) && (iExtIter != solver_container[val_iZone][val_iInst][MESH_0][FLOW_SOL]->GetIter_Update_AoA())) { output_files = false; } - + if (fea || fluid_structure) output_files = false; /*--- We need to evaluate some of the objective functions to write the value on the history file ---*/ - + if (((iExtIter % (config[val_iZone]->GetWrt_Sol_Freq())) == 0) || (!fixed_cl && (iExtIter == (config[val_iZone]->GetnInner_Iter()-1))) || /*--- If CL mode we need to compute the complete solution at two very particular iterations ---*/ (fixed_cl && (iExtIter == (config[val_iZone]->GetnInner_Iter()-2) || - (solver_container[val_iZone][val_iInst][MESH_0][FLOW_SOL]->GetStart_AoA_FD() && + (solver_container[val_iZone][val_iInst][MESH_0][FLOW_SOL]->GetStart_AoA_FD() && iExtIter == solver_container[val_iZone][val_iInst][MESH_0][FLOW_SOL]->GetIter_Update_AoA())))) { - + if ((rank == MASTER_NODE) && output_files) cout << endl << "------------------------ Evaluate Special Output ------------------------"; - + switch (config[val_iZone]->GetKind_Solver()) { case EULER: case NAVIER_STOKES: case RANS: @@ -4645,45 +4645,45 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, SpecialOutput_SonicBoom(solver_container[val_iZone][val_iInst][MESH_0][FLOW_SOL], geometry[val_iZone][val_iInst][MESH_0], config[val_iZone], output_files); } - + /*--- For specific applications, evaluate and plot the cp coefficent at different stations. ---*/ - + if (config[val_iZone]->GetPlot_Section_Forces()) { SpecialOutput_SpanLoad(solver_container[val_iZone][val_iInst][MESH_0][FLOW_SOL], geometry[val_iZone][val_iInst][MESH_0], config[val_iZone], output_files); } - + break; } - + /*--- Output a file with the forces breakdown. ---*/ - + if (config[val_iZone]->GetTime_Marching() == HARMONIC_BALANCE) { SpecialOutput_HarmonicBalance(solver_container, geometry, config, val_iInst, nInst, output_files); } - + /*--- Compute span-wise values file for turbomachinery. ---*/ - + if (config[val_iZone]->GetBoolTurbomachinery()) { SpecialOutput_Turbo(solver_container, geometry, config, val_iZone, output_files); } - + /*--- Output a file with the forces breakdown. ---*/ - + SpecialOutput_ForcesBreakdown(solver_container, geometry, config, val_iZone, output_files); - + if ((rank == MASTER_NODE) && output_files) cout << "-------------------------------------------------------------------------" << endl << endl; - + } - + } - + /*--- Output using only the master node ---*/ - + if (rank == MASTER_NODE) { - + /*-- Compute the total objective if a "combo" objective is used ---*/ - + if (output_comboObj) { solver_container[val_iZone][val_iInst][FinestMesh][FLOW_SOL]->SetTotal_ComboObj(0.0); switch (config[val_iZone]->GetKind_Solver()) { @@ -4693,7 +4693,7 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, break; } } - + unsigned long ExtIter_OffSet = config[val_iZone]->GetExtIter_OffSet(); if (config[val_iZone]->GetTime_Marching() == DT_STEPPING_1ST || config[val_iZone]->GetTime_Marching() == DT_STEPPING_2ND) @@ -4701,7 +4701,7 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, /*--- WARNING: These buffers have hard-coded lengths. Note that you may have to adjust them to be larger if adding more entries. ---*/ - + char begin[1000], direct_coeff[1000], heat_coeff[1000], equivalent_area_coeff[1000], engine_coeff[1000], rotating_frame_coeff[1000], Cp_inverse_design[1000], Heat_inverse_design[1000], surface_coeff[1000], aeroelastic_coeff[1000], monitoring_coeff[10000], buffet_coeff[1000], adjoint_coeff[1000], flow_resid[1000], adj_flow_resid[1000], turb_resid[1000], trans_resid[1000], adj_turb_resid[1000], @@ -4711,13 +4711,13 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, su2double dummy = 0.0, *Coord; unsigned short iVar, iMarker_Monitoring; - + unsigned long LinSolvIter = 0, iPointMaxResid; su2double timeiter = timeused/su2double(iExtIter+1); - + unsigned short nDim = geometry[val_iZone][val_iInst][FinestMesh]->GetnDim(); - + bool rotating_frame = config[val_iZone]->GetRotating_Frame(); bool aeroelastic = config[val_iZone]->GetAeroelastic_Simulation(); bool equiv_area = config[val_iZone]->GetEquivArea(); @@ -4735,26 +4735,26 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, bool heat = ((config[val_iZone]->GetKind_Solver() == HEAT_EQUATION_FVM) || (config[val_iZone]->GetWeakly_Coupled_Heat())); bool weakly_coupled_heat = config[val_iZone]->GetWeakly_Coupled_Heat(); 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() == FEM_EULER) || - (config[val_iZone]->GetKind_Solver() == FEM_NAVIER_STOKES) || (config[val_iZone]->GetKind_Solver() == FEM_RANS) || + (config[val_iZone]->GetKind_Solver() == RANS) || (config[val_iZone]->GetKind_Solver() == FEM_EULER) || + (config[val_iZone]->GetKind_Solver() == FEM_NAVIER_STOKES) || (config[val_iZone]->GetKind_Solver() == FEM_RANS) || (config[val_iZone]->GetKind_Solver() == FEM_LES) || (config[val_iZone]->GetKind_Solver() == ADJ_EULER) || (config[val_iZone]->GetKind_Solver() == ADJ_NAVIER_STOKES) || (config[val_iZone]->GetKind_Solver() == ADJ_RANS) || (config[val_iZone]->GetKind_Solver() == INC_EULER) || (config[val_iZone]->GetKind_Solver() == INC_NAVIER_STOKES) || (config[val_iZone]->GetKind_Solver() == INC_RANS); bool buffet = (config[val_iZone]->GetBuffet_Monitoring() || config[val_iZone]->GetKind_ObjFunc() == BUFFET_SENSOR); - + bool fem = ((config[val_iZone]->GetKind_Solver() == FEM_ELASTICITY) || // FEM structural solver. (config[val_iZone]->GetKind_Solver() == DISC_ADJ_FEM)); bool linear_analysis = (config[val_iZone]->GetGeometricConditions() == SMALL_DEFORMATIONS); // Linear analysis. bool nonlinear_analysis = (config[val_iZone]->GetGeometricConditions() == LARGE_DEFORMATIONS); // Nonlinear analysis. bool fsi = (config[val_iZone]->GetFSI_Simulation()); // FEM structural solver. bool discadj_fem = (config[val_iZone]->GetKind_Solver() == DISC_ADJ_FEM); - + bool turbo = config[val_iZone]->GetBoolTurbomachinery(); unsigned short nTurboPerf = config[val_iZone]->GetnMarker_TurboPerformance(); - bool output_per_surface = config[val_iZone]->GetWrt_Surface(); + bool output_per_surface = config[val_iZone]->GetWrt_Surface(); unsigned short direct_diff = config[val_iZone]->GetDirectDiff(); @@ -4777,7 +4777,7 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, } /*--- Initialize variables to store information from all domains (direct solution) ---*/ - + su2double Total_CL = 0.0, Total_CD = 0.0, Total_CSF = 0.0, Total_CMx = 0.0, Total_CMy = 0.0, Total_CMz = 0.0, Total_CEff = 0.0, Total_CEquivArea = 0.0, Total_CNearFieldOF = 0.0, Total_CFx = 0.0, Total_CFy = 0.0, Total_CFz = 0.0, Total_CMerit = 0.0, Total_CT = 0.0, Total_CQ = 0.0, @@ -4802,9 +4802,9 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, su2double D_Total_CL = 0.0, D_Total_CD = 0.0, D_Total_CSF = 0.0, D_Total_CMx = 0.0, D_Total_CMy = 0.0, D_Total_CMz = 0.0, D_Total_CEff = 0.0, D_Total_CFx = 0.0, D_Total_CFy = 0.0, D_Total_CFz = 0.0, D_Total_NetThrust = 0.0, D_Total_Power = 0.0, D_Total_AeroCD = 0.0, D_Total_SolidCD = 0.0, D_Total_IDR = 0.0, D_Total_IDC = 0.0, D_Total_Custom_ObjFunc = 0.0, D_Total_Heat = 0.0, D_Total_MaxHeat = 0.0, D_TotalPressure_Loss = 0.0, D_FlowAngle_Out = 0.0, D_TotalStaticEfficiency = 0.0, - D_TotalTotalEfficiency = 0.0, D_EntropyGen = 0.0, + D_TotalTotalEfficiency = 0.0, D_EntropyGen = 0.0, D_Surface_Uniformity = 0.0, D_Surface_SecondaryStrength = 0.0, D_Surface_MomentumDistortion = 0.0, D_Surface_SecondOverUniform = 0.0, D_Surface_PressureDrop = 0.0; - + /*--- Residual arrays ---*/ su2double *residual_flow = NULL, *residual_turbulent = NULL, @@ -4815,7 +4815,7 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, su2double *residual_fea = NULL; su2double *residual_fem = NULL; su2double *residual_heat = NULL; - + /*--- Coefficients Monitored arrays ---*/ su2double *aeroelastic_plunge = NULL, *aeroelastic_pitch = NULL, @@ -4830,13 +4830,13 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, *Surface_CMy = NULL, *Surface_CMz = NULL, *Surface_Buffet_Metric = NULL; - + /*--- Initialize number of variables ---*/ unsigned short nVar_Flow = 0, nVar_Turb = 0, nVar_Trans = 0, nVar_Heat = 0, nVar_AdjFlow = 0, nVar_AdjTurb = 0, nVar_AdjHeat = 0, nVar_FEM = 0; - + /*--- Direct problem variables ---*/ if (compressible) nVar_Flow = nDim+2; else nVar_Flow = nDim+2; if (turbulent) { @@ -4855,7 +4855,7 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, if (config[val_iZone]->GetKind_Solver() == DISC_ADJ_FEM) nVar_FEM = nDim; } - + /*--- Adjoint problem variables ---*/ if (compressible) nVar_AdjFlow = nDim+2; else nVar_AdjFlow = nDim+2; if (turbulent) { @@ -4865,18 +4865,18 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, } } if (weakly_coupled_heat) nVar_AdjHeat = 1; - + /*--- Allocate memory for the residual ---*/ residual_flow = new su2double[nVar_Flow]; residual_turbulent = new su2double[nVar_Turb]; residual_transition = new su2double[nVar_Trans]; residual_heat = new su2double[nVar_Heat]; residual_fem = new su2double[nVar_FEM]; - + residual_adjflow = new su2double[nVar_AdjFlow]; residual_adjturbulent = new su2double[nVar_AdjTurb]; residual_adjheat = new su2double[nVar_AdjHeat]; - + /*--- Allocate memory for the coefficients being monitored ---*/ aeroelastic_plunge = new su2double[config[ZONE_0]->GetnMarker_Monitoring()]; aeroelastic_pitch = new su2double[config[ZONE_0]->GetnMarker_Monitoring()]; @@ -4891,20 +4891,20 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, Surface_CMy = new su2double[config[ZONE_0]->GetnMarker_Monitoring()]; Surface_CMz = new su2double[config[ZONE_0]->GetnMarker_Monitoring()]; if(buffet) Surface_Buffet_Metric = new su2double[config[ZONE_0]->GetnMarker_Monitoring()]; - + /*--- Write information from nodes ---*/ - + switch (config[val_iZone]->GetKind_Solver()) { - + case EULER: case NAVIER_STOKES: case RANS: - case INC_EULER: case INC_NAVIER_STOKES: case INC_RANS: + case INC_EULER: case INC_NAVIER_STOKES: case INC_RANS: case FEM_EULER: case FEM_NAVIER_STOKES: case FEM_RANS: case FEM_LES: case ADJ_EULER: case ADJ_NAVIER_STOKES: case ADJ_RANS: 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: - + /*--- Flow solution coefficients ---*/ - + Total_CL = solver_container[val_iZone][val_iInst][FinestMesh][FLOW_SOL]->GetTotal_CL(); Total_CD = solver_container[val_iZone][val_iInst][FinestMesh][FLOW_SOL]->GetTotal_CD(); Total_CSF = solver_container[val_iZone][val_iInst][FinestMesh][FLOW_SOL]->GetTotal_CSF(); @@ -4930,7 +4930,7 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, Total_Temperature = solver_container[val_iZone][val_iInst][FinestMesh][HEAT_SOL]->GetTotal_AvgTemperature(); } } - + if(buffet){ Total_Buffet_Metric = solver_container[val_iZone][val_iInst][FinestMesh][FLOW_SOL]->GetTotal_Buffet_Metric(); } @@ -4962,17 +4962,17 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, D_Total_IDR = SU2_TYPE::GetDerivative(Total_IDR); D_Total_IDC = SU2_TYPE::GetDerivative(Total_IDC); } - + } - + if (equiv_area) { Total_CEquivArea = solver_container[val_iZone][val_iInst][FinestMesh][FLOW_SOL]->GetTotal_CEquivArea(); Total_CNearFieldOF = solver_container[val_iZone][val_iInst][FinestMesh][FLOW_SOL]->GetTotal_CNearFieldOF(); - + Total_CEquivArea = config[val_iZone]->GetWeightCd()*Total_CD + (1.0-config[val_iZone]->GetWeightCd())*Total_CEquivArea; Total_CNearFieldOF = config[val_iZone]->GetWeightCd()*Total_CD + (1.0-config[val_iZone]->GetWeightCd())*Total_CNearFieldOF; } - + if (engine || actuator_disk) { Total_NetThrust = solver_container[val_iZone][val_iInst][FinestMesh][FLOW_SOL]->GetTotal_NetThrust(); Total_Power = solver_container[val_iZone][val_iInst][FinestMesh][FLOW_SOL]->GetTotal_Power(); @@ -4981,13 +4981,13 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, Total_IDR = solver_container[val_iZone][val_iInst][FinestMesh][FLOW_SOL]->GetTotal_IDR(); Total_IDC = solver_container[val_iZone][val_iInst][FinestMesh][FLOW_SOL]->GetTotal_IDC(); } - + if (rotating_frame) { Total_CT = solver_container[val_iZone][val_iInst][FinestMesh][FLOW_SOL]->GetTotal_CT(); Total_CQ = solver_container[val_iZone][val_iInst][FinestMesh][FLOW_SOL]->GetTotal_CQ(); Total_CMerit = solver_container[val_iZone][val_iInst][FinestMesh][FLOW_SOL]->GetTotal_CMerit(); } - + if (aeroelastic) { /*--- Look over the markers being monitored and get the desired values ---*/ for (iMarker_Monitoring = 0; iMarker_Monitoring < config[ZONE_0]->GetnMarker_Monitoring(); iMarker_Monitoring++) { @@ -4995,7 +4995,7 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, aeroelastic_pitch[iMarker_Monitoring] = config[val_iZone]->GetAeroelastic_pitch(iMarker_Monitoring); } } - + if (output_per_surface) { /*--- Look over the markers being monitored and get the desired values ---*/ for (iMarker_Monitoring = 0; iMarker_Monitoring < config[ZONE_0]->GetnMarker_Monitoring(); iMarker_Monitoring++) { @@ -5009,11 +5009,11 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, Surface_CMx[iMarker_Monitoring] = solver_container[val_iZone][val_iInst][FinestMesh][FLOW_SOL]->GetSurface_CMx(iMarker_Monitoring); Surface_CMy[iMarker_Monitoring] = solver_container[val_iZone][val_iInst][FinestMesh][FLOW_SOL]->GetSurface_CMy(iMarker_Monitoring); Surface_CMz[iMarker_Monitoring] = solver_container[val_iZone][val_iInst][FinestMesh][FLOW_SOL]->GetSurface_CMz(iMarker_Monitoring); - + if(buffet) Surface_Buffet_Metric[iMarker_Monitoring] = solver_container[val_iZone][val_iInst][FinestMesh][FLOW_SOL]->GetSurface_Buffet_Metric(iMarker_Monitoring); } } - + if (turbo) { /*--- Loop over the nMarker of turboperformance and get the desired values ---*/ for (iMarker_Monitoring = 0; iMarker_Monitoring < nTurboPerf; iMarker_Monitoring++) { @@ -5030,7 +5030,7 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, D_EntropyGen = SU2_TYPE::GetDerivative(EntropyGen[nTurboPerf-1][nSpanWiseSections]); } } - + /*--- Get flux-averaged values at the specified surface ---*/ if (output_surface) { @@ -5059,14 +5059,14 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, D_Surface_PressureDrop = SU2_TYPE::GetDerivative(Surface_PressureDrop); } } - + /*--- Flow Residuals ---*/ - + for (iVar = 0; iVar < nVar_Flow; iVar++) residual_flow[iVar] = solver_container[val_iZone][val_iInst][FinestMesh][FLOW_SOL]->GetRes_RMS(iVar); - + /*--- Turbulent residual ---*/ - + if (turbulent) { for (iVar = 0; iVar < nVar_Turb; iVar++) residual_turbulent[iVar] = solver_container[val_iZone][val_iInst][FinestMesh][TURB_SOL]->GetRes_RMS(iVar); @@ -5078,31 +5078,31 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, } } - + /*--- Transition residual ---*/ - + if (transition) { for (iVar = 0; iVar < nVar_Trans; iVar++) residual_transition[iVar] = solver_container[val_iZone][val_iInst][FinestMesh][TRANS_SOL]->GetRes_RMS(iVar); } - - + + /*--- FEA residual ---*/ // if (fluid_structure) { // for (iVar = 0; iVar < nVar_FEA; iVar++) // residual_fea[iVar] = solver_container[ZONE_0][FinestMesh][FEA_SOL]->GetRes_RMS(iVar); // } - + /*--- Iterations of the linear solver ---*/ - + LinSolvIter = (unsigned long) solver_container[val_iZone][val_iInst][FinestMesh][FLOW_SOL]->GetIterLinSolver(); - + /*--- Adjoint solver ---*/ - + if (adjoint) { - + /*--- Adjoint solution coefficients ---*/ - + Total_Sens_Geo = solver_container[val_iZone][val_iInst][FinestMesh][ADJFLOW_SOL]->GetTotal_Sens_Geo(); Total_Sens_Mach = solver_container[val_iZone][val_iInst][FinestMesh][ADJFLOW_SOL]->GetTotal_Sens_Mach(); Total_Sens_AoA = solver_container[val_iZone][val_iInst][FinestMesh][ADJFLOW_SOL]->GetTotal_Sens_AoA() * PI_NUMBER / 180.0; @@ -5112,13 +5112,13 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, Total_Sens_ModVel = solver_container[val_iZone][val_iInst][FinestMesh][ADJFLOW_SOL]->GetTotal_Sens_ModVel(); /*--- Adjoint flow residuals ---*/ - + for (iVar = 0; iVar < nVar_AdjFlow; iVar++) { residual_adjflow[iVar] = solver_container[val_iZone][val_iInst][FinestMesh][ADJFLOW_SOL]->GetRes_RMS(iVar); } - + /*--- Adjoint turbulent residuals ---*/ - + if (turbulent) { if (!frozen_visc) { for (iVar = 0; iVar < nVar_AdjTurb; iVar++) @@ -5131,11 +5131,11 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, residual_adjheat[iVar] = solver_container[val_iZone][val_iInst][FinestMesh][ADJHEAT_SOL]->GetRes_RMS(iVar); } } - + } - + break; - + case HEAT_EQUATION_FVM: @@ -5152,13 +5152,13 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, } break; - + case FEM_ELASTICITY: - + /*--- FEM coefficients -- As of now, this is the Von Mises Stress ---*/ - + Total_VMStress = solver_container[val_iZone][val_iInst][FinestMesh][FEA_SOL]->GetTotal_CFEA(); - + Total_ForceCoeff = solver_container[val_iZone][val_iInst][FinestMesh][FEA_SOL]->GetForceCoeff(); Total_IncLoad = solver_container[val_iZone][val_iInst][FinestMesh][FEA_SOL]->GetLoad_Increment(); @@ -5168,7 +5168,7 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, /*--- Residuals: ---*/ /*--- Linear analysis: RMS of the displacements in the nDim coordinates ---*/ /*--- Nonlinear analysis: UTOL, RTOL and DTOL (defined in the Postprocessing function) ---*/ - + if (linear_analysis) { for (iVar = 0; iVar < nVar_FEM; iVar++) { residual_fem[iVar] = solver_container[val_iZone][val_iInst][FinestMesh][FEA_SOL]->GetRes_RMS(iVar); @@ -5179,7 +5179,7 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, residual_fem[iVar] = solver_container[val_iZone][val_iInst][FinestMesh][FEA_SOL]->GetRes_FEM(iVar); } } - + break; case DISC_ADJ_FEM: @@ -5205,9 +5205,9 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, //Extra_Total_Temperature = solver_container[ExtraHeatOutputZone][val_iInst][FinestMesh][HEAT_SOL]->GetTotal_Temperature(); Extra_Heat_Residual = log10(solver_container[ExtraHeatOutputZone][val_iInst][FinestMesh][HEAT_SOL]->GetRes_RMS(0)); } - + /*--- Header frequency ---*/ - + bool Unsteady = ((config[val_iZone]->GetTime_Marching() == DT_STEPPING_1ST) || (config[val_iZone]->GetTime_Marching() == DT_STEPPING_2ND)); bool In_NoDualTime = (!DualTime_Iteration && (iExtIter % config[val_iZone]->GetWrt_Con_Freq() == 0)); @@ -5215,7 +5215,7 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, bool In_DualTime_1 = (!DualTime_Iteration && Unsteady); bool In_DualTime_2 = (Unsteady && DualTime_Iteration && (iExtIter % config[val_iZone]->GetWrt_Con_Freq() == 0)); bool In_DualTime_3 = (Unsteady && !DualTime_Iteration && (iExtIter % config[val_iZone]->GetWrt_Con_Freq() == 0)); - + /*--- Header frequency: analogy for dynamic structural analysis ---*/ /*--- DualTime_Iteration is a bool we receive, which is true if it comes from FEM_StructuralIteration and false from SU2_CFD ---*/ /*--- We maintain the name, as it is an input of the function ---*/ @@ -5227,13 +5227,13 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, bool In_Dynamic_1 = (!DualTime_Iteration && nonlinear_analysis); bool In_Dynamic_2 = (nonlinear_analysis && DualTime_Iteration && (iExtIter % config[val_iZone]->GetWrt_Con_Freq() == 0)); bool In_Dynamic_3 = (nonlinear_analysis && !DualTime_Iteration && (iExtIter % config[val_iZone]->GetWrt_Con_Freq() == 0)); - + bool write_heads; if (Unsteady) write_heads = (iIntIter == 0); else write_heads = (((iExtIter % (config[val_iZone]->GetWrt_Con_Freq()*40)) == 0)); - + bool write_turbo = (((iExtIter % (config[val_iZone]->GetWrt_Con_Freq()*40)) == 0) || (iExtIter == (config[val_iZone]->GetnInner_Iter() -1))); - + /*--- Analogous for dynamic problems (as of now I separate the problems, it may be worthy to do all together later on ---*/ bool write_heads_FEM; if (nonlinear_analysis) write_heads_FEM = (iIntIter == 0); @@ -5242,28 +5242,28 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, if ( (!fem && ((In_NoDualTime || In_DualTime_0 || In_DualTime_1) && (In_NoDualTime || In_DualTime_2 || In_DualTime_3))) || (fem && ( (In_NoDynamic || In_Dynamic_0 || In_Dynamic_1) && (In_NoDynamic || In_Dynamic_2 || In_Dynamic_3))) ) { - - + + /*--- Prepare the history file output, note that the dual time output don't write to the history file ---*/ if (!DualTime_Iteration) { - + /*--- Write the begining of the history file ---*/ SPRINTF(begin, "%12d", SU2_TYPE::Int(iExtIter+ExtIter_OffSet)); - + /*--- Write the end of the history file ---*/ SPRINTF (end, ", %12.10f, %12.10f, %12.10f\n", su2double(LinSolvIter), config[val_iZone]->GetCFL(MESH_0), timeused/60.0); - + /*--- Write the solution and residual of the history file ---*/ switch (config[val_iZone]->GetKind_Solver()) { - + case EULER : case NAVIER_STOKES: case RANS: - case INC_EULER : case INC_NAVIER_STOKES: case INC_RANS: + case INC_EULER : case INC_NAVIER_STOKES: case INC_RANS: case FEM_EULER : case FEM_NAVIER_STOKES: case FEM_RANS: case FEM_LES: case ADJ_EULER: case ADJ_NAVIER_STOKES: case ADJ_RANS: 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: - + /*--- Direct coefficients ---*/ SPRINTF (direct_coeff, ", %14.8e, %14.8e, %14.8e, %14.8e, %14.8e, %14.8e, %14.8e, %14.8e, %14.8e, %14.8e, %14.8e, %14.8e", Total_CL, Total_CD, Total_CSF, Total_CMx, Total_CMy, Total_CMz, Total_CFx, Total_CFy, @@ -5277,7 +5277,7 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, SPRINTF (Cp_inverse_design, ", %14.8e", solver_container[val_iZone][val_iInst][FinestMesh][FLOW_SOL]->GetTotal_CpDiff()); if (thermal && !turbo) SPRINTF (Heat_inverse_design, ", %14.8e", solver_container[val_iZone][val_iInst][FinestMesh][FLOW_SOL]->GetTotal_HeatFluxDiff()); } - + if (direct_diff != NO_DERIVATIVE) { if (!turbo) SPRINTF (d_direct_coeff, ", %14.8e, %14.8e, %14.8e, %14.8e, %14.8e, %14.8e, %14.8e, %14.8e, %14.8e, %14.8e, %14.8e", @@ -5310,7 +5310,7 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, strcat(aeroelastic_coeff, surface_coeff); } } - + if (output_per_surface) { for (iMarker_Monitoring = 0; iMarker_Monitoring < config[ZONE_0]->GetnMarker_Monitoring(); iMarker_Monitoring++) { //Append one by one the surface coeff to monitoring coeff. (Think better way do this, maybe use string) @@ -5339,7 +5339,7 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, strcat(monitoring_coeff, surface_coeff); SPRINTF(surface_coeff, ", %12.10f", Surface_CMz[iMarker_Monitoring]); strcat(monitoring_coeff, surface_coeff); - + if(buffet){ SPRINTF(surface_coeff, ", %12.10f", Surface_Buffet_Metric[iMarker_Monitoring]); strcat(monitoring_coeff, surface_coeff); @@ -5387,8 +5387,8 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, } } - - + + /*--- Flow residual ---*/ if (nDim == 2) { if (compressible) SPRINTF (flow_resid, ", %14.8e, %14.8e, %14.8e, %14.8e, %14.8e", log10 (residual_flow[0]), log10 (residual_flow[1]), log10 (residual_flow[2]), log10 (residual_flow[3]), dummy); @@ -5398,7 +5398,7 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, if (compressible) SPRINTF (flow_resid, ", %14.8e, %14.8e, %14.8e, %14.8e, %14.8e", log10 (residual_flow[0]), log10 (residual_flow[1]), log10 (residual_flow[2]), log10 (residual_flow[3]), log10 (residual_flow[4]) ); if (incompressible) SPRINTF (flow_resid, ", %14.8e, %14.8e, %14.8e, %14.8e, %14.8e", log10 (residual_flow[0]), log10 (residual_flow[1]), log10 (residual_flow[2]), log10 (residual_flow[3]), log10 (residual_flow[4])); } - + /*--- Turbulent residual ---*/ if (turbulent) { switch(nVar_Turb) { @@ -5406,18 +5406,18 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, case 2: SPRINTF (turb_resid, ", %12.10f, %12.10f", log10(residual_turbulent[0]), log10(residual_turbulent[1])); break; } } - + /*---- Averaged stagnation pressure at an exit ----*/ - + if (output_surface) { SPRINTF( surface_outputs, ", %14.8e, %14.8e, %14.8e, %14.8e, %14.8e, %14.8e, %14.8e, %14.8e, %14.8e, %14.8e, %14.8e, %14.8e, %14.8e, %14.8e", Surface_MassFlow, Surface_Mach, Surface_Temperature, Surface_Pressure, Surface_Density, Surface_Enthalpy, Surface_NormalVelocity, Surface_Uniformity, Surface_SecondaryStrength, Surface_MomentumDistortion, Surface_SecondOverUniform, Surface_TotalTemperature, Surface_TotalPressure, Surface_PressureDrop); if (direct_diff != NO_DERIVATIVE) { - SPRINTF( d_surface_outputs, ", %14.8e, %14.8e, %14.8e, %14.8e, %14.8e", + SPRINTF( d_surface_outputs, ", %14.8e, %14.8e, %14.8e, %14.8e, %14.8e", D_Surface_Uniformity, D_Surface_SecondaryStrength, D_Surface_MomentumDistortion, D_Surface_SecondOverUniform, D_Surface_PressureDrop); } } - + /*--- Transition residual ---*/ if (transition) { SPRINTF (trans_resid, ", %12.10f, %12.10f", log10(residual_transition[0]), log10(residual_transition[1])); @@ -5435,7 +5435,7 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, // } if (adjoint) { - + /*--- Adjoint coefficients ---*/ if (!turbo) { if (compressible) { @@ -5456,7 +5456,7 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, if (compressible) SPRINTF (adj_flow_resid, ", %14.8e, %14.8e, %14.8e, %14.8e, %14.8e", log10 (residual_adjflow[0]), log10 (residual_adjflow[1]), log10 (residual_adjflow[2]), log10 (residual_adjflow[3]), log10 (residual_adjflow[4]) ); if (incompressible) SPRINTF (adj_flow_resid, ", %14.8e, %14.8e, %14.8e, %14.8e, %14.8e", log10 (residual_adjflow[0]), log10 (residual_adjflow[1]), log10 (residual_adjflow[2]), log10 (residual_adjflow[3]), log10 (residual_adjflow[4])); } - + /*--- Adjoint turbulent residuals ---*/ if (turbulent) if (!frozen_visc) { @@ -5472,7 +5472,7 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, if (weakly_coupled_heat) { SPRINTF (heat_resid, ", %14.8e", log10 (residual_heat[0])); } - + break; case HEAT_EQUATION_FVM: @@ -5481,9 +5481,9 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, SPRINTF (heat_resid, ", %14.8e", log10 (residual_heat[0])); break; - + case FEM_ELASTICITY: - + SPRINTF (begin_fem, ", %14.8e", 0.0); if (incload) SPRINTF (fem_coeff, ", %14.8e, %14.8e, %14.8e", Total_VMStress, Total_ForceCoeff, Total_IncLoad); @@ -5524,7 +5524,7 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, if (!Unsteady && (config[val_iZone]->GetTime_Marching() != TIME_STEPPING)) { switch (config[val_iZone]->GetKind_Solver()) { case EULER : case NAVIER_STOKES: case RANS: - case INC_EULER : case INC_NAVIER_STOKES: case INC_RANS: + case INC_EULER : case INC_NAVIER_STOKES: case INC_RANS: case FEM_EULER : case FEM_NAVIER_STOKES: case FEM_RANS: case FEM_LES: case ADJ_EULER : case ADJ_NAVIER_STOKES: case ADJ_RANS: @@ -5593,7 +5593,7 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, 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: - + cout << endl; cout << "------------------------ Discrete Adjoint Summary -----------------------" << endl; cout << "Total Geometry Sensitivity (updated every " << config[val_iZone]->GetWrt_Sol_Freq() << " iterations): "; @@ -5628,7 +5628,7 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, switch (config[val_iZone]->GetKind_Solver()) { case EULER : case NAVIER_STOKES: - case INC_EULER : case INC_NAVIER_STOKES: + case INC_EULER : case INC_NAVIER_STOKES: case FEM_EULER : case FEM_NAVIER_STOKES: case FEM_LES: /*--- Visualize the maximum residual ---*/ @@ -5671,7 +5671,7 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, else if (rotating_frame && nDim == 3 && !turbo) cout << " Res[Rho]" << " Res[RhoE]" << " CThrust(Total)" << " CTorque(Total)" << endl; else if (aeroelastic) cout << " Res[Rho]" << " Res[RhoE]" << " CLift(Total)" << " CDrag(Total)" << " plunge" << " pitch" << endl; else if (equiv_area) cout << " Res[Rho]" << " CLift(Total)" << " CDrag(Total)" << " CPress(N-F)" << endl; - + else if (turbo){ if(nZone < 2){ @@ -5683,7 +5683,7 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, cout << " Res[Rho]" << " Res[RhoE]" << " TTEfficiency(%)" << " Entropy Gen.(%)"; } } - + else if (actuator_disk) cout << " Res[Rho]" << " Res[RhoE]" << " CL(Total)" << " CD-CT(Total)"; else if (engine) cout << " Res[Rho]" << " Res[RhoE]" << " CL(Total)" << " CD-CT(Total)"; else cout << " Res[Rho]" << " Res[RhoE]" << " CL(Total)" << " CD(Total)"; @@ -5914,7 +5914,7 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, } /*--- Write the solution on the screen ---*/ - + if ((val_iZone == 0 && val_iInst == 0)|| fluid_structure){ cout.precision(6); cout.setf(ios::fixed, ios::floatfield); @@ -5945,14 +5945,14 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, } } } - + switch (config[val_iZone]->GetKind_Solver()) { case EULER : case NAVIER_STOKES: - case INC_EULER : case INC_NAVIER_STOKES: + case INC_EULER : case INC_NAVIER_STOKES: case FEM_EULER : case FEM_NAVIER_STOKES: case FEM_LES: - + /*--- Write history file ---*/ - + if ((!DualTime_Iteration) && (output_files)) { if (!turbo) { config[val_iZone]->GetHistFile()[0] << begin << direct_coeff; @@ -5971,7 +5971,7 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, else { config[val_iZone]->GetHistFile()[0] << begin << turbo_coeff << flow_resid; } - + if (aeroelastic) config[val_iZone]->GetHistFile()[0] << aeroelastic_coeff; if (output_per_surface) config[val_iZone]->GetHistFile()[0] << monitoring_coeff; if (output_surface) config[val_iZone]->GetHistFile()[0] << surface_outputs; @@ -6015,7 +6015,7 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, cout << Total_CNearFieldOF; } else if (turbo) { cout.setf(ios::scientific, ios::floatfield); - + if (nZone < 2) { cout.width(15); cout << TotalPressureLoss[0][nSpanWiseSections]*100.0; cout.width(15); cout << EntropyGen[0][nSpanWiseSections]*100.0; @@ -6024,9 +6024,9 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, cout.width(15); cout << TotalTotalEfficiency[nTurboPerf -1][nSpanWiseSections]*100.0; cout.width(15); cout << EntropyGen[nTurboPerf -1][nSpanWiseSections]*100.0; } - + cout.unsetf(ios_base::floatfield); - + } else if (weakly_coupled_heat) { cout.width(14); cout << log10(Total_Heat); } else { cout.width(15); cout << min(10000.0, max(-10000.0, Total_CL)); cout.width(15); cout << min(10000.0, max(-10000.0, Total_CD)); } @@ -6039,15 +6039,15 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, if (extra_heat_output) { cout.width(15); cout << Extra_Heat_Residual; cout.width(15); cout << Extra_Total_Heat; } cout << endl; - + } } break; - + case RANS : case INC_RANS: - + /*--- Write history file ---*/ - + if ((!DualTime_Iteration) && (output_files)) { if (!turbo) { @@ -6067,7 +6067,7 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, else { config[val_iZone]->GetHistFile()[0] << begin << turbo_coeff << flow_resid << turb_resid; } - + if (aeroelastic) config[val_iZone]->GetHistFile()[0] << aeroelastic_coeff; if (output_per_surface) config[val_iZone]->GetHistFile()[0] << monitoring_coeff; if (output_surface) config[val_iZone]->GetHistFile()[0] << surface_outputs; @@ -6079,7 +6079,7 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, config[val_iZone]->GetHistFile()[0] << end; config[val_iZone]->GetHistFile()[0].flush(); } - + /*--- Write screen output ---*/ if ((val_iZone == 0 && val_iInst == 0)|| fluid_structure){ @@ -6140,11 +6140,11 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, } if (extra_heat_output) { cout.width(15); cout << Extra_Heat_Residual; cout.width(15); cout << Extra_Total_Heat; } - cout << endl; + cout << endl; } } break; - + case HEAT_EQUATION_FVM: @@ -6155,11 +6155,11 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, break; case FEM_ELASTICITY: - + if (!DualTime_Iteration) { config[val_iZone]->GetHistFile()[0] << begin << fem_coeff << fem_resid << end_fem; config[val_iZone]->GetHistFile()[0].flush(); - + cout.precision(6); cout.setf(ios::fixed, ios::floatfield); if (linear_analysis) { @@ -6172,14 +6172,14 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, cout.width(14); cout << log10(residual_fem[1]); cout.width(14); cout << log10(residual_fem[2]); } - + cout.precision(4); cout.setf(ios::scientific, ios::floatfield); cout.width(14); cout << Total_VMStress; cout << endl; } break; - + case DISC_ADJ_FEM: cout.precision(6); @@ -6217,7 +6217,7 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, case ADJ_EULER : case ADJ_NAVIER_STOKES : case DISC_ADJ_EULER: case DISC_ADJ_NAVIER_STOKES: case DISC_ADJ_INC_EULER: case DISC_ADJ_INC_NAVIER_STOKES: - + if (!DualTime_Iteration) { config[val_iZone]->GetHistFile()[0] << begin << adjoint_coeff << adj_flow_resid << end; config[val_iZone]->GetHistFile()[0].flush(); @@ -6267,9 +6267,9 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, } } break; - + case ADJ_RANS : case DISC_ADJ_RANS: case DISC_ADJ_INC_RANS: - + if (!DualTime_Iteration) { config[val_iZone]->GetHistFile()[0] << begin << adjoint_coeff << adj_flow_resid; if (!frozen_visc) @@ -6326,12 +6326,12 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, } } break; - + } cout.unsetf(ios::fixed); } - + delete [] residual_flow; delete [] residual_turbulent; @@ -6355,16 +6355,16 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, delete [] Surface_CMz; delete [] aeroelastic_pitch; delete [] aeroelastic_plunge; - + } } void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry ****geometry, CConfig **config, unsigned short val_iZone, bool output) { - + char cstr[200]; unsigned short iDim, iMarker_Monitoring; ofstream Breakdown_file; - + bool compressible = (config[val_iZone]->GetKind_Regime() == COMPRESSIBLE); bool incompressible = (config[val_iZone]->GetKind_Regime() == INCOMPRESSIBLE); bool unsteady = (config[val_iZone]->GetTime_Marching() != NO); @@ -6385,15 +6385,15 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry (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 ---*/ - + if ((rank == MASTER_NODE) && (flow) && (output)) { - + cout << endl << "Writing the forces breakdown file ("<< config[val_iZone]->GetBreakdown_FileName() << ")." << endl; - + /*--- Initialize variables to store information from all domains (direct solution) ---*/ - + su2double Total_CL = 0.0, Total_CD = 0.0, Total_CSF = 0.0, Total_CMx = 0.0, Total_CMy = 0.0, Total_CMz = 0.0, Total_CEff = 0.0, Total_CoPx = 0.0, Total_CoPy = 0.0, Total_CoPz = 0.0, @@ -6425,14 +6425,14 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry *Surface_CEff_Mnt = NULL, *Surface_CFx_Mnt = NULL, *Surface_CFy_Mnt = NULL, *Surface_CFz_Mnt = NULL, *Surface_CMx_Mnt = NULL, *Surface_CMy_Mnt = NULL, *Surface_CMz_Mnt = NULL; - + /*--- WARNING: when compiling on Windows, ctime() is not available. Comment out the two lines below that use the dt variable. ---*/ //time_t now = time(0); //string dt = ctime(&now); dt[24] = '.'; - + /*--- Allocate memory for the coefficients being monitored ---*/ - + Surface_CL = new su2double[config[ZONE_0]->GetnMarker_Monitoring()]; Surface_CD = new su2double[config[ZONE_0]->GetnMarker_Monitoring()]; Surface_CSF = new su2double[config[ZONE_0]->GetnMarker_Monitoring()]; @@ -6443,7 +6443,7 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry Surface_CMx = new su2double[config[ZONE_0]->GetnMarker_Monitoring()]; Surface_CMy = new su2double[config[ZONE_0]->GetnMarker_Monitoring()]; Surface_CMz = new su2double[config[ZONE_0]->GetnMarker_Monitoring()]; - + Surface_CL_Inv = new su2double[config[ZONE_0]->GetnMarker_Monitoring()]; Surface_CD_Inv = new su2double[config[ZONE_0]->GetnMarker_Monitoring()]; Surface_CSF_Inv = new su2double[config[ZONE_0]->GetnMarker_Monitoring()]; @@ -6454,7 +6454,7 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry Surface_CMx_Inv = new su2double[config[ZONE_0]->GetnMarker_Monitoring()]; Surface_CMy_Inv = new su2double[config[ZONE_0]->GetnMarker_Monitoring()]; Surface_CMz_Inv = new su2double[config[ZONE_0]->GetnMarker_Monitoring()]; - + Surface_CL_Visc = new su2double[config[ZONE_0]->GetnMarker_Monitoring()]; Surface_CD_Visc = new su2double[config[ZONE_0]->GetnMarker_Monitoring()]; Surface_CSF_Visc = @@ -6466,8 +6466,8 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry Surface_CMx_Visc = new su2double[config[ZONE_0]->GetnMarker_Monitoring()]; Surface_CMy_Visc = new su2double[config[ZONE_0]->GetnMarker_Monitoring()]; Surface_CMz_Visc = new su2double[config[ZONE_0]->GetnMarker_Monitoring()]; - - + + Surface_CL_Mnt = new su2double[config[ZONE_0]->GetnMarker_Monitoring()]; Surface_CD_Mnt = new su2double[config[ZONE_0]->GetnMarker_Monitoring()]; Surface_CSF_Mnt = @@ -6481,7 +6481,7 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry Surface_CMz_Mnt = new su2double[config[ZONE_0]->GetnMarker_Monitoring()]; /*--- Flow solution coefficients ---*/ - + Total_CL = solver[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetTotal_CL(); Total_CD = solver[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetTotal_CD(); Total_CSF = solver[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetTotal_CSF(); @@ -6492,7 +6492,7 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry Total_CFx = solver[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetTotal_CFx(); Total_CFy = solver[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetTotal_CFy(); Total_CFz = solver[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetTotal_CFz(); - + if (nDim == 2) { Total_CoPx = solver[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetTotal_CoPx() / solver[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetTotal_CFy(); Total_CoPy = solver[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetTotal_CoPy() / solver[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetTotal_CFx(); @@ -6503,11 +6503,11 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry Total_CoPy = 0.0; Total_CoPz = solver[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetTotal_CoPz() / solver[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetTotal_CFx(); } - + if (config[ZONE_0]->GetSystemMeasurements() == US) { Total_CoPx *= 12.0; Total_CoPy *= 12.0; Total_CoPz *= 12.0; } - + /*--- Flow inviscid solution coefficients ---*/ - + Inv_CL = solver[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetAllBound_CL_Inv(); Inv_CD = @@ -6528,9 +6528,9 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry solver[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetAllBound_CFy_Inv(); Inv_CFz = solver[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetAllBound_CFz_Inv(); - + /*--- Flow viscous solution coefficients ---*/ - + Visc_CL = solver[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetAllBound_CL_Visc(); Visc_CD = @@ -6551,9 +6551,9 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry solver[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetAllBound_CFy_Visc(); Visc_CFz = solver[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetAllBound_CFz_Visc(); - + /*--- Flow momentum solution coefficients ---*/ - + Mnt_CL = solver[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetAllBound_CL_Mnt(); Mnt_CD = @@ -6574,10 +6574,10 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry solver[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetAllBound_CFy_Mnt(); Mnt_CFz = solver[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetAllBound_CFz_Mnt(); - - + + /*--- Look over the markers being monitored and get the desired values ---*/ - + for (iMarker_Monitoring = 0; iMarker_Monitoring < config[ZONE_0]->GetnMarker_Monitoring(); iMarker_Monitoring++) { @@ -6611,7 +6611,7 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry Surface_CFz[iMarker_Monitoring] = solver[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetSurface_CFz( iMarker_Monitoring); - + Surface_CL_Inv[iMarker_Monitoring] = solver[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetSurface_CL_Inv( iMarker_Monitoring); @@ -6672,7 +6672,7 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry Surface_CFz_Visc[iMarker_Monitoring] = solver[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetSurface_CFz_Visc( iMarker_Monitoring); - + Surface_CL_Mnt[iMarker_Monitoring] = solver[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetSurface_CL_Mnt( iMarker_Monitoring); @@ -6703,17 +6703,17 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry Surface_CFz_Mnt[iMarker_Monitoring] = solver[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetSurface_CFz_Mnt( iMarker_Monitoring); - + } - - + + /*--- Write file name with extension ---*/ - + string filename = config[val_iZone]->GetBreakdown_FileName(); strcpy (cstr, filename.data()); - + Breakdown_file.open(cstr, ios::out); - + Breakdown_file << "\n" <<"-------------------------------------------------------------------------" << "\n"; Breakdown_file <<"| ___ _ _ ___ |" << "\n"; Breakdown_file <<"| / __| | | |_ ) Release 6.1.0 \"Falcon\" |" << "\n"; @@ -6752,11 +6752,11 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry Breakdown_file << "| You should have received a copy of the GNU Lesser General Public |" << "\n"; Breakdown_file << "| License along with SU2. If not, see . |" << "\n"; Breakdown_file <<"-------------------------------------------------------------------------" << "\n"; - + Breakdown_file.precision(6); Breakdown_file << "\n" << "\n" << "Problem definition:" << "\n" << "\n"; - + switch (Kind_Solver) { case EULER: case INC_EULER: if (compressible) Breakdown_file << "Compressible Euler equations." << "\n"; @@ -6795,7 +6795,7 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry (Kind_Solver == RANS) || (Kind_Solver == ADJ_RANS)) Breakdown_file << "Reynolds number: " << config[val_iZone]->GetReynolds() <<"."<< "\n"; } - + if (fixed_cl) { Breakdown_file << "Simulation at a cte. CL: " << config[val_iZone]->GetTarget_CL() << ".\n"; Breakdown_file << "Approx. Delta CL / Delta AoA: " << config[val_iZone]->GetdCL_dAlpha() << " (1/deg).\n"; @@ -6806,17 +6806,17 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry } Breakdown_file << "Approx. Delta CMz / Delta CL: " << config[val_iZone]->GetdCMz_dCL() << ".\n"; } - + if (Ref_NonDim == DIMENSIONAL) { Breakdown_file << "Dimensional simulation." << "\n"; } else if (Ref_NonDim == FREESTREAM_PRESS_EQ_ONE) { Breakdown_file << "Non-Dimensional simulation (P=1.0, Rho=1.0, T=1.0 at the farfield)." << "\n"; } else if (Ref_NonDim == FREESTREAM_VEL_EQ_MACH) { Breakdown_file << "Non-Dimensional simulation (V=Mach, Rho=1.0, T=1.0 at the farfield)." << "\n"; } else if (Ref_NonDim == FREESTREAM_VEL_EQ_ONE) { Breakdown_file << "Non-Dimensional simulation (V=1.0, Rho=1.0, T=1.0 at the farfield)." << "\n"; } - + if (config[val_iZone]->GetSystemMeasurements() == SI) { Breakdown_file << "The reference area is " << config[val_iZone]->GetRefArea() << " m^2." << "\n"; Breakdown_file << "The reference length is " << config[val_iZone]->GetRefLength() << " m." << "\n"; } - + if (config[val_iZone]->GetSystemMeasurements() == US) { Breakdown_file << "The reference area is " << config[val_iZone]->GetRefArea()*12.0*12.0 << " in^2." << "\n"; Breakdown_file << "The reference length is " << config[val_iZone]->GetRefLength()*12.0 << " in." << "\n"; @@ -6832,10 +6832,10 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry Breakdown_file << "temperature and pressure using the ideal gas law." << "\n"; } } - + if (dynamic_grid) Breakdown_file << "Force coefficients computed using MACH_MOTION." << "\n"; else Breakdown_file << "Force coefficients computed using free-stream values." << "\n"; - + if (incompressible) { Breakdown_file << "Viscous and Inviscid flow: rho_ref, and vel_ref" << "\n"; Breakdown_file << "are based on the free-stream values, p_ref = rho_ref*vel_ref^2." << "\n"; @@ -6846,12 +6846,12 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry if (viscous) Breakdown_file << "Reynolds number: " << config[val_iZone]->GetReynolds() << ", computed using free-stream values."<< "\n"; Breakdown_file << "Only dimensional computation, the grid should be dimensional." << "\n"; } - + Breakdown_file <<"-- Input conditions:"<< "\n"; - + if (compressible) { switch (config[val_iZone]->GetKind_FluidModel()) { - + case STANDARD_AIR: Breakdown_file << "Fluid Model: STANDARD_AIR "<< "\n"; Breakdown_file << "Specific gas constant: " << config[val_iZone]->GetGas_Constant(); @@ -6860,14 +6860,14 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry Breakdown_file << "Specific gas constant (non-dim): " << config[val_iZone]->GetGas_ConstantND()<< "\n"; Breakdown_file << "Specific Heat Ratio: 1.4000 "<< "\n"; break; - + case IDEAL_GAS: Breakdown_file << "Fluid Model: IDEAL_GAS "<< "\n"; Breakdown_file << "Specific gas constant: " << config[val_iZone]->GetGas_Constant() << " N.m/kg.K." << "\n"; Breakdown_file << "Specific gas constant (non-dim): " << config[val_iZone]->GetGas_ConstantND()<< "\n"; Breakdown_file << "Specific Heat Ratio: "<< config[val_iZone]->GetGamma() << "\n"; break; - + case VW_GAS: Breakdown_file << "Fluid Model: Van der Waals "<< "\n"; Breakdown_file << "Specific gas constant: " << config[val_iZone]->GetGas_Constant() << " N.m/kg.K." << "\n"; @@ -6878,7 +6878,7 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry Breakdown_file << "Critical Pressure (non-dim): " << config[val_iZone]->GetPressure_Critical() /config[val_iZone]->GetPressure_Ref() << "\n"; Breakdown_file << "Critical Temperature (non-dim) : " << config[val_iZone]->GetTemperature_Critical() /config[val_iZone]->GetTemperature_Ref() << "\n"; break; - + case PR_GAS: Breakdown_file << "Fluid Model: Peng-Robinson "<< "\n"; Breakdown_file << "Specific gas constant: " << config[val_iZone]->GetGas_Constant() << " N.m/kg.K." << "\n"; @@ -6890,11 +6890,11 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry Breakdown_file << "Critical Temperature (non-dim) : " << config[val_iZone]->GetTemperature_Critical() /config[val_iZone]->GetTemperature_Ref() << "\n"; break; } - + if (viscous) { - + switch (config[val_iZone]->GetKind_ViscosityModel()) { - + case CONSTANT_VISCOSITY: Breakdown_file << "Viscosity Model: CONSTANT_VISCOSITY "<< "\n"; Breakdown_file << "Laminar Viscosity: " << config[val_iZone]->GetMu_Constant(); @@ -6902,7 +6902,7 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry else if (config[val_iZone]->GetSystemMeasurements() == US) Breakdown_file << " lbf.s/ft^2." << "\n"; Breakdown_file << "Laminar Viscosity (non-dim): " << config[val_iZone]->GetMu_ConstantND()<< "\n"; break; - + case SUTHERLAND: Breakdown_file << "Viscosity Model: SUTHERLAND "<< "\n"; Breakdown_file << "Ref. Laminar Viscosity: " << config[val_iZone]->GetMu_Ref(); @@ -6918,23 +6918,23 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry Breakdown_file << "Ref. Temperature (non-dim): " << config[val_iZone]->GetMu_Temperature_RefND()<< "\n"; Breakdown_file << "Sutherland constant (non-dim): "<< config[val_iZone]->GetMu_SND()<< "\n"; break; - + } switch (config[val_iZone]->GetKind_ConductivityModel()) { - + case CONSTANT_PRANDTL: Breakdown_file << "Conductivity Model: CONSTANT_PRANDTL "<< "\n"; Breakdown_file << "Prandtl: " << config[val_iZone]->GetPrandtl_Lam()<< "\n"; break; - + case CONSTANT_CONDUCTIVITY: Breakdown_file << "Conductivity Model: CONSTANT_CONDUCTIVITY "<< "\n"; Breakdown_file << "Molecular Conductivity: " << config[val_iZone]->GetKt_Constant()<< " W/m^2.K." << "\n"; Breakdown_file << "Molecular Conductivity (non-dim): " << config[val_iZone]->GetKt_ConstantND()<< "\n"; break; - + } - + if ((Kind_Solver == RANS) || (Kind_Solver == ADJ_RANS) || (Kind_Solver == DISC_ADJ_RANS)) { switch (config[val_iZone]->GetKind_ConductivityModel_Turb()) { case CONSTANT_PRANDTL_TURB: @@ -6947,10 +6947,10 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry break; } } - + } } - + if (incompressible) { Breakdown_file << "Bulk modulus: " << config[val_iZone]->GetBulk_Modulus(); if (config[val_iZone]->GetSystemMeasurements() == SI) Breakdown_file << " Pa." << "\n"; @@ -6959,29 +6959,29 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry if (config[val_iZone]->GetSystemMeasurements() == SI) Breakdown_file << " Pa." << "\n"; else if (config[val_iZone]->GetSystemMeasurements() == US) Breakdown_file << " psf." << "\n"; } - + Breakdown_file << "Free-stream static pressure: " << config[val_iZone]->GetPressure_FreeStream(); if (config[val_iZone]->GetSystemMeasurements() == SI) Breakdown_file << " Pa." << "\n"; else if (config[val_iZone]->GetSystemMeasurements() == US) Breakdown_file << " psf." << "\n"; - + Breakdown_file << "Free-stream total pressure: " << config[val_iZone]->GetPressure_FreeStream() * pow( 1.0+config[val_iZone]->GetMach()*config[val_iZone]->GetMach()*0.5*(config[val_iZone]->GetGamma()-1.0), config[val_iZone]->GetGamma()/(config[val_iZone]->GetGamma()-1.0) ); if (config[val_iZone]->GetSystemMeasurements() == SI) Breakdown_file << " Pa." << "\n"; else if (config[val_iZone]->GetSystemMeasurements() == US) Breakdown_file << " psf." << "\n"; - + if (compressible) { Breakdown_file << "Free-stream temperature: " << config[val_iZone]->GetTemperature_FreeStream(); if (config[val_iZone]->GetSystemMeasurements() == SI) Breakdown_file << " K." << "\n"; else if (config[val_iZone]->GetSystemMeasurements() == US) Breakdown_file << " R." << "\n"; - + Breakdown_file << "Free-stream total temperature: " << config[val_iZone]->GetTemperature_FreeStream() * (1.0 + config[val_iZone]->GetMach() * config[val_iZone]->GetMach() * 0.5 * (config[val_iZone]->GetGamma() - 1.0)); if (config[val_iZone]->GetSystemMeasurements() == SI) Breakdown_file << " K." << "\n"; else if (config[val_iZone]->GetSystemMeasurements() == US) Breakdown_file << " R." << "\n"; } - + Breakdown_file << "Free-stream density: " << config[val_iZone]->GetDensity_FreeStream(); if (config[val_iZone]->GetSystemMeasurements() == SI) Breakdown_file << " kg/m^3." << "\n"; else if (config[val_iZone]->GetSystemMeasurements() == US) Breakdown_file << " slug/ft^3." << "\n"; - + if (nDim == 2) { Breakdown_file << "Free-stream velocity: (" << config[val_iZone]->GetVelocity_FreeStream()[0] << ", "; Breakdown_file << config[val_iZone]->GetVelocity_FreeStream()[1] << ")"; @@ -6992,17 +6992,17 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry } if (config[val_iZone]->GetSystemMeasurements() == SI) Breakdown_file << " m/s. "; else if (config[val_iZone]->GetSystemMeasurements() == US) Breakdown_file << " ft/s. "; - + Breakdown_file << "Magnitude: " << config[val_iZone]->GetModVel_FreeStream(); if (config[val_iZone]->GetSystemMeasurements() == SI) Breakdown_file << " m/s." << "\n"; else if (config[val_iZone]->GetSystemMeasurements() == US) Breakdown_file << " ft/s." << "\n"; - + if (compressible) { Breakdown_file << "Free-stream total energy per unit mass: " << config[val_iZone]->GetEnergy_FreeStream(); if (config[val_iZone]->GetSystemMeasurements() == SI) Breakdown_file << " m^2/s^2." << "\n"; else if (config[val_iZone]->GetSystemMeasurements() == US) Breakdown_file << " ft^2/s^2." << "\n"; } - + if (viscous) { Breakdown_file << "Free-stream viscosity: " << config[val_iZone]->GetViscosity_FreeStream(); if (config[val_iZone]->GetSystemMeasurements() == SI) Breakdown_file << " N.s/m^2." << "\n"; @@ -7016,49 +7016,49 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry else if (config[val_iZone]->GetSystemMeasurements() == US) Breakdown_file << " 1/s." << "\n"; } } - + if (unsteady) { Breakdown_file << "Total time: " << config[val_iZone]->GetTotal_UnstTime() << " s. Time step: " << config[val_iZone]->GetDelta_UnstTime() << " s." << "\n"; } - + /*--- Print out reference values. ---*/ - + Breakdown_file <<"-- Reference values:"<< "\n"; - + if (compressible) { Breakdown_file << "Reference specific gas constant: " << config[val_iZone]->GetGas_Constant_Ref(); if (config[val_iZone]->GetSystemMeasurements() == SI) Breakdown_file << " N.m/kg.K." << "\n"; else if (config[val_iZone]->GetSystemMeasurements() == US) Breakdown_file << " lbf.ft/slug.R." << "\n"; } - + Breakdown_file << "Reference pressure: " << config[val_iZone]->GetPressure_Ref(); if (config[val_iZone]->GetSystemMeasurements() == SI) Breakdown_file << " Pa." << "\n"; else if (config[val_iZone]->GetSystemMeasurements() == US) Breakdown_file << " psf." << "\n"; - + if (compressible) { Breakdown_file << "Reference temperature: " << config[val_iZone]->GetTemperature_Ref(); if (config[val_iZone]->GetSystemMeasurements() == SI) Breakdown_file << " K." << "\n"; else if (config[val_iZone]->GetSystemMeasurements() == US) Breakdown_file << " R." << "\n"; } - + Breakdown_file << "Reference density: " << config[val_iZone]->GetDensity_Ref(); if (config[val_iZone]->GetSystemMeasurements() == SI) Breakdown_file << " kg/m^3." << "\n"; else if (config[val_iZone]->GetSystemMeasurements() == US) Breakdown_file << " slug/ft^3." << "\n"; - + Breakdown_file << "Reference velocity: " << config[val_iZone]->GetVelocity_Ref(); if (config[val_iZone]->GetSystemMeasurements() == SI) Breakdown_file << " m/s." << "\n"; else if (config[val_iZone]->GetSystemMeasurements() == US) Breakdown_file << " ft/s." << "\n"; - + if (compressible) { Breakdown_file << "Reference energy per unit mass: " << config[val_iZone]->GetEnergy_Ref(); if (config[val_iZone]->GetSystemMeasurements() == SI) Breakdown_file << " m^2/s^2." << "\n"; else if (config[val_iZone]->GetSystemMeasurements() == US) Breakdown_file << " ft^2/s^2." << "\n"; } - + if (incompressible) { Breakdown_file << "Reference length: " << config[val_iZone]->GetLength_Ref(); if (config[val_iZone]->GetSystemMeasurements() == SI) Breakdown_file << " m." << "\n"; else if (config[val_iZone]->GetSystemMeasurements() == US) Breakdown_file << " in." << "\n"; } - + if (viscous) { Breakdown_file << "Reference viscosity: " << config[val_iZone]->GetViscosity_Ref(); if (config[val_iZone]->GetSystemMeasurements() == SI) Breakdown_file << " N.s/m^2." << "\n"; @@ -7069,12 +7069,12 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry else if (config[val_iZone]->GetSystemMeasurements() == US) Breakdown_file << " lbf/ft.s.R." << "\n"; } } - - + + if (unsteady) Breakdown_file << "Reference time: " << config[val_iZone]->GetTime_Ref() <<" s." << "\n"; - + /*--- Print out resulting non-dim values here. ---*/ - + Breakdown_file << "-- Resulting non-dimensional state:" << "\n"; Breakdown_file << "Mach number (non-dim): " << config[val_iZone]->GetMach() << "\n"; if (viscous) { @@ -7086,16 +7086,16 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry Breakdown_file << "Froude number (non-dim): " << config[val_iZone]->GetFroude() << "\n"; Breakdown_file << "Lenght of the baseline wave (non-dim): " << 2.0*PI_NUMBER*config[val_iZone]->GetFroude()*config[val_iZone]->GetFroude() << "\n"; } - + if (compressible) { Breakdown_file << "Specific gas constant (non-dim): " << config[val_iZone]->GetGas_ConstantND() << "\n"; Breakdown_file << "Free-stream temperature (non-dim): " << config[val_iZone]->GetTemperature_FreeStreamND() << "\n"; } - + Breakdown_file << "Free-stream pressure (non-dim): " << config[val_iZone]->GetPressure_FreeStreamND() << "\n"; - + Breakdown_file << "Free-stream density (non-dim): " << config[val_iZone]->GetDensity_FreeStreamND() << "\n"; - + if (nDim == 2) { Breakdown_file << "Free-stream velocity (non-dim): (" << config[val_iZone]->GetVelocity_FreeStreamND()[0] << ", "; Breakdown_file << config[val_iZone]->GetVelocity_FreeStreamND()[1] << "). "; @@ -7104,10 +7104,10 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry Breakdown_file << config[val_iZone]->GetVelocity_FreeStreamND()[1] << ", " << config[val_iZone]->GetVelocity_FreeStreamND()[2] << "). "; } Breakdown_file << "Magnitude: " << config[val_iZone]->GetModVel_FreeStreamND() << "\n"; - + if (compressible) Breakdown_file << "Free-stream total energy per unit mass (non-dim): " << config[val_iZone]->GetEnergy_FreeStreamND() << "\n"; - + if (viscous) { Breakdown_file << "Free-stream viscosity (non-dim): " << config[val_iZone]->GetViscosity_FreeStreamND() << "\n"; if (turbulent) { @@ -7115,7 +7115,7 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry Breakdown_file << "Free-stream specific dissipation (non-dim): " << config[val_iZone]->GetOmega_FreeStreamND() << "\n"; } } - + if (unsteady) { Breakdown_file << "Total time (non-dim): " << config[val_iZone]->GetTotal_UnstTimeND() << "\n"; Breakdown_file << "Time step (non-dim): " << config[val_iZone]->GetDelta_UnstTimeND() << "\n"; @@ -7210,7 +7210,7 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry if (config[val_iZone]->GetSystemMeasurements() == SI) Breakdown_file << " Pa." << endl; else if (config[val_iZone]->GetSystemMeasurements() == US) Breakdown_file << " psf." << endl; break; - + case INC_IDEAL_GAS_POLY: Breakdown_file << "Fluid Model: INC_IDEAL_GAS_POLY "<< endl; Breakdown_file << "Variable density incompressible flow using ideal gas law." << endl; @@ -7262,7 +7262,7 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry Breakdown_file << "Ref. Temperature (non-dim): " << config[val_iZone]->GetMu_Temperature_RefND()<< "\n"; Breakdown_file << "Sutherland constant (non-dim): "<< config[val_iZone]->GetMu_SND()<< "\n"; break; - + case POLYNOMIAL_VISCOSITY: Breakdown_file << "Viscosity Model: POLYNOMIAL_VISCOSITY "<< endl; Breakdown_file << "Mu(T) polynomial coefficients: \n ("; @@ -7310,9 +7310,9 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry } Breakdown_file << ")." << endl; break; - + } - + if ((Kind_Solver == RANS) || (Kind_Solver == ADJ_RANS) || (Kind_Solver == DISC_ADJ_RANS)) { switch (config[val_iZone]->GetKind_ConductivityModel_Turb()) { case CONSTANT_PRANDTL_TURB: @@ -7325,7 +7325,7 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry break; } } - + } } @@ -7461,7 +7461,7 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry Breakdown_file << config[val_iZone]->GetVelocity_FreeStreamND()[1] << ", " << config[val_iZone]->GetVelocity_FreeStreamND()[2] << "). "; } Breakdown_file << "Magnitude: " << config[val_iZone]->GetModVel_FreeStreamND() << "\n"; - + if (viscous) { Breakdown_file << "Initial viscosity (non-dim): " << config[val_iZone]->GetViscosity_FreeStreamND() << "\n"; if (turbulent) { @@ -7469,7 +7469,7 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry Breakdown_file << "Initial specific dissipation (non-dim): " << config[val_iZone]->GetOmega_FreeStreamND() << "\n"; } } - + if (unsteady) { Breakdown_file << "Total time (non-dim): " << config[val_iZone]->GetTotal_UnstTimeND() << "\n"; Breakdown_file << "Time step (non-dim): " << config[val_iZone]->GetDelta_UnstTimeND() << "\n"; @@ -7478,14 +7478,14 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry } /*--- Begin forces breakdown info. ---*/ - + Breakdown_file << fixed; Breakdown_file << "\n" << "\n" <<"Forces breakdown:" << "\n" << "\n"; if (nDim == 3) { su2double m = solver[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetTotal_CFz()/solver[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetTotal_CFx(); su2double term = (Total_CoPz/m)-Total_CoPx; - + if (term > 0) Breakdown_file << "Center of Pressure: X=" << 1/m <<"Z-"<< term << "." << "\n\n"; else Breakdown_file << "Center of Pressure: X=" << 1/m <<"Z+"<< fabs(term); if (config[val_iZone]->GetSystemMeasurements() == SI) Breakdown_file << " m." << "\n\n"; @@ -7547,7 +7547,7 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry Breakdown_file << "%): "; Breakdown_file.width(11); Breakdown_file << Mnt_CL << "\n"; - + Breakdown_file << "Total CD: "; Breakdown_file.width(11); Breakdown_file << Total_CD; @@ -7566,7 +7566,7 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry Breakdown_file << SU2_TYPE::Int((Mnt_CD * 100.0) / (Total_CD + EPS)) << "%): "; Breakdown_file.width(11); Breakdown_file << Mnt_CD << "\n"; - + if (nDim == 3) { Breakdown_file << "Total CSF: "; Breakdown_file.width(11); @@ -7590,7 +7590,7 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry Breakdown_file.width(11); Breakdown_file << Mnt_CSF << "\n"; } - + Breakdown_file << "Total CL/CD: "; Breakdown_file.width(11); Breakdown_file << Total_CEff; @@ -7612,7 +7612,7 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry Breakdown_file << "%): "; Breakdown_file.width(11); Breakdown_file << Mnt_CEff << "\n"; - + if (nDim == 3) { Breakdown_file << "Total CMx: "; Breakdown_file.width(11); @@ -7635,7 +7635,7 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry Breakdown_file << "%): "; Breakdown_file.width(11); Breakdown_file << Mnt_CMx << "\n"; - + Breakdown_file << "Total CMy: "; Breakdown_file.width(11); Breakdown_file << Total_CMy; @@ -7658,7 +7658,7 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry Breakdown_file.width(11); Breakdown_file << Mnt_CMy << "\n"; } - + Breakdown_file << "Total CMz: "; Breakdown_file.width(11); Breakdown_file << Total_CMz; @@ -7680,7 +7680,7 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry Breakdown_file << "%): "; Breakdown_file.width(11); Breakdown_file << Mnt_CMz << "\n"; - + Breakdown_file << "Total CFx: "; Breakdown_file.width(11); Breakdown_file << Total_CFx; @@ -7702,7 +7702,7 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry Breakdown_file << "%): "; Breakdown_file.width(11); Breakdown_file << Mnt_CFx << "\n"; - + Breakdown_file << "Total CFy: "; Breakdown_file.width(11); Breakdown_file << Total_CFy; @@ -7724,7 +7724,7 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry Breakdown_file << "%): "; Breakdown_file.width(11); Breakdown_file << Mnt_CFy << "\n"; - + if (nDim == 3) { Breakdown_file << "Total CFz: "; Breakdown_file.width(11); @@ -7748,17 +7748,17 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry Breakdown_file.width(11); Breakdown_file << Mnt_CFz << "\n"; } - + Breakdown_file << "\n" << "\n"; - + for (iMarker_Monitoring = 0; iMarker_Monitoring < config[val_iZone]->GetnMarker_Monitoring(); iMarker_Monitoring++) { - + Breakdown_file << "Surface name: " << config[val_iZone]->GetMarker_Monitoring_TagBound( iMarker_Monitoring) << "\n" << "\n"; - + Breakdown_file << "Total CL ("; Breakdown_file.width(5); Breakdown_file @@ -7795,7 +7795,7 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry Breakdown_file << "%): "; Breakdown_file.width(11); Breakdown_file << Surface_CL_Mnt[iMarker_Monitoring] << "\n"; - + Breakdown_file << "Total CD ("; Breakdown_file.width(5); Breakdown_file @@ -7832,7 +7832,7 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry Breakdown_file << "%): "; Breakdown_file.width(11); Breakdown_file << Surface_CD_Mnt[iMarker_Monitoring] << "\n"; - + if (nDim == 3) { Breakdown_file << "Total CSF ("; Breakdown_file.width(5); @@ -7873,7 +7873,7 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry Breakdown_file << Surface_CSF_Mnt[iMarker_Monitoring] << "\n"; } - + Breakdown_file << "Total CL/CD ("; Breakdown_file.width(5); Breakdown_file @@ -7911,9 +7911,9 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry Breakdown_file.width(11); Breakdown_file << Surface_CEff_Mnt[iMarker_Monitoring] << "\n"; - + if (nDim == 3) { - + Breakdown_file << "Total CMx ("; Breakdown_file.width(5); Breakdown_file @@ -7951,7 +7951,7 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry Breakdown_file.width(11); Breakdown_file << Surface_CMx_Mnt[iMarker_Monitoring] << "\n"; - + Breakdown_file << "Total CMy ("; Breakdown_file.width(5); Breakdown_file @@ -7990,7 +7990,7 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry Breakdown_file << Surface_CMy_Mnt[iMarker_Monitoring] << "\n"; } - + Breakdown_file << "Total CMz ("; Breakdown_file.width(5); Breakdown_file @@ -8027,7 +8027,7 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry Breakdown_file.width(11); Breakdown_file << Surface_CMz_Mnt[iMarker_Monitoring] << "\n"; - + Breakdown_file << "Total CFx ("; Breakdown_file.width(5); Breakdown_file @@ -8064,7 +8064,7 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry Breakdown_file.width(11); Breakdown_file << Surface_CFx_Mnt[iMarker_Monitoring] << "\n"; - + Breakdown_file << "Total CFy ("; Breakdown_file.width(5); Breakdown_file @@ -8101,7 +8101,7 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry Breakdown_file.width(11); Breakdown_file << Surface_CFy_Mnt[iMarker_Monitoring] << "\n"; - + if (nDim == 3) { Breakdown_file << "Total CFz ("; Breakdown_file.width(5); @@ -8140,14 +8140,14 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry Breakdown_file.width(11); Breakdown_file << Surface_CFz_Mnt[iMarker_Monitoring] << "\n"; - + } - + Breakdown_file << "\n"; - - + + } - + delete [] Surface_CL; delete [] Surface_CD; delete [] Surface_CSF; @@ -8158,7 +8158,7 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry delete [] Surface_CMx; delete [] Surface_CMy; delete [] Surface_CMz; - + delete [] Surface_CL_Inv; delete [] Surface_CD_Inv; delete [] Surface_CSF_Inv; @@ -8169,7 +8169,7 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry delete [] Surface_CMx_Inv; delete [] Surface_CMy_Inv; delete [] Surface_CMz_Inv; - + delete [] Surface_CL_Visc; delete [] Surface_CD_Visc; delete [] Surface_CSF_Visc; @@ -8193,20 +8193,20 @@ void COutputLegacy::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry delete [] Surface_CMz_Mnt; Breakdown_file.close(); - + } - + } void COutputLegacy::SetResult_Files(CSolver *****solver_container, CGeometry ****geometry, CConfig **config, unsigned long iExtIter, unsigned short val_nZone) { - + unsigned short iZone; - + for (iZone = 0; iZone < val_nZone; iZone++) { - + /*--- Flags identifying the types of files to be written. ---*/ - + bool Wrt_Vol = config[iZone]->GetWrt_Vol_Sol(); bool Wrt_Srf = config[iZone]->GetWrt_Srf_Sol(); bool Wrt_Csv = config[iZone]->GetWrt_Csv_Sol(); @@ -8214,53 +8214,53 @@ void COutputLegacy::SetResult_Files(CSolver *****solver_container, CGeometry *** #ifdef HAVE_MPI /*--- Do not merge the volume solutions if we are running in parallel. Force the use of SU2_SOL to merge the volume sols in this case. ---*/ - + SU2_MPI::Comm_size(MPI_COMM_WORLD, &size); if (size > SINGLE_NODE) { Wrt_Vol = false; Wrt_Srf = false; } #endif - + if (rank == MASTER_NODE) cout << endl << "Writing comma-separated values (CSV) surface files." << endl; - + switch (config[iZone]->GetKind_Solver()) { - + case EULER : case NAVIER_STOKES : case RANS : - case INC_EULER : case INC_NAVIER_STOKES : case INC_RANS : + case INC_EULER : case INC_NAVIER_STOKES : case INC_RANS : case FEM_EULER : case FEM_NAVIER_STOKES : case FEM_RANS : case FEM_LES : - + if (Wrt_Csv) SetSurfaceCSV_Flow(config[iZone], geometry[iZone][INST_0][MESH_0], solver_container[iZone][INST_0][MESH_0][FLOW_SOL], iExtIter, iZone, INST_0); break; - + case ADJ_EULER : case ADJ_NAVIER_STOKES : case ADJ_RANS : case DISC_ADJ_EULER: case DISC_ADJ_NAVIER_STOKES: case DISC_ADJ_RANS: case DISC_ADJ_INC_NAVIER_STOKES: case DISC_ADJ_INC_RANS: case DISC_ADJ_INC_EULER: if (Wrt_Csv) SetSurfaceCSV_Adjoint(config[iZone], geometry[iZone][INST_0][MESH_0], solver_container[iZone][INST_0][MESH_0][ADJFLOW_SOL], solver_container[iZone][INST_0][MESH_0][FLOW_SOL], iExtIter, iZone, INST_0); break; - + } - + /*--- Get the file output format ---*/ - + unsigned short FileFormat = config[iZone]->GetTabular_FileFormat(); - + /*--- Merge the node coordinates and connectivity, if necessary. This is only performed if a volume solution file is requested, and it is active by default. ---*/ - + if (Wrt_Vol || Wrt_Srf) { if (rank == MASTER_NODE) cout << "Merging connectivities in the Master node." << endl; MergeConnectivity(config[iZone], geometry[iZone][INST_0][MESH_0], iZone); } - + /*--- Merge coordinates of all grid nodes (excluding ghost points). The grid coordinates are always merged and included first in the restart files. ---*/ - + if (rank == MASTER_NODE) cout << "Merging coordinates in the Master node." << endl; MergeCoordinates(config[iZone], geometry[iZone][INST_0][MESH_0]); - + if ((rank == MASTER_NODE) && (Wrt_Vol || Wrt_Srf)) { if (FileFormat == TECPLOT_BINARY) { if (rank == MASTER_NODE) cout << "Writing Tecplot binary volume and surface mesh files." << endl; @@ -8272,143 +8272,143 @@ void COutputLegacy::SetResult_Files(CSolver *****solver_container, CGeometry *** DeallocateConnectivity(config[iZone], geometry[iZone][INST_0][MESH_0], wrote_surf_file); } } - + /*--- Merge the solution data needed for volume solutions and restarts ---*/ - + if (rank == MASTER_NODE) cout << "Merging solution in the Master node." << endl; MergeSolution(config[iZone], geometry[iZone][INST_0][MESH_0], solver_container[iZone][INST_0][MESH_0], iZone); - + /*--- Write restart, or Tecplot files using the merged data. This data lives only on the master, and these routines are currently executed by the master proc alone (as if in serial). ---*/ - + if (rank == MASTER_NODE) { - + /*--- Write a native restart file ---*/ - + if (rank == MASTER_NODE) cout << "Writing SU2 native restart file." << endl; SetRestart(config[iZone], geometry[iZone][INST_0][MESH_0], solver_container[iZone][INST_0][MESH_0] , iZone); - + if (Wrt_Vol) { - + switch (FileFormat) { - + case TECPLOT: - + /*--- Write a Tecplot ASCII file ---*/ - + if (rank == MASTER_NODE) cout << "Writing Tecplot ASCII file volume solution file." << endl; // SetTecplotASCII(config[iZone], geometry[iZone][INST_0][MESH_0], solver_container[iZone][INST_0][MESH_0], iZone, val_nZone, false); DeallocateConnectivity(config[iZone], geometry[iZone][INST_0][MESH_0], false); break; - - - + + + case TECPLOT_BINARY: - + /*--- Write a Tecplot binary solution file ---*/ - + if (rank == MASTER_NODE) cout << "Writing Tecplot binary volume solution file." << endl; // SetTecplotBinary_DomainSolution(config[iZone], geometry[iZone][INST_0][MESH_0], iZone); break; - - + + case PARAVIEW: - + /*--- Write a Paraview ASCII file ---*/ - + if (rank == MASTER_NODE) cout << "Writing Paraview ASCII volume solution file." << endl; // SetParaview_ASCII(config[iZone], geometry[iZone][INST_0][MESH_0], iZone, val_nZone, false); DeallocateConnectivity(config[iZone], geometry[iZone][INST_0][MESH_0], false); break; - + case PARAVIEW_BINARY: - + /*--- Write a ParaView ASCII file instead for now in serial. ---*/ - + if (rank == MASTER_NODE) cout << "ParaView binary volume files not available in this mode." << endl; if (rank == MASTER_NODE) cout << " Writing ParaView ASCII volume solution file instead." << endl; // SetParaview_ASCII(config[iZone], geometry[iZone][INST_0][MESH_0], iZone, val_nZone, false); DeallocateConnectivity(config[iZone], geometry[iZone][INST_0][MESH_0], false); break; - + default: break; } - + } - + if (Wrt_Srf) { - + switch (FileFormat) { - + case TECPLOT: - + /*--- Write a Tecplot ASCII file ---*/ - + if (rank == MASTER_NODE) cout << "Writing Tecplot ASCII surface solution file." << endl; // SetTecplotASCII(config[iZone], geometry[iZone][INST_0][MESH_0], solver_container[iZone][INST_0][MESH_0] , iZone, val_nZone, true); DeallocateConnectivity(config[iZone], geometry[iZone][INST_0][MESH_0], true); break; - + case TECPLOT_BINARY: - + /*--- Write a Tecplot binary solution file ---*/ - + if (rank == MASTER_NODE) cout << "Writing Tecplot binary surface solution file." << endl; // SetTecplotBinary_SurfaceSolution(config[iZone], geometry[iZone][INST_0][MESH_0], iZone); break; - + case PARAVIEW: - + /*--- Write a Paraview ASCII file ---*/ - + if (rank == MASTER_NODE) cout << "Writing Paraview ASCII surface solution file." << endl; // SetParaview_ASCII(config[iZone], geometry[iZone][INST_0][MESH_0], iZone, val_nZone, true); DeallocateConnectivity(config[iZone], geometry[iZone][INST_0][MESH_0], true); break; - + case PARAVIEW_BINARY: - + /*--- Write a ParaView ASCII file instead for now in serial. ---*/ - + if (rank == MASTER_NODE) cout << "ParaView binary surface files not available in this mode." << endl; if (rank == MASTER_NODE) cout << " Writing ParaView ASCII surface solution file instead." << endl; // SetParaview_ASCII(config[iZone], geometry[iZone][INST_0][MESH_0], iZone, val_nZone, true); DeallocateConnectivity(config[iZone], geometry[iZone][INST_0][MESH_0], true); break; - + default: break; } - + } - + /*--- Release memory needed for merging the solution data. ---*/ - + DeallocateCoordinates(config[iZone], geometry[iZone][INST_0][MESH_0]); DeallocateSolution(config[iZone], geometry[iZone][INST_0][MESH_0]); - + } - + /*--- Final broadcast (informing other procs that the base output file was written). ---*/ - + #ifdef HAVE_MPI SU2_MPI::Bcast(&wrote_base_file, 1, MPI_UNSIGNED_SHORT, MASTER_NODE, MPI_COMM_WORLD); SU2_MPI::Bcast(&wrote_surf_file, 1, MPI_UNSIGNED_SHORT, MASTER_NODE, MPI_COMM_WORLD); #endif - + } } void COutputLegacy::SetBaselineResult_Files(CSolver ***solver, CGeometry ***geometry, CConfig **config, unsigned long iExtIter, unsigned short val_nZone) { - + unsigned short iZone, iInst, nInst; - + for (iZone = 0; iZone < val_nZone; iZone++) { - + nInst = config[iZone]->GetnTimeInstances(); for (iInst = 0; iInst < nInst; iInst++) { @@ -8479,11 +8479,11 @@ void COutputLegacy::SetBaselineResult_Files(CSolver ***solver, CGeometry ***geom // SetParaview_ASCII(config[iZone], geometry[iZone][iInst], iZone, val_nZone, false); DeallocateConnectivity(config[iZone], geometry[iZone][iInst], false); break; - + case PARAVIEW_BINARY: - + /*--- Write a ParaView ASCII file instead for now in serial. ---*/ - + if (rank == MASTER_NODE) cout << "ParaView binary volume files not available in this mode." << endl; if (rank == MASTER_NODE) cout << " Writing ParaView ASCII volume solution file instead." << endl; // SetParaview_ASCII(config[iZone], geometry[iZone][iInst], iZone, val_nZone, false); @@ -8528,15 +8528,15 @@ void COutputLegacy::SetBaselineResult_Files(CSolver ***solver, CGeometry ***geom break; case PARAVIEW_BINARY: - + /*--- Write a ParaView ASCII file instead for now in serial. ---*/ - + if (rank == MASTER_NODE) cout << "ParaView binary surface files not available in this mode." << endl; if (rank == MASTER_NODE) cout << " Writing ParaView ASCII surface solution file instead." << endl; // SetParaview_ASCII(config[iZone], geometry[iZone][iInst], iZone, val_nZone, true); DeallocateConnectivity(config[iZone], geometry[iZone][iInst], true); break; - + default: break; } @@ -8590,35 +8590,35 @@ void COutputLegacy::SetMesh_Files(CGeometry **geometry, CConfig **config, unsign } for (iZone = 0; iZone < val_nZone; iZone++) { - + /*--- Flags identifying the types of files to be written. ---*/ - + bool Wrt_Vol = config[iZone]->GetVisualize_Volume_Def(); bool Wrt_Srf = config[iZone]->GetVisualize_Surface_Def(); //bool Wrt_Crd = config[iZone]->GetWrt_Crd_Sol(); - + /*--- Merge the node coordinates and connectivity if necessary. This is only performed if a volume solution file is requested, and it is active by default. ---*/ - + if (rank == MASTER_NODE) cout <<"Merging grid connectivity." << endl; MergeConnectivity(config[iZone], geometry[iZone], iZone); - + /*--- Merge coordinates of all grid nodes (excluding ghost points). The grid coordinates are always merged and included first in the restart files. ---*/ - + if (rank == MASTER_NODE) cout <<"Merging grid coordinates." << endl; MergeCoordinates(config[iZone], geometry[iZone]); - + /*--- Write restart, Tecplot or Paraview files using the merged data. This data lives only on the master, and these routines are currently executed by the master proc alone (as if in serial). ---*/ - + if (rank == MASTER_NODE) { - + if (Wrt_Vol) { - + if (rank == MASTER_NODE) cout <<"Writing volume mesh file." << endl; // /*--- Write a Tecplot ASCII file ---*/ @@ -8633,15 +8633,15 @@ void COutputLegacy::SetMesh_Files(CGeometry **geometry, CConfig **config, unsign // if (rank == MASTER_NODE) cout <<"Writing ASCII tecplot volume mesh file by default." << endl; //// SetTecplotASCII_Mesh(config[iZone], geometry[iZone], iZone, false, new_file); // } - + } - + if (Wrt_Srf) { - + if (rank == MASTER_NODE) cout <<"Writing surface mesh file." << endl; - + /*--- Write a Tecplot ASCII file ---*/ - + // if (config[iZone]->GetOutput_FileFormat() == PARAVIEW) SetParaview_MeshASCII(config[iZone], geometry[iZone], iZone, val_nZone, true, new_file); // else if (config[iZone]->GetOutput_FileFormat() == PARAVIEW_BINARY) { // if (rank == MASTER_NODE) cout <<"Writing ASCII paraview surface mesh file by default." << endl; @@ -8652,48 +8652,48 @@ void COutputLegacy::SetMesh_Files(CGeometry **geometry, CConfig **config, unsign // if (rank == MASTER_NODE) cout <<"Writing ASCII tecplot surface mesh file by default." << endl; // SetTecplotASCII_Mesh(config[iZone], geometry[iZone], iZone, true, new_file); // } - + } - + /*--- Write a .su2 ASCII file ---*/ if (su2_file) { - + if (rank == MASTER_NODE) cout <<"Writing .su2 file." << endl; - + // SetSU2_MeshASCII(config[iZone], geometry[iZone], iZone, output_file); - + /*--- Write an stl surface file ---*/ - + if (rank == MASTER_NODE) cout <<"Writing .stl surface file." << endl; - + // SetSTL_MeshASCII(config[iZone], geometry[iZone]); - + } - + /*--- Write a binary file with the grid coordinates alone. ---*/ - + // if (Wrt_Crd) { // if (rank == MASTER_NODE) cout <<"Writing .dat binary coordinates file." << endl; // WriteCoordinates_Binary(config[iZone], geometry[iZone], iZone); // } - + /*--- Deallocate connectivity ---*/ - + DeallocateConnectivity(config[iZone], geometry[iZone], true); DeallocateConnectivity(config[iZone], geometry[iZone], false); DeallocateCoordinates(config[iZone], geometry[iZone]); - + } /*--- Final broadcast (informing other procs that the base output file was written). ---*/ - + #ifdef HAVE_MPI SU2_MPI::Bcast(&wrote_base_file, 1, MPI_UNSIGNED_SHORT, MASTER_NODE, MPI_COMM_WORLD); #endif - + /*--- Write an csv surface file, done in parallel ---*/ if (rank == MASTER_NODE) cout <<"Writing .csv surface file." << endl; @@ -8710,7 +8710,7 @@ void COutputLegacy::SetMesh_Files(CGeometry **geometry, CConfig **config, unsign } void COutputLegacy::SpecialOutput_SpanLoad(CSolver *solver, CGeometry *geometry, CConfig *config, bool output) { - + short iSection, nSection; unsigned long iVertex, iPoint, Trailing_Point; su2double *Plane_P0, *Plane_P0_, *Plane_Normal, *Plane_Normal_, *CPressure, @@ -8721,12 +8721,12 @@ void COutputLegacy::SpecialOutput_SpanLoad(CSolver *solver, CGeometry *geometry, RefLength, Alpha, CL_Inv, Xcoord_LeadingEdge = 0.0, Ycoord_LeadingEdge = 0.0, Zcoord_LeadingEdge = 0.0, Xcoord_TrailingEdge = 0.0, Ycoord_TrailingEdge = 0.0, Zcoord_TrailingEdge = 0.0, - Xcoord_LeadingEdge_ = 0.0, + Xcoord_LeadingEdge_ = 0.0, Xcoord_TrailingEdge_ = 0.0, Ycoord_TrailingEdge_ = 0.0, Zcoord_TrailingEdge_ = 0.0, MaxDistance, Distance, Chord, Aux, Dihedral_Trailing; - + su2double B, Y, C_L, C_L0, Elliptic_Spanload; - + vector Xcoord_Airfoil, Ycoord_Airfoil, Zcoord_Airfoil, CPressure_Airfoil; vector Xcoord_Airfoil_, Ycoord_Airfoil_, Zcoord_Airfoil_, @@ -8734,21 +8734,21 @@ void COutputLegacy::SpecialOutput_SpanLoad(CSolver *solver, CGeometry *geometry, string Marker_Tag, Slice_Filename, Slice_Ext; ofstream Cp_File; unsigned short iDim; - + bool dynamic_grid = config->GetDynamic_Grid(); - + Plane_P0 = new su2double[3]; Plane_P0_ = new su2double[3]; Plane_Normal = new su2double[3]; Plane_Normal_ = new su2double[3]; CPressure = new su2double[geometry->GetnPoint()]; - + if ((rank == MASTER_NODE) && (output)) { cout << endl << "Writing the spanload file (load_distribution.dat)."; } - + /*--- Compute some reference quantities and necessary values ---*/ - + RefDensity = solver->GetDensity_Inf(); RefPressure = solver->GetPressure_Inf(); RefArea = config->GetRefArea(); @@ -8757,7 +8757,7 @@ void COutputLegacy::SpecialOutput_SpanLoad(CSolver *solver, CGeometry *geometry, Origin = config->GetRefOriginMoment(0); RefLength = config->GetRefLength(); Alpha = config->GetAoA() * PI_NUMBER / 180.0; - + if (dynamic_grid) { Gas_Constant = config->GetGas_ConstantND(); Mach2Vel = sqrt( @@ -8770,26 +8770,26 @@ void COutputLegacy::SpecialOutput_SpanLoad(CSolver *solver, CGeometry *geometry, RefVel2 += Velocity_Inf[iDim] * Velocity_Inf[iDim]; } factor = 1.0 / (0.5 * RefDensity * RefArea * RefVel2); - + if (geometry->GetnDim() == 3) { - + /*--- Copy the pressure to an auxiliar structure ---*/ - + for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { CPressure[iPoint] = (solver->GetNodes()->GetPressure(iPoint) - RefPressure) * factor * RefArea; } - + nSection = config->GetnLocationStations(); - + for (iSection = 0; iSection < nSection; iSection++) { - + /*--- Read the values from the config file ---*/ - + Plane_Normal[0] = 0.0; Plane_P0[0] = 0.0; Plane_Normal[1] = 0.0; Plane_P0[1] = 0.0; Plane_Normal[2] = 0.0; Plane_P0[2] = 0.0; - + if (config->GetGeo_Description() == FUSELAGE) { Plane_Normal[0] = 1.0; Plane_P0[0] = config->GetLocationStations(iSection); @@ -8798,27 +8798,27 @@ void COutputLegacy::SpecialOutput_SpanLoad(CSolver *solver, CGeometry *geometry, Plane_Normal[0] = 0.0; Plane_Normal[1] = -sin(config->GetLocationStations(iSection)*PI_NUMBER/180.0); Plane_Normal[2] = cos(config->GetLocationStations(iSection)*PI_NUMBER/180.0); - + /*--- Apply tilt angle to the plane ---*/ - + su2double Tilt_Angle = config->GetNacelleLocation(3)*PI_NUMBER/180; su2double Plane_NormalX_Tilt = Plane_Normal[0]*cos(Tilt_Angle) + Plane_Normal[2]*sin(Tilt_Angle); su2double Plane_NormalY_Tilt = Plane_Normal[1]; su2double Plane_NormalZ_Tilt = Plane_Normal[2]*cos(Tilt_Angle) - Plane_Normal[0]*sin(Tilt_Angle); - + /*--- Apply toe angle to the plane ---*/ - + su2double Toe_Angle = config->GetNacelleLocation(4)*PI_NUMBER/180; su2double Plane_NormalX_Tilt_Toe = Plane_NormalX_Tilt*cos(Toe_Angle) - Plane_NormalY_Tilt*sin(Toe_Angle); su2double Plane_NormalY_Tilt_Toe = Plane_NormalX_Tilt*sin(Toe_Angle) + Plane_NormalY_Tilt*cos(Toe_Angle); su2double Plane_NormalZ_Tilt_Toe = Plane_NormalZ_Tilt; - + /*--- Update normal vector ---*/ - + Plane_Normal[0] = Plane_NormalX_Tilt_Toe; Plane_Normal[1] = Plane_NormalY_Tilt_Toe; Plane_Normal[2] = Plane_NormalZ_Tilt_Toe; - + } else { Plane_Normal[1] = 1.0; @@ -8826,21 +8826,21 @@ void COutputLegacy::SpecialOutput_SpanLoad(CSolver *solver, CGeometry *geometry, } /*--- Compute the airfoil sections (note that we feed in the Cp) ---*/ - + geometry->ComputeAirfoil_Section(Plane_P0, Plane_Normal, -1E6, 1E6, -1E6, 1E6, -1E6, 1E6, CPressure, Xcoord_Airfoil, Ycoord_Airfoil, Zcoord_Airfoil, CPressure_Airfoil, true, config); - + if ((rank == MASTER_NODE) && (Xcoord_Airfoil.size() == 0)) { if ((config->GetGeo_Description() == FUSELAGE) || (config->GetGeo_Description() == WING)) cout << endl << "Please check the config file, the section (" << Plane_P0[0] <<", " << Plane_P0[1] <<", " << Plane_P0[2] << ") has not been detected." << endl; if (config->GetGeo_Description() == NACELLE) cout << endl << "Please check the config file, the section (" << Plane_Normal[0] <<", " << Plane_Normal[1] <<", " << Plane_Normal[2] << ") has not been detected." << endl; } - - + + /*--- Compute dihedral using a step in the station value ---*/ - + Plane_P0_[0] = 0.0; Plane_Normal_[0] = 0.0; Plane_P0_[1] = 0.0; Plane_Normal_[1] = 0.0; Plane_P0_[2] = 0.0; Plane_Normal_[2] = 0.0; @@ -8855,53 +8855,53 @@ void COutputLegacy::SpecialOutput_SpanLoad(CSolver *solver, CGeometry *geometry, Plane_Normal_[0] = 0.0; Plane_Normal_[1] = -sin((config->GetLocationStations(iSection) + 0.01)*PI_NUMBER/180.0); Plane_Normal_[2] = cos((config->GetLocationStations(iSection) + 0.01)*PI_NUMBER/180.0); - + /*--- Apply tilt angle to the plane ---*/ - + su2double Tilt_Angle = config->GetNacelleLocation(3)*PI_NUMBER/180; su2double Plane_NormalX_Tilt = Plane_Normal[0]*cos(Tilt_Angle) + Plane_Normal[2]*sin(Tilt_Angle); su2double Plane_NormalY_Tilt = Plane_Normal[1]; su2double Plane_NormalZ_Tilt = Plane_Normal[2]*cos(Tilt_Angle) - Plane_Normal[0]*sin(Tilt_Angle); - + /*--- Apply toe angle to the plane ---*/ - + su2double Toe_Angle = config->GetNacelleLocation(4)*PI_NUMBER/180; su2double Plane_NormalX_Tilt_Toe = Plane_NormalX_Tilt*cos(Toe_Angle) - Plane_NormalY_Tilt*sin(Toe_Angle); su2double Plane_NormalY_Tilt_Toe = Plane_NormalX_Tilt*sin(Toe_Angle) + Plane_NormalY_Tilt*cos(Toe_Angle); su2double Plane_NormalZ_Tilt_Toe = Plane_NormalZ_Tilt; - + /*--- Update normal vector ---*/ - + Plane_Normal[0] = Plane_NormalX_Tilt_Toe; Plane_Normal[1] = Plane_NormalY_Tilt_Toe; Plane_Normal[2] = Plane_NormalZ_Tilt_Toe; - + } else { Plane_Normal_[0] = 0.0; Plane_Normal_[1] = -sin((config->GetLocationStations(iSection) - 0.01)*PI_NUMBER/180.0); Plane_Normal_[2] = cos((config->GetLocationStations(iSection) - 0.01)*PI_NUMBER/180.0); - + /*--- Apply tilt angle to the plane ---*/ - + su2double Tilt_Angle = config->GetNacelleLocation(3)*PI_NUMBER/180; su2double Plane_NormalX_Tilt = Plane_Normal[0]*cos(Tilt_Angle) + Plane_Normal[2]*sin(Tilt_Angle); su2double Plane_NormalY_Tilt = Plane_Normal[1]; su2double Plane_NormalZ_Tilt = Plane_Normal[2]*cos(Tilt_Angle) - Plane_Normal[0]*sin(Tilt_Angle); - + /*--- Apply toe angle to the plane ---*/ - + su2double Toe_Angle = config->GetNacelleLocation(4)*PI_NUMBER/180; su2double Plane_NormalX_Tilt_Toe = Plane_NormalX_Tilt*cos(Toe_Angle) - Plane_NormalY_Tilt*sin(Toe_Angle); su2double Plane_NormalY_Tilt_Toe = Plane_NormalX_Tilt*sin(Toe_Angle) + Plane_NormalY_Tilt*cos(Toe_Angle); su2double Plane_NormalZ_Tilt_Toe = Plane_NormalZ_Tilt; - + /*--- Update normal vector ---*/ - + Plane_Normal[0] = Plane_NormalX_Tilt_Toe; Plane_Normal[1] = Plane_NormalY_Tilt_Toe; Plane_Normal[2] = Plane_NormalZ_Tilt_Toe; - + } } else { @@ -8909,17 +8909,17 @@ void COutputLegacy::SpecialOutput_SpanLoad(CSolver *solver, CGeometry *geometry, if (iSection == 0) Plane_P0_[1] = config->GetLocationStations(iSection) + 0.01; else Plane_P0_[1] = config->GetLocationStations(iSection) - 0.01; } - + geometry->ComputeAirfoil_Section(Plane_P0_, Plane_Normal_, -1E6, 1E6, -1E6, 1E6, -1E6, 1E6, CPressure, Xcoord_Airfoil_, Ycoord_Airfoil_, Zcoord_Airfoil_, CPressure_Airfoil_, true, config); - + /*--- Output the pressure on each section (tecplot format) ---*/ - + if ((rank == MASTER_NODE) && (Xcoord_Airfoil.size() != 0)) { - + /*--- Find leading and trailing edge ---*/ - + Xcoord_LeadingEdge = 1E6; Xcoord_TrailingEdge = -1E6; for (iVertex = 0; iVertex < Xcoord_Airfoil.size(); iVertex++) { if (Xcoord_Airfoil[iVertex] < Xcoord_LeadingEdge) { @@ -8933,11 +8933,11 @@ void COutputLegacy::SpecialOutput_SpanLoad(CSolver *solver, CGeometry *geometry, Zcoord_TrailingEdge = Zcoord_Airfoil[iVertex]; } } - + Chord = (Xcoord_TrailingEdge-Xcoord_LeadingEdge); - + /*--- Compute dihedral ---*/ - + Xcoord_LeadingEdge_ = 1E6; Xcoord_TrailingEdge_ = -1E6; for (iVertex = 0; iVertex < Xcoord_Airfoil_.size(); iVertex++) { if (Xcoord_Airfoil_[iVertex] < Xcoord_LeadingEdge_) { @@ -8949,27 +8949,27 @@ void COutputLegacy::SpecialOutput_SpanLoad(CSolver *solver, CGeometry *geometry, Zcoord_TrailingEdge_ = Zcoord_Airfoil_[iVertex]; } } - + if (iSection == 0) { Dihedral_Trailing = atan((Zcoord_TrailingEdge_ - Zcoord_TrailingEdge) / (Ycoord_TrailingEdge_ - Ycoord_TrailingEdge))*180/PI_NUMBER; } else { Dihedral_Trailing = atan((Zcoord_TrailingEdge - Zcoord_TrailingEdge_) / (Ycoord_TrailingEdge - Ycoord_TrailingEdge_))*180/PI_NUMBER; } - + /*--- Write Cp at each section (tecplot format) ---*/ - + if (output) { - + ofstream Cp_File; - + if (iSection == 0) { Cp_File.open("cp_sections.dat", ios::out); Cp_File << "TITLE = \"Airfoil sections\"" << endl; Cp_File << "VARIABLES = \"x/c\",\"Cp\",\"x\",\"y\",\"z\",\"y/c\",\"z/c\"" << endl; } else Cp_File.open("cp_sections.dat", ios::app); - + if (config->GetGeo_Description() == NACELLE) { su2double theta_deg = atan2(Plane_Normal[1], -Plane_Normal[2])/PI_NUMBER*180 + 180; Cp_File << "ZONE T=\"Theta = " << theta_deg << " deg\", I= " << Xcoord_Airfoil.size() << ", F=POINT" << "\n"; @@ -8977,33 +8977,33 @@ void COutputLegacy::SpecialOutput_SpanLoad(CSolver *solver, CGeometry *geometry, else { if (config->GetSystemMeasurements() == SI) Cp_File << "ZONE T=\"y = " << Plane_P0[1] << " m\", I= " << Xcoord_Airfoil.size() << ", F=POINT" << "\n"; - + if (config->GetSystemMeasurements() == US) Cp_File << "ZONE T=\"y = " << Plane_P0[1]*12.0 << " in\", I= " << Xcoord_Airfoil.size() << ", F=POINT" << "\n"; } - - + + /*--- Coordinates and pressure value ---*/ - + for (iVertex = 0; iVertex < Xcoord_Airfoil.size(); iVertex++) { - + su2double XCoord = Xcoord_Airfoil[iVertex]; su2double YCoord = Ycoord_Airfoil[iVertex]; su2double ZCoord = Zcoord_Airfoil[iVertex]; - + /*--- Undo the transformation based on the Theta angle ---*/ - + if (config->GetGeo_Description() == NACELLE) { su2double theta_deg = atan2(Plane_Normal[1],-Plane_Normal[2])/PI_NUMBER*180 + 180; su2double Angle = theta_deg*PI_NUMBER/180 - 0.5*PI_NUMBER; - + XCoord = Xcoord_Airfoil[iVertex] + config->GetNacelleLocation(0); YCoord = (Ycoord_Airfoil[iVertex]*cos(Angle) - Zcoord_Airfoil[iVertex]*sin(Angle)) + config->GetNacelleLocation(1); ZCoord = (Zcoord_Airfoil[iVertex]*cos(Angle) + Ycoord_Airfoil[iVertex]*sin(Angle)) + config->GetNacelleLocation(2); - + } - + if (config->GetSystemMeasurements() == US) { Cp_File << (Xcoord_Airfoil[iVertex] - Xcoord_LeadingEdge) / Chord << " " << CPressure_Airfoil[iVertex] << " " << XCoord * 12.0 << " " << YCoord * 12.0 << " " << ZCoord * 12.0 @@ -9014,57 +9014,57 @@ void COutputLegacy::SpecialOutput_SpanLoad(CSolver *solver, CGeometry *geometry, << " " << XCoord << " " << YCoord << " " << ZCoord << " " << (Ycoord_Airfoil[iVertex] - Ycoord_LeadingEdge) / Chord << " " << (Zcoord_Airfoil[iVertex] - Zcoord_LeadingEdge) / Chord << "\n"; } - + } - + Cp_File.close(); - + } - + /*--- Compute load distribution ---*/ - + ForceInviscid[0] = 0.0; ForceInviscid[1] = 0.0; ForceInviscid[2] = 0.0; MomentInviscid[1] = 0.0; - + for (iVertex = 0; iVertex < Xcoord_Airfoil.size() - 1; iVertex++) { - + NDPressure = 0.5 * (CPressure_Airfoil[iVertex] + CPressure_Airfoil[iVertex + 1]); - + Force[0] = -(Zcoord_Airfoil[iVertex + 1] - Zcoord_Airfoil[iVertex]) * NDPressure; Force[1] = 0.0; Force[2] = (Xcoord_Airfoil[iVertex + 1] - Xcoord_Airfoil[iVertex]) * NDPressure; - + ForceInviscid[0] += Force[0]; ForceInviscid[1] += Force[1]; ForceInviscid[2] += Force[2]; - + MomentDist[0] = 0.5 * (Xcoord_Airfoil[iVertex] + Xcoord_Airfoil[iVertex + 1]) - Origin[0]; MomentDist[1] = 0.5 * (Ycoord_Airfoil[iVertex] + Ycoord_Airfoil[iVertex + 1]) - Origin[1]; MomentDist[2] = 0.5 * (Zcoord_Airfoil[iVertex] + Zcoord_Airfoil[iVertex + 1]) - Origin[3]; - + MomentInviscid[1] += (Force[0] * MomentDist[2] - Force[2] * MomentDist[0]) / RefLength; - + } - + /*--- Compute local chord, for the nondimensionalization ---*/ - + MaxDistance = 0.0; Trailing_Point = 0; - + for (iVertex = 1; iVertex < Xcoord_Airfoil.size(); iVertex++) { - + Distance = sqrt(pow(Xcoord_Airfoil[iVertex] - Xcoord_Airfoil[Trailing_Point], 2.0) + pow(Ycoord_Airfoil[iVertex] - Ycoord_Airfoil[Trailing_Point], 2.0) + pow(Zcoord_Airfoil[iVertex] - Zcoord_Airfoil[Trailing_Point], 2.0)); - + if (MaxDistance < Distance) { MaxDistance = Distance; } - + } - + Chord = MaxDistance; - + CL_Inv = cos(Dihedral_Trailing * PI_NUMBER / 180.0) * fabs( -ForceInviscid[0] * sin(Alpha) + ForceInviscid[2] * cos(Alpha) )/ Chord; - + /*--- Compute sectional lift at the root ---*/ - + B = 2.0*config->GetSemiSpan(); RefArea = config->GetRefArea(); C_L = solver->GetTotal_CL(); @@ -9072,15 +9072,15 @@ void COutputLegacy::SpecialOutput_SpanLoad(CSolver *solver, CGeometry *geometry, Y = Ycoord_Airfoil[0]; Aux = Y/(0.5*B); Elliptic_Spanload = (C_L0 / RefLength) * sqrt(fabs(1.0-Aux*Aux)); - - + + /*--- Write load distribution ---*/ - + if (output) { - + ofstream Load_File; if (iSection == 0) { - + if ((config->GetTabular_FileFormat() == TAB_CSV)) { Load_File.open("load_distribution.csv", ios::out); Load_File << "\"Percent Semispan\",\"Sectional C_L\",\"Spanload (c C_L / c_ref) \",\"Elliptic Spanload\"" << endl; @@ -9095,38 +9095,38 @@ void COutputLegacy::SpecialOutput_SpanLoad(CSolver *solver, CGeometry *geometry, if ((config->GetTabular_FileFormat() == TAB_CSV)) Load_File.open("load_distribution.csv", ios::app); else Load_File.open("load_distribution.dat", ios::app); } - - + + /*--- CL and spanload ---*/ - + if ((config->GetTabular_FileFormat() == TAB_CSV)) Load_File << 100.0*Ycoord_Airfoil[0]/(0.5*B) << ", " << CL_Inv << ", " << Chord*CL_Inv / RefLength <<", " << Elliptic_Spanload << endl; else Load_File << 100.0*Ycoord_Airfoil[0]/(0.5*B) << " " << CL_Inv << " " << Chord*CL_Inv / RefLength <<" " << Elliptic_Spanload << endl; - + Load_File.close(); - + } - + } - + } - + } - + /*--- Delete dynamically allocated memory ---*/ - + delete[] Plane_P0; delete[] Plane_P0_; delete[] Plane_Normal; delete[] Plane_Normal_; delete[] CPressure; - + } void COutputLegacy::SetCp_InverseDesign(CSolver *solver_container, CGeometry *geometry, CConfig *config, unsigned long iExtIter) { - + unsigned short iMarker, icommas, Boundary, iDim; unsigned long iVertex, iPoint, (*Point2Vertex)[2], nPointLocal = 0, nPointGlobal = 0; su2double XCoord, YCoord, ZCoord, Pressure, PressureCoeff = 0, Cp, CpTarget, *Normal = NULL, Area, PressDiff; @@ -9134,56 +9134,56 @@ void COutputLegacy::SetCp_InverseDesign(CSolver *solver_container, CGeometry *ge string text_line, surfCp_filename; ifstream Surface_file; char buffer[50], cstr[200]; - - + + nPointLocal = geometry->GetnPoint(); #ifdef HAVE_MPI SU2_MPI::Allreduce(&nPointLocal, &nPointGlobal, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); #else nPointGlobal = nPointLocal; #endif - + Point2Vertex = new unsigned long[nPointGlobal][2]; PointInDomain = new bool[nPointGlobal]; - + for (iPoint = 0; iPoint < nPointGlobal; iPoint ++) PointInDomain[iPoint] = false; - + for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { Boundary = config->GetMarker_All_KindBC(iMarker); - + if ((Boundary == EULER_WALL ) || (Boundary == HEAT_FLUX ) || (Boundary == ISOTHERMAL ) || (Boundary == NEARFIELD_BOUNDARY)) { for (iVertex = 0; iVertex < geometry->GetnVertex(iMarker); iVertex++) { - + /*--- The Pressure file uses the global numbering ---*/ - + #ifndef HAVE_MPI iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); #else iPoint = geometry->node[geometry->vertex[iMarker][iVertex]->GetNode()]->GetGlobalIndex(); #endif - + if (geometry->vertex[iMarker][iVertex]->GetNode() < geometry->GetnPointDomain()) { Point2Vertex[iPoint][0] = iMarker; Point2Vertex[iPoint][1] = iVertex; PointInDomain[iPoint] = true; solver_container->SetCPressureTarget(iMarker, iVertex, 0.0); } - + } } } - + /*--- Prepare to read the surface pressure files (CSV) ---*/ - + surfCp_filename = "TargetCp"; strcpy (cstr, surfCp_filename.c_str()); - + /*--- Write file name with extension if unsteady or steady ---*/ - + if ((config->GetTime_Marching() && config->GetTime_Domain()) || (config->GetTime_Marching() == HARMONIC_BALANCE)) { if ((SU2_TYPE::Int(iExtIter) >= 0) && (SU2_TYPE::Int(iExtIter) < 10)) SPRINTF (buffer, "_0000%d.dat", SU2_TYPE::Int(iExtIter)); @@ -9194,90 +9194,90 @@ void COutputLegacy::SetCp_InverseDesign(CSolver *solver_container, CGeometry *ge } else SPRINTF (buffer, ".dat"); - + strcat (cstr, buffer); - + /*--- Read the surface pressure file ---*/ - + string::size_type position; - + Surface_file.open(cstr, ios::in); - + if (!(Surface_file.fail())) { - + getline(Surface_file, text_line); - + while (getline(Surface_file, text_line)) { for (icommas = 0; icommas < 50; icommas++) { position = text_line.find( ",", 0 ); if (position!=string::npos) text_line.erase (position,1); } stringstream point_line(text_line); - + if (geometry->GetnDim() == 2) point_line >> iPoint >> XCoord >> YCoord >> Pressure >> PressureCoeff; if (geometry->GetnDim() == 3) point_line >> iPoint >> XCoord >> YCoord >> ZCoord >> Pressure >> PressureCoeff; - + if (PointInDomain[iPoint]) { - + /*--- Find the vertex for the Point and Marker ---*/ - + iMarker = Point2Vertex[iPoint][0]; iVertex = Point2Vertex[iPoint][1]; - + solver_container->SetCPressureTarget(iMarker, iVertex, PressureCoeff); - + } - + } - + Surface_file.close(); - + } - + /*--- Compute the pressure difference ---*/ - + PressDiff = 0.0; for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { Boundary = config->GetMarker_All_KindBC(iMarker); - + if ((Boundary == EULER_WALL ) || (Boundary == HEAT_FLUX ) || (Boundary == ISOTHERMAL ) || (Boundary == NEARFIELD_BOUNDARY)) { for (iVertex = 0; iVertex < geometry->GetnVertex(iMarker); iVertex++) { - + Normal = geometry->vertex[iMarker][iVertex]->GetNormal(); - + Cp = solver_container->GetCPressure(iMarker, iVertex); CpTarget = solver_container->GetCPressureTarget(iMarker, iVertex); - + Area = 0.0; for (iDim = 0; iDim < geometry->GetnDim(); iDim++) Area += Normal[iDim]*Normal[iDim]; Area = sqrt(Area); - + PressDiff += Area * (CpTarget - Cp) * (CpTarget - Cp); } - + } } - + #ifdef HAVE_MPI su2double MyPressDiff = PressDiff; PressDiff = 0.0; SU2_MPI::Allreduce(&MyPressDiff, &PressDiff, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); #endif - + /*--- Update the total Cp difference coeffient ---*/ - + solver_container->SetTotal_CpDiff(PressDiff); - + delete [] Point2Vertex; delete [] PointInDomain; - + } void COutputLegacy::SetHeatFlux_InverseDesign(CSolver *solver_container, CGeometry *geometry, CConfig *config, unsigned long iExtIter) { - + unsigned short iMarker, icommas, Boundary, iDim; unsigned long iVertex, iPoint, (*Point2Vertex)[2], nPointLocal = 0, nPointGlobal = 0; su2double XCoord, YCoord, ZCoord, PressureCoeff, HeatFlux = 0.0, HeatFluxDiff, HeatFluxTarget, *Normal = NULL, Area, @@ -9286,38 +9286,38 @@ void COutputLegacy::SetHeatFlux_InverseDesign(CSolver *solver_container, CGeomet string text_line, surfHeatFlux_filename; ifstream Surface_file; char buffer[50], cstr[200]; - - + + nPointLocal = geometry->GetnPoint(); #ifdef HAVE_MPI SU2_MPI::Allreduce(&nPointLocal, &nPointGlobal, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); #else nPointGlobal = nPointLocal; #endif - + Point2Vertex = new unsigned long[nPointGlobal][2]; PointInDomain = new bool[nPointGlobal]; - + for (iPoint = 0; iPoint < nPointGlobal; iPoint ++) PointInDomain[iPoint] = false; - + for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { Boundary = config->GetMarker_All_KindBC(iMarker); - + if ((Boundary == EULER_WALL ) || (Boundary == HEAT_FLUX ) || (Boundary == ISOTHERMAL ) || (Boundary == NEARFIELD_BOUNDARY)) { for (iVertex = 0; iVertex < geometry->GetnVertex(iMarker); iVertex++) { - + /*--- The Pressure file uses the global numbering ---*/ - + #ifndef HAVE_MPI iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); #else iPoint = geometry->node[geometry->vertex[iMarker][iVertex]->GetNode()]->GetGlobalIndex(); #endif - + if (geometry->vertex[iMarker][iVertex]->GetNode() < geometry->GetnPointDomain()) { Point2Vertex[iPoint][0] = iMarker; Point2Vertex[iPoint][1] = iVertex; @@ -9327,14 +9327,14 @@ void COutputLegacy::SetHeatFlux_InverseDesign(CSolver *solver_container, CGeomet } } } - + /*--- Prepare to read the surface pressure files (CSV) ---*/ - + surfHeatFlux_filename = "TargetHeatFlux"; strcpy (cstr, surfHeatFlux_filename.c_str()); - + /*--- Write file name with extension if unsteady or steady ---*/ - + if ((config->GetTime_Marching() && config->GetTime_Domain()) || (config->GetTime_Marching() == HARMONIC_BALANCE)) { if ((SU2_TYPE::Int(iExtIter) >= 0) && (SU2_TYPE::Int(iExtIter) < 10)) SPRINTF (buffer, "_0000%d.dat", SU2_TYPE::Int(iExtIter)); @@ -9345,90 +9345,90 @@ void COutputLegacy::SetHeatFlux_InverseDesign(CSolver *solver_container, CGeomet } else SPRINTF (buffer, ".dat"); - + strcat (cstr, buffer); - + /*--- Read the surface pressure file ---*/ - + string::size_type position; - + Surface_file.open(cstr, ios::in); - + if (!(Surface_file.fail())) { - + getline(Surface_file, text_line); - + while (getline(Surface_file, text_line)) { for (icommas = 0; icommas < 50; icommas++) { position = text_line.find( ",", 0 ); if (position!=string::npos) text_line.erase (position,1); } stringstream point_line(text_line); - + if (geometry->GetnDim() == 2) point_line >> iPoint >> XCoord >> YCoord >> Pressure >> PressureCoeff >> Cf >> HeatFlux; if (geometry->GetnDim() == 3) point_line >> iPoint >> XCoord >> YCoord >> ZCoord >> Pressure >> PressureCoeff >> Cf >> HeatFlux; - + if (PointInDomain[iPoint]) { - + /*--- Find the vertex for the Point and Marker ---*/ - + iMarker = Point2Vertex[iPoint][0]; iVertex = Point2Vertex[iPoint][1]; - + solver_container->SetHeatFluxTarget(iMarker, iVertex, HeatFlux); - + } - + } - + Surface_file.close(); } - + /*--- Compute the pressure difference ---*/ - + HeatFluxDiff = 0.0; for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { Boundary = config->GetMarker_All_KindBC(iMarker); - + if ((Boundary == EULER_WALL ) || (Boundary == HEAT_FLUX ) || (Boundary == ISOTHERMAL ) || (Boundary == NEARFIELD_BOUNDARY)) { for (iVertex = 0; iVertex < geometry->GetnVertex(iMarker); iVertex++) { - + Normal = geometry->vertex[iMarker][iVertex]->GetNormal(); - + HeatFlux = solver_container->GetHeatFlux(iMarker, iVertex); HeatFluxTarget = solver_container->GetHeatFluxTarget(iMarker, iVertex); - + Area = 0.0; for (iDim = 0; iDim < geometry->GetnDim(); iDim++) Area += Normal[iDim]*Normal[iDim]; Area = sqrt(Area); - + HeatFluxDiff += Area * (HeatFluxTarget - HeatFlux) * (HeatFluxTarget - HeatFlux); - + } - + } } - + #ifdef HAVE_MPI su2double MyHeatFluxDiff = HeatFluxDiff; HeatFluxDiff = 0.0; SU2_MPI::Allreduce(&MyHeatFluxDiff, &HeatFluxDiff, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); #endif - + /*--- Update the total HeatFlux difference coeffient ---*/ - + solver_container->SetTotal_HeatFluxDiff(HeatFluxDiff); - + delete [] Point2Vertex; delete [] PointInDomain; - + } void COutputLegacy::SpecialOutput_SonicBoom(CSolver *solver, CGeometry *geometry, CConfig *config, bool output) { - + ofstream EquivArea_file, FuncGrad_file; unsigned short iMarker = 0, iDim; short *AzimuthalAngle = NULL; @@ -9441,14 +9441,14 @@ void COutputLegacy::SpecialOutput_SonicBoom(CSolver *solver, CGeometry *geometry *IdPoint = NULL, *IdDomain = NULL, auxDomain; unsigned short iPhiAngle; ofstream NearFieldEA_file; ifstream TargetEA_file; - + su2double XCoordBegin_OF = config->GetEA_IntLimit(0); su2double XCoordEnd_OF = config->GetEA_IntLimit(1); - + unsigned short nDim = geometry->GetnDim(); su2double AoA = -(config->GetAoA()*PI_NUMBER/180.0); su2double EAScaleFactor = config->GetEA_ScaleFactor(); // The EA Obj. Func. should be ~ force based Obj. Func. - + Mach = config->GetMach(); Gamma = config->GetGamma(); Beta = sqrt(Mach*Mach-1.0); @@ -9460,15 +9460,15 @@ void COutputLegacy::SpecialOutput_SonicBoom(CSolver *solver, CGeometry *geometry ModVelocity_Inf = 0; for (iDim = 0; iDim < 3; iDim++) ModVelocity_Inf += Velocity_Inf[iDim] * Velocity_Inf[iDim]; - + factor = 4.0*sqrt(2.0*Beta*R_Plane) / (Gamma*Pressure_Inf*Mach*Mach); - + if (rank == MASTER_NODE) cout << endl << "Writing Equivalent Area files."; #ifndef HAVE_MPI - + /*--- Compute the total number of points on the near-field ---*/ - + nVertex_NearField = 0; for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) if (config->GetMarker_All_KindBC(iMarker) == NEARFIELD_BOUNDARY) @@ -9476,16 +9476,16 @@ void COutputLegacy::SpecialOutput_SonicBoom(CSolver *solver, CGeometry *geometry iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); Face_Normal = geometry->vertex[iMarker][iVertex]->GetNormal(); Coord = geometry->node[iPoint]->GetCoord(); - + /*--- Using Face_Normal(z), and Coord(z) we identify only a surface, note that there are 2 NEARFIELD_BOUNDARY surfaces ---*/ - + if ((Face_Normal[nDim-1] > 0.0) && (Coord[nDim-1] < 0.0)) nVertex_NearField ++; } - + /*--- Create an array with all the coordinates, points, pressures, face area, equivalent area, and nearfield weight ---*/ - + Xcoord = new su2double[nVertex_NearField]; Ycoord = new su2double[nVertex_NearField]; Zcoord = new su2double[nVertex_NearField]; @@ -9498,9 +9498,9 @@ void COutputLegacy::SpecialOutput_SonicBoom(CSolver *solver, CGeometry *geometry TargetArea = new su2double[nVertex_NearField]; NearFieldWeight = new su2double[nVertex_NearField]; Weight = new su2double[nVertex_NearField]; - + /*--- Copy the boundary information to an array ---*/ - + nVertex_NearField = 0; for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) if (config->GetMarker_All_KindBC(iMarker) == NEARFIELD_BOUNDARY) @@ -9508,65 +9508,65 @@ void COutputLegacy::SpecialOutput_SonicBoom(CSolver *solver, CGeometry *geometry iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); Face_Normal = geometry->vertex[iMarker][iVertex]->GetNormal(); Coord = geometry->node[iPoint]->GetCoord(); - + if ((Face_Normal[nDim-1] > 0.0) && (Coord[nDim-1] < 0.0)) { - + IdPoint[nVertex_NearField] = iPoint; Xcoord[nVertex_NearField] = geometry->node[iPoint]->GetCoord(0); Ycoord[nVertex_NearField] = geometry->node[iPoint]->GetCoord(1); - + if (nDim ==2) { AzimuthalAngle[nVertex_NearField] = 0; } - + if (nDim == 3) { Zcoord[nVertex_NearField] = geometry->node[iPoint]->GetCoord(2); - + /*--- Rotate the nearfield cylinder (AoA) only 3D ---*/ - + su2double YcoordRot = Ycoord[nVertex_NearField]; su2double ZcoordRot = Xcoord[nVertex_NearField]*sin(AoA) + Zcoord[nVertex_NearField]*cos(AoA); - + /*--- Compute the Azimuthal angle (resolution of degress in the Azimuthal angle)---*/ - + su2double AngleDouble; short AngleInt; AngleDouble = fabs(atan(-YcoordRot/ZcoordRot)*180.0/PI_NUMBER); - + /*--- Fix an azimuthal line due to misalignments of the near-field ---*/ - + su2double FixAzimuthalLine = config->GetFixAzimuthalLine(); - + if ((AngleDouble >= FixAzimuthalLine - 0.1) && (AngleDouble <= FixAzimuthalLine + 0.1)) AngleDouble = FixAzimuthalLine - 0.1; - + AngleInt = SU2_TYPE::Short(floor(AngleDouble + 0.5)); if (AngleInt >= 0) AzimuthalAngle[nVertex_NearField] = AngleInt; else AzimuthalAngle[nVertex_NearField] = 180 + AngleInt; } - + if (AzimuthalAngle[nVertex_NearField] <= 60) { Pressure[nVertex_NearField] = solver->GetNodes()->GetPressure(iPoint); FaceArea[nVertex_NearField] = fabs(Face_Normal[nDim-1]); nVertex_NearField ++; } - + } } - + #else - + int nProcessor; SU2_MPI::Comm_size(MPI_COMM_WORLD, &nProcessor); - + unsigned long nLocalVertex_NearField = 0, MaxLocalVertex_NearField = 0; int iProcessor; - + unsigned long *Buffer_Receive_nVertex = NULL; if (rank == MASTER_NODE) { Buffer_Receive_nVertex = new unsigned long [nProcessor]; } - + /*--- Compute the total number of points of the near-field ghost nodes ---*/ - + nLocalVertex_NearField = 0; for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) if (config->GetMarker_All_KindBC(iMarker) == NEARFIELD_BOUNDARY) @@ -9574,36 +9574,36 @@ void COutputLegacy::SpecialOutput_SonicBoom(CSolver *solver, CGeometry *geometry iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); Face_Normal = geometry->vertex[iMarker][iVertex]->GetNormal(); Coord = geometry->node[iPoint]->GetCoord(); - + if (geometry->node[iPoint]->GetDomain()) if ((Face_Normal[nDim-1] > 0.0) && (Coord[nDim-1] < 0.0)) nLocalVertex_NearField ++; } - + unsigned long *Buffer_Send_nVertex = new unsigned long [1]; Buffer_Send_nVertex[0] = nLocalVertex_NearField; - + /*--- Send Near-Field vertex information --*/ - + SU2_MPI::Allreduce(&nLocalVertex_NearField, &nVertex_NearField, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); SU2_MPI::Allreduce(&nLocalVertex_NearField, &MaxLocalVertex_NearField, 1, MPI_UNSIGNED_LONG, MPI_MAX, MPI_COMM_WORLD); SU2_MPI::Gather(Buffer_Send_nVertex, 1, MPI_UNSIGNED_LONG, Buffer_Receive_nVertex, 1, MPI_UNSIGNED_LONG, MASTER_NODE, MPI_COMM_WORLD); delete [] Buffer_Send_nVertex; - + su2double *Buffer_Send_Xcoord = new su2double[MaxLocalVertex_NearField]; su2double *Buffer_Send_Ycoord = new su2double[MaxLocalVertex_NearField]; su2double *Buffer_Send_Zcoord = new su2double[MaxLocalVertex_NearField]; unsigned long *Buffer_Send_IdPoint = new unsigned long [MaxLocalVertex_NearField]; su2double *Buffer_Send_Pressure = new su2double [MaxLocalVertex_NearField]; su2double *Buffer_Send_FaceArea = new su2double[MaxLocalVertex_NearField]; - + su2double *Buffer_Receive_Xcoord = NULL; su2double *Buffer_Receive_Ycoord = NULL; su2double *Buffer_Receive_Zcoord = NULL; unsigned long *Buffer_Receive_IdPoint = NULL; su2double *Buffer_Receive_Pressure = NULL; su2double *Buffer_Receive_FaceArea = NULL; - + if (rank == MASTER_NODE) { Buffer_Receive_Xcoord = new su2double[nProcessor*MaxLocalVertex_NearField]; Buffer_Receive_Ycoord = new su2double[nProcessor*MaxLocalVertex_NearField]; @@ -9612,22 +9612,22 @@ void COutputLegacy::SpecialOutput_SonicBoom(CSolver *solver, CGeometry *geometry Buffer_Receive_Pressure = new su2double[nProcessor*MaxLocalVertex_NearField]; Buffer_Receive_FaceArea = new su2double[nProcessor*MaxLocalVertex_NearField]; } - + unsigned long nBuffer_Xcoord = MaxLocalVertex_NearField; unsigned long nBuffer_Ycoord = MaxLocalVertex_NearField; unsigned long nBuffer_Zcoord = MaxLocalVertex_NearField; unsigned long nBuffer_IdPoint = MaxLocalVertex_NearField; unsigned long nBuffer_Pressure = MaxLocalVertex_NearField; unsigned long nBuffer_FaceArea = MaxLocalVertex_NearField; - + for (iVertex = 0; iVertex < MaxLocalVertex_NearField; iVertex++) { Buffer_Send_IdPoint[iVertex] = 0; Buffer_Send_Pressure[iVertex] = 0.0; Buffer_Send_FaceArea[iVertex] = 0.0; Buffer_Send_Xcoord[iVertex] = 0.0; Buffer_Send_Ycoord[iVertex] = 0.0; Buffer_Send_Zcoord[iVertex] = 0.0; } - + /*--- Copy coordinates, index points, and pressures to the auxiliar vector --*/ - + nLocalVertex_NearField = 0; for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) if (config->GetMarker_All_KindBC(iMarker) == NEARFIELD_BOUNDARY) @@ -9635,7 +9635,7 @@ void COutputLegacy::SpecialOutput_SonicBoom(CSolver *solver, CGeometry *geometry iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); Face_Normal = geometry->vertex[iMarker][iVertex]->GetNormal(); Coord = geometry->node[iPoint]->GetCoord(); - + if (geometry->node[iPoint]->GetDomain()) if ((Face_Normal[nDim-1] > 0.0) && (Coord[nDim-1] < 0.0)) { Buffer_Send_IdPoint[nLocalVertex_NearField] = iPoint; @@ -9647,9 +9647,9 @@ void COutputLegacy::SpecialOutput_SonicBoom(CSolver *solver, CGeometry *geometry nLocalVertex_NearField++; } } - + /*--- Send all the information --*/ - + SU2_MPI::Gather(Buffer_Send_Xcoord, nBuffer_Xcoord, MPI_DOUBLE, Buffer_Receive_Xcoord, nBuffer_Xcoord, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); SU2_MPI::Gather(Buffer_Send_Ycoord, nBuffer_Ycoord, MPI_DOUBLE, Buffer_Receive_Ycoord, nBuffer_Ycoord, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); SU2_MPI::Gather(Buffer_Send_Zcoord, nBuffer_Zcoord, MPI_DOUBLE, Buffer_Receive_Zcoord, nBuffer_Zcoord, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); @@ -9662,9 +9662,9 @@ void COutputLegacy::SpecialOutput_SonicBoom(CSolver *solver, CGeometry *geometry delete [] Buffer_Send_IdPoint; delete [] Buffer_Send_Pressure; delete [] Buffer_Send_FaceArea; - + if (rank == MASTER_NODE) { - + Xcoord = new su2double[nVertex_NearField]; Ycoord = new su2double[nVertex_NearField]; Zcoord = new su2double[nVertex_NearField]; @@ -9677,43 +9677,43 @@ void COutputLegacy::SpecialOutput_SonicBoom(CSolver *solver, CGeometry *geometry TargetArea = new su2double[nVertex_NearField]; NearFieldWeight = new su2double[nVertex_NearField]; Weight = new su2double[nVertex_NearField]; - + nVertex_NearField = 0; for (iProcessor = 0; iProcessor < nProcessor; iProcessor++) for (iVertex = 0; iVertex < Buffer_Receive_nVertex[iProcessor]; iVertex++) { Xcoord[nVertex_NearField] = Buffer_Receive_Xcoord[iProcessor*MaxLocalVertex_NearField+iVertex]; Ycoord[nVertex_NearField] = Buffer_Receive_Ycoord[iProcessor*MaxLocalVertex_NearField+iVertex]; - + if (nDim == 2) { AzimuthalAngle[nVertex_NearField] = 0; } - + if (nDim == 3) { Zcoord[nVertex_NearField] = Buffer_Receive_Zcoord[iProcessor*MaxLocalVertex_NearField+iVertex]; - + /*--- Rotate the nearfield cylinder ---*/ - + su2double YcoordRot = Ycoord[nVertex_NearField]; su2double ZcoordRot = Xcoord[nVertex_NearField]*sin(AoA) + Zcoord[nVertex_NearField]*cos(AoA); - + /*--- Compute the Azimuthal angle ---*/ - + su2double AngleDouble; short AngleInt; AngleDouble = fabs(atan(-YcoordRot/ZcoordRot)*180.0/PI_NUMBER); - + /*--- Fix an azimuthal line due to misalignments of the near-field ---*/ - + su2double FixAzimuthalLine = config->GetFixAzimuthalLine(); - + if ((AngleDouble >= FixAzimuthalLine - 0.1) && (AngleDouble <= FixAzimuthalLine + 0.1)) AngleDouble = FixAzimuthalLine - 0.1; - + AngleInt = SU2_TYPE::Short(floor(AngleDouble + 0.5)); - + if (AngleInt >= 0) AzimuthalAngle[nVertex_NearField] = AngleInt; else AzimuthalAngle[nVertex_NearField] = 180 + AngleInt; } - + if (AzimuthalAngle[nVertex_NearField] <= 60) { IdPoint[nVertex_NearField] = Buffer_Receive_IdPoint[iProcessor*MaxLocalVertex_NearField+iVertex]; Pressure[nVertex_NearField] = Buffer_Receive_Pressure[iProcessor*MaxLocalVertex_NearField+iVertex]; @@ -9721,36 +9721,36 @@ void COutputLegacy::SpecialOutput_SonicBoom(CSolver *solver, CGeometry *geometry IdDomain[nVertex_NearField] = iProcessor; nVertex_NearField++; } - + } - + delete [] Buffer_Receive_nVertex; - + delete [] Buffer_Receive_Xcoord; delete [] Buffer_Receive_Ycoord; delete [] Buffer_Receive_Zcoord; delete [] Buffer_Receive_IdPoint; delete [] Buffer_Receive_Pressure; delete [] Buffer_Receive_FaceArea; - + } - + #endif - + if (rank == MASTER_NODE) { - + vector PhiAngleList; vector::iterator IterPhiAngleList; - + for (iVertex = 0; iVertex < nVertex_NearField; iVertex++) PhiAngleList.push_back(AzimuthalAngle[iVertex]); - + sort( PhiAngleList.begin(), PhiAngleList.end()); IterPhiAngleList = unique( PhiAngleList.begin(), PhiAngleList.end()); PhiAngleList.resize( IterPhiAngleList - PhiAngleList.begin() ); - + /*--- Create vectors and distribute the values among the different PhiAngle queues ---*/ - + vector > Xcoord_PhiAngle; Xcoord_PhiAngle.resize(PhiAngleList.size()); vector > Ycoord_PhiAngle; Ycoord_PhiAngle.resize(PhiAngleList.size()); vector > Zcoord_PhiAngle; Zcoord_PhiAngle.resize(PhiAngleList.size()); @@ -9762,9 +9762,9 @@ void COutputLegacy::SpecialOutput_SonicBoom(CSolver *solver, CGeometry *geometry vector > TargetArea_PhiAngle; TargetArea_PhiAngle.resize(PhiAngleList.size()); vector > NearFieldWeight_PhiAngle; NearFieldWeight_PhiAngle.resize(PhiAngleList.size()); vector > Weight_PhiAngle; Weight_PhiAngle.resize(PhiAngleList.size()); - + /*--- Distribute the values among the different PhiAngles ---*/ - + for (iVertex = 0; iVertex < nVertex_NearField; iVertex++) for (iPhiAngle = 0; iPhiAngle < PhiAngleList.size(); iPhiAngle++) if (AzimuthalAngle[iVertex] == PhiAngleList[iPhiAngle]) { @@ -9780,9 +9780,9 @@ void COutputLegacy::SpecialOutput_SonicBoom(CSolver *solver, CGeometry *geometry NearFieldWeight_PhiAngle[iPhiAngle].push_back(NearFieldWeight[iVertex]); Weight_PhiAngle[iPhiAngle].push_back(Weight[iVertex]); } - + /*--- Order the arrays (x Coordinate, Pressure, Point, and Domain) ---*/ - + for (iPhiAngle = 0; iPhiAngle < PhiAngleList.size(); iPhiAngle++) for (iVertex = 0; iVertex < Xcoord_PhiAngle[iPhiAngle].size(); iVertex++) for (jVertex = 0; jVertex < Xcoord_PhiAngle[iPhiAngle].size() - 1 - iVertex; jVertex++) @@ -9795,91 +9795,91 @@ void COutputLegacy::SpecialOutput_SonicBoom(CSolver *solver, CGeometry *geometry auxPoint = IdPoint_PhiAngle[iPhiAngle][jVertex]; IdPoint_PhiAngle[iPhiAngle][jVertex] = IdPoint_PhiAngle[iPhiAngle][jVertex+1]; IdPoint_PhiAngle[iPhiAngle][jVertex+1] = auxPoint; auxDomain = IdDomain_PhiAngle[iPhiAngle][jVertex]; IdDomain_PhiAngle[iPhiAngle][jVertex] = IdDomain_PhiAngle[iPhiAngle][jVertex+1]; IdDomain_PhiAngle[iPhiAngle][jVertex+1] = auxDomain; } - - + + /*--- Check that all the azimuth lists have the same size ---*/ - + unsigned short nVertex = Xcoord_PhiAngle[0].size(); for (iPhiAngle = 0; iPhiAngle < PhiAngleList.size(); iPhiAngle++) { unsigned short nVertex_aux = Xcoord_PhiAngle[iPhiAngle].size(); if (nVertex_aux != nVertex) cout <<"Be careful!!! one azimuth list is shorter than the other"<< endl; nVertex = min(nVertex, nVertex_aux); } - + /*--- Compute equivalent area distribution at each azimuth angle ---*/ - + for (iPhiAngle = 0; iPhiAngle < PhiAngleList.size(); iPhiAngle++) { EquivArea_PhiAngle[iPhiAngle][0] = 0.0; for (iVertex = 1; iVertex < EquivArea_PhiAngle[iPhiAngle].size(); iVertex++) { EquivArea_PhiAngle[iPhiAngle][iVertex] = 0.0; - + Coord_i = Xcoord_PhiAngle[iPhiAngle][iVertex]*cos(AoA) - Zcoord_PhiAngle[iPhiAngle][iVertex]*sin(AoA); - + for (jVertex = 0; jVertex < iVertex-1; jVertex++) { - + Coord_j = Xcoord_PhiAngle[iPhiAngle][jVertex]*cos(AoA) - Zcoord_PhiAngle[iPhiAngle][jVertex]*sin(AoA); jp1Coord = Xcoord_PhiAngle[iPhiAngle][jVertex+1]*cos(AoA) - Zcoord_PhiAngle[iPhiAngle][jVertex+1]*sin(AoA); - + jFunction = factor*(Pressure_PhiAngle[iPhiAngle][jVertex] - Pressure_Inf)*sqrt(Coord_i-Coord_j); jp1Function = factor*(Pressure_PhiAngle[iPhiAngle][jVertex+1] - Pressure_Inf)*sqrt(Coord_i-jp1Coord); - + DeltaX = (jp1Coord-Coord_j); MeanFuntion = 0.5*(jp1Function + jFunction); EquivArea_PhiAngle[iPhiAngle][iVertex] += DeltaX * MeanFuntion; } } } - + /*--- Create a file with the equivalent area distribution at each azimuthal angle ---*/ - + NearFieldEA_file.precision(15); - + if (output) { - + NearFieldEA_file.open("Equivalent_Area.dat", ios::out); NearFieldEA_file << "TITLE = \"Equivalent Area evaluation at each azimuthal angle\"" << "\n"; - + if (config->GetSystemMeasurements() == US) NearFieldEA_file << "VARIABLES = \"Height (in) at r="<< R_Plane*12.0 << " in. (cyl. coord. system)\""; else NearFieldEA_file << "VARIABLES = \"Height (m) at r="<< R_Plane << " m. (cylindrical coordinate system)\""; - + for (iPhiAngle = 0; iPhiAngle < PhiAngleList.size(); iPhiAngle++) { if (config->GetSystemMeasurements() == US) NearFieldEA_file << ", \"Equivalent Area (ft2), F= " << PhiAngleList[iPhiAngle] << " deg.\""; else NearFieldEA_file << ", \"Equivalent Area (m2), F= " << PhiAngleList[iPhiAngle] << " deg.\""; } - + NearFieldEA_file << "\n"; for (iVertex = 0; iVertex < EquivArea_PhiAngle[0].size(); iVertex++) { - + su2double XcoordRot = Xcoord_PhiAngle[0][iVertex]*cos(AoA) - Zcoord_PhiAngle[0][iVertex]*sin(AoA); su2double XcoordRot_init = Xcoord_PhiAngle[0][0]*cos(AoA) - Zcoord_PhiAngle[0][0]*sin(AoA); - + if (config->GetSystemMeasurements() == US) NearFieldEA_file << scientific << (XcoordRot - XcoordRot_init) * 12.0; else NearFieldEA_file << scientific << (XcoordRot - XcoordRot_init); - + for (iPhiAngle = 0; iPhiAngle < PhiAngleList.size(); iPhiAngle++) { NearFieldEA_file << scientific << ", " << EquivArea_PhiAngle[iPhiAngle][iVertex]; } - + NearFieldEA_file << "\n"; - + } NearFieldEA_file.close(); - + } - + /*--- Read target equivalent area from the configuration file, this first implementation requires a complete table (same as the original EA table). so... no interpolation. ---*/ - + vector > TargetArea_PhiAngle_Trans; TargetEA_file.open("TargetEA.dat", ios::in); - + if (TargetEA_file.fail()) { /*--- Set the table to 0 ---*/ for (iPhiAngle = 0; iPhiAngle < PhiAngleList.size(); iPhiAngle++) @@ -9887,68 +9887,68 @@ void COutputLegacy::SpecialOutput_SonicBoom(CSolver *solver, CGeometry *geometry TargetArea_PhiAngle[iPhiAngle][iVertex] = 0.0; } else { - + /*--- skip header lines ---*/ - + string line; getline(TargetEA_file, line); getline(TargetEA_file, line); - + while (TargetEA_file) { - + string line; getline(TargetEA_file, line); istringstream is(line); vector row; unsigned short iter = 0; - + while (is.good()) { string token; getline(is, token,','); - + istringstream js(token); - + su2double data; js >> data; - + /*--- The first element in the table is the coordinate (in or m)---*/ - + if (iter != 0) row.push_back(data); iter++; - + } TargetArea_PhiAngle_Trans.push_back(row); } - + for (iPhiAngle = 0; iPhiAngle < PhiAngleList.size(); iPhiAngle++) for (iVertex = 0; iVertex < EquivArea_PhiAngle[iPhiAngle].size(); iVertex++) TargetArea_PhiAngle[iPhiAngle][iVertex] = TargetArea_PhiAngle_Trans[iVertex][iPhiAngle]; - + } - + /*--- Divide by the number of Phi angles in the nearfield ---*/ - + su2double PhiFactor = 1.0/su2double(PhiAngleList.size()); - + /*--- Evaluate the objective function ---*/ - + InverseDesign = 0; for (iPhiAngle = 0; iPhiAngle < PhiAngleList.size(); iPhiAngle++) for (iVertex = 0; iVertex < EquivArea_PhiAngle[iPhiAngle].size(); iVertex++) { Weight_PhiAngle[iPhiAngle][iVertex] = 1.0; Coord_i = Xcoord_PhiAngle[iPhiAngle][iVertex]; - + su2double Difference = EquivArea_PhiAngle[iPhiAngle][iVertex]-TargetArea_PhiAngle[iPhiAngle][iVertex]; su2double percentage = fabs(Difference)*100/fabs(TargetArea_PhiAngle[iPhiAngle][iVertex]); - + if ((percentage < 0.1) || (Coord_i < XCoordBegin_OF) || (Coord_i > XCoordEnd_OF)) Difference = 0.0; - + InverseDesign += EAScaleFactor*PhiFactor*Weight_PhiAngle[iPhiAngle][iVertex]*Difference*Difference; - + } - + /*--- Evaluate the weight of the nearfield pressure (adjoint input) ---*/ - + for (iPhiAngle = 0; iPhiAngle < PhiAngleList.size(); iPhiAngle++) for (iVertex = 0; iVertex < EquivArea_PhiAngle[iPhiAngle].size(); iVertex++) { Coord_i = Xcoord_PhiAngle[iPhiAngle][iVertex]; @@ -9956,64 +9956,64 @@ void COutputLegacy::SpecialOutput_SonicBoom(CSolver *solver, CGeometry *geometry for (jVertex = iVertex; jVertex < EquivArea_PhiAngle[iPhiAngle].size(); jVertex++) { Coord_j = Xcoord_PhiAngle[iPhiAngle][jVertex]; Weight_PhiAngle[iPhiAngle][iVertex] = 1.0; - + su2double Difference = EquivArea_PhiAngle[iPhiAngle][jVertex]-TargetArea_PhiAngle[iPhiAngle][jVertex]; su2double percentage = fabs(Difference)*100/fabs(TargetArea_PhiAngle[iPhiAngle][jVertex]); - + if ((percentage < 0.1) || (Coord_j < XCoordBegin_OF) || (Coord_j > XCoordEnd_OF)) Difference = 0.0; - + NearFieldWeight_PhiAngle[iPhiAngle][iVertex] += EAScaleFactor*PhiFactor*Weight_PhiAngle[iPhiAngle][iVertex]*2.0*Difference*factor*sqrt(Coord_j-Coord_i); } } - + /*--- Write the Nearfield pressure at each Azimuthal PhiAngle ---*/ - + EquivArea_file.precision(15); - + if (output) { - + EquivArea_file.open("nearfield_flow.dat", ios::out); EquivArea_file << "TITLE = \"Equivalent Area evaluation at each azimuthal angle\"" << "\n"; - + if (config->GetSystemMeasurements() == US) EquivArea_file << "VARIABLES = \"Height (in) at r="<< R_Plane*12.0 << " in. (cyl. coord. system)\",\"Equivalent Area (ft2)\",\"Target Equivalent Area (ft2)\",\"Cp\"" << "\n"; else EquivArea_file << "VARIABLES = \"Height (m) at r="<< R_Plane << " m. (cylindrical coordinate system)\",\"Equivalent Area (m2)\",\"Target Equivalent Area (m2)\",\"Cp\"" << "\n"; - + for (iPhiAngle = 0; iPhiAngle < PhiAngleList.size(); iPhiAngle++) { EquivArea_file << fixed << "ZONE T= \"F=" << PhiAngleList[iPhiAngle] << " deg.\"" << "\n"; for (iVertex = 0; iVertex < Xcoord_PhiAngle[iPhiAngle].size(); iVertex++) { - + su2double XcoordRot = Xcoord_PhiAngle[0][iVertex]*cos(AoA) - Zcoord_PhiAngle[0][iVertex]*sin(AoA); su2double XcoordRot_init = Xcoord_PhiAngle[0][0]*cos(AoA) - Zcoord_PhiAngle[0][0]*sin(AoA); - + if (config->GetSystemMeasurements() == US) EquivArea_file << scientific << (XcoordRot - XcoordRot_init) * 12.0; else EquivArea_file << scientific << (XcoordRot - XcoordRot_init); - + EquivArea_file << scientific << ", " << EquivArea_PhiAngle[iPhiAngle][iVertex] << ", " << TargetArea_PhiAngle[iPhiAngle][iVertex] << ", " << (Pressure_PhiAngle[iPhiAngle][iVertex]-Pressure_Inf)/Pressure_Inf << "\n"; } } - + EquivArea_file.close(); - + } - + /*--- Write Weight file for adjoint computation ---*/ - + FuncGrad_file.precision(15); - + if (output) { - + FuncGrad_file.open("WeightNF.dat", ios::out); - + FuncGrad_file << scientific << "-1.0"; for (iPhiAngle = 0; iPhiAngle < PhiAngleList.size(); iPhiAngle++) FuncGrad_file << scientific << "\t" << PhiAngleList[iPhiAngle]; FuncGrad_file << "\n"; - + for (iVertex = 0; iVertex < NearFieldWeight_PhiAngle[0].size(); iVertex++) { su2double XcoordRot = Xcoord_PhiAngle[0][iVertex]*cos(AoA) - Zcoord_PhiAngle[0][iVertex]*sin(AoA); FuncGrad_file << scientific << XcoordRot; @@ -10022,41 +10022,41 @@ void COutputLegacy::SpecialOutput_SonicBoom(CSolver *solver, CGeometry *geometry FuncGrad_file << "\n"; } FuncGrad_file.close(); - + } - + /*--- Delete structures ---*/ - + delete [] Xcoord; delete [] Ycoord; delete [] Zcoord; delete [] AzimuthalAngle; delete [] IdPoint; delete [] IdDomain; delete [] Pressure; delete [] FaceArea; delete [] EquivArea; delete [] TargetArea; delete [] NearFieldWeight; delete [] Weight; - + } - + #ifndef HAVE_MPI - + /*--- Store the value of the NearField coefficient ---*/ - + solver->SetTotal_CEquivArea(InverseDesign); - + #else - + /*--- Send the value of the NearField coefficient to all the processors ---*/ - + SU2_MPI::Bcast(&InverseDesign, 1, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); - + /*--- Store the value of the NearField coefficient ---*/ - + solver->SetTotal_CEquivArea(InverseDesign); - + #endif - + } void COutputLegacy::SpecialOutput_Distortion(CSolver *solver, CGeometry *geometry, CConfig *config, bool output) { - + unsigned short iMarker, iDim, iMarker_Analyze; unsigned long iPoint, iVertex; su2double xCoord = 0.0, yCoord = 0.0, zCoord = 0.0, Area = 0.0, *Vector, TotalArea = 0.0; @@ -10074,8 +10074,8 @@ void COutputLegacy::SpecialOutput_Distortion(CSolver *solver, CGeometry *geometr unsigned long Total_Index; unsigned short Theta_DC60 = 60, nStation_DC60 = 5; su2double PT_Mean, Mach_Mean, q_Mean, PT, q, *PT_Sector, PT_Sector_Min, DC60, *PT_Station, *PT_Station_Min, *Mach_Station, *Mach_Station_Min, IDR, IDC, IDC_Mach; - - + + bool Engine_HalfModel = config->GetEngine_HalfModel(); su2double SignFlip = 1.0; su2double Beta, Alpha; @@ -10098,11 +10098,11 @@ void COutputLegacy::SpecialOutput_Distortion(CSolver *solver, CGeometry *geometr if ((config->GetTabular_FileFormat() == TAB_CSV)) strcpy (cstr, "surface_analysis.vtk"); else strcpy (cstr, "surface_analysis.dat"); - + SurfFlow_file.precision(15); SurfFlow_file.open(cstr, ios::out); - + if ((config->GetTabular_FileFormat() == TAB_CSV)) { SurfFlow_file << "# vtk DataFile Version 3.0" << endl; SurfFlow_file << "vtk output" << endl; @@ -10112,9 +10112,9 @@ void COutputLegacy::SpecialOutput_Distortion(CSolver *solver, CGeometry *geometr SurfFlow_file <<"TITLE = \"Surface Analysis\"" <inf\", \"TT/TTinf\", \"P/Pinf\", \"T/Tinf\", \"vx/vinf\", \"vy/vinf\", \"vz/vinf\", \"a (deg)\", \"b (deg)\", \"Mach\", \"Filtered a (deg)\", \"Filtered b (deg)\", \"Filtered Mach\"" << endl; } - + } - + /*--- Loop over all the markers to analyze ---*/ for (iMarker_Analyze = 0; iMarker_Analyze < config->GetnMarker_Analyze(); iMarker_Analyze++) { @@ -10140,7 +10140,7 @@ void COutputLegacy::SpecialOutput_Distortion(CSolver *solver, CGeometry *geometr /*--- Communicate the number of local vertices on each partition to the master node ---*/ - + Buffer_Send_nVertex[0] = nLocalVertex_Surface; if (rank == MASTER_NODE) Buffer_Recv_nVertex = new unsigned long [nProcessor]; @@ -10165,36 +10165,36 @@ void COutputLegacy::SpecialOutput_Distortion(CSolver *solver, CGeometry *geometr su2double *Buffer_Send_PT = NULL, *Buffer_Recv_PT = NULL; Buffer_Send_PT = new su2double [MaxLocalVertex_Surface]; - + su2double *Buffer_Send_TT = NULL, *Buffer_Recv_TT = NULL; Buffer_Send_TT = new su2double [MaxLocalVertex_Surface]; - + su2double *Buffer_Send_P = NULL, *Buffer_Recv_P = NULL; Buffer_Send_P = new su2double [MaxLocalVertex_Surface]; - + su2double *Buffer_Send_T = NULL, *Buffer_Recv_T = NULL; Buffer_Send_T = new su2double [MaxLocalVertex_Surface]; - + su2double *Buffer_Send_Mach = NULL, *Buffer_Recv_Mach = NULL; Buffer_Send_Mach = new su2double [MaxLocalVertex_Surface]; - + su2double *Buffer_Send_Vel_x = NULL, *Buffer_Recv_Vel_x = NULL; Buffer_Send_Vel_x = new su2double [MaxLocalVertex_Surface]; - + su2double *Buffer_Send_Vel_y = NULL, *Buffer_Recv_Vel_y = NULL; Buffer_Send_Vel_y = new su2double [MaxLocalVertex_Surface]; - + su2double *Buffer_Send_Vel_z = NULL, *Buffer_Recv_Vel_z = NULL; if (nDim == 3) Buffer_Send_Vel_z = new su2double [MaxLocalVertex_Surface]; - + su2double *Buffer_Send_q = NULL, *Buffer_Recv_q = NULL; Buffer_Send_q = new su2double [MaxLocalVertex_Surface]; - + su2double *Buffer_Send_Area = NULL, *Buffer_Recv_Area = NULL; Buffer_Send_Area = new su2double [MaxLocalVertex_Surface]; - + /*--- Prepare the receive buffers on the master node only. ---*/ - + if (rank == MASTER_NODE) { Buffer_Recv_Coord_x = new su2double [nProcessor*MaxLocalVertex_Surface]; Buffer_Recv_Coord_y = new su2double [nProcessor*MaxLocalVertex_Surface]; @@ -10212,25 +10212,25 @@ void COutputLegacy::SpecialOutput_Distortion(CSolver *solver, CGeometry *geometr Buffer_Recv_q = new su2double [nProcessor*MaxLocalVertex_Surface]; Buffer_Recv_Area = new su2double [nProcessor*MaxLocalVertex_Surface]; } - + /*--- Loop over all vertices in this partition and load the data of the specified type into the buffer to be sent to the master node. ---*/ - + nVertex_Surface = 0; for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { string Marker_TagBound = config->GetMarker_All_TagBound(iMarker); if (Marker_TagBound == Analyze_TagBound) { - + for (iVertex = 0; iVertex < geometry->GetnVertex(iMarker); iVertex++) { iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); - + if (geometry->node[iPoint]->GetDomain()) { - + Buffer_Send_Coord_x[nVertex_Surface] = geometry->node[iPoint]->GetCoord(0); 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->GetNodes()->GetPressure(iPoint); Density = solver->GetNodes()->GetDensity(iPoint); Temperature = solver->GetNodes()->GetTemperature(iPoint); @@ -10238,61 +10238,61 @@ void COutputLegacy::SpecialOutput_Distortion(CSolver *solver, CGeometry *geometr Velocity2 = solver->GetNodes()->GetVelocity2(iPoint); Mach = sqrt(Velocity2)/SoundSpeed; Gamma = config->GetGamma(); - + Mach_Inf = config->GetMach(); Pressure_Inf = config->GetPressure_FreeStreamND(); Temperature_Inf = config->GetTemperature_FreeStreamND(); Velocity_Inf = sqrt(config->GetVelocity_FreeStreamND()[0]*config->GetVelocity_FreeStreamND()[0] + config->GetVelocity_FreeStreamND()[1]*config->GetVelocity_FreeStreamND()[1] + config->GetVelocity_FreeStreamND()[2]*config->GetVelocity_FreeStreamND()[2]); - + Buffer_Send_P[nVertex_Surface] = Pressure / Pressure_Inf; Buffer_Send_T[nVertex_Surface] = Temperature / Temperature_Inf; Buffer_Send_Mach[nVertex_Surface] = Mach; - + TotalPressure = Pressure * pow( 1.0 + Mach * Mach * 0.5 * (Gamma - 1.0), Gamma / (Gamma - 1.0)); TotalPressure_Inf = Pressure_Inf * pow( 1.0 + Mach_Inf * Mach_Inf * 0.5 * (Gamma - 1.0), Gamma / (Gamma - 1.0)); Buffer_Send_PT[nVertex_Surface] = TotalPressure / TotalPressure_Inf; - + TotalTemperature = Temperature * (1.0 + Mach * Mach * 0.5 * (Gamma - 1.0)); 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->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->GetNodes()->GetVelocity(iPoint,2) / Velocity_Inf; } - + Buffer_Send_q[nVertex_Surface] = 0.5*Density*Velocity2; - + Vector = geometry->vertex[iMarker][iVertex]->GetNormal(); Area = 0.0; for (iDim = 0; iDim < nDim; iDim++) { Area += Vector[iDim]*Vector[iDim]; } Area = sqrt(Area); Buffer_Send_Area[nVertex_Surface] = Area; - + /*--- If US system, the output should be in inches ---*/ - + if (config->GetSystemMeasurements() == US) { - + Buffer_Send_Coord_x[nVertex_Surface] *= 12.0; Buffer_Send_Coord_y[nVertex_Surface] *= 12.0; if (nDim == 3) Buffer_Send_Coord_z[nVertex_Surface] *= 12.0; Buffer_Send_Area[nVertex_Surface] *= 144.0; - + } - + nVertex_Surface++; - + } } break; } } - + /*--- Send the information to the master node ---*/ - + #ifdef HAVE_MPI - + SU2_MPI::Gather(Buffer_Send_Coord_x, MaxLocalVertex_Surface, MPI_DOUBLE, Buffer_Recv_Coord_x, MaxLocalVertex_Surface, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); SU2_MPI::Gather(Buffer_Send_Coord_y, MaxLocalVertex_Surface, MPI_DOUBLE, Buffer_Recv_Coord_y, MaxLocalVertex_Surface, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); if (nDim == 3) SU2_MPI::Gather(Buffer_Send_Coord_z, MaxLocalVertex_Surface, MPI_DOUBLE, Buffer_Recv_Coord_z, MaxLocalVertex_Surface, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); @@ -10306,9 +10306,9 @@ void COutputLegacy::SpecialOutput_Distortion(CSolver *solver, CGeometry *geometr if (nDim == 3) SU2_MPI::Gather(Buffer_Send_Vel_z, MaxLocalVertex_Surface, MPI_DOUBLE, Buffer_Recv_Vel_z, MaxLocalVertex_Surface, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); SU2_MPI::Gather(Buffer_Send_q, MaxLocalVertex_Surface, MPI_DOUBLE, Buffer_Recv_q, MaxLocalVertex_Surface, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); SU2_MPI::Gather(Buffer_Send_Area, MaxLocalVertex_Surface, MPI_DOUBLE, Buffer_Recv_Area, MaxLocalVertex_Surface, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); - + #else - + for (iVertex = 0; iVertex < MaxLocalVertex_Surface; iVertex++) { Buffer_Recv_Coord_x[iVertex] = Buffer_Send_Coord_x[iVertex]; Buffer_Recv_Coord_y[iVertex] = Buffer_Send_Coord_y[iVertex]; @@ -10324,31 +10324,31 @@ void COutputLegacy::SpecialOutput_Distortion(CSolver *solver, CGeometry *geometr Buffer_Recv_q[iVertex] = Buffer_Send_q[iVertex]; Buffer_Recv_Area[iVertex] = Buffer_Send_Area[iVertex]; } - + #endif - + if (rank == MASTER_NODE) { - + /*--- Compute the location of the critical points of the distortion measure, and center of gravity ---*/ - + TotalArea = 0.0; xCoord_CG = 0.0; yCoord_CG = 0.0; zCoord_CG = 0.0; PT_Mean = 0.0; Mach_Mean = 0.0; q_Mean = 0.0; - + for (iProcessor = 0; iProcessor < nProcessor; iProcessor++) { for (iVertex = 0; iVertex < Buffer_Recv_nVertex[iProcessor]; iVertex++) { - + /*--- Current index position and global index ---*/ - + Total_Index = iProcessor*MaxLocalVertex_Surface+iVertex; - + /*--- Retrieve the merged data for this node ---*/ - + xCoord = Buffer_Recv_Coord_x[Total_Index]; yCoord = Buffer_Recv_Coord_y[Total_Index]; if (nDim == 3) zCoord = Buffer_Recv_Coord_z[Total_Index]; PT = Buffer_Recv_PT[Total_Index]; Mach = Buffer_Recv_Mach[Total_Index]; q = Buffer_Recv_q[Total_Index]; - + Area = Buffer_Recv_Area[Total_Index]; TotalArea += Area; xCoord_CG += xCoord*Area; @@ -10357,66 +10357,66 @@ void COutputLegacy::SpecialOutput_Distortion(CSolver *solver, CGeometry *geometr PT_Mean += PT*Area; Mach_Mean += PT*Area; q_Mean += q*Area; - + } } - + /*--- Evaluate the area averaged pressure and CG ---*/ - + xCoord_CG = xCoord_CG / TotalArea; yCoord_CG = yCoord_CG / TotalArea; zCoord_CG = zCoord_CG / TotalArea; PT_Mean /= TotalArea; Mach_Mean /= TotalArea; q_Mean /= TotalArea; - + /*--- If it is a half model, CGy = 0 ---*/ - + if (Engine_HalfModel) { yCoord_CG = 0.0; } - + /*--- Compute hub and tip radius ---*/ - + TipRadius = 1E-6; HubRadius = 1E6; for (iProcessor = 0; iProcessor < nProcessor; iProcessor++) { for (iVertex = 0; iVertex < Buffer_Recv_nVertex[iProcessor]; iVertex++) { - + /*--- Current index position and global index ---*/ - + Total_Index = iProcessor*MaxLocalVertex_Surface+iVertex; - + /*--- Retrieve the merged data for this node ---*/ - + xCoord = Buffer_Recv_Coord_x[Total_Index]; yCoord = Buffer_Recv_Coord_y[Total_Index]; if (nDim == 3) zCoord = Buffer_Recv_Coord_z[Total_Index]; - + if (nDim == 2) Distance = sqrt((xCoord_CG-xCoord)*(xCoord_CG-xCoord) + (yCoord_CG-yCoord)*(yCoord_CG-yCoord)); - + if (nDim == 3) Distance = sqrt((xCoord_CG-xCoord)*(xCoord_CG-xCoord) + (yCoord_CG-yCoord)*(yCoord_CG-yCoord) + (zCoord_CG-zCoord)*(zCoord_CG-zCoord)); - + if (Distance > TipRadius) TipRadius = Distance; if (Distance < HubRadius) HubRadius = Distance; - + } } - + if (HubRadius/TipRadius < 0.05) HubRadius = 0.0; - + /*--- Evaluate the DC60 parameter ---*/ - + Theta = Theta_DC60; nStation = nStation_DC60; - + nAngle = SU2_TYPE::Int(360/float(Theta)); r = new su2double [nStation+1]; - + /*--- Allocate memory ---*/ - + PT_Sector = new su2double [nAngle]; ProbeArray = new su2double ** [nAngle]; for (iAngle = 0; iAngle < nAngle; iAngle++) { @@ -10425,91 +10425,91 @@ void COutputLegacy::SpecialOutput_Distortion(CSolver *solver, CGeometry *geometr ProbeArray[iAngle][iStation] = new su2double [5]; } } - + /*--- Define the radius for each probe ---*/ - + r[0] = HubRadius; r[nStation] = TipRadius; for (iStation = 1; iStation < nStation; iStation++) { r[iStation] = sqrt( r[iStation-1]*r[iStation-1] + (r[nStation]*r[nStation] - r[0]*r[0])/float(nStation) ); } - + /*--- Define the probe rack ---*/ - + UpVector[0] = 0.0; UpVector[1] = 0.0; UpVector[2] = 1.0; - + for (iAngle = 0; iAngle < nAngle; iAngle++) { - + radians = -iAngle*Theta*2.0*PI_NUMBER/360; RotatedVector[0] = UpVector[0]; RotatedVector[1] = UpVector[1] * cos(radians) - UpVector[2] * sin(radians); RotatedVector[2] = UpVector[1] * sin(radians) + UpVector[2] * cos(radians); - + for (iStation = 1; iStation <= nStation; iStation++) { ProbeArray[iAngle][iStation-1][0] = xCoord_CG+RotatedVector[0]*sqrt(0.5*(r[iStation]*r[iStation]+r[iStation-1]*r[iStation-1])); ProbeArray[iAngle][iStation-1][1] = yCoord_CG+RotatedVector[1]*sqrt(0.5*(r[iStation]*r[iStation]+r[iStation-1]*r[iStation-1])); ProbeArray[iAngle][iStation-1][2] = zCoord_CG+RotatedVector[2]*sqrt(0.5*(r[iStation]*r[iStation]+r[iStation-1]*r[iStation-1])); } - + } - + /*--- Compute the Total pressure at each probe, closes grid point to the location ---*/ - + for (iAngle = 0; iAngle < nAngle; iAngle++) { - + for (iStation = 0; iStation < nStation; iStation++) { xCoord_ = ProbeArray[iAngle][iStation][0]; yCoord_ = ProbeArray[iAngle][iStation][1]; zCoord_ = ProbeArray[iAngle][iStation][2]; - + MinDistance = 1E6; - + for (iProcessor = 0; iProcessor < nProcessor; iProcessor++) { for (iVertex = 0; iVertex < Buffer_Recv_nVertex[iProcessor]; iVertex++) { - + Total_Index = iProcessor*MaxLocalVertex_Surface+iVertex; xCoord = Buffer_Recv_Coord_x[Total_Index]; yCoord = Buffer_Recv_Coord_y[Total_Index]; if (nDim == 3) zCoord = Buffer_Recv_Coord_z[Total_Index]; - + dx = (xCoord_ - xCoord); dy = (yCoord_ - yCoord); if (nDim == 3) dz = (zCoord_ - zCoord); - + Distance = dx*dx + dy*dy; if (nDim == 3) Distance += dz*dz; Distance = sqrt(Distance); - + if (Engine_HalfModel) { - + yCoord = -yCoord; - + dx_ = (xCoord_ - xCoord); dy_ = (yCoord_ - yCoord); if (nDim == 3) dz_ = (zCoord_ - zCoord); - + Distance_Mirror = dx_*dx_ + dy_*dy_; if (nDim == 3) Distance_Mirror += dz_*dz_; Distance_Mirror = sqrt(Distance_Mirror); - + if (Distance_Mirror < Distance) { Distance = Distance_Mirror; dx = dx_; dy = dy_; if (nDim == 3) dz = dz_; } - + } - + if (Distance <= MinDistance) { MinDistance = Distance; ProbeArray[iAngle][iStation][3] = Buffer_Recv_PT[Total_Index]; ProbeArray[iAngle][iStation][4] = Buffer_Recv_q[Total_Index]; } - + } } - + } - + } - + /*--- Evaluate the average pressure at each sector, fan face and dynamic pressure ---*/ - + PT_Mean = 0.0; q_Mean = 0.0; for (iAngle = 0; iAngle < nAngle; iAngle++) { PT_Sector[iAngle] = 0.0; @@ -10519,50 +10519,50 @@ void COutputLegacy::SpecialOutput_Distortion(CSolver *solver, CGeometry *geometr q_Mean += ProbeArray[iAngle][iStation][4]/float(nStation*nAngle); } } - + /*--- Compute the min value of the averaged pressure at each sector ---*/ - + PT_Sector_Min = PT_Sector[0]; for (iAngle = 1; iAngle < nAngle; iAngle++) { if (PT_Sector[iAngle] <= PT_Sector_Min) PT_Sector_Min = PT_Sector[iAngle]; } - + /*--- Set the value of the distortion, it only works for one surface ---*/ - + Mach_Inf = config->GetMach(); Gamma = config->GetGamma(); TotalPressure_Inf = config->GetPressure_FreeStreamND() * pow( 1.0 + Mach_Inf * Mach_Inf * 0.5 * (Gamma - 1.0), Gamma / (Gamma - 1.0)); - + if (q_Mean != 0.0) DC60 = ((PT_Mean - PT_Sector_Min)*TotalPressure_Inf)/q_Mean; else DC60 = 0.0; - + config->SetSurface_DC60(iMarker_Analyze, DC60); - + solver->SetTotal_DC60(DC60); - + /*--- Deallocate the memory ---*/ - + delete[] r; - + delete [] PT_Sector; - + for (iAngle = 0; iAngle < nAngle; iAngle++) { for (iStation = 0; iStation < nStation; iStation++) { delete[] ProbeArray[iAngle][iStation]; } } delete[] ProbeArray; - - + + /*--- Evaluate the IDC, and IDR parameters ---*/ - + nStation = SU2_TYPE::Int(config->GetDistortionRack()[0]); Theta = SU2_TYPE::Int(config->GetDistortionRack()[1]); nAngle = SU2_TYPE::Int(360/float(Theta)); - + /*--- Allocate memory ---*/ - + r = new su2double [nStation+1]; ProbeArray = new su2double ** [nAngle]; for (iAngle = 0; iAngle < nAngle; iAngle++) { @@ -10571,92 +10571,92 @@ void COutputLegacy::SpecialOutput_Distortion(CSolver *solver, CGeometry *geometr ProbeArray[iAngle][iStation] = new su2double [4]; } } - + /*--- Define the radius for each probe ---*/ - + r[0] = HubRadius; r[nStation] = TipRadius; for (iStation = 1; iStation < nStation; iStation++) { r[iStation] = sqrt( r[iStation-1]*r[iStation-1] + (r[nStation]*r[nStation] - r[0]*r[0])/float(nStation) ); } - + /*--- Define the probe rack ---*/ - + UpVector[0] = 0.0; UpVector[1] = 0.0; UpVector[2] = 1.0; - + for (iAngle = 0; iAngle < nAngle; iAngle++) { - + radians = -iAngle*Theta*2.0*PI_NUMBER/360; RotatedVector[0] = UpVector[0]; RotatedVector[1] = UpVector[1] * cos(radians) - UpVector[2] * sin(radians); RotatedVector[2] = UpVector[1] * sin(radians) + UpVector[2] * cos(radians); - + for (iStation = 1; iStation <= nStation; iStation++) { ProbeArray[iAngle][iStation-1][0] = xCoord_CG+RotatedVector[0]*sqrt(0.5*(r[iStation]*r[iStation]+r[iStation-1]*r[iStation-1])); ProbeArray[iAngle][iStation-1][1] = yCoord_CG+RotatedVector[1]*sqrt(0.5*(r[iStation]*r[iStation]+r[iStation-1]*r[iStation-1])); ProbeArray[iAngle][iStation-1][2] = zCoord_CG+RotatedVector[2]*sqrt(0.5*(r[iStation]*r[iStation]+r[iStation-1]*r[iStation-1])); } - + } - + /*--- Compute the Total pressure at each probe, closes grid point to the location ---*/ - + for (iAngle = 0; iAngle < nAngle; iAngle++) { for (iStation = 0; iStation < nStation; iStation++) { xCoord_ = ProbeArray[iAngle][iStation][0]; yCoord_ = ProbeArray[iAngle][iStation][1]; zCoord_ = ProbeArray[iAngle][iStation][2]; - + MinDistance = 1E6; - + for (iProcessor = 0; iProcessor < nProcessor; iProcessor++) { for (iVertex = 0; iVertex < Buffer_Recv_nVertex[iProcessor]; iVertex++) { - + Total_Index = iProcessor*MaxLocalVertex_Surface+iVertex; xCoord = Buffer_Recv_Coord_x[Total_Index]; yCoord = Buffer_Recv_Coord_y[Total_Index]; if (nDim == 3) zCoord = Buffer_Recv_Coord_z[Total_Index]; - + dx = (xCoord_ - xCoord); dy = (yCoord_ - yCoord); if (nDim == 3) dz = (zCoord_ - zCoord); - + Distance = dx*dx + dy*dy; if (nDim == 3) Distance += dz*dz; Distance = sqrt(Distance); - + if (Engine_HalfModel) { - + yCoord = -yCoord; - + dx_ = (xCoord_ - xCoord); dy_ = (yCoord_ - yCoord); if (nDim == 3) dz_ = (zCoord_ - zCoord); - + Distance_Mirror = dx_*dx_ + dy_*dy_; if (nDim == 3) Distance_Mirror += dz_*dz_; Distance_Mirror = sqrt(Distance_Mirror); - + if (Distance_Mirror < Distance) { Distance = Distance_Mirror; dx = dx_; dy = dy_; if (nDim == 3) dz = dz_; } - + } - + if (Distance <= MinDistance) { MinDistance = Distance; ProbeArray[iAngle][iStation][3] = Buffer_Recv_PT[Total_Index]; } - + } } - + } - + } - + /*--- Evaluate the average and min. pressure at each station/radius and fan ---*/ - + PT_Station = new su2double [nStation]; PT_Station_Min = new su2double [nStation]; - + PT_Mean = 0.0; for (iStation = 0; iStation < nStation; iStation++) { PT_Station[iStation] = 0.0; @@ -10668,97 +10668,97 @@ void COutputLegacy::SpecialOutput_Distortion(CSolver *solver, CGeometry *geometr PT_Mean += ProbeArray[iAngle][iStation][3]/float(nStation*nAngle); } } - + /*--- Set the value of the distortion, it only works for one surface ---*/ - + IDC = 0.0; for (iStation = 0; iStation < nStation-1; iStation++) { IDC = max (IDC, 0.5*((PT_Station[iStation] - PT_Station_Min[iStation])/PT_Mean + (PT_Station[iStation+1] - PT_Station_Min[iStation+1])/PT_Mean) ); - + } - + config->SetSurface_IDC(iMarker_Analyze, IDC); solver->SetTotal_IDC(IDC); - + IDR = 0.0; for (iStation = 0; iStation < nStation; iStation++) { IDR = max (IDR, (PT_Mean-PT_Station[iStation])/PT_Mean); } - + config->SetSurface_IDR(iMarker_Analyze, IDR); - + solver->SetTotal_IDR(IDR); - + /*--- Release IDX parameters ---*/ - + delete [] PT_Station_Min; delete [] PT_Station; - + /*--- Evaluate the IDC Mach parameter ---*/ - + /*--- Compute the Mach number at each probe, closes grid point to the location ---*/ - + for (iAngle = 0; iAngle < nAngle; iAngle++) { for (iStation = 0; iStation < nStation; iStation++) { xCoord_ = ProbeArray[iAngle][iStation][0]; yCoord_ = ProbeArray[iAngle][iStation][1]; zCoord_ = ProbeArray[iAngle][iStation][2]; - + MinDistance = 1E6; - + for (iProcessor = 0; iProcessor < nProcessor; iProcessor++) { for (iVertex = 0; iVertex < Buffer_Recv_nVertex[iProcessor]; iVertex++) { - + Total_Index = iProcessor*MaxLocalVertex_Surface+iVertex; - + xCoord = Buffer_Recv_Coord_x[Total_Index]; yCoord = Buffer_Recv_Coord_y[Total_Index]; if (nDim == 3) zCoord = Buffer_Recv_Coord_z[Total_Index]; - + dx = (xCoord_ - xCoord); dy = (yCoord_ - yCoord); if (nDim == 3) dz = (zCoord_ - zCoord); - + Distance = dx*dx + dy*dy; if (nDim == 3) Distance += dz*dz; Distance = sqrt(Distance); - + if (Engine_HalfModel) { - + yCoord = -yCoord; - + dx_ = (xCoord_ - xCoord); dy_ = (yCoord_ - yCoord); if (nDim == 3) dz_ = (zCoord_ - zCoord); - + Distance_Mirror = dx_*dx_ + dy_*dy_; if (nDim == 3) Distance_Mirror += dz_*dz_; Distance_Mirror = sqrt(Distance_Mirror); - + if (Distance_Mirror < Distance) { Distance = Distance_Mirror; dx = dx_; dy = dy_; if (nDim == 3) dz = dz_; } - + } - + if (Distance <= MinDistance) { MinDistance = Distance; ProbeArray[iAngle][iStation][3] = Buffer_Recv_Mach[Total_Index]; } - + } } - + } - + } - + /*--- Evaluate the average and min. pressure at each station/radius and fan face ---*/ - + Mach_Station = new su2double [nStation]; Mach_Station_Min = new su2double [nStation]; - + Mach_Mean = 0.0; for (iStation = 0; iStation < nStation; iStation++) { Mach_Station[iStation] = 0.0; @@ -10770,26 +10770,26 @@ void COutputLegacy::SpecialOutput_Distortion(CSolver *solver, CGeometry *geometr Mach_Mean += ProbeArray[iAngle][iStation][3]/float(nStation*nAngle); } } - + /*--- Set the value of the distortion, it only works for one surface ---*/ - + IDC_Mach = 0.0; for (iStation = 0; iStation < nStation-1; iStation++) { if (Mach_Mean != 0) IDC_Mach = max (IDC_Mach, 0.5*((Mach_Station[iStation] - Mach_Station_Min[iStation])/Mach_Mean + (Mach_Station[iStation+1] - Mach_Station_Min[iStation+1])/Mach_Mean) ); - + } - + config->SetSurface_IDC_Mach(iMarker_Analyze, IDC_Mach); - + solver->SetTotal_IDC_Mach(IDC_Mach); - + delete [] Mach_Station_Min; delete [] Mach_Station; - + /*--- Release distortion parameters ---*/ - + delete[] r; for (iAngle = 0; iAngle < nAngle; iAngle++) { for (iStation = 0; iStation < nStation; iStation++) { @@ -10797,16 +10797,16 @@ void COutputLegacy::SpecialOutput_Distortion(CSolver *solver, CGeometry *geometr } } delete[] ProbeArray; - + /*--- Create the distortion plot ---*/ - + Theta = 10; nStation = 20; - + nAngle = SU2_TYPE::Int(360/float(Theta)); r = new su2double [nStation+1]; - + /*--- Allocate memory ---*/ - + ProbeArray = new su2double ** [nAngle]; for (iAngle = 0; iAngle < nAngle; iAngle++) { ProbeArray[iAngle] = new su2double * [nStation]; @@ -10814,82 +10814,82 @@ void COutputLegacy::SpecialOutput_Distortion(CSolver *solver, CGeometry *geometr ProbeArray[iAngle][iStation] = new su2double [11]; } } - + /*--- Define the radius for each probe ---*/ - + r[0] = HubRadius; r[nStation] = TipRadius; - + for (iStation = 1; iStation < nStation; iStation++) { r[iStation] = sqrt( r[iStation-1]*r[iStation-1] + (r[nStation]*r[nStation] - r[0]*r[0])/float(nStation) ); } - + /*--- Define the probe rack ---*/ - + UpVector[0] = 0.0; UpVector[1] = 0.0; UpVector[2] = 1.0; - + for (iAngle = 0; iAngle < nAngle; iAngle++) { - + radians = -iAngle*Theta*2.0*PI_NUMBER/360; RotatedVector[0] = UpVector[0]; RotatedVector[1] = UpVector[1] * cos(radians) - UpVector[2] * sin(radians); RotatedVector[2] = UpVector[1] * sin(radians) + UpVector[2] * cos(radians); - + for (iStation = 1; iStation <= nStation; iStation++) { ProbeArray[iAngle][iStation-1][0] = xCoord_CG+RotatedVector[0]*sqrt(0.5*(r[iStation]*r[iStation]+r[iStation-1]*r[iStation-1])); ProbeArray[iAngle][iStation-1][1] = yCoord_CG+RotatedVector[1]*sqrt(0.5*(r[iStation]*r[iStation]+r[iStation-1]*r[iStation-1])); ProbeArray[iAngle][iStation-1][2] = zCoord_CG+RotatedVector[2]*sqrt(0.5*(r[iStation]*r[iStation]+r[iStation-1]*r[iStation-1])); } - + } - + /*--- Compute the primitieve variables, closest grid point to the location + gradient ---*/ - + for (iAngle = 0; iAngle < nAngle; iAngle++) { for (iStation = 0; iStation < nStation; iStation++) { xCoord_ = ProbeArray[iAngle][iStation][0]; yCoord_ = ProbeArray[iAngle][iStation][1]; zCoord_ = ProbeArray[iAngle][iStation][2]; - + MinDistance = 1E6; - + for (iProcessor = 0; iProcessor < nProcessor; iProcessor++) { for (iVertex = 0; iVertex < Buffer_Recv_nVertex[iProcessor]; iVertex++) { - + Total_Index = iProcessor*MaxLocalVertex_Surface+iVertex; xCoord = Buffer_Recv_Coord_x[Total_Index]; yCoord = Buffer_Recv_Coord_y[Total_Index]; if (nDim == 3) zCoord = Buffer_Recv_Coord_z[Total_Index]; - + dx = (xCoord_ - xCoord); dy = (yCoord_ - yCoord); if (nDim == 3) dz = (zCoord_ - zCoord); - + Distance = dx*dx + dy*dy; if (nDim == 3) Distance += dz*dz; Distance = sqrt(Distance); - + SignFlip = 1.0; - + if (Engine_HalfModel) { - + yCoord = -yCoord; - + dx_ = (xCoord_ - xCoord); dy_ = (yCoord_ - yCoord); if (nDim == 3) dz_ = (zCoord_ - zCoord); - + Distance_Mirror = dx_*dx_ + dy_*dy_; if (nDim == 3) Distance_Mirror += dz_*dz_; Distance_Mirror = sqrt(Distance_Mirror); - + if (Distance_Mirror < Distance) { SignFlip = -1.0; Distance = Distance_Mirror; dx = dx_; dy = dy_; if (nDim == 3) dz = dz_; } - + } - - + + if (Distance <= MinDistance) { MinDistance = Distance; ProbeArray[iAngle][iStation][3] = Buffer_Recv_PT[Total_Index]; @@ -10901,16 +10901,16 @@ void COutputLegacy::SpecialOutput_Distortion(CSolver *solver, CGeometry *geometr ProbeArray[iAngle][iStation][9] = SignFlip * Buffer_Recv_Vel_y[Total_Index]; if (nDim == 3) ProbeArray[iAngle][iStation][10] = Buffer_Recv_Vel_z[Total_Index]; } - + } } - + } - + } - + /*--- Reverse in the Y direction to move the solution from 3D to 2D ---*/ - + yCoord_CG = -yCoord_CG; for (iAngle = 0; iAngle < nAngle; iAngle++) { for (iStation = 0; iStation < nStation; iStation++) { @@ -10918,11 +10918,11 @@ void COutputLegacy::SpecialOutput_Distortion(CSolver *solver, CGeometry *geometr ProbeArray[iAngle][iStation][1] = -ProbeArray[iAngle][iStation][1]; } } - + if (output) { - + if (config->GetTabular_FileFormat() == TAB_CSV) { - + SurfFlow_file << "\nDATASET UNSTRUCTURED_GRID" << endl; SurfFlow_file <<"POINTS " << nAngle*nStation << " float" << endl; for (iAngle = 0; iAngle < nAngle; iAngle++) { @@ -10930,7 +10930,7 @@ void COutputLegacy::SpecialOutput_Distortion(CSolver *solver, CGeometry *geometr SurfFlow_file << ProbeArray[iAngle][iStation][1]-yCoord_CG << " " << ProbeArray[iAngle][iStation][2]-zCoord_CG << " 0.0 " <<" "; } } - + SurfFlow_file <<"\nCELLS " << nAngle*(nStation-1) <<" "<< nAngle*(nStation-1)*5 << endl; for (iAngle = 0; iAngle < nAngle; iAngle++) { for (iStation = 0; iStation < nStation-1; iStation++) { @@ -10939,81 +10939,81 @@ void COutputLegacy::SpecialOutput_Distortion(CSolver *solver, CGeometry *geometr SurfFlow_file << "4 " << a <<" "<< b <<" "<< c <<" "<< d <<" "; } } - + SurfFlow_file <<"\nCELL_TYPES " << nAngle*(nStation-1) << endl; for (iAngle = 0; iAngle < nAngle; iAngle++) { for (iStation = 0; iStation < nStation-1; iStation++) { SurfFlow_file << "9 " ; } } - + SurfFlow_file <<"\nPOINT_DATA " << nAngle*nStation << endl; SurfFlow_file <<"SCALARS PT/PT_inf float" << endl; SurfFlow_file <<"LOOKUP_TABLE default" << endl; - + for (iAngle = 0; iAngle < nAngle; iAngle++) { for (iStation = 0; iStation < nStation; iStation++) { SurfFlow_file << ProbeArray[iAngle][iStation][3] << " "; } } - + SurfFlow_file <<"SCALARS TT/TT_inf float" << endl; SurfFlow_file <<"LOOKUP_TABLE default" << endl; - + for (iAngle = 0; iAngle < nAngle; iAngle++) { for (iStation = 0; iStation < nStation; iStation++) { SurfFlow_file << ProbeArray[iAngle][iStation][4] << " "; } } - + SurfFlow_file <<"SCALARS Alpha float" << endl; SurfFlow_file <<"LOOKUP_TABLE default" << endl; - + for (iAngle = 0; iAngle < nAngle; iAngle++) { for (iStation = 0; iStation < nStation; iStation++) { Alpha = atan(ProbeArray[iAngle][iStation][10]/ProbeArray[iAngle][iStation][8])*360.0/(2.0*PI_NUMBER); SurfFlow_file << Alpha << " "; } } - + SurfFlow_file <<"SCALARS Beta float" << endl; SurfFlow_file <<"LOOKUP_TABLE default" << endl; - + for (iAngle = 0; iAngle < nAngle; iAngle++) { for (iStation = 0; iStation < nStation; iStation++) { Beta = atan(ProbeArray[iAngle][iStation][9]/ProbeArray[iAngle][iStation][8])*360.0/(2.0*PI_NUMBER); SurfFlow_file << Beta << " "; } } - + SurfFlow_file <<"SCALARS Mach float" << endl; SurfFlow_file <<"LOOKUP_TABLE default" << endl; - + for (iAngle = 0; iAngle < nAngle; iAngle++) { for (iStation = 0; iStation < nStation; iStation++) { SurfFlow_file << ProbeArray[iAngle][iStation][7] << " "; } } - + SurfFlow_file <<"VECTORS Velocity float" << endl; - + for (iAngle = 0; iAngle < nAngle; iAngle++) { for (iStation = 0; iStation < nStation; iStation++) { SurfFlow_file << ProbeArray[iAngle][iStation][8] << " " << ProbeArray[iAngle][iStation][9] << " " << ProbeArray[iAngle][iStation][10] << " "; } } - + } else { - + SurfFlow_file <<"ZONE T= \"" << Analyze_TagBound <<"\", NODES=" << nAngle*nStation << " , ELEMENTS= " << nAngle*(nStation-1) <<", DATAPACKING=POINT, ZONETYPE=FEQUADRILATERAL" << endl; - + for (iAngle = 0; iAngle < nAngle; iAngle++) { for (iStation = 0; iStation < nStation; iStation++) { - + Alpha = atan(ProbeArray[iAngle][iStation][10]/ProbeArray[iAngle][iStation][8])*360.0/(2.0*PI_NUMBER); Beta = atan(ProbeArray[iAngle][iStation][9]/ProbeArray[iAngle][iStation][8])*360.0/(2.0*PI_NUMBER); - + Mach_ij = ProbeArray[iAngle][iStation][7]; if (iAngle+1 != nAngle) Mach_ip1j = ProbeArray[iAngle+1][iStation][7]; else Mach_ip1j = ProbeArray[0][iStation][7]; @@ -11024,7 +11024,7 @@ void COutputLegacy::SpecialOutput_Distortion(CSolver *solver, CGeometry *geometr if (iStation-1 != -1) Mach_ijm1 = ProbeArray[iAngle][iStation-1][7]; else Mach_ijm1 = ProbeArray[iAngle][nStation-1][7]; Filtered_Mach = (4.0*Mach_ij+Mach_ip1j+Mach_im1j+Mach_ijp1+Mach_ijm1)/8.0; - + Alpha_ij = atan(ProbeArray[iAngle][iStation][10]/ProbeArray[iAngle][iStation][8])*360.0/(2.0*PI_NUMBER); if (iAngle+1 != nAngle) Alpha_ip1j = atan(ProbeArray[iAngle+1][iStation][10]/ProbeArray[iAngle+1][iStation][8])*360.0/(2.0*PI_NUMBER); else Alpha_ip1j = atan(ProbeArray[0][iStation][10]/ProbeArray[0][iStation][8])*360.0/(2.0*PI_NUMBER); @@ -11035,7 +11035,7 @@ void COutputLegacy::SpecialOutput_Distortion(CSolver *solver, CGeometry *geometr if (iStation-1 != -1) Alpha_ijm1 = atan(ProbeArray[iAngle][iStation-1][10]/ProbeArray[iAngle][iStation-1][8])*360.0/(2.0*PI_NUMBER); else Alpha_ijm1 = atan(ProbeArray[iAngle][nStation-1][10]/ProbeArray[iAngle][nStation-1][8])*360.0/(2.0*PI_NUMBER); Filtered_Alpha = (4.0*Alpha_ij+Alpha_ip1j+Alpha_im1j+Alpha_ijp1+Alpha_ijm1)/8.0; - + Beta_ij = atan(ProbeArray[iAngle][iStation][9]/ProbeArray[iAngle][iStation][8])*360.0/(2.0*PI_NUMBER); if (iAngle+1 != nAngle) Beta_ip1j = atan(ProbeArray[iAngle+1][iStation][9]/ProbeArray[iAngle+1][iStation][8])*360.0/(2.0*PI_NUMBER); else Beta_ip1j = atan(ProbeArray[0][iStation][9]/ProbeArray[0][iStation][8])*360.0/(2.0*PI_NUMBER); @@ -11046,8 +11046,8 @@ void COutputLegacy::SpecialOutput_Distortion(CSolver *solver, CGeometry *geometr if (iStation-1 != -1) Beta_ijm1 = atan(ProbeArray[iAngle][iStation-1][9]/ProbeArray[iAngle][iStation-1][8])*360.0/(2.0*PI_NUMBER); else Beta_ijm1 = atan(ProbeArray[iAngle][nStation-1][9]/ProbeArray[iAngle][nStation-1][8])*360.0/(2.0*PI_NUMBER); Filtered_Beta = (4.0*Beta_ij+Beta_ip1j+Beta_im1j+Beta_ijp1+Beta_ijm1)/8.0; - - + + SurfFlow_file << " " << ProbeArray[iAngle][iStation][1]-yCoord_CG <<" " << ProbeArray[iAngle][iStation][2]-zCoord_CG @@ -11057,10 +11057,10 @@ void COutputLegacy::SpecialOutput_Distortion(CSolver *solver, CGeometry *geometr <<" " << ProbeArray[iAngle][iStation][10] <<" " << Alpha <<" " << Beta << " " << ProbeArray[iAngle][iStation][7] <<" " << Filtered_Alpha <<" " << Filtered_Beta << " " << Filtered_Mach << endl; - + } } - + for (iAngle = 0; iAngle < nAngle; iAngle++) { for (iStation = 0; iStation < nStation-1; iStation++) { a = iAngle*nStation+iStation; b = a + nStation; c = b+1; d = a +1; @@ -11068,9 +11068,9 @@ void COutputLegacy::SpecialOutput_Distortion(CSolver *solver, CGeometry *geometr SurfFlow_file << a+1 <<" "<< b+1 <<" "<< c+1 <<" "<< d+1 << endl; } } - + /*--- Add extra info ---*/ - + SurfFlow_file << "TEXT X=14, Y=86, F=HELV-BOLD, C=BLUE, H=2.0, "; unsigned short RackProbes = SU2_TYPE::Int(config->GetDistortionRack()[0]); unsigned short RackAngle = SU2_TYPE::Int(config->GetDistortionRack()[1]); @@ -11083,17 +11083,17 @@ void COutputLegacy::SpecialOutput_Distortion(CSolver *solver, CGeometry *geometr SurfFlow_file << ", MassFlow " << config->GetSurface_MassFlow(iMarker_Analyze) << ",\\" << "\\n"; SurfFlow_file << "IDC " << config->GetSurface_IDC(iMarker_Analyze)*100 << "%, IDCM " << config->GetSurface_IDC_Mach(iMarker_Analyze)*100 << "%, IDR " << config->GetSurface_IDR(iMarker_Analyze)*100 << "%,\\" << "\\n"; SurfFlow_file << "DC60 " << config->GetSurface_DC60(iMarker_Analyze) << ".\"" << endl; - + } - + } /*--- Release the recv buffers on the master node ---*/ - + delete [] Buffer_Recv_Coord_x; delete [] Buffer_Recv_Coord_y; if (nDim == 3) delete [] Buffer_Recv_Coord_z; - + delete [] Buffer_Recv_PT; delete [] Buffer_Recv_TT; delete [] Buffer_Recv_P; @@ -11103,11 +11103,11 @@ void COutputLegacy::SpecialOutput_Distortion(CSolver *solver, CGeometry *geometr delete [] Buffer_Recv_Vel_y; if (nDim == 3) delete [] Buffer_Recv_Vel_z; delete [] Buffer_Recv_q; - + delete [] Buffer_Recv_Area; - + delete [] Buffer_Recv_nVertex; - + delete[] r; for (iAngle = 0; iAngle < nAngle; iAngle++) { for (iStation = 0; iStation < nStation; iStation++) { @@ -11115,9 +11115,9 @@ void COutputLegacy::SpecialOutput_Distortion(CSolver *solver, CGeometry *geometr } } delete[] ProbeArray; - + } - + // if ((rank == MASTER_NODE) && !config->GetDiscrete_Adjoint()) { // // cout << "Surface ("<< Analyze_TagBound << "): "; @@ -11129,13 +11129,13 @@ void COutputLegacy::SpecialOutput_Distortion(CSolver *solver, CGeometry *geometr // << "%. DC60 " << config->GetSurface_DC60(iMarker_Analyze) << "." << endl; // // } - + /*--- Release the memory for the remaining buffers and exit ---*/ - + delete [] Buffer_Send_Coord_x; delete [] Buffer_Send_Coord_y; if (nDim == 3) delete [] Buffer_Send_Coord_z; - + delete [] Buffer_Send_PT; delete [] Buffer_Send_TT; delete [] Buffer_Send_P; @@ -11145,13 +11145,13 @@ void COutputLegacy::SpecialOutput_Distortion(CSolver *solver, CGeometry *geometr delete [] Buffer_Send_Vel_y; if (nDim == 3) delete [] Buffer_Send_Vel_z; delete [] Buffer_Send_q; - + delete [] Buffer_Send_Area; - + } - + /*--- Close the tecplot file ---*/ - + if (output) { SurfFlow_file.close(); } @@ -11242,7 +11242,7 @@ void COutputLegacy::SpecialOutput_FSI(ofstream *FSIHist_file, CGeometry ****geom /*--- Flow residual output ---*/ case EULER : case NAVIER_STOKES: case RANS : - case INC_EULER : case INC_NAVIER_STOKES: case INC_RANS : + case INC_EULER : case INC_NAVIER_STOKES: case INC_RANS : FSIHist_file[0] << flow_resid; if (turbulent) FSIHist_file[0] << turb_resid; break; @@ -11272,7 +11272,7 @@ void COutputLegacy::SpecialOutput_FSI(ofstream *FSIHist_file, CGeometry ****geom switch (config[ZONE_FLOW]->GetKind_Solver()) { case EULER : case NAVIER_STOKES: case RANS : - case INC_EULER : case INC_NAVIER_STOKES: case INC_RANS : + case INC_EULER : case INC_NAVIER_STOKES: case INC_RANS : FSIHist_file[0] << flow_coeff; if (turbulent) FSIHist_file[0] << turb_resid; if (direct_diff != NO_DERIVATIVE) { @@ -11281,7 +11281,7 @@ void COutputLegacy::SpecialOutput_FSI(ofstream *FSIHist_file, CGeometry ****geom break; 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: + case DISC_ADJ_INC_EULER: case DISC_ADJ_INC_NAVIER_STOKES: case DISC_ADJ_INC_RANS: FSIHist_file[0] << adj_flow_resid; break; @@ -11521,7 +11521,7 @@ void COutputLegacy::SetSensitivity_Files(CGeometry ***geometry, CConfig **config (config[iZone]->GetMarker_All_KindBC(iMarker) == ISOTHERMAL ) || (config[iZone]->GetMarker_All_KindBC(iMarker) == CHT_WALL_INTERFACE )) { - + nVertex = geometry[iZone][INST_0]->GetnVertex(iMarker); for (iVertex = 0; iVertex < nVertex; iVertex++) { @@ -11811,12 +11811,12 @@ void COutputLegacy::WriteTurboPerfConvHistory(CConfig *config){ cout << endl << "-------------------------------------------------------------------------" << endl; cout << endl; } - + } void COutputLegacy::SpecialOutput_Turbo(CSolver *****solver, CGeometry ****geometry, CConfig **config, unsigned short val_iZone, bool output) { - + string inMarker_Tag, outMarker_Tag, inMarkerTag_Mix; unsigned short nZone = config[val_iZone]->GetnZone(); @@ -11956,14 +11956,14 @@ void COutputLegacy::SpecialOutput_Turbo(CSolver *****solver, CGeometry ****geome SPRINTF (buffer, "_%d.dat", SU2_TYPE::Int(val_iZone)); spanwise_performance_filename.append(string(buffer)); } - + myfile.open (spanwise_performance_filename.data(), ios::out | ios::trunc); myfile.setf(ios::scientific); myfile.precision(12); - + myfile << "TITLE = \"Inflow Span-wise Kinematic Values. iExtIter = " << iExtIter << " \"" << endl; myfile << "VARIABLES =" << endl; - + myfile.width(30); myfile << "\"SpanWise Value[m]\""; myfile.width(15); myfile << "\"iSpan\""; myfile.width(30); myfile << "\"Normal Mach[-]\""; @@ -11977,10 +11977,10 @@ void COutputLegacy::SpecialOutput_Turbo(CSolver *****solver, CGeometry ****geome myfile.width(30); myfile << "\"Absolute Flow Angle[deg]\""; myfile.width(30); myfile << "\"Relative Flow Angle[deg]\""; myfile << endl; - - + + for(iSpan = 0; iSpan < config[ZONE_0]->GetnSpan_iZones(val_iZone); iSpan++){ - + myfile.width(30); myfile << SpanWiseValuesIn[iSpan]; myfile.width(15); myfile << iSpan; for (iDim = 0; iDim < 4; iDim++){ @@ -12003,9 +12003,9 @@ void COutputLegacy::SpecialOutput_Turbo(CSolver *****solver, CGeometry ****geome } myfile << endl; } - + myfile.close(); - + /*--- Writing Span wise outflow thermodynamic quantities. ---*/ spanwise_performance_filename = "TURBOMACHINERY/outflow_spanwise_kinematic_values.dat"; if (nZone > 1){ @@ -12014,14 +12014,14 @@ void COutputLegacy::SpecialOutput_Turbo(CSolver *****solver, CGeometry ****geome SPRINTF (buffer, "_%d.dat", SU2_TYPE::Int(val_iZone)); spanwise_performance_filename.append(string(buffer)); } - + myfile.open (spanwise_performance_filename.data(), ios::out | ios::trunc); myfile.setf(ios::scientific); myfile.precision(12); - + myfile << "TITLE = \"Outflow Span-wise Kinematic Values. iExtIter = " << iExtIter << " \"" << endl; myfile << "VARIABLES =" << endl; - + myfile.width(30); myfile << "\"SpanWise Value[m]\""; myfile.width(15); myfile << "\"iSpan\""; myfile.width(30); myfile << "\"Normal Mach[-]\""; @@ -12035,10 +12035,10 @@ void COutputLegacy::SpecialOutput_Turbo(CSolver *****solver, CGeometry ****geome myfile.width(30); myfile << "\"Absolute Flow Angle[deg]\""; myfile.width(30); myfile << "\"Relative Flow Angle[deg]\""; myfile << endl; - - + + for(iSpan = 0; iSpan < config[ZONE_0]->GetnSpan_iZones(val_iZone); iSpan++){ - + myfile.width(30); myfile << SpanWiseValuesOut[iSpan]; myfile.width(15); myfile << iSpan; for (iDim = 0; iDim < 4; iDim++){ @@ -12061,14 +12061,14 @@ void COutputLegacy::SpecialOutput_Turbo(CSolver *****solver, CGeometry ****geome } myfile << endl; } - + myfile.close(); - + } } void COutputLegacy::SpecialOutput_HarmonicBalance(CSolver *****solver, CGeometry ****geometry, CConfig **config, unsigned short iInst, unsigned short val_nInst, bool output) { - + /*--- Write file with flow quantities for harmonic balance HB ---*/ ofstream HB_output_file; ofstream mean_HB_file; @@ -12113,14 +12113,14 @@ void COutputLegacy::SpecialOutput_HarmonicBalance(CSolver *****solver, CGeometry N.B. Summing across processors within a given zone is being done elsewhere. ---*/ for (kInst = 0; kInst < val_nInst; kInst++) { - + /*--- Flow solution coefficients (parallel) ---*/ sbuf_var[0] = solver[ZONE_0][kInst][MESH_0][FLOW_SOL]->GetTotal_CL(); sbuf_var[1] = solver[ZONE_0][kInst][INST_0][FLOW_SOL]->GetTotal_CD(); sbuf_var[2] = solver[ZONE_0][kInst][INST_0][FLOW_SOL]->GetTotal_CMx(); sbuf_var[3] = solver[ZONE_0][kInst][INST_0][FLOW_SOL]->GetTotal_CMy(); sbuf_var[4] = solver[ZONE_0][kInst][INST_0][FLOW_SOL]->GetTotal_CMz(); - + for (iVar = 0; iVar < nVar_output; iVar++) { rbuf_var[iVar] = sbuf_var[iVar]; } @@ -12184,7 +12184,7 @@ void COutputLegacy::SetResult_Files_Parallel(CSolver *****solver_container, CConfig **config, unsigned long iExtIter, unsigned short val_nZone) { - + unsigned short iZone, iVar, iInst; unsigned long iPoint; unsigned short nInst = 1; @@ -12198,12 +12198,12 @@ void COutputLegacy::SetResult_Files_Parallel(CSolver *****solver_container, (KindSolver == FEM_NAVIER_STOKES) || (KindSolver == FEM_RANS) || (KindSolver == FEM_LES)); - + /*--- Get the file output format ---*/ - + unsigned short FileFormat = config[iZone]->GetTabular_FileFormat(); nInst = config[iZone]->GetnTimeInstances(); - + for (iInst = 0; iInst < nInst; iInst++){ bool cont_adj = config[iZone]->GetContinuous_Adjoint(); @@ -12240,18 +12240,18 @@ void COutputLegacy::SetResult_Files_Parallel(CSolver *****solver_container, PrepareOffsets(config[iZone], geometry[iZone][iInst][MESH_0]); /*--- Write out CSV files in parallel for flow and adjoint. ---*/ - + if (rank == MASTER_NODE) cout << endl << "Writing comma-separated values (CSV) surface files." << endl; - + switch (config[iZone]->GetKind_Solver()) { case EULER : case NAVIER_STOKES : case RANS : - case INC_EULER : case INC_NAVIER_STOKES : case INC_RANS : + case INC_EULER : case INC_NAVIER_STOKES : case INC_RANS : if (Wrt_Csv) SetSurfaceCSV_Flow(config[iZone], geometry[iZone][iInst][MESH_0], solver_container[iZone][iInst][MESH_0][FLOW_SOL], iExtIter, iZone, iInst); break; case ADJ_EULER : case ADJ_NAVIER_STOKES : case ADJ_RANS : 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: + case DISC_ADJ_INC_EULER: case DISC_ADJ_INC_NAVIER_STOKES: case DISC_ADJ_INC_RANS: if (Wrt_Csv) SetSurfaceCSV_Adjoint(config[iZone], geometry[iZone][iInst][MESH_0], solver_container[iZone][iInst][MESH_0][ADJFLOW_SOL], solver_container[iZone][iInst][MESH_0][FLOW_SOL], iExtIter, iZone, iInst); @@ -12268,7 +12268,7 @@ void COutputLegacy::SetResult_Files_Parallel(CSolver *****solver_container, switch (config[iZone]->GetKind_Solver()) { case EULER : case NAVIER_STOKES : case RANS : - case INC_EULER : case INC_NAVIER_STOKES : case INC_RANS : + case INC_EULER : case INC_NAVIER_STOKES : case INC_RANS : if (compressible) LoadLocalData_Flow(config[iZone], geometry[iZone][iInst][MESH_0], solver_container[iZone][iInst][MESH_0], iZone); else @@ -12276,7 +12276,7 @@ void COutputLegacy::SetResult_Files_Parallel(CSolver *****solver_container, break; case ADJ_EULER : case ADJ_NAVIER_STOKES : case ADJ_RANS : 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: + case DISC_ADJ_INC_EULER: case DISC_ADJ_INC_NAVIER_STOKES: case DISC_ADJ_INC_RANS: LoadLocalData_AdjFlow(config[iZone], geometry[iZone][iInst][MESH_0], solver_container[iZone][iInst][MESH_0], iZone); break; case FEM_ELASTICITY: case DISC_ADJ_FEM: @@ -12289,62 +12289,62 @@ void COutputLegacy::SetResult_Files_Parallel(CSolver *****solver_container, LoadLocalData_FEM(config[iZone], geometry[iZone][iInst][MESH_0], solver_container[iZone][iInst][MESH_0], iZone); default: break; } - + /*--- Store the solution to be used on the final iteration with cte. lift mode. ---*/ if ((!cont_adj) && (!disc_adj) && (config[iZone]->GetFixed_CL_Mode()) && - (solver_container[iZone][iInst][MESH_0][FLOW_SOL]->GetStart_AoA_FD()) && + (solver_container[iZone][iInst][MESH_0][FLOW_SOL]->GetStart_AoA_FD()) && iExtIter == solver_container[iZone][iInst][MESH_0][FLOW_SOL]->GetIter_Update_AoA()) { //(config[iZone]->GetnExtIter()-config[iZone]->GetIter_dCL_dAlpha() -1 == iExtIter)) { if (rank == MASTER_NODE) cout << "Storing solution output data locally on each rank (cte. CL mode)." << endl; - + Local_Data_Copy = new su2double*[geometry[iZone][iInst][MESH_0]->GetnPoint()]; for (iPoint = 0; iPoint < geometry[iZone][iInst][MESH_0]->GetnPoint(); iPoint++) { Local_Data_Copy[iPoint] = new su2double[nVar_Par]; } - + for (iPoint = 0; iPoint < geometry[iZone][iInst][MESH_0]->GetnPoint(); iPoint++) { for (iVar = 0; iVar < nVar_Par; iVar++) { Local_Data_Copy[iPoint][iVar] = Local_Data[iPoint][iVar]; } } - + } - + /*--- Recover the solution to be used on the final iteration with cte. lift mode. ---*/ if ((!cont_adj) && (!disc_adj) && (config[iZone]->GetFixed_CL_Mode()) && (solver_container[iZone][iInst][MESH_0][FLOW_SOL]->GetEnd_AoA_FD()) && - //(iExtIter - solver_container[iZone][iInst][MESH_0][FLOW_SOL]->GetIter_Update_AoA() == config[iZone]->GetIter_dCL_dAlpha()) && + //(iExtIter - solver_container[iZone][iInst][MESH_0][FLOW_SOL]->GetIter_Update_AoA() == config[iZone]->GetIter_dCL_dAlpha()) && (Local_Data_Copy != NULL)) { if (rank == MASTER_NODE) cout << "Recovering solution output data locally on each rank (cte. CL mode)." << endl; - + for (iPoint = 0; iPoint < geometry[iZone][iInst][MESH_0]->GetnPoint(); iPoint++) { for (iVar = 0; iVar < nVar_Par; iVar++) { Local_Data[iPoint][iVar] = Local_Data_Copy[iPoint][iVar]; } } - + for (iPoint = 0; iPoint < geometry[iZone][iInst][MESH_0]->GetnPoint(); iPoint++) delete [] Local_Data_Copy[iPoint]; delete [] Local_Data_Copy; - + } - + /*--- After loading the data local to a processor, we perform a sorting, i.e., a linear partitioning of the data across all ranks in the communicator. ---*/ - + if (rank == MASTER_NODE) cout << "Sorting output data across all ranks." << endl; if (fem_solver) SortOutputData_FEM(config[iZone], geometry[iZone][iInst][MESH_0]); else SortOutputData(config[iZone], geometry[iZone][iInst][MESH_0]); - + /*--- Write either a binary or ASCII restart file in parallel. ---*/ if (config[iZone]->GetWrt_Binary_Restart()) { @@ -12363,14 +12363,14 @@ void COutputLegacy::SetResult_Files_Parallel(CSolver *****solver_container, WriteCSV_Slice(config[iZone], geometry[iZone][iInst][MESH_0], solver_container[iZone][iInst][MESH_0][FLOW_SOL], iExtIter, iZone, 1); } - + /*--- Write the solution files if they are requested and we are executing with a single rank (all data on one proc and no comm. overhead). Once we have parallel binary versions of Tecplot / ParaView / CGNS / etc., we can allow the write of the viz. files as well. ---*/ if (Wrt_Vol || Wrt_Srf) { - + /*--- First, sort all connectivity into linearly partitioned chunks of elements. ---*/ if (rank == MASTER_NODE) @@ -12403,7 +12403,7 @@ void COutputLegacy::SetResult_Files_Parallel(CSolver *****solver_container, // solver_container[iZone][iInst][MESH_0], iZone, val_nZone, iInst, nInst, false); break; - + case TECPLOT_BINARY: @@ -12416,7 +12416,7 @@ void COutputLegacy::SetResult_Files_Parallel(CSolver *****solver_container, // solver_container[iZone][iInst][MESH_0], iZone, val_nZone, iInst, nInst, false); break; - + case PARAVIEW: @@ -12426,11 +12426,11 @@ void COutputLegacy::SetResult_Files_Parallel(CSolver *****solver_container, // WriteParaViewASCII_Parallel(config[iZone], geometry[iZone][iInst][MESH_0], // solver_container[iZone][iInst][MESH_0], iZone, val_nZone, iInst, nInst, false); break; - + case PARAVIEW_BINARY: - + /*--- Write a Paraview binary file ---*/ - + if (rank == MASTER_NODE) cout << "Writing Paraview binary volume solution file." << endl; // WriteParaViewBinary_Parallel(config[iZone], geometry[iZone][iInst][MESH_0], // solver_container[iZone][iInst][MESH_0], iZone, val_nZone, false); @@ -12474,16 +12474,16 @@ void COutputLegacy::SetResult_Files_Parallel(CSolver *****solver_container, // WriteParaViewASCII_Parallel(config[iZone], geometry[iZone][iInst][MESH_0], // solver_container[iZone][iInst][MESH_0], iZone, val_nZone, iInst, nInst, true); break; - + case PARAVIEW_BINARY: - + /*--- Write a Paraview binary file ---*/ - + if (rank == MASTER_NODE) cout << "Writing Paraview binary surface solution file." << endl; // WriteParaViewBinary_Parallel(config[iZone], geometry[iZone][iInst][MESH_0], // solver_container[iZone][iInst][MESH_0], iZone, val_nZone, true); break; - + default: break; @@ -12515,15 +12515,15 @@ void COutputLegacy::SetResult_Files_Parallel(CSolver *****solver_container, } void COutputLegacy::LoadLocalData_Flow(CConfig *config, CGeometry *geometry, CSolver **solver, unsigned short val_iZone) { - + unsigned short iDim; unsigned short Kind_Solver = config->GetKind_Solver(); unsigned short nDim = geometry->GetnDim(); - + unsigned long iVar, jVar; unsigned long iPoint, jPoint, FirstIndex = NONE, SecondIndex = NONE, iMarker, iVertex; unsigned long nVar_First = 0, nVar_Second = 0, nVar_Consv_Par = 0; - + su2double RefArea = config->GetRefArea(); su2double Gamma = config->GetGamma(); su2double RefVel2; @@ -12536,13 +12536,13 @@ void COutputLegacy::LoadLocalData_Flow(CConfig *config, CGeometry *geometry, CSo bool dynamic_grid = config->GetDynamic_Grid(); bool rotating_frame = config->GetRotating_Frame(); bool Wrt_Halo = config->GetWrt_Halo(), isPeriodic; - + int *Local_Halo = NULL; - + stringstream varname; - + /*--- Set the non-dimensionalization for coefficients. ---*/ - + if (dynamic_grid) { Gas_Constant = config->GetGas_ConstantND(); Mach2Vel = sqrt(Gamma*Gas_Constant*config->GetTemperature_FreeStreamND()); @@ -12557,20 +12557,20 @@ void COutputLegacy::LoadLocalData_Flow(CConfig *config, CGeometry *geometry, CSo RefDensity = solver[FLOW_SOL]->GetDensity_Inf(); RefPressure = solver[FLOW_SOL]->GetPressure_Inf(); factor = 1.0 / (0.5*RefDensity*RefArea*RefVel2); - + /*--- Use a switch statement to decide how many solver containers we have in this zone for output. ---*/ - + switch (config->GetKind_Solver()) { case EULER : case NAVIER_STOKES: FirstIndex = FLOW_SOL; SecondIndex = NONE; break; case RANS : FirstIndex = FLOW_SOL; SecondIndex = TURB_SOL; break; default: SecondIndex = NONE; break; } - + nVar_First = solver[FirstIndex]->GetnVar(); if (SecondIndex != NONE) nVar_Second = solver[SecondIndex]->GetnVar(); nVar_Consv_Par = nVar_First + nVar_Second; - + /*--------------------------------------------------------------------------*/ /*--- Step 1: Register the variables that will be output. To register a ---*/ /*--- variable, two things are required. First, increment the ---*/ @@ -12580,26 +12580,26 @@ void COutputLegacy::LoadLocalData_Flow(CConfig *config, CGeometry *geometry, CSo /*--- Second, add a name for the variable to the vector that ---*/ /*--- holds the string names. ---*/ /*--------------------------------------------------------------------------*/ - + /*--- All output files first need the grid coordinates. ---*/ - + nVar_Par = 1; Variable_Names.push_back("x"); nVar_Par += 1; Variable_Names.push_back("y"); if (geometry->GetnDim() == 3) { nVar_Par += 1; Variable_Names.push_back("z"); } - + /*--- At a mininum, the restarts and visualization files need the conservative variables, so these follow next. ---*/ - + nVar_Par += nVar_Consv_Par; - + Variable_Names.push_back("Density"); Variable_Names.push_back("Momentum_x"); Variable_Names.push_back("Momentum_y"); if (geometry->GetnDim() == 3) Variable_Names.push_back("Momentum_z"); Variable_Names.push_back("Energy"); - + if (SecondIndex != NONE) { if ((config->GetKind_Turb_Model() == SST) || (config->GetKind_Turb_Model() == SST_SUST)) { Variable_Names.push_back("TKE"); @@ -12609,21 +12609,21 @@ void COutputLegacy::LoadLocalData_Flow(CConfig *config, CGeometry *geometry, CSo Variable_Names.push_back("Nu_Tilde"); } } - + /*--- If requested, register the limiter and residuals for all of the equations in the current flow problem. ---*/ - + /*--- Add the limiters ---*/ - + if (config->GetWrt_Limiters()) { nVar_Par += nVar_Consv_Par; - + Variable_Names.push_back("Limiter_Density"); Variable_Names.push_back("Limiter_Momentum_x"); Variable_Names.push_back("Limiter_Momentum_y"); if (geometry->GetnDim() == 3) Variable_Names.push_back("Limiter_Momentum_z"); Variable_Names.push_back("Limiter_Energy"); - + if (SecondIndex != NONE) { if ((config->GetKind_Turb_Model() == SST) || (config->GetKind_Turb_Model() == SST_SUST)) { Variable_Names.push_back("Limiter_TKE"); @@ -12634,18 +12634,18 @@ void COutputLegacy::LoadLocalData_Flow(CConfig *config, CGeometry *geometry, CSo } } } - + /*--- Add the residuals ---*/ - + if (config->GetWrt_Residuals()) { nVar_Par += nVar_Consv_Par; - + Variable_Names.push_back("Residual_Density"); Variable_Names.push_back("Residual_Momentum_x"); Variable_Names.push_back("Residual_Momentum_y"); if (geometry->GetnDim() == 3) Variable_Names.push_back("Residual_Momentum_z"); Variable_Names.push_back("Residual_Energy"); - + if (SecondIndex != NONE) { if ((config->GetKind_Turb_Model() == SST) || (config->GetKind_Turb_Model() == SST_SUST)) { Variable_Names.push_back("Residual_TKE"); @@ -12656,37 +12656,37 @@ void COutputLegacy::LoadLocalData_Flow(CConfig *config, CGeometry *geometry, CSo } } } - + /*--- Add the grid velocity. ---*/ - + if (dynamic_grid) { if (geometry->GetnDim() == 2) nVar_Par += 2; else if (geometry->GetnDim() == 3) nVar_Par += 3; - + Variable_Names.push_back("Grid_Velocity_x"); Variable_Names.push_back("Grid_Velocity_y"); if (geometry->GetnDim() == 3) Variable_Names.push_back("Grid_Velocity_z"); } - - + + /*--- Add Pressure, Temperature, Cp, Mach. ---*/ - + nVar_Par += 1; Variable_Names.push_back("Pressure"); - + nVar_Par += 2; Variable_Names.push_back("Temperature"); Variable_Names.push_back("Mach"); - + nVar_Par += 1; if ((config->GetTabular_FileFormat() == TAB_CSV)){ Variable_Names.push_back("Pressure_Coefficient"); } else { Variable_Names.push_back("Cp"); } - + /*--- Add Laminar Viscosity, Skin Friction, Heat Flux, & yPlus to the restart file ---*/ - + if ((Kind_Solver == NAVIER_STOKES) || (Kind_Solver == RANS)) { if ((config->GetTabular_FileFormat() == TAB_CSV)){ nVar_Par += 1; Variable_Names.push_back("Laminar_Viscosity"); @@ -12714,9 +12714,9 @@ void COutputLegacy::LoadLocalData_Flow(CConfig *config, CGeometry *geometry, CSo Variable_Names.push_back("h"); } } - + /*--- Add Eddy Viscosity. ---*/ - + if (Kind_Solver == RANS) { nVar_Par += 2; if ((config->GetTabular_FileFormat() == TAB_CSV)){ @@ -12727,16 +12727,16 @@ void COutputLegacy::LoadLocalData_Flow(CConfig *config, CGeometry *geometry, CSo Variable_Names.push_back("mt"); } } - + /*--- Add the distance to the nearest sharp edge if requested. ---*/ - + if (config->GetWrt_SharpEdges()) { nVar_Par += 1; Variable_Names.push_back("Sharp_Edge_Dist"); } - + /*--- Add the intermittency for the BC trans. model. ---*/ - + if (transition) { nVar_Par += 1; if ((config->GetTabular_FileFormat() == TAB_CSV)){ @@ -12745,19 +12745,19 @@ void COutputLegacy::LoadLocalData_Flow(CConfig *config, CGeometry *geometry, CSo Variable_Names.push_back("gBC"); } } - + if (config->GetKind_HybridRANSLES()!=NO_HYBRIDRANSLES){ nVar_Par +=1; Variable_Names.push_back("DES_LengthScale"); nVar_Par +=1; Variable_Names.push_back("Wall_Distance"); } - + if (config->GetKind_RoeLowDiss() != NO_ROELOWDISS){ nVar_Par +=1; Variable_Names.push_back("Roe_Dissipation"); } - + if (solver[FLOW_SOL]->VerificationSolution) { if (solver[FLOW_SOL]->VerificationSolution->ExactSolutionKnown()) { nVar_Par += 2*nVar_Consv_Par; @@ -12773,9 +12773,9 @@ void COutputLegacy::LoadLocalData_Flow(CConfig *config, CGeometry *geometry, CSo Variable_Names.push_back("Error_Energy"); } } - + /*--- New variables get registered here before the end of the loop. ---*/ - + if ((Kind_Solver == NAVIER_STOKES) || (Kind_Solver == RANS)) { nVar_Par += 2; Variable_Names.push_back("Vorticity_x"); @@ -12783,14 +12783,14 @@ void COutputLegacy::LoadLocalData_Flow(CConfig *config, CGeometry *geometry, CSo if (geometry->GetnDim() == 3) { nVar_Par += 1; Variable_Names.push_back("Vorticity_z"); } - + if (geometry->GetnDim() == 3) { nVar_Par +=1; Variable_Names.push_back("Q_Criterion"); } } - + if (rotating_frame) { nVar_Par += 2; Variable_Names.push_back("Relative_Velocity_x"); @@ -12799,7 +12799,7 @@ void COutputLegacy::LoadLocalData_Flow(CConfig *config, CGeometry *geometry, CSo nVar_Par += 1; Variable_Names.push_back("Relative_Velocity_z"); } } - + if (config->GetWrt_MeshQuality()) { nVar_Par +=1; Variable_Names.push_back("Orthogonality"); @@ -12808,11 +12808,11 @@ void COutputLegacy::LoadLocalData_Flow(CConfig *config, CGeometry *geometry, CSo nVar_Par +=1; Variable_Names.push_back("Volume_Ratio"); } - - - + + + /*--- Auxiliary vectors for variables defined on surfaces only. ---*/ - + if ((Kind_Solver == NAVIER_STOKES) || (Kind_Solver == RANS)) { Aux_Frict_x = new su2double[geometry->GetnPoint()]; Aux_Frict_y = new su2double[geometry->GetnPoint()]; @@ -12820,12 +12820,12 @@ void COutputLegacy::LoadLocalData_Flow(CConfig *config, CGeometry *geometry, CSo Aux_Heat = new su2double[geometry->GetnPoint()]; Aux_yPlus = new su2double[geometry->GetnPoint()]; Aux_Buffet = new su2double[geometry->GetnPoint()]; - + /*--- First, loop through the mesh in order to find and store the value of the viscous coefficients at any surface nodes. They will be placed in an auxiliary vector and then communicated like all other volumetric variables. ---*/ - + for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { Aux_Frict_x[iPoint] = 0.0; Aux_Frict_y[iPoint] = 0.0; @@ -12848,30 +12848,30 @@ void COutputLegacy::LoadLocalData_Flow(CConfig *config, CGeometry *geometry, CSo } } } - + /*--- Allocate the local data structure now that we know how many variables are in the output. ---*/ - + Local_Data = new su2double*[geometry->GetnPoint()]; for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { Local_Data[iPoint] = new su2double[nVar_Par]; } - + Local_Halo = new int[geometry->GetnPoint()]; for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) Local_Halo[iPoint] = !geometry->node[iPoint]->GetDomain(); - + /*--- Search all send/recv boundaries on this partition for any periodic nodes that were part of the original domain. We want to recover these for visualization purposes. ---*/ - + if (!Wrt_Halo) { for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { if (config->GetMarker_All_KindBC(iMarker) == SEND_RECEIVE) { - + /*--- Checking for less than or equal to the rank, because there may be some periodic halo nodes that send info to the same rank. ---*/ - + for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); isPeriodic = ((geometry->vertex[iMarker][iVertex]->GetRotation_Type() > 0) && @@ -12881,7 +12881,7 @@ void COutputLegacy::LoadLocalData_Flow(CConfig *config, CGeometry *geometry, CSo } } } - + /*--------------------------------------------------------------------------*/ /*--- Step 2: Loop over all grid nodes and load up the desired data for ---*/ /*--- the restart and vizualization files. Note that we need to ---*/ @@ -12893,47 +12893,47 @@ void COutputLegacy::LoadLocalData_Flow(CConfig *config, CGeometry *geometry, CSo /*--- ordering of the data loading MUST match the order of the ---*/ /*--- variable registration above for the files to be correct. ---*/ /*--------------------------------------------------------------------------*/ - + jPoint = 0; - + for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { - + /*--- Check for halos & write only if requested ---*/ - + if (!Local_Halo[iPoint] || Wrt_Halo) { - + /*--- Restart the column index with each new point. ---*/ - + iVar = 0; - + /*--- Load the grid node coordinate values. ---*/ - + for (iDim = 0; iDim < geometry->GetnDim(); iDim++) { Local_Data[jPoint][iVar] = geometry->node[iPoint]->GetCoord(iDim); if (config->GetSystemMeasurements() == US) Local_Data[jPoint][iVar] *= 12.0; iVar++; } - + /*--- Load the conservative variable states for the mean flow variables. ---*/ - + for (jVar = 0; jVar < nVar_First; jVar++) { Local_Data[jPoint][iVar] = solver[FirstIndex]->GetNodes()->GetSolution(iPoint, jVar); iVar++; } - + /*--- If this is RANS, i.e., the second solver container is not empty, then load data for the conservative turbulence variables. ---*/ - + if (SecondIndex != NONE) { for (jVar = 0; jVar < nVar_Second; jVar++) { Local_Data[jPoint][iVar] = solver[SecondIndex]->GetNodes()->GetSolution(iPoint, jVar); iVar++; } } - + /*--- If limiters and/or residuals are requested. ---*/ - + /*--- Limiters ---*/ if (config->GetWrt_Limiters()) { /*--- Mean Flow Limiters ---*/ @@ -12949,27 +12949,27 @@ void COutputLegacy::LoadLocalData_Flow(CConfig *config, CGeometry *geometry, CSo } } } - + /*--- Residuals ---*/ if (config->GetWrt_Residuals()) { /*--- Mean Flow Residuals ---*/ for (jVar = 0; jVar < nVar_First; jVar++) { - Local_Data[jPoint][iVar] = solver[FirstIndex]->LinSysRes.GetBlock(iPoint, jVar); + Local_Data[jPoint][iVar] = solver[FirstIndex]->LinSysRes(iPoint, jVar); iVar++; } /*--- RANS Residuals ---*/ if (SecondIndex != NONE) { for (jVar = 0; jVar < nVar_Second; jVar++) { - Local_Data[jPoint][iVar] = solver[SecondIndex]->LinSysRes.GetBlock(iPoint, jVar); + Local_Data[jPoint][iVar] = solver[SecondIndex]->LinSysRes(iPoint, jVar); iVar++; } } } - - - + + + /*--- Load buffers with the three grid velocity components. ---*/ - + if (dynamic_grid) { Grid_Vel = geometry->node[iPoint]->GetGridVel(); Local_Data[jPoint][iVar] = Grid_Vel[0]; iVar++; @@ -12979,22 +12979,22 @@ void COutputLegacy::LoadLocalData_Flow(CConfig *config, CGeometry *geometry, CSo iVar++; } } - + /*--- Load data for the pressure, temperature, Cp, and Mach variables. ---*/ - + 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]->GetNodes()->GetLaminarViscosity(iPoint); iVar++; - + /*--- Load data for the skin friction, heat flux, buffet, and y-plus. ---*/ - + Local_Data[jPoint][iVar] = Aux_Frict_x[iPoint]; iVar++; Local_Data[jPoint][iVar] = Aux_Frict_y[iPoint]; iVar++; if (geometry->GetnDim() == 3) { @@ -13002,74 +13002,74 @@ void COutputLegacy::LoadLocalData_Flow(CConfig *config, CGeometry *geometry, CSo iVar++; } if (config->GetBuffet_Monitoring() || config->GetKind_ObjFunc() == BUFFET_SENSOR) { - Local_Data[jPoint][iVar] = Aux_Buffet[iPoint]; + Local_Data[jPoint][iVar] = Aux_Buffet[iPoint]; iVar++; } Local_Data[jPoint][iVar] = Aux_Heat[iPoint]; iVar++; - + } - + /*--- Load data for the Eddy viscosity for RANS. ---*/ - + if (Kind_Solver == RANS) { Local_Data[jPoint][iVar] = Aux_yPlus[iPoint]; iVar++; Local_Data[jPoint][iVar] = solver[FLOW_SOL]->GetNodes()->GetEddyViscosity(iPoint); iVar++; } - + /*--- Load data for the distance to the nearest sharp edge. ---*/ - + if (config->GetWrt_SharpEdges()) { Local_Data[jPoint][iVar] = geometry->node[iPoint]->GetSharpEdge_Distance(); iVar++; } - + /*--- Load data for the intermittency of the BC trans. model. ---*/ - + if (transition) { Local_Data[jPoint][iVar] = solver[TURB_SOL]->GetNodes()->GetGammaBC(iPoint); iVar++; } - + if (config->GetKind_HybridRANSLES()!=NO_HYBRIDRANSLES){ 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]->GetNodes()->GetRoe_Dissipation(iPoint); iVar++; } - + if (solver[FLOW_SOL]->VerificationSolution) { if (solver[FLOW_SOL]->VerificationSolution->ExactSolutionKnown()) { - + /*--- Get the physical time if necessary. ---*/ su2double time = 0.0; if (config->GetTime_Marching()) time = config->GetPhysicalTime(); - + /* Set the pointers to the coordinates and solution of this DOF. */ const su2double *coor = geometry->node[iPoint]->GetCoord(); 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}; - + /* Get the verification solution. */ solver[FLOW_SOL]->VerificationSolution->GetSolution(coor, time, mmsSol); for (jVar = 0; jVar < nVar_First; jVar++) { Local_Data[jPoint][iVar] = mmsSol[jVar]; iVar++; } - + /* Get local error from the verification solution class. */ solver[FLOW_SOL]->VerificationSolution->GetLocalError(coor, time, solDOF, error); for (jVar = 0; jVar < nVar_First; jVar++) { Local_Data[jPoint][iVar] = error[jVar]; iVar++; } - + } } - + /*--- New variables can be loaded to the Local_Data structure here, assuming they were registered above correctly. ---*/ - + if ((Kind_Solver == NAVIER_STOKES) || (Kind_Solver == RANS)) { Local_Data[jPoint][iVar] = solver[FLOW_SOL]->GetNodes()->GetVorticity(iPoint)[0]; iVar++; Local_Data[jPoint][iVar] = solver[FLOW_SOL]->GetNodes()->GetVorticity(iPoint)[1]; iVar++; @@ -13077,17 +13077,17 @@ void COutputLegacy::LoadLocalData_Flow(CConfig *config, CGeometry *geometry, CSo 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]->GetNodes()->GetGradient_Primitive(iPoint, iDim+1, 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 ---*/ - + 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]); @@ -13097,15 +13097,15 @@ void COutputLegacy::LoadLocalData_Flow(CConfig *config, CGeometry *geometry, CSo 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 = 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); Local_Data[jPoint][iVar] = Q; iVar++; } } - + /*--- For rotating frame problems, compute the relative velocity. ---*/ - + if (rotating_frame) { Grid_Vel = geometry->node[iPoint]->GetGridVel(); su2double *Solution = solver[FLOW_SOL]->GetNodes()->GetSolution(iPoint); @@ -13118,7 +13118,7 @@ void COutputLegacy::LoadLocalData_Flow(CConfig *config, CGeometry *geometry, CSo } /*--- Output the mesh quality metrics. ---*/ - + if (config->GetWrt_MeshQuality()) { Local_Data[jPoint][iVar] = geometry->Orthogonality[iPoint]; iVar++; Local_Data[jPoint][iVar] = geometry->Aspect_Ratio[iPoint]; iVar++; @@ -13126,17 +13126,17 @@ void COutputLegacy::LoadLocalData_Flow(CConfig *config, CGeometry *geometry, CSo } } - + /*--- Increment the point counter, as there may have been halos we skipped over during the data loading. ---*/ - + jPoint++; - + } - - + + /*--- Free memory for auxiliary vectors. ---*/ - + if ((Kind_Solver == NAVIER_STOKES) || (Kind_Solver == RANS)) { delete [] Aux_Frict_x; delete [] Aux_Frict_y; @@ -13145,9 +13145,9 @@ void COutputLegacy::LoadLocalData_Flow(CConfig *config, CGeometry *geometry, CSo delete [] Aux_yPlus; delete [] Aux_Buffet; } - + delete [] Local_Halo; - + } void COutputLegacy::LoadLocalData_IncFlow(CConfig *config, CGeometry *geometry, CSolver **solver, unsigned short val_iZone) { @@ -13268,17 +13268,17 @@ void COutputLegacy::LoadLocalData_IncFlow(CConfig *config, CGeometry *geometry, /*--- Add the limiters ---*/ - + if (config->GetWrt_Limiters()) { nVar_Par += nVar_Consv_Par; - + Variable_Names.push_back("Limiter_Pressure"); Variable_Names.push_back("Limiter_Velocity_x"); Variable_Names.push_back("Limiter_Velocity_y"); if (geometry->GetnDim() == 3) Variable_Names.push_back("Limiter_Velocity_z"); if (energy || weakly_coupled_heat) Variable_Names.push_back("Limiter_Temperature"); - + if (SecondIndex != NONE) { if ((config->GetKind_Turb_Model() == SST) || (config->GetKind_Turb_Model() == SST_SUST)) { Variable_Names.push_back("Limiter_TKE"); @@ -13289,19 +13289,19 @@ void COutputLegacy::LoadLocalData_IncFlow(CConfig *config, CGeometry *geometry, } } } - + /*--- Add the residuals ---*/ - + if (config->GetWrt_Residuals()) { nVar_Par += nVar_Consv_Par; - + Variable_Names.push_back("Residual_Pressure"); Variable_Names.push_back("Residual_Velocity_x"); Variable_Names.push_back("Residual_Velocity_y"); if (geometry->GetnDim() == 3) Variable_Names.push_back("Residual_Velocity_z"); if (energy || weakly_coupled_heat) Variable_Names.push_back("Residual_Temperature"); - + if (SecondIndex != NONE) { if ((config->GetKind_Turb_Model() == SST) || (config->GetKind_Turb_Model() == SST_SUST)) { Variable_Names.push_back("Residual_TKE"); @@ -13312,29 +13312,29 @@ void COutputLegacy::LoadLocalData_IncFlow(CConfig *config, CGeometry *geometry, } } } - + /*--- Add the grid velocity. ---*/ - + if (dynamic_grid) { if (geometry->GetnDim() == 2) nVar_Par += 2; else if (geometry->GetnDim() == 3) nVar_Par += 3; - + Variable_Names.push_back("Grid_Velocity_x"); Variable_Names.push_back("Grid_Velocity_y"); if (geometry->GetnDim() == 3) Variable_Names.push_back("Grid_Velocity_z"); } - + /*--- Add Cp. ---*/ - + nVar_Par += 1; if ((config->GetTabular_FileFormat() == TAB_CSV)){ Variable_Names.push_back("Pressure_Coefficient"); } else { Variable_Names.push_back("Cp"); } - + /*--- Add Laminar Viscosity, Skin Friction, and Heat Flux to the restart file ---*/ - + if ((Kind_Solver == INC_NAVIER_STOKES) || (Kind_Solver == INC_RANS)) { if ((config->GetTabular_FileFormat() == TAB_CSV)){ nVar_Par += 1; Variable_Names.push_back("Laminar_Viscosity"); @@ -13362,9 +13362,9 @@ void COutputLegacy::LoadLocalData_IncFlow(CConfig *config, CGeometry *geometry, } } } - + /*--- Add Y+ and Eddy Viscosity. ---*/ - + if (Kind_Solver == INC_RANS) { nVar_Par += 2; if ((config->GetTabular_FileFormat() == TAB_CSV)){ @@ -13375,16 +13375,16 @@ void COutputLegacy::LoadLocalData_IncFlow(CConfig *config, CGeometry *geometry, Variable_Names.push_back("mt"); } } - + /*--- Add the distance to the nearest sharp edge if requested. ---*/ - + if (config->GetWrt_SharpEdges()) { nVar_Par += 1; Variable_Names.push_back("Sharp_Edge_Dist"); } - + /*--- Add the intermittency for the BC trans. model. ---*/ - + if (transition) { nVar_Par += 1; if ((config->GetTabular_FileFormat() == TAB_CSV)){ @@ -13393,22 +13393,22 @@ void COutputLegacy::LoadLocalData_IncFlow(CConfig *config, CGeometry *geometry, Variable_Names.push_back("gBC"); } } - + if (variable_density) { nVar_Par += 1; Variable_Names.push_back("Density"); } - + if (wrt_cp) { nVar_Par += 1; Variable_Names.push_back("Specific_Heat"); } - + if (wrt_kt) { nVar_Par += 1; Variable_Names.push_back("Thermal_Conductivity"); } - + if (solver[FLOW_SOL]->VerificationSolution) { if (solver[FLOW_SOL]->VerificationSolution->ExactSolutionKnown()) { nVar_Par += 2*nVar_Consv_Par; @@ -13424,19 +13424,19 @@ void COutputLegacy::LoadLocalData_IncFlow(CConfig *config, CGeometry *geometry, if (energy || weakly_coupled_heat) Variable_Names.push_back("Error_Temperature"); } } - + if ((Kind_Solver == INC_NAVIER_STOKES) || (Kind_Solver == INC_RANS)) { nVar_Par += 2; Variable_Names.push_back("Vorticity_x"); Variable_Names.push_back("Vorticity_y"); nVar_Par += 1; Variable_Names.push_back("Vorticity_z"); - + if (geometry->GetnDim() == 3) { nVar_Par +=1; Variable_Names.push_back("Q_Criterion"); } } - + if (config->GetWrt_MeshQuality()) { nVar_Par +=1; Variable_Names.push_back("Orthogonality"); @@ -13445,10 +13445,10 @@ void COutputLegacy::LoadLocalData_IncFlow(CConfig *config, CGeometry *geometry, nVar_Par +=1; Variable_Names.push_back("Volume_Ratio"); } - + /*--- New variables get registered here before the end of the loop. ---*/ - - + + /*--- Auxiliary vectors for variables defined on surfaces only. ---*/ @@ -13574,7 +13574,7 @@ void COutputLegacy::LoadLocalData_IncFlow(CConfig *config, CGeometry *geometry, } /*--- If limiters and/or residuals are requested. ---*/ - + /*--- Limiters ---*/ if (config->GetWrt_Limiters()) { /*--- Mean Flow Limiters ---*/ @@ -13590,27 +13590,27 @@ void COutputLegacy::LoadLocalData_IncFlow(CConfig *config, CGeometry *geometry, } } } - + /*--- Residuals ---*/ if (config->GetWrt_Residuals()) { /*--- Mean Flow Residuals ---*/ for (jVar = 0; jVar < nVar_First; jVar++) { - Local_Data[jPoint][iVar] = solver[FirstIndex]->LinSysRes.GetBlock(iPoint, jVar); + Local_Data[jPoint][iVar] = solver[FirstIndex]->LinSysRes(iPoint, jVar); iVar++; } /*--- RANS Residuals ---*/ if (SecondIndex != NONE) { for (jVar = 0; jVar < nVar_Second; jVar++) { - Local_Data[jPoint][iVar] = solver[SecondIndex]->LinSysRes.GetBlock(iPoint, jVar); + Local_Data[jPoint][iVar] = solver[SecondIndex]->LinSysRes(iPoint, jVar); iVar++; } } } - - + + /*--- Load buffers with the three grid velocity components. ---*/ - + if (dynamic_grid) { Grid_Vel = geometry->node[iPoint]->GetGridVel(); Local_Data[jPoint][iVar] = Grid_Vel[0]; iVar++; @@ -13620,112 +13620,112 @@ void COutputLegacy::LoadLocalData_IncFlow(CConfig *config, CGeometry *geometry, iVar++; } } - + /*--- Load data for Cp and Mach variables. ---*/ - + 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]->GetNodes()->GetLaminarViscosity(iPoint); iVar++; - + /*--- Load data for the skin friction, heat flux, and y-plus. ---*/ - + Local_Data[jPoint][iVar] = Aux_Frict_x[iPoint]; iVar++; Local_Data[jPoint][iVar] = Aux_Frict_y[iPoint]; iVar++; if (geometry->GetnDim() == 3) { Local_Data[jPoint][iVar] = Aux_Frict_z[iPoint]; iVar++; } - + if (energy || weakly_coupled_heat) { Local_Data[jPoint][iVar] = Aux_Heat[iPoint]; iVar++; } - + } - + /*--- Load data for the Eddy viscosity for RANS. ---*/ - + if (Kind_Solver == INC_RANS) { Local_Data[jPoint][iVar] = Aux_yPlus[iPoint]; iVar++; Local_Data[jPoint][iVar] = solver[FLOW_SOL]->GetNodes()->GetEddyViscosity(iPoint); iVar++; } - + /*--- Load data for the distance to the nearest sharp edge. ---*/ - + if (config->GetWrt_SharpEdges()) { Local_Data[jPoint][iVar] = geometry->node[iPoint]->GetSharpEdge_Distance(); iVar++; } - + /*--- Load data for the intermittency of the BC trans. model. ---*/ - + if (transition) { 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]->GetNodes()->GetDensity(iPoint); iVar++; } - + /*--- Load Cp and conductivity if they are temperature-dependent. ---*/ if (wrt_cp) { Local_Data[jPoint][iVar] = solver[FLOW_SOL]->GetNodes()->GetSpecificHeatCp(iPoint); iVar++; } - + if (wrt_kt) { Local_Data[jPoint][iVar] = solver[FLOW_SOL]->GetNodes()->GetThermalConductivity(iPoint); iVar++; } - + if (solver[FLOW_SOL]->VerificationSolution) { if (solver[FLOW_SOL]->VerificationSolution->ExactSolutionKnown()) { - + /*--- Get the physical time if necessary. ---*/ su2double time = 0.0; if (config->GetTime_Marching()) time = config->GetPhysicalTime(); - + /* Set the pointers to the coordinates and solution of this DOF. */ const su2double *coor = geometry->node[iPoint]->GetCoord(); 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}; - + /* Get the verification solution. */ solver[FLOW_SOL]->VerificationSolution->GetSolution(coor, time, mmsSol); for (jVar = 0; jVar < nVar_First; jVar++) { Local_Data[jPoint][iVar] = mmsSol[jVar]; iVar++; } - + /* Get local error from the verification solution class. */ solver[FLOW_SOL]->VerificationSolution->GetLocalError(coor, time, solDOF, error); for (jVar = 0; jVar < nVar_First; jVar++) { Local_Data[jPoint][iVar] = error[jVar]; iVar++; } - + } } - + if ((Kind_Solver == INC_NAVIER_STOKES) || (Kind_Solver == INC_RANS)) { - + 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]->GetNodes()->GetGradient_Primitive(iPoint, iDim+1, 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 ---*/ - + 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]); @@ -13735,37 +13735,37 @@ void COutputLegacy::LoadLocalData_IncFlow(CConfig *config, CGeometry *geometry, 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 = 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); - + Local_Data[jPoint][iVar] = Q; iVar++; } } - + /*--- Output the mesh quality metrics. ---*/ - + if (config->GetWrt_MeshQuality()) { Local_Data[jPoint][iVar] = geometry->Orthogonality[iPoint]; iVar++; Local_Data[jPoint][iVar] = geometry->Aspect_Ratio[iPoint]; iVar++; Local_Data[jPoint][iVar] = geometry->Volume_Ratio[iPoint]; iVar++; } - + /*--- New variables can be loaded to the Local_Data structure here, assuming they were registered above correctly. ---*/ - + } - + /*--- Increment the point counter, as there may have been halos we skipped over during the data loading. ---*/ - + jPoint++; - + } - + /*--- Free memory for auxiliary vectors. ---*/ - + if ((Kind_Solver == INC_NAVIER_STOKES) || (Kind_Solver == INC_RANS)) { delete [] Aux_Frict_x; delete [] Aux_Frict_y; @@ -13775,48 +13775,48 @@ void COutputLegacy::LoadLocalData_IncFlow(CConfig *config, CGeometry *geometry, } delete [] Local_Halo; - + } void COutputLegacy::LoadLocalData_AdjFlow(CConfig *config, CGeometry *geometry, CSolver **solver, unsigned short val_iZone) { - + unsigned short iDim; unsigned short Kind_Solver = config->GetKind_Solver(); unsigned short nDim = geometry->GetnDim(); - + unsigned long iVar, jVar; unsigned long iPoint, jPoint, FirstIndex = NONE, SecondIndex = NONE, iMarker, iVertex; unsigned long nVar_First = 0, nVar_Second = 0, nVar_Consv_Par = 0; - + su2double *Aux_Sens = NULL; su2double *Grid_Vel = NULL; su2double *Normal, Area; - + bool incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); bool dynamic_grid = config->GetDynamic_Grid(); bool Wrt_Halo = config->GetWrt_Halo(), isPeriodic; - + int *Local_Halo; - + stringstream varname; - + /*--- Use a switch statement to decide how many solver containers we have in this zone for output. ---*/ - + switch (config->GetKind_Solver()) { case ADJ_EULER : case ADJ_NAVIER_STOKES : FirstIndex = ADJFLOW_SOL; SecondIndex = NONE; break; case ADJ_RANS : FirstIndex = ADJFLOW_SOL; if (config->GetFrozen_Visc_Cont()) SecondIndex = NONE; else SecondIndex = ADJTURB_SOL; break; - case DISC_ADJ_EULER: case DISC_ADJ_NAVIER_STOKES: + case DISC_ADJ_EULER: case DISC_ADJ_NAVIER_STOKES: case DISC_ADJ_INC_EULER: case DISC_ADJ_INC_NAVIER_STOKES: FirstIndex = ADJFLOW_SOL; SecondIndex = NONE; break; case DISC_ADJ_RANS: case DISC_ADJ_INC_RANS: FirstIndex = ADJFLOW_SOL; if (config->GetFrozen_Visc_Disc()) SecondIndex = NONE; else SecondIndex = ADJTURB_SOL; break; } - + nVar_First = solver[FirstIndex]->GetnVar(); if (SecondIndex != NONE) nVar_Second = solver[SecondIndex]->GetnVar(); nVar_Consv_Par = nVar_First + nVar_Second; - + /*--------------------------------------------------------------------------*/ /*--- Step 1: Register the variables that will be output. To register a ---*/ /*--- variable, two things are required. First, increment the ---*/ @@ -13826,20 +13826,20 @@ void COutputLegacy::LoadLocalData_AdjFlow(CConfig *config, CGeometry *geometry, /*--- Second, add a name for the variable to the vector that ---*/ /*--- holds the string names. ---*/ /*--------------------------------------------------------------------------*/ - + /*--- All output files first need the grid coordinates. ---*/ - + nVar_Par = 1; Variable_Names.push_back("x"); nVar_Par += 1; Variable_Names.push_back("y"); if (geometry->GetnDim() == 3) { nVar_Par += 1; Variable_Names.push_back("z"); } - + /*--- At a mininum, the restarts and visualization files need the conservative variables, so these follow next. ---*/ - + nVar_Par += nVar_Consv_Par; - + /*--- For now, leave the names as "Conservative_", etc., in order to avoid confusion with the serial version, which still prints these names. Names can be set alternatively by using the commented code @@ -13887,9 +13887,9 @@ void COutputLegacy::LoadLocalData_AdjFlow(CConfig *config, CGeometry *geometry, /*--- If requested, register the limiter and residuals for all of the equations in the current flow problem. ---*/ - + /*--- Add the limiters ---*/ - + if (config->GetWrt_Limiters()) { nVar_Par += nVar_Consv_Par; if (incompressible) { @@ -13916,9 +13916,9 @@ void COutputLegacy::LoadLocalData_AdjFlow(CConfig *config, CGeometry *geometry, } } } - + /*--- Add the residuals ---*/ - + if (config->GetWrt_Residuals()) { nVar_Par += nVar_Consv_Par; if (incompressible) { @@ -13945,9 +13945,9 @@ void COutputLegacy::LoadLocalData_AdjFlow(CConfig *config, CGeometry *geometry, } } } - + /*--- Add the grid velocity. ---*/ - + if (dynamic_grid) { if (geometry->GetnDim() == 2) nVar_Par += 2; else if (geometry->GetnDim() == 3) nVar_Par += 3; @@ -13955,14 +13955,14 @@ void COutputLegacy::LoadLocalData_AdjFlow(CConfig *config, CGeometry *geometry, Variable_Names.push_back("Grid_Velocity_y"); if (geometry->GetnDim() == 3) Variable_Names.push_back("Grid_Velocity_z"); } - + /*--- All adjoint solvers write the surface sensitivity. ---*/ - + nVar_Par += 1; Variable_Names.push_back("Surface_Sensitivity"); - + /*--- For the continouus adjoint, we write either convective scheme's dissipation sensor (centered) or limiter (uwpind) for adj. density. ---*/ - + if (( Kind_Solver == ADJ_EULER ) || ( Kind_Solver == ADJ_NAVIER_STOKES ) || ( Kind_Solver == ADJ_RANS )) { @@ -13973,20 +13973,20 @@ void COutputLegacy::LoadLocalData_AdjFlow(CConfig *config, CGeometry *geometry, Variable_Names.push_back("Limiter_Adjoint_Density"); } } - + /*--- New variables get registered here before the end of the loop. ---*/ - - - + + + /*--- Auxiliary vectors for variables defined on surfaces only. ---*/ - + Aux_Sens = new su2double[geometry->GetnPoint()]; - + /*--- First, loop through the mesh in order to find and store the value of the viscous coefficients at any surface nodes. They will be placed in an auxiliary vector and then communicated like all other volumetric variables. ---*/ - + for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { Aux_Sens[iPoint] = 0.0; } @@ -14001,30 +14001,30 @@ void COutputLegacy::LoadLocalData_AdjFlow(CConfig *config, CGeometry *geometry, Aux_Sens[iPoint] = solver[ADJFLOW_SOL]->GetCSensitivity(iMarker, iVertex)/Area; } } - + /*--- Allocate the local data structure now that we know how many variables are in the output. ---*/ - + Local_Data = new su2double*[geometry->GetnPoint()]; for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { Local_Data[iPoint] = new su2double[nVar_Par]; } - + Local_Halo = new int[geometry->GetnPoint()]; for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) Local_Halo[iPoint] = !geometry->node[iPoint]->GetDomain(); - + /*--- Search all send/recv boundaries on this partition for any periodic nodes that were part of the original domain. We want to recover these for visualization purposes. ---*/ - + if (!Wrt_Halo) { for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { if (config->GetMarker_All_KindBC(iMarker) == SEND_RECEIVE) { - + /*--- Checking for less than or equal to the rank, because there may be some periodic halo nodes that send info to the same rank. ---*/ - + for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); isPeriodic = ((geometry->vertex[iMarker][iVertex]->GetRotation_Type() > 0) && @@ -14034,7 +14034,7 @@ void COutputLegacy::LoadLocalData_AdjFlow(CConfig *config, CGeometry *geometry, } } } - + /*--------------------------------------------------------------------------*/ /*--- Step 2: Loop over all grid nodes and load up the desired data for ---*/ /*--- the restart and vizualization files. Note that we need to ---*/ @@ -14046,41 +14046,41 @@ void COutputLegacy::LoadLocalData_AdjFlow(CConfig *config, CGeometry *geometry, /*--- ordering of the data loading MUST match the order of the ---*/ /*--- variable registration above for the files to be correct. ---*/ /*--------------------------------------------------------------------------*/ - + jPoint = 0; - + for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { - + /*--- Check for halos & write only if requested ---*/ - + if (!Local_Halo[iPoint] || Wrt_Halo) { - + /*--- Restart the column index with each new point. ---*/ - + iVar = 0; - + /*--- Load the grid node coordinate values. ---*/ - + for (iDim = 0; iDim < geometry->GetnDim(); iDim++) { Local_Data[jPoint][iVar] = geometry->node[iPoint]->GetCoord(iDim); if (config->GetSystemMeasurements() == US) Local_Data[jPoint][iVar] *= 12.0; iVar++; } - + /*--- Load the conservative variable states for the mean flow variables. If requested, load the limiters and residuals as well. ---*/ - + for (jVar = 0; jVar < nVar_First; jVar++) { Local_Data[jPoint][iVar] = solver[FirstIndex]->GetNodes()->GetSolution(iPoint, jVar); iVar++; } - - + + /*--- If this is Adj. RANS, i.e., the second solver container is not empty, then load data for the conservative turbulence variables and the limiters / residuals (if requested). ----*/ - + if (SecondIndex != NONE) { for (jVar = 0; jVar < nVar_Second; jVar++) { Local_Data[jPoint][iVar] = solver[SecondIndex]->GetNodes()->GetSolution(iPoint, jVar); @@ -14103,7 +14103,7 @@ void COutputLegacy::LoadLocalData_AdjFlow(CConfig *config, CGeometry *geometry, iVar++; } } - + if (config->GetWrt_Limiters()) { for (jVar = 0; jVar < nVar_First; jVar++) { Local_Data[jPoint][iVar] = solver[FirstIndex]->GetNodes()->GetLimiter(iPoint, jVar); @@ -14116,11 +14116,11 @@ void COutputLegacy::LoadLocalData_AdjFlow(CConfig *config, CGeometry *geometry, } } } - + if (config->GetWrt_Residuals()) { for (jVar = 0; jVar < nVar_First; jVar++) { if (!config->GetDiscrete_Adjoint()) { - Local_Data[jPoint][iVar] = solver[FirstIndex]->LinSysRes.GetBlock(iPoint, jVar); + Local_Data[jPoint][iVar] = solver[FirstIndex]->LinSysRes(iPoint, jVar); } else { Local_Data[jPoint][iVar] = solver[FirstIndex]->GetNodes()->GetSolution(iPoint, jVar) - solver[FirstIndex]->GetNodes()->GetSolution_Old(iPoint, jVar); @@ -14130,7 +14130,7 @@ void COutputLegacy::LoadLocalData_AdjFlow(CConfig *config, CGeometry *geometry, if (SecondIndex != NONE) { for (jVar = 0; jVar < nVar_Second; jVar++) { if (!config->GetDiscrete_Adjoint()) { - Local_Data[jPoint][iVar] = solver[SecondIndex]->LinSysRes.GetBlock(iPoint, jVar); + Local_Data[jPoint][iVar] = solver[SecondIndex]->LinSysRes(iPoint, jVar); } else { Local_Data[jPoint][iVar] = solver[SecondIndex]->GetNodes()->GetSolution(iPoint, jVar) - solver[SecondIndex]->GetNodes()->GetSolution_Old(iPoint, jVar); @@ -14139,9 +14139,9 @@ void COutputLegacy::LoadLocalData_AdjFlow(CConfig *config, CGeometry *geometry, } } } - + /*--- Load buffers with the three grid velocity components. ---*/ - + if (dynamic_grid) { Grid_Vel = geometry->node[iPoint]->GetGridVel(); Local_Data[jPoint][iVar] = Grid_Vel[0]; iVar++; @@ -14151,13 +14151,13 @@ void COutputLegacy::LoadLocalData_AdjFlow(CConfig *config, CGeometry *geometry, iVar++; } } - + /*--- Load data for the surface sensitivity. ---*/ - + Local_Data[iPoint][iVar] = Aux_Sens[iPoint]; iVar++; - + /*--- Load data for the convective scheme sensor. ---*/ - + if (( Kind_Solver == ADJ_EULER ) || ( Kind_Solver == ADJ_NAVIER_STOKES ) || ( Kind_Solver == ADJ_RANS )) { @@ -14167,53 +14167,53 @@ void COutputLegacy::LoadLocalData_AdjFlow(CConfig *config, CGeometry *geometry, Local_Data[jPoint][iVar] = solver[ADJFLOW_SOL]->GetNodes()->GetLimiter(iPoint, 0); iVar++; } } - + /*--- New variables can be loaded to the Local_Data structure here, assuming they were registered above correctly. ---*/ - + } - + /*--- Increment the point counter, as there may have been halos we skipped over during the data loading. ---*/ - + jPoint++; } - - + + /*--- Free memory for auxiliary vectors. ---*/ - + delete [] Aux_Sens; delete [] Local_Halo; - + } void COutputLegacy::LoadLocalData_Elasticity(CConfig *config, CGeometry *geometry, CSolver **solver, unsigned short val_iZone) { - + unsigned short iDim; - + unsigned long iVar, jVar; unsigned long iPoint, jPoint, FirstIndex = NONE, iMarker, iVertex; unsigned long nVar_First = 0, nVar_Consv_Par = 0; - + su2double *Node_Vel = NULL, *Node_Accel = NULL; const su2double *Stress = NULL; bool Wrt_Halo = config->GetWrt_Halo(), isPeriodic; int *Local_Halo = NULL; - + stringstream varname; - + /*--- Use a switch statement to decide how many solver containers we have in this zone for output. ---*/ - + switch (config->GetKind_Solver()) { case FEM_ELASTICITY: FirstIndex = FEA_SOL; break; case DISC_ADJ_FEM: FirstIndex = ADJFEA_SOL; break; } - + nVar_First = solver[FirstIndex]->GetnVar(); nVar_Consv_Par = nVar_First; - + /*--------------------------------------------------------------------------*/ /*--- Step 1: Register the variables that will be output. To register a ---*/ /*--- variable, two things are required. First, increment the ---*/ @@ -14223,25 +14223,25 @@ void COutputLegacy::LoadLocalData_Elasticity(CConfig *config, CGeometry *geometr /*--- Second, add a name for the variable to the vector that ---*/ /*--- holds the string names. ---*/ /*--------------------------------------------------------------------------*/ - + /*--- All output files first need the grid coordinates. ---*/ - + nVar_Par = 1; Variable_Names.push_back("x"); nVar_Par += 1; Variable_Names.push_back("y"); if (geometry->GetnDim() == 3) { nVar_Par += 1; Variable_Names.push_back("z"); } - + /*--- At a mininum, the restarts and visualization files need the conservative variables, so these follow next. ---*/ - + nVar_Par += nVar_Consv_Par; - + /*--- For now, leave the names as "Conservative_", etc., in order to avoid confusion with the serial version, which still prints these names. Names can be set alternatively by using the commented code below. ---*/ - + Variable_Names.push_back("Displacement_x"); Variable_Names.push_back("Displacement_y"); if (geometry->GetnDim() == 3) @@ -14249,10 +14249,10 @@ void COutputLegacy::LoadLocalData_Elasticity(CConfig *config, CGeometry *geometr /*--- If requested, register the limiter and residuals for all of the equations in the current flow problem. ---*/ - - + + /*--- Add the residuals ---*/ - + if (config->GetWrt_Residuals()) { nVar_Par += nVar_Consv_Par; Variable_Names.push_back("Residual_Displacement_x"); @@ -14260,10 +14260,10 @@ void COutputLegacy::LoadLocalData_Elasticity(CConfig *config, CGeometry *geometr if (geometry->GetnDim() == 3) Variable_Names.push_back("Residual_Displacement_z"); } - + /*--- If the analysis is dynamic... ---*/ if (config->GetTime_Domain()) { - + /*--- Velocities ---*/ nVar_Par += 2; Variable_Names.push_back("Velocity_x"); @@ -14272,7 +14272,7 @@ void COutputLegacy::LoadLocalData_Elasticity(CConfig *config, CGeometry *geometr nVar_Par += 1; Variable_Names.push_back("Velocity_z"); } - + /*--- Accelerations ---*/ nVar_Par += 2; Variable_Names.push_back("Acceleration_x"); @@ -14282,11 +14282,11 @@ void COutputLegacy::LoadLocalData_Elasticity(CConfig *config, CGeometry *geometr Variable_Names.push_back("Acceleration_z"); } } - + if (!(config->GetDiscrete_Adjoint())) { - + /*--- Add the stresses. ---*/ - + nVar_Par += 3; Variable_Names.push_back("Sxx"); Variable_Names.push_back("Syy"); @@ -14297,41 +14297,41 @@ void COutputLegacy::LoadLocalData_Elasticity(CConfig *config, CGeometry *geometr Variable_Names.push_back("Sxz"); Variable_Names.push_back("Syz"); } - + /*--- Add the Von Mises Stress. ---*/ - + nVar_Par += 1; Variable_Names.push_back("Von_Mises_Stress"); - + } - + /*--- New variables get registered here before the end of the loop. ---*/ - - - + + + /*--- Allocate the local data structure now that we know how many variables are in the output. ---*/ - + Local_Data = new su2double*[geometry->GetnPoint()]; for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { Local_Data[iPoint] = new su2double[nVar_Par]; } - + Local_Halo = new int[geometry->GetnPoint()]; for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) Local_Halo[iPoint] = !geometry->node[iPoint]->GetDomain(); - + /*--- Search all send/recv boundaries on this partition for any periodic nodes that were part of the original domain. We want to recover these for visualization purposes. ---*/ - + if (!Wrt_Halo) { for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { if (config->GetMarker_All_KindBC(iMarker) == SEND_RECEIVE) { - + /*--- Checking for less than or equal to the rank, because there may be some periodic halo nodes that send info to the same rank. ---*/ - + for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); isPeriodic = ((geometry->vertex[iMarker][iVertex]->GetRotation_Type() > 0) && @@ -14341,7 +14341,7 @@ void COutputLegacy::LoadLocalData_Elasticity(CConfig *config, CGeometry *geometr } } } - + /*--------------------------------------------------------------------------*/ /*--- Step 2: Loop over all grid nodes and load up the desired data for ---*/ /*--- the restart and vizualization files. Note that we need to ---*/ @@ -14353,51 +14353,51 @@ void COutputLegacy::LoadLocalData_Elasticity(CConfig *config, CGeometry *geometr /*--- ordering of the data loading MUST match the order of the ---*/ /*--- variable registration above for the files to be correct. ---*/ /*--------------------------------------------------------------------------*/ - + jPoint = 0; - + for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { - + /*--- Check for halos & write only if requested ---*/ - + if (!Local_Halo[iPoint] || Wrt_Halo) { - + /*--- Restart the column index with each new point. ---*/ - + iVar = 0; - + /*--- Load the grid node coordinate values. ---*/ - + for (iDim = 0; iDim < geometry->GetnDim(); iDim++) { Local_Data[jPoint][iVar] = geometry->node[iPoint]->GetCoord(iDim); if (config->GetSystemMeasurements() == US) Local_Data[jPoint][iVar] *= 12.0; iVar++; } - + /*--- Load the conservative variable states for the mean flow variables. If requested, load the limiters and residuals as well. ---*/ - + for (jVar = 0; jVar < nVar_First; jVar++) { Local_Data[jPoint][iVar] = solver[FirstIndex]->GetNodes()->GetSolution(iPoint, jVar); iVar++; } - + if (config->GetWrt_Residuals()) { for (jVar = 0; jVar < nVar_First; jVar++) { - Local_Data[jPoint][iVar] = solver[FirstIndex]->LinSysRes.GetBlock(iPoint, jVar); + Local_Data[jPoint][iVar] = solver[FirstIndex]->LinSysRes(iPoint, jVar); iVar++; } } - - - + + + /*--- Load the velocities and accelerations (dynamic calculations). ---*/ - + if (config->GetTime_Domain()) { - + /*--- Velocities ---*/ - + 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++; @@ -14405,9 +14405,9 @@ void COutputLegacy::LoadLocalData_Elasticity(CConfig *config, CGeometry *geometr Local_Data[jPoint][iVar] = Node_Vel[2]; iVar++; } - + /*--- Accelerations ---*/ - + 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++; @@ -14416,20 +14416,20 @@ void COutputLegacy::LoadLocalData_Elasticity(CConfig *config, CGeometry *geometr iVar++; } } - + if (!(config->GetDiscrete_Adjoint())) { - + /*--- Add the stresses. ---*/ - + Stress = solver[FEA_SOL]->GetNodes()->GetStress_FEM(iPoint); - + /*--- Sigma xx ---*/ Local_Data[jPoint][iVar] = Stress[0]; iVar++; /*--- Sigma yy ---*/ Local_Data[jPoint][iVar] = Stress[1]; iVar++; /*--- Sigma xy ---*/ Local_Data[jPoint][iVar] = Stress[2]; iVar++; - + if (geometry->GetnDim() == 3) { /*--- Sigma zz ---*/ Local_Data[jPoint][iVar] = Stress[3]; iVar++; @@ -14438,56 +14438,56 @@ void COutputLegacy::LoadLocalData_Elasticity(CConfig *config, CGeometry *geometr /*--- Sigma yz ---*/ Local_Data[jPoint][iVar] = Stress[5]; iVar++; } - + /*--- Add the Von Mises Stress. ---*/ - + Local_Data[iPoint][iVar] = solver[FEA_SOL]->GetNodes()->GetVonMises_Stress(iPoint); iVar++; - - + + /*--- New variables can be loaded to the Local_Data structure here, assuming they were registered above correctly. ---*/ - + } - - + + /*--- Increment the point counter, as there may have been halos we skipped over during the data loading. ---*/ - + jPoint++; } } - + /*--- Free memory for auxiliary vectors. ---*/ - + delete [] Local_Halo; - + } void COutputLegacy::LoadLocalData_Base(CConfig *config, CGeometry *geometry, CSolver **solver, unsigned short val_iZone) { - + unsigned short iDim; - + unsigned long iVar, jVar; unsigned long iPoint, jPoint, FirstIndex = NONE, iMarker, iVertex; unsigned long nVar_First = 0, nVar_Consv_Par = 0; - + bool Wrt_Halo = config->GetWrt_Halo(), isPeriodic; - + int *Local_Halo; - + stringstream varname; - + /*--- Use a switch statement to decide how many solver containers we have in this zone for output. ---*/ - + switch (config->GetKind_Solver()) { case HEAT_EQUATION_FVM: FirstIndex = HEAT_SOL; break; } - + nVar_First = solver[FirstIndex]->GetnVar(); nVar_Consv_Par = nVar_First; - + /*--------------------------------------------------------------------------*/ /*--- Step 1: Register the variables that will be output. To register a ---*/ /*--- variable, two things are required. First, increment the ---*/ @@ -14497,31 +14497,31 @@ void COutputLegacy::LoadLocalData_Base(CConfig *config, CGeometry *geometry, CSo /*--- Second, add a name for the variable to the vector that ---*/ /*--- holds the string names. ---*/ /*--------------------------------------------------------------------------*/ - + /*--- All output files first need the grid coordinates. ---*/ - + nVar_Par = 1; Variable_Names.push_back("x"); nVar_Par += 1; Variable_Names.push_back("y"); if (geometry->GetnDim() == 3) { nVar_Par += 1; Variable_Names.push_back("z"); } - + /*--- At a mininum, the restarts and visualization files need the conservative variables, so these follow next. ---*/ - + nVar_Par += nVar_Consv_Par; for (iVar = 0; iVar < nVar_Consv_Par; iVar++) { varname << "Conservative_" << iVar+1; Variable_Names.push_back(varname.str()); varname.str(""); } - + /*--- If requested, register the residuals for all of the equations in the current problem. ---*/ - - + + /*--- Add the residuals ---*/ - + if (config->GetWrt_Residuals()) { nVar_Par += nVar_Consv_Par; for (iVar = 0; iVar < nVar_Consv_Par; iVar++) { @@ -14530,34 +14530,34 @@ void COutputLegacy::LoadLocalData_Base(CConfig *config, CGeometry *geometry, CSo varname.str(""); } } - + /*--- New variables get registered here before the end of the loop. ---*/ - - - + + + /*--- Allocate the local data structure now that we know how many variables are in the output. ---*/ - + Local_Data = new su2double*[geometry->GetnPoint()]; for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { Local_Data[iPoint] = new su2double[nVar_Par]; } - + Local_Halo = new int[geometry->GetnPoint()]; for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) Local_Halo[iPoint] = !geometry->node[iPoint]->GetDomain(); - + /*--- Search all send/recv boundaries on this partition for any periodic nodes that were part of the original domain. We want to recover these for visualization purposes. ---*/ - + if (!Wrt_Halo) { for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { if (config->GetMarker_All_KindBC(iMarker) == SEND_RECEIVE) { - + /*--- Checking for less than or equal to the rank, because there may be some periodic halo nodes that send info to the same rank. ---*/ - + for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); isPeriodic = ((geometry->vertex[iMarker][iVertex]->GetRotation_Type() > 0) && @@ -14567,7 +14567,7 @@ void COutputLegacy::LoadLocalData_Base(CConfig *config, CGeometry *geometry, CSo } } } - + /*--------------------------------------------------------------------------*/ /*--- Step 2: Loop over all grid nodes and load up the desired data for ---*/ /*--- the restart and vizualization files. Note that we need to ---*/ @@ -14579,103 +14579,103 @@ void COutputLegacy::LoadLocalData_Base(CConfig *config, CGeometry *geometry, CSo /*--- ordering of the data loading MUST match the order of the ---*/ /*--- variable registration above for the files to be correct. ---*/ /*--------------------------------------------------------------------------*/ - + jPoint = 0; - + for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { - + /*--- Check for halos & write only if requested ---*/ - + if (!Local_Halo[iPoint] || Wrt_Halo) { - + /*--- Restart the column index with each new point. ---*/ - + iVar = 0; - + /*--- Load the grid node coordinate values. ---*/ - + for (iDim = 0; iDim < geometry->GetnDim(); iDim++) { Local_Data[jPoint][iVar] = geometry->node[iPoint]->GetCoord(iDim); if (config->GetSystemMeasurements() == US) Local_Data[jPoint][iVar] *= 12.0; iVar++; } - + /*--- Load the conservative variable states for the mean flow variables. If requested, load the limiters and residuals as well. ---*/ - + for (jVar = 0; jVar < nVar_First; jVar++) { Local_Data[jPoint][iVar] = solver[FirstIndex]->GetNodes()->GetSolution(iPoint, jVar); iVar++; } - + if (config->GetWrt_Residuals()) { for (jVar = 0; jVar < nVar_First; jVar++) { - Local_Data[jPoint][iVar] = solver[FirstIndex]->LinSysRes.GetBlock(iPoint, jVar); + Local_Data[jPoint][iVar] = solver[FirstIndex]->LinSysRes(iPoint, jVar); iVar++; } } - - + + /*--- New variables can be loaded to the Local_Data structure here, assuming they were registered above correctly. ---*/ - + /*--- Increment the point counter, as there may have been halos we skipped over during the data loading. ---*/ - + jPoint++; - + } } - + /*--- Free memory for auxiliary vectors. ---*/ - + delete [] Local_Halo; - + } void COutputLegacy::SortConnectivity(CConfig *config, CGeometry *geometry, unsigned short val_iZone) { /*--- Flags identifying the types of files to be written. ---*/ - + bool Wrt_Vol = config->GetWrt_Vol_Sol(); bool Wrt_Srf = config->GetWrt_Srf_Sol(); - + /*--- Sort connectivity for each type of element (excluding halos). Note In these routines, we sort the connectivity into a linear partitioning across all processors based on the global index of the grid nodes. ---*/ - + /*--- Sort volumetric grid connectivity. ---*/ - + if (Wrt_Vol) { - + if ((rank == MASTER_NODE) && (size != SINGLE_NODE)) cout <<"Sorting volumetric grid connectivity." << endl; - + SortVolumetricConnectivity(config, geometry, TRIANGLE ); SortVolumetricConnectivity(config, geometry, QUADRILATERAL); SortVolumetricConnectivity(config, geometry, TETRAHEDRON ); SortVolumetricConnectivity(config, geometry, HEXAHEDRON ); SortVolumetricConnectivity(config, geometry, PRISM ); SortVolumetricConnectivity(config, geometry, PYRAMID ); - + } - + /*--- Sort surface grid connectivity. ---*/ - + if (Wrt_Srf) { - + if ((rank == MASTER_NODE) && (size != SINGLE_NODE)) cout <<"Sorting surface grid connectivity." << endl; - + SortSurfaceConnectivity(config, geometry, LINE ); SortSurfaceConnectivity(config, geometry, TRIANGLE ); SortSurfaceConnectivity(config, geometry, QUADRILATERAL); - + } - + /*--- Reduce the total number of cells we will be writing in the output files. ---*/ - + unsigned long nTotal_Elem = nParallel_Tria + nParallel_Quad + nParallel_Tetr + nParallel_Hexa + nParallel_Pris + nParallel_Pyra; unsigned long nTotal_Surf_Elem = nParallel_Line + nParallel_BoundTria + nParallel_BoundQuad; #ifndef HAVE_MPI @@ -14685,21 +14685,21 @@ void COutputLegacy::SortConnectivity(CConfig *config, CGeometry *geometry, unsig SU2_MPI::Allreduce(&nTotal_Elem, &nGlobal_Elem_Par, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); SU2_MPI::Allreduce(&nTotal_Surf_Elem, &nSurf_Elem_Par, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); #endif - + } void COutputLegacy::SortVolumetricConnectivity(CConfig *config, CGeometry *geometry, unsigned short Elem_Type) { - + unsigned long iProcessor; unsigned short NODES_PER_ELEMENT = 0; unsigned long iPoint, jPoint, kPoint, nLocalPoint, nTotalPoint; unsigned long nElem_Total = 0, Global_Index; - + unsigned long iVertex, iMarker; int SendRecv, RecvFrom; - + bool notPeriodic, notHalo, addedPeriodic, isPeriodic; - + int *Local_Halo = NULL; int *Conn_Elem = NULL; @@ -14708,12 +14708,12 @@ void COutputLegacy::SortVolumetricConnectivity(CConfig *config, CGeometry *geome SU2_MPI::Status status; int ind; #endif - + /*--- Store the local number of this element type and the number of nodes per this element type. In serial, this will be the total number of this element type in the entire mesh. In parallel, it is the number on only the current partition. ---*/ - + switch (Elem_Type) { case TRIANGLE: NODES_PER_ELEMENT = N_POINTS_TRIANGLE; @@ -14736,22 +14736,22 @@ void COutputLegacy::SortVolumetricConnectivity(CConfig *config, CGeometry *geome default: SU2_MPI::Error("Unrecognized element type", CURRENT_FUNCTION); } - + /*--- Force the removal of all added periodic elements (use global index). First, we isolate and create a list of all added periodic points, excluding those that were part of the original domain (we want these to be in the output files). ---*/ - + vector Added_Periodic; Added_Periodic.clear(); - + if (config->GetKind_SU2() != SU2_DEF) { for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { if (config->GetMarker_All_KindBC(iMarker) == SEND_RECEIVE) { SendRecv = config->GetMarker_All_SendRecv(iMarker); for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); - + if ((geometry->vertex[iMarker][iVertex]->GetRotation_Type() > 0) && (geometry->vertex[iMarker][iVertex]->GetRotation_Type() % 2 == 0) && (SendRecv < 0)) { @@ -14761,21 +14761,21 @@ void COutputLegacy::SortVolumetricConnectivity(CConfig *config, CGeometry *geome } } } - + /*--- Now we communicate this information to all processors, so that they can force the removal of these particular nodes by flagging them as halo points. In general, this should be a small percentage of the total mesh, so the communication/storage costs here shouldn't be prohibitive. ---*/ - + /*--- First communicate the number of points that each rank has found. ---*/ - + unsigned long nAddedPeriodic = 0, maxAddedPeriodic = 0; unsigned long Buffer_Send_nAddedPeriodic[1], *Buffer_Recv_nAddedPeriodic = NULL; Buffer_Recv_nAddedPeriodic = new unsigned long[size]; - + nAddedPeriodic = Added_Periodic.size(); Buffer_Send_nAddedPeriodic[0] = nAddedPeriodic; - + #ifdef HAVE_MPI SU2_MPI::Allreduce(&nAddedPeriodic, &maxAddedPeriodic, 1, MPI_UNSIGNED_LONG, MPI_MAX, MPI_COMM_WORLD); @@ -14785,18 +14785,18 @@ void COutputLegacy::SortVolumetricConnectivity(CConfig *config, CGeometry *geome maxAddedPeriodic = nAddedPeriodic; Buffer_Recv_nAddedPeriodic[0] = Buffer_Send_nAddedPeriodic[0]; #endif - + /*--- Communicate the global index values of all added periodic nodes. ---*/ unsigned long *Buffer_Send_AddedPeriodic = new unsigned long[maxAddedPeriodic]; unsigned long *Buffer_Recv_AddedPeriodic = new unsigned long[size*maxAddedPeriodic]; - + for (iPoint = 0; iPoint < Added_Periodic.size(); iPoint++) { Buffer_Send_AddedPeriodic[iPoint] = Added_Periodic[iPoint]; } - + /*--- Gather the element connectivity information. All processors will now have a copy of the global index values for all added periodic points. ---*/ - + #ifdef HAVE_MPI SU2_MPI::Allgather(Buffer_Send_AddedPeriodic, maxAddedPeriodic, MPI_UNSIGNED_LONG, Buffer_Recv_AddedPeriodic, maxAddedPeriodic, MPI_UNSIGNED_LONG, @@ -14805,73 +14805,73 @@ void COutputLegacy::SortVolumetricConnectivity(CConfig *config, CGeometry *geome for (iPoint = 0; iPoint < maxAddedPeriodic; iPoint++) Buffer_Recv_AddedPeriodic[iPoint] = Buffer_Send_AddedPeriodic[iPoint]; #endif - + /*--- Search all send/recv boundaries on this partition for halo cells. In particular, consider only the recv conditions (these are the true halo nodes). Check the ranks of the processors that are communicating and choose to keep only the halo cells from the higher rank processor. Here, we are also choosing to keep periodic nodes that were part of the original domain. We will check the communicated list of added periodic points. ---*/ - + Local_Halo = new int[geometry->GetnPoint()]; for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) Local_Halo[iPoint] = !geometry->node[iPoint]->GetDomain(); - + for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { if (config->GetMarker_All_KindBC(iMarker) == SEND_RECEIVE) { SendRecv = config->GetMarker_All_SendRecv(iMarker); RecvFrom = abs(SendRecv)-1; - + for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); Global_Index = geometry->node[iPoint]->GetGlobalIndex(); - + /*--- We need to keep one copy of overlapping halo cells. ---*/ - + notHalo = ((geometry->vertex[iMarker][iVertex]->GetRotation_Type() == 0) && (SendRecv < 0) && (rank > RecvFrom)); - + /*--- We want to keep the periodic nodes that were part of the original domain. For SU2_DEF we want to keep all periodic nodes. ---*/ - + if (config->GetKind_SU2() == SU2_DEF) { isPeriodic = ((geometry->vertex[iMarker][iVertex]->GetRotation_Type() > 0)); }else { isPeriodic = ((geometry->vertex[iMarker][iVertex]->GetRotation_Type() > 0) && (geometry->vertex[iMarker][iVertex]->GetRotation_Type() % 2 == 1)); } - + notPeriodic = (isPeriodic && (SendRecv < 0)); - + /*--- Lastly, check that this isn't an added periodic point that we will forcibly remove. Use the communicated list of these points. ---*/ - + addedPeriodic = false; kPoint = 0; for (iProcessor = 0; iProcessor < (unsigned long)size; iProcessor++) { for (jPoint = 0; jPoint < Buffer_Recv_nAddedPeriodic[iProcessor]; jPoint++) { if (Global_Index == Buffer_Recv_AddedPeriodic[kPoint+jPoint]) addedPeriodic = true; } - + /*--- Adjust jNode to index of next proc's data in the buffers. ---*/ - + kPoint = (iProcessor+1)*maxAddedPeriodic; - + } - + /*--- If we found either of these types of nodes, flag them to be kept. ---*/ - + if ((notHalo || notPeriodic) && !addedPeriodic) { Local_Halo[iPoint] = false; } - + } } } - + /*--- Now that we've done the gymnastics to find any periodic points, compute the total number of local and global points for the output. ---*/ - + nLocalPoint = 0; for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) if (Local_Halo[iPoint] == false) @@ -14883,31 +14883,31 @@ void COutputLegacy::SortVolumetricConnectivity(CConfig *config, CGeometry *geome #else nTotalPoint = nLocalPoint; #endif - + /*--- Compute the number of points that will be on each processor. This is a linear partitioning with the addition of a simple load balancing for any remainder points. ---*/ - + unsigned long *npoint_procs = new unsigned long[size]; unsigned long *starting_node = new unsigned long[size]; unsigned long *ending_node = new unsigned long[size]; unsigned long *nPoint_Linear = new unsigned long[size+1]; - + unsigned long total_pt_accounted = 0; for (int ii = 0; ii < size; ii++) { npoint_procs[ii] = nTotalPoint/size; total_pt_accounted = total_pt_accounted + npoint_procs[ii]; } - + /*--- Get the number of remainder points after the even division. ---*/ - + unsigned long rem_points = nTotalPoint-total_pt_accounted; for (unsigned long ii = 0; ii < rem_points; ii++) { npoint_procs[ii]++; } - + /*--- Store the local number of nodes and the beginning/end index ---*/ - + starting_node[0] = 0; ending_node[0] = starting_node[0] + npoint_procs[0]; nPoint_Linear[0] = 0; @@ -14917,46 +14917,46 @@ void COutputLegacy::SortVolumetricConnectivity(CConfig *config, CGeometry *geome nPoint_Linear[ii] = nPoint_Linear[ii-1] + npoint_procs[ii-1]; } nPoint_Linear[size] = nTotalPoint; - + /*--- We start with the connectivity distributed across all procs with no particular ordering assumed. We need to loop through our local partition and decide how many elements we must send to each other rank in order to have all elements sorted according to a linear partitioning of the grid nodes, i.e., rank 0 holds the first nPoint()/nProcessors nodes. First, initialize a counter and flag. ---*/ - + int *nElem_Send = new int[size+1]; nElem_Send[0] = 0; int *nElem_Recv = new int[size+1]; nElem_Recv[0] = 0; int *nElem_Flag = new int[size]; - + for (int ii=0; ii < size; ii++) { nElem_Send[ii] = 0; nElem_Recv[ii] = 0; nElem_Flag[ii]= -1; } nElem_Send[size] = 0; nElem_Recv[size] = 0; - + for (int ii = 0; ii < (int)geometry->GetnElem(); ii++ ) { if (geometry->elem[ii]->GetVTK_Type() == Elem_Type) { for ( int jj = 0; jj < NODES_PER_ELEMENT; jj++ ) { - + /*--- Get the index of the current point. ---*/ - + iPoint = geometry->elem[ii]->GetNode(jj); Global_Index = geometry->node[iPoint]->GetGlobalIndex(); - + /*--- Search for the lowest global index in this element. We send the element to the processor owning the range that includes the lowest global index value. ---*/ - + for (int kk = 0; kk < NODES_PER_ELEMENT; kk++) { jPoint = geometry->elem[ii]->GetNode(kk); unsigned long newID = geometry->node[jPoint]->GetGlobalIndex(); if (newID < Global_Index) Global_Index = newID; } - + /*--- Search for the processor that owns this point ---*/ - + iProcessor = Global_Index/npoint_procs[0]; if (iProcessor >= (unsigned long)size) iProcessor = (unsigned long)size-1; @@ -14964,93 +14964,93 @@ void COutputLegacy::SortVolumetricConnectivity(CConfig *config, CGeometry *geome while(Global_Index >= nPoint_Linear[iProcessor+1]) iProcessor++; else while(Global_Index < nPoint_Linear[iProcessor]) iProcessor--; - + /*--- If we have not visited this element yet, increment our number of elements that must be sent to a particular proc. ---*/ - + if ((nElem_Flag[iProcessor] != ii)) { nElem_Flag[iProcessor] = ii; nElem_Send[iProcessor+1]++; } - + } } } - + /*--- Communicate the number of cells to be sent/recv'd amongst all processors. After this communication, each proc knows how many cells it will receive from each other processor. ---*/ - + #ifdef HAVE_MPI SU2_MPI::Alltoall(&(nElem_Send[1]), 1, MPI_INT, &(nElem_Recv[1]), 1, MPI_INT, MPI_COMM_WORLD); #else nElem_Recv[1] = nElem_Send[1]; #endif - + /*--- Prepare to send connectivities. First check how many messages we will be sending and receiving. Here we also put the counters into cumulative storage format to make the communications simpler. ---*/ - + int nSends = 0, nRecvs = 0; for (int ii=0; ii < size; ii++) nElem_Flag[ii] = -1; - + for (int ii = 0; ii < size; ii++) { if ((ii != rank) && (nElem_Send[ii+1] > 0)) nSends++; if ((ii != rank) && (nElem_Recv[ii+1] > 0)) nRecvs++; - + nElem_Send[ii+1] += nElem_Send[ii]; nElem_Recv[ii+1] += nElem_Recv[ii]; } - + /*--- Allocate memory to hold the connectivity that we are sending. ---*/ - + unsigned long *connSend = NULL; connSend = new unsigned long[NODES_PER_ELEMENT*nElem_Send[size]]; for (int ii = 0; ii < NODES_PER_ELEMENT*nElem_Send[size]; ii++) connSend[ii] = 0; - + /*--- Allocate arrays for storing halo flags. ---*/ - + unsigned short *haloSend = new unsigned short[nElem_Send[size]]; for (int ii = 0; ii < nElem_Send[size]; ii++) haloSend[ii] = false; - + /*--- Create an index variable to keep track of our index position as we load up the send buffer. ---*/ - + unsigned long *index = new unsigned long[size]; for (int ii=0; ii < size; ii++) index[ii] = NODES_PER_ELEMENT*nElem_Send[ii]; - + unsigned long *haloIndex = new unsigned long[size]; for (int ii=0; ii < size; ii++) haloIndex[ii] = nElem_Send[ii]; - + /*--- Loop through our elements and load the elems and their additional data that we will send to the other procs. ---*/ - + for (int ii = 0; ii < (int)geometry->GetnElem(); ii++) { if (geometry->elem[ii]->GetVTK_Type() == Elem_Type) { for ( int jj = 0; jj < NODES_PER_ELEMENT; jj++ ) { - + /*--- Get the index of the current point. ---*/ - + iPoint = geometry->elem[ii]->GetNode(jj); Global_Index = geometry->node[iPoint]->GetGlobalIndex(); - + /*--- Search for the lowest global index in this element. We send the element to the processor owning the range that includes the lowest global index value. ---*/ - + for (int kk = 0; kk < NODES_PER_ELEMENT; kk++) { jPoint = geometry->elem[ii]->GetNode(kk); unsigned long newID = geometry->node[jPoint]->GetGlobalIndex(); if (newID < Global_Index) Global_Index = newID; } - + /*--- Search for the processor that owns this point ---*/ - + iProcessor = Global_Index/npoint_procs[0]; if (iProcessor >= (unsigned long)size) iProcessor = (unsigned long)size-1; @@ -15058,67 +15058,67 @@ void COutputLegacy::SortVolumetricConnectivity(CConfig *config, CGeometry *geome while(Global_Index >= nPoint_Linear[iProcessor+1]) iProcessor++; else while(Global_Index < nPoint_Linear[iProcessor]) iProcessor--; - + /*--- Load connectivity into the buffer for sending ---*/ - + if (nElem_Flag[iProcessor] != ii) { - + nElem_Flag[iProcessor] = ii; unsigned long nn = index[iProcessor]; unsigned long mm = haloIndex[iProcessor]; - + /*--- Load the connectivity values. ---*/ - + for (int kk = 0; kk < NODES_PER_ELEMENT; kk++) { iPoint = geometry->elem[ii]->GetNode(kk); connSend[nn] = geometry->node[iPoint]->GetGlobalIndex(); nn++; - + /*--- Check if this is a halo node. If so, flag this element as a halo cell. We will use this later to sort and remove any duplicates from the connectivity list. ---*/ - + if (Local_Halo[iPoint]) haloSend[mm] = true; - + } - + /*--- Increment the index by the message length ---*/ - + index[iProcessor] += NODES_PER_ELEMENT; haloIndex[iProcessor]++; - + } } } } - + /*--- Free memory after loading up the send buffer. ---*/ - + delete [] index; delete [] haloIndex; - + /*--- Allocate the memory that we need for receiving the conn values and then cue up the non-blocking receives. Note that we do not include our own rank in the communications. We will directly copy our own data later. ---*/ - + unsigned long *connRecv = NULL; connRecv = new unsigned long[NODES_PER_ELEMENT*nElem_Recv[size]]; for (int ii = 0; ii < NODES_PER_ELEMENT*nElem_Recv[size]; ii++) connRecv[ii] = 0; - + unsigned short *haloRecv = new unsigned short[nElem_Recv[size]]; for (int ii = 0; ii < nElem_Recv[size]; ii++) haloRecv[ii] = false; - + #ifdef HAVE_MPI /*--- We need double the number of messages to send both the conn. and the flags for the halo cells. ---*/ - + send_req = new SU2_MPI::Request[2*nSends]; recv_req = new SU2_MPI::Request[2*nRecvs]; - + /*--- Launch the non-blocking recv's for the connectivity. ---*/ - + unsigned long iMessage = 0; for (int ii=0; ii nElem_Recv[ii])) { @@ -15132,9 +15132,9 @@ void COutputLegacy::SortVolumetricConnectivity(CConfig *config, CGeometry *geome iMessage++; } } - + /*--- Launch the non-blocking sends of the connectivity. ---*/ - + iMessage = 0; for (int ii=0; ii nElem_Send[ii])) { @@ -15148,9 +15148,9 @@ void COutputLegacy::SortVolumetricConnectivity(CConfig *config, CGeometry *geome iMessage++; } } - + /*--- Repeat the process to communicate the halo flags. ---*/ - + iMessage = 0; for (int ii=0; ii nElem_Recv[ii])) { @@ -15164,9 +15164,9 @@ void COutputLegacy::SortVolumetricConnectivity(CConfig *config, CGeometry *geome iMessage++; } } - + /*--- Launch the non-blocking sends of the halo flags. ---*/ - + iMessage = 0; for (int ii=0; ii nElem_Send[ii])) { @@ -15181,41 +15181,41 @@ void COutputLegacy::SortVolumetricConnectivity(CConfig *config, CGeometry *geome } } #endif - + /*--- Copy my own rank's data into the recv buffer directly. ---*/ - + int mm = NODES_PER_ELEMENT*nElem_Recv[rank]; int ll = NODES_PER_ELEMENT*nElem_Send[rank]; int kk = NODES_PER_ELEMENT*nElem_Send[rank+1]; - + for (int nn=ll; nn 0) Conn_Elem = new int[NODES_PER_ELEMENT*nElem_Recv[size]]; int count = 0; nElem_Total = 0; for (int ii = 0; ii < nElem_Recv[size]; ii++) { @@ -15227,10 +15227,10 @@ void COutputLegacy::SortVolumetricConnectivity(CConfig *config, CGeometry *geome } } } - + /*--- Store the particular global element count in the class data, and set the class data pointer to the connectivity array. ---*/ - + switch (Elem_Type) { case TRIANGLE: nParallel_Tria = nElem_Total; @@ -15260,9 +15260,9 @@ void COutputLegacy::SortVolumetricConnectivity(CConfig *config, CGeometry *geome SU2_MPI::Error("Unrecognized element type", CURRENT_FUNCTION); break; } - + /*--- Free temporary memory from communications ---*/ - + delete [] connSend; delete [] connRecv; delete [] haloSend; @@ -15273,7 +15273,7 @@ void COutputLegacy::SortVolumetricConnectivity(CConfig *config, CGeometry *geome delete [] nElem_Flag; delete [] Buffer_Recv_nAddedPeriodic; delete [] Buffer_Send_AddedPeriodic; - delete [] Buffer_Recv_AddedPeriodic; + delete [] Buffer_Recv_AddedPeriodic; delete [] npoint_procs; delete [] starting_node; delete [] ending_node; @@ -15282,31 +15282,31 @@ void COutputLegacy::SortVolumetricConnectivity(CConfig *config, CGeometry *geome } void COutputLegacy::SortSurfaceConnectivity(CConfig *config, CGeometry *geometry, unsigned short Elem_Type) { - + unsigned long iProcessor; unsigned short NODES_PER_ELEMENT; unsigned long iPoint, jPoint, kPoint, nLocalPoint, nTotalPoint; unsigned long nElem_Total = 0, Global_Index; - + unsigned long iVertex, iMarker; int SendRecv, RecvFrom; - + bool notPeriodic, notHalo, addedPeriodic, isPeriodic; - + int *Local_Halo = NULL; int *Conn_Elem = NULL; - + #ifdef HAVE_MPI SU2_MPI::Request *send_req, *recv_req; SU2_MPI::Status status; int ind; #endif - + /*--- Store the local number of this element type and the number of nodes per this element type. In serial, this will be the total number of this element type in the entire mesh. In parallel, it is the number on only the current partition. ---*/ - + switch (Elem_Type) { case LINE: NODES_PER_ELEMENT = N_POINTS_LINE; @@ -15322,22 +15322,22 @@ void COutputLegacy::SortSurfaceConnectivity(CConfig *config, CGeometry *geometry NODES_PER_ELEMENT = 0; break; } - + /*--- Force the removal of all added periodic elements (use global index). First, we isolate and create a list of all added periodic points, excluding those that were part of the original domain (we want these to be in the output files). ---*/ - + vector Added_Periodic; Added_Periodic.clear(); - + if (config->GetKind_SU2() != SU2_DEF) { for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { if (config->GetMarker_All_KindBC(iMarker) == SEND_RECEIVE) { SendRecv = config->GetMarker_All_SendRecv(iMarker); for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); - + if ((geometry->vertex[iMarker][iVertex]->GetRotation_Type() > 0) && (geometry->vertex[iMarker][iVertex]->GetRotation_Type() % 2 == 0) && (SendRecv < 0)) { @@ -15347,21 +15347,21 @@ void COutputLegacy::SortSurfaceConnectivity(CConfig *config, CGeometry *geometry } } } - + /*--- Now we communicate this information to all processors, so that they can force the removal of these particular nodes by flagging them as halo points. In general, this should be a small percentage of the total mesh, so the communication/storage costs here shouldn't be prohibitive. ---*/ - + /*--- First communicate the number of points that each rank has found. ---*/ - + unsigned long nAddedPeriodic = 0, maxAddedPeriodic = 0; unsigned long Buffer_Send_nAddedPeriodic[1], *Buffer_Recv_nAddedPeriodic = NULL; Buffer_Recv_nAddedPeriodic = new unsigned long[size]; - + nAddedPeriodic = Added_Periodic.size(); Buffer_Send_nAddedPeriodic[0] = nAddedPeriodic; - + #ifdef HAVE_MPI SU2_MPI::Allreduce(&nAddedPeriodic, &maxAddedPeriodic, 1, MPI_UNSIGNED_LONG, MPI_MAX, MPI_COMM_WORLD); @@ -15371,18 +15371,18 @@ void COutputLegacy::SortSurfaceConnectivity(CConfig *config, CGeometry *geometry maxAddedPeriodic = nAddedPeriodic; Buffer_Recv_nAddedPeriodic[0] = Buffer_Send_nAddedPeriodic[0]; #endif - + /*--- Communicate the global index values of all added periodic nodes. ---*/ unsigned long *Buffer_Send_AddedPeriodic = new unsigned long[maxAddedPeriodic]; unsigned long *Buffer_Recv_AddedPeriodic = new unsigned long[size*maxAddedPeriodic]; - + for (iPoint = 0; iPoint < Added_Periodic.size(); iPoint++) { Buffer_Send_AddedPeriodic[iPoint] = Added_Periodic[iPoint]; } - + /*--- Gather the element connectivity information. All processors will now have a copy of the global index values for all added periodic points. ---*/ - + #ifdef HAVE_MPI SU2_MPI::Allgather(Buffer_Send_AddedPeriodic, maxAddedPeriodic, MPI_UNSIGNED_LONG, Buffer_Recv_AddedPeriodic, maxAddedPeriodic, MPI_UNSIGNED_LONG, @@ -15391,109 +15391,109 @@ void COutputLegacy::SortSurfaceConnectivity(CConfig *config, CGeometry *geometry for (iPoint = 0; iPoint < maxAddedPeriodic; iPoint++) Buffer_Recv_AddedPeriodic[iPoint] = Buffer_Send_AddedPeriodic[iPoint]; #endif - + /*--- Search all send/recv boundaries on this partition for halo cells. In particular, consider only the recv conditions (these are the true halo nodes). Check the ranks of the processors that are communicating and choose to keep only the halo cells from the higher rank processor. Here, we are also choosing to keep periodic nodes that were part of the original domain. We will check the communicated list of added periodic points. ---*/ - + Local_Halo = new int[geometry->GetnPoint()]; for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) Local_Halo[iPoint] = !geometry->node[iPoint]->GetDomain(); - + for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { if (config->GetMarker_All_KindBC(iMarker) == SEND_RECEIVE) { SendRecv = config->GetMarker_All_SendRecv(iMarker); RecvFrom = abs(SendRecv)-1; - + for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); Global_Index = geometry->node[iPoint]->GetGlobalIndex(); - + /*--- We need to keep one copy of overlapping halo cells. ---*/ - + notHalo = ((geometry->vertex[iMarker][iVertex]->GetRotation_Type() == 0) && (SendRecv < 0) && (rank > RecvFrom)); - + /*--- We want to keep the periodic nodes that were part of the original domain. For SU2_DEF we want to keep all periodic nodes. ---*/ - + if (config->GetKind_SU2() == SU2_DEF) { isPeriodic = ((geometry->vertex[iMarker][iVertex]->GetRotation_Type() > 0)); }else { isPeriodic = ((geometry->vertex[iMarker][iVertex]->GetRotation_Type() > 0) && (geometry->vertex[iMarker][iVertex]->GetRotation_Type() % 2 == 1)); } - + notPeriodic = (isPeriodic && (SendRecv < 0)); - + /*--- Lastly, check that this isn't an added periodic point that we will forcibly remove. Use the communicated list of these points. ---*/ - + addedPeriodic = false; kPoint = 0; for (iProcessor = 0; iProcessor < (unsigned long)size; iProcessor++) { for (jPoint = 0; jPoint < Buffer_Recv_nAddedPeriodic[iProcessor]; jPoint++) { if (Global_Index == Buffer_Recv_AddedPeriodic[kPoint+jPoint]) addedPeriodic = true; } - + /*--- Adjust jNode to index of next proc's data in the buffers. ---*/ - + kPoint = (iProcessor+1)*maxAddedPeriodic; - + } - + /*--- If we found either of these types of nodes, flag them to be kept. ---*/ - + if ((notHalo || notPeriodic) && !addedPeriodic) { Local_Halo[iPoint] = false; } - + } } } - + /*--- Now that we've done the gymnastics to find any periodic points, compute the total number of local and global points for the output. ---*/ - + nLocalPoint = 0; for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) if (Local_Halo[iPoint] == false) nLocalPoint++; - + #ifdef HAVE_MPI SU2_MPI::Allreduce(&nLocalPoint, &nTotalPoint, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); #else nTotalPoint = nLocalPoint; #endif - + /*--- Compute the number of points that will be on each processor. This is a linear partitioning with the addition of a simple load balancing for any remainder points. ---*/ - + unsigned long *npoint_procs = new unsigned long[size]; unsigned long *starting_node = new unsigned long[size]; unsigned long *ending_node = new unsigned long[size]; unsigned long *nPoint_Linear = new unsigned long[size+1]; - + unsigned long total_pt_accounted = 0; for (int ii = 0; ii < size; ii++) { npoint_procs[ii] = nTotalPoint/size; total_pt_accounted = total_pt_accounted + npoint_procs[ii]; } - + /*--- Get the number of remainder points after the even division. ---*/ - + unsigned long rem_points = nTotalPoint-total_pt_accounted; for (unsigned long ii = 0; ii < rem_points; ii++) { npoint_procs[ii]++; } - + /*--- Store the local number of nodes and the beginning/end index ---*/ - + starting_node[0] = 0; ending_node[0] = starting_node[0] + npoint_procs[0]; nPoint_Linear[0] = 0; @@ -15503,18 +15503,18 @@ void COutputLegacy::SortSurfaceConnectivity(CConfig *config, CGeometry *geometry nPoint_Linear[ii] = nPoint_Linear[ii-1] + npoint_procs[ii-1]; } nPoint_Linear[size] = nTotalPoint; - + /*--- We start with the connectivity distributed across all procs with no particular ordering assumed. We need to loop through our local partition and decide how many elements we must send to each other rank in order to have all elements sorted according to a linear partitioning of the grid nodes, i.e., rank 0 holds the first nPoint()/nProcessors nodes. First, initialize a counter and flag. ---*/ - + int *nElem_Send = new int[size+1]; nElem_Send[0] = 0; int *nElem_Recv = new int[size+1]; nElem_Recv[0] = 0; int *nElem_Flag = new int[size]; - + for (int ii=0; ii < size; ii++) { nElem_Send[ii] = 0; nElem_Recv[ii] = 0; @@ -15524,29 +15524,29 @@ void COutputLegacy::SortSurfaceConnectivity(CConfig *config, CGeometry *geometry for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { if (config->GetMarker_All_Plotting(iMarker) == YES) { - + for (int ii = 0; ii < (int)geometry->GetnElem_Bound(iMarker); ii++) { - + if (geometry->bound[iMarker][ii]->GetVTK_Type() == Elem_Type) { for ( int jj = 0; jj < NODES_PER_ELEMENT; jj++ ) { - + /*--- Get the index of the current point. ---*/ - + iPoint = geometry->bound[iMarker][ii]->GetNode(jj); Global_Index = geometry->node[iPoint]->GetGlobalIndex(); - + /*--- Search for the lowest global index in this element. We send the element to the processor owning the range that includes the lowest global index value. ---*/ - + for (int kk = 0; kk < NODES_PER_ELEMENT; kk++) { jPoint = geometry->bound[iMarker][ii]->GetNode(kk); unsigned long newID = geometry->node[jPoint]->GetGlobalIndex(); if (newID < Global_Index) Global_Index = newID; } - + /*--- Search for the processor that owns this point ---*/ - + iProcessor = Global_Index/npoint_procs[0]; if (iProcessor >= (unsigned long)size) iProcessor = (unsigned long)size-1; @@ -15554,99 +15554,99 @@ void COutputLegacy::SortSurfaceConnectivity(CConfig *config, CGeometry *geometry while(Global_Index >= nPoint_Linear[iProcessor+1]) iProcessor++; else while(Global_Index < nPoint_Linear[iProcessor]) iProcessor--; - + /*--- If we have not visited this element yet, increment our number of elements that must be sent to a particular proc. ---*/ - + if ((nElem_Flag[iProcessor] != ii)) { nElem_Flag[iProcessor] = ii; nElem_Send[iProcessor+1]++; } - + } } } } } - + /*--- Communicate the number of cells to be sent/recv'd amongst all processors. After this communication, each proc knows how many cells it will receive from each other processor. ---*/ - + #ifdef HAVE_MPI SU2_MPI::Alltoall(&(nElem_Send[1]), 1, MPI_INT, &(nElem_Recv[1]), 1, MPI_INT, MPI_COMM_WORLD); #else nElem_Recv[1] = nElem_Send[1]; #endif - + /*--- Prepare to send connectivities. First check how many messages we will be sending and receiving. Here we also put the counters into cumulative storage format to make the communications simpler. ---*/ - + int nSends = 0, nRecvs = 0; for (int ii=0; ii < size; ii++) nElem_Flag[ii] = -1; - + for (int ii = 0; ii < size; ii++) { if ((ii != rank) && (nElem_Send[ii+1] > 0)) nSends++; if ((ii != rank) && (nElem_Recv[ii+1] > 0)) nRecvs++; - + nElem_Send[ii+1] += nElem_Send[ii]; nElem_Recv[ii+1] += nElem_Recv[ii]; } - + /*--- Allocate memory to hold the connectivity that we are sending. ---*/ - + unsigned long *connSend = NULL; connSend = new unsigned long[NODES_PER_ELEMENT*nElem_Send[size]]; for (int ii = 0; ii < NODES_PER_ELEMENT*nElem_Send[size]; ii++) connSend[ii] = 0; - + /*--- Allocate arrays for storing halo flags. ---*/ - + unsigned short *haloSend = new unsigned short[nElem_Send[size]]; for (int ii = 0; ii < nElem_Send[size]; ii++) haloSend[ii] = false; - + /*--- Create an index variable to keep track of our index position as we load up the send buffer. ---*/ - + unsigned long *index = new unsigned long[size]; for (int ii=0; ii < size; ii++) index[ii] = NODES_PER_ELEMENT*nElem_Send[ii]; - + unsigned long *haloIndex = new unsigned long[size]; for (int ii=0; ii < size; ii++) haloIndex[ii] = nElem_Send[ii]; - + /*--- Loop through our elements and load the elems and their additional data that we will send to the other procs. ---*/ - + for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { if (config->GetMarker_All_Plotting(iMarker) == YES) { - + for (int ii = 0; ii < (int)geometry->GetnElem_Bound(iMarker); ii++) { - + if (geometry->bound[iMarker][ii]->GetVTK_Type() == Elem_Type) { for ( int jj = 0; jj < NODES_PER_ELEMENT; jj++ ) { - + /*--- Get the index of the current point. ---*/ - + iPoint = geometry->bound[iMarker][ii]->GetNode(jj); Global_Index = geometry->node[iPoint]->GetGlobalIndex(); - + /*--- Search for the lowest global index in this element. We send the element to the processor owning the range that includes the lowest global index value. ---*/ - + for (int kk = 0; kk < NODES_PER_ELEMENT; kk++) { jPoint = geometry->bound[iMarker][ii]->GetNode(kk); unsigned long newID = geometry->node[jPoint]->GetGlobalIndex(); if (newID < Global_Index) Global_Index = newID; } - + /*--- Search for the processor that owns this point ---*/ - + iProcessor = Global_Index/npoint_procs[0]; if (iProcessor >= (unsigned long)size) iProcessor = (unsigned long)size-1; @@ -15654,69 +15654,69 @@ void COutputLegacy::SortSurfaceConnectivity(CConfig *config, CGeometry *geometry while(Global_Index >= nPoint_Linear[iProcessor+1]) iProcessor++; else while(Global_Index < nPoint_Linear[iProcessor]) iProcessor--; - + /*--- Load connectivity into the buffer for sending ---*/ - + if (nElem_Flag[iProcessor] != ii) { - + nElem_Flag[iProcessor] = ii; unsigned long nn = index[iProcessor]; unsigned long mm = haloIndex[iProcessor]; - + /*--- Load the connectivity values. ---*/ - + for (int kk = 0; kk < NODES_PER_ELEMENT; kk++) { iPoint = geometry->bound[iMarker][ii]->GetNode(kk); connSend[nn] = geometry->node[iPoint]->GetGlobalIndex(); nn++; - + /*--- Check if this is a halo node. If so, flag this element as a halo cell. We will use this later to sort and remove any duplicates from the connectivity list. ---*/ - + if (Local_Halo[iPoint]) haloSend[mm] = true; - + } - + /*--- Increment the index by the message length ---*/ - + index[iProcessor] += NODES_PER_ELEMENT; haloIndex[iProcessor]++; - + } } } } } } - + /*--- Free memory after loading up the send buffer. ---*/ - + delete [] index; delete [] haloIndex; - + /*--- Allocate the memory that we need for receiving the conn values and then cue up the non-blocking receives. Note that we do not include our own rank in the communications. We will directly copy our own data later. ---*/ - + unsigned long *connRecv = NULL; connRecv = new unsigned long[NODES_PER_ELEMENT*nElem_Recv[size]]; for (int ii = 0; ii < NODES_PER_ELEMENT*nElem_Recv[size]; ii++) connRecv[ii] = 0; - + unsigned short *haloRecv = new unsigned short[nElem_Recv[size]]; for (int ii = 0; ii < nElem_Recv[size]; ii++) haloRecv[ii] = false; - + #ifdef HAVE_MPI /*--- We need double the number of messages to send both the conn. and the flags for the halo cells. ---*/ - + send_req = new SU2_MPI::Request[2*nSends]; recv_req = new SU2_MPI::Request[2*nRecvs]; - + /*--- Launch the non-blocking recv's for the connectivity. ---*/ - + unsigned long iMessage = 0; for (int ii=0; ii nElem_Recv[ii])) { @@ -15730,9 +15730,9 @@ void COutputLegacy::SortSurfaceConnectivity(CConfig *config, CGeometry *geometry iMessage++; } } - + /*--- Launch the non-blocking sends of the connectivity. ---*/ - + iMessage = 0; for (int ii=0; ii nElem_Send[ii])) { @@ -15746,9 +15746,9 @@ void COutputLegacy::SortSurfaceConnectivity(CConfig *config, CGeometry *geometry iMessage++; } } - + /*--- Repeat the process to communicate the halo flags. ---*/ - + iMessage = 0; for (int ii=0; ii nElem_Recv[ii])) { @@ -15762,9 +15762,9 @@ void COutputLegacy::SortSurfaceConnectivity(CConfig *config, CGeometry *geometry iMessage++; } } - + /*--- Launch the non-blocking sends of the halo flags. ---*/ - + iMessage = 0; for (int ii=0; ii nElem_Send[ii])) { @@ -15779,41 +15779,41 @@ void COutputLegacy::SortSurfaceConnectivity(CConfig *config, CGeometry *geometry } } #endif - + /*--- Copy my own rank's data into the recv buffer directly. ---*/ - + int mm = NODES_PER_ELEMENT*nElem_Recv[rank]; int ll = NODES_PER_ELEMENT*nElem_Send[rank]; int kk = NODES_PER_ELEMENT*nElem_Send[rank+1]; - + for (int nn=ll; nn 0) Conn_Elem = new int[NODES_PER_ELEMENT*nElem_Recv[size]]; int count = 0; nElem_Total = 0; for (int ii = 0; ii < nElem_Recv[size]; ii++) { @@ -15828,7 +15828,7 @@ void COutputLegacy::SortSurfaceConnectivity(CConfig *config, CGeometry *geometry /*--- Store the particular global element count in the class data, and set the class data pointer to the connectivity array. ---*/ - + switch (Elem_Type) { case LINE: nParallel_Line = nElem_Total; @@ -15846,9 +15846,9 @@ void COutputLegacy::SortSurfaceConnectivity(CConfig *config, CGeometry *geometry SU2_MPI::Error("Unrecognized element type", CURRENT_FUNCTION); break; } - + /*--- Free temporary memory from communications ---*/ - + delete [] connSend; delete [] connRecv; delete [] haloSend; @@ -15864,40 +15864,40 @@ void COutputLegacy::SortSurfaceConnectivity(CConfig *config, CGeometry *geometry delete [] starting_node; delete [] ending_node; delete [] nPoint_Linear; - + } void COutputLegacy::SortOutputData(CConfig *config, CGeometry *geometry) { - + unsigned short iMarker; unsigned long iProcessor; unsigned long iPoint, Global_Index, nLocalPoint, nTotalPoint, iVertex; - + int VARS_PER_POINT = nVar_Par; int *Local_Halo = NULL; bool isPeriodic; - + #ifdef HAVE_MPI SU2_MPI::Request *send_req, *recv_req; SU2_MPI::Status status; int ind; #endif - + /*--- Search all send/recv boundaries on this partition for any periodic nodes that were part of the original domain. We want to recover these for visualization purposes. ---*/ - + Local_Halo = new int[geometry->GetnPoint()]; for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) Local_Halo[iPoint] = !geometry->node[iPoint]->GetDomain(); - + for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { if (config->GetMarker_All_KindBC(iMarker) == SEND_RECEIVE) { - + /*--- Checking for less than or equal to the rank, because there may be some periodic halo nodes that send info to the same rank. ---*/ - + for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); isPeriodic = ((geometry->vertex[iMarker][iVertex]->GetRotation_Type() > 0) && @@ -15906,46 +15906,46 @@ void COutputLegacy::SortOutputData(CConfig *config, CGeometry *geometry) { } } } - + /*--- Sum total number of nodes that belong to the domain ---*/ - + nLocalPoint = 0; for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) if (Local_Halo[iPoint] == false) nLocalPoint++; - + #ifdef HAVE_MPI SU2_MPI::Allreduce(&nLocalPoint, &nTotalPoint, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); #else nTotalPoint = nLocalPoint; #endif - + /*--- Now that we know the actual number of points we need to output, compute the number of points that will be on each processor. This is a linear partitioning with the addition of a simple load balancing for any remainder points. ---*/ - + unsigned long *npoint_procs = new unsigned long[size]; unsigned long *starting_node = new unsigned long[size]; unsigned long *ending_node = new unsigned long[size]; unsigned long *nPoint_Linear = new unsigned long[size+1]; - + unsigned long total_pt_accounted = 0; for (int ii = 0; ii < size; ii++) { npoint_procs[ii] = nTotalPoint/size; total_pt_accounted = total_pt_accounted + npoint_procs[ii]; } - + /*--- Get the number of remainder points after the even division. ---*/ - + unsigned long rem_points = nTotalPoint-total_pt_accounted; for (unsigned long ii = 0; ii < rem_points; ii++) { npoint_procs[ii]++; } - + /*--- Store the local number of nodes and the beginning/end index ---*/ - + starting_node[0] = 0; ending_node[0] = starting_node[0] + npoint_procs[0]; nPoint_Linear[0] = 0; @@ -15955,37 +15955,37 @@ void COutputLegacy::SortOutputData(CConfig *config, CGeometry *geometry) { nPoint_Linear[ii] = nPoint_Linear[ii-1] + npoint_procs[ii-1]; } nPoint_Linear[size] = nTotalPoint; - + /*--- We start with the grid nodes distributed across all procs with no particular ordering assumed. We need to loop through our local partition and decide how many nodes we must send to each other rank in order to have all nodes sorted according to a linear partitioning of the grid nodes, i.e., rank 0 holds the first ~ nGlobalPoint()/nProcessors nodes. First, initialize a counter and flag. ---*/ - + int *nPoint_Send = new int[size+1]; nPoint_Send[0] = 0; int *nPoint_Recv = new int[size+1]; nPoint_Recv[0] = 0; int *nPoint_Flag = new int[size]; - + for (int ii=0; ii < size; ii++) { nPoint_Send[ii] = 0; nPoint_Recv[ii] = 0; nPoint_Flag[ii]= -1; } nPoint_Send[size] = 0; nPoint_Recv[size] = 0; - + for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++ ) { - + /*--- We only write interior points and recovered periodic points. ---*/ - + if (!Local_Halo[iPoint]) { - + /*--- Get the global index of the current point. ---*/ - + Global_Index = geometry->node[iPoint]->GetGlobalIndex(); - + /*--- Search for the processor that owns this point ---*/ - + iProcessor = Global_Index/npoint_procs[0]; if (iProcessor >= (unsigned long)size) iProcessor = (unsigned long)size-1; @@ -15993,83 +15993,83 @@ void COutputLegacy::SortOutputData(CConfig *config, CGeometry *geometry) { while(Global_Index >= nPoint_Linear[iProcessor+1]) iProcessor++; else while(Global_Index < nPoint_Linear[iProcessor]) iProcessor--; - + /*--- If we have not visited this node yet, increment our number of elements that must be sent to a particular proc. ---*/ - + if (nPoint_Flag[iProcessor] != (int)iPoint) { nPoint_Flag[iProcessor] = (int)iPoint; nPoint_Send[iProcessor+1]++; } - + } } - + /*--- Communicate the number of nodes to be sent/recv'd amongst all processors. After this communication, each proc knows how many cells it will receive from each other processor. ---*/ - + #ifdef HAVE_MPI SU2_MPI::Alltoall(&(nPoint_Send[1]), 1, MPI_INT, &(nPoint_Recv[1]), 1, MPI_INT, MPI_COMM_WORLD); #else nPoint_Recv[1] = nPoint_Send[1]; #endif - + /*--- Prepare to send coordinates. First check how many messages we will be sending and receiving. Here we also put the counters into cumulative storage format to make the communications simpler. ---*/ - + int nSends = 0, nRecvs = 0; for (int ii=0; ii < size; ii++) nPoint_Flag[ii] = -1; - + for (int ii = 0; ii < size; ii++) { if ((ii != rank) && (nPoint_Send[ii+1] > 0)) nSends++; if ((ii != rank) && (nPoint_Recv[ii+1] > 0)) nRecvs++; - + nPoint_Send[ii+1] += nPoint_Send[ii]; nPoint_Recv[ii+1] += nPoint_Recv[ii]; } - + /*--- Allocate memory to hold the connectivity that we are sending. ---*/ - + su2double *connSend = NULL; connSend = new su2double[VARS_PER_POINT*nPoint_Send[size]]; for (int ii = 0; ii < VARS_PER_POINT*nPoint_Send[size]; ii++) connSend[ii] = 0; - + /*--- Allocate arrays for sending the global ID. ---*/ - + unsigned long *idSend = new unsigned long[nPoint_Send[size]]; for (int ii = 0; ii < nPoint_Send[size]; ii++) idSend[ii] = 0; - + /*--- Create an index variable to keep track of our index positions as we load up the send buffer. ---*/ - + unsigned long *index = new unsigned long[size]; for (int ii=0; ii < size; ii++) index[ii] = VARS_PER_POINT*nPoint_Send[ii]; - + unsigned long *idIndex = new unsigned long[size]; for (int ii=0; ii < size; ii++) idIndex[ii] = nPoint_Send[ii]; - + /*--- Loop through our elements and load the elems and their additional data that we will send to the other procs. ---*/ - + for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { - + /*--- We only write interior points and recovered periodic points. ---*/ - + if (!Local_Halo[iPoint]) { - + /*--- Get the index of the current point. ---*/ - + Global_Index = geometry->node[iPoint]->GetGlobalIndex(); - + /*--- Search for the processor that owns this point. ---*/ - + iProcessor = Global_Index/npoint_procs[0]; if (iProcessor >= (unsigned long)size) iProcessor = (unsigned long)size-1; @@ -16077,61 +16077,61 @@ void COutputLegacy::SortOutputData(CConfig *config, CGeometry *geometry) { while(Global_Index >= nPoint_Linear[iProcessor+1]) iProcessor++; else while(Global_Index < nPoint_Linear[iProcessor]) iProcessor--; - + /*--- Load node coordinates into the buffer for sending. ---*/ - + if (nPoint_Flag[iProcessor] != (int)iPoint) { - + nPoint_Flag[iProcessor] = (int)iPoint; unsigned long nn = index[iProcessor]; - + /*--- Load the data values. ---*/ - + for (unsigned short kk = 0; kk < VARS_PER_POINT; kk++) { connSend[nn] = Local_Data[iPoint][kk]; nn++; } - + /*--- Load the global ID (minus offset) for sorting the points once they all reach the correct processor. ---*/ - + nn = idIndex[iProcessor]; idSend[nn] = Global_Index - starting_node[iProcessor]; - + /*--- Increment the index by the message length ---*/ - + index[iProcessor] += VARS_PER_POINT; idIndex[iProcessor]++; - + } } } - + /*--- Free memory after loading up the send buffer. ---*/ - + delete [] index; delete [] idIndex; - + /*--- Allocate the memory that we need for receiving the conn values and then cue up the non-blocking receives. Note that we do not include our own rank in the communications. We will directly copy our own data later. ---*/ - + su2double *connRecv = NULL; connRecv = new su2double[VARS_PER_POINT*nPoint_Recv[size]]; for (int ii = 0; ii < VARS_PER_POINT*nPoint_Recv[size]; ii++) connRecv[ii] = 0; - + unsigned long *idRecv = new unsigned long[nPoint_Recv[size]]; for (int ii = 0; ii < nPoint_Recv[size]; ii++) idRecv[ii] = 0; - + #ifdef HAVE_MPI /*--- We need double the number of messages to send both the conn. and the global IDs. ---*/ - + send_req = new SU2_MPI::Request[2*nSends]; recv_req = new SU2_MPI::Request[2*nRecvs]; - + unsigned long iMessage = 0; for (int ii=0; ii nPoint_Recv[ii])) { @@ -16145,9 +16145,9 @@ void COutputLegacy::SortOutputData(CConfig *config, CGeometry *geometry) { iMessage++; } } - + /*--- Launch the non-blocking sends of the connectivity. ---*/ - + iMessage = 0; for (int ii=0; ii nPoint_Send[ii])) { @@ -16161,9 +16161,9 @@ void COutputLegacy::SortOutputData(CConfig *config, CGeometry *geometry) { iMessage++; } } - + /*--- Repeat the process to communicate the global IDs. ---*/ - + iMessage = 0; for (int ii=0; ii nPoint_Recv[ii])) { @@ -16177,9 +16177,9 @@ void COutputLegacy::SortOutputData(CConfig *config, CGeometry *geometry) { iMessage++; } } - + /*--- Launch the non-blocking sends of the global IDs. ---*/ - + iMessage = 0; for (int ii=0; ii nPoint_Send[ii])) { @@ -16194,40 +16194,40 @@ void COutputLegacy::SortOutputData(CConfig *config, CGeometry *geometry) { } } #endif - + /*--- Copy my own rank's data into the recv buffer directly. ---*/ - + int mm = VARS_PER_POINT*nPoint_Recv[rank]; int ll = VARS_PER_POINT*nPoint_Send[rank]; int kk = VARS_PER_POINT*nPoint_Send[rank+1]; - + for (int nn=ll; nnGetnPoint(); iPoint++) delete [] Local_Data[iPoint]; delete [] Local_Data; - + delete [] Local_Halo; delete [] npoint_procs; delete [] starting_node; delete [] ending_node; delete [] nPoint_Linear; - + } void COutputLegacy::SortOutputData_Surface(CConfig *config, CGeometry *geometry) { - + unsigned short iMarker; unsigned long iProcessor; unsigned long iPoint, jPoint, kPoint, iElem; unsigned long Global_Index, nLocalPoint, nTotalPoint, iVertex; - + int VARS_PER_POINT = nVar_Par; int *Local_Halo = NULL; int iNode, count; int SendRecv, RecvFrom; - + bool notPeriodic, notHalo, addedPeriodic, isPeriodic; #ifdef HAVE_MPI @@ -16291,7 +16291,7 @@ void COutputLegacy::SortOutputData_Surface(CConfig *config, CGeometry *geometry) SU2_MPI::Status status; int ind; #endif - + /*--------------------------------------------------------------------------*/ /*--- Step 1: We already have the surface connectivity spread out in ---*/ /*--- linear partitions across all procs and the output data ---*/ @@ -16304,21 +16304,21 @@ void COutputLegacy::SortOutputData_Surface(CConfig *config, CGeometry *geometry) /*--- different between the nodes and elements, so we will ---*/ /*--- have to move between the two systems in this routine. ---*/ /*--------------------------------------------------------------------------*/ - + /*--- Search all send/recv boundaries on this partition for any periodic nodes that were part of the original domain. We want to recover these for visualization purposes. This is the linear partitioning for nodes. ---*/ - + Local_Halo = new int[geometry->GetnPoint()]; for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) Local_Halo[iPoint] = !geometry->node[iPoint]->GetDomain(); - + for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { if (config->GetMarker_All_KindBC(iMarker) == SEND_RECEIVE) { - + /*--- Checking for less than or equal to the rank, because there may be some periodic halo nodes that send info to the same rank. ---*/ - + for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); isPeriodic = ((geometry->vertex[iMarker][iVertex]->GetRotation_Type() > 0) && @@ -16327,48 +16327,48 @@ void COutputLegacy::SortOutputData_Surface(CConfig *config, CGeometry *geometry) } } } - + /*--- Sum total number of nodes that belong to the domain ---*/ - + nLocalPoint = 0; for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) if (Local_Halo[iPoint] == false) nLocalPoint++; - + #ifdef HAVE_MPI SU2_MPI::Allreduce(&nLocalPoint, &nTotalPoint, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); #else nTotalPoint = nLocalPoint; #endif - + /*--- Now that we know the actual number of points we need to output, compute the number of points that will be on each processor. This is a linear partitioning with the addition of a simple load balancing for any remainder points. ---*/ - + unsigned long *npoint_procs = new unsigned long[size]; unsigned long *starting_node = new unsigned long[size]; unsigned long *ending_node = new unsigned long[size]; - + unsigned long *nPoint_Linear_Nodes = new unsigned long[size+1]; unsigned long *nPoint_Linear_Elems = new unsigned long[size+1]; - + unsigned long total_pt_accounted = 0; for (int ii = 0; ii < size; ii++) { npoint_procs[ii] = nTotalPoint/size; total_pt_accounted = total_pt_accounted + npoint_procs[ii]; } - + /*--- Get the number of remainder points after the even division. ---*/ - + unsigned long rem_points = nTotalPoint-total_pt_accounted; for (unsigned long ii = 0; ii < rem_points; ii++) { npoint_procs[ii]++; } - + /*--- Store the local number of nodes and the beginning/end index ---*/ - + starting_node[0] = 0; ending_node[0] = starting_node[0] + npoint_procs[0]; nPoint_Linear_Nodes[0] = 0; @@ -16378,34 +16378,34 @@ void COutputLegacy::SortOutputData_Surface(CConfig *config, CGeometry *geometry) nPoint_Linear_Nodes[ii] = nPoint_Linear_Nodes[ii-1] + npoint_procs[ii-1]; } nPoint_Linear_Nodes[size] = nTotalPoint; - + /*--- Prepare to check and communicate the nodes that each proc has locally from the surface connectivity. ---*/ - + int *nElem_Send = new int[size+1]; nElem_Send[0] = 0; int *nElem_Recv = new int[size+1]; nElem_Recv[0] = 0; int *nElem_Flag = new int[size]; - + for (int ii=0; ii < size; ii++) { nElem_Send[ii] = 0; nElem_Recv[ii] = 0; nElem_Flag[ii]= -1; } nElem_Send[size] = 0; nElem_Recv[size] = 0; - + /*--- Loop through our local line elements and check where each of the grid nodes resides based on global index. ---*/ - + for (int ii = 0; ii < (int)nParallel_Line; ii++) { for ( int jj = 0; jj < N_POINTS_LINE; jj++ ) { - + /*--- Get global index. Note the -1 since it was 1-based for viz. ---*/ - + iNode = ii*N_POINTS_LINE+jj; Global_Index = Conn_BoundLine_Par[iNode]-1; - + /*--- Search for the processor that owns this point ---*/ - + iProcessor = Global_Index/npoint_procs[0]; if (iProcessor >= (unsigned long)size) iProcessor = (unsigned long)size-1; @@ -16413,33 +16413,33 @@ void COutputLegacy::SortOutputData_Surface(CConfig *config, CGeometry *geometry) while(Global_Index >= nPoint_Linear_Nodes[iProcessor+1]) iProcessor++; else while(Global_Index < nPoint_Linear_Nodes[iProcessor]) iProcessor--; - + /*--- If we have not visited this element yet, increment our number of elements that must be sent to a particular proc. ---*/ - + if ((nElem_Flag[iProcessor] != iNode)) { nElem_Flag[iProcessor] = iNode; nElem_Send[iProcessor+1]++; } - + } } - + /*--- Reset out flags and then loop through our local triangle surface elements performing the same check for where each grid node resides. ---*/ - + for (int ii=0; ii < size; ii++) nElem_Flag[ii]= -1; - + for (int ii = 0; ii < (int)nParallel_BoundTria; ii++) { for ( int jj = 0; jj < N_POINTS_TRIANGLE; jj++ ) { - + /*--- Get global index. Note the -1 since it was 1-based for viz. ---*/ - + iNode = ii*N_POINTS_TRIANGLE + jj; Global_Index = Conn_BoundTria_Par[iNode]-1; - + /*--- Search for the processor that owns this point ---*/ - + iProcessor = Global_Index/npoint_procs[0]; if (iProcessor >= (unsigned long)size) iProcessor = (unsigned long)size-1; @@ -16447,33 +16447,33 @@ void COutputLegacy::SortOutputData_Surface(CConfig *config, CGeometry *geometry) while(Global_Index >= nPoint_Linear_Nodes[iProcessor+1]) iProcessor++; else while(Global_Index < nPoint_Linear_Nodes[iProcessor]) iProcessor--; - + /*--- If we have not visited this element yet, increment our number of elements that must be sent to a particular proc. ---*/ - + if ((nElem_Flag[iProcessor] != iNode)) { nElem_Flag[iProcessor] = iNode; nElem_Send[iProcessor+1]++; } - + } } - + /*--- Reset out flags and then loop through our local quad surface elements performing the same check for where each grid node resides. ---*/ - + for (int ii=0; ii < size; ii++) nElem_Flag[ii]= -1; - + for (int ii = 0; ii < (int)nParallel_BoundQuad; ii++) { for ( int jj = 0; jj < N_POINTS_QUADRILATERAL; jj++ ) { - + /*--- Get global index. Note the -1 since it was 1-based for viz. ---*/ - + iNode = ii*N_POINTS_QUADRILATERAL+jj; Global_Index = Conn_BoundQuad_Par[iNode]-1; - + /*--- Search for the processor that owns this point ---*/ - + iProcessor = Global_Index/npoint_procs[0]; if (iProcessor >= (unsigned long)size) iProcessor = (unsigned long)size-1; @@ -16481,69 +16481,69 @@ void COutputLegacy::SortOutputData_Surface(CConfig *config, CGeometry *geometry) while(Global_Index >= nPoint_Linear_Nodes[iProcessor+1]) iProcessor++; else while(Global_Index < nPoint_Linear_Nodes[iProcessor]) iProcessor--; - + /*--- If we have not visited this element yet, increment our number of elements that must be sent to a particular proc. ---*/ - + if ((nElem_Flag[iProcessor] != iNode)) { nElem_Flag[iProcessor] = iNode; nElem_Send[iProcessor+1]++; } - + } } - + /*--- Communicate the number of nodes to be sent/recv'd amongst all processors. After this communication, each proc knows how many nodes it will receive from each other processor. ---*/ - + #ifdef HAVE_MPI SU2_MPI::Alltoall(&(nElem_Send[1]), 1, MPI_INT, &(nElem_Recv[1]), 1, MPI_INT, MPI_COMM_WORLD); #else nElem_Recv[1] = nElem_Send[1]; #endif - + /*--- Prepare to send. First check how many messages we will be sending and receiving. Here we also put the counters into cumulative storage format to make the communications simpler. ---*/ - + int nSends = 0, nRecvs = 0; for (int ii=0; ii < size; ii++) nElem_Flag[ii] = -1; - + for (int ii = 0; ii < size; ii++) { if ((ii != rank) && (nElem_Send[ii+1] > 0)) nSends++; if ((ii != rank) && (nElem_Recv[ii+1] > 0)) nRecvs++; - + nElem_Send[ii+1] += nElem_Send[ii]; nElem_Recv[ii+1] += nElem_Recv[ii]; } - + /*--- Allocate arrays for sending the global ID. ---*/ - + unsigned long *idSend = new unsigned long[nElem_Send[size]]; for (int ii = 0; ii < nElem_Send[size]; ii++) idSend[ii] = 0; - + /*--- Create an index variable to keep track of our index positions as we load up the send buffer. ---*/ - + unsigned long *idIndex = new unsigned long[size]; for (int ii=0; ii < size; ii++) idIndex[ii] = nElem_Send[ii]; - + /*--- Now loop back through the local connectivities for the surface elements and load up the global IDs for sending to their home proc. ---*/ - + for (int ii = 0; ii < (int)nParallel_Line; ii++) { for ( int jj = 0; jj < N_POINTS_LINE; jj++ ) { - + /*--- Get global index. Note the -1 since it was 1-based for viz. ---*/ - + iNode = ii*N_POINTS_LINE+jj; Global_Index = Conn_BoundLine_Par[iNode]-1; - + /*--- Search for the processor that owns this point ---*/ - + iProcessor = Global_Index/npoint_procs[0]; if (iProcessor >= (unsigned long)size) iProcessor = (unsigned long)size-1; @@ -16551,39 +16551,39 @@ void COutputLegacy::SortOutputData_Surface(CConfig *config, CGeometry *geometry) while(Global_Index >= nPoint_Linear_Nodes[iProcessor+1]) iProcessor++; else while(Global_Index < nPoint_Linear_Nodes[iProcessor]) iProcessor--; - + /*--- Load global ID into the buffer for sending ---*/ - + if (nElem_Flag[iProcessor] != iNode) { - + nElem_Flag[iProcessor] = iNode; unsigned long nn = idIndex[iProcessor]; - + /*--- Load the connectivity values. ---*/ - + idSend[nn] = Global_Index; nn++; - + /*--- Increment the index by the message length ---*/ - + idIndex[iProcessor]++; - + } - + } } - + for (int ii=0; ii < size; ii++) nElem_Flag[ii]= -1; - + for (int ii = 0; ii < (int)nParallel_BoundTria; ii++) { for ( int jj = 0; jj < N_POINTS_TRIANGLE; jj++ ) { - + /*--- Get global index. Note the -1 since it was 1-based for viz. ---*/ - + iNode = ii*N_POINTS_TRIANGLE + jj; Global_Index = Conn_BoundTria_Par[iNode]-1; - + /*--- Search for the processor that owns this point ---*/ - + iProcessor = Global_Index/npoint_procs[0]; if (iProcessor >= (unsigned long)size) iProcessor = (unsigned long)size-1; @@ -16591,39 +16591,39 @@ void COutputLegacy::SortOutputData_Surface(CConfig *config, CGeometry *geometry) while(Global_Index >= nPoint_Linear_Nodes[iProcessor+1]) iProcessor++; else while(Global_Index < nPoint_Linear_Nodes[iProcessor]) iProcessor--; - + /*--- Load global ID into the buffer for sending ---*/ - + if (nElem_Flag[iProcessor] != iNode) { - + nElem_Flag[iProcessor] = iNode; unsigned long nn = idIndex[iProcessor]; - + /*--- Load the connectivity values. ---*/ - + idSend[nn] = Global_Index; nn++; - + /*--- Increment the index by the message length ---*/ - + idIndex[iProcessor]++; - + } - + } } - + for (int ii=0; ii < size; ii++) nElem_Flag[ii]= -1; - + for (int ii = 0; ii < (int)nParallel_BoundQuad; ii++) { for ( int jj = 0; jj < N_POINTS_QUADRILATERAL; jj++ ) { - + /*--- Get global index. Note the -1 since it was 1-based for viz. ---*/ - + iNode = ii*N_POINTS_QUADRILATERAL+jj; Global_Index = Conn_BoundQuad_Par[iNode]-1; - + /*--- Search for the processor that owns this point ---*/ - + iProcessor = Global_Index/npoint_procs[0]; if (iProcessor >= (unsigned long)size) iProcessor = (unsigned long)size-1; @@ -16631,46 +16631,46 @@ void COutputLegacy::SortOutputData_Surface(CConfig *config, CGeometry *geometry) while(Global_Index >= nPoint_Linear_Nodes[iProcessor+1]) iProcessor++; else while(Global_Index < nPoint_Linear_Nodes[iProcessor]) iProcessor--; - + /*--- Load global ID into the buffer for sending ---*/ - + if (nElem_Flag[iProcessor] != iNode) { - + nElem_Flag[iProcessor] = iNode; unsigned long nn = idIndex[iProcessor]; - + /*--- Load the connectivity values. ---*/ - + idSend[nn] = Global_Index; nn++; - + /*--- Increment the index by the message length ---*/ - + idIndex[iProcessor]++; - + } - + } } - + /*--- Allocate the memory that we need for receiving the global IDs values and then cue up the non-blocking receives. Note that we do not include our own rank in the communications. We will directly copy our own data later. ---*/ - + unsigned long *idRecv = NULL; idRecv = new unsigned long[nElem_Recv[size]]; for (int ii = 0; ii < nElem_Recv[size]; ii++) idRecv[ii] = 0; - + #ifdef HAVE_MPI /*--- We need double the number of messages to send both the conn. and the flags for the halo cells. ---*/ - + send_req = new SU2_MPI::Request[nSends]; recv_req = new SU2_MPI::Request[nRecvs]; - + /*--- Launch the non-blocking recv's for the global IDs. ---*/ - + unsigned long iMessage = 0; for (int ii=0; ii nElem_Recv[ii])) { @@ -16684,9 +16684,9 @@ void COutputLegacy::SortOutputData_Surface(CConfig *config, CGeometry *geometry) iMessage++; } } - + /*--- Launch the non-blocking sends of the global IDs. ---*/ - + iMessage = 0; for (int ii=0; ii nElem_Send[ii])) { @@ -16701,30 +16701,30 @@ void COutputLegacy::SortOutputData_Surface(CConfig *config, CGeometry *geometry) } } #endif - + /*--- Copy my own rank's data into the recv buffer directly. ---*/ - + int mm = nElem_Recv[rank]; int ll = nElem_Send[rank]; int kk = nElem_Send[rank+1]; - + for (int nn=ll; nn Added_Periodic; Added_Periodic.clear(); - + if (config->GetKind_SU2() != SU2_DEF) { for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { if (config->GetMarker_All_KindBC(iMarker) == SEND_RECEIVE) { SendRecv = config->GetMarker_All_SendRecv(iMarker); for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); - + if ((geometry->vertex[iMarker][iVertex]->GetRotation_Type() > 0) && (geometry->vertex[iMarker][iVertex]->GetRotation_Type() % 2 == 0) && (SendRecv < 0)) { @@ -16860,21 +16860,21 @@ void COutputLegacy::SortOutputData_Surface(CConfig *config, CGeometry *geometry) } } } - + /*--- Now we communicate this information to all processors, so that they can force the removal of these particular nodes by flagging them as halo points. In general, this should be a small percentage of the total mesh, so the communication/storage costs here shouldn't be prohibitive. ---*/ - + /*--- First communicate the number of points that each rank has found. ---*/ - + unsigned long nAddedPeriodic = 0, maxAddedPeriodic = 0; unsigned long Buffer_Send_nAddedPeriodic[1], *Buffer_Recv_nAddedPeriodic = NULL; Buffer_Recv_nAddedPeriodic = new unsigned long[size]; - + nAddedPeriodic = Added_Periodic.size(); Buffer_Send_nAddedPeriodic[0] = nAddedPeriodic; - + #ifdef HAVE_MPI SU2_MPI::Allreduce(&nAddedPeriodic, &maxAddedPeriodic, 1, MPI_UNSIGNED_LONG, MPI_MAX, MPI_COMM_WORLD); @@ -16884,18 +16884,18 @@ void COutputLegacy::SortOutputData_Surface(CConfig *config, CGeometry *geometry) maxAddedPeriodic = nAddedPeriodic; Buffer_Recv_nAddedPeriodic[0] = Buffer_Send_nAddedPeriodic[0]; #endif - + /*--- Communicate the global index values of all added periodic nodes. ---*/ unsigned long *Buffer_Send_AddedPeriodic = new unsigned long[maxAddedPeriodic]; unsigned long *Buffer_Recv_AddedPeriodic = new unsigned long[size*maxAddedPeriodic]; - + for (iPoint = 0; iPoint < Added_Periodic.size(); iPoint++) { Buffer_Send_AddedPeriodic[iPoint] = Added_Periodic[iPoint]; } - + /*--- Gather the element connectivity information. All processors will now have a copy of the global index values for all added periodic points. ---*/ - + #ifdef HAVE_MPI SU2_MPI::Allgather(Buffer_Send_AddedPeriodic, maxAddedPeriodic, MPI_UNSIGNED_LONG, Buffer_Recv_AddedPeriodic, maxAddedPeriodic, MPI_UNSIGNED_LONG, @@ -16904,103 +16904,103 @@ void COutputLegacy::SortOutputData_Surface(CConfig *config, CGeometry *geometry) for (iPoint = 0; iPoint < maxAddedPeriodic; iPoint++) Buffer_Recv_AddedPeriodic[iPoint] = Buffer_Send_AddedPeriodic[iPoint]; #endif - + /*--- Search all send/recv boundaries on this partition for halo cells. In particular, consider only the recv conditions (these are the true halo nodes). Check the ranks of the processors that are communicating and choose to keep only the halo cells from the higher rank processor. Here, we are also choosing to keep periodic nodes that were part of the original domain. We will check the communicated list of added periodic points. ---*/ - + for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) Local_Halo[iPoint] = !geometry->node[iPoint]->GetDomain(); - + for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { if (config->GetMarker_All_KindBC(iMarker) == SEND_RECEIVE) { SendRecv = config->GetMarker_All_SendRecv(iMarker); RecvFrom = abs(SendRecv)-1; - + for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); Global_Index = geometry->node[iPoint]->GetGlobalIndex(); - + /*--- We need to keep one copy of overlapping halo cells. ---*/ - + notHalo = ((geometry->vertex[iMarker][iVertex]->GetRotation_Type() == 0) && (SendRecv < 0) && (rank > RecvFrom)); - + /*--- We want to keep the periodic nodes that were part of the original domain. For SU2_DEF we want to keep all periodic nodes. ---*/ - + if (config->GetKind_SU2() == SU2_DEF) { isPeriodic = ((geometry->vertex[iMarker][iVertex]->GetRotation_Type() > 0)); }else { isPeriodic = ((geometry->vertex[iMarker][iVertex]->GetRotation_Type() > 0) && (geometry->vertex[iMarker][iVertex]->GetRotation_Type() % 2 == 1)); } - + notPeriodic = (isPeriodic && (SendRecv < 0)); - + /*--- Lastly, check that this isn't an added periodic point that we will forcibly remove. Use the communicated list of these points. ---*/ - + addedPeriodic = false; kPoint = 0; for (iProcessor = 0; iProcessor < (unsigned long)size; iProcessor++) { for (jPoint = 0; jPoint < Buffer_Recv_nAddedPeriodic[iProcessor]; jPoint++) { if (Global_Index == Buffer_Recv_AddedPeriodic[kPoint+jPoint]) addedPeriodic = true; } - + /*--- Adjust jNode to index of next proc's data in the buffers. ---*/ - + kPoint = (iProcessor+1)*maxAddedPeriodic; - + } - + /*--- If we found either of these types of nodes, flag them to be kept. ---*/ - + if ((notHalo || notPeriodic) && !addedPeriodic) { Local_Halo[iPoint] = false; } - + } } } - + /*--- Now that we've done the gymnastics to find any periodic points, compute the total number of local and global points for the output. ---*/ - + nLocalPoint = 0; for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) if (Local_Halo[iPoint] == false) nLocalPoint++; - + #ifdef HAVE_MPI SU2_MPI::Allreduce(&nLocalPoint, &nTotalPoint, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); #else nTotalPoint = nLocalPoint; #endif - + /*--- Compute the number of points that will be on each processor. This is a linear partitioning with the addition of a simple load balancing for any remainder points. ---*/ - + total_pt_accounted = 0; for (int ii = 0; ii < size; ii++) { npoint_procs[ii] = nTotalPoint/size; total_pt_accounted = total_pt_accounted + npoint_procs[ii]; } - + /*--- Get the number of remainder points after the even division. ---*/ - + rem_points = nTotalPoint-total_pt_accounted; for (unsigned long ii = 0; ii < rem_points; ii++) { npoint_procs[ii]++; } - + /*--- Store the local number of nodes and the beginning/end index ---*/ - + starting_node[0] = 0; ending_node[0] = starting_node[0] + npoint_procs[0]; nPoint_Linear_Elems[0] = 0; @@ -17010,25 +17010,25 @@ void COutputLegacy::SortOutputData_Surface(CConfig *config, CGeometry *geometry) nPoint_Linear_Elems[ii] = nPoint_Linear_Elems[ii-1] + npoint_procs[ii-1]; } nPoint_Linear_Elems[size] = nTotalPoint; - + /*--- Reset our flags and counters ---*/ - + for (int ii=0; ii < size; ii++) { nElem_Send[ii] = 0; nElem_Recv[ii] = 0; nElem_Flag[ii]= -1; } nElem_Send[size] = 0; nElem_Recv[size] = 0; - + /*--- Loop through my local surface nodes, find which proc the global value lives on, then communicate the global ID and remumbered value. ---*/ - + for (int ii = 0; ii < (int)nSurf_Poin_Par; ii++) { - + Global_Index = globalP[ii]; - + /*--- Search for the processor that owns this point ---*/ - + iProcessor = Global_Index/npoint_procs[0]; if (iProcessor >= (unsigned long)size) iProcessor = (unsigned long)size-1; @@ -17036,75 +17036,75 @@ void COutputLegacy::SortOutputData_Surface(CConfig *config, CGeometry *geometry) while(Global_Index >= nPoint_Linear_Elems[iProcessor+1]) iProcessor++; else while(Global_Index < nPoint_Linear_Elems[iProcessor]) iProcessor--; - + /*--- If we have not visited this element yet, increment our number of elements that must be sent to a particular proc. ---*/ - + if ((nElem_Flag[iProcessor] != ii)) { nElem_Flag[iProcessor] = ii; nElem_Send[iProcessor+1]++; } - + } - + /*--- Communicate the number of cells to be sent/recv'd amongst all processors. After this communication, each proc knows how many cells it will receive from each other processor. ---*/ - + #ifdef HAVE_MPI SU2_MPI::Alltoall(&(nElem_Send[1]), 1, MPI_INT, &(nElem_Recv[1]), 1, MPI_INT, MPI_COMM_WORLD); #else nElem_Recv[1] = nElem_Send[1]; #endif - + /*--- Prepare to send. First check how many messages we will be sending and receiving. Here we also put the counters into cumulative storage format to make the communications simpler. ---*/ - + nSends = 0; nRecvs = 0; for (int ii=0; ii < size; ii++) nElem_Flag[ii] = -1; - + for (int ii = 0; ii < size; ii++) { if ((ii != rank) && (nElem_Send[ii+1] > 0)) nSends++; if ((ii != rank) && (nElem_Recv[ii+1] > 0)) nRecvs++; - + nElem_Send[ii+1] += nElem_Send[ii]; nElem_Recv[ii+1] += nElem_Recv[ii]; } - + /*--- Allocate memory to hold the globals that we are sending. ---*/ - + unsigned long *globalSend = NULL; globalSend = new unsigned long[nElem_Send[size]]; for (int ii = 0; ii < nElem_Send[size]; ii++) globalSend[ii] = 0; - + /*--- Allocate memory to hold the renumbering that we are sending. ---*/ - + unsigned long *renumbSend = NULL; renumbSend = new unsigned long[nElem_Send[size]]; for (int ii = 0; ii < nElem_Send[size]; ii++) renumbSend[ii] = 0; - + /*--- Create an index variable to keep track of our index position as we load up the send buffer. ---*/ - + unsigned long *index = new unsigned long[size]; for (int ii=0; ii < size; ii++) index[ii] = nElem_Send[ii]; - + /*--- Loop back through and load up the buffers for the global IDs and their new renumbering values. ---*/ - + for (int ii = 0; ii < (int)nSurf_Poin_Par; ii++) { - + Global_Index = globalP[ii]; - + /*--- Search for the processor that owns this point ---*/ - + iProcessor = Global_Index/npoint_procs[0]; if (iProcessor >= (unsigned long)size) iProcessor = (unsigned long)size-1; @@ -17112,51 +17112,51 @@ void COutputLegacy::SortOutputData_Surface(CConfig *config, CGeometry *geometry) while(Global_Index >= nPoint_Linear_Elems[iProcessor+1]) iProcessor++; else while(Global_Index < nPoint_Linear_Elems[iProcessor]) iProcessor--; - - + + if (nElem_Flag[iProcessor] != ii) { - + nElem_Flag[iProcessor] = ii; unsigned long nn = index[iProcessor]; - + globalSend[nn] = Global_Index; renumbSend[nn] = renumbP[ii]; - + /*--- Increment the index by the message length ---*/ - + index[iProcessor]++; - + } } - + /*--- Free memory after loading up the send buffer. ---*/ - + delete [] index; - + /*--- Allocate the memory that we need for receiving the values and then cue up the non-blocking receives. Note that we do not include our own rank in the communications. We will directly copy our own data later. ---*/ - + unsigned long *globalRecv = NULL; globalRecv = new unsigned long[nElem_Recv[size]]; for (int ii = 0; ii < nElem_Recv[size]; ii++) globalRecv[ii] = 0; - + unsigned long *renumbRecv = NULL; renumbRecv = new unsigned long[nElem_Recv[size]]; for (int ii = 0; ii < nElem_Recv[size]; ii++) renumbRecv[ii] = 0; - + #ifdef HAVE_MPI /*--- We need double the number of messages to send both the conn. and the flags for the halo cells. ---*/ - + send_req = new SU2_MPI::Request[2*nSends]; recv_req = new SU2_MPI::Request[2*nRecvs]; - + /*--- Launch the non-blocking recv's for the global ID. ---*/ - + iMessage = 0; for (int ii=0; ii nElem_Recv[ii])) { @@ -17170,9 +17170,9 @@ void COutputLegacy::SortOutputData_Surface(CConfig *config, CGeometry *geometry) iMessage++; } } - + /*--- Launch the non-blocking sends of the global ID. ---*/ - + iMessage = 0; for (int ii=0; ii nElem_Send[ii])) { @@ -17186,9 +17186,9 @@ void COutputLegacy::SortOutputData_Surface(CConfig *config, CGeometry *geometry) iMessage++; } } - + /*--- Launch the non-blocking recv's for the renumbered ID. ---*/ - + iMessage = 0; for (int ii=0; ii nElem_Recv[ii])) { @@ -17202,9 +17202,9 @@ void COutputLegacy::SortOutputData_Surface(CConfig *config, CGeometry *geometry) iMessage++; } } - + /*--- Launch the non-blocking sends of the renumbered ID. ---*/ - + iMessage = 0; for (int ii=0; ii nElem_Send[ii])) { @@ -17218,66 +17218,66 @@ void COutputLegacy::SortOutputData_Surface(CConfig *config, CGeometry *geometry) iMessage++; } } - + #endif - + /*--- Load our own procs data into the buffers directly. ---*/ - + mm = nElem_Recv[rank]; ll = nElem_Send[rank]; kk = nElem_Send[rank+1]; - + for (int nn=ll; nn renumber for nodes. Note the adding of 1 back in here for the eventual viz. purposes. ---*/ - + map Global2Renumber; for (int ii = 0; ii < nElem_Recv[size]; ii++) { Global2Renumber[globalRecv[ii]] = renumbRecv[ii] + 1; } - - + + /*--- The final step is one last pass over all elements to check for points outside of the linear partitions of the elements. Again, note that elems were distributed based on their smallest global ID, so some nodes of the elem may have global IDs lying outside of the linear partitioning. We need to recover the mapping for these outliers. We loop over all local surface elements to find these. ---*/ - + vector::iterator it; vector outliers; - + for (int ii = 0; ii < (int)nParallel_Line; ii++) { for ( int jj = 0; jj < N_POINTS_LINE; jj++ ) { - + iNode = ii*N_POINTS_LINE+jj; Global_Index = Conn_BoundLine_Par[iNode]-1; - + /*--- Search for the processor that owns this point ---*/ - + iProcessor = Global_Index/npoint_procs[0]; if (iProcessor >= (unsigned long)size) iProcessor = (unsigned long)size-1; @@ -17285,26 +17285,26 @@ void COutputLegacy::SortOutputData_Surface(CConfig *config, CGeometry *geometry) while(Global_Index >= nPoint_Linear_Elems[iProcessor+1]) iProcessor++; else while(Global_Index < nPoint_Linear_Elems[iProcessor]) iProcessor--; - + /*--- Store the global ID if it is outside our own linear partition. ---*/ - + if ((iProcessor != (unsigned long)rank)) { outliers.push_back(Global_Index); } - + } } - + for (int ii=0; ii < size; ii++) nElem_Flag[ii]= -1; - + for (int ii = 0; ii < (int)nParallel_BoundTria; ii++) { for ( int jj = 0; jj < N_POINTS_TRIANGLE; jj++ ) { - + iNode = ii*N_POINTS_TRIANGLE + jj; Global_Index = Conn_BoundTria_Par[iNode]-1; - + /*--- Search for the processor that owns this point ---*/ - + iProcessor = Global_Index/npoint_procs[0]; if (iProcessor >= (unsigned long)size) iProcessor = (unsigned long)size-1; @@ -17312,26 +17312,26 @@ void COutputLegacy::SortOutputData_Surface(CConfig *config, CGeometry *geometry) while(Global_Index >= nPoint_Linear_Elems[iProcessor+1]) iProcessor++; else while(Global_Index < nPoint_Linear_Elems[iProcessor]) iProcessor--; - + /*--- Store the global ID if it is outside our own linear partition. ---*/ - + if ((iProcessor != (unsigned long)rank)) { outliers.push_back(Global_Index); } - + } } - + for (int ii=0; ii < size; ii++) nElem_Flag[ii]= -1; - + for (int ii = 0; ii < (int)nParallel_BoundQuad; ii++) { for ( int jj = 0; jj < N_POINTS_QUADRILATERAL; jj++ ) { - + iNode = ii*N_POINTS_QUADRILATERAL+jj; Global_Index = Conn_BoundQuad_Par[iNode]-1; - + /*--- Search for the processor that owns this point ---*/ - + iProcessor = Global_Index/npoint_procs[0]; if (iProcessor >= (unsigned long)size) iProcessor = (unsigned long)size-1; @@ -17339,40 +17339,40 @@ void COutputLegacy::SortOutputData_Surface(CConfig *config, CGeometry *geometry) while(Global_Index >= nPoint_Linear_Elems[iProcessor+1]) iProcessor++; else while(Global_Index < nPoint_Linear_Elems[iProcessor]) iProcessor--; - + /*--- Store the global ID if it is outside our own linear partition. ---*/ - + if ((iProcessor != (unsigned long)rank)) { outliers.push_back(Global_Index); } - + } } - + /*--- Create a unique list of global IDs that fall outside of our procs linear partition. ---*/ - + sort(outliers.begin(), outliers.end()); it = unique(outliers.begin(), outliers.end()); outliers.resize(it - outliers.begin()); - + /*--- Now loop over the outliers and communicate to those procs that hold the new numbering for our outlier points. We need to ask for the new numbering from these procs. ---*/ - + for (int ii=0; ii < size; ii++) { nElem_Send[ii] = 0; nElem_Recv[ii] = 0; nElem_Flag[ii]= -1; } nElem_Send[size] = 0; nElem_Recv[size] = 0; - + for (int ii = 0; ii < (int)outliers.size(); ii++) { - + Global_Index = outliers[ii]; - + /*--- Search for the processor that owns this point ---*/ - + iProcessor = Global_Index/npoint_procs[0]; if (iProcessor >= (unsigned long)size) iProcessor = (unsigned long)size-1; @@ -17380,61 +17380,61 @@ void COutputLegacy::SortOutputData_Surface(CConfig *config, CGeometry *geometry) while(Global_Index >= nPoint_Linear_Nodes[iProcessor+1]) iProcessor++; else while(Global_Index < nPoint_Linear_Nodes[iProcessor]) iProcessor--; - + /*--- If we have not visited this element yet, increment our number of elements that must be sent to a particular proc. ---*/ - + if ((nElem_Flag[iProcessor] != ii)) { nElem_Flag[iProcessor] = ii; nElem_Send[iProcessor+1]++; } - + } - + /*--- Communicate the number of cells to be sent/recv'd amongst all processors. After this communication, each proc knows how many cells it will receive from each other processor. ---*/ - + #ifdef HAVE_MPI SU2_MPI::Alltoall(&(nElem_Send[1]), 1, MPI_INT, &(nElem_Recv[1]), 1, MPI_INT, MPI_COMM_WORLD); #else nElem_Recv[1] = nElem_Send[1]; #endif - + /*--- Prepare to send connectivities. First check how many messages we will be sending and receiving. Here we also put the counters into cumulative storage format to make the communications simpler. ---*/ - + nSends = 0; nRecvs = 0; for (int ii=0; ii < size; ii++) nElem_Flag[ii] = -1; - + for (int ii = 0; ii < size; ii++) { if ((ii != rank) && (nElem_Send[ii+1] > 0)) nSends++; if ((ii != rank) && (nElem_Recv[ii+1] > 0)) nRecvs++; - + nElem_Send[ii+1] += nElem_Send[ii]; nElem_Recv[ii+1] += nElem_Recv[ii]; } - + delete [] idSend; idSend = new unsigned long[nElem_Send[size]]; for (int ii = 0; ii < nElem_Send[size]; ii++) idSend[ii] = 0; - + /*--- Reset our index variable for reuse. ---*/ - + for (int ii=0; ii < size; ii++) idIndex[ii] = nElem_Send[ii]; - + /*--- Loop over the outliers again and load up the global IDs. ---*/ - + for (int ii = 0; ii < (int)outliers.size(); ii++) { - + Global_Index = outliers[ii]; - + /*--- Search for the processor that owns this point ---*/ - + iProcessor = Global_Index/npoint_procs[0]; if (iProcessor >= (unsigned long)size) iProcessor = (unsigned long)size-1; @@ -17442,45 +17442,45 @@ void COutputLegacy::SortOutputData_Surface(CConfig *config, CGeometry *geometry) while(Global_Index >= nPoint_Linear_Nodes[iProcessor+1]) iProcessor++; else while(Global_Index < nPoint_Linear_Nodes[iProcessor]) iProcessor--; - + /*--- If we have not visited this element yet, increment our number of elements that must be sent to a particular proc. ---*/ - + if ((nElem_Flag[iProcessor] != ii)) { - + nElem_Flag[iProcessor] = ii; unsigned long nn = idIndex[iProcessor]; - + /*--- Load the global ID values. ---*/ - + idSend[nn] = Global_Index; nn++; - + /*--- Increment the index by the message length ---*/ - + idIndex[iProcessor]++; - + } } - + /*--- Allocate the memory that we need for receiving the values and then cue up the non-blocking receives. Note that we do not include our own rank in the communications. We will directly copy our own data later. ---*/ - + delete [] idRecv; idRecv = new unsigned long[nElem_Recv[size]]; for (int ii = 0; ii < nElem_Recv[size]; ii++) idRecv[ii] = 0; - + #ifdef HAVE_MPI /*--- We need double the number of messages to send both the conn. and the flags for the halo cells. ---*/ - + send_req = new SU2_MPI::Request[nSends]; recv_req = new SU2_MPI::Request[nRecvs]; - + /*--- Launch the non-blocking recv's for the connectivity. ---*/ - + iMessage = 0; for (int ii=0; ii nElem_Recv[ii])) { @@ -17494,9 +17494,9 @@ void COutputLegacy::SortOutputData_Surface(CConfig *config, CGeometry *geometry) iMessage++; } } - + /*--- Launch the non-blocking sends of the connectivity. ---*/ - + iMessage = 0; for (int ii=0; ii nElem_Send[ii])) { @@ -17511,33 +17511,33 @@ void COutputLegacy::SortOutputData_Surface(CConfig *config, CGeometry *geometry) } } #endif - + /*--- Copy my own rank's data into the recv buffer directly. ---*/ - + mm = nElem_Recv[rank]; ll = nElem_Send[rank]; kk = nElem_Send[rank+1]; - + for (int nn=ll; nn nElem_Send[ii])) { @@ -17571,9 +17571,9 @@ void COutputLegacy::SortOutputData_Surface(CConfig *config, CGeometry *geometry) iMessage++; } } - + /*--- Launch the non-blocking recv's for the connectivity. ---*/ - + iMessage = 0; for (int ii=0; ii nElem_Recv[ii])) { @@ -17588,55 +17588,55 @@ void COutputLegacy::SortOutputData_Surface(CConfig *config, CGeometry *geometry) } } #endif - + /*--- Copy my own rank's data into the recv buffer directly. ---*/ - + mm = nElem_Send[rank]; ll = nElem_Recv[rank]; kk = nElem_Recv[rank+1]; - + for (int nn=ll; nn renumber transformation. Note that by construction, + the global -> renumber transformation. Note that by construction, nElem_Send[ii] == outliers.size(). We also add in the 1 for viz. here. ---*/ - + for (int ii = 0; ii < nElem_Send[size]; ii++) { Global2Renumber[outliers[ii]] = idSend[ii] + 1; } - + /*--- We can now overwrite the local connectivity for our surface elems using our completed map with the new global renumbering. Whew!! Note the -1 when accessing the conn from the map. ---*/ - + for (iElem = 0; iElem < nParallel_Line; iElem++) { iNode = (int)iElem*N_POINTS_LINE; Conn_BoundLine_Par[iNode+0] = (int)Global2Renumber[Conn_BoundLine_Par[iNode+0]-1]; Conn_BoundLine_Par[iNode+1] = (int)Global2Renumber[Conn_BoundLine_Par[iNode+1]-1]; } - + for (iElem = 0; iElem < nParallel_BoundTria; iElem++) { iNode = (int)iElem*N_POINTS_TRIANGLE; Conn_BoundTria_Par[iNode+0] = (int)Global2Renumber[Conn_BoundTria_Par[iNode+0]-1]; Conn_BoundTria_Par[iNode+1] = (int)Global2Renumber[Conn_BoundTria_Par[iNode+1]-1]; Conn_BoundTria_Par[iNode+2] = (int)Global2Renumber[Conn_BoundTria_Par[iNode+2]-1]; } - + for (iElem = 0; iElem < nParallel_BoundQuad; iElem++) { iNode = (int)iElem*N_POINTS_QUADRILATERAL; Conn_BoundQuad_Par[iNode+0] = (int)Global2Renumber[Conn_BoundQuad_Par[iNode+0]-1]; @@ -17644,14 +17644,14 @@ void COutputLegacy::SortOutputData_Surface(CConfig *config, CGeometry *geometry) Conn_BoundQuad_Par[iNode+2] = (int)Global2Renumber[Conn_BoundQuad_Par[iNode+2]-1]; Conn_BoundQuad_Par[iNode+3] = (int)Global2Renumber[Conn_BoundQuad_Par[iNode+3]-1]; } - + /*--- Free temporary memory ---*/ - + delete [] idIndex; delete [] surfPoint; delete [] globalP; delete [] renumbP; - + delete [] idSend; delete [] idRecv; delete [] globalSend; @@ -17672,13 +17672,13 @@ void COutputLegacy::SortOutputData_Surface(CConfig *config, CGeometry *geometry) delete [] nPoint_Linear_Nodes; delete [] nPoint_Send; delete [] nPoint_Recv; - + } void COutputLegacy::WriteRestart_Parallel_ASCII(CConfig *config, CGeometry *geometry, CSolver **solver, unsigned short val_iZone, unsigned short val_iInst) { - + /*--- Local variables ---*/ - + unsigned short nZone = geometry->GetnZone(), nInst = config->GetnTimeInstances(); unsigned short iVar; unsigned long iPoint, iExtIter = config->GetInnerIter(); @@ -17688,11 +17688,11 @@ void COutputLegacy::WriteRestart_Parallel_ASCII(CConfig *config, CGeometry *geom config->GetDiscrete_Adjoint()); ofstream restart_file; string filename; - + int iProcessor; /*--- Retrieve filename from config ---*/ - + // if ((config->GetContinuous_Adjoint()) || (config->GetDiscrete_Adjoint())) { // filename = config->GetRestart_AdjFileName(); // filename = config->GetObjFunc_Extension(filename); @@ -17703,11 +17703,11 @@ void COutputLegacy::WriteRestart_Parallel_ASCII(CConfig *config, CGeometry *geom // } else { // filename = config->GetRestart_FileName(); // } - + /*--- Append the zone number if multizone problems ---*/ if (nZone > 1) filename= config->GetMultizone_FileName(filename, val_iZone, ".dat"); - + /*--- Append the zone number if multiple instance problems ---*/ if (nInst > 1) filename= config->GetMultiInstance_FileName(filename, val_iInst, ".dat"); @@ -17720,9 +17720,9 @@ void COutputLegacy::WriteRestart_Parallel_ASCII(CConfig *config, CGeometry *geom } else if ((fem || disc_adj_fem) && (config->GetWrt_Dynamic())) { filename = config->GetUnsteady_FileName(filename, SU2_TYPE::Int(iExtIter), ".dat"); } - + /*--- Only the master node writes the header. ---*/ - + if (rank == MASTER_NODE) { restart_file.open(filename.c_str(), ios::out); restart_file.precision(15); @@ -17732,39 +17732,39 @@ void COutputLegacy::WriteRestart_Parallel_ASCII(CConfig *config, CGeometry *geom restart_file << "\t\"" << Variable_Names[Variable_Names.size()-1] << "\"" << endl; restart_file.close(); } - + #ifdef HAVE_MPI SU2_MPI::Barrier(MPI_COMM_WORLD); #endif - + /*--- All processors open the file. ---*/ - + restart_file.open(filename.c_str(), ios::out | ios::app); restart_file.precision(15); - + /*--- Write the restart file in parallel, processor by processor. ---*/ - + unsigned long myPoint = 0, offset = 0, Global_Index; for (iProcessor = 0; iProcessor < size; iProcessor++) { if (rank == iProcessor) { for (iPoint = 0; iPoint < nParallel_Poin; iPoint++) { - + /*--- Global Index of the current point. (note outer loop over procs) ---*/ - + Global_Index = iPoint + offset; - + /*--- Only write original domain points, i.e., exclude any periodic or halo nodes, even if they are output in the viz. files. ---*/ - + if (Global_Index < nPoint_Restart) { - + /*--- Write global index. (note outer loop over procs) ---*/ - + restart_file << Global_Index << "\t"; myPoint++; - + /*--- Loop over the variables and write the values to file ---*/ - + for (iVar = 0; iVar < nVar_Par; iVar++) { restart_file << scientific << Parallel_Data[iVar][iPoint] << "\t"; } @@ -17778,7 +17778,7 @@ void COutputLegacy::WriteRestart_Parallel_ASCII(CConfig *config, CGeometry *geom SU2_MPI::Allreduce(&myPoint, &offset, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); SU2_MPI::Barrier(MPI_COMM_WORLD); #endif - + } /*--- Write the metadata (master rank alone) ----*/ @@ -17809,7 +17809,7 @@ void COutputLegacy::WriteRestart_Parallel_ASCII(CConfig *config, CGeometry *geom /*--- All processors close the file. ---*/ restart_file.close(); - + } void COutputLegacy::WriteRestart_Parallel_Binary(CConfig *config, CGeometry *geometry, CSolver **solver, unsigned short val_iZone, unsigned short val_iInst) { @@ -17862,7 +17862,7 @@ void COutputLegacy::WriteRestart_Parallel_Binary(CConfig *config, CGeometry *geo /*--- Prepare the first ints containing the counts. The first is a magic number that we can use to check for binary files (it is the hex representation for "SU2"). The second two values are number of variables - and number of points (DoFs). The last two values are for metadata: + and number of points (DoFs). The last two values are for metadata: one int for ExtIter and 8 su2doubles. ---*/ int var_buf_size = 5; @@ -17908,13 +17908,13 @@ void COutputLegacy::WriteRestart_Parallel_Binary(CConfig *config, CGeometry *geo } /*--- Set a timer for the binary file writing. ---*/ - + #ifndef HAVE_MPI StartTime = su2double(clock())/su2double(CLOCKS_PER_SEC); #else StartTime = MPI_Wtime(); #endif - + #ifndef HAVE_MPI FILE* fhw; @@ -17930,9 +17930,9 @@ void COutputLegacy::WriteRestart_Parallel_Binary(CConfig *config, CGeometry *geo fwrite(var_buf, var_buf_size, sizeof(int), fhw); file_size += (su2double)var_buf_size*sizeof(int); - + /*--- Write the variable names to the file. Note that we are adopting a - fixed length of 33 for the string length to match with CGNS. This is + fixed length of 33 for the string length to match with CGNS. This is needed for when we read the strings later. ---*/ for (iVar = 0; iVar < nVar_Par; iVar++) { @@ -18004,7 +18004,7 @@ void COutputLegacy::WriteRestart_Parallel_Binary(CConfig *config, CGeometry *geo } /*--- First, write the number of variables and points (i.e., cols and rows), - which we will need in order to read the file later. Also, write the + which we will need in order to read the file later. Also, write the variable string names here. Only the master rank writes the header. ---*/ if (rank == MASTER_NODE) { @@ -18075,32 +18075,32 @@ void COutputLegacy::WriteRestart_Parallel_Binary(CConfig *config, CGeometry *geo #endif /*--- Compute and store the write time. ---*/ - + #ifndef HAVE_MPI StopTime = su2double(clock())/su2double(CLOCKS_PER_SEC); #else StopTime = MPI_Wtime(); #endif UsedTime = StopTime-StartTime; - + /*--- Communicate the total file size for the restart ---*/ - + #ifdef HAVE_MPI su2double my_file_size = file_size; SU2_MPI::Allreduce(&my_file_size, &file_size, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); #endif - + /*--- Compute and store the bandwidth ---*/ - + Bandwidth = file_size/(1.0e6)/UsedTime; config->SetRestart_Bandwidth_Agg(config->GetRestart_Bandwidth_Agg()+Bandwidth); - + if ((rank == MASTER_NODE) && (wrt_perf)) { cout << "Wrote " << file_size/1.0e6 << " MB to disk in "; cout << UsedTime << " s. (" << Bandwidth << " MB/s)." << endl; } - + /*--- Free temporary data buffer for writing the binary file. ---*/ delete [] buf; @@ -18355,13 +18355,13 @@ void COutputLegacy::WriteCSV_Slice(CConfig *config, CGeometry *geometry, delete [] Buffer_Send_Data; delete [] Buffer_Send_GlobalIndex; - + } void COutputLegacy::DeallocateConnectivity_Parallel(CConfig *config, CGeometry *geometry, bool surf_sol) { - + /*--- Deallocate memory for connectivity data on each processor. ---*/ - + if (surf_sol) { if (Conn_BoundLine_Par != NULL) delete [] Conn_BoundLine_Par; if (Conn_BoundTria_Par != NULL) delete [] Conn_BoundTria_Par; @@ -18375,13 +18375,13 @@ void COutputLegacy::DeallocateConnectivity_Parallel(CConfig *config, CGeometry * if (Conn_Pris_Par != NULL) delete [] Conn_Pris_Par; if (Conn_Pyra_Par != NULL) delete [] Conn_Pyra_Par; } - + } void COutputLegacy::DeallocateData_Parallel(CConfig *config, CGeometry *geometry) { - + /*--- Deallocate memory for solution data ---*/ - + for (unsigned short iVar = 0; iVar < nVar_Par; iVar++) { if (Parallel_Data[iVar] != NULL) delete [] Parallel_Data[iVar]; } @@ -18400,18 +18400,18 @@ void COutputLegacy::DeallocateData_Parallel(CConfig *config, CGeometry *geometry } void COutputLegacy::DeallocateSurfaceData_Parallel(CConfig *config, CGeometry *geometry) { - + /*--- Deallocate memory for surface solution data ---*/ for (unsigned short iVar = 0; iVar < nVar_Par; iVar++) { if (Parallel_Surf_Data[iVar] != NULL) delete [] Parallel_Surf_Data[iVar]; } if (Parallel_Surf_Data != NULL) delete [] Parallel_Surf_Data; - + } void COutputLegacy::SpecialOutput_AnalyzeSurface(CSolver *solver, CGeometry *geometry, CConfig *config, bool output) { - + unsigned short iDim, iMarker, iMarker_Analyze; unsigned long iVertex, iPoint; su2double Mach = 0.0, Pressure, Temperature = 0.0, TotalPressure = 0.0, TotalTemperature = 0.0, @@ -18431,7 +18431,7 @@ void COutputLegacy::SpecialOutput_AnalyzeSurface(CSolver *solver, CGeometry *geo bool axisymmetric = config->GetAxisymmetric(); unsigned short nMarker_Analyze = config->GetnMarker_Analyze(); - + su2double *Vector = new su2double[nDim]; su2double *Surface_MassFlow = new su2double[nMarker]; su2double *Surface_Mach = new su2double[nMarker]; @@ -18447,11 +18447,11 @@ void COutputLegacy::SpecialOutput_AnalyzeSurface(CSolver *solver, CGeometry *geo su2double *Surface_VelocityIdeal = new su2double[nMarker]; su2double *Surface_Area = new su2double[nMarker]; su2double *Surface_MassFlow_Abs = new su2double[nMarker]; - + /*--- Compute the numerical fan face Mach number, and the total area of the inflow ---*/ - + for (iMarker = 0; iMarker < nMarker; iMarker++) { - + Surface_MassFlow[iMarker] = 0.0; Surface_Mach[iMarker] = 0.0; Surface_Temperature[iMarker] = 0.0; @@ -18468,14 +18468,14 @@ void COutputLegacy::SpecialOutput_AnalyzeSurface(CSolver *solver, CGeometry *geo Surface_MassFlow_Abs[iMarker] = 0.0; if (config->GetMarker_All_Analyze(iMarker) == YES) { - + for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); - + if (geometry->node[iPoint]->GetDomain()) { - + geometry->vertex[iMarker][iVertex]->GetNormal(Vector); - + if (axisymmetric) { if (geometry->node[iPoint]->GetCoord(1) != 0.0) AxiFactor = 2.0*PI_NUMBER*geometry->node[iPoint]->GetCoord(1); @@ -18495,7 +18495,7 @@ void COutputLegacy::SpecialOutput_AnalyzeSurface(CSolver *solver, CGeometry *geo Vn += Velocity[iDim] * Vector[iDim] * AxiFactor; MassFlow += Vector[iDim] * AxiFactor * Density * Velocity[iDim]; } - + Area = sqrt (Area); if (AxiFactor == 0.0) Vn = 0.0; else Vn /= Area; Vn2 = Vn * Vn; @@ -18537,7 +18537,7 @@ void COutputLegacy::SpecialOutput_AnalyzeSurface(CSolver *solver, CGeometry *geo if (Kind_Average == AVERAGE_MASSFLUX) Weight = abs(MassFlow); else if (Kind_Average == AVERAGE_AREA) Weight = abs(Area); else Weight = 1.0; - + Surface_Mach[iMarker] += Mach*Weight; Surface_Temperature[iMarker] += Temperature*Weight; Surface_Density[iMarker] += Density*Weight; @@ -18556,13 +18556,13 @@ void COutputLegacy::SpecialOutput_AnalyzeSurface(CSolver *solver, CGeometry *geo } } - + } - + } - + /*--- Copy to the appropriate structure ---*/ - + su2double *Surface_MassFlow_Local = new su2double [nMarker_Analyze]; su2double *Surface_Mach_Local = new su2double [nMarker_Analyze]; su2double *Surface_Temperature_Local = new su2double [nMarker_Analyze]; @@ -18576,7 +18576,7 @@ void COutputLegacy::SpecialOutput_AnalyzeSurface(CSolver *solver, CGeometry *geo su2double *Surface_TotalPressure_Local = new su2double [nMarker_Analyze]; su2double *Surface_Area_Local = new su2double [nMarker_Analyze]; su2double *Surface_MassFlow_Abs_Local = new su2double [nMarker_Analyze]; - + su2double *Surface_MassFlow_Total = new su2double [nMarker_Analyze]; su2double *Surface_Mach_Total = new su2double [nMarker_Analyze]; su2double *Surface_Temperature_Total = new su2double [nMarker_Analyze]; @@ -18607,7 +18607,7 @@ void COutputLegacy::SpecialOutput_AnalyzeSurface(CSolver *solver, CGeometry *geo Surface_TotalPressure_Local[iMarker_Analyze] = 0.0; Surface_Area_Local[iMarker_Analyze] = 0.0; Surface_MassFlow_Abs_Local[iMarker_Analyze] = 0.0; - + Surface_MassFlow_Total[iMarker_Analyze] = 0.0; Surface_Mach_Total[iMarker_Analyze] = 0.0; Surface_Temperature_Total[iMarker_Analyze] = 0.0; @@ -18625,17 +18625,17 @@ void COutputLegacy::SpecialOutput_AnalyzeSurface(CSolver *solver, CGeometry *geo Surface_MomentumDistortion_Total[iMarker_Analyze] = 0.0; } - + /*--- Compute the numerical fan face Mach number, mach number, temperature and the total area ---*/ - + for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { - + if (config->GetMarker_All_Analyze(iMarker) == YES) { - + for (iMarker_Analyze= 0; iMarker_Analyze < nMarker_Analyze; iMarker_Analyze++) { - + /*--- Add the Surface_MassFlow, and Surface_Area to the particular boundary ---*/ - + if (config->GetMarker_All_TagBound(iMarker) == config->GetMarker_Analyze_TagBound(iMarker_Analyze)) { Surface_MassFlow_Local[iMarker_Analyze] += Surface_MassFlow[iMarker]; Surface_Mach_Local[iMarker_Analyze] += Surface_Mach[iMarker]; @@ -18651,13 +18651,13 @@ void COutputLegacy::SpecialOutput_AnalyzeSurface(CSolver *solver, CGeometry *geo Surface_Area_Local[iMarker_Analyze] += Surface_Area[iMarker]; Surface_MassFlow_Abs_Local[iMarker_Analyze] += Surface_MassFlow_Abs[iMarker]; } - + } - + } - + } - + #ifdef HAVE_MPI if (config->GetComm_Level() == COMM_FULL) { SU2_MPI::Allreduce(Surface_MassFlow_Local, Surface_MassFlow_Total, nMarker_Analyze, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); @@ -18675,7 +18675,7 @@ void COutputLegacy::SpecialOutput_AnalyzeSurface(CSolver *solver, CGeometry *geo SU2_MPI::Allreduce(Surface_MassFlow_Abs_Local, Surface_MassFlow_Abs_Total, nMarker_Analyze, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); } #else - + for (iMarker_Analyze = 0; iMarker_Analyze < nMarker_Analyze; iMarker_Analyze++) { Surface_MassFlow_Total[iMarker_Analyze] = Surface_MassFlow_Local[iMarker_Analyze]; Surface_Mach_Total[iMarker_Analyze] = Surface_Mach_Local[iMarker_Analyze]; @@ -18691,14 +18691,14 @@ void COutputLegacy::SpecialOutput_AnalyzeSurface(CSolver *solver, CGeometry *geo Surface_Area_Total[iMarker_Analyze] = Surface_Area_Local[iMarker_Analyze]; Surface_MassFlow_Abs_Total[iMarker_Analyze] = Surface_MassFlow_Abs_Local[iMarker_Analyze]; } - + #endif - + /*--- Compute the value of Surface_Area_Total, and Surface_Pressure_Total, and set the value in the config structure for future use ---*/ - + for (iMarker_Analyze = 0; iMarker_Analyze < nMarker_Analyze; iMarker_Analyze++) { - + if (Kind_Average == AVERAGE_MASSFLUX) Weight = Surface_MassFlow_Abs_Total[iMarker_Analyze]; else if (Kind_Average == AVERAGE_AREA) Weight = abs(Surface_Area_Total[iMarker_Analyze]); else Weight = 1.0; @@ -18740,28 +18740,28 @@ void COutputLegacy::SpecialOutput_AnalyzeSurface(CSolver *solver, CGeometry *geo } } - + for (iMarker_Analyze = 0; iMarker_Analyze < nMarker_Analyze; iMarker_Analyze++) { - + su2double MassFlow = Surface_MassFlow_Total[iMarker_Analyze] * config->GetDensity_Ref() * config->GetVelocity_Ref(); if (config->GetSystemMeasurements() == US) MassFlow *= 32.174; config->SetSurface_MassFlow(iMarker_Analyze, MassFlow); - + su2double Mach = Surface_Mach_Total[iMarker_Analyze]; config->SetSurface_Mach(iMarker_Analyze, Mach); - + su2double Temperature = Surface_Temperature_Total[iMarker_Analyze] * config->GetTemperature_Ref(); config->SetSurface_Temperature(iMarker_Analyze, Temperature); - + su2double Pressure = Surface_Pressure_Total[iMarker_Analyze] * config->GetPressure_Ref(); config->SetSurface_Pressure(iMarker_Analyze, Pressure); - + su2double Density = Surface_Density_Total[iMarker_Analyze] * config->GetDensity_Ref(); config->SetSurface_Density(iMarker_Analyze, Density); - + su2double Enthalpy = Surface_Enthalpy_Total[iMarker_Analyze]; config->SetSurface_Enthalpy(iMarker_Analyze, Enthalpy); - + su2double NormalVelocity = Surface_NormalVelocity_Total[iMarker_Analyze] * config->GetVelocity_Ref(); config->SetSurface_NormalVelocity(iMarker_Analyze, NormalVelocity); @@ -18779,10 +18779,10 @@ void COutputLegacy::SpecialOutput_AnalyzeSurface(CSolver *solver, CGeometry *geo su2double TotalTemperature = Surface_TotalTemperature_Total[iMarker_Analyze] * config->GetTemperature_Ref(); config->SetSurface_TotalTemperature(iMarker_Analyze, TotalTemperature); - + su2double TotalPressure = Surface_TotalPressure_Total[iMarker_Analyze] * config->GetPressure_Ref(); config->SetSurface_TotalPressure(iMarker_Analyze, TotalPressure); - + } /*--- Compute the average static pressure drop between two surfaces. Note @@ -18802,30 +18802,30 @@ void COutputLegacy::SpecialOutput_AnalyzeSurface(CSolver *solver, CGeometry *geo } if ((rank == MASTER_NODE) && !config->GetDiscrete_Adjoint() && output) { - + cout.precision(6); cout.setf(ios::scientific, ios::floatfield); cout << endl << "Computing surface mean values." << endl << endl; - + for (iMarker_Analyze = 0; iMarker_Analyze < nMarker_Analyze; iMarker_Analyze++) { cout << "Surface "<< config->GetMarker_Analyze_TagBound(iMarker_Analyze) << ":" << endl; - + if (nDim == 3) { if (config->GetSystemMeasurements() == SI) cout << setw(20) << "Area (m^2): "; else cout << setw(20) << "Area (ft^2): "; } else { if (config->GetSystemMeasurements() == SI) cout << setw(20) << "Area (m): "; else cout << setw(20) << "Area (ft): "; } - + if (config->GetSystemMeasurements() == SI) cout << setw(15) << fabs(Surface_Area_Total[iMarker_Analyze]); else if (config->GetSystemMeasurements() == US) cout << setw(15) << fabs(Surface_Area_Total[iMarker_Analyze])*12.0*12.0; - + cout << endl; su2double MassFlow = config->GetSurface_MassFlow(iMarker_Analyze); if (config->GetSystemMeasurements() == SI) cout << setw(20) << "Mf (kg/s): " << setw(15) << MassFlow; else if (config->GetSystemMeasurements() == US) cout << setw(20) << "Mf (lbs/s): " << setw(15) << MassFlow; - + su2double NormalVelocity = config->GetSurface_NormalVelocity(iMarker_Analyze); if (config->GetSystemMeasurements() == SI) cout << setw(20) << "Vn (m/s): " << setw(15) << NormalVelocity; else if (config->GetSystemMeasurements() == US) cout << setw(20) << "Vn (ft/s): " << setw(15) << NormalVelocity; - + cout << endl; su2double Uniformity = config->GetSurface_Uniformity(iMarker_Analyze); @@ -18849,7 +18849,7 @@ void COutputLegacy::SpecialOutput_AnalyzeSurface(CSolver *solver, CGeometry *geo su2double Pressure = config->GetSurface_Pressure(iMarker_Analyze); if (config->GetSystemMeasurements() == SI) cout << setw(20) << "P (Pa): " << setw(15) << Pressure; else if (config->GetSystemMeasurements() == US) cout << setw(20) << "P (psf): " << setw(15) << Pressure; - + su2double TotalPressure = config->GetSurface_TotalPressure(iMarker_Analyze); if (config->GetSystemMeasurements() == SI) cout << setw(20) << "PT (Pa): " << setw(15) <GetSystemMeasurements() == US) cout << setw(20) << "PT (psf): " << setw(15) <GetTabular_FileFormat() == TAB_CSV){ @@ -20526,7 +20526,7 @@ void COutputLegacy::LoadLocalData_FEM(CConfig *config, CGeometry *geometry, CSol Variable_Names.push_back("Cp"); } Variable_Names.push_back("Mach"); - + if ((Kind_Solver == FEM_NAVIER_STOKES) || (Kind_Solver == FEM_LES)){ nVar_Par += 1; Variable_Names.push_back("Laminar_Viscosity"); @@ -20535,7 +20535,7 @@ void COutputLegacy::LoadLocalData_FEM(CConfig *config, CGeometry *geometry, CSol nVar_Par += 1; Variable_Names.push_back("Eddy_Viscosity"); } - + if (solver[FLOW_SOL]->VerificationSolution) { if (solver[FLOW_SOL]->VerificationSolution->ExactSolutionKnown()) { nVar_Par += 2*nVar_Consv_Par; @@ -20551,9 +20551,9 @@ void COutputLegacy::LoadLocalData_FEM(CConfig *config, CGeometry *geometry, CSol Variable_Names.push_back("Error_Energy"); } } - + /*--- New variables get registered here before the end of the loop. ---*/ - + /*--- Create an object of the class CMeshFEM_DG and retrieve the necessary geometrical information for the FEM DG solver. ---*/ @@ -20598,34 +20598,34 @@ void COutputLegacy::LoadLocalData_FEM(CConfig *config, CGeometry *geometry, CSol const unsigned long offset = nVar_First*volElem[l].offsetDOFsSolLocal; su2double *solDOFs = solver[FirstIndex]->GetVecSolDOFs() + offset; - + for(unsigned short j=0; jSetTDState_rhoe(U[0], StaticEnergy); - + /*--- Load data for the pressure, temperature, Cp, and Mach variables. ---*/ - + Local_Data[jPoint][iVar] = DGFluidModel->GetPressure(); iVar++; Local_Data[jPoint][iVar] = DGFluidModel->GetTemperature(); iVar++; Local_Data[jPoint][iVar] = DGFluidModel->GetCp(); iVar++; Local_Data[jPoint][iVar] = sqrt(Velocity2)/DGFluidModel->GetSoundSpeed(); iVar++; - + if ((Kind_Solver == FEM_NAVIER_STOKES) || (Kind_Solver == FEM_LES)){ Local_Data[jPoint][iVar] = DGFluidModel->GetLaminarViscosity(); iVar++; } @@ -20649,14 +20649,14 @@ void COutputLegacy::LoadLocalData_FEM(CConfig *config, CGeometry *geometry, CSol // todo: Export Eddy instead of Laminar viscosity Local_Data[jPoint][iVar] = DGFluidModel->GetLaminarViscosity(); iVar++; } - + if (solver[FLOW_SOL]->VerificationSolution) { if (solver[FLOW_SOL]->VerificationSolution->ExactSolutionKnown()) { - + /*--- Get the physical time if necessary. ---*/ su2double time = 0.0; if (config->GetTime_Marching()) time = config->GetPhysicalTime(); - + /* Get the verification solution. */ su2double mmsSol[5]; solver[FLOW_SOL]->VerificationSolution->GetSolution(coor, time, mmsSol); @@ -20664,7 +20664,7 @@ void COutputLegacy::LoadLocalData_FEM(CConfig *config, CGeometry *geometry, CSol Local_Data[jPoint][iVar] = mmsSol[jVar]; iVar++; } - + /* Get local error from the verification solution class. */ su2double error[5]; solver[FLOW_SOL]->VerificationSolution->GetLocalError(coor, time, U, error); @@ -20674,17 +20674,17 @@ void COutputLegacy::LoadLocalData_FEM(CConfig *config, CGeometry *geometry, CSol } } } - + /*--- New variables can be loaded to the Local_Data structure here, assuming they were registered above correctly. ---*/ - + } - + /*--- Increment the point counter. ---*/ - + jPoint++; } - + } @@ -20831,7 +20831,7 @@ void COutputLegacy::PrepareOffsets(CConfig *config, CGeometry *geometry) { nPointCumulative[ii] = nPointCumulative[ii-1] + nPointLinear[ii-1]; } nPointCumulative[size] = nGlobalPoint_Sort; - + } void COutputLegacy::SortConnectivity_FEM(CConfig *config, CGeometry *geometry, unsigned short val_iZone) { @@ -20885,7 +20885,7 @@ void COutputLegacy::SortConnectivity_FEM(CConfig *config, CGeometry *geometry, u SU2_MPI::Allreduce(&nTotal_Elem, &nGlobal_Elem_Par, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); SU2_MPI::Allreduce(&nTotal_Surf_Elem, &nSurf_Elem_Par, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); #endif - + } void COutputLegacy::SortVolumetricConnectivity_FEM(CConfig *config, CGeometry *geometry, unsigned short Elem_Type) { @@ -21035,7 +21035,7 @@ void COutputLegacy::SortSurfaceConnectivity_FEM(CConfig *config, CGeometry *geom default: SU2_MPI::Error("Unrecognized element type", CURRENT_FUNCTION); } - + /*--- Create an object of the class CMeshFEM_DG and retrieve the necessary geometrical information for the FEM DG solver. ---*/ CMeshFEM_DG *DGGeometry = dynamic_cast(geometry); @@ -21462,11 +21462,11 @@ void COutputLegacy::SortOutputData_FEM(CConfig *config, CGeometry *geometry) { delete [] nPoint_Recv; delete [] nPoint_Send; delete [] nPoint_Flag; - + for (iPoint = 0; iPoint < nLocalPoint_Sort; iPoint++) delete [] Local_Data[iPoint]; delete [] Local_Data; - + } void COutputLegacy::SortOutputData_Surface_FEM(CConfig *config, CGeometry *geometry) { diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 3149759398cf..6e9d1c604c71 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -3452,7 +3452,7 @@ void CEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_contain /*--- Get stored time spectral source term and add to residual ---*/ for (iVar = 0; iVar < nVar; iVar++) { - LinSysRes[iPoint*nVar+iVar] += Volume * nodes->GetHarmonicBalance_Source(iPoint,iVar); + LinSysRes(iPoint,iVar) += Volume * nodes->GetHarmonicBalance_Source(iPoint,iVar); } } } @@ -3512,7 +3512,7 @@ void CEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_contain /*--- Compute the residual for this control volume and subtract. ---*/ for (iVar = 0; iVar < nVar; iVar++) { - LinSysRes[iPoint*nVar+iVar] -= sourceMan[iVar]*Volume; + LinSysRes(iPoint,iVar) -= sourceMan[iVar]*Volume; } } } @@ -4736,7 +4736,7 @@ void CEulerSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver else { Jacobian.SetVal2Diag(iPoint, 1.0); for (unsigned short iVar = 0; iVar < nVar; iVar++) { - LinSysRes[iPoint*nVar + iVar] = 0.0; + LinSysRes(iPoint,iVar) = 0.0; local_Res_TruncError[iVar] = 0.0; } } diff --git a/SU2_CFD/src/solvers/CFEASolver.cpp b/SU2_CFD/src/solvers/CFEASolver.cpp index 673f85e3e04a..c6299bba4bb1 100644 --- a/SU2_CFD/src/solvers/CFEASolver.cpp +++ b/SU2_CFD/src/solvers/CFEASolver.cpp @@ -909,7 +909,7 @@ void CFEASolver::Compute_StiffMatrix(CGeometry *geometry, CNumerics **numerics, auto Ta = element->Get_Kt_a(iNode); for (iVar = 0; iVar < nVar; iVar++) - LinSysRes[indexNode[iNode]*nVar+iVar] -= simp_penalty*Ta[iVar]; + LinSysRes(indexNode[iNode], iVar) -= simp_penalty*Ta[iVar]; for (jNode = 0; jNode < nNodes; jNode++) { auto Kab = element->Get_Kab(iNode, jNode); @@ -1024,13 +1024,13 @@ void CFEASolver::Compute_StiffMatrix_NodalStressRes(CGeometry *geometry, CNumeri auto Ta = fea_elem->Get_Kt_a(iNode); for (iVar = 0; iVar < nVar; iVar++) - LinSysRes[indexNode[iNode]*nVar+iVar] -= simp_penalty*Ta[iVar]; + LinSysRes(indexNode[iNode], iVar) -= simp_penalty*Ta[iVar]; /*--- Retrieve the electric contribution to the residual. ---*/ if (de_effects) { auto Ta_DE = de_elem->Get_Kt_a(iNode); for (iVar = 0; iVar < nVar; iVar++) - LinSysRes[indexNode[iNode]*nVar+iVar] -= simp_penalty*Ta_DE[iVar]; + LinSysRes(indexNode[iNode], iVar) -= simp_penalty*Ta_DE[iVar]; } for (jNode = 0; jNode < nNodes; jNode++) { @@ -1224,8 +1224,8 @@ void CFEASolver::Compute_MassRes(CGeometry *geometry, CNumerics **numerics, CCon su2double Mab = simp_penalty * element->Get_Mab(iNode, jNode); for (iVar = 0; iVar < nVar; iVar++) { - TimeRes[indexNode[iNode]*nVar+iVar] += Mab * TimeRes_Aux.GetBlock(indexNode[iNode],iVar); - TimeRes[indexNode[jNode]*nVar+iVar] += Mab * TimeRes_Aux.GetBlock(indexNode[jNode],iVar); + TimeRes[indexNode[iNode]*nVar+iVar] += Mab * TimeRes_Aux(indexNode[iNode],iVar); + TimeRes[indexNode[jNode]*nVar+iVar] += Mab * TimeRes_Aux(indexNode[jNode],iVar); } } } @@ -1322,7 +1322,7 @@ void CFEASolver::Compute_NodalStressRes(CGeometry *geometry, CNumerics **numeric for (iNode = 0; iNode < nNodes; iNode++) { auto Ta = element->Get_Kt_a(iNode); for (iVar = 0; iVar < nVar; iVar++) - LinSysRes[indexNode[iNode]*nVar+iVar] -= simp_penalty*Ta[iVar]; + LinSysRes(indexNode[iNode], iVar) -= simp_penalty*Ta[iVar]; } } // end iElem loop @@ -1429,7 +1429,7 @@ void CFEASolver::Compute_NodalStress(CGeometry *geometry, CNumerics **numerics, auto Ta = element->Get_Kt_a(iNode); for (iVar = 0; iVar < nVar; iVar++) - LinSysReact[iPoint*nVar+iVar] += simp_penalty*Ta[iVar]; + LinSysReact(iPoint,iVar) += simp_penalty*Ta[iVar]; /*--- Divide the nodal stress by the number of elements that will contribute to this point. ---*/ su2double weight = simp_penalty / geometry->node[iPoint]->GetnElem(); @@ -1535,7 +1535,7 @@ void CFEASolver::Compute_NodalStress(CGeometry *geometry, CNumerics **numerics, for (iVar = 0; iVar < nVar; iVar++) { /*--- Retrieve reaction ---*/ - val_Reaction = LinSysReact.GetBlock(iPoint, iVar); + val_Reaction = LinSysReact(iPoint, iVar); myfile << "F" << iVar + 1 << ": " << val_Reaction << " \t " ; } @@ -1556,7 +1556,7 @@ 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++) { - TimeRes_Aux[iPoint*nVar+iVar] = + TimeRes_Aux(iPoint,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) @@ -1593,7 +1593,7 @@ void CFEASolver::Compute_NodalStress(CGeometry *geometry, CNumerics **numerics, for (iVar = 0; iVar < nVar; iVar++) { /*--- Retrieve the time contribution and reaction. ---*/ - val_Reaction = LinSysReact.GetBlock(iPoint, iVar) + TimeRes.GetBlock(iPoint, iVar); + val_Reaction = LinSysReact(iPoint, iVar) + TimeRes(iPoint, iVar); myfile << "F" << iVar + 1 << ": " << val_Reaction << " \t " ; } @@ -2391,21 +2391,21 @@ void CFEASolver::ImplicitNewmark_Iteration(CGeometry *geometry, CSolver **solver /*--- External surface load contribution. ---*/ for (iVar = 0; iVar < nVar; iVar++) { - LinSysRes[iPoint*nVar+iVar] += loadIncr * nodes->Get_SurfaceLoad_Res(iPoint,iVar); + LinSysRes(iPoint,iVar) += loadIncr * nodes->Get_SurfaceLoad_Res(iPoint,iVar); } /*--- Body forces contribution (dead load). ---*/ if (body_forces) { for (iVar = 0; iVar < nVar; iVar++) { - LinSysRes[iPoint*nVar+iVar] += loadIncr * nodes->Get_BodyForces_Res(iPoint,iVar); + LinSysRes(iPoint,iVar) += loadIncr * nodes->Get_BodyForces_Res(iPoint,iVar); } } /*--- FSI contribution (flow loads). ---*/ for (iVar = 0; iVar < nVar; iVar++) { - LinSysRes[iPoint*nVar+iVar] += loadIncr * nodes->Get_FlowTraction(iPoint,iVar); + LinSysRes(iPoint,iVar) += loadIncr * nodes->Get_FlowTraction(iPoint,iVar); } } @@ -2433,7 +2433,7 @@ void CFEASolver::ImplicitNewmark_Iteration(CGeometry *geometry, CSolver **solver SU2_OMP_FOR_STAT(omp_chunk_size) for (iPoint = 0; iPoint < nPoint; iPoint++) { for (iVar = 0; iVar < nVar; iVar++) { - TimeRes_Aux[iPoint*nVar+iVar] = + TimeRes_Aux(iPoint,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) @@ -2466,7 +2466,7 @@ void CFEASolver::ImplicitNewmark_Update(CGeometry *geometry, CSolver **solver_co for (iPoint = 0; iPoint < nPointDomain; iPoint++) { /*--- Displacement component of the solution. ---*/ for (iVar = 0; iVar < nVar; iVar++) - nodes->Add_DeltaSolution(iPoint, iVar, LinSysSol[iPoint*nVar+iVar]); + nodes->Add_DeltaSolution(iPoint, iVar, LinSysSol(iPoint,iVar)); } if (dynamic) { @@ -2597,21 +2597,21 @@ void CFEASolver::GeneralizedAlpha_Iteration(CGeometry *geometry, CSolver **solve /*--- External surface load contribution. ---*/ for (iVar = 0; iVar < nVar; iVar++) { - LinSysRes[iPoint*nVar+iVar] += loadIncr * nodes->Get_SurfaceLoad_Res(iPoint,iVar); + LinSysRes(iPoint,iVar) += loadIncr * nodes->Get_SurfaceLoad_Res(iPoint,iVar); } /*--- Body forces contribution (dead load). ---*/ if (body_forces) { for (iVar = 0; iVar < nVar; iVar++) { - LinSysRes[iPoint*nVar+iVar] += loadIncr * nodes->Get_BodyForces_Res(iPoint,iVar); + LinSysRes(iPoint,iVar) += loadIncr * nodes->Get_BodyForces_Res(iPoint,iVar); } } /*--- FSI contribution (flow loads). ---*/ for (iVar = 0; iVar < nVar; iVar++) { - LinSysRes[iPoint*nVar+iVar] += loadIncr * nodes->Get_FlowTraction(iPoint,iVar); + LinSysRes(iPoint,iVar) += loadIncr * nodes->Get_FlowTraction(iPoint,iVar); } } @@ -2632,7 +2632,7 @@ void CFEASolver::GeneralizedAlpha_Iteration(CGeometry *geometry, CSolver **solve SU2_OMP_FOR_STAT(omp_chunk_size) for (iPoint = 0; iPoint < nPoint; iPoint++) { for (iVar = 0; iVar < nVar; iVar++) { - TimeRes_Aux[iPoint*nVar+iVar] = + TimeRes_Aux(iPoint,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) @@ -2652,8 +2652,8 @@ void CFEASolver::GeneralizedAlpha_Iteration(CGeometry *geometry, CSolver **solve /*--- External surface load contribution ---*/ for (iVar = 0; iVar < nVar; iVar++) { - LinSysRes[iPoint*nVar+iVar] += loadIncr * ( (1-alpha_f) * nodes->Get_SurfaceLoad_Res(iPoint,iVar) + - alpha_f * nodes->Get_SurfaceLoad_Res_n(iPoint,iVar) ); + LinSysRes(iPoint,iVar) += loadIncr * ( (1-alpha_f) * nodes->Get_SurfaceLoad_Res(iPoint,iVar) + + alpha_f * nodes->Get_SurfaceLoad_Res_n(iPoint,iVar) ); } /*--- Add the contribution to the residual due to body forces. @@ -2661,15 +2661,15 @@ void CFEASolver::GeneralizedAlpha_Iteration(CGeometry *geometry, CSolver **solve if (body_forces) { for (iVar = 0; iVar < nVar; iVar++) { - LinSysRes[iPoint*nVar+iVar] += loadIncr * nodes->Get_BodyForces_Res(iPoint,iVar); + LinSysRes(iPoint,iVar) += loadIncr * nodes->Get_BodyForces_Res(iPoint,iVar); } } /*--- Add FSI contribution. ---*/ for (iVar = 0; iVar < nVar; iVar++) { - LinSysRes[iPoint*nVar+iVar] += loadIncr * ( (1-alpha_f) * nodes->Get_FlowTraction(iPoint,iVar) + - alpha_f * nodes->Get_FlowTraction_n(iPoint,iVar) ); + LinSysRes(iPoint,iVar) += loadIncr * ( (1-alpha_f) * nodes->Get_FlowTraction(iPoint,iVar) + + alpha_f * nodes->Get_FlowTraction_n(iPoint,iVar) ); } } } @@ -2685,7 +2685,7 @@ void CFEASolver::GeneralizedAlpha_UpdateDisp(CGeometry *geometry, CSolver **solv SU2_OMP_PARALLEL_(for schedule(static,omp_chunk_size)) for (unsigned long iPoint = 0; iPoint < nPointDomain; iPoint++) for (unsigned short iVar = 0; iVar < nVar; iVar++) - nodes->Add_DeltaSolution(iPoint, iVar, LinSysSol[iPoint*nVar+iVar]); + nodes->Add_DeltaSolution(iPoint, iVar, LinSysSol(iPoint,iVar)); /*--- Perform the MPI communication of the solution, displacements only. ---*/ diff --git a/SU2_CFD/src/solvers/CSolver.cpp b/SU2_CFD/src/solvers/CSolver.cpp index e9ff98b5cdff..bb064ff649f4 100644 --- a/SU2_CFD/src/solvers/CSolver.cpp +++ b/SU2_CFD/src/solvers/CSolver.cpp @@ -511,27 +511,27 @@ void CSolver::InitiatePeriodicComms(CGeometry *geometry, volume to the other side of the periodic face. ---*/ for (iVar = 0; iVar < nVar; iVar++) { - bufDSend[buf_offset+iVar] = LinSysRes.GetBlock(iPoint, iVar); + bufDSend[buf_offset+iVar] = LinSysRes(iPoint, iVar); } /*--- Rotate the momentum components of the residual array. ---*/ if (rotate_periodic) { if (nDim == 2) { - bufDSend[buf_offset+1] = (rotMatrix[0][0]*LinSysRes.GetBlock(iPoint, 1) + - rotMatrix[0][1]*LinSysRes.GetBlock(iPoint, 2)); - bufDSend[buf_offset+2] = (rotMatrix[1][0]*LinSysRes.GetBlock(iPoint, 1) + - rotMatrix[1][1]*LinSysRes.GetBlock(iPoint, 2)); + bufDSend[buf_offset+1] = (rotMatrix[0][0]*LinSysRes(iPoint, 1) + + rotMatrix[0][1]*LinSysRes(iPoint, 2)); + bufDSend[buf_offset+2] = (rotMatrix[1][0]*LinSysRes(iPoint, 1) + + rotMatrix[1][1]*LinSysRes(iPoint, 2)); } else { - bufDSend[buf_offset+1] = (rotMatrix[0][0]*LinSysRes.GetBlock(iPoint, 1) + - rotMatrix[0][1]*LinSysRes.GetBlock(iPoint, 2) + - rotMatrix[0][2]*LinSysRes.GetBlock(iPoint, 3)); - bufDSend[buf_offset+2] = (rotMatrix[1][0]*LinSysRes.GetBlock(iPoint, 1) + - rotMatrix[1][1]*LinSysRes.GetBlock(iPoint, 2) + - rotMatrix[1][2]*LinSysRes.GetBlock(iPoint, 3)); - bufDSend[buf_offset+3] = (rotMatrix[2][0]*LinSysRes.GetBlock(iPoint, 1) + - rotMatrix[2][1]*LinSysRes.GetBlock(iPoint, 2) + - rotMatrix[2][2]*LinSysRes.GetBlock(iPoint, 3)); + bufDSend[buf_offset+1] = (rotMatrix[0][0]*LinSysRes(iPoint, 1) + + rotMatrix[0][1]*LinSysRes(iPoint, 2) + + rotMatrix[0][2]*LinSysRes(iPoint, 3)); + bufDSend[buf_offset+2] = (rotMatrix[1][0]*LinSysRes(iPoint, 1) + + rotMatrix[1][1]*LinSysRes(iPoint, 2) + + rotMatrix[1][2]*LinSysRes(iPoint, 3)); + bufDSend[buf_offset+3] = (rotMatrix[2][0]*LinSysRes(iPoint, 1) + + rotMatrix[2][1]*LinSysRes(iPoint, 2) + + rotMatrix[2][2]*LinSysRes(iPoint, 3)); } } buf_offset += nVar; diff --git a/SU2_CFD/src/solvers/CTurbSASolver.cpp b/SU2_CFD/src/solvers/CTurbSASolver.cpp index 5f185bc0fc4c..5e155e2108f5 100644 --- a/SU2_CFD/src/solvers/CTurbSASolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSASolver.cpp @@ -448,7 +448,7 @@ void CTurbSASolver::Source_Residual(CGeometry *geometry, CSolver **solver_contai for (unsigned short iVar = 0; iVar < nVar; iVar++) { su2double Source = nodes->GetHarmonicBalance_Source(iPoint,iVar); - LinSysRes[iPoint*nVar+iVar] += Source*Volume; + LinSysRes(iPoint,iVar) += Source*Volume; } } } diff --git a/SU2_CFD/src/solvers/CTurbSolver.cpp b/SU2_CFD/src/solvers/CTurbSolver.cpp index b19d24983769..ef81397e02e6 100644 --- a/SU2_CFD/src/solvers/CTurbSolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSolver.cpp @@ -523,7 +523,7 @@ void CTurbSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver_ for (unsigned short iVar = 0; iVar < nVar; iVar++) { nodes->AddConservativeSolution(iPoint, iVar, - nodes->GetUnderRelaxation(iPoint)*LinSysSol[iPoint*nVar+iVar], + nodes->GetUnderRelaxation(iPoint)*LinSysSol(iPoint,iVar), density, density_old, lowerlimit[iVar], upperlimit[iVar]); } } @@ -612,11 +612,11 @@ void CTurbSolver::ComputeUnderRelaxationFactor(CSolver **solver_container, CConf void CTurbSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iRKStep, unsigned short iMesh, unsigned short RunTime_EqSystem) { + const bool sst_model = (config->GetKind_Turb_Model() == SST) || (config->GetKind_Turb_Model() == SST_SUST); const bool implicit = (config->GetKind_TimeIntScheme_Turb() == EULER_IMPLICIT); - const bool incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); const bool first_order = (config->GetTime_Marching() == DT_STEPPING_1ST); const bool second_order = (config->GetTime_Marching() == DT_STEPPING_2ND); - const unsigned short turbModel = config->GetKind_Turb_Model(); + const bool incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); /*--- Store the physical time step ---*/ @@ -632,16 +632,12 @@ void CTurbSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_con unsigned short iVar, iMarker, iDim; unsigned long iPoint, jPoint, iEdge, iVertex; - const su2double *U_time_nM1, *U_time_n, *U_time_nP1; + const su2double *U_time_nM1 = nullptr, *U_time_n = nullptr, *U_time_nP1 = nullptr; su2double Volume_nM1, Volume_nP1; su2double Density_nM1, Density_n, Density_nP1; - const su2double *Normal = NULL, *GridVel_i = NULL, *GridVel_j = NULL; + const su2double *Normal = nullptr, *GridVel_i = nullptr, *GridVel_j = nullptr; su2double Residual_GCL; - /*--- "Allocate" local (to the thread) Residual to then write to CSysVector. ---*/ - su2double Res_Time[MAXNVAR] = {0.0}; - - /*--- Compute the dual time-stepping source term for static meshes ---*/ if (!dynamic_grid) { @@ -667,7 +663,7 @@ void CTurbSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_con /*--- Compute the dual time-stepping source term based on the chosen time discretization scheme (1st- or 2nd-order).---*/ - if ((turbModel == SST) || (turbModel == SST_SUST)) { + if (sst_model) { /*--- If this is the SST model, we need to multiply by the density in order to get the conservative variables ---*/ @@ -688,26 +684,24 @@ void CTurbSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_con for (iVar = 0; iVar < nVar; iVar++) { if (first_order) - Res_Time[iVar] = ( Density_nP1*U_time_nP1[iVar] - Density_n*U_time_n[iVar])*Volume_nP1 / TimeStep; + LinSysRes(iPoint,iVar) += ( Density_nP1*U_time_nP1[iVar] - Density_n*U_time_n[iVar])*Volume_nP1 / TimeStep; if (second_order) - Res_Time[iVar] = ( 3.0*Density_nP1*U_time_nP1[iVar] - 4.0*Density_n*U_time_n[iVar] - +1.0*Density_nM1*U_time_nM1[iVar])*Volume_nP1 / (2.0*TimeStep); + LinSysRes(iPoint,iVar) += ( 3.0*Density_nP1*U_time_nP1[iVar] - 4.0*Density_n*U_time_n[iVar] + +1.0*Density_nM1*U_time_nM1[iVar] ) * Volume_nP1/(2.0*TimeStep); } } else { for (iVar = 0; iVar < nVar; iVar++) { if (first_order) - Res_Time[iVar] = (U_time_nP1[iVar] - U_time_n[iVar])*Volume_nP1 / TimeStep; + LinSysRes(iPoint,iVar) += (U_time_nP1[iVar] - U_time_n[iVar])*Volume_nP1 / TimeStep; if (second_order) - Res_Time[iVar] = ( 3.0*U_time_nP1[iVar] - 4.0*U_time_n[iVar] - +1.0*U_time_nM1[iVar])*Volume_nP1 / (2.0*TimeStep); + LinSysRes(iPoint,iVar) += ( 3.0*U_time_nP1[iVar] - 4.0*U_time_n[iVar] + +1.0*U_time_nM1[iVar] ) * Volume_nP1/(2.0*TimeStep); } } - /*--- Store the residual and compute the Jacobian contribution due to the dual time source term. ---*/ - - LinSysRes.AddBlock(iPoint, Res_Time); + /*--- Compute the Jacobian contribution due to the dual time source term. ---*/ if (implicit) { if (first_order) Jacobian.AddVal2Diag(iPoint, Volume_nP1/TimeStep); if (second_order) Jacobian.AddVal2Diag(iPoint, (Volume_nP1*3.0)/(2.0*TimeStep)); @@ -765,20 +759,19 @@ void CTurbSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_con /*--- Multiply by density at node i for the SST model ---*/ - if ((turbModel == SST) || (turbModel == SST_SUST)) { + if (sst_model) { 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++) - Res_Time[iVar] = Density_n*U_time_n[iVar]*Residual_GCL; + LinSysRes(iPoint,iVar) += Density_n*U_time_n[iVar]*Residual_GCL; } else { for (iVar = 0; iVar < nVar; iVar++) - Res_Time[iVar] = U_time_n[iVar]*Residual_GCL; + LinSysRes(iPoint,iVar) += U_time_n[iVar]*Residual_GCL; } - LinSysRes.AddBlock(iPoint, Res_Time); /*--- Compute the GCL component of the source term for node j ---*/ @@ -786,20 +779,19 @@ void CTurbSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_con /*--- Multiply by density at node j for the SST model ---*/ - if ((turbModel == SST) || (turbModel == SST_SUST)) { + if (sst_model) { 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++) - Res_Time[iVar] = Density_n*U_time_n[iVar]*Residual_GCL; + LinSysRes(jPoint,iVar) -= Density_n*U_time_n[iVar]*Residual_GCL; } else { for (iVar = 0; iVar < nVar; iVar++) - Res_Time[iVar] = U_time_n[iVar]*Residual_GCL; + LinSysRes(jPoint,iVar) -= U_time_n[iVar]*Residual_GCL; } - LinSysRes.SubtractBlock(jPoint, Res_Time); } } // end color loop @@ -835,20 +827,19 @@ void CTurbSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_con /*--- Multiply by density at node i for the SST model ---*/ - if ((turbModel == SST) || (turbModel == SST_SUST)) { + if (sst_model) { 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++) - Res_Time[iVar] = Density_n*U_time_n[iVar]*Residual_GCL; + LinSysRes(iPoint,iVar) += Density_n*U_time_n[iVar]*Residual_GCL; } else { for (iVar = 0; iVar < nVar; iVar++) - Res_Time[iVar] = U_time_n[iVar]*Residual_GCL; + LinSysRes(iPoint,iVar) += U_time_n[iVar]*Residual_GCL; } - LinSysRes.AddBlock(iPoint, Res_Time); } } @@ -879,7 +870,7 @@ void CTurbSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_con introduction of the GCL term above, the remainder of the source residual due to the time discretization has a new form.---*/ - if ((turbModel == SST) || (turbModel == SST_SUST)) { + if (sst_model) { /*--- If this is the SST model, we need to multiply by the density in order to get the conservative variables ---*/ @@ -900,32 +891,31 @@ void CTurbSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_con for (iVar = 0; iVar < nVar; iVar++) { if (first_order) - Res_Time[iVar] = (Density_nP1*U_time_nP1[iVar] - Density_n*U_time_n[iVar])*(Volume_nP1/TimeStep); + LinSysRes(iPoint,iVar) += (Density_nP1*U_time_nP1[iVar] - Density_n*U_time_n[iVar])*(Volume_nP1/TimeStep); if (second_order) - Res_Time[iVar] = (Density_nP1*U_time_nP1[iVar] - Density_n*U_time_n[iVar])*(3.0*Volume_nP1/(2.0*TimeStep)) - + (Density_nM1*U_time_nM1[iVar] - Density_n*U_time_n[iVar])*(Volume_nM1/(2.0*TimeStep)); + LinSysRes(iPoint,iVar) += (Density_nP1*U_time_nP1[iVar] - Density_n*U_time_n[iVar])*(3.0*Volume_nP1/(2.0*TimeStep)) + + (Density_nM1*U_time_nM1[iVar] - Density_n*U_time_n[iVar])*(Volume_nM1/(2.0*TimeStep)); } } else { for (iVar = 0; iVar < nVar; iVar++) { if (first_order) - Res_Time[iVar] = (U_time_nP1[iVar] - U_time_n[iVar])*(Volume_nP1/TimeStep); + LinSysRes(iPoint,iVar) += (U_time_nP1[iVar] - U_time_n[iVar])*(Volume_nP1/TimeStep); if (second_order) - Res_Time[iVar] = (U_time_nP1[iVar] - U_time_n[iVar])*(3.0*Volume_nP1/(2.0*TimeStep)) - + (U_time_nM1[iVar] - U_time_n[iVar])*(Volume_nM1/(2.0*TimeStep)); + LinSysRes(iPoint,iVar) += (U_time_nP1[iVar] - U_time_n[iVar])*(3.0*Volume_nP1/(2.0*TimeStep)) + + (U_time_nM1[iVar] - U_time_n[iVar])*(Volume_nM1/(2.0*TimeStep)); } } - /*--- Store the residual and compute the Jacobian contribution due to the dual time source term. ---*/ - - LinSysRes.AddBlock(iPoint, Res_Time); + /*--- Compute the Jacobian contribution due to the dual time source term. ---*/ if (implicit) { if (first_order) Jacobian.AddVal2Diag(iPoint, Volume_nP1/TimeStep); if (second_order) Jacobian.AddVal2Diag(iPoint, (Volume_nP1*3.0)/(2.0*TimeStep)); } } - } + + } // end dynamic grid } // end SU2_OMP_PARALLEL From b56c46cd70cb3813eb227e8e1f4092b0dfdd9fe1 Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Fri, 7 Feb 2020 14:29:05 +0000 Subject: [PATCH 095/118] update sliding interface testcases --- TestCases/parallel_regression.py | 8 ++++---- TestCases/serial_regression.py | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index 192387765097..81647c2d6736 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -911,7 +911,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.398157, 0.353079, 0.405679] #last 4 columns + channel_2D.test_vals = [2.000000, 0.000000, 0.397871, 0.352785, 0.405448] #last 4 columns channel_2D.su2_exec = "parallel_computation.py -f" channel_2D.timeout = 100 channel_2D.tol = 0.00001 @@ -924,7 +924,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.620137, 0.505221, 0.415605] #last 4 columns + channel_3D.test_vals = [2.000000, 0.000000, 0.620166, 0.505156, 0.415129] #last 4 columns channel_3D.su2_exec = "parallel_computation.py -f" channel_3D.timeout = 1600 channel_3D.tol = 0.00001 @@ -950,7 +950,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.777044, 1.134689, 1.224326] #last 4 columns + rotating_cylinders.test_vals = [3.000000, 0.000000, 0.777274, 1.134742, 1.224125] #last 4 columns rotating_cylinders.su2_exec = "parallel_computation.py -f" rotating_cylinders.timeout = 1600 rotating_cylinders.tol = 0.00001 @@ -963,7 +963,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.228298, 1.648277] #last 4 columns + supersonic_vortex_shedding.test_vals = [5.000000, 0.000000, 1.227386, 1.638722] #last 4 columns supersonic_vortex_shedding.su2_exec = "parallel_computation.py -f" supersonic_vortex_shedding.timeout = 1600 supersonic_vortex_shedding.tol = 0.00001 diff --git a/TestCases/serial_regression.py b/TestCases/serial_regression.py index 019cd5f34a67..a520e9ffd242 100644 --- a/TestCases/serial_regression.py +++ b/TestCases/serial_regression.py @@ -968,7 +968,7 @@ def main(): uniform_flow.cfg_dir = "sliding_interface/uniform_flow" uniform_flow.cfg_file = "uniform_NN.cfg" uniform_flow.test_iter = 2 - uniform_flow.test_vals = [2.000000, 0.000000, -0.205134, -13.254129] #last 4 columns + uniform_flow.test_vals = [2.000000, 0.000000, -0.205134, -13.253497] #last 4 columns uniform_flow.su2_exec = "SU2_CFD" uniform_flow.timeout = 1600 uniform_flow.tol = 0.000001 @@ -981,7 +981,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.398070, 0.353082, 0.405729] #last 4 columns + channel_2D.test_vals = [2.000000, 0.000000, 0.398017, 0.352786, 0.405475] #last 4 columns channel_2D.su2_exec = "SU2_CFD" channel_2D.timeout = 100 channel_2D.tol = 0.00001 @@ -994,7 +994,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.661403, 0.769795, 0.696074] #last 5 columns + channel_3D.test_vals = [1.000000, 0.000000, 0.661408, 0.769920, 0.696040] #last 5 columns channel_3D.su2_exec = "SU2_CFD" channel_3D.timeout = 1600 channel_3D.tol = 0.00001 From c6907c213cefcb84e8966aeef78840bde7e6e40a Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Fri, 7 Feb 2020 14:53:09 +0000 Subject: [PATCH 096/118] update cases with minute changes --- TestCases/parallel_regression.py | 6 +++--- TestCases/serial_regression.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index 81647c2d6736..38882e291d20 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -91,7 +91,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.137680, -6.705671, 0.300000, 0.019470] #last 4 columns + fixedCL_naca0012.test_vals = [-12.137879, -6.705803, 0.300000, 0.019470] #last 4 columns fixedCL_naca0012.su2_exec = "parallel_computation.py -f" fixedCL_naca0012.timeout = 1600 fixedCL_naca0012.tol = 0.00001 @@ -173,7 +173,7 @@ def main(): poiseuille_profile.cfg_dir = "navierstokes/poiseuille" poiseuille_profile.cfg_file = "profile_poiseuille.cfg" poiseuille_profile.test_iter = 10 - poiseuille_profile.test_vals = [-12.493462, -7.671815, -0.000000, 2.085796] #last 4 columns + poiseuille_profile.test_vals = [-12.493492, -7.671588, -0.000000, 2.085796] #last 4 columns poiseuille_profile.su2_exec = "parallel_computation.py -f" poiseuille_profile.timeout = 1600 poiseuille_profile.tol = 0.00001 @@ -243,7 +243,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.078482, -16.147828, 1.064326, 0.019770] #last 4 columns + turb_naca0012_sa.test_vals = [-12.078361, -16.147829, 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 diff --git a/TestCases/serial_regression.py b/TestCases/serial_regression.py index a520e9ffd242..44446929fb5c 100644 --- a/TestCases/serial_regression.py +++ b/TestCases/serial_regression.py @@ -93,7 +93,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.129591, -6.702940, 0.300000, 0.019470] #last 4 columns + fixedCL_naca0012.test_vals = [-12.129044, -6.702294, 0.300000, 0.019470] #last 4 columns fixedCL_naca0012.su2_exec = "SU2_CFD" fixedCL_naca0012.new_output = True fixedCL_naca0012.timeout = 1600 @@ -182,7 +182,7 @@ def main(): poiseuille_profile.cfg_dir = "navierstokes/poiseuille" poiseuille_profile.cfg_file = "profile_poiseuille.cfg" poiseuille_profile.test_iter = 10 - poiseuille_profile.test_vals = [-12.494733, -7.712320, -0.000000, 2.085796] #last 4 columns + poiseuille_profile.test_vals = [-12.494705, -7.711759, -0.000000, 2.085796] #last 4 columns poiseuille_profile.su2_exec = "SU2_CFD" poiseuille_profile.new_output = True poiseuille_profile.timeout = 1600 @@ -257,7 +257,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.075973, -16.146770, 1.064326, 0.019770] #last 4 columns + turb_naca0012_sa.test_vals = [-12.075893, -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 From f013845ffa2192d2b91befb32dcad8379b2a77f5 Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Fri, 7 Feb 2020 15:13:12 +0000 Subject: [PATCH 097/118] update UQ testcases after comparing solution --- TestCases/parallel_regression.py | 8 ++++---- TestCases/serial_regression.py | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index 38882e291d20..31ad1ab873c6 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -631,7 +631,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.906243, 1.337959, 6.052221, 2.395629] #last 4 columns + turb_naca0012_1c.test_vals = [-4.907889, 1.337608, 6.052866, 2.396063] #last 4 columns turb_naca0012_1c.su2_exec = "parallel_computation.py -f" turb_naca0012_1c.timeout = 1600 turb_naca0012_1c.tol = 0.00001 @@ -642,7 +642,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.230215, 1.262233, 6.052131, 2.395642] #last 4 columns + turb_naca0012_2c.test_vals = [-5.230205, 1.262234, 6.052183, 2.395669] #last 4 columns turb_naca0012_2c.su2_exec = "parallel_computation.py -f" turb_naca0012_2c.timeout = 1600 turb_naca0012_2c.tol = 0.00001 @@ -664,7 +664,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.007909, 1.310935, 6.054741, 2.397402] #last 4 columns + turb_naca0012_p1c1.test_vals = [-5.008192, 1.310849, 6.054689, 2.397346] #last 4 columns turb_naca0012_p1c1.su2_exec = "parallel_computation.py -f" turb_naca0012_p1c1.timeout = 1600 turb_naca0012_p1c1.tol = 0.00001 @@ -675,7 +675,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.264043, 1.251313, 6.055013, 2.397532] #last 4 columns + turb_naca0012_p1c2.test_vals = [-5.264112, 1.251274, 6.054818, 2.397393] #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 44446929fb5c..4c2f18a68526 100644 --- a/TestCases/serial_regression.py +++ b/TestCases/serial_regression.py @@ -674,7 +674,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.906675, 1.337889, 6.085815, 2.413950] #last 4 columns + turb_naca0012_1c.test_vals = [-4.910211, 1.337024, 6.085849, 2.414025] #last 4 columns turb_naca0012_1c.su2_exec = "SU2_CFD" turb_naca0012_1c.new_output = True turb_naca0012_1c.timeout = 1600 @@ -686,7 +686,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.230275, 1.262205, 6.085899, 2.413590] #last 4 columns + turb_naca0012_2c.test_vals = [-5.230242, 1.262219, 6.085926, 2.413617] #last 4 columns turb_naca0012_2c.su2_exec = "SU2_CFD" turb_naca0012_2c.new_output = True turb_naca0012_2c.timeout = 1600 @@ -710,7 +710,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.003083, 1.312255, 6.085205, 2.413463] #last 4 columns + turb_naca0012_p1c1.test_vals = [-5.003327, 1.312032, 6.085201, 2.413460] #last 4 columns turb_naca0012_p1c1.su2_exec = "SU2_CFD" turb_naca0012_p1c1.new_output = True turb_naca0012_p1c1.timeout = 1600 @@ -722,7 +722,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.263968, 1.251341, 6.085723, 2.413449] #last 4 columns + turb_naca0012_p1c2.test_vals = [-5.263992, 1.251332, 6.085705, 2.413434] #last 4 columns turb_naca0012_p1c2.su2_exec = "SU2_CFD" turb_naca0012_p1c2.new_output = True turb_naca0012_p1c2.timeout = 1600 From a3df199da573c01a4505dc730bb32c11fadee219 Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Fri, 7 Feb 2020 16:08:12 +0000 Subject: [PATCH 098/118] add worksharing to some CVariable methods --- Common/include/omp_structure.hpp | 25 ++++++++++++++++ SU2_CFD/include/variables/CVariable.hpp | 14 ++++----- SU2_CFD/src/drivers/CDriver.cpp | 12 +++----- SU2_CFD/src/solvers/CEulerSolver.cpp | 23 +++++++-------- SU2_CFD/src/variables/CVariable.cpp | 39 ++++++++++++++++++------- 5 files changed, 76 insertions(+), 37 deletions(-) diff --git a/Common/include/omp_structure.hpp b/Common/include/omp_structure.hpp index c9ba9976bcf1..662779582ef1 100644 --- a/Common/include/omp_structure.hpp +++ b/Common/include/omp_structure.hpp @@ -124,3 +124,28 @@ inline size_t computeStaticChunkSize(size_t totalWork, return roundUpDiv(workPerThread, chunksPerThread); } +/*! + * \brief Copy data from one array-like object to another in parallel. + * \param[in] size - Number of elements. + * \param[in] src - Source array. + * \param[in] dst - Destination array. + */ +template +void parallelCopy(size_t size, const T* src, U* dst) +{ + SU2_OMP_FOR_STAT(4196) + for(size_t i=0; i +void parallelSet(size_t size, T val, U* dst) +{ + SU2_OMP_FOR_STAT(4196) + for(size_t i=0; i AD_InputIndex; /*!< \brief Indices of Solution variables in the adjoint vector. */ su2matrix AD_OutputIndex; /*!< \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. */ + 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: diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index a2b78ec160c4..edaeaf6a4bc6 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -2079,12 +2079,8 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol /*--- Instantiate one numerics object per thread for each required term. ---*/ - SU2_OMP_PARALLEL + for (int thread = 0; thread < omp_get_max_threads(); ++thread) { - /// TODO: we are segfaulting when allocating in parallel... - SU2_OMP_CRITICAL - { - const int thread = omp_get_thread_num(); const int offset = thread * MAX_TERMS; const int conv_term = CONV_TERM + offset; @@ -2699,7 +2695,7 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol if (!spalart_allmaras) SU2_OMP_MASTER SU2_MPI::Error("Only the SA turbulence model can be used with the continuous adjoint solver.", CURRENT_FUNCTION); - + /*--- Definition of the convective scheme for each equation and mesh level ---*/ switch (config->GetKind_ConvNumScheme_AdjTurb()) { case NO_CONVECTIVE: @@ -2825,7 +2821,7 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol if (config->GetDeform_Mesh()) numerics[MESH_0][MESH_SOL][fea_term] = new CFEAMeshElasticity(nDim, nDim, geometry[MESH_0]->GetnElem(), config); - }} // end SU2_OMP_PARALLEL + } // end "per-thread" allocation loop } diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 6e9d1c604c71..d71ac71ec3de 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -2442,10 +2442,6 @@ void CEulerSolver::SetInitialCondition(CGeometry **geometry, CSolver ***solver_c } - } // end SU2_OMP_PARALLEL - - /// TODO: The rest is not included in parallel region because Set_Solution_time_n* does not have worksharing yet. - /*--- Make sure that the solution is well initialized for unsteady calculations with dual time-stepping (load additional restarts for 2nd-order). ---*/ @@ -2465,13 +2461,17 @@ void CEulerSolver::SetInitialCondition(CGeometry **geometry, CSolver ***solver_c if (restart && (TimeIter == config->GetRestart_Iter()) && (config->GetTime_Marching() == DT_STEPPING_2ND)) { - /*--- Load an additional restart file for a 2nd-order restart ---*/ + SU2_OMP_MASTER + { + /*--- Load an additional restart file for a 2nd-order restart ---*/ - solver_container[MESH_0][FLOW_SOL]->LoadRestart(geometry, solver_container, config, SU2_TYPE::Int(config->GetRestart_Iter()-1), true); + solver_container[MESH_0][FLOW_SOL]->LoadRestart(geometry, solver_container, config, config->GetRestart_Iter()-1, true); - /*--- Load an additional restart file for the turbulence model ---*/ - if (rans) - solver_container[MESH_0][TURB_SOL]->LoadRestart(geometry, solver_container, config, SU2_TYPE::Int(config->GetRestart_Iter()-1), false); + /*--- Load an additional restart file for the turbulence model ---*/ + if (rans) + solver_container[MESH_0][TURB_SOL]->LoadRestart(geometry, solver_container, config, config->GetRestart_Iter()-1, false); + } + SU2_OMP_BARRIER /*--- Push back this new solution to time level N. ---*/ @@ -2484,6 +2484,8 @@ void CEulerSolver::SetInitialCondition(CGeometry **geometry, CSolver ***solver_c } } + } // end SU2_OMP_PARALLEL + } void CEulerSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh, unsigned short iRKStep, unsigned short RunTime_EqSystem, bool Output) { @@ -3650,10 +3652,7 @@ void CEulerSolver::SetUndivided_Laplacian(CGeometry *geometry, CConfig *config) SU2_OMP_PARALLEL { - /// TODO: Add worksharing to SetUnd_LaplZero and co. - SU2_OMP_MASTER nodes->SetUnd_LaplZero(); - SU2_OMP_BARRIER /*--- Loop interior edges ---*/ diff --git a/SU2_CFD/src/variables/CVariable.cpp b/SU2_CFD/src/variables/CVariable.cpp index e3aeae191f7d..441b222e4938 100644 --- a/SU2_CFD/src/variables/CVariable.cpp +++ b/SU2_CFD/src/variables/CVariable.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -27,6 +27,7 @@ #include "../../include/variables/CVariable.hpp" +#include "../../../Common/include/omp_structure.hpp" CVariable::CVariable(unsigned long npoint, unsigned long nvar, CConfig *config) { @@ -79,23 +80,41 @@ CVariable::CVariable(unsigned long npoint, unsigned long ndim, unsigned long nva Solution_BGS_k.resize(nPoint,nVar) = su2double(0.0); } -void CVariable::Set_OldSolution() { Solution_Old = Solution; } +void CVariable::Set_OldSolution() { + assert(Solution_Old.size() == Solution.size()); + parallelCopy(Solution.size(), Solution.data(), Solution_Old.data()); +} -void CVariable::Set_Solution() { Solution = Solution_Old; } +void CVariable::Set_Solution() { + assert(Solution.size() == Solution_Old.size()); + parallelCopy(Solution_Old.size(), Solution_Old.data(), Solution.data()); +} -void CVariable::Set_Solution_time_n() { Solution_time_n = Solution; } +void CVariable::Set_Solution_time_n() { + assert(Solution_time_n.size() == Solution.size()); + parallelCopy(Solution.size(), Solution.data(), Solution_time_n.data()); +} -void CVariable::Set_Solution_time_n1() { Solution_time_n1 = Solution_time_n; } +void CVariable::Set_Solution_time_n1() { + assert(Solution_time_n1.size() == Solution_time_n.size()); + parallelCopy(Solution_time_n.size(), Solution_time_n.data(), Solution_time_n1.data()); +} -void CVariable::Set_BGSSolution_k() { Solution_BGS_k = Solution; } +void CVariable::Set_BGSSolution_k() { + assert(Solution_BGS_k.size() == Solution.size()); + parallelCopy(Solution.size(), Solution.data(), Solution_BGS_k.data()); +} -void CVariable::Restore_BGSSolution_k() { Solution = Solution_BGS_k; } +void CVariable::Restore_BGSSolution_k() { + assert(Solution.size() == Solution_BGS_k.size()); + parallelCopy(Solution_BGS_k.size(), Solution_BGS_k.data(), Solution.data()); +} -void CVariable::SetResidualSumZero() { Residual_Sum.setConstant(0.0); } +void CVariable::SetResidualSumZero() { parallelSet(Residual_Sum.size(), 0.0, Residual_Sum.data()); } -void CVariable::SetUnd_LaplZero() { Undivided_Laplacian.setConstant(0.0); } +void CVariable::SetUnd_LaplZero() { parallelSet(Undivided_Laplacian.size(), 0.0, Undivided_Laplacian.data()); } -void CVariable::SetExternalZero() { External.setConstant(0.0); } +void CVariable::SetExternalZero() { parallelSet(External.size(), 0.0, External.data()); } void CVariable::RegisterSolution(bool input, bool push_index) { for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) { From 1993f850000785dc19fc252c75af10a4860f86a8 Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Fri, 7 Feb 2020 17:17:50 +0000 Subject: [PATCH 099/118] move the parallel region out of CSysSolve, clients call "Solve" already in parallel --- Common/include/linear_algebra/CSysSolve.hpp | 4 + Common/src/linear_algebra/CSysSolve.cpp | 123 ++++++++++---------- SU2_CFD/include/solvers/CFEASolver.hpp | 7 +- SU2_CFD/src/solvers/CEulerSolver.cpp | 18 ++- SU2_CFD/src/solvers/CFEASolver.cpp | 31 +++-- SU2_CFD/src/solvers/CTurbSolver.cpp | 20 ++-- 6 files changed, 106 insertions(+), 97 deletions(-) diff --git a/Common/include/linear_algebra/CSysSolve.hpp b/Common/include/linear_algebra/CSysSolve.hpp index 20f480bf4f0d..4922064507f7 100644 --- a/Common/include/linear_algebra/CSysSolve.hpp +++ b/Common/include/linear_algebra/CSysSolve.hpp @@ -57,6 +57,10 @@ using namespace std; * creating CSysSolve objects we can more easily assign different * matrix-vector products and preconditioners to different problems * that may arise in a hierarchical solver (i.e. multigrid). + * + * The methods of this class are designed to be called by multiple OpenMP threads. + * Beware of writes to class member variables, for example "Residual" should only + * be modified by one thread. */ template class CSysSolve { diff --git a/Common/src/linear_algebra/CSysSolve.cpp b/Common/src/linear_algebra/CSysSolve.cpp index f38ad6d212f0..fafd401fedee 100644 --- a/Common/src/linear_algebra/CSysSolve.cpp +++ b/Common/src/linear_algebra/CSysSolve.cpp @@ -751,8 +751,12 @@ void CSysSolve::HandleTemporariesIn(const CSysVector & Lin /*--- When the type is the same the temporaties are not required ---*/ /*--- Set the pointers ---*/ - LinSysRes_ptr = &LinSysRes; - LinSysSol_ptr = &LinSysSol; + SU2_OMP_MASTER + { + LinSysRes_ptr = &LinSysRes; + LinSysSol_ptr = &LinSysSol; + } + SU2_OMP_BARRIER } template<> @@ -760,8 +764,12 @@ void CSysSolve::HandleTemporariesOut(CSysVector & LinSysSo /*--- When the type is the same the temporaties are not required ---*/ /*--- Reset the pointers ---*/ - LinSysRes_ptr = nullptr; - LinSysSol_ptr = nullptr; + SU2_OMP_MASTER + { + LinSysRes_ptr = nullptr; + LinSysSol_ptr = nullptr; + } + SU2_OMP_BARRIER } #ifdef CODI_REVERSE_TYPE @@ -774,8 +782,12 @@ void CSysSolve::HandleTemporariesIn(const CSysVector & LinSysSol_tmp.PassiveCopy(LinSysSol); /*--- Set the pointers ---*/ - LinSysRes_ptr = &LinSysRes_tmp; - LinSysSol_ptr = &LinSysSol_tmp; + SU2_OMP_MASTER + { + LinSysRes_ptr = &LinSysRes_tmp; + LinSysSol_ptr = &LinSysSol_tmp; + } + SU2_OMP_BARRIER } template<> @@ -786,8 +798,12 @@ void CSysSolve::HandleTemporariesOut(CSysVector & LinS LinSysSol.PassiveCopy(LinSysSol_tmp); /*--- Reset the pointers ---*/ - LinSysRes_ptr = nullptr; - LinSysSol_ptr = nullptr; + SU2_OMP_MASTER + { + LinSysRes_ptr = nullptr; + LinSysSol_ptr = nullptr; + } + SU2_OMP_BARRIER } #endif @@ -878,68 +894,53 @@ unsigned long CSysSolve::Solve(CSysMatrix & Jacobian, co break; } - /*--- Start a thread-parallel section covering the preparation of the - * preconditioner and the solution of the linear solver. - * Beware of shared variables, i.e. defined outside the section or - * members of ANY class used therein, they should be treated as - * read-only or explicitly synchronized if written to. ---*/ + /*--- Build preconditioner. ---*/ - unsigned long IterLinSol = 0; + precond->Build(); - SU2_OMP_PARALLEL - { - /*--- Build preconditioner in parallel. ---*/ - precond->Build(); + /*--- Solve system. ---*/ - /*--- Thread-local variables. ---*/ - unsigned long iter = 0; - ScalarType residual = 0.0, norm0 = 0.0; + unsigned long IterLinSol = 0; + ScalarType residual = 0.0, norm0 = 0.0; - switch (KindSolver) { - case BCGSTAB: - iter = BCGSTAB_LinSolver(*LinSysRes_ptr, *LinSysSol_ptr, mat_vec, *precond, SolverTol, MaxIter, residual, ScreenOutput, config); - break; - case FGMRES: - iter = FGMRES_LinSolver(*LinSysRes_ptr, *LinSysSol_ptr, mat_vec, *precond, SolverTol, MaxIter, residual, ScreenOutput, config); - break; - case CONJUGATE_GRADIENT: - iter = CG_LinSolver(*LinSysRes_ptr, *LinSysSol_ptr, mat_vec, *precond, SolverTol, MaxIter, residual, ScreenOutput, config); - break; - case RESTARTED_FGMRES: - norm0 = LinSysRes_ptr->norm(); - while (iter < MaxIter) { - /*--- Enforce a hard limit on total number of iterations ---*/ - unsigned long IterLimit = min(RestartIter, MaxIter-iter); - iter += FGMRES_LinSolver(*LinSysRes_ptr, *LinSysSol_ptr, mat_vec, *precond, SolverTol, IterLimit, residual, ScreenOutput, config); - if ( residual < SolverTol*norm0 ) break; - } - break; - case SMOOTHER: - iter = Smoother_LinSolver(*LinSysRes_ptr, *LinSysSol_ptr, mat_vec, *precond, SolverTol, MaxIter, residual, ScreenOutput, config); - break; - case PASTIX_LDLT : case PASTIX_LU: - Jacobian.BuildPastixPreconditioner(geometry, config, KindSolver); - Jacobian.ComputePastixPreconditioner(*LinSysRes_ptr, *LinSysSol_ptr, geometry, config); - iter = 1; - break; - default: - SU2_MPI::Error("Unknown type of linear solver.",CURRENT_FUNCTION); - } + switch (KindSolver) { + case BCGSTAB: + IterLinSol = BCGSTAB_LinSolver(*LinSysRes_ptr, *LinSysSol_ptr, mat_vec, *precond, SolverTol, MaxIter, residual, ScreenOutput, config); + break; + case FGMRES: + IterLinSol = FGMRES_LinSolver(*LinSysRes_ptr, *LinSysSol_ptr, mat_vec, *precond, SolverTol, MaxIter, residual, ScreenOutput, config); + break; + case CONJUGATE_GRADIENT: + IterLinSol = CG_LinSolver(*LinSysRes_ptr, *LinSysSol_ptr, mat_vec, *precond, SolverTol, MaxIter, residual, ScreenOutput, config); + break; + case RESTARTED_FGMRES: + norm0 = LinSysRes_ptr->norm(); + while (IterLinSol < MaxIter) { + /*--- Enforce a hard limit on total number of iterations ---*/ + unsigned long IterLimit = min(RestartIter, MaxIter-IterLinSol); + IterLinSol += FGMRES_LinSolver(*LinSysRes_ptr, *LinSysSol_ptr, mat_vec, *precond, SolverTol, IterLimit, residual, ScreenOutput, config); + if ( residual < SolverTol*norm0 ) break; + } + break; + case SMOOTHER: + IterLinSol = Smoother_LinSolver(*LinSysRes_ptr, *LinSysSol_ptr, mat_vec, *precond, SolverTol, MaxIter, residual, ScreenOutput, config); + break; + case PASTIX_LDLT : case PASTIX_LU: + Jacobian.BuildPastixPreconditioner(geometry, config, KindSolver); + Jacobian.ComputePastixPreconditioner(*LinSysRes_ptr, *LinSysSol_ptr, geometry, config); + IterLinSol = 1; + break; + default: + SU2_MPI::Error("Unknown type of linear solver.",CURRENT_FUNCTION); + } - /*--- Only one thread modifies shared variables, synchronization - * is not required as we are exiting the parallel section. ---*/ - SU2_OMP_MASTER - { - IterLinSol = iter; - Residual = residual; - } + SU2_OMP_MASTER + Residual = residual; - } // end SU2_OMP_PARALLEL + HandleTemporariesOut(LinSysSol); delete precond; - HandleTemporariesOut(LinSysSol); - if(TapeActive) { bool RequiresTranspose = !mesh_deform; // jacobian is symmetric diff --git a/SU2_CFD/include/solvers/CFEASolver.hpp b/SU2_CFD/include/solvers/CFEASolver.hpp index da76e495bb91..d004836fe0e4 100644 --- a/SU2_CFD/include/solvers/CFEASolver.hpp +++ b/SU2_CFD/include/solvers/CFEASolver.hpp @@ -85,9 +85,12 @@ class CFEASolver : public CSolver { bool topol_filter_applied; /*!< \brief True if density filtering has been performed. */ unsigned long nElement; /*!< \brief Number of elements. */ - unsigned long IterLinSol; /*!< \brief Number of iterations of the linear solver. */ - CVariable* nodes = nullptr; /*!< \brief The highest level in the variable hierarchy this solver can safely use. */ + /*! + * \brief The highest level in the variable hierarchy this solver can safely use, + * CVariable is the common denominator between the FEA and Mesh deformation variables. + */ + CVariable* nodes = nullptr; /*! * \brief Return nodes to allow CSolver::base_nodes to be set. diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index d71ac71ec3de..94ba10d1721b 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -4782,20 +4782,16 @@ void CEulerSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver delete [] LowMachPrec; } - } // end SU2_OMP_PARALLEL - - /// TODO: We should be able to call the linear solver inside the parallel region. - /*--- Solve or smooth the linear system. ---*/ - auto IterLinSol = System.Solve(Jacobian, LinSysRes, LinSysSol, geometry, config); - SetResLinSolver(System.GetResidual()); - SetIterLinSolver(IterLinSol); - - /*--- Go back to parallel. ---*/ - - SU2_OMP_PARALLEL + auto iter = System.Solve(Jacobian, LinSysRes, LinSysSol, geometry, config); + SU2_OMP_MASTER { + SetIterLinSolver(iter); + SetResLinSolver(System.GetResidual()); + } + SU2_OMP_BARRIER + ComputeUnderRelaxationFactor(solver_container, config); diff --git a/SU2_CFD/src/solvers/CFEASolver.cpp b/SU2_CFD/src/solvers/CFEASolver.cpp index c6299bba4bb1..8a92716470ef 100644 --- a/SU2_CFD/src/solvers/CFEASolver.cpp +++ b/SU2_CFD/src/solvers/CFEASolver.cpp @@ -2763,23 +2763,32 @@ void CFEASolver::GeneralizedAlpha_UpdateLoads(CGeometry *geometry, CSolver **sol void CFEASolver::Solve_System(CGeometry *geometry, CConfig *config) { + SU2_OMP_PARALLEL + { /*--- Initialize residual and solution at the ghost points ---*/ - for (auto iPoint = nPointDomain; iPoint < nPoint; iPoint++) { - LinSysRes.SetBlock_Zero(iPoint); - LinSysSol.SetBlock_Zero(iPoint); - } - - IterLinSol = System.Solve(Jacobian, LinSysRes, LinSysSol, geometry, config); - - /*--- The the number of iterations of the linear solver ---*/ + SU2_OMP(sections) + { + SU2_OMP(section) + for (auto iPoint = nPointDomain; iPoint < nPoint; iPoint++) + LinSysRes.SetBlock_Zero(iPoint); - SetIterLinSolver(IterLinSol); + SU2_OMP(section) + for (auto iPoint = nPointDomain; iPoint < nPoint; iPoint++) + LinSysSol.SetBlock_Zero(iPoint); + } - /*--- Store the value of the residual. ---*/ + /*--- Solve or smooth the linear system. ---*/ - SetResLinSolver(System.GetResidual()); + auto iter = System.Solve(Jacobian, LinSysRes, LinSysSol, geometry, config); + SU2_OMP_MASTER + { + SetIterLinSolver(iter); + SetResLinSolver(System.GetResidual()); + } + SU2_OMP_BARRIER + } // end SU2_OMP_PARALLEL } diff --git a/SU2_CFD/src/solvers/CTurbSolver.cpp b/SU2_CFD/src/solvers/CTurbSolver.cpp index ef81397e02e6..ae31272d6c37 100644 --- a/SU2_CFD/src/solvers/CTurbSolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSolver.cpp @@ -466,7 +466,7 @@ void CTurbSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver_ /*--- Initialize residual and solution at the ghost points ---*/ - SU2_OMP(sections nowait) + SU2_OMP(sections) { SU2_OMP(section) for (unsigned long iPoint = nPointDomain; iPoint < nPoint; iPoint++) @@ -477,20 +477,16 @@ void CTurbSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver_ LinSysSol.SetBlock_Zero(iPoint); } - } // end SU2_OMP_PARALLEL - - /// TODO: We should be able to call the linear solver inside the parallel region. - /*--- Solve or smooth the linear system ---*/ - unsigned long IterLinSol = System.Solve(Jacobian, LinSysRes, LinSysSol, geometry, config); - SetIterLinSolver(IterLinSol); - SetResLinSolver(System.GetResidual()); - - /*--- Go back to parallel. ---*/ - - SU2_OMP_PARALLEL + auto iter = System.Solve(Jacobian, LinSysRes, LinSysSol, geometry, config); + SU2_OMP_MASTER { + SetIterLinSolver(iter); + SetResLinSolver(System.GetResidual()); + } + SU2_OMP_BARRIER + ComputeUnderRelaxationFactor(solver_container, config); From 704bf0995f744a7ca6d2ba7390471e29795571fc Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Fri, 7 Feb 2020 18:49:08 +0000 Subject: [PATCH 100/118] missing sliding_interface updates --- TestCases/serial_regression.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TestCases/serial_regression.py b/TestCases/serial_regression.py index 4c2f18a68526..c087bcb6449f 100644 --- a/TestCases/serial_regression.py +++ b/TestCases/serial_regression.py @@ -1020,7 +1020,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.777044, 1.134679, 1.224316] #last 4 columns + rotating_cylinders.test_vals = [3.000000, 0.000000, 0.777273, 1.134732, 1.224115] #last 4 columns rotating_cylinders.su2_exec = "SU2_CFD" rotating_cylinders.timeout = 1600 rotating_cylinders.tol = 0.00001 @@ -1033,7 +1033,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.228735, 1.648284] #last 4 columns + supersonic_vortex_shedding.test_vals = [5.000000, 0.000000, 1.227921, 1.638901] #last 4 columns supersonic_vortex_shedding.su2_exec = "SU2_CFD" supersonic_vortex_shedding.timeout = 1600 supersonic_vortex_shedding.tol = 0.00001 From 9d95257646d0b85514cb926c0e89b58ea06a0050 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Sat, 8 Feb 2020 13:09:19 +0000 Subject: [PATCH 101/118] add worksharing construct to MG routines --- SU2_CFD/include/variables/CVariable.hpp | 4 +- SU2_CFD/src/integration_structure.cpp | 8 +- SU2_CFD/src/integration_time.cpp | 840 +++++++++++++----------- SU2_CFD/src/variables/CVariable.cpp | 2 - 4 files changed, 476 insertions(+), 378 deletions(-) diff --git a/SU2_CFD/include/variables/CVariable.hpp b/SU2_CFD/include/variables/CVariable.hpp index 74c367715d40..5b4a75afa4f4 100644 --- a/SU2_CFD/include/variables/CVariable.hpp +++ b/SU2_CFD/include/variables/CVariable.hpp @@ -524,7 +524,9 @@ class CVariable { /*! * \brief Set summed residual vector to zero value. */ - void SetResidualSumZero(); + inline void SetResidualSumZero(unsigned long iPoint) { + for (unsigned long iVar = 0; iVar < nVar; iVar++) Residual_Sum(iPoint,iVar) = 0.0; + } /*! * \brief Set the velocity of the truncation error to zero. diff --git a/SU2_CFD/src/integration_structure.cpp b/SU2_CFD/src/integration_structure.cpp index cb5c7b134854..1a6e743f7beb 100644 --- a/SU2_CFD/src/integration_structure.cpp +++ b/SU2_CFD/src/integration_structure.cpp @@ -25,8 +25,9 @@ * License along with SU2. If not, see . */ - #include "../include/integration_structure.hpp" +#include "../../Common/include/omp_structure.hpp" + CIntegration::CIntegration(CConfig *config) { rank = SU2_MPI::GetRank(); @@ -284,10 +285,15 @@ void CIntegration::Adjoint_Setup(CGeometry ****geometry, CSolver *****solver_con solver_container[iZone][INST_0][iMGLevel][FLOW_SOL]->SetTime_Step(geometry[iZone][INST_0][iMGLevel], solver_container[iZone][INST_0][iMGLevel], config[iZone], iMGLevel, Iteration); /*--- Set the force coefficients ---*/ + + SU2_OMP_MASTER + { solver_container[iZone][INST_0][iMGLevel][FLOW_SOL]->SetTotal_CD(solver_container[iZone][INST_0][MESH_0][FLOW_SOL]->GetTotal_CD()); solver_container[iZone][INST_0][iMGLevel][FLOW_SOL]->SetTotal_CL(solver_container[iZone][INST_0][MESH_0][FLOW_SOL]->GetTotal_CL()); solver_container[iZone][INST_0][iMGLevel][FLOW_SOL]->SetTotal_CT(solver_container[iZone][INST_0][MESH_0][FLOW_SOL]->GetTotal_CT()); solver_container[iZone][INST_0][iMGLevel][FLOW_SOL]->SetTotal_CQ(solver_container[iZone][INST_0][MESH_0][FLOW_SOL]->GetTotal_CQ()); + } + SU2_OMP_BARRIER /*--- Restrict solution and gradients to the coarse levels ---*/ diff --git a/SU2_CFD/src/integration_time.cpp b/SU2_CFD/src/integration_time.cpp index 1272674eed47..6c06d5c523da 100644 --- a/SU2_CFD/src/integration_time.cpp +++ b/SU2_CFD/src/integration_time.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -25,8 +25,9 @@ * License along with SU2. If not, see . */ - #include "../include/integration_structure.hpp" +#include "../../Common/include/omp_structure.hpp" + CMultiGridIntegration::CMultiGridIntegration(CConfig *config) : CIntegration(config) {} @@ -42,7 +43,7 @@ void CMultiGridIntegration::MultiGrid_Iteration(CGeometry ****geometry, unsigned short FinestMesh; su2double monitor = 1.0; bool FullMG = false; - + const bool direct = ((config[iZone]->GetKind_Solver() == EULER) || (config[iZone]->GetKind_Solver() == NAVIER_STOKES) || (config[iZone]->GetKind_Solver() == RANS) || @@ -55,30 +56,37 @@ void CMultiGridIntegration::MultiGrid_Iteration(CGeometry ****geometry, (config[iZone]->GetKind_Solver() == DISC_ADJ_FEM_EULER) || (config[iZone]->GetKind_Solver() == DISC_ADJ_FEM_NS) || (config[iZone]->GetKind_Solver() == DISC_ADJ_RANS)); + const unsigned short SolContainer_Position = config[iZone]->GetContainerPosition(RunTime_EqSystem); unsigned short RecursiveParam = config[iZone]->GetMGCycle(); - + if (config[iZone]->GetMGCycle() == FULLMG_CYCLE) { RecursiveParam = V_CYCLE; FullMG = true; } - + /*--- Full multigrid strategy and start up with fine grid only works with the direct problem ---*/ - if (!config[iZone]->GetRestart() && FullMG && direct && ( Convergence_FullMG && (config[iZone]->GetFinestMesh() != MESH_0 ))) { - SetProlongated_Solution(RunTime_EqSystem, solver_container[iZone][iInst][config[iZone]->GetFinestMesh()-1][SolContainer_Position], - solver_container[iZone][iInst][config[iZone]->GetFinestMesh()][SolContainer_Position], - geometry[iZone][iInst][config[iZone]->GetFinestMesh()-1], geometry[iZone][iInst][config[iZone]->GetFinestMesh()], + FinestMesh = config[iZone]->GetFinestMesh(); + + if (!config[iZone]->GetRestart() && FullMG && direct && ( Convergence_FullMG && (FinestMesh != MESH_0 ))) { + + SetProlongated_Solution(RunTime_EqSystem, + solver_container[iZone][iInst][FinestMesh-1][SolContainer_Position], + solver_container[iZone][iInst][FinestMesh][SolContainer_Position], + geometry[iZone][iInst][FinestMesh-1], + geometry[iZone][iInst][FinestMesh], config[iZone]); + config[iZone]->SubtractFinestMesh(); } /*--- Set the current finest grid (full multigrid strategy) ---*/ - + FinestMesh = config[iZone]->GetFinestMesh(); /*--- Perform the Full Approximation Scheme multigrid ---*/ - + MultiGrid_Cycle(geometry, solver_container, numerics_container, config, FinestMesh, RecursiveParam, RunTime_EqSystem, iZone, iInst); @@ -86,162 +94,202 @@ void CMultiGridIntegration::MultiGrid_Iteration(CGeometry ****geometry, /*--- Computes primitive variables and gradients in the finest mesh (useful for the next solver (turbulence) and output ---*/ solver_container[iZone][iInst][MESH_0][SolContainer_Position]->Preprocessing(geometry[iZone][iInst][MESH_0], - solver_container[iZone][iInst][MESH_0], config[iZone], - MESH_0, NO_RK_ITER, RunTime_EqSystem, true); - + solver_container[iZone][iInst][MESH_0], + config[iZone], MESH_0, NO_RK_ITER, + RunTime_EqSystem, true); /*--- Compute non-dimensional parameters and the convergence monitor ---*/ - + NonDimensional_Parameters(geometry[iZone][iInst], solver_container[iZone][iInst], numerics_container[iZone][iInst], config[iZone], FinestMesh, RunTime_EqSystem, &monitor); - + } void CMultiGridIntegration::MultiGrid_Cycle(CGeometry ****geometry, CSolver *****solver_container, CNumerics ******numerics_container, - CConfig **config, + CConfig **config_container, unsigned short iMesh, unsigned short RecursiveParam, unsigned short RunTime_EqSystem, unsigned short iZone, unsigned short iInst) { - - unsigned short iPreSmooth, iPostSmooth, iRKStep, iRKLimit = 1; - unsigned short SolContainer_Position = config[iZone]->GetContainerPosition(RunTime_EqSystem); - + + CConfig* config = config_container[iZone]; + + const unsigned short SolContainer_Position = config->GetContainerPosition(RunTime_EqSystem); + const bool classical_rk4 = (config->GetKind_TimeIntScheme() == CLASSICAL_RK4_EXPLICIT); + + /*--- Shorter names to refer to fine grid entities. ---*/ + + CGeometry* geometry_fine = geometry[iZone][iInst][iMesh]; + CSolver** solver_container_fine = solver_container[iZone][iInst][iMesh]; + CSolver* solver_fine = solver_container_fine[SolContainer_Position]; + CNumerics** numerics_fine = numerics_container[iZone][iInst][iMesh][SolContainer_Position]; + + /*--- Number of RK steps. ---*/ + + unsigned short iRKLimit = 1; + + switch (config->GetKind_TimeIntScheme()) { + case RUNGE_KUTTA_EXPLICIT: + iRKLimit = config->GetnRKStep(); + break; + case CLASSICAL_RK4_EXPLICIT: + iRKLimit = 4; + break; + case EULER_EXPLICIT: + case EULER_IMPLICIT: + iRKLimit = 1; + break; + } + /*--- Do a presmoothing on the grid iMesh to be restricted to the grid iMesh+1 ---*/ - - for (iPreSmooth = 0; iPreSmooth < config[iZone]->GetMG_PreSmooth(iMesh); iPreSmooth++) { - - switch (config[iZone]->GetKind_TimeIntScheme()) { - case RUNGE_KUTTA_EXPLICIT: iRKLimit = config[iZone]->GetnRKStep(); break; - case CLASSICAL_RK4_EXPLICIT: iRKLimit = 4; break; - case EULER_EXPLICIT: case EULER_IMPLICIT: iRKLimit = 1; break; } + + for (unsigned short iPreSmooth = 0; iPreSmooth < config->GetMG_PreSmooth(iMesh); iPreSmooth++) { /*--- Time and space integration ---*/ - - for (iRKStep = 0; iRKStep < iRKLimit; iRKStep++) { - + + for (unsigned short iRKStep = 0; iRKStep < iRKLimit; iRKStep++) { + /*--- Send-Receive boundary conditions, and preprocessing ---*/ - - solver_container[iZone][iInst][iMesh][SolContainer_Position]->Preprocessing(geometry[iZone][iInst][iMesh], solver_container[iZone][iInst][iMesh], config[iZone], iMesh, iRKStep, RunTime_EqSystem, false); - + + solver_fine->Preprocessing(geometry_fine, solver_container_fine, config, iMesh, iRKStep, RunTime_EqSystem, false); + if (iRKStep == 0) { - + /*--- Set the old solution ---*/ - - solver_container[iZone][iInst][iMesh][SolContainer_Position]->Set_OldSolution(geometry[iZone][iInst][iMesh]); - if (config[iZone]->GetKind_TimeIntScheme() == CLASSICAL_RK4_EXPLICIT) - solver_container[iZone][iInst][iMesh][SolContainer_Position]->Set_NewSolution(geometry[iZone][iInst][iMesh]); + solver_fine->Set_OldSolution(geometry_fine); + + if (classical_rk4) + solver_fine->Set_NewSolution(geometry_fine); /*--- Compute time step, max eigenvalue, and integration scheme (steady and unsteady problems) ---*/ - - solver_container[iZone][iInst][iMesh][SolContainer_Position]->SetTime_Step(geometry[iZone][iInst][iMesh], solver_container[iZone][iInst][iMesh], config[iZone], iMesh, config[iZone]->GetTimeIter()); - + + solver_fine->SetTime_Step(geometry_fine, solver_container_fine, config, iMesh, config->GetTimeIter()); + /*--- Restrict the solution and gradient for the adjoint problem ---*/ - - Adjoint_Setup(geometry, solver_container, config, RunTime_EqSystem, config[iZone]->GetTimeIter(), iZone); - + + Adjoint_Setup(geometry, solver_container, config_container, RunTime_EqSystem, config->GetTimeIter(), iZone); + } - + /*--- Space integration ---*/ - - Space_Integration(geometry[iZone][iInst][iMesh], solver_container[iZone][iInst][iMesh], numerics_container[iZone][iInst][iMesh][SolContainer_Position], config[iZone], iMesh, iRKStep, RunTime_EqSystem); - + + Space_Integration(geometry_fine, solver_container_fine, numerics_fine, config, iMesh, iRKStep, RunTime_EqSystem); + /*--- Time integration, update solution using the old solution plus the solution increment ---*/ - - Time_Integration(geometry[iZone][iInst][iMesh], solver_container[iZone][iInst][iMesh], config[iZone], iRKStep, RunTime_EqSystem); - + + Time_Integration(geometry_fine, solver_container_fine, config, iRKStep, RunTime_EqSystem); + /*--- Send-Receive boundary conditions, and postprocessing ---*/ - - solver_container[iZone][iInst][iMesh][SolContainer_Position]->Postprocessing(geometry[iZone][iInst][iMesh], solver_container[iZone][iInst][iMesh], config[iZone], iMesh); - + + solver_fine->Postprocessing(geometry_fine, solver_container_fine, config, iMesh); + } - + } - + /*--- Compute Forcing Term $P_(k+1) = I^(k+1)_k(P_k+F_k(u_k))-F_(k+1)(I^(k+1)_k u_k)$ and update solution for multigrid ---*/ - if ( iMesh < config[iZone]->GetnMGLevels() ) { + + if ( iMesh < config->GetnMGLevels() ) { + + /*--- Shorter names to refer to coarse grid entities. ---*/ + + CGeometry* geometry_coarse = geometry[iZone][iInst][iMesh+1]; + CSolver** solver_container_coarse = solver_container[iZone][iInst][iMesh+1]; + CSolver* solver_coarse = solver_container_coarse[SolContainer_Position]; + CNumerics** numerics_coarse = numerics_container[iZone][iInst][iMesh+1][SolContainer_Position]; + /*--- Compute $r_k = P_k + F_k(u_k)$ ---*/ - - solver_container[iZone][iInst][iMesh][SolContainer_Position]->Preprocessing(geometry[iZone][iInst][iMesh], solver_container[iZone][iInst][iMesh], config[iZone], iMesh, NO_RK_ITER, RunTime_EqSystem, false); - Space_Integration(geometry[iZone][iInst][iMesh], solver_container[iZone][iInst][iMesh], numerics_container[iZone][iInst][iMesh][SolContainer_Position], config[iZone], iMesh, NO_RK_ITER, RunTime_EqSystem); - SetResidual_Term(geometry[iZone][iInst][iMesh], solver_container[iZone][iInst][iMesh][SolContainer_Position]); - + + solver_fine->Preprocessing(geometry_fine, solver_container_fine, config, iMesh, NO_RK_ITER, RunTime_EqSystem, false); + + /// TODO: For implicit schemes, this call to Space_Integration can skip building the system matrix. + Space_Integration(geometry_fine, solver_container_fine, numerics_fine, config, iMesh, NO_RK_ITER, RunTime_EqSystem); + + SetResidual_Term(geometry_fine, solver_fine); + /*--- Compute $r_(k+1) = F_(k+1)(I^(k+1)_k u_k)$ ---*/ - - SetRestricted_Solution(RunTime_EqSystem, solver_container[iZone][iInst][iMesh][SolContainer_Position], solver_container[iZone][iInst][iMesh+1][SolContainer_Position], geometry[iZone][iInst][iMesh], geometry[iZone][iInst][iMesh+1], config[iZone]); - solver_container[iZone][iInst][iMesh+1][SolContainer_Position]->Preprocessing(geometry[iZone][iInst][iMesh+1], solver_container[iZone][iInst][iMesh+1], config[iZone], iMesh+1, NO_RK_ITER, RunTime_EqSystem, false); - Space_Integration(geometry[iZone][iInst][iMesh+1], solver_container[iZone][iInst][iMesh+1], numerics_container[iZone][iInst][iMesh+1][SolContainer_Position], config[iZone], iMesh+1, NO_RK_ITER, RunTime_EqSystem); - + + SetRestricted_Solution(RunTime_EqSystem, solver_fine, solver_coarse, geometry_fine, geometry_coarse, config); + + solver_coarse->Preprocessing(geometry_coarse, solver_container_coarse, config, iMesh+1, NO_RK_ITER, RunTime_EqSystem, false); + + Space_Integration(geometry_coarse, solver_container_coarse, numerics_coarse, config, iMesh+1, NO_RK_ITER, RunTime_EqSystem); + /*--- Compute $P_(k+1) = I^(k+1)_k(r_k) - r_(k+1) ---*/ - - SetForcing_Term(solver_container[iZone][iInst][iMesh][SolContainer_Position], solver_container[iZone][iInst][iMesh+1][SolContainer_Position], geometry[iZone][iInst][iMesh], geometry[iZone][iInst][iMesh+1], config[iZone], iMesh+1); - - /*--- Recursive call to MultiGrid_Cycle ---*/ - + + SetForcing_Term(solver_fine, solver_coarse, geometry_fine, geometry_coarse, config, iMesh+1); + + /*--- Recursive call to MultiGrid_Cycle (this routine). ---*/ + for (unsigned short imu = 0; imu <= RecursiveParam; imu++) { - if (iMesh == config[iZone]->GetnMGLevels()-2) MultiGrid_Cycle(geometry, solver_container, numerics_container, config, iMesh+1, 0, RunTime_EqSystem, iZone, iInst); - else MultiGrid_Cycle(geometry, solver_container, numerics_container, config, iMesh+1, RecursiveParam, RunTime_EqSystem, iZone, iInst); + + unsigned short nextRecurseParam = RecursiveParam; + if (iMesh == config->GetnMGLevels()-2) + nextRecurseParam = 0; + + MultiGrid_Cycle(geometry, solver_container, numerics_container, config_container, + iMesh+1, nextRecurseParam, RunTime_EqSystem, iZone, iInst); } - + /*--- Compute prolongated solution, and smooth the correction $u^(new)_k = u_k + Smooth(I^k_(k+1)(u_(k+1)-I^(k+1)_k u_k))$ ---*/ + + GetProlongated_Correction(RunTime_EqSystem, solver_fine, solver_coarse, geometry_fine, geometry_coarse, config); + + SmoothProlongated_Correction(RunTime_EqSystem, solver_fine, geometry_fine, config->GetMG_CorrecSmooth(iMesh), 1.25, config); + + SetProlongated_Correction(solver_fine, geometry_fine, config, iMesh); + - GetProlongated_Correction(RunTime_EqSystem, solver_container[iZone][iInst][iMesh][SolContainer_Position], solver_container[iZone][iInst][iMesh+1][SolContainer_Position], - geometry[iZone][iInst][iMesh], geometry[iZone][iInst][iMesh+1], config[iZone]); - SmoothProlongated_Correction(RunTime_EqSystem, solver_container[iZone][iInst][iMesh][SolContainer_Position], geometry[iZone][iInst][iMesh], - config[iZone]->GetMG_CorrecSmooth(iMesh), 1.25, config[iZone]); - SetProlongated_Correction(solver_container[iZone][iInst][iMesh][SolContainer_Position], geometry[iZone][iInst][iMesh], config[iZone], iMesh); - - /*--- Solution postsmoothing in the prolongated grid ---*/ - - for (iPostSmooth = 0; iPostSmooth < config[iZone]->GetMG_PostSmooth(iMesh); iPostSmooth++) { - - switch (config[iZone]->GetKind_TimeIntScheme()) { - case RUNGE_KUTTA_EXPLICIT: iRKLimit = config[iZone]->GetnRKStep(); break; - case CLASSICAL_RK4_EXPLICIT: iRKLimit = 4; break; - case EULER_EXPLICIT: case EULER_IMPLICIT: iRKLimit = 1; break; } + /*--- Solution post-smoothing in the prolongated grid. ---*/ + + for (unsigned short iPostSmooth = 0; iPostSmooth < config->GetMG_PostSmooth(iMesh); iPostSmooth++) { + + for (unsigned short iRKStep = 0; iRKStep < iRKLimit; iRKStep++) { + + solver_fine->Preprocessing(geometry_fine, solver_container_fine, config, iMesh, iRKStep, RunTime_EqSystem, false); - for (iRKStep = 0; iRKStep < iRKLimit; iRKStep++) { - - solver_container[iZone][iInst][iMesh][SolContainer_Position]->Preprocessing(geometry[iZone][iInst][iMesh], solver_container[iZone][iInst][iMesh], config[iZone], iMesh, iRKStep, RunTime_EqSystem, false); - if (iRKStep == 0) { - solver_container[iZone][iInst][iMesh][SolContainer_Position]->Set_OldSolution(geometry[iZone][iInst][iMesh]); - if (config[iZone]->GetKind_TimeIntScheme() == CLASSICAL_RK4_EXPLICIT) - solver_container[iZone][iInst][iMesh][SolContainer_Position]->Set_NewSolution(geometry[iZone][iInst][iMesh]); - solver_container[iZone][iInst][iMesh][SolContainer_Position]->SetTime_Step(geometry[iZone][iInst][iMesh], solver_container[iZone][iInst][iMesh], config[iZone], iMesh, config[iZone]->GetTimeIter()); + solver_fine->Set_OldSolution(geometry_fine); + + if (classical_rk4) solver_fine->Set_NewSolution(geometry_fine); + + solver_fine->SetTime_Step(geometry_fine, solver_container_fine, config, iMesh, config->GetTimeIter()); } - - Space_Integration(geometry[iZone][iInst][iMesh], solver_container[iZone][iInst][iMesh], numerics_container[iZone][iInst][iMesh][SolContainer_Position], config[iZone], iMesh, iRKStep, RunTime_EqSystem); - Time_Integration(geometry[iZone][iInst][iMesh], solver_container[iZone][iInst][iMesh], config[iZone], iRKStep, RunTime_EqSystem); - - solver_container[iZone][iInst][iMesh][SolContainer_Position]->Postprocessing(geometry[iZone][iInst][iMesh], solver_container[iZone][iInst][iMesh], config[iZone], iMesh); - + + Space_Integration(geometry_fine, solver_container_fine, numerics_fine, config, iMesh, iRKStep, RunTime_EqSystem); + + Time_Integration(geometry_fine, solver_container_fine, config, iRKStep, RunTime_EqSystem); + + solver_fine->Postprocessing(geometry_fine, solver_container_fine, config, iMesh); + } } } - + } -void CMultiGridIntegration::GetProlongated_Correction(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, - CGeometry *geo_coarse, CConfig *config) { +void CMultiGridIntegration::GetProlongated_Correction(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, + CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config) { unsigned long Point_Fine, Point_Coarse, iVertex; unsigned short Boundary, iMarker, iChildren, iVar; - su2double Area_Parent, Area_Children, *Solution_Fine, *Solution_Coarse; - + su2double Area_Parent, Area_Children; + const su2double *Solution_Fine = nullptr, *Solution_Coarse = nullptr; + const unsigned short nVar = sol_coarse->GetnVar(); - + su2double *Solution = new su2double[nVar]; - + + SU2_OMP_FOR_STAT(roundUpDiv(geo_coarse->GetnPointDomain(), omp_get_num_threads())) for (Point_Coarse = 0; Point_Coarse < geo_coarse->GetnPointDomain(); Point_Coarse++) { - + Area_Parent = geo_coarse->node[Point_Coarse]->GetVolume(); - + for (iVar = 0; iVar < nVar; iVar++) Solution[iVar] = 0.0; - + 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(); @@ -249,226 +297,244 @@ void CMultiGridIntegration::GetProlongated_Correction(unsigned short RunTime_EqS for (iVar = 0; iVar < nVar; iVar++) Solution[iVar] -= Solution_Fine[iVar]*Area_Children/Area_Parent; } - + 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->GetNodes()->SetSolution_Old(Point_Coarse,Solution); - } + delete [] Solution; + /*--- Remove any contributions from no-slip walls. ---*/ - + for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { Boundary = config->GetMarker_All_KindBC(iMarker); - if ((Boundary == HEAT_FLUX ) || - (Boundary == ISOTHERMAL ) || - (Boundary == CHT_WALL_INTERFACE )) { - + if ((Boundary == HEAT_FLUX) || + (Boundary == ISOTHERMAL) || + (Boundary == CHT_WALL_INTERFACE)) { + + SU2_OMP_FOR_STAT(32) for (iVertex = 0; iVertex < geo_coarse->nVertex[iMarker]; iVertex++) { - + Point_Coarse = geo_coarse->vertex[iMarker][iVertex]->GetNode(); - + /*--- For dirichlet boundary condtions, set the correction to zero. Note that Solution_Old stores the correction not the actual value ---*/ - + sol_coarse->GetNodes()->SetVelSolutionOldZero(Point_Coarse); - + } - } } - + /*--- MPI the set solution old ---*/ - - sol_coarse->InitiateComms(geo_coarse, config, SOLUTION_OLD); - sol_coarse->CompleteComms(geo_coarse, config, SOLUTION_OLD); + SU2_OMP_MASTER + { + sol_coarse->InitiateComms(geo_coarse, config, SOLUTION_OLD); + sol_coarse->CompleteComms(geo_coarse, config, SOLUTION_OLD); + } + SU2_OMP_BARRIER + + /// TODO: Need to check for possible race condition here (multiple coarse points setting the same fine). + + SU2_OMP_FOR_STAT(roundUpDiv(geo_coarse->GetnPointDomain(), omp_get_num_threads())) 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->GetNodes()->GetSolution_Old(Point_Coarse)); } } - - delete [] Solution; - + } -void CMultiGridIntegration::SmoothProlongated_Correction (unsigned short RunTime_EqSystem, CSolver *solver, CGeometry *geometry, - unsigned short val_nSmooth, su2double val_smooth_coeff, CConfig *config) { - su2double *Residual_Old, *Residual_Sum, *Residual, *Residual_i, *Residual_j; - unsigned short iVar, iSmooth, iMarker, nneigh; - unsigned long iEdge, iPoint, jPoint, iVertex; +void CMultiGridIntegration::SmoothProlongated_Correction(unsigned short RunTime_EqSystem, CSolver *solver, CGeometry *geometry, + unsigned short val_nSmooth, su2double val_smooth_coeff, CConfig *config) { + + /*--- Check if there is work to do. ---*/ + if (val_nSmooth == 0) return; + const su2double *Residual_Old, *Residual_Sum, *Residual_j; + unsigned short iVar, iSmooth, iMarker, iNeigh; + unsigned long iPoint, jPoint, iVertex; + const unsigned short nVar = solver->GetnVar(); - - if (val_nSmooth > 0) { - - Residual = new su2double [nVar]; - - for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { - Residual_Old = solver->LinSysRes.GetBlock(iPoint); - solver->GetNodes()->SetResidual_Old(iPoint,Residual_Old); - } + + SU2_OMP_FOR_STAT(roundUpDiv(geometry->GetnPoint(), omp_get_num_threads())) + for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { + Residual_Old = solver->LinSysRes.GetBlock(iPoint); + solver->GetNodes()->SetResidual_Old(iPoint,Residual_Old); + } + + /*--- Jacobi iterations. ---*/ + + for (iSmooth = 0; iSmooth < val_nSmooth; iSmooth++) { - /*--- Jacobi iterations ---*/ + /*--- Loop over all mesh points (sum the residuals of direct neighbors). ---*/ - for (iSmooth = 0; iSmooth < val_nSmooth; iSmooth++) { - solver->GetNodes()->SetResidualSumZero(); + SU2_OMP_FOR_STAT(roundUpDiv(geometry->GetnPoint(), omp_get_num_threads())) + for (iPoint = 0; iPoint < geometry->GetnPoint(); ++iPoint) { - /*--- Loop over Interior edges ---*/ + solver->GetNodes()->SetResidualSumZero(iPoint); - for (iEdge = 0; iEdge < geometry->GetnEdge(); iEdge++) { - iPoint = geometry->edge[iEdge]->GetNode(0); - jPoint = geometry->edge[iEdge]->GetNode(1); - - Residual_i = solver->LinSysRes.GetBlock(iPoint); + for (iNeigh = 0; iNeigh < geometry->node[iPoint]->GetnPoint(); ++iNeigh) { + jPoint = geometry->node[iPoint]->GetPoint(iNeigh); Residual_j = solver->LinSysRes.GetBlock(jPoint); - - /*--- Accumulate nearest neighbor Residual to Res_sum for each variable ---*/ - - solver->GetNodes()->AddResidual_Sum(iPoint,Residual_j); - solver->GetNodes()->AddResidual_Sum(jPoint,Residual_i); + solver->GetNodes()->AddResidual_Sum(iPoint, Residual_j); } + + } - /*--- Loop over all mesh points (Update Residuals with averaged sum) ---*/ + /*--- Loop over all mesh points (update residuals with the neighbor averages). ---*/ - for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { - nneigh = geometry->node[iPoint]->GetnPoint(); - 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)); - } - solver->LinSysRes.SetBlock(iPoint, Residual); - } + SU2_OMP_FOR_STAT(roundUpDiv(geometry->GetnPoint(), omp_get_num_threads())) + for (iPoint = 0; iPoint < geometry->GetnPoint(); ++iPoint) { + + su2double factor = 1.0/(1.0+val_smooth_coeff*su2double(geometry->node[iPoint]->GetnPoint())); - /*--- Copy boundary values ---*/ + Residual_Sum = solver->GetNodes()->GetResidual_Sum(iPoint); + Residual_Old = solver->GetNodes()->GetResidual_Old(iPoint); - for (iMarker = 0; iMarker < geometry->GetnMarker(); iMarker++) - if ((config->GetMarker_All_KindBC(iMarker) != INTERNAL_BOUNDARY) && - (config->GetMarker_All_KindBC(iMarker) != PERIODIC_BOUNDARY)) { - for (iVertex = 0; iVertex < geometry->GetnVertex(iMarker); iVertex++) { + for (iVar = 0; iVar < nVar; iVar++) + solver->LinSysRes(iPoint,iVar) = (Residual_Old[iVar] + val_smooth_coeff*Residual_Sum[iVar])*factor; + } + + /*--- Restore original residuals (without average) at boundary points. ---*/ + + for (iMarker = 0; iMarker < geometry->GetnMarker(); iMarker++) { + if ((config->GetMarker_All_KindBC(iMarker) != INTERNAL_BOUNDARY) && + (config->GetMarker_All_KindBC(iMarker) != PERIODIC_BOUNDARY)) { + + SU2_OMP_FOR_STAT(32) + for (iVertex = 0; iVertex < geometry->GetnVertex(iMarker); iVertex++) { iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); Residual_Old = solver->GetNodes()->GetResidual_Old(iPoint); solver->LinSysRes.SetBlock(iPoint, Residual_Old); } - } + } } - - delete [] Residual; - + } + } void CMultiGridIntegration::Smooth_Solution(unsigned short RunTime_EqSystem, CSolver *solver, CGeometry *geometry, unsigned short val_nSmooth, su2double val_smooth_coeff, CConfig *config) { - su2double *Solution_Old, *Solution_Sum, *Solution, *Solution_i, *Solution_j; - unsigned short iVar, iSmooth, iMarker, nneigh; - unsigned long iEdge, iPoint, jPoint, iVertex; - const unsigned short nVar = solver->GetnVar(); + /*--- Check if there is work to do. ---*/ + if (val_nSmooth == 0) return; - if (val_nSmooth > 0) { - - Solution = new su2double [nVar]; - - for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { - Solution_Old = solver->GetNodes()->GetSolution(iPoint); - solver->GetNodes()->SetResidual_Old(iPoint,Solution_Old); - } + const su2double *Solution_Old, *Solution_Sum, *Solution_j; + unsigned short iVar, iSmooth, iMarker, iNeigh; + unsigned long iPoint, jPoint, iVertex; + + const unsigned short nVar = solver->GetnVar(); + + SU2_OMP_FOR_STAT(roundUpDiv(geometry->GetnPoint(), omp_get_num_threads())) + for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { + Solution_Old = solver->GetNodes()->GetSolution(iPoint); + solver->GetNodes()->SetResidual_Old(iPoint,Solution_Old); + } + + /*--- Jacobi iterations ---*/ + + for (iSmooth = 0; iSmooth < val_nSmooth; iSmooth++) { - /*--- Jacobi iterations ---*/ + /*--- Loop over all mesh points (sum the solutions of direct neighbors). ---*/ - for (iSmooth = 0; iSmooth < val_nSmooth; iSmooth++) { - solver->GetNodes()->SetResidualSumZero(); + SU2_OMP_FOR_STAT(roundUpDiv(geometry->GetnPoint(), omp_get_num_threads())) + for (iPoint = 0; iPoint < geometry->GetnPoint(); ++iPoint) { - /*--- Loop over Interior edges ---*/ + solver->GetNodes()->SetResidualSumZero(iPoint); - for (iEdge = 0; iEdge < geometry->GetnEdge(); iEdge++) { - iPoint = geometry->edge[iEdge]->GetNode(0); - jPoint = geometry->edge[iEdge]->GetNode(1); - - Solution_i = solver->GetNodes()->GetSolution(iPoint); + for (iNeigh = 0; iNeigh < geometry->node[iPoint]->GetnPoint(); ++iNeigh) { + jPoint = geometry->node[iPoint]->GetPoint(iNeigh); Solution_j = solver->GetNodes()->GetSolution(jPoint); - - /*--- Accumulate nearest neighbor Residual to Res_sum for each variable ---*/ - - solver->GetNodes()->AddResidual_Sum(iPoint,Solution_j); - solver->GetNodes()->AddResidual_Sum(jPoint,Solution_i); + solver->GetNodes()->AddResidual_Sum(iPoint, Solution_j); } + + } + + /*--- Loop over all mesh points (update solutions with the neighbor averages). ---*/ + + SU2_OMP_FOR_STAT(roundUpDiv(geometry->GetnPoint(), omp_get_num_threads())) + for (iPoint = 0; iPoint < geometry->GetnPoint(); ++iPoint) { + + su2double factor = 1.0/(1.0+val_smooth_coeff*su2double(geometry->node[iPoint]->GetnPoint())); - /*--- Loop over all mesh points (Update Residuals with averaged sum) ---*/ + Solution_Sum = solver->GetNodes()->GetResidual_Sum(iPoint); + Solution_Old = solver->GetNodes()->GetResidual_Old(iPoint); - for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { - nneigh = geometry->node[iPoint]->GetnPoint(); - 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->GetNodes()->SetSolution(iPoint,Solution); + for (iVar = 0; iVar < nVar; iVar++) { + su2double Solution = (Solution_Old[iVar] + val_smooth_coeff*Solution_Sum[iVar])*factor; + solver->GetNodes()->SetSolution(iPoint, iVar, Solution); } - - /*--- Copy boundary values ---*/ - - for (iMarker = 0; iMarker < geometry->GetnMarker(); iMarker++) - if ((config->GetMarker_All_KindBC(iMarker) != INTERNAL_BOUNDARY) && - (config->GetMarker_All_KindBC(iMarker) != PERIODIC_BOUNDARY)) { - for (iVertex = 0; iVertex < geometry->GetnVertex(iMarker); iVertex++) { + } + + /*--- Copy boundary values ---*/ + + for (iMarker = 0; iMarker < geometry->GetnMarker(); iMarker++) { + if ((config->GetMarker_All_KindBC(iMarker) != INTERNAL_BOUNDARY) && + (config->GetMarker_All_KindBC(iMarker) != PERIODIC_BOUNDARY)) { + + SU2_OMP_FOR_STAT(32) + for (iVertex = 0; iVertex < geometry->GetnVertex(iMarker); iVertex++) { iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); Solution_Old = solver->GetNodes()->GetResidual_Old(iPoint); solver->GetNodes()->SetSolution(iPoint,Solution_Old); } - } + } } - - delete [] Solution; - + } } -void CMultiGridIntegration::SetProlongated_Correction(CSolver *sol_fine, CGeometry *geo_fine, CConfig *config, unsigned short iMesh) { +void CMultiGridIntegration::SetProlongated_Correction(CSolver *sol_fine, CGeometry *geo_fine, + CConfig *config, unsigned short iMesh) { unsigned long Point_Fine; unsigned short iVar; su2double *Solution_Fine, *Residual_Fine; - + const unsigned short nVar = sol_fine->GetnVar(); - su2double factor = config->GetDamp_Correc_Prolong(); //pow(config->GetDamp_Correc_Prolong(), iMesh+1); - - su2double *Solution = new su2double [nVar]; - + const su2double factor = config->GetDamp_Correc_Prolong(); //pow(config->GetDamp_Correc_Prolong(), iMesh+1); + + SU2_OMP_FOR_STAT(roundUpDiv(geo_fine->GetnPointDomain(), omp_get_num_threads())) for (Point_Fine = 0; Point_Fine < geo_fine->GetnPointDomain(); Point_Fine++) { Residual_Fine = sol_fine->LinSysRes.GetBlock(Point_Fine); 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]; + if (Residual_Fine[iVar] != Residual_Fine[iVar]) + Residual_Fine[iVar] = 0.0; + Solution_Fine[iVar] += factor*Residual_Fine[iVar]; } - sol_fine->GetNodes()->SetSolution(Point_Fine,Solution); } - + /*--- MPI the new interpolated solution ---*/ - - sol_fine->InitiateComms(geo_fine, config, SOLUTION); - sol_fine->CompleteComms(geo_fine, config, SOLUTION); - - delete [] Solution; + + SU2_OMP_MASTER + { + sol_fine->InitiateComms(geo_fine, config, SOLUTION); + sol_fine->CompleteComms(geo_fine, config, SOLUTION); + } + SU2_OMP_BARRIER + } -void CMultiGridIntegration::SetProlongated_Solution(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config) { +void CMultiGridIntegration::SetProlongated_Solution(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, + CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config) { unsigned long Point_Fine, Point_Coarse; unsigned short iChildren; + + /// TODO: Need to check for possible race condition here (multiple coarse points setting the same fine). + SU2_OMP_FOR_STAT(roundUpDiv(geo_coarse->GetnPointDomain(), omp_get_num_threads())) 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); @@ -477,67 +543,76 @@ void CMultiGridIntegration::SetProlongated_Solution(unsigned short RunTime_EqSys } } -void CMultiGridIntegration::SetForcing_Term(CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config, unsigned short iMesh) { +void CMultiGridIntegration::SetForcing_Term(CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, + CGeometry *geo_coarse, CConfig *config, unsigned short iMesh) { + unsigned long Point_Fine, Point_Coarse, iVertex; unsigned short iMarker, iVar, iChildren; - su2double *Residual_Fine; - + const su2double *Residual_Fine; + const unsigned short nVar = sol_coarse->GetnVar(); su2double factor = config->GetDamp_Res_Restric(); //pow(config->GetDamp_Res_Restric(), iMesh); - + su2double *Residual = new su2double[nVar]; - + + SU2_OMP_FOR_STAT(roundUpDiv(geo_coarse->GetnPointDomain(), omp_get_num_threads())) for (Point_Coarse = 0; Point_Coarse < geo_coarse->GetnPointDomain(); Point_Coarse++) { - sol_coarse->GetNodes()->SetRes_TruncErrorZero(Point_Coarse); + 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++) { Point_Fine = geo_coarse->node[Point_Coarse]->GetChildren_CV(iChildren); Residual_Fine = sol_fine->LinSysRes.GetBlock(Point_Fine); for (iVar = 0; iVar < nVar; iVar++) Residual[iVar] += factor*Residual_Fine[iVar]; } - sol_coarse->GetNodes()->AddRes_TruncError(Point_Coarse,Residual); + sol_coarse->GetNodes()->AddRes_TruncError(Point_Coarse, Residual); } - + + delete [] Residual; + for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { - if ((config->GetMarker_All_KindBC(iMarker) == HEAT_FLUX ) || - (config->GetMarker_All_KindBC(iMarker) == ISOTHERMAL ) || - (config->GetMarker_All_KindBC(iMarker) == CHT_WALL_INTERFACE )) { + if ((config->GetMarker_All_KindBC(iMarker) == HEAT_FLUX) || + (config->GetMarker_All_KindBC(iMarker) == ISOTHERMAL) || + (config->GetMarker_All_KindBC(iMarker) == CHT_WALL_INTERFACE)) { + + SU2_OMP_FOR_STAT(32) for (iVertex = 0; iVertex < geo_coarse->nVertex[iMarker]; iVertex++) { Point_Coarse = geo_coarse->vertex[iMarker][iVertex]->GetNode(); sol_coarse->GetNodes()->SetVel_ResTruncError_Zero(Point_Coarse); } } } - + + SU2_OMP_FOR_STAT(roundUpDiv(geo_coarse->GetnPointDomain(), omp_get_num_threads())) for (Point_Coarse = 0; Point_Coarse < geo_coarse->GetnPointDomain(); Point_Coarse++) { sol_coarse->GetNodes()->SubtractRes_TruncError(Point_Coarse, sol_coarse->LinSysRes.GetBlock(Point_Coarse)); } - - delete [] Residual; + } void CMultiGridIntegration::SetResidual_Term(CGeometry *geometry, CSolver *solver) { - unsigned long iPoint; - - for (iPoint = 0; iPoint < geometry->GetnPointDomain(); iPoint++) + + SU2_OMP_FOR_STAT(roundUpDiv(geometry->GetnPointDomain(), omp_get_num_threads())) + for (unsigned long iPoint = 0; iPoint < geometry->GetnPointDomain(); iPoint++) solver->LinSysRes.AddBlock(iPoint, solver->GetNodes()->GetResTruncError(iPoint)); - + } void CMultiGridIntegration::SetRestricted_Residual(CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config) { unsigned long iVertex, Point_Fine, Point_Coarse; unsigned short iMarker, iVar, iChildren; su2double *Residual_Fine; - + const unsigned short nVar = sol_coarse->GetnVar(); - + su2double *Residual = new su2double[nVar]; - + for (Point_Coarse = 0; Point_Coarse < geo_coarse->GetnPointDomain(); Point_Coarse++) { 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++) { Point_Fine = geo_coarse->node[Point_Coarse]->GetChildren_CV(iChildren); @@ -547,7 +622,7 @@ void CMultiGridIntegration::SetRestricted_Residual(CSolver *sol_fine, CSolver *s } sol_coarse->GetNodes()->AddRes_TruncError(Point_Coarse,Residual); } - + for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { if ((config->GetMarker_All_KindBC(iMarker) == HEAT_FLUX ) || (config->GetMarker_All_KindBC(iMarker) == ISOTHERMAL ) || @@ -558,31 +633,36 @@ void CMultiGridIntegration::SetRestricted_Residual(CSolver *sol_fine, CSolver *s } } } - + delete [] Residual; } -void CMultiGridIntegration::SetRestricted_Solution(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config) { +void CMultiGridIntegration::SetRestricted_Solution(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, + CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config) { + unsigned long iVertex, Point_Fine, Point_Coarse; unsigned short iMarker, iVar, iChildren, iDim; - su2double Area_Parent, Area_Children, *Solution_Fine, *Grid_Vel, Vector[3]; - + su2double Area_Parent, Area_Children, Vector[3] = {0.0}; + const su2double *Solution_Fine = nullptr, *Grid_Vel = nullptr; + const unsigned short SolContainer_Position = config->GetContainerPosition(RunTime_EqSystem); const unsigned short nVar = sol_coarse->GetnVar(); const unsigned short nDim = geo_fine->GetnDim(); - const bool grid_movement = config->GetGrid_Movement(); - + const bool grid_movement = config->GetGrid_Movement(); + su2double *Solution = new su2double[nVar]; - + /*--- Compute coarse solution from fine solution ---*/ - + + SU2_OMP_FOR_STAT(roundUpDiv(geo_coarse->GetnPointDomain(), omp_get_num_threads())) for (Point_Coarse = 0; Point_Coarse < geo_coarse->GetnPointDomain(); Point_Coarse++) { - Area_Parent = geo_coarse->node[Point_Coarse]->GetVolume(); + Area_Parent = geo_coarse->node[Point_Coarse]->GetVolume(); + for (iVar = 0; iVar < nVar; iVar++) Solution[iVar] = 0.0; - + 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->GetNodes()->GetSolution(Point_Fine); @@ -590,131 +670,143 @@ void CMultiGridIntegration::SetRestricted_Solution(unsigned short RunTime_EqSyst Solution[iVar] += Solution_Fine[iVar]*Area_Children/Area_Parent; } } - - sol_coarse->GetNodes()->SetSolution(Point_Coarse,Solution); - + + sol_coarse->GetNodes()->SetSolution(Point_Coarse, Solution); + } + delete [] Solution; + /*--- Update the solution at the no-slip walls ---*/ - + for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { - if ((config->GetMarker_All_KindBC(iMarker) == HEAT_FLUX ) || - (config->GetMarker_All_KindBC(iMarker) == ISOTHERMAL ) || - (config->GetMarker_All_KindBC(iMarker) == CHT_WALL_INTERFACE )) { - + if ((config->GetMarker_All_KindBC(iMarker) == HEAT_FLUX) || + (config->GetMarker_All_KindBC(iMarker) == ISOTHERMAL) || + (config->GetMarker_All_KindBC(iMarker) == CHT_WALL_INTERFACE)) { + + SU2_OMP_FOR_STAT(32) for (iVertex = 0; iVertex < geo_coarse->nVertex[iMarker]; iVertex++) { - Point_Coarse = geo_coarse->vertex[iMarker][iVertex]->GetNode(); + Point_Coarse = geo_coarse->vertex[iMarker][iVertex]->GetNode(); + if (SolContainer_Position == FLOW_SOL) { - + /*--- At moving walls, set the solution based on the new density and wall velocity ---*/ - + if (grid_movement) { Grid_Vel = geo_coarse->node[Point_Coarse]->GetGridVel(); for (iDim = 0; iDim < nDim; iDim++) Vector[iDim] = sol_coarse->GetNodes()->GetSolution(Point_Coarse,0)*Grid_Vel[iDim]; - sol_coarse->GetNodes()->SetVelSolutionVector(Point_Coarse,Vector); - } else { - + sol_coarse->GetNodes()->SetVelSolutionVector(Point_Coarse, Vector); + } + else { /*--- For stationary no-slip walls, set the velocity to zero. ---*/ - + sol_coarse->GetNodes()->SetVelSolutionZero(Point_Coarse); } - + } - + if (SolContainer_Position == ADJFLOW_SOL) { sol_coarse->GetNodes()->SetVelSolutionDVector(Point_Coarse); } - + } } } - + /*--- MPI the new interpolated solution ---*/ - - sol_coarse->InitiateComms(geo_coarse, config, SOLUTION); - sol_coarse->CompleteComms(geo_coarse, config, SOLUTION); - - delete [] Solution; - + + SU2_OMP_MASTER + { + sol_coarse->InitiateComms(geo_coarse, config, SOLUTION); + sol_coarse->CompleteComms(geo_coarse, config, SOLUTION); + } + SU2_OMP_BARRIER + } -void CMultiGridIntegration::SetRestricted_Gradient(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, - CGeometry *geo_coarse, CConfig *config) { +void CMultiGridIntegration::SetRestricted_Gradient(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, + CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config) { unsigned long Point_Fine, Point_Coarse; unsigned short iVar, iDim, iChildren; - su2double Area_Parent, Area_Children, **Gradient_fine; - + su2double Area_Parent, Area_Children; + const su2double* const* Gradient_fine = nullptr; + const unsigned short nDim = geo_coarse->GetnDim(); const unsigned short nVar = sol_coarse->GetnVar(); - + su2double **Gradient = new su2double* [nVar]; for (iVar = 0; iVar < nVar; iVar++) Gradient[iVar] = new su2double [nDim]; - + + SU2_OMP_FOR_STAT(roundUpDiv(geo_coarse->GetnPoint(), omp_get_num_threads())) for (Point_Coarse = 0; Point_Coarse < geo_coarse->GetnPoint(); Point_Coarse++) { Area_Parent = geo_coarse->node[Point_Coarse]->GetVolume(); - + for (iVar = 0; iVar < nVar; iVar++) for (iDim = 0; iDim < nDim; iDim++) Gradient[iVar][iDim] = 0.0; - + 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->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->GetNodes()->SetGradient(Point_Coarse,Gradient); } - + for (iVar = 0; iVar < nVar; iVar++) delete [] Gradient[iVar]; delete [] Gradient; - + } void CMultiGridIntegration::NonDimensional_Parameters(CGeometry **geometry, CSolver ***solver_container, CNumerics ****numerics_container, - CConfig *config, unsigned short FinestMesh, unsigned short RunTime_EqSystem, + CConfig *config, unsigned short FinestMesh, unsigned short RunTime_EqSystem, su2double *monitor) { - + SU2_OMP_MASTER switch (RunTime_EqSystem) { - + case RUNTIME_FLOW_SYS: - + /*--- Calculate the inviscid and viscous forces ---*/ - + solver_container[FinestMesh][FLOW_SOL]->Pressure_Forces(geometry[FinestMesh], config); solver_container[FinestMesh][FLOW_SOL]->Momentum_Forces(geometry[FinestMesh], config); solver_container[FinestMesh][FLOW_SOL]->Friction_Forces(geometry[FinestMesh], config); - + /*--- Evaluate the buffet metric if requested ---*/ - + if(config->GetBuffet_Monitoring() || config->GetKind_ObjFunc() == BUFFET_SENSOR){ solver_container[FinestMesh][FLOW_SOL]->Buffet_Monitoring(geometry[FinestMesh], config); } - + break; - + case RUNTIME_ADJFLOW_SYS: - + /*--- Calculate the inviscid and viscous sensitivities ---*/ - - solver_container[FinestMesh][ADJFLOW_SOL]->Inviscid_Sensitivity(geometry[FinestMesh], solver_container[FinestMesh], numerics_container[FinestMesh][ADJFLOW_SOL][CONV_BOUND_TERM], config); - solver_container[FinestMesh][ADJFLOW_SOL]->Viscous_Sensitivity(geometry[FinestMesh], solver_container[FinestMesh], numerics_container[FinestMesh][ADJFLOW_SOL][CONV_BOUND_TERM], config); - + + solver_container[FinestMesh][ADJFLOW_SOL]->Inviscid_Sensitivity(geometry[FinestMesh], solver_container[FinestMesh], + numerics_container[FinestMesh][ADJFLOW_SOL][CONV_BOUND_TERM], config); + + solver_container[FinestMesh][ADJFLOW_SOL]->Viscous_Sensitivity(geometry[FinestMesh], solver_container[FinestMesh], + numerics_container[FinestMesh][ADJFLOW_SOL][CONV_BOUND_TERM], config); + /*--- Smooth the inviscid and viscous sensitivities ---*/ - - if (config->GetKind_SensSmooth() != NONE) solver_container[FinestMesh][ADJFLOW_SOL]->Smooth_Sensitivity(geometry[FinestMesh], solver_container[FinestMesh], numerics_container[FinestMesh][ADJFLOW_SOL][CONV_BOUND_TERM], config); - + + if (config->GetKind_SensSmooth() != NONE) + solver_container[FinestMesh][ADJFLOW_SOL]->Smooth_Sensitivity(geometry[FinestMesh], solver_container[FinestMesh], + numerics_container[FinestMesh][ADJFLOW_SOL][CONV_BOUND_TERM], config); break; - } - + SU2_OMP_BARRIER + } CSingleGridIntegration::CSingleGridIntegration(CConfig *config) : CIntegration(config) { } @@ -724,43 +816,43 @@ CSingleGridIntegration::~CSingleGridIntegration(void) { } void CSingleGridIntegration::SingleGrid_Iteration(CGeometry ****geometry, CSolver *****solver_container, CNumerics ******numerics_container, CConfig **config, unsigned short RunTime_EqSystem, unsigned short iZone, unsigned short iInst) { unsigned short iMesh; - + unsigned short SolContainer_Position = config[iZone]->GetContainerPosition(RunTime_EqSystem); unsigned short FinestMesh = config[iZone]->GetFinestMesh(); /*--- Preprocessing ---*/ - + solver_container[iZone][iInst][FinestMesh][SolContainer_Position]->Preprocessing(geometry[iZone][iInst][FinestMesh], solver_container[iZone][iInst][FinestMesh], config[iZone], FinestMesh, 0, RunTime_EqSystem, false); - + /*--- Set the old solution ---*/ - + solver_container[iZone][iInst][FinestMesh][SolContainer_Position]->Set_OldSolution(geometry[iZone][iInst][FinestMesh]); - + /*--- Time step evaluation ---*/ - + solver_container[iZone][iInst][FinestMesh][SolContainer_Position]->SetTime_Step(geometry[iZone][iInst][FinestMesh], solver_container[iZone][iInst][FinestMesh], config[iZone], FinestMesh, config[iZone]->GetTimeIter()); - + /*--- Space integration ---*/ - + Space_Integration(geometry[iZone][iInst][FinestMesh], solver_container[iZone][iInst][FinestMesh], numerics_container[iZone][iInst][FinestMesh][SolContainer_Position], config[iZone], FinestMesh, NO_RK_ITER, RunTime_EqSystem); - + /*--- Time integration ---*/ - + Time_Integration(geometry[iZone][iInst][FinestMesh], solver_container[iZone][iInst][FinestMesh], config[iZone], NO_RK_ITER, RunTime_EqSystem); - + /*--- Postprocessing ---*/ - + solver_container[iZone][iInst][FinestMesh][SolContainer_Position]->Postprocessing(geometry[iZone][iInst][FinestMesh], solver_container[iZone][iInst][FinestMesh], config[iZone], FinestMesh); - + if (RunTime_EqSystem == RUNTIME_HEAT_SYS) { solver_container[iZone][iInst][FinestMesh][HEAT_SOL]->Heat_Fluxes(geometry[iZone][iInst][FinestMesh], solver_container[iZone][iInst][FinestMesh], config[iZone]); } - + /*--- If turbulence model, copy the turbulence variables to the coarse levels ---*/ - + if (RunTime_EqSystem == RUNTIME_TURB_SYS) { for (iMesh = FinestMesh; iMesh < config[iZone]->GetnMGLevels(); iMesh++) { SetRestricted_Solution(RunTime_EqSystem, solver_container[iZone][iInst][iMesh][SolContainer_Position], solver_container[iZone][iInst][iMesh+1][SolContainer_Position], geometry[iZone][iInst][iMesh], geometry[iZone][iInst][iMesh+1], config[iZone]); @@ -773,68 +865,68 @@ void CSingleGridIntegration::SetRestricted_Solution(unsigned short RunTime_EqSys unsigned long Point_Fine, Point_Coarse; unsigned short iVar, iChildren; su2double Area_Parent, Area_Children, *Solution_Fine, *Solution; - + unsigned short nVar = sol_coarse->GetnVar(); - + Solution = new su2double[nVar]; - + /*--- Compute coarse solution from fine solution ---*/ - + for (Point_Coarse = 0; Point_Coarse < geo_coarse->GetnPointDomain(); Point_Coarse++) { Area_Parent = geo_coarse->node[Point_Coarse]->GetVolume(); - + for (iVar = 0; iVar < nVar; iVar++) Solution[iVar] = 0.0; - + 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->GetNodes()->GetSolution(Point_Fine); for (iVar = 0; iVar < nVar; iVar++) Solution[iVar] += Solution_Fine[iVar]*Area_Children/Area_Parent; } - + sol_coarse->GetNodes()->SetSolution(Point_Coarse,Solution); - + } - + /*--- MPI the new interpolated solution ---*/ - + sol_coarse->InitiateComms(geo_coarse, config, SOLUTION); sol_coarse->CompleteComms(geo_coarse, config, SOLUTION); - + delete [] Solution; - + } void CSingleGridIntegration::SetRestricted_EddyVisc(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config) { - + unsigned long iVertex, Point_Fine, Point_Coarse; unsigned short iMarker, iChildren; su2double Area_Parent, Area_Children, EddyVisc_Fine, EddyVisc; - + /*--- Compute coarse Eddy Viscosity from fine solution ---*/ - + for (Point_Coarse = 0; Point_Coarse < geo_coarse->GetnPointDomain(); Point_Coarse++) { Area_Parent = geo_coarse->node[Point_Coarse]->GetVolume(); - + EddyVisc = 0.0; - + 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->GetNodes()->GetmuT(Point_Fine); EddyVisc += EddyVisc_Fine*Area_Children/Area_Parent; } - + sol_coarse->GetNodes()->SetmuT(Point_Coarse,EddyVisc); - + } - + /*--- Update solution at the no slip wall boundary, only the first variable (nu_tilde -in SA and SA_NEG- and k -in SST-), to guarantee that the eddy viscoisty is zero on the surface ---*/ - + for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { if ((config->GetMarker_All_KindBC(iMarker) == HEAT_FLUX ) || (config->GetMarker_All_KindBC(iMarker) == ISOTHERMAL ) || @@ -847,10 +939,10 @@ void CSingleGridIntegration::SetRestricted_EddyVisc(unsigned short RunTime_EqSys } /*--- MPI the new interpolated solution (this also includes the eddy viscosity) ---*/ - + sol_coarse->InitiateComms(geo_coarse, config, SOLUTION_EDDY); sol_coarse->CompleteComms(geo_coarse, config, SOLUTION_EDDY); - + } diff --git a/SU2_CFD/src/variables/CVariable.cpp b/SU2_CFD/src/variables/CVariable.cpp index 441b222e4938..66e093b1143c 100644 --- a/SU2_CFD/src/variables/CVariable.cpp +++ b/SU2_CFD/src/variables/CVariable.cpp @@ -110,8 +110,6 @@ void CVariable::Restore_BGSSolution_k() { parallelCopy(Solution_BGS_k.size(), Solution_BGS_k.data(), Solution.data()); } -void CVariable::SetResidualSumZero() { parallelSet(Residual_Sum.size(), 0.0, Residual_Sum.data()); } - void CVariable::SetUnd_LaplZero() { parallelSet(Undivided_Laplacian.size(), 0.0, Undivided_Laplacian.data()); } void CVariable::SetExternalZero() { parallelSet(External.size(), 0.0, External.data()); } From c06342a8981e55719aeec07466158786f747f98f Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Sat, 8 Feb 2020 14:38:11 +0000 Subject: [PATCH 102/118] split CIntegration files --- SU2_CFD/include/SU2_CFD.hpp | 1 - SU2_CFD/include/drivers/CDriver.hpp | 2 +- .../integration/CFEM_DG_Integration.hpp | 82 ++ SU2_CFD/include/integration/CIntegration.hpp | 384 ++++++++++ .../integration/CMultiGridIntegration.hpp | 191 +++++ .../integration/CSingleGridIntegration.hpp | 80 ++ .../integration/CStructuralIntegration.hpp | 53 ++ SU2_CFD/include/integration_structure.hpp | 709 ------------------ SU2_CFD/include/integration_structure.inl | 83 -- SU2_CFD/include/iteration_structure.hpp | 2 +- SU2_CFD/obj/Makefile.am | 7 +- SU2_CFD/src/drivers/CDriver.cpp | 5 + .../src/integration/CFEM_DG_Integration.cpp | 184 +++++ .../CIntegration.cpp} | 8 +- .../CMultiGridIntegration.cpp} | 417 ++-------- .../integration/CSingleGridIntegration.cpp | 164 ++++ .../integration/CStructuralIntegration.cpp | 60 ++ SU2_CFD/src/meson.build | 10 +- 18 files changed, 1266 insertions(+), 1176 deletions(-) create mode 100644 SU2_CFD/include/integration/CFEM_DG_Integration.hpp create mode 100644 SU2_CFD/include/integration/CIntegration.hpp create mode 100644 SU2_CFD/include/integration/CMultiGridIntegration.hpp create mode 100644 SU2_CFD/include/integration/CSingleGridIntegration.hpp create mode 100644 SU2_CFD/include/integration/CStructuralIntegration.hpp delete mode 100644 SU2_CFD/include/integration_structure.hpp delete mode 100644 SU2_CFD/include/integration_structure.inl create mode 100644 SU2_CFD/src/integration/CFEM_DG_Integration.cpp rename SU2_CFD/src/{integration_structure.cpp => integration/CIntegration.cpp} (99%) rename SU2_CFD/src/{integration_time.cpp => integration/CMultiGridIntegration.cpp} (66%) create mode 100644 SU2_CFD/src/integration/CSingleGridIntegration.cpp create mode 100644 SU2_CFD/src/integration/CStructuralIntegration.cpp diff --git a/SU2_CFD/include/SU2_CFD.hpp b/SU2_CFD/include/SU2_CFD.hpp index 525fb4a43e44..eb8be4d1c97c 100644 --- a/SU2_CFD/include/SU2_CFD.hpp +++ b/SU2_CFD/include/SU2_CFD.hpp @@ -39,7 +39,6 @@ #include "drivers/CDiscAdjSinglezoneDriver.hpp" #include "drivers/CDiscAdjMultizoneDriver.hpp" #include "drivers/CDummyDriver.hpp" -#include "integration_structure.hpp" #include "output/COutput.hpp" #include "../../Common/include/fem_geometry_structure.hpp" #include "../../Common/include/geometry/CGeometry.hpp" diff --git a/SU2_CFD/include/drivers/CDriver.hpp b/SU2_CFD/include/drivers/CDriver.hpp index 731cd7d8eb68..aa92cacdebf7 100644 --- a/SU2_CFD/include/drivers/CDriver.hpp +++ b/SU2_CFD/include/drivers/CDriver.hpp @@ -31,7 +31,7 @@ #include "../../../Common/include/mpi_structure.hpp" #include "../iteration_structure.hpp" -#include "../integration_structure.hpp" +#include "../integration/CIntegration.hpp" #include "../solvers/CSolver.hpp" #include "../interfaces/CInterface.hpp" diff --git a/SU2_CFD/include/integration/CFEM_DG_Integration.hpp b/SU2_CFD/include/integration/CFEM_DG_Integration.hpp new file mode 100644 index 000000000000..1194e68bcf66 --- /dev/null +++ b/SU2_CFD/include/integration/CFEM_DG_Integration.hpp @@ -0,0 +1,82 @@ +/*! + * \file CFEM_DG_Integration.hpp + * \brief Declaration of class for integration with the FEM DG solver. + * \author E. van der Weide, T. Economon + * \version 7.0.1 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "CIntegration.hpp" + +/*! + * \class CFEM_DG_Integration + * \brief Class for integration with the FEM DG solver. + * \author E. van der Weide, T. Economon + * \version 7.0.1 "Blackbird" + */ +class CFEM_DG_Integration final : public CIntegration { +public: + /*! + * \brief Constructor of the class. + * \param[in] config - Definition of the particular problem. + */ + CFEM_DG_Integration(CConfig *config); + + /*! + * \brief Do the numerical integration (implicit) of the turbulence solver. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] solver_container - Container vector with all the solutions. + * \param[in] numerics_container - Description of the numerical method (the way in which the equations are solved). + * \param[in] config - Definition of the particular problem. + * \param[in] RunTime_EqSystem - System of equations which is going to be solved. + */ + void SingleGrid_Iteration(CGeometry ****geometry, CSolver *****solver_container, + CNumerics ******numerics_container, CConfig **config, + unsigned short RunTime_EqSystem, unsigned short iZone, unsigned short iInst) override; + + /*! + * \brief Perform the spatial integration of the numerical system. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] solver_container - Container vector with all the solutions. + * \param[in] solver - 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] iStep - Current step of the Runge-Kutta iteration for the RK schemes + and the step in the local time stepping for ADER-DG. + * \param[in] RunTime_EqSystem - System of equations which is going to be solved. + */ + void Space_Integration(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics, CConfig *config, + unsigned short iMesh, unsigned short iStep, unsigned short RunTime_EqSystem); + + /*! + * \brief Perform the time integration (explicit or implicit) of the numerical system. + * \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] iStep - Current step of the Runge-Kutta iteration for the RK schemes + and the step in the local time stepping for ADER-DG. + * \param[in] RunTime_EqSystem - System of equations which is going to be solved. + * \param[in] Iteration - Current iteration. + */ + void Time_Integration(CGeometry *geometry, CSolver **solver_container, CConfig *config, + unsigned short iStep, unsigned short RunTime_EqSystem); +}; diff --git a/SU2_CFD/include/integration/CIntegration.hpp b/SU2_CFD/include/integration/CIntegration.hpp new file mode 100644 index 000000000000..47ce1de5183d --- /dev/null +++ b/SU2_CFD/include/integration/CIntegration.hpp @@ -0,0 +1,384 @@ +/*! + * \file CIntegration.hpp + * \brief Declaration of the main routines to orchestrate space and time integration. + * \author F. Palacios, T. Economon + * \version 7.0.1 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include +#include +#include + +#include "../solvers/CSolver.hpp" +#include "../../../Common/include/geometry/CGeometry.hpp" +#include "../../../Common/include/CConfig.hpp" + +using namespace std; + +/*! + * \class CIntegration + * \brief Main class for doing the space integration, time integration, and monitoring + * of a system of Partial Differential Equations (PDE). + * \author F. Palacios + */ +class CIntegration { +protected: + int rank, /*!< \brief MPI Rank. */ + size; /*!< \brief MPI Size. */ + su2double + Cauchy_Value, /*!< \brief Summed value of the convergence indicator. */ + Cauchy_Func; /*!< \brief Current value of the convergence indicator at one iteration. */ + unsigned short Cauchy_Counter; /*!< \brief Number of elements of the Cauchy serial. */ + su2double *Cauchy_Serie; /*!< \brief Complete Cauchy serial. */ + su2double + Old_Func, /*!< \brief Old value of the objective function (the function which is monitored). */ + New_Func; /*!< \brief Current value of the objective function (the function which is monitored). */ + bool Convergence, /*!< \brief To indicate if the flow solver (direct, adjoint, or linearized) has converged or not. */ + Convergence_FSI, /*!< \brief To indicate if the FSI problem has converged or not. */ + Convergence_FullMG; /*!< \brief To indicate if the Full Multigrid has converged and it is necessary to add a new level. */ + su2double InitResidual; /*!< \brief Initial value of the residual to evaluate the convergence level. */ + +public: + + /*! + * \brief Constructor of the class. + */ + CIntegration(CConfig *config); + + /*! + * \brief Destructor of the class. + */ + virtual ~CIntegration(void); + + /*! + * \brief Do the space integration of the numerical system. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] solver_container - Container vector with all the solutions. + * \param[in] solver - 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. + * \param[in] RunTime_EqSystem - System of equations which is going to be solved. + */ + void Space_Integration(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics, CConfig *config, + unsigned short iMesh, unsigned short iRKStep, unsigned short RunTime_EqSystem); + + /*! + * \brief Do the space integration of the numerical system on a FEM framework. + * \author R. Sanchez + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] solver_container - Container vector with all the solutions. + * \param[in] solver - Description of the numerical method. + * \param[in] config - Definition of the particular problem. + * \param[in] RunTime_EqSystem - System of equations which is going to be solved. + */ + void Space_Integration_FEM(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics, CConfig *config, + unsigned short RunTime_EqSystem); + + /*! + * \brief Do the time integration (explicit or implicit) of the numerical system. + * \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. + */ + void Time_Integration(CGeometry *geometry, CSolver **solver_container, CConfig *config, + unsigned short iRKStep, unsigned short RunTime_EqSystem); + + /*! + * \brief Do the time integration (explicit or implicit) of the numerical system on a FEM framework. + * \author R. Sanchez + * \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] RunTime_EqSystem - System of equations which is going to be solved. + * \param[in] Iteration - Current iteration. + */ + void Time_Integration_FEM(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics, CConfig *config, + unsigned short RunTime_EqSystem); + + /*! + * \brief Initialize the adjoint solution using the primal problem. + * \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] RunTime_EqSystem - System of equations which is going to be solved. + * \param[in] Iteration - Current iteration. + */ + void Adjoint_Setup(CGeometry ****geometry, CSolver *****solver_container, CConfig **config, + unsigned short RunTime_EqSystem, unsigned long Iteration, unsigned short iZone); + + /*! + * \brief Average the scalar output in case there is a unsteady solution. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] config - Definition of the particular problem. + * \param[in] Iteration - Current iteration. + * \param[in] monitor - Objective function to be averaged. + * \param[in] iMesh - Index of the mesh. + */ + void Average_Monitoring(CGeometry *geometry, CConfig *config, + unsigned long Iteration, su2double monitor, unsigned short iMesh); + + /*! + * \brief Get the value of the convergence. + * \return Level of convergence of the solution. + */ + inline su2double GetCauchy_Value(void) const { return Cauchy_Value; } + + /*! + * \brief Get the indicator of the convergence for the direct, adjoint and linearized problem. + * \return TRUE means that the convergence criteria is satisfied; + * otherwise FALSE. + */ + inline bool GetConvergence(void) const { return Convergence; } + + /*! + * \brief Get the indicator of the convergence for the Fluid-Structure Interaction problem. + * \return TRUE means that the convergence criteria is satisfied; + * otherwise FALSE. + */ + inline bool GetConvergence_FSI(void) const { return Convergence_FSI; } + + /*! + * \brief Set the indicator of the convergence. + * \param[in] value - TRUE means that the convergence criteria is satisfied; + * otherwise FALSE. + */ + inline void SetConvergence(bool value) { Convergence = value; } + + + /*! + * \brief Set the indicator of the convergence for FSI. + * \param[in] valueFSI - TRUE means that the convergence criteria for FSI is satisfied; + * otherwise FALSE. + */ + inline void SetConvergence_FSI(bool valueFSI) { Convergence_FSI = valueFSI; } + + + /*! + * \brief Get the indicator of the convergence for the full multigrid problem. + * \return TRUE means that the convergence criteria is satisfied; + * otherwise FALSE. + */ + inline bool GetConvergence_FullMG(void) const { return Convergence_FullMG; } + + /*! + * \brief Save the solution, and volume at different time steps. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] solution - Flow solution. + * \param[in] config - Definition of the particular problem. + */ + void SetDualTime_Solver(CGeometry *geometry, CSolver *solver, CConfig *config, unsigned short iMesh); + + /*! + * \brief Save the structural solution at different time steps. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] solution - Structural solution. + * \param[in] config - Definition of the particular problem. + */ + void SetStructural_Solver(CGeometry *geometry, CSolver *solver, CConfig *config, unsigned short iMesh); + + /*! + * \brief Save the structural solution at different time steps. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] solver_container - Structural solution. + * \param[in] config - Definition of the particular problem. + */ + void SetFEM_StructuralSolver(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh); + + /*! + * \brief A virtual member. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] solver_container - Container vector with all the solutions. + * \param[in] numerics_container - Description of the numerical method (the way in which the equations are solved). + * \param[in] config - Definition of the particular problem. + * \param[in] RunTime_EqSystem - System of equations which is going to be solved. + */ + virtual void MultiGrid_Iteration(CGeometry ****geometry, CSolver *****solver_container, + CNumerics ******numerics_container, CConfig **config, + unsigned short RunTime_EqSystem, unsigned short iZone, unsigned short iInst) { }; + + /*! + * \brief A virtual member. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] solver_container - Container vector with all the solutions. + * \param[in] numerics_container - Description of the numerical method (the way in which the equations are solved). + * \param[in] config - Definition of the particular problem. + * \param[in] iMesh - Index of the mesh in multigrid computations. + * \param[in] mu - Variable for controlling the kind of multigrid algorithm. + * \param[in] RunTime_EqSystem - System of equations which is going to be solved. + */ + virtual void MultiGrid_Cycle(CGeometry ****geometry, CSolver *****solver_container, CNumerics ******numerics_container, + CConfig **config, unsigned short iMesh, unsigned short mu, unsigned short RunTime_EqSystem, + unsigned short iZone, unsigned short iInst) { }; + + /*! + * \brief A virtual member. + * \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] RunTime_EqSystem - System of equations which is going to be solved. + * \param[in] monitor - value of the non-dimensional parameters for monitoring the convergence. + */ + virtual void NonDimensional_Parameters(CGeometry **geometry, CSolver ***solver_container, CNumerics ****numerics_container, + CConfig *config, unsigned short FinestMesh, unsigned short RunTime_EqSystem, + su2double *monitor) { }; + + /*! + * \brief A virtual member. + * \param[out] sol_fine - Pointer to the solution on the fine grid. + * \param[in] geo_fine - Geometrical definition of the fine grid. + * \param[in] config - Definition of the particular problem. + */ + virtual void SetProlongated_Correction(CSolver *sol_fine, CGeometry *geo_fine, CConfig *config, unsigned short iMesh) { } + + /*! + * \brief A virtual member. + * \param[in] RunTime_EqSystem - System of equations which is going to be solved. + * \param[out] sol_fine - Pointer to the solution on the fine grid. + * \param[in] sol_coarse - Pointer to the solution on the coarse grid. + * \param[in] geo_fine - Geometrical definition of the fine grid. + * \param[in] geo_coarse - Geometrical definition of the coarse grid. + * \param[in] config - Definition of the particular problem. + */ + virtual void SetProlongated_Solution(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, + CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config) { }; + + /*! + * \brief A virtual member. + * \param[in] sol_fine - Pointer to the solution on the fine grid. + * \param[out] sol_coarse - Pointer to the solution on the coarse grid. + * \param[in] geo_fine - Geometrical definition of the fine grid. + * \param[in] geo_coarse - Geometrical definition of the coarse grid. + * \param[in] config - Definition of the particular problem. + */ + virtual void SetRestricted_Residual(CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, + CGeometry *geo_coarse, CConfig *config) { }; + + /*! + * \brief A virtual member. + * \param[in] RunTime_EqSystem - System of equations which is going to be solved. + * \param[in] sol_fine - Pointer to the solution on the fine grid. + * \param[out] sol_coarse - Pointer to the solution on the coarse grid. + * \param[in] geo_fine - Geometrical definition of the fine grid. + * \param[in] geo_coarse - Geometrical definition of the coarse grid. + * \param[in] config - Definition of the particular problem. + * \param[in] iMesh - Index of the mesh in multigrid computations. + * \param[in] InclSharedDomain - Include the shared domain in the interpolation. + */ + virtual void SetRestricted_Solution(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config) { } + + /*! + * \brief A virtual member. + * \param[in] RunTime_EqSystem - System of equations which is going to be solved. + * \param[in] sol_fine - Pointer to the solution on the fine grid. + * \param[out] sol_coarse - Pointer to the solution on the coarse grid. + * \param[in] geo_fine - Geometrical definition of the fine grid. + * \param[in] geo_coarse - Geometrical definition of the coarse grid. + * \param[in] config - Definition of the particular problem. + * \param[in] iMesh - Index of the mesh in multigrid computations. + * \param[in] InclSharedDomain - Include the shared domain in the interpolation. + */ + virtual void SetRestricted_EddyVisc(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config) { } + + /*! + * \brief A virtual member. + * \param[in] RunTime_EqSystem - System of equations which is going to be solved. + * \param[in] sol_fine - Pointer to the solution on the fine grid. + * \param[out] sol_coarse - Pointer to the solution on the coarse grid. + * \param[in] geo_fine - Geometrical definition of the fine grid. + * \param[in] geo_coarse - Geometrical definition of the coarse grid. + * \param[in] config - Definition of the particular problem. + */ + virtual void SetRestricted_Gradient(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, + CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config) { }; + + /*! + * \brief A virtual member. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] flow - Flow solution. + */ + virtual void SetResidual_Term(CGeometry *geometry, CSolver *flow) { } + + /*! + * \brief A virtual member. + * \param[in] sol_fine - Pointer to the solution on the fine grid. + * \param[in] sol_coarse - Pointer to the solution on the coarse grid. + * \param[in] geo_fine - Geometrical definition of the fine grid. + * \param[in] geo_coarse - Geometrical definition of the coarse grid. + * \param[in] config - Definition of the particular problem. + */ + virtual void SetForcing_Term(CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, CGeometry *geo_coarse, + CConfig *config, unsigned short iMesh) { }; + + /*! + * \brief A virtual member. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] solver_container - Container vector with all the solutions. + * \param[in] numerics_container - Description of the numerical method (the way in which the equations are solved). + * \param[in] config - Definition of the particular problem. + * \param[in] RunTime_EqSystem - System of equations which is going to be solved. + */ + virtual void SingleGrid_Iteration(CGeometry ****geometry, CSolver *****solver_container, CNumerics ******numerics_container, + CConfig **config, unsigned short RunTime_EqSystem, unsigned short iZone, unsigned short iInst) { }; + + /*! + * \brief A virtual member. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] solver_container - Container vector with all the solutions. + * \param[in] numerics_container - Description of the numerical method (the way in which the equations are solved). + * \param[in] config - Definition of the particular problem. + * \param[in] RunTime_EqSystem - System of equations which is going to be solved. + */ + virtual void Structural_Iteration(CGeometry ****geometry, CSolver *****solver_container, CNumerics ******numerics_container, + CConfig **config, unsigned short RunTime_EqSystem, unsigned short iZone, unsigned short iInst) { }; + + /*! + * \brief A virtual member. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] solver_container - Container vector with all the solutions. + * \param[in] numerics_container - Description of the numerical method (the way in which the equations are solved). + * \param[in] config - Definition of the particular problem. + * \param[in] RunTime_EqSystem - System of equations which is going to be solved. + * \param[in] iMesh - Index of the mesh in multigrid computations. + */ + virtual void SetPotential_Solver(CGeometry ****geometry, CSolver *****solver_container, CNumerics ******numerics_container, + CConfig **config, unsigned short RunTime_EqSystem, unsigned short iMesh, unsigned short iZone) { }; + + /*! + * \brief A virtual member. + * \param[in] RunTime_EqSystem - System of equations which is going to be solved. + * \param[in] solution - Container vector with all the solutions on the finest grid. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] val_nSmooth - Number of smoothing iterations. + * \param[in] val_smooth_coeff - Relaxation factor. + * \param[in] config - Definition of the particular problem. + */ + virtual void Smooth_Solution(unsigned short RunTime_EqSystem, CSolver *solver, CGeometry *geometry, + unsigned short val_nSmooth, su2double val_smooth_coeff, CConfig *config) { }; + +}; + diff --git a/SU2_CFD/include/integration/CMultiGridIntegration.hpp b/SU2_CFD/include/integration/CMultiGridIntegration.hpp new file mode 100644 index 000000000000..0d8450b0288f --- /dev/null +++ b/SU2_CFD/include/integration/CMultiGridIntegration.hpp @@ -0,0 +1,191 @@ +/*! + * \file CMultiGridIntegration.hpp + * \brief Declaration of class for time integration using a multigrid method. + * \author F. Palacios, T. Economon + * \version 7.0.1 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "CIntegration.hpp" + +/*! + * \class CMultiGridIntegration + * \brief Class for time integration using a multigrid method. + * \author F. Palacios + */ +class CMultiGridIntegration final : public CIntegration { +public: + /*! + * \brief Constructor of the class. + * \param[in] config - Definition of the particular problem. + */ + CMultiGridIntegration(CConfig *config); + + /*! + * \brief This subroutine calls the MultiGrid_Cycle and also prepare the multigrid levels and the monitoring. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] solver_container - Container vector with all the solutions. + * \param[in] numerics_container - Description of the numerical method (the way in which the equations are solved). + * \param[in] config - Definition of the particular problem. + * \param[in] RunTime_EqSystem - System of equations which is going to be solved. + * \param[in] Iteration - Current iteration. + */ + void MultiGrid_Iteration(CGeometry ****geometry, CSolver *****solver_container, CNumerics ******numerics_container, + CConfig **config, unsigned short RunTime_EqSystem, unsigned short iZone, unsigned short iInst); + + /*! + * \brief Perform a Full-Approximation Storage (FAS) Multigrid. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] solver_container - Container vector with all the solutions. + * \param[in] numerics_container - Description of the numerical method (the way in which the equations are solved). + * \param[in] config - Definition of the particular problem. + * \param[in] iMesh - Index of the mesh in multigrid computations. + * \param[in] mu - Variable for controlling the kind of multigrid algorithm. + * \param[in] RunTime_EqSystem - System of equations which is going to be solved. + * \param[in] Iteration - Current iteration. + */ + void MultiGrid_Cycle(CGeometry ****geometry, CSolver *****solver_container, CNumerics ******numerics_container, + CConfig **config, unsigned short iMesh, unsigned short mu, unsigned short RunTime_EqSystem, unsigned short iZone, unsigned short iInst); + + /*! + * \brief Compute the non-dimensional parameters. + * \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] RunTime_EqSystem - System of equations which is going to be solved. + * \param[in] Iteration - Current iteration. + * \param[in] monitor - value of the non-dimensional parameters for monitoring the convergence. + */ + void NonDimensional_Parameters(CGeometry **geometry, CSolver ***solver_container, CNumerics ****numerics_container, + CConfig *config, unsigned short FinestMesh, unsigned short RunTime_EqSystem, + su2double *monitor); + + /*! + * \brief Compute the fine solution from a coarse solution. + * \param[in] RunTime_EqSystem - System of equations which is going to be solved. + * \param[out] sol_fine - Pointer to the solution on the fine grid. + * \param[in] sol_coarse - Pointer to the solution on the coarse grid. + * \param[in] geo_fine - Geometrical definition of the fine grid. + * \param[in] geo_coarse - Geometrical definition of the coarse grid. + * \param[in] config - Definition of the particular problem. + */ + void SetProlongated_Solution(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, + CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config); + + /*! + * \brief Compute the fine grid correction from the coarse solution. + * \param[out] sol_fine - Pointer to the solution on the fine grid. + * \param[in] sol_coarse - Pointer to the solution on the coarse grid. + * \param[in] geo_fine - Geometrical definition of the fine grid. + * \param[in] geo_coarse - Geometrical definition of the coarse grid. + * \param[in] config - Definition of the particular problem. + */ + void GetProlongated_Correction(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, + CGeometry *geo_coarse, CConfig *config); + + /*! + * \brief Do an implicit smoothing of the prolongated correction. + * \param[in] RunTime_EqSystem - System of equations which is going to be solved. + * \param[in] solution - Container vector with all the solutions on the finest grid. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] val_nSmooth - Number of smoothing iterations. + * \param[in] val_smooth_coeff - Relaxation factor. + * \param[in] config - Definition of the particular problem. + */ + void SmoothProlongated_Correction(unsigned short RunTime_EqSystem, CSolver *solver, CGeometry *geometry, + unsigned short val_nSmooth, su2double val_smooth_coeff, CConfig *config); + + /*! + * \brief Do an implicit smoothing of the solution. + * \param[in] RunTime_EqSystem - System of equations which is going to be solved. + * \param[in] solution - Container vector with all the solutions on the finest grid. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] val_nSmooth - Number of smoothing iterations. + * \param[in] val_smooth_coeff - Relaxation factor. + * \param[in] config - Definition of the particular problem. + */ + void Smooth_Solution(unsigned short RunTime_EqSystem, CSolver *solver, CGeometry *geometry, + unsigned short val_nSmooth, su2double val_smooth_coeff, CConfig *config); + + /*! + * \brief Set the value of the corrected fine grid solution. + * \param[out] sol_fine - Pointer to the solution on the fine grid. + * \param[in] geo_fine - Geometrical definition of the fine grid. + * \param[in] config - Definition of the particular problem. + */ + void SetProlongated_Correction(CSolver *sol_fine, CGeometry *geo_fine, CConfig *config, unsigned short iMesh); + + /*! + * \brief Compute truncation error in the coarse grid using the fine grid information. + * \param[in] sol_fine - Pointer to the solution on the fine grid. + * \param[out] sol_coarse - Pointer to the solution on the coarse grid. + * \param[in] geo_fine - Geometrical definition of the fine grid. + * \param[in] geo_coarse - Geometrical definition of the coarse grid. + * \param[in] config - Definition of the particular problem. + */ + void SetRestricted_Residual(CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, + CGeometry *geo_coarse, CConfig *config); + + /*! + * \brief Restrict solution from fine grid to a coarse grid. + * \param[in] RunTime_EqSystem - System of equations which is going to be solved. + * \param[in] sol_fine - Pointer to the solution on the fine grid. + * \param[out] sol_coarse - Pointer to the solution on the coarse grid. + * \param[in] geo_fine - Geometrical definition of the fine grid. + * \param[in] geo_coarse - Geometrical definition of the coarse grid. + * \param[in] config - Definition of the particular problem. + * \param[in] iMesh - Index of the mesh in multigrid computations. + * \param[in] InclSharedDomain - Include the shared domain in the interpolation. + */ + void SetRestricted_Solution(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config); + + /*! + * \brief Compute the gradient in coarse grid using the fine grid information. + * \param[in] RunTime_EqSystem - System of equations which is going to be solved. + * \param[in] sol_fine - Pointer to the solution on the fine grid. + * \param[out] sol_coarse - Pointer to the solution on the coarse grid. + * \param[in] geo_fine - Geometrical definition of the fine grid. + * \param[in] geo_coarse - Geometrical definition of the coarse grid. + * \param[in] config - Definition of the particular problem. + */ + void SetRestricted_Gradient(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, + CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config); + + /*! + * \brief Add the truncation error to the residual. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] flow - Flow solution. + */ + void SetResidual_Term(CGeometry *geometry, CSolver *flow); + + /*! + * \brief Compute the forcing term. + * \param[in] sol_fine - Pointer to the solution on the fine grid. + * \param[in] sol_coarse - Pointer to the solution on the coarse grid. + * \param[in] geo_fine - Geometrical definition of the fine grid. + * \param[in] geo_coarse - Geometrical definition of the coarse grid. + * \param[in] config - Definition of the particular problem. + */ + void SetForcing_Term(CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, CGeometry *geo_coarse, + CConfig *config, unsigned short iMesh); +}; + diff --git a/SU2_CFD/include/integration/CSingleGridIntegration.hpp b/SU2_CFD/include/integration/CSingleGridIntegration.hpp new file mode 100644 index 000000000000..586b5fc64c5e --- /dev/null +++ b/SU2_CFD/include/integration/CSingleGridIntegration.hpp @@ -0,0 +1,80 @@ +/*! + * \file CSingleGridIntegration.hpp + * \brief Declaration of class for numerical integration of fine grid-only problems. + * \author A. Bueno. + * \version 7.0.1 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "CIntegration.hpp" + +/*! + * \class CSingleGridIntegration + * \brief Class for numerical integration of fine grid-only problems (e.g. turbulence). + * \author A. Bueno. + */ +class CSingleGridIntegration final : public CIntegration { +public: + /*! + * \brief Constructor of the class. + * \param[in] config - Definition of the particular problem. + */ + CSingleGridIntegration(CConfig *config); + + /*! + * \brief Do the numerical integration (implicit) of the turbulence solver. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] solver_container - Container vector with all the solutions. + * \param[in] numerics_container - Description of the numerical method (the way in which the equations are solved). + * \param[in] config - Definition of the particular problem. + * \param[in] RunTime_EqSystem - System of equations which is going to be solved. + */ + void SingleGrid_Iteration(CGeometry ****geometry, CSolver *****solver_container, CNumerics ******numerics_container, + CConfig **config, unsigned short RunTime_EqSystem, unsigned short iZone, unsigned short iInst); + + /*! + * \brief Restrict solution from fine grid to a coarse grid. + * \param[in] RunTime_EqSystem - System of equations which is going to be solved. + * \param[in] sol_fine - Pointer to the solution on the fine grid. + * \param[out] sol_coarse - Pointer to the solution on the coarse grid. + * \param[in] geo_fine - Geometrical definition of the fine grid. + * \param[in] geo_coarse - Geometrical definition of the coarse grid. + * \param[in] config - Definition of the particular problem. + * \param[in] iMesh - Index of the mesh in multigrid computations. + * \param[in] InclSharedDomain - Include the shared domain in the interpolation. + */ + void SetRestricted_Solution(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config); + + /*! + * \brief Restrict solution from fine grid to a coarse grid. + * \param[in] RunTime_EqSystem - System of equations which is going to be solved. + * \param[in] sol_fine - Pointer to the solution on the fine grid. + * \param[out] sol_coarse - Pointer to the solution on the coarse grid. + * \param[in] geo_fine - Geometrical definition of the fine grid. + * \param[in] geo_coarse - Geometrical definition of the coarse grid. + * \param[in] config - Definition of the particular problem. + * \param[in] iMesh - Index of the mesh in multigrid computations. + * \param[in] InclSharedDomain - Include the shared domain in the interpolation. + */ + void SetRestricted_EddyVisc(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config); + +}; diff --git a/SU2_CFD/include/integration/CStructuralIntegration.hpp b/SU2_CFD/include/integration/CStructuralIntegration.hpp new file mode 100644 index 000000000000..381ffd0f9d15 --- /dev/null +++ b/SU2_CFD/include/integration/CStructuralIntegration.hpp @@ -0,0 +1,53 @@ +/*! + * \file CStructuralIntegration.hpp + * \brief Declaration of class for numerical integration of structural problems. + * \author R. Sanchez. + * \version 7.0.1 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "CIntegration.hpp" + +/*! + * \class CStructuralIntegration + * \brief Class for numerical integration of structural problems. + * \author R. Sanchez. + */ +class CStructuralIntegration final : public CIntegration { +public: + /*! + * \brief Constructor of the class. + * \param[in] config - Definition of the particular problem. + */ + CStructuralIntegration(CConfig *config); + + /*! + * \brief Do the numerical integration (implicit) of the structural solver. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] solver_container - Container vector with all the solutions. + * \param[in] numerics_container - Description of the numerical method (the way in which the equations are solved). + * \param[in] config - Definition of the particular problem. + * \param[in] RunTime_EqSystem - System of equations which is going to be solved. + */ + void Structural_Iteration(CGeometry ****geometry, CSolver *****solver_container, CNumerics ******numerics_container, + CConfig **config, unsigned short RunTime_EqSystem, unsigned short iZone, unsigned short iInst) override; +}; diff --git a/SU2_CFD/include/integration_structure.hpp b/SU2_CFD/include/integration_structure.hpp deleted file mode 100644 index 203829c34702..000000000000 --- a/SU2_CFD/include/integration_structure.hpp +++ /dev/null @@ -1,709 +0,0 @@ -/*! - * \file integration_structure.hpp - * \brief Headers of the main subroutines for space and time integration. - * The subroutines and functions are in the integration_structure.cpp, - * integration_time.cpp, and integration_notime.cpp files. - * \author F. Palacios, T. Economon - * \version 7.0.1 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "../../Common/include/mpi_structure.hpp" - -#include -#include -#include - -#include "solvers/CSolver.hpp" -#include "../../Common/include/geometry/CGeometry.hpp" -#include "../../Common/include/CConfig.hpp" - -using namespace std; - -/*! - * \class CIntegration - * \brief Main class for doing the space integration, time integration, and monitoring - * of a system of Partial Differential Equations (PDE). - * \author F. Palacios - */ -class CIntegration { -protected: - int rank, /*!< \brief MPI Rank. */ - size; /*!< \brief MPI Size. */ - su2double - Cauchy_Value, /*!< \brief Summed value of the convergence indicator. */ - Cauchy_Func; /*!< \brief Current value of the convergence indicator at one iteration. */ - unsigned short Cauchy_Counter; /*!< \brief Number of elements of the Cauchy serial. */ - su2double *Cauchy_Serie; /*!< \brief Complete Cauchy serial. */ - su2double - Old_Func, /*!< \brief Old value of the objective function (the function which is monitored). */ - New_Func; /*!< \brief Current value of the objective function (the function which is monitored). */ - bool Convergence, /*!< \brief To indicate if the flow solver (direct, adjoint, or linearized) has converged or not. */ - Convergence_FSI, /*!< \brief To indicate if the FSI problem has converged or not. */ - Convergence_FullMG; /*!< \brief To indicate if the Full Multigrid has converged and it is necessary to add a new level. */ - su2double InitResidual; /*!< \brief Initial value of the residual to evaluate the convergence level. */ - -public: - - /*! - * \brief Constructor of the class. - */ - CIntegration(CConfig *config); - - /*! - * \brief Destructor of the class. - */ - virtual ~CIntegration(void); - - /*! - * \brief Do the space integration of the numerical system. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] solver_container - Container vector with all the solutions. - * \param[in] solver - 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. - * \param[in] RunTime_EqSystem - System of equations which is going to be solved. - */ - void Space_Integration(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics, CConfig *config, - unsigned short iMesh, unsigned short iRKStep, unsigned short RunTime_EqSystem); - - /*! - * \brief Do the space integration of the numerical system on a FEM framework. - * \author R. Sanchez - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] solver_container - Container vector with all the solutions. - * \param[in] solver - Description of the numerical method. - * \param[in] config - Definition of the particular problem. - * \param[in] RunTime_EqSystem - System of equations which is going to be solved. - */ - void Space_Integration_FEM(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics, CConfig *config, - unsigned short RunTime_EqSystem); - - /*! - * \brief Do the time integration (explicit or implicit) of the numerical system. - * \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. - */ - void Time_Integration(CGeometry *geometry, CSolver **solver_container, CConfig *config, - unsigned short iRKStep, unsigned short RunTime_EqSystem); - - /*! - * \brief Do the time integration (explicit or implicit) of the numerical system on a FEM framework. - * \author R. Sanchez - * \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] RunTime_EqSystem - System of equations which is going to be solved. - * \param[in] Iteration - Current iteration. - */ - void Time_Integration_FEM(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics, CConfig *config, - unsigned short RunTime_EqSystem); - - /*! - * \brief Initialize the adjoint solution using the primal problem. - * \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] RunTime_EqSystem - System of equations which is going to be solved. - * \param[in] Iteration - Current iteration. - */ - void Adjoint_Setup(CGeometry ****geometry, CSolver *****solver_container, CConfig **config, - unsigned short RunTime_EqSystem, unsigned long Iteration, unsigned short iZone); - - /*! - * \brief Average the scalar output in case there is a unsteady solution. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] config - Definition of the particular problem. - * \param[in] Iteration - Current iteration. - * \param[in] monitor - Objective function to be averaged. - * \param[in] iMesh - Index of the mesh. - */ - void Average_Monitoring(CGeometry *geometry, CConfig *config, - unsigned long Iteration, su2double monitor, unsigned short iMesh); - - /*! - * \brief Get the value of the convergence. - * \return Level of convergence of the solution. - */ - su2double GetCauchy_Value(void); - - /*! - * \brief Get the indicator of the convergence for the direct, adjoint and linearized problem. - * \return TRUE means that the convergence criteria is satisfied; - * otherwise FALSE. - */ - bool GetConvergence(void); - - /*! - * \brief Get the indicator of the convergence for the Fluid-Structure Interaction problem. - * \return TRUE means that the convergence criteria is satisfied; - * otherwise FALSE. - */ - bool GetConvergence_FSI(void); - - /*! - * \brief Set the indicator of the convergence. - * \param[in] value - TRUE means that the convergence criteria is satisfied; - * otherwise FALSE. - */ - void SetConvergence(bool value); - - - /*! - * \brief Set the indicator of the convergence for FSI. - * \param[in] valueFSI - TRUE means that the convergence criteria for FSI is satisfied; - * otherwise FALSE. - */ - void SetConvergence_FSI(bool valueFSI); - - - /*! - * \brief Get the indicator of the convergence for the full multigrid problem. - * \return TRUE means that the convergence criteria is satisfied; - * otherwise FALSE. - */ - bool GetConvergence_FullMG(void); - - /*! - * \brief Save the solution, and volume at different time steps. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] solution - Flow solution. - * \param[in] config - Definition of the particular problem. - */ - void SetDualTime_Solver(CGeometry *geometry, CSolver *solver, CConfig *config, unsigned short iMesh); - - /*! - * \brief Save the structural solution at different time steps. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] solution - Structural solution. - * \param[in] config - Definition of the particular problem. - */ - void SetStructural_Solver(CGeometry *geometry, CSolver *solver, CConfig *config, unsigned short iMesh); - - /*! - * \brief Save the structural solution at different time steps. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] solver_container - Structural solution. - * \param[in] config - Definition of the particular problem. - */ - void SetFEM_StructuralSolver(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh); - - /*! - * \brief A virtual member. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] solver_container - Container vector with all the solutions. - * \param[in] numerics_container - Description of the numerical method (the way in which the equations are solved). - * \param[in] config - Definition of the particular problem. - * \param[in] RunTime_EqSystem - System of equations which is going to be solved. - */ - virtual void MultiGrid_Iteration(CGeometry ****geometry, CSolver *****solver_container, CNumerics ******numerics_container, - CConfig **config, unsigned short RunTime_EqSystem, unsigned short iZone, unsigned short iInst); - - /*! - * \brief A virtual member. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] solver_container - Container vector with all the solutions. - * \param[in] numerics_container - Description of the numerical method (the way in which the equations are solved). - * \param[in] config - Definition of the particular problem. - * \param[in] iMesh - Index of the mesh in multigrid computations. - * \param[in] mu - Variable for controlling the kind of multigrid algorithm. - * \param[in] RunTime_EqSystem - System of equations which is going to be solved. - */ - virtual void MultiGrid_Cycle(CGeometry ****geometry, CSolver *****solver_container, CNumerics ******numerics_container, - CConfig **config, unsigned short iMesh, unsigned short mu, unsigned short RunTime_EqSystem, - unsigned short iZone, unsigned short iInst); - - /*! - * \brief A virtual member. - * \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] RunTime_EqSystem - System of equations which is going to be solved. - * \param[in] monitor - value of the non-dimensional parameters for monitoring the convergence. - */ - virtual void NonDimensional_Parameters(CGeometry **geometry, CSolver ***solver_container, CNumerics ****numerics_container, - CConfig *config, unsigned short FinestMesh, unsigned short RunTime_EqSystem, - su2double *monitor); - - /*! - * \brief A virtual member. - * \param[out] sol_fine - Pointer to the solution on the fine grid. - * \param[in] geo_fine - Geometrical definition of the fine grid. - * \param[in] config - Definition of the particular problem. - */ - virtual void SetProlongated_Correction(CSolver *sol_fine, CGeometry *geo_fine, CConfig *config, unsigned short iMesh); - - /*! - * \brief A virtual member. - * \param[in] RunTime_EqSystem - System of equations which is going to be solved. - * \param[out] sol_fine - Pointer to the solution on the fine grid. - * \param[in] sol_coarse - Pointer to the solution on the coarse grid. - * \param[in] geo_fine - Geometrical definition of the fine grid. - * \param[in] geo_coarse - Geometrical definition of the coarse grid. - * \param[in] config - Definition of the particular problem. - */ - virtual void SetProlongated_Solution(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, - CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config); - - /*! - * \brief A virtual member. - * \param[in] sol_fine - Pointer to the solution on the fine grid. - * \param[out] sol_coarse - Pointer to the solution on the coarse grid. - * \param[in] geo_fine - Geometrical definition of the fine grid. - * \param[in] geo_coarse - Geometrical definition of the coarse grid. - * \param[in] config - Definition of the particular problem. - */ - virtual void SetRestricted_Residual(CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, - CGeometry *geo_coarse, CConfig *config); - - /*! - * \brief A virtual member. - * \param[in] RunTime_EqSystem - System of equations which is going to be solved. - * \param[in] sol_fine - Pointer to the solution on the fine grid. - * \param[out] sol_coarse - Pointer to the solution on the coarse grid. - * \param[in] geo_fine - Geometrical definition of the fine grid. - * \param[in] geo_coarse - Geometrical definition of the coarse grid. - * \param[in] config - Definition of the particular problem. - * \param[in] iMesh - Index of the mesh in multigrid computations. - * \param[in] InclSharedDomain - Include the shared domain in the interpolation. - */ - virtual void SetRestricted_Solution(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config); - - /*! - * \brief A virtual member. - * \param[in] RunTime_EqSystem - System of equations which is going to be solved. - * \param[in] sol_fine - Pointer to the solution on the fine grid. - * \param[out] sol_coarse - Pointer to the solution on the coarse grid. - * \param[in] geo_fine - Geometrical definition of the fine grid. - * \param[in] geo_coarse - Geometrical definition of the coarse grid. - * \param[in] config - Definition of the particular problem. - * \param[in] iMesh - Index of the mesh in multigrid computations. - * \param[in] InclSharedDomain - Include the shared domain in the interpolation. - */ - virtual void SetRestricted_EddyVisc(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config); - - /*! - * \brief A virtual member. - * \param[in] RunTime_EqSystem - System of equations which is going to be solved. - * \param[in] sol_fine - Pointer to the solution on the fine grid. - * \param[out] sol_coarse - Pointer to the solution on the coarse grid. - * \param[in] geo_fine - Geometrical definition of the fine grid. - * \param[in] geo_coarse - Geometrical definition of the coarse grid. - * \param[in] config - Definition of the particular problem. - */ - virtual void SetRestricted_Gradient(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, - CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config); - - /*! - * \brief A virtual member. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] flow - Flow solution. - */ - virtual void SetResidual_Term(CGeometry *geometry, CSolver *flow); - - /*! - * \brief A virtual member. - * \param[in] sol_fine - Pointer to the solution on the fine grid. - * \param[in] sol_coarse - Pointer to the solution on the coarse grid. - * \param[in] geo_fine - Geometrical definition of the fine grid. - * \param[in] geo_coarse - Geometrical definition of the coarse grid. - * \param[in] config - Definition of the particular problem. - */ - virtual void SetForcing_Term(CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, CGeometry *geo_coarse, - CConfig *config, unsigned short iMesh); - - /*! - * \brief A virtual member. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] solver_container - Container vector with all the solutions. - * \param[in] numerics_container - Description of the numerical method (the way in which the equations are solved). - * \param[in] config - Definition of the particular problem. - * \param[in] RunTime_EqSystem - System of equations which is going to be solved. - */ - virtual void SingleGrid_Iteration(CGeometry ****geometry, CSolver *****solver_container, CNumerics ******numerics_container, - CConfig **config, unsigned short RunTime_EqSystem, unsigned short iZone, unsigned short iInst); - - - /*! - * \brief A virtual member. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] solver_container - Container vector with all the solutions. - * \param[in] numerics_container - Description of the numerical method (the way in which the equations are solved). - * \param[in] config - Definition of the particular problem. - * \param[in] RunTime_EqSystem - System of equations which is going to be solved. - */ - virtual void Structural_Iteration(CGeometry ****geometry, CSolver *****solver_container, CNumerics ******numerics_container, - CConfig **config, unsigned short RunTime_EqSystem, unsigned short iZone, unsigned short iInst); - - - /*! - * \brief A virtual member. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] solver_container - Container vector with all the solutions. - * \param[in] numerics_container - Description of the numerical method (the way in which the equations are solved). - * \param[in] config - Definition of the particular problem. - * \param[in] RunTime_EqSystem - System of equations which is going to be solved. - * \param[in] iMesh - Index of the mesh in multigrid computations. - */ - virtual void SetPotential_Solver(CGeometry ****geometry, CSolver *****solver_container, CNumerics ******numerics_container, - CConfig **config, unsigned short RunTime_EqSystem, unsigned short iMesh, unsigned short iZone); - - /*! - * \brief A virtual member. - * \param[in] RunTime_EqSystem - System of equations which is going to be solved. - * \param[in] solution - Container vector with all the solutions on the finest grid. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] val_nSmooth - Number of smoothing iterations. - * \param[in] val_smooth_coeff - Relaxation factor. - * \param[in] config - Definition of the particular problem. - */ - virtual void Smooth_Solution(unsigned short RunTime_EqSystem, CSolver *solver, CGeometry *geometry, - unsigned short val_nSmooth, su2double val_smooth_coeff, CConfig *config); - -}; - -/*! - * \class CMultiGridIntegration - * \brief Class for doing the numerical integration using a multigrid method. - * \author F. Palacios - */ -class CMultiGridIntegration : public CIntegration { -protected: - -public: - - /*! - * \brief Constructor of the class. - * \param[in] config - Definition of the particular problem. - */ - CMultiGridIntegration(CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CMultiGridIntegration(void); - - /*! - * \brief This subroutine calls the MultiGrid_Cycle and also prepare the multigrid levels and the monitoring. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] solver_container - Container vector with all the solutions. - * \param[in] numerics_container - Description of the numerical method (the way in which the equations are solved). - * \param[in] config - Definition of the particular problem. - * \param[in] RunTime_EqSystem - System of equations which is going to be solved. - * \param[in] Iteration - Current iteration. - */ - void MultiGrid_Iteration(CGeometry ****geometry, CSolver *****solver_container, CNumerics ******numerics_container, - CConfig **config, unsigned short RunTime_EqSystem, unsigned short iZone, unsigned short iInst); - - /*! - * \brief Perform a Full-Approximation Storage (FAS) Multigrid. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] solver_container - Container vector with all the solutions. - * \param[in] numerics_container - Description of the numerical method (the way in which the equations are solved). - * \param[in] config - Definition of the particular problem. - * \param[in] iMesh - Index of the mesh in multigrid computations. - * \param[in] mu - Variable for controlling the kind of multigrid algorithm. - * \param[in] RunTime_EqSystem - System of equations which is going to be solved. - * \param[in] Iteration - Current iteration. - */ - void MultiGrid_Cycle(CGeometry ****geometry, CSolver *****solver_container, CNumerics ******numerics_container, - CConfig **config, unsigned short iMesh, unsigned short mu, unsigned short RunTime_EqSystem, unsigned short iZone, unsigned short iInst); - - /*! - * \brief Compute the non-dimensional parameters. - * \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] RunTime_EqSystem - System of equations which is going to be solved. - * \param[in] Iteration - Current iteration. - * \param[in] monitor - value of the non-dimensional parameters for monitoring the convergence. - */ - void NonDimensional_Parameters(CGeometry **geometry, CSolver ***solver_container, CNumerics ****numerics_container, - CConfig *config, unsigned short FinestMesh, unsigned short RunTime_EqSystem, - su2double *monitor); - - /*! - * \brief Compute the fine solution from a coarse solution. - * \param[in] RunTime_EqSystem - System of equations which is going to be solved. - * \param[out] sol_fine - Pointer to the solution on the fine grid. - * \param[in] sol_coarse - Pointer to the solution on the coarse grid. - * \param[in] geo_fine - Geometrical definition of the fine grid. - * \param[in] geo_coarse - Geometrical definition of the coarse grid. - * \param[in] config - Definition of the particular problem. - */ - void SetProlongated_Solution(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, - CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config); - - /*! - * \brief Compute the fine grid correction from the coarse solution. - * \param[out] sol_fine - Pointer to the solution on the fine grid. - * \param[in] sol_coarse - Pointer to the solution on the coarse grid. - * \param[in] geo_fine - Geometrical definition of the fine grid. - * \param[in] geo_coarse - Geometrical definition of the coarse grid. - * \param[in] config - Definition of the particular problem. - */ - void GetProlongated_Correction(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, - CGeometry *geo_coarse, CConfig *config); - - /*! - * \brief Do an implicit smoothing of the prolongated correction. - * \param[in] RunTime_EqSystem - System of equations which is going to be solved. - * \param[in] solution - Container vector with all the solutions on the finest grid. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] val_nSmooth - Number of smoothing iterations. - * \param[in] val_smooth_coeff - Relaxation factor. - * \param[in] config - Definition of the particular problem. - */ - void SmoothProlongated_Correction(unsigned short RunTime_EqSystem, CSolver *solver, CGeometry *geometry, - unsigned short val_nSmooth, su2double val_smooth_coeff, CConfig *config); - - /*! - * \brief Do an implicit smoothing of the solution. - * \param[in] RunTime_EqSystem - System of equations which is going to be solved. - * \param[in] solution - Container vector with all the solutions on the finest grid. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] val_nSmooth - Number of smoothing iterations. - * \param[in] val_smooth_coeff - Relaxation factor. - * \param[in] config - Definition of the particular problem. - */ - void Smooth_Solution(unsigned short RunTime_EqSystem, CSolver *solver, CGeometry *geometry, - unsigned short val_nSmooth, su2double val_smooth_coeff, CConfig *config); - - /*! - * \brief Set the value of the corrected fine grid solution. - * \param[out] sol_fine - Pointer to the solution on the fine grid. - * \param[in] geo_fine - Geometrical definition of the fine grid. - * \param[in] config - Definition of the particular problem. - */ - void SetProlongated_Correction(CSolver *sol_fine, CGeometry *geo_fine, CConfig *config, unsigned short iMesh); - - /*! - * \brief Compute truncation error in the coarse grid using the fine grid information. - * \param[in] sol_fine - Pointer to the solution on the fine grid. - * \param[out] sol_coarse - Pointer to the solution on the coarse grid. - * \param[in] geo_fine - Geometrical definition of the fine grid. - * \param[in] geo_coarse - Geometrical definition of the coarse grid. - * \param[in] config - Definition of the particular problem. - */ - void SetRestricted_Residual(CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, - CGeometry *geo_coarse, CConfig *config); - - /*! - * \brief Restrict solution from fine grid to a coarse grid. - * \param[in] RunTime_EqSystem - System of equations which is going to be solved. - * \param[in] sol_fine - Pointer to the solution on the fine grid. - * \param[out] sol_coarse - Pointer to the solution on the coarse grid. - * \param[in] geo_fine - Geometrical definition of the fine grid. - * \param[in] geo_coarse - Geometrical definition of the coarse grid. - * \param[in] config - Definition of the particular problem. - * \param[in] iMesh - Index of the mesh in multigrid computations. - * \param[in] InclSharedDomain - Include the shared domain in the interpolation. - */ - void SetRestricted_Solution(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config); - - /*! - * \brief Compute the gradient in coarse grid using the fine grid information. - * \param[in] RunTime_EqSystem - System of equations which is going to be solved. - * \param[in] sol_fine - Pointer to the solution on the fine grid. - * \param[out] sol_coarse - Pointer to the solution on the coarse grid. - * \param[in] geo_fine - Geometrical definition of the fine grid. - * \param[in] geo_coarse - Geometrical definition of the coarse grid. - * \param[in] config - Definition of the particular problem. - */ - void SetRestricted_Gradient(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, - CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config); - - /*! - * \brief Add the truncation error to the residual. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] flow - Flow solution. - */ - void SetResidual_Term(CGeometry *geometry, CSolver *flow); - - /*! - * \brief Compute the forcing term. - * \param[in] sol_fine - Pointer to the solution on the fine grid. - * \param[in] sol_coarse - Pointer to the solution on the coarse grid. - * \param[in] geo_fine - Geometrical definition of the fine grid. - * \param[in] geo_coarse - Geometrical definition of the coarse grid. - * \param[in] config - Definition of the particular problem. - */ - void SetForcing_Term(CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, CGeometry *geo_coarse, - CConfig *config, unsigned short iMesh); -}; - -/*! - * \class CSingleGridIntegration - * \brief Class for doing the numerical integration of the turbulence model. - * \author A. Bueno. - */ -class CSingleGridIntegration : public CIntegration { -public: - - /*! - * \brief Constructor of the class. - * \param[in] config - Definition of the particular problem. - */ - CSingleGridIntegration(CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CSingleGridIntegration(void); - - /*! - * \brief Do the numerical integration (implicit) of the turbulence solver. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] solver_container - Container vector with all the solutions. - * \param[in] numerics_container - Description of the numerical method (the way in which the equations are solved). - * \param[in] config - Definition of the particular problem. - * \param[in] RunTime_EqSystem - System of equations which is going to be solved. - */ - void SingleGrid_Iteration(CGeometry ****geometry, CSolver *****solver_container, CNumerics ******numerics_container, - CConfig **config, unsigned short RunTime_EqSystem, unsigned short iZone, unsigned short iInst); - - /*! - * \brief Restrict solution from fine grid to a coarse grid. - * \param[in] RunTime_EqSystem - System of equations which is going to be solved. - * \param[in] sol_fine - Pointer to the solution on the fine grid. - * \param[out] sol_coarse - Pointer to the solution on the coarse grid. - * \param[in] geo_fine - Geometrical definition of the fine grid. - * \param[in] geo_coarse - Geometrical definition of the coarse grid. - * \param[in] config - Definition of the particular problem. - * \param[in] iMesh - Index of the mesh in multigrid computations. - * \param[in] InclSharedDomain - Include the shared domain in the interpolation. - */ - void SetRestricted_Solution(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config); - - /*! - * \brief Restrict solution from fine grid to a coarse grid. - * \param[in] RunTime_EqSystem - System of equations which is going to be solved. - * \param[in] sol_fine - Pointer to the solution on the fine grid. - * \param[out] sol_coarse - Pointer to the solution on the coarse grid. - * \param[in] geo_fine - Geometrical definition of the fine grid. - * \param[in] geo_coarse - Geometrical definition of the coarse grid. - * \param[in] config - Definition of the particular problem. - * \param[in] iMesh - Index of the mesh in multigrid computations. - * \param[in] InclSharedDomain - Include the shared domain in the interpolation. - */ - void SetRestricted_EddyVisc(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config); - -}; - - -/*! - * \class CStructuralIntegration - * \brief Class for doing the numerical integration of the structural model. - * \author R. Sanchez. - */ -class CStructuralIntegration : public CIntegration { -public: - - /*! - * \brief Constructor of the class. - * \param[in] config - Definition of the particular problem. - */ - CStructuralIntegration(CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CStructuralIntegration(void); - - /*! - * \brief Do the numerical integration (implicit) of the structural solver. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] solver_container - Container vector with all the solutions. - * \param[in] numerics_container - Description of the numerical method (the way in which the equations are solved). - * \param[in] config - Definition of the particular problem. - * \param[in] RunTime_EqSystem - System of equations which is going to be solved. - */ - void Structural_Iteration(CGeometry ****geometry, CSolver *****solver_container, CNumerics ******numerics_container, - CConfig **config, unsigned short RunTime_EqSystem, unsigned short iZone, unsigned short iInst); - -}; - -/*! - * \class CFEM_DG_Integration - * \brief Class for integration with the FEM DG solver. - * \author E. van der Weide, T. Economon - * \version 7.0.1 "Blackbird" - */ -class CFEM_DG_Integration : public CIntegration { -public: - - /*! - * \brief Constructor of the class. - * \param[in] config - Definition of the particular problem. - */ - CFEM_DG_Integration(CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CFEM_DG_Integration(void); - - /*! - * \brief Do the numerical integration (implicit) of the turbulence solver. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] solver_container - Container vector with all the solutions. - * \param[in] numerics_container - Description of the numerical method (the way in which the equations are solved). - * \param[in] config - Definition of the particular problem. - * \param[in] RunTime_EqSystem - System of equations which is going to be solved. - */ - void SingleGrid_Iteration(CGeometry ****geometry, CSolver *****solver_container, CNumerics ******numerics_container, - CConfig **config, unsigned short RunTime_EqSystem, unsigned short iZone, unsigned short iInst); - /*! - * \brief Perform the spatial integration of the numerical system. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] solver_container - Container vector with all the solutions. - * \param[in] solver - 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] iStep - Current step of the Runge-Kutta iteration for the RK schemes - and the step in the local time stepping for ADER-DG. - * \param[in] RunTime_EqSystem - System of equations which is going to be solved. - */ - void Space_Integration(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics, CConfig *config, - unsigned short iMesh, unsigned short iStep, unsigned short RunTime_EqSystem); - - /*! - * \brief Perform the time integration (explicit or implicit) of the numerical system. - * \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] iStep - Current step of the Runge-Kutta iteration for the RK schemes - and the step in the local time stepping for ADER-DG. - * \param[in] RunTime_EqSystem - System of equations which is going to be solved. - * \param[in] Iteration - Current iteration. - */ - void Time_Integration(CGeometry *geometry, CSolver **solver_container, CConfig *config, - unsigned short iStep, unsigned short RunTime_EqSystem); -}; - -#include "integration_structure.inl" diff --git a/SU2_CFD/include/integration_structure.inl b/SU2_CFD/include/integration_structure.inl deleted file mode 100644 index 8c16529cc9b8..000000000000 --- a/SU2_CFD/include/integration_structure.inl +++ /dev/null @@ -1,83 +0,0 @@ -/*! - * \file integration_structure.inl - * \brief In-Line subroutines of the integration_structure.hpp file. - * \author F. Palacios, T. Economon - * \version 7.0.1 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -inline su2double CIntegration::GetCauchy_Value(void) { return Cauchy_Value; } - -inline bool CIntegration::GetConvergence(void) { return Convergence; } - -inline bool CIntegration::GetConvergence_FSI(void) { return Convergence_FSI; } - -inline bool CIntegration::GetConvergence_FullMG(void) { return Convergence_FullMG; } - -inline void CIntegration::SetConvergence(bool value) { Convergence = value; } - -inline void CIntegration::SetConvergence_FSI(bool valueFSI) { Convergence_FSI = valueFSI; } - -inline void CIntegration::MultiGrid_Iteration(CGeometry ****geometry, CSolver *****solver_container, CNumerics ******numerics_container, - CConfig **config, unsigned short RunTime_EqSystem, unsigned short iZone, unsigned short iInst) { } - -inline void CIntegration::MultiGrid_Cycle(CGeometry ****geometry, CSolver *****solver_container, CNumerics ******numerics_container, - CConfig **config, unsigned short iMesh, unsigned short mu, unsigned short RunTime_EqSystem, - unsigned short iZone, unsigned short iInst) { } - -inline void CIntegration::NonDimensional_Parameters(CGeometry **geometry, CSolver ***solver_container, CNumerics ****numerics_container, - CConfig *config, unsigned short FinestMesh, unsigned short RunTime_EqSystem, - su2double *monitor) { } - -inline void CIntegration::SetProlongated_Correction(CSolver *sol_fine, CGeometry *geo_fine, CConfig *config, unsigned short iMesh) { } - -inline void CIntegration::SetProlongated_Solution(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, - CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config) { } - -inline void CIntegration::SetRestricted_Residual(CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, - CGeometry *geo_coarse, CConfig *config) { } - -inline void CIntegration::SetRestricted_Solution(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config) { } - -inline void CIntegration::SetRestricted_EddyVisc(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config) { } - -inline void CIntegration::SetRestricted_Gradient(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, - CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config) { } - -inline void CIntegration::SetResidual_Term(CGeometry *geometry, CSolver *flow) { } - -inline void CIntegration::SetForcing_Term(CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, CGeometry *geo_coarse, - CConfig *config, unsigned short iMesh) { } - -inline void CIntegration::SingleGrid_Iteration(CGeometry ****geometry, CSolver *****solver_container, CNumerics ******numerics_container, - CConfig **config, unsigned short RunTime_EqSystem, unsigned short iZone, unsigned short iInst) { } - -inline void CIntegration::Structural_Iteration(CGeometry ****geometry, CSolver *****solver_container, CNumerics ******numerics_container, - CConfig **config, unsigned short RunTime_EqSystem, unsigned short iZone, unsigned short iInst) { } - - -inline void CIntegration::SetPotential_Solver(CGeometry ****geometry, CSolver *****solver_container, CNumerics ******numerics_container, - CConfig **config, unsigned short RunTime_EqSystem, unsigned short iMesh, unsigned short iZone) { } - -inline void CIntegration::Smooth_Solution(unsigned short RunTime_EqSystem, CSolver *solver, CGeometry *geometry, unsigned short val_nSmooth, su2double val_smooth_coeff, CConfig *config) { } diff --git a/SU2_CFD/include/iteration_structure.hpp b/SU2_CFD/include/iteration_structure.hpp index 4e2296bdc4d3..826eb478ec58 100644 --- a/SU2_CFD/include/iteration_structure.hpp +++ b/SU2_CFD/include/iteration_structure.hpp @@ -33,9 +33,9 @@ #include "../../Common/include/mpi_structure.hpp" #include "../../Common/include/geometry/CGeometry.hpp" #include "../../Common/include/grid_movement_structure.hpp" -#include "integration_structure.hpp" #include "output/COutput.hpp" #include "../../Common/include/CConfig.hpp" +#include "../include/integration/CIntegration.hpp" using namespace std; diff --git a/SU2_CFD/obj/Makefile.am b/SU2_CFD/obj/Makefile.am index 219ceb7a94b7..1f7cf5e5e338 100644 --- a/SU2_CFD/obj/Makefile.am +++ b/SU2_CFD/obj/Makefile.am @@ -54,8 +54,11 @@ libSU2Core_sources = ../src/definition_structure.cpp \ ../src/fluid_model_pvdw.cpp \ ../src/fluid_model_ppr.cpp \ ../src/fluid_model_inc.cpp \ - ../src/integration_structure.cpp \ - ../src/integration_time.cpp \ + ../src/integration/CIntegration.cpp \ + ../src/integration/CSingleGridIntegration.cpp \ + ../src/integration/CMultiGridIntegration.cpp \ + ../src/integration/CStructuralIntegration.cpp \ + ../src/integration/CFEM_DG_Integration.cpp \ ../src/drivers/CMultizoneDriver.cpp \ ../src/drivers/CSinglezoneDriver.cpp \ ../src/drivers/CDiscAdjSinglezoneDriver.cpp \ diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index efe65a113d82..7c5dccb80eb1 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -85,6 +85,11 @@ #include "../../include/numerics/elasticity/CFEANonlinearElasticity.hpp" #include "../../include/numerics/elasticity/nonlinear_models.hpp" +#include "../../include/integration/CSingleGridIntegration.hpp" +#include "../../include/integration/CMultiGridIntegration.hpp" +#include "../../include/integration/CStructuralIntegration.hpp" +#include "../../include/integration/CFEM_DG_Integration.hpp" + #include "../../../Common/include/omp_structure.hpp" #include diff --git a/SU2_CFD/src/integration/CFEM_DG_Integration.cpp b/SU2_CFD/src/integration/CFEM_DG_Integration.cpp new file mode 100644 index 000000000000..a5202ada63dc --- /dev/null +++ b/SU2_CFD/src/integration/CFEM_DG_Integration.cpp @@ -0,0 +1,184 @@ +/*! + * \file CFEM_DG_Integration.cpp + * \brief Definition of time and space integration for the DG solver. + * \author F. Palacios, T. Economon + * \version 7.0.1 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../include/integration/CFEM_DG_Integration.hpp" + + +CFEM_DG_Integration::CFEM_DG_Integration(CConfig *config) : CIntegration(config) { } + +void CFEM_DG_Integration::SingleGrid_Iteration(CGeometry ****geometry, + CSolver *****solver_container, + CNumerics ******numerics_container, + CConfig **config, + unsigned short RunTime_EqSystem, + unsigned short iZone, + unsigned short iInst) { + + unsigned short iMesh, iStep, iLimit = 1; + unsigned short SolContainer_Position = config[iZone]->GetContainerPosition(RunTime_EqSystem); + unsigned short FinestMesh = config[iZone]->GetFinestMesh(); + + /*--- For now, we assume no geometric multigrid. ---*/ + iMesh = FinestMesh; + + /*--- Check if only the Jacobian of the spatial discretization must + be computed. If so, call the appropriate function and return. ---*/ + if (config[iZone]->GetJacobian_Spatial_Discretization_Only()) { + solver_container[iZone][iInst][iMesh][SolContainer_Position]->ComputeSpatialJacobian(geometry[iZone][iInst][iMesh], solver_container[iZone][iInst][iMesh], + numerics_container[iZone][iInst][iMesh][SolContainer_Position], + config[iZone], iMesh, RunTime_EqSystem); + return; + } + + /*--- Determine the number of stages in the time stepping algorithm. + For the Runge-Kutta schemes this is the number of RK stages, + while for ADER-DG this information is not used, because a more + complicated algorithm must be used to facilitate time accurate + local time stepping. Note that we are currently hard-coding + the classical RK4 scheme. ---*/ + bool useADER = false; + switch (config[iZone]->GetKind_TimeIntScheme()) { + case RUNGE_KUTTA_EXPLICIT: iLimit = config[iZone]->GetnRKStep(); break; + case CLASSICAL_RK4_EXPLICIT: iLimit = 4; break; + case ADER_DG: iLimit = 1; useADER = true; break; + case EULER_EXPLICIT: case EULER_IMPLICIT: iLimit = 1; break; } + + /*--- In case an unsteady simulation is carried out, it is possible that a + synchronization time step is specified. If so, set the boolean + TimeSynSpecified to true, which leads to an outer loop in the + algorithm below. ---*/ + bool TimeSyncSpecified = false; + const su2double TimeSync = config[iZone]->GetTime_Step()/config[iZone]->GetTime_Ref(); + if(config[iZone]->GetTime_Marching() == TIME_STEPPING && + config[iZone]->GetUnst_CFL() != 0.0 && + TimeSync != 0.0) TimeSyncSpecified = true; + + /*--- Outer loop, which is only active when a synchronization time has been + specified for an unsteady simulation. ---*/ + bool syncTimeReached = false; + su2double timeEvolved = 0.0; + while( !syncTimeReached ) { + + /* Compute the time step for stability. */ + solver_container[iZone][iInst][iMesh][SolContainer_Position]->SetTime_Step(geometry[iZone][iInst][iMesh], + solver_container[iZone][iInst][iMesh], + config[iZone], iMesh, config[iZone]->GetTimeIter()); + /* Possibly overrule the specified time step when a synchronization time was + specified and determine whether or not the time loop must be continued. + When TimeSyncSpecified is false, the loop is always terminated. */ + if( TimeSyncSpecified ) + solver_container[iZone][iInst][iMesh][SolContainer_Position]->CheckTimeSynchronization(config[iZone], + TimeSync, timeEvolved, + syncTimeReached); + else + syncTimeReached = true; + + /*--- For ADER in combination with time accurate local time stepping, the + space and time integration are tightly coupled and cannot be treated + segregatedly. Therefore a different function is called for ADER to + carry out the space and time integration. ---*/ + if( useADER ) { + solver_container[iZone][iInst][iMesh][SolContainer_Position]->ADER_SpaceTimeIntegration(geometry[iZone][iInst][iMesh], solver_container[iZone][iInst][iMesh], + numerics_container[iZone][iInst][iMesh][SolContainer_Position], + config[iZone], iMesh, RunTime_EqSystem); + } + else { + + /*--- Time and space integration can be decoupled. ---*/ + for (iStep = 0; iStep < iLimit; iStep++) { + + /*--- Preprocessing ---*/ + solver_container[iZone][iInst][iMesh][SolContainer_Position]->Preprocessing(geometry[iZone][iInst][iMesh], solver_container[iZone][iInst][iMesh], + config[iZone], iMesh, iStep, RunTime_EqSystem, false); + + /*--- Space integration ---*/ + Space_Integration(geometry[iZone][iInst][iMesh], solver_container[iZone][iInst][iMesh], + numerics_container[iZone][iInst][iMesh][SolContainer_Position], + config[iZone], iMesh, iStep, RunTime_EqSystem); + + /*--- Time integration, update solution using the old solution plus the solution increment ---*/ + Time_Integration(geometry[iZone][iInst][iMesh], solver_container[iZone][iInst][iMesh], + config[iZone], iStep, RunTime_EqSystem); + + /*--- Postprocessing ---*/ + solver_container[iZone][iInst][iMesh][SolContainer_Position]->Postprocessing(geometry[iZone][iInst][iMesh], solver_container[iZone][iInst][iMesh], + config[iZone], iMesh); + } + } + } + + /*--- Calculate the inviscid and viscous forces ---*/ + solver_container[iZone][iInst][FinestMesh][SolContainer_Position]->Pressure_Forces(geometry[iZone][iInst][iMesh], config[iZone]); + + solver_container[iZone][iInst][FinestMesh][SolContainer_Position]->Friction_Forces(geometry[iZone][iInst][iMesh], config[iZone]); + + /*--- Convergence strategy ---*/ + + //Convergence_Monitoring(geometry[iZone][iInst][FinestMesh], config[iZone], Iteration, monitor, FinestMesh); +} + +void CFEM_DG_Integration::Space_Integration(CGeometry *geometry, + CSolver **solver_container, + CNumerics **numerics, + CConfig *config, unsigned short iMesh, + unsigned short iStep, + unsigned short RunTime_EqSystem) { + + unsigned short MainSolver = config->GetContainerPosition(RunTime_EqSystem); + + /*--- Runge-Kutta type of time integration schemes. In the first step, i.e. + if iStep == 0, set the old solution (working solution for the DG part), + and if needed, the new solution. ---*/ + if (iStep == 0) { + solver_container[MainSolver]->Set_OldSolution(geometry); + + if (config->GetKind_TimeIntScheme() == CLASSICAL_RK4_EXPLICIT) { + solver_container[MainSolver]->Set_NewSolution(geometry); + } + } + + /*--- Compute the spatial residual by processing the task list. ---*/ + solver_container[MainSolver]->ProcessTaskList_DG(geometry, solver_container, numerics, config, iMesh); +} + +void CFEM_DG_Integration::Time_Integration(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iStep, + unsigned short RunTime_EqSystem) { + + unsigned short MainSolver = config->GetContainerPosition(RunTime_EqSystem); + + /*--- Perform the time integration ---*/ + switch (config->GetKind_TimeIntScheme()) { + case (RUNGE_KUTTA_EXPLICIT): + solver_container[MainSolver]->ExplicitRK_Iteration(geometry, solver_container, config, iStep); + break; + case (CLASSICAL_RK4_EXPLICIT): + solver_container[MainSolver]->ClassicalRK4_Iteration(geometry, solver_container, config, iStep); + break; + default: + SU2_MPI::Error("Time integration scheme not implemented.", CURRENT_FUNCTION); + } +} diff --git a/SU2_CFD/src/integration_structure.cpp b/SU2_CFD/src/integration/CIntegration.cpp similarity index 99% rename from SU2_CFD/src/integration_structure.cpp rename to SU2_CFD/src/integration/CIntegration.cpp index 1a6e743f7beb..95f3b74c4547 100644 --- a/SU2_CFD/src/integration_structure.cpp +++ b/SU2_CFD/src/integration/CIntegration.cpp @@ -1,6 +1,6 @@ /*! - * \file integration_structure.cpp - * \brief This subroutine includes the space and time integration structure + * \file CIntegration.cpp + * \brief Implementation of the base class for space and time integration. * \author F. Palacios, T. Economon * \version 7.0.1 "Blackbird" * @@ -25,8 +25,8 @@ * License along with SU2. If not, see . */ -#include "../include/integration_structure.hpp" -#include "../../Common/include/omp_structure.hpp" +#include "../../include/integration/CIntegration.hpp" +#include "../../../Common/include/omp_structure.hpp" CIntegration::CIntegration(CConfig *config) { diff --git a/SU2_CFD/src/integration_time.cpp b/SU2_CFD/src/integration/CMultiGridIntegration.cpp similarity index 66% rename from SU2_CFD/src/integration_time.cpp rename to SU2_CFD/src/integration/CMultiGridIntegration.cpp index 6c06d5c523da..9b30bb1bbed3 100644 --- a/SU2_CFD/src/integration_time.cpp +++ b/SU2_CFD/src/integration/CMultiGridIntegration.cpp @@ -1,6 +1,6 @@ /*! - * \file integration_time.cpp - * \brief Time dependent numerical methods + * \file CMultiGridIntegration.cpp + * \brief Implementation of the multigrid integration class. * \author F. Palacios, T. Economon * \version 7.0.1 "Blackbird" * @@ -25,13 +25,11 @@ * License along with SU2. If not, see . */ -#include "../include/integration_structure.hpp" -#include "../../Common/include/omp_structure.hpp" +#include "../../include/integration/CMultiGridIntegration.hpp" +#include "../../../Common/include/omp_structure.hpp" -CMultiGridIntegration::CMultiGridIntegration(CConfig *config) : CIntegration(config) {} - -CMultiGridIntegration::~CMultiGridIntegration(void) { } +CMultiGridIntegration::CMultiGridIntegration(CConfig *config) : CIntegration(config) { } void CMultiGridIntegration::MultiGrid_Iteration(CGeometry ****geometry, CSolver *****solver_container, @@ -243,7 +241,7 @@ void CMultiGridIntegration::MultiGrid_Cycle(CGeometry ****geometry, SetProlongated_Correction(solver_fine, geometry_fine, config, iMesh); - + /*--- Solution post-smoothing in the prolongated grid. ---*/ for (unsigned short iPostSmooth = 0; iPostSmooth < config->GetMG_PostSmooth(iMesh); iPostSmooth++) { @@ -306,7 +304,7 @@ void CMultiGridIntegration::GetProlongated_Correction(unsigned short RunTime_EqS for (iVar = 0; iVar < nVar; iVar++) sol_coarse->GetNodes()->SetSolution_Old(Point_Coarse,Solution); } - + delete [] Solution; /*--- Remove any contributions from no-slip walls. ---*/ @@ -341,7 +339,7 @@ void CMultiGridIntegration::GetProlongated_Correction(unsigned short RunTime_EqS SU2_OMP_BARRIER /// TODO: Need to check for possible race condition here (multiple coarse points setting the same fine). - + SU2_OMP_FOR_STAT(roundUpDiv(geo_coarse->GetnPointDomain(), omp_get_num_threads())) for (Point_Coarse = 0; Point_Coarse < geo_coarse->GetnPointDomain(); Point_Coarse++) { for (iChildren = 0; iChildren < geo_coarse->node[Point_Coarse]->GetnChildren_CV(); iChildren++) { @@ -357,7 +355,7 @@ void CMultiGridIntegration::SmoothProlongated_Correction(unsigned short RunTime_ /*--- Check if there is work to do. ---*/ if (val_nSmooth == 0) return; - + const su2double *Residual_Old, *Residual_Sum, *Residual_j; unsigned short iVar, iSmooth, iMarker, iNeigh; unsigned long iPoint, jPoint, iVertex; @@ -373,32 +371,32 @@ void CMultiGridIntegration::SmoothProlongated_Correction(unsigned short RunTime_ /*--- Jacobi iterations. ---*/ for (iSmooth = 0; iSmooth < val_nSmooth; iSmooth++) { - + /*--- Loop over all mesh points (sum the residuals of direct neighbors). ---*/ - + SU2_OMP_FOR_STAT(roundUpDiv(geometry->GetnPoint(), omp_get_num_threads())) for (iPoint = 0; iPoint < geometry->GetnPoint(); ++iPoint) { - + solver->GetNodes()->SetResidualSumZero(iPoint); - + for (iNeigh = 0; iNeigh < geometry->node[iPoint]->GetnPoint(); ++iNeigh) { jPoint = geometry->node[iPoint]->GetPoint(iNeigh); Residual_j = solver->LinSysRes.GetBlock(jPoint); solver->GetNodes()->AddResidual_Sum(iPoint, Residual_j); } - + } - + /*--- Loop over all mesh points (update residuals with the neighbor averages). ---*/ - + SU2_OMP_FOR_STAT(roundUpDiv(geometry->GetnPoint(), omp_get_num_threads())) for (iPoint = 0; iPoint < geometry->GetnPoint(); ++iPoint) { - + su2double factor = 1.0/(1.0+val_smooth_coeff*su2double(geometry->node[iPoint]->GetnPoint())); - + Residual_Sum = solver->GetNodes()->GetResidual_Sum(iPoint); Residual_Old = solver->GetNodes()->GetResidual_Old(iPoint); - + for (iVar = 0; iVar < nVar; iVar++) solver->LinSysRes(iPoint,iVar) = (Residual_Old[iVar] + val_smooth_coeff*Residual_Sum[iVar])*factor; } @@ -408,7 +406,7 @@ void CMultiGridIntegration::SmoothProlongated_Correction(unsigned short RunTime_ for (iMarker = 0; iMarker < geometry->GetnMarker(); iMarker++) { if ((config->GetMarker_All_KindBC(iMarker) != INTERNAL_BOUNDARY) && (config->GetMarker_All_KindBC(iMarker) != PERIODIC_BOUNDARY)) { - + SU2_OMP_FOR_STAT(32) for (iVertex = 0; iVertex < geometry->GetnVertex(iMarker); iVertex++) { iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); @@ -417,17 +415,17 @@ void CMultiGridIntegration::SmoothProlongated_Correction(unsigned short RunTime_ } } } - + } - + } void CMultiGridIntegration::Smooth_Solution(unsigned short RunTime_EqSystem, CSolver *solver, CGeometry *geometry, unsigned short val_nSmooth, su2double val_smooth_coeff, CConfig *config) { - + /*--- Check if there is work to do. ---*/ if (val_nSmooth == 0) return; - + const su2double *Solution_Old, *Solution_Sum, *Solution_j; unsigned short iVar, iSmooth, iMarker, iNeigh; unsigned long iPoint, jPoint, iVertex; @@ -443,32 +441,32 @@ void CMultiGridIntegration::Smooth_Solution(unsigned short RunTime_EqSystem, CSo /*--- Jacobi iterations ---*/ for (iSmooth = 0; iSmooth < val_nSmooth; iSmooth++) { - + /*--- Loop over all mesh points (sum the solutions of direct neighbors). ---*/ - + SU2_OMP_FOR_STAT(roundUpDiv(geometry->GetnPoint(), omp_get_num_threads())) for (iPoint = 0; iPoint < geometry->GetnPoint(); ++iPoint) { - + solver->GetNodes()->SetResidualSumZero(iPoint); - + for (iNeigh = 0; iNeigh < geometry->node[iPoint]->GetnPoint(); ++iNeigh) { jPoint = geometry->node[iPoint]->GetPoint(iNeigh); Solution_j = solver->GetNodes()->GetSolution(jPoint); solver->GetNodes()->AddResidual_Sum(iPoint, Solution_j); } - + } - + /*--- Loop over all mesh points (update solutions with the neighbor averages). ---*/ - + SU2_OMP_FOR_STAT(roundUpDiv(geometry->GetnPoint(), omp_get_num_threads())) for (iPoint = 0; iPoint < geometry->GetnPoint(); ++iPoint) { - + su2double factor = 1.0/(1.0+val_smooth_coeff*su2double(geometry->node[iPoint]->GetnPoint())); - + Solution_Sum = solver->GetNodes()->GetResidual_Sum(iPoint); Solution_Old = solver->GetNodes()->GetResidual_Old(iPoint); - + for (iVar = 0; iVar < nVar; iVar++) { su2double Solution = (Solution_Old[iVar] + val_smooth_coeff*Solution_Sum[iVar])*factor; solver->GetNodes()->SetSolution(iPoint, iVar, Solution); @@ -480,7 +478,7 @@ void CMultiGridIntegration::Smooth_Solution(unsigned short RunTime_EqSystem, CSo for (iMarker = 0; iMarker < geometry->GetnMarker(); iMarker++) { if ((config->GetMarker_All_KindBC(iMarker) != INTERNAL_BOUNDARY) && (config->GetMarker_All_KindBC(iMarker) != PERIODIC_BOUNDARY)) { - + SU2_OMP_FOR_STAT(32) for (iVertex = 0; iVertex < geometry->GetnVertex(iMarker); iVertex++) { iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); @@ -489,9 +487,9 @@ void CMultiGridIntegration::Smooth_Solution(unsigned short RunTime_EqSystem, CSo } } } - + } - + } void CMultiGridIntegration::SetProlongated_Correction(CSolver *sol_fine, CGeometry *geo_fine, @@ -533,7 +531,7 @@ void CMultiGridIntegration::SetProlongated_Solution(unsigned short RunTime_EqSys unsigned short iChildren; /// TODO: Need to check for possible race condition here (multiple coarse points setting the same fine). - + SU2_OMP_FOR_STAT(roundUpDiv(geo_coarse->GetnPointDomain(), omp_get_num_threads())) for (Point_Coarse = 0; Point_Coarse < geo_coarse->GetnPointDomain(); Point_Coarse++) { for (iChildren = 0; iChildren < geo_coarse->node[Point_Coarse]->GetnChildren_CV(); iChildren++) { @@ -545,7 +543,7 @@ void CMultiGridIntegration::SetProlongated_Solution(unsigned short RunTime_EqSys void CMultiGridIntegration::SetForcing_Term(CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config, unsigned short iMesh) { - + unsigned long Point_Fine, Point_Coarse, iVertex; unsigned short iMarker, iVar, iChildren; const su2double *Residual_Fine; @@ -557,11 +555,11 @@ void CMultiGridIntegration::SetForcing_Term(CSolver *sol_fine, CSolver *sol_coar SU2_OMP_FOR_STAT(roundUpDiv(geo_coarse->GetnPointDomain(), omp_get_num_threads())) for (Point_Coarse = 0; Point_Coarse < geo_coarse->GetnPointDomain(); Point_Coarse++) { - + 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++) { Point_Fine = geo_coarse->node[Point_Coarse]->GetChildren_CV(iChildren); Residual_Fine = sol_fine->LinSysRes.GetBlock(Point_Fine); @@ -577,7 +575,7 @@ void CMultiGridIntegration::SetForcing_Term(CSolver *sol_fine, CSolver *sol_coar if ((config->GetMarker_All_KindBC(iMarker) == HEAT_FLUX) || (config->GetMarker_All_KindBC(iMarker) == ISOTHERMAL) || (config->GetMarker_All_KindBC(iMarker) == CHT_WALL_INTERFACE)) { - + SU2_OMP_FOR_STAT(32) for (iVertex = 0; iVertex < geo_coarse->nVertex[iMarker]; iVertex++) { Point_Coarse = geo_coarse->vertex[iMarker][iVertex]->GetNode(); @@ -656,7 +654,7 @@ void CMultiGridIntegration::SetRestricted_Solution(unsigned short RunTime_EqSyst SU2_OMP_FOR_STAT(roundUpDiv(geo_coarse->GetnPointDomain(), omp_get_num_threads())) for (Point_Coarse = 0; Point_Coarse < geo_coarse->GetnPointDomain(); Point_Coarse++) { - + Area_Parent = geo_coarse->node[Point_Coarse]->GetVolume(); for (iVar = 0; iVar < nVar; iVar++) Solution[iVar] = 0.0; @@ -674,7 +672,7 @@ void CMultiGridIntegration::SetRestricted_Solution(unsigned short RunTime_EqSyst sol_coarse->GetNodes()->SetSolution(Point_Coarse, Solution); } - + delete [] Solution; /*--- Update the solution at the no-slip walls ---*/ @@ -686,7 +684,7 @@ void CMultiGridIntegration::SetRestricted_Solution(unsigned short RunTime_EqSyst SU2_OMP_FOR_STAT(32) for (iVertex = 0; iVertex < geo_coarse->nVertex[iMarker]; iVertex++) { - + Point_Coarse = geo_coarse->vertex[iMarker][iVertex]->GetNode(); if (SolContainer_Position == FLOW_SOL) { @@ -809,328 +807,3 @@ void CMultiGridIntegration::NonDimensional_Parameters(CGeometry **geometry, CSol } -CSingleGridIntegration::CSingleGridIntegration(CConfig *config) : CIntegration(config) { } - -CSingleGridIntegration::~CSingleGridIntegration(void) { } - -void CSingleGridIntegration::SingleGrid_Iteration(CGeometry ****geometry, CSolver *****solver_container, - CNumerics ******numerics_container, CConfig **config, unsigned short RunTime_EqSystem, unsigned short iZone, unsigned short iInst) { - unsigned short iMesh; - - unsigned short SolContainer_Position = config[iZone]->GetContainerPosition(RunTime_EqSystem); - - unsigned short FinestMesh = config[iZone]->GetFinestMesh(); - - /*--- Preprocessing ---*/ - - solver_container[iZone][iInst][FinestMesh][SolContainer_Position]->Preprocessing(geometry[iZone][iInst][FinestMesh], solver_container[iZone][iInst][FinestMesh], config[iZone], FinestMesh, 0, RunTime_EqSystem, false); - - /*--- Set the old solution ---*/ - - solver_container[iZone][iInst][FinestMesh][SolContainer_Position]->Set_OldSolution(geometry[iZone][iInst][FinestMesh]); - - /*--- Time step evaluation ---*/ - - solver_container[iZone][iInst][FinestMesh][SolContainer_Position]->SetTime_Step(geometry[iZone][iInst][FinestMesh], solver_container[iZone][iInst][FinestMesh], config[iZone], FinestMesh, config[iZone]->GetTimeIter()); - - /*--- Space integration ---*/ - - Space_Integration(geometry[iZone][iInst][FinestMesh], solver_container[iZone][iInst][FinestMesh], numerics_container[iZone][iInst][FinestMesh][SolContainer_Position], - config[iZone], FinestMesh, NO_RK_ITER, RunTime_EqSystem); - - /*--- Time integration ---*/ - - Time_Integration(geometry[iZone][iInst][FinestMesh], solver_container[iZone][iInst][FinestMesh], config[iZone], NO_RK_ITER, - RunTime_EqSystem); - - /*--- Postprocessing ---*/ - - solver_container[iZone][iInst][FinestMesh][SolContainer_Position]->Postprocessing(geometry[iZone][iInst][FinestMesh], solver_container[iZone][iInst][FinestMesh], config[iZone], FinestMesh); - - if (RunTime_EqSystem == RUNTIME_HEAT_SYS) { - solver_container[iZone][iInst][FinestMesh][HEAT_SOL]->Heat_Fluxes(geometry[iZone][iInst][FinestMesh], solver_container[iZone][iInst][FinestMesh], config[iZone]); - } - - /*--- If turbulence model, copy the turbulence variables to the coarse levels ---*/ - - if (RunTime_EqSystem == RUNTIME_TURB_SYS) { - for (iMesh = FinestMesh; iMesh < config[iZone]->GetnMGLevels(); iMesh++) { - SetRestricted_Solution(RunTime_EqSystem, solver_container[iZone][iInst][iMesh][SolContainer_Position], solver_container[iZone][iInst][iMesh+1][SolContainer_Position], geometry[iZone][iInst][iMesh], geometry[iZone][iInst][iMesh+1], config[iZone]); - SetRestricted_EddyVisc(RunTime_EqSystem, solver_container[iZone][iInst][iMesh][SolContainer_Position], solver_container[iZone][iInst][iMesh+1][SolContainer_Position], geometry[iZone][iInst][iMesh], geometry[iZone][iInst][iMesh+1], config[iZone]); - } - } -} - -void CSingleGridIntegration::SetRestricted_Solution(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config) { - unsigned long Point_Fine, Point_Coarse; - unsigned short iVar, iChildren; - su2double Area_Parent, Area_Children, *Solution_Fine, *Solution; - - unsigned short nVar = sol_coarse->GetnVar(); - - Solution = new su2double[nVar]; - - /*--- Compute coarse solution from fine solution ---*/ - - for (Point_Coarse = 0; Point_Coarse < geo_coarse->GetnPointDomain(); Point_Coarse++) { - Area_Parent = geo_coarse->node[Point_Coarse]->GetVolume(); - - for (iVar = 0; iVar < nVar; iVar++) Solution[iVar] = 0.0; - - 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->GetNodes()->GetSolution(Point_Fine); - for (iVar = 0; iVar < nVar; iVar++) - Solution[iVar] += Solution_Fine[iVar]*Area_Children/Area_Parent; - } - - sol_coarse->GetNodes()->SetSolution(Point_Coarse,Solution); - - } - - /*--- MPI the new interpolated solution ---*/ - - sol_coarse->InitiateComms(geo_coarse, config, SOLUTION); - sol_coarse->CompleteComms(geo_coarse, config, SOLUTION); - - delete [] Solution; - -} - -void CSingleGridIntegration::SetRestricted_EddyVisc(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config) { - - unsigned long iVertex, Point_Fine, Point_Coarse; - unsigned short iMarker, iChildren; - su2double Area_Parent, Area_Children, EddyVisc_Fine, EddyVisc; - - /*--- Compute coarse Eddy Viscosity from fine solution ---*/ - - for (Point_Coarse = 0; Point_Coarse < geo_coarse->GetnPointDomain(); Point_Coarse++) { - Area_Parent = geo_coarse->node[Point_Coarse]->GetVolume(); - - EddyVisc = 0.0; - - 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->GetNodes()->GetmuT(Point_Fine); - EddyVisc += EddyVisc_Fine*Area_Children/Area_Parent; - } - - sol_coarse->GetNodes()->SetmuT(Point_Coarse,EddyVisc); - - } - - /*--- Update solution at the no slip wall boundary, only the first - variable (nu_tilde -in SA and SA_NEG- and k -in SST-), to guarantee that the eddy viscoisty - is zero on the surface ---*/ - - for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { - if ((config->GetMarker_All_KindBC(iMarker) == HEAT_FLUX ) || - (config->GetMarker_All_KindBC(iMarker) == ISOTHERMAL ) || - (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->GetNodes()->SetmuT(Point_Coarse,0.0); - } - } - } - - /*--- MPI the new interpolated solution (this also includes the eddy viscosity) ---*/ - - sol_coarse->InitiateComms(geo_coarse, config, SOLUTION_EDDY); - sol_coarse->CompleteComms(geo_coarse, config, SOLUTION_EDDY); - -} - - -CStructuralIntegration::CStructuralIntegration(CConfig *config) : CIntegration(config) { } - -CStructuralIntegration::~CStructuralIntegration(void) { } - -void CStructuralIntegration::Structural_Iteration(CGeometry ****geometry, CSolver *****solver_container, - CNumerics ******numerics_container, CConfig **config, unsigned short RunTime_EqSystem, unsigned short iZone, unsigned short iInst) { - - unsigned short SolContainer_Position = config[iZone]->GetContainerPosition(RunTime_EqSystem); - - /*--- Preprocessing ---*/ - - solver_container[iZone][iInst][MESH_0][SolContainer_Position]->Preprocessing(geometry[iZone][iInst][MESH_0], solver_container[iZone][iInst][MESH_0], - config[iZone], numerics_container[iZone][iInst][MESH_0][SolContainer_Position], MESH_0, NO_RK_ITER, RunTime_EqSystem, false); - - - /*--- Space integration ---*/ - - Space_Integration_FEM(geometry[iZone][iInst][MESH_0], solver_container[iZone][iInst][MESH_0], numerics_container[iZone][iInst][MESH_0][SolContainer_Position], - config[iZone], RunTime_EqSystem); - - /*--- Time integration ---*/ - - Time_Integration_FEM(geometry[iZone][iInst][MESH_0], solver_container[iZone][iInst][MESH_0], numerics_container[iZone][iInst][MESH_0][SolContainer_Position], - config[iZone], RunTime_EqSystem); - - /*--- Postprocessing ---*/ - - solver_container[iZone][iInst][MESH_0][SolContainer_Position]->Postprocessing(geometry[iZone][iInst][MESH_0], solver_container[iZone][iInst][MESH_0], - config[iZone], numerics_container[iZone][iInst][MESH_0][SolContainer_Position], MESH_0); - -} - -CFEM_DG_Integration::CFEM_DG_Integration(CConfig *config) : CIntegration(config) { } - -CFEM_DG_Integration::~CFEM_DG_Integration(void) { } - -void CFEM_DG_Integration::SingleGrid_Iteration(CGeometry ****geometry, - CSolver *****solver_container, - CNumerics ******numerics_container, - CConfig **config, - unsigned short RunTime_EqSystem, - unsigned short iZone, - unsigned short iInst) { - - unsigned short iMesh, iStep, iLimit = 1; - unsigned short SolContainer_Position = config[iZone]->GetContainerPosition(RunTime_EqSystem); - unsigned short FinestMesh = config[iZone]->GetFinestMesh(); - - /*--- For now, we assume no geometric multigrid. ---*/ - iMesh = FinestMesh; - - /*--- Check if only the Jacobian of the spatial discretization must - be computed. If so, call the appropriate function and return. ---*/ - if (config[iZone]->GetJacobian_Spatial_Discretization_Only()) { - solver_container[iZone][iInst][iMesh][SolContainer_Position]->ComputeSpatialJacobian(geometry[iZone][iInst][iMesh], solver_container[iZone][iInst][iMesh], - numerics_container[iZone][iInst][iMesh][SolContainer_Position], - config[iZone], iMesh, RunTime_EqSystem); - return; - } - - /*--- Determine the number of stages in the time stepping algorithm. - For the Runge-Kutta schemes this is the number of RK stages, - while for ADER-DG this information is not used, because a more - complicated algorithm must be used to facilitate time accurate - local time stepping. Note that we are currently hard-coding - the classical RK4 scheme. ---*/ - bool useADER = false; - switch (config[iZone]->GetKind_TimeIntScheme()) { - case RUNGE_KUTTA_EXPLICIT: iLimit = config[iZone]->GetnRKStep(); break; - case CLASSICAL_RK4_EXPLICIT: iLimit = 4; break; - case ADER_DG: iLimit = 1; useADER = true; break; - case EULER_EXPLICIT: case EULER_IMPLICIT: iLimit = 1; break; } - - /*--- In case an unsteady simulation is carried out, it is possible that a - synchronization time step is specified. If so, set the boolean - TimeSynSpecified to true, which leads to an outer loop in the - algorithm below. ---*/ - bool TimeSyncSpecified = false; - const su2double TimeSync = config[iZone]->GetTime_Step()/config[iZone]->GetTime_Ref(); - if(config[iZone]->GetTime_Marching() == TIME_STEPPING && - config[iZone]->GetUnst_CFL() != 0.0 && - TimeSync != 0.0) TimeSyncSpecified = true; - - /*--- Outer loop, which is only active when a synchronization time has been - specified for an unsteady simulation. ---*/ - bool syncTimeReached = false; - su2double timeEvolved = 0.0; - while( !syncTimeReached ) { - - /* Compute the time step for stability. */ - solver_container[iZone][iInst][iMesh][SolContainer_Position]->SetTime_Step(geometry[iZone][iInst][iMesh], - solver_container[iZone][iInst][iMesh], - config[iZone], iMesh, config[iZone]->GetTimeIter()); - /* Possibly overrule the specified time step when a synchronization time was - specified and determine whether or not the time loop must be continued. - When TimeSyncSpecified is false, the loop is always terminated. */ - if( TimeSyncSpecified ) - solver_container[iZone][iInst][iMesh][SolContainer_Position]->CheckTimeSynchronization(config[iZone], - TimeSync, timeEvolved, - syncTimeReached); - else - syncTimeReached = true; - - /*--- For ADER in combination with time accurate local time stepping, the - space and time integration are tightly coupled and cannot be treated - segregatedly. Therefore a different function is called for ADER to - carry out the space and time integration. ---*/ - if( useADER ) { - solver_container[iZone][iInst][iMesh][SolContainer_Position]->ADER_SpaceTimeIntegration(geometry[iZone][iInst][iMesh], solver_container[iZone][iInst][iMesh], - numerics_container[iZone][iInst][iMesh][SolContainer_Position], - config[iZone], iMesh, RunTime_EqSystem); - } - else { - - /*--- Time and space integration can be decoupled. ---*/ - for (iStep = 0; iStep < iLimit; iStep++) { - - /*--- Preprocessing ---*/ - solver_container[iZone][iInst][iMesh][SolContainer_Position]->Preprocessing(geometry[iZone][iInst][iMesh], solver_container[iZone][iInst][iMesh], - config[iZone], iMesh, iStep, RunTime_EqSystem, false); - - /*--- Space integration ---*/ - Space_Integration(geometry[iZone][iInst][iMesh], solver_container[iZone][iInst][iMesh], - numerics_container[iZone][iInst][iMesh][SolContainer_Position], - config[iZone], iMesh, iStep, RunTime_EqSystem); - - /*--- Time integration, update solution using the old solution plus the solution increment ---*/ - Time_Integration(geometry[iZone][iInst][iMesh], solver_container[iZone][iInst][iMesh], - config[iZone], iStep, RunTime_EqSystem); - - /*--- Postprocessing ---*/ - solver_container[iZone][iInst][iMesh][SolContainer_Position]->Postprocessing(geometry[iZone][iInst][iMesh], solver_container[iZone][iInst][iMesh], - config[iZone], iMesh); - } - } - } - - /*--- Calculate the inviscid and viscous forces ---*/ - solver_container[iZone][iInst][FinestMesh][SolContainer_Position]->Pressure_Forces(geometry[iZone][iInst][iMesh], config[iZone]); - - solver_container[iZone][iInst][FinestMesh][SolContainer_Position]->Friction_Forces(geometry[iZone][iInst][iMesh], config[iZone]); - - /*--- Convergence strategy ---*/ - - //Convergence_Monitoring(geometry[iZone][iInst][FinestMesh], config[iZone], Iteration, monitor, FinestMesh); -} - -void CFEM_DG_Integration::Space_Integration(CGeometry *geometry, - CSolver **solver_container, - CNumerics **numerics, - CConfig *config, unsigned short iMesh, - unsigned short iStep, - unsigned short RunTime_EqSystem) { - - unsigned short MainSolver = config->GetContainerPosition(RunTime_EqSystem); - - /*--- Runge-Kutta type of time integration schemes. In the first step, i.e. - if iStep == 0, set the old solution (working solution for the DG part), - and if needed, the new solution. ---*/ - if (iStep == 0) { - solver_container[MainSolver]->Set_OldSolution(geometry); - - if (config->GetKind_TimeIntScheme() == CLASSICAL_RK4_EXPLICIT) { - solver_container[MainSolver]->Set_NewSolution(geometry); - } - } - - /*--- Compute the spatial residual by processing the task list. ---*/ - solver_container[MainSolver]->ProcessTaskList_DG(geometry, solver_container, numerics, config, iMesh); -} - -void CFEM_DG_Integration::Time_Integration(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iStep, - unsigned short RunTime_EqSystem) { - - unsigned short MainSolver = config->GetContainerPosition(RunTime_EqSystem); - - /*--- Perform the time integration ---*/ - switch (config->GetKind_TimeIntScheme()) { - case (RUNGE_KUTTA_EXPLICIT): - solver_container[MainSolver]->ExplicitRK_Iteration(geometry, solver_container, config, iStep); - break; - case (CLASSICAL_RK4_EXPLICIT): - solver_container[MainSolver]->ClassicalRK4_Iteration(geometry, solver_container, config, iStep); - break; - default: - SU2_MPI::Error("Time integration scheme not implemented.", CURRENT_FUNCTION); - } -} diff --git a/SU2_CFD/src/integration/CSingleGridIntegration.cpp b/SU2_CFD/src/integration/CSingleGridIntegration.cpp new file mode 100644 index 000000000000..e68f2b0cf3b9 --- /dev/null +++ b/SU2_CFD/src/integration/CSingleGridIntegration.cpp @@ -0,0 +1,164 @@ +/*! + * \file CSingleGridIntegration.cpp + * \brief Single (fine) grid integration class implementation. + * \author F. Palacios, T. Economon + * \version 7.0.1 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../include/integration/CSingleGridIntegration.hpp" + + +CSingleGridIntegration::CSingleGridIntegration(CConfig *config) : CIntegration(config) { } + +void CSingleGridIntegration::SingleGrid_Iteration(CGeometry ****geometry, CSolver *****solver_container, + CNumerics ******numerics_container, CConfig **config, unsigned short RunTime_EqSystem, unsigned short iZone, unsigned short iInst) { + unsigned short iMesh; + + unsigned short SolContainer_Position = config[iZone]->GetContainerPosition(RunTime_EqSystem); + + unsigned short FinestMesh = config[iZone]->GetFinestMesh(); + + /*--- Preprocessing ---*/ + + solver_container[iZone][iInst][FinestMesh][SolContainer_Position]->Preprocessing(geometry[iZone][iInst][FinestMesh], solver_container[iZone][iInst][FinestMesh], config[iZone], FinestMesh, 0, RunTime_EqSystem, false); + + /*--- Set the old solution ---*/ + + solver_container[iZone][iInst][FinestMesh][SolContainer_Position]->Set_OldSolution(geometry[iZone][iInst][FinestMesh]); + + /*--- Time step evaluation ---*/ + + solver_container[iZone][iInst][FinestMesh][SolContainer_Position]->SetTime_Step(geometry[iZone][iInst][FinestMesh], solver_container[iZone][iInst][FinestMesh], config[iZone], FinestMesh, config[iZone]->GetTimeIter()); + + /*--- Space integration ---*/ + + Space_Integration(geometry[iZone][iInst][FinestMesh], solver_container[iZone][iInst][FinestMesh], numerics_container[iZone][iInst][FinestMesh][SolContainer_Position], + config[iZone], FinestMesh, NO_RK_ITER, RunTime_EqSystem); + + /*--- Time integration ---*/ + + Time_Integration(geometry[iZone][iInst][FinestMesh], solver_container[iZone][iInst][FinestMesh], config[iZone], NO_RK_ITER, + RunTime_EqSystem); + + /*--- Postprocessing ---*/ + + solver_container[iZone][iInst][FinestMesh][SolContainer_Position]->Postprocessing(geometry[iZone][iInst][FinestMesh], solver_container[iZone][iInst][FinestMesh], config[iZone], FinestMesh); + + if (RunTime_EqSystem == RUNTIME_HEAT_SYS) { + solver_container[iZone][iInst][FinestMesh][HEAT_SOL]->Heat_Fluxes(geometry[iZone][iInst][FinestMesh], solver_container[iZone][iInst][FinestMesh], config[iZone]); + } + + /*--- If turbulence model, copy the turbulence variables to the coarse levels ---*/ + + if (RunTime_EqSystem == RUNTIME_TURB_SYS) { + for (iMesh = FinestMesh; iMesh < config[iZone]->GetnMGLevels(); iMesh++) { + SetRestricted_Solution(RunTime_EqSystem, solver_container[iZone][iInst][iMesh][SolContainer_Position], solver_container[iZone][iInst][iMesh+1][SolContainer_Position], geometry[iZone][iInst][iMesh], geometry[iZone][iInst][iMesh+1], config[iZone]); + SetRestricted_EddyVisc(RunTime_EqSystem, solver_container[iZone][iInst][iMesh][SolContainer_Position], solver_container[iZone][iInst][iMesh+1][SolContainer_Position], geometry[iZone][iInst][iMesh], geometry[iZone][iInst][iMesh+1], config[iZone]); + } + } +} + +void CSingleGridIntegration::SetRestricted_Solution(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config) { + unsigned long Point_Fine, Point_Coarse; + unsigned short iVar, iChildren; + su2double Area_Parent, Area_Children, *Solution_Fine, *Solution; + + unsigned short nVar = sol_coarse->GetnVar(); + + Solution = new su2double[nVar]; + + /*--- Compute coarse solution from fine solution ---*/ + + for (Point_Coarse = 0; Point_Coarse < geo_coarse->GetnPointDomain(); Point_Coarse++) { + Area_Parent = geo_coarse->node[Point_Coarse]->GetVolume(); + + for (iVar = 0; iVar < nVar; iVar++) Solution[iVar] = 0.0; + + 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->GetNodes()->GetSolution(Point_Fine); + for (iVar = 0; iVar < nVar; iVar++) + Solution[iVar] += Solution_Fine[iVar]*Area_Children/Area_Parent; + } + + sol_coarse->GetNodes()->SetSolution(Point_Coarse,Solution); + + } + + /*--- MPI the new interpolated solution ---*/ + + sol_coarse->InitiateComms(geo_coarse, config, SOLUTION); + sol_coarse->CompleteComms(geo_coarse, config, SOLUTION); + + delete [] Solution; + +} + +void CSingleGridIntegration::SetRestricted_EddyVisc(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config) { + + unsigned long iVertex, Point_Fine, Point_Coarse; + unsigned short iMarker, iChildren; + su2double Area_Parent, Area_Children, EddyVisc_Fine, EddyVisc; + + /*--- Compute coarse Eddy Viscosity from fine solution ---*/ + + for (Point_Coarse = 0; Point_Coarse < geo_coarse->GetnPointDomain(); Point_Coarse++) { + Area_Parent = geo_coarse->node[Point_Coarse]->GetVolume(); + + EddyVisc = 0.0; + + 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->GetNodes()->GetmuT(Point_Fine); + EddyVisc += EddyVisc_Fine*Area_Children/Area_Parent; + } + + sol_coarse->GetNodes()->SetmuT(Point_Coarse,EddyVisc); + + } + + /*--- Update solution at the no slip wall boundary, only the first + variable (nu_tilde -in SA and SA_NEG- and k -in SST-), to guarantee that the eddy viscoisty + is zero on the surface ---*/ + + for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { + if ((config->GetMarker_All_KindBC(iMarker) == HEAT_FLUX ) || + (config->GetMarker_All_KindBC(iMarker) == ISOTHERMAL ) || + (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->GetNodes()->SetmuT(Point_Coarse,0.0); + } + } + } + + /*--- MPI the new interpolated solution (this also includes the eddy viscosity) ---*/ + + sol_coarse->InitiateComms(geo_coarse, config, SOLUTION_EDDY); + sol_coarse->CompleteComms(geo_coarse, config, SOLUTION_EDDY); + +} + diff --git a/SU2_CFD/src/integration/CStructuralIntegration.cpp b/SU2_CFD/src/integration/CStructuralIntegration.cpp new file mode 100644 index 000000000000..fdd8b5055511 --- /dev/null +++ b/SU2_CFD/src/integration/CStructuralIntegration.cpp @@ -0,0 +1,60 @@ +/*! + * \file CStructuralIntegration.cpp + * \brief Space and time integration for structural problems. + * \author F. Palacios, T. Economon + * \version 7.0.1 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../include/integration/CStructuralIntegration.hpp" + + +CStructuralIntegration::CStructuralIntegration(CConfig *config) : CIntegration(config) { } + +void CStructuralIntegration::Structural_Iteration(CGeometry ****geometry, CSolver *****solver_container, + CNumerics ******numerics_container, CConfig **config, unsigned short RunTime_EqSystem, unsigned short iZone, unsigned short iInst) { + + unsigned short SolContainer_Position = config[iZone]->GetContainerPosition(RunTime_EqSystem); + + /*--- Preprocessing ---*/ + + solver_container[iZone][iInst][MESH_0][SolContainer_Position]->Preprocessing(geometry[iZone][iInst][MESH_0], solver_container[iZone][iInst][MESH_0], + config[iZone], numerics_container[iZone][iInst][MESH_0][SolContainer_Position], MESH_0, NO_RK_ITER, RunTime_EqSystem, false); + + + /*--- Space integration ---*/ + + Space_Integration_FEM(geometry[iZone][iInst][MESH_0], solver_container[iZone][iInst][MESH_0], numerics_container[iZone][iInst][MESH_0][SolContainer_Position], + config[iZone], RunTime_EqSystem); + + /*--- Time integration ---*/ + + Time_Integration_FEM(geometry[iZone][iInst][MESH_0], solver_container[iZone][iInst][MESH_0], numerics_container[iZone][iInst][MESH_0][SolContainer_Position], + config[iZone], RunTime_EqSystem); + + /*--- Postprocessing ---*/ + + solver_container[iZone][iInst][MESH_0][SolContainer_Position]->Postprocessing(geometry[iZone][iInst][MESH_0], solver_container[iZone][iInst][MESH_0], + config[iZone], numerics_container[iZone][iInst][MESH_0][SolContainer_Position], MESH_0); + +} + diff --git a/SU2_CFD/src/meson.build b/SU2_CFD/src/meson.build index 3541b7afac62..063c179b48f7 100644 --- a/SU2_CFD/src/meson.build +++ b/SU2_CFD/src/meson.build @@ -1,7 +1,5 @@ -su2_cfd_src = files(['integration_structure.cpp', - 'transport_model.cpp', +su2_cfd_src = files(['transport_model.cpp', 'fluid_model_pvdw.cpp', - 'integration_time.cpp', 'fluid_model_pig.cpp', 'iteration_structure.cpp', 'fluid_model_inc.cpp', @@ -137,6 +135,12 @@ su2_cfd_src += files(['drivers/CDriver.cpp', 'drivers/CDiscAdjSinglezoneDriver.cpp', 'drivers/CDummyDriver.cpp']) +su2_cfd_src += files(['integration/CIntegration.cpp', + 'integration/CSingleGridIntegration.cpp', + 'integration/CMultiGridIntegration.cpp', + 'integration/CStructuralIntegration.cpp', + 'integration/CFEM_DG_Integration.cpp']) + if get_option('enable-normal') su2_cfd = executable('SU2_CFD', su2_cfd_src, From 3c01897b232141a7cd39bc0b2b18337ecaf7193d Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Sat, 8 Feb 2020 18:20:53 +0000 Subject: [PATCH 103/118] cleanup integration classes, unused/not implemented, unnecessary virtual, etc. --- .../integration/CFEM_DG_Integration.hpp | 1 + SU2_CFD/include/integration/CIntegration.hpp | 224 ++---------------- .../integration/CMultiGridIntegration.hpp | 123 +++++----- .../integration/CSingleGridIntegration.hpp | 44 ++-- .../integration/CStructuralIntegration.hpp | 28 ++- SU2_CFD/src/integration/CIntegration.cpp | 222 +---------------- .../src/integration/CMultiGridIntegration.cpp | 154 ++++-------- .../integration/CSingleGridIntegration.cpp | 54 +++-- .../integration/CStructuralIntegration.cpp | 196 +++++++++++++-- SU2_CFD/src/iteration_structure.cpp | 2 +- 10 files changed, 387 insertions(+), 661 deletions(-) diff --git a/SU2_CFD/include/integration/CFEM_DG_Integration.hpp b/SU2_CFD/include/integration/CFEM_DG_Integration.hpp index 1194e68bcf66..a54c67d57043 100644 --- a/SU2_CFD/include/integration/CFEM_DG_Integration.hpp +++ b/SU2_CFD/include/integration/CFEM_DG_Integration.hpp @@ -53,6 +53,7 @@ class CFEM_DG_Integration final : public CIntegration { CNumerics ******numerics_container, CConfig **config, unsigned short RunTime_EqSystem, unsigned short iZone, unsigned short iInst) override; +private: /*! * \brief Perform the spatial integration of the numerical system. * \param[in] geometry - Geometrical definition of the problem. diff --git a/SU2_CFD/include/integration/CIntegration.hpp b/SU2_CFD/include/integration/CIntegration.hpp index 47ce1de5183d..123c7fad3122 100644 --- a/SU2_CFD/include/integration/CIntegration.hpp +++ b/SU2_CFD/include/integration/CIntegration.hpp @@ -51,7 +51,7 @@ class CIntegration { Cauchy_Value, /*!< \brief Summed value of the convergence indicator. */ Cauchy_Func; /*!< \brief Current value of the convergence indicator at one iteration. */ unsigned short Cauchy_Counter; /*!< \brief Number of elements of the Cauchy serial. */ - su2double *Cauchy_Serie; /*!< \brief Complete Cauchy serial. */ + vector Cauchy_Serie; /*!< \brief Complete Cauchy serial. */ su2double Old_Func, /*!< \brief Old value of the objective function (the function which is monitored). */ New_Func; /*!< \brief Current value of the objective function (the function which is monitored). */ @@ -60,18 +60,6 @@ class CIntegration { Convergence_FullMG; /*!< \brief To indicate if the Full Multigrid has converged and it is necessary to add a new level. */ su2double InitResidual; /*!< \brief Initial value of the residual to evaluate the convergence level. */ -public: - - /*! - * \brief Constructor of the class. - */ - CIntegration(CConfig *config); - - /*! - * \brief Destructor of the class. - */ - virtual ~CIntegration(void); - /*! * \brief Do the space integration of the numerical system. * \param[in] geometry - Geometrical definition of the problem. @@ -82,20 +70,9 @@ class CIntegration { * \param[in] iRKStep - Current step of the Runge-Kutta iteration. * \param[in] RunTime_EqSystem - System of equations which is going to be solved. */ - void Space_Integration(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics, CConfig *config, - unsigned short iMesh, unsigned short iRKStep, unsigned short RunTime_EqSystem); - - /*! - * \brief Do the space integration of the numerical system on a FEM framework. - * \author R. Sanchez - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] solver_container - Container vector with all the solutions. - * \param[in] solver - Description of the numerical method. - * \param[in] config - Definition of the particular problem. - * \param[in] RunTime_EqSystem - System of equations which is going to be solved. - */ - void Space_Integration_FEM(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics, CConfig *config, - unsigned short RunTime_EqSystem); + void Space_Integration(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics, + CConfig *config, unsigned short iMesh, unsigned short iRKStep, + unsigned short RunTime_EqSystem); /*! * \brief Do the time integration (explicit or implicit) of the numerical system. @@ -106,41 +83,18 @@ class CIntegration { * \param[in] RunTime_EqSystem - System of equations which is going to be solved. */ void Time_Integration(CGeometry *geometry, CSolver **solver_container, CConfig *config, - unsigned short iRKStep, unsigned short RunTime_EqSystem); - - /*! - * \brief Do the time integration (explicit or implicit) of the numerical system on a FEM framework. - * \author R. Sanchez - * \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] RunTime_EqSystem - System of equations which is going to be solved. - * \param[in] Iteration - Current iteration. - */ - void Time_Integration_FEM(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics, CConfig *config, - unsigned short RunTime_EqSystem); + unsigned short iRKStep, unsigned short RunTime_EqSystem); +public: /*! - * \brief Initialize the adjoint solution using the primal problem. - * \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] RunTime_EqSystem - System of equations which is going to be solved. - * \param[in] Iteration - Current iteration. + * \brief Constructor of the class. */ - void Adjoint_Setup(CGeometry ****geometry, CSolver *****solver_container, CConfig **config, - unsigned short RunTime_EqSystem, unsigned long Iteration, unsigned short iZone); + CIntegration(CConfig *config); /*! - * \brief Average the scalar output in case there is a unsteady solution. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] config - Definition of the particular problem. - * \param[in] Iteration - Current iteration. - * \param[in] monitor - Objective function to be averaged. - * \param[in] iMesh - Index of the mesh. + * \brief Destructor of the class. */ - void Average_Monitoring(CGeometry *geometry, CConfig *config, - unsigned long Iteration, su2double monitor, unsigned short iMesh); + virtual ~CIntegration(void) = default; /*! * \brief Get the value of the convergence. @@ -193,21 +147,13 @@ class CIntegration { */ void SetDualTime_Solver(CGeometry *geometry, CSolver *solver, CConfig *config, unsigned short iMesh); - /*! - * \brief Save the structural solution at different time steps. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] solution - Structural solution. - * \param[in] config - Definition of the particular problem. - */ - void SetStructural_Solver(CGeometry *geometry, CSolver *solver, CConfig *config, unsigned short iMesh); - /*! * \brief Save the structural solution at different time steps. * \param[in] geometry - Geometrical definition of the problem. * \param[in] solver_container - Structural solution. * \param[in] config - Definition of the particular problem. */ - void SetFEM_StructuralSolver(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh); + void SetStructural_Solver(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh); /*! * \brief A virtual member. @@ -221,119 +167,6 @@ class CIntegration { CNumerics ******numerics_container, CConfig **config, unsigned short RunTime_EqSystem, unsigned short iZone, unsigned short iInst) { }; - /*! - * \brief A virtual member. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] solver_container - Container vector with all the solutions. - * \param[in] numerics_container - Description of the numerical method (the way in which the equations are solved). - * \param[in] config - Definition of the particular problem. - * \param[in] iMesh - Index of the mesh in multigrid computations. - * \param[in] mu - Variable for controlling the kind of multigrid algorithm. - * \param[in] RunTime_EqSystem - System of equations which is going to be solved. - */ - virtual void MultiGrid_Cycle(CGeometry ****geometry, CSolver *****solver_container, CNumerics ******numerics_container, - CConfig **config, unsigned short iMesh, unsigned short mu, unsigned short RunTime_EqSystem, - unsigned short iZone, unsigned short iInst) { }; - - /*! - * \brief A virtual member. - * \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] RunTime_EqSystem - System of equations which is going to be solved. - * \param[in] monitor - value of the non-dimensional parameters for monitoring the convergence. - */ - virtual void NonDimensional_Parameters(CGeometry **geometry, CSolver ***solver_container, CNumerics ****numerics_container, - CConfig *config, unsigned short FinestMesh, unsigned short RunTime_EqSystem, - su2double *monitor) { }; - - /*! - * \brief A virtual member. - * \param[out] sol_fine - Pointer to the solution on the fine grid. - * \param[in] geo_fine - Geometrical definition of the fine grid. - * \param[in] config - Definition of the particular problem. - */ - virtual void SetProlongated_Correction(CSolver *sol_fine, CGeometry *geo_fine, CConfig *config, unsigned short iMesh) { } - - /*! - * \brief A virtual member. - * \param[in] RunTime_EqSystem - System of equations which is going to be solved. - * \param[out] sol_fine - Pointer to the solution on the fine grid. - * \param[in] sol_coarse - Pointer to the solution on the coarse grid. - * \param[in] geo_fine - Geometrical definition of the fine grid. - * \param[in] geo_coarse - Geometrical definition of the coarse grid. - * \param[in] config - Definition of the particular problem. - */ - virtual void SetProlongated_Solution(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, - CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config) { }; - - /*! - * \brief A virtual member. - * \param[in] sol_fine - Pointer to the solution on the fine grid. - * \param[out] sol_coarse - Pointer to the solution on the coarse grid. - * \param[in] geo_fine - Geometrical definition of the fine grid. - * \param[in] geo_coarse - Geometrical definition of the coarse grid. - * \param[in] config - Definition of the particular problem. - */ - virtual void SetRestricted_Residual(CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, - CGeometry *geo_coarse, CConfig *config) { }; - - /*! - * \brief A virtual member. - * \param[in] RunTime_EqSystem - System of equations which is going to be solved. - * \param[in] sol_fine - Pointer to the solution on the fine grid. - * \param[out] sol_coarse - Pointer to the solution on the coarse grid. - * \param[in] geo_fine - Geometrical definition of the fine grid. - * \param[in] geo_coarse - Geometrical definition of the coarse grid. - * \param[in] config - Definition of the particular problem. - * \param[in] iMesh - Index of the mesh in multigrid computations. - * \param[in] InclSharedDomain - Include the shared domain in the interpolation. - */ - virtual void SetRestricted_Solution(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config) { } - - /*! - * \brief A virtual member. - * \param[in] RunTime_EqSystem - System of equations which is going to be solved. - * \param[in] sol_fine - Pointer to the solution on the fine grid. - * \param[out] sol_coarse - Pointer to the solution on the coarse grid. - * \param[in] geo_fine - Geometrical definition of the fine grid. - * \param[in] geo_coarse - Geometrical definition of the coarse grid. - * \param[in] config - Definition of the particular problem. - * \param[in] iMesh - Index of the mesh in multigrid computations. - * \param[in] InclSharedDomain - Include the shared domain in the interpolation. - */ - virtual void SetRestricted_EddyVisc(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config) { } - - /*! - * \brief A virtual member. - * \param[in] RunTime_EqSystem - System of equations which is going to be solved. - * \param[in] sol_fine - Pointer to the solution on the fine grid. - * \param[out] sol_coarse - Pointer to the solution on the coarse grid. - * \param[in] geo_fine - Geometrical definition of the fine grid. - * \param[in] geo_coarse - Geometrical definition of the coarse grid. - * \param[in] config - Definition of the particular problem. - */ - virtual void SetRestricted_Gradient(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, - CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config) { }; - - /*! - * \brief A virtual member. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] flow - Flow solution. - */ - virtual void SetResidual_Term(CGeometry *geometry, CSolver *flow) { } - - /*! - * \brief A virtual member. - * \param[in] sol_fine - Pointer to the solution on the fine grid. - * \param[in] sol_coarse - Pointer to the solution on the coarse grid. - * \param[in] geo_fine - Geometrical definition of the fine grid. - * \param[in] geo_coarse - Geometrical definition of the coarse grid. - * \param[in] config - Definition of the particular problem. - */ - virtual void SetForcing_Term(CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, CGeometry *geo_coarse, - CConfig *config, unsigned short iMesh) { }; - /*! * \brief A virtual member. * \param[in] geometry - Geometrical definition of the problem. @@ -342,8 +175,9 @@ class CIntegration { * \param[in] config - Definition of the particular problem. * \param[in] RunTime_EqSystem - System of equations which is going to be solved. */ - virtual void SingleGrid_Iteration(CGeometry ****geometry, CSolver *****solver_container, CNumerics ******numerics_container, - CConfig **config, unsigned short RunTime_EqSystem, unsigned short iZone, unsigned short iInst) { }; + virtual void SingleGrid_Iteration(CGeometry ****geometry, CSolver *****solver_container, + CNumerics ******numerics_container, CConfig **config, + unsigned short RunTime_EqSystem, unsigned short iZone, unsigned short iInst) { }; /*! * \brief A virtual member. @@ -353,32 +187,8 @@ class CIntegration { * \param[in] config - Definition of the particular problem. * \param[in] RunTime_EqSystem - System of equations which is going to be solved. */ - virtual void Structural_Iteration(CGeometry ****geometry, CSolver *****solver_container, CNumerics ******numerics_container, - CConfig **config, unsigned short RunTime_EqSystem, unsigned short iZone, unsigned short iInst) { }; - - /*! - * \brief A virtual member. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] solver_container - Container vector with all the solutions. - * \param[in] numerics_container - Description of the numerical method (the way in which the equations are solved). - * \param[in] config - Definition of the particular problem. - * \param[in] RunTime_EqSystem - System of equations which is going to be solved. - * \param[in] iMesh - Index of the mesh in multigrid computations. - */ - virtual void SetPotential_Solver(CGeometry ****geometry, CSolver *****solver_container, CNumerics ******numerics_container, - CConfig **config, unsigned short RunTime_EqSystem, unsigned short iMesh, unsigned short iZone) { }; - - /*! - * \brief A virtual member. - * \param[in] RunTime_EqSystem - System of equations which is going to be solved. - * \param[in] solution - Container vector with all the solutions on the finest grid. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] val_nSmooth - Number of smoothing iterations. - * \param[in] val_smooth_coeff - Relaxation factor. - * \param[in] config - Definition of the particular problem. - */ - virtual void Smooth_Solution(unsigned short RunTime_EqSystem, CSolver *solver, CGeometry *geometry, - unsigned short val_nSmooth, su2double val_smooth_coeff, CConfig *config) { }; + virtual void Structural_Iteration(CGeometry ****geometry, CSolver *****solver_container, + CNumerics ******numerics_container, CConfig **config, + unsigned short RunTime_EqSystem, unsigned short iZone, unsigned short iInst) { }; }; - diff --git a/SU2_CFD/include/integration/CMultiGridIntegration.hpp b/SU2_CFD/include/integration/CMultiGridIntegration.hpp index 0d8450b0288f..9e8d57b9f416 100644 --- a/SU2_CFD/include/integration/CMultiGridIntegration.hpp +++ b/SU2_CFD/include/integration/CMultiGridIntegration.hpp @@ -49,9 +49,11 @@ class CMultiGridIntegration final : public CIntegration { * \param[in] RunTime_EqSystem - System of equations which is going to be solved. * \param[in] Iteration - Current iteration. */ - void MultiGrid_Iteration(CGeometry ****geometry, CSolver *****solver_container, CNumerics ******numerics_container, - CConfig **config, unsigned short RunTime_EqSystem, unsigned short iZone, unsigned short iInst); + void MultiGrid_Iteration(CGeometry ****geometry, CSolver *****solver_container, + CNumerics ******numerics_container, CConfig **config, + unsigned short RunTime_EqSystem, unsigned short iZone, unsigned short iInst) override; +private: /*! * \brief Perform a Full-Approximation Storage (FAS) Multigrid. * \param[in] geometry - Geometrical definition of the problem. @@ -63,8 +65,48 @@ class CMultiGridIntegration final : public CIntegration { * \param[in] RunTime_EqSystem - System of equations which is going to be solved. * \param[in] Iteration - Current iteration. */ - void MultiGrid_Cycle(CGeometry ****geometry, CSolver *****solver_container, CNumerics ******numerics_container, - CConfig **config, unsigned short iMesh, unsigned short mu, unsigned short RunTime_EqSystem, unsigned short iZone, unsigned short iInst); + void MultiGrid_Cycle(CGeometry ****geometry, CSolver *****solver_container, + CNumerics ******numerics_container, CConfig **config, + unsigned short iMesh, unsigned short mu, unsigned short RunTime_EqSystem, + unsigned short iZone, unsigned short iInst); + + /*! + * \brief Compute the forcing term. + * \param[in] sol_fine - Pointer to the solution on the fine grid. + * \param[in] sol_coarse - Pointer to the solution on the coarse grid. + * \param[in] geo_fine - Geometrical definition of the fine grid. + * \param[in] geo_coarse - Geometrical definition of the coarse grid. + * \param[in] config - Definition of the particular problem. + */ + void SetForcing_Term(CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, + CGeometry *geo_coarse, CConfig *config, unsigned short iMesh); + + /*! + * \brief Add the truncation error to the residual. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] flow - Flow solution. + */ + void SetResidual_Term(CGeometry *geometry, CSolver *flow); + + /*! + * \brief Set the value of the corrected fine grid solution. + * \param[out] sol_fine - Pointer to the solution on the fine grid. + * \param[in] geo_fine - Geometrical definition of the fine grid. + * \param[in] config - Definition of the particular problem. + */ + void SetProlongated_Correction(CSolver *sol_fine, CGeometry *geo_fine, CConfig *config, unsigned short iMesh); + + /*! + * \brief Compute the gradient in coarse grid using the fine grid information. + * \param[in] RunTime_EqSystem - System of equations which is going to be solved. + * \param[in] sol_fine - Pointer to the solution on the fine grid. + * \param[out] sol_coarse - Pointer to the solution on the coarse grid. + * \param[in] geo_fine - Geometrical definition of the fine grid. + * \param[in] geo_coarse - Geometrical definition of the coarse grid. + * \param[in] config - Definition of the particular problem. + */ + void SetRestricted_Gradient(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, + CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config); /*! * \brief Compute the non-dimensional parameters. @@ -89,7 +131,7 @@ class CMultiGridIntegration final : public CIntegration { * \param[in] config - Definition of the particular problem. */ void SetProlongated_Solution(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, - CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config); + CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config); /*! * \brief Compute the fine grid correction from the coarse solution. @@ -99,8 +141,8 @@ class CMultiGridIntegration final : public CIntegration { * \param[in] geo_coarse - Geometrical definition of the coarse grid. * \param[in] config - Definition of the particular problem. */ - void GetProlongated_Correction(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, - CGeometry *geo_coarse, CConfig *config); + void GetProlongated_Correction(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, + CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config); /*! * \brief Do an implicit smoothing of the prolongated correction. @@ -112,39 +154,8 @@ class CMultiGridIntegration final : public CIntegration { * \param[in] config - Definition of the particular problem. */ void SmoothProlongated_Correction(unsigned short RunTime_EqSystem, CSolver *solver, CGeometry *geometry, - unsigned short val_nSmooth, su2double val_smooth_coeff, CConfig *config); - - /*! - * \brief Do an implicit smoothing of the solution. - * \param[in] RunTime_EqSystem - System of equations which is going to be solved. - * \param[in] solution - Container vector with all the solutions on the finest grid. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] val_nSmooth - Number of smoothing iterations. - * \param[in] val_smooth_coeff - Relaxation factor. - * \param[in] config - Definition of the particular problem. - */ - void Smooth_Solution(unsigned short RunTime_EqSystem, CSolver *solver, CGeometry *geometry, unsigned short val_nSmooth, su2double val_smooth_coeff, CConfig *config); - /*! - * \brief Set the value of the corrected fine grid solution. - * \param[out] sol_fine - Pointer to the solution on the fine grid. - * \param[in] geo_fine - Geometrical definition of the fine grid. - * \param[in] config - Definition of the particular problem. - */ - void SetProlongated_Correction(CSolver *sol_fine, CGeometry *geo_fine, CConfig *config, unsigned short iMesh); - - /*! - * \brief Compute truncation error in the coarse grid using the fine grid information. - * \param[in] sol_fine - Pointer to the solution on the fine grid. - * \param[out] sol_coarse - Pointer to the solution on the coarse grid. - * \param[in] geo_fine - Geometrical definition of the fine grid. - * \param[in] geo_coarse - Geometrical definition of the coarse grid. - * \param[in] config - Definition of the particular problem. - */ - void SetRestricted_Residual(CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, - CGeometry *geo_coarse, CConfig *config); - /*! * \brief Restrict solution from fine grid to a coarse grid. * \param[in] RunTime_EqSystem - System of equations which is going to be solved. @@ -156,36 +167,18 @@ class CMultiGridIntegration final : public CIntegration { * \param[in] iMesh - Index of the mesh in multigrid computations. * \param[in] InclSharedDomain - Include the shared domain in the interpolation. */ - void SetRestricted_Solution(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config); + void SetRestricted_Solution(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, + CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config); /*! - * \brief Compute the gradient in coarse grid using the fine grid information. - * \param[in] RunTime_EqSystem - System of equations which is going to be solved. - * \param[in] sol_fine - Pointer to the solution on the fine grid. - * \param[out] sol_coarse - Pointer to the solution on the coarse grid. - * \param[in] geo_fine - Geometrical definition of the fine grid. - * \param[in] geo_coarse - Geometrical definition of the coarse grid. - * \param[in] config - Definition of the particular problem. - */ - void SetRestricted_Gradient(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, - CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config); - - /*! - * \brief Add the truncation error to the residual. + * \brief Initialize the adjoint solution using the primal problem. * \param[in] geometry - Geometrical definition of the problem. - * \param[in] flow - Flow solution. - */ - void SetResidual_Term(CGeometry *geometry, CSolver *flow); - - /*! - * \brief Compute the forcing term. - * \param[in] sol_fine - Pointer to the solution on the fine grid. - * \param[in] sol_coarse - Pointer to the solution on the coarse grid. - * \param[in] geo_fine - Geometrical definition of the fine grid. - * \param[in] geo_coarse - Geometrical definition of the coarse grid. + * \param[in] solver_container - Container vector with all the solutions. * \param[in] config - Definition of the particular problem. + * \param[in] RunTime_EqSystem - System of equations which is going to be solved. + * \param[in] Iteration - Current iteration. */ - void SetForcing_Term(CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, CGeometry *geo_coarse, - CConfig *config, unsigned short iMesh); -}; + void Adjoint_Setup(CGeometry ****geometry, CSolver *****solver_container, CConfig **config, + unsigned short RunTime_EqSystem, unsigned long Iteration, unsigned short iZone); +}; diff --git a/SU2_CFD/include/integration/CSingleGridIntegration.hpp b/SU2_CFD/include/integration/CSingleGridIntegration.hpp index 586b5fc64c5e..614d424b7ee3 100644 --- a/SU2_CFD/include/integration/CSingleGridIntegration.hpp +++ b/SU2_CFD/include/integration/CSingleGridIntegration.hpp @@ -33,24 +33,7 @@ * \author A. Bueno. */ class CSingleGridIntegration final : public CIntegration { -public: - /*! - * \brief Constructor of the class. - * \param[in] config - Definition of the particular problem. - */ - CSingleGridIntegration(CConfig *config); - - /*! - * \brief Do the numerical integration (implicit) of the turbulence solver. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] solver_container - Container vector with all the solutions. - * \param[in] numerics_container - Description of the numerical method (the way in which the equations are solved). - * \param[in] config - Definition of the particular problem. - * \param[in] RunTime_EqSystem - System of equations which is going to be solved. - */ - void SingleGrid_Iteration(CGeometry ****geometry, CSolver *****solver_container, CNumerics ******numerics_container, - CConfig **config, unsigned short RunTime_EqSystem, unsigned short iZone, unsigned short iInst); - +private: /*! * \brief Restrict solution from fine grid to a coarse grid. * \param[in] RunTime_EqSystem - System of equations which is going to be solved. @@ -62,7 +45,8 @@ class CSingleGridIntegration final : public CIntegration { * \param[in] iMesh - Index of the mesh in multigrid computations. * \param[in] InclSharedDomain - Include the shared domain in the interpolation. */ - void SetRestricted_Solution(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config); + void SetRestricted_Solution(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, + CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config); /*! * \brief Restrict solution from fine grid to a coarse grid. @@ -75,6 +59,26 @@ class CSingleGridIntegration final : public CIntegration { * \param[in] iMesh - Index of the mesh in multigrid computations. * \param[in] InclSharedDomain - Include the shared domain in the interpolation. */ - void SetRestricted_EddyVisc(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config); + void SetRestricted_EddyVisc(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, + CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config); + +public: + /*! + * \brief Constructor of the class. + * \param[in] config - Definition of the particular problem. + */ + CSingleGridIntegration(CConfig *config); + + /*! + * \brief Do the numerical integration (implicit) of the turbulence solver. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] solver_container - Container vector with all the solutions. + * \param[in] numerics_container - Description of the numerical method (the way in which the equations are solved). + * \param[in] config - Definition of the particular problem. + * \param[in] RunTime_EqSystem - System of equations which is going to be solved. + */ + void SingleGrid_Iteration(CGeometry ****geometry, CSolver *****solver_container, + CNumerics ******numerics_container, CConfig **config, + unsigned short RunTime_EqSystem, unsigned short iZone, unsigned short iInst) override; }; diff --git a/SU2_CFD/include/integration/CStructuralIntegration.hpp b/SU2_CFD/include/integration/CStructuralIntegration.hpp index 381ffd0f9d15..d83aae75b8e2 100644 --- a/SU2_CFD/include/integration/CStructuralIntegration.hpp +++ b/SU2_CFD/include/integration/CStructuralIntegration.hpp @@ -48,6 +48,30 @@ class CStructuralIntegration final : public CIntegration { * \param[in] config - Definition of the particular problem. * \param[in] RunTime_EqSystem - System of equations which is going to be solved. */ - void Structural_Iteration(CGeometry ****geometry, CSolver *****solver_container, CNumerics ******numerics_container, - CConfig **config, unsigned short RunTime_EqSystem, unsigned short iZone, unsigned short iInst) override; + void Structural_Iteration(CGeometry ****geometry, CSolver *****solver_container, + CNumerics ******numerics_container, CConfig **config, + unsigned short RunTime_EqSystem, unsigned short iZone, unsigned short iInst) override; + +private: + /*! + * \brief Do the space integration of the numerical system on a FEM framework. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] solver_container - Container vector with all the solutions. + * \param[in] solver - Description of the numerical method. + * \param[in] config - Definition of the particular problem. + * \param[in] RunTime_EqSystem - System of equations which is going to be solved. + */ + void Space_Integration_FEM(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics, + CConfig *config, unsigned short RunTime_EqSystem); + + /*! + * \brief Do the time integration (explicit or implicit) of the numerical system on a FEM framework. + * \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] RunTime_EqSystem - System of equations which is going to be solved. + * \param[in] Iteration - Current iteration. + */ + void Time_Integration_FEM(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics, + CConfig *config, unsigned short RunTime_EqSystem); }; diff --git a/SU2_CFD/src/integration/CIntegration.cpp b/SU2_CFD/src/integration/CIntegration.cpp index 95f3b74c4547..399a5e466ec1 100644 --- a/SU2_CFD/src/integration/CIntegration.cpp +++ b/SU2_CFD/src/integration/CIntegration.cpp @@ -40,14 +40,10 @@ CIntegration::CIntegration(CConfig *config) { Convergence = false; Convergence_FSI = false; Convergence_FullMG = false; - Cauchy_Serie = new su2double [config->GetCauchy_Elems()+1]; + Cauchy_Serie.resize(config->GetCauchy_Elems()+1, 0.0); InitResidual = 0.0; } -CIntegration::~CIntegration(void) { - delete [] Cauchy_Serie; -} - void CIntegration::Space_Integration(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics, @@ -171,7 +167,7 @@ void CIntegration::Space_Integration(CGeometry *geometry, solver_container[MainSolver]->BC_Custom(geometry, solver_container, numerics[CONV_BOUND_TERM], numerics[VISC_BOUND_TERM], config, iMarker); break; case CHT_WALL_INTERFACE: - if ((MainSolver == HEAT_SOL) || (MainSolver == FLOW_SOL && ((config->GetKind_Regime() == COMPRESSIBLE) || config->GetEnergy_Equation()))) { + if ((MainSolver == HEAT_SOL) || ((MainSolver == FLOW_SOL) && ((config->GetKind_Regime() == COMPRESSIBLE) || config->GetEnergy_Equation()))) { solver_container[MainSolver]->BC_ConjugateHeat_Interface(geometry, solver_container, numerics[CONV_BOUND_TERM], config, iMarker); } else { @@ -191,125 +187,6 @@ void CIntegration::Space_Integration(CGeometry *geometry, } -void CIntegration::Space_Integration_FEM(CGeometry *geometry, - CSolver **solver_container, - CNumerics **numerics, - CConfig *config, - unsigned short RunTime_EqSystem) { - - bool dynamic = config->GetTime_Domain(); - bool first_iter = (config->GetInnerIter() == 0); - bool linear_analysis = (config->GetGeometricConditions() == SMALL_DEFORMATIONS); - bool nonlinear_analysis = (config->GetGeometricConditions() == LARGE_DEFORMATIONS); - unsigned short IterativeScheme = config->GetKind_SpaceIteScheme_FEA(); - - unsigned short MainSolver = config->GetContainerPosition(RunTime_EqSystem); - CSolver* solver = solver_container[MainSolver]; - - /*--- Initial calculation, different logic for restarted simulations. ---*/ - bool initial_calc = false; - if (config->GetRestart()) - initial_calc = (config->GetTimeIter() == config->GetRestart_Iter()) && first_iter; - else - initial_calc = (config->GetTimeIter() == 0) && first_iter; - - /*--- Mass Matrix computed during preprocessing, see notes therein. ---*/ - - /*--- If the analysis is linear, only a the constitutive term of the stiffness matrix has to be computed. ---*/ - /*--- This is done only once, at the beginning of the calculation. From then on, K is constant. ---*/ - /*--- For correct differentiation of dynamic cases the matrix needs to be computed every time. ---*/ - if (linear_analysis && (dynamic || initial_calc)) - solver->Compute_StiffMatrix(geometry, numerics, config); - - if (nonlinear_analysis) { - - /*--- If the analysis is nonlinear the stress terms also need to be computed. ---*/ - /*--- For full Newton-Raphson the stiffness matrix and the nodal term are updated every time. ---*/ - if (IterativeScheme == NEWTON_RAPHSON) { - solver->Compute_StiffMatrix_NodalStressRes(geometry, numerics, config); - } - - /*--- If the method is modified Newton-Raphson, the stiffness matrix is only computed once at the beginning - * of the time step, then only the Nodal Stress Term has to be computed on each iteration. ---*/ - if (IterativeScheme == MODIFIED_NEWTON_RAPHSON) { - if (first_iter) - solver->Compute_StiffMatrix_NodalStressRes(geometry, numerics, config); - else - solver->Compute_NodalStressRes(geometry, numerics, config); - } - - } - - /*--- Apply the NATURAL BOUNDARY CONDITIONS (loads). ---*/ - /*--- If there are FSI loads, they have to be previously applied at other level involving both zones. ---*/ - - for (unsigned short iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { - switch (config->GetMarker_All_KindBC(iMarker)) { - - /*--- Some external loads are considered constant over the time step ---*/ - - case LOAD_DIR_BOUNDARY: - if (first_iter) - solver->BC_Dir_Load(geometry, numerics[FEA_TERM], config, iMarker); - break; - - case LOAD_SINE_BOUNDARY: - if (first_iter) - solver->BC_Sine_Load(geometry, numerics[FEA_TERM], config, iMarker); - break; - - /*--- Others are not, because they depend on the geometry ---*/ - - case LOAD_BOUNDARY: - solver->BC_Normal_Load(geometry, numerics[FEA_TERM], config, iMarker); - break; - - case DAMPER_BOUNDARY: - solver->BC_Damper(geometry, numerics[FEA_TERM], config, iMarker); - break; - } - } - -} - -void CIntegration::Adjoint_Setup(CGeometry ****geometry, CSolver *****solver_container, CConfig **config, - unsigned short RunTime_EqSystem, unsigned long Iteration, unsigned short iZone) { - - unsigned short iMGLevel; - - if ( ( (RunTime_EqSystem == RUNTIME_ADJFLOW_SYS) && (Iteration == 0) ) ) { - for (iMGLevel = 0; iMGLevel <= config[iZone]->GetnMGLevels(); iMGLevel++) { - - /*--- Set the time step in all the MG levels ---*/ - - solver_container[iZone][INST_0][iMGLevel][FLOW_SOL]->SetTime_Step(geometry[iZone][INST_0][iMGLevel], solver_container[iZone][INST_0][iMGLevel], config[iZone], iMGLevel, Iteration); - - /*--- Set the force coefficients ---*/ - - SU2_OMP_MASTER - { - solver_container[iZone][INST_0][iMGLevel][FLOW_SOL]->SetTotal_CD(solver_container[iZone][INST_0][MESH_0][FLOW_SOL]->GetTotal_CD()); - solver_container[iZone][INST_0][iMGLevel][FLOW_SOL]->SetTotal_CL(solver_container[iZone][INST_0][MESH_0][FLOW_SOL]->GetTotal_CL()); - solver_container[iZone][INST_0][iMGLevel][FLOW_SOL]->SetTotal_CT(solver_container[iZone][INST_0][MESH_0][FLOW_SOL]->GetTotal_CT()); - solver_container[iZone][INST_0][iMGLevel][FLOW_SOL]->SetTotal_CQ(solver_container[iZone][INST_0][MESH_0][FLOW_SOL]->GetTotal_CQ()); - } - SU2_OMP_BARRIER - - /*--- Restrict solution and gradients to the coarse levels ---*/ - - 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]); -// 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]); - } - - } - } - -} - void CIntegration::Time_Integration(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iRKStep, unsigned short RunTime_EqSystem) { unsigned short MainSolver = config->GetContainerPosition(RunTime_EqSystem); @@ -356,78 +233,6 @@ void CIntegration::Time_Integration(CGeometry *geometry, CSolver **solver_contai } -void CIntegration::Time_Integration_FEM(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics, CConfig *config, - unsigned short RunTime_EqSystem) { - - unsigned short iMarker; - - unsigned short MainSolver = config->GetContainerPosition(RunTime_EqSystem); - - /*--- Set the Jacobian according to the different time integration methods ---*/ - - switch (config->GetKind_TimeIntScheme_FEA()) { - case (CD_EXPLICIT): - solver_container[MainSolver]->ImplicitNewmark_Iteration(geometry, solver_container, config); - break; - case (NEWMARK_IMPLICIT): - solver_container[MainSolver]->ImplicitNewmark_Iteration(geometry, solver_container, config); - break; - case (GENERALIZED_ALPHA): - solver_container[MainSolver]->GeneralizedAlpha_Iteration(geometry, solver_container, config); - break; - } - - /*--- Apply ESSENTIAL BOUNDARY CONDITIONS ---*/ - - for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { - switch (config->GetMarker_All_KindBC(iMarker)) { - case CLAMPED_BOUNDARY: - solver_container[MainSolver]->BC_Clamped(geometry, numerics[FEA_TERM], config, iMarker); - break; - case DISP_DIR_BOUNDARY: - solver_container[MainSolver]->BC_DispDir(geometry, numerics[FEA_TERM], config, iMarker); - break; - case DISPLACEMENT_BOUNDARY: - solver_container[MainSolver]->BC_Normal_Displacement(geometry, numerics[CONV_BOUND_TERM], config, iMarker); - break; - } - } - - /*--- Solver linearized system ---*/ - - solver_container[MainSolver]->Solve_System(geometry, config); - - /*--- Update solution ---*/ - - switch (config->GetKind_TimeIntScheme_FEA()) { - case (CD_EXPLICIT): - solver_container[MainSolver]->ImplicitNewmark_Update(geometry, solver_container, config); - break; - case (NEWMARK_IMPLICIT): - solver_container[MainSolver]->ImplicitNewmark_Update(geometry, solver_container, config); - break; - case (GENERALIZED_ALPHA): - solver_container[MainSolver]->GeneralizedAlpha_UpdateDisp(geometry, solver_container, config); - break; - } - - /*--- Reinforce ESSENTIAL BOUNDARY CONDITIONS: avoids accumulation of numerical error ---*/ - - for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { - switch (config->GetMarker_All_KindBC(iMarker)) { - case CLAMPED_BOUNDARY: - solver_container[MainSolver]->BC_Clamped_Post(geometry, numerics[FEA_TERM], config, iMarker); - break; - } - } - - /*--- Perform the MPI communication of the solution ---*/ - - solver_container[MainSolver]->InitiateComms(geometry, config, SOLUTION_FEA); - solver_container[MainSolver]->CompleteComms(geometry, config, SOLUTION_FEA); - -} - void CIntegration::SetDualTime_Solver(CGeometry *geometry, CSolver *solver, CConfig *config, unsigned short iMesh) { @@ -460,6 +265,7 @@ void CIntegration::SetDualTime_Solver(CGeometry *geometry, CSolver *solver, CCon /*--- Store old aeroelastic solutions ---*/ if (config->GetGrid_Movement() && config->GetAeroelastic_Simulation() && (iMesh == MESH_0)) { + config->SetAeroelastic_n1(); config->SetAeroelastic_n(); @@ -528,27 +334,7 @@ void CIntegration::SetDualTime_Solver(CGeometry *geometry, CSolver *solver, CCon } -void CIntegration::SetStructural_Solver(CGeometry *geometry, CSolver *solver, CConfig *config, unsigned short iMesh) { - - 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) { +void CIntegration::SetStructural_Solver(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh) { bool fsi = config->GetFSI_Simulation(); diff --git a/SU2_CFD/src/integration/CMultiGridIntegration.cpp b/SU2_CFD/src/integration/CMultiGridIntegration.cpp index 9b30bb1bbed3..e2f9faab4665 100644 --- a/SU2_CFD/src/integration/CMultiGridIntegration.cpp +++ b/SU2_CFD/src/integration/CMultiGridIntegration.cpp @@ -38,7 +38,6 @@ void CMultiGridIntegration::MultiGrid_Iteration(CGeometry ****geometry, unsigned short RunTime_EqSystem, unsigned short iZone, unsigned short iInst) { - unsigned short FinestMesh; su2double monitor = 1.0; bool FullMG = false; @@ -65,7 +64,7 @@ void CMultiGridIntegration::MultiGrid_Iteration(CGeometry ****geometry, /*--- Full multigrid strategy and start up with fine grid only works with the direct problem ---*/ - FinestMesh = config[iZone]->GetFinestMesh(); + unsigned short FinestMesh = config[iZone]->GetFinestMesh(); if (!config[iZone]->GetRestart() && FullMG && direct && ( Convergence_FullMG && (FinestMesh != MESH_0 ))) { @@ -420,78 +419,6 @@ void CMultiGridIntegration::SmoothProlongated_Correction(unsigned short RunTime_ } -void CMultiGridIntegration::Smooth_Solution(unsigned short RunTime_EqSystem, CSolver *solver, CGeometry *geometry, - unsigned short val_nSmooth, su2double val_smooth_coeff, CConfig *config) { - - /*--- Check if there is work to do. ---*/ - if (val_nSmooth == 0) return; - - const su2double *Solution_Old, *Solution_Sum, *Solution_j; - unsigned short iVar, iSmooth, iMarker, iNeigh; - unsigned long iPoint, jPoint, iVertex; - - const unsigned short nVar = solver->GetnVar(); - - SU2_OMP_FOR_STAT(roundUpDiv(geometry->GetnPoint(), omp_get_num_threads())) - for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { - Solution_Old = solver->GetNodes()->GetSolution(iPoint); - solver->GetNodes()->SetResidual_Old(iPoint,Solution_Old); - } - - /*--- Jacobi iterations ---*/ - - for (iSmooth = 0; iSmooth < val_nSmooth; iSmooth++) { - - /*--- Loop over all mesh points (sum the solutions of direct neighbors). ---*/ - - SU2_OMP_FOR_STAT(roundUpDiv(geometry->GetnPoint(), omp_get_num_threads())) - for (iPoint = 0; iPoint < geometry->GetnPoint(); ++iPoint) { - - solver->GetNodes()->SetResidualSumZero(iPoint); - - for (iNeigh = 0; iNeigh < geometry->node[iPoint]->GetnPoint(); ++iNeigh) { - jPoint = geometry->node[iPoint]->GetPoint(iNeigh); - Solution_j = solver->GetNodes()->GetSolution(jPoint); - solver->GetNodes()->AddResidual_Sum(iPoint, Solution_j); - } - - } - - /*--- Loop over all mesh points (update solutions with the neighbor averages). ---*/ - - SU2_OMP_FOR_STAT(roundUpDiv(geometry->GetnPoint(), omp_get_num_threads())) - for (iPoint = 0; iPoint < geometry->GetnPoint(); ++iPoint) { - - su2double factor = 1.0/(1.0+val_smooth_coeff*su2double(geometry->node[iPoint]->GetnPoint())); - - Solution_Sum = solver->GetNodes()->GetResidual_Sum(iPoint); - Solution_Old = solver->GetNodes()->GetResidual_Old(iPoint); - - for (iVar = 0; iVar < nVar; iVar++) { - su2double Solution = (Solution_Old[iVar] + val_smooth_coeff*Solution_Sum[iVar])*factor; - solver->GetNodes()->SetSolution(iPoint, iVar, Solution); - } - } - - /*--- Copy boundary values ---*/ - - for (iMarker = 0; iMarker < geometry->GetnMarker(); iMarker++) { - if ((config->GetMarker_All_KindBC(iMarker) != INTERNAL_BOUNDARY) && - (config->GetMarker_All_KindBC(iMarker) != PERIODIC_BOUNDARY)) { - - SU2_OMP_FOR_STAT(32) - for (iVertex = 0; iVertex < geometry->GetnVertex(iMarker); iVertex++) { - iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); - Solution_Old = solver->GetNodes()->GetResidual_Old(iPoint); - solver->GetNodes()->SetSolution(iPoint,Solution_Old); - } - } - } - - } - -} - void CMultiGridIntegration::SetProlongated_Correction(CSolver *sol_fine, CGeometry *geo_fine, CConfig *config, unsigned short iMesh) { unsigned long Point_Fine; @@ -524,7 +451,6 @@ void CMultiGridIntegration::SetProlongated_Correction(CSolver *sol_fine, CGeomet } - void CMultiGridIntegration::SetProlongated_Solution(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config) { unsigned long Point_Fine, Point_Coarse; @@ -599,42 +525,6 @@ void CMultiGridIntegration::SetResidual_Term(CGeometry *geometry, CSolver *solve } -void CMultiGridIntegration::SetRestricted_Residual(CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config) { - unsigned long iVertex, Point_Fine, Point_Coarse; - unsigned short iMarker, iVar, iChildren; - su2double *Residual_Fine; - - const unsigned short nVar = sol_coarse->GetnVar(); - - su2double *Residual = new su2double[nVar]; - - for (Point_Coarse = 0; Point_Coarse < geo_coarse->GetnPointDomain(); Point_Coarse++) { - 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++) { - Point_Fine = geo_coarse->node[Point_Coarse]->GetChildren_CV(iChildren); - Residual_Fine = sol_fine->LinSysRes.GetBlock(Point_Fine); - for (iVar = 0; iVar < nVar; iVar++) - Residual[iVar] += Residual_Fine[iVar]; - } - sol_coarse->GetNodes()->AddRes_TruncError(Point_Coarse,Residual); - } - - for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { - if ((config->GetMarker_All_KindBC(iMarker) == HEAT_FLUX ) || - (config->GetMarker_All_KindBC(iMarker) == ISOTHERMAL ) || - (config->GetMarker_All_KindBC(iMarker) == CHT_WALL_INTERFACE )) { - for (iVertex = 0; iVertexnVertex[iMarker]; iVertex++) { - Point_Coarse = geo_coarse->vertex[iMarker][iVertex]->GetNode(); - sol_coarse->GetNodes()->SetVel_ResTruncError_Zero(Point_Coarse); - } - } - } - - delete [] Residual; -} - void CMultiGridIntegration::SetRestricted_Solution(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config) { @@ -764,8 +654,9 @@ void CMultiGridIntegration::SetRestricted_Gradient(unsigned short RunTime_EqSyst } -void CMultiGridIntegration::NonDimensional_Parameters(CGeometry **geometry, CSolver ***solver_container, CNumerics ****numerics_container, - CConfig *config, unsigned short FinestMesh, unsigned short RunTime_EqSystem, +void CMultiGridIntegration::NonDimensional_Parameters(CGeometry **geometry, CSolver ***solver_container, + CNumerics ****numerics_container, CConfig *config, + unsigned short FinestMesh, unsigned short RunTime_EqSystem, su2double *monitor) { SU2_OMP_MASTER switch (RunTime_EqSystem) { @@ -807,3 +698,40 @@ void CMultiGridIntegration::NonDimensional_Parameters(CGeometry **geometry, CSol } +void CMultiGridIntegration::Adjoint_Setup(CGeometry ****geometry, CSolver *****solver_container, CConfig **config, + unsigned short RunTime_EqSystem, unsigned long Iteration, unsigned short iZone) { + + unsigned short iMGLevel; + + if ( ( (RunTime_EqSystem == RUNTIME_ADJFLOW_SYS) && (Iteration == 0) ) ) { + for (iMGLevel = 0; iMGLevel <= config[iZone]->GetnMGLevels(); iMGLevel++) { + + /*--- Set the time step in all the MG levels ---*/ + + solver_container[iZone][INST_0][iMGLevel][FLOW_SOL]->SetTime_Step(geometry[iZone][INST_0][iMGLevel], solver_container[iZone][INST_0][iMGLevel], config[iZone], iMGLevel, Iteration); + + /*--- Set the force coefficients ---*/ + + SU2_OMP_MASTER + { + solver_container[iZone][INST_0][iMGLevel][FLOW_SOL]->SetTotal_CD(solver_container[iZone][INST_0][MESH_0][FLOW_SOL]->GetTotal_CD()); + solver_container[iZone][INST_0][iMGLevel][FLOW_SOL]->SetTotal_CL(solver_container[iZone][INST_0][MESH_0][FLOW_SOL]->GetTotal_CL()); + solver_container[iZone][INST_0][iMGLevel][FLOW_SOL]->SetTotal_CT(solver_container[iZone][INST_0][MESH_0][FLOW_SOL]->GetTotal_CT()); + solver_container[iZone][INST_0][iMGLevel][FLOW_SOL]->SetTotal_CQ(solver_container[iZone][INST_0][MESH_0][FLOW_SOL]->GetTotal_CQ()); + } + SU2_OMP_BARRIER + + /*--- Restrict solution and gradients to the coarse levels ---*/ + + 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]); +// 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]); + } + + } + } + +} diff --git a/SU2_CFD/src/integration/CSingleGridIntegration.cpp b/SU2_CFD/src/integration/CSingleGridIntegration.cpp index e68f2b0cf3b9..c662ca667338 100644 --- a/SU2_CFD/src/integration/CSingleGridIntegration.cpp +++ b/SU2_CFD/src/integration/CSingleGridIntegration.cpp @@ -31,54 +31,76 @@ CSingleGridIntegration::CSingleGridIntegration(CConfig *config) : CIntegration(config) { } void CSingleGridIntegration::SingleGrid_Iteration(CGeometry ****geometry, CSolver *****solver_container, - CNumerics ******numerics_container, CConfig **config, unsigned short RunTime_EqSystem, unsigned short iZone, unsigned short iInst) { - unsigned short iMesh; + CNumerics ******numerics_container, CConfig **config, + unsigned short RunTime_EqSystem, unsigned short iZone, + unsigned short iInst) { unsigned short SolContainer_Position = config[iZone]->GetContainerPosition(RunTime_EqSystem); unsigned short FinestMesh = config[iZone]->GetFinestMesh(); + CGeometry* geometry_fine = geometry[iZone][iInst][FinestMesh]; + CSolver** solvers_fine = solver_container[iZone][iInst][FinestMesh]; + /*--- Preprocessing ---*/ - solver_container[iZone][iInst][FinestMesh][SolContainer_Position]->Preprocessing(geometry[iZone][iInst][FinestMesh], solver_container[iZone][iInst][FinestMesh], config[iZone], FinestMesh, 0, RunTime_EqSystem, false); + solvers_fine[SolContainer_Position]->Preprocessing(geometry_fine, solvers_fine, config[iZone], + FinestMesh, 0, RunTime_EqSystem, false); /*--- Set the old solution ---*/ - solver_container[iZone][iInst][FinestMesh][SolContainer_Position]->Set_OldSolution(geometry[iZone][iInst][FinestMesh]); + solvers_fine[SolContainer_Position]->Set_OldSolution(geometry_fine); /*--- Time step evaluation ---*/ - solver_container[iZone][iInst][FinestMesh][SolContainer_Position]->SetTime_Step(geometry[iZone][iInst][FinestMesh], solver_container[iZone][iInst][FinestMesh], config[iZone], FinestMesh, config[iZone]->GetTimeIter()); + solvers_fine[SolContainer_Position]->SetTime_Step(geometry_fine, solvers_fine, config[iZone], + FinestMesh, config[iZone]->GetTimeIter()); /*--- Space integration ---*/ - Space_Integration(geometry[iZone][iInst][FinestMesh], solver_container[iZone][iInst][FinestMesh], numerics_container[iZone][iInst][FinestMesh][SolContainer_Position], + Space_Integration(geometry_fine, solvers_fine, + numerics_container[iZone][iInst][FinestMesh][SolContainer_Position], config[iZone], FinestMesh, NO_RK_ITER, RunTime_EqSystem); /*--- Time integration ---*/ - Time_Integration(geometry[iZone][iInst][FinestMesh], solver_container[iZone][iInst][FinestMesh], config[iZone], NO_RK_ITER, - RunTime_EqSystem); + Time_Integration(geometry_fine, solvers_fine, config[iZone], NO_RK_ITER, RunTime_EqSystem); /*--- Postprocessing ---*/ - solver_container[iZone][iInst][FinestMesh][SolContainer_Position]->Postprocessing(geometry[iZone][iInst][FinestMesh], solver_container[iZone][iInst][FinestMesh], config[iZone], FinestMesh); + solvers_fine[SolContainer_Position]->Postprocessing(geometry_fine, solvers_fine, config[iZone], FinestMesh); if (RunTime_EqSystem == RUNTIME_HEAT_SYS) { - solver_container[iZone][iInst][FinestMesh][HEAT_SOL]->Heat_Fluxes(geometry[iZone][iInst][FinestMesh], solver_container[iZone][iInst][FinestMesh], config[iZone]); + solvers_fine[HEAT_SOL]->Heat_Fluxes(geometry_fine, solvers_fine, config[iZone]); } /*--- If turbulence model, copy the turbulence variables to the coarse levels ---*/ if (RunTime_EqSystem == RUNTIME_TURB_SYS) { - for (iMesh = FinestMesh; iMesh < config[iZone]->GetnMGLevels(); iMesh++) { - SetRestricted_Solution(RunTime_EqSystem, solver_container[iZone][iInst][iMesh][SolContainer_Position], solver_container[iZone][iInst][iMesh+1][SolContainer_Position], geometry[iZone][iInst][iMesh], geometry[iZone][iInst][iMesh+1], config[iZone]); - SetRestricted_EddyVisc(RunTime_EqSystem, solver_container[iZone][iInst][iMesh][SolContainer_Position], solver_container[iZone][iInst][iMesh+1][SolContainer_Position], geometry[iZone][iInst][iMesh], geometry[iZone][iInst][iMesh+1], config[iZone]); + + for (unsigned short iMesh = FinestMesh; iMesh < config[iZone]->GetnMGLevels(); iMesh++) { + + SetRestricted_Solution(RunTime_EqSystem, + solver_container[iZone][iInst][iMesh][SolContainer_Position], + solver_container[iZone][iInst][iMesh+1][SolContainer_Position], + geometry[iZone][iInst][iMesh], + geometry[iZone][iInst][iMesh+1], + config[iZone]); + + SetRestricted_EddyVisc(RunTime_EqSystem, + solver_container[iZone][iInst][iMesh][SolContainer_Position], + solver_container[iZone][iInst][iMesh+1][SolContainer_Position], + geometry[iZone][iInst][iMesh], + geometry[iZone][iInst][iMesh+1], + config[iZone]); } + } + } -void CSingleGridIntegration::SetRestricted_Solution(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config) { +void CSingleGridIntegration::SetRestricted_Solution(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, + CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config) { unsigned long Point_Fine, Point_Coarse; unsigned short iVar, iChildren; su2double Area_Parent, Area_Children, *Solution_Fine, *Solution; @@ -116,7 +138,8 @@ void CSingleGridIntegration::SetRestricted_Solution(unsigned short RunTime_EqSys } -void CSingleGridIntegration::SetRestricted_EddyVisc(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config) { +void CSingleGridIntegration::SetRestricted_EddyVisc(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, + CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config) { unsigned long iVertex, Point_Fine, Point_Coarse; unsigned short iMarker, iChildren; @@ -161,4 +184,3 @@ void CSingleGridIntegration::SetRestricted_EddyVisc(unsigned short RunTime_EqSys sol_coarse->CompleteComms(geo_coarse, config, SOLUTION_EDDY); } - diff --git a/SU2_CFD/src/integration/CStructuralIntegration.cpp b/SU2_CFD/src/integration/CStructuralIntegration.cpp index fdd8b5055511..64bc7c68c20b 100644 --- a/SU2_CFD/src/integration/CStructuralIntegration.cpp +++ b/SU2_CFD/src/integration/CStructuralIntegration.cpp @@ -31,30 +31,188 @@ CStructuralIntegration::CStructuralIntegration(CConfig *config) : CIntegration(config) { } void CStructuralIntegration::Structural_Iteration(CGeometry ****geometry, CSolver *****solver_container, - CNumerics ******numerics_container, CConfig **config, unsigned short RunTime_EqSystem, unsigned short iZone, unsigned short iInst) { + CNumerics ******numerics_container, CConfig **config, + unsigned short RunTime_EqSystem, unsigned short iZone, + unsigned short iInst) { unsigned short SolContainer_Position = config[iZone]->GetContainerPosition(RunTime_EqSystem); - /*--- Preprocessing ---*/ - - solver_container[iZone][iInst][MESH_0][SolContainer_Position]->Preprocessing(geometry[iZone][iInst][MESH_0], solver_container[iZone][iInst][MESH_0], - config[iZone], numerics_container[iZone][iInst][MESH_0][SolContainer_Position], MESH_0, NO_RK_ITER, RunTime_EqSystem, false); - - - /*--- Space integration ---*/ - - Space_Integration_FEM(geometry[iZone][iInst][MESH_0], solver_container[iZone][iInst][MESH_0], numerics_container[iZone][iInst][MESH_0][SolContainer_Position], - config[iZone], RunTime_EqSystem); - - /*--- Time integration ---*/ + CSolver* solver = solver_container[iZone][iInst][MESH_0][SolContainer_Position]; + + + solver->Preprocessing(geometry[iZone][iInst][MESH_0], + solver_container[iZone][iInst][MESH_0], + config[iZone], + numerics_container[iZone][iInst][MESH_0][SolContainer_Position], + MESH_0, + NO_RK_ITER, + RunTime_EqSystem, + false); + + Space_Integration_FEM(geometry[iZone][iInst][MESH_0], + solver_container[iZone][iInst][MESH_0], + numerics_container[iZone][iInst][MESH_0][SolContainer_Position], + config[iZone], + RunTime_EqSystem); + + Time_Integration_FEM(geometry[iZone][iInst][MESH_0], + solver_container[iZone][iInst][MESH_0], + numerics_container[iZone][iInst][MESH_0][SolContainer_Position], + config[iZone], + RunTime_EqSystem); + + solver->Postprocessing(geometry[iZone][iInst][MESH_0], + solver_container[iZone][iInst][MESH_0], + config[iZone], + numerics_container[iZone][iInst][MESH_0][SolContainer_Position], + MESH_0); +} - Time_Integration_FEM(geometry[iZone][iInst][MESH_0], solver_container[iZone][iInst][MESH_0], numerics_container[iZone][iInst][MESH_0][SolContainer_Position], - config[iZone], RunTime_EqSystem); +void CStructuralIntegration::Space_Integration_FEM(CGeometry *geometry, CSolver **solver_container, + CNumerics **numerics, CConfig *config, + unsigned short RunTime_EqSystem) { + bool dynamic = config->GetTime_Domain(); + bool first_iter = (config->GetInnerIter() == 0); + bool linear_analysis = (config->GetGeometricConditions() == SMALL_DEFORMATIONS); + bool nonlinear_analysis = (config->GetGeometricConditions() == LARGE_DEFORMATIONS); + unsigned short IterativeScheme = config->GetKind_SpaceIteScheme_FEA(); + + unsigned short MainSolver = config->GetContainerPosition(RunTime_EqSystem); + CSolver* solver = solver_container[MainSolver]; + + /*--- Initial calculation, different logic for restarted simulations. ---*/ + bool initial_calc = false; + if (config->GetRestart()) + initial_calc = (config->GetTimeIter() == config->GetRestart_Iter()) && first_iter; + else + initial_calc = (config->GetTimeIter() == 0) && first_iter; + + /*--- Mass Matrix computed during preprocessing, see notes therein. ---*/ + + /*--- If the analysis is linear, only a the constitutive term of the stiffness matrix has to be computed. ---*/ + /*--- This is done only once, at the beginning of the calculation. From then on, K is constant. ---*/ + /*--- For correct differentiation of dynamic cases the matrix needs to be computed every time. ---*/ + if (linear_analysis && (dynamic || initial_calc)) + solver->Compute_StiffMatrix(geometry, numerics, config); + + if (nonlinear_analysis) { + + /*--- If the analysis is nonlinear the stress terms also need to be computed. ---*/ + /*--- For full Newton-Raphson the stiffness matrix and the nodal term are updated every time. ---*/ + if (IterativeScheme == NEWTON_RAPHSON) { + solver->Compute_StiffMatrix_NodalStressRes(geometry, numerics, config); + } + + /*--- If the method is modified Newton-Raphson, the stiffness matrix is only computed once at the beginning + * of the time step, then only the Nodal Stress Term has to be computed on each iteration. ---*/ + if (IterativeScheme == MODIFIED_NEWTON_RAPHSON) { + if (first_iter) + solver->Compute_StiffMatrix_NodalStressRes(geometry, numerics, config); + else + solver->Compute_NodalStressRes(geometry, numerics, config); + } + + } + + /*--- Apply the NATURAL BOUNDARY CONDITIONS (loads). ---*/ + /*--- If there are FSI loads, they have to be previously applied at other level involving both zones. ---*/ + + for (unsigned short iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { + switch (config->GetMarker_All_KindBC(iMarker)) { + + /*--- Some external loads are considered constant over the time step ---*/ + + case LOAD_DIR_BOUNDARY: + if (first_iter) + solver->BC_Dir_Load(geometry, numerics[FEA_TERM], config, iMarker); + break; + + case LOAD_SINE_BOUNDARY: + if (first_iter) + solver->BC_Sine_Load(geometry, numerics[FEA_TERM], config, iMarker); + break; + + /*--- Others are not, because they depend on the geometry ---*/ + + case LOAD_BOUNDARY: + solver->BC_Normal_Load(geometry, numerics[FEA_TERM], config, iMarker); + break; + + case DAMPER_BOUNDARY: + solver->BC_Damper(geometry, numerics[FEA_TERM], config, iMarker); + break; + } + } - /*--- Postprocessing ---*/ +} - solver_container[iZone][iInst][MESH_0][SolContainer_Position]->Postprocessing(geometry[iZone][iInst][MESH_0], solver_container[iZone][iInst][MESH_0], - config[iZone], numerics_container[iZone][iInst][MESH_0][SolContainer_Position], MESH_0); +void CStructuralIntegration::Time_Integration_FEM(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics, + CConfig *config, unsigned short RunTime_EqSystem) { + unsigned short iMarker; + + unsigned short MainSolver = config->GetContainerPosition(RunTime_EqSystem); + + /*--- Set the Jacobian according to the different time integration methods ---*/ + + switch (config->GetKind_TimeIntScheme_FEA()) { + case (CD_EXPLICIT): + solver_container[MainSolver]->ImplicitNewmark_Iteration(geometry, solver_container, config); + break; + case (NEWMARK_IMPLICIT): + solver_container[MainSolver]->ImplicitNewmark_Iteration(geometry, solver_container, config); + break; + case (GENERALIZED_ALPHA): + solver_container[MainSolver]->GeneralizedAlpha_Iteration(geometry, solver_container, config); + break; + } + + /*--- Apply ESSENTIAL BOUNDARY CONDITIONS ---*/ + + for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { + switch (config->GetMarker_All_KindBC(iMarker)) { + case CLAMPED_BOUNDARY: + solver_container[MainSolver]->BC_Clamped(geometry, numerics[FEA_TERM], config, iMarker); + break; + case DISP_DIR_BOUNDARY: + solver_container[MainSolver]->BC_DispDir(geometry, numerics[FEA_TERM], config, iMarker); + break; + case DISPLACEMENT_BOUNDARY: + solver_container[MainSolver]->BC_Normal_Displacement(geometry, numerics[CONV_BOUND_TERM], config, iMarker); + break; + } + } + + /*--- Solver linearized system ---*/ + + solver_container[MainSolver]->Solve_System(geometry, config); + + /*--- Update solution ---*/ + + switch (config->GetKind_TimeIntScheme_FEA()) { + case (CD_EXPLICIT): + solver_container[MainSolver]->ImplicitNewmark_Update(geometry, solver_container, config); + break; + case (NEWMARK_IMPLICIT): + solver_container[MainSolver]->ImplicitNewmark_Update(geometry, solver_container, config); + break; + case (GENERALIZED_ALPHA): + solver_container[MainSolver]->GeneralizedAlpha_UpdateDisp(geometry, solver_container, config); + break; + } + + /*--- Reinforce ESSENTIAL BOUNDARY CONDITIONS: avoids accumulation of numerical error ---*/ + + for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { + switch (config->GetMarker_All_KindBC(iMarker)) { + case CLAMPED_BOUNDARY: + solver_container[MainSolver]->BC_Clamped_Post(geometry, numerics[FEA_TERM], config, iMarker); + break; + } + } + + /*--- Perform the MPI communication of the solution ---*/ + + solver_container[MainSolver]->InitiateComms(geometry, config, SOLUTION_FEA); + solver_container[MainSolver]->CompleteComms(geometry, config, SOLUTION_FEA); } - diff --git a/SU2_CFD/src/iteration_structure.cpp b/SU2_CFD/src/iteration_structure.cpp index 5f5a05c7083f..8fb661344971 100644 --- a/SU2_CFD/src/iteration_structure.cpp +++ b/SU2_CFD/src/iteration_structure.cpp @@ -1630,7 +1630,7 @@ void CFEAIteration::Update(COutput *output, /*----------------- Update structural solver ----------------------*/ if (dynamic) { - integration[val_iZone][val_iInst][FEA_SOL]->SetFEM_StructuralSolver(geometry[val_iZone][val_iInst][MESH_0], solver[val_iZone][val_iInst][MESH_0], config[val_iZone], MESH_0); + integration[val_iZone][val_iInst][FEA_SOL]->SetStructural_Solver(geometry[val_iZone][val_iInst][MESH_0], solver[val_iZone][val_iInst][MESH_0], config[val_iZone], MESH_0); integration[val_iZone][val_iInst][FEA_SOL]->SetConvergence(false); /*--- Verify convergence criteria (based on total time) ---*/ From 0f97d6252299a05aeb8bfa1f3842bf3ad2151394 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Sat, 8 Feb 2020 18:31:05 +0000 Subject: [PATCH 104/118] add worksharing to SingleGridIntegration --- .../src/integration/CMultiGridIntegration.cpp | 43 +++++++++++-------- .../integration/CSingleGridIntegration.cpp | 38 +++++++++++----- 2 files changed, 52 insertions(+), 29 deletions(-) diff --git a/SU2_CFD/src/integration/CMultiGridIntegration.cpp b/SU2_CFD/src/integration/CMultiGridIntegration.cpp index e2f9faab4665..2585dbb5f14f 100644 --- a/SU2_CFD/src/integration/CMultiGridIntegration.cpp +++ b/SU2_CFD/src/integration/CMultiGridIntegration.cpp @@ -701,37 +701,44 @@ void CMultiGridIntegration::NonDimensional_Parameters(CGeometry **geometry, CSol void CMultiGridIntegration::Adjoint_Setup(CGeometry ****geometry, CSolver *****solver_container, CConfig **config, unsigned short RunTime_EqSystem, unsigned long Iteration, unsigned short iZone) { - unsigned short iMGLevel; + if ((RunTime_EqSystem != RUNTIME_ADJFLOW_SYS) || (Iteration != 0)) return; - if ( ( (RunTime_EqSystem == RUNTIME_ADJFLOW_SYS) && (Iteration == 0) ) ) { - for (iMGLevel = 0; iMGLevel <= config[iZone]->GetnMGLevels(); iMGLevel++) { + for (unsigned short iMGLevel = 0; iMGLevel <= config[iZone]->GetnMGLevels(); iMGLevel++) { - /*--- Set the time step in all the MG levels ---*/ + /*--- Set the time step in all the MG levels ---*/ - solver_container[iZone][INST_0][iMGLevel][FLOW_SOL]->SetTime_Step(geometry[iZone][INST_0][iMGLevel], solver_container[iZone][INST_0][iMGLevel], config[iZone], iMGLevel, Iteration); + solver_container[iZone][INST_0][iMGLevel][FLOW_SOL]->SetTime_Step(geometry[iZone][INST_0][iMGLevel], + solver_container[iZone][INST_0][iMGLevel], + config[iZone], iMGLevel, Iteration); - /*--- Set the force coefficients ---*/ + /*--- Set the force coefficients ---*/ - SU2_OMP_MASTER - { + SU2_OMP_MASTER + { solver_container[iZone][INST_0][iMGLevel][FLOW_SOL]->SetTotal_CD(solver_container[iZone][INST_0][MESH_0][FLOW_SOL]->GetTotal_CD()); solver_container[iZone][INST_0][iMGLevel][FLOW_SOL]->SetTotal_CL(solver_container[iZone][INST_0][MESH_0][FLOW_SOL]->GetTotal_CL()); solver_container[iZone][INST_0][iMGLevel][FLOW_SOL]->SetTotal_CT(solver_container[iZone][INST_0][MESH_0][FLOW_SOL]->GetTotal_CT()); solver_container[iZone][INST_0][iMGLevel][FLOW_SOL]->SetTotal_CQ(solver_container[iZone][INST_0][MESH_0][FLOW_SOL]->GetTotal_CQ()); - } - SU2_OMP_BARRIER + } + SU2_OMP_BARRIER - /*--- Restrict solution and gradients to the coarse levels ---*/ + /*--- Restrict solution and gradients to the coarse levels ---*/ - 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]); + 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]); // 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]); - } - +// 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]); } + } } diff --git a/SU2_CFD/src/integration/CSingleGridIntegration.cpp b/SU2_CFD/src/integration/CSingleGridIntegration.cpp index c662ca667338..75585510fb41 100644 --- a/SU2_CFD/src/integration/CSingleGridIntegration.cpp +++ b/SU2_CFD/src/integration/CSingleGridIntegration.cpp @@ -26,6 +26,7 @@ */ #include "../../include/integration/CSingleGridIntegration.hpp" +#include "../../../Common/include/omp_structure.hpp" CSingleGridIntegration::CSingleGridIntegration(CConfig *config) : CIntegration(config) { } @@ -103,15 +104,18 @@ void CSingleGridIntegration::SetRestricted_Solution(unsigned short RunTime_EqSys CGeometry *geo_fine, CGeometry *geo_coarse, CConfig *config) { unsigned long Point_Fine, Point_Coarse; unsigned short iVar, iChildren; - su2double Area_Parent, Area_Children, *Solution_Fine, *Solution; + su2double Area_Parent, Area_Children; + const su2double *Solution_Fine; unsigned short nVar = sol_coarse->GetnVar(); - Solution = new su2double[nVar]; + su2double *Solution = new su2double[nVar]; /*--- Compute coarse solution from fine solution ---*/ + SU2_OMP_FOR_STAT(roundUpDiv(geo_coarse->GetnPointDomain(), omp_get_num_threads())) for (Point_Coarse = 0; Point_Coarse < geo_coarse->GetnPointDomain(); Point_Coarse++) { + Area_Parent = geo_coarse->node[Point_Coarse]->GetVolume(); for (iVar = 0; iVar < nVar; iVar++) Solution[iVar] = 0.0; @@ -129,12 +133,16 @@ void CSingleGridIntegration::SetRestricted_Solution(unsigned short RunTime_EqSys } - /*--- MPI the new interpolated solution ---*/ + delete [] Solution; - sol_coarse->InitiateComms(geo_coarse, config, SOLUTION); - sol_coarse->CompleteComms(geo_coarse, config, SOLUTION); + /*--- MPI the new interpolated solution ---*/ - delete [] Solution; + SU2_OMP_MASTER + { + sol_coarse->InitiateComms(geo_coarse, config, SOLUTION); + sol_coarse->CompleteComms(geo_coarse, config, SOLUTION); + } + SU2_OMP_BARRIER } @@ -147,7 +155,9 @@ void CSingleGridIntegration::SetRestricted_EddyVisc(unsigned short RunTime_EqSys /*--- Compute coarse Eddy Viscosity from fine solution ---*/ + SU2_OMP_FOR_STAT(roundUpDiv(geo_coarse->GetnPointDomain(), omp_get_num_threads())) for (Point_Coarse = 0; Point_Coarse < geo_coarse->GetnPointDomain(); Point_Coarse++) { + Area_Parent = geo_coarse->node[Point_Coarse]->GetVolume(); EddyVisc = 0.0; @@ -168,9 +178,11 @@ void CSingleGridIntegration::SetRestricted_EddyVisc(unsigned short RunTime_EqSys is zero on the surface ---*/ for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { - if ((config->GetMarker_All_KindBC(iMarker) == HEAT_FLUX ) || - (config->GetMarker_All_KindBC(iMarker) == ISOTHERMAL ) || - (config->GetMarker_All_KindBC(iMarker) == CHT_WALL_INTERFACE )) { + if ((config->GetMarker_All_KindBC(iMarker) == HEAT_FLUX) || + (config->GetMarker_All_KindBC(iMarker) == ISOTHERMAL) || + (config->GetMarker_All_KindBC(iMarker) == CHT_WALL_INTERFACE)) { + + SU2_OMP_FOR_STAT(32) for (iVertex = 0; iVertex < geo_coarse->nVertex[iMarker]; iVertex++) { Point_Coarse = geo_coarse->vertex[iMarker][iVertex]->GetNode(); sol_coarse->GetNodes()->SetmuT(Point_Coarse,0.0); @@ -180,7 +192,11 @@ void CSingleGridIntegration::SetRestricted_EddyVisc(unsigned short RunTime_EqSys /*--- MPI the new interpolated solution (this also includes the eddy viscosity) ---*/ - sol_coarse->InitiateComms(geo_coarse, config, SOLUTION_EDDY); - sol_coarse->CompleteComms(geo_coarse, config, SOLUTION_EDDY); + SU2_OMP_MASTER + { + sol_coarse->InitiateComms(geo_coarse, config, SOLUTION_EDDY); + sol_coarse->CompleteComms(geo_coarse, config, SOLUTION_EDDY); + } + SU2_OMP_BARRIER } From 65787ccf7eb833bf77d2a259a84ae6d0e0e543e9 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Sat, 8 Feb 2020 18:36:10 +0000 Subject: [PATCH 105/118] more worksharing in CIntegration --- SU2_CFD/src/integration/CIntegration.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/SU2_CFD/src/integration/CIntegration.cpp b/SU2_CFD/src/integration/CIntegration.cpp index 399a5e466ec1..a52813c17ca2 100644 --- a/SU2_CFD/src/integration/CIntegration.cpp +++ b/SU2_CFD/src/integration/CIntegration.cpp @@ -233,7 +233,6 @@ void CIntegration::Time_Integration(CGeometry *geometry, CSolver **solver_contai } - void CIntegration::SetDualTime_Solver(CGeometry *geometry, CSolver *solver, CConfig *config, unsigned short iMesh) { unsigned long iPoint; @@ -242,6 +241,7 @@ void CIntegration::SetDualTime_Solver(CGeometry *geometry, CSolver *solver, CCon solver->GetNodes()->Set_Solution_time_n(); solver->ResetCFLAdapt(); + SU2_OMP_FOR_STAT(roundUpDiv(geometry->GetnPoint(), omp_get_num_threads())) for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { /*--- Initialize the underrelaxation ---*/ @@ -264,6 +264,7 @@ void CIntegration::SetDualTime_Solver(CGeometry *geometry, CSolver *solver, CCon } /*--- Store old aeroelastic solutions ---*/ + SU2_OMP_MASTER if (config->GetGrid_Movement() && config->GetAeroelastic_Simulation() && (iMesh == MESH_0)) { config->SetAeroelastic_n1(); @@ -331,6 +332,7 @@ void CIntegration::SetDualTime_Solver(CGeometry *geometry, CSolver *solver, CCon } #endif } + SU2_OMP_BARRIER } From 22bbb44154538849d1a9672c776c9404ddb1838f Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Mon, 10 Feb 2020 10:48:26 +0000 Subject: [PATCH 106/118] prepare limiters and gradients to be called in parallel --- .../gradients/computeGradientsGreenGauss.hpp | 150 ++++---- .../computeGradientsLeastSquares.hpp | 358 +++++++++--------- SU2_CFD/include/limiters/CLimiterDetails.hpp | 87 ++--- SU2_CFD/include/limiters/computeLimiters.hpp | 11 +- .../include/limiters/computeLimiters_impl.hpp | 180 ++++----- SU2_CFD/obj/Makefile.am | 1 + SU2_CFD/src/limiters/CLimiterDetails.cpp | 36 ++ SU2_CFD/src/meson.build | 2 + 8 files changed, 431 insertions(+), 394 deletions(-) create mode 100644 SU2_CFD/src/limiters/CLimiterDetails.cpp diff --git a/SU2_CFD/include/gradients/computeGradientsGreenGauss.hpp b/SU2_CFD/include/gradients/computeGradientsGreenGauss.hpp index 73af369c842b..9c86bac6e1f4 100644 --- a/SU2_CFD/include/gradients/computeGradientsGreenGauss.hpp +++ b/SU2_CFD/include/gradients/computeGradientsGreenGauss.hpp @@ -73,117 +73,121 @@ void computeGradientsGreenGauss(CSolver* solver, SU2_OMP_PARALLEL { - /*--- For each (non-halo) volume integrate over its faces (edges). ---*/ - SU2_OMP_FOR_DYN(chunkSize) - for (size_t iPoint = 0; iPoint < nPointDomain; ++iPoint) - { - auto node = geometry.node[iPoint]; + /*--- For each (non-halo) volume integrate over its faces (edges). ---*/ - AD::StartPreacc(); - AD::SetPreaccIn(node->GetVolume()); - AD::SetPreaccIn(node->GetPeriodicVolume()); + SU2_OMP_FOR_DYN(chunkSize) + for (size_t iPoint = 0; iPoint < nPointDomain; ++iPoint) + { + auto node = geometry.node[iPoint]; - for (size_t iVar = varBegin; iVar < varEnd; ++iVar) - AD::SetPreaccIn(field(iPoint,iVar)); + AD::StartPreacc(); + AD::SetPreaccIn(node->GetVolume()); + AD::SetPreaccIn(node->GetPeriodicVolume()); - /*--- Clear the gradient. --*/ + for (size_t iVar = varBegin; iVar < varEnd; ++iVar) + AD::SetPreaccIn(field(iPoint,iVar)); - for (size_t iVar = varBegin; iVar < varEnd; ++iVar) - for (size_t iDim = 0; iDim < nDim; ++iDim) - gradient(iPoint, iVar, iDim) = 0.0; + /*--- Clear the gradient. --*/ - /*--- Handle averaging and division by volume in one constant. ---*/ + for (size_t iVar = varBegin; iVar < varEnd; ++iVar) + for (size_t iDim = 0; iDim < nDim; ++iDim) + gradient(iPoint, iVar, iDim) = 0.0; - su2double halfOnVol = 0.5 / (node->GetVolume()+node->GetPeriodicVolume()); + /*--- Handle averaging and division by volume in one constant. ---*/ - /*--- Add a contribution due to each neighbor. ---*/ + su2double halfOnVol = 0.5 / (node->GetVolume()+node->GetPeriodicVolume()); - for (size_t iNeigh = 0; iNeigh < node->GetnPoint(); ++iNeigh) - { - size_t iEdge = node->GetEdge(iNeigh); - size_t jPoint = node->GetPoint(iNeigh); - - /*--- Determine if edge points inwards or outwards of iPoint. - * If inwards we need to flip the area vector. ---*/ + /*--- Add a contribution due to each neighbor. ---*/ - su2double dir = (iPoint == geometry.edge[iEdge]->GetNode(0))? 1.0 : -1.0; - su2double weight = dir * halfOnVol; + for (size_t iNeigh = 0; iNeigh < node->GetnPoint(); ++iNeigh) + { + size_t iEdge = node->GetEdge(iNeigh); + size_t jPoint = node->GetPoint(iNeigh); - const su2double* area = geometry.edge[iEdge]->GetNormal(); - AD::SetPreaccIn(area, nDim); + /*--- Determine if edge points inwards or outwards of iPoint. + * If inwards we need to flip the area vector. ---*/ - for (size_t iVar = varBegin; iVar < varEnd; ++iVar) - { - AD::SetPreaccIn(field(jPoint,iVar)); + su2double dir = (iPoint == geometry.edge[iEdge]->GetNode(0))? 1.0 : -1.0; + su2double weight = dir * halfOnVol; - su2double flux = weight * (field(iPoint,iVar) + field(jPoint,iVar)); + const su2double* area = geometry.edge[iEdge]->GetNormal(); + AD::SetPreaccIn(area, nDim); - for (size_t iDim = 0; iDim < nDim; ++iDim) - gradient(iPoint, iVar, iDim) += flux * area[iDim]; - } + for (size_t iVar = varBegin; iVar < varEnd; ++iVar) + { + AD::SetPreaccIn(field(jPoint,iVar)); - } + su2double flux = weight * (field(iPoint,iVar) + field(jPoint,iVar)); - for (size_t iVar = varBegin; iVar < varEnd; ++iVar) for (size_t iDim = 0; iDim < nDim; ++iDim) - AD::SetPreaccOut(gradient(iPoint,iVar,iDim)); + gradient(iPoint, iVar, iDim) += flux * area[iDim]; + } - AD::EndPreacc(); } - /*--- Add boundary fluxes. ---*/ + for (size_t iVar = varBegin; iVar < varEnd; ++iVar) + for (size_t iDim = 0; iDim < nDim; ++iDim) + AD::SetPreaccOut(gradient(iPoint,iVar,iDim)); + + AD::EndPreacc(); + } - for (size_t iMarker = 0; iMarker < geometry.GetnMarker(); ++iMarker) + /*--- Add boundary fluxes. ---*/ + + for (size_t iMarker = 0; iMarker < geometry.GetnMarker(); ++iMarker) + { + if ((config.GetMarker_All_KindBC(iMarker) != INTERNAL_BOUNDARY) && + (config.GetMarker_All_KindBC(iMarker) != PERIODIC_BOUNDARY)) { - if ((config.GetMarker_All_KindBC(iMarker) != INTERNAL_BOUNDARY) && - (config.GetMarker_All_KindBC(iMarker) != PERIODIC_BOUNDARY)) - { - /*--- Work is shared in inner loop as two markers - * may try to update the same point. ---*/ + /*--- Work is shared in inner loop as two markers + * may try to update the same point. ---*/ - SU2_OMP_FOR_STAT(OMP_MAX_CHUNK) - for (size_t iVertex = 0; iVertex < geometry.GetnVertex(iMarker); ++iVertex) - { - size_t iPoint = geometry.vertex[iMarker][iVertex]->GetNode(); - auto node = geometry.node[iPoint]; + SU2_OMP_FOR_STAT(32) + for (size_t iVertex = 0; iVertex < geometry.GetnVertex(iMarker); ++iVertex) + { + size_t iPoint = geometry.vertex[iMarker][iVertex]->GetNode(); + auto node = geometry.node[iPoint]; - /*--- Halo points do not need to be considered. ---*/ + /*--- Halo points do not need to be considered. ---*/ - if (!node->GetDomain()) continue; + if (!node->GetDomain()) continue; - su2double volume = node->GetVolume() + node->GetPeriodicVolume(); + su2double volume = node->GetVolume() + node->GetPeriodicVolume(); - const su2double* area = geometry.vertex[iMarker][iVertex]->GetNormal(); + const su2double* area = geometry.vertex[iMarker][iVertex]->GetNormal(); - for (size_t iVar = varBegin; iVar < varEnd; iVar++) - { - su2double flux = field(iPoint,iVar) / volume; + for (size_t iVar = varBegin; iVar < varEnd; iVar++) + { + su2double flux = field(iPoint,iVar) / volume; - for (size_t iDim = 0; iDim < nDim; iDim++) - gradient(iPoint, iVar, iDim) -= flux * area[iDim]; - } + for (size_t iDim = 0; iDim < nDim; iDim++) + gradient(iPoint, iVar, iDim) -= flux * area[iDim]; } } } - - } // end SU2_OMP_PARALLEL + } /*--- If no solver was provided we do not communicate ---*/ - if (solver == nullptr) return; + SU2_OMP_MASTER + if (solver != nullptr) + { + /*--- Account for periodic contributions. ---*/ + + for (size_t iPeriodic = 1; iPeriodic <= config.GetnMarker_Periodic()/2; ++iPeriodic) + { + solver->InitiatePeriodicComms(&geometry, &config, iPeriodic, kindPeriodicComm); + solver->CompletePeriodicComms(&geometry, &config, iPeriodic, kindPeriodicComm); + } - /*--- Account for periodic contributions. ---*/ + /*--- Obtain the gradients at halo points from the MPI ranks that own them. ---*/ - for (size_t iPeriodic = 1; iPeriodic <= config.GetnMarker_Periodic()/2; ++iPeriodic) - { - solver->InitiatePeriodicComms(&geometry, &config, iPeriodic, kindPeriodicComm); - solver->CompletePeriodicComms(&geometry, &config, iPeriodic, kindPeriodicComm); + solver->InitiateComms(&geometry, &config, kindMpiComm); + solver->CompleteComms(&geometry, &config, kindMpiComm); } + SU2_OMP_BARRIER - /*--- Obtain the gradients at halo points from the MPI ranks that own them. ---*/ - - solver->InitiateComms(&geometry, &config, kindMpiComm); - solver->CompleteComms(&geometry, &config, kindMpiComm); + } // end SU2_OMP_PARALLEL } diff --git a/SU2_CFD/include/gradients/computeGradientsLeastSquares.hpp b/SU2_CFD/include/gradients/computeGradientsLeastSquares.hpp index 5db466a82922..55f09c28a058 100644 --- a/SU2_CFD/include/gradients/computeGradientsLeastSquares.hpp +++ b/SU2_CFD/include/gradients/computeGradientsLeastSquares.hpp @@ -74,242 +74,244 @@ void computeGradientsLeastSquares(CSolver* solver, SU2_OMP_PARALLEL { - /*--- First loop over non-halo points of the grid. ---*/ - SU2_OMP_FOR_DYN(chunkSize) - for (size_t iPoint = 0; iPoint < nPointDomain; ++iPoint) - { - auto node = geometry.node[iPoint]; - const su2double* coord_i = node->GetCoord(); + /*--- First loop over non-halo points of the grid. ---*/ - AD::StartPreacc(); - AD::SetPreaccIn(coord_i, nDim); + SU2_OMP_FOR_DYN(chunkSize) + for (size_t iPoint = 0; iPoint < nPointDomain; ++iPoint) + { + auto node = geometry.node[iPoint]; + const su2double* coord_i = node->GetCoord(); - for (size_t iVar = varBegin; iVar < varEnd; ++iVar) - AD::SetPreaccIn(field(iPoint,iVar)); + AD::StartPreacc(); + AD::SetPreaccIn(coord_i, nDim); - /*--- Clear gradient and Rmatrix. ---*/ + for (size_t iVar = varBegin; iVar < varEnd; ++iVar) + AD::SetPreaccIn(field(iPoint,iVar)); - for (size_t iVar = varBegin; iVar < varEnd; ++iVar) - for (size_t iDim = 0; iDim < nDim; ++iDim) - gradient(iPoint, iVar, iDim) = 0.0; + /*--- Clear gradient and Rmatrix. ---*/ + for (size_t iVar = varBegin; iVar < varEnd; ++iVar) for (size_t iDim = 0; iDim < nDim; ++iDim) - for (size_t jDim = 0; jDim < nDim; ++jDim) - Rmatrix(iPoint, iDim, jDim) = 0.0; + gradient(iPoint, iVar, iDim) = 0.0; + for (size_t iDim = 0; iDim < nDim; ++iDim) + for (size_t jDim = 0; jDim < nDim; ++jDim) + Rmatrix(iPoint, iDim, jDim) = 0.0; - for (size_t iNeigh = 0; iNeigh < node->GetnPoint(); ++iNeigh) - { - size_t jPoint = node->GetPoint(iNeigh); - const su2double* coord_j = geometry.node[jPoint]->GetCoord(); - AD::SetPreaccIn(coord_j, nDim); + for (size_t iNeigh = 0; iNeigh < node->GetnPoint(); ++iNeigh) + { + size_t jPoint = node->GetPoint(iNeigh); - /*--- Distance vector from iPoint to jPoint ---*/ + const su2double* coord_j = geometry.node[jPoint]->GetCoord(); + AD::SetPreaccIn(coord_j, nDim); - su2double dist_ij[MAXNDIM] = {0.0}; + /*--- Distance vector from iPoint to jPoint ---*/ - for (size_t iDim = 0; iDim < nDim; ++iDim) - dist_ij[iDim] = coord_j[iDim] - coord_i[iDim]; + su2double dist_ij[MAXNDIM] = {0.0}; - /*--- Compute inverse weight, default 1 (unweighted). ---*/ + for (size_t iDim = 0; iDim < nDim; ++iDim) + dist_ij[iDim] = coord_j[iDim] - coord_i[iDim]; - su2double weight = 1.0; + /*--- Compute inverse weight, default 1 (unweighted). ---*/ - if (weighted) - { - weight = 0.0; - for (size_t iDim = 0; iDim < nDim; ++iDim) - weight += dist_ij[iDim] * dist_ij[iDim]; - } + su2double weight = 1.0; - /*--- Sumations for entries of upper triangular matrix R. ---*/ + if (weighted) + { + weight = 0.0; + for (size_t iDim = 0; iDim < nDim; ++iDim) + weight += dist_ij[iDim] * dist_ij[iDim]; + } - if (weight > 0.0) - { - weight = 1.0 / weight; + /*--- Sumations for entries of upper triangular matrix R. ---*/ - Rmatrix(iPoint,0,0) += dist_ij[0]*dist_ij[0]*weight; - Rmatrix(iPoint,0,1) += dist_ij[0]*dist_ij[1]*weight; - Rmatrix(iPoint,1,1) += dist_ij[1]*dist_ij[1]*weight; + if (weight > 0.0) + { + weight = 1.0 / weight; - if (nDim == 3) - { - Rmatrix(iPoint,0,2) += dist_ij[0]*dist_ij[2]*weight; - Rmatrix(iPoint,1,2) += dist_ij[1]*dist_ij[2]*weight; - Rmatrix(iPoint,2,1) += dist_ij[0]*dist_ij[2]*weight; - Rmatrix(iPoint,2,2) += dist_ij[2]*dist_ij[2]*weight; - } + Rmatrix(iPoint,0,0) += dist_ij[0]*dist_ij[0]*weight; + Rmatrix(iPoint,0,1) += dist_ij[0]*dist_ij[1]*weight; + Rmatrix(iPoint,1,1) += dist_ij[1]*dist_ij[1]*weight; - /*--- Entries of c:= transpose(A)*b ---*/ + if (nDim == 3) + { + Rmatrix(iPoint,0,2) += dist_ij[0]*dist_ij[2]*weight; + Rmatrix(iPoint,1,2) += dist_ij[1]*dist_ij[2]*weight; + Rmatrix(iPoint,2,1) += dist_ij[0]*dist_ij[2]*weight; + Rmatrix(iPoint,2,2) += dist_ij[2]*dist_ij[2]*weight; + } + + /*--- Entries of c:= transpose(A)*b ---*/ - for (size_t iVar = varBegin; iVar < varEnd; ++iVar) - { - AD::SetPreaccIn(field(jPoint,iVar)); + for (size_t iVar = varBegin; iVar < varEnd; ++iVar) + { + AD::SetPreaccIn(field(jPoint,iVar)); - su2double delta_ij = weight * (field(jPoint,iVar) - field(iPoint,iVar)); + su2double delta_ij = weight * (field(jPoint,iVar) - field(iPoint,iVar)); - for (size_t iDim = 0; iDim < nDim; ++iDim) - gradient(iPoint, iVar, iDim) += dist_ij[iDim] * delta_ij; - } + for (size_t iDim = 0; iDim < nDim; ++iDim) + gradient(iPoint, iVar, iDim) += dist_ij[iDim] * delta_ij; } } + } - for (size_t iDim = 0; iDim < nDim; ++iDim) - for (size_t jDim = 0; jDim < nDim; ++jDim) - AD::SetPreaccOut(Rmatrix(iPoint, iDim, jDim)); + for (size_t iDim = 0; iDim < nDim; ++iDim) + for (size_t jDim = 0; jDim < nDim; ++jDim) + AD::SetPreaccOut(Rmatrix(iPoint, iDim, jDim)); - for (size_t iVar = varBegin; iVar < varEnd; ++iVar) - for (size_t iDim = 0; iDim < nDim; ++iDim) - AD::SetPreaccOut(gradient(iPoint, iVar, iDim)); + for (size_t iVar = varBegin; iVar < varEnd; ++iVar) + for (size_t iDim = 0; iDim < nDim; ++iDim) + AD::SetPreaccOut(gradient(iPoint, iVar, iDim)); - AD::EndPreacc(); - } + AD::EndPreacc(); + } - /*--- Correct the gradient values across any periodic boundaries. ---*/ + /*--- Correct the gradient values across any periodic boundaries. ---*/ - if (solver != nullptr) + SU2_OMP_MASTER + if (solver != nullptr) + { + for (size_t iPeriodic = 1; iPeriodic <= config.GetnMarker_Periodic()/2; ++iPeriodic) { - SU2_OMP_MASTER - { - for (size_t iPeriodic = 1; iPeriodic <= config.GetnMarker_Periodic()/2; ++iPeriodic) - { - solver->InitiatePeriodicComms(&geometry, &config, iPeriodic, kindPeriodicComm); - solver->CompletePeriodicComms(&geometry, &config, iPeriodic, kindPeriodicComm); - } - } - SU2_OMP_BARRIER + solver->InitiatePeriodicComms(&geometry, &config, iPeriodic, kindPeriodicComm); + solver->CompletePeriodicComms(&geometry, &config, iPeriodic, kindPeriodicComm); } + } + SU2_OMP_BARRIER - /*--- Second loop over points of the grid to compute final gradient. ---*/ + /*--- Second loop over points of the grid to compute final gradient. ---*/ - SU2_OMP_FOR_DYN(chunkSize) - for (size_t iPoint = 0; iPoint < nPointDomain; ++iPoint) - { - /*--- Entries of upper triangular matrix R. ---*/ - - su2double r11 = Rmatrix(iPoint,0,0); - su2double r12 = Rmatrix(iPoint,0,1); - su2double r22 = Rmatrix(iPoint,1,1); - su2double r13 = 0.0, r23 = 0.0, r23_a = 0.0, r23_b = 0.0, r33 = 0.0; - - AD::StartPreacc(); - AD::SetPreaccIn(r11); - AD::SetPreaccIn(r12); - AD::SetPreaccIn(r22); - - if (r11 >= 0.0) r11 = sqrt(r11); - if (r11 >= 0.0) r12 /= r11; else r12 = 0.0; - su2double tmp = r22-r12*r12; - if (tmp >= 0.0) r22 = sqrt(tmp); else r22 = 0.0; - - if (nDim == 3) { - r13 = Rmatrix(iPoint,0,2); - r23_a = Rmatrix(iPoint,1,2); - r23_b = Rmatrix(iPoint,2,1); - r33 = Rmatrix(iPoint,2,2); - - AD::SetPreaccIn(r13); - AD::SetPreaccIn(r23_a); - AD::SetPreaccIn(r23_b); - AD::SetPreaccIn(r33); - - if (r11 >= 0.0) 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; - } - - tmp = r33 - r23*r23 - r13*r13; - if (tmp >= 0.0) r33 = sqrt(tmp); else r33 = 0.0; + SU2_OMP_FOR_DYN(chunkSize) + for (size_t iPoint = 0; iPoint < nPointDomain; ++iPoint) + { + /*--- Entries of upper triangular matrix R. ---*/ + + su2double r11 = Rmatrix(iPoint,0,0); + su2double r12 = Rmatrix(iPoint,0,1); + su2double r22 = Rmatrix(iPoint,1,1); + su2double r13 = 0.0, r23 = 0.0, r23_a = 0.0, r23_b = 0.0, r33 = 0.0; + + AD::StartPreacc(); + AD::SetPreaccIn(r11); + AD::SetPreaccIn(r12); + AD::SetPreaccIn(r22); + + if (r11 >= 0.0) r11 = sqrt(r11); + if (r11 >= 0.0) r12 /= r11; else r12 = 0.0; + su2double tmp = r22-r12*r12; + if (tmp >= 0.0) r22 = sqrt(tmp); else r22 = 0.0; + + if (nDim == 3) { + r13 = Rmatrix(iPoint,0,2); + r23_a = Rmatrix(iPoint,1,2); + r23_b = Rmatrix(iPoint,2,1); + r33 = Rmatrix(iPoint,2,2); + + AD::SetPreaccIn(r13); + AD::SetPreaccIn(r23_a); + AD::SetPreaccIn(r23_b); + AD::SetPreaccIn(r33); + + if (r11 >= 0.0) 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; } - /*--- Compute determinant ---*/ + tmp = r33 - r23*r23 - r13*r13; + if (tmp >= 0.0) r33 = sqrt(tmp); else r33 = 0.0; + } - su2double detR2 = (r11*r22)*(r11*r22); - if (nDim == 3) detR2 *= r33*r33; + /*--- Compute determinant ---*/ - /*--- Detect singular matrices ---*/ + su2double detR2 = (r11*r22)*(r11*r22); + if (nDim == 3) detR2 *= r33*r33; - bool singular = false; + /*--- Detect singular matrices ---*/ - if (detR2 <= EPS) { - detR2 = 1.0; - singular = true; - } + bool singular = false; - /*--- S matrix := inv(R)*traspose(inv(R)) ---*/ + if (detR2 <= EPS) { + detR2 = 1.0; + singular = true; + } - su2double Smatrix[MAXNDIM][MAXNDIM]; + /*--- S matrix := inv(R)*traspose(inv(R)) ---*/ - if (singular) { - for (size_t iDim = 0; iDim < nDim; ++iDim) - for (size_t jDim = 0; jDim < nDim; ++jDim) - Smatrix[iDim][jDim] = 0.0; - } - else { - if (nDim == 2) { - Smatrix[0][0] = (r12*r12+r22*r22)/detR2; - Smatrix[0][1] = -r11*r12/detR2; - Smatrix[1][0] = Smatrix[0][1]; - Smatrix[1][1] = r11*r11/detR2; - } - else { - su2double z11 = r22*r33; - su2double z12 =-r12*r33; - su2double z13 = r12*r23-r13*r22; - su2double z22 = r11*r33; - su2double z23 =-r11*r23; - su2double z33 = r11*r22; - - Smatrix[0][0] = (z11*z11+z12*z12+z13*z13)/detR2; - Smatrix[0][1] = (z12*z22+z13*z23)/detR2; - Smatrix[0][2] = (z13*z33)/detR2; - Smatrix[1][0] = Smatrix[0][1]; - Smatrix[1][1] = (z22*z22+z23*z23)/detR2; - Smatrix[1][2] = (z23*z33)/detR2; - Smatrix[2][0] = Smatrix[0][2]; - Smatrix[2][1] = Smatrix[1][2]; - Smatrix[2][2] = (z33*z33)/detR2; - } - } + su2double Smatrix[MAXNDIM][MAXNDIM]; + if (singular) { for (size_t iDim = 0; iDim < nDim; ++iDim) for (size_t jDim = 0; jDim < nDim; ++jDim) - AD::SetPreaccOut(Smatrix[iDim][jDim]); + Smatrix[iDim][jDim] = 0.0; + } + else { + if (nDim == 2) { + Smatrix[0][0] = (r12*r12+r22*r22)/detR2; + Smatrix[0][1] = -r11*r12/detR2; + Smatrix[1][0] = Smatrix[0][1]; + Smatrix[1][1] = r11*r11/detR2; + } + else { + su2double z11 = r22*r33; + su2double z12 =-r12*r33; + su2double z13 = r12*r23-r13*r22; + su2double z22 = r11*r33; + su2double z23 =-r11*r23; + su2double z33 = r11*r22; + + Smatrix[0][0] = (z11*z11+z12*z12+z13*z13)/detR2; + Smatrix[0][1] = (z12*z22+z13*z23)/detR2; + Smatrix[0][2] = (z13*z33)/detR2; + Smatrix[1][0] = Smatrix[0][1]; + Smatrix[1][1] = (z22*z22+z23*z23)/detR2; + Smatrix[1][2] = (z23*z33)/detR2; + Smatrix[2][0] = Smatrix[0][2]; + Smatrix[2][1] = Smatrix[1][2]; + Smatrix[2][2] = (z33*z33)/detR2; + } + } - AD::EndPreacc(); + for (size_t iDim = 0; iDim < nDim; ++iDim) + for (size_t jDim = 0; jDim < nDim; ++jDim) + AD::SetPreaccOut(Smatrix[iDim][jDim]); - /*--- Computation of the gradient: S*c ---*/ + AD::EndPreacc(); - for (size_t iVar = varBegin; iVar < varEnd; ++iVar) - { - su2double Cvector[MAXNDIM]; + /*--- Computation of the gradient: S*c ---*/ - for (size_t iDim = 0; iDim < nDim; ++iDim) - { - Cvector[iDim] = 0.0; - for (size_t jDim = 0; jDim < nDim; ++jDim) - Cvector[iDim] += Smatrix[iDim][jDim] * gradient(iPoint, iVar, jDim); - } + for (size_t iVar = varBegin; iVar < varEnd; ++iVar) + { + su2double Cvector[MAXNDIM]; - for (size_t iDim = 0; iDim < nDim; ++iDim) - gradient(iPoint, iVar, iDim) = Cvector[iDim]; + for (size_t iDim = 0; iDim < nDim; ++iDim) + { + Cvector[iDim] = 0.0; + for (size_t jDim = 0; jDim < nDim; ++jDim) + Cvector[iDim] += Smatrix[iDim][jDim] * gradient(iPoint, iVar, jDim); } - } - } // end SU2_OMP_PARALLEL + for (size_t iDim = 0; iDim < nDim; ++iDim) + gradient(iPoint, iVar, iDim) = Cvector[iDim]; + } + } /*--- If no solver was provided we do not communicate ---*/ - if (solver == nullptr) return; + SU2_OMP_MASTER + if (solver != nullptr) + { + /*--- Obtain the gradients at halo points from the MPI ranks that own them. ---*/ - /*--- Obtain the gradients at halo points from the MPI ranks that own them. ---*/ + solver->InitiateComms(&geometry, &config, kindMpiComm); + solver->CompleteComms(&geometry, &config, kindMpiComm); + } + SU2_OMP_BARRIER - solver->InitiateComms(&geometry, &config, kindMpiComm); - solver->CompleteComms(&geometry, &config, kindMpiComm); + } // end SU2_OMP_PARALLEL } diff --git a/SU2_CFD/include/limiters/CLimiterDetails.hpp b/SU2_CFD/include/limiters/CLimiterDetails.hpp index f3ccf6e2972d..99e852eb44aa 100644 --- a/SU2_CFD/include/limiters/CLimiterDetails.hpp +++ b/SU2_CFD/include/limiters/CLimiterDetails.hpp @@ -1,6 +1,6 @@ /*! * \file CLimiterDetails.hpp - * \brief A template class that allows defining limiters via + * \brief A class template that allows defining limiters via * specialization of particular details. * \author P. Gomes * \version 7.0.1 "Blackbird" @@ -155,7 +155,7 @@ struct CLimiterDetails template<> struct CLimiterDetails { - su2activematrix fieldMin, fieldMax; + static su2activevector sharedMin, sharedMax; su2activevector eps2; /*! @@ -165,75 +165,68 @@ struct CLimiterDetails inline void preprocess(CGeometry& geometry, CConfig& config, size_t varBegin, size_t varEnd, const FieldType& field) { - /*--- Determine the max and min global value for each variable. - * Each thread initially works on one row of fieldMin/Max (the - * rows are padded to a multiple of 8 to avoid false sharing), - * then the master thread performs a reduction over all threads - * and mpi ranks onto row 0, the final result. ---*/ + /*--- Determine the max and min global value for each variable. ---*/ - size_t nThread = omp_get_num_threads(); - size_t nCols = roundUpDiv(varEnd,8)*8; + su2double largeNum = 0.1*std::numeric_limits::max(); + + /*--- Allocate the static members (shared between threads) to + * perform the reduction across all threads in the rank. ---*/ SU2_OMP_MASTER { - su2double largeNum = 0.1*std::numeric_limits::max(); - fieldMin.resize(nThread, nCols) = largeNum; - fieldMax.resize(nThread, nCols) =-largeNum; - eps2.resize(nCols); + sharedMin.resize(varEnd) = largeNum; + sharedMax.resize(varEnd) =-largeNum; } SU2_OMP_BARRIER /*--- Per thread reduction. ---*/ - SU2_OMP_FOR_STAT(512) + su2activevector localMin(varEnd), localMax(varEnd); + localMin = largeNum; + localMax =-largeNum; + + SU2_OMP(for schedule(static, 512) nowait) for(size_t iPoint = 0; iPoint < geometry.GetnPointDomain(); ++iPoint) { - size_t iThread = omp_get_thread_num(); - for(size_t iVar = varBegin; iVar < varEnd; ++iVar) { - fieldMin(iThread, iVar) = min(fieldMin(iThread, iVar), field(iPoint, iVar)); - fieldMax(iThread, iVar) = max(fieldMax(iThread, iVar), field(iPoint, iVar)); + localMin(iVar) = min(localMin(iVar), field(iPoint, iVar)); + localMax(iVar) = max(localMax(iVar), field(iPoint, iVar)); } } - SU2_OMP_MASTER - { - /*--- Per rank reduction. ---*/ + /*--- Per rank reduction. ---*/ - for(size_t iThread = 1; iThread < nThread; ++iThread) - { - for(size_t iVar = varBegin; iVar < varEnd; ++iVar) - { - fieldMin(0,iVar) = min(fieldMin(0,iVar), fieldMin(iThread, iVar)); - fieldMax(0,iVar) = max(fieldMax(0,iVar), fieldMax(iThread, iVar)); - } - } - - /*--- Global reduction, (re)using eps2 as the recv buffer. ---*/ - - SU2_MPI::Allreduce(fieldMin[0], eps2.data(), nCols, MPI_DOUBLE, MPI_MIN, MPI_COMM_WORLD); + SU2_OMP_CRITICAL + for(size_t iVar = varBegin; iVar < varEnd; ++iVar) + { + sharedMin(iVar) = min(sharedMin(iVar), localMin(iVar)); + sharedMax(iVar) = max(sharedMax(iVar), localMax(iVar)); + } + SU2_OMP_BARRIER - for(size_t iVar = varBegin; iVar < varEnd; ++iVar) - fieldMin(0,iVar) = eps2(iVar); + /*--- Global reduction. ---*/ - SU2_MPI::Allreduce(fieldMax[0], eps2.data(), nCols, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD); + SU2_OMP_MASTER + { + localMin = sharedMin; + SU2_MPI::Allreduce(localMin.data(), sharedMin.data(), varEnd, MPI_DOUBLE, MPI_MIN, MPI_COMM_WORLD); - for(size_t iVar = varBegin; iVar < varEnd; ++iVar) - fieldMax(0,iVar) = eps2(iVar); + localMax = sharedMax; + SU2_MPI::Allreduce(localMax.data(), sharedMax.data(), varEnd, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD); + } + SU2_OMP_BARRIER - /*--- Compute eps^2 ---*/ + /*--- Compute eps^2 (each thread has its own copy of it). ---*/ - su2double K = config.GetVenkat_LimiterCoeff(); + eps2.resize(varEnd); + su2double K = config.GetVenkat_LimiterCoeff(); - for(size_t iVar = varBegin; iVar < varEnd; ++iVar) - { - su2double range = fieldMax(0,iVar) - fieldMin(0,iVar); - eps2(iVar) = max(pow(K*range, 2), LimiterHelpers::epsilon()); - } + for(size_t iVar = varBegin; iVar < varEnd; ++iVar) + { + su2double range = sharedMax(iVar) - sharedMin(iVar); + eps2(iVar) = max(pow(K*range, 2), LimiterHelpers::epsilon()); } - SU2_OMP_BARRIER - } /*! diff --git a/SU2_CFD/include/limiters/computeLimiters.hpp b/SU2_CFD/include/limiters/computeLimiters.hpp index 2db8361c8fce..36820d1fa292 100644 --- a/SU2_CFD/include/limiters/computeLimiters.hpp +++ b/SU2_CFD/include/limiters/computeLimiters.hpp @@ -58,13 +58,10 @@ computeLimiters_impl(solver, kindMpiComm, \ switch (LimiterKind) { case NO_LIMITER: { - SU2_OMP_PARALLEL - { - SU2_OMP_FOR_STAT(512) - for(size_t iPoint = 0; iPoint < geometry.GetnPoint(); ++iPoint) - for(size_t iVar = varBegin; iVar < varEnd; ++iVar) - limiter(iPoint, iVar) = 1.0; - } + SU2_OMP_FOR_STAT(512) + for(size_t iPoint = 0; iPoint < geometry.GetnPoint(); ++iPoint) + for(size_t iVar = varBegin; iVar < varEnd; ++iVar) + limiter(iPoint, iVar) = 1.0; break; } case BARTH_JESPERSEN: diff --git a/SU2_CFD/include/limiters/computeLimiters_impl.hpp b/SU2_CFD/include/limiters/computeLimiters_impl.hpp index c2f5a1a68e6f..4cdc96aa216e 100644 --- a/SU2_CFD/include/limiters/computeLimiters_impl.hpp +++ b/SU2_CFD/include/limiters/computeLimiters_impl.hpp @@ -1,7 +1,8 @@ /*! * \file computeLimiters_impl.hpp - * \brief Generic and general computation of limiters. - * \note Common methods are derived by defining only small details. + * \brief Generic computation of limiters. + * \note Common methods are derived by defining small details + * via specialization of CLimiterDetails. * \author P. Gomes * \version 7.0.1 "Blackbird" * @@ -28,7 +29,7 @@ /*! - * \brief General limiter computation for methods based on one limiter + * \brief Generic limiter computation for methods based on one limiter * value per point (as opposed to one per edge) and per variable. * \note This implementation can be used to derive most common methods * by specializing the limiter functions (e.g. Venkatakrishnan) @@ -79,8 +80,6 @@ void computeLimiters_impl(CSolver* solver, if (varEnd > MAXNVAR) SU2_MPI::Error("Number of variables is too large, increase MAXNVAR.", CURRENT_FUNCTION); - CLimiterDetails limiterDetails; - size_t nPointDomain = geometry.GetnPointDomain(); size_t nPoint = geometry.GetnPoint(); size_t nDim = geometry.GetnDim(); @@ -113,131 +112,130 @@ void computeLimiters_impl(CSolver* solver, SU2_OMP_PARALLEL { - limiterDetails.preprocess(geometry, config, varBegin, varEnd, field); - /*--- Courtesy barrier in case someone forgets preprocess is parallel. ---*/ - SU2_OMP_BARRIER + CLimiterDetails limiterDetails; - /*--- Initialize all min/max field values if we have - * periodic comms. otherwise do it inside main loop. ---*/ + limiterDetails.preprocess(geometry, config, varBegin, varEnd, field); - if (periodic) - { - SU2_OMP_FOR_STAT(chunkSize) - for (size_t iPoint = 0; iPoint < nPoint; ++iPoint) - for (size_t iVar = varBegin; iVar < varEnd; ++iVar) - fieldMax(iPoint,iVar) = fieldMin(iPoint,iVar) = field(iPoint,iVar); + /*--- Initialize all min/max field values if we have + * periodic comms. otherwise do it inside main loop. ---*/ - SU2_OMP_MASTER + if (periodic) + { + SU2_OMP_FOR_STAT(chunkSize) + for (size_t iPoint = 0; iPoint < nPoint; ++iPoint) + for (size_t iVar = varBegin; iVar < varEnd; ++iVar) + fieldMax(iPoint,iVar) = fieldMin(iPoint,iVar) = field(iPoint,iVar); + + SU2_OMP_MASTER + { + for (size_t iPeriodic = 1; iPeriodic <= config.GetnMarker_Periodic()/2; ++iPeriodic) { - for (size_t iPeriodic = 1; iPeriodic <= config.GetnMarker_Periodic()/2; ++iPeriodic) - { - solver->InitiatePeriodicComms(&geometry, &config, iPeriodic, kindPeriodicComm1); - solver->CompletePeriodicComms(&geometry, &config, iPeriodic, kindPeriodicComm1); - } + solver->InitiatePeriodicComms(&geometry, &config, iPeriodic, kindPeriodicComm1); + solver->CompletePeriodicComms(&geometry, &config, iPeriodic, kindPeriodicComm1); } - SU2_OMP_BARRIER } + SU2_OMP_BARRIER + } - /*--- Compute limiter for each point. ---*/ + /*--- Compute limiter for each point. ---*/ - SU2_OMP_FOR_DYN(chunkSize) - for (size_t iPoint = 0; iPoint < nPointDomain; ++iPoint) - { - auto node = geometry.node[iPoint]; - const su2double* coord_i = node->GetCoord(); + SU2_OMP_FOR_DYN(chunkSize) + for (size_t iPoint = 0; iPoint < nPointDomain; ++iPoint) + { + auto node = geometry.node[iPoint]; + const su2double* coord_i = node->GetCoord(); - AD::StartPreacc(); - AD::SetPreaccIn(coord_i, nDim); + AD::StartPreacc(); + AD::SetPreaccIn(coord_i, nDim); - for (size_t iVar = varBegin; iVar < varEnd; ++iVar) - { - AD::SetPreaccIn(field(iPoint,iVar)); - - if (periodic) { - /*--- Started outside loop, so counts as input. ---*/ - AD::SetPreaccIn(fieldMax(iPoint,iVar)); - AD::SetPreaccIn(fieldMin(iPoint,iVar)); - } - else { - /*--- Initialize min/max now for iPoint if not periodic. ---*/ - fieldMax(iPoint,iVar) = field(iPoint,iVar); - fieldMin(iPoint,iVar) = field(iPoint,iVar); - } + for (size_t iVar = varBegin; iVar < varEnd; ++iVar) + { + AD::SetPreaccIn(field(iPoint,iVar)); - for(size_t iDim = 0; iDim < nDim; ++iDim) - AD::SetPreaccIn(gradient(iPoint,iVar,iDim)); + if (periodic) { + /*--- Started outside loop, so counts as input. ---*/ + AD::SetPreaccIn(fieldMax(iPoint,iVar)); + AD::SetPreaccIn(fieldMin(iPoint,iVar)); } + else { + /*--- Initialize min/max now for iPoint if not periodic. ---*/ + fieldMax(iPoint,iVar) = field(iPoint,iVar); + fieldMin(iPoint,iVar) = field(iPoint,iVar); + } + + for(size_t iDim = 0; iDim < nDim; ++iDim) + AD::SetPreaccIn(gradient(iPoint,iVar,iDim)); + } - /*--- Initialize min/max projection out of iPoint. ---*/ + /*--- Initialize min/max projection out of iPoint. ---*/ - su2double projMax[MAXNVAR], projMin[MAXNVAR]; + su2double projMax[MAXNVAR], projMin[MAXNVAR]; - for (size_t iVar = varBegin; iVar < varEnd; ++iVar) - projMax[iVar] = projMin[iVar] = 0.0; + for (size_t iVar = varBegin; iVar < varEnd; ++iVar) + projMax[iVar] = projMin[iVar] = 0.0; - /*--- Compute max/min projection and values over direct neighbors. ---*/ + /*--- Compute max/min projection and values over direct neighbors. ---*/ - for(size_t iNeigh = 0; iNeigh < node->GetnPoint(); ++iNeigh) - { - size_t jPoint = node->GetPoint(iNeigh); + for(size_t iNeigh = 0; iNeigh < node->GetnPoint(); ++iNeigh) + { + size_t jPoint = node->GetPoint(iNeigh); - const su2double* coord_j = geometry.node[jPoint]->GetCoord(); - AD::SetPreaccIn(coord_j, nDim); + const su2double* coord_j = geometry.node[jPoint]->GetCoord(); + AD::SetPreaccIn(coord_j, nDim); - /*--- Distance vector from iPoint to face (middle of the edge). ---*/ + /*--- Distance vector from iPoint to face (middle of the edge). ---*/ - su2double dist_ij[MAXNDIM] = {0.0}; + su2double dist_ij[MAXNDIM] = {0.0}; - for(size_t iDim = 0; iDim < nDim; ++iDim) - dist_ij[iDim] = 0.5 * (coord_j[iDim] - coord_i[iDim]); + for(size_t iDim = 0; iDim < nDim; ++iDim) + dist_ij[iDim] = 0.5 * (coord_j[iDim] - coord_i[iDim]); - /*--- Project each variable, update min/max. ---*/ + /*--- Project each variable, update min/max. ---*/ - for(size_t iVar = varBegin; iVar < varEnd; ++iVar) - { - su2double proj = 0.0; + for(size_t iVar = varBegin; iVar < varEnd; ++iVar) + { + su2double proj = 0.0; - for(size_t iDim = 0; iDim < nDim; ++iDim) - proj += dist_ij[iDim] * gradient(iPoint,iVar,iDim); + for(size_t iDim = 0; iDim < nDim; ++iDim) + proj += dist_ij[iDim] * gradient(iPoint,iVar,iDim); - projMax[iVar] = max(projMax[iVar], proj); - projMin[iVar] = min(projMin[iVar], proj); + projMax[iVar] = max(projMax[iVar], proj); + projMin[iVar] = min(projMin[iVar], proj); - AD::SetPreaccIn(field(jPoint,iVar)); + AD::SetPreaccIn(field(jPoint,iVar)); - fieldMax(iPoint,iVar) = max(fieldMax(iPoint,iVar), field(jPoint,iVar)); - fieldMin(iPoint,iVar) = min(fieldMin(iPoint,iVar), field(jPoint,iVar)); - } + fieldMax(iPoint,iVar) = max(fieldMax(iPoint,iVar), field(jPoint,iVar)); + fieldMin(iPoint,iVar) = min(fieldMin(iPoint,iVar), field(jPoint,iVar)); } + } - /*--- Compute the geometric factor. ---*/ + /*--- Compute the geometric factor. ---*/ - su2double geoFactor = limiterDetails.geometricFactor(iPoint, geometry); + su2double geoFactor = limiterDetails.geometricFactor(iPoint, geometry); - /*--- Final limiter computation for each variable, get the min limiter - * out of the positive/negative projections and deltas. ---*/ + /*--- Final limiter computation for each variable, get the min limiter + * out of the positive/negative projections and deltas. ---*/ - for(size_t iVar = varBegin; iVar < varEnd; ++iVar) - { - su2double limMax = limiterDetails.limiterFunction(iVar, projMax[iVar], - fieldMax(iPoint,iVar) - field(iPoint,iVar)); + for(size_t iVar = varBegin; iVar < varEnd; ++iVar) + { + su2double limMax = limiterDetails.limiterFunction(iVar, projMax[iVar], + fieldMax(iPoint,iVar) - field(iPoint,iVar)); - su2double limMin = limiterDetails.limiterFunction(iVar, projMin[iVar], - fieldMin(iPoint,iVar) - field(iPoint,iVar)); + su2double limMin = limiterDetails.limiterFunction(iVar, projMin[iVar], + fieldMin(iPoint,iVar) - field(iPoint,iVar)); - limiter(iPoint,iVar) = geoFactor * min(limMax, limMin); + limiter(iPoint,iVar) = geoFactor * min(limMax, limMin); - AD::SetPreaccOut(limiter(iPoint,iVar)); - } - - AD::EndPreacc(); + AD::SetPreaccOut(limiter(iPoint,iVar)); } - } // end SU2_OMP_PARALLEL + AD::EndPreacc(); + } /*--- If no solver was provided we do not communicate. ---*/ + SU2_OMP_MASTER if (solver != nullptr) { /*--- Account for periodic effects, take the minimum limiter on each periodic pair. ---*/ @@ -253,8 +251,12 @@ void computeLimiters_impl(CSolver* solver, solver->InitiateComms(&geometry, &config, kindMpiComm); solver->CompleteComms(&geometry, &config, kindMpiComm); } + SU2_OMP_BARRIER #ifdef CODI_REVERSE_TYPE if (tapeActive) AD::StartRecording(); #endif + + } // end SU2_OMP_PARALLEL + } diff --git a/SU2_CFD/obj/Makefile.am b/SU2_CFD/obj/Makefile.am index 1f7cf5e5e338..4a4199913532 100644 --- a/SU2_CFD/obj/Makefile.am +++ b/SU2_CFD/obj/Makefile.am @@ -147,6 +147,7 @@ libSU2Core_sources = ../src/definition_structure.cpp \ ../src/solvers/CTurbSolver.cpp \ ../src/solvers/CTurbSASolver.cpp \ ../src/solvers/CTurbSSTSolver.cpp \ + ../src/limiters/CLimiterDetails.cpp \ ../src/CMarkerProfileReaderFVM.cpp \ ../src/interfaces/CInterface.cpp \ ../src/interfaces/cfd/CConservativeVarsInterface.cpp \ diff --git a/SU2_CFD/src/limiters/CLimiterDetails.cpp b/SU2_CFD/src/limiters/CLimiterDetails.cpp new file mode 100644 index 000000000000..70d9e9fb01ac --- /dev/null +++ b/SU2_CFD/src/limiters/CLimiterDetails.cpp @@ -0,0 +1,36 @@ +/*! + * \file CLimiterDetails.cpp + * \brief A class template that allows defining limiters via + * specialization of particular details. + * \author P. Gomes + * \version 7.0.1 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../Common/include/geometry/CGeometry.hpp" +#include "../../../Common/include/omp_structure.hpp" +#include "../../include/limiters/CLimiterDetails.hpp" + +/*--- Definition of the static members of the Venkatakrishnan-Wang + * specialization of CLimiterDetails, need to be here due to ODR. ---*/ +su2activevector CLimiterDetails::sharedMin; +su2activevector CLimiterDetails::sharedMax; diff --git a/SU2_CFD/src/meson.build b/SU2_CFD/src/meson.build index 063c179b48f7..69548c7cbb8c 100644 --- a/SU2_CFD/src/meson.build +++ b/SU2_CFD/src/meson.build @@ -141,6 +141,8 @@ su2_cfd_src += files(['integration/CIntegration.cpp', 'integration/CStructuralIntegration.cpp', 'integration/CFEM_DG_Integration.cpp']) +su2_cfd_src += files(['limiters/CLimiterDetails.cpp']) + if get_option('enable-normal') su2_cfd = executable('SU2_CFD', su2_cfd_src, From 252b2d2b08e36ec1d242d397f91c96aa5f28ce30 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Mon, 10 Feb 2020 13:06:15 +0000 Subject: [PATCH 107/118] fix build --- SU2_DEF/src/meson.build | 5 +++-- SU2_DOT/src/meson.build | 6 ++++-- SU2_SOL/src/meson.build | 6 +++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/SU2_DEF/src/meson.build b/SU2_DEF/src/meson.build index 2c0b5d456e38..531b19fb1184 100644 --- a/SU2_DEF/src/meson.build +++ b/SU2_DEF/src/meson.build @@ -5,7 +5,7 @@ if get_option('enable-normal') 'solvers/CBaselineSolver.cpp', 'CMarkerProfileReaderFVM.cpp', 'output/COutput.cpp', - 'output/tools/CWindowingTools.cpp', + 'output/tools/CWindowingTools.cpp', 'output/CMeshOutput.cpp', 'output/output_structure_legacy.cpp', 'variables/CBaselineVariable.cpp', @@ -26,7 +26,8 @@ if get_option('enable-normal') 'output/filewriter/CSU2BinaryFileWriter.cpp', 'output/filewriter/CParaviewXMLFileWriter.cpp', 'output/filewriter/CParaviewVTMFileWriter.cpp', - 'output/filewriter/CSU2MeshFileWriter.cpp']) + 'output/filewriter/CSU2MeshFileWriter.cpp', + 'limiters/CLimiterDetails.cpp']) su2_def = executable('SU2_DEF', su2_def_src, diff --git a/SU2_DOT/src/meson.build b/SU2_DOT/src/meson.build index 083a1c3ed569..d286c0f45b37 100644 --- a/SU2_DOT/src/meson.build +++ b/SU2_DOT/src/meson.build @@ -25,7 +25,8 @@ if get_option('enable-normal') 'output/filewriter/CParaviewXMLFileWriter.cpp', 'output/filewriter/CParaviewVTMFileWriter.cpp', 'variables/CBaselineVariable.cpp', - 'variables/CVariable.cpp']) + 'variables/CVariable.cpp', + 'limiters/CLimiterDetails.cpp']) su2_dot = executable('SU2_DOT', su2_dot_src, @@ -63,7 +64,8 @@ if get_option('enable-autodiff') 'output/filewriter/CParaviewXMLFileWriter.cpp', 'output/filewriter/CParaviewVTMFileWriter.cpp', 'variables/CBaselineVariable.cpp', - 'variables/CVariable.cpp']) + 'variables/CVariable.cpp', + 'limiters/CLimiterDetails.cpp']) su2_dot_ad = executable('SU2_DOT_AD', su2_dot_src_ad, diff --git a/SU2_SOL/src/meson.build b/SU2_SOL/src/meson.build index d43b59837803..c782fb6f2169 100644 --- a/SU2_SOL/src/meson.build +++ b/SU2_SOL/src/meson.build @@ -6,7 +6,7 @@ if get_option('enable-normal') 'CMarkerProfileReaderFVM.cpp', 'output/COutput.cpp', 'output/output_structure_legacy.cpp', - 'output/tools/CWindowingTools.cpp', + 'output/tools/CWindowingTools.cpp', 'output/CBaselineOutput.cpp', 'output/filewriter/CParallelDataSorter.cpp', 'output/filewriter/CParallelFileWriter.cpp', @@ -26,8 +26,8 @@ if get_option('enable-normal') 'output/filewriter/CParaviewXMLFileWriter.cpp', 'output/filewriter/CParaviewVTMFileWriter.cpp', 'variables/CBaselineVariable.cpp', - 'variables/CVariable.cpp']) - + 'variables/CVariable.cpp', + 'limiters/CLimiterDetails.cpp']) su2_sol = executable('SU2_SOL', su2_sol_src, From 2687904b24f44658ec4920124cabd537d81dc309 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Tue, 11 Feb 2020 13:28:15 +0000 Subject: [PATCH 108/118] single parallel section for all preprocessing, reduce number of CSolver virtual functions --- .../gradients/computeGradientsGreenGauss.hpp | 7 - .../computeGradientsLeastSquares.hpp | 7 - .../include/limiters/computeLimiters_impl.hpp | 7 - SU2_CFD/include/solvers/CAdjEulerSolver.hpp | 8 +- SU2_CFD/include/solvers/CEulerSolver.hpp | 180 +++++++++--------- SU2_CFD/include/solvers/CHeatSolverFVM.hpp | 2 +- SU2_CFD/include/solvers/CIncEulerSolver.hpp | 8 +- SU2_CFD/include/solvers/CIncNSSolver.hpp | 2 +- SU2_CFD/include/solvers/CNSSolver.hpp | 39 ++-- SU2_CFD/include/solvers/CSolver.hpp | 96 ---------- SU2_CFD/src/solvers/CEulerSolver.cpp | 99 +++++----- SU2_CFD/src/solvers/CNSSolver.cpp | 135 ++++++++----- 12 files changed, 259 insertions(+), 331 deletions(-) diff --git a/SU2_CFD/include/gradients/computeGradientsGreenGauss.hpp b/SU2_CFD/include/gradients/computeGradientsGreenGauss.hpp index 9c86bac6e1f4..9f1f58990089 100644 --- a/SU2_CFD/include/gradients/computeGradientsGreenGauss.hpp +++ b/SU2_CFD/include/gradients/computeGradientsGreenGauss.hpp @@ -69,11 +69,6 @@ void computeGradientsGreenGauss(CSolver* solver, omp_get_max_threads(), OMP_MAX_CHUNK); #endif - /*--- Start OpenMP parallel section. ---*/ - - SU2_OMP_PARALLEL - { - /*--- For each (non-halo) volume integrate over its faces (edges). ---*/ SU2_OMP_FOR_DYN(chunkSize) @@ -188,6 +183,4 @@ void computeGradientsGreenGauss(CSolver* solver, } SU2_OMP_BARRIER - } // end SU2_OMP_PARALLEL - } diff --git a/SU2_CFD/include/gradients/computeGradientsLeastSquares.hpp b/SU2_CFD/include/gradients/computeGradientsLeastSquares.hpp index 55f09c28a058..d9e6b402bd5e 100644 --- a/SU2_CFD/include/gradients/computeGradientsLeastSquares.hpp +++ b/SU2_CFD/include/gradients/computeGradientsLeastSquares.hpp @@ -70,11 +70,6 @@ void computeGradientsLeastSquares(CSolver* solver, omp_get_max_threads(), OMP_MAX_CHUNK); #endif - /*--- Start OpenMP parallel section. ---*/ - - SU2_OMP_PARALLEL - { - /*--- First loop over non-halo points of the grid. ---*/ SU2_OMP_FOR_DYN(chunkSize) @@ -312,6 +307,4 @@ void computeGradientsLeastSquares(CSolver* solver, } SU2_OMP_BARRIER - } // end SU2_OMP_PARALLEL - } diff --git a/SU2_CFD/include/limiters/computeLimiters_impl.hpp b/SU2_CFD/include/limiters/computeLimiters_impl.hpp index 4cdc96aa216e..fbe5fd061250 100644 --- a/SU2_CFD/include/limiters/computeLimiters_impl.hpp +++ b/SU2_CFD/include/limiters/computeLimiters_impl.hpp @@ -108,11 +108,6 @@ void computeLimiters_impl(CSolver* solver, } #endif - /*--- Start OpenMP parallel section. ---*/ - - SU2_OMP_PARALLEL - { - CLimiterDetails limiterDetails; limiterDetails.preprocess(geometry, config, varBegin, varEnd, field); @@ -257,6 +252,4 @@ void computeLimiters_impl(CSolver* solver, if (tapeActive) AD::StartRecording(); #endif - } // end SU2_OMP_PARALLEL - } diff --git a/SU2_CFD/include/solvers/CAdjEulerSolver.hpp b/SU2_CFD/include/solvers/CAdjEulerSolver.hpp index 5a5d9ecf946c..2da69ba120ce 100644 --- a/SU2_CFD/include/solvers/CAdjEulerSolver.hpp +++ b/SU2_CFD/include/solvers/CAdjEulerSolver.hpp @@ -124,7 +124,7 @@ class CAdjEulerSolver : public CSolver { * \param[in] geometry - Geometrical definition of the problem. * \param[in] config - Definition of the particular problem. */ - void Set_MPI_ActDisk(CSolver **solver_container, CGeometry *geometry, CConfig *config) final; + void Set_MPI_ActDisk(CSolver **solver_container, CGeometry *geometry, CConfig *config); /*! * \brief Created the force projection vector for adjoint boundary conditions. @@ -228,7 +228,7 @@ class CAdjEulerSolver : public CSolver { * \param[in] geometry - Geometrical definition of the problem. * \param[in] config - Definition of the particular problem. */ - void SetUndivided_Laplacian(CGeometry *geometry, CConfig *config) final; + void SetUndivided_Laplacian(CGeometry *geometry, CConfig *config); /*! * \brief Value of the characteristic variables at the boundaries. @@ -291,7 +291,7 @@ class CAdjEulerSolver : public CSolver { * \param[in] solver_container - Container vector with all the solutions. * \param[in] config - Definition of the particular problem. */ - void SetCentered_Dissipation_Sensor(CGeometry *geometry, CConfig *config) final; + void SetCentered_Dissipation_Sensor(CGeometry *geometry, CConfig *config); /*! * \brief Update the AoA and freestream velocity at the farfield. @@ -305,7 +305,7 @@ class CAdjEulerSolver : public CSolver { CSolver **solver_container, CConfig *config, unsigned short iMesh, - bool Output) final; + bool Output); /*! * \brief Impose via the residual the adjoint Euler wall boundary condition. diff --git a/SU2_CFD/include/solvers/CEulerSolver.hpp b/SU2_CFD/include/solvers/CEulerSolver.hpp index 715a19efa74f..eb205a47e329 100644 --- a/SU2_CFD/include/solvers/CEulerSolver.hpp +++ b/SU2_CFD/include/solvers/CEulerSolver.hpp @@ -204,10 +204,12 @@ class CEulerSolver : public CSolver { su2double dCL_dAlpha; /*!< \brief Value of dCL_dAlpha used to control CL in fixed CL mode */ unsigned long BCThrust_Counter; unsigned short nSpanWiseSections; /*!< \brief Number of span-wise sections. */ - unsigned short nSpanMax; /*!< \brief Max number of maximum span-wise sections for all zones */ + unsigned short nSpanMax; /*!< \brief Max number of maximum span-wise sections for all zones. */ unsigned short nMarkerTurboPerf; /*!< \brief Number of turbo performance. */ - vector FluidModel; /*!< \brief fluid model used in the solver */ + vector FluidModel; /*!< \brief fluid model used in the solver. */ + + unsigned long ErrorCounter = 0; /*!< \brief Counter for number of un-physical states. */ /*--- Turbomachinery Solver Variables ---*/ @@ -294,6 +296,94 @@ class CEulerSolver : public CSolver { */ void SumEdgeFluxes(CGeometry* geometry); + /*! + * \brief Update the AoA and freestream velocity at the farfield. + * \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 - current mesh level for the multigrid. + * \param[in] Output - boolean to determine whether to print output. + */ + void SetFarfield_AoA(CGeometry *geometry, CSolver **solver_container, + CConfig *config, unsigned short iMesh, bool Output); + + /*! + * \brief Compute a pressure sensor switch. + * \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 SetCentered_Dissipation_Sensor(CGeometry *geometry, CConfig *config); + + /*! + * \brief Compute Ducros Sensor for Roe Dissipation. + * \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 SetUpwind_Ducros_Sensor(CGeometry *geometry, CConfig *config); + + /*! + * \brief Compute the Fan face Mach number. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] solution - Container vector with all the solutions. + */ + void GetPower_Properties(CGeometry *geometry, CConfig *config, + unsigned short iMesh, bool Output); + + /*! + * \brief Parallelization of Undivided Laplacian. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] config - Definition of the particular problem. + */ + void Set_MPI_ActDisk(CSolver **solver_container, CGeometry *geometry, CConfig *config); + + /*! + * \brief Update the AoA and freestream velocity at the farfield. + * \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 - current mesh level for the multigrid. + * \param[in] Output - boolean to determine whether to print output. + */ + void SetActDisk_BCThrust(CGeometry *geometry, CSolver **solver_container, + CConfig *config, unsigned short iMesh, bool Output); + + /*! + * \brief Compute the max eigenvalue. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] config - Definition of the particular problem. + */ + void SetMax_Eigenvalue(CGeometry *geometry, CConfig *config); + + /*! + * \brief Compute the undivided laplacian for the solution, except the energy equation. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] config - Definition of the particular problem. + */ + void SetUndivided_Laplacian(CGeometry *geometry, CConfig *config); + + /*! + * \brief A virtual member. + * \param[in] geometry - Geometrical definition. + * \param[in] config - Definition of the particular problem. + */ + inline virtual void SetRoe_Dissipation(CGeometry *geometry, CConfig *config) { } + +private: + /*! + * \brief Compute the velocity^2, SoundSpeed, Pressure, Enthalpy, Viscosity. + * \param[in] solver_container - Container vector with all the solutions. + * \param[in] config - Definition of the particular problem. + * \param[in] Output - boolean to determine whether to print output. + * \return - The number of non-physical points. + */ + unsigned long SetPrimitive_Variables(CSolver **solver_container, + CConfig *config, + bool Output); + +protected: + public: /*! @@ -522,33 +612,6 @@ class CEulerSolver : public CSolver { CConfig *config, unsigned short iMesh) final; - /*! - * \brief Compute the velocity^2, SoundSpeed, Pressure, Enthalpy, Viscosity. - * \param[in] solver_container - Container vector with all the solutions. - * \param[in] config - Definition of the particular problem. - * \param[in] Output - boolean to determine whether to print output. - * \return - The number of non-physical points. - */ - unsigned long SetPrimitive_Variables(CSolver **solver_container, - CConfig *config, - bool Output) override; - - /*! - * \brief Compute a pressure sensor switch. - * \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 SetCentered_Dissipation_Sensor(CGeometry *geometry, CConfig *config) final; - - /*! - * \brief Compute Ducros Sensor for Roe Dissipation. - * \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 SetUpwind_Ducros_Sensor(CGeometry *geometry, CConfig *config) final; - /*! * \brief Compute the gradient of the primitive variables using Green-Gauss method, * and stores the result in the Gradient_Primitive variable. @@ -588,27 +651,6 @@ class CEulerSolver : public CSolver { void SetPreconditioner(const CConfig *config, unsigned long iPoint, su2double delta, su2double** preconditioner) const; - /*! - * \brief Compute the undivided laplacian for the solution, except the energy equation. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] config - Definition of the particular problem. - */ - void SetUndivided_Laplacian(CGeometry *geometry, CConfig *config) final; - - /*! - * \brief Compute the max eigenvalue. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] config - Definition of the particular problem. - */ - void SetMax_Eigenvalue(CGeometry *geometry, CConfig *config) final; - - /*! - * \brief Parallelization of Undivided Laplacian. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] config - Definition of the particular problem. - */ - void Set_MPI_ActDisk(CSolver **solver_container, CGeometry *geometry, CConfig *config) final; - /*! * \brief Parallelization of Undivided Laplacian. * \param[in] geometry - Geometrical definition of the problem. @@ -984,44 +1026,6 @@ class CEulerSolver : public CSolver { CConfig *config, unsigned short iRKStep) final; - /*! - * \brief Compute the Fan face Mach number. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] solution - Container vector with all the solutions. - */ - void GetPower_Properties(CGeometry *geometry, - CConfig *config, - unsigned short iMesh, - bool Output) final; - - /*! - * \brief Update the AoA and freestream velocity at the farfield. - * \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 - current mesh level for the multigrid. - * \param[in] Output - boolean to determine whether to print output. - */ - void SetActDisk_BCThrust(CGeometry *geometry, - CSolver **solver_container, - CConfig *config, - unsigned short iMesh, - bool Output) final; - - /*! - * \brief Update the AoA and freestream velocity at the farfield. - * \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 - current mesh level for the multigrid. - * \param[in] Output - boolean to determine whether to print output. - */ - void SetFarfield_AoA(CGeometry *geometry, - CSolver **solver_container, - CConfig *config, - unsigned short iMesh, - bool Output) final; - /*! * \brief Check for convergence of the Fixed CL mode to the target CL * \param[in] config - Definition of the particular problem. diff --git a/SU2_CFD/include/solvers/CHeatSolverFVM.hpp b/SU2_CFD/include/solvers/CHeatSolverFVM.hpp index 53e6e681cc38..ece3275a474e 100644 --- a/SU2_CFD/include/solvers/CHeatSolverFVM.hpp +++ b/SU2_CFD/include/solvers/CHeatSolverFVM.hpp @@ -131,7 +131,7 @@ class CHeatSolverFVM final : public CSolver { * \param[in] geometry - Geometrical definition of the problem. * \param[in] config - Definition of the particular problem. */ - void SetUndivided_Laplacian(CGeometry *geometry, CConfig *config) override; + void SetUndivided_Laplacian(CGeometry *geometry, CConfig *config); /*! * \brief Compute the spatial integration using a centered scheme. diff --git a/SU2_CFD/include/solvers/CIncEulerSolver.hpp b/SU2_CFD/include/solvers/CIncEulerSolver.hpp index e9ef8143eb96..e2228fc5d66c 100644 --- a/SU2_CFD/include/solvers/CIncEulerSolver.hpp +++ b/SU2_CFD/include/solvers/CIncEulerSolver.hpp @@ -420,7 +420,7 @@ class CIncEulerSolver : public CSolver { */ unsigned long SetPrimitive_Variables(CSolver **solver_container, CConfig *config, - bool Output) override; + bool Output); /*! * \brief Compute a pressure sensor switch. @@ -428,7 +428,7 @@ class CIncEulerSolver : public CSolver { * \param[in] solver_container - Container vector with all the solutions. * \param[in] config - Definition of the particular problem. */ - void SetCentered_Dissipation_Sensor(CGeometry *geometry, CConfig *config) final; + void SetCentered_Dissipation_Sensor(CGeometry *geometry, CConfig *config); /*! * \brief Compute the gradient of the primitive variables using Green-Gauss method, @@ -464,14 +464,14 @@ class CIncEulerSolver : public CSolver { * \param[in] geometry - Geometrical definition of the problem. * \param[in] config - Definition of the particular problem. */ - void SetUndivided_Laplacian(CGeometry *geometry, CConfig *config) final; + void SetUndivided_Laplacian(CGeometry *geometry, CConfig *config); /*! * \brief Compute the max eigenvalue. * \param[in] geometry - Geometrical definition of the problem. * \param[in] config - Definition of the particular problem. */ - void SetMax_Eigenvalue(CGeometry *geometry, CConfig *config) final; + void SetMax_Eigenvalue(CGeometry *geometry, CConfig *config); /*! * \author H. Kline diff --git a/SU2_CFD/include/solvers/CIncNSSolver.hpp b/SU2_CFD/include/solvers/CIncNSSolver.hpp index 88f3a82f9d6a..3894ed506d02 100644 --- a/SU2_CFD/include/solvers/CIncNSSolver.hpp +++ b/SU2_CFD/include/solvers/CIncNSSolver.hpp @@ -315,7 +315,7 @@ class CIncNSSolver final : public CIncEulerSolver { */ unsigned long SetPrimitive_Variables(CSolver **solver_container, CConfig *config, - bool Output) override; + bool Output); /*! * \brief Impose a no-slip condition. diff --git a/SU2_CFD/include/solvers/CNSSolver.hpp b/SU2_CFD/include/solvers/CNSSolver.hpp index 8d49125a132f..4609fc883759 100644 --- a/SU2_CFD/include/solvers/CNSSolver.hpp +++ b/SU2_CFD/include/solvers/CNSSolver.hpp @@ -61,6 +61,27 @@ class CNSSolver final : public CEulerSolver { StrainMag_Max, Omega_Max; /*!< \brief Maximum Strain Rate magnitude and Omega. */ + /*! + * \brief A virtual member. + * \param[in] geometry - Geometrical definition. + * \param[in] config - Definition of the particular problem. + */ + void SetRoe_Dissipation(CGeometry *geometry, CConfig *config) override; + +private: + /*! + * \brief Compute the velocity^2, SoundSpeed, Pressure, Enthalpy, Viscosity. + * \param[in] solver_container - Container vector with all the solutions. + * \param[in] config - Definition of the particular problem. + * \param[in] Output - boolean to determine whether to print output. + * \return - The number of non-physical points. + */ + unsigned long SetPrimitive_Variables(CSolver **solver_container, + CConfig *config, + bool Output); + +protected: + public: /*! @@ -270,17 +291,6 @@ class CNSSolver final : public CEulerSolver { unsigned short RunTime_EqSystem, bool Output) override; - /*! - * \brief Compute the velocity^2, SoundSpeed, Pressure, Enthalpy, Viscosity. - * \param[in] solver_container - Container vector with all the solutions. - * \param[in] config - Definition of the particular problem. - * \param[in] Output - boolean to determine whether to print output. - * \return - The number of non-physical points. - */ - unsigned long SetPrimitive_Variables(CSolver **solver_container, - CConfig *config, - bool Output) override; - /*! * \brief Compute weighted-sum "combo" objective output * \param[in] config - Definition of the particular problem. @@ -508,13 +518,6 @@ class CNSSolver final : public CEulerSolver { */ inline void SetOmega_Max(su2double val_omega_max) override { Omega_Max = val_omega_max; } - /*! - * \brief A virtual member. - * \param[in] geometry - Geometrical definition. - * \param[in] config - Definition of the particular problem. - */ - void SetRoe_Dissipation(CGeometry *geometry, CConfig *config) override; - /*! * \brief Computes the wall shear stress (Tau_Wall) on the surface using a wall function. * \param[in] geometry - Geometrical definition of the problem. diff --git a/SU2_CFD/include/solvers/CSolver.hpp b/SU2_CFD/include/solvers/CSolver.hpp index b3af35bfee98..18a4ff37be5f 100644 --- a/SU2_CFD/include/solvers/CSolver.hpp +++ b/SU2_CFD/include/solvers/CSolver.hpp @@ -820,22 +820,6 @@ class CSolver { unsigned short RunTime_EqSystem, bool Output) { } - /*! - * \brief A virtual member. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] config - Definition of the particular problem. - */ - inline virtual void SetUndivided_Laplacian(CGeometry *geometry, CConfig *config) { } - - /*! - * \brief A virtual member. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] config - Definition of the particular problem. - */ - inline virtual void Set_MPI_ActDisk(CSolver **solver_container, - CGeometry *geometry, - CConfig *config) { } - /*! * \brief A virtual member. * \param[in] geometry - Geometrical definition of the problem. @@ -843,29 +827,6 @@ class CSolver { */ inline virtual void Set_MPI_Nearfield(CGeometry *geometry, CConfig *config) { } - /*! - * \brief A virtual member. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] config - Definition of the particular problem. - */ - inline virtual void SetMax_Eigenvalue(CGeometry *geometry, CConfig *config) { } - - /*! - * \brief A virtual member. - * \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. - */ - inline virtual void SetCentered_Dissipation_Sensor(CGeometry *geometry, CConfig *config) { } - - /*! - * \brief A virtual member. - * \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. - */ - inline virtual void SetUpwind_Ducros_Sensor(CGeometry *geometry, CConfig *config) { } - /*! * \brief A virtual member. * \param[in] geometry - Geometrical definition of the problem. @@ -2264,18 +2225,6 @@ class CSolver { */ inline virtual su2double GetInflow_MassFlow(unsigned short val_marker) const { return 0; } - /*! - * \brief A virtual member. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] config - Definition of the particular problem. - * \param[in] iMesh - current mesh level for the multigrid. - * \param[in] Output - boolean to determine whether to print output. - */ - inline virtual void GetPower_Properties(CGeometry *geometry, - CConfig *config, - unsigned short iMesh, - bool Output) { } - /*! * \brief A virtual member. * \param[in] geometry - Geometrical definition of the problem. @@ -2288,20 +2237,6 @@ class CSolver { unsigned short iMesh, bool Output) { } - /*! - * \brief A virtual member. - * \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 - current mesh level for the multigrid. - * \param[in] Output - boolean to determine whether to print output. - */ - inline virtual void SetFarfield_AoA(CGeometry *geometry, - CSolver **solver_container, - CConfig *config, - unsigned short iMesh, - bool Output) { } - /*! * \brief A virtual member. * \param[in] config - Definition of the particular problem. @@ -2340,20 +2275,6 @@ class CSolver { */ inline virtual su2double GetAoA_inc(void) const { return 0.0; } - /*! - * \brief A virtual member. - * \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 - current mesh level for the multigrid. - * \param[in] Output - boolean to determine whether to print output. - */ - inline virtual void SetActDisk_BCThrust(CGeometry *geometry, - CSolver **solver_container, - CConfig *config, - unsigned short iMesh, - bool Output) { } - /*! * \brief A virtual member. * \param[in] val_marker - Surface marker where the coefficient is computed. @@ -4189,16 +4110,6 @@ class CSolver { */ inline virtual su2double GetLoad_Increment() const { return 0; } - /*! - * \brief A virtual member. - * \param[in] solver_container - Container vector with all the solutions. - * \param[in] config - Definition of the particular problem. - * \param[in] Output - boolean to determine whether to print output. - */ - inline virtual unsigned long SetPrimitive_Variables(CSolver **solver_container, - CConfig *config, - bool Output) { return 0; } - /*! * \brief A virtual member. * \param[in] Value of freestream pressure. @@ -4660,13 +4571,6 @@ class CSolver { CConfig *config, unsigned short iMesh) { } - /*! - * \brief A virtual member. - * \param[in] geometry - Geometrical definition. - * \param[in] config - Definition of the particular problem. - */ - inline virtual void SetRoe_Dissipation(CGeometry *geometry, CConfig *config) {} - /*! * \brief A virtual member. * \param[in] solver - Solver container diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 94ba10d1721b..f4e9078a1b54 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -2490,9 +2490,8 @@ void CEulerSolver::SetInitialCondition(CGeometry **geometry, CSolver ***solver_c void CEulerSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh, unsigned short iRKStep, unsigned short RunTime_EqSystem, bool Output) { - /// TODO: Try to start a parallel section here encompassing all "heavy" methods. - - unsigned long ErrorCounter = 0; + SU2_OMP_PARALLEL + { unsigned long InnerIter = config->GetInnerIter(); bool cont_adjoint = config->GetContinuous_Adjoint(); @@ -2515,28 +2514,59 @@ void CEulerSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container /*--- Update the angle of attack at the far-field for fixed CL calculations (only direct problem). ---*/ - if ((fixed_cl) && (!disc_adjoint) && (!cont_adjoint)) { SetFarfield_AoA(geometry, solver_container, config, iMesh, Output); } + if (fixed_cl && !disc_adjoint && !cont_adjoint) { + SU2_OMP_MASTER + SetFarfield_AoA(geometry, solver_container, config, iMesh, Output); + SU2_OMP_BARRIER + } /*--- Set the primitive variables ---*/ - ErrorCounter = SetPrimitive_Variables(solver_container, config, Output); + SU2_OMP_MASTER + ErrorCounter = 0; + SU2_OMP_BARRIER + + SU2_OMP_ATOMIC + ErrorCounter += SetPrimitive_Variables(solver_container, config, Output); + + if ((iMesh == MESH_0) && (config->GetComm_Level() == COMM_FULL)) { + SU2_OMP_BARRIER + SU2_OMP_MASTER + { + unsigned long tmp = ErrorCounter; + SU2_MPI::Allreduce(&tmp, &ErrorCounter, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); + config->SetNonphysical_Points(ErrorCounter); + } + SU2_OMP_BARRIER + } /*--- Compute the engine properties ---*/ - if (engine) { GetPower_Properties(geometry, config, iMesh, Output); } + if (engine) { + SU2_OMP_MASTER + GetPower_Properties(geometry, config, iMesh, Output); + SU2_OMP_BARRIER + } /*--- Compute the actuator disk properties and distortion levels ---*/ if (actuator_disk) { - Set_MPI_ActDisk(solver_container, geometry, config); - GetPower_Properties(geometry, config, iMesh, Output); - SetActDisk_BCThrust(geometry, solver_container, config, iMesh, Output); + SU2_OMP_MASTER + { + Set_MPI_ActDisk(solver_container, geometry, config); + GetPower_Properties(geometry, config, iMesh, Output); + SetActDisk_BCThrust(geometry, solver_container, config, iMesh, Output); + } + SU2_OMP_BARRIER } /*--- Compute NearField MPI ---*/ - if (nearfield) { Set_MPI_Nearfield(geometry, config); } - + if (nearfield) { + SU2_OMP_MASTER + Set_MPI_Nearfield(geometry, config); + SU2_OMP_BARRIER + } /*--- Upwind second order reconstruction ---*/ @@ -2553,9 +2583,8 @@ void CEulerSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container /*--- Limiter computation ---*/ - if (limiter && (iMesh == MESH_0) - && !Output && !van_albada) { SetPrimitive_Limiter(geometry, config); } - + if (limiter && (iMesh == MESH_0) && !Output && !van_albada) + SetPrimitive_Limiter(geometry, config); } /*--- Artificial dissipation ---*/ @@ -2570,7 +2599,7 @@ void CEulerSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container /*--- Roe Low Dissipation Sensor ---*/ - if (roe_low_dissipation){ + if (roe_low_dissipation) { SetRoe_Dissipation(geometry, config); if (kind_row_dissipation == FD_DUCROS || kind_row_dissipation == NTS_DUCROS){ SetUpwind_Ducros_Sensor(geometry, config); @@ -2581,15 +2610,7 @@ void CEulerSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container if (implicit && !disc_adjoint) Jacobian.SetValZero(); - /*--- Error message ---*/ - - if (config->GetComm_Level() == COMM_FULL) { - if (iMesh == MESH_0) { - unsigned long tmp = ErrorCounter; - SU2_MPI::Allreduce(&tmp, &ErrorCounter, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); - config->SetNonphysical_Points(ErrorCounter); - } - } + } // end SU2_OMP_PARALLEL } @@ -2598,9 +2619,11 @@ void CEulerSolver::Postprocessing(CGeometry *geometry, CSolver **solver_containe unsigned long CEulerSolver::SetPrimitive_Variables(CSolver **solver_container, CConfig *config, bool Output) { + /*--- Number of non-physical points, local to the thread, needs + * further reduction if function is called in parallel ---*/ unsigned long nonPhysicalPoints = 0; - SU2_OMP_PARALLEL_(for schedule(static,omp_chunk_size) reduction(+:nonPhysicalPoints)) + SU2_OMP_FOR_STAT(omp_chunk_size) for (unsigned long iPoint = 0; iPoint < nPoint; iPoint ++) { /*--- Compressible flow, primitive variables nDim+5, (T, vx, vy, vz, P, rho, h, c, lamMu, eddyMu, ThCond, Cp) ---*/ @@ -3540,11 +3563,6 @@ void CEulerSolver::Source_Template(CGeometry *geometry, CSolver **solver_contain void CEulerSolver::SetMax_Eigenvalue(CGeometry *geometry, CConfig *config) { - /*--- Start OpenMP parallel section. ---*/ - - SU2_OMP_PARALLEL - { - /*--- Loop domain points. ---*/ SU2_OMP_FOR_DYN(omp_chunk_size) @@ -3642,16 +3660,12 @@ void CEulerSolver::SetMax_Eigenvalue(CGeometry *geometry, CConfig *config) { InitiateComms(geometry, config, MAX_EIGENVALUE); CompleteComms(geometry, config, MAX_EIGENVALUE); } + SU2_OMP_BARRIER - } // end SU2_OMP_PARALLEL } void CEulerSolver::SetUndivided_Laplacian(CGeometry *geometry, CConfig *config) { - /*--- Start OpenMP parallel section. ---*/ - - SU2_OMP_PARALLEL - { nodes->SetUnd_LaplZero(); /*--- Loop interior edges ---*/ @@ -3723,16 +3737,12 @@ void CEulerSolver::SetUndivided_Laplacian(CGeometry *geometry, CConfig *config) InitiateComms(geometry, config, UNDIVIDED_LAPLACIAN); CompleteComms(geometry, config, UNDIVIDED_LAPLACIAN); } + SU2_OMP_BARRIER - } // end SU2_OMP_PARALLEL } void CEulerSolver::SetCentered_Dissipation_Sensor(CGeometry *geometry, CConfig *config) { - /*--- Start OpenMP parallel section. ---*/ - - SU2_OMP_PARALLEL - { /*--- Reset variables to store the undivided pressure ---*/ SU2_OMP_FOR_STAT(omp_chunk_size) @@ -3809,17 +3819,12 @@ void CEulerSolver::SetCentered_Dissipation_Sensor(CGeometry *geometry, CConfig * InitiateComms(geometry, config, SENSOR); CompleteComms(geometry, config, SENSOR); } + SU2_OMP_BARRIER - } // end SU2_OMP_PARALLEL } void CEulerSolver::SetUpwind_Ducros_Sensor(CGeometry *geometry, CConfig *config){ - /*--- Start OpenMP parallel section. ---*/ - - SU2_OMP_PARALLEL - { - SU2_OMP_FOR_STAT(omp_chunk_size) for (unsigned long iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { @@ -3868,8 +3873,8 @@ void CEulerSolver::SetUpwind_Ducros_Sensor(CGeometry *geometry, CConfig *config) InitiateComms(geometry, config, SENSOR); CompleteComms(geometry, config, SENSOR); } + SU2_OMP_BARRIER - } // end SU2_OMP_PARALLEL } void CEulerSolver::Pressure_Forces(CGeometry *geometry, CConfig *config) { diff --git a/SU2_CFD/src/solvers/CNSSolver.cpp b/SU2_CFD/src/solvers/CNSSolver.cpp index 1c3e89c5cd1d..5b4419930c9c 100644 --- a/SU2_CFD/src/solvers/CNSSolver.cpp +++ b/SU2_CFD/src/solvers/CNSSolver.cpp @@ -168,9 +168,8 @@ CNSSolver::~CNSSolver(void) { void CNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh, unsigned short iRKStep, unsigned short RunTime_EqSystem, bool Output) { - /// TODO: Try to start a parallel section here encompassing all "heavy" methods. - - unsigned long ErrorCounter = 0; + SU2_OMP_PARALLEL + { unsigned long InnerIter = config->GetInnerIter(); bool cont_adjoint = config->GetContinuous_Adjoint(); @@ -195,26 +194,58 @@ void CNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container, C /*--- Update the angle of attack at the far-field for fixed CL calculations (only direct problem). ---*/ - if ((fixed_cl) && (!disc_adjoint) && (!cont_adjoint)) { SetFarfield_AoA(geometry, solver_container, config, iMesh, Output); } + if (fixed_cl && !disc_adjoint && !cont_adjoint) { + SU2_OMP_MASTER + SetFarfield_AoA(geometry, solver_container, config, iMesh, Output); + SU2_OMP_BARRIER + } /*--- Set the primitive variables ---*/ - ErrorCounter = SetPrimitive_Variables(solver_container, config, Output); + SU2_OMP_MASTER + ErrorCounter = 0; + SU2_OMP_BARRIER + + SU2_OMP_ATOMIC + ErrorCounter += SetPrimitive_Variables(solver_container, config, Output); + + if ((iMesh == MESH_0) && (config->GetComm_Level() == COMM_FULL)) { + SU2_OMP_BARRIER + SU2_OMP_MASTER + { + unsigned long tmp = ErrorCounter; + SU2_MPI::Allreduce(&tmp, &ErrorCounter, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); + config->SetNonphysical_Points(ErrorCounter); + } + SU2_OMP_BARRIER + } /*--- Compute the engine properties ---*/ - if (engine) { GetPower_Properties(geometry, config, iMesh, Output); } + if (engine) { + SU2_OMP_MASTER + GetPower_Properties(geometry, config, iMesh, Output); + SU2_OMP_BARRIER + } /*--- Compute the actuator disk properties and distortion levels ---*/ if (actuator_disk) { - Set_MPI_ActDisk(solver_container, geometry, config); - SetActDisk_BCThrust(geometry, solver_container, config, iMesh, Output); + SU2_OMP_MASTER + { + Set_MPI_ActDisk(solver_container, geometry, config); + SetActDisk_BCThrust(geometry, solver_container, config, iMesh, Output); + } + SU2_OMP_BARRIER } /*--- Compute NearField MPI ---*/ - if (nearfield) { Set_MPI_Nearfield(geometry, config); } + if (nearfield) { + SU2_OMP_MASTER + Set_MPI_Nearfield(geometry, config); + SU2_OMP_BARRIER + } /*--- Artificial dissipation ---*/ @@ -258,79 +289,81 @@ void CNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container, C /*--- Compute the limiter in case we need it in the turbulence model or to limit the viscous terms (check this logic with JST and 2nd order turbulence model) ---*/ - if ((iMesh == MESH_0) && (limiter_flow || limiter_turb || limiter_adjflow) - && !Output && !van_albada) { SetPrimitive_Limiter(geometry, config); } + if ((iMesh == MESH_0) && (limiter_flow || limiter_turb || limiter_adjflow) && !Output && !van_albada) { + SetPrimitive_Limiter(geometry, config); + } /*--- Evaluate the vorticity and strain rate magnitude ---*/ - StrainMag_Max = 0.0; Omega_Max = 0.0; - - SU2_OMP_PARALLEL + SU2_OMP_MASTER { - solver_container[FLOW_SOL]->GetNodes()->SetVorticity_StrainMag(); - - su2double strainMax = 0.0, omegaMax = 0.0; - - SU2_OMP(for schedule(static,omp_chunk_size) nowait) - for (unsigned long iPoint = 0; iPoint < nPoint; iPoint++) { - - su2double StrainMag = solver_container[FLOW_SOL]->GetNodes()->GetStrainMag(iPoint); - const su2double* Vorticity = solver_container[FLOW_SOL]->GetNodes()->GetVorticity(iPoint); - su2double Omega = sqrt(Vorticity[0]*Vorticity[0]+ Vorticity[1]*Vorticity[1]+ Vorticity[2]*Vorticity[2]); - - strainMax = max(strainMax, StrainMag); - omegaMax = max(omegaMax, Omega); - - } - SU2_OMP_CRITICAL - { - StrainMag_Max = max(StrainMag_Max, strainMax); - Omega_Max = max(Omega_Max, omegaMax); - } - - } // end SU2_OMP_PARALLEL - - /*--- Compute the TauWall from the wall functions ---*/ + StrainMag_Max = 0.0; + Omega_Max = 0.0; + } + SU2_OMP_BARRIER - if (wall_functions) - SetTauWall_WF(geometry, solver_container, config); + solver_container[FLOW_SOL]->GetNodes()->SetVorticity_StrainMag(); - /*--- Initialize the Jacobian matrices ---*/ + su2double strainMax = 0.0, omegaMax = 0.0; - if (implicit && !config->GetDiscrete_Adjoint()) Jacobian.SetValZero(); + SU2_OMP(for schedule(static,omp_chunk_size) nowait) + for (unsigned long iPoint = 0; iPoint < nPoint; iPoint++) { - /*--- Error message ---*/ + su2double StrainMag = solver_container[FLOW_SOL]->GetNodes()->GetStrainMag(iPoint); + const su2double* Vorticity = solver_container[FLOW_SOL]->GetNodes()->GetVorticity(iPoint); + su2double Omega = sqrt(Vorticity[0]*Vorticity[0]+ Vorticity[1]*Vorticity[1]+ Vorticity[2]*Vorticity[2]); - if (config->GetComm_Level() == COMM_FULL) { + strainMax = max(strainMax, StrainMag); + omegaMax = max(omegaMax, Omega); - if (iMesh == MESH_0) { + } + SU2_OMP_CRITICAL + { + StrainMag_Max = max(StrainMag_Max, strainMax); + Omega_Max = max(Omega_Max, omegaMax); + } - unsigned long MyErrorCounter = ErrorCounter; + if ((iMesh == MESH_0) && (config->GetComm_Level() == COMM_FULL)) { + SU2_OMP_BARRIER + SU2_OMP_MASTER + { su2double MyOmega_Max = Omega_Max; su2double MyStrainMag_Max = StrainMag_Max; - SU2_MPI::Allreduce(&MyErrorCounter, &ErrorCounter, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); SU2_MPI::Allreduce(&MyStrainMag_Max, &StrainMag_Max, 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD); SU2_MPI::Allreduce(&MyOmega_Max, &Omega_Max, 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD); - config->SetNonphysical_Points(ErrorCounter); solver_container[FLOW_SOL]->SetStrainMag_Max(StrainMag_Max); solver_container[FLOW_SOL]->SetOmega_Max(Omega_Max); - } + SU2_OMP_BARRIER + } + + /*--- Compute the TauWall from the wall functions ---*/ + if (wall_functions) { + SU2_OMP_MASTER + SetTauWall_WF(geometry, solver_container, config); + SU2_OMP_BARRIER } + /*--- Initialize the Jacobian matrices ---*/ + + if (implicit && !config->GetDiscrete_Adjoint()) Jacobian.SetValZero(); + + } // end SU2_OMP_PARALLEL } unsigned long CNSSolver::SetPrimitive_Variables(CSolver **solver_container, CConfig *config, bool Output) { + /*--- Number of non-physical points, local to the thread, needs + * further reduction if function is called in parallel ---*/ unsigned long nonPhysicalPoints = 0; const unsigned short turb_model = config->GetKind_Turb_Model(); const bool tkeNeeded = (turb_model == SST) || (turb_model == SST_SUST); - SU2_OMP_PARALLEL_(for schedule(static,omp_chunk_size) reduction(+:nonPhysicalPoints)) + SU2_OMP_FOR_STAT(omp_chunk_size) for (unsigned long iPoint = 0; iPoint < nPoint; iPoint ++) { /*--- Retrieve the value of the kinetic energy (if needed). ---*/ @@ -1554,7 +1587,7 @@ void CNSSolver::SetRoe_Dissipation(CGeometry *geometry, CConfig *config){ const unsigned short kind_roe_dissipation = config->GetKind_RoeLowDiss(); - SU2_OMP_PARALLEL_(for schedule(static,omp_chunk_size)) + SU2_OMP_FOR_STAT(omp_chunk_size) for (unsigned long iPoint = 0; iPoint < nPoint; iPoint++) { if (kind_roe_dissipation == FD || kind_roe_dissipation == FD_DUCROS){ From fcc39c03c74e3e9d85177015f4be68a13819a506 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Tue, 11 Feb 2020 15:26:07 +0000 Subject: [PATCH 109/118] single parallel regions for pre/post processing turbulence solvers --- SU2_CFD/include/solvers/CSolver.hpp | 10 --- SU2_CFD/include/solvers/CTurbSASolver.hpp | 21 +++---- SU2_CFD/include/variables/CTurbSAVariable.hpp | 5 +- SU2_CFD/include/variables/CVariable.hpp | 3 +- SU2_CFD/src/solvers/CTurbSASolver.cpp | 62 +++++++++++-------- SU2_CFD/src/solvers/CTurbSSTSolver.cpp | 23 ++++--- SU2_CFD/src/variables/CTurbSAVariable.cpp | 11 ++-- 7 files changed, 73 insertions(+), 62 deletions(-) diff --git a/SU2_CFD/include/solvers/CSolver.hpp b/SU2_CFD/include/solvers/CSolver.hpp index 18a4ff37be5f..966dd6a9fa53 100644 --- a/SU2_CFD/include/solvers/CSolver.hpp +++ b/SU2_CFD/include/solvers/CSolver.hpp @@ -4571,16 +4571,6 @@ class CSolver { CConfig *config, unsigned short iMesh) { } - /*! - * \brief A virtual member. - * \param[in] solver - Solver container - * \param[in] geometry - Geometrical definition. - * \param[in] config - Definition of the particular problem. - */ - inline virtual void SetDES_LengthScale(CSolver** solver, - CGeometry *geometry, - CConfig *config) { } - /*! * \brief A virtual member. * \param[in] geometry - Geometrical definition. diff --git a/SU2_CFD/include/solvers/CTurbSASolver.hpp b/SU2_CFD/include/solvers/CTurbSASolver.hpp index 1d314d1a4501..403f5c3fe9c1 100644 --- a/SU2_CFD/include/solvers/CTurbSASolver.hpp +++ b/SU2_CFD/include/solvers/CTurbSASolver.hpp @@ -41,6 +41,16 @@ class CTurbSASolver final : public CTurbSolver { private: su2double nu_tilde_Inf, nu_tilde_Engine, nu_tilde_ActDisk; + /*! + * \brief A virtual member. + * \param[in] solver - Solver container + * \param[in] geometry - Geometrical definition. + * \param[in] config - Definition of the particular problem. + */ + void SetDES_LengthScale(CSolver** solver, + CGeometry *geometry, + CConfig *config); + public: /*! * \brief Constructor of the class. @@ -361,17 +371,6 @@ class CTurbSASolver final : public CTurbSolver { for (unsigned long iPoint = 0; iPoint < nPoint; iPoint++) nodes->SetSolution(iPoint, 0, nu_tilde_Inf); } - - /*! - * \brief A virtual member. - * \param[in] solver - Solver container - * \param[in] geometry - Geometrical definition. - * \param[in] config - Definition of the particular problem. - */ - void SetDES_LengthScale(CSolver** solver, - CGeometry *geometry, - CConfig *config) override; - /*! * \brief Store of a set of provided inlet profile values at a vertex. * \param[in] val_inlet - vector containing the inlet values for the current vertex. diff --git a/SU2_CFD/include/variables/CTurbSAVariable.hpp b/SU2_CFD/include/variables/CTurbSAVariable.hpp index ad2d9a18539a..64f6e069e903 100644 --- a/SU2_CFD/include/variables/CTurbSAVariable.hpp +++ b/SU2_CFD/include/variables/CTurbSAVariable.hpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -108,7 +108,8 @@ class CTurbSAVariable final : public CTurbVariable { * \brief Set the vortex tilting measure for computation of the EDDES length scale * \param[in] iPoint - Point index. */ - void SetVortex_Tilting(unsigned long iPoint, su2double **PrimGrad_Flow, su2double* Vorticity, su2double LaminarViscosity) override; + void SetVortex_Tilting(unsigned long iPoint, const su2double* const* PrimGrad_Flow, + const su2double* Vorticity, su2double LaminarViscosity) override; /*! * \brief Get the vortex tilting measure for computation of the EDDES length scale diff --git a/SU2_CFD/include/variables/CVariable.hpp b/SU2_CFD/include/variables/CVariable.hpp index 5b4a75afa4f4..5870c5870d82 100644 --- a/SU2_CFD/include/variables/CVariable.hpp +++ b/SU2_CFD/include/variables/CVariable.hpp @@ -2740,7 +2740,8 @@ class CVariable { inline virtual su2double GetTauWall(unsigned long iPoint) const { return 0.0; } - inline virtual void SetVortex_Tilting(unsigned long iPoint, su2double **PrimGrad_Flow, su2double* Vorticity, su2double LaminarViscosity) {} + inline virtual void SetVortex_Tilting(unsigned long iPoint, const su2double* const* PrimGrad_Flow, + const su2double* Vorticity, su2double LaminarViscosity) {} inline virtual su2double GetVortex_Tilting(unsigned long iPoint) const { return 0.0; } diff --git a/SU2_CFD/src/solvers/CTurbSASolver.cpp b/SU2_CFD/src/solvers/CTurbSASolver.cpp index 5e155e2108f5..a141bb10f292 100644 --- a/SU2_CFD/src/solvers/CTurbSASolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSASolver.cpp @@ -270,22 +270,19 @@ CTurbSASolver::~CTurbSASolver(void) { void CTurbSASolver::Preprocessing(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh, unsigned short iRKStep, unsigned short RunTime_EqSystem, bool Output) { - /// TODO: Try to start a parallel section here encompassing all "heavy" methods. + SU2_OMP_PARALLEL + { - unsigned long iPoint; bool limiter_turb = (config->GetKind_SlopeLimit_Turb() != NO_LIMITER) && (config->GetInnerIter() <= config->GetLimiterIter()); unsigned short kind_hybridRANSLES = config->GetKind_HybridRANSLES(); - su2double** PrimGrad_Flow = NULL; - su2double* Vorticity = NULL; - su2double Laminar_Viscosity = 0; + const su2double* const* PrimGrad_Flow = nullptr; + const su2double* Vorticity = nullptr; + su2double Laminar_Viscosity = 0.0; - SU2_OMP_PARALLEL - { /*--- Clear residual and system matrix. ---*/ LinSysRes.SetValZero(); Jacobian.SetValZero(); - } /*--- Upwind second order reconstruction and gradients ---*/ @@ -297,21 +294,26 @@ void CTurbSASolver::Preprocessing(CGeometry *geometry, CSolver **solver_containe 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); + + 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_turb) SetSolution_Limiter(geometry, config); - if (kind_hybridRANSLES != NO_HYBRIDRANSLES){ + if (kind_hybridRANSLES != NO_HYBRIDRANSLES) { /*--- Set the vortex tilting coefficient at every node if required ---*/ if (kind_hybridRANSLES == SA_EDDES){ - for (iPoint = 0; iPoint < nPoint; iPoint++){ - PrimGrad_Flow = solver_container[FLOW_SOL]->GetNodes()->GetGradient_Primitive(iPoint); - Vorticity = solver_container[FLOW_SOL]->GetNodes()->GetVorticity(iPoint); + SU2_OMP_FOR_STAT(omp_chunk_size) + for (unsigned long iPoint = 0; iPoint < nPoint; iPoint++){ + Vorticity = solver_container[FLOW_SOL]->GetNodes()->GetVorticity(iPoint); + PrimGrad_Flow = solver_container[FLOW_SOL]->GetNodes()->GetGradient_Primitive(iPoint); Laminar_Viscosity = solver_container[FLOW_SOL]->GetNodes()->GetLaminarViscosity(iPoint); - nodes->SetVortex_Tilting(iPoint,PrimGrad_Flow, Vorticity, Laminar_Viscosity); + nodes->SetVortex_Tilting(iPoint, PrimGrad_Flow, Vorticity, Laminar_Viscosity); } } @@ -320,17 +322,23 @@ void CTurbSASolver::Preprocessing(CGeometry *geometry, CSolver **solver_containe SetDES_LengthScale(solver_container, geometry, config); } + + } // end SU2_OMP_PARALLEL + } void CTurbSASolver::Postprocessing(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh) { + SU2_OMP_PARALLEL + { + const su2double cv1_3 = 7.1*7.1*7.1; const bool neg_spalart_allmaras = (config->GetKind_Turb_Model() == SA_NEG); /*--- Compute eddy viscosity ---*/ - SU2_OMP_PARALLEL_(for schedule(static,omp_chunk_size)) + SU2_OMP_FOR_STAT(omp_chunk_size) for (unsigned long iPoint = 0; iPoint < nPoint; iPoint ++) { su2double rho = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); @@ -345,12 +353,14 @@ void CTurbSASolver::Postprocessing(CGeometry *geometry, CSolver **solver_contain su2double muT = rho*fv1*nu_hat; - if (neg_spalart_allmaras && (muT < 0.0)) muT = 0.0; + if (neg_spalart_allmaras) muT = max(muT,0.0); nodes->SetmuT(iPoint,muT); } + } // end SU2_OMP_PARALLEL + } void CTurbSASolver::Source_Residual(CGeometry *geometry, CSolver **solver_container, @@ -2087,17 +2097,17 @@ void CTurbSASolver::SetDES_LengthScale(CSolver **solver, CGeometry *geometry, CC su2double density = 0.0, laminarViscosity = 0.0, kinematicViscosity = 0.0, eddyViscosity = 0.0, kinematicViscosityTurb = 0.0, wallDistance = 0.0, lengthScale = 0.0; - su2double maxDelta = 0.0, deltaAux = 0.0, distDES = 0.0, uijuij = 0.0, k2 = 0.0, r_d = 0.0, f_d = 0.0, - deltaDDES = 0.0, omega = 0.0, ln_max = 0.0, ln[3] = {0.0, 0.0, 0.0}, - aux_ln = 0.0, f_kh = 0.0; + su2double maxDelta = 0.0, deltaAux = 0.0, distDES = 0.0, uijuij = 0.0, k2 = 0.0, r_d = 0.0, f_d = 0.0; + su2double deltaDDES = 0.0, omega = 0.0, ln_max = 0.0, ln[3] = {0.0}, aux_ln = 0.0, f_kh = 0.0; su2double nu_hat, fw_star = 0.424, cv1_3 = pow(7.1, 3.0); k2 = pow(0.41, 2.0); su2double cb1 = 0.1355, ct3 = 1.2, ct4 = 0.5; su2double sigma = 2./3., cb2 = 0.622, f_max=1.0, f_min=0.1, a1=0.15, a2=0.3; su2double cw1 = 0.0, Ji = 0.0, Ji_2 = 0.0, Ji_3 = 0.0, fv1 = 0.0, fv2 = 0.0, ft2 = 0.0, psi_2 = 0.0; - su2double *coord_i = NULL, *coord_j = NULL, **primVarGrad = NULL, *vorticity = NULL, delta[3] = {0.0,0.0,0.0}, - ratioOmega[3] = {0.0, 0.0, 0.0}, vortexTiltingMeasure = 0.0; + const su2double *coord_i = nullptr, *coord_j = nullptr, *const *primVarGrad = nullptr, *vorticity = nullptr; + su2double delta[3] = {0.0}, ratioOmega[3] = {0.0}, vortexTiltingMeasure = 0.0; + SU2_OMP_FOR_DYN(omp_chunk_size) for (iPoint = 0; iPoint < nPointDomain; iPoint++){ coord_i = geometry->node[iPoint]->GetCoord(); @@ -2142,7 +2152,7 @@ void CTurbSASolver::SetDES_LengthScale(CSolver **solver, CGeometry *geometry, CC ---*/ maxDelta = geometry->node[iPoint]->GetMaxLength(); - distDES = constDES * maxDelta; + distDES = constDES * maxDelta; lengthScale = min(distDES,wallDistance); break; @@ -2172,8 +2182,8 @@ void CTurbSASolver::SetDES_LengthScale(CSolver **solver, CGeometry *geometry, CC jPoint = geometry->node[iPoint]->GetPoint(iNeigh); coord_j = geometry->node[jPoint]->GetCoord(); for ( iDim = 0; iDim < nDim; iDim++){ - deltaAux = abs(coord_j[iDim] - coord_i[iDim]); - delta[iDim] = max(delta[iDim], deltaAux); + deltaAux = abs(coord_j[iDim] - coord_i[iDim]); + delta[iDim] = max(delta[iDim], deltaAux); } deltaDDES = geometry->node[iPoint]->GetMaxLength(); } @@ -2255,7 +2265,7 @@ void CTurbSASolver::SetDES_LengthScale(CSolver **solver, CGeometry *geometry, CC } - nodes->SetDES_LengthScale(iPoint,lengthScale); + nodes->SetDES_LengthScale(iPoint, lengthScale); } } diff --git a/SU2_CFD/src/solvers/CTurbSSTSolver.cpp b/SU2_CFD/src/solvers/CTurbSSTSolver.cpp index 3259a33892ee..36382ad7851e 100644 --- a/SU2_CFD/src/solvers/CTurbSSTSolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSSTSolver.cpp @@ -271,17 +271,15 @@ CTurbSSTSolver::~CTurbSSTSolver(void) { void CTurbSSTSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh, unsigned short iRKStep, unsigned short RunTime_EqSystem, bool Output) { - /// TODO: Try to start a parallel section here encompassing all "heavy" methods. + SU2_OMP_PARALLEL + { const bool limiter_turb = (config->GetKind_SlopeLimit_Turb() != NO_LIMITER) && (config->GetInnerIter() <= config->GetLimiterIter()); - SU2_OMP_PARALLEL - { /*--- Clear residual and system matrix. ---*/ LinSysRes.SetValZero(); Jacobian.SetValZero(); - } /*--- Upwind second order reconstruction and gradients ---*/ @@ -293,16 +291,25 @@ void CTurbSSTSolver::Preprocessing(CGeometry *geometry, CSolver **solver_contain 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); + + 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_turb) SetSolution_Limiter(geometry, config); + } // end SU2_OMP_PARALLEL + } void CTurbSSTSolver::Postprocessing(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh) { + SU2_OMP_PARALLEL + { + const su2double a1 = constants[7]; /*--- Compute turbulence gradients. ---*/ @@ -314,7 +321,7 @@ void CTurbSSTSolver::Postprocessing(CGeometry *geometry, CSolver **solver_contai SetSolution_Gradient_LS(geometry, config); } - SU2_OMP_PARALLEL_(for schedule(static,omp_chunk_size)) + SU2_OMP_FOR_STAT(omp_chunk_size) for (unsigned long iPoint = 0; iPoint < nPoint; iPoint ++) { /*--- Compute blending functions and cross diffusion ---*/ @@ -344,6 +351,8 @@ void CTurbSSTSolver::Postprocessing(CGeometry *geometry, CSolver **solver_contai } + } // end SU2_OMP_PARALLEL + } void CTurbSSTSolver::Source_Residual(CGeometry *geometry, CSolver **solver_container, diff --git a/SU2_CFD/src/variables/CTurbSAVariable.cpp b/SU2_CFD/src/variables/CTurbSAVariable.cpp index fa099ceb6759..eb48ec0a6ad1 100644 --- a/SU2_CFD/src/variables/CTurbSAVariable.cpp +++ b/SU2_CFD/src/variables/CTurbSAVariable.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -29,8 +29,9 @@ #include "../../include/variables/CTurbSAVariable.hpp" -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 long npoint, + unsigned long ndim, unsigned long nvar, CConfig *config) : + CTurbVariable(npoint, ndim, nvar, config) { Solution_Old = Solution = val_nu_tilde; @@ -50,8 +51,8 @@ CTurbSAVariable::CTurbSAVariable(su2double val_nu_tilde, su2double val_muT, unsi Vortex_Tilting.resize(nPoint); } -void CTurbSAVariable::SetVortex_Tilting(unsigned long iPoint, su2double **PrimGrad_Flow, - su2double* Vorticity, su2double LaminarViscosity) { +void CTurbSAVariable::SetVortex_Tilting(unsigned long iPoint, const su2double* const* PrimGrad_Flow, + const 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; From c3b06cee3a3c4aac48304489aae7b3fd8698f883 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Tue, 11 Feb 2020 16:37:53 +0000 Subject: [PATCH 110/118] single parallel region for entire multigrid and singlegrid iterations --- SU2_CFD/include/solvers/CEulerSolver.hpp | 15 +- SU2_CFD/src/integration/CIntegration.cpp | 21 ++- .../src/integration/CMultiGridIntegration.cpp | 10 + .../integration/CSingleGridIntegration.cpp | 9 + SU2_CFD/src/iteration_structure.cpp | 2 +- SU2_CFD/src/solvers/CEulerSolver.cpp | 171 +++++++----------- SU2_CFD/src/solvers/CNSSolver.cpp | 7 +- SU2_CFD/src/solvers/CSolver.cpp | 2 +- SU2_CFD/src/solvers/CTurbSASolver.cpp | 15 -- SU2_CFD/src/solvers/CTurbSSTSolver.cpp | 15 -- SU2_CFD/src/solvers/CTurbSolver.cpp | 25 +-- 11 files changed, 117 insertions(+), 175 deletions(-) diff --git a/SU2_CFD/include/solvers/CEulerSolver.hpp b/SU2_CFD/include/solvers/CEulerSolver.hpp index eb205a47e329..47dd22c38dc8 100644 --- a/SU2_CFD/include/solvers/CEulerSolver.hpp +++ b/SU2_CFD/include/solvers/CEulerSolver.hpp @@ -211,6 +211,9 @@ class CEulerSolver : public CSolver { unsigned long ErrorCounter = 0; /*!< \brief Counter for number of un-physical states. */ + su2double Global_Delta_Time = 0.0, /*!< \brief Time-step for TIME_STEPPING time marching strategy. */ + Global_Delta_UnstTimeND = 0.0; /*!< \brief Unsteady time step for the dual time strategy. */ + /*--- Turbomachinery Solver Variables ---*/ su2double ***AverageFlux = nullptr, @@ -600,18 +603,6 @@ class CEulerSolver : public CSolver { unsigned short RunTime_EqSystem, bool Output) override; - /*! - * \brief A virtual member. - * \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 Postprocessing(CGeometry *geometry, - CSolver **solver_container, - CConfig *config, - unsigned short iMesh) final; - /*! * \brief Compute the gradient of the primitive variables using Green-Gauss method, * and stores the result in the Gradient_Primitive variable. diff --git a/SU2_CFD/src/integration/CIntegration.cpp b/SU2_CFD/src/integration/CIntegration.cpp index a52813c17ca2..98fdb968d38b 100644 --- a/SU2_CFD/src/integration/CIntegration.cpp +++ b/SU2_CFD/src/integration/CIntegration.cpp @@ -83,6 +83,11 @@ void CIntegration::Space_Integration(CGeometry *geometry, if (dual_time) solver_container[MainSolver]->SetResidual_DualTime(geometry, solver_container, config, iRKStep, iMesh, RunTime_EqSystem); + /// TODO: No boundary condition supports hybrid parallelism yet, master thread does all the work. + + SU2_OMP_MASTER + { + /*--- Boundary conditions that depend on other boundaries (they require MPI sincronization)---*/ solver_container[MainSolver]->BC_Fluid_Interface(geometry, solver_container, numerics[CONV_BOUND_TERM], numerics[VISC_BOUND_TERM], config); @@ -185,10 +190,14 @@ void CIntegration::Space_Integration(CGeometry *geometry, solver_container[MainSolver]->BC_Periodic(geometry, solver_container, numerics[CONV_BOUND_TERM], config); } + } // end SU2_OMP_MASTER + SU2_OMP_BARRIER + } -void CIntegration::Time_Integration(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iRKStep, - unsigned short RunTime_EqSystem) { +void CIntegration::Time_Integration(CGeometry *geometry, CSolver **solver_container, CConfig *config, + unsigned short iRKStep, unsigned short RunTime_EqSystem) { + unsigned short MainSolver = config->GetContainerPosition(RunTime_EqSystem); unsigned short KindSolver = config->GetKind_Solver(); @@ -235,11 +244,17 @@ void CIntegration::Time_Integration(CGeometry *geometry, CSolver **solver_contai void CIntegration::SetDualTime_Solver(CGeometry *geometry, CSolver *solver, CConfig *config, unsigned short iMesh) { + SU2_OMP_PARALLEL + { + unsigned long iPoint; solver->GetNodes()->Set_Solution_time_n1(); solver->GetNodes()->Set_Solution_time_n(); + + SU2_OMP_MASTER solver->ResetCFLAdapt(); + SU2_OMP_BARRIER SU2_OMP_FOR_STAT(roundUpDiv(geometry->GetnPoint(), omp_get_num_threads())) for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { @@ -334,6 +349,8 @@ void CIntegration::SetDualTime_Solver(CGeometry *geometry, CSolver *solver, CCon } SU2_OMP_BARRIER + } // end SU2_OMP_PARALLEL + } void CIntegration::SetStructural_Solver(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh) { diff --git a/SU2_CFD/src/integration/CMultiGridIntegration.cpp b/SU2_CFD/src/integration/CMultiGridIntegration.cpp index 2585dbb5f14f..fab9c897e05c 100644 --- a/SU2_CFD/src/integration/CMultiGridIntegration.cpp +++ b/SU2_CFD/src/integration/CMultiGridIntegration.cpp @@ -38,6 +38,12 @@ void CMultiGridIntegration::MultiGrid_Iteration(CGeometry ****geometry, unsigned short RunTime_EqSystem, unsigned short iZone, unsigned short iInst) { + + /*--- Start an OpenMP parallel region covering the entire MG iteration. ---*/ + + SU2_OMP_PARALLEL + { + su2double monitor = 1.0; bool FullMG = false; @@ -75,7 +81,9 @@ void CMultiGridIntegration::MultiGrid_Iteration(CGeometry ****geometry, geometry[iZone][iInst][FinestMesh], config[iZone]); + SU2_OMP_MASTER config[iZone]->SubtractFinestMesh(); + SU2_OMP_BARRIER } /*--- Set the current finest grid (full multigrid strategy) ---*/ @@ -100,6 +108,8 @@ void CMultiGridIntegration::MultiGrid_Iteration(CGeometry ****geometry, numerics_container[iZone][iInst], config[iZone], FinestMesh, RunTime_EqSystem, &monitor); + } // end SU2_OMP_PARALLEL + } void CMultiGridIntegration::MultiGrid_Cycle(CGeometry ****geometry, diff --git a/SU2_CFD/src/integration/CSingleGridIntegration.cpp b/SU2_CFD/src/integration/CSingleGridIntegration.cpp index 75585510fb41..a5fee270c33e 100644 --- a/SU2_CFD/src/integration/CSingleGridIntegration.cpp +++ b/SU2_CFD/src/integration/CSingleGridIntegration.cpp @@ -36,6 +36,11 @@ void CSingleGridIntegration::SingleGrid_Iteration(CGeometry ****geometry, CSolve unsigned short RunTime_EqSystem, unsigned short iZone, unsigned short iInst) { + /*--- Start an OpenMP parallel region covering the entire iteration. ---*/ + + SU2_OMP_PARALLEL + { + unsigned short SolContainer_Position = config[iZone]->GetContainerPosition(RunTime_EqSystem); unsigned short FinestMesh = config[iZone]->GetFinestMesh(); @@ -72,7 +77,9 @@ void CSingleGridIntegration::SingleGrid_Iteration(CGeometry ****geometry, CSolve solvers_fine[SolContainer_Position]->Postprocessing(geometry_fine, solvers_fine, config[iZone], FinestMesh); if (RunTime_EqSystem == RUNTIME_HEAT_SYS) { + SU2_OMP_MASTER solvers_fine[HEAT_SOL]->Heat_Fluxes(geometry_fine, solvers_fine, config[iZone]); + SU2_OMP_BARRIER } /*--- If turbulence model, copy the turbulence variables to the coarse levels ---*/ @@ -98,6 +105,8 @@ void CSingleGridIntegration::SingleGrid_Iteration(CGeometry ****geometry, CSolve } + } // end SU2_OMP_PARALLEL + } void CSingleGridIntegration::SetRestricted_Solution(unsigned short RunTime_EqSystem, CSolver *sol_fine, CSolver *sol_coarse, diff --git a/SU2_CFD/src/iteration_structure.cpp b/SU2_CFD/src/iteration_structure.cpp index 8fb661344971..31c90853efd4 100644 --- a/SU2_CFD/src/iteration_structure.cpp +++ b/SU2_CFD/src/iteration_structure.cpp @@ -625,7 +625,7 @@ void CFluidIteration::Update(COutput *output, /*--- Update dual time solver for the dynamic mesh solver ---*/ if (config[val_iZone]->GetDeform_Mesh()) { - solver[val_iZone][val_iInst][MESH_0][MESH_SOL]->SetDualTime_Mesh(); + solver[val_iZone][val_iInst][MESH_0][MESH_SOL]->SetDualTime_Mesh(); } /*--- Update dual time solver for the turbulence model ---*/ diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index f4e9078a1b54..e41f09678263 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -2488,10 +2488,8 @@ void CEulerSolver::SetInitialCondition(CGeometry **geometry, CSolver ***solver_c } -void CEulerSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh, unsigned short iRKStep, unsigned short RunTime_EqSystem, bool Output) { - - SU2_OMP_PARALLEL - { +void CEulerSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh, + unsigned short iRKStep, unsigned short RunTime_EqSystem, bool Output) { unsigned long InnerIter = config->GetInnerIter(); bool cont_adjoint = config->GetContinuous_Adjoint(); @@ -2610,13 +2608,8 @@ void CEulerSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container if (implicit && !disc_adjoint) Jacobian.SetValZero(); - } // end SU2_OMP_PARALLEL - } -void CEulerSolver::Postprocessing(CGeometry *geometry, CSolver **solver_container, CConfig *config, - unsigned short iMesh) { } - unsigned long CEulerSolver::SetPrimitive_Variables(CSolver **solver_container, CConfig *config, bool Output) { /*--- Number of non-physical points, local to the thread, needs @@ -2658,14 +2651,13 @@ void CEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, * Critical sections are used for this instead of reduction * clauses for compatibility with OpenMP 2.0 (Windows...). ---*/ - Min_Delta_Time = 1e30; Max_Delta_Time = 0.0; - - su2double Global_Delta_Time, Global_Delta_UnstTimeND = 1e30; - - /*--- Start OpenMP parallel section. ---*/ - - SU2_OMP_PARALLEL + SU2_OMP_MASTER { + Min_Delta_Time = 1e30; + Max_Delta_Time = 0.0; + Global_Delta_UnstTimeND = 1e30; + } + SU2_OMP_BARRIER const su2double *Normal = nullptr; su2double Area, Vol, Mean_SoundSpeed, Mean_ProjVel, Lambda, Local_Delta_Time, Local_Delta_Time_Visc; @@ -2880,7 +2872,7 @@ void CEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, SU2_OMP(for schedule(static,omp_chunk_size) nowait) for (iPoint = 0; iPoint < nPointDomain; iPoint++) { - Global_Delta_UnstTimeND = min(Global_Delta_UnstTimeND,config->GetUnst_CFL()*Global_Delta_Time/nodes->GetLocalCFL(iPoint)); + glbDtND = min(glbDtND, config->GetUnst_CFL()*Global_Delta_Time / nodes->GetLocalCFL(iPoint)); } SU2_OMP_CRITICAL Global_Delta_UnstTimeND = min(Global_Delta_UnstTimeND, glbDtND); @@ -2906,8 +2898,6 @@ void CEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, } } - } // end SU2_OMP_PARALLEL - } void CEulerSolver::Centered_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics_container, @@ -2916,10 +2906,6 @@ void CEulerSolver::Centered_Residual(CGeometry *geometry, CSolver **solver_conta const bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); const bool jst_scheme = (config->GetKind_Centered_Flow() == JST) && (iMesh == MESH_0); - /*--- Start OpenMP parallel section. ---*/ - - SU2_OMP_PARALLEL - { /*--- Pick one numerics object per thread. ---*/ CNumerics* numerics = numerics_container[CONV_TERM + omp_get_thread_num()*MAX_TERMS]; @@ -3006,8 +2992,6 @@ void CEulerSolver::Centered_Residual(CGeometry *geometry, CSolver **solver_conta Jacobian.SetDiagonalAsColumnSum(); } - } // end SU2_OMP_PARALLEL - } void CEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_container, @@ -3032,11 +3016,9 @@ void CEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_contain /*--- Non-physical counter. ---*/ unsigned long counter_local = 0; + SU2_OMP_MASTER + ErrorCounter = 0; - /*--- Start OpenMP parallel section. ---*/ - - SU2_OMP_PARALLEL_(reduction(+:counter_local)) - { /*--- Pick one numerics object per thread. ---*/ CNumerics* numerics = numerics_container[CONV_TERM + omp_get_thread_num()*MAX_TERMS]; @@ -3253,17 +3235,24 @@ void CEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_contain Jacobian.SetDiagonalAsColumnSum(); } - } // end SU2_OMP_PARALLEL - /*--- Warning message about non-physical reconstructions. ---*/ - if (config->GetComm_Level() == COMM_FULL) { - if (iMesh == MESH_0) { - unsigned long counter_global = 0; - SU2_MPI::Reduce(&counter_local, &counter_global, 1, MPI_UNSIGNED_LONG, MPI_SUM, MASTER_NODE, MPI_COMM_WORLD); - config->SetNonphysical_Reconstr(counter_global); + if ((iMesh == MESH_0) && (config->GetComm_Level() == COMM_FULL)) { + /*--- Add counter results for all threads. ---*/ + SU2_OMP_ATOMIC + ErrorCounter += counter_local; + SU2_OMP_BARRIER + + /*--- Add counter results for all ranks. ---*/ + SU2_OMP_MASTER + { + counter_local = ErrorCounter; + SU2_MPI::Reduce(&counter_local, &ErrorCounter, 1, MPI_UNSIGNED_LONG, MPI_SUM, MASTER_NODE, MPI_COMM_WORLD); + config->SetNonphysical_Reconstr(ErrorCounter); } + SU2_OMP_BARRIER } + } void CEulerSolver::SumEdgeFluxes(CGeometry* geometry) { @@ -3353,10 +3342,6 @@ void CEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_contain const bool windgust = config->GetWind_Gust(); const bool body_force = config->GetBody_Force(); - /*--- Start OpenMP parallel section. ---*/ - - SU2_OMP_PARALLEL - { /*--- Pick one numerics object per thread. ---*/ CNumerics* numerics = numerics_container[SOURCE_FIRST_TERM + omp_get_thread_num()*MAX_TERMS]; @@ -3543,8 +3528,6 @@ void CEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_contain } } - } // end SU2_OMP_PARALLEL - } void CEulerSolver::Source_Template(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, @@ -4558,11 +4541,6 @@ void CEulerSolver::Explicit_Iteration(CGeometry *geometry, CSolver **solver_cont const su2double RK_FuncCoeff[] = {1.0/6.0, 1.0/3.0, 1.0/3.0, 1.0/6.0}; const su2double RK_TimeCoeff[] = {0.5, 0.5, 1.0, 1.0}; - - /*--- Start OpenMP parallel section. ---*/ - - SU2_OMP_PARALLEL - { /*--- Set shared residual variables to 0 and declare * local ones for current thread to work on. ---*/ @@ -4657,8 +4635,8 @@ void CEulerSolver::Explicit_Iteration(CGeometry *geometry, CSolver **solver_cont ComputeVerificationError(geometry, config); } + SU2_OMP_BARRIER - } // end SU2_OMP_PARALLEL } void CEulerSolver::ExplicitRK_Iteration(CGeometry *geometry, CSolver **solver_container, @@ -4684,10 +4662,6 @@ void CEulerSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver const bool roe_turkel = config->GetKind_Upwind_Flow() == TURKEL; const bool low_mach_prec = config->Low_Mach_Preconditioning(); - /*--- Start OpenMP parallel section. ---*/ - - SU2_OMP_PARALLEL - { /*--- Local matrix for preconditioning. ---*/ su2double** LowMachPrec = nullptr; if (roe_turkel || low_mach_prec) { @@ -4831,8 +4805,8 @@ void CEulerSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver ComputeVerificationError(geometry, config); } + SU2_OMP_BARRIER - } // end SU2_OMP_PARALLEL } void CEulerSolver::ComputeUnderRelaxationFactor(CSolver **solver_container, CConfig *config) { @@ -11284,11 +11258,14 @@ void CEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_co unsigned short iVar, jVar, iMarker, iDim; unsigned long iPoint, jPoint, iEdge, iVertex; - su2double *U_time_nM1, *U_time_n, *U_time_nP1; + const su2double *U_time_nM1 = nullptr, *U_time_n = nullptr, *U_time_nP1 = nullptr; su2double Volume_nM1, Volume_nP1, TimeStep; - su2double *Normal = NULL, *GridVel_i = NULL, *GridVel_j = NULL, Residual_GCL; + const su2double *Normal = nullptr, *GridVel_i = nullptr, *GridVel_j = nullptr; + su2double Residual_GCL; - bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + const bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + const bool first_order = (config->GetTime_Marching() == DT_STEPPING_1ST); + const bool second_order = (config->GetTime_Marching() == DT_STEPPING_2ND); /*--- Store the physical time step ---*/ @@ -11300,6 +11277,7 @@ void CEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_co /*--- Loop over all nodes (excluding halos) ---*/ + SU2_OMP_FOR_STAT(omp_chunk_size) for (iPoint = 0; iPoint < nPointDomain; iPoint++) { /*--- Retrieve the solution at time levels n-1, n, and n+1. Note that @@ -11320,25 +11298,16 @@ void CEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_co for (iVar = 0; iVar < nVar; iVar++) { if (config->GetTime_Marching() == DT_STEPPING_1ST) - Residual[iVar] = (U_time_nP1[iVar] - U_time_n[iVar])*Volume_nP1 / TimeStep; + LinSysRes(iPoint,iVar) += (U_time_nP1[iVar] - U_time_n[iVar])*Volume_nP1 / TimeStep; if (config->GetTime_Marching() == DT_STEPPING_2ND) - Residual[iVar] = ( 3.0*U_time_nP1[iVar] - 4.0*U_time_n[iVar] - +1.0*U_time_nM1[iVar])*Volume_nP1 / (2.0*TimeStep); + LinSysRes(iPoint,iVar) += ( 3.0*U_time_nP1[iVar] - 4.0*U_time_n[iVar] + +1.0*U_time_nM1[iVar])*Volume_nP1 / (2.0*TimeStep); } - /*--- Store the residual and compute the Jacobian contribution due - to the dual time source term. ---*/ - - LinSysRes.AddBlock(iPoint, Residual); + /*--- Compute the Jacobian contribution due to the dual time source term. ---*/ if (implicit) { - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) Jacobian_i[iVar][jVar] = 0.0; - if (config->GetTime_Marching() == DT_STEPPING_1ST) - Jacobian_i[iVar][iVar] = Volume_nP1 / TimeStep; - if (config->GetTime_Marching() == DT_STEPPING_2ND) - Jacobian_i[iVar][iVar] = (Volume_nP1*3.0)/(2.0*TimeStep); - } - Jacobian.AddBlock2Diag(iPoint, Jacobian_i); + if (first_order) Jacobian.AddVal2Diag(iPoint, Volume_nP1/TimeStep); + if (second_order) Jacobian.AddVal2Diag(iPoint, (Volume_nP1*3.0)/(2.0*TimeStep)); } } @@ -11354,6 +11323,10 @@ void CEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_co we will loop over the edges and boundaries to compute the GCL component of the dual time source term that depends on grid velocities. ---*/ + /// TODO: This edge loop needs to be transformed to point loop as contrary + /// to turbulence solvers, this method is also called for coarse grids. + + SU2_OMP_MASTER for (iEdge = 0; iEdge < geometry->GetnEdge(); iEdge++) { /*--- Get indices for nodes i & j plus the face normal ---*/ @@ -11389,44 +11362,46 @@ void CEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_co LinSysRes.SubtractBlock(jPoint, Residual); } + SU2_OMP_BARRIER /*--- Loop over the boundary edges ---*/ for (iMarker = 0; iMarker < geometry->GetnMarker(); iMarker++) { if ((config->GetMarker_All_KindBC(iMarker) != INTERNAL_BOUNDARY) && (config->GetMarker_All_KindBC(iMarker) != PERIODIC_BOUNDARY)) { - for (iVertex = 0; iVertex < geometry->GetnVertex(iMarker); iVertex++) { - /*--- Get the index for node i plus the boundary face normal ---*/ + SU2_OMP_FOR_STAT(OMP_MIN_SIZE) + for (iVertex = 0; iVertex < geometry->GetnVertex(iMarker); iVertex++) { - iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); - Normal = geometry->vertex[iMarker][iVertex]->GetNormal(); + /*--- Get the index for node i plus the boundary face normal ---*/ - /*--- Grid velocities stored at boundary node i ---*/ + iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); + Normal = geometry->vertex[iMarker][iVertex]->GetNormal(); - GridVel_i = geometry->node[iPoint]->GetGridVel(); + /*--- Grid velocities stored at boundary node i ---*/ - /*--- Compute the GCL term by dotting the grid velocity with the face - normal. The normal is negated to match the boundary convention. ---*/ + GridVel_i = geometry->node[iPoint]->GetGridVel(); - Residual_GCL = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - Residual_GCL -= 0.5*(GridVel_i[iDim]+GridVel_i[iDim])*Normal[iDim]; + /*--- Compute the GCL term by dotting the grid velocity with the face + normal. The normal is negated to match the boundary convention. ---*/ - /*--- Compute the GCL component of the source term for node i ---*/ + Residual_GCL = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + Residual_GCL -= 0.5*(GridVel_i[iDim]+GridVel_i[iDim])*Normal[iDim]; - 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 i ---*/ - } + U_time_n = nodes->GetSolution_time_n(iPoint); + for (iVar = 0; iVar < nVar; iVar++) + LinSysRes(iPoint,iVar) += U_time_n[iVar]*Residual_GCL; + } } } /*--- Loop over all nodes (excluding halos) to compute the remainder of the dual time-stepping source term. ---*/ + SU2_OMP_FOR_STAT(omp_chunk_size) for (iPoint = 0; iPoint < nPointDomain; iPoint++) { /*--- Retrieve the solution at time levels n-1, n, and n+1. Note that @@ -11450,24 +11425,16 @@ void CEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_co for (iVar = 0; iVar < nVar; iVar++) { if (config->GetTime_Marching() == DT_STEPPING_1ST) - Residual[iVar] = (U_time_nP1[iVar] - U_time_n[iVar])*(Volume_nP1/TimeStep); + LinSysRes(iPoint,iVar) += (U_time_nP1[iVar] - U_time_n[iVar])*(Volume_nP1/TimeStep); if (config->GetTime_Marching() == DT_STEPPING_2ND) - Residual[iVar] = (U_time_nP1[iVar] - U_time_n[iVar])*(3.0*Volume_nP1/(2.0*TimeStep)) - + (U_time_nM1[iVar] - U_time_n[iVar])*(Volume_nM1/(2.0*TimeStep)); + LinSysRes(iPoint,iVar) += (U_time_nP1[iVar] - U_time_n[iVar])*(3.0*Volume_nP1/(2.0*TimeStep)) + + (U_time_nM1[iVar] - U_time_n[iVar])*(Volume_nM1/(2.0*TimeStep)); } - /*--- Store the residual and compute the Jacobian contribution due - to the dual time source term. ---*/ - LinSysRes.AddBlock(iPoint, Residual); + /*--- Compute the Jacobian contribution due to the dual time source term. ---*/ if (implicit) { - for (iVar = 0; iVar < nVar; iVar++) { - for (jVar = 0; jVar < nVar; jVar++) Jacobian_i[iVar][jVar] = 0.0; - if (config->GetTime_Marching() == DT_STEPPING_1ST) - Jacobian_i[iVar][iVar] = Volume_nP1/TimeStep; - if (config->GetTime_Marching() == DT_STEPPING_2ND) - Jacobian_i[iVar][iVar] = (3.0*Volume_nP1)/(2.0*TimeStep); - } - Jacobian.AddBlock2Diag(iPoint, Jacobian_i); + if (first_order) Jacobian.AddVal2Diag(iPoint, Volume_nP1/TimeStep); + if (second_order) Jacobian.AddVal2Diag(iPoint, (Volume_nP1*3.0)/(2.0*TimeStep)); } } } diff --git a/SU2_CFD/src/solvers/CNSSolver.cpp b/SU2_CFD/src/solvers/CNSSolver.cpp index 5b4419930c9c..c7c1f3209d90 100644 --- a/SU2_CFD/src/solvers/CNSSolver.cpp +++ b/SU2_CFD/src/solvers/CNSSolver.cpp @@ -166,10 +166,8 @@ CNSSolver::~CNSSolver(void) { } -void CNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh, unsigned short iRKStep, unsigned short RunTime_EqSystem, bool Output) { - - SU2_OMP_PARALLEL - { +void CNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh, + unsigned short iRKStep, unsigned short RunTime_EqSystem, bool Output) { unsigned long InnerIter = config->GetInnerIter(); bool cont_adjoint = config->GetContinuous_Adjoint(); @@ -351,7 +349,6 @@ void CNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container, C if (implicit && !config->GetDiscrete_Adjoint()) Jacobian.SetValZero(); - } // end SU2_OMP_PARALLEL } unsigned long CNSSolver::SetPrimitive_Variables(CSolver **solver_container, CConfig *config, bool Output) { diff --git a/SU2_CFD/src/solvers/CSolver.cpp b/SU2_CFD/src/solvers/CSolver.cpp index bb064ff649f4..a7d0d262dc3d 100644 --- a/SU2_CFD/src/solvers/CSolver.cpp +++ b/SU2_CFD/src/solvers/CSolver.cpp @@ -2317,7 +2317,7 @@ void CSolver::CompleteComms(CGeometry *geometry, } -void CSolver::ResetCFLAdapt(){ +void CSolver::ResetCFLAdapt() { NonLinRes_Series.clear(); NonLinRes_Value = 0; NonLinRes_Func = 0; diff --git a/SU2_CFD/src/solvers/CTurbSASolver.cpp b/SU2_CFD/src/solvers/CTurbSASolver.cpp index a141bb10f292..61ed84e0d972 100644 --- a/SU2_CFD/src/solvers/CTurbSASolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSASolver.cpp @@ -270,9 +270,6 @@ CTurbSASolver::~CTurbSASolver(void) { void CTurbSASolver::Preprocessing(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh, unsigned short iRKStep, unsigned short RunTime_EqSystem, bool Output) { - SU2_OMP_PARALLEL - { - bool limiter_turb = (config->GetKind_SlopeLimit_Turb() != NO_LIMITER) && (config->GetInnerIter() <= config->GetLimiterIter()); unsigned short kind_hybridRANSLES = config->GetKind_HybridRANSLES(); @@ -323,15 +320,10 @@ void CTurbSASolver::Preprocessing(CGeometry *geometry, CSolver **solver_containe } - } // end SU2_OMP_PARALLEL - } void CTurbSASolver::Postprocessing(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh) { - SU2_OMP_PARALLEL - { - const su2double cv1_3 = 7.1*7.1*7.1; const bool neg_spalart_allmaras = (config->GetKind_Turb_Model() == SA_NEG); @@ -359,8 +351,6 @@ void CTurbSASolver::Postprocessing(CGeometry *geometry, CSolver **solver_contain } - } // end SU2_OMP_PARALLEL - } void CTurbSASolver::Source_Residual(CGeometry *geometry, CSolver **solver_container, @@ -372,10 +362,6 @@ void CTurbSASolver::Source_Residual(CGeometry *geometry, CSolver **solver_contai CVariable* flowNodes = solver_container[FLOW_SOL]->GetNodes(); - /*--- Start OpenMP parallel section. ---*/ - - SU2_OMP_PARALLEL - { /*--- Pick one numerics object per thread. ---*/ CNumerics* numerics = numerics_container[SOURCE_FIRST_TERM + omp_get_thread_num()*MAX_TERMS]; @@ -463,7 +449,6 @@ void CTurbSASolver::Source_Residual(CGeometry *geometry, CSolver **solver_contai } } - } // end SU2_OMP_PARALLEL } void CTurbSASolver::Source_Template(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, diff --git a/SU2_CFD/src/solvers/CTurbSSTSolver.cpp b/SU2_CFD/src/solvers/CTurbSSTSolver.cpp index 36382ad7851e..e8004e8ccf02 100644 --- a/SU2_CFD/src/solvers/CTurbSSTSolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSSTSolver.cpp @@ -271,9 +271,6 @@ CTurbSSTSolver::~CTurbSSTSolver(void) { void CTurbSSTSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh, unsigned short iRKStep, unsigned short RunTime_EqSystem, bool Output) { - SU2_OMP_PARALLEL - { - const bool limiter_turb = (config->GetKind_SlopeLimit_Turb() != NO_LIMITER) && (config->GetInnerIter() <= config->GetLimiterIter()); @@ -300,16 +297,11 @@ void CTurbSSTSolver::Preprocessing(CGeometry *geometry, CSolver **solver_contain if (limiter_turb) SetSolution_Limiter(geometry, config); - } // end SU2_OMP_PARALLEL - } void CTurbSSTSolver::Postprocessing(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh) { - SU2_OMP_PARALLEL - { - const su2double a1 = constants[7]; /*--- Compute turbulence gradients. ---*/ @@ -351,8 +343,6 @@ void CTurbSSTSolver::Postprocessing(CGeometry *geometry, CSolver **solver_contai } - } // end SU2_OMP_PARALLEL - } void CTurbSSTSolver::Source_Residual(CGeometry *geometry, CSolver **solver_container, @@ -360,10 +350,6 @@ void CTurbSSTSolver::Source_Residual(CGeometry *geometry, CSolver **solver_conta CVariable* flowNodes = solver_container[FLOW_SOL]->GetNodes(); - /*--- Start OpenMP parallel section. ---*/ - - SU2_OMP_PARALLEL - { /*--- Pick one numerics object per thread. ---*/ CNumerics* numerics = numerics_container[SOURCE_FIRST_TERM + omp_get_thread_num()*MAX_TERMS]; @@ -422,7 +408,6 @@ void CTurbSSTSolver::Source_Residual(CGeometry *geometry, CSolver **solver_conta } - } // end SU2_OMP_PARALLEL } void CTurbSSTSolver::Source_Template(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, diff --git a/SU2_CFD/src/solvers/CTurbSolver.cpp b/SU2_CFD/src/solvers/CTurbSolver.cpp index ae31272d6c37..b2c13b08571b 100644 --- a/SU2_CFD/src/solvers/CTurbSolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSolver.cpp @@ -93,10 +93,6 @@ void CTurbSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_containe CVariable* flowNodes = solver_container[FLOW_SOL]->GetNodes(); - /*--- Start OpenMP parallel section. ---*/ - - SU2_OMP_PARALLEL - { /*--- Pick one numerics object per thread. ---*/ CNumerics* numerics = numerics_container[CONV_TERM + omp_get_thread_num()*MAX_TERMS]; @@ -233,7 +229,7 @@ void CTurbSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_containe } } // end color loop - } // end SU2_OMP_PARALLEL + } void CTurbSolver::Viscous_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics_container, @@ -241,10 +237,6 @@ void CTurbSolver::Viscous_Residual(CGeometry *geometry, CSolver **solver_contain CVariable* flowNodes = solver_container[FLOW_SOL]->GetNodes(); - /*--- Start OpenMP parallel section. ---*/ - - SU2_OMP_PARALLEL - { /*--- Pick one numerics object per thread. ---*/ CNumerics* numerics = numerics_container[VISC_TERM + omp_get_thread_num()*MAX_TERMS]; @@ -307,7 +299,7 @@ void CTurbSolver::Viscous_Residual(CGeometry *geometry, CSolver **solver_contain } } // end color loop - } // end SU2_OMP_PARALLEL + } void CTurbSolver::BC_Sym_Plane(CGeometry *geometry, @@ -410,10 +402,6 @@ void CTurbSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver_ CVariable* flowNodes = solver_container[FLOW_SOL]->GetNodes(); - /*--- Start OpenMP parallel section. ---*/ - - SU2_OMP_PARALLEL - { /*--- Set shared residual variables to 0 and declare * local ones for current thread to work on. ---*/ @@ -544,8 +532,8 @@ void CTurbSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver_ SetResidual_RMS(geometry, config); } + SU2_OMP_BARRIER - } // end SU2_OMP_PARALLEL } void CTurbSolver::ComputeUnderRelaxationFactor(CSolver **solver_container, CConfig *config) { @@ -618,11 +606,6 @@ void CTurbSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_con const su2double TimeStep = config->GetDelta_UnstTimeND(); - /*--- Start OpenMP parallel section. ---*/ - - SU2_OMP_PARALLEL - { - /*--- Local variables ---*/ unsigned short iVar, iMarker, iDim; @@ -913,8 +896,6 @@ void CTurbSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_con } // end dynamic grid - } // end SU2_OMP_PARALLEL - } From f59037699448c0c2325048fed1b4c0d8357208ef Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Tue, 11 Feb 2020 16:44:03 +0000 Subject: [PATCH 111/118] leave TODO in CSolver::AdaptCFLNumber --- SU2_CFD/src/solvers/CSolver.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/SU2_CFD/src/solvers/CSolver.cpp b/SU2_CFD/src/solvers/CSolver.cpp index a7d0d262dc3d..0bee19805db1 100644 --- a/SU2_CFD/src/solvers/CSolver.cpp +++ b/SU2_CFD/src/solvers/CSolver.cpp @@ -2331,6 +2331,8 @@ void CSolver::AdaptCFLNumber(CGeometry **geometry, CSolver ***solver_container, CConfig *config) { + /// TODO: Add OpenMP stuff to this method + /* Adapt the CFL number on all multigrid levels using an exponential progression with under-relaxation approach. */ From f1880722170e3b7d833c164b99637c32042c4d85 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Wed, 12 Feb 2020 10:41:42 +0000 Subject: [PATCH 112/118] do the MG and SG iterations in parallel only if the solver supports it --- SU2_CFD/include/solvers/CEulerSolver.hpp | 5 ++ SU2_CFD/include/solvers/CSolver.hpp | 7 ++ SU2_CFD/include/solvers/CTransLMSolver.hpp | 5 ++ SU2_CFD/include/solvers/CTurbSolver.hpp | 5 ++ .../src/integration/CMultiGridIntegration.cpp | 73 +++++++++++-------- .../integration/CSingleGridIntegration.cpp | 28 +++---- SU2_CFD/src/solvers/CEulerSolver.cpp | 57 ++++++--------- SU2_CFD/src/solvers/CSolver.cpp | 26 ++----- 8 files changed, 103 insertions(+), 103 deletions(-) diff --git a/SU2_CFD/include/solvers/CEulerSolver.hpp b/SU2_CFD/include/solvers/CEulerSolver.hpp index 47dd22c38dc8..4841b9bf78c7 100644 --- a/SU2_CFD/include/solvers/CEulerSolver.hpp +++ b/SU2_CFD/include/solvers/CEulerSolver.hpp @@ -2879,4 +2879,9 @@ class CEulerSolver : public CSolver { */ void ComputeVerificationError(CGeometry *geometry, CConfig *config) final; + /*! + * \brief The Euler and NS solvers support MPI+OpenMP (except the BC bits). + */ + inline bool GetHasHybridParallel() const final { return true; } + }; diff --git a/SU2_CFD/include/solvers/CSolver.hpp b/SU2_CFD/include/solvers/CSolver.hpp index 966dd6a9fa53..65da608c99d6 100644 --- a/SU2_CFD/include/solvers/CSolver.hpp +++ b/SU2_CFD/include/solvers/CSolver.hpp @@ -4717,6 +4717,13 @@ class CSolver { */ virtual su2double GetMaximum_Volume() const { return 0.0; } + /*! + * \brief Whether the methods of the solver called by multi/single-grid + * iteration can be executed by multiple threads. + * \return Should return true if "yes", false if "no". + */ + inline virtual bool GetHasHybridParallel() const { return false; } + protected: /*! * \brief Allocate the memory for the verification solution, if necessary. diff --git a/SU2_CFD/include/solvers/CTransLMSolver.hpp b/SU2_CFD/include/solvers/CTransLMSolver.hpp index 8723d0bca98d..9ec5bd7fd73a 100644 --- a/SU2_CFD/include/solvers/CTransLMSolver.hpp +++ b/SU2_CFD/include/solvers/CTransLMSolver.hpp @@ -236,6 +236,11 @@ class CTransLMSolver final : public CTurbSolver { CSolver **solver_container, CConfig *config) override; + /*! + * \brief No support for OpenMP+MPI. + */ + inline bool GetHasHybridParallel() const override { return false; } + // Another set of matrix structures for the Lm equations CSysMatrix JacobianItmc; /*!< \brief Complete sparse Jacobian structure for implicit computations. */ su2double *LinSysSolItmc; /*!< \brief vector to store iterative solution of implicit linear system. */ diff --git a/SU2_CFD/include/solvers/CTurbSolver.hpp b/SU2_CFD/include/solvers/CTurbSolver.hpp index e2117c1d0269..fda4736d7286 100644 --- a/SU2_CFD/include/solvers/CTurbSolver.hpp +++ b/SU2_CFD/include/solvers/CTurbSolver.hpp @@ -355,4 +355,9 @@ class CTurbSolver : public CSolver { Inlet_TurbVars[val_marker][val_vertex][val_dim] = val_turb_var; } + /*! + * \brief SA and SST support OpenMP+MPI. + */ + inline bool GetHasHybridParallel() const override { return true; } + }; diff --git a/SU2_CFD/src/integration/CMultiGridIntegration.cpp b/SU2_CFD/src/integration/CMultiGridIntegration.cpp index fab9c897e05c..978d50240930 100644 --- a/SU2_CFD/src/integration/CMultiGridIntegration.cpp +++ b/SU2_CFD/src/integration/CMultiGridIntegration.cpp @@ -39,28 +39,37 @@ void CMultiGridIntegration::MultiGrid_Iteration(CGeometry ****geometry, unsigned short iZone, unsigned short iInst) { - /*--- Start an OpenMP parallel region covering the entire MG iteration. ---*/ + bool direct; + switch (config[iZone]->GetKind_Solver()) { + case EULER: + case NAVIER_STOKES: + case RANS: + case FEM_EULER: + case FEM_NAVIER_STOKES: + case FEM_RANS: + case FEM_LES: + case DISC_ADJ_EULER: + case DISC_ADJ_NAVIER_STOKES: + case DISC_ADJ_FEM_EULER: + case DISC_ADJ_FEM_NS: + case DISC_ADJ_RANS: + direct = true; + break; + default: + direct = false; + break; + } - SU2_OMP_PARALLEL + const unsigned short Solver_Position = config[iZone]->GetContainerPosition(RunTime_EqSystem); + + /*--- Start an OpenMP parallel region covering the entire MG iteration, if the solver supports it. ---*/ + + SU2_OMP_PARALLEL_(if(solver_container[iZone][iInst][MESH_0][Solver_Position]->GetHasHybridParallel())) { su2double monitor = 1.0; bool FullMG = false; - const bool direct = ((config[iZone]->GetKind_Solver() == EULER) || - (config[iZone]->GetKind_Solver() == NAVIER_STOKES) || - (config[iZone]->GetKind_Solver() == RANS) || - (config[iZone]->GetKind_Solver() == FEM_EULER) || - (config[iZone]->GetKind_Solver() == FEM_NAVIER_STOKES) || - (config[iZone]->GetKind_Solver() == FEM_RANS) || - (config[iZone]->GetKind_Solver() == FEM_LES) || - (config[iZone]->GetKind_Solver() == DISC_ADJ_EULER) || - (config[iZone]->GetKind_Solver() == DISC_ADJ_NAVIER_STOKES) || - (config[iZone]->GetKind_Solver() == DISC_ADJ_FEM_EULER) || - (config[iZone]->GetKind_Solver() == DISC_ADJ_FEM_NS) || - (config[iZone]->GetKind_Solver() == DISC_ADJ_RANS)); - - const unsigned short SolContainer_Position = config[iZone]->GetContainerPosition(RunTime_EqSystem); unsigned short RecursiveParam = config[iZone]->GetMGCycle(); if (config[iZone]->GetMGCycle() == FULLMG_CYCLE) { @@ -75,8 +84,8 @@ void CMultiGridIntegration::MultiGrid_Iteration(CGeometry ****geometry, if (!config[iZone]->GetRestart() && FullMG && direct && ( Convergence_FullMG && (FinestMesh != MESH_0 ))) { SetProlongated_Solution(RunTime_EqSystem, - solver_container[iZone][iInst][FinestMesh-1][SolContainer_Position], - solver_container[iZone][iInst][FinestMesh][SolContainer_Position], + solver_container[iZone][iInst][FinestMesh-1][Solver_Position], + solver_container[iZone][iInst][FinestMesh][Solver_Position], geometry[iZone][iInst][FinestMesh-1], geometry[iZone][iInst][FinestMesh], config[iZone]); @@ -93,15 +102,15 @@ void CMultiGridIntegration::MultiGrid_Iteration(CGeometry ****geometry, /*--- Perform the Full Approximation Scheme multigrid ---*/ MultiGrid_Cycle(geometry, solver_container, numerics_container, config, - FinestMesh, RecursiveParam, RunTime_EqSystem, - iZone, iInst); + FinestMesh, RecursiveParam, RunTime_EqSystem, iZone, iInst); /*--- Computes primitive variables and gradients in the finest mesh (useful for the next solver (turbulence) and output ---*/ - solver_container[iZone][iInst][MESH_0][SolContainer_Position]->Preprocessing(geometry[iZone][iInst][MESH_0], - solver_container[iZone][iInst][MESH_0], - config[iZone], MESH_0, NO_RK_ITER, - RunTime_EqSystem, true); + solver_container[iZone][iInst][MESH_0][Solver_Position]->Preprocessing(geometry[iZone][iInst][MESH_0], + solver_container[iZone][iInst][MESH_0], + config[iZone], MESH_0, NO_RK_ITER, + RunTime_EqSystem, true); + /*--- Compute non-dimensional parameters and the convergence monitor ---*/ NonDimensional_Parameters(geometry[iZone][iInst], solver_container[iZone][iInst], @@ -124,15 +133,15 @@ void CMultiGridIntegration::MultiGrid_Cycle(CGeometry ****geometry, CConfig* config = config_container[iZone]; - const unsigned short SolContainer_Position = config->GetContainerPosition(RunTime_EqSystem); + const unsigned short Solver_Position = config->GetContainerPosition(RunTime_EqSystem); const bool classical_rk4 = (config->GetKind_TimeIntScheme() == CLASSICAL_RK4_EXPLICIT); /*--- Shorter names to refer to fine grid entities. ---*/ CGeometry* geometry_fine = geometry[iZone][iInst][iMesh]; CSolver** solver_container_fine = solver_container[iZone][iInst][iMesh]; - CSolver* solver_fine = solver_container_fine[SolContainer_Position]; - CNumerics** numerics_fine = numerics_container[iZone][iInst][iMesh][SolContainer_Position]; + CSolver* solver_fine = solver_container_fine[Solver_Position]; + CNumerics** numerics_fine = numerics_container[iZone][iInst][iMesh][Solver_Position]; /*--- Number of RK steps. ---*/ @@ -206,8 +215,8 @@ void CMultiGridIntegration::MultiGrid_Cycle(CGeometry ****geometry, CGeometry* geometry_coarse = geometry[iZone][iInst][iMesh+1]; CSolver** solver_container_coarse = solver_container[iZone][iInst][iMesh+1]; - CSolver* solver_coarse = solver_container_coarse[SolContainer_Position]; - CNumerics** numerics_coarse = numerics_container[iZone][iInst][iMesh+1][SolContainer_Position]; + CSolver* solver_coarse = solver_container_coarse[Solver_Position]; + CNumerics** numerics_coarse = numerics_container[iZone][iInst][iMesh+1][Solver_Position]; /*--- Compute $r_k = P_k + F_k(u_k)$ ---*/ @@ -543,7 +552,7 @@ void CMultiGridIntegration::SetRestricted_Solution(unsigned short RunTime_EqSyst su2double Area_Parent, Area_Children, Vector[3] = {0.0}; const su2double *Solution_Fine = nullptr, *Grid_Vel = nullptr; - const unsigned short SolContainer_Position = config->GetContainerPosition(RunTime_EqSystem); + const unsigned short Solver_Position = config->GetContainerPosition(RunTime_EqSystem); const unsigned short nVar = sol_coarse->GetnVar(); const unsigned short nDim = geo_fine->GetnDim(); const bool grid_movement = config->GetGrid_Movement(); @@ -587,7 +596,7 @@ void CMultiGridIntegration::SetRestricted_Solution(unsigned short RunTime_EqSyst Point_Coarse = geo_coarse->vertex[iMarker][iVertex]->GetNode(); - if (SolContainer_Position == FLOW_SOL) { + if (Solver_Position == FLOW_SOL) { /*--- At moving walls, set the solution based on the new density and wall velocity ---*/ @@ -605,7 +614,7 @@ void CMultiGridIntegration::SetRestricted_Solution(unsigned short RunTime_EqSyst } - if (SolContainer_Position == ADJFLOW_SOL) { + if (Solver_Position == ADJFLOW_SOL) { sol_coarse->GetNodes()->SetVelSolutionDVector(Point_Coarse); } diff --git a/SU2_CFD/src/integration/CSingleGridIntegration.cpp b/SU2_CFD/src/integration/CSingleGridIntegration.cpp index a5fee270c33e..85745ebf2881 100644 --- a/SU2_CFD/src/integration/CSingleGridIntegration.cpp +++ b/SU2_CFD/src/integration/CSingleGridIntegration.cpp @@ -36,13 +36,13 @@ void CSingleGridIntegration::SingleGrid_Iteration(CGeometry ****geometry, CSolve unsigned short RunTime_EqSystem, unsigned short iZone, unsigned short iInst) { + const unsigned short Solver_Position = config[iZone]->GetContainerPosition(RunTime_EqSystem); + /*--- Start an OpenMP parallel region covering the entire iteration. ---*/ - SU2_OMP_PARALLEL + SU2_OMP_PARALLEL_(if(solver_container[iZone][iInst][MESH_0][Solver_Position]->GetHasHybridParallel())) { - unsigned short SolContainer_Position = config[iZone]->GetContainerPosition(RunTime_EqSystem); - unsigned short FinestMesh = config[iZone]->GetFinestMesh(); CGeometry* geometry_fine = geometry[iZone][iInst][FinestMesh]; @@ -50,22 +50,22 @@ void CSingleGridIntegration::SingleGrid_Iteration(CGeometry ****geometry, CSolve /*--- Preprocessing ---*/ - solvers_fine[SolContainer_Position]->Preprocessing(geometry_fine, solvers_fine, config[iZone], - FinestMesh, 0, RunTime_EqSystem, false); + solvers_fine[Solver_Position]->Preprocessing(geometry_fine, solvers_fine, config[iZone], + FinestMesh, 0, RunTime_EqSystem, false); /*--- Set the old solution ---*/ - solvers_fine[SolContainer_Position]->Set_OldSolution(geometry_fine); + solvers_fine[Solver_Position]->Set_OldSolution(geometry_fine); /*--- Time step evaluation ---*/ - solvers_fine[SolContainer_Position]->SetTime_Step(geometry_fine, solvers_fine, config[iZone], - FinestMesh, config[iZone]->GetTimeIter()); + solvers_fine[Solver_Position]->SetTime_Step(geometry_fine, solvers_fine, config[iZone], + FinestMesh, config[iZone]->GetTimeIter()); /*--- Space integration ---*/ Space_Integration(geometry_fine, solvers_fine, - numerics_container[iZone][iInst][FinestMesh][SolContainer_Position], + numerics_container[iZone][iInst][FinestMesh][Solver_Position], config[iZone], FinestMesh, NO_RK_ITER, RunTime_EqSystem); /*--- Time integration ---*/ @@ -74,7 +74,7 @@ void CSingleGridIntegration::SingleGrid_Iteration(CGeometry ****geometry, CSolve /*--- Postprocessing ---*/ - solvers_fine[SolContainer_Position]->Postprocessing(geometry_fine, solvers_fine, config[iZone], FinestMesh); + solvers_fine[Solver_Position]->Postprocessing(geometry_fine, solvers_fine, config[iZone], FinestMesh); if (RunTime_EqSystem == RUNTIME_HEAT_SYS) { SU2_OMP_MASTER @@ -89,15 +89,15 @@ void CSingleGridIntegration::SingleGrid_Iteration(CGeometry ****geometry, CSolve for (unsigned short iMesh = FinestMesh; iMesh < config[iZone]->GetnMGLevels(); iMesh++) { SetRestricted_Solution(RunTime_EqSystem, - solver_container[iZone][iInst][iMesh][SolContainer_Position], - solver_container[iZone][iInst][iMesh+1][SolContainer_Position], + solver_container[iZone][iInst][iMesh][Solver_Position], + solver_container[iZone][iInst][iMesh+1][Solver_Position], geometry[iZone][iInst][iMesh], geometry[iZone][iInst][iMesh+1], config[iZone]); SetRestricted_EddyVisc(RunTime_EqSystem, - solver_container[iZone][iInst][iMesh][SolContainer_Position], - solver_container[iZone][iInst][iMesh+1][SolContainer_Position], + solver_container[iZone][iInst][iMesh][Solver_Position], + solver_container[iZone][iInst][iMesh+1][Solver_Position], geometry[iZone][iInst][iMesh], geometry[iZone][iInst][iMesh+1], config[iZone]); diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index e41f09678263..e0059907768a 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -11255,7 +11255,7 @@ void CEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_co /*--- Local variables ---*/ - unsigned short iVar, jVar, iMarker, iDim; + unsigned short iVar, iMarker, iDim, iNeigh; unsigned long iPoint, jPoint, iEdge, iVertex; const su2double *U_time_nM1 = nullptr, *U_time_n = nullptr, *U_time_nP1 = nullptr; @@ -11297,9 +11297,9 @@ void CEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_co time discretization scheme (1st- or 2nd-order).---*/ for (iVar = 0; iVar < nVar; iVar++) { - if (config->GetTime_Marching() == DT_STEPPING_1ST) + if (first_order) LinSysRes(iPoint,iVar) += (U_time_nP1[iVar] - U_time_n[iVar])*Volume_nP1 / TimeStep; - if (config->GetTime_Marching() == DT_STEPPING_2ND) + if (second_order) LinSysRes(iPoint,iVar) += ( 3.0*U_time_nP1[iVar] - 4.0*U_time_n[iVar] +1.0*U_time_nM1[iVar])*Volume_nP1 / (2.0*TimeStep); } @@ -11323,46 +11323,31 @@ void CEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_co we will loop over the edges and boundaries to compute the GCL component of the dual time source term that depends on grid velocities. ---*/ - /// TODO: This edge loop needs to be transformed to point loop as contrary - /// to turbulence solvers, this method is also called for coarse grids. - - SU2_OMP_MASTER - for (iEdge = 0; iEdge < geometry->GetnEdge(); iEdge++) { - - /*--- Get indices for nodes i & j plus the face normal ---*/ - - iPoint = geometry->edge[iEdge]->GetNode(0); - jPoint = geometry->edge[iEdge]->GetNode(1); - Normal = geometry->edge[iEdge]->GetNormal(); - - /*--- Grid velocities stored at nodes i & j ---*/ + SU2_OMP_FOR_STAT(omp_chunk_size) + for (iPoint = 0; iPoint < nPointDomain; ++iPoint) { GridVel_i = geometry->node[iPoint]->GetGridVel(); - GridVel_j = geometry->node[jPoint]->GetGridVel(); - - /*--- Compute the GCL term by averaging the grid velocities at the - edge mid-point and dotting with the face normal. ---*/ + U_time_n = nodes->GetSolution_time_n(iPoint); - Residual_GCL = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - Residual_GCL += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; + for (iNeigh = 0; iNeigh < geometry->node[iPoint]->GetnNeighbor(); iNeigh++) { - /*--- Compute the GCL component of the source term for node i ---*/ + iEdge = geometry->node[iPoint]->GetEdge(iNeigh); + Normal = geometry->edge[iEdge]->GetNormal(); - 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); + jPoint = geometry->node[iPoint]->GetPoint(iNeigh); + GridVel_j = geometry->node[jPoint]->GetGridVel(); - /*--- Compute the GCL component of the source term for node j ---*/ + /*--- Determine whether to consider the normal outward or inward. ---*/ + su2double dir = (geometry->edge[iEdge]->GetNode(0) == iPoint)? 0.5 : -0.5; - 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); + Residual_GCL = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + Residual_GCL += dir*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; + for (iVar = 0; iVar < nVar; iVar++) + LinSysRes(iPoint,iVar) += U_time_n[iVar]*Residual_GCL; + } } - SU2_OMP_BARRIER /*--- Loop over the boundary edges ---*/ @@ -11424,9 +11409,9 @@ void CEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_co due to the time discretization has a new form.---*/ for (iVar = 0; iVar < nVar; iVar++) { - if (config->GetTime_Marching() == DT_STEPPING_1ST) + if (first_order) LinSysRes(iPoint,iVar) += (U_time_nP1[iVar] - U_time_n[iVar])*(Volume_nP1/TimeStep); - if (config->GetTime_Marching() == DT_STEPPING_2ND) + if (second_order) LinSysRes(iPoint,iVar) += (U_time_nP1[iVar] - U_time_n[iVar])*(3.0*Volume_nP1/(2.0*TimeStep)) + (U_time_nM1[iVar] - U_time_n[iVar])*(Volume_nM1/(2.0*TimeStep)); } diff --git a/SU2_CFD/src/solvers/CSolver.cpp b/SU2_CFD/src/solvers/CSolver.cpp index 0bee19805db1..3c26438d6f46 100644 --- a/SU2_CFD/src/solvers/CSolver.cpp +++ b/SU2_CFD/src/solvers/CSolver.cpp @@ -2331,7 +2331,7 @@ void CSolver::AdaptCFLNumber(CGeometry **geometry, CSolver ***solver_container, CConfig *config) { - /// TODO: Add OpenMP stuff to this method + /// TODO: Add OpenMP stuff to this method. /* Adapt the CFL number on all multigrid levels using an exponential progression with under-relaxation approach. */ @@ -2497,26 +2497,10 @@ void CSolver::AdaptCFLNumber(CGeometry **geometry, /* 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; + SU2_MPI::Allreduce(&myCFLMin, &Min_CFL_Local, 1, MPI_DOUBLE, MPI_MIN, MPI_COMM_WORLD); + SU2_MPI::Allreduce(&myCFLMax, &Max_CFL_Local, 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD); + SU2_MPI::Allreduce(&myCFLSum, &Avg_CFL_Local, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); + Avg_CFL_Local /= su2double(geometry[iMesh]->GetGlobal_nPointDomain()); } From 3a123cd145d94927995ed8c4460ee77290384024 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Wed, 12 Feb 2020 10:55:31 +0000 Subject: [PATCH 113/118] cleanup unreachable calls to FEA time integration methods --- SU2_CFD/src/integration/CIntegration.cpp | 41 +++++------------------- 1 file changed, 8 insertions(+), 33 deletions(-) diff --git a/SU2_CFD/src/integration/CIntegration.cpp b/SU2_CFD/src/integration/CIntegration.cpp index 98fdb968d38b..99aa92e8e5bf 100644 --- a/SU2_CFD/src/integration/CIntegration.cpp +++ b/SU2_CFD/src/integration/CIntegration.cpp @@ -199,45 +199,20 @@ void CIntegration::Time_Integration(CGeometry *geometry, CSolver **solver_contai unsigned short iRKStep, unsigned short RunTime_EqSystem) { unsigned short MainSolver = config->GetContainerPosition(RunTime_EqSystem); - unsigned short KindSolver = config->GetKind_Solver(); - /*--- Perform the time integration ---*/ - - /*--- Fluid time integration schemes ---*/ - - if (KindSolver != FEM_ELASTICITY) { - - switch (config->GetKind_TimeIntScheme()) { - case (RUNGE_KUTTA_EXPLICIT): - solver_container[MainSolver]->ExplicitRK_Iteration(geometry, solver_container, config, iRKStep); - break; - case (CLASSICAL_RK4_EXPLICIT): - solver_container[MainSolver]->ClassicalRK4_Iteration(geometry, solver_container, config, iRKStep); - break; - case (EULER_EXPLICIT): - solver_container[MainSolver]->ExplicitEuler_Iteration(geometry, solver_container, config); - break; - case (EULER_IMPLICIT): - solver_container[MainSolver]->ImplicitEuler_Iteration(geometry, solver_container, config); - break; - } - - /*--- Structural time integration schemes ---*/ - - } - else if (KindSolver == FEM_ELASTICITY) { - - switch (config->GetKind_TimeIntScheme_FEA()) { - case (CD_EXPLICIT): + switch (config->GetKind_TimeIntScheme()) { + case (RUNGE_KUTTA_EXPLICIT): solver_container[MainSolver]->ExplicitRK_Iteration(geometry, solver_container, config, iRKStep); break; - case (NEWMARK_IMPLICIT): - solver_container[MainSolver]->ImplicitNewmark_Iteration(geometry, solver_container, config); + case (CLASSICAL_RK4_EXPLICIT): + solver_container[MainSolver]->ClassicalRK4_Iteration(geometry, solver_container, config, iRKStep); break; - case (GENERALIZED_ALPHA): + case (EULER_EXPLICIT): + solver_container[MainSolver]->ExplicitEuler_Iteration(geometry, solver_container, config); + break; + case (EULER_IMPLICIT): solver_container[MainSolver]->ImplicitEuler_Iteration(geometry, solver_container, config); break; - } } } From e1eb7862425a6dedc47e8ca5617357a02de88d20 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Wed, 12 Feb 2020 12:37:05 +0000 Subject: [PATCH 114/118] update some sliding cases (again) --- TestCases/parallel_regression.py | 2 +- TestCases/serial_regression.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index e1b34dbf26fd..eeca81b69e32 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -911,7 +911,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.397871, 0.352785, 0.405448] #last 4 columns + channel_2D.test_vals = [2.000000, 0.000000, 0.397891, 0.352785, 0.405448] #last 4 columns channel_2D.su2_exec = "parallel_computation.py -f" channel_2D.timeout = 100 channel_2D.tol = 0.00001 diff --git a/TestCases/serial_regression.py b/TestCases/serial_regression.py index 95f3896d649b..6ffe404cf79f 100644 --- a/TestCases/serial_regression.py +++ b/TestCases/serial_regression.py @@ -1056,7 +1056,7 @@ def main(): uniform_flow.cfg_dir = "sliding_interface/uniform_flow" uniform_flow.cfg_file = "uniform_NN.cfg" uniform_flow.test_iter = 2 - uniform_flow.test_vals = [2.000000, 0.000000, -0.205134, -13.253497] #last 4 columns + uniform_flow.test_vals = [2.000000, 0.000000, -0.205134, -13.250256] #last 4 columns uniform_flow.su2_exec = "SU2_CFD" uniform_flow.timeout = 1600 uniform_flow.tol = 0.000001 @@ -1069,7 +1069,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.398017, 0.352786, 0.405475] #last 4 columns + channel_2D.test_vals = [2.000000, 0.000000, 0.397985, 0.352786, 0.405475] #last 4 columns channel_2D.su2_exec = "SU2_CFD" channel_2D.timeout = 100 channel_2D.tol = 0.00001 From 6ea86f4f28dfedcfa2fbee9e1c51c3157559c35f Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Wed, 12 Feb 2020 16:58:32 +0000 Subject: [PATCH 115/118] allow compilation with AD+OpenMP (experimental) --- Common/include/omp_structure.hpp | 17 +++++++- Common/src/linear_algebra/CSysVector.cpp | 16 +------ SU2_CFD/src/solvers/CFEASolver.cpp | 53 +++++++++++++++++------- 3 files changed, 56 insertions(+), 30 deletions(-) diff --git a/Common/include/omp_structure.hpp b/Common/include/omp_structure.hpp index 662779582ef1..9bf3058c44af 100644 --- a/Common/include/omp_structure.hpp +++ b/Common/include/omp_structure.hpp @@ -46,7 +46,8 @@ /*--- Detect compilation with OpenMP support, protect agaisnt * using OpenMP with AD (not supported yet). ---*/ -#if defined(_OPENMP) && !defined(CODI_REVERSE_TYPE) && !defined(CODI_FORWARD_TYPE) +//#if defined(_OPENMP) && !defined(CODI_REVERSE_TYPE) && !defined(CODI_FORWARD_TYPE) +#if defined(_OPENMP) #define HAVE_OMP #include @@ -149,3 +150,17 @@ void parallelSet(size_t size, T val, U* dst) SU2_OMP_FOR_STAT(4196) for(size_t i=0; i +inline void safeAdd(T rhs, T& lhs) +{ + SU2_OMP_CRITICAL + lhs += rhs; +} + +template<> +inline void safeAdd(passivedouble rhs, passivedouble& lhs) +{ + SU2_OMP_ATOMIC + lhs += rhs; +} diff --git a/Common/src/linear_algebra/CSysVector.cpp b/Common/src/linear_algebra/CSysVector.cpp index ee9dff71a218..7461ddca3e0f 100644 --- a/Common/src/linear_algebra/CSysVector.cpp +++ b/Common/src/linear_algebra/CSysVector.cpp @@ -205,20 +205,6 @@ void CSysVector::CopyToArray(ScalarType* u_array) const { for(auto i=0ul; i -inline void reduce(ScalarType local, ScalarType& shared) { - SU2_OMP_CRITICAL - shared += local; -} -template<> -inline void reduce(passivedouble local, passivedouble& shared) { - SU2_OMP_ATOMIC - shared += local; -} - template ScalarType CSysVector::dot(const CSysVector & u) const { @@ -235,7 +221,7 @@ ScalarType CSysVector::dot(const CSysVector & u) const { sum += vec_val[i]*u.vec_val[i]; /*--- Update shared variable with "our" partial sum. ---*/ - reduce(sum, dotRes); + safeAdd(sum, dotRes); #ifdef HAVE_MPI /*--- Reduce across all mpi ranks, only master thread communicates. ---*/ diff --git a/SU2_CFD/src/solvers/CFEASolver.cpp b/SU2_CFD/src/solvers/CFEASolver.cpp index 8a92716470ef..6d60f173a0c4 100644 --- a/SU2_CFD/src/solvers/CFEASolver.cpp +++ b/SU2_CFD/src/solvers/CFEASolver.cpp @@ -3058,7 +3058,11 @@ void CFEASolver::Compute_OFRefGeom(CGeometry *geometry, CSolver **solver_contain su2double objective_function = 0.0; - SU2_OMP_PARALLEL_(for schedule(static,omp_chunk_size) reduction(+:objective_function)) + SU2_OMP_PARALLEL + { + su2double obj_fun_local = 0.0; + + SU2_OMP_FOR_STAT(omp_chunk_size) for (unsigned long iPoint = 0; iPoint < nPointDomain; iPoint++) { for (unsigned short iVar = 0; iVar < nVar; iVar++) { @@ -3070,9 +3074,10 @@ void CFEASolver::Compute_OFRefGeom(CGeometry *geometry, CSolver **solver_contain su2double current_solution = nodes->GetSolution(iPoint,iVar); /*--- The objective function is the sum of the difference between solution and difference, squared ---*/ - objective_function += pow(current_solution - reference_geometry, 2); + obj_fun_local += pow(current_solution - reference_geometry, 2); } - + } + safeAdd(obj_fun_local, objective_function); } SU2_MPI::Allreduce(&objective_function, &Total_OFRefGeom, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); @@ -3195,17 +3200,25 @@ void CFEASolver::Compute_OFVolFrac(CGeometry *geometry, CSolver **solver_contain su2double total_volume = 0.0, integral = 0.0, discreteness = 0.0; - SU2_OMP_PARALLEL_(for schedule(static,omp_chunk_size) reduction(+:total_volume,integral,discreteness)) + SU2_OMP_PARALLEL + { + su2double tot_vol_loc = 0.0, integral_loc = 0.0, discrete_loc = 0.0; + + SU2_OMP_FOR_STAT(omp_chunk_size) for (unsigned long iElem = 0; iElem < nElement; ++iElem) { /*--- count only elements that belong to the partition ---*/ - if ( geometry->node[geometry->elem[iElem]->GetNode(0)]->GetDomain() ){ + if (geometry->node[geometry->elem[iElem]->GetNode(0)]->GetDomain()) { su2double volume = geometry->elem[iElem]->GetVolume(); su2double rho = element_properties[iElem]->GetPhysicalDensity(); - total_volume += volume; - integral += volume*rho; - discreteness += volume*4.0*rho*(1.0-rho); + tot_vol_loc += volume; + integral_loc += volume*rho; + discrete_loc += volume*4.0*rho*(1.0-rho); } } + safeAdd(tot_vol_loc, total_volume); + safeAdd(integral_loc, integral); + safeAdd(discrete_loc, discreteness); + } su2double tmp; SU2_MPI::Allreduce(&total_volume,&tmp,1,MPI_DOUBLE,MPI_SUM,MPI_COMM_WORLD); @@ -3250,7 +3263,11 @@ void CFEASolver::Compute_OFCompliance(CGeometry *geometry, CSolver **solver_cont su2double compliance = 0.0; - SU2_OMP_PARALLEL_(for schedule(static,omp_chunk_size) reduction(+:compliance)) + SU2_OMP_PARALLEL + { + su2double comp_local = 0.0; + + SU2_OMP_FOR_STAT(omp_chunk_size) for (unsigned long iPoint = 0; iPoint < nPointDomain; iPoint++) { unsigned short iVar; @@ -3276,7 +3293,9 @@ void CFEASolver::Compute_OFCompliance(CGeometry *geometry, CSolver **solver_cont /*--- Add work contribution from this node ---*/ for (iVar = 0; iVar < nVar; iVar++) - compliance += nodalForce[iVar]*nodes->GetSolution(iPoint,iVar); + comp_local += nodalForce[iVar]*nodes->GetSolution(iPoint,iVar); + } + safeAdd(comp_local, compliance); } SU2_MPI::Allreduce(&compliance, &Total_OFCompliance, 1,MPI_DOUBLE,MPI_SUM,MPI_COMM_WORLD); @@ -3302,7 +3321,11 @@ void CFEASolver::Stiffness_Penalty(CGeometry *geometry, CSolver **solver, CNumer su2double totalVolume_reduce = 0.0; /*--- Loop over the elements in the domain. ---*/ - SU2_OMP_PARALLEL_(for schedule(dynamic,omp_chunk_size) reduction(+:weightedValue,totalVolume)) + SU2_OMP_PARALLEL + { + su2double weighted_loc = 0.0, totalVol_loc = 0.0; + + SU2_OMP_FOR_DYN(omp_chunk_size) for (unsigned long iElem = 0; iElem < nElement; iElem++) { int thread = omp_get_thread_num(); @@ -3337,16 +3360,18 @@ void CFEASolver::Stiffness_Penalty(CGeometry *geometry, CSolver **solver, CNumer elementVolume = element->ComputeVolume(); // Compute the total volume - totalVolume += elementVolume; + totalVol_loc += elementVolume; // Retrieve the value of the design variable su2double dvValue = numerics[FEA_TERM]->Get_DV_Val(element_properties[iElem]->GetDV()); // Add the weighted sum of the value of the design variable - weightedValue += dvValue * elementVolume; + weighted_loc += dvValue * elementVolume; } - + } + safeAdd(totalVol_loc, totalVolume); + safeAdd(weighted_loc, weightedValue); } // Reduce value across processors for parallelization From 9bb71bbbeeec08db524b037085d961ae43e1a7c6 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Thu, 13 Feb 2020 16:40:35 +0000 Subject: [PATCH 116/118] cleanup color loops no more need for #ifdef HAVE_OMP --- Common/include/omp_structure.hpp | 22 ++-- Common/include/toolboxes/graph_toolbox.hpp | 50 ++++++++ Common/src/linear_algebra/CSysVector.cpp | 2 +- SU2_CFD/include/solvers/CEulerSolver.hpp | 12 +- SU2_CFD/include/solvers/CFEASolver.hpp | 11 +- SU2_CFD/include/solvers/CTurbSolver.hpp | 13 +- SU2_CFD/src/solvers/CEulerSolver.cpp | 65 +++------- SU2_CFD/src/solvers/CFEASolver.cpp | 134 ++++++--------------- SU2_CFD/src/solvers/CMeshSolver.cpp | 7 +- SU2_CFD/src/solvers/CTurbSolver.cpp | 52 +++----- 10 files changed, 159 insertions(+), 209 deletions(-) diff --git a/Common/include/omp_structure.hpp b/Common/include/omp_structure.hpp index 9bf3058c44af..60efbe837867 100644 --- a/Common/include/omp_structure.hpp +++ b/Common/include/omp_structure.hpp @@ -38,6 +38,8 @@ #pragma once +#include + #if defined(_MSC_VER) #define PRAGMIZE(X) __pragma(X) #else @@ -46,8 +48,7 @@ /*--- Detect compilation with OpenMP support, protect agaisnt * using OpenMP with AD (not supported yet). ---*/ -//#if defined(_OPENMP) && !defined(CODI_REVERSE_TYPE) && !defined(CODI_FORWARD_TYPE) -#if defined(_OPENMP) +#if defined(_OPENMP) && !defined(CODI_REVERSE_TYPE) && !defined(CODI_FORWARD_TYPE) #define HAVE_OMP #include @@ -151,15 +152,22 @@ void parallelSet(size_t size, T val, U* dst) for(size_t i=0; i -inline void safeAdd(T rhs, T& lhs) +/*! + * \brief Atomically update a (shared) lhs value with a (local) rhs value. + * \brief For types without atomic support (non-arithmetic) this is done via critical. + * \param[in] rhs - Local variable being added to the shared one. + * \param[in,out] lhs - Destination array. + */ +template::value,bool>::type = 0> +inline void atomicAdd(T rhs, T& lhs) { SU2_OMP_CRITICAL lhs += rhs; } - -template<> -inline void safeAdd(passivedouble rhs, passivedouble& lhs) +template::value,bool>::type = 0> +inline void atomicAdd(T rhs, T& lhs) { SU2_OMP_ATOMIC lhs += rhs; diff --git a/Common/include/toolboxes/graph_toolbox.hpp b/Common/include/toolboxes/graph_toolbox.hpp index a18848991716..ecdbacedfb5c 100644 --- a/Common/include/toolboxes/graph_toolbox.hpp +++ b/Common/include/toolboxes/graph_toolbox.hpp @@ -542,3 +542,53 @@ T createNaturalColoring(Index_t numInnerIndexes) return T(std::move(outerPtr), std::move(innerIdx)); } + + +/*! + * \brief A way to represent one grid color that allows range-for syntax. + */ +template +struct GridColor +{ + static_assert(std::is_integral::value,""); + + const T size; + const T* const indices; + + GridColor(const T* idx = nullptr, T sz = 0) : size(sz), indices(idx) { } + + inline const T* begin() const {return indices;} + inline const T* end() const {return indices+size;} +}; + + +/*! + * \brief A way to represent natural coloring {0,1,2,...,size-1} with zero + * overhead (behaves like looping with an integer index, after optimization...). + */ +template +struct DummyGridColor +{ + static_assert(std::is_integral::value,""); + + T size; + struct { + inline T operator[] (T i) const {return i;} + } + indices; + + DummyGridColor(T sz = 0) : size(sz) { } + + struct IteratorLikeInt { + T i; + inline IteratorLikeInt(T pos = 0) : i(pos) {} + inline IteratorLikeInt& operator++ () {++i; return *this;} + inline IteratorLikeInt operator++ (int) {auto j=i++; return IteratorLikeInt(j);} + inline T operator* () const {return i;} + inline T operator-> () const {return i;} + inline bool operator==(const IteratorLikeInt& other) const {return i==other.i;} + inline bool operator!=(const IteratorLikeInt& other) const {return i!=other.i;} + }; + inline IteratorLikeInt begin() const {return IteratorLikeInt(0);} + inline IteratorLikeInt end() const {return IteratorLikeInt(size);} +}; diff --git a/Common/src/linear_algebra/CSysVector.cpp b/Common/src/linear_algebra/CSysVector.cpp index 7461ddca3e0f..0a5fbedfc09a 100644 --- a/Common/src/linear_algebra/CSysVector.cpp +++ b/Common/src/linear_algebra/CSysVector.cpp @@ -221,7 +221,7 @@ ScalarType CSysVector::dot(const CSysVector & u) const { sum += vec_val[i]*u.vec_val[i]; /*--- Update shared variable with "our" partial sum. ---*/ - safeAdd(sum, dotRes); + atomicAdd(sum, dotRes); #ifdef HAVE_MPI /*--- Reduce across all mpi ranks, only master thread communicates. ---*/ diff --git a/SU2_CFD/include/solvers/CEulerSolver.hpp b/SU2_CFD/include/solvers/CEulerSolver.hpp index 4841b9bf78c7..d90129ef5f6d 100644 --- a/SU2_CFD/include/solvers/CEulerSolver.hpp +++ b/SU2_CFD/include/solvers/CEulerSolver.hpp @@ -262,12 +262,12 @@ class CEulerSolver : public CSolver { /*--- Shallow copy of grid coloring for OpenMP parallelization. ---*/ - struct EdgeColor { - unsigned long size; /*!< \brief Number of edges with a given color. */ - const unsigned long* indices; /*!< \brief Array of edge indices for a given color. */ - }; - vector EdgeColoring; /*!< \brief Edge colors. */ - unsigned long ColorGroupSize; /*!< \brief Group size used for coloring, chunk size in edge loops must be a multiple of this. */ +#ifdef HAVE_OMP + vector > EdgeColoring; /*!< \brief Edge colors. */ +#else + array,1> EdgeColoring; +#endif + unsigned long ColorGroupSize; /*!< \brief Group size used for coloring, chunk size in edge loops must be a multiple of this. */ /*--- Edge fluxes, for OpenMP parallelization on coarse grids. As it is difficult to * color them, we first store the fluxes and then compute the sum for each cell. diff --git a/SU2_CFD/include/solvers/CFEASolver.hpp b/SU2_CFD/include/solvers/CFEASolver.hpp index d004836fe0e4..6d1f1ebf5eca 100644 --- a/SU2_CFD/include/solvers/CFEASolver.hpp +++ b/SU2_CFD/include/solvers/CFEASolver.hpp @@ -28,6 +28,7 @@ #pragma once #include "CSolver.hpp" +#include "../../../Common/include/omp_structure.hpp" /*! * \class CFEASolver @@ -74,11 +75,11 @@ class CFEASolver : public CSolver { su2double RelaxCoeff; /*!< \brief Relaxation coefficient . */ su2double FSI_Residual; /*!< \brief FSI residual. */ - struct ElemColor { - unsigned long size; /*!< \brief Number of elements with a given color. */ - const unsigned long* indices; /*!< \brief Array of element indices for a given color. */ - }; - vector ElemColoring; /*!< \brief Element colors. */ +#ifdef HAVE_OMP + vector > ElemColoring; /*!< \brief Element colors. */ +#else + array,1> ElemColoring; +#endif unsigned long ColorGroupSize; /*!< \brief Group size used for coloring, chunk size must be a multiple of this. */ bool element_based; /*!< \brief Bool to determine if an element-based file is used. */ diff --git a/SU2_CFD/include/solvers/CTurbSolver.hpp b/SU2_CFD/include/solvers/CTurbSolver.hpp index fda4736d7286..b0284a378c54 100644 --- a/SU2_CFD/include/solvers/CTurbSolver.hpp +++ b/SU2_CFD/include/solvers/CTurbSolver.hpp @@ -29,6 +29,7 @@ #include "CSolver.hpp" #include "../variables/CTurbVariable.hpp" +#include "../../../Common/include/omp_structure.hpp" /*! * \class CTurbSolver @@ -61,12 +62,12 @@ class CTurbSolver : public CSolver { /*--- Shallow copy of grid coloring for OpenMP parallelization. ---*/ - struct EdgeColor { - unsigned long size; /*!< \brief Number of edges with a given color. */ - const unsigned long* indices; /*!< \brief Array of edge indices for a given color. */ - }; - vector EdgeColoring; /*!< \brief Edge colors. */ - unsigned long ColorGroupSize; /*!< \brief Group size used for coloring, chunk size in edge loops must be a multiple of this. */ +#ifdef HAVE_OMP + vector > EdgeColoring; /*!< \brief Edge colors. */ +#else + array,1> EdgeColoring; +#endif + unsigned long ColorGroupSize; /*!< \brief Group size used for coloring, chunk size in edge loops must be a multiple of this. */ /*! * \brief The highest level in the variable hierarchy this solver can safely use. diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index e0059907768a..20f06e0d686e 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -429,11 +429,10 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, if (!coloring.empty()) { auto nColor = coloring.getOuterSize(); - EdgeColoring.resize(nColor); + EdgeColoring.reserve(nColor); for(auto iColor = 0ul; iColor < nColor; ++iColor) { - EdgeColoring[iColor].size = coloring.getNumNonZeros(iColor); - EdgeColoring[iColor].indices = coloring.innerIdx(iColor); + EdgeColoring.emplace_back(coloring.innerIdx(iColor), coloring.getNumNonZeros(iColor)); } } ColorGroupSize = geometry->GetEdgeColorGroupSize(); @@ -443,6 +442,8 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, } omp_chunk_size = computeStaticChunkSize(nPoint, omp_get_max_threads(), OMP_MAX_SIZE); +#else + EdgeColoring[0] = DummyGridColor<>(geometry->GetnEdge()); #endif /*--- Check that the initial solution is physical, report any non-physical nodes ---*/ @@ -2912,22 +2913,15 @@ void CEulerSolver::Centered_Residual(CGeometry *geometry, CSolver **solver_conta /*--- Determine if using the reducer strategy is necessary, see CEulerSolver::SumEdgeFluxes(). ---*/ const bool reducer_strategy = (MGLevel != MESH_0) && (omp_get_num_threads() > 1); -#ifdef HAVE_OMP - /*--- Chunk size is at least OMP_MIN_SIZE and a multiple of the color group size. ---*/ - auto chunkSize = roundUpDiv(OMP_MIN_SIZE, ColorGroupSize)*ColorGroupSize; - /*--- Loop over edge colors. ---*/ for (auto color : EdgeColoring) { - SU2_OMP_FOR_DYN(chunkSize) + /*--- Chunk size is at least OMP_MIN_SIZE and a multiple of the color group size. ---*/ + SU2_OMP_FOR_DYN(roundUpDiv(OMP_MIN_SIZE, ColorGroupSize)*ColorGroupSize) for(auto k = 0ul; k < color.size; ++k) { auto iEdge = color.indices[k]; -#else - /*--- Natural coloring. ---*/ - { - for (auto iEdge = 0ul; iEdge < geometry->GetnEdge(); iEdge++) { -#endif + /*--- Points in edge, set normal vectors, and number of neighbors ---*/ auto iPoint = geometry->edge[iEdge]->GetNode(0); @@ -3029,24 +3023,15 @@ void CEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_contain /*--- Determine if using the reducer strategy is necessary, see CEulerSolver::SumEdgeFluxes(). ---*/ const bool reducer_strategy = (MGLevel != MESH_0) && (omp_get_num_threads() > 1); - /*--- Loop over all the edges ---*/ - -#ifdef HAVE_OMP - /*--- Chunk size is at least OMP_MIN_SIZE and a multiple of the color group size. ---*/ - auto chunkSize = roundUpDiv(OMP_MIN_SIZE, ColorGroupSize)*ColorGroupSize; - - /*--- Loop over edge colors. ---*/ + /*--- Loop over edge colors. ---*/ for (auto color : EdgeColoring) { - SU2_OMP_FOR_DYN(chunkSize) + /*--- Chunk size is at least OMP_MIN_SIZE and a multiple of the color group size. ---*/ + SU2_OMP_FOR_DYN(roundUpDiv(OMP_MIN_SIZE, ColorGroupSize)*ColorGroupSize) for(auto k = 0ul; k < color.size; ++k) { auto iEdge = color.indices[k]; -#else - /*--- Natural coloring. ---*/ - { - for (auto iEdge = 0ul; iEdge < geometry->GetnEdge(); iEdge++) { -#endif + unsigned short iDim, iVar; /*--- Points in edge and normal vectors ---*/ @@ -3651,24 +3636,15 @@ void CEulerSolver::SetUndivided_Laplacian(CGeometry *geometry, CConfig *config) nodes->SetUnd_LaplZero(); - /*--- Loop interior edges ---*/ - -#ifdef HAVE_OMP - /*--- Chunk size is at least OMP_MIN_SIZE and a multiple of the color group size. ---*/ - auto chunkSize = roundUpDiv(OMP_MIN_SIZE, ColorGroupSize)*ColorGroupSize; - /*--- Loop over edge colors. ---*/ for (auto color : EdgeColoring) { - SU2_OMP_FOR_STAT(chunkSize) + /*--- Chunk size is at least OMP_MIN_SIZE and a multiple of the color group size. ---*/ + SU2_OMP_FOR_DYN(roundUpDiv(OMP_MIN_SIZE, ColorGroupSize)*ColorGroupSize) for(auto k = 0ul; k < color.size; ++k) { auto iEdge = color.indices[k]; -#else - /*--- Natural coloring. ---*/ - { - for (auto iEdge = 0ul; iEdge < geometry->GetnEdge(); iEdge++) { -#endif + auto iPoint = geometry->edge[iEdge]->GetNode(0); auto jPoint = geometry->edge[iEdge]->GetNode(1); @@ -3734,22 +3710,15 @@ void CEulerSolver::SetCentered_Dissipation_Sensor(CGeometry *geometry, CConfig * jPoint_UndLapl[iPoint] = 0.0; } -#ifdef HAVE_OMP - /*--- Chunk size is at least OMP_MIN_SIZE and a multiple of the color group size. ---*/ - auto chunkSize = roundUpDiv(OMP_MIN_SIZE, ColorGroupSize)*ColorGroupSize; - /*--- Loop over edge colors. ---*/ for (auto color : EdgeColoring) { - SU2_OMP_FOR_STAT(chunkSize) + /*--- Chunk size is at least OMP_MIN_SIZE and a multiple of the color group size. ---*/ + SU2_OMP_FOR_DYN(roundUpDiv(OMP_MIN_SIZE, ColorGroupSize)*ColorGroupSize) for(auto k = 0ul; k < color.size; ++k) { auto iEdge = color.indices[k]; -#else - /*--- Natural coloring. ---*/ - { - for (auto iEdge = 0ul; iEdge < geometry->GetnEdge(); iEdge++) { -#endif + auto iPoint = geometry->edge[iEdge]->GetNode(0); auto jPoint = geometry->edge[iEdge]->GetNode(1); diff --git a/SU2_CFD/src/solvers/CFEASolver.cpp b/SU2_CFD/src/solvers/CFEASolver.cpp index 6d60f173a0c4..b4ac53dd387d 100644 --- a/SU2_CFD/src/solvers/CFEASolver.cpp +++ b/SU2_CFD/src/solvers/CFEASolver.cpp @@ -28,7 +28,6 @@ #include "../../include/solvers/CFEASolver.hpp" #include "../../include/variables/CFEABoundVariable.hpp" #include "../../../Common/include/toolboxes/printing_toolbox.hpp" -#include "../../../Common/include/omp_structure.hpp" #include /*! @@ -248,16 +247,17 @@ CFEASolver::CFEASolver(CGeometry *geometry, CConfig *config) : CSolver() { if (!coloring.empty()) { auto nColor = coloring.getOuterSize(); - ElemColoring.resize(nColor); + ElemColoring.reserve(nColor); for(auto iColor = 0ul; iColor < nColor; ++iColor) { - ElemColoring[iColor].size = coloring.getNumNonZeros(iColor); - ElemColoring[iColor].indices = coloring.innerIdx(iColor); + ElemColoring.emplace_back(coloring.innerIdx(iColor), coloring.getNumNonZeros(iColor)); } } ColorGroupSize = geometry->GetElementColorGroupSize(); omp_chunk_size = computeStaticChunkSize(nPointDomain, omp_get_max_threads(), OMP_MAX_SIZE); +#else + ElemColoring[0] = DummyGridColor<>(nElement); #endif iElem_iDe = nullptr; @@ -846,22 +846,14 @@ void CFEASolver::Compute_StiffMatrix(CGeometry *geometry, CNumerics **numerics, LinSysRes.SetValZero(); Jacobian.SetValZero(); -#ifdef HAVE_OMP - /*--- Chunk size is at least OMP_MIN_SIZE and a multiple of the color group size. ---*/ - auto chunkSize = roundUpDiv(OMP_MIN_SIZE, ColorGroupSize)*ColorGroupSize; + for(auto color : ElemColoring) { - /*--- Loop over element colors. ---*/ - for (auto color : ElemColoring) - { - SU2_OMP_FOR_DYN(chunkSize) + /*--- Chunk size is at least OMP_MIN_SIZE and a multiple of the color group size. ---*/ + SU2_OMP_FOR_DYN(roundUpDiv(OMP_MIN_SIZE, ColorGroupSize)*ColorGroupSize) for(auto k = 0ul; k < color.size; ++k) { auto iElem = color.indices[k]; -#else - /*--- Natural coloring. ---*/ - { - for (auto iElem = 0ul; iElem < nElement; iElem++) { -#endif + unsigned short iNode, jNode, iDim, iVar; int thread = omp_get_thread_num(); @@ -942,22 +934,14 @@ void CFEASolver::Compute_StiffMatrix_NodalStressRes(CGeometry *geometry, CNumeri LinSysRes.SetValZero(); Jacobian.SetValZero(); -#ifdef HAVE_OMP - /*--- Chunk size is at least OMP_MIN_SIZE and a multiple of the color group size. ---*/ - auto chunkSize = roundUpDiv(OMP_MIN_SIZE, ColorGroupSize)*ColorGroupSize; + for(auto color : ElemColoring) { - /*--- Loop over element colors. ---*/ - for (auto color : ElemColoring) - { - SU2_OMP_FOR_DYN(chunkSize) + /*--- Chunk size is at least OMP_MIN_SIZE and a multiple of the color group size. ---*/ + SU2_OMP_FOR_DYN(roundUpDiv(OMP_MIN_SIZE, ColorGroupSize)*ColorGroupSize) for(auto k = 0ul; k < color.size; ++k) { auto iElem = color.indices[k]; -#else - /*--- Natural coloring. ---*/ - { - for (auto iElem = 0ul; iElem < nElement; iElem++) { -#endif + unsigned short iNode, jNode, iDim, iVar; int thread = omp_get_thread_num(); @@ -1081,22 +1065,14 @@ void CFEASolver::Compute_MassMatrix(CGeometry *geometry, CNumerics **numerics, C /*--- Clear matrix before calculation. ---*/ MassMatrix.SetValZero(); -#ifdef HAVE_OMP - /*--- Chunk size is at least OMP_MIN_SIZE and a multiple of the color group size. ---*/ - auto chunkSize = roundUpDiv(OMP_MIN_SIZE, ColorGroupSize)*ColorGroupSize; + for(auto color : ElemColoring) { - /*--- Loop over element colors. ---*/ - for (auto color : ElemColoring) - { - SU2_OMP_FOR_DYN(chunkSize) + /*--- Chunk size is at least OMP_MIN_SIZE and a multiple of the color group size. ---*/ + SU2_OMP_FOR_DYN(roundUpDiv(OMP_MIN_SIZE, ColorGroupSize)*ColorGroupSize) for(auto k = 0ul; k < color.size; ++k) { auto iElem = color.indices[k]; -#else - /*--- Natural coloring. ---*/ - { - for (auto iElem = 0ul; iElem < nElement; iElem++) { -#endif + unsigned short iNode, jNode, iDim, iVar; int thread = omp_get_thread_num(); @@ -1166,22 +1142,14 @@ void CFEASolver::Compute_MassRes(CGeometry *geometry, CNumerics **numerics, CCon TimeRes.SetValZero(); SU2_OMP_BARRIER -#ifdef HAVE_OMP - /*--- Chunk size is at least OMP_MIN_SIZE and a multiple of the color group size. ---*/ - auto chunkSize = roundUpDiv(OMP_MIN_SIZE, ColorGroupSize)*ColorGroupSize; + for(auto color : ElemColoring) { - /*--- Loop over element colors. ---*/ - for (auto color : ElemColoring) - { - SU2_OMP_FOR_DYN(chunkSize) + /*--- Chunk size is at least OMP_MIN_SIZE and a multiple of the color group size. ---*/ + SU2_OMP_FOR_DYN(roundUpDiv(OMP_MIN_SIZE, ColorGroupSize)*ColorGroupSize) for(auto k = 0ul; k < color.size; ++k) { auto iElem = color.indices[k]; -#else - /*--- Natural coloring. ---*/ - { - for (auto iElem = 0ul; iElem < nElement; iElem++) { -#endif + unsigned short iNode, jNode, iDim, iVar; int thread = omp_get_thread_num(); @@ -1254,22 +1222,14 @@ void CFEASolver::Compute_NodalStressRes(CGeometry *geometry, CNumerics **numeric LinSysRes.SetValZero(); SU2_OMP_BARRIER -#ifdef HAVE_OMP - /*--- Chunk size is at least OMP_MIN_SIZE and a multiple of the color group size. ---*/ - auto chunkSize = roundUpDiv(OMP_MIN_SIZE, ColorGroupSize)*ColorGroupSize; + for(auto color : ElemColoring) { - /*--- Loop over element colors. ---*/ - for (auto color : ElemColoring) - { - SU2_OMP_FOR_DYN(chunkSize) + /*--- Chunk size is at least OMP_MIN_SIZE and a multiple of the color group size. ---*/ + SU2_OMP_FOR_DYN(roundUpDiv(OMP_MIN_SIZE, ColorGroupSize)*ColorGroupSize) for(auto k = 0ul; k < color.size; ++k) { auto iElem = color.indices[k]; -#else - /*--- Natural coloring. ---*/ - { - for (auto iElem = 0ul; iElem < nElement; iElem++) { -#endif + unsigned short iNode, iDim, iVar; int thread = omp_get_thread_num(); @@ -1359,22 +1319,14 @@ void CFEASolver::Compute_NodalStress(CGeometry *geometry, CNumerics **numerics, } } -#ifdef HAVE_OMP - /*--- Chunk size is at least OMP_MIN_SIZE and a multiple of the color group size. ---*/ - auto chunkSize = roundUpDiv(OMP_MIN_SIZE, ColorGroupSize)*ColorGroupSize; + for(auto color : ElemColoring) { - /*--- Loop over element colors. ---*/ - for (auto color : ElemColoring) - { - SU2_OMP_FOR_DYN(chunkSize) + /*--- Chunk size is at least OMP_MIN_SIZE and a multiple of the color group size. ---*/ + SU2_OMP_FOR_DYN(roundUpDiv(OMP_MIN_SIZE, ColorGroupSize)*ColorGroupSize) for(auto k = 0ul; k < color.size; ++k) { auto iElem = color.indices[k]; -#else - /*--- Natural coloring. ---*/ - { - for (auto iElem = 0ul; iElem < nElement; iElem++) { -#endif + unsigned short iNode, iDim, iVar, iStress; int thread = omp_get_thread_num(); @@ -1629,22 +1581,14 @@ void CFEASolver::Compute_DeadLoad(CGeometry *geometry, CNumerics **numerics, CCo for (unsigned long iPoint = 0; iPoint < nPoint; iPoint++) nodes->Clear_BodyForces_Res(iPoint); -#ifdef HAVE_OMP - /*--- Chunk size is at least OMP_MIN_SIZE and a multiple of the color group size. ---*/ - auto chunkSize = roundUpDiv(OMP_MIN_SIZE, ColorGroupSize)*ColorGroupSize; + for(auto color : ElemColoring) { - /*--- Loop over element colors. ---*/ - for (auto color : ElemColoring) - { - SU2_OMP_FOR_DYN(chunkSize) + /*--- Chunk size is at least OMP_MIN_SIZE and a multiple of the color group size. ---*/ + SU2_OMP_FOR_DYN(roundUpDiv(OMP_MIN_SIZE, ColorGroupSize)*ColorGroupSize) for(auto k = 0ul; k < color.size; ++k) { auto iElem = color.indices[k]; -#else - /*--- Natural coloring. ---*/ - { - for (auto iElem = 0ul; iElem < nElement; iElem++) { -#endif + unsigned short iNode, iDim, iVar; int thread = omp_get_thread_num(); @@ -3077,7 +3021,7 @@ void CFEASolver::Compute_OFRefGeom(CGeometry *geometry, CSolver **solver_contain obj_fun_local += pow(current_solution - reference_geometry, 2); } } - safeAdd(obj_fun_local, objective_function); + atomicAdd(obj_fun_local, objective_function); } SU2_MPI::Allreduce(&objective_function, &Total_OFRefGeom, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); @@ -3215,9 +3159,9 @@ void CFEASolver::Compute_OFVolFrac(CGeometry *geometry, CSolver **solver_contain discrete_loc += volume*4.0*rho*(1.0-rho); } } - safeAdd(tot_vol_loc, total_volume); - safeAdd(integral_loc, integral); - safeAdd(discrete_loc, discreteness); + atomicAdd(tot_vol_loc, total_volume); + atomicAdd(integral_loc, integral); + atomicAdd(discrete_loc, discreteness); } su2double tmp; @@ -3295,7 +3239,7 @@ void CFEASolver::Compute_OFCompliance(CGeometry *geometry, CSolver **solver_cont for (iVar = 0; iVar < nVar; iVar++) comp_local += nodalForce[iVar]*nodes->GetSolution(iPoint,iVar); } - safeAdd(comp_local, compliance); + atomicAdd(comp_local, compliance); } SU2_MPI::Allreduce(&compliance, &Total_OFCompliance, 1,MPI_DOUBLE,MPI_SUM,MPI_COMM_WORLD); @@ -3370,8 +3314,8 @@ void CFEASolver::Stiffness_Penalty(CGeometry *geometry, CSolver **solver, CNumer } } - safeAdd(totalVol_loc, totalVolume); - safeAdd(weighted_loc, weightedValue); + atomicAdd(totalVol_loc, totalVolume); + atomicAdd(weighted_loc, weightedValue); } // Reduce value across processors for parallelization diff --git a/SU2_CFD/src/solvers/CMeshSolver.cpp b/SU2_CFD/src/solvers/CMeshSolver.cpp index 7cde555d4ac7..0d4e959a1ac6 100644 --- a/SU2_CFD/src/solvers/CMeshSolver.cpp +++ b/SU2_CFD/src/solvers/CMeshSolver.cpp @@ -107,16 +107,17 @@ CMeshSolver::CMeshSolver(CGeometry *geometry, CConfig *config) : CFEASolver(true if (!coloring.empty()) { auto nColor = coloring.getOuterSize(); - ElemColoring.resize(nColor); + ElemColoring.reserve(nColor); for(auto iColor = 0ul; iColor < nColor; ++iColor) { - ElemColoring[iColor].size = coloring.getNumNonZeros(iColor); - ElemColoring[iColor].indices = coloring.innerIdx(iColor); + ElemColoring.emplace_back(coloring.innerIdx(iColor), coloring.getNumNonZeros(iColor)); } } ColorGroupSize = geometry->GetElementColorGroupSize(); omp_chunk_size = computeStaticChunkSize(nPointDomain, omp_get_max_threads(), OMP_MAX_SIZE); +#else + ElemColoring[0] = DummyGridColor<>(nElement); #endif /*--- Structural parameters ---*/ diff --git a/SU2_CFD/src/solvers/CTurbSolver.cpp b/SU2_CFD/src/solvers/CTurbSolver.cpp index b2c13b08571b..82f27c6de917 100644 --- a/SU2_CFD/src/solvers/CTurbSolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSolver.cpp @@ -57,14 +57,15 @@ CTurbSolver::CTurbSolver(CGeometry* geometry, CConfig *config) : CSolver() { EdgeColoring.resize(nColor); for(auto iColor = 0ul; iColor < nColor; ++iColor) { - EdgeColoring[iColor].size = coloring.getNumNonZeros(iColor); - EdgeColoring[iColor].indices = coloring.innerIdx(iColor); + EdgeColoring.emplace_back(coloring.innerIdx(iColor), coloring.getNumNonZeros(iColor)); } } ColorGroupSize = geometry->GetEdgeColorGroupSize(); nPoint = geometry->GetnPoint(); omp_chunk_size = computeStaticChunkSize(nPoint, omp_get_max_threads(), OMP_MAX_SIZE); +#else + EdgeColoring[0] = DummyGridColor<>(geometry->GetnEdge()); #endif } @@ -100,24 +101,15 @@ void CTurbSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_containe su2double solution_i[MAXNVAR] = {0.0}, flowPrimVar_i[MAXNVARFLOW] = {0.0}; su2double solution_j[MAXNVAR] = {0.0}, flowPrimVar_j[MAXNVARFLOW] = {0.0}; - /*--- Loop over all the edges ---*/ - -#ifdef HAVE_OMP - /*--- Chunk size is at least OMP_MIN_SIZE and a multiple of the color group size. ---*/ - auto chunkSize = roundUpDiv(OMP_MIN_SIZE, ColorGroupSize)*ColorGroupSize; - /*--- Loop over edge colors. ---*/ for (auto color : EdgeColoring) { - SU2_OMP_FOR_DYN(chunkSize) + /*--- Chunk size is at least OMP_MIN_SIZE and a multiple of the color group size. ---*/ + SU2_OMP_FOR_DYN(roundUpDiv(OMP_MIN_SIZE, ColorGroupSize)*ColorGroupSize) for(auto k = 0ul; k < color.size; ++k) { auto iEdge = color.indices[k]; -#else - /*--- Natural coloring. ---*/ - { - for (auto iEdge = 0ul; iEdge < geometry->GetnEdge(); iEdge++) { -#endif + unsigned short iDim, iVar; /*--- Points in edge and normal vectors ---*/ @@ -240,24 +232,15 @@ void CTurbSolver::Viscous_Residual(CGeometry *geometry, CSolver **solver_contain /*--- Pick one numerics object per thread. ---*/ CNumerics* numerics = numerics_container[VISC_TERM + omp_get_thread_num()*MAX_TERMS]; - /*--- Loop over all the edges ---*/ - -#ifdef HAVE_OMP - /*--- Chunk size is at least OMP_MIN_SIZE and a multiple of the color group size. ---*/ - auto chunkSize = roundUpDiv(OMP_MIN_SIZE, ColorGroupSize)*ColorGroupSize; - /*--- Loop over edge colors. ---*/ for (auto color : EdgeColoring) { - SU2_OMP_FOR_DYN(chunkSize) + /*--- Chunk size is at least OMP_MIN_SIZE and a multiple of the color group size. ---*/ + SU2_OMP_FOR_DYN(roundUpDiv(OMP_MIN_SIZE, ColorGroupSize)*ColorGroupSize) for(auto k = 0ul; k < color.size; ++k) { auto iEdge = color.indices[k]; -#else - /*--- Natural coloring. ---*/ - { - for (auto iEdge = 0ul; iEdge < geometry->GetnEdge(); iEdge++) { -#endif + /*--- Points in edge ---*/ auto iPoint = geometry->edge[iEdge]->GetNode(0); @@ -609,7 +592,7 @@ void CTurbSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_con /*--- Local variables ---*/ unsigned short iVar, iMarker, iDim; - unsigned long iPoint, jPoint, iEdge, iVertex; + unsigned long iPoint, jPoint, iVertex; const su2double *U_time_nM1 = nullptr, *U_time_n = nullptr, *U_time_nP1 = nullptr; su2double Volume_nM1, Volume_nP1; @@ -698,22 +681,15 @@ void CTurbSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_con we will loop over the edges and boundaries to compute the GCL component of the dual time source term that depends on grid velocities. ---*/ -#ifdef HAVE_OMP - /*--- Chunk size is at least OMP_MIN_SIZE and a multiple of the color group size. ---*/ - auto chunkSize = roundUpDiv(OMP_MIN_SIZE, ColorGroupSize)*ColorGroupSize; - /*--- Loop over edge colors. ---*/ for (auto color : EdgeColoring) { - SU2_OMP_FOR_DYN(chunkSize) + /*--- Chunk size is at least OMP_MIN_SIZE and a multiple of the color group size. ---*/ + SU2_OMP_FOR_DYN(roundUpDiv(OMP_MIN_SIZE, ColorGroupSize)*ColorGroupSize) for(auto k = 0ul; k < color.size; ++k) { - iEdge = color.indices[k]; -#else - /*--- Natural coloring. ---*/ - { - for (iEdge = 0ul; iEdge < geometry->GetnEdge(); iEdge++) { -#endif + auto iEdge = color.indices[k]; + /*--- Get indices for nodes i & j plus the face normal ---*/ iPoint = geometry->edge[iEdge]->GetNode(0); From f48e3e4423a8ccc94278db992fbb618e1e63bcb8 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Sun, 16 Feb 2020 11:01:05 +0000 Subject: [PATCH 117/118] fix some typos --- Common/include/omp_structure.hpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Common/include/omp_structure.hpp b/Common/include/omp_structure.hpp index 60efbe837867..a6176e1710c9 100644 --- a/Common/include/omp_structure.hpp +++ b/Common/include/omp_structure.hpp @@ -48,7 +48,8 @@ /*--- Detect compilation with OpenMP support, protect agaisnt * using OpenMP with AD (not supported yet). ---*/ -#if defined(_OPENMP) && !defined(CODI_REVERSE_TYPE) && !defined(CODI_FORWARD_TYPE) +//#if defined(_OPENMP) && !defined(CODI_REVERSE_TYPE) && !defined(CODI_FORWARD_TYPE) +#if defined(_OPENMP) #define HAVE_OMP #include @@ -154,9 +155,9 @@ void parallelSet(size_t size, T val, U* dst) /*! * \brief Atomically update a (shared) lhs value with a (local) rhs value. - * \brief For types without atomic support (non-arithmetic) this is done via critical. + * \note For types without atomic support (non-arithmetic) this is done via critical. * \param[in] rhs - Local variable being added to the shared one. - * \param[in,out] lhs - Destination array. + * \param[in,out] lhs - Shared variable being updated. */ template::value,bool>::type = 0> From 3fdfd0c3ee855f42caa1128ec97891354f457945 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Sun, 16 Feb 2020 11:09:25 +0000 Subject: [PATCH 118/118] fix #846 --- Common/src/CConfig.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index d43f29d9c3d6..2f2ae70f6071 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -5543,15 +5543,21 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { cout <<"based on the physical case: "; } switch (Kind_Solver) { - case EULER: case DISC_ADJ_EULER: case FEM_EULER: case DISC_ADJ_FEM_EULER: + case EULER: case DISC_ADJ_EULER: + case INC_EULER: case DISC_ADJ_INC_EULER: + case FEM_EULER: case DISC_ADJ_FEM_EULER: if (Kind_Regime == COMPRESSIBLE) cout << "Compressible Euler equations." << endl; if (Kind_Regime == INCOMPRESSIBLE) cout << "Incompressible Euler equations." << endl; break; - case NAVIER_STOKES: case DISC_ADJ_NAVIER_STOKES: case FEM_NAVIER_STOKES: case DISC_ADJ_FEM_NS: + case NAVIER_STOKES: case DISC_ADJ_NAVIER_STOKES: + case INC_NAVIER_STOKES: case DISC_ADJ_INC_NAVIER_STOKES: + case FEM_NAVIER_STOKES: case DISC_ADJ_FEM_NS: if (Kind_Regime == COMPRESSIBLE) cout << "Compressible Laminar Navier-Stokes' equations." << endl; if (Kind_Regime == INCOMPRESSIBLE) cout << "Incompressible Laminar Navier-Stokes' equations." << endl; break; - case RANS: case DISC_ADJ_RANS: case FEM_RANS: case DISC_ADJ_FEM_RANS: + case RANS: case DISC_ADJ_RANS: + case INC_RANS: case DISC_ADJ_INC_RANS: + case FEM_RANS: case DISC_ADJ_FEM_RANS: if (Kind_Regime == COMPRESSIBLE) cout << "Compressible RANS equations." << endl; if (Kind_Regime == INCOMPRESSIBLE) cout << "Incompressible RANS equations." << endl; cout << "Turbulence model: ";